+2008-11-12 Owen Taylor <otaylor@redhat.com>
+
+ Only allow one <namespace/> element per <repository/> (#560419)
+
+ * girepository/girparser.c: The logic in girparser.c didn't work
+ very well if there were multiple <namespace/> nodes within a
+ single <repository/> (context->namespace was always the overall
+ filename and not the the name specified in the <namespace/>
+ element for one thing; this would cause aliases to be mis-prefixed
+ in include modules.) Also check that the "name" in the
+ <namespace/> node matches the filename.
+
+2008-11-12 Owen Taylor <otaylor@redhat.com>
+
+ Add a GirParser object to hold the state of a compilation
+
+ * girepository/girparser.[ch] tools/compiler.c: Add a toplevel
+ GirParser object to hold state that is global across a
+ compilation. Currently just holds the include path, but will
+ eventually also keep a cached list of parsed modules.
+
2008-11-12 Tommi Komulainen <tommi.komulainen@iki.fi>
* girepository/girepository.c (find_namespace_latest): Fix
if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_REPOSITORY)
{
const gchar *name, *version, *shared_library;
-
+
+ if (ctx->current_module != NULL)
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "Only one <namespace/> element is currently allowed per <repository/>");
+ goto out;
+ }
+
name = find_attribute ("name", attribute_names, attribute_values);
version = find_attribute ("version", attribute_names, attribute_values);
shared_library = find_attribute ("shared-library", attribute_names, attribute_values);
MISSING_ATTRIBUTE (context, error, element_name, "version");
else
{
+ if (strcmp (name, ctx->namespace) != 0)
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "<namespace/> name element '%s' doesn't match file name '%s'",
+ name, ctx->namespace);
+
ctx->current_module = g_ir_module_new (name, version, shared_library);
ctx->modules = g_list_append (ctx->modules, ctx->current_module);
ctx->current_module->dependencies = ctx->dependencies;
GList *modules;
GList *iter;
const char *slash;
+ char *dash;
char *namespace;
if (!g_str_has_suffix (filename, ".gir"))
namespace = g_strdup (slash+1);
namespace[strlen(namespace)-4] = '\0';
+ /* Remove version */
+ dash = strstr (namespace, "-");
+ if (dash != NULL)
+ *dash = '\0';
+
if (!g_file_get_contents (filename, &buffer, &length, error))
return NULL;