int argnum1 = 0;
int argnum2 = 0;
int argnumc = 0;
+ bool argnum1_glib_context = false;
+ bool argnum2_glib_context = false;
int argtotal = 0;
/* Start parsing from the end. */
while (p > spec)
{
if (isdigit ((unsigned char) p[-1])
- || ((p[-1] == 'c' || p[-1] == 't')
+ || ((p[-1] == 'c' || p[-1] == 'g' || p[-1] == 't')
&& p - 1 > spec && isdigit ((unsigned char) p[-2])))
{
bool contextp = (p[-1] == 'c');
+ bool glibp = (p[-1] == 'g');
bool totalp = (p[-1] == 't');
do
/* At most two normal arguments can be given. */
break;
argnum2 = argnum1;
+ argnum2_glib_context = argnum1_glib_context;
argnum1 = arg;
+ argnum1_glib_context = glibp;
}
p--;
if (argnum1 == 0 && argnum2 == 0)
/* At least one non-context argument must be given. */
break;
+ if (argnumc != 0
+ && (argnum1_glib_context || argnum2_glib_context))
+ /* Incompatible ways to specify the context. */
+ break;
*endp = p;
shapep->argnum1 = (argnum1 > 0 ? argnum1 : 1);
shapep->argnum2 = argnum2;
shapep->argnumc = argnumc;
+ shapep->argnum1_glib_context = argnum1_glib_context;
+ shapep->argnum2_glib_context = argnum2_glib_context;
shapep->argtotal = argtotal;
return;
}
shapep->argnum1 = 1;
shapep->argnum2 = 0;
shapep->argnumc = 0;
+ shapep->argnum1_glib_context = false;
+ shapep->argnum2_glib_context = false;
shapep->argtotal = 0;
}
if (old_shapes->shapes[i].argnum1 == shape->argnum1
&& old_shapes->shapes[i].argnum2 == shape->argnum2
&& old_shapes->shapes[i].argnumc == shape->argnumc
+ && old_shapes->shapes[i].argnum1_glib_context
+ == shape->argnum1_glib_context
+ && old_shapes->shapes[i].argnum2_glib_context
+ == shape->argnum2_glib_context
&& old_shapes->shapes[i].argtotal == shape->argtotal)
{
found = true;
ap->alternative[i].argnumc = shapes->shapes[i].argnumc;
ap->alternative[i].argnum1 = shapes->shapes[i].argnum1;
ap->alternative[i].argnum2 = shapes->shapes[i].argnum2;
+ ap->alternative[i].argnum1_glib_context =
+ shapes->shapes[i].argnum1_glib_context;
+ ap->alternative[i].argnum2_glib_context =
+ shapes->shapes[i].argnum2_glib_context;
ap->alternative[i].argtotal = shapes->shapes[i].argtotal;
ap->alternative[i].msgctxt = NULL;
ap->alternative[i].msgctxt_pos.file_name = NULL;
ccp->argnumc = cp->argnumc;
ccp->argnum1 = cp->argnum1;
ccp->argnum2 = cp->argnum2;
+ ccp->argnum1_glib_context = cp->argnum1_glib_context;
+ ccp->argnum2_glib_context = cp->argnum2_glib_context;
ccp->argtotal = cp->argtotal;
ccp->msgctxt = (cp->msgctxt != NULL ? xstrdup (cp->msgctxt) : NULL);
ccp->msgctxt_pos = cp->msgctxt_pos;
Now call remember_a_message. */
message_ty *mp;
+ /* 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)
+ abort ();
+ if (best_cp->argnum1_glib_context)
+ {
+ const char *separator = strchr (best_cp->msgid, '|');
+
+ if (separator == NULL)
+ {
+ error_with_progname = false;
+ error (0, 0,
+ _("%s:%d: warning: missing context for keyword '%.*s'"),
+ best_cp->msgid_pos.file_name, best_cp->msgid_pos.line_number,
+ ap->keyword_len, ap->keyword);
+ error_with_progname = true;
+ }
+ else
+ {
+ size_t ctxt_len = separator - best_cp->msgid;
+ char *ctxt = (char *) xmalloc (ctxt_len + 1);
+
+ memcpy (ctxt, best_cp->msgid, ctxt_len);
+ ctxt[ctxt_len] = '\0';
+ best_cp->msgctxt = ctxt;
+ best_cp->msgid = xstrdup (separator + 1);
+ }
+ }
+ if (best_cp->msgid_plural != NULL && best_cp->argnum2_glib_context)
+ {
+ const char *separator = strchr (best_cp->msgid_plural, '|');
+
+ if (separator == NULL)
+ {
+ error_with_progname = false;
+ error (0, 0,
+ _("%s:%d: warning: missing context for plural argument of keyword '%.*s'"),
+ best_cp->msgid_plural_pos.file_name,
+ best_cp->msgid_plural_pos.line_number,
+ ap->keyword_len, ap->keyword);
+ error_with_progname = true;
+ }
+ else
+ {
+ size_t ctxt_len = separator - best_cp->msgid_plural;
+ char *ctxt = (char *) xmalloc (ctxt_len + 1);
+
+ memcpy (ctxt, best_cp->msgid_plural, ctxt_len);
+ ctxt[ctxt_len] = '\0';
+ if (best_cp->msgctxt == NULL)
+ best_cp->msgctxt = ctxt;
+ else
+ {
+ if (strcmp (ctxt, best_cp->msgctxt) != 0)
+ {
+ error_with_progname = false;
+ error (0, 0,
+ _("%s:%d: context mismatch between singular and plural form"),
+ best_cp->msgid_plural_pos.file_name,
+ best_cp->msgid_plural_pos.line_number);
+ error_with_progname = true;
+ }
+ free (ctxt);
+ }
+ best_cp->msgid_plural = xstrdup (separator + 1);
+ }
+ }
+
mp = remember_a_message (ap->mlp, best_cp->msgctxt, best_cp->msgid,
best_cp->msgid_context,
&best_cp->msgid_pos,
/* xgettext common functions.
- Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2006 Free Software Foundation, Inc.
Written by Peter Miller <millerp@canb.auug.org.au>
and Bruno Haible <haible@clisp.cons.org>, 2001.
int argnum1; /* argument number to use for msgid */
int argnum2; /* argument number to use for msgid_plural */
int argnumc; /* argument number to use for msgctxt */
+ bool argnum1_glib_context; /* argument argnum1 has the syntax "ctxt|msgid" */
+ bool argnum2_glib_context; /* argument argnum2 has the syntax "ctxt|msgid" */
int argtotal; /* total number of arguments */
};
int argnumc; /* number of context argument, 0 when seen */
int argnum1; /* number of singular argument, 0 when seen */
int argnum2; /* number of plural argument, 0 when seen */
+ bool argnum1_glib_context; /* argument argnum1 has the syntax "ctxt|msgid" */
+ bool argnum2_glib_context; /* argument argnum2 has the syntax "ctxt|msgid" */
int argtotal; /* total number of arguments, 0 if unspecified */
char *msgctxt; /* context - owned string, or NULL */
lex_pos_ty msgctxt_pos;