]> granicus.if.org Git - flex/commitdiff
apply patches submitted by sodabrew
authorWill Estes <wlestes@users.sourceforge.net>
Wed, 7 Mar 2007 21:50:24 +0000 (21:50 +0000)
committerWill Estes <wlestes@users.sourceforge.net>
Wed, 7 Mar 2007 21:50:24 +0000 (21:50 +0000)
NEWS
filter.c
flex.skl

diff --git a/NEWS b/NEWS
index d790bdf6c84524c1c970e815e3e768b32042cf50..2fa65157e6c0f07ac12a9318f26e1110ac5d5009 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,11 @@ See the file COPYING for copying conditions.
 
 * after version 2.5.33
 
+** flex better escapes filenames with special characters in them
+(resolves#1623600)
+
+** a memory leak was plugged(resolves bug #1601111)
+
 ** pattern language expanded; see the manual for details on the below
    highlights
 
index 54fa50cd23a0aff430706921394c36af5228043d..b0c7bf1edb09718763d6d4a0a259b2872205d35d 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -354,24 +354,43 @@ int filter_fix_linedirs (struct filter *chain)
                        num = regmatch_strtol (&m[1], buf, NULL, 0);
                        fname = regmatch_dup (&m[2], buf);
 
-                       if (strcmp
-                           (fname, outfilename ? outfilename : "<stdout>")
-                           == 0
-                           || strcmp (fname,
-                                      headerfilename ? headerfilename :
-                                      "<stdout>") == 0) {
+                       if (strcmp (fname,
+                               outfilename ? outfilename : "<stdout>")
+                                       == 0
+                        || strcmp (fname,
+                               headerfilename ? headerfilename : "<stdout>")
+                                       == 0) {
+
+                               char    *s1, *s2;
+                               char    filename[MAXLINE];
+
+                               s1 = fname;
+                               s2 = filename;
+
+                               while ((s2 - filename) < (MAXLINE - 1) && *s1) {
+                                       /* Escape the backslash */
+                                       if (*s1 == '\\')
+                                               *s2++ = '\\';
+                                       /* Escape the double quote */
+                                       if (*s1 == '\"')
+                                               *s2++ = '\\';
+                                       /* Copy the character as usual */
+                                       *s2++ = *s1++;
+                               }
+
+                               *s2 = '\0';
+
                                /* Adjust the line directives. */
                                in_gen = true;
                                snprintf (buf, readsz, "#line %d \"%s\"\n",
-                                        lineno + 1, fname);
-                               free (fname);
-
+                                         lineno + 1, filename);
                        }
                        else {
                                /* it's a #line directive for code we didn't write */
                                in_gen = false;
                        }
 
+                       free (fname);
                        last_was_blank = false;
                }
 
index 3cf3064bee45aa699f5db38b36638a633d6edce9..4ab57c9d573be7b8ebabcc585da093f5a176f677 100644 (file)
--- a/flex.skl
+++ b/flex.skl
@@ -1647,6 +1647,13 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
        else
                ret_val = EOB_ACT_CONTINUE_SCAN;
 
+       if ((yy_size_t) (yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+               /* Extend the array by 50%, plus the number we really need. */
+               yy_size_t new_size = yy_n_chars + number_to_move + (yy_n_chars >> 1);
+               YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+                       (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size);
+       }
+
        YY_G(yy_n_chars) += number_to_move;
        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;