]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Accept all kinds of comparison operators in the plural expression.
authorBruno Haible <bruno@clisp.org>
Mon, 12 Mar 2001 20:28:14 +0000 (20:28 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 12 Mar 2001 20:28:14 +0000 (20:28 +0000)
intl/ChangeLog
intl/dcigettext.c
intl/gettextP.h
intl/plural.y

index 5561e64ac9ff69ba3e3726afbae2e208a5ada33e..095a17beac57a158b1115efc40249974a2695baf 100644 (file)
@@ -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.
index a34c7916f6122037b6c1ef5db59fb0334aaffdc2..982689bf4d9736fc33d03cb2e629dfd8368bd42d 100644 (file)
@@ -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));
index fe12fce125926af41b1c6a4c0f8ec2ba95a5e71d..0c8520cdf07a92603853f96b4de2f6f1e7930b5c 100644 (file)
@@ -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.  */
index 54dc7b257465b15865c9ed0168f8c260c1d49720..f835fa5f2de0d7bd1c1bde5dd1fc0bfe3c390a70 100644 (file)
@@ -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 '/':