Copy wininet to branch
[reactos.git] / reactos / lib / msi / cond.tab.c
1 /* A Bison parser, made by GNU Bison 1.875b. */
2
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program 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
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36 /* Identify Bison output. */
37 #define YYBISON 1
38
39 /* Skeleton name. */
40 #define YYSKELETON_NAME "yacc.c"
41
42 /* Pure parsers. */
43 #define YYPURE 1
44
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
47
48 /* If NAME_PREFIX is specified substitute the variables and functions
49 names. */
50 #define yyparse COND_parse
51 #define yylex COND_lex
52 #define yyerror COND_error
53 #define yylval COND_lval
54 #define yychar COND_char
55 #define yydebug COND_debug
56 #define yynerrs COND_nerrs
57
58
59 /* Tokens. */
60 #ifndef YYTOKENTYPE
61 # define YYTOKENTYPE
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
63 know about them. */
64 enum yytokentype {
65 COND_SPACE = 258,
66 COND_EOF = 259,
67 COND_OR = 260,
68 COND_AND = 261,
69 COND_NOT = 262,
70 COND_LT = 263,
71 COND_GT = 264,
72 COND_EQ = 265,
73 COND_LPAR = 266,
74 COND_RPAR = 267,
75 COND_TILDA = 268,
76 COND_PERCENT = 269,
77 COND_DOLLARS = 270,
78 COND_QUESTION = 271,
79 COND_AMPER = 272,
80 COND_EXCLAM = 273,
81 COND_IDENT = 274,
82 COND_NUMBER = 275,
83 COND_LITER = 276,
84 COND_ERROR = 277
85 };
86 #endif
87 #define COND_SPACE 258
88 #define COND_EOF 259
89 #define COND_OR 260
90 #define COND_AND 261
91 #define COND_NOT 262
92 #define COND_LT 263
93 #define COND_GT 264
94 #define COND_EQ 265
95 #define COND_LPAR 266
96 #define COND_RPAR 267
97 #define COND_TILDA 268
98 #define COND_PERCENT 269
99 #define COND_DOLLARS 270
100 #define COND_QUESTION 271
101 #define COND_AMPER 272
102 #define COND_EXCLAM 273
103 #define COND_IDENT 274
104 #define COND_NUMBER 275
105 #define COND_LITER 276
106 #define COND_ERROR 277
107
108
109
110
111 /* Copy the first part of user declarations. */
112 #line 1 "./cond.y"
113
114
115 /*
116 * Implementation of the Microsoft Installer (msi.dll)
117 *
118 * Copyright 2003 Mike McCormack for CodeWeavers
119 *
120 * This library is free software; you can redistribute it and/or
121 * modify it under the terms of the GNU Lesser General Public
122 * License as published by the Free Software Foundation; either
123 * version 2.1 of the License, or (at your option) any later version.
124 *
125 * This library is distributed in the hope that it will be useful,
126 * but WITHOUT ANY WARRANTY; without even the implied warranty of
127 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
128 * Lesser General Public License for more details.
129 *
130 * You should have received a copy of the GNU Lesser General Public
131 * License along with this library; if not, write to the Free Software
132 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
133 */
134
135 #include "config.h"
136
137 #include <stdarg.h>
138 #include <stdio.h>
139 #include <stdlib.h>
140
141 #include "windef.h"
142 #include "winbase.h"
143 #include "wine/debug.h"
144 #include "wine/unicode.h"
145
146 #include "msi.h"
147 #include "msiquery.h"
148 #include "msipriv.h"
149
150 #define YYLEX_PARAM info
151 #define YYPARSE_PARAM info
152
153 static int COND_error(char *str);
154
155 WINE_DEFAULT_DEBUG_CHANNEL(msi);
156
157 typedef struct tag_yyinput
158 {
159 MSIPACKAGE *package;
160 LPCWSTR str;
161 INT n;
162 MSICONDITION result;
163 } COND_input;
164
165 struct cond_str {
166 LPCWSTR data;
167 INT len;
168 };
169
170 static LPWSTR COND_GetString( struct cond_str *str );
171 static LPWSTR COND_GetLiteral( struct cond_str *str );
172 static int COND_lex( void *COND_lval, COND_input *info);
173
174 typedef INT (*comp_int)(INT a, INT b);
175 typedef INT (*comp_str)(LPWSTR a, LPWSTR b, BOOL caseless);
176 typedef INT (*comp_m1)(LPWSTR a,int b);
177 typedef INT (*comp_m2)(int a,LPWSTR b);
178
179 static INT comp_lt_i(INT a, INT b);
180 static INT comp_gt_i(INT a, INT b);
181 static INT comp_le_i(INT a, INT b);
182 static INT comp_ge_i(INT a, INT b);
183 static INT comp_eq_i(INT a, INT b);
184 static INT comp_ne_i(INT a, INT b);
185 static INT comp_bitand(INT a, INT b);
186 static INT comp_highcomp(INT a, INT b);
187 static INT comp_lowcomp(INT a, INT b);
188
189 static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless);
190 static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless);
191 static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless);
192 static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless);
193 static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless);
194 static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless);
195 static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless);
196 static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless);
197 static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless);
198
199 static INT comp_eq_m1(LPWSTR a, INT b);
200 static INT comp_ne_m1(LPWSTR a, INT b);
201 static INT comp_lt_m1(LPWSTR a, INT b);
202 static INT comp_gt_m1(LPWSTR a, INT b);
203 static INT comp_le_m1(LPWSTR a, INT b);
204 static INT comp_ge_m1(LPWSTR a, INT b);
205
206 static INT comp_eq_m2(INT a, LPWSTR b);
207 static INT comp_ne_m2(INT a, LPWSTR b);
208 static INT comp_lt_m2(INT a, LPWSTR b);
209 static INT comp_gt_m2(INT a, LPWSTR b);
210 static INT comp_le_m2(INT a, LPWSTR b);
211 static INT comp_ge_m2(INT a, LPWSTR b);
212
213
214
215 /* Enabling traces. */
216 #ifndef YYDEBUG
217 # define YYDEBUG 0
218 #endif
219
220 /* Enabling verbose error messages. */
221 #ifdef YYERROR_VERBOSE
222 # undef YYERROR_VERBOSE
223 # define YYERROR_VERBOSE 1
224 #else
225 # define YYERROR_VERBOSE 0
226 #endif
227
228 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
229 #line 106 "./cond.y"
230 typedef union YYSTYPE {
231 struct cond_str str;
232 LPWSTR string;
233 INT value;
234 comp_int fn_comp_int;
235 comp_str fn_comp_str;
236 comp_m1 fn_comp_m1;
237 comp_m2 fn_comp_m2;
238 } YYSTYPE;
239 /* Line 191 of yacc.c. */
240 #line 241 "cond.tab.c"
241 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
242 # define YYSTYPE_IS_DECLARED 1
243 # define YYSTYPE_IS_TRIVIAL 1
244 #endif
245
246
247
248 /* Copy the second part of user declarations. */
249
250
251 /* Line 214 of yacc.c. */
252 #line 253 "cond.tab.c"
253
254 #if ! defined (yyoverflow) || YYERROR_VERBOSE
255
256 /* The parser invokes alloca or malloc; define the necessary symbols. */
257
258 # if YYSTACK_USE_ALLOCA
259 # define YYSTACK_ALLOC alloca
260 # else
261 # ifndef YYSTACK_USE_ALLOCA
262 # if defined (alloca) || defined (_ALLOCA_H)
263 # define YYSTACK_ALLOC alloca
264 # else
265 # ifdef __GNUC__
266 # define YYSTACK_ALLOC __builtin_alloca
267 # endif
268 # endif
269 # endif
270 # endif
271
272 # ifdef YYSTACK_ALLOC
273 /* Pacify GCC's `empty if-body' warning. */
274 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
275 # else
276 # if defined (__STDC__) || defined (__cplusplus)
277 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
278 # define YYSIZE_T size_t
279 # endif
280 # define YYSTACK_ALLOC malloc
281 # define YYSTACK_FREE free
282 # endif
283 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
284
285
286 #if (! defined (yyoverflow) \
287 && (! defined (__cplusplus) \
288 || (YYSTYPE_IS_TRIVIAL)))
289
290 /* A type that is properly aligned for any stack member. */
291 union yyalloc
292 {
293 short yyss;
294 YYSTYPE yyvs;
295 };
296
297 /* The size of the maximum gap between one aligned stack and the next. */
298 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
299
300 /* The size of an array large to enough to hold all stacks, each with
301 N elements. */
302 # define YYSTACK_BYTES(N) \
303 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
304 + YYSTACK_GAP_MAXIMUM)
305
306 /* Copy COUNT objects from FROM to TO. The source and destination do
307 not overlap. */
308 # ifndef YYCOPY
309 # if 1 < __GNUC__
310 # define YYCOPY(To, From, Count) \
311 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
312 # else
313 # define YYCOPY(To, From, Count) \
314 do \
315 { \
316 register YYSIZE_T yyi; \
317 for (yyi = 0; yyi < (Count); yyi++) \
318 (To)[yyi] = (From)[yyi]; \
319 } \
320 while (0)
321 # endif
322 # endif
323
324 /* Relocate STACK from its old location to the new one. The
325 local variables YYSIZE and YYSTACKSIZE give the old and new number of
326 elements in the stack, and YYPTR gives the new location of the
327 stack. Advance YYPTR to a properly aligned location for the next
328 stack. */
329 # define YYSTACK_RELOCATE(Stack) \
330 do \
331 { \
332 YYSIZE_T yynewbytes; \
333 YYCOPY (&yyptr->Stack, Stack, yysize); \
334 Stack = &yyptr->Stack; \
335 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
336 yyptr += yynewbytes / sizeof (*yyptr); \
337 } \
338 while (0)
339
340 #endif
341
342 #if defined (__STDC__) || defined (__cplusplus)
343 typedef signed char yysigned_char;
344 #else
345 typedef short yysigned_char;
346 #endif
347
348 /* YYFINAL -- State number of the termination state. */
349 #define YYFINAL 30
350 /* YYLAST -- Last index in YYTABLE. */
351 #define YYLAST 146
352
353 /* YYNTOKENS -- Number of terminals. */
354 #define YYNTOKENS 23
355 /* YYNNTS -- Number of nonterminals. */
356 #define YYNNTS 17
357 /* YYNRULES -- Number of rules. */
358 #define YYNRULES 65
359 /* YYNRULES -- Number of states. */
360 #define YYNSTATES 74
361
362 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
363 #define YYUNDEFTOK 2
364 #define YYMAXUTOK 277
365
366 #define YYTRANSLATE(YYX) \
367 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
368
369 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
370 static const unsigned char yytranslate[] =
371 {
372 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
373 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
374 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
375 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
376 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
377 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
378 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
379 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
380 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
381 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
382 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
383 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
384 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
385 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
386 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
387 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
388 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
389 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
390 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
391 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
392 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
398 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
399 15, 16, 17, 18, 19, 20, 21, 22
400 };
401
402 #if YYDEBUG
403 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
404 YYRHS. */
405 static const unsigned char yyprhs[] =
406 {
407 0, 0, 3, 5, 7, 11, 13, 17, 19, 22,
408 24, 26, 30, 34, 39, 43, 47, 51, 53, 56,
409 58, 60, 63, 66, 69, 72, 75, 77, 80, 82,
410 84, 87, 90, 93, 96, 99, 101, 104, 106, 108,
411 111, 114, 117, 120, 123, 125, 128, 130, 132, 135,
412 138, 141, 144, 147, 149, 151, 153, 155, 157, 160,
413 163, 166, 169, 171, 174, 176
414 };
415
416 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
417 static const yysigned_char yyrhs[] =
418 {
419 24, 0, -1, 25, -1, 26, -1, 26, 5, 25,
420 -1, 27, -1, 26, 6, 27, -1, 28, -1, 7,
421 28, -1, 33, -1, 34, -1, 33, 29, 33, -1,
422 34, 30, 34, -1, 34, 13, 30, 34, -1, 34,
423 31, 33, -1, 33, 32, 34, -1, 11, 25, 12,
424 -1, 10, -1, 8, 9, -1, 8, -1, 9, -1,
425 8, 10, -1, 9, 10, -1, 9, 8, -1, 8,
426 8, -1, 9, 9, -1, 10, -1, 8, 9, -1,
427 8, -1, 9, -1, 8, 10, -1, 9, 10, -1,
428 9, 8, -1, 8, 8, -1, 9, 9, -1, 10,
429 -1, 8, 9, -1, 8, -1, 9, -1, 8, 10,
430 -1, 9, 10, -1, 9, 8, -1, 8, 8, -1,
431 9, 9, -1, 10, -1, 8, 9, -1, 8, -1,
432 9, -1, 8, 10, -1, 9, 10, -1, 9, 8,
433 -1, 8, 8, -1, 9, 9, -1, 36, -1, 39,
434 -1, 37, -1, 35, -1, 21, -1, 15, 38, -1,
435 16, 38, -1, 17, 38, -1, 18, 38, -1, 38,
436 -1, 14, 38, -1, 19, -1, 20, -1
437 };
438
439 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
440 static const unsigned short yyrline[] =
441 {
442 0, 136, 136, 144, 148, 155, 159, 166, 170, 178,
443 182, 186, 190, 194, 198, 202, 206, 214, 218, 222,
444 226, 230, 234, 239, 243, 247, 255, 259, 263, 267,
445 271, 275, 280, 284, 288, 296, 300, 304, 308, 312,
446 316, 321, 325, 329, 337, 341, 345, 349, 353, 357,
447 362, 366, 370, 377, 381, 388, 392, 399, 408, 417,
448 426, 435, 447, 470, 484, 493
449 };
450 #endif
451
452 #if YYDEBUG || YYERROR_VERBOSE
453 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
454 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
455 static const char *const yytname[] =
456 {
457 "$end", "error", "$undefined", "COND_SPACE", "COND_EOF", "COND_OR",
458 "COND_AND", "COND_NOT", "COND_LT", "COND_GT", "COND_EQ", "COND_LPAR",
459 "COND_RPAR", "COND_TILDA", "COND_PERCENT", "COND_DOLLARS",
460 "COND_QUESTION", "COND_AMPER", "COND_EXCLAM", "COND_IDENT",
461 "COND_NUMBER", "COND_LITER", "COND_ERROR", "$accept", "condition",
462 "expression", "boolean_term", "boolean_factor", "term", "comp_op_i",
463 "comp_op_s", "comp_op_m1", "comp_op_m2", "value_i", "value_s",
464 "literal", "symbol_i", "symbol_s", "identifier", "integer", 0
465 };
466 #endif
467
468 # ifdef YYPRINT
469 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
470 token YYLEX-NUM. */
471 static const unsigned short yytoknum[] =
472 {
473 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
474 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
475 275, 276, 277
476 };
477 # endif
478
479 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
480 static const unsigned char yyr1[] =
481 {
482 0, 23, 24, 25, 25, 26, 26, 27, 27, 28,
483 28, 28, 28, 28, 28, 28, 28, 29, 29, 29,
484 29, 29, 29, 29, 29, 29, 30, 30, 30, 30,
485 30, 30, 30, 30, 30, 31, 31, 31, 31, 31,
486 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
487 32, 32, 32, 33, 33, 34, 34, 35, 36, 36,
488 36, 36, 37, 37, 38, 39
489 };
490
491 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
492 static const unsigned char yyr2[] =
493 {
494 0, 2, 1, 1, 3, 1, 3, 1, 2, 1,
495 1, 3, 3, 4, 3, 3, 3, 1, 2, 1,
496 1, 2, 2, 2, 2, 2, 1, 2, 1, 1,
497 2, 2, 2, 2, 2, 1, 2, 1, 1, 2,
498 2, 2, 2, 2, 1, 2, 1, 1, 2, 2,
499 2, 2, 2, 1, 1, 1, 1, 1, 2, 2,
500 2, 2, 1, 2, 1, 1
501 };
502
503 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
504 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
505 means the default is an error. */
506 static const unsigned char yydefact[] =
507 {
508 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
509 57, 0, 2, 3, 5, 7, 9, 10, 56, 53,
510 55, 62, 54, 8, 0, 63, 58, 59, 60, 61,
511 1, 0, 0, 19, 20, 17, 0, 0, 37, 38,
512 35, 0, 0, 0, 16, 4, 6, 24, 18, 21,
513 23, 25, 22, 11, 15, 42, 36, 39, 41, 43,
514 40, 28, 29, 26, 0, 12, 14, 33, 27, 30,
515 32, 34, 31, 13
516 };
517
518 /* YYDEFGOTO[NTERM-NUM]. */
519 static const yysigned_char yydefgoto[] =
520 {
521 -1, 11, 12, 13, 14, 15, 36, 42, 43, 37,
522 16, 17, 18, 19, 20, 21, 22
523 };
524
525 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
526 STATE-NUM. */
527 #define YYPACT_NINF -37
528 static const short yypact[] =
529 {
530 -4, 51, -4, -11, -11, -11, -11, -11, -37, -37,
531 -37, 18, -37, -1, -37, -37, 49, 14, -37, -37,
532 -37, -37, -37, -37, 19, -37, -37, -37, -37, -37,
533 -37, -4, -4, 11, 25, 34, 111, 59, 28, 42,
534 60, 130, 59, 111, -37, -37, -37, 63, 69, 72,
535 73, 81, 82, -37, -37, 85, 91, 94, 95, 103,
536 104, 133, 136, -37, 59, -37, -37, -37, -37, -37,
537 -37, -37, -37, -37
538 };
539
540 /* YYPGOTO[NTERM-NUM]. */
541 static const short yypgoto[] =
542 {
543 -37, -37, -2, -37, -6, 39, -37, 0, -37, -37,
544 -34, -36, -37, -37, -37, 129, -37
545 };
546
547 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
548 positive, shift that token. If negative, reduce the rule which
549 number is the opposite. If zero, do what YYDEFACT says.
550 If YYTABLE_NINF, syntax error. */
551 #define YYTABLE_NINF -53
552 static const yysigned_char yytable[] =
553 {
554 24, 54, 53, 1, 31, 32, 65, 2, 8, 66,
555 3, 4, 5, 6, 7, 8, 9, 10, 30, 47,
556 48, 49, 38, 39, 40, -46, 46, 41, 73, 45,
557 -46, 44, -46, 50, 51, 52, 55, 56, 57, -47,
558 23, 64, -28, 0, -47, 0, -47, -28, -44, -28,
559 58, 59, 60, -44, 0, -44, -29, 33, 34, 35,
560 0, -29, 2, -29, 0, 3, 4, 5, 6, 7,
561 8, 9, 10, 3, -26, 0, 0, -51, 8, -26,
562 10, -26, -51, -45, -51, 0, -48, -50, -45, 0,
563 -45, -48, -50, -48, -50, -52, -49, 0, 0, -33,
564 -52, -49, -52, -49, -33, -27, -33, 0, -30, -32,
565 -27, 0, -27, -30, -32, -30, -32, -34, -31, 0,
566 0, 0, -34, -31, -34, -31, 4, 5, 6, 7,
567 0, 9, 25, 26, 27, 28, 29, 0, 61, 62,
568 63, 67, 68, 69, 70, 71, 72
569 };
570
571 static const yysigned_char yycheck[] =
572 {
573 2, 37, 36, 7, 5, 6, 42, 11, 19, 43,
574 14, 15, 16, 17, 18, 19, 20, 21, 0, 8,
575 9, 10, 8, 9, 10, 14, 32, 13, 64, 31,
576 19, 12, 21, 8, 9, 10, 8, 9, 10, 14,
577 1, 41, 14, -1, 19, -1, 21, 19, 14, 21,
578 8, 9, 10, 19, -1, 21, 14, 8, 9, 10,
579 -1, 19, 11, 21, -1, 14, 15, 16, 17, 18,
580 19, 20, 21, 14, 14, -1, -1, 14, 19, 19,
581 21, 21, 19, 14, 21, -1, 14, 14, 19, -1,
582 21, 19, 19, 21, 21, 14, 14, -1, -1, 14,
583 19, 19, 21, 21, 19, 14, 21, -1, 14, 14,
584 19, -1, 21, 19, 19, 21, 21, 14, 14, -1,
585 -1, -1, 19, 19, 21, 21, 15, 16, 17, 18,
586 -1, 20, 3, 4, 5, 6, 7, -1, 8, 9,
587 10, 8, 9, 10, 8, 9, 10
588 };
589
590 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
591 symbol of state STATE-NUM. */
592 static const unsigned char yystos[] =
593 {
594 0, 7, 11, 14, 15, 16, 17, 18, 19, 20,
595 21, 24, 25, 26, 27, 28, 33, 34, 35, 36,
596 37, 38, 39, 28, 25, 38, 38, 38, 38, 38,
597 0, 5, 6, 8, 9, 10, 29, 32, 8, 9,
598 10, 13, 30, 31, 12, 25, 27, 8, 9, 10,
599 8, 9, 10, 33, 34, 8, 9, 10, 8, 9,
600 10, 8, 9, 10, 30, 34, 33, 8, 9, 10,
601 8, 9, 10, 34
602 };
603
604 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
605 # define YYSIZE_T __SIZE_TYPE__
606 #endif
607 #if ! defined (YYSIZE_T) && defined (size_t)
608 # define YYSIZE_T size_t
609 #endif
610 #if ! defined (YYSIZE_T)
611 # if defined (__STDC__) || defined (__cplusplus)
612 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
613 # define YYSIZE_T size_t
614 # endif
615 #endif
616 #if ! defined (YYSIZE_T)
617 # define YYSIZE_T unsigned int
618 #endif
619
620 #define yyerrok (yyerrstatus = 0)
621 #define yyclearin (yychar = YYEMPTY)
622 #define YYEMPTY (-2)
623 #define YYEOF 0
624
625 #define YYACCEPT goto yyacceptlab
626 #define YYABORT goto yyabortlab
627 #define YYERROR goto yyerrlab1
628
629
630 /* Like YYERROR except do call yyerror. This remains here temporarily
631 to ease the transition to the new meaning of YYERROR, for GCC.
632 Once GCC version 2 has supplanted version 1, this can go. */
633
634 #define YYFAIL goto yyerrlab
635
636 #define YYRECOVERING() (!!yyerrstatus)
637
638 #define YYBACKUP(Token, Value) \
639 do \
640 if (yychar == YYEMPTY && yylen == 1) \
641 { \
642 yychar = (Token); \
643 yylval = (Value); \
644 yytoken = YYTRANSLATE (yychar); \
645 YYPOPSTACK; \
646 goto yybackup; \
647 } \
648 else \
649 { \
650 yyerror ("syntax error: cannot back up");\
651 YYERROR; \
652 } \
653 while (0)
654
655 #define YYTERROR 1
656 #define YYERRCODE 256
657
658 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
659 are run). */
660
661 #ifndef YYLLOC_DEFAULT
662 # define YYLLOC_DEFAULT(Current, Rhs, N) \
663 Current.first_line = Rhs[1].first_line; \
664 Current.first_column = Rhs[1].first_column; \
665 Current.last_line = Rhs[N].last_line; \
666 Current.last_column = Rhs[N].last_column;
667 #endif
668
669 /* YYLEX -- calling `yylex' with the right arguments. */
670
671 #ifdef YYLEX_PARAM
672 # define YYLEX yylex (&yylval, YYLEX_PARAM)
673 #else
674 # define YYLEX yylex (&yylval)
675 #endif
676
677 /* Enable debugging if requested. */
678 #if YYDEBUG
679
680 # ifndef YYFPRINTF
681 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
682 # define YYFPRINTF fprintf
683 # endif
684
685 # define YYDPRINTF(Args) \
686 do { \
687 if (yydebug) \
688 YYFPRINTF Args; \
689 } while (0)
690
691 # define YYDSYMPRINT(Args) \
692 do { \
693 if (yydebug) \
694 yysymprint Args; \
695 } while (0)
696
697 # define YYDSYMPRINTF(Title, Token, Value, Location) \
698 do { \
699 if (yydebug) \
700 { \
701 YYFPRINTF (stderr, "%s ", Title); \
702 yysymprint (stderr, \
703 Token, Value); \
704 YYFPRINTF (stderr, "\n"); \
705 } \
706 } while (0)
707
708 /*------------------------------------------------------------------.
709 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
710 | TOP (cinluded). |
711 `------------------------------------------------------------------*/
712
713 #if defined (__STDC__) || defined (__cplusplus)
714 static void
715 yy_stack_print (short *bottom, short *top)
716 #else
717 static void
718 yy_stack_print (bottom, top)
719 short *bottom;
720 short *top;
721 #endif
722 {
723 YYFPRINTF (stderr, "Stack now");
724 for (/* Nothing. */; bottom <= top; ++bottom)
725 YYFPRINTF (stderr, " %d", *bottom);
726 YYFPRINTF (stderr, "\n");
727 }
728
729 # define YY_STACK_PRINT(Bottom, Top) \
730 do { \
731 if (yydebug) \
732 yy_stack_print ((Bottom), (Top)); \
733 } while (0)
734
735
736 /*------------------------------------------------.
737 | Report that the YYRULE is going to be reduced. |
738 `------------------------------------------------*/
739
740 #if defined (__STDC__) || defined (__cplusplus)
741 static void
742 yy_reduce_print (int yyrule)
743 #else
744 static void
745 yy_reduce_print (yyrule)
746 int yyrule;
747 #endif
748 {
749 int yyi;
750 unsigned int yylno = yyrline[yyrule];
751 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
752 yyrule - 1, yylno);
753 /* Print the symbols being reduced, and their result. */
754 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
755 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
756 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
757 }
758
759 # define YY_REDUCE_PRINT(Rule) \
760 do { \
761 if (yydebug) \
762 yy_reduce_print (Rule); \
763 } while (0)
764
765 /* Nonzero means print parse trace. It is left uninitialized so that
766 multiple parsers can coexist. */
767 int yydebug;
768 #else /* !YYDEBUG */
769 # define YYDPRINTF(Args)
770 # define YYDSYMPRINT(Args)
771 # define YYDSYMPRINTF(Title, Token, Value, Location)
772 # define YY_STACK_PRINT(Bottom, Top)
773 # define YY_REDUCE_PRINT(Rule)
774 #endif /* !YYDEBUG */
775
776
777 /* YYINITDEPTH -- initial size of the parser's stacks. */
778 #ifndef YYINITDEPTH
779 # define YYINITDEPTH 200
780 #endif
781
782 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
783 if the built-in stack extension method is used).
784
785 Do not make this value too large; the results are undefined if
786 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
787 evaluated with infinite-precision integer arithmetic. */
788
789 #if YYMAXDEPTH == 0
790 # undef YYMAXDEPTH
791 #endif
792
793 #ifndef YYMAXDEPTH
794 # define YYMAXDEPTH 10000
795 #endif
796
797 \f
798
799 #if YYERROR_VERBOSE
800
801 # ifndef yystrlen
802 # if defined (__GLIBC__) && defined (_STRING_H)
803 # define yystrlen strlen
804 # else
805 /* Return the length of YYSTR. */
806 static YYSIZE_T
807 # if defined (__STDC__) || defined (__cplusplus)
808 yystrlen (const char *yystr)
809 # else
810 yystrlen (yystr)
811 const char *yystr;
812 # endif
813 {
814 register const char *yys = yystr;
815
816 while (*yys++ != '\0')
817 continue;
818
819 return yys - yystr - 1;
820 }
821 # endif
822 # endif
823
824 # ifndef yystpcpy
825 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
826 # define yystpcpy stpcpy
827 # else
828 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
829 YYDEST. */
830 static char *
831 # if defined (__STDC__) || defined (__cplusplus)
832 yystpcpy (char *yydest, const char *yysrc)
833 # else
834 yystpcpy (yydest, yysrc)
835 char *yydest;
836 const char *yysrc;
837 # endif
838 {
839 register char *yyd = yydest;
840 register const char *yys = yysrc;
841
842 while ((*yyd++ = *yys++) != '\0')
843 continue;
844
845 return yyd - 1;
846 }
847 # endif
848 # endif
849
850 #endif /* !YYERROR_VERBOSE */
851
852 \f
853
854 #if YYDEBUG
855 /*--------------------------------.
856 | Print this symbol on YYOUTPUT. |
857 `--------------------------------*/
858
859 #if defined (__STDC__) || defined (__cplusplus)
860 static void
861 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
862 #else
863 static void
864 yysymprint (yyoutput, yytype, yyvaluep)
865 FILE *yyoutput;
866 int yytype;
867 YYSTYPE *yyvaluep;
868 #endif
869 {
870 /* Pacify ``unused variable'' warnings. */
871 (void) yyvaluep;
872
873 if (yytype < YYNTOKENS)
874 {
875 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
876 # ifdef YYPRINT
877 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
878 # endif
879 }
880 else
881 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
882
883 switch (yytype)
884 {
885 default:
886 break;
887 }
888 YYFPRINTF (yyoutput, ")");
889 }
890
891 #endif /* ! YYDEBUG */
892 /*-----------------------------------------------.
893 | Release the memory associated to this symbol. |
894 `-----------------------------------------------*/
895
896 #if defined (__STDC__) || defined (__cplusplus)
897 static void
898 yydestruct (int yytype, YYSTYPE *yyvaluep)
899 #else
900 static void
901 yydestruct (yytype, yyvaluep)
902 int yytype;
903 YYSTYPE *yyvaluep;
904 #endif
905 {
906 /* Pacify ``unused variable'' warnings. */
907 (void) yyvaluep;
908
909 switch (yytype)
910 {
911
912 default:
913 break;
914 }
915 }
916 \f
917
918 /* Prevent warnings from -Wmissing-prototypes. */
919
920 #ifdef YYPARSE_PARAM
921 # if defined (__STDC__) || defined (__cplusplus)
922 int yyparse (void *YYPARSE_PARAM);
923 # else
924 int yyparse ();
925 # endif
926 #else /* ! YYPARSE_PARAM */
927 #if defined (__STDC__) || defined (__cplusplus)
928 int yyparse (void);
929 #else
930 int yyparse ();
931 #endif
932 #endif /* ! YYPARSE_PARAM */
933
934
935
936
937
938
939 /*----------.
940 | yyparse. |
941 `----------*/
942
943 #ifdef YYPARSE_PARAM
944 # if defined (__STDC__) || defined (__cplusplus)
945 int yyparse (void *YYPARSE_PARAM)
946 # else
947 int yyparse (YYPARSE_PARAM)
948 void *YYPARSE_PARAM;
949 # endif
950 #else /* ! YYPARSE_PARAM */
951 #if defined (__STDC__) || defined (__cplusplus)
952 int
953 yyparse (void)
954 #else
955 int
956 yyparse ()
957
958 #endif
959 #endif
960 {
961 /* The lookahead symbol. */
962 int yychar;
963
964 /* The semantic value of the lookahead symbol. */
965 YYSTYPE yylval;
966
967 /* Number of syntax errors so far. */
968 int yynerrs;
969
970 register int yystate;
971 register int yyn;
972 int yyresult;
973 /* Number of tokens to shift before error messages enabled. */
974 int yyerrstatus;
975 /* Lookahead token as an internal (translated) token number. */
976 int yytoken = 0;
977
978 /* Three stacks and their tools:
979 `yyss': related to states,
980 `yyvs': related to semantic values,
981 `yyls': related to locations.
982
983 Refer to the stacks thru separate pointers, to allow yyoverflow
984 to reallocate them elsewhere. */
985
986 /* The state stack. */
987 short yyssa[YYINITDEPTH];
988 short *yyss = yyssa;
989 register short *yyssp;
990
991 /* The semantic value stack. */
992 YYSTYPE yyvsa[YYINITDEPTH];
993 YYSTYPE *yyvs = yyvsa;
994 register YYSTYPE *yyvsp;
995
996
997
998 #define YYPOPSTACK (yyvsp--, yyssp--)
999
1000 YYSIZE_T yystacksize = YYINITDEPTH;
1001
1002 /* The variables used to return semantic value and location from the
1003 action routines. */
1004 YYSTYPE yyval;
1005
1006
1007 /* When reducing, the number of symbols on the RHS of the reduced
1008 rule. */
1009 int yylen;
1010
1011 YYDPRINTF ((stderr, "Starting parse\n"));
1012
1013 yystate = 0;
1014 yyerrstatus = 0;
1015 yynerrs = 0;
1016 yychar = YYEMPTY; /* Cause a token to be read. */
1017
1018 /* Initialize stack pointers.
1019 Waste one element of value and location stack
1020 so that they stay on the same level as the state stack.
1021 The wasted elements are never initialized. */
1022
1023 yyssp = yyss;
1024 yyvsp = yyvs;
1025
1026 goto yysetstate;
1027
1028 /*------------------------------------------------------------.
1029 | yynewstate -- Push a new state, which is found in yystate. |
1030 `------------------------------------------------------------*/
1031 yynewstate:
1032 /* In all cases, when you get here, the value and location stacks
1033 have just been pushed. so pushing a state here evens the stacks.
1034 */
1035 yyssp++;
1036
1037 yysetstate:
1038 *yyssp = yystate;
1039
1040 if (yyss + yystacksize - 1 <= yyssp)
1041 {
1042 /* Get the current used size of the three stacks, in elements. */
1043 YYSIZE_T yysize = yyssp - yyss + 1;
1044
1045 #ifdef yyoverflow
1046 {
1047 /* Give user a chance to reallocate the stack. Use copies of
1048 these so that the &'s don't force the real ones into
1049 memory. */
1050 YYSTYPE *yyvs1 = yyvs;
1051 short *yyss1 = yyss;
1052
1053
1054 /* Each stack pointer address is followed by the size of the
1055 data in use in that stack, in bytes. This used to be a
1056 conditional around just the two extra args, but that might
1057 be undefined if yyoverflow is a macro. */
1058 yyoverflow ("parser stack overflow",
1059 &yyss1, yysize * sizeof (*yyssp),
1060 &yyvs1, yysize * sizeof (*yyvsp),
1061
1062 &yystacksize);
1063
1064 yyss = yyss1;
1065 yyvs = yyvs1;
1066 }
1067 #else /* no yyoverflow */
1068 # ifndef YYSTACK_RELOCATE
1069 goto yyoverflowlab;
1070 # else
1071 /* Extend the stack our own way. */
1072 if (YYMAXDEPTH <= yystacksize)
1073 goto yyoverflowlab;
1074 yystacksize *= 2;
1075 if (YYMAXDEPTH < yystacksize)
1076 yystacksize = YYMAXDEPTH;
1077
1078 {
1079 short *yyss1 = yyss;
1080 union yyalloc *yyptr =
1081 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1082 if (! yyptr)
1083 goto yyoverflowlab;
1084 YYSTACK_RELOCATE (yyss);
1085 YYSTACK_RELOCATE (yyvs);
1086
1087 # undef YYSTACK_RELOCATE
1088 if (yyss1 != yyssa)
1089 YYSTACK_FREE (yyss1);
1090 }
1091 # endif
1092 #endif /* no yyoverflow */
1093
1094 yyssp = yyss + yysize - 1;
1095 yyvsp = yyvs + yysize - 1;
1096
1097
1098 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1099 (unsigned long int) yystacksize));
1100
1101 if (yyss + yystacksize - 1 <= yyssp)
1102 YYABORT;
1103 }
1104
1105 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1106
1107 goto yybackup;
1108
1109 /*-----------.
1110 | yybackup. |
1111 `-----------*/
1112 yybackup:
1113
1114 /* Do appropriate processing given the current state. */
1115 /* Read a lookahead token if we need one and don't already have one. */
1116 /* yyresume: */
1117
1118 /* First try to decide what to do without reference to lookahead token. */
1119
1120 yyn = yypact[yystate];
1121 if (yyn == YYPACT_NINF)
1122 goto yydefault;
1123
1124 /* Not known => get a lookahead token if don't already have one. */
1125
1126 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1127 if (yychar == YYEMPTY)
1128 {
1129 YYDPRINTF ((stderr, "Reading a token: "));
1130 yychar = YYLEX;
1131 }
1132
1133 if (yychar <= YYEOF)
1134 {
1135 yychar = yytoken = YYEOF;
1136 YYDPRINTF ((stderr, "Now at end of input.\n"));
1137 }
1138 else
1139 {
1140 yytoken = YYTRANSLATE (yychar);
1141 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1142 }
1143
1144 /* If the proper action on seeing token YYTOKEN is to reduce or to
1145 detect an error, take that action. */
1146 yyn += yytoken;
1147 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1148 goto yydefault;
1149 yyn = yytable[yyn];
1150 if (yyn <= 0)
1151 {
1152 if (yyn == 0 || yyn == YYTABLE_NINF)
1153 goto yyerrlab;
1154 yyn = -yyn;
1155 goto yyreduce;
1156 }
1157
1158 if (yyn == YYFINAL)
1159 YYACCEPT;
1160
1161 /* Shift the lookahead token. */
1162 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1163
1164 /* Discard the token being shifted unless it is eof. */
1165 if (yychar != YYEOF)
1166 yychar = YYEMPTY;
1167
1168 *++yyvsp = yylval;
1169
1170
1171 /* Count tokens shifted since error; after three, turn off error
1172 status. */
1173 if (yyerrstatus)
1174 yyerrstatus--;
1175
1176 yystate = yyn;
1177 goto yynewstate;
1178
1179
1180 /*-----------------------------------------------------------.
1181 | yydefault -- do the default action for the current state. |
1182 `-----------------------------------------------------------*/
1183 yydefault:
1184 yyn = yydefact[yystate];
1185 if (yyn == 0)
1186 goto yyerrlab;
1187 goto yyreduce;
1188
1189
1190 /*-----------------------------.
1191 | yyreduce -- Do a reduction. |
1192 `-----------------------------*/
1193 yyreduce:
1194 /* yyn is the number of a rule to reduce with. */
1195 yylen = yyr2[yyn];
1196
1197 /* If YYLEN is nonzero, implement the default value of the action:
1198 `$$ = $1'.
1199
1200 Otherwise, the following line sets YYVAL to garbage.
1201 This behavior is undocumented and Bison
1202 users should not rely upon it. Assigning to YYVAL
1203 unconditionally makes the parser a bit smaller, and it avoids a
1204 GCC warning that YYVAL may be used uninitialized. */
1205 yyval = yyvsp[1-yylen];
1206
1207
1208 YY_REDUCE_PRINT (yyn);
1209 switch (yyn)
1210 {
1211 case 2:
1212 #line 137 "./cond.y"
1213 {
1214 COND_input* cond = (COND_input*) info;
1215 cond->result = yyvsp[0].value;
1216 ;}
1217 break;
1218
1219 case 3:
1220 #line 145 "./cond.y"
1221 {
1222 yyval.value = yyvsp[0].value;
1223 ;}
1224 break;
1225
1226 case 4:
1227 #line 149 "./cond.y"
1228 {
1229 yyval.value = yyvsp[-2].value || yyvsp[0].value;
1230 ;}
1231 break;
1232
1233 case 5:
1234 #line 156 "./cond.y"
1235 {
1236 yyval.value = yyvsp[0].value;
1237 ;}
1238 break;
1239
1240 case 6:
1241 #line 160 "./cond.y"
1242 {
1243 yyval.value = yyvsp[-2].value && yyvsp[0].value;
1244 ;}
1245 break;
1246
1247 case 7:
1248 #line 167 "./cond.y"
1249 {
1250 yyval.value = yyvsp[0].value;
1251 ;}
1252 break;
1253
1254 case 8:
1255 #line 171 "./cond.y"
1256 {
1257 yyval.value = ! yyvsp[0].value;
1258 ;}
1259 break;
1260
1261 case 9:
1262 #line 179 "./cond.y"
1263 {
1264 yyval.value = yyvsp[0].value;
1265 ;}
1266 break;
1267
1268 case 10:
1269 #line 183 "./cond.y"
1270 {
1271 yyval.value = yyvsp[0].string[0] ? MSICONDITION_TRUE : MSICONDITION_FALSE;
1272 ;}
1273 break;
1274
1275 case 11:
1276 #line 187 "./cond.y"
1277 {
1278 yyval.value = yyvsp[-1].fn_comp_int( yyvsp[-2].value, yyvsp[0].value );
1279 ;}
1280 break;
1281
1282 case 12:
1283 #line 191 "./cond.y"
1284 {
1285 yyval.value = yyvsp[-1].fn_comp_str( yyvsp[-2].string, yyvsp[0].string, FALSE );
1286 ;}
1287 break;
1288
1289 case 13:
1290 #line 195 "./cond.y"
1291 {
1292 yyval.value = yyvsp[-1].fn_comp_str( yyvsp[-3].string, yyvsp[0].string, TRUE );
1293 ;}
1294 break;
1295
1296 case 14:
1297 #line 199 "./cond.y"
1298 {
1299 yyval.value = yyvsp[-1].fn_comp_m1( yyvsp[-2].string, yyvsp[0].value );
1300 ;}
1301 break;
1302
1303 case 15:
1304 #line 203 "./cond.y"
1305 {
1306 yyval.value = yyvsp[-1].fn_comp_m2( yyvsp[-2].value, yyvsp[0].string );
1307 ;}
1308 break;
1309
1310 case 16:
1311 #line 207 "./cond.y"
1312 {
1313 yyval.value = yyvsp[-1].value;
1314 ;}
1315 break;
1316
1317 case 17:
1318 #line 215 "./cond.y"
1319 {
1320 yyval.fn_comp_int = comp_eq_i;
1321 ;}
1322 break;
1323
1324 case 18:
1325 #line 219 "./cond.y"
1326 {
1327 yyval.fn_comp_int = comp_ne_i;
1328 ;}
1329 break;
1330
1331 case 19:
1332 #line 223 "./cond.y"
1333 {
1334 yyval.fn_comp_int = comp_lt_i;
1335 ;}
1336 break;
1337
1338 case 20:
1339 #line 227 "./cond.y"
1340 {
1341 yyval.fn_comp_int = comp_gt_i;
1342 ;}
1343 break;
1344
1345 case 21:
1346 #line 231 "./cond.y"
1347 {
1348 yyval.fn_comp_int = comp_le_i;
1349 ;}
1350 break;
1351
1352 case 22:
1353 #line 235 "./cond.y"
1354 {
1355 yyval.fn_comp_int = comp_ge_i;
1356 ;}
1357 break;
1358
1359 case 23:
1360 #line 240 "./cond.y"
1361 {
1362 yyval.fn_comp_int = comp_bitand;
1363 ;}
1364 break;
1365
1366 case 24:
1367 #line 244 "./cond.y"
1368 {
1369 yyval.fn_comp_int = comp_highcomp;
1370 ;}
1371 break;
1372
1373 case 25:
1374 #line 248 "./cond.y"
1375 {
1376 yyval.fn_comp_int = comp_lowcomp;
1377 ;}
1378 break;
1379
1380 case 26:
1381 #line 256 "./cond.y"
1382 {
1383 yyval.fn_comp_str = comp_eq_s;
1384 ;}
1385 break;
1386
1387 case 27:
1388 #line 260 "./cond.y"
1389 {
1390 yyval.fn_comp_str = comp_ne_s;
1391 ;}
1392 break;
1393
1394 case 28:
1395 #line 264 "./cond.y"
1396 {
1397 yyval.fn_comp_str = comp_lt_s;
1398 ;}
1399 break;
1400
1401 case 29:
1402 #line 268 "./cond.y"
1403 {
1404 yyval.fn_comp_str = comp_gt_s;
1405 ;}
1406 break;
1407
1408 case 30:
1409 #line 272 "./cond.y"
1410 {
1411 yyval.fn_comp_str = comp_le_s;
1412 ;}
1413 break;
1414
1415 case 31:
1416 #line 276 "./cond.y"
1417 {
1418 yyval.fn_comp_str = comp_ge_s;
1419 ;}
1420 break;
1421
1422 case 32:
1423 #line 281 "./cond.y"
1424 {
1425 yyval.fn_comp_str = comp_substring;
1426 ;}
1427 break;
1428
1429 case 33:
1430 #line 285 "./cond.y"
1431 {
1432 yyval.fn_comp_str = comp_start;
1433 ;}
1434 break;
1435
1436 case 34:
1437 #line 289 "./cond.y"
1438 {
1439 yyval.fn_comp_str = comp_end;
1440 ;}
1441 break;
1442
1443 case 35:
1444 #line 297 "./cond.y"
1445 {
1446 yyval.fn_comp_m1 = comp_eq_m1;
1447 ;}
1448 break;
1449
1450 case 36:
1451 #line 301 "./cond.y"
1452 {
1453 yyval.fn_comp_m1 = comp_ne_m1;
1454 ;}
1455 break;
1456
1457 case 37:
1458 #line 305 "./cond.y"
1459 {
1460 yyval.fn_comp_m1 = comp_lt_m1;
1461 ;}
1462 break;
1463
1464 case 38:
1465 #line 309 "./cond.y"
1466 {
1467 yyval.fn_comp_m1 = comp_gt_m1;
1468 ;}
1469 break;
1470
1471 case 39:
1472 #line 313 "./cond.y"
1473 {
1474 yyval.fn_comp_m1 = comp_le_m1;
1475 ;}
1476 break;
1477
1478 case 40:
1479 #line 317 "./cond.y"
1480 {
1481 yyval.fn_comp_m1 = comp_ge_m1;
1482 ;}
1483 break;
1484
1485 case 41:
1486 #line 322 "./cond.y"
1487 {
1488 yyval.fn_comp_m1 = 0;
1489 ;}
1490 break;
1491
1492 case 42:
1493 #line 326 "./cond.y"
1494 {
1495 yyval.fn_comp_m1 = 0;
1496 ;}
1497 break;
1498
1499 case 43:
1500 #line 330 "./cond.y"
1501 {
1502 yyval.fn_comp_m1 = 0;
1503 ;}
1504 break;
1505
1506 case 44:
1507 #line 338 "./cond.y"
1508 {
1509 yyval.fn_comp_m2 = comp_eq_m2;
1510 ;}
1511 break;
1512
1513 case 45:
1514 #line 342 "./cond.y"
1515 {
1516 yyval.fn_comp_m2 = comp_ne_m2;
1517 ;}
1518 break;
1519
1520 case 46:
1521 #line 346 "./cond.y"
1522 {
1523 yyval.fn_comp_m2 = comp_lt_m2;
1524 ;}
1525 break;
1526
1527 case 47:
1528 #line 350 "./cond.y"
1529 {
1530 yyval.fn_comp_m2 = comp_gt_m2;
1531 ;}
1532 break;
1533
1534 case 48:
1535 #line 354 "./cond.y"
1536 {
1537 yyval.fn_comp_m2 = comp_le_m2;
1538 ;}
1539 break;
1540
1541 case 49:
1542 #line 358 "./cond.y"
1543 {
1544 yyval.fn_comp_m2 = comp_ge_m2;
1545 ;}
1546 break;
1547
1548 case 50:
1549 #line 363 "./cond.y"
1550 {
1551 yyval.fn_comp_m2 = 0;
1552 ;}
1553 break;
1554
1555 case 51:
1556 #line 367 "./cond.y"
1557 {
1558 yyval.fn_comp_m2 = 0;
1559 ;}
1560 break;
1561
1562 case 52:
1563 #line 371 "./cond.y"
1564 {
1565 yyval.fn_comp_m2 = 0;
1566 ;}
1567 break;
1568
1569 case 53:
1570 #line 378 "./cond.y"
1571 {
1572 yyval.value = yyvsp[0].value;
1573 ;}
1574 break;
1575
1576 case 54:
1577 #line 382 "./cond.y"
1578 {
1579 yyval.value = yyvsp[0].value;
1580 ;}
1581 break;
1582
1583 case 55:
1584 #line 389 "./cond.y"
1585 {
1586 yyval.string = yyvsp[0].string;
1587 ;}
1588 break;
1589
1590 case 56:
1591 #line 393 "./cond.y"
1592 {
1593 yyval.string = yyvsp[0].string;
1594 ;}
1595 break;
1596
1597 case 57:
1598 #line 400 "./cond.y"
1599 {
1600 yyval.string = COND_GetLiteral(&yyvsp[0].str);
1601 if( !yyval.string )
1602 YYABORT;
1603 ;}
1604 break;
1605
1606 case 58:
1607 #line 409 "./cond.y"
1608 {
1609 COND_input* cond = (COND_input*) info;
1610 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1611
1612 MSI_GetComponentStateW(cond->package, yyvsp[0].string, &install, &action );
1613 yyval.value = action;
1614 HeapFree( GetProcessHeap(), 0, yyvsp[0].string );
1615 ;}
1616 break;
1617
1618 case 59:
1619 #line 418 "./cond.y"
1620 {
1621 COND_input* cond = (COND_input*) info;
1622 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1623
1624 MSI_GetComponentStateW(cond->package, yyvsp[0].string, &install, &action );
1625 yyval.value = install;
1626 HeapFree( GetProcessHeap(), 0, yyvsp[0].string );
1627 ;}
1628 break;
1629
1630 case 60:
1631 #line 427 "./cond.y"
1632 {
1633 COND_input* cond = (COND_input*) info;
1634 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1635
1636 MSI_GetFeatureStateW(cond->package, yyvsp[0].string, &install, &action );
1637 yyval.value = action;
1638 HeapFree( GetProcessHeap(), 0, yyvsp[0].string );
1639 ;}
1640 break;
1641
1642 case 61:
1643 #line 436 "./cond.y"
1644 {
1645 COND_input* cond = (COND_input*) info;
1646 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1647
1648 MSI_GetFeatureStateW(cond->package, yyvsp[0].string, &install, &action );
1649 yyval.value = install;
1650 HeapFree( GetProcessHeap(), 0, yyvsp[0].string );
1651 ;}
1652 break;
1653
1654 case 62:
1655 #line 448 "./cond.y"
1656 {
1657 DWORD sz;
1658 COND_input* cond = (COND_input*) info;
1659
1660 sz = 0;
1661 MSI_GetPropertyW(cond->package, yyvsp[0].string, NULL, &sz);
1662 if (sz == 0)
1663 {
1664 yyval.string = HeapAlloc( GetProcessHeap(), 0 ,sizeof(WCHAR));
1665 yyval.string[0] = 0;
1666 }
1667 else
1668 {
1669 sz ++;
1670 yyval.string = HeapAlloc( GetProcessHeap(), 0, sz*sizeof (WCHAR) );
1671
1672 /* Lookup the identifier */
1673
1674 MSI_GetPropertyW(cond->package,yyvsp[0].string,yyval.string,&sz);
1675 }
1676 HeapFree( GetProcessHeap(), 0, yyvsp[0].string );
1677 ;}
1678 break;
1679
1680 case 63:
1681 #line 471 "./cond.y"
1682 {
1683 UINT len = GetEnvironmentVariableW( yyvsp[0].string, NULL, 0 );
1684 if( len++ )
1685 {
1686 yyval.string = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) );
1687 if( yyval.string )
1688 GetEnvironmentVariableW( yyvsp[0].string, yyval.string, len );
1689 }
1690 HeapFree( GetProcessHeap(), 0, yyvsp[0].string );
1691 ;}
1692 break;
1693
1694 case 64:
1695 #line 485 "./cond.y"
1696 {
1697 yyval.string = COND_GetString(&yyvsp[0].str);
1698 if( !yyval.string )
1699 YYABORT;
1700 ;}
1701 break;
1702
1703 case 65:
1704 #line 494 "./cond.y"
1705 {
1706 LPWSTR szNum = COND_GetString(&yyvsp[0].str);
1707 if( !szNum )
1708 YYABORT;
1709 yyval.value = atoiW( szNum );
1710 HeapFree( GetProcessHeap(), 0, szNum );
1711 ;}
1712 break;
1713
1714
1715 }
1716
1717 /* Line 999 of yacc.c. */
1718 #line 1719 "cond.tab.c"
1719 \f
1720 yyvsp -= yylen;
1721 yyssp -= yylen;
1722
1723
1724 YY_STACK_PRINT (yyss, yyssp);
1725
1726 *++yyvsp = yyval;
1727
1728
1729 /* Now `shift' the result of the reduction. Determine what state
1730 that goes to, based on the state we popped back to and the rule
1731 number reduced by. */
1732
1733 yyn = yyr1[yyn];
1734
1735 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1736 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1737 yystate = yytable[yystate];
1738 else
1739 yystate = yydefgoto[yyn - YYNTOKENS];
1740
1741 goto yynewstate;
1742
1743
1744 /*------------------------------------.
1745 | yyerrlab -- here on detecting error |
1746 `------------------------------------*/
1747 yyerrlab:
1748 /* If not already recovering from an error, report this error. */
1749 if (!yyerrstatus)
1750 {
1751 ++yynerrs;
1752 #if YYERROR_VERBOSE
1753 yyn = yypact[yystate];
1754
1755 if (YYPACT_NINF < yyn && yyn < YYLAST)
1756 {
1757 YYSIZE_T yysize = 0;
1758 int yytype = YYTRANSLATE (yychar);
1759 const char* yyprefix;
1760 char *yymsg;
1761 int yyx;
1762
1763 /* Start YYX at -YYN if negative to avoid negative indexes in
1764 YYCHECK. */
1765 int yyxbegin = yyn < 0 ? -yyn : 0;
1766
1767 /* Stay within bounds of both yycheck and yytname. */
1768 int yychecklim = YYLAST - yyn;
1769 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1770 int yycount = 0;
1771
1772 yyprefix = ", expecting ";
1773 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1774 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1775 {
1776 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1777 yycount += 1;
1778 if (yycount == 5)
1779 {
1780 yysize = 0;
1781 break;
1782 }
1783 }
1784 yysize += (sizeof ("syntax error, unexpected ")
1785 + yystrlen (yytname[yytype]));
1786 yymsg = (char *) YYSTACK_ALLOC (yysize);
1787 if (yymsg != 0)
1788 {
1789 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1790 yyp = yystpcpy (yyp, yytname[yytype]);
1791
1792 if (yycount < 5)
1793 {
1794 yyprefix = ", expecting ";
1795 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1796 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1797 {
1798 yyp = yystpcpy (yyp, yyprefix);
1799 yyp = yystpcpy (yyp, yytname[yyx]);
1800 yyprefix = " or ";
1801 }
1802 }
1803 yyerror (yymsg);
1804 YYSTACK_FREE (yymsg);
1805 }
1806 else
1807 yyerror ("syntax error; also virtual memory exhausted");
1808 }
1809 else
1810 #endif /* YYERROR_VERBOSE */
1811 yyerror ("syntax error");
1812 }
1813
1814
1815
1816 if (yyerrstatus == 3)
1817 {
1818 /* If just tried and failed to reuse lookahead token after an
1819 error, discard it. */
1820
1821 /* Return failure if at end of input. */
1822 if (yychar == YYEOF)
1823 {
1824 /* Pop the error token. */
1825 YYPOPSTACK;
1826 /* Pop the rest of the stack. */
1827 while (yyss < yyssp)
1828 {
1829 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1830 yydestruct (yystos[*yyssp], yyvsp);
1831 YYPOPSTACK;
1832 }
1833 YYABORT;
1834 }
1835
1836 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1837 yydestruct (yytoken, &yylval);
1838 yychar = YYEMPTY;
1839
1840 }
1841
1842 /* Else will try to reuse lookahead token after shifting the error
1843 token. */
1844 goto yyerrlab1;
1845
1846
1847 /*----------------------------------------------------.
1848 | yyerrlab1 -- error raised explicitly by an action. |
1849 `----------------------------------------------------*/
1850 yyerrlab1:
1851 yyerrstatus = 3; /* Each real token shifted decrements this. */
1852
1853 for (;;)
1854 {
1855 yyn = yypact[yystate];
1856 if (yyn != YYPACT_NINF)
1857 {
1858 yyn += YYTERROR;
1859 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1860 {
1861 yyn = yytable[yyn];
1862 if (0 < yyn)
1863 break;
1864 }
1865 }
1866
1867 /* Pop the current state because it cannot handle the error token. */
1868 if (yyssp == yyss)
1869 YYABORT;
1870
1871 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1872 yydestruct (yystos[yystate], yyvsp);
1873 yyvsp--;
1874 yystate = *--yyssp;
1875
1876 YY_STACK_PRINT (yyss, yyssp);
1877 }
1878
1879 if (yyn == YYFINAL)
1880 YYACCEPT;
1881
1882 YYDPRINTF ((stderr, "Shifting error token, "));
1883
1884 *++yyvsp = yylval;
1885
1886
1887 yystate = yyn;
1888 goto yynewstate;
1889
1890
1891 /*-------------------------------------.
1892 | yyacceptlab -- YYACCEPT comes here. |
1893 `-------------------------------------*/
1894 yyacceptlab:
1895 yyresult = 0;
1896 goto yyreturn;
1897
1898 /*-----------------------------------.
1899 | yyabortlab -- YYABORT comes here. |
1900 `-----------------------------------*/
1901 yyabortlab:
1902 yyresult = 1;
1903 goto yyreturn;
1904
1905 #ifndef yyoverflow
1906 /*----------------------------------------------.
1907 | yyoverflowlab -- parser overflow comes here. |
1908 `----------------------------------------------*/
1909 yyoverflowlab:
1910 yyerror ("parser stack overflow");
1911 yyresult = 2;
1912 /* Fall through. */
1913 #endif
1914
1915 yyreturn:
1916 #ifndef yyoverflow
1917 if (yyss != yyssa)
1918 YYSTACK_FREE (yyss);
1919 #endif
1920 return yyresult;
1921 }
1922
1923
1924 #line 503 "./cond.y"
1925
1926
1927
1928 static int COND_IsAlpha( WCHAR x )
1929 {
1930 return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) ||
1931 ( ( x >= 'a' ) && ( x <= 'z' ) ) ||
1932 ( ( x == '_' ) ) );
1933 }
1934
1935 static int COND_IsNumber( WCHAR x )
1936 {
1937 return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') );
1938 }
1939
1940
1941 /* the mess of comparison functions */
1942
1943 static INT comp_lt_i(INT a, INT b)
1944 { return (a < b); }
1945 static INT comp_gt_i(INT a, INT b)
1946 { return (a > b); }
1947 static INT comp_le_i(INT a, INT b)
1948 { return (a <= b); }
1949 static INT comp_ge_i(INT a, INT b)
1950 { return (a >= b); }
1951 static INT comp_eq_i(INT a, INT b)
1952 { return (a == b); }
1953 static INT comp_ne_i(INT a, INT b)
1954 { return (a != b); }
1955 static INT comp_bitand(INT a, INT b)
1956 { return a & b;}
1957 static INT comp_highcomp(INT a, INT b)
1958 { return HIWORD(a)==b; }
1959 static INT comp_lowcomp(INT a, INT b)
1960 { return LOWORD(a)==b; }
1961
1962 static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless)
1963 { if (casless) return !strcmpiW(a,b); else return !strcmpW(a,b);}
1964 static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless)
1965 { if (casless) return strcmpiW(a,b); else return strcmpW(a,b);}
1966 static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless)
1967 { if (casless) return strcmpiW(a,b)<0; else return strcmpW(a,b)<0;}
1968 static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless)
1969 { if (casless) return strcmpiW(a,b)>0; else return strcmpW(a,b)>0;}
1970 static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless)
1971 { if (casless) return strcmpiW(a,b)<=0; else return strcmpW(a,b)<=0;}
1972 static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless)
1973 { if (casless) return strcmpiW(a,b)>=0; else return strcmpW(a,b)>=0;}
1974 static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless)
1975 /* ERROR NOT WORKING REWRITE */
1976 { if (casless) return strstrW(a,b)!=NULL; else return strstrW(a,b)!=NULL;}
1977 static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless)
1978 { if (casless) return strncmpiW(a,b,strlenW(b))==0;
1979 else return strncmpW(a,b,strlenW(b))==0;}
1980 static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless)
1981 {
1982 int i = strlenW(a);
1983 int j = strlenW(b);
1984 if (j>i)
1985 return 0;
1986 if (casless) return (!strcmpiW(&a[i-j-1],b));
1987 else return (!strcmpW(&a[i-j-1],b));
1988 }
1989
1990
1991 static INT comp_eq_m1(LPWSTR a, INT b)
1992 { if (COND_IsNumber(a[0])) return atoiW(a)==b; else return 0;}
1993 static INT comp_ne_m1(LPWSTR a, INT b)
1994 { if (COND_IsNumber(a[0])) return atoiW(a)!=b; else return 1;}
1995 static INT comp_lt_m1(LPWSTR a, INT b)
1996 { if (COND_IsNumber(a[0])) return atoiW(a)<b; else return 0;}
1997 static INT comp_gt_m1(LPWSTR a, INT b)
1998 { if (COND_IsNumber(a[0])) return atoiW(a)>b; else return 0;}
1999 static INT comp_le_m1(LPWSTR a, INT b)
2000 { if (COND_IsNumber(a[0])) return atoiW(a)<=b; else return 0;}
2001 static INT comp_ge_m1(LPWSTR a, INT b)
2002 { if (COND_IsNumber(a[0])) return atoiW(a)>=b; else return 0;}
2003
2004 static INT comp_eq_m2(INT a, LPWSTR b)
2005 { if (COND_IsNumber(b[0])) return a == atoiW(b); else return 0;}
2006 static INT comp_ne_m2(INT a, LPWSTR b)
2007 { if (COND_IsNumber(b[0])) return a != atoiW(b); else return 1;}
2008 static INT comp_lt_m2(INT a, LPWSTR b)
2009 { if (COND_IsNumber(b[0])) return a < atoiW(b); else return 0;}
2010 static INT comp_gt_m2(INT a, LPWSTR b)
2011 { if (COND_IsNumber(b[0])) return a > atoiW(b); else return 0;}
2012 static INT comp_le_m2(INT a, LPWSTR b)
2013 { if (COND_IsNumber(b[0])) return a <= atoiW(b); else return 0;}
2014 static INT comp_ge_m2(INT a, LPWSTR b)
2015 { if (COND_IsNumber(b[0])) return a >= atoiW(b); else return 0;}
2016
2017
2018
2019 static int COND_IsIdent( WCHAR x )
2020 {
2021 return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' )
2022 || ( x == '#' ) || (x == '.') );
2023 }
2024
2025 static int COND_GetOne( struct cond_str *str, COND_input *cond )
2026 {
2027 static const WCHAR szNot[] = {'N','O','T',0};
2028 static const WCHAR szAnd[] = {'A','N','D',0};
2029 static const WCHAR szOr[] = {'O','R',0};
2030 WCHAR ch;
2031 int rc, len = 1;
2032
2033 str->data = &cond->str[cond->n];
2034
2035 ch = str->data[0];
2036 switch( ch )
2037 {
2038 case 0: return 0;
2039 case '(': rc = COND_LPAR; break;
2040 case ')': rc = COND_RPAR; break;
2041 case '&': rc = COND_AMPER; break;
2042 case '!': rc = COND_EXCLAM; break;
2043 case '$': rc = COND_DOLLARS; break;
2044 case '?': rc = COND_QUESTION; break;
2045 case '%': rc = COND_PERCENT; break;
2046 case ' ': rc = COND_SPACE; break;
2047 case '=': rc = COND_EQ; break;
2048 case '~': rc = COND_TILDA; break;
2049 case '<': rc = COND_LT; break;
2050 case '>': rc = COND_GT; break;
2051 case '"':
2052 {
2053 const WCHAR *ch2 = str->data + 1;
2054
2055
2056 while ( *ch2 && *ch2 != '"' )
2057 ++ch2;
2058 if (*ch2 == '"')
2059 {
2060 len = ch2 - str->data + 1;
2061 rc = COND_LITER;
2062 break;
2063 }
2064 }
2065 ERR("Unterminated string\n");
2066 rc = COND_ERROR;
2067 break;
2068 default:
2069 if( COND_IsAlpha( ch ) )
2070 {
2071 while( COND_IsIdent( str->data[len] ) )
2072 len++;
2073 rc = COND_IDENT;
2074 break;
2075 }
2076
2077 if( COND_IsNumber( ch ) )
2078 {
2079 while( COND_IsNumber( str->data[len] ) )
2080 len++;
2081 rc = COND_NUMBER;
2082 break;
2083 }
2084
2085 ERR("Got unknown character %c(%x)\n",ch,ch);
2086 rc = COND_ERROR;
2087 break;
2088 }
2089
2090 /* keyword identifiers */
2091 if( rc == COND_IDENT )
2092 {
2093 if( (len==3) && (strncmpiW(str->data,szNot,len)==0) )
2094 rc = COND_NOT;
2095 else if( (len==3) && (strncmpiW(str->data,szAnd,len)==0) )
2096 rc = COND_AND;
2097 else if( (len==2) && (strncmpiW(str->data,szOr,len)==0) )
2098 rc = COND_OR;
2099 }
2100
2101 cond->n += len;
2102 str->len = len;
2103
2104 return rc;
2105 }
2106
2107 static int COND_lex( void *COND_lval, COND_input *cond )
2108 {
2109 int rc;
2110 struct cond_str *str = COND_lval;
2111
2112 do {
2113 rc = COND_GetOne( str, cond );
2114 } while (rc == COND_SPACE);
2115
2116 return rc;
2117 }
2118
2119 static LPWSTR COND_GetString( struct cond_str *str )
2120 {
2121 LPWSTR ret;
2122
2123 ret = HeapAlloc( GetProcessHeap(), 0, (str->len+1) * sizeof (WCHAR) );
2124 if( ret )
2125 {
2126 strncpyW( ret, str->data, str->len );
2127 ret[str->len]=0;
2128 }
2129 TRACE("Got identifier %s\n",debugstr_w(ret));
2130 return ret;
2131 }
2132
2133 static LPWSTR COND_GetLiteral( struct cond_str *str )
2134 {
2135 LPWSTR ret;
2136
2137 ret = HeapAlloc( GetProcessHeap(), 0, (str->len-1) * sizeof (WCHAR) );
2138 if( ret )
2139 {
2140 memcpy( ret, str->data+1, (str->len-2) * sizeof(WCHAR) );
2141 ret[str->len - 2]=0;
2142 }
2143 TRACE("Got literal %s\n",debugstr_w(ret));
2144 return ret;
2145 }
2146
2147 static int COND_error(char *str)
2148 {
2149 return 0;
2150 }
2151
2152 MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
2153 {
2154 COND_input cond;
2155 MSICONDITION r;
2156
2157 cond.package = package;
2158 cond.str = szCondition;
2159 cond.n = 0;
2160 cond.result = -1;
2161
2162 TRACE("Evaluating %s\n",debugstr_w(szCondition));
2163
2164 if( szCondition && !COND_parse( &cond ) )
2165 r = cond.result;
2166 else
2167 r = MSICONDITION_ERROR;
2168
2169 TRACE("Evaluates to %i\n",r);
2170 return r;
2171 }
2172
2173 MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition )
2174 {
2175 MSIPACKAGE *package;
2176 UINT ret;
2177
2178 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
2179 if( !package)
2180 return ERROR_INVALID_HANDLE;
2181 ret = MSI_EvaluateConditionW( package, szCondition );
2182 msiobj_release( &package->hdr );
2183 return ret;
2184 }
2185
2186 MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition )
2187 {
2188 LPWSTR szwCond = NULL;
2189 MSICONDITION r;
2190
2191 if( szCondition )
2192 {
2193 UINT len = MultiByteToWideChar( CP_ACP, 0, szCondition, -1, NULL, 0 );
2194 szwCond = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
2195 MultiByteToWideChar( CP_ACP, 0, szCondition, -1, szwCond, len );
2196 }
2197
2198 r = MsiEvaluateConditionW( hInstall, szwCond );
2199
2200 HeapFree( GetProcessHeap(), 0, szwCond );
2201
2202 return r;
2203 }
2204