]> git.decadent.org.uk Git - ap-utils.git/blob - intl/plural-exp.h
Update config.{sub,guess} in the right place at build time - closes: #534825
[ap-utils.git] / intl / plural-exp.h
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.
4
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)
8    any later version.
9
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.
14
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,
18    USA.  */
19
20 #ifndef _PLURAL_EXP_H
21 #define _PLURAL_EXP_H
22
23 #ifndef PARAMS
24 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
25 #  define PARAMS(args) args
26 # else
27 #  define PARAMS(args) ()
28 # endif
29 #endif
30
31 #ifndef internal_function
32 # define internal_function
33 #endif
34
35
36 /* This is the representation of the expressions to determine the
37    plural form.  */
38 struct expression
39 {
40   int nargs;                    /* Number of arguments.  */
41   enum operator
42   {
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.  */
52     plus,                       /* Addition.  */
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.  */
64   } operation;
65   union
66   {
67     unsigned long int num;      /* Number value for `num'.  */
68     struct expression *args[3]; /* Up to three arguments.  */
69   } val;
70 };
71
72 /* This is the data structure to pass information to the parser and get
73    the result in a thread-safe way.  */
74 struct parse_args
75 {
76   const char *cp;
77   struct expression *res;
78 };
79
80
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.  */
91 #ifdef _LIBC
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__
101 #else
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
106 #endif
107
108 extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
109      internal_function;
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))
115      internal_function;
116
117 #if !defined (_LIBC) && !defined (IN_LIBINTL)
118 extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
119                                               unsigned long int n));
120 #endif
121
122 #endif /* _PLURAL_EXP_H */