From: Juerg Billeter Date: Tue, 27 Nov 2007 19:48:54 +0000 (+0000) Subject: concatenate adjacent string literal tokens X-Git-Tag: VALA_0_1_6~141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=815f47ef3075e9cae6f7dbdd283c3d19bd90d198;p=platform%2Fupstream%2Fvala.git concatenate adjacent string literal tokens 2007-11-27 Juerg Billeter * gobject-introspection/cparser.y: concatenate adjacent string literal tokens svn path=/trunk/; revision=726 --- diff --git a/ChangeLog b/ChangeLog index d8a6845..07ab851 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-11-27 Jürg Billeter + * gobject-introspection/cparser.y: concatenate adjacent string literal + tokens + +2007-11-27 Jürg Billeter + * vapi/glib-2.0.vapi: bind sscanf instead of scanf, add memcpy binding 2007-11-27 Jürg Billeter diff --git a/gobject-introspection/cparser.y b/gobject-introspection/cparser.y index 415607e..c29ca8f 100644 --- a/gobject-introspection/cparser.y +++ b/gobject-introspection/cparser.y @@ -133,6 +133,7 @@ static void csymbol_merge_type (CSymbol *symbol, CType *type) %type unary_operator %type function_macro %type object_macro +%type strings %% @@ -166,15 +167,31 @@ primary_expression { $$ = csymbol_new (CSYMBOL_TYPE_INVALID); } - | STRING + | strings + | '(' expression ')' + { + $$ = $2; + } + ; + +/* concatenate adjacent string literal tokens */ +strings + : STRING { $$ = csymbol_new (CSYMBOL_TYPE_CONST); yytext[strlen (yytext) - 1] = '\0'; $$->const_string = g_strcompress (yytext + 1); } - | '(' expression ')' + | strings STRING { - $$ = $2; + char *strings, *string2; + $$ = $1; + yytext[strlen (yytext) - 1] = '\0'; + string2 = g_strcompress (yytext + 1); + strings = g_strconcat ($$->const_string, string2, NULL); + g_free ($$->const_string); + g_free (string2); + $$->const_string = strings; } ;