From 5c94d329b25ab757285933480abcc47195b7d0b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Granjoux?= Date: Wed, 30 May 2012 21:10:06 +0200 Subject: [PATCH] libanjuta, am-project: bgo #675118 - Project manager never finishes loading Anjuta project --- libanjuta/anjuta-token-stream.c | 12 ++++++++++++ libanjuta/anjuta-token.c | 2 +- plugins/am-project/am-scanner.l | 10 ++++++++-- plugins/am-project/tests/bugs.at | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/libanjuta/anjuta-token-stream.c b/libanjuta/anjuta-token-stream.c index eba687f62..c03577ccd 100644 --- a/libanjuta/anjuta-token-stream.c +++ b/libanjuta/anjuta-token-stream.c @@ -82,6 +82,9 @@ struct _AnjutaTokenStream /* Current file */ GFile *current_file; + + /* Content */ + AnjutaToken *content; }; /* Helpers functions @@ -318,12 +321,21 @@ AnjutaTokenStream * anjuta_token_stream_push (AnjutaTokenStream *parent, AnjutaToken *root, AnjutaToken *content, GFile *file) { AnjutaTokenStream *child; + AnjutaTokenStream *stream; + + /* Check if content is not already parsed to avoid endless parsing loop */ + for (stream = parent; stream != NULL; stream = stream->parent) + { + if (stream->content == content) return NULL; + } + /* Create new stream */ child = g_new (AnjutaTokenStream, 1); child->first = content; child->pos = 0; child->begin = 0; child->parent = parent; + child->content = content; child->token = content; child->start = child->token; child->last = content == NULL ? NULL : anjuta_token_last (content); diff --git a/libanjuta/anjuta-token.c b/libanjuta/anjuta-token.c index 65e2a9f53..b4fd6e0e6 100644 --- a/libanjuta/anjuta-token.c +++ b/libanjuta/anjuta-token.c @@ -1183,7 +1183,7 @@ anjuta_token_cut (AnjutaToken *token, guint pos, guint size) } else { - memcpy(copy->data.pos, copy->data.pos + pos, size); + memmove(copy->data.pos, copy->data.pos + pos, size); } copy->data.length = size; diff --git a/plugins/am-project/am-scanner.l b/plugins/am-project/am-scanner.l index bcc77f5e4..54b5b1e54 100644 --- a/plugins/am-project/am-scanner.l +++ b/plugins/am-project/am-scanner.l @@ -514,9 +514,13 @@ amp_am_scanner_parse_variable (AmpAmScanner *scanner, AnjutaToken *variable) { value = amp_project_get_subst_variable_token (scanner->project, name); } - g_free (string); - amp_am_scanner_parse_token (scanner, variable, value, NULL, NULL); + if (amp_am_scanner_parse_token (scanner, variable, value, NULL, NULL) == NULL) + { + /* Recursive variable, display a warning */ + g_warning ("Recursive variable %s. Discard value", name); + } + g_free (string); } void @@ -554,6 +558,8 @@ amp_am_scanner_parse_token (AmpAmScanner *scanner, AnjutaToken *root, AnjutaToke AnjutaTokenStream *stream; stream = anjuta_token_stream_push (scanner->stream, root, content, filename); + if (stream == NULL) return NULL; + first = anjuta_token_stream_get_root (stream); scanner->eof = filename != NULL; diff --git a/plugins/am-project/tests/bugs.at b/plugins/am-project/tests/bugs.at index d379879f2..b9e74236b 100644 --- a/plugins/am-project/tests/bugs.at +++ b/plugins/am-project/tests/bugs.at @@ -78,4 +78,26 @@ AT_CHECK([diff output expect]) +AS_MKDIR_P([project4]) +AT_DATA([project4/configure.ac], +[[ +AC_CONFIG_FILES(Makefile) +]]) +AT_DATA([project4/Makefile.am], +[[ +GDU__v_DB2OMF_=$(GDU__v_DB2OMF_$(AM_DEFAULT_VERBOSITY)) + +$(GDU__v_DB2OMF_) +]]) +AT_DATA([expect], +[[ROOT (): project4 + SOURCE (): configure.ac + SOURCE (): Makefile.am +]]) +AT_PARSER_CHECK([load project4 \ + list]) +AT_CHECK([diff output expect]) + + + AT_CLEANUP -- 2.11.4.GIT