[gnome-builder] makecache: fix shell parsing for simple makefile lines



commit 2dc6164b2e437628c4c07a918520d8d38aa509b2
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 30 14:43:50 2015 -0700

    makecache: fix shell parsing for simple makefile lines
    
    For simpler lines, where we don't parse earlier in the line, we could hit
    a situation where \ is on the suffix. We don't actually need the additional
    line information, and this simply was breaking g_shell_parse_argv().
    
    For now, let's just drop the \ from the line. Longer term, we probably
    need to investigate whether or not we need the additional lines. My
    5 minute test did not show positive results in doing so.
    
    This happens to fix loading parsing of CFLAGS for the systemd project for
    me. However, I have not exhaustively checked.

 libide/autotools/ide-makecache.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/libide/autotools/ide-makecache.c b/libide/autotools/ide-makecache.c
index 7dfbe17..70748d2 100644
--- a/libide/autotools/ide-makecache.c
+++ b/libide/autotools/ide-makecache.c
@@ -45,7 +45,7 @@
 
 struct _IdeMakecache
 {
-  IdeObject parent_instance;
+  IdeObject    parent_instance;
 
   /* Immutable after instance creation */
   GFile       *makefile;
@@ -798,6 +798,7 @@ ide_makecache_parse_c_cxx (IdeMakecache *self,
   gint argc = 0;
   gchar **argv = NULL;
   gboolean in_expand = FALSE;
+  GError *error = NULL;
   gsize i;
 
   g_assert (line != NULL);
@@ -807,8 +808,12 @@ ide_makecache_parse_c_cxx (IdeMakecache *self,
   while (isspace (*line))
     line++;
 
-  if (!g_shell_parse_argv (line, &argc, &argv, NULL))
-    return;
+  if (!g_shell_parse_argv (line, &argc, &argv, &error))
+    {
+      g_warning ("Failed to parse line: %s", error->message);
+      g_clear_error (&error);
+      return;
+    }
 
   g_ptr_array_add (ret, g_strdup (self->llvm_flags));
 
@@ -995,7 +1000,16 @@ ide_makecache_get_file_flags_worker (GTask        *task,
 
       for (i = 0; lines [i]; i++)
         {
-          const gchar *line = lines [i];
+          gchar *line = lines [i];
+          gsize linelen;
+
+          if (line [0] == '\0')
+            continue;
+
+          linelen = strlen (line);
+
+          if (line [linelen - 1] == '\\')
+            line [linelen - 1] = '\0';
 
           if ((ret = ide_makecache_parse_line (self, line, relpath, subdir ?: ".")))
             break;


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