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,
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;
{
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;
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;
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 ();
}
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;
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;
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;
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;
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;
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. */
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);
}
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;
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)
{
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,
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;
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)
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 ();
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;
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;
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);
}
}
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;
}
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;
}
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;
}
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);
}
}
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)
{
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;
{
/* 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;
}
{
/* 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);
}
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)
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;
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)
{
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
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;
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)
#ifndef _XGETTEXT_MESSAGE_H
#define _XGETTEXT_MESSAGE_H
+#include <stdbool.h>
+
#include "message.h"
#include "pos.h"
#include "rc-str-list.h"
/* 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
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)
{