[PATCH 1/3] parse: split out _do_parse_cflags
Oneric
oneric at oneric.de
Fri Oct 15 20:31:15 UTC 2021
Pure refactoring with no functional changes,
prepares addition of Cflags.private.
---
parse.c | 73 +++++++++++++++++++++++++++++++--------------------------
1 file changed, 40 insertions(+), 33 deletions(-)
diff --git a/parse.c b/parse.c
index 6e9907c..f4a1baa 100644
--- a/parse.c
+++ b/parse.c
@@ -798,40 +798,9 @@ parse_libs_private (Package *pkg, const char *str, const char *path)
}
static void
-parse_cflags (Package *pkg, const char *str, const char *path)
+_do_parse_cflags (Package *pkg, int argc, char **argv)
{
- /* Strip out -I flags, put them in a separate list. */
-
- char *trimmed;
- char **argv = NULL;
- int argc = 0;
- GError *error = NULL;
int i;
-
- if (pkg->cflags)
- {
- verbose_error ("Cflags field occurs twice in '%s'\n", path);
- if (parse_strict)
- exit (1);
- else
- return;
- }
-
- trimmed = trim_and_sub (pkg, str, path);
-
- if (trimmed && *trimmed &&
- !g_shell_parse_argv (trimmed, &argc, &argv, &error))
- {
- verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n",
- error ? error->message : "unknown");
- if (parse_strict)
- exit (1);
- else
- {
- g_free (trimmed);
- return;
- }
- }
i = 0;
while (i < argc)
@@ -881,9 +850,47 @@ parse_cflags (Package *pkg, const char *str, const char *path)
g_free (flag);
g_free (arg);
-
+
++i;
}
+}
+
+static void
+parse_cflags (Package *pkg, const char *str, const char *path)
+{
+ /* Strip out -I flags, put them in a separate list. */
+
+ char *trimmed;
+ char **argv = NULL;
+ int argc = 0;
+ GError *error = NULL;
+
+ if (pkg->cflags)
+ {
+ verbose_error ("Cflags field occurs twice in '%s'\n", path);
+ if (parse_strict)
+ exit (1);
+ else
+ return;
+ }
+
+ trimmed = trim_and_sub (pkg, str, path);
+
+ if (trimmed && *trimmed &&
+ !g_shell_parse_argv (trimmed, &argc, &argv, &error))
+ {
+ verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n",
+ error ? error->message : "unknown");
+ if (parse_strict)
+ exit (1);
+ else
+ {
+ g_free (trimmed);
+ return;
+ }
+ }
+
+ _do_parse_cflags(pkg, argc, argv);
g_strfreev (argv);
g_free (trimmed);
--
2.30.2
More information about the pkg-config
mailing list