bug-gnulib
[Top][All Lists]
Advanced

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

regex simplification of update to register offsets


From: Paul Eggert
Subject: regex simplification of update to register offsets
Date: Wed, 31 Aug 2005 12:55:50 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed this and filed glibc bug 1279:

2005-08-31  Paul Eggert  <address@hidden>

        * lib/regexec.c (re_search_internal): Simplify update of
        rm_so and rm_eo by replacing "if (A == B) A += C - B;"
        with the equivalent of "if (A == B) A = C;".  This will
        make the code more reliable once we port to 64-bit hosts.
        * config/srclist.txt: Add glibc bug 1279.

--- lib/regexec.c       31 Aug 2005 19:38:13 -0000      1.10
+++ lib/regexec.c       31 Aug 2005 19:46:05 -0000
@@ -856,14 +856,14 @@ re_search_internal (const regex_t *preg,
 #ifdef RE_ENABLE_I18N
            if (BE (mctx.input.offsets_needed != 0, 0))
              {
-               if (pmatch[reg_idx].rm_so == mctx.input.valid_len)
-                 pmatch[reg_idx].rm_so += mctx.input.valid_raw_len - 
mctx.input.valid_len;
-               else
-                 pmatch[reg_idx].rm_so = 
mctx.input.offsets[pmatch[reg_idx].rm_so];
-               if (pmatch[reg_idx].rm_eo == mctx.input.valid_len)
-                 pmatch[reg_idx].rm_eo += mctx.input.valid_raw_len - 
mctx.input.valid_len;
-               else
-                 pmatch[reg_idx].rm_eo = 
mctx.input.offsets[pmatch[reg_idx].rm_eo];
+               pmatch[reg_idx].rm_so =
+                 (pmatch[reg_idx].rm_so == mctx.input.valid_len
+                  ? mctx.input.valid_raw_len
+                  : mctx.input.offsets[pmatch[reg_idx].rm_so]);
+               pmatch[reg_idx].rm_eo =
+                 (pmatch[reg_idx].rm_eo == mctx.input.valid_len
+                  ? mctx.input.valid_raw_len
+                  : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
              }
 #else
            assert (mctx.input.offsets_needed == 0);
--- config/srclist.txt  31 Aug 2005 19:40:49 -0000      1.90
+++ config/srclist.txt  31 Aug 2005 19:54:32 -0000
@@ -147,6 +147,7 @@ $LIBCSRC/stdlib/getsubopt.c         lib gpl
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1241
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1245
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1278
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1279
 #$LIBCSRC/posix/regexec.c              lib gpl
 #
 # c89 changes $LIBCSRC/string/strdup.c         lib gpl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]