From b31a2ae395991490a7b9bc6886233dea8b5f4d87 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 28 Aug 2008 22:13:00 +0000 Subject: [PATCH] Fix --includedir handling * tests/scanner/Makefile.am: Pass the right --includedir args. Add a Makefile dep. * tools/compiler.c: Pass includedirs down. * girepository/girparser.c: Actually put includedirs in context, pass down. Fix locate_gir. svn path=/trunk/; revision=514 --- girparser.c | 25 ++++++++++++++++--------- girparser.h | 2 ++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/girparser.c b/girparser.c index 7f20ce9ab..f357cb1e9 100644 --- a/girparser.c +++ b/girparser.c @@ -68,7 +68,7 @@ struct _ParseContext ParseState state; ParseState prev_state; - const char **includes; + const char * const*includes; GList *modules; gboolean prefix_aliases; @@ -126,7 +126,7 @@ static GMarkupParser firstpass_parser = }; static char * -locate_gir (const char *name, const char **extra_paths) +locate_gir (const char *name, const char * const* extra_paths) { const gchar *const *datadirs; const gchar *const *dir; @@ -146,11 +146,14 @@ locate_gir (const char *name, const char **extra_paths) return path; g_free (path); path = NULL; - if (firstpass && !*dir) - { - firstpass = FALSE; - dir = extra_paths; - } + } + for (dir = extra_paths; *dir; dir++) + { + path = g_build_filename (*dir, girname, NULL); + if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) + return path; + g_free (path); + path = NULL; } g_free (girname); return path; @@ -1968,6 +1971,7 @@ parse_include (GMarkupParseContext *context, g_free (girpath); sub_ctx.state = STATE_START; + sub_ctx.includes = ctx->includes; sub_ctx.prefix_aliases = TRUE; sub_ctx.namespace = name; sub_ctx.aliases = ctx->aliases; @@ -2630,7 +2634,8 @@ static GMarkupParser parser = }; GList * -g_ir_parse_string (const char *namespace, +g_ir_parse_string (const gchar *namespace, + const gchar *const *includes, const gchar *buffer, gssize length, GError **error) @@ -2639,6 +2644,7 @@ g_ir_parse_string (const char *namespace, GMarkupParseContext *context; ctx.state = STATE_START; + ctx.includes = includes; ctx.prefix_aliases = FALSE; ctx.namespace = namespace; ctx.aliases = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -2672,6 +2678,7 @@ g_ir_parse_string (const char *namespace, GList * g_ir_parse_file (const gchar *filename, + const gchar *const *includes, GError **error) { gchar *buffer; @@ -2701,7 +2708,7 @@ g_ir_parse_file (const gchar *filename, if (!g_file_get_contents (filename, &buffer, &length, error)) return NULL; - modules = g_ir_parse_string (namespace, buffer, length, error); + modules = g_ir_parse_string (namespace, includes, buffer, length, error); g_free (namespace); diff --git a/girparser.h b/girparser.h index ed9e6cebf..68b3acf5f 100644 --- a/girparser.h +++ b/girparser.h @@ -27,9 +27,11 @@ G_BEGIN_DECLS GList *g_ir_parse_string (const gchar *buffer, + const gchar *const *includes, gssize length, GError **error); GList *g_ir_parse_file (const gchar *filename, + const gchar *const *includes, GError **error);