>From f911aa9d9209a6a78d4eafaf68574189418bfe0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= Date: Sun, 11 Aug 2013 16:53:49 +0200 Subject: [PATCH] x-glade: Fix comment extraction. --- gettext-tools/src/ChangeLog | 11 +++++++++++ gettext-tools/src/x-glade.c | 28 ++++++++-------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 38dc376..4060a37 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,14 @@ +2013-08-11 Miguel Angel Arruga Vivas + + * x-glade.c (struct element_state): Remove field extracted_comment. + (comment_handler): Add foward declaration. + (start_element_glade2): Call comment_handler. + (start_element_gtkbuilder): Likewise. + (end_element_glade2): Remove extracted_comment references. + (end_element_gtkbuilder): Likewise. + (start_element_handler): Likewise. + (end_element_handler): Likewise. + 2013-08-09 Daiki Ueno * x-gsettings.c (extract_gsettings): Add guard when expat is not diff --git a/gettext-tools/src/x-glade.c b/gettext-tools/src/x-glade.c index d95cd8e..7a6124e 100644 --- a/gettext-tools/src/x-glade.c +++ b/gettext-tools/src/x-glade.c @@ -132,7 +132,6 @@ struct element_state { bool extract_string; bool extract_context; /* used by Glade 2 */ - char *extracted_comment; /* used by Glade 2 or GtkBuilder */ char *extracted_context; /* used by GtkBuilder */ int lineno; char *buffer; @@ -203,11 +202,14 @@ end_element_glade1 (struct element_state *p, const char *name) { remember_a_message (mlp, NULL, p->buffer, null_context, &pos, - p->extracted_comment, savable_comment); + NULL, savable_comment); p->buffer = NULL; } } +/* Foward declaration of needed local function. */ +static void comment_handler (void *userData, const char *data); + static void start_element_glade2 (struct element_state *p, const char *name, const char **attributes) @@ -224,24 +226,19 @@ start_element_glade2 (struct element_state *p, const char *name, { bool has_translatable = false; bool has_context = false; - const char *extracted_comment = NULL; const char **attp = attributes; while (*attp != NULL) { if (strcmp (attp[0], "translatable") == 0) has_translatable = (strcmp (attp[1], "yes") == 0); else if (strcmp (attp[0], "comments") == 0) - extracted_comment = attp[1]; + comment_handler (NULL, attp[1]); else if (strcmp (attp[0], "context") == 0) has_context = (strcmp (attp[1], "yes") == 0); attp += 2; } p->extract_string = has_translatable; p->extract_context = has_context; - p->extracted_comment = - (has_translatable && extracted_comment != NULL - ? xstrdup (extracted_comment) - : NULL); } /* In Glade 2, the attribute description="..." of @@ -313,7 +310,7 @@ Missing context for the string extracted from '%s' element"), if (msgid != NULL) remember_a_message (mlp, msgctxt, msgid, null_context, &pos, - p->extracted_comment, savable_comment); + NULL, savable_comment); } static void @@ -328,7 +325,6 @@ start_element_gtkbuilder (struct element_state *p, const char *name, if (!p->extract_string) { bool has_translatable = false; - const char *extracted_comment = NULL; const char *extracted_context = NULL; const char **attp = attributes; while (*attp != NULL) @@ -336,16 +332,12 @@ start_element_gtkbuilder (struct element_state *p, const char *name, if (strcmp (attp[0], "translatable") == 0) has_translatable = (strcmp (attp[1], "yes") == 0); else if (strcmp (attp[0], "comments") == 0) - extracted_comment = attp[1]; + comment_handler (NULL, attp[1]); else if (strcmp (attp[0], "context") == 0) extracted_context = attp[1]; attp += 2; } p->extract_string = has_translatable; - p->extracted_comment = - (has_translatable && extracted_comment != NULL - ? xstrdup (extracted_comment) - : NULL); p->extracted_context = (has_translatable && extracted_context != NULL ? xstrdup (extracted_context) @@ -364,8 +356,7 @@ end_element_gtkbuilder (struct element_state *p, const char *name) if (p->buffer != NULL) { remember_a_message (mlp, p->extracted_context, p->buffer, - null_context, &pos, - p->extracted_comment, savable_comment); + null_context, &pos, NULL, savable_comment); p->buffer = NULL; p->extracted_context = NULL; } @@ -434,7 +425,6 @@ The root element <%s> is not allowed in a valid Glade file"), p = &stack[stack_depth]; p->extract_string = extract_all; p->extract_context = false; - p->extracted_comment = NULL; p->extracted_context = NULL; element_parser->start_element (p, name, attributes); @@ -468,8 +458,6 @@ end_element_handler (void *userData, const char *name) } /* Free memory for this stack level. */ - if (p->extracted_comment != NULL) - free (p->extracted_comment); if (p->extracted_context != NULL) free (p->extracted_context); if (p->buffer != NULL) -- 1.7.10.4