annotate intl/plural-exp.h @ 1:cc6293c827ec trunk

[svn] Get rid of stuff we don't want in the repository. (compiled translations/autotools cache)
author nenolod
date Mon, 24 Oct 2005 03:12:26 -0700
parents cb178e5ad177
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* Expression parsing and evaluation for plural form selection.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify it
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 under the terms of the GNU Library General Public License as published
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 by the Free Software Foundation; either version 2, or (at your option)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 Library General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 License along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 USA. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 #ifndef _PLURAL_EXP_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21 #define _PLURAL_EXP_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #ifndef PARAMS
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 # define PARAMS(args) args
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 # else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 # define PARAMS(args) ()
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 # endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #ifndef internal_function
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 # define internal_function
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #ifndef attribute_hidden
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 # define attribute_hidden
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 /* This is the representation of the expressions to determine the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 plural form. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 struct expression
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 int nargs; /* Number of arguments. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 enum operator
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 /* Without arguments: */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 var, /* The variable "n". */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 num, /* Decimal number. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 /* Unary operators: */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 lnot, /* Logical NOT. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 /* Binary operators: */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 mult, /* Multiplication. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 divide, /* Division. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 module, /* Modulo operation. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 plus, /* Addition. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 minus, /* Subtraction. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 less_than, /* Comparison. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 greater_than, /* Comparison. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 less_or_equal, /* Comparison. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 greater_or_equal, /* Comparison. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 equal, /* Comparison for equality. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 not_equal, /* Comparison for inequality. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 land, /* Logical AND. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 lor, /* Logical OR. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 /* Ternary operators: */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 qmop /* Question mark operator. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 } operation;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 union
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 unsigned long int num; /* Number value for `num'. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 struct expression *args[3]; /* Up to three arguments. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 } val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 /* This is the data structure to pass information to the parser and get
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 the result in a thread-safe way. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 struct parse_args
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 const char *cp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 struct expression *res;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 /* Names for the libintl functions are a problem. This source code is used
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 1. in the GNU C Library library,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 2. in the GNU libintl library,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 3. in the GNU gettext tools.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 The function names in each situation must be different, to allow for
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 binary incompatible changes in 'struct expression'. Furthermore,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 1. in the GNU C Library library, the names have a __ prefix,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 2.+3. in the GNU libintl library and in the GNU gettext tools, the names
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 must follow ANSI C and not start with __.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 So we have to distinguish the three cases. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 #ifdef _LIBC
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 # define FREE_EXPRESSION __gettext_free_exp
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 # define PLURAL_PARSE __gettextparse
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 # define GERMANIC_PLURAL __gettext_germanic_plural
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 #elif defined (IN_LIBINTL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 # define FREE_EXPRESSION libintl_gettext_free_exp
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 # define PLURAL_PARSE libintl_gettextparse
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 # define GERMANIC_PLURAL libintl_gettext_germanic_plural
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 # define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 #else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 # define FREE_EXPRESSION free_plural_expression
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 # define PLURAL_PARSE parse_plural_expression
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 # define GERMANIC_PLURAL germanic_plural
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 internal_function;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 extern int PLURAL_PARSE PARAMS ((void *arg));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 extern struct expression GERMANIC_PLURAL attribute_hidden;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 struct expression **pluralp,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 unsigned long int *npluralsp))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 internal_function;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 #if !defined (_LIBC) && !defined (IN_LIBINTL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 unsigned long int n));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 #endif /* _PLURAL_EXP_H */