diff options
author | Stef Walter <stefw@collabora.co.uk> | 2011-05-14 21:49:53 +0200 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2011-08-10 10:39:59 -0400 |
commit | 7f178ddeadd99ee82ec0da6ff963392b44d223c3 (patch) | |
tree | b2b964997c4d5dace3d2cf5133523bfabb1e56ff /giscanner/sourcescanner.c | |
parent | 37213bcbf7dde51bf955501c709d0b940722d32a (diff) | |
download | gobject-introspection-7f178ddeadd99ee82ec0da6ff963392b44d223c3.tar.gz |
Fix symbols being reported in invalid files
* Due to the way that flex/bison works, the symbols were being added
to the scanner after additional lines are parsed.
* If these lines are #line directives, then scanner->current_filename
can change between when the symbol is parsed and when it's added.
* Change so that symbol gets filename when parsing rather than when
being added to the scanner.
https://bugzilla.gnome.org/show_bug.cgi?id=650200
Diffstat (limited to 'giscanner/sourcescanner.c')
-rw-r--r-- | giscanner/sourcescanner.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/giscanner/sourcescanner.c b/giscanner/sourcescanner.c index e519a942..1ae14bc3 100644 --- a/giscanner/sourcescanner.c +++ b/giscanner/sourcescanner.c @@ -24,10 +24,11 @@ #include <string.h> GISourceSymbol * -gi_source_symbol_new (GISourceSymbolType type, int line) +gi_source_symbol_new (GISourceSymbolType type, const gchar *filename, int line) { GISourceSymbol *s = g_slice_new0 (GISourceSymbol); s->ref_count = 1; + s->source_filename = g_strdup (filename); s->type = type; s->line = line; return s; @@ -255,11 +256,7 @@ gi_source_scanner_add_symbol (GISourceScanner *scanner, if (found_filename || scanner->macro_scan) scanner->symbols = g_slist_prepend (scanner->symbols, gi_source_symbol_ref (symbol)); - /* TODO: Refcounted string here or some other optimization */ - if (found_filename && symbol->source_filename == NULL) - { - symbol->source_filename = g_strdup (scanner->current_filename); - } + g_assert (symbol->source_filename != NULL); switch (symbol->type) { |