diff options
author | Bruno Haible <bruno@clisp.org> | 2001-03-12 20:28:14 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2001-03-12 20:28:14 +0000 |
commit | ef56f35dc0450a81ab34c1d142884c46a3bacc9b (patch) | |
tree | c65760958b0b863742bef26f27a0029220a548de | |
parent | 9b6914394704197e3e4af3a0501089ee0d63608c (diff) | |
download | external_gettext-ef56f35dc0450a81ab34c1d142884c46a3bacc9b.zip external_gettext-ef56f35dc0450a81ab34c1d142884c46a3bacc9b.tar.gz external_gettext-ef56f35dc0450a81ab34c1d142884c46a3bacc9b.tar.bz2 |
Accept all kinds of comparison operators in the plural expression.
-rw-r--r-- | intl/ChangeLog | 10 | ||||
-rw-r--r-- | intl/dcigettext.c | 12 | ||||
-rw-r--r-- | intl/gettextP.h | 8 | ||||
-rw-r--r-- | intl/plural.y | 62 |
4 files changed, 78 insertions, 14 deletions
diff --git a/intl/ChangeLog b/intl/ChangeLog index 5561e64..095a17b 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,13 @@ +2001-03-12 Bruno Haible <haible@clisp.cons.org> + + * gettextP.h (struct expression): Add operators less_than, + greater_than, less_or_equal, greater_or_equal. + * plural.y ('<', '>', LE, GE): New operators. + (exp): Add rules with these operators. + (FREE_EXPRESSION): Recognize these operators. + (yylex): Don't skip "\\n". Recognize '<', '>', LE, GE operators. + * dcigettext.c (plural_eval): Recognize these operators. + 2001-03-10 Bruno Haible <haible@clisp.cons.org> * Makefile.in (libintl.la): Pass -liconv and flag -no-undefined. diff --git a/intl/dcigettext.c b/intl/dcigettext.c index a34c791..982689b 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -1009,6 +1009,18 @@ plural_eval (pexp, n) case minus: return (plural_eval (pexp->val.args2.left, n) - plural_eval (pexp->val.args2.right, n)); + case less_than: + return (plural_eval (pexp->val.args2.left, n) + < plural_eval (pexp->val.args2.right, n)); + case greater_than: + return (plural_eval (pexp->val.args2.left, n) + > plural_eval (pexp->val.args2.right, n)); + case less_or_equal: + return (plural_eval (pexp->val.args2.left, n) + <= plural_eval (pexp->val.args2.right, n)); + case greater_or_equal: + return (plural_eval (pexp->val.args2.left, n) + >= plural_eval (pexp->val.args2.right, n)); case equal: return (plural_eval (pexp->val.args2.left, n) == plural_eval (pexp->val.args2.right, n)); diff --git a/intl/gettextP.h b/intl/gettextP.h index fe12fce..0c8520c 100644 --- a/intl/gettextP.h +++ b/intl/gettextP.h @@ -84,8 +84,12 @@ struct expression module, /* Module operation. */ plus, /* Addition. */ minus, /* Subtraction. */ - equal, /* Comparision for equality. */ - not_equal, /* Comparision for inequality. */ + less_than, /* Comparison. */ + greater_than, /* Comparison. */ + less_or_equal, /* Comparison. */ + greater_or_equal, /* Comparison. */ + equal, /* Comparison for equality. */ + not_equal, /* Comparison for inequality. */ land, /* Logical AND. */ lor, /* Logical OR. */ qmop /* Question mark operator. */ diff --git a/intl/plural.y b/intl/plural.y index 54dc7b2..f835fa5 100644 --- a/intl/plural.y +++ b/intl/plural.y @@ -60,12 +60,16 @@ static int yylex PARAMS ((YYSTYPE *lval, const char **pexp)); static void yyerror PARAMS ((const char *str)); %} -%left '?' -%left '|' -%left '&' -%left '=', '!' -%left '+', '-' -%left '*', '/', '%' +/* This declares that all operators are left-associative, and that the + precedence order is the same as in C. There is no unary minus. */ +%left '?' /* ? */ +%left '|' /* || */ +%left '&' /* && */ +%left '=', '!' /* == != */ +%nonassoc '<', '>', LE, GE /* < > <= >= */ +%left '+', '-' /* + - */ +%left '*', '/', '%' /* * / % */ + %token <num> NUMBER %type <exp> exp @@ -102,6 +106,26 @@ exp: exp '?' exp ':' exp if (($$ = new_exp_2 (not_equal, $1, $3)) == NULL) YYABORT } + | exp '<' exp + { + if (($$ = new_exp_2 (less_than, $1, $3)) == NULL) + YYABORT + } + | exp '>' exp + { + if (($$ = new_exp_2 (greater_than, $1, $3)) == NULL) + YYABORT + } + | exp LE exp + { + if (($$ = new_exp_2 (less_or_equal, $1, $3)) == NULL) + YYABORT + } + | exp GE exp + { + if (($$ = new_exp_2 (greater_or_equal, $1, $3)) == NULL) + YYABORT + } | exp '+' exp { if (($$ = new_exp_2 (plus, $1, $3)) == NULL) @@ -233,6 +257,10 @@ FREE_EXPRESSION (exp) case module: case plus: case minus: + case less_than: + case greater_than: + case less_or_equal: + case greater_or_equal: case equal: case not_equal: case land: @@ -259,12 +287,6 @@ yylex (lval, pexp) while (1) { - if (exp[0] == '\\' && exp[1] == '\n') - { - exp += 2; - continue; - } - if (exp[0] == '\0') { *pexp = exp; @@ -311,6 +333,22 @@ yylex (lval, pexp) result = YYERRCODE; break; + case '<': + if (exp[0] == '=') + { + ++exp; + result = LE; + } + break; + + case '>': + if (exp[0] == '=') + { + ++exp; + result = GE; + } + break; + case 'n': case '*': case '/': |