Mailinglist Archive: opensuse-bugs (9719 mails)

< Previous Next >
[Bug 329992] Invalid behavior of grep with regexp ^[A-Z]
  • From: bugzilla_noreply@xxxxxxxxxx
  • Date: Tue, 27 Nov 2007 13:39:32 -0700 (MST)
  • Message-id: <20071127203932.157B3CC6B5@xxxxxxxxxxxxxxxxxxxxxx>
https://bugzilla.novell.com/show_bug.cgi?id=329992#c24





--- Comment #24 from Michael Matz <matz@xxxxxxxxxx> 2007-11-27 13:39:31 MST ---
Can be checked with this standalone program:

% cat regex-test.c
#include <sys/types.h>
#include <wchar.h>
#include <stdio.h>
#include <regex.h>
#include <locale.h>

int main()
{
regex_t reg;
int err;
int do_match;
wchar_t bla[6];
setlocale (LC_ALL, "");
if ((err = regcomp (&reg, "^[A-Z]", REG_NOSUB)))
{
char buf[1024];
regerror (err, &reg, buf, 1024);
buf[1023] = 0;
printf ("error: %s\n", buf);
return 1;
}
bla[1] = bla[3] = bla[5] = 0;
bla[0] = 'p';
bla[2] = 'A';
bla[4] = 'Z';
printf ("p <=> A: %d\n", wcscoll (bla + 0, bla + 2));
printf ("p <=> Z: %d\n", wcscoll (bla + 0, bla + 4));
if (wcscoll (bla + 0, bla + 2) >= 0
&& wcscoll (bla + 0, bla + 4) <= 0)
do_match = 1;
else
do_match = 0;
if (do_match == (!regexec (&reg, "p", 0, 0, 0) ? 1 : 0))
printf ("Okay\n");
else
{
printf ("Bad\n");
return 2;
}
regfree (&reg);
return 0;
}

If it prints 'Bad' then wcscoll() and regexp ranges don't agree, which is
a bug IMHO. For 10.3 and LANG=de_DE.UTF-8 (or en_US.UTF-8) this occurs.
Interestingly the bug does not occur in cs_CZ (UTF-8 or not). There 'p' is
_not_ sorted between 'A' and 'Z', so presumably the bug isn't triggered.
That might be the reason you don't see it.


--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

< Previous Next >