From 0001803f0b9523c94fa2ede48eaecb047fef4524 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Mon, 21 Nov 2011 20:51:19 -0500 Subject: Bash-4.1 distribution source --- test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'test.c') diff --git a/test.c b/test.c index ad634f9..180940c 100644 --- a/test.c +++ b/test.c @@ -65,8 +65,9 @@ extern int errno; #endif #if !defined (STREQ) -# define STREQ(a, b) ((a)[0] == (b)[0] && strcmp (a, b) == 0) +# define STREQ(a, b) ((a)[0] == (b)[0] && strcmp ((a), (b)) == 0) #endif /* !STREQ */ +#define STRCOLLEQ(a, b) ((a)[0] == (b)[0] && strcoll ((a), (b)) == 0) #if !defined (R_OK) #define R_OK 4 @@ -375,12 +376,16 @@ binary_test (op, arg1, arg2, flags) if (op[0] == '=' && (op[1] == '\0' || (op[1] == '=' && op[2] == '\0'))) return (patmatch ? patcomp (arg1, arg2, EQ) : STREQ (arg1, arg2)); - else if ((op[0] == '>' || op[0] == '<') && op[1] == '\0') - return ((op[0] == '>') ? (strcmp (arg1, arg2) > 0) : (strcmp (arg1, arg2) < 0)); - + { + if (shell_compatibility_level > 40 && flags & TEST_LOCALE) + return ((op[0] == '>') ? (strcoll (arg1, arg2) > 0) : (strcoll (arg1, arg2) < 0)); + else + return ((op[0] == '>') ? (strcmp (arg1, arg2) > 0) : (strcmp (arg1, arg2) < 0)); + } else if (op[0] == '!' && op[1] == '=' && op[2] == '\0') return (patmatch ? patcomp (arg1, arg2, NE) : (STREQ (arg1, arg2) == 0)); + else if (op[2] == 't') { -- cgit v1.2.3