From 672fd41bbcc594603afb7ce444ae2ffd23dc0bdc Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 7 Feb 2001 01:28:35 +0000 Subject: Update. 2001-02-06 Ulrich Drepper * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: First attempt to fix the broken code. Patch by Jes Sorensen. --- linuxthreads/ChangeLog | 5 ++ .../sysdeps/unix/sysv/linux/ia64/pt-initfini.c | 6 +- posix/bug-regex1.c | 64 +++++++++++++++++ posix/regex.c | 80 ++++++++++++++-------- 4 files changed, 122 insertions(+), 33 deletions(-) create mode 100644 posix/bug-regex1.c diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index b47d6488d3..ae5f86622c 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,8 @@ +2001-02-06 Ulrich Drepper + + * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: First attempt to fix the + broken code. Patch by Jes Sorensen. + 2001-02-06 Andreas Jaeger * sysdeps/pthread/pthread.h: Move __pthread_initialize from here diff --git a/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c b/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c index 766d4815fc..5ea75d6aed 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c +++ b/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c @@ -60,13 +60,11 @@ _init: st8 [r12] = gp, -16 br.call.sptk.many b0 = __pthread_initialize_minimal# ;; ;; - cmp.eq p6, p7 = 0, r15 - (p6) br.cond.dptk .L5 + cmp.ne p6, p0 = 0, r15 - br.call.sptk.many b0 = __gmon_start__# ;; +(p6) br.call.sptk.many b0 = __gmon_start__# ;; adds r12 = 16, r12 ;; -.L5: ld8 gp = [r12] ;; .align 16 diff --git a/posix/bug-regex1.c b/posix/bug-regex1.c new file mode 100644 index 0000000000..262a22e971 --- /dev/null +++ b/posix/bug-regex1.c @@ -0,0 +1,64 @@ +/* Test case by Jim Meyering . */ +#include +#include +#include +#include + +int +main (void) +{ + struct re_pattern_buffer regex; + struct re_registers regs; + const char *s; + int match; + int result = 0; + + memset (®ex, '\0', sizeof (regex)); + + setlocale (LC_ALL, "de_DE.ISO-8859-1"); + fwide (stdout, -1); + + re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_DEBUG); + + puts ("in C locale"); + setlocale (LC_ALL, "C"); + s = re_compile_pattern ("[anù]*n", 7, ®ex); + if (s != NULL) + { + puts ("re_compile_pattern return non-NULL value"); + result = 1; + } + else + { + match = re_match (®ex, "an", 2, 0, ®s); + if (match != 2) + { + printf ("re_match returned %d, expected 2\n", match); + result = 1; + } + else + puts (" -> OK"); + } + + puts ("in de_DE.ISO-8859-1 locale"); + setlocale (LC_ALL, "de_DE.ISO-8859-1"); + s = re_compile_pattern ("[anù]*n", 7, ®ex); + if (s != NULL) + { + puts ("re_compile_pattern return non-NULL value"); + result = 1; + } + else + { + match = re_match (®ex, "an", 2, 0, ®s); + if (match != 2) + { + printf ("re_match returned %d, expected 2\n", match); + result = 1; + } + else + puts (" -> OK"); + } + + return result; +} diff --git a/posix/regex.c b/posix/regex.c index b4979d0bc1..a6e6507542 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -62,7 +62,13 @@ # define US_CHAR_TYPE wchar_t/* unsigned character type */ # define COMPILED_BUFFER_VAR wc_buffer # define OFFSET_ADDRESS_SIZE 1 /* the size which STORE_NUMBER macro use */ -# define PUT_CHAR(c) printf ("%C", c) /* Should we use wide stream?? */ +# define PUT_CHAR(c) \ + do { \ + if (MC_CUR_MAX == 1) \ + putchar (c); \ + else \ + printf ("%C", (wint_t) c); /* Should we use wide stream?? */ \ + } while (0) # define TRUE 1 # define FALSE 0 #else @@ -754,7 +760,7 @@ print_partial_compiled_pattern (start, end) while (p < pend) { #ifdef _LIBC - printf ("%t:\t", p - start); + printf ("%td:\t", p - start); #else printf ("%ld:\t", (long int) (p - start)); #endif @@ -782,7 +788,7 @@ print_partial_compiled_pattern (start, end) printf ("/exactn_bin/%d", mcnt); do { - printf("/%x", *p++); + printf("/%lx", (long int) *p++); } while (--mcnt); break; @@ -790,16 +796,16 @@ print_partial_compiled_pattern (start, end) case start_memory: mcnt = *p++; - printf ("/start_memory/%d/%d", mcnt, *p++); + printf ("/start_memory/%d/%ld", mcnt, (long int) *p++); break; case stop_memory: mcnt = *p++; - printf ("/stop_memory/%d/%d", mcnt, *p++); + printf ("/stop_memory/%d/%ld", mcnt, (long int) *p++); break; case duplicate: - printf ("/duplicate/%d", *p++); + printf ("/duplicate/%ld", (long int) *p++); break; case anychar: @@ -817,7 +823,7 @@ print_partial_compiled_pattern (start, end) p += 5; length = *workp++; /* the length of char_classes */ for (i=0 ; i bufp->allocated) \ EXTEND_BUFFER () #else @@ -1922,7 +1934,7 @@ static reg_errcode_t compile_range _RE_ARGS ((unsigned int range_start, #define BUF_PUSH(c) \ do { \ GET_BUFFER_SPACE (1); \ - *b++ = (US_CHAR_TYPE) (c); \ + *b++ = (US_CHAR_TYPE) (c); \ } while (0) @@ -4153,7 +4165,7 @@ regex_compile (pattern, size, syntax, bufp) /* We have succeeded; set the length of the buffer. */ #ifdef MBS_SUPPORT - bufp->used = (int) b - (int) COMPILED_BUFFER_VAR; + bufp->used = (uintptr_t) b - (uintptr_t) COMPILED_BUFFER_VAR; #else bufp->used = b - bufp->buffer; #endif @@ -5936,7 +5948,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) goto fail; SET_REGS_MATCHED (); - DEBUG_PRINT2 (" Matched `%d'.\n", *d); + DEBUG_PRINT2 (" Matched `%ld'.\n", (long int) *d); d++; break; @@ -6308,7 +6320,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) matched within the group is recorded (in the internal registers data structure) under the register number. */ case start_memory: - DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); + DEBUG_PRINT3 ("EXECUTING start_memory %ld (%ld):\n", + (long int) *p, (long int) p[1]); /* Find out if this group can match the empty string. */ p1 = p; /* To send to group_match_null_string_p. */ @@ -6356,7 +6369,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) arguments are the same as start_memory's: the register number, and the number of inner groups. */ case stop_memory: - DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); + DEBUG_PRINT3 ("EXECUTING stop_memory %ld (%ld):\n", + (long int) *p, (long int) p[1]); /* We need to save the string position the last time we were at this close-group operator in case the group is operated @@ -6766,8 +6780,16 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) { p[-(1+OFFSET_ADDRESS_SIZE)] = (US_CHAR_TYPE) pop_failure_jump; - DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", - c, p1[3+OFFSET_ADDRESS_SIZE]); +#ifdef MBS_SUPPORT + if (MB_CUR_MAX != 1) + DEBUG_PRINT3 (" %C != %C => pop_failure_jump.\n", + (wint_t) c, + (wint_t) p1[3+OFFSET_ADDRESS_SIZE]); + else +#endif + DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", + (char) c, + (char) p1[3+OFFSET_ADDRESS_SIZE]); } #ifndef MBS_SUPPORT @@ -6776,7 +6798,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) { int not = (re_opcode_t) p1[3] == charset_not; - if (c < (unsigned char) (p1[4] * BYTEWIDTH) + if (c < (unsigned) (p1[4] * BYTEWIDTH) && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; -- cgit 1.4.1