From: Bruno Haible Date: Sun, 4 Nov 2018 19:23:36 +0000 (+0100) Subject: xgettext: Simplify calling convention of remember_a_message. X-Git-Tag: v0.20~258 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=874695014981801ea59e2240677179669ae30858;p=thirdparty%2Fgettext.git xgettext: Simplify calling convention of remember_a_message. * gettext-tools/src/xg-message.h (remember_a_message, remember_a_message_plural): Add is_utf8, comment_is_utf8 arguments. * gettext-tools/src/xg-message.c (remember_a_message, remember_a_message_plural): Likewise. * gettext-tools/src/xg-arglist-parser.c (arglist_parser_done): Update callers. * gettext-tools/src/x-awk.c (extract_parenthesized): Likewise. * gettext-tools/src/x-c.c (extract_parenthesized): Likewise. * gettext-tools/src/x-csharp.c (extract_parenthesized): Likewise. * gettext-tools/src/x-desktop.c (extract_desktop_handle_pair): Likewise. * gettext-tools/src/x-elisp.c (read_object): Likewise. * gettext-tools/src/x-java.c (extract_parenthesized): Likewise. * gettext-tools/src/x-javascript.c (extract_balanced): Likewise. * gettext-tools/src/x-librep.c (read_object): Likewise. * gettext-tools/src/x-lisp.c (read_object): Likewise. * gettext-tools/src/x-lua.c (extract_balanced): Likewise. * gettext-tools/src/x-perl.c (extract_variable, interpolate_keywords, extract_balanced): Likewise. * gettext-tools/src/x-php.c (extract_balanced): Likewise. * gettext-tools/src/x-python.c (extract_balanced): Likewise. * gettext-tools/src/x-rst.c (extract_rst, extract_rsj): Likewise. * gettext-tools/src/x-scheme.c (read_object): Likewise. * gettext-tools/src/x-sh.c (read_word, read_command): Likewise. * gettext-tools/src/x-smalltalk.c (extract_smalltalk): Likewise. * gettext-tools/src/x-tcl.c (read_command): Likewise. * gettext-tools/src/x-vala.c (extract_balanced): Likewise. * gettext-tools/src/x-ycp.c (extract_parenthesized): Likewise. * gettext-tools/src/xgettext.c (xgettext_its_extract_callback): Likewise. --- diff --git a/gettext-tools/src/x-awk.c b/gettext-tools/src/x-awk.c index b97e29806..993aa3aab 100644 --- a/gettext-tools/src/x-awk.c +++ b/gettext-tools/src/x-awk.c @@ -788,8 +788,8 @@ extract_parenthesized (message_list_ty *mlp, pos.line_number = token.line_number; if (extract_all) - remember_a_message (mlp, NULL, token.string, inner_context, &pos, - NULL, savable_comment); + remember_a_message (mlp, NULL, token.string, false, inner_context, + &pos, NULL, savable_comment, false); else arglist_parser_remember (argparser, arg, token.string, inner_context, @@ -807,8 +807,8 @@ extract_parenthesized (message_list_ty *mlp, pos.file_name = logical_file_name; pos.line_number = token.line_number; - remember_a_message (mlp, NULL, token.string, inner_context, &pos, - NULL, savable_comment); + remember_a_message (mlp, NULL, token.string, false, inner_context, + &pos, NULL, savable_comment, false); } next_is_argument = false; next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index a8a0b84fa..09f474c24 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -2303,17 +2303,19 @@ extract_parenthesized (message_list_ty *mlp, { char *string = mixed_string_contents (token.mixed_string); mixed_string_free (token.mixed_string); - xgettext_current_source_encoding = po_charset_utf8; if (extract_all) - remember_a_message (mlp, NULL, string, inner_context, - &token.pos, NULL, token.comment); + remember_a_message (mlp, NULL, string, true, inner_context, + &token.pos, NULL, token.comment, false); else - arglist_parser_remember (argparser, arg, string, - inner_context, - token.pos.file_name, - token.pos.line_number, - token.comment); - xgettext_current_source_encoding = xgettext_global_source_encoding; + { + xgettext_current_source_encoding = po_charset_utf8; + arglist_parser_remember (argparser, arg, string, + inner_context, + token.pos.file_name, + token.pos.line_number, + token.comment); + xgettext_current_source_encoding = xgettext_global_source_encoding; + } drop_reference (token.comment); } next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-csharp.c b/gettext-tools/src/x-csharp.c index c5a8e5ff6..cfa6ea622 100644 --- a/gettext-tools/src/x-csharp.c +++ b/gettext-tools/src/x-csharp.c @@ -2018,16 +2018,18 @@ extract_parenthesized (message_list_ty *mlp, token_type_ty terminator, pos.file_name = logical_file_name; pos.line_number = token.line_number; - xgettext_current_source_encoding = po_charset_utf8; if (extract_all) - remember_a_message (mlp, NULL, string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, string, true, inner_context, + &pos, NULL, token.comment, true); else - arglist_parser_remember (argparser, arg, string, - inner_context, - pos.file_name, pos.line_number, - token.comment); - xgettext_current_source_encoding = xgettext_global_source_encoding; + { + xgettext_current_source_encoding = po_charset_utf8; + arglist_parser_remember (argparser, arg, string, + inner_context, + pos.file_name, pos.line_number, + token.comment); + xgettext_current_source_encoding = xgettext_global_source_encoding; + } } drop_reference (token.comment); next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-desktop.c b/gettext-tools/src/x-desktop.c index f0987918d..fc3d7e1fa 100644 --- a/gettext-tools/src/x-desktop.c +++ b/gettext-tools/src/x-desktop.c @@ -125,9 +125,9 @@ extract_desktop_handle_pair (struct desktop_reader_ty *reader, bool is_list = (bool) keyword_value; remember_a_message (extract_reader->mlp, NULL, - desktop_unescape_string (value, is_list), + desktop_unescape_string (value, is_list), false, null_context, key_pos, - NULL, savable_comment); + NULL, savable_comment, false); } savable_comment_reset (); } diff --git a/gettext-tools/src/x-elisp.c b/gettext-tools/src/x-elisp.c index 75360eeed..3fff84f90 100644 --- a/gettext-tools/src/x-elisp.c +++ b/gettext-tools/src/x-elisp.c @@ -895,8 +895,9 @@ read_object (struct object *op, bool first_in_list, bool new_backquote_flag, pos.file_name = logical_file_name; pos.line_number = op->line_number_at_start; - remember_a_message (mlp, NULL, string_of_object (op), - null_context, &pos, NULL, savable_comment); + remember_a_message (mlp, NULL, string_of_object (op), false, + null_context, &pos, NULL, savable_comment, + false); } last_non_comment_line = line_number; return; diff --git a/gettext-tools/src/x-java.c b/gettext-tools/src/x-java.c index 8e8477d50..e019f4e5a 100644 --- a/gettext-tools/src/x-java.c +++ b/gettext-tools/src/x-java.c @@ -1217,16 +1217,18 @@ extract_parenthesized (message_list_ty *mlp, token_type_ty terminator, pos.file_name = logical_file_name; pos.line_number = token.line_number; - xgettext_current_source_encoding = po_charset_utf8; if (extract_all) - remember_a_message (mlp, NULL, string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, string, true, inner_context, + &pos, NULL, token.comment, true); else - arglist_parser_remember (argparser, arg, string, - inner_context, - pos.file_name, pos.line_number, - token.comment); - xgettext_current_source_encoding = xgettext_global_source_encoding; + { + xgettext_current_source_encoding = po_charset_utf8; + arglist_parser_remember (argparser, arg, string, + inner_context, + pos.file_name, pos.line_number, + token.comment); + xgettext_current_source_encoding = xgettext_global_source_encoding; + } } drop_reference (token.comment); next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-javascript.c b/gettext-tools/src/x-javascript.c index c2599dafe..0dea9c079 100644 --- a/gettext-tools/src/x-javascript.c +++ b/gettext-tools/src/x-javascript.c @@ -1518,16 +1518,18 @@ extract_balanced (message_list_ty *mlp, pos.file_name = logical_file_name; pos.line_number = token.line_number; - xgettext_current_source_encoding = po_charset_utf8; if (extract_all) - remember_a_message (mlp, NULL, string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, string, true, inner_context, + &pos, NULL, token.comment, true); else - arglist_parser_remember (argparser, arg, string, - inner_context, - pos.file_name, pos.line_number, - token.comment); - xgettext_current_source_encoding = xgettext_current_file_source_encoding; + { + xgettext_current_source_encoding = po_charset_utf8; + arglist_parser_remember (argparser, arg, string, + inner_context, + pos.file_name, pos.line_number, + token.comment); + xgettext_current_source_encoding = xgettext_current_file_source_encoding; + } } drop_reference (token.comment); next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-librep.c b/gettext-tools/src/x-librep.c index 4fbc30732..552e58beb 100644 --- a/gettext-tools/src/x-librep.c +++ b/gettext-tools/src/x-librep.c @@ -831,8 +831,9 @@ read_object (struct object *op, flag_context_ty outer_context) pos.file_name = logical_file_name; pos.line_number = op->line_number_at_start; - remember_a_message (mlp, NULL, string_of_object (op), - null_context, &pos, NULL, savable_comment); + remember_a_message (mlp, NULL, string_of_object (op), false, + null_context, &pos, NULL, savable_comment, + false); } last_non_comment_line = line_number; return; diff --git a/gettext-tools/src/x-lisp.c b/gettext-tools/src/x-lisp.c index ec6fadf49..0680c17dc 100644 --- a/gettext-tools/src/x-lisp.c +++ b/gettext-tools/src/x-lisp.c @@ -1191,9 +1191,9 @@ read_object (struct object *op, flag_context_ty outer_context) pos.file_name = logical_file_name; pos.line_number = op->line_number_at_start; - remember_a_message (mlp, NULL, string_of_object (op), + remember_a_message (mlp, NULL, string_of_object (op), false, null_context, &pos, - NULL, savable_comment); + NULL, savable_comment, false); } last_non_comment_line = line_number; return; diff --git a/gettext-tools/src/x-lua.c b/gettext-tools/src/x-lua.c index 0d5ce6dc1..f45d3e029 100644 --- a/gettext-tools/src/x-lua.c +++ b/gettext-tools/src/x-lua.c @@ -1145,8 +1145,8 @@ extract_balanced (message_list_ty *mlp, token_type_ty delim, pos.line_number = token.line_number; if (extract_all) - remember_a_message (mlp, NULL, token.string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, token.string, false, inner_context, + &pos, NULL, token.comment, false); else { /* A string immediately after a symbol means a function call. */ diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index 59b8df055..f2b4365f0 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -1587,10 +1587,9 @@ extract_variable (message_list_ty *mlp, token_ty *tp, int first) pos.line_number = line_number; pos.file_name = logical_file_name; - xgettext_current_source_encoding = po_charset_utf8; remember_a_message (mlp, NULL, xstrdup (t1->string), - context, &pos, NULL, savable_comment); - xgettext_current_source_encoding = xgettext_global_source_encoding; + true, context, &pos, NULL, + savable_comment, true); free_token (t2); free_token (t1); } @@ -2017,10 +2016,8 @@ interpolate_keywords (message_list_ty *mlp, const char *string, int lineno) buffer[bufpos] = '\0'; token.string = xstrdup (buffer); extract_quotelike_pass3 (&token, EXIT_FAILURE); - xgettext_current_source_encoding = po_charset_utf8; - remember_a_message (mlp, NULL, token.string, context, &pos, - NULL, savable_comment); - xgettext_current_source_encoding = xgettext_global_source_encoding; + remember_a_message (mlp, NULL, token.string, true, context, &pos, + NULL, savable_comment, true); /* FALLTHROUGH */ default: context = null_context; @@ -3317,10 +3314,8 @@ extract_balanced (message_list_ty *mlp, pos.file_name = logical_file_name; pos.line_number = tp->line_number; - xgettext_current_source_encoding = po_charset_utf8; - remember_a_message (mlp, NULL, string, inner_context, &pos, - NULL, tp->comment); - xgettext_current_source_encoding = xgettext_global_source_encoding; + remember_a_message (mlp, NULL, string, true, inner_context, &pos, + NULL, tp->comment, true); } else if (!skip_until_comma) { diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c index 211943247..1c5b1092f 100644 --- a/gettext-tools/src/x-php.c +++ b/gettext-tools/src/x-php.c @@ -1531,8 +1531,8 @@ extract_balanced (message_list_ty *mlp, pos.line_number = token.line_number; if (extract_all) - remember_a_message (mlp, NULL, token.string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, token.string, false, inner_context, + &pos, NULL, token.comment, false); else arglist_parser_remember (argparser, arg, token.string, inner_context, diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index 50aa587c1..19f584678 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -1633,16 +1633,18 @@ extract_balanced (message_list_ty *mlp, pos.file_name = logical_file_name; pos.line_number = token.line_number; - xgettext_current_source_encoding = po_charset_utf8; if (extract_all) - remember_a_message (mlp, NULL, string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, string, true, inner_context, + &pos, NULL, token.comment, true); else - arglist_parser_remember (argparser, arg, string, - inner_context, - pos.file_name, pos.line_number, - token.comment); - xgettext_current_source_encoding = xgettext_current_file_source_encoding; + { + xgettext_current_source_encoding = po_charset_utf8; + arglist_parser_remember (argparser, arg, string, + inner_context, + pos.file_name, pos.line_number, + token.comment); + xgettext_current_source_encoding = xgettext_current_file_source_encoding; + } } drop_reference (token.comment); next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-rst.c b/gettext-tools/src/x-rst.c index 860b43bef..d9705e11b 100644 --- a/gettext-tools/src/x-rst.c +++ b/gettext-tools/src/x-rst.c @@ -228,7 +228,8 @@ extract_rst (FILE *f, pos.file_name = location; pos.line_number = (size_t)(-1); - remember_a_message (mlp, NULL, msgid, null_context, &pos, NULL, NULL); + remember_a_message (mlp, NULL, msgid, false, null_context, &pos, NULL, + NULL, false); /* Here c is the last read character: EOF or '\n'. */ if (c == EOF) @@ -634,8 +635,8 @@ extract_rsj (FILE *f, pos.file_name = location; pos.line_number = (size_t)(-1); - remember_a_message (mlp, NULL, msgid, null_context, &pos, - NULL, NULL); + remember_a_message (mlp, NULL, msgid, true, null_context, + &pos, NULL, NULL, false); /* Parse a comma. */ c = phase2_getc (); diff --git a/gettext-tools/src/x-scheme.c b/gettext-tools/src/x-scheme.c index 262d650a4..2856b6a80 100644 --- a/gettext-tools/src/x-scheme.c +++ b/gettext-tools/src/x-scheme.c @@ -1323,8 +1323,9 @@ read_object (struct object *op, flag_context_ty outer_context) pos.file_name = logical_file_name; pos.line_number = op->line_number_at_start; - remember_a_message (mlp, NULL, string_of_object (op), - null_context, &pos, NULL, savable_comment); + remember_a_message (mlp, NULL, string_of_object (op), false, + null_context, &pos, NULL, savable_comment, + false); } last_non_comment_line = line_number; return; diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index a072f03a6..75f170816 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -1092,7 +1092,8 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) string.chars[string.charcount++] = (unsigned char) c; } remember_a_message (mlp, NULL, string_of_token (&string), - context, &pos, NULL, savable_comment); + false, context, &pos, NULL, + savable_comment, false); free_token (&string); error_with_progname = false; @@ -1257,8 +1258,9 @@ read_command (int looking_for, flag_context_ty outer_context) pos.file_name = logical_file_name; pos.line_number = inner.line_number_at_start; - remember_a_message (mlp, NULL, string_of_word (&inner), - inner_context, &pos, NULL, savable_comment); + remember_a_message (mlp, NULL, string_of_word (&inner), false, + inner_context, &pos, NULL, savable_comment, + false); } } diff --git a/gettext-tools/src/x-smalltalk.c b/gettext-tools/src/x-smalltalk.c index a2c6bd658..73c2b038d 100644 --- a/gettext-tools/src/x-smalltalk.c +++ b/gettext-tools/src/x-smalltalk.c @@ -535,8 +535,9 @@ extract_smalltalk (FILE *f, lex_pos_ty pos; pos.file_name = logical_file_name; pos.line_number = token.line_number; - remember_a_message (mlp, NULL, token.string, null_context, - &pos, NULL, savable_comment); + remember_a_message (mlp, NULL, token.string, false, + null_context, &pos, NULL, savable_comment, + false); state = 0; break; } @@ -545,9 +546,9 @@ extract_smalltalk (FILE *f, lex_pos_ty pos; pos.file_name = logical_file_name; pos.line_number = token.line_number; - plural_mp = remember_a_message (mlp, NULL, token.string, + plural_mp = remember_a_message (mlp, NULL, token.string, false, null_context, &pos, - NULL, savable_comment); + NULL, savable_comment, false); state = 4; break; } @@ -557,9 +558,9 @@ extract_smalltalk (FILE *f, pos.file_name = logical_file_name; pos.line_number = token.line_number; if (plural_mp != NULL) - remember_a_message_plural (plural_mp, token.string, + remember_a_message_plural (plural_mp, token.string, false, null_context, &pos, - savable_comment); + savable_comment, false); state = 0; break; } diff --git a/gettext-tools/src/x-tcl.c b/gettext-tools/src/x-tcl.c index 78784e9aa..43704c7d0 100644 --- a/gettext-tools/src/x-tcl.c +++ b/gettext-tools/src/x-tcl.c @@ -887,9 +887,9 @@ read_command (int looking_for, flag_context_ty outer_context) pos.file_name = logical_file_name; pos.line_number = inner.line_number_at_start; - remember_a_message (mlp, NULL, string_of_word (&inner), + remember_a_message (mlp, NULL, string_of_word (&inner), false, inner_context, &pos, - NULL, savable_comment); + NULL, savable_comment, false); } } diff --git a/gettext-tools/src/x-vala.c b/gettext-tools/src/x-vala.c index f765f5222..c0347693e 100644 --- a/gettext-tools/src/x-vala.c +++ b/gettext-tools/src/x-vala.c @@ -1330,12 +1330,12 @@ extract_balanced (message_list_ty *mlp, token_type_ty delim, pos.file_name = logical_file_name; pos.line_number = token.line_number; - xgettext_current_source_encoding = po_charset_utf8; if (extract_all) - remember_a_message (mlp, NULL, string, inner_context, - &pos, NULL, token.comment); + remember_a_message (mlp, NULL, string, true, inner_context, + &pos, NULL, token.comment, false); else { + xgettext_current_source_encoding = po_charset_utf8; /* A string immediately after a symbol means a function call. */ if (state) { @@ -1351,8 +1351,8 @@ extract_balanced (message_list_ty *mlp, token_type_ty delim, arglist_parser_remember (argparser, arg, string, inner_context, pos.file_name, pos.line_number, token.comment); + xgettext_current_source_encoding = xgettext_global_source_encoding; } - xgettext_current_source_encoding = xgettext_global_source_encoding; } drop_reference (token.comment); next_context_iter = null_context_list_iterator; diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index 0392718a8..e27ba12d0 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -681,8 +681,8 @@ extract_parenthesized (message_list_ty *mlp, { /* Seen an msgid. */ plural_mp = remember_a_message (mlp, NULL, token.string, - inner_context, &pos, - NULL, token.comment); + false, inner_context, &pos, + NULL, token.comment, false); plural_state = 1; state = 2; } @@ -690,9 +690,9 @@ extract_parenthesized (message_list_ty *mlp, { /* Seen an msgid_plural. */ if (plural_mp != NULL) - remember_a_message_plural (plural_mp, token.string, + remember_a_message_plural (plural_mp, token.string, false, inner_context, &pos, - token.comment); + token.comment, false); state = 0; } drop_reference (token.comment); diff --git a/gettext-tools/src/xg-arglist-parser.c b/gettext-tools/src/xg-arglist-parser.c index bb97b41ef..f15eee713 100644 --- a/gettext-tools/src/xg-arglist-parser.c +++ b/gettext-tools/src/xg-arglist-parser.c @@ -478,14 +478,14 @@ arglist_parser_done (struct arglist_parser *ap, int argnum) } mp = remember_a_message (ap->mlp, best_cp->msgctxt, best_cp->msgid, - msgid_context, + false, msgid_context, &best_cp->msgid_pos, - NULL, best_cp->msgid_comment); + NULL, best_cp->msgid_comment, false); if (mp != NULL && best_cp->msgid_plural != NULL) - remember_a_message_plural (mp, best_cp->msgid_plural, + remember_a_message_plural (mp, best_cp->msgid_plural, false, msgid_plural_context, &best_cp->msgid_plural_pos, - NULL); + NULL, false); } if (best_cp->xcomments.nitems > 0) diff --git a/gettext-tools/src/xg-message.c b/gettext-tools/src/xg-message.c index caf58cf4d..b1938407c 100644 --- a/gettext-tools/src/xg-message.c +++ b/gettext-tools/src/xg-message.c @@ -136,9 +136,9 @@ and a mapping instead of a tuple for the arguments.\n"), message_ty * remember_a_message (message_list_ty *mlp, char *msgctxt, char *msgid, - flag_context_ty context, lex_pos_ty *pos, + bool is_utf8, flag_context_ty context, lex_pos_ty *pos, const char *extracted_comment, - refcounted_string_list_ty *comment) + refcounted_string_list_ty *comment, bool comment_is_utf8) { enum is_format is_format[NFORMATS]; struct argument_range range; @@ -173,9 +173,12 @@ remember_a_message (message_list_ty *mlp, char *msgctxt, char *msgid, for (i = 0; i < NSYNTAXCHECKS; i++) do_syntax_check[i] = undecided; - if (msgctxt != NULL) - CONVERT_STRING (msgctxt, lc_string); - CONVERT_STRING (msgid, lc_string); + if (!is_utf8) + { + if (msgctxt != NULL) + CONVERT_STRING (msgctxt, lc_string); + CONVERT_STRING (msgid, lc_string); + } if (msgctxt == NULL && msgid[0] == '\0' && !xgettext_omit_header) { @@ -275,7 +278,8 @@ meta information, not the empty string.\n"))); if (s == NULL) break; - CONVERT_STRING (s, lc_comment); + if (!comment_is_utf8) + CONVERT_STRING (s, lc_comment); /* To reduce the possibility of unwanted matches we do a two step match: the line must contain 'xgettext:' and one of @@ -479,9 +483,10 @@ meta information, not the empty string.\n"))); void -remember_a_message_plural (message_ty *mp, char *string, +remember_a_message_plural (message_ty *mp, char *string, bool is_utf8, flag_context_ty context, lex_pos_ty *pos, - refcounted_string_list_ty *comment) + refcounted_string_list_ty *comment, + bool comment_is_utf8) { char *msgid_plural; char *msgstr1; @@ -493,7 +498,8 @@ remember_a_message_plural (message_ty *mp, char *string, savable_comment_to_xgettext_comment (comment); - CONVERT_STRING (msgid_plural, lc_string); + if (!is_utf8) + CONVERT_STRING (msgid_plural, lc_string); /* See if the message is already a plural message. */ if (mp->msgid_plural == NULL) diff --git a/gettext-tools/src/xg-message.h b/gettext-tools/src/xg-message.h index 621cbbca1..83ba4a6a4 100644 --- a/gettext-tools/src/xg-message.h +++ b/gettext-tools/src/xg-message.h @@ -17,6 +17,8 @@ #ifndef _XGETTEXT_MESSAGE_H #define _XGETTEXT_MESSAGE_H +#include + #include "message.h" #include "pos.h" #include "rc-str-list.h" @@ -30,36 +32,46 @@ extern "C" { /* Add a message to the list of extracted messages. - msgctxt must be either NULL or a malloc()ed string; its ownership is passed + MSGCTXT must be either NULL or a malloc()ed string; its ownership is passed to the callee. MSGID must be a malloc()ed string; its ownership is passed to the callee. + IS_UTF8 must be true if MSGCTXT and MSGID have already been converted to + UTF-8. POS->file_name must be allocated with indefinite extent. EXTRACTED_COMMENT is a comment that needs to be copied into the POT file, or NULL. COMMENT may be savable_comment, or it may be a saved copy of savable_comment (then add_reference must be used when saving it, and drop_reference while dropping it). Clear savable_comment. + COMMENT_IS_UTF8 must be true if COMMENT has already been converted to UTF-8. Return the new or found message, or NULL if the message is excluded. */ extern message_ty *remember_a_message (message_list_ty *mlp, char *msgctxt, char *msgid, + bool is_utf8, flag_context_ty context, lex_pos_ty *pos, const char *extracted_comment, - refcounted_string_list_ty *comment); + refcounted_string_list_ty *comment, + bool comment_is_utf8); /* Add an msgid_plural to a message previously returned by remember_a_message. STRING must be a malloc()ed string; its ownership is passed to the callee. + IS_UTF8 must be true if STRING has already been converted to UTF-8. POS->file_name must be allocated with indefinite extent. COMMENT may be savable_comment, or it may be a saved copy of savable_comment (then add_reference must be used when saving it, and drop_reference while - dropping it). Clear savable_comment. */ + dropping it). Clear savable_comment. + COMMENT_IS_UTF8 must be true if COMMENT has already been converted to UTF-8. + */ extern void remember_a_message_plural (message_ty *mp, char *string, + bool is_utf8, flag_context_ty context, lex_pos_ty *pos, - refcounted_string_list_ty *comment); + refcounted_string_list_ty *comment, + bool comment_is_utf8); #ifdef __cplusplus diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 9c9c03841..63f7c3f7c 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -1795,8 +1795,9 @@ xgettext_its_extract_callback (message_list_ty *mlp, message = remember_a_message (mlp, msgctxt == NULL ? NULL : xstrdup (msgctxt), xstrdup (msgid), + false, null_context, pos, - extracted_comment, NULL); + extracted_comment, NULL, false); if (add_itstool_comments) {