+2001-11-03 Bruno Haible <haible@clisp.cons.org>
+
+ Add YCP plural form support.
+ * x-ycp.c (enum token_type_ty): New value token_type_comma.
+ (x_ycp_lex): Recognize comma.
+ (extract_ycp): Also recognize the _("singular","plural" pattern.
+
2001-11-01 Bruno Haible <haible@clisp.cons.org>
* msgfmt.c (check_plural_eval): Fix #if mistake.
token_type_eof,
token_type_lparen, /* ( */
token_type_rparen, /* ) */
+ token_type_comma, /* , */
token_type_i18n, /* _( */
token_type_string_literal, /* "abc" */
token_type_other /* number, symbol, misc. operator */
tp->type = token_type_rparen;
return;
+ case ',':
+ tp->type = token_type_comma;
+ return;
+
default:
/* We could carefully recognize each of the 2 and 3 character
operators, but it is not necessary, as we only need to recognize
{
message_list_ty *mlp = mdlp->item[0]->messages;
int state;
+ message_ty *plural_mp = NULL; /* defined only when in states 1 and 2 */
- /* The file is broken into tokens. Look for
+ /* The file is broken into tokens.
+ Normal handling: Look for
[A] _( [B] msgid ... )
+ Plural handling: Look for
+ [A] _( [B] msgid [C] , [D] msgid_plural ... )
At point [A]: state == 0.
- At point [B]: state == 1. */
+ At point [B]: state == 1, plural_mp == NULL.
+ At point [C]: state == 2, plural_mp != NULL.
+ At point [D]: state == 1, plural_mp != NULL. */
fp = f;
real_file_name = real_filename;
{
case token_type_i18n:
state = 1;
+ plural_mp = NULL;
continue;
case token_type_string_literal:
pos.file_name = logical_file_name;
pos.line_number = token.line_number;
- remember_a_message (mlp, token.string, &pos);
+ if (plural_mp == NULL)
+ {
+ /* Seen an msgid. */
+ plural_mp = remember_a_message (mlp, token.string, &pos);
+ state = 2;
+ }
+ else
+ {
+ /* Seen an msgid_plural. */
+ remember_a_message_plural (plural_mp, token.string, &pos);
+ state = 0;
+ }
}
else
- free (token.string);
- state = 0;
+ {
+ free (token.string);
+ state = 0;
+ }
+ continue;
+
+ case token_type_comma:
+ if (state == 2)
+ state = 1;
+ else
+ state = 0;
continue;
case token_type_eof: