[gnome-builder] Bug 766131 - Update modeline parser



commit 441c35fd64842c1fcb360925106421ac58dbbeb4
Author: Raunaq Abhyankar <raunaq abhyankar gmail com>
Date:   Tue May 10 22:07:20 2016 +0530

    Bug 766131 - Update modeline parser
    
    If while parsing a modeline we already reach \0 we should not
    increment the pointer, we must instead break out of the loop.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766131

 libide/modelines/modeline-parser.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/libide/modelines/modeline-parser.c b/libide/modelines/modeline-parser.c
index 89a4ad2..2f81056 100644
--- a/libide/modelines/modeline-parser.c
+++ b/libide/modelines/modeline-parser.c
@@ -567,18 +567,21 @@ parse_kate_modeline (gchar           *s,
  * Line numbers are counted starting at one.
  */
 static void
-parse_modeline (gchar           *s,
+parse_modeline (gchar           *line,
                gint             line_number,
                gint             line_count,
                ModelineOptions *options)
 {
-       gchar prev;
+       gchar *s = line;
 
        /* look for the beginning of a modeline */
-       for (prev = ' '; (s != NULL) && (*s != '\0'); prev = *(s++))
+       while (s != NULL && *s != '\0')
        {
-               if (!g_ascii_isspace (prev))
-                       continue;
+               if (s > line && !g_ascii_isspace (*(s - 1)))
+                {
+                        s++;
+                       continue;
+                }
 
                if ((line_number <= 3 || line_number > line_count - 3) &&
                    (strncmp (s, "ex:", 3) == 0 ||
@@ -603,6 +606,10 @@ parse_modeline (gchar           *s,
 
                        s = parse_kate_modeline (s + 5, options);
                }
+               else
+                {
+                        s++;
+                }
        }
 }
 


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