1 /* Expression parsing and evaluation for plural form selection.
2 Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
26 # define PARAMS(args) args
28 # define PARAMS(args) ()
32 #ifndef internal_function
33 # define internal_function
36 #ifndef attribute_hidden
37 # define attribute_hidden
41 /* This is the representation of the expressions to determine the
45 int nargs
; /* Number of arguments. */
48 /* Without arguments: */
49 var
, /* The variable "n". */
50 num
, /* Decimal number. */
51 /* Unary operators: */
52 lnot
, /* Logical NOT. */
53 /* Binary operators: */
54 mult
, /* Multiplication. */
55 divide
, /* Division. */
56 module
, /* Modulo operation. */
58 minus
, /* Subtraction. */
59 less_than
, /* Comparison. */
60 greater_than
, /* Comparison. */
61 less_or_equal
, /* Comparison. */
62 greater_or_equal
, /* Comparison. */
63 equal
, /* Comparison for equality. */
64 not_equal
, /* Comparison for inequality. */
65 land
, /* Logical AND. */
66 lor
, /* Logical OR. */
67 /* Ternary operators: */
68 qmop
/* Question mark operator. */
72 unsigned long int num
; /* Number value for `num'. */
73 struct expression
*args
[3]; /* Up to three arguments. */
77 /* This is the data structure to pass information to the parser and get
78 the result in a thread-safe way. */
82 struct expression
*res
;
86 /* Names for the libintl functions are a problem. This source code is used
87 1. in the GNU C Library library,
88 2. in the GNU libintl library,
89 3. in the GNU gettext tools.
90 The function names in each situation must be different, to allow for
91 binary incompatible changes in 'struct expression'. Furthermore,
92 1. in the GNU C Library library, the names have a __ prefix,
93 2.+3. in the GNU libintl library and in the GNU gettext tools, the names
94 must follow ANSI C and not start with __.
95 So we have to distinguish the three cases. */
97 # define FREE_EXPRESSION __gettext_free_exp
98 # define PLURAL_PARSE __gettextparse
99 # define GERMANIC_PLURAL __gettext_germanic_plural
100 # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
101 #elif defined (IN_LIBINTL)
102 # define FREE_EXPRESSION libintl_gettext_free_exp
103 # define PLURAL_PARSE libintl_gettextparse
104 # define GERMANIC_PLURAL libintl_gettext_germanic_plural
105 # define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
107 # define FREE_EXPRESSION free_plural_expression
108 # define PLURAL_PARSE parse_plural_expression
109 # define GERMANIC_PLURAL germanic_plural
110 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
113 extern void FREE_EXPRESSION
PARAMS ((struct expression
*exp
))
115 extern int PLURAL_PARSE
PARAMS ((void *arg
));
116 extern const struct expression GERMANIC_PLURAL attribute_hidden
;
117 extern void EXTRACT_PLURAL_EXPRESSION
PARAMS ((const char *nullentry
,
118 struct expression
**pluralp
,
119 unsigned long int *npluralsp
))
122 #if !defined (_LIBC) && !defined (IN_LIBINTL)
123 extern unsigned long int plural_eval
PARAMS ((struct expression
*pexp
,
124 unsigned long int n
));
127 #endif /* _PLURAL_EXP_H */