[MSI] Prevent uninitialized variable usage
[reactos.git] / dll / win32 / msi / cond.tab.c
1 /* A Bison parser, made by GNU Bison 3.0. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 1
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62 /* Substitute the variable and function names. */
63 #define yyparse cond_parse
64 #define yylex cond_lex
65 #define yyerror cond_error
66 #define yydebug cond_debug
67 #define yynerrs cond_nerrs
68
69
70 /* Copy the first part of user declarations. */
71 #line 1 "cond.y" /* yacc.c:339 */
72
73
74 /*
75 * Implementation of the Microsoft Installer (msi.dll)
76 *
77 * Copyright 2003 Mike McCormack for CodeWeavers
78 *
79 * This library is free software; you can redistribute it and/or
80 * modify it under the terms of the GNU Lesser General Public
81 * License as published by the Free Software Foundation; either
82 * version 2.1 of the License, or (at your option) any later version.
83 *
84 * This library is distributed in the hope that it will be useful,
85 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87 * Lesser General Public License for more details.
88 *
89 * You should have received a copy of the GNU Lesser General Public
90 * License along with this library; if not, write to the Free Software
91 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
92 */
93
94 #define COBJMACROS
95
96 #include "config.h"
97
98 #include <stdarg.h>
99 #include <stdio.h>
100 #include <stdlib.h>
101
102 #include "windef.h"
103 #include "winbase.h"
104 #include "winuser.h"
105 #include "msi.h"
106 #include "msiquery.h"
107 #include "objbase.h"
108 #include "oleauto.h"
109
110 #include "msipriv.h"
111 #include "msiserver.h"
112 #include "wine/debug.h"
113 #include "wine/unicode.h"
114 #include "wine/list.h"
115
116 WINE_DEFAULT_DEBUG_CHANNEL(msi);
117
118 typedef struct tag_yyinput
119 {
120 MSIPACKAGE *package;
121 LPCWSTR str;
122 INT n;
123 MSICONDITION result;
124 struct list mem;
125 } COND_input;
126
127 struct cond_str {
128 LPCWSTR data;
129 INT len;
130 };
131
132 struct value {
133 enum value_type {
134 VALUE_INTEGER,
135 VALUE_LITERAL,
136 VALUE_SYMBOL
137 } type;
138 union {
139 INT integer;
140 WCHAR *string;
141 } u;
142 };
143
144 static LPWSTR COND_GetString( COND_input *info, const struct cond_str *str );
145 static LPWSTR COND_GetLiteral( COND_input *info, const struct cond_str *str );
146 static int cond_lex( void *COND_lval, COND_input *info);
147 static int cond_error( COND_input *info, const char *str);
148
149 static void *cond_alloc( COND_input *cond, unsigned int sz );
150 static void *cond_track_mem( COND_input *cond, void *ptr, unsigned int sz );
151 static void cond_free( void *ptr );
152
153 static INT compare_int( INT a, INT operator, INT b );
154 static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b, BOOL convert );
155
156 static BOOL num_from_prop( LPCWSTR p, INT *val )
157 {
158 INT ret = 0, sign = 1;
159
160 if (!p)
161 return FALSE;
162 if (*p == '-')
163 {
164 sign = -1;
165 p++;
166 }
167 if (!*p)
168 return FALSE;
169 while (*p)
170 {
171 if( *p < '0' || *p > '9' )
172 return FALSE;
173 ret = ret*10 + (*p - '0');
174 p++;
175 }
176 *val = ret*sign;
177 return TRUE;
178 }
179
180 static void value_free( struct value val )
181 {
182 if (val.type != VALUE_INTEGER)
183 cond_free( val.u.string );
184 }
185
186
187 #line 188 "cond.tab.c" /* yacc.c:339 */
188
189 # ifndef YY_NULL
190 # if defined __cplusplus && 201103L <= __cplusplus
191 # define YY_NULL nullptr
192 # else
193 # define YY_NULL 0
194 # endif
195 # endif
196
197 /* Enabling verbose error messages. */
198 #ifdef YYERROR_VERBOSE
199 # undef YYERROR_VERBOSE
200 # define YYERROR_VERBOSE 1
201 #else
202 # define YYERROR_VERBOSE 0
203 #endif
204
205 /* In a future release of Bison, this section will be replaced
206 by #include "cond.tab.h". */
207 #ifndef YY_COND_E_REACTOSSYNC_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED
208 # define YY_COND_E_REACTOSSYNC_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED
209 /* Debug traces. */
210 #ifndef YYDEBUG
211 # define YYDEBUG 0
212 #endif
213 #if YYDEBUG
214 extern int cond_debug;
215 #endif
216
217 /* Token type. */
218 #ifndef YYTOKENTYPE
219 # define YYTOKENTYPE
220 enum yytokentype
221 {
222 COND_SPACE = 258,
223 COND_EOF = 259,
224 COND_OR = 260,
225 COND_AND = 261,
226 COND_NOT = 262,
227 COND_XOR = 263,
228 COND_IMP = 264,
229 COND_EQV = 265,
230 COND_LT = 266,
231 COND_GT = 267,
232 COND_EQ = 268,
233 COND_NE = 269,
234 COND_GE = 270,
235 COND_LE = 271,
236 COND_ILT = 272,
237 COND_IGT = 273,
238 COND_IEQ = 274,
239 COND_INE = 275,
240 COND_IGE = 276,
241 COND_ILE = 277,
242 COND_LPAR = 278,
243 COND_RPAR = 279,
244 COND_TILDA = 280,
245 COND_SS = 281,
246 COND_ISS = 282,
247 COND_ILHS = 283,
248 COND_IRHS = 284,
249 COND_LHS = 285,
250 COND_RHS = 286,
251 COND_PERCENT = 287,
252 COND_DOLLARS = 288,
253 COND_QUESTION = 289,
254 COND_AMPER = 290,
255 COND_EXCLAM = 291,
256 COND_IDENT = 292,
257 COND_NUMBER = 293,
258 COND_LITER = 294,
259 COND_ERROR = 295
260 };
261 #endif
262
263 /* Value type. */
264 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
265 typedef union YYSTYPE YYSTYPE;
266 union YYSTYPE
267 {
268 #line 122 "cond.y" /* yacc.c:355 */
269
270 struct cond_str str;
271 struct value value;
272 LPWSTR identifier;
273 INT operator;
274 BOOL bool;
275
276 #line 277 "cond.tab.c" /* yacc.c:355 */
277 };
278 # define YYSTYPE_IS_TRIVIAL 1
279 # define YYSTYPE_IS_DECLARED 1
280 #endif
281
282
283
284 int cond_parse (COND_input *info);
285
286 #endif /* !YY_COND_E_REACTOSSYNC_GCC_DLL_WIN32_MSI_COND_TAB_H_INCLUDED */
287
288 /* Copy the second part of user declarations. */
289
290 #line 291 "cond.tab.c" /* yacc.c:358 */
291
292 #ifdef short
293 # undef short
294 #endif
295
296 #ifdef YYTYPE_UINT8
297 typedef YYTYPE_UINT8 yytype_uint8;
298 #else
299 typedef unsigned char yytype_uint8;
300 #endif
301
302 #ifdef YYTYPE_INT8
303 typedef YYTYPE_INT8 yytype_int8;
304 #else
305 typedef signed char yytype_int8;
306 #endif
307
308 #ifdef YYTYPE_UINT16
309 typedef YYTYPE_UINT16 yytype_uint16;
310 #else
311 typedef unsigned short int yytype_uint16;
312 #endif
313
314 #ifdef YYTYPE_INT16
315 typedef YYTYPE_INT16 yytype_int16;
316 #else
317 typedef short int yytype_int16;
318 #endif
319
320 #ifndef YYSIZE_T
321 # ifdef __SIZE_TYPE__
322 # define YYSIZE_T __SIZE_TYPE__
323 # elif defined size_t
324 # define YYSIZE_T size_t
325 # elif ! defined YYSIZE_T
326 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
327 # define YYSIZE_T size_t
328 # else
329 # define YYSIZE_T unsigned int
330 # endif
331 #endif
332
333 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
334
335 #ifndef YY_
336 # if defined YYENABLE_NLS && YYENABLE_NLS
337 # if ENABLE_NLS
338 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
339 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
340 # endif
341 # endif
342 # ifndef YY_
343 # define YY_(Msgid) Msgid
344 # endif
345 #endif
346
347 #ifndef __attribute__
348 /* This feature is available in gcc versions 2.5 and later. */
349 # if (! defined __GNUC__ || __GNUC__ < 2 \
350 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
351 # define __attribute__(Spec) /* empty */
352 # endif
353 #endif
354
355 /* Suppress unused-variable warnings by "using" E. */
356 #if ! defined lint || defined __GNUC__
357 # define YYUSE(E) ((void) (E))
358 #else
359 # define YYUSE(E) /* empty */
360 #endif
361
362 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
363 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
364 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
365 _Pragma ("GCC diagnostic push") \
366 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
367 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
368 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
369 _Pragma ("GCC diagnostic pop")
370 #else
371 # define YY_INITIAL_VALUE(Value) Value
372 #endif
373 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
374 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
375 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
376 #endif
377 #ifndef YY_INITIAL_VALUE
378 # define YY_INITIAL_VALUE(Value) /* Nothing. */
379 #endif
380
381
382 #if ! defined yyoverflow || YYERROR_VERBOSE
383
384 /* The parser invokes alloca or malloc; define the necessary symbols. */
385
386 # ifdef YYSTACK_USE_ALLOCA
387 # if YYSTACK_USE_ALLOCA
388 # ifdef __GNUC__
389 # define YYSTACK_ALLOC __builtin_alloca
390 # elif defined __BUILTIN_VA_ARG_INCR
391 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
392 # elif defined _AIX
393 # define YYSTACK_ALLOC __alloca
394 # elif defined _MSC_VER
395 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
396 # define alloca _alloca
397 # else
398 # define YYSTACK_ALLOC alloca
399 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
400 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
401 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
402 # ifndef EXIT_SUCCESS
403 # define EXIT_SUCCESS 0
404 # endif
405 # endif
406 # endif
407 # endif
408 # endif
409
410 # ifdef YYSTACK_ALLOC
411 /* Pacify GCC's 'empty if-body' warning. */
412 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
413 # ifndef YYSTACK_ALLOC_MAXIMUM
414 /* The OS might guarantee only one guard page at the bottom of the stack,
415 and a page size can be as small as 4096 bytes. So we cannot safely
416 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
417 to allow for a few compiler-allocated temporary stack slots. */
418 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
419 # endif
420 # else
421 # define YYSTACK_ALLOC YYMALLOC
422 # define YYSTACK_FREE YYFREE
423 # ifndef YYSTACK_ALLOC_MAXIMUM
424 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
425 # endif
426 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
427 && ! ((defined YYMALLOC || defined malloc) \
428 && (defined YYFREE || defined free)))
429 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
430 # ifndef EXIT_SUCCESS
431 # define EXIT_SUCCESS 0
432 # endif
433 # endif
434 # ifndef YYMALLOC
435 # define YYMALLOC malloc
436 # if ! defined malloc && ! defined EXIT_SUCCESS
437 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
438 # endif
439 # endif
440 # ifndef YYFREE
441 # define YYFREE free
442 # if ! defined free && ! defined EXIT_SUCCESS
443 void free (void *); /* INFRINGES ON USER NAME SPACE */
444 # endif
445 # endif
446 # endif
447 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
448
449
450 #if (! defined yyoverflow \
451 && (! defined __cplusplus \
452 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
453
454 /* A type that is properly aligned for any stack member. */
455 union yyalloc
456 {
457 yytype_int16 yyss_alloc;
458 YYSTYPE yyvs_alloc;
459 };
460
461 /* The size of the maximum gap between one aligned stack and the next. */
462 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
463
464 /* The size of an array large to enough to hold all stacks, each with
465 N elements. */
466 # define YYSTACK_BYTES(N) \
467 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
468 + YYSTACK_GAP_MAXIMUM)
469
470 # define YYCOPY_NEEDED 1
471
472 /* Relocate STACK from its old location to the new one. The
473 local variables YYSIZE and YYSTACKSIZE give the old and new number of
474 elements in the stack, and YYPTR gives the new location of the
475 stack. Advance YYPTR to a properly aligned location for the next
476 stack. */
477 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
478 do \
479 { \
480 YYSIZE_T yynewbytes; \
481 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
482 Stack = &yyptr->Stack_alloc; \
483 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
484 yyptr += yynewbytes / sizeof (*yyptr); \
485 } \
486 while (0)
487
488 #endif
489
490 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
491 /* Copy COUNT objects from SRC to DST. The source and destination do
492 not overlap. */
493 # ifndef YYCOPY
494 # if defined __GNUC__ && 1 < __GNUC__
495 # define YYCOPY(Dst, Src, Count) \
496 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
497 # else
498 # define YYCOPY(Dst, Src, Count) \
499 do \
500 { \
501 YYSIZE_T yyi; \
502 for (yyi = 0; yyi < (Count); yyi++) \
503 (Dst)[yyi] = (Src)[yyi]; \
504 } \
505 while (0)
506 # endif
507 # endif
508 #endif /* !YYCOPY_NEEDED */
509
510 /* YYFINAL -- State number of the termination state. */
511 #define YYFINAL 24
512 /* YYLAST -- Last index in YYTABLE. */
513 #define YYLAST 67
514
515 /* YYNTOKENS -- Number of terminals. */
516 #define YYNTOKENS 41
517 /* YYNNTS -- Number of nonterminals. */
518 #define YYNNTS 8
519 /* YYNRULES -- Number of rules. */
520 #define YYNRULES 41
521 /* YYNSTATES -- Number of states. */
522 #define YYNSTATES 56
523
524 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
525 by yylex, with out-of-bounds checking. */
526 #define YYUNDEFTOK 2
527 #define YYMAXUTOK 295
528
529 #define YYTRANSLATE(YYX) \
530 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
531
532 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
533 as returned by yylex, without out-of-bounds checking. */
534 static const yytype_uint8 yytranslate[] =
535 {
536 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
562 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
563 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
564 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
565 35, 36, 37, 38, 39, 40
566 };
567
568 #if YYDEBUG
569 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
570 static const yytype_uint16 yyrline[] =
571 {
572 0, 149, 149, 155, 162, 166, 170, 174, 178, 185,
573 189, 196, 200, 208, 243, 251, 252, 253, 254, 255,
574 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
575 266, 267, 268, 272, 286, 301, 309, 319, 336, 353,
576 370, 390
577 };
578 #endif
579
580 #if YYDEBUG || YYERROR_VERBOSE || 0
581 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
582 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
583 static const char *const yytname[] =
584 {
585 "$end", "error", "$undefined", "COND_SPACE", "COND_EOF", "COND_OR",
586 "COND_AND", "COND_NOT", "COND_XOR", "COND_IMP", "COND_EQV", "COND_LT",
587 "COND_GT", "COND_EQ", "COND_NE", "COND_GE", "COND_LE", "COND_ILT",
588 "COND_IGT", "COND_IEQ", "COND_INE", "COND_IGE", "COND_ILE", "COND_LPAR",
589 "COND_RPAR", "COND_TILDA", "COND_SS", "COND_ISS", "COND_ILHS",
590 "COND_IRHS", "COND_LHS", "COND_RHS", "COND_PERCENT", "COND_DOLLARS",
591 "COND_QUESTION", "COND_AMPER", "COND_EXCLAM", "COND_IDENT",
592 "COND_NUMBER", "COND_LITER", "COND_ERROR", "$accept", "condition",
593 "expression", "boolean_term", "boolean_factor", "operator", "value",
594 "identifier", YY_NULL
595 };
596 #endif
597
598 # ifdef YYPRINT
599 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
600 (internal) symbol number NUM (which must be that of a token). */
601 static const yytype_uint16 yytoknum[] =
602 {
603 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
604 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
605 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
606 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
607 295
608 };
609 # endif
610
611 #define YYPACT_NINF -45
612
613 #define yypact_value_is_default(Yystate) \
614 (!!((Yystate) == (-45)))
615
616 #define YYTABLE_NINF -1
617
618 #define yytable_value_is_error(Yytable_value) \
619 0
620
621 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
622 STATE-NUM. */
623 static const yytype_int8 yypact[] =
624 {
625 -7, -7, -7, -36, -36, -36, -36, -36, -45, -45,
626 -45, 2, 5, 3, -45, 23, -45, -45, -2, -45,
627 -45, -45, -45, -45, -45, -7, -7, -7, -7, -7,
628 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
629 -45, -45, -45, -45, -45, -45, -45, -45, 24, -45,
630 3, 3, 3, 3, -45, -45
631 };
632
633 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
634 Performed when YYTABLE does not specify something else to do. Zero
635 means the default is an error. */
636 static const yytype_uint8 yydefact[] =
637 {
638 3, 0, 0, 0, 0, 0, 0, 0, 41, 36,
639 35, 0, 2, 4, 9, 12, 33, 11, 0, 34,
640 37, 38, 39, 40, 1, 0, 0, 0, 0, 0,
641 17, 18, 15, 16, 20, 19, 24, 25, 22, 23,
642 27, 26, 21, 28, 31, 32, 29, 30, 0, 14,
643 5, 7, 6, 8, 10, 13
644 };
645
646 /* YYPGOTO[NTERM-NUM]. */
647 static const yytype_int8 yypgoto[] =
648 {
649 -45, -45, 9, 39, 4, -45, -44, 14
650 };
651
652 /* YYDEFGOTO[NTERM-NUM]. */
653 static const yytype_int8 yydefgoto[] =
654 {
655 -1, 11, 12, 13, 14, 48, 15, 16
656 };
657
658 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
659 positive, shift that token. If negative, reduce the rule whose
660 number is the opposite. If YYTABLE_NINF, syntax error. */
661 static const yytype_uint8 yytable[] =
662 {
663 1, 8, 24, 25, 55, 17, 26, 27, 28, 29,
664 25, 18, 0, 26, 27, 28, 2, 19, 20, 21,
665 22, 23, 49, 0, 0, 3, 4, 5, 6, 7,
666 8, 9, 10, 54, 30, 31, 32, 33, 34, 35,
667 36, 37, 38, 39, 40, 41, 0, 0, 0, 42,
668 43, 44, 45, 46, 47, 0, 3, 4, 5, 6,
669 7, 8, 9, 10, 50, 51, 52, 53
670 };
671
672 static const yytype_int8 yycheck[] =
673 {
674 7, 37, 0, 5, 48, 1, 8, 9, 10, 6,
675 5, 2, -1, 8, 9, 10, 23, 3, 4, 5,
676 6, 7, 24, -1, -1, 32, 33, 34, 35, 36,
677 37, 38, 39, 29, 11, 12, 13, 14, 15, 16,
678 17, 18, 19, 20, 21, 22, -1, -1, -1, 26,
679 27, 28, 29, 30, 31, -1, 32, 33, 34, 35,
680 36, 37, 38, 39, 25, 26, 27, 28
681 };
682
683 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
684 symbol of state STATE-NUM. */
685 static const yytype_uint8 yystos[] =
686 {
687 0, 7, 23, 32, 33, 34, 35, 36, 37, 38,
688 39, 42, 43, 44, 45, 47, 48, 45, 43, 48,
689 48, 48, 48, 48, 0, 5, 8, 9, 10, 6,
690 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
691 21, 22, 26, 27, 28, 29, 30, 31, 46, 24,
692 44, 44, 44, 44, 45, 47
693 };
694
695 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
696 static const yytype_uint8 yyr1[] =
697 {
698 0, 41, 42, 42, 43, 43, 43, 43, 43, 44,
699 44, 45, 45, 45, 45, 46, 46, 46, 46, 46,
700 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
701 46, 46, 46, 47, 47, 47, 47, 47, 47, 47,
702 47, 48
703 };
704
705 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
706 static const yytype_uint8 yyr2[] =
707 {
708 0, 2, 1, 0, 1, 3, 3, 3, 3, 1,
709 3, 2, 1, 3, 3, 1, 1, 1, 1, 1,
710 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
711 1, 1, 1, 1, 2, 1, 1, 2, 2, 2,
712 2, 1
713 };
714
715
716 #define yyerrok (yyerrstatus = 0)
717 #define yyclearin (yychar = YYEMPTY)
718 #define YYEMPTY (-2)
719 #define YYEOF 0
720
721 #define YYACCEPT goto yyacceptlab
722 #define YYABORT goto yyabortlab
723 #define YYERROR goto yyerrorlab
724
725
726 #define YYRECOVERING() (!!yyerrstatus)
727
728 #define YYBACKUP(Token, Value) \
729 do \
730 if (yychar == YYEMPTY) \
731 { \
732 yychar = (Token); \
733 yylval = (Value); \
734 YYPOPSTACK (yylen); \
735 yystate = *yyssp; \
736 goto yybackup; \
737 } \
738 else \
739 { \
740 yyerror (info, YY_("syntax error: cannot back up")); \
741 YYERROR; \
742 } \
743 while (0)
744
745 /* Error token number */
746 #define YYTERROR 1
747 #define YYERRCODE 256
748
749
750
751 /* Enable debugging if requested. */
752 #if YYDEBUG
753
754 # ifndef YYFPRINTF
755 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
756 # define YYFPRINTF fprintf
757 # endif
758
759 # define YYDPRINTF(Args) \
760 do { \
761 if (yydebug) \
762 YYFPRINTF Args; \
763 } while (0)
764
765 /* This macro is provided for backward compatibility. */
766 #ifndef YY_LOCATION_PRINT
767 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
768 #endif
769
770
771 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
772 do { \
773 if (yydebug) \
774 { \
775 YYFPRINTF (stderr, "%s ", Title); \
776 yy_symbol_print (stderr, \
777 Type, Value, info); \
778 YYFPRINTF (stderr, "\n"); \
779 } \
780 } while (0)
781
782
783 /*----------------------------------------.
784 | Print this symbol's value on YYOUTPUT. |
785 `----------------------------------------*/
786
787 static void
788 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, COND_input *info)
789 {
790 FILE *yyo = yyoutput;
791 YYUSE (yyo);
792 YYUSE (info);
793 if (!yyvaluep)
794 return;
795 # ifdef YYPRINT
796 if (yytype < YYNTOKENS)
797 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
798 # endif
799 YYUSE (yytype);
800 }
801
802
803 /*--------------------------------.
804 | Print this symbol on YYOUTPUT. |
805 `--------------------------------*/
806
807 static void
808 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, COND_input *info)
809 {
810 YYFPRINTF (yyoutput, "%s %s (",
811 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
812
813 yy_symbol_value_print (yyoutput, yytype, yyvaluep, info);
814 YYFPRINTF (yyoutput, ")");
815 }
816
817 /*------------------------------------------------------------------.
818 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
819 | TOP (included). |
820 `------------------------------------------------------------------*/
821
822 static void
823 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
824 {
825 YYFPRINTF (stderr, "Stack now");
826 for (; yybottom <= yytop; yybottom++)
827 {
828 int yybot = *yybottom;
829 YYFPRINTF (stderr, " %d", yybot);
830 }
831 YYFPRINTF (stderr, "\n");
832 }
833
834 # define YY_STACK_PRINT(Bottom, Top) \
835 do { \
836 if (yydebug) \
837 yy_stack_print ((Bottom), (Top)); \
838 } while (0)
839
840
841 /*------------------------------------------------.
842 | Report that the YYRULE is going to be reduced. |
843 `------------------------------------------------*/
844
845 static void
846 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, COND_input *info)
847 {
848 unsigned long int yylno = yyrline[yyrule];
849 int yynrhs = yyr2[yyrule];
850 int yyi;
851 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
852 yyrule - 1, yylno);
853 /* The symbols being reduced. */
854 for (yyi = 0; yyi < yynrhs; yyi++)
855 {
856 YYFPRINTF (stderr, " $%d = ", yyi + 1);
857 yy_symbol_print (stderr,
858 yystos[yyssp[yyi + 1 - yynrhs]],
859 &(yyvsp[(yyi + 1) - (yynrhs)])
860 , info);
861 YYFPRINTF (stderr, "\n");
862 }
863 }
864
865 # define YY_REDUCE_PRINT(Rule) \
866 do { \
867 if (yydebug) \
868 yy_reduce_print (yyssp, yyvsp, Rule, info); \
869 } while (0)
870
871 /* Nonzero means print parse trace. It is left uninitialized so that
872 multiple parsers can coexist. */
873 int yydebug;
874 #else /* !YYDEBUG */
875 # define YYDPRINTF(Args)
876 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
877 # define YY_STACK_PRINT(Bottom, Top)
878 # define YY_REDUCE_PRINT(Rule)
879 #endif /* !YYDEBUG */
880
881
882 /* YYINITDEPTH -- initial size of the parser's stacks. */
883 #ifndef YYINITDEPTH
884 # define YYINITDEPTH 200
885 #endif
886
887 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
888 if the built-in stack extension method is used).
889
890 Do not make this value too large; the results are undefined if
891 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
892 evaluated with infinite-precision integer arithmetic. */
893
894 #ifndef YYMAXDEPTH
895 # define YYMAXDEPTH 10000
896 #endif
897
898
899 #if YYERROR_VERBOSE
900
901 # ifndef yystrlen
902 # if defined __GLIBC__ && defined _STRING_H
903 # define yystrlen strlen
904 # else
905 /* Return the length of YYSTR. */
906 static YYSIZE_T
907 yystrlen (const char *yystr)
908 {
909 YYSIZE_T yylen;
910 for (yylen = 0; yystr[yylen]; yylen++)
911 continue;
912 return yylen;
913 }
914 # endif
915 # endif
916
917 # ifndef yystpcpy
918 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
919 # define yystpcpy stpcpy
920 # else
921 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
922 YYDEST. */
923 static char *
924 yystpcpy (char *yydest, const char *yysrc)
925 {
926 char *yyd = yydest;
927 const char *yys = yysrc;
928
929 while ((*yyd++ = *yys++) != '\0')
930 continue;
931
932 return yyd - 1;
933 }
934 # endif
935 # endif
936
937 # ifndef yytnamerr
938 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
939 quotes and backslashes, so that it's suitable for yyerror. The
940 heuristic is that double-quoting is unnecessary unless the string
941 contains an apostrophe, a comma, or backslash (other than
942 backslash-backslash). YYSTR is taken from yytname. If YYRES is
943 null, do not copy; instead, return the length of what the result
944 would have been. */
945 static YYSIZE_T
946 yytnamerr (char *yyres, const char *yystr)
947 {
948 if (*yystr == '"')
949 {
950 YYSIZE_T yyn = 0;
951 char const *yyp = yystr;
952
953 for (;;)
954 switch (*++yyp)
955 {
956 case '\'':
957 case ',':
958 goto do_not_strip_quotes;
959
960 case '\\':
961 if (*++yyp != '\\')
962 goto do_not_strip_quotes;
963 /* Fall through. */
964 default:
965 if (yyres)
966 yyres[yyn] = *yyp;
967 yyn++;
968 break;
969
970 case '"':
971 if (yyres)
972 yyres[yyn] = '\0';
973 return yyn;
974 }
975 do_not_strip_quotes: ;
976 }
977
978 if (! yyres)
979 return yystrlen (yystr);
980
981 return yystpcpy (yyres, yystr) - yyres;
982 }
983 # endif
984
985 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
986 about the unexpected token YYTOKEN for the state stack whose top is
987 YYSSP.
988
989 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
990 not large enough to hold the message. In that case, also set
991 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
992 required number of bytes is too large to store. */
993 static int
994 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
995 yytype_int16 *yyssp, int yytoken)
996 {
997 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
998 YYSIZE_T yysize = yysize0;
999 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1000 /* Internationalized format string. */
1001 const char *yyformat = YY_NULL;
1002 /* Arguments of yyformat. */
1003 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1004 /* Number of reported tokens (one for the "unexpected", one per
1005 "expected"). */
1006 int yycount = 0;
1007
1008 /* There are many possibilities here to consider:
1009 - If this state is a consistent state with a default action, then
1010 the only way this function was invoked is if the default action
1011 is an error action. In that case, don't check for expected
1012 tokens because there are none.
1013 - The only way there can be no lookahead present (in yychar) is if
1014 this state is a consistent state with a default action. Thus,
1015 detecting the absence of a lookahead is sufficient to determine
1016 that there is no unexpected or expected token to report. In that
1017 case, just report a simple "syntax error".
1018 - Don't assume there isn't a lookahead just because this state is a
1019 consistent state with a default action. There might have been a
1020 previous inconsistent state, consistent state with a non-default
1021 action, or user semantic action that manipulated yychar.
1022 - Of course, the expected token list depends on states to have
1023 correct lookahead information, and it depends on the parser not
1024 to perform extra reductions after fetching a lookahead from the
1025 scanner and before detecting a syntax error. Thus, state merging
1026 (from LALR or IELR) and default reductions corrupt the expected
1027 token list. However, the list is correct for canonical LR with
1028 one exception: it will still contain any token that will not be
1029 accepted due to an error action in a later state.
1030 */
1031 if (yytoken != YYEMPTY)
1032 {
1033 int yyn = yypact[*yyssp];
1034 yyarg[yycount++] = yytname[yytoken];
1035 if (!yypact_value_is_default (yyn))
1036 {
1037 /* Start YYX at -YYN if negative to avoid negative indexes in
1038 YYCHECK. In other words, skip the first -YYN actions for
1039 this state because they are default actions. */
1040 int yyxbegin = yyn < 0 ? -yyn : 0;
1041 /* Stay within bounds of both yycheck and yytname. */
1042 int yychecklim = YYLAST - yyn + 1;
1043 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1044 int yyx;
1045
1046 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1047 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1048 && !yytable_value_is_error (yytable[yyx + yyn]))
1049 {
1050 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1051 {
1052 yycount = 1;
1053 yysize = yysize0;
1054 break;
1055 }
1056 yyarg[yycount++] = yytname[yyx];
1057 {
1058 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1059 if (! (yysize <= yysize1
1060 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1061 return 2;
1062 yysize = yysize1;
1063 }
1064 }
1065 }
1066 }
1067
1068 switch (yycount)
1069 {
1070 # define YYCASE_(N, S) \
1071 case N: \
1072 yyformat = S; \
1073 break
1074 YYCASE_(0, YY_("syntax error"));
1075 YYCASE_(1, YY_("syntax error, unexpected %s"));
1076 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1077 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1078 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1079 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1080 # undef YYCASE_
1081 }
1082
1083 {
1084 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1085 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1086 return 2;
1087 yysize = yysize1;
1088 }
1089
1090 if (*yymsg_alloc < yysize)
1091 {
1092 *yymsg_alloc = 2 * yysize;
1093 if (! (yysize <= *yymsg_alloc
1094 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1095 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1096 return 1;
1097 }
1098
1099 /* Avoid sprintf, as that infringes on the user's name space.
1100 Don't have undefined behavior even if the translation
1101 produced a string with the wrong number of "%s"s. */
1102 {
1103 char *yyp = *yymsg;
1104 int yyi = 0;
1105 while ((*yyp = *yyformat) != '\0')
1106 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1107 {
1108 yyp += yytnamerr (yyp, yyarg[yyi++]);
1109 yyformat += 2;
1110 }
1111 else
1112 {
1113 yyp++;
1114 yyformat++;
1115 }
1116 }
1117 return 0;
1118 }
1119 #endif /* YYERROR_VERBOSE */
1120
1121 /*-----------------------------------------------.
1122 | Release the memory associated to this symbol. |
1123 `-----------------------------------------------*/
1124
1125 static void
1126 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, COND_input *info)
1127 {
1128 YYUSE (yyvaluep);
1129 YYUSE (info);
1130 if (!yymsg)
1131 yymsg = "Deleting";
1132 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1133
1134 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1135 YYUSE (yytype);
1136 YY_IGNORE_MAYBE_UNINITIALIZED_END
1137 }
1138
1139
1140
1141
1142 /*----------.
1143 | yyparse. |
1144 `----------*/
1145
1146 int
1147 yyparse (COND_input *info)
1148 {
1149 /* The lookahead symbol. */
1150 int yychar;
1151
1152
1153 /* The semantic value of the lookahead symbol. */
1154 /* Default value used for initialization, for pacifying older GCCs
1155 or non-GCC compilers. */
1156 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1157 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1158
1159 /* Number of syntax errors so far. */
1160 int yynerrs;
1161
1162 int yystate;
1163 /* Number of tokens to shift before error messages enabled. */
1164 int yyerrstatus;
1165
1166 /* The stacks and their tools:
1167 'yyss': related to states.
1168 'yyvs': related to semantic values.
1169
1170 Refer to the stacks through separate pointers, to allow yyoverflow
1171 to reallocate them elsewhere. */
1172
1173 /* The state stack. */
1174 yytype_int16 yyssa[YYINITDEPTH];
1175 yytype_int16 *yyss;
1176 yytype_int16 *yyssp;
1177
1178 /* The semantic value stack. */
1179 YYSTYPE yyvsa[YYINITDEPTH];
1180 YYSTYPE *yyvs;
1181 YYSTYPE *yyvsp;
1182
1183 YYSIZE_T yystacksize;
1184
1185 int yyn;
1186 int yyresult;
1187 /* Lookahead token as an internal (translated) token number. */
1188 int yytoken = 0;
1189 /* The variables used to return semantic value and location from the
1190 action routines. */
1191 YYSTYPE yyval;
1192
1193 #if YYERROR_VERBOSE
1194 /* Buffer for error messages, and its allocated size. */
1195 char yymsgbuf[128];
1196 char *yymsg = yymsgbuf;
1197 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1198 #endif
1199
1200 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1201
1202 /* The number of symbols on the RHS of the reduced rule.
1203 Keep to zero when no symbol should be popped. */
1204 int yylen = 0;
1205
1206 yyssp = yyss = yyssa;
1207 yyvsp = yyvs = yyvsa;
1208 yystacksize = YYINITDEPTH;
1209
1210 YYDPRINTF ((stderr, "Starting parse\n"));
1211
1212 yystate = 0;
1213 yyerrstatus = 0;
1214 yynerrs = 0;
1215 yychar = YYEMPTY; /* Cause a token to be read. */
1216 goto yysetstate;
1217
1218 /*------------------------------------------------------------.
1219 | yynewstate -- Push a new state, which is found in yystate. |
1220 `------------------------------------------------------------*/
1221 yynewstate:
1222 /* In all cases, when you get here, the value and location stacks
1223 have just been pushed. So pushing a state here evens the stacks. */
1224 yyssp++;
1225
1226 yysetstate:
1227 *yyssp = yystate;
1228
1229 if (yyss + yystacksize - 1 <= yyssp)
1230 {
1231 /* Get the current used size of the three stacks, in elements. */
1232 YYSIZE_T yysize = yyssp - yyss + 1;
1233
1234 #ifdef yyoverflow
1235 {
1236 /* Give user a chance to reallocate the stack. Use copies of
1237 these so that the &'s don't force the real ones into
1238 memory. */
1239 YYSTYPE *yyvs1 = yyvs;
1240 yytype_int16 *yyss1 = yyss;
1241
1242 /* Each stack pointer address is followed by the size of the
1243 data in use in that stack, in bytes. This used to be a
1244 conditional around just the two extra args, but that might
1245 be undefined if yyoverflow is a macro. */
1246 yyoverflow (YY_("memory exhausted"),
1247 &yyss1, yysize * sizeof (*yyssp),
1248 &yyvs1, yysize * sizeof (*yyvsp),
1249 &yystacksize);
1250
1251 yyss = yyss1;
1252 yyvs = yyvs1;
1253 }
1254 #else /* no yyoverflow */
1255 # ifndef YYSTACK_RELOCATE
1256 goto yyexhaustedlab;
1257 # else
1258 /* Extend the stack our own way. */
1259 if (YYMAXDEPTH <= yystacksize)
1260 goto yyexhaustedlab;
1261 yystacksize *= 2;
1262 if (YYMAXDEPTH < yystacksize)
1263 yystacksize = YYMAXDEPTH;
1264
1265 {
1266 yytype_int16 *yyss1 = yyss;
1267 union yyalloc *yyptr =
1268 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1269 if (! yyptr)
1270 goto yyexhaustedlab;
1271 YYSTACK_RELOCATE (yyss_alloc, yyss);
1272 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1273 # undef YYSTACK_RELOCATE
1274 if (yyss1 != yyssa)
1275 YYSTACK_FREE (yyss1);
1276 }
1277 # endif
1278 #endif /* no yyoverflow */
1279
1280 yyssp = yyss + yysize - 1;
1281 yyvsp = yyvs + yysize - 1;
1282
1283 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1284 (unsigned long int) yystacksize));
1285
1286 if (yyss + yystacksize - 1 <= yyssp)
1287 YYABORT;
1288 }
1289
1290 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1291
1292 if (yystate == YYFINAL)
1293 YYACCEPT;
1294
1295 goto yybackup;
1296
1297 /*-----------.
1298 | yybackup. |
1299 `-----------*/
1300 yybackup:
1301
1302 /* Do appropriate processing given the current state. Read a
1303 lookahead token if we need one and don't already have one. */
1304
1305 /* First try to decide what to do without reference to lookahead token. */
1306 yyn = yypact[yystate];
1307 if (yypact_value_is_default (yyn))
1308 goto yydefault;
1309
1310 /* Not known => get a lookahead token if don't already have one. */
1311
1312 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1313 if (yychar == YYEMPTY)
1314 {
1315 YYDPRINTF ((stderr, "Reading a token: "));
1316 yychar = yylex (&yylval, info);
1317 }
1318
1319 if (yychar <= YYEOF)
1320 {
1321 yychar = yytoken = YYEOF;
1322 YYDPRINTF ((stderr, "Now at end of input.\n"));
1323 }
1324 else
1325 {
1326 yytoken = YYTRANSLATE (yychar);
1327 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1328 }
1329
1330 /* If the proper action on seeing token YYTOKEN is to reduce or to
1331 detect an error, take that action. */
1332 yyn += yytoken;
1333 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1334 goto yydefault;
1335 yyn = yytable[yyn];
1336 if (yyn <= 0)
1337 {
1338 if (yytable_value_is_error (yyn))
1339 goto yyerrlab;
1340 yyn = -yyn;
1341 goto yyreduce;
1342 }
1343
1344 /* Count tokens shifted since error; after three, turn off error
1345 status. */
1346 if (yyerrstatus)
1347 yyerrstatus--;
1348
1349 /* Shift the lookahead token. */
1350 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1351
1352 /* Discard the shifted token. */
1353 yychar = YYEMPTY;
1354
1355 yystate = yyn;
1356 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1357 *++yyvsp = yylval;
1358 YY_IGNORE_MAYBE_UNINITIALIZED_END
1359
1360 goto yynewstate;
1361
1362
1363 /*-----------------------------------------------------------.
1364 | yydefault -- do the default action for the current state. |
1365 `-----------------------------------------------------------*/
1366 yydefault:
1367 yyn = yydefact[yystate];
1368 if (yyn == 0)
1369 goto yyerrlab;
1370 goto yyreduce;
1371
1372
1373 /*-----------------------------.
1374 | yyreduce -- Do a reduction. |
1375 `-----------------------------*/
1376 yyreduce:
1377 /* yyn is the number of a rule to reduce with. */
1378 yylen = yyr2[yyn];
1379
1380 /* If YYLEN is nonzero, implement the default value of the action:
1381 '$$ = $1'.
1382
1383 Otherwise, the following line sets YYVAL to garbage.
1384 This behavior is undocumented and Bison
1385 users should not rely upon it. Assigning to YYVAL
1386 unconditionally makes the parser a bit smaller, and it avoids a
1387 GCC warning that YYVAL may be used uninitialized. */
1388 yyval = yyvsp[1-yylen];
1389
1390
1391 YY_REDUCE_PRINT (yyn);
1392 switch (yyn)
1393 {
1394 case 2:
1395 #line 150 "cond.y" /* yacc.c:1646 */
1396 {
1397 COND_input* cond = (COND_input*) info;
1398 cond->result = (yyvsp[0].bool);
1399 }
1400 #line 1401 "cond.tab.c" /* yacc.c:1646 */
1401 break;
1402
1403 case 3:
1404 #line 155 "cond.y" /* yacc.c:1646 */
1405 {
1406 COND_input* cond = (COND_input*) info;
1407 cond->result = MSICONDITION_NONE;
1408 }
1409 #line 1410 "cond.tab.c" /* yacc.c:1646 */
1410 break;
1411
1412 case 4:
1413 #line 163 "cond.y" /* yacc.c:1646 */
1414 {
1415 (yyval.bool) = (yyvsp[0].bool);
1416 }
1417 #line 1418 "cond.tab.c" /* yacc.c:1646 */
1418 break;
1419
1420 case 5:
1421 #line 167 "cond.y" /* yacc.c:1646 */
1422 {
1423 (yyval.bool) = (yyvsp[-2].bool) || (yyvsp[0].bool);
1424 }
1425 #line 1426 "cond.tab.c" /* yacc.c:1646 */
1426 break;
1427
1428 case 6:
1429 #line 171 "cond.y" /* yacc.c:1646 */
1430 {
1431 (yyval.bool) = !(yyvsp[-2].bool) || (yyvsp[0].bool);
1432 }
1433 #line 1434 "cond.tab.c" /* yacc.c:1646 */
1434 break;
1435
1436 case 7:
1437 #line 175 "cond.y" /* yacc.c:1646 */
1438 {
1439 (yyval.bool) = ( (yyvsp[-2].bool) || (yyvsp[0].bool) ) && !( (yyvsp[-2].bool) && (yyvsp[0].bool) );
1440 }
1441 #line 1442 "cond.tab.c" /* yacc.c:1646 */
1442 break;
1443
1444 case 8:
1445 #line 179 "cond.y" /* yacc.c:1646 */
1446 {
1447 (yyval.bool) = ( (yyvsp[-2].bool) && (yyvsp[0].bool) ) || ( !(yyvsp[-2].bool) && !(yyvsp[0].bool) );
1448 }
1449 #line 1450 "cond.tab.c" /* yacc.c:1646 */
1450 break;
1451
1452 case 9:
1453 #line 186 "cond.y" /* yacc.c:1646 */
1454 {
1455 (yyval.bool) = (yyvsp[0].bool);
1456 }
1457 #line 1458 "cond.tab.c" /* yacc.c:1646 */
1458 break;
1459
1460 case 10:
1461 #line 190 "cond.y" /* yacc.c:1646 */
1462 {
1463 (yyval.bool) = (yyvsp[-2].bool) && (yyvsp[0].bool);
1464 }
1465 #line 1466 "cond.tab.c" /* yacc.c:1646 */
1466 break;
1467
1468 case 11:
1469 #line 197 "cond.y" /* yacc.c:1646 */
1470 {
1471 (yyval.bool) = !(yyvsp[0].bool);
1472 }
1473 #line 1474 "cond.tab.c" /* yacc.c:1646 */
1474 break;
1475
1476 case 12:
1477 #line 201 "cond.y" /* yacc.c:1646 */
1478 {
1479 if ((yyvsp[0].value).type == VALUE_INTEGER)
1480 (yyval.bool) = (yyvsp[0].value).u.integer ? 1 : 0;
1481 else
1482 (yyval.bool) = (yyvsp[0].value).u.string && (yyvsp[0].value).u.string[0];
1483 value_free( (yyvsp[0].value) );
1484 }
1485 #line 1486 "cond.tab.c" /* yacc.c:1646 */
1486 break;
1487
1488 case 13:
1489 #line 209 "cond.y" /* yacc.c:1646 */
1490 {
1491 if ((yyvsp[-2].value).type == VALUE_INTEGER && (yyvsp[0].value).type == VALUE_INTEGER)
1492 {
1493 (yyval.bool) = compare_int((yyvsp[-2].value).u.integer, (yyvsp[-1].operator), (yyvsp[0].value).u.integer);
1494 }
1495 else if ((yyvsp[-2].value).type != VALUE_INTEGER && (yyvsp[0].value).type != VALUE_INTEGER)
1496 {
1497 (yyval.bool) = compare_string((yyvsp[-2].value).u.string, (yyvsp[-1].operator), (yyvsp[0].value).u.string,
1498 (yyvsp[-2].value).type == VALUE_SYMBOL || (yyvsp[0].value).type == VALUE_SYMBOL);
1499 }
1500 else if ((yyvsp[-2].value).type == VALUE_LITERAL || (yyvsp[0].value).type == VALUE_LITERAL)
1501 {
1502 (yyval.bool) = FALSE;
1503 }
1504 else if ((yyvsp[-2].value).type == VALUE_SYMBOL) /* symbol operator integer */
1505 {
1506 int num;
1507 if (num_from_prop( (yyvsp[-2].value).u.string, &num ))
1508 (yyval.bool) = compare_int( num, (yyvsp[-1].operator), (yyvsp[0].value).u.integer );
1509 else
1510 (yyval.bool) = ((yyvsp[-1].operator) == COND_NE || (yyvsp[-1].operator) == COND_INE );
1511 }
1512 else /* integer operator symbol */
1513 {
1514 int num;
1515 if (num_from_prop( (yyvsp[0].value).u.string, &num ))
1516 (yyval.bool) = compare_int( (yyvsp[-2].value).u.integer, (yyvsp[-1].operator), num );
1517 else
1518 (yyval.bool) = ((yyvsp[-1].operator) == COND_NE || (yyvsp[-1].operator) == COND_INE );
1519 }
1520
1521 value_free( (yyvsp[-2].value) );
1522 value_free( (yyvsp[0].value) );
1523 }
1524 #line 1525 "cond.tab.c" /* yacc.c:1646 */
1525 break;
1526
1527 case 14:
1528 #line 244 "cond.y" /* yacc.c:1646 */
1529 {
1530 (yyval.bool) = (yyvsp[-1].bool);
1531 }
1532 #line 1533 "cond.tab.c" /* yacc.c:1646 */
1533 break;
1534
1535 case 15:
1536 #line 251 "cond.y" /* yacc.c:1646 */
1537 { (yyval.operator) = COND_EQ; }
1538 #line 1539 "cond.tab.c" /* yacc.c:1646 */
1539 break;
1540
1541 case 16:
1542 #line 252 "cond.y" /* yacc.c:1646 */
1543 { (yyval.operator) = COND_NE; }
1544 #line 1545 "cond.tab.c" /* yacc.c:1646 */
1545 break;
1546
1547 case 17:
1548 #line 253 "cond.y" /* yacc.c:1646 */
1549 { (yyval.operator) = COND_LT; }
1550 #line 1551 "cond.tab.c" /* yacc.c:1646 */
1551 break;
1552
1553 case 18:
1554 #line 254 "cond.y" /* yacc.c:1646 */
1555 { (yyval.operator) = COND_GT; }
1556 #line 1557 "cond.tab.c" /* yacc.c:1646 */
1557 break;
1558
1559 case 19:
1560 #line 255 "cond.y" /* yacc.c:1646 */
1561 { (yyval.operator) = COND_LE; }
1562 #line 1563 "cond.tab.c" /* yacc.c:1646 */
1563 break;
1564
1565 case 20:
1566 #line 256 "cond.y" /* yacc.c:1646 */
1567 { (yyval.operator) = COND_GE; }
1568 #line 1569 "cond.tab.c" /* yacc.c:1646 */
1569 break;
1570
1571 case 21:
1572 #line 257 "cond.y" /* yacc.c:1646 */
1573 { (yyval.operator) = COND_SS; }
1574 #line 1575 "cond.tab.c" /* yacc.c:1646 */
1575 break;
1576
1577 case 22:
1578 #line 258 "cond.y" /* yacc.c:1646 */
1579 { (yyval.operator) = COND_IEQ; }
1580 #line 1581 "cond.tab.c" /* yacc.c:1646 */
1581 break;
1582
1583 case 23:
1584 #line 259 "cond.y" /* yacc.c:1646 */
1585 { (yyval.operator) = COND_INE; }
1586 #line 1587 "cond.tab.c" /* yacc.c:1646 */
1587 break;
1588
1589 case 24:
1590 #line 260 "cond.y" /* yacc.c:1646 */
1591 { (yyval.operator) = COND_ILT; }
1592 #line 1593 "cond.tab.c" /* yacc.c:1646 */
1593 break;
1594
1595 case 25:
1596 #line 261 "cond.y" /* yacc.c:1646 */
1597 { (yyval.operator) = COND_IGT; }
1598 #line 1599 "cond.tab.c" /* yacc.c:1646 */
1599 break;
1600
1601 case 26:
1602 #line 262 "cond.y" /* yacc.c:1646 */
1603 { (yyval.operator) = COND_ILE; }
1604 #line 1605 "cond.tab.c" /* yacc.c:1646 */
1605 break;
1606
1607 case 27:
1608 #line 263 "cond.y" /* yacc.c:1646 */
1609 { (yyval.operator) = COND_IGE; }
1610 #line 1611 "cond.tab.c" /* yacc.c:1646 */
1611 break;
1612
1613 case 28:
1614 #line 264 "cond.y" /* yacc.c:1646 */
1615 { (yyval.operator) = COND_ISS; }
1616 #line 1617 "cond.tab.c" /* yacc.c:1646 */
1617 break;
1618
1619 case 29:
1620 #line 265 "cond.y" /* yacc.c:1646 */
1621 { (yyval.operator) = COND_LHS; }
1622 #line 1623 "cond.tab.c" /* yacc.c:1646 */
1623 break;
1624
1625 case 30:
1626 #line 266 "cond.y" /* yacc.c:1646 */
1627 { (yyval.operator) = COND_RHS; }
1628 #line 1629 "cond.tab.c" /* yacc.c:1646 */
1629 break;
1630
1631 case 31:
1632 #line 267 "cond.y" /* yacc.c:1646 */
1633 { (yyval.operator) = COND_ILHS; }
1634 #line 1635 "cond.tab.c" /* yacc.c:1646 */
1635 break;
1636
1637 case 32:
1638 #line 268 "cond.y" /* yacc.c:1646 */
1639 { (yyval.operator) = COND_IRHS; }
1640 #line 1641 "cond.tab.c" /* yacc.c:1646 */
1641 break;
1642
1643 case 33:
1644 #line 273 "cond.y" /* yacc.c:1646 */
1645 {
1646 COND_input* cond = (COND_input*) info;
1647 UINT len;
1648
1649 (yyval.value).type = VALUE_SYMBOL;
1650 (yyval.value).u.string = msi_dup_property( cond->package->db, (yyvsp[0].identifier) );
1651 if ((yyval.value).u.string)
1652 {
1653 len = (lstrlenW((yyval.value).u.string) + 1) * sizeof (WCHAR);
1654 (yyval.value).u.string = cond_track_mem( cond, (yyval.value).u.string, len );
1655 }
1656 cond_free( (yyvsp[0].identifier) );
1657 }
1658 #line 1659 "cond.tab.c" /* yacc.c:1646 */
1659 break;
1660
1661 case 34:
1662 #line 287 "cond.y" /* yacc.c:1646 */
1663 {
1664 COND_input* cond = (COND_input*) info;
1665 UINT len = GetEnvironmentVariableW( (yyvsp[0].identifier), NULL, 0 );
1666 (yyval.value).type = VALUE_SYMBOL;
1667 (yyval.value).u.string = NULL;
1668 if (len++)
1669 {
1670 (yyval.value).u.string = cond_alloc( cond, len*sizeof (WCHAR) );
1671 if( !(yyval.value).u.string )
1672 YYABORT;
1673 GetEnvironmentVariableW( (yyvsp[0].identifier), (yyval.value).u.string, len );
1674 }
1675 cond_free( (yyvsp[0].identifier) );
1676 }
1677 #line 1678 "cond.tab.c" /* yacc.c:1646 */
1678 break;
1679
1680 case 35:
1681 #line 302 "cond.y" /* yacc.c:1646 */
1682 {
1683 COND_input* cond = (COND_input*) info;
1684 (yyval.value).type = VALUE_LITERAL;
1685 (yyval.value).u.string = COND_GetLiteral( cond, &(yyvsp[0].str) );
1686 if( !(yyval.value).u.string )
1687 YYABORT;
1688 }
1689 #line 1690 "cond.tab.c" /* yacc.c:1646 */
1690 break;
1691
1692 case 36:
1693 #line 310 "cond.y" /* yacc.c:1646 */
1694 {
1695 COND_input* cond = (COND_input*) info;
1696 LPWSTR szNum = COND_GetString( cond, &(yyvsp[0].str) );
1697 if( !szNum )
1698 YYABORT;
1699 (yyval.value).type = VALUE_INTEGER;
1700 (yyval.value).u.integer = atoiW( szNum );
1701 cond_free( szNum );
1702 }
1703 #line 1704 "cond.tab.c" /* yacc.c:1646 */
1704 break;
1705
1706 case 37:
1707 #line 320 "cond.y" /* yacc.c:1646 */
1708 {
1709 COND_input* cond = (COND_input*) info;
1710 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1711
1712 if(MSI_GetComponentStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1713 {
1714 (yyval.value).type = VALUE_LITERAL;
1715 (yyval.value).u.string = NULL;
1716 }
1717 else
1718 {
1719 (yyval.value).type = VALUE_INTEGER;
1720 (yyval.value).u.integer = action;
1721 }
1722 cond_free( (yyvsp[0].identifier) );
1723 }
1724 #line 1725 "cond.tab.c" /* yacc.c:1646 */
1725 break;
1726
1727 case 38:
1728 #line 337 "cond.y" /* yacc.c:1646 */
1729 {
1730 COND_input* cond = (COND_input*) info;
1731 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1732
1733 if(MSI_GetComponentStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1734 {
1735 (yyval.value).type = VALUE_LITERAL;
1736 (yyval.value).u.string = NULL;
1737 }
1738 else
1739 {
1740 (yyval.value).type = VALUE_INTEGER;
1741 (yyval.value).u.integer = install;
1742 }
1743 cond_free( (yyvsp[0].identifier) );
1744 }
1745 #line 1746 "cond.tab.c" /* yacc.c:1646 */
1746 break;
1747
1748 case 39:
1749 #line 354 "cond.y" /* yacc.c:1646 */
1750 {
1751 COND_input* cond = (COND_input*) info;
1752 INSTALLSTATE install, action;
1753
1754 if (MSI_GetFeatureStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1755 {
1756 (yyval.value).type = VALUE_LITERAL;
1757 (yyval.value).u.string = NULL;
1758 }
1759 else
1760 {
1761 (yyval.value).type = VALUE_INTEGER;
1762 (yyval.value).u.integer = action;
1763 }
1764 cond_free( (yyvsp[0].identifier) );
1765 }
1766 #line 1767 "cond.tab.c" /* yacc.c:1646 */
1767 break;
1768
1769 case 40:
1770 #line 371 "cond.y" /* yacc.c:1646 */
1771 {
1772 COND_input* cond = (COND_input*) info;
1773 INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
1774
1775 if(MSI_GetFeatureStateW(cond->package, (yyvsp[0].identifier), &install, &action ) != ERROR_SUCCESS)
1776 {
1777 (yyval.value).type = VALUE_LITERAL;
1778 (yyval.value).u.string = NULL;
1779 }
1780 else
1781 {
1782 (yyval.value).type = VALUE_INTEGER;
1783 (yyval.value).u.integer = install;
1784 }
1785 cond_free( (yyvsp[0].identifier) );
1786 }
1787 #line 1788 "cond.tab.c" /* yacc.c:1646 */
1788 break;
1789
1790 case 41:
1791 #line 391 "cond.y" /* yacc.c:1646 */
1792 {
1793 COND_input* cond = (COND_input*) info;
1794 (yyval.identifier) = COND_GetString( cond, &(yyvsp[0].str) );
1795 if( !(yyval.identifier) )
1796 YYABORT;
1797 }
1798 #line 1799 "cond.tab.c" /* yacc.c:1646 */
1799 break;
1800
1801
1802 #line 1803 "cond.tab.c" /* yacc.c:1646 */
1803 default: break;
1804 }
1805 /* User semantic actions sometimes alter yychar, and that requires
1806 that yytoken be updated with the new translation. We take the
1807 approach of translating immediately before every use of yytoken.
1808 One alternative is translating here after every semantic action,
1809 but that translation would be missed if the semantic action invokes
1810 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1811 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1812 incorrect destructor might then be invoked immediately. In the
1813 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1814 to an incorrect destructor call or verbose syntax error message
1815 before the lookahead is translated. */
1816 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1817
1818 YYPOPSTACK (yylen);
1819 yylen = 0;
1820 YY_STACK_PRINT (yyss, yyssp);
1821
1822 *++yyvsp = yyval;
1823
1824 /* Now 'shift' the result of the reduction. Determine what state
1825 that goes to, based on the state we popped back to and the rule
1826 number reduced by. */
1827
1828 yyn = yyr1[yyn];
1829
1830 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1831 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1832 yystate = yytable[yystate];
1833 else
1834 yystate = yydefgoto[yyn - YYNTOKENS];
1835
1836 goto yynewstate;
1837
1838
1839 /*--------------------------------------.
1840 | yyerrlab -- here on detecting error. |
1841 `--------------------------------------*/
1842 yyerrlab:
1843 /* Make sure we have latest lookahead translation. See comments at
1844 user semantic actions for why this is necessary. */
1845 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1846
1847 /* If not already recovering from an error, report this error. */
1848 if (!yyerrstatus)
1849 {
1850 ++yynerrs;
1851 #if ! YYERROR_VERBOSE
1852 yyerror (info, YY_("syntax error"));
1853 #else
1854 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1855 yyssp, yytoken)
1856 {
1857 char const *yymsgp = YY_("syntax error");
1858 int yysyntax_error_status;
1859 yysyntax_error_status = YYSYNTAX_ERROR;
1860 if (yysyntax_error_status == 0)
1861 yymsgp = yymsg;
1862 else if (yysyntax_error_status == 1)
1863 {
1864 if (yymsg != yymsgbuf)
1865 YYSTACK_FREE (yymsg);
1866 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1867 if (!yymsg)
1868 {
1869 yymsg = yymsgbuf;
1870 yymsg_alloc = sizeof yymsgbuf;
1871 yysyntax_error_status = 2;
1872 }
1873 else
1874 {
1875 yysyntax_error_status = YYSYNTAX_ERROR;
1876 yymsgp = yymsg;
1877 }
1878 }
1879 yyerror (info, yymsgp);
1880 if (yysyntax_error_status == 2)
1881 goto yyexhaustedlab;
1882 }
1883 # undef YYSYNTAX_ERROR
1884 #endif
1885 }
1886
1887
1888
1889 if (yyerrstatus == 3)
1890 {
1891 /* If just tried and failed to reuse lookahead token after an
1892 error, discard it. */
1893
1894 if (yychar <= YYEOF)
1895 {
1896 /* Return failure if at end of input. */
1897 if (yychar == YYEOF)
1898 YYABORT;
1899 }
1900 else
1901 {
1902 yydestruct ("Error: discarding",
1903 yytoken, &yylval, info);
1904 yychar = YYEMPTY;
1905 }
1906 }
1907
1908 /* Else will try to reuse lookahead token after shifting the error
1909 token. */
1910 goto yyerrlab1;
1911
1912
1913 /*---------------------------------------------------.
1914 | yyerrorlab -- error raised explicitly by YYERROR. |
1915 `---------------------------------------------------*/
1916 yyerrorlab:
1917
1918 /* Pacify compilers like GCC when the user code never invokes
1919 YYERROR and the label yyerrorlab therefore never appears in user
1920 code. */
1921 if (/*CONSTCOND*/ 0)
1922 goto yyerrorlab;
1923
1924 /* Do not reclaim the symbols of the rule whose action triggered
1925 this YYERROR. */
1926 YYPOPSTACK (yylen);
1927 yylen = 0;
1928 YY_STACK_PRINT (yyss, yyssp);
1929 yystate = *yyssp;
1930 goto yyerrlab1;
1931
1932
1933 /*-------------------------------------------------------------.
1934 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1935 `-------------------------------------------------------------*/
1936 yyerrlab1:
1937 yyerrstatus = 3; /* Each real token shifted decrements this. */
1938
1939 for (;;)
1940 {
1941 yyn = yypact[yystate];
1942 if (!yypact_value_is_default (yyn))
1943 {
1944 yyn += YYTERROR;
1945 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1946 {
1947 yyn = yytable[yyn];
1948 if (0 < yyn)
1949 break;
1950 }
1951 }
1952
1953 /* Pop the current state because it cannot handle the error token. */
1954 if (yyssp == yyss)
1955 YYABORT;
1956
1957
1958 yydestruct ("Error: popping",
1959 yystos[yystate], yyvsp, info);
1960 YYPOPSTACK (1);
1961 yystate = *yyssp;
1962 YY_STACK_PRINT (yyss, yyssp);
1963 }
1964
1965 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1966 *++yyvsp = yylval;
1967 YY_IGNORE_MAYBE_UNINITIALIZED_END
1968
1969
1970 /* Shift the error token. */
1971 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1972
1973 yystate = yyn;
1974 goto yynewstate;
1975
1976
1977 /*-------------------------------------.
1978 | yyacceptlab -- YYACCEPT comes here. |
1979 `-------------------------------------*/
1980 yyacceptlab:
1981 yyresult = 0;
1982 goto yyreturn;
1983
1984 /*-----------------------------------.
1985 | yyabortlab -- YYABORT comes here. |
1986 `-----------------------------------*/
1987 yyabortlab:
1988 yyresult = 1;
1989 goto yyreturn;
1990
1991 #if !defined yyoverflow || YYERROR_VERBOSE
1992 /*-------------------------------------------------.
1993 | yyexhaustedlab -- memory exhaustion comes here. |
1994 `-------------------------------------------------*/
1995 yyexhaustedlab:
1996 yyerror (info, YY_("memory exhausted"));
1997 yyresult = 2;
1998 /* Fall through. */
1999 #endif
2000
2001 yyreturn:
2002 if (yychar != YYEMPTY)
2003 {
2004 /* Make sure we have latest lookahead translation. See comments at
2005 user semantic actions for why this is necessary. */
2006 yytoken = YYTRANSLATE (yychar);
2007 yydestruct ("Cleanup: discarding lookahead",
2008 yytoken, &yylval, info);
2009 }
2010 /* Do not reclaim the symbols of the rule whose action triggered
2011 this YYABORT or YYACCEPT. */
2012 YYPOPSTACK (yylen);
2013 YY_STACK_PRINT (yyss, yyssp);
2014 while (yyssp != yyss)
2015 {
2016 yydestruct ("Cleanup: popping",
2017 yystos[*yyssp], yyvsp, info);
2018 YYPOPSTACK (1);
2019 }
2020 #ifndef yyoverflow
2021 if (yyss != yyssa)
2022 YYSTACK_FREE (yyss);
2023 #endif
2024 #if YYERROR_VERBOSE
2025 if (yymsg != yymsgbuf)
2026 YYSTACK_FREE (yymsg);
2027 #endif
2028 return yyresult;
2029 }
2030 #line 399 "cond.y" /* yacc.c:1906 */
2031
2032
2033
2034 static int COND_IsAlpha( WCHAR x )
2035 {
2036 return( ( ( x >= 'A' ) && ( x <= 'Z' ) ) ||
2037 ( ( x >= 'a' ) && ( x <= 'z' ) ) ||
2038 ( ( x == '_' ) ) );
2039 }
2040
2041 static int COND_IsNumber( WCHAR x )
2042 {
2043 return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') );
2044 }
2045
2046 static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
2047 {
2048 LPWSTR strlower, sublower, r;
2049 strlower = CharLowerW( strdupW( str ) );
2050 sublower = CharLowerW( strdupW( sub ) );
2051 r = strstrW( strlower, sublower );
2052 if (r)
2053 r = (LPWSTR)str + (r - strlower);
2054 msi_free( strlower );
2055 msi_free( sublower );
2056 return r;
2057 }
2058
2059 static BOOL str_is_number( LPCWSTR str )
2060 {
2061 int i;
2062
2063 if (!*str)
2064 return FALSE;
2065
2066 for (i = 0; i < lstrlenW( str ); i++)
2067 if (!isdigitW(str[i]))
2068 return FALSE;
2069
2070 return TRUE;
2071 }
2072
2073 static INT compare_substring( LPCWSTR a, INT operator, LPCWSTR b )
2074 {
2075 int lhs, rhs;
2076
2077 /* substring operators return 0 if LHS is missing */
2078 if (!a || !*a)
2079 return 0;
2080
2081 /* substring operators return 1 if RHS is missing */
2082 if (!b || !*b)
2083 return 1;
2084
2085 /* if both strings contain only numbers, use integer comparison */
2086 lhs = atoiW(a);
2087 rhs = atoiW(b);
2088 if (str_is_number(a) && str_is_number(b))
2089 return compare_int( lhs, operator, rhs );
2090
2091 switch (operator)
2092 {
2093 case COND_SS:
2094 return strstrW( a, b ) != 0;
2095 case COND_ISS:
2096 return strstriW( a, b ) != 0;
2097 case COND_LHS:
2098 {
2099 int l = strlenW( a );
2100 int r = strlenW( b );
2101 if (r > l) return 0;
2102 return !strncmpW( a, b, r );
2103 }
2104 case COND_RHS:
2105 {
2106 int l = strlenW( a );
2107 int r = strlenW( b );
2108 if (r > l) return 0;
2109 return !strncmpW( a + (l - r), b, r );
2110 }
2111 case COND_ILHS:
2112 {
2113 int l = strlenW( a );
2114 int r = strlenW( b );
2115 if (r > l) return 0;
2116 return !strncmpiW( a, b, r );
2117 }
2118 case COND_IRHS:
2119 {
2120 int l = strlenW( a );
2121 int r = strlenW( b );
2122 if (r > l) return 0;
2123 return !strncmpiW( a + (l - r), b, r );
2124 }
2125 default:
2126 ERR("invalid substring operator\n");
2127 return 0;
2128 }
2129 return 0;
2130 }
2131
2132 static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b, BOOL convert )
2133 {
2134 if (operator >= COND_SS && operator <= COND_RHS)
2135 return compare_substring( a, operator, b );
2136
2137 /* null and empty string are equivalent */
2138 if (!a) a = szEmpty;
2139 if (!b) b = szEmpty;
2140
2141 if (convert && str_is_number(a) && str_is_number(b))
2142 return compare_int( atoiW(a), operator, atoiW(b) );
2143
2144 /* a or b may be NULL */
2145 switch (operator)
2146 {
2147 case COND_LT:
2148 return strcmpW( a, b ) < 0;
2149 case COND_GT:
2150 return strcmpW( a, b ) > 0;
2151 case COND_EQ:
2152 return strcmpW( a, b ) == 0;
2153 case COND_NE:
2154 return strcmpW( a, b ) != 0;
2155 case COND_GE:
2156 return strcmpW( a, b ) >= 0;
2157 case COND_LE:
2158 return strcmpW( a, b ) <= 0;
2159 case COND_ILT:
2160 return strcmpiW( a, b ) < 0;
2161 case COND_IGT:
2162 return strcmpiW( a, b ) > 0;
2163 case COND_IEQ:
2164 return strcmpiW( a, b ) == 0;
2165 case COND_INE:
2166 return strcmpiW( a, b ) != 0;
2167 case COND_IGE:
2168 return strcmpiW( a, b ) >= 0;
2169 case COND_ILE:
2170 return strcmpiW( a, b ) <= 0;
2171 default:
2172 ERR("invalid string operator\n");
2173 return 0;
2174 }
2175 return 0;
2176 }
2177
2178
2179 static INT compare_int( INT a, INT operator, INT b )
2180 {
2181 switch (operator)
2182 {
2183 case COND_LT:
2184 case COND_ILT:
2185 return a < b;
2186 case COND_GT:
2187 case COND_IGT:
2188 return a > b;
2189 case COND_EQ:
2190 case COND_IEQ:
2191 return a == b;
2192 case COND_NE:
2193 case COND_INE:
2194 return a != b;
2195 case COND_GE:
2196 case COND_IGE:
2197 return a >= b;
2198 case COND_LE:
2199 case COND_ILE:
2200 return a <= b;
2201 case COND_SS:
2202 case COND_ISS:
2203 return ( a & b ) ? 1 : 0;
2204 case COND_RHS:
2205 return ( ( a & 0xffff ) == b ) ? 1 : 0;
2206 case COND_LHS:
2207 return ( ( (a>>16) & 0xffff ) == b ) ? 1 : 0;
2208 default:
2209 ERR("invalid integer operator\n");
2210 return 0;
2211 }
2212 return 0;
2213 }
2214
2215
2216 static int COND_IsIdent( WCHAR x )
2217 {
2218 return( COND_IsAlpha( x ) || COND_IsNumber( x ) || ( x == '_' )
2219 || ( x == '#' ) || (x == '.') );
2220 }
2221
2222 static int COND_GetOperator( COND_input *cond )
2223 {
2224 static const struct {
2225 const WCHAR str[4];
2226 int id;
2227 } table[] = {
2228 { {'~','<','=',0}, COND_ILE },
2229 { {'~','>','<',0}, COND_ISS },
2230 { {'~','>','>',0}, COND_IRHS },
2231 { {'~','<','>',0}, COND_INE },
2232 { {'~','>','=',0}, COND_IGE },
2233 { {'~','<','<',0}, COND_ILHS },
2234 { {'~','=',0}, COND_IEQ },
2235 { {'~','<',0}, COND_ILT },
2236 { {'~','>',0}, COND_IGT },
2237 { {'>','=',0}, COND_GE },
2238 { {'>','<',0}, COND_SS },
2239 { {'<','<',0}, COND_LHS },
2240 { {'<','>',0}, COND_NE },
2241 { {'<','=',0}, COND_LE },
2242 { {'>','>',0}, COND_RHS },
2243 { {'>',0}, COND_GT },
2244 { {'<',0}, COND_LT },
2245 { {0}, 0 }
2246 };
2247 LPCWSTR p = &cond->str[cond->n];
2248 int i = 0, len;
2249
2250 while ( 1 )
2251 {
2252 len = lstrlenW( table[i].str );
2253 if ( !len || 0 == strncmpW( table[i].str, p, len ) )
2254 break;
2255 i++;
2256 }
2257 cond->n += len;
2258 return table[i].id;
2259 }
2260
2261 static int COND_GetOne( struct cond_str *str, COND_input *cond )
2262 {
2263 int rc, len = 1;
2264 WCHAR ch;
2265
2266 str->data = &cond->str[cond->n];
2267
2268 ch = str->data[0];
2269
2270 switch( ch )
2271 {
2272 case 0: return 0;
2273 case '(': rc = COND_LPAR; break;
2274 case ')': rc = COND_RPAR; break;
2275 case '&': rc = COND_AMPER; break;
2276 case '!': rc = COND_EXCLAM; break;
2277 case '$': rc = COND_DOLLARS; break;
2278 case '?': rc = COND_QUESTION; break;
2279 case '%': rc = COND_PERCENT; break;
2280 case ' ': rc = COND_SPACE; break;
2281 case '=': rc = COND_EQ; break;
2282
2283 case '~':
2284 case '<':
2285 case '>':
2286 rc = COND_GetOperator( cond );
2287 if (!rc)
2288 rc = COND_ERROR;
2289 return rc;
2290 default:
2291 rc = 0;
2292 }
2293
2294 if ( rc )
2295 {
2296 cond->n += len;
2297 return rc;
2298 }
2299
2300 if (ch == '"' )
2301 {
2302 LPCWSTR p = strchrW( str->data + 1, '"' );
2303 if (!p) return COND_ERROR;
2304 len = p - str->data + 1;
2305 rc = COND_LITER;
2306 }
2307 else if( COND_IsAlpha( ch ) )
2308 {
2309 static const WCHAR szNot[] = {'N','O','T',0};
2310 static const WCHAR szAnd[] = {'A','N','D',0};
2311 static const WCHAR szXor[] = {'X','O','R',0};
2312 static const WCHAR szEqv[] = {'E','Q','V',0};
2313 static const WCHAR szImp[] = {'I','M','P',0};
2314 static const WCHAR szOr[] = {'O','R',0};
2315
2316 while( COND_IsIdent( str->data[len] ) )
2317 len++;
2318 rc = COND_IDENT;
2319
2320 if ( len == 3 )
2321 {
2322 if ( !strncmpiW( str->data, szNot, len ) )
2323 rc = COND_NOT;
2324 else if( !strncmpiW( str->data, szAnd, len ) )
2325 rc = COND_AND;
2326 else if( !strncmpiW( str->data, szXor, len ) )
2327 rc = COND_XOR;
2328 else if( !strncmpiW( str->data, szEqv, len ) )
2329 rc = COND_EQV;
2330 else if( !strncmpiW( str->data, szImp, len ) )
2331 rc = COND_IMP;
2332 }
2333 else if( (len == 2) && !strncmpiW( str->data, szOr, len ) )
2334 rc = COND_OR;
2335 }
2336 else if( COND_IsNumber( ch ) )
2337 {
2338 while( COND_IsNumber( str->data[len] ) )
2339 len++;
2340 rc = COND_NUMBER;
2341 }
2342 else
2343 {
2344 ERR("Got unknown character %c(%x)\n",ch,ch);
2345 return COND_ERROR;
2346 }
2347
2348 cond->n += len;
2349 str->len = len;
2350
2351 return rc;
2352 }
2353
2354 static int cond_lex( void *COND_lval, COND_input *cond )
2355 {
2356 int rc;
2357 struct cond_str *str = COND_lval;
2358
2359 do {
2360 rc = COND_GetOne( str, cond );
2361 } while (rc == COND_SPACE);
2362
2363 return rc;
2364 }
2365
2366 static LPWSTR COND_GetString( COND_input *cond, const struct cond_str *str )
2367 {
2368 LPWSTR ret;
2369
2370 ret = cond_alloc( cond, (str->len+1) * sizeof (WCHAR) );
2371 if( ret )
2372 {
2373 memcpy( ret, str->data, str->len * sizeof(WCHAR));
2374 ret[str->len]=0;
2375 }
2376 TRACE("Got identifier %s\n",debugstr_w(ret));
2377 return ret;
2378 }
2379
2380 static LPWSTR COND_GetLiteral( COND_input *cond, const struct cond_str *str )
2381 {
2382 LPWSTR ret;
2383
2384 ret = cond_alloc( cond, (str->len-1) * sizeof (WCHAR) );
2385 if( ret )
2386 {
2387 memcpy( ret, str->data+1, (str->len-2) * sizeof(WCHAR) );
2388 ret[str->len - 2]=0;
2389 }
2390 TRACE("Got literal %s\n",debugstr_w(ret));
2391 return ret;
2392 }
2393
2394 static void *cond_alloc( COND_input *cond, unsigned int sz )
2395 {
2396 struct list *mem;
2397
2398 mem = msi_alloc( sizeof (struct list) + sz );
2399 if( !mem )
2400 return NULL;
2401
2402 list_add_head( &(cond->mem), mem );
2403 return mem + 1;
2404 }
2405
2406 static void *cond_track_mem( COND_input *cond, void *ptr, unsigned int sz )
2407 {
2408 void *new_ptr;
2409
2410 if( !ptr )
2411 return ptr;
2412
2413 new_ptr = cond_alloc( cond, sz );
2414 if( !new_ptr )
2415 {
2416 msi_free( ptr );
2417 return NULL;
2418 }
2419
2420 memcpy( new_ptr, ptr, sz );
2421 msi_free( ptr );
2422 return new_ptr;
2423 }
2424
2425 static void cond_free( void *ptr )
2426 {
2427 struct list *mem = (struct list *)ptr - 1;
2428
2429 if( ptr )
2430 {
2431 list_remove( mem );
2432 msi_free( mem );
2433 }
2434 }
2435
2436 static int cond_error( COND_input *info, const char *str )
2437 {
2438 TRACE("%s\n", str );
2439 return 0;
2440 }
2441
2442 MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
2443 {
2444 COND_input cond;
2445 MSICONDITION r;
2446 struct list *mem, *safety;
2447
2448 TRACE("%s\n", debugstr_w( szCondition ) );
2449
2450 if (szCondition == NULL) return MSICONDITION_NONE;
2451
2452 cond.package = package;
2453 cond.str = szCondition;
2454 cond.n = 0;
2455 cond.result = MSICONDITION_ERROR;
2456
2457 list_init( &cond.mem );
2458
2459 if ( !cond_parse( &cond ) )
2460 r = cond.result;
2461 else
2462 r = MSICONDITION_ERROR;
2463
2464 LIST_FOR_EACH_SAFE( mem, safety, &cond.mem )
2465 {
2466 /* The tracked memory lives directly after the list struct */
2467 void *ptr = mem + 1;
2468 if ( r != MSICONDITION_ERROR )
2469 WARN( "condition parser failed to free up some memory: %p\n", ptr );
2470 cond_free( ptr );
2471 }
2472
2473 TRACE("%i <- %s\n", r, debugstr_w(szCondition));
2474 return r;
2475 }
2476
2477 MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szCondition )
2478 {
2479 MSIPACKAGE *package;
2480 UINT ret;
2481
2482 package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
2483 if( !package )
2484 {
2485 HRESULT hr;
2486 BSTR condition;
2487 IWineMsiRemotePackage *remote_package;
2488
2489 remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
2490 if (!remote_package)
2491 return MSICONDITION_ERROR;
2492
2493 condition = SysAllocString( szCondition );
2494 if (!condition)
2495 {
2496 IWineMsiRemotePackage_Release( remote_package );
2497 return ERROR_OUTOFMEMORY;
2498 }
2499
2500 hr = IWineMsiRemotePackage_EvaluateCondition( remote_package, condition );
2501
2502 SysFreeString( condition );
2503 IWineMsiRemotePackage_Release( remote_package );
2504
2505 if (FAILED(hr))
2506 {
2507 if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
2508 return HRESULT_CODE(hr);
2509
2510 return ERROR_FUNCTION_FAILED;
2511 }
2512
2513 return ERROR_SUCCESS;
2514 }
2515
2516 ret = MSI_EvaluateConditionW( package, szCondition );
2517 msiobj_release( &package->hdr );
2518 return ret;
2519 }
2520
2521 MSICONDITION WINAPI MsiEvaluateConditionA( MSIHANDLE hInstall, LPCSTR szCondition )
2522 {
2523 LPWSTR szwCond = NULL;
2524 MSICONDITION r;
2525
2526 szwCond = strdupAtoW( szCondition );
2527 if( szCondition && !szwCond )
2528 return MSICONDITION_ERROR;
2529
2530 r = MsiEvaluateConditionW( hInstall, szwCond );
2531 msi_free( szwCond );
2532 return r;
2533 }