summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-08-12 02:08:43 +0000
committerache <ache@FreeBSD.org>1996-08-12 02:08:43 +0000
commit77e622e5f25c08e0ab4d9d25fc42753bec118696 (patch)
treea3be606c999c0bb6ff2a365fc8c4a2801466ac1a /bin
parent95acc9d04c0ee3aaafedd42cab40628423f9fccc (diff)
downloadFreeBSD-src-77e622e5f25c08e0ab4d9d25fc42753bec118696.zip
FreeBSD-src-77e622e5f25c08e0ab4d9d25fc42753bec118696.tar.gz
Use collate for alpha character ranges
Diffstat (limited to 'bin')
-rw-r--r--bin/csh/glob.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/bin/csh/glob.c b/bin/csh/glob.c
index 2dd0895..e429ff6 100644
--- a/bin/csh/glob.c
+++ b/bin/csh/glob.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: glob.c,v 1.2 1994/09/24 02:54:05 davidg Exp $
+ * $Id: glob.c,v 1.3 1995/05/30 00:06:35 rgrimes Exp $
*/
#ifndef lint
@@ -93,6 +93,7 @@ static int pmatch __P((Char *, Char *));
static void pword __P((void));
static void psave __P((int));
static void backeval __P((Char *, bool));
+static int collcmp __P((int, int));
static Char *
@@ -832,6 +833,38 @@ Gmatch(string, pattern)
}
static int
+collcmp (c1, c2)
+int c1, c2;
+{
+ static char s1[2], s2[2];
+
+ if (c1 == c2)
+ return (0);
+ if ( (isascii(c1) && isascii(c2))
+ || (!isalpha(c1) && !isalpha(c2))
+ )
+ return (c1 - c2);
+ if (isalpha(c1) && !isalpha(c2)) {
+ if (isupper(c1))
+ return ('A' - c2);
+ else
+ return ('a' - c2);
+ } else if (isalpha(c2) && !isalpha(c1)) {
+ if (isupper(c2))
+ return (c1 - 'A');
+ else
+ return (c1 - 'a');
+ }
+ if (isupper(c1) && islower(c2))
+ return (-1);
+ else if (islower(c1) && isupper(c2))
+ return (1);
+ s1[0] = c1;
+ s2[0] = c2;
+ return strcoll(s1, s2);
+}
+
+static int
pmatch(string, pattern)
register Char *string, *pattern;
{
@@ -866,8 +899,9 @@ pmatch(string, pattern)
if (match)
continue;
if (rangec == '-' && *(pattern-2) != '[' && *pattern != ']') {
- match = (stringc <= (*pattern & TRIM) &&
- (*(pattern-2) & TRIM) <= stringc);
+ match = ( collcmp(stringc, *pattern & TRIM) <= 0
+ && collcmp(*(pattern-2) & TRIM, stringc) <= 0
+ );
pattern++;
}
else
OpenPOWER on IntegriCloud