]>
Dogcows Code - chaz/openbox/blob - intl/eval-plural.h
1 /* Plural expression evaluation.
2 Copyright (C) 2000-2002 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published
6 by the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23 /* Evaluate the plural expression and return an index value. */
24 STATIC
unsigned long int plural_eval
PARAMS ((struct expression
*pexp
,
32 struct expression
*pexp
;
38 switch (pexp
->operation
)
51 /* pexp->operation must be lnot. */
52 unsigned long int arg
= plural_eval (pexp
->val
.args
[0], n
);
57 unsigned long int leftarg
= plural_eval (pexp
->val
.args
[0], n
);
58 if (pexp
->operation
== lor
)
59 return leftarg
|| plural_eval (pexp
->val
.args
[1], n
);
60 else if (pexp
->operation
== land
)
61 return leftarg
&& plural_eval (pexp
->val
.args
[1], n
);
64 unsigned long int rightarg
= plural_eval (pexp
->val
.args
[1], n
);
66 switch (pexp
->operation
)
69 return leftarg
* rightarg
;
71 #if !INTDIV0_RAISES_SIGFPE
75 return leftarg
/ rightarg
;
77 #if !INTDIV0_RAISES_SIGFPE
81 return leftarg
% rightarg
;
83 return leftarg
+ rightarg
;
85 return leftarg
- rightarg
;
87 return leftarg
< rightarg
;
89 return leftarg
> rightarg
;
91 return leftarg
<= rightarg
;
92 case greater_or_equal
:
93 return leftarg
>= rightarg
;
95 return leftarg
== rightarg
;
97 return leftarg
!= rightarg
;
107 /* pexp->operation must be qmop. */
108 unsigned long int boolarg
= plural_eval (pexp
->val
.args
[0], n
);
109 return plural_eval (pexp
->val
.args
[boolarg
? 1 : 2], n
);
This page took 0.041126 seconds and 4 git commands to generate.