[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#362514: locales: et_EE causes "sed -e expression #1 char 19: Invalid range end"



On Fri, Apr 14, 2006 at 12:31:53AM +0300, Juhan Ernits wrote:
[...]
> I could _not_ reproduce the bug with the following program:
> 
>  
> #include <locale.h>
> #include <stdio.h>
> #include <string.h>
> #include <regex.h>
> #include <stdlib.h>
> 
> int
> main (void)
> {
>   struct re_pattern_buffer regex;
>   const char *s;
>   int match;
>   int result = 0;
>   int syntax = 17105606;
>   
> 
>   memset (&regex, '\0', sizeof (regex));
>   re_set_syntax (syntax);
[...]

You forgot to call setlocale(); with this call, this bug can be
reproduced.  Here is a simpler test case.
Thanks.

Denis
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <stdlib.h>

int
main (void)
{
  struct re_pattern_buffer regex;
  const char * r = "[A-Z]";

  setlocale(LC_COLLATE, "");
  memset (&regex, '\0', sizeof (regex));
  re_set_syntax (17105606);
  regex.fastmap = malloc(1 << (sizeof (char) * 8));
  if (re_compile_pattern (r, strlen(r), &regex) != NULL)
    puts (" -> BAD");
  else
    puts (" -> OK");

  return 0;
}

Reply to: