]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(init_syntax_once): move below definition of
authorUlrich Drepper <drepper@redhat.com>
Wed, 10 Nov 1999 03:29:43 +0000 (03:29 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 10 Nov 1999 03:29:43 +0000 (03:29 +0000)
ISALNUM etc., then use ISALNUM to init the table, so that
the word ops will work if i18n'ed.
(SYNTAX): And subscript with 0xFF for 8bit character sets.
(re_match_2_internal): Correct check for charset after exactn in loop.

posix/regex.c

index 5f52deb0846265bcf5c7c2dcc5c019525f4ac933..04df21e308144914a223894aa73f9d70ee9e870b 100644 (file)
@@ -164,46 +164,6 @@ char *realloc ();
 #  define SWITCH_ENUM_CAST(x) (x)
 # endif
 
-/* How many characters in the character set.  */
-# define CHAR_SET_SIZE 256
-
-# ifdef SYNTAX_TABLE
-
-extern char *re_syntax_table;
-
-# else /* not SYNTAX_TABLE */
-
-static char re_syntax_table[CHAR_SET_SIZE];
-
-static void
-init_syntax_once ()
-{
-   register int c;
-   static int done;
-
-   if (done)
-     return;
-
-   bzero (re_syntax_table, sizeof re_syntax_table);
-
-   for (c = 'a'; c <= 'z'; c++)
-     re_syntax_table[c] = Sword;
-
-   for (c = 'A'; c <= 'Z'; c++)
-     re_syntax_table[c] = Sword;
-
-   for (c = '0'; c <= '9'; c++)
-     re_syntax_table[c] = Sword;
-
-   re_syntax_table['_'] = Sword;
-
-   done = 1;
-}
-
-# endif /* not SYNTAX_TABLE */
-
-# define SYNTAX(c) re_syntax_table[c]
-
 #endif /* not emacs */
 \f
 /* Get the interface, including the syntax bits.  */
@@ -276,6 +236,43 @@ init_syntax_once ()
 # define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
 #endif
 \f
+#ifndef emacs
+/* How many characters in the character set.  */
+# define CHAR_SET_SIZE 256
+
+# ifdef SYNTAX_TABLE
+
+extern char *re_syntax_table;
+
+# else /* not SYNTAX_TABLE */
+
+static char re_syntax_table[CHAR_SET_SIZE];
+
+static void
+init_syntax_once ()
+{
+   register int c;
+   static int done = 0;
+
+   if (done)
+     return;
+   bzero (re_syntax_table, sizeof re_syntax_table);
+
+   for (c = 0; c < CHAR_SET_SIZE; ++c)
+     if (ISALNUM (c))
+       re_syntax_table[c] = Sword;
+
+   re_syntax_table['_'] = Sword;
+
+   done = 1;
+}
+
+# endif /* not SYNTAX_TABLE */
+
+# define SYNTAX(c) re_syntax_table[((c) & 0xFF)]
+
+#endif /* emacs */
+\f
 /* Should we use malloc or alloca?  If REGEX_MALLOC is not defined, we
    use `alloca' instead of `malloc'.  This is because using malloc in
    re_search* or re_match* could cause memory leaks when C-g is used in
@@ -4836,11 +4833,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
                /* We win if the first character of the loop is not part
                    of the charset.  */
                 if ((re_opcode_t) p1[3] == exactn
-                   && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
-                         && (p2[2 + p1[5] / BYTEWIDTH]
-                             & (1 << (p1[5] % BYTEWIDTH)))))
-                  {
-                   p[-3] = (unsigned char) pop_failure_jump;
+                   && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
+                         && (p2[2 + p1[5] / BYTEWIDTH]
+                             & (1 << (p1[5] % BYTEWIDTH)))))
+                 {
+                   p[-3] = (unsigned char) pop_failure_jump;
                    DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
                   }