PATCH: make regex.c friendly for BPs.
Greg McGary
greg@mcgary.org
Fri Jul 7 00:01:00 GMT 2000
2000-07-06 Greg McGary <greg@mcgary.org>
* posix/regex.c (EXTEND_BUFFER): Compute increment once.
Move all three components of a bounded pointer.
Index: posix/regex.c
===================================================================
RCS file: /cvs/glibc/libc/posix/regex.c,v
retrieving revision 1.74
diff -u -p -B -w -r1.74 regex.c
--- regex.c 2000/07/05 22:00:29 1.74
+++ regex.c 2000/07/07 06:57:51
@@ -1747,6 +1747,12 @@ static reg_errcode_t compile_range _RE_A
reset the pointers that pointed into the old block to point to the
correct places in the new one. If extending the buffer results in it
being larger than MAX_BUF_SIZE, then flag memory exhausted. */
+#if __BOUNDED_POINTERS__
+# define MOVE_BUFFER_POINTER(P) \
+ (__ptrlow (P) += incr, __ptrhigh (P) += incr, __ptrvalue (P) += incr)
+#else
+# define MOVE_BUFFER_POINTER(P) (P) += incr
+#endif
#define EXTEND_BUFFER() \
do { \
unsigned char *old_buffer = bufp->buffer; \
@@ -1761,14 +1767,15 @@ static reg_errcode_t compile_range _RE_A
/* If the buffer moved, move all the pointers into it. */ \
if (old_buffer != bufp->buffer) \
{ \
- b = (b - old_buffer) + bufp->buffer; \
- begalt = (begalt - old_buffer) + bufp->buffer; \
+ int incr = bufp->buffer - old_buffer; \
+ MOVE_BUFFER_POINTER (b); \
+ MOVE_BUFFER_POINTER (begalt); \
if (fixup_alt_jump) \
- fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
+ MOVE_BUFFER_POINTER (fixup_alt_jump); \
if (laststart) \
- laststart = (laststart - old_buffer) + bufp->buffer; \
+ MOVE_BUFFER_POINTER (laststart); \
if (pending_exact) \
- pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
+ MOVE_BUFFER_POINTER (pending_exact); \
} \
} while (0)
More information about the Libc-hacker
mailing list