* gettext-tools/src/xg-arglist-parser.h: Include xg-mixed-string.h.
(struct partial_call): Change type of fields msgctxt, msgid, msgid_plural to
'mixed_string_ty *'.
(arglist_parser_remember, arglist_parser_remember_msgctxt): Take a
'mixed_string_ty *' argument instead of a 'char *' argument.
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_clone): Update
accordingly.
(arglist_parser_remember, arglist_parser_remember_msgctxt): Take a
'mixed_string_ty *' argument.
(arglist_parser_done): Convert the mixed_string to UTF-8 encoded 'char *' here.
This is where from_current_source_encoding gets invoked now: immediately before
invoking remember_a_message, that is, only when we really need to know the
--from-source encoding.
* gettext-tools/src/x-c.c (extract_parenthesized): Pass the mixed_string to
arglist_parser_remember. Don't set xgettext_current_source_encoding around
arglist_parser_done calls.
* gettext-tools/src/x-csharp.c (extract_parenthesized): Likewise.
* gettext-tools/src/x-java.c (extract_parenthesized): Likewise.
* gettext-tools/src/x-javascript.c (extract_balanced): Likewise.
* gettext-tools/src/x-python.c (extract_balanced): Likewise.
* gettext-tools/src/x-vala.c (extract_balanced): Likewise.
* gettext-tools/src/x-lisp.c: Include xg-mixed-string.h.
(read_object): Convert the string to a mixed_string_ty before passing it to
arglist_parser_remember.
* gettext-tools/src/x-elisp.c: Likewise.
* gettext-tools/src/x-librep.c: Likewise.
* gettext-tools/src/x-scheme.c: Likewise.
* gettext-tools/src/x-awk.c: Include xg-mixed-string.h.
(extract_parenthesized): Convert the string to a mixed_string_ty before passing
it to arglist_parser_remember.
* gettext-tools/src/x-lua.c: Include xg-mixed-string.h.
(extract_balanced): Convert the string to a mixed_string_ty before passing it to
arglist_parser_remember.
* gettext-tools/src/x-php.c: Include xg-mixed-string.h.
(extract_balanced): Convert the string to a mixed_string_ty before passing it to
arglist_parser_remember.
* gettext-tools/src/x-sh.c: Include xg-mixed-string.h.
(read_command): Convert the string to a mixed_string_ty before passing it to
arglist_parser_remember.
* gettext-tools/src/x-tcl.c: Include xg-mixed-string.h.
(read_command): Convert the string to a mixed_string_ty before passing it to
arglist_parser_remember.
* gettext-tools/src/x-perl.c (extract_balanced): Convert the string to a
mixed_string_ty before passing it to arglist_parser_remember. Don't set
xgettext_current_source_encoding around arglist_parser_done calls.
#include "message.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
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, pos.line_number,
- savable_comment);
+ {
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (token.string, lc_string,
+ pos.file_name, pos.line_number);
+ free (token.string);
+ arglist_parser_remember (argparser, arg, ms,
+ inner_context,
+ pos.file_name, pos.line_number,
+ savable_comment);
+ }
}
next_is_argument = false;
next_context_iter = null_context_list_iterator;
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding =
- xgettext_global_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
continue;
case xgettext_token_type_rparen:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return false;
case xgettext_token_type_comma:
case xgettext_token_type_string_literal:
{
- char *string = mixed_string_contents (token.mixed_string);
- mixed_string_free (token.mixed_string);
if (extract_all)
- remember_a_message (mlp, NULL, string, true, inner_context,
- &token.pos, NULL, token.comment, false);
+ {
+ char *string = mixed_string_contents (token.mixed_string);
+ mixed_string_free (token.mixed_string);
+ remember_a_message (mlp, NULL, string, true, inner_context,
+ &token.pos, NULL, token.comment, false);
+ }
else
{
xgettext_current_source_encoding = po_charset_utf8;
- arglist_parser_remember (argparser, arg, string,
+ arglist_parser_remember (argparser, arg, token.mixed_string,
inner_context,
token.pos.file_name,
token.pos.line_number,
continue;
case xgettext_token_type_eof:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
default:
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rparen:
if (terminator == token_type_rparen)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return false;
}
if (terminator == token_type_rbrace)
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rbrace:
if (terminator == token_type_rbrace)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return false;
}
if (terminator == token_type_rparen)
case token_type_string_literal:
{
- char *string;
lex_pos_ty pos;
- string = mixed_string_contents (token.mixed_string);
- mixed_string_free (token.mixed_string);
-
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
if (extract_all)
- remember_a_message (mlp, NULL, string, true, inner_context,
- &pos, NULL, token.comment, true);
+ {
+ char *string = mixed_string_contents (token.mixed_string);
+ mixed_string_free (token.mixed_string);
+ remember_a_message (mlp, NULL, string, true, inner_context,
+ &pos, NULL, token.comment, true);
+ }
else
{
xgettext_current_source_encoding = po_charset_utf8;
- arglist_parser_remember (argparser, arg, string,
+ arglist_parser_remember (argparser, arg, token.mixed_string,
inner_context,
pos.file_name, pos.line_number,
token.comment);
continue;
case token_type_eof:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
case token_type_dot:
#include "message.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
{
/* These are the argument positions. */
if (argparser != NULL && inner.type == t_string)
- arglist_parser_remember (argparser, arg,
- string_of_object (&inner),
- inner_context,
- logical_file_name,
- inner.line_number_at_start,
- savable_comment);
+ {
+ char *s = string_of_object (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
+ arglist_parser_remember (argparser, arg, ms,
+ inner_context,
+ logical_file_name,
+ inner.line_number_at_start,
+ savable_comment);
+ }
}
free_object (&inner);
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rparen:
if (terminator == token_type_rparen)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return false;
}
if (terminator == token_type_rbrace)
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rbrace:
if (terminator == token_type_rbrace)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return false;
}
if (terminator == token_type_rparen)
case token_type_string_literal:
{
- char *string;
lex_pos_ty pos;
- string = mixed_string_contents (token.mixed_string);
- mixed_string_free (token.mixed_string);
-
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
if (extract_all)
- remember_a_message (mlp, NULL, string, true, inner_context,
- &pos, NULL, token.comment, true);
+ {
+ char *string = mixed_string_contents (token.mixed_string);
+ mixed_string_free (token.mixed_string);
+ remember_a_message (mlp, NULL, string, true, inner_context,
+ &pos, NULL, token.comment, true);
+ }
else
{
xgettext_current_source_encoding = po_charset_utf8;
- arglist_parser_remember (argparser, arg, string,
+ arglist_parser_remember (argparser, arg, token.mixed_string,
inner_context,
pos.file_name, pos.line_number,
token.comment);
continue;
case token_type_eof:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
case token_type_dot:
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rparen:
if (delim == token_type_rparen || delim == token_type_eof)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return false;
}
next_context_iter = null_context_list_iterator;
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rbracket:
if (delim == token_type_rbracket || delim == token_type_eof)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return false;
}
next_context_iter = null_context_list_iterator;
case token_type_string:
{
- char *string;
lex_pos_ty pos;
- string = mixed_string_contents (token.mixed_string);
- mixed_string_free (token.mixed_string);
-
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
if (extract_all)
- remember_a_message (mlp, NULL, string, true, inner_context,
- &pos, NULL, token.comment, true);
+ {
+ char *string = mixed_string_contents (token.mixed_string);
+ mixed_string_free (token.mixed_string);
+ remember_a_message (mlp, NULL, string, true, inner_context,
+ &pos, NULL, token.comment, true);
+ }
else
{
xgettext_current_source_encoding = po_charset_utf8;
- arglist_parser_remember (argparser, arg, string,
+ arglist_parser_remember (argparser, arg, token.mixed_string,
inner_context,
pos.file_name, pos.line_number,
token.comment);
continue;
case token_type_eof:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return true;
case token_type_keyword:
#include "message.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
{
/* These are the argument positions. */
if (argparser != NULL && inner.type == t_string)
- arglist_parser_remember (argparser, arg,
- string_of_object (&inner),
- inner_context,
- logical_file_name,
- inner.line_number_at_start,
- savable_comment);
+ {
+ char *s = string_of_object (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
+ arglist_parser_remember (argparser, arg, ms,
+ inner_context,
+ logical_file_name,
+ inner.line_number_at_start,
+ savable_comment);
+ }
}
free_object (&inner);
#include "message.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
{
/* These are the argument positions. */
if (argparser != NULL && inner.type == t_string)
- arglist_parser_remember (argparser, arg,
- string_of_object (&inner),
- inner_context,
- logical_file_name,
- inner.line_number_at_start,
- savable_comment);
+ {
+ char *s = string_of_object (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
+ arglist_parser_remember (argparser, arg, ms,
+ inner_context,
+ logical_file_name,
+ inner.line_number_at_start,
+ savable_comment);
+ }
}
free_object (&inner);
#include "rc-str-list.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
&pos, NULL, token.comment, false);
else
{
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (token.string, lc_string,
+ pos.file_name, pos.line_number);
+ free (token.string);
/* A string immediately after a symbol means a function call. */
if (state)
{
struct arglist_parser *tmp_argparser;
tmp_argparser = arglist_parser_alloc (mlp, next_shapes);
- arglist_parser_remember (tmp_argparser, 1, token.string,
+ arglist_parser_remember (tmp_argparser, 1, ms,
inner_context, pos.file_name,
pos.line_number, token.comment);
arglist_parser_done (tmp_argparser, 1);
}
else
- arglist_parser_remember (argparser, arg, token.string,
+ arglist_parser_remember (argparser, arg, ms,
inner_context, pos.file_name,
pos.line_number, token.comment);
}
#include "xgettext.h"
#include "xg-pos.h"
#include "xg-encoding.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
if (delim == tp->type)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
if (next_argparser != NULL)
free (next_argparser);
#if DEBUG_PERL
if (comma_delim && tp->type == token_type_comma)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
if (next_argparser != NULL)
free (next_argparser);
#if DEBUG_PERL
inner_context, next_context_iter,
1, next_argparser))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
inner_context, next_context_iter,
1, next_argparser))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
next_is_argument = false;
inner_context, next_context_iter,
arg, arglist_parser_clone (argparser)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
if (next_argparser != NULL)
free (next_argparser);
free_token (tp);
if (arglist_parser_decidedp (argparser, arg))
{
/* We have missed the argument. */
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
argparser = arglist_parser_alloc (mlp, NULL);
arg = 0;
}
if (must_collect)
{
char *string = collect_message (mlp, tp, EXIT_FAILURE);
-
+ mixed_string_ty *ms =
+ mixed_string_alloc_utf8 (string, lc_string,
+ logical_file_name, tp->line_number);
+ free (string);
xgettext_current_source_encoding = po_charset_utf8;
- arglist_parser_remember (argparser, arg,
- string, inner_context,
+ arglist_parser_remember (argparser, arg, ms, inner_context,
logical_file_name, tp->line_number,
tp->comment);
xgettext_current_source_encoding = xgettext_global_source_encoding;
if (arglist_parser_decidedp (argparser, arg))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
argparser = arglist_parser_alloc (mlp, NULL);
}
fprintf (stderr, "%s:%d: type EOF (%d)\n",
logical_file_name, tp->line_number, nesting_level);
#endif
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
if (next_argparser != NULL)
free (next_argparser);
next_argparser = NULL;
null_context, null_context_list_iterator,
1, arglist_parser_alloc (mlp, NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
if (next_argparser != NULL)
free (next_argparser);
free_token (tp);
null_context, null_context_list_iterator,
1, arglist_parser_alloc (mlp, NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
if (next_argparser != NULL)
free (next_argparser);
free_token (tp);
#endif
/* The ultimate sign. */
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
argparser = arglist_parser_alloc (mlp, NULL);
/* FIXME: Instead of resetting outer_context here, it may be better
#include "rc-str-list.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
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, pos.line_number,
- token.comment);
+ {
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (token.string, lc_string,
+ pos.file_name, pos.line_number);
+ free (token.string);
+ arglist_parser_remember (argparser, arg, ms, inner_context,
+ pos.file_name, pos.line_number,
+ token.comment);
+ }
drop_reference (token.comment);
}
next_context_iter = null_context_list_iterator;
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rparen:
if (delim == token_type_rparen || delim == token_type_eof)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return false;
}
next_context_iter = null_context_list_iterator;
null_context, null_context_list_iterator,
arglist_parser_alloc (mlp, NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rbracket:
if (delim == token_type_rbracket || delim == token_type_eof)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return false;
}
next_context_iter = null_context_list_iterator;
case token_type_string:
{
- char *string;
lex_pos_ty pos;
- string = mixed_string_contents (token.mixed_string);
- mixed_string_free (token.mixed_string);
-
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
if (extract_all)
- remember_a_message (mlp, NULL, string, true, inner_context,
- &pos, NULL, token.comment, true);
+ {
+ char *string = mixed_string_contents (token.mixed_string);
+ mixed_string_free (token.mixed_string);
+ remember_a_message (mlp, NULL, string, true, inner_context,
+ &pos, NULL, token.comment, true);
+ }
else
{
xgettext_current_source_encoding = po_charset_utf8;
- arglist_parser_remember (argparser, arg, string,
+ arglist_parser_remember (argparser, arg, token.mixed_string,
inner_context,
pos.file_name, pos.line_number,
token.comment);
continue;
case token_type_eof:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_current_file_source_encoding;
return true;
case token_type_plus:
#include "message.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
{
/* These are the argument positions. */
if (argparser != NULL && inner.type == t_string)
- arglist_parser_remember (argparser, arg,
- string_of_object (&inner),
- inner_context,
- logical_file_name,
- inner.line_number_at_start,
- savable_comment);
+ {
+ char *s = string_of_object (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
+ arglist_parser_remember (argparser, arg, ms,
+ inner_context,
+ logical_file_name,
+ inner.line_number_at_start,
+ savable_comment);
+ }
}
free_object (&inner);
#include "message.h"
#include "xgettext.h"
#include "xg-pos.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
&& memcmp (argparser->keyword, "ngettext", 8) == 0));
if (accepts_context && argparser->next_is_msgctxt)
{
+ char *s = string_of_word (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
argparser->next_is_msgctxt = false;
- arglist_parser_remember_msgctxt (argparser,
- string_of_word (&inner),
+ arglist_parser_remember_msgctxt (argparser, ms,
inner_context,
logical_file_name,
inner.line_number_at_start);
&& (inner.token->charcount >= 10
&& memcmp (inner.token->chars, "--context=", 10) == 0))
{
+ char *s = substring_of_word (&inner, 10);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
argparser->next_is_msgctxt = false;
- arglist_parser_remember_msgctxt (argparser,
- substring_of_word (&inner, 10),
+ arglist_parser_remember_msgctxt (argparser, ms,
inner_context,
logical_file_name,
inner.line_number_at_start);
}
else
{
- arglist_parser_remember (argparser, arg,
- string_of_word (&inner),
+ char *s = string_of_word (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
+ arglist_parser_remember (argparser, arg, ms,
inner_context,
logical_file_name,
inner.line_number_at_start,
#include "xgettext.h"
#include "xg-pos.h"
#include "xg-encoding.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
#include "xg-arglist-parser.h"
{
/* These are the argument positions. */
if (argparser != NULL && inner.type == t_string)
- arglist_parser_remember (argparser, arg,
- string_of_word (&inner),
- inner_context,
- logical_file_name,
- inner.line_number_at_start,
- savable_comment);
+ {
+ char *s = string_of_word (&inner);
+ mixed_string_ty *ms =
+ mixed_string_alloc_simple (s, lc_string,
+ logical_file_name,
+ inner.line_number_at_start);
+ free (s);
+ arglist_parser_remember (argparser, arg, ms,
+ inner_context,
+ logical_file_name,
+ inner.line_number_at_start,
+ savable_comment);
+ }
}
free_word (&inner);
arglist_parser_alloc (mlp,
state ? next_shapes : NULL)))
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
}
next_context_iter = null_context_list_iterator;
case token_type_rparen:
if (delim == token_type_rparen || delim == token_type_eof)
{
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return false;
}
continue;
case token_type_eof:
- xgettext_current_source_encoding = po_charset_utf8;
arglist_parser_done (argparser, arg);
- xgettext_current_source_encoding = xgettext_global_source_encoding;
return true;
case token_type_string_literal:
{
- char *string;
lex_pos_ty pos;
- string = mixed_string_contents (token.mixed_string);
- mixed_string_free (token.mixed_string);
-
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
if (extract_all)
- remember_a_message (mlp, NULL, string, true, inner_context,
- &pos, NULL, token.comment, false);
+ {
+ char *string = mixed_string_contents (token.mixed_string);
+ mixed_string_free (token.mixed_string);
+ 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)
{
struct arglist_parser *tmp_argparser;
tmp_argparser = arglist_parser_alloc (mlp, next_shapes);
- arglist_parser_remember (tmp_argparser, 1, string,
+ xgettext_current_source_encoding = po_charset_utf8;
+ arglist_parser_remember (tmp_argparser, 1, token.mixed_string,
inner_context, pos.file_name,
pos.line_number, token.comment);
+ xgettext_current_source_encoding = xgettext_global_source_encoding;
arglist_parser_done (tmp_argparser, 1);
}
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, token.mixed_string,
+ inner_context, pos.file_name,
+ pos.line_number, token.comment);
+ xgettext_current_source_encoding = xgettext_global_source_encoding;
+ }
}
}
drop_reference (token.comment);
ccp->argnum2_glib_context = cp->argnum2_glib_context;
ccp->argtotal = cp->argtotal;
ccp->xcomments = cp->xcomments;
- ccp->msgctxt = (cp->msgctxt != NULL ? xstrdup (cp->msgctxt) : NULL);
+ ccp->msgctxt =
+ (cp->msgctxt != NULL ? mixed_string_clone (cp->msgctxt) : NULL);
ccp->msgctxt_pos = cp->msgctxt_pos;
- ccp->msgid = (cp->msgid != NULL ? xstrdup (cp->msgid) : NULL);
+ ccp->msgid = (cp->msgid != NULL ? mixed_string_clone (cp->msgid) : NULL);
ccp->msgid_context = cp->msgid_context;
ccp->msgid_pos = cp->msgctxt_pos;
ccp->msgid_comment = add_reference (cp->msgid_comment);
ccp->msgid_plural =
- (cp->msgid_plural != NULL ? xstrdup (cp->msgid_plural) : NULL);
+ (cp->msgid_plural != NULL ? mixed_string_clone (cp->msgid_plural) : NULL);
ccp->msgid_plural_context = cp->msgid_plural_context;
ccp->msgid_plural_pos = cp->msgid_plural_pos;
}
void
arglist_parser_remember (struct arglist_parser *ap,
- int argnum, char *string,
+ int argnum, mixed_string_ty *string,
flag_context_ty context,
char *file_name, size_t line_number,
refcounted_string_list_ty *comment)
/* Note: There is a memory leak here: When string was stored but is later
not used by arglist_parser_done, we don't free it. */
if (!stored_string)
- free (string);
+ mixed_string_free (string);
}
void
arglist_parser_remember_msgctxt (struct arglist_parser *ap,
- char *string,
+ mixed_string_ty *string,
flag_context_ty context,
char *file_name, size_t line_number)
{
/* Note: There is a memory leak here: When string was stored but is later
not used by arglist_parser_done, we don't free it. */
if (!stored_string)
- free (string);
+ mixed_string_free (string);
}
{
/* best_cp indicates the best found complete call.
Now call remember_a_message. */
+ flag_context_ty msgid_context;
+ flag_context_ty msgid_plural_context;
+ char *best_msgctxt;
+ char *best_msgid;
+ char *best_msgid_plural;
message_ty *mp;
+ msgid_context = best_cp->msgid_context;
+ msgid_plural_context = best_cp->msgid_plural_context;
+
+ /* Special support for the 3-argument tr operator in Qt:
+ When --qt and --keyword=tr:1,1,2c,3t are specified, add to the
+ context the information that the argument is expected to be a
+ qt-plural-format. */
+ if (recognize_qt_formatstrings ()
+ && best_cp->msgid_plural == best_cp->msgid)
+ {
+ msgid_context.is_format3 = yes_according_to_context;
+ msgid_plural_context.is_format3 = yes_according_to_context;
+ }
+
+ best_msgctxt =
+ (best_cp->msgctxt != NULL
+ ? mixed_string_contents_free1 (best_cp->msgctxt)
+ : NULL);
+ best_msgid =
+ (best_cp->msgid != NULL
+ ? mixed_string_contents_free1 (best_cp->msgid)
+ : NULL);
+ best_msgid_plural =
+ (best_cp->msgid_plural != NULL
+ ? /* Special support for the 3-argument tr operator in Qt. */
+ (best_cp->msgid_plural == best_cp->msgid
+ ? xstrdup (best_msgid)
+ : mixed_string_contents_free1 (best_cp->msgid_plural))
+ : NULL);
+
/* Split strings in the GNOME glib syntax "msgctxt|msgid". */
if (best_cp->argnum1_glib_context || best_cp->argnum2_glib_context)
/* split_keywordspec should not allow the context to be specified
in two different ways. */
- if (best_cp->msgctxt != NULL)
+ if (best_msgctxt != NULL)
abort ();
if (best_cp->argnum1_glib_context)
{
- const char *separator = strchr (best_cp->msgid, '|');
+ const char *separator = strchr (best_msgid, '|');
if (separator == NULL)
{
}
else
{
- size_t ctxt_len = separator - best_cp->msgid;
+ size_t ctxt_len = separator - best_msgid;
char *ctxt = XNMALLOC (ctxt_len + 1, char);
- memcpy (ctxt, best_cp->msgid, ctxt_len);
+ memcpy (ctxt, best_msgid, ctxt_len);
ctxt[ctxt_len] = '\0';
- best_cp->msgctxt = ctxt;
- best_cp->msgid = xstrdup (separator + 1);
+ best_msgctxt = ctxt;
+ best_msgid = xstrdup (separator + 1);
}
}
- if (best_cp->msgid_plural != NULL && best_cp->argnum2_glib_context)
+ if (best_msgid_plural != NULL && best_cp->argnum2_glib_context)
{
- const char *separator = strchr (best_cp->msgid_plural, '|');
+ const char *separator = strchr (best_msgid_plural, '|');
if (separator == NULL)
{
}
else
{
- size_t ctxt_len = separator - best_cp->msgid_plural;
+ size_t ctxt_len = separator - best_msgid_plural;
char *ctxt = XNMALLOC (ctxt_len + 1, char);
- memcpy (ctxt, best_cp->msgid_plural, ctxt_len);
+ memcpy (ctxt, best_msgid_plural, ctxt_len);
ctxt[ctxt_len] = '\0';
- if (best_cp->msgctxt == NULL)
- best_cp->msgctxt = ctxt;
+ if (best_msgctxt == NULL)
+ best_msgctxt = ctxt;
else
{
- if (strcmp (ctxt, best_cp->msgctxt) != 0)
+ if (strcmp (ctxt, best_msgctxt) != 0)
{
error_with_progname = false;
error_at_line (0, 0,
}
free (ctxt);
}
- best_cp->msgid_plural = xstrdup (separator + 1);
+ best_msgid_plural = xstrdup (separator + 1);
}
}
- {
- flag_context_ty msgid_context = best_cp->msgid_context;
- flag_context_ty msgid_plural_context = best_cp->msgid_plural_context;
-
- /* Special support for the 3-argument tr operator in Qt:
- When --qt and --keyword=tr:1,1,2c,3t are specified, add to the
- context the information that the argument is expected to be a
- qt-plural-format. */
- if (recognize_qt_formatstrings ()
- && best_cp->msgid_plural == best_cp->msgid)
- {
- msgid_context.is_format3 = yes_according_to_context;
- msgid_plural_context.is_format3 = yes_according_to_context;
- }
-
- mp = remember_a_message (ap->mlp, best_cp->msgctxt, best_cp->msgid,
- false, msgid_context,
- &best_cp->msgid_pos,
- NULL, best_cp->msgid_comment, false);
- if (mp != NULL && best_cp->msgid_plural != NULL)
- remember_a_message_plural (mp, best_cp->msgid_plural, false,
- msgid_plural_context,
- &best_cp->msgid_plural_pos,
- NULL, false);
- }
+ mp = remember_a_message (ap->mlp, best_msgctxt, best_msgid, true,
+ msgid_context,
+ &best_cp->msgid_pos,
+ NULL, best_cp->msgid_comment, false);
+ if (mp != NULL && best_msgid_plural != NULL)
+ remember_a_message_plural (mp, best_msgid_plural, true,
+ msgid_plural_context,
+ &best_cp->msgid_plural_pos,
+ NULL, false);
if (best_cp->xcomments.nitems > 0)
{
#include "rc-str-list.h"
#include "str-list.h"
+#include "xg-mixed-string.h"
#include "xg-arglist-context.h"
#include "xg-arglist-callshape.h"
bool argnum2_glib_context; /* argument argnum2 has the syntax "ctxt|msgid" */
int argtotal; /* total number of arguments, 0 if unspecified */
string_list_ty xcomments; /* auto-extracted comments */
- char *msgctxt; /* context - owned string, or NULL */
+ mixed_string_ty *msgctxt; /* context - owned mixed_string, or NULL */
lex_pos_ty msgctxt_pos;
- char *msgid; /* msgid - owned string, or NULL */
+ mixed_string_ty *msgid; /* msgid - owned mixed_string, or NULL */
flag_context_ty msgid_context;
lex_pos_ty msgid_pos;
refcounted_string_list_ty *msgid_comment;
- char *msgid_plural; /* msgid_plural - owned string, or NULL */
+ mixed_string_ty *msgid_plural; /* msgid_plural - owned mixed_string, or NULL */
flag_context_ty msgid_plural_context;
lex_pos_ty msgid_plural_pos;
};
/* Clones an arglist_parser. */
extern struct arglist_parser * arglist_parser_clone (struct arglist_parser *ap);
/* Adds a string argument to an arglist_parser. ARGNUM must be > 0.
- STRING must be malloc()ed string; its ownership is passed to the callee.
+ STRING must be a mixed_string; its ownership is passed to the callee.
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. */
extern void arglist_parser_remember (struct arglist_parser *ap,
- int argnum, char *string,
+ int argnum, mixed_string_ty *string,
flag_context_ty context,
char *file_name, size_t line_number,
refcounted_string_list_ty *comment);
/* Adds a string argument as msgctxt to an arglist_parser, without incrementing
the current argument number.
- STRING must be malloc()ed string; its ownership is passed to the callee.
+ STRING must be a mixed_string; its ownership is passed to the callee.
FILE_NAME must be allocated with indefinite extent. */
extern void arglist_parser_remember_msgctxt (struct arglist_parser *ap,
- char *string,
+ mixed_string_ty *string,
flag_context_ty context,
char *file_name, size_t line_number);
/* Tests whether an arglist_parser has is not waiting for more arguments after