]> code.delx.au - gnu-emacs/blobdiff - src/regex.c
(redraw_overlapping_rows): Fix detection of
[gnu-emacs] / src / regex.c
index eca78f2ab94309ec20df550e3b3c98168e49bf4e..91259dc77942602eaebaf6fb3dcc186467faf806 100644 (file)
@@ -3,7 +3,7 @@
    internationalization features.)
 
    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-                 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
                  Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
 
 # define RE_CHAR_TO_MULTIBYTE(c) unibyte_to_multibyte_table[(c)]
 
-# define RE_CHAR_TO_UNIBYTE(c)                 \
-  (ASCII_CHAR_P (c) ? (c)                      \
-   : CHAR_BYTE8_P (c) ? CHAR_TO_BYTE8 (c)      \
-   : multibyte_char_to_unibyte_safe (c))
+# define RE_CHAR_TO_UNIBYTE(c) CHAR_TO_BYTE_SAFE (c)
 
 /* Set C a (possibly converted to multibyte) character before P.  P
    points into a string which is the virtual concatenation of STR1
@@ -1854,8 +1851,10 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
    being larger than MAX_BUF_SIZE, then flag memory exhausted.  */
 #if __BOUNDED_POINTERS__
 # define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
-# define MOVE_BUFFER_POINTER(P) \
-  (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
+# define MOVE_BUFFER_POINTER(P)                                        \
+  (__ptrlow (P) = new_buffer + (__ptrlow (P) - old_buffer),    \
+   SET_HIGH_BOUND (P),                                         \
+   __ptrvalue (P) = new_buffer + (__ptrvalue (P) - old_buffer))
 # define ELSE_EXTEND_BUFFER_HIGH_BOUND         \
   else                                         \
     {                                          \
@@ -1869,12 +1868,12 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
        SET_HIGH_BOUND (pending_exact);         \
     }
 #else
-# define MOVE_BUFFER_POINTER(P) (P) += incr
+# define MOVE_BUFFER_POINTER(P) ((P) = new_buffer + ((P) - old_buffer))
 # define ELSE_EXTEND_BUFFER_HIGH_BOUND
 #endif
 #define EXTEND_BUFFER()                                                        \
   do {                                                                 \
-    re_char *old_buffer = bufp->buffer;                                        \
+    unsigned char *old_buffer = bufp->buffer;                          \
     if (bufp->allocated == MAX_BUF_SIZE)                               \
       return REG_ESIZE;                                                        \
     bufp->allocated <<= 1;                                             \
@@ -1886,7 +1885,7 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
     /* If the buffer moved, move all the pointers into it.  */         \
     if (old_buffer != bufp->buffer)                                    \
       {                                                                        \
-       int incr = bufp->buffer - old_buffer;                           \
+       unsigned char *new_buffer = bufp->buffer;                       \
        MOVE_BUFFER_POINTER (b);                                        \
        MOVE_BUFFER_POINTER (begalt);                                   \
        if (fixup_alt_jump)                                             \
@@ -5572,10 +5571,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
                if (multibyte)
                  {
                    pat_ch = STRING_CHAR_AND_LENGTH (p, pend - p, pat_charlen);
-                   if (CHAR_BYTE8_P (pat_ch))
-                     pat_ch = CHAR_TO_BYTE8 (pat_ch);
-                   else
-                     pat_ch = RE_CHAR_TO_UNIBYTE (pat_ch);
+                   pat_ch = RE_CHAR_TO_UNIBYTE (pat_ch);
                  }
                else
                  {
@@ -6839,20 +6835,17 @@ void
 regfree (preg)
     regex_t *preg;
 {
-  if (preg->buffer != NULL)
-    free (preg->buffer);
+  free (preg->buffer);
   preg->buffer = NULL;
 
   preg->allocated = 0;
   preg->used = 0;
 
-  if (preg->fastmap != NULL)
-    free (preg->fastmap);
+  free (preg->fastmap);
   preg->fastmap = NULL;
   preg->fastmap_accurate = 0;
 
-  if (preg->translate != NULL)
-    free (preg->translate);
+  free (preg->translate);
   preg->translate = NULL;
 }
 WEAK_ALIAS (__regfree, regfree)