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