/* A Bison parser, made from sdl_y.y by GNU Bison version 1.28 */ #define YYBISON 1 /* Identify Bison output. */ #define yyparse sdl_parse #define yylex sdl_lex #define yyerror sdl_error #define yylval sdl_lval #define yychar sdl_char #define yydebug sdl_debug #define yynerrs sdl_nerrs #define NAME 257 #define BEGIN_STACK 258 #define REPEAT 259 #define NEW_CARD 260 #define NEW_ENTRY 261 #define AFTER_STACK 262 #define AFTER_ALL 263 #define IF 264 #define ELSE 265 #define SORT_BY 266 #define USE 267 #define USE_RPL 268 #define STRCPY 269 #define PAGE 270 #define END 271 #define STRING 272 #define NUMBER 273 #define EXIST 274 #define CONTINUE 275 #define BREAK 276 #define SER_WRITE 277 #define LNK_WRITE 278 #define WPG_WRITE 279 #define INDEX 280 #define SUBSTR 281 #define WHEN 282 #define LINK 283 #define STRCAT 284 #define GIVEN_NEW 285 #define CARD_BOOK 286 #define BOOK_ENTRIES 287 #define SKIP 288 #define CIF_ON 289 #define CIF_OFF 290 #define GT 291 #define GTE 292 #define LT 293 #define LTE 294 #define EQ 295 #define NEQ 296 #define STRCMP 297 #define STRLEN 298 #define ERROR 299 #define QUAD 300 #define NORMALIZE 301 #define PRINT 302 #define RICH_LINES 303 #define OR 304 #define AND 305 #define REPEAT_DATA 306 #define NEXT_CARD 307 #define LOSE_CURRENT_ENTRY 308 #define TOC_WRITE 309 #define FIND_UNIT 310 #define SYM_SIZE 311 #define RPL_ASSIGN 312 #define UNARYMINUS 313 #define PLUS_PLUS 314 #define MINUS_MINUS 315 #define TO_THE 316 #line 1 "sdl_y.y" #define YYDEBUG 1 /* sdl_y.y yacc syntactical description of stack definition language, sdl. */ /* This pushdown automaton's stacktype: */ #define MAX_TEXT_LENGTH (512) typedef struct { unsigned char value[512]; unsigned char text[MAX_TEXT_LENGTH+1]; unsigned char other[20]; struct LinkNode *node; int stack_int; } stack_block; #define YYSTYPE stack_block /* This is the size of a block of pointers to cards, used in a reallocation strategy for dynamic allocation. This number is used in both the card arrays for each stack in rpl_list, and for creating card arrays in WHEN-LINK constructions. */ #define CARD_PTR_BLOCK 500 /* This is for dynamic allocation of blocks of pointers to entries used in the WHEN-LINK constructions. */ #define ENTRY_PTR_BLOCK 500 /* Card */ struct Card { unsigned char name[50]; int used; unsigned char *fields[50]; struct Entry **entries; } *current_card, *pushed_current_card; /* Entry */ struct Entry { struct Card *card; int used; unsigned char *fields[50]; } *current_entry, *pushed_current_entry; /* All the .rpl files, where the index is independent of the .rpl stack number, only indicating the order of creation. */ struct rpl { unsigned char fields[50][100]; struct Card **cards; int card_index; } *rpl_list[200]; /* The PAGE_TOTAL list keeps track of all assignments with PAGE_TOTAL on the value side, so that when the final number of cards in a card_book is finally determined, (in cases where the number of entries per card in data sensitive), it can be added to these variables. */ #define PAGE_TOTAL_LIST_LIMIT 10000 struct { struct Card *card; struct Entry *entry; int field; } page_total_list[PAGE_TOTAL_LIST_LIMIT]; int ptl_index = 0; /* Beginning of structures needed for the WHEN-LINK constructions. */ struct Condition { int type; int field; int comparison; unsigned char value[100]; }; struct C_Condition { int typeA; int typeB; int fieldA; int fieldB; int comparison; unsigned char value[100]; }; struct { int entries; int cards; struct Entry **entry_list; struct Card **card_list; int list_index; struct Condition card_condition[20]; struct Condition entry_condition[20]; int rplnum_exists; int rplnum; int entry_condition_total; int card_condition_total; int c_condition_total; struct Condition c_condition[20]; } A,B; struct LinkNode { int type; int list; int operator; struct LinkNode *left; struct LinkNode *right; int field; unsigned char value[100]; }; struct Link { int list; int field; int type; struct LinkNode *node; }; struct { int condition_total; struct C_Condition conditions[20]; int link_total; struct Link links[20]; } C; /* End of structures needed for the WHEN-LINK constructions. */ #include #include #include #include unsigned char *skip_list[20][100]; int skip_list_index[20]; struct Card *skip_card[100]; struct Entry *skip_entry[100]; struct Entry **skip_entries[100]; int skip_card_index[20]; int skip_card_num[20]; int starting_point; int card_book_data_index; unsigned char given_field_name_list[10][5][100]; unsigned char given_field_value_list[10][5][100]; unsigned char cb_field_name_list[10][100], cb_field_value_list[10][100]; int repeat_data = 0; int next_card = 0; int lose_current_entry = 0; int card_book_count = 1; int pagetotal_seen = 0; int pagetotal_enabled = 0; int no_max_safeguard = 0; int use_cif = 1; /* Default behavior is to use the .cif file */ unsigned char *Ellip[] = { (unsigned char *) "WGS84" , (unsigned char *) "BESSEL1841", (unsigned char *) "HK1963", (unsigned char *) "ED50", (unsigned char *) "CLARK1880", (unsigned char *) "WGS72", (unsigned char *) "NAD27", (unsigned char *) "GERMAN_FIX"}; #if 0 #define SD_DEBUG_LEX #define SD_DEBUG1 #define SD_DEBUG2 #define SD_DEBUG3 #define SD_DEBUG4 #define SD_DEBUG5 #define SD_DEBUG6 #define SD_DEBUG7 #define FU_DEBUG #define RICH_DEBUG #endif /* sorting #define SD_DEBUG4 */ #define EQUAL 1 #define NOT_EQUAL 2 #define ENTRY 1 #define CARD 2 #define STACK 3 #define OPERATOR 4 #define VALUE 5 #define MINUS 6 #define PLUS 7 int first_given[5] = {1,1,1,1,1}; int given_data_index[5]; int given_file_pos[5]; int given_line_pos[5]; int current_given = 0; int skip_given = 0; int u_card_num = 1; int u_entry_total = 0; int pushed_u_entry_total = 0; int u_current_page = 0; int u_page_total; int first_book_card = 1; int book_file_pos; int book_line_pos; int in_card_book = 0; int in_book_entries = 0; int entries_file_pos; int entries_line_pos; int max_book_entries; int entries_ok = 0; int file_lineno = 1; int entry_index = 0; int pushed_entry_index = 0; extern unsigned char global_defs[25][50]; extern int globals_def_index; extern struct { unsigned char name[50]; unsigned char field_names[50][50]; unsigned char list_field_names[50][50]; } card_types[100]; extern int card_type_index; extern unsigned char field_names[100][100]; extern int field_name_index; FILE *data_fd; extern FILE *sdl_fd; int assign_stack = 0; struct Card * assign_card = (struct Card *) 0; struct Entry * assign_entry = (struct Entry * ) 0; int assign_name = 0; unsigned char **data_ptr; int current_repeat = 0; int continue_repeat = 0; int break_repeat = 0; unsigned char sdl_file[50]; unsigned char data_file[50]; int data_size = 0; int current_rpl = 0; int rpl_index = 0; unsigned char current_card_type[100]; int do_not_execute = 0; unsigned char string_list[100][100]; int str_l_index = 0; unsigned char sym_list[100][100]; int sym_l_index = 0; int fd_input_done = 0; #define MAX_REPEATS 100 int data_lines = 0; int in_new_stack = 0; int in_new_card = 0; int in_new_entry = 0; #define ALPHA 1 #define REV_ALPHA 2 #define FORK 3 #define PAV 4 #define DATE 5 #define FLEUR 6 #define NUMERICAL 7 #define ALPHANUMERIC 8 #define MAX_CODE 100000 #define MAX_AFTER_CODE 5000000 #define SAFEGUARD_LIMIT 10000 /* above to prevent faults when programmer misuses max-entry-free cardbooks */ int data_records = 0; int number_of_keys = 0; int key_type[10]; unsigned char key_field[10][50]; #define MEM_ALLOCS 50000 #if 0 struct { unsigned char *ptr; int used; } mems[MEM_ALLOCS+2]; #endif int mem_tot = 0; unsigned char *mem_temp; unsigned char sdl_getc(); long repeat_line_pos[100]; long repeat_file_pos[100]; long p1=0; long p2=0; long p3=0; long p4=0; unsigned char *my_malloc(int size); unsigned char *get_local_value(unsigned char *s); struct Card *get_card(int rpl_number,int card_index); struct Entry *get_entry(struct Card *card,int entry_index); int data_field_index(unsigned char *field_name); unsigned char *data_field(unsigned int index,unsigned int field); unsigned char *itoa(int n,unsigned char *s); void a_b_compare(); void clean_a_b(); void create_a(); void create_b(); void sort_a(); void sort_b(); void init_given_fields(stack_block *block); void init_cb_fields(stack_block *block); void sdl_restart ( FILE *input_file ); #ifndef YYSTYPE #define YYSTYPE int #endif #include #ifndef __cplusplus #ifndef __STDC__ #define const #endif #endif #define YYFINAL 343 #define YYFLAG -32768 #define YYNTBASE 79 #define YYTRANSLATE(x) ((unsigned)(x) <= 316 ? yytranslate[x] : 106) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 66, 2, 2, 2, 2, 2, 2, 72, 73, 63, 62, 76, 61, 2, 64, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 75, 60, 74, 59, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 77, 2, 78, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 70, 2, 71, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 65, 67, 68, 69 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 2, 4, 7, 8, 13, 14, 20, 21, 30, 31, 40, 41, 47, 48, 54, 55, 61, 62, 69, 78, 83, 89, 95, 101, 107, 111, 115, 125, 133, 141, 144, 147, 150, 153, 156, 159, 173, 184, 185, 191, 202, 210, 215, 219, 221, 225, 231, 235, 239, 242, 246, 250, 254, 258, 262, 266, 270, 274, 278, 282, 286, 290, 293, 295, 297, 302, 309, 318, 325, 330, 332, 336, 340, 344, 348, 352, 356, 359, 361, 363, 368, 375, 384, 391, 396, 398, 400, 404, 408, 412, 426, 437, 445, 447, 448, 450, 452, 456, 460, 474, 485, 493, 507, 518, 526, 530, 534, 538, 540, 542, 544, 546, 550, 554, 558 }; static const short yyrhs[] = { 80, 0, 81, 0, 80, 81, 0, 0, 4, 82, 80, 17, 0, 0, 5, 83, 70, 80, 71, 0, 0, 31, 72, 103, 73, 84, 70, 80, 71, 0, 0, 32, 72, 105, 73, 85, 70, 80, 71, 0, 0, 33, 86, 70, 80, 71, 0, 0, 6, 70, 87, 80, 71, 0, 0, 7, 70, 88, 80, 71, 0, 0, 10, 93, 70, 89, 80, 71, 0, 28, 70, 95, 71, 29, 70, 99, 71, 0, 3, 74, 93, 75, 0, 12, 72, 92, 73, 75, 0, 13, 72, 93, 73, 75, 0, 48, 72, 93, 73, 75, 0, 45, 72, 18, 73, 75, 0, 3, 68, 75, 0, 3, 67, 75, 0, 16, 72, 3, 76, 3, 76, 93, 73, 75, 0, 15, 72, 3, 76, 93, 73, 75, 0, 30, 72, 3, 76, 93, 73, 75, 0, 21, 75, 0, 22, 75, 0, 34, 75, 0, 52, 75, 0, 53, 75, 0, 54, 75, 0, 3, 77, 93, 78, 77, 93, 78, 77, 93, 78, 58, 93, 75, 0, 3, 77, 93, 78, 77, 93, 78, 58, 93, 75, 0, 0, 3, 58, 90, 93, 75, 0, 3, 77, 93, 78, 77, 93, 78, 77, 93, 78, 0, 3, 77, 93, 78, 77, 93, 78, 0, 3, 77, 93, 78, 0, 3, 77, 78, 0, 3, 0, 3, 76, 3, 0, 92, 76, 3, 76, 3, 0, 93, 50, 93, 0, 93, 51, 93, 0, 66, 93, 0, 93, 59, 93, 0, 93, 38, 93, 0, 93, 60, 93, 0, 93, 40, 93, 0, 93, 41, 93, 0, 93, 42, 93, 0, 93, 61, 93, 0, 93, 62, 93, 0, 93, 63, 93, 0, 93, 64, 93, 0, 72, 93, 73, 0, 93, 69, 93, 0, 61, 93, 0, 91, 0, 19, 0, 20, 72, 93, 73, 0, 43, 72, 93, 76, 93, 73, 0, 27, 72, 93, 76, 93, 76, 93, 73, 0, 26, 72, 93, 76, 93, 73, 0, 44, 72, 93, 73, 0, 18, 0, 94, 61, 94, 0, 94, 62, 94, 0, 94, 63, 94, 0, 94, 64, 94, 0, 72, 94, 73, 0, 94, 69, 94, 0, 61, 94, 0, 91, 0, 19, 0, 20, 72, 94, 73, 0, 43, 72, 94, 76, 94, 73, 0, 27, 72, 94, 76, 94, 76, 94, 73, 0, 26, 72, 94, 76, 94, 73, 0, 44, 72, 94, 73, 0, 18, 0, 96, 0, 95, 76, 96, 0, 97, 41, 97, 0, 97, 42, 97, 0, 72, 3, 73, 3, 77, 98, 78, 77, 98, 78, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 0, 94, 0, 0, 94, 0, 100, 0, 99, 76, 100, 0, 101, 58, 102, 0, 72, 3, 73, 3, 77, 98, 78, 77, 98, 78, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 77, 98, 78, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 77, 98, 78, 0, 72, 3, 73, 3, 77, 98, 78, 0, 102, 61, 102, 0, 102, 62, 102, 0, 72, 102, 73, 0, 19, 0, 18, 0, 3, 0, 104, 0, 103, 76, 104, 0, 3, 77, 78, 0, 103, 76, 19, 0, 103, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, 347, 353, 354, 357, 399, 403, 417, 460, 503, 528, 574, 669, 691, 751, 771, 782, 796, 803, 814, 824, 871, 888, 906, 936, 943, 950, 963, 976, 992, 1003, 1015, 1025, 1036, 1054, 1067, 1080, 1092, 1110, 1127, 1134, 1236, 1266, 1304, 1326, 1355, 1382, 1391, 1402, 1408, 1414, 1420, 1426, 1432, 1438, 1444, 1450, 1456, 1462, 1468, 1474, 1480, 1486, 1492, 1498, 1505, 1512, 1525, 1531, 1538, 1544, 1550, 1559, 1565, 1571, 1577, 1583, 1589, 1595, 1601, 1608, 1615, 1621, 1627, 1634, 1640, 1646, 1655, 1656, 1659, 1823, 1989, 2030, 2069, 2105, 2114, 2121, 2124, 2125, 2128, 2155, 2163, 2171, 2181, 2195, 2209, 2218, 2228, 2238, 2244, 2252, 2260, 2282, 2289, 2300, 2308, 2316 }; #endif #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) static const char * const yytname[] = { "$","error","$undefined.","NAME","BEGIN_STACK", "REPEAT","NEW_CARD","NEW_ENTRY","AFTER_STACK","AFTER_ALL","IF","ELSE","SORT_BY", "USE","USE_RPL","STRCPY","PAGE","END","STRING","NUMBER","EXIST","CONTINUE","BREAK", "SER_WRITE","LNK_WRITE","WPG_WRITE","INDEX","SUBSTR","WHEN","LINK","STRCAT", "GIVEN_NEW","CARD_BOOK","BOOK_ENTRIES","SKIP","CIF_ON","CIF_OFF","GT","GTE", "LT","LTE","EQ","NEQ","STRCMP","STRLEN","ERROR","QUAD","NORMALIZE","PRINT","RICH_LINES", "OR","AND","REPEAT_DATA","NEXT_CARD","LOSE_CURRENT_ENTRY","TOC_WRITE","FIND_UNIT", "SYM_SIZE","RPL_ASSIGN","'>'","'<'","'-'","'+'","'*'","'/'","UNARYMINUS","'!'", "PLUS_PLUS","MINUS_MINUS","TO_THE","'{'","'}'","'('","')'","'='","';'","','", "'['","']'","sdl","statements","statement","@1","@2","@3","@4","@5","@6","@7", "@8","@9","var","sort_by_args","expr","when_expr","when_conditions","when_condition", "when_value","when_index","link_statements","link_statement","link_variable", "link_expr","given_list","data_ref","book_list", NULL }; #endif static const short yyr1[] = { 0, 79, 80, 80, 82, 81, 83, 81, 84, 81, 85, 81, 86, 81, 87, 81, 88, 81, 89, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 90, 81, 91, 91, 91, 91, 91, 92, 92, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 95, 95, 96, 96, 97, 97, 97, 97, 98, 98, 99, 99, 100, 101, 101, 101, 102, 102, 102, 102, 102, 102, 102, 102, 102, 103, 103, 104, 105, 105 }; static const short yyr2[] = { 0, 1, 1, 2, 0, 4, 0, 5, 0, 8, 0, 8, 0, 5, 0, 5, 0, 5, 0, 6, 8, 4, 5, 5, 5, 5, 3, 3, 9, 7, 7, 2, 2, 2, 2, 2, 2, 13, 10, 0, 5, 10, 7, 4, 3, 1, 3, 5, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 4, 6, 8, 6, 4, 1, 3, 3, 3, 3, 3, 3, 2, 1, 1, 4, 6, 8, 6, 4, 1, 1, 3, 3, 3, 13, 10, 7, 1, 0, 1, 1, 3, 3, 13, 10, 7, 13, 10, 7, 3, 3, 3, 1, 1, 1, 1, 3, 3, 3, 1 }; static const short yydefact[] = { 0, 0, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 1, 2, 39, 0, 0, 0, 0, 0, 0, 14, 16, 45, 71, 65, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 31, 32, 0, 0, 0, 0, 0, 33, 0, 0, 34, 35, 36, 3, 0, 27, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 86, 80, 0, 0, 0, 0, 0, 0, 0, 79, 94, 0, 87, 0, 0, 0, 0, 112, 116, 0, 0, 0, 0, 0, 21, 0, 5, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 61, 52, 54, 55, 56, 48, 49, 51, 53, 57, 58, 59, 60, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 10, 0, 0, 0, 40, 0, 7, 15, 17, 43, 66, 0, 0, 0, 70, 0, 46, 22, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 76, 72, 73, 74, 75, 77, 0, 88, 89, 90, 0, 114, 0, 113, 115, 0, 13, 25, 24, 0, 0, 0, 0, 0, 19, 0, 0, 0, 81, 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 69, 0, 67, 47, 29, 0, 0, 0, 0, 95, 0, 0, 97, 0, 30, 0, 0, 0, 0, 42, 0, 0, 84, 0, 82, 96, 0, 0, 20, 0, 0, 9, 11, 0, 0, 0, 68, 28, 0, 93, 0, 98, 111, 110, 109, 0, 99, 38, 0, 0, 83, 95, 0, 111, 0, 0, 0, 0, 41, 0, 95, 0, 108, 106, 107, 0, 92, 0, 0, 37, 95, 102, 95, 0, 95, 0, 91, 0, 105, 101, 95, 95, 0, 0, 104, 100, 95, 0, 103, 0, 0, 0 }; static const short yydefgoto[] = { 341, 24, 25, 31, 32, 224, 227, 58, 73, 74, 154, 66, 46, 99, 47, 277, 114, 115, 116, 278, 263, 264, 265, 298, 119, 120, 122 }; static const short yypact[] = { 714, -36,-32768,-32768, -55, -46, 288, -43, -17, 4, 8, -33, 3, 17, 23, 34, 43,-32768, 46, 54, 60, 65, 68, 73, 714,-32768,-32768, 79, 80, 288, 288, 714, 71,-32768,-32768, 84,-32768,-32768, 88, 90, 96, 101, 104, 288, 288, 288,-32768, 1268, 153, 288, 174, 177,-32768,-32768, 70, 179, 180, 180, 114,-32768, 167, 288,-32768,-32768,-32768,-32768, 288,-32768,-32768, 983, 191, 662, 714, 714, 714, 131, 288, 288, 288, 288, 288, 117, 117, 1103, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288,-32768, 122, -60, 1118, 123, 136,-32768,-32768, 142, 143, 145, 146, 150, 220, 300,-32768, 326, -70,-32768, 5, 148, 149, -1,-32768, 152, 157, 714, 163, 1133, 1013,-32768, 160,-32768, 370, 404, 456,-32768, 713, 1148, 863, 893, 923, 1163,-32768, 467, 467, 467, 467, 1283, 1313, 467, 467, -30, -30, 117, 117, 117, 714, 222, 170, 245, 181, 288, 254, 220, 220, 220, 220, 220, 220, 190, -66, 66, 220, 220, 220, 220, 220, 233, 70, 70, 70, 288, 187, -32768, 180, 9,-32768, 490, 192, 196,-32768, 288,-32768, -32768,-32768, 189,-32768, 288, 288, 288,-32768, 542,-32768, -32768, 199,-32768, 1178, 200, 248, 22, 83, 103, 261, 274,-32768, 36, 36, 190, 190, 190, 210,-32768,-32768, -32768, 1193,-32768, 212,-32768,-32768, 223,-32768,-32768,-32768, 743, 288, 1208, 953, 1223,-32768, 296, 229, 288,-32768, 220, 220, 220,-32768, 228, 241, 253, 714, 714, -50, 773,-32768, 288,-32768,-32768,-32768, 1238, 277, 132, 295, 220, 313, -62,-32768, 271,-32768, 576, 628, 288, 288, 256, 1253, 260,-32768, 220,-32768, 326, 258, 264,-32768, 241, 2,-32768,-32768, 1043, 803, 288,-32768,-32768, 381, 265, 342,-32768,-32768,-32768,-32768, 7, 31,-32768, 289, 833,-32768, 220, 275, 278, -25, 2, 2, 288,-32768, 270, 220, 350,-32768,-32768,-32768, 1073, 285, 291, 286, -32768, 220, 293, 220, 301, 220, 303,-32768, 306, 294, 316, 220, 220, 318, 319, 317,-32768, 220, 327,-32768, 355, 378,-32768 }; static const short yypgoto[] = {-32768, -29, 6,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768, -54,-32768, -26, 124,-32768, 230, -76, -122,-32768, 140,-32768, -226, 356, -79,-32768 }; #define YYLAST 1382 static const short yytable[] = { 112, 175, 71, 69, 70, 294, 176, 211, 269, 280, 305, 75, 118, 156, 281, 33, 157, 81, 82, 83, 295, 296, 26, 100, 34, 295, 296, 270, 226, 48, 65, 27, 28, 94, 95, 125, 307, 308, 29, 96, 126, 30, 52, 130, 131, 132, 177, 178, 314, 134, 135, 136, 137, 138, 139, 49, 112, 112, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 306, 181, 35, 297, 182, 50, 65, 53, 297, 51, 315, 316, 170, 171, 172, 173, 54, 103, 104, 105, 174, 307, 308, 185, 55, 106, 107, 241, 172, 173, 220, 221, 225, 225, 174, 56, 112, 112, 112, 112, 112, 112, 108, 109, 57, 112, 112, 112, 112, 112, 59, 112, 112, 112, 199, 60, 170, 171, 172, 173, 110, 61, 204, 35, 174, 65, 65, 65, 212, 62, 72, 111, 63, 170, 171, 172, 173, 64, 36, 37, 38, 174, 222, 67, 68, 98, 39, 40, 242, 76, 75, 77, 231, 170, 171, 172, 173, 78, 233, 234, 235, 174, 79, 41, 42, 80, 101, 113, 243, 102, 311, 117, 118, 123, 124, 96, 112, 112, 112, 319, 65, 43, 170, 171, 172, 173, 44, 155, 159, 325, 174, 327, 45, 329, 65, 251, 112, 275, 133, 334, 335, 160, 257, 161, 162, 339, 163, 164, 267, 268, 112, 165, 35, 179, 200, 180, 272, 183, 84, 184, 85, 86, 87, 167, 169, 186, 189, 103, 104, 105, 88, 89, 285, 286, 201, 106, 107, 202, 112, 90, 91, 92, 93, 94, 95, 203, 205, 112, 174, 96, 301, 218, 108, 109, 223, 232, 229, 112, 128, 112, 230, 112, 65, 65, 237, 239, 245, 112, 112, 246, 110, 248, 317, 112, 206, 207, 208, 209, 210, 169, 35, 166, 249, 213, 214, 215, 216, 217, 255, 113, 113, 113, 168, 256, 261, 36, 37, 38, 170, 171, 172, 173, 262, 39, 40, 279, 174, 103, 104, 105, 240, 170, 171, 172, 173, 106, 107, 266, 282, 174, 41, 42, 287, 244, 289, 291, 292, 170, 171, 172, 173, 303, 108, 109, 304, 174, 309, 318, 43, 274, 313, 312, 320, 44, 342, 170, 171, 172, 173, 45, 110, 322, 324, 174, 258, 259, 260, 276, 323, 326, 332, 166, 1, 2, 3, 4, 5, 343, 328, 6, 330, 7, 8, 331, 9, 10, 170, 171, 172, 173, 11, 12, 333, 338, 174, 336, 337, 13, 290, 14, 15, 16, 17, 18, 340, 219, 1, 2, 3, 4, 5, 0, 121, 6, 19, 7, 8, 20, 9, 10, 293, 21, 22, 23, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 190, 170, 171, 172, 173, 0, 0, 0, 19, 174, 0, 20, 0, 302, 0, 21, 22, 23, 1, 2, 3, 4, 5, 0, 0, 6, 0, 7, 8, 0, 9, 10, 0, 0, 191, 0, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 1, 2, 3, 4, 5, 0, 0, 6, 19, 7, 8, 20, 9, 10, 0, 21, 22, 23, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 192, 92, 93, 94, 95, 0, 0, 0, 19, 96, 0, 20, 0, 0, 0, 21, 22, 23, 1, 2, 3, 4, 5, 0, 0, 6, 0, 7, 8, 0, 9, 10, 0, 0, 228, 0, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 1, 2, 3, 4, 5, 0, 0, 6, 19, 7, 8, 20, 9, 10, 0, 21, 22, 23, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 236, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 20, 0, 0, 0, 21, 22, 23, 1, 2, 3, 4, 5, 0, 0, 6, 0, 7, 8, 0, 9, 10, 0, 0, 283, 0, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 1, 2, 3, 4, 5, 0, 0, 6, 19, 7, 8, 20, 9, 10, 129, 21, 22, 23, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 284, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 20, 0, 0, 0, 21, 22, 23, 1, 2, 3, 4, 5, 0, 0, 6, 0, 7, 8, 0, 9, 10, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, 18, 0, 0, 84, 0, 85, 86, 87, 0, 0, 0, 19, 0, 0, 20, 88, 89, 0, 21, 22, 23, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 0, 0, 193, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 0, 0, 250, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 0, 0, 271, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 0, 0, 300, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 0, 0, 310, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 195, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 196, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 197, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 253, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 127, 0, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 188, 0, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 299, 0, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 321, 0, 0, 0, 0, 88, 89, 0, 84, 0, 85, 86, 87, 0, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 140, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 158, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 187, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 194, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 198, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 238, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 247, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 252, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 254, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 273, 90, 91, 92, 93, 94, 95, 88, 89, 0, 84, 96, 85, 86, 87, 288, 90, 91, 92, 93, 94, 95, 0, 89, 0, 0, 96, 97, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 84, 96, 85, 86, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, 0, 96 }; static const short yycheck[] = { 54, 71, 31, 29, 30, 3, 76, 73, 58, 71, 3, 77, 3, 73, 76, 70, 76, 43, 44, 45, 18, 19, 58, 49, 70, 18, 19, 77, 19, 72, 24, 67, 68, 63, 64, 61, 61, 62, 74, 69, 66, 77, 75, 72, 73, 74, 41, 42, 73, 75, 76, 77, 78, 79, 80, 72, 110, 111, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 297, 73, 3, 72, 76, 72, 71, 75, 72, 72, 307, 308, 61, 62, 63, 64, 70, 18, 19, 20, 69, 61, 62, 123, 72, 26, 27, 76, 63, 64, 177, 178, 182, 183, 69, 72, 161, 162, 163, 164, 165, 166, 43, 44, 72, 170, 171, 172, 173, 174, 75, 176, 177, 178, 154, 72, 61, 62, 63, 64, 61, 72, 159, 3, 69, 130, 131, 132, 73, 75, 70, 72, 75, 61, 62, 63, 64, 75, 18, 19, 20, 69, 179, 75, 75, 3, 26, 27, 76, 72, 77, 72, 189, 61, 62, 63, 64, 72, 195, 196, 197, 69, 72, 43, 44, 72, 3, 54, 76, 3, 303, 3, 3, 70, 18, 69, 241, 242, 243, 312, 185, 61, 61, 62, 63, 64, 66, 76, 76, 322, 69, 324, 72, 326, 199, 232, 261, 76, 78, 332, 333, 76, 239, 72, 72, 338, 72, 72, 248, 249, 275, 72, 3, 76, 3, 77, 253, 76, 38, 73, 40, 41, 42, 110, 111, 73, 77, 18, 19, 20, 50, 51, 269, 270, 75, 26, 27, 3, 303, 59, 60, 61, 62, 63, 64, 75, 3, 312, 69, 69, 287, 29, 43, 44, 78, 77, 75, 322, 78, 324, 75, 326, 267, 268, 76, 76, 3, 332, 333, 70, 61, 70, 309, 338, 161, 162, 163, 164, 165, 166, 3, 72, 70, 170, 171, 172, 173, 174, 3, 176, 177, 178, 3, 75, 77, 18, 19, 20, 61, 62, 63, 64, 72, 26, 27, 3, 69, 18, 19, 20, 73, 61, 62, 63, 64, 26, 27, 75, 58, 69, 43, 44, 77, 73, 75, 78, 73, 61, 62, 63, 64, 77, 43, 44, 3, 69, 58, 78, 61, 73, 73, 77, 3, 66, 0, 61, 62, 63, 64, 72, 61, 77, 77, 69, 241, 242, 243, 73, 78, 77, 77, 72, 3, 4, 5, 6, 7, 0, 78, 10, 78, 12, 13, 78, 15, 16, 61, 62, 63, 64, 21, 22, 77, 77, 69, 78, 78, 28, 275, 30, 31, 32, 33, 34, 78, 176, 3, 4, 5, 6, 7, -1, 57, 10, 45, 12, 13, 48, 15, 16, 281, 52, 53, 54, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 71, 61, 62, 63, 64, -1, -1, -1, 45, 69, -1, 48, -1, 73, -1, 52, 53, 54, 3, 4, 5, 6, 7, -1, -1, 10, -1, 12, 13, -1, 15, 16, -1, -1, 71, -1, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 3, 4, 5, 6, 7, -1, -1, 10, 45, 12, 13, 48, 15, 16, -1, 52, 53, 54, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 71, 61, 62, 63, 64, -1, -1, -1, 45, 69, -1, 48, -1, -1, -1, 52, 53, 54, 3, 4, 5, 6, 7, -1, -1, 10, -1, 12, 13, -1, 15, 16, -1, -1, 71, -1, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 3, 4, 5, 6, 7, -1, -1, 10, 45, 12, 13, 48, 15, 16, -1, 52, 53, 54, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 71, -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, -1, -1, 52, 53, 54, 3, 4, 5, 6, 7, -1, -1, 10, -1, 12, 13, -1, 15, 16, -1, -1, 71, -1, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 3, 4, 5, 6, 7, -1, -1, 10, 45, 12, 13, 48, 15, 16, 17, 52, 53, 54, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 71, -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, -1, -1, 52, 53, 54, 3, 4, 5, 6, 7, -1, -1, 10, -1, 12, 13, -1, 15, 16, -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, -1, 28, -1, 30, 31, 32, 33, 34, -1, -1, 38, -1, 40, 41, 42, -1, -1, -1, 45, -1, -1, 48, 50, 51, -1, 52, 53, 54, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, -1, -1, 78, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, -1, -1, 78, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, -1, -1, 78, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, -1, -1, 78, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, -1, -1, 78, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, 76, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, 76, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, 76, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, 76, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, 75, -1, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, 75, -1, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, 75, -1, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, 75, -1, -1, -1, -1, 50, 51, -1, 38, -1, 40, 41, 42, -1, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, 50, 51, -1, 38, 69, 40, 41, 42, 73, 59, 60, 61, 62, 63, 64, -1, 51, -1, -1, 69, 70, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, 38, 69, 40, 41, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, 69 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/lib/bison.simple" /* This file comes from bison-1.28. */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ #ifndef YYSTACK_USE_ALLOCA #ifdef alloca #define YYSTACK_USE_ALLOCA #else /* alloca not defined */ #ifdef __GNUC__ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #else /* not GNU C. */ #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) #define YYSTACK_USE_ALLOCA #include #else /* not sparc */ /* We think this test detects Watcom and Microsoft C. */ /* This used to test MSDOS, but that is a bad idea since that symbol is in the user namespace. */ #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) #if 0 /* No need for malloc.h, which pollutes the namespace; instead, just don't use alloca. */ #include #endif #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) /* I don't know what this was needed for, but it pollutes the namespace. So I turned it off. rms, 2 May 1997. */ /* #include */ #pragma alloca #define YYSTACK_USE_ALLOCA #else /* not MSDOS, or __TURBOC__, or _AIX */ #if 0 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, and on HPUX 10. Eventually we can turn this on. */ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #endif /* __hpux */ #endif #endif /* not _AIX */ #endif /* not MSDOS, or __TURBOC__ */ #endif /* not sparc */ #endif /* not GNU C */ #endif /* alloca not defined */ #endif /* YYSTACK_USE_ALLOCA not defined */ #ifdef YYSTACK_USE_ALLOCA #define YYSTACK_ALLOC alloca #else #define YYSTACK_ALLOC malloc #endif /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YYPURE #define YYLEX yylex() #endif #ifdef YYPURE #ifdef YYLSP_NEEDED #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) #else #define YYLEX yylex(&yylval, &yylloc) #endif #else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, YYLEX_PARAM) #else #define YYLEX yylex(&yylval) #endif #endif /* not YYLSP_NEEDED */ #endif /* If nonreentrant, generate the variables here */ #ifndef YYPURE int yychar; /* the lookahead symbol */ YYSTYPE yylval; /* the semantic value of the */ /* lookahead symbol */ #ifdef YYLSP_NEEDED YYLTYPE yylloc; /* location data for the lookahead */ /* symbol */ #endif int yynerrs; /* number of parse errors so far */ #endif /* not YYPURE */ #if YYDEBUG != 0 int yydebug; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif /* Define __yy_memcpy. Note that the size argument should be passed with type unsigned int, because that is what the non-GCC definitions require. With GCC, __builtin_memcpy takes an arg of type size_t, but it can handle unsigned int. */ #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (to, from, count) char *to; char *from; unsigned int count; { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #else /* __cplusplus */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (char *to, char *from, unsigned int count) { register char *t = to; register char *f = from; register int i = count; while (i-- > 0) *t++ = *f++; } #endif #endif #line 217 "/usr/lib/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM #ifdef __cplusplus #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM #define YYPARSE_PARAM_DECL #else /* not __cplusplus */ #define YYPARSE_PARAM_ARG YYPARSE_PARAM #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; #endif /* not __cplusplus */ #else /* not YYPARSE_PARAM */ #define YYPARSE_PARAM_ARG #define YYPARSE_PARAM_DECL #endif /* not YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ #ifdef YYPARSE_PARAM int yyparse (void *); #else int yyparse (void); #endif #endif int yyparse(YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL { register int yystate; register int yyn; register short *yyssp; register YYSTYPE *yyvsp; int yyerrstatus; /* number of tokens to shift before error messages enabled */ int yychar1 = 0; /* lookahead token as an internal (translated) token number */ short yyssa[YYINITDEPTH]; /* the state stack */ YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ short *yyss = yyssa; /* refer to the stacks thru separate pointers */ YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YYLSP_NEEDED YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif int yystacksize = YYINITDEPTH; int yyfree_stacks = 0; #ifdef YYPURE int yychar; YYSTYPE yylval; int yynerrs; #ifdef YYLSP_NEEDED YYLTYPE yylloc; #endif #endif YYSTYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ int yylen; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YYLSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yynewstate: *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YYLSP_NEEDED YYLTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YYLSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; #ifndef YYSTACK_USE_ALLOCA yyfree_stacks = 1; #endif yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); __yy_memcpy ((char *)yyss, (char *)yyss1, size * (unsigned int) sizeof (*yyssp)); yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * (unsigned int) sizeof (*yyvsp)); #ifdef YYLSP_NEEDED yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); __yy_memcpy ((char *)yyls, (char *)yyls1, size * (unsigned int) sizeof (*yylsp)); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YYLSP_NEEDED yylsp = yyls + size - 1; #endif #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Entering state %d\n", yystate); #endif goto yybackup; yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Reading a token: "); #endif yychar = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(yychar); #if YYDEBUG != 0 if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, yychar, yylval); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /* Do the default action for the current state. */ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; /* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YYDEBUG != 0 if (yydebug) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 1: #line 348 "sdl_y.y" { printf("\nDone.\n"); ; break;} case 4: #line 358 "sdl_y.y" { # ifdef SD_DEBUG4 yydebug = 1; # endif if (in_new_stack) { printf("You may not nest STACK blocks.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } in_new_stack = 1; if (!do_not_execute ) { unsigned char buf[100]; /* Making the first card in a stack. */ current_card = (struct Card *) my_malloc(sizeof(struct Card)); entry_index = 0; current_card->entries = (struct Entry **) my_malloc(100*sizeof(struct Entry *)); current_card->entries[entry_index] = (struct Entry *) my_malloc(sizeof(struct Entry)); current_entry = current_card->entries[entry_index]; current_entry->card = current_card; entry_index++; /* Update the rpl_list to include this stack. */ /* the rpl_list consists of pointers to all the rpl files so far constructed. These are all still in memory as linked lists. */ rpl_list[rpl_index] = (struct rpl *) my_malloc(sizeof(struct rpl)); rpl_list[rpl_index]->cards = (struct Card **) my_malloc(CARD_PTR_BLOCK*sizeof(struct Card *)); rpl_list[rpl_index]->card_index = 1; rpl_list[rpl_index]->cards[rpl_list[rpl_index]->card_index] = current_card; current_rpl = rpl_index; rpl_index++; /* Card index maintenance. */ /* note: rpl_list[current_rpl]->card_index is always one greater than the real current card number */ rpl_list[current_rpl]->card_index++; u_card_num = 1; set_local_value("CARDNUM",itoa(u_card_num,buf)); } ; break;} case 5: #line 400 "sdl_y.y" { in_new_stack = 0; ; break;} case 6: #line 404 "sdl_y.y" { /* When the token REPEAT appears, the lexical module takes note of the file position and stores it in p1, whence it is pushed onto a stack of loop information here. This strategy is used for each loop interpretation. */ repeat_file_pos[current_repeat] = p1; repeat_line_pos[current_repeat++] = file_lineno; ; break;} case 7: #line 418 "sdl_y.y" { /* The state of do_not_execute is important for each interpretive instruction. Most only check it to see whether or not they should execute. Repeats always put themselves on the stack, whether or not they are executing, which doesn't seem correct but works... After a block is run, the value of do_not_execute might be CONTINUE, which implies that the loop be restarted, or BREAK which implies that it shouldn't. If the loop needs restarting, the stored file position is popped and the file repositioned. */ if (do_not_execute == CONTINUE && continue_repeat == current_repeat) { do_not_execute = 0; # ifdef SD_DEBUG3 printf("\n***TURNING EVERYTHING ON from CONTINUE %d\n",current_repeat); # endif } if (!do_not_execute) { fseek(sdl_fd,repeat_file_pos[current_repeat-1],0); file_lineno = repeat_line_pos[current_repeat-1]; // ### ber sdl_flush_lex_buffers(); // sdl_restart(sdl_fd); // yysptr = yysbuf; /* Reset lexer input stream */ # ifdef SD_DEBUG2 printf("\nACTIVE REPEAT %d ENDS & STARTS ANEW\n",current_repeat); # endif } /* breaks and continues always effect only the correct level */ if ((do_not_execute == BREAK) && (break_repeat == current_repeat) ) { do_not_execute = 0; # ifdef SD_DEBUG2 printf("\nACTIVE REPEAT %d ENDS & BREAKS",current_repeat); # endif # ifdef SD_DEBUG3 printf("\n***TURNING EVERYTHING ON from BREAK %d\n",current_repeat); # endif } current_repeat--; ; break;} case 8: #line 461 "sdl_y.y" { /* GIVEN_NEW is a Piper-loop, so named because Jan Piper was going loopy trying to do what these structures do. They are loops with inherited conditions, so that the constraint on the outside loop (based on a changed value while traversing input records) applies also to the inner loop. */ /* if in card book, complain */ if (in_card_book) { printf("You currently may not use GIVEN within a card_book.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* if in repeat, complain */ if (current_repeat) { printf("You may not use GIVEN within repeat blocks.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (!do_not_execute) { if (first_given[current_given]) { if (current_given) { given_data_index[current_given] = given_data_index[current_given-1]; } else { given_data_index[current_given] = 0; } init_given_fields(&yyvsp[-1]); first_given[current_given] = 0; } skip_card[current_given] = current_card; skip_entries[current_given] = current_card->entries; skip_entry[current_given] = current_entry; skip_card_index[current_given] = rpl_list[current_rpl]->card_index; skip_card_num[current_given] = u_card_num; given_file_pos[current_given] = p2; given_line_pos[current_given++] = file_lineno; } ; break;} case 9: #line 504 "sdl_y.y" { if ((do_not_execute == SKIP) && (skip_given == current_given)) { do_not_execute = 0; first_book_card = 1; given_undo(); } /* if there's more new data start loop again */ if (!do_not_execute) { if (given_advance(&yyvsp[-5])) { fseek(sdl_fd,given_file_pos[current_given-1],0); file_lineno = given_line_pos[current_given-1]; sdl_flush_lex_buffers(); //sdl_restart(sdl_fd); // yysptr = yysbuf; /* Reset lexer input stream */ } else { first_given[current_given-1] = 1; } /* or fall out of loop */ clear_skip_list(); current_given--; } ; break;} case 10: #line 529 "sdl_y.y" { unsigned char buf[100]; /* if in new card, complain */ if (in_new_card) { printf("You currently may not call card_book within new_card.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* if in card book, complain */ if (in_card_book) { printf("You currently may not nest card_books.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } in_card_book = 1; if (!do_not_execute) { /* user accessible variables */ u_entry_total = 0; set_local_value("ENTRYTOTAL",itoa(u_entry_total,buf)); u_current_page++; set_local_value("CURRENTPAGE",itoa(u_current_page,buf)); if (first_book_card) { card_book_count = 1; set_u_page_total(&yyvsp[-1]); if (current_given) { card_book_data_index = given_data_index[current_given -1]; } else { card_book_data_index = 0; } /* Set Global User variable DATA_INDEX */ set_local_value("DATA_INDEX",itoa(card_book_data_index,buf)); init_cb_fields(&yyvsp[-1]); first_book_card = 0; u_current_page = 1; set_local_value("CURRENTPAGE",itoa(u_current_page,buf)); } /* for looping */ book_file_pos = p3; book_line_pos = file_lineno; } ; break;} case 11: #line 575 "sdl_y.y" { int cba_return_value = 0; int new_value = 0; int old_value = 0; if (!do_not_execute) { make_new_card(); /* if repeat_data, reset it, restart loop but don't do card_book_advance. */ if (repeat_data) { repeat_data = 0; cba_return_value = 1; } else { cba_return_value = card_book_advance(); } /* if there's more new data start loop again */ if (entries_ok && cba_return_value) { fseek( sdl_fd, book_file_pos, 0); file_lineno = book_line_pos; sdl_flush_lex_buffers(); // sdl_restart(sdl_fd); // yysptr = yysbuf; /* Reset lexer input stream */ card_book_count++; printf("card_book_count incremented to %d\n",card_book_count); } else { /* fall out of loop */ first_book_card = 1; /* put in pagetotals if any */ /* ... if no skip */ if (ptl_index > 0 && (max_book_entries == -1)) { int i; unsigned char buf[100000]; strcpy(buf,""); for (i=0;ifields[page_total_list[i].field]) { strcpy(buf,page_total_list[i].entry->fields[page_total_list[i].field]); new_value = atoi(buf) + card_book_count + 1; sprintf(buf,"%d",new_value); if (strlen(buf) > strlen(page_total_list[i].entry->fields[page_total_list[i].field]) + 2) { /* error & exit */ printf("Failed to add pagetotal %d to entry fields after card book.\n",card_book_count); printf("Line %d. Exiting.\n",file_lineno); exit(1); } strcpy(page_total_list[i].entry->fields[page_total_list[i].field],buf); /* ... watch out for lose_entry entries! */ } } else { /* card */ if (page_total_list[i].card->fields[page_total_list[i].field]) { strcpy(buf,page_total_list[i].card->fields[page_total_list[i].field]); old_value = atoi(buf); new_value = old_value + card_book_count + 1; printf("\nold_value %d, card_book_count %d, new_value %d\n", old_value, card_book_count, new_value); sprintf(buf,"%d",new_value); if (strlen(buf) > (strlen(page_total_list[i].card->fields[page_total_list[i].field]) + 2)) { /* error & exit */ printf("Failed to add pagetotal %d to card fields after card book.\n",card_book_count); printf("Line %d. Exiting.\n",file_lineno); exit(1); } strcpy(page_total_list[i].card->fields[page_total_list[i].field],buf); } } } /* reset */ ptl_index = 0; memset(page_total_list,0,sizeof(page_total_list)); printf("card_book_count reset to %d\n",card_book_count); } card_book_count = 1; } } in_card_book = 0; if ((do_not_execute == BREAK)) { do_not_execute = 0; first_book_card = 1; } ; break;} case 12: #line 670 "sdl_y.y" { /* if not in card book, complain */ if (!in_card_book) { printf("You must use book_entries within a card_book.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* if in book entries, complain */ if (in_book_entries) { printf("You may not nest BOOK_ENTRIES blocks.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } in_book_entries = 1; if (!do_not_execute) { entries_ok = 1; entries_file_pos = p4; entries_line_pos = file_lineno; } ; break;} case 13: #line 692 "sdl_y.y" { unsigned char buf[100]; int cba_return_value = 0; if (!do_not_execute) { /* if LOSE_CURRENT_ENTRY then do so. */ if (lose_current_entry) { lose_current_entry = 0; lose_entry(); u_entry_total--; } make_new_entry(); ++u_entry_total; /* if under maximum entries, start loop again */ /* or, if no max entries (-1), if NEXT_CARD not set and no_max_safeguard is less than 10000. */ if (max_book_entries == -1 && ++no_max_safeguard > SAFEGUARD_LIMIT) { printf("%s: Bookentries loop iterated past safety limit %d. Line %d. Exiting.\n", sdl_file, SAFEGUARD_LIMIT, file_lineno); exit(1); } if ((max_book_entries == -1 && next_card == 0) || (u_entry_total < max_book_entries)) { if (repeat_data) { repeat_data = 0; cba_return_value = 1; } else { cba_return_value = card_book_advance(); } if (cba_return_value) { fseek(sdl_fd,entries_file_pos,0); sdl_flush_lex_buffers(); // sdl_restart(sdl_fd); // yysptr = yysbuf; /* Reset lexer input stream */ file_lineno = entries_line_pos; } else { entries_ok = 0; } } else { /* otherwise fall out of loop */ no_max_safeguard = 0; /* note: next_card's job is done just by not resetting book_entries loop. New card is automatically created when we fall out. */ if (next_card) next_card = 0; } set_local_value("ENTRYTOTAL",itoa(u_entry_total,buf)); } in_book_entries = 0; ; break;} case 14: #line 752 "sdl_y.y" { unsigned char buf[100]; # ifdef SD_DEBUG5 printf("\n NEW CARD number is %d.\n",rpl_list[current_rpl]->card_index-1); # endif if (in_new_card) { printf("You may not nest NEW_CARD blocks.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } in_new_card = 1; if (!do_not_execute) { if (in_card_book) { make_and_push_card(); } u_entry_total = 0; set_local_value("ENTRYTOTAL",itoa(u_entry_total,buf)); } ; break;} case 15: #line 772 "sdl_y.y" { if (!do_not_execute) { if (in_card_book) { finish_and_pop_card(); } else { make_new_card(); } } in_new_card = 0; ; break;} case 16: #line 783 "sdl_y.y" { unsigned char buf[100]; if (in_new_entry) { printf("You may not nest NEW_ENTRY blocks.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } in_new_entry = 1; if (!do_not_execute) { u_entry_total++; set_local_value("ENTRYTOTAL",itoa(u_entry_total,buf)); } ; break;} case 17: #line 797 "sdl_y.y" { if (!do_not_execute) { make_new_entry(); } in_new_entry = 0; ; break;} case 18: #line 804 "sdl_y.y" { /* everyone watches do_not_execute */ if ((!do_not_execute) && (!atoi(yyvsp[-1].value))) { do_not_execute = 1; strcpy(yyval.text,"DO_NOT_EXECUTE"); # ifdef SD_DEBUG3 printf("\n***TURNING EVERYTHING OFF from IF\n"); # endif } ; break;} case 19: #line 815 "sdl_y.y" { /* if execution turned off by partner, turn on. */ if (!strcmp(yyvsp[-2].text,"DO_NOT_EXECUTE")) { do_not_execute = 0; # ifdef SD_DEBUG3 printf("\n***TURNING EVERYTHING ON from IF\n"); # endif } ; break;} case 20: #line 825 "sdl_y.y" { /* don't do within a card, entry or a repeat construct */ if (in_card_book) { printf("You may not use WHEN-LINK within a card_book.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (in_new_card) { printf("You may not use WHEN-LINK in a card block.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (in_new_entry) { printf("You may not use WHEN-LINK in an entry block.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (in_book_entries) { printf("You may not use WHEN-LINK in a book_entries block.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (current_repeat) { printf("You may not use WHEN-LINK in a repeat block.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (current_given) { printf("You may not use WHEN-LINK in a given_new block.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (!do_not_execute) { /* (first we check for (a,b) type sets already restricted by the given (a,b) conditions, and sorted by the given (c) keys in the proper order.) */ create_a(); create_b(); sort_a(); sort_b(); a_b_compare(); clean_a_b(); } ; break;} case 21: #line 872 "sdl_y.y" { /* update or create local variable. */ if (!do_not_execute) { if (yyvsp[-3].text[0] == '_') { printf("\nSDL: Used _variable in '=' expression.\n"); printf("Perhaps use -> instead.\n"); printf("Variable: %s. Line %d. Exiting.\n", yyvsp[-3].text,file_lineno); exit(1); } set_local_value(yyvsp[-3].text,yyvsp[-1].value); # ifdef SD_DEBUG3 printf("#### %s is %s.",yyvsp[-3].text,yyvsp[-1].value); # endif } ; break;} case 22: #line 889 "sdl_y.y" { int i; if (!do_not_execute) { if (!strlen(data_file)) { printf("%s: sort before data available. Line %d. Exiting.\n", sdl_file, file_lineno); exit(1); } sort(); # ifdef SD_DEBUG6 for (i=0;iname); len = strlen(yyvsp[-1].value); ptr = my_malloc(len+2); assign_entry->fields[assign_name] = ptr; strcpy(assign_entry->fields[assign_name],yyvsp[-1].value); assign_entry->used = 1; assign_entry = 0; } ; break;} case 38: #line 1111 "sdl_y.y" { unsigned char *ptr; int len; /* ... exception for _Card needs to be made (not a field) */ if (!do_not_execute) { assign_stack = get_rpl_number(yyvsp[-7].value); assign_card = get_card(assign_stack,atoi(yyvsp[-4].value)); assign_name = card_field_index(yyvsp[-9].text,assign_card->name); len = strlen(yyvsp[-1].value); ptr = my_malloc(len+2); assign_card->fields[assign_name] = ptr; strcpy(assign_card->fields[assign_name],yyvsp[-1].value); assign_card->used = 1; } ; break;} case 39: #line 1128 "sdl_y.y" { if (!do_not_execute) { pagetotal_enabled = 1; pagetotal_seen = 0; } ; break;} case 40: #line 1135 "sdl_y.y" { unsigned char *ptr; int len,field_index; /* this is the only rpl_assign that anyone uses anymore. */ if (!do_not_execute) { pagetotal_enabled = 0; if (yyvsp[-4].text[0] == '_') { if (!in_new_card && !in_new_entry && !in_card_book) { printf("\nSDL: _Assignments without index must be made in\n"); printf(" new_card, card_book or new_entry block.\n"); printf(" Line %d. Exiting.\n",file_lineno); exit(1); } if (yyvsp[-4].text[1] == '_') { /* entry field */ field_index = entry_field_index(&yyvsp[-4].text[2], current_card_type); len = strlen(yyvsp[-1].value); ptr = my_malloc(len+4); current_entry->fields[field_index] = ptr; strcpy(current_entry->fields[field_index],yyvsp[-1].value); current_entry->used = 1; } else { /* card field */ if (!strcmp(yyvsp[-4].text,"_Card")) { strcpy(current_card_type,yyvsp[-1].value); strcpy(current_card->name,yyvsp[-1].value); current_card->used = 1; } else { field_index = card_field_index(&yyvsp[-4].text[1], current_card_type); len = strlen(yyvsp[-1].value); ptr = my_malloc(len+4); current_card->fields[field_index] = ptr; strcpy(current_card->fields[field_index],yyvsp[-1].value); current_card->used = 1; } } } else { /* .rpl global */ field_index = global_field_index(yyvsp[-4].text); strcpy(rpl_list[current_rpl]->fields[field_index],yyvsp[-1].value); } /* Save this card, entry and field. */ if (in_card_book && pagetotal_seen && (max_book_entries == -1)) { pagetotal_seen = 0; if (yyvsp[-4].text[0] == '_') { if (yyvsp[-4].text[1] == '_') { # ifdef SD_DEBUG7 printf("\nPAGETOTAL entry current_card %d, current_entry %d, field_index %d\n", current_card,current_entry,field_index); # endif if (!current_entry->fields[field_index]) { printf("There is no pointer at entry field %s.\n",yyvsp[-4].text); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* entry */ page_total_list[ptl_index].card = current_card; page_total_list[ptl_index].entry = current_entry; page_total_list[ptl_index++].field = field_index; if (ptl_index > PAGE_TOTAL_LIST_LIMIT) { printf("The number of page_totals to be inserted exceeded PAGE_TOTAL_LIST_LIMIT %d.\n",PAGE_TOTAL_LIST_LIMIT); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } else { # ifdef SD_DEBUG7 printf("\nPAGETOTAL card current_card %d, current_entry %d, field_index %d\n", current_card,current_entry,field_index); # endif if (!current_card->fields[field_index]) { printf("There is no pointer at card field %s.\n",yyvsp[-4].text); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* card */ page_total_list[ptl_index].card = current_card; /* entry is 0 if it's a card field */ page_total_list[ptl_index].entry = 0; page_total_list[ptl_index++].field = field_index; if (ptl_index > PAGE_TOTAL_LIST_LIMIT) { printf("The number of page_totals to be inserted exceeded PAGE_TOTAL_LIST_LIMIT %d.\n",PAGE_TOTAL_LIST_LIMIT); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } } } } ; break;} case 41: #line 1237 "sdl_y.y" { /* get value of entry field given rpl card, and entry, e.g. "S2Offset [21][15][2]" */ if (!do_not_execute) { assign_stack = get_rpl_number(yyvsp[-7].value); # ifdef SD_DEBUG5 printf("\n#### rpl_number for %s is %d.",yyvsp[-7].value,assign_stack); # endif assign_card = get_card(assign_stack,atoi(yyvsp[-4].value)); # ifdef SD_DEBUG5 printf("\n#### card %s for rpl %d is %d.",yyvsp[-4].value,assign_stack,assign_card); # endif assign_entry = get_entry(assign_card,atoi(yyvsp[-1].value)); assign_name = entry_field_index(yyvsp[-9].text,assign_card->name); if (!assign_entry->fields[assign_name]) { strcpy(yyval.value,""); } else { strcpy(yyval.value,assign_entry->fields[assign_name]); } # ifdef SD_DEBUG5 printf("\n#### overall value is %s.\n",yyval.value); # endif assign_entry = 0; } ; break;} case 42: #line 1267 "sdl_y.y" { /* get value of card field given rpl and card, e.g. "City[12][100]" */ if (!do_not_execute) { assign_stack = get_rpl_number(yyvsp[-4].value); # ifdef SD_DEBUG5 printf("\n#### rpl_number for %s is %d.",yyvsp[-4].value,assign_stack); # endif assign_card = get_card(assign_stack,atoi(yyvsp[-1].value)); # ifdef SD_DEBUG5 printf("\n#### card %s for rpl %d is %d.",yyvsp[-1].value,assign_stack,assign_card); # endif if (!strcasecmp(yyvsp[-6].text,"card")){ # ifdef SD_DEBUG5 printf("\n#### card %s's name is %s.",assign_card,assign_card->name); # endif strcpy(yyval.value,assign_card->name); } else { assign_name = card_field_index(yyvsp[-6].text,assign_card->name); if (!assign_card->fields[assign_name]) { strcpy(yyval.value,""); } else { strcpy(yyval.value,assign_card->fields[assign_name]); } # ifdef SD_DEBUG5 printf("\n#### overall value is %s.\n",yyval.value); # endif } } ; break;} case 43: #line 1305 "sdl_y.y" { /* this referes to source data, not .rpl (output) data */ int field_index; unsigned char *ptr; if (!do_not_execute) { if (yyvsp[-3].text[0] == '$') { /* index to the active read structure. */ field_index = data_field_index(&yyvsp[-3].text[1]); strcpy(yyval.value,(ptr=data_field( atoi(yyvsp[-1].value), field_index))); my_free(ptr); # ifdef SD_DEBUG3 printf("#### %s [ %s ] is %s.",yyvsp[-3].text,yyvsp[-1].value,yyval.value); # endif } else { printf("SDL: name with single index used without $ prefix.\n"); printf("Variable %s. Line %d. Exiting.\n",yyvsp[-3].text,file_lineno); exit(1); } } ; break;} case 44: #line 1327 "sdl_y.y" { /* this referes to source data, not .rpl (output) data */ int field_index; unsigned char *ptr; if (!do_not_execute) { /* complain if not in given or card_book */ if (!in_card_book && !current_given) { printf("You may not use empty brackets outside card_book or given_new.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (yyvsp[-2].text[0] == '$') { /* index to the active read structure. */ field_index = data_field_index(&yyvsp[-2].text[1]); if (in_card_book) { strcpy(yyval.value,(ptr=data_field(card_book_data_index, field_index))); } else { strcpy(yyval.value,(ptr=data_field(given_data_index[current_given-1], field_index))); } my_free(ptr); } else { printf("SDL: name with blank index used without $ prefix.\n"); printf("Variable %s. Line %d. Exiting.\n",yyvsp[-2].text,file_lineno); exit(1); } } ; break;} case 45: #line 1356 "sdl_y.y" { /* check for badly placed names */ if (!do_not_execute) { if (pagetotal_enabled && in_card_book && !strcmp(yyvsp[0].text,"PAGETOTAL")) { pagetotal_seen = 1; } if (yyvsp[0].text[0] == '$') { printf("SDL: source reference (using $) must have index.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (yyvsp[0].text[0] == '_') { printf("SDL: _var should only be used on left side of '<-' .\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* user symbol */ strcpy(yyval.value,get_local_value(yyvsp[0].text)); # ifdef SD_DEBUG3 printf("##### %s is %s.",yyvsp[0].text,yyval.value); # endif } ; break;} case 46: #line 1383 "sdl_y.y" { /* write into keys */ if (!do_not_execute) { key_type[number_of_keys] = string_to_key(yyvsp[-2].text); strcpy(key_field[number_of_keys],yyvsp[0].text); number_of_keys++; } ; break;} case 47: #line 1392 "sdl_y.y" { /* write into keys */ if (!do_not_execute) { key_type[number_of_keys] = string_to_key(yyvsp[-2].text); strcpy(key_field[number_of_keys],yyvsp[0].text); number_of_keys++; } ; break;} case 48: #line 1403 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value) || atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 49: #line 1409 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value) && atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 50: #line 1415 "sdl_y.y" { if (!do_not_execute) { if (!atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 51: #line 1421 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value) > atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 52: #line 1427 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value)>= atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 53: #line 1433 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value) < atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 54: #line 1439 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value)<= atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 55: #line 1445 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value) == atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 56: #line 1451 "sdl_y.y" { if (!do_not_execute) { if (atoi(yyvsp[-2].value) != atoi(yyvsp[0].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 57: #line 1457 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) - atoi(yyvsp[0].value)),yyval.value); } ; break;} case 58: #line 1463 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) + atoi(yyvsp[0].value)),yyval.value); } ; break;} case 59: #line 1469 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) * atoi(yyvsp[0].value)),yyval.value); } ; break;} case 60: #line 1475 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) / atoi(yyvsp[0].value)),yyval.value); } ; break;} case 61: #line 1481 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[-1].value); } ; break;} case 62: #line 1487 "sdl_y.y" { if (!do_not_execute) { itoa(pow(atoi(yyvsp[-2].value),atoi(yyvsp[0].value)),yyval.value); } ; break;} case 63: #line 1493 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[0].value) * -1),yyval.value); } ; break;} case 64: #line 1499 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,yyvsp[0].text); } ; break;} case 65: #line 1506 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,yyvsp[0].text); } ; break;} case 66: #line 1513 "sdl_y.y" { if (!do_not_execute) { if (yyvsp[-1].value) { if (strlen(yyvsp[-1].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } else { strcpy(yyval.value,"0"); } } ; break;} case 67: #line 1526 "sdl_y.y" { if (!do_not_execute) { itoa(strcmp(yyvsp[-3].value,yyvsp[-1].value),yyval.value); } ; break;} case 68: #line 1532 "sdl_y.y" { if (!do_not_execute) { strncpy(yyval.value,&yyvsp[-5].value[atoi(yyvsp[-3].value)],atoi(yyvsp[-1].value)); yyval.value[atoi(yyvsp[-1].value)] = '\0'; } ; break;} case 69: #line 1539 "sdl_y.y" { if (!do_not_execute) { itoa(myindex(yyvsp[-3].value,yyvsp[-1].value),yyval.value); } ; break;} case 70: #line 1545 "sdl_y.y" { if (!do_not_execute) { itoa(strlen(yyvsp[-1].value),yyval.value); } ; break;} case 71: #line 1551 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,yyvsp[0].text); } ; break;} case 72: #line 1560 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) - atoi(yyvsp[0].value)),yyval.value); } ; break;} case 73: #line 1566 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) + atoi(yyvsp[0].value)),yyval.value); } ; break;} case 74: #line 1572 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) * atoi(yyvsp[0].value)),yyval.value); } ; break;} case 75: #line 1578 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[-2].value) / atoi(yyvsp[0].value)),yyval.value); } ; break;} case 76: #line 1584 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[-1].value); } ; break;} case 77: #line 1590 "sdl_y.y" { if (!do_not_execute) { itoa(pow(atoi(yyvsp[-2].value),atoi(yyvsp[0].value)),yyval.value); } ; break;} case 78: #line 1596 "sdl_y.y" { if (!do_not_execute) { itoa((atoi(yyvsp[0].value) * -1),yyval.value); } ; break;} case 79: #line 1602 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,yyvsp[0].text); } ; break;} case 80: #line 1609 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,yyvsp[0].text); } ; break;} case 81: #line 1616 "sdl_y.y" { if (!do_not_execute) { if (strlen(yyvsp[-1].value)) strcpy(yyval.value,"1"); else strcpy(yyval.value,"0"); } ; break;} case 82: #line 1622 "sdl_y.y" { if (!do_not_execute) { itoa(strcmp(yyvsp[-3].value,yyvsp[-1].value),yyval.value); } ; break;} case 83: #line 1628 "sdl_y.y" { if (!do_not_execute) { strncpy(yyval.value,&yyvsp[-5].value[atoi(yyvsp[-3].value)],atoi(yyvsp[-1].value)); yyval.value[atoi(yyvsp[-1].value)] = '\0'; } ; break;} case 84: #line 1635 "sdl_y.y" { if (!do_not_execute) { itoa(myindex(yyvsp[-3].value,yyvsp[-1].value),yyval.value); } ; break;} case 85: #line 1641 "sdl_y.y" { if (!do_not_execute) { itoa(strlen(yyvsp[-1].value),yyval.value); } ; break;} case 86: #line 1647 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,yyvsp[0].text); } ; break;} case 89: #line 1660 "sdl_y.y" { /* determine condition type (a, b) or c based on what's in when_values for type (a,b), put condition on list for that set, which will be used upon close of when section to narrow down the data for the linking. For type c, put encoded condition on list for link time */ if (!do_not_execute) { /* condition for A */ if ((!strcmp(yyvsp[-2].text,"A")) && (!strcmp(yyvsp[0].text,"VALUE"))) { if (!strcmp(yyvsp[-2].value,"ENTRY")) { A.entry_condition[A.entry_condition_total].field = A_entry_lookup(yyvsp[-2].other); strcpy(A.entry_condition[A.entry_condition_total].value,yyvsp[0].value); A.entry_condition[A.entry_condition_total].comparison = EQUAL; A.entry_condition[A.entry_condition_total].type = ENTRY; A.entry_condition_total++; } if (!strcmp(yyvsp[-2].value,"CARD")) { if (!strcmp(yyvsp[-2].other,"Card")) { A.card_condition[A.card_condition_total].field = -1; } else { A.card_condition[A.card_condition_total].field = A_card_lookup(yyvsp[-2].other); } strcpy(A.card_condition[A.card_condition_total].value,yyvsp[0].value); A.card_condition[A.card_condition_total].comparison = EQUAL; A.card_condition[A.card_condition_total].type = CARD; A.card_condition_total++; } } if ((!strcmp(yyvsp[-2].text,"VALUE")) && (!strcmp(yyvsp[0].text,"A"))) { if (!strcmp(yyvsp[0].value,"ENTRY")) { A.entry_condition[A.entry_condition_total].field = A_entry_lookup(yyvsp[0].other); strcpy(A.entry_condition[A.entry_condition_total].value,yyvsp[-2].value); A.entry_condition[A.entry_condition_total].comparison = EQUAL; A.entry_condition[A.entry_condition_total].type = ENTRY; A.entry_condition_total++; } if (!strcmp(yyvsp[0].value,"CARD")) { if (!strcmp(yyvsp[0].other,"Card")) { A.card_condition[A.card_condition_total].field = -1; } else { A.card_condition[A.card_condition_total].field = A_card_lookup(yyvsp[0].other); } strcpy(A.card_condition[A.card_condition_total].value,yyvsp[-2].value); A.card_condition[A.card_condition_total].comparison = EQUAL; A.card_condition[A.card_condition_total].type = CARD; A.card_condition_total++; } } /* condition for B */ if ((!strcmp(yyvsp[-2].text,"B")) && (!strcmp(yyvsp[0].text,"VALUE"))) { if (!strcmp(yyvsp[-2].value,"ENTRY")) { B.entry_condition[B.entry_condition_total].field = B_entry_lookup(yyvsp[-2].other); strcpy(B.entry_condition[B.entry_condition_total].value,yyvsp[0].value); B.entry_condition[B.entry_condition_total].comparison = EQUAL; B.entry_condition[B.entry_condition_total].type = ENTRY; B.entry_condition_total++; } if (!strcmp(yyvsp[-2].value,"CARD")) { if (!strcmp(yyvsp[-2].other,"Card")) { B.card_condition[B.card_condition_total].field = -1; } else { B.card_condition[B.card_condition_total].field = B_card_lookup(yyvsp[-2].other); } strcpy(B.card_condition[B.card_condition_total].value,yyvsp[0].value); B.card_condition[B.card_condition_total].comparison = EQUAL; B.card_condition[B.card_condition_total].type = CARD; B.card_condition_total++; } } if ((!strcmp(yyvsp[-2].text,"VALUE")) && (!strcmp(yyvsp[0].text,"B"))) { if (!strcmp(yyvsp[0].value,"ENTRY")) { B.entry_condition[B.entry_condition_total].field = B_entry_lookup(yyvsp[0].other); strcpy(B.entry_condition[B.entry_condition_total].value,yyvsp[-2].value); B.entry_condition[B.entry_condition_total].comparison = EQUAL; B.entry_condition[B.entry_condition_total].type = ENTRY; B.entry_condition_total++; } if (!strcmp(yyvsp[0].value,"CARD")) { if (!strcmp(yyvsp[0].other,"Card")) { B.card_condition[B.card_condition_total].field = -1; } else { B.card_condition[B.card_condition_total].field = B_card_lookup(yyvsp[0].other); } strcpy(B.card_condition[B.card_condition_total].value,yyvsp[-2].value); B.card_condition[B.card_condition_total].comparison = EQUAL; B.card_condition[B.card_condition_total].type = CARD; B.card_condition_total++; } } if ((!strcmp(yyvsp[-2].text,"B")) && (!strcmp(yyvsp[0].text,"A"))) { /* a,b condition -- for sort */ if (!strcmp(yyvsp[-2].value,"ENTRY")) { B.c_condition[B.c_condition_total].field = B_entry_lookup(yyvsp[-2].other); B.c_condition[B.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeA = ENTRY; C.conditions[C.condition_total].fieldA = B_entry_lookup(yyvsp[-2].other); } if (!strcmp(yyvsp[-2].value,"CARD")) { B.c_condition[B.c_condition_total].field = B_card_lookup(yyvsp[-2].other); B.c_condition[B.c_condition_total].type = CARD; C.conditions[C.condition_total].typeA = CARD; C.conditions[C.condition_total].fieldA = B_card_lookup(yyvsp[-2].other); } if (!strcmp(yyvsp[0].value,"ENTRY")) { A.c_condition[A.c_condition_total].field = A_entry_lookup(yyvsp[0].other); A.c_condition[A.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeB = ENTRY; C.conditions[C.condition_total].fieldB = A_entry_lookup(yyvsp[0].other); } if (!strcmp(yyvsp[0].value,"CARD")) { A.c_condition[A.c_condition_total].field = A_card_lookup(yyvsp[0].other); A.c_condition[A.c_condition_total].type = CARD; C.conditions[C.condition_total].typeB = CARD; C.conditions[C.condition_total].fieldB = A_card_lookup(yyvsp[0].other); } A.c_condition_total++; B.c_condition_total++; /* a,b condition -- for cartesian product search */ C.conditions[C.condition_total].comparison = EQUAL; C.condition_total++; } if ((!strcmp(yyvsp[-2].text,"A")) && (!strcmp(yyvsp[0].text,"B"))) { if (!strcmp(yyvsp[0].value,"ENTRY")) { B.c_condition[B.c_condition_total].field = B_entry_lookup(yyvsp[0].other); B.c_condition[B.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeB = ENTRY; C.conditions[C.condition_total].fieldB = B_entry_lookup(yyvsp[0].other); } if (!strcmp(yyvsp[0].value,"CARD")) { B.c_condition[B.c_condition_total].field = B_card_lookup(yyvsp[0].other); B.c_condition[B.c_condition_total].type = CARD; C.conditions[C.condition_total].typeB = CARD; C.conditions[C.condition_total].fieldB = B_card_lookup(yyvsp[0].other); } if (!strcmp(yyvsp[-2].value,"ENTRY")) { A.c_condition[A.c_condition_total].field = A_entry_lookup(yyvsp[-2].other); A.c_condition[A.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeA = ENTRY; C.conditions[C.condition_total].fieldA = A_entry_lookup(yyvsp[-2].other); } if (!strcmp(yyvsp[-2].value,"CARD")) { A.c_condition[A.c_condition_total].field = A_card_lookup(yyvsp[-2].other); A.c_condition[A.c_condition_total].type = CARD; C.conditions[C.condition_total].typeA = CARD; C.conditions[C.condition_total].fieldA = A_card_lookup(yyvsp[-2].other); } A.c_condition_total++; B.c_condition_total++; /* a,b condition -- for cartesian product search */ C.conditions[C.condition_total].comparison = EQUAL; C.condition_total++; } } ; break;} case 90: #line 1824 "sdl_y.y" { /* determine condition type (a, b) or c based on what's in when_values for type (a,b), put condition on list for that set, which will be used upon close of when section to narrow down the data for the linking. For type c, put encoded condition on list for link time */ if (!do_not_execute) { /* condition for A */ if ((!strcmp(yyvsp[-2].text,"A")) && (!strcmp(yyvsp[0].text,"VALUE"))) { if (!strcmp(yyvsp[-2].value,"ENTRY")) { A.entry_condition[A.entry_condition_total].field = A_entry_lookup(yyvsp[-2].other); strcpy(A.entry_condition[A.entry_condition_total].value,yyvsp[0].value); A.entry_condition[A.entry_condition_total].comparison = NOT_EQUAL; A.entry_condition[A.entry_condition_total].type = ENTRY; A.entry_condition_total++; } if (!strcmp(yyvsp[-2].value,"CARD")) { if (!strcmp(yyvsp[-2].other,"Card")) { A.card_condition[A.card_condition_total].field = -1; } else { A.card_condition[A.card_condition_total].field = A_card_lookup(yyvsp[-2].other); } strcpy(A.card_condition[A.card_condition_total].value,yyvsp[0].value); A.card_condition[A.card_condition_total].comparison = NOT_EQUAL; A.card_condition[A.card_condition_total].type = CARD; A.card_condition_total++; } } if ((!strcmp(yyvsp[-2].text,"VALUE")) && (!strcmp(yyvsp[0].text,"A"))) { if (!strcmp(yyvsp[0].value,"ENTRY")) { A.entry_condition[A.entry_condition_total].field = A_entry_lookup(yyvsp[0].other); strcpy(A.entry_condition[A.entry_condition_total].value,yyvsp[-2].value); A.entry_condition[A.entry_condition_total].comparison = NOT_EQUAL; A.entry_condition[A.entry_condition_total].type = ENTRY; A.entry_condition_total++; } if (!strcmp(yyvsp[0].value,"CARD")) { if (!strcmp(yyvsp[0].other,"Card")) { A.card_condition[A.card_condition_total].field = -1; } else { A.card_condition[A.card_condition_total].field = A_card_lookup(yyvsp[0].other); } strcpy(A.card_condition[A.card_condition_total].value,yyvsp[-2].value); A.card_condition[A.card_condition_total].comparison = NOT_EQUAL; A.card_condition[A.card_condition_total].type = CARD; A.card_condition_total++; } } /* condition for B */ if ((!strcmp(yyvsp[-2].text,"B")) && (!strcmp(yyvsp[0].text,"VALUE"))) { if (!strcmp(yyvsp[-2].value,"ENTRY")) { B.entry_condition[B.entry_condition_total].field = B_entry_lookup(yyvsp[-2].other); strcpy(B.entry_condition[B.entry_condition_total].value,yyvsp[0].value); B.entry_condition[B.entry_condition_total].comparison = NOT_EQUAL; B.entry_condition[B.entry_condition_total].type = ENTRY; B.entry_condition_total++; } if (!strcmp(yyvsp[-2].value,"CARD")) { if (!strcmp(yyvsp[-2].other,"Card")) { B.card_condition[B.card_condition_total].field = -1; } else { B.card_condition[B.card_condition_total].field = B_card_lookup(yyvsp[-2].other); } strcpy(B.card_condition[B.card_condition_total].value,yyvsp[0].value); B.card_condition[B.card_condition_total].comparison = NOT_EQUAL; B.card_condition[B.card_condition_total].type = CARD; B.card_condition_total++; } } if ((!strcmp(yyvsp[-2].text,"VALUE")) && (!strcmp(yyvsp[0].text,"B"))) { if (!strcmp(yyvsp[0].value,"ENTRY")) { B.entry_condition[B.entry_condition_total].field = B_entry_lookup(yyvsp[0].other); strcpy(B.entry_condition[B.entry_condition_total].value,yyvsp[-2].value); B.entry_condition[B.entry_condition_total].comparison = NOT_EQUAL; B.entry_condition[B.entry_condition_total].type = ENTRY; B.entry_condition_total++; } if (!strcmp(yyvsp[0].value,"CARD")) { if (!strcmp(yyvsp[0].other,"Card")) { B.card_condition[B.card_condition_total].field = -1; } else { B.card_condition[B.card_condition_total].field = B_card_lookup(yyvsp[0].other); } strcpy(B.card_condition[B.card_condition_total].value,yyvsp[-2].value); B.card_condition[B.card_condition_total].comparison = NOT_EQUAL; B.card_condition[B.card_condition_total].type = CARD; B.card_condition_total++; } } if ((!strcmp(yyvsp[-2].text,"B")) && (!strcmp(yyvsp[0].text,"A"))) { /* a,b condition -- for sort */ if (!strcmp(yyvsp[-2].value,"ENTRY")) { B.c_condition[B.c_condition_total].field = B_entry_lookup(yyvsp[-2].other); B.c_condition[B.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeA = ENTRY; C.conditions[C.condition_total].fieldA = B_entry_lookup(yyvsp[-2].other); } if (!strcmp(yyvsp[-2].value,"CARD")) { B.c_condition[B.c_condition_total].field = B_card_lookup(yyvsp[-2].other); B.c_condition[B.c_condition_total].type = CARD; C.conditions[C.condition_total].typeA = CARD; C.conditions[C.condition_total].fieldA = B_card_lookup(yyvsp[-2].other); } if (!strcmp(yyvsp[0].value,"ENTRY")) { A.c_condition[A.c_condition_total].field = A_entry_lookup(yyvsp[0].other); A.c_condition[A.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeB = ENTRY; C.conditions[C.condition_total].fieldB = A_entry_lookup(yyvsp[0].other); } if (!strcmp(yyvsp[0].value,"CARD")) { A.c_condition[A.c_condition_total].field = A_card_lookup(yyvsp[0].other); A.c_condition[A.c_condition_total].type = CARD; C.conditions[C.condition_total].typeB = CARD; C.conditions[C.condition_total].fieldB = A_card_lookup(yyvsp[0].other); } A.c_condition_total++; B.c_condition_total++; /* a,b condition -- for cartesian product search */ C.conditions[C.condition_total].comparison = NOT_EQUAL; C.condition_total++; } if ((!strcmp(yyvsp[-2].text,"A")) && (!strcmp(yyvsp[0].text,"B"))) { if (!strcmp(yyvsp[0].value,"ENTRY")) { B.c_condition[B.c_condition_total].field = B_entry_lookup(yyvsp[0].other); B.c_condition[B.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeB = ENTRY; C.conditions[C.condition_total].fieldB = B_entry_lookup(yyvsp[0].other); } if (!strcmp(yyvsp[0].value,"CARD")) { B.c_condition[B.c_condition_total].field = B_card_lookup(yyvsp[0].other); B.c_condition[B.c_condition_total].type = CARD; C.conditions[C.condition_total].typeB = CARD; C.conditions[C.condition_total].fieldB = B_card_lookup(yyvsp[0].other); } if (!strcmp(yyvsp[-2].value,"ENTRY")) { A.c_condition[A.c_condition_total].field = A_entry_lookup(yyvsp[-2].other); A.c_condition[A.c_condition_total].type = ENTRY; C.conditions[C.condition_total].typeA = ENTRY; C.conditions[C.condition_total].fieldA = A_entry_lookup(yyvsp[-2].other); } if (!strcmp(yyvsp[-2].value,"CARD")) { A.c_condition[A.c_condition_total].field = A_card_lookup(yyvsp[-2].other); A.c_condition[A.c_condition_total].type = CARD; C.conditions[C.condition_total].typeA = CARD; C.conditions[C.condition_total].fieldA = A_card_lookup(yyvsp[-2].other); } A.c_condition_total++; B.c_condition_total++; /* a,b condition -- for cartesian product search */ C.conditions[C.condition_total].comparison = NOT_EQUAL; C.condition_total++; } } ; break;} case 91: #line 1990 "sdl_y.y" { if (!do_not_execute) { /* entry search */ /* if blank is set, search all entries */ /* if not sorted already, sort entry list for that stack by NAME */ /* make certain stack exists. mark somewhere if sorted stack has changed. */ if (!strcmp(yyvsp[-11].text,"A")) { A.entries = 1; if (A.rplnum == -1) { A.rplnum = get_rpl_number(yyvsp[-7].value); A.rplnum_exists = 1; } else { if (A.rplnum != get_rpl_number(yyvsp[-7].value)) { printf("SDL: inconsistant use of stack number for A.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } strcpy(yyval.text,"A"); strcpy(yyval.value,"ENTRY"); strcpy(yyval.other,yyvsp[-9].text); } if (!strcmp(yyvsp[-11].text,"B")) { B.entries = 1; if (B.rplnum == -1) { B.rplnum = get_rpl_number(yyvsp[-7].value); B.rplnum_exists = 1; } else { if (B.rplnum != get_rpl_number(yyvsp[-7].value)) { printf("SDL: inconsistant use of stack number for B.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } strcpy(yyval.text,"B"); strcpy(yyval.value,"ENTRY"); strcpy(yyval.other,yyvsp[-9].text); } } ; break;} case 92: #line 2031 "sdl_y.y" { if (!do_not_execute) { /* card search */ if (!strcmp(yyvsp[-8].text,"A")) { A.cards = 1; if (A.rplnum == -1) { A.rplnum = get_rpl_number(yyvsp[-4].value); A.rplnum_exists = 1; } else { if (A.rplnum != get_rpl_number(yyvsp[-4].value)) { printf("SDL: inconsistant use of stack number for A.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } strcpy(yyval.text,"A"); strcpy(yyval.value,"CARD"); strcpy(yyval.other,yyvsp[-6].text); } if (!strcmp(yyvsp[-8].text,"B")) { B.cards = 1; if (B.rplnum == -1) { B.rplnum = get_rpl_number(yyvsp[-4].value); B.rplnum_exists = 1; } else { if (B.rplnum != get_rpl_number(yyvsp[-4].value)) { printf("SDL: inconsistant use of stack number for B.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } strcpy(yyval.text,"B"); strcpy(yyval.value,"CARD"); strcpy(yyval.other,yyvsp[-6].text); } } ; break;} case 93: #line 2070 "sdl_y.y" { if (!do_not_execute) { /* stack search */ if (!strcmp(yyvsp[-5].text,"A")) { if (A.rplnum == -1) { A.rplnum = get_rpl_number(yyvsp[-1].value); A.rplnum_exists = 1; } else { if (A.rplnum != get_rpl_number(yyvsp[-1].value)) { printf("SDL: inconsistant use of stack number for A.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } strcpy(yyval.text,"A"); strcpy(yyval.value,"STACK"); strcpy(yyval.other,yyvsp[-3].text); } if (!strcmp(yyvsp[-5].text,"B")) { if (B.rplnum == -1) { B.rplnum = get_rpl_number(yyvsp[-1].value); B.rplnum_exists = 1; } else { if (B.rplnum != get_rpl_number(yyvsp[-1].value)) { printf("SDL: inconsistant use of stack number for B.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } } strcpy(yyval.text,"B"); strcpy(yyval.value,"STACK"); strcpy(yyval.other,yyvsp[-3].text); } } ; break;} case 94: #line 2106 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcpy(yyval.text,"VALUE"); } ; break;} case 95: #line 2115 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.text,""); /* clear */ } ; break;} case 99: #line 2129 "sdl_y.y" { if (!do_not_execute) { C.links[C.link_total].node = yyvsp[0].node; C.links[C.link_total].list = (int) yyvsp[-2].text[0]; C.links[C.link_total].type = yyvsp[-2].stack_int; if (!strcmp(yyvsp[-2].text,"A")) { if (yyvsp[-2].stack_int == ENTRY) { C.links[C.link_total].field = A_entry_lookup(yyvsp[-2].other); } if (yyvsp[-2].stack_int == CARD) { C.links[C.link_total].field = A_card_lookup(yyvsp[-2].other); } } if (!strcmp(yyvsp[-2].text,"B")) { if (yyvsp[-2].stack_int == ENTRY) { C.links[C.link_total].field = B_entry_lookup(yyvsp[-2].other); } if (yyvsp[-2].stack_int == CARD) { C.links[C.link_total].field = B_card_lookup(yyvsp[-2].other); } } C.link_total++; } ; break;} case 100: #line 2156 "sdl_y.y" { if (!do_not_execute) { yyval.stack_int = ENTRY; strcpy(yyval.text,yyvsp[-11].text); strcpy(yyval.other,yyvsp[-9].text); } ; break;} case 101: #line 2164 "sdl_y.y" { if (!do_not_execute) { yyval.stack_int = CARD; strcpy(yyval.text,yyvsp[-8].text); strcpy(yyval.other,yyvsp[-6].text); } ; break;} case 102: #line 2172 "sdl_y.y" { if (!do_not_execute) { yyval.stack_int = STACK; strcpy(yyval.text,yyvsp[-5].text); strcpy(yyval.other,yyvsp[-3].text); } ; break;} case 103: #line 2182 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->list = (int) yyvsp[-11].text[0]; yyval.node->type = ENTRY; if (!strcmp(yyvsp[-11].text,"A")) { yyval.node->field = A_entry_lookup(yyvsp[-9].text); } if (!strcmp(yyvsp[-11].text,"B")) { yyval.node->field = B_entry_lookup(yyvsp[-9].text); } } ; break;} case 104: #line 2196 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->list = (int) yyvsp[-8].text[0]; yyval.node->type = CARD; if (!strcmp(yyvsp[-8].text,"A")) { yyval.node->field = A_card_lookup(yyvsp[-6].text); } if (!strcmp(yyvsp[-8].text,"B")) { yyval.node->field = B_card_lookup(yyvsp[-6].text); } } ; break;} case 105: #line 2210 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->list = (int) yyvsp[-5].text[0]; yyval.node->type = STACK; yyval.node->field = global_field_index(yyvsp[-3].text); } ; break;} case 106: #line 2219 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->operator = MINUS; yyval.node->type = OPERATOR; yyval.node->left = yyvsp[-2].node; yyval.node->right = yyvsp[0].node; } ; break;} case 107: #line 2229 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->operator = PLUS; yyval.node->type = OPERATOR; yyval.node->left = yyvsp[-2].node; yyval.node->right = yyvsp[0].node; } ; break;} case 108: #line 2239 "sdl_y.y" { if (!do_not_execute) { yyval.node = yyvsp[-1].node; } ; break;} case 109: #line 2245 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->type = VALUE; strcpy(yyval.node->value,yyvsp[0].value); } ; break;} case 110: #line 2253 "sdl_y.y" { if (!do_not_execute) { yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->type = VALUE; strcpy(yyval.node->value,yyvsp[0].value); } ; break;} case 111: #line 2261 "sdl_y.y" { /* check for badly placed names */ if (!do_not_execute) { if (yyvsp[0].text[0] == '$') { printf("SDL: source reference (using $) must have index.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } if (yyvsp[0].text[0] == '_') { printf("SDL: _var should only be used on left side of '<-' .\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* user symbol */ yyval.node = (struct LinkNode *) my_malloc(sizeof(struct LinkNode)+1); yyval.node->type = VALUE; strcpy(yyval.node->value,get_local_value(yyvsp[0].text)); } ; break;} case 112: #line 2283 "sdl_y.y" { /* first one */ if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); } ; break;} case 113: #line 2290 "sdl_y.y" { /* the rest */ if (!do_not_execute) { strcpy(yyval.value,yyvsp[-2].value); strcat(yyval.value, " "); strcat(yyval.value, yyvsp[0].value); } ; break;} case 114: #line 2301 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[-2].text); } ; break;} case 115: #line 2309 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[-2].value); strcat(yyval.value, " "); strcat(yyval.value, yyvsp[0].value); } ; break;} case 116: #line 2317 "sdl_y.y" { if (!do_not_execute) { strcpy(yyval.value,yyvsp[0].value); strcat(yyval.value, " "); strcat(yyval.value, "-1"); } ; break;} } /* the action file gets copied in in place of this dollarsign */ #line 543 "/usr/lib/bison.simple" yyvsp -= yylen; yyssp -= yylen; #ifdef YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YYLSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; yyerrlab: /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; msg = (char *) malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); if (count < 5) { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; } } yyerror(msg); free(msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ yyerror("parse error"); } goto yyerrlab1; yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); #endif yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; yyerrdefault: /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) goto yydefault; #endif yyerrpop: /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YYLSP_NEEDED yylsp--; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; yyacceptlab: /* YYACCEPT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 0; yyabortlab: /* YYABORT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 1; } #line 2326 "sdl_y.y" just_for_debugging() { } unsigned char *my_malloc(size) int size; { /* unsigned char *temp; */ # ifdef SD_DEBUG3 printf("S:MM"); printf("%d\n",mem_tot++); printf("size %d\n",size); # endif if (size < 1) { printf("SD_RPL: Attempt to allocate less than one byte.\n"); printf("%d Exiting.\n",size); exit(1); } # ifdef SD_DEBUG3 printf("now\n"); if (mem_tot == 444473) { just_for_debugging(); } # endif mem_temp = (unsigned char *)calloc(1,size); # ifdef SD_DEBUG3 printf("1temp:%d\n",mem_temp); printf("\n\n\n"); # endif if (mem_temp == (unsigned char *) NULL) { printf("SDL: Out of memory. Exiting.\n"); exit(1); } # ifdef SD_DEBUG3 printf("2temp:%d\n",mem_temp); printf("\n\n\n"); # endif memset(mem_temp,0,size); # ifdef SD_DEBUG3 printf("F:MM\n"); # endif return mem_temp; } my_free(ptr) unsigned char *ptr; { if (ptr == (unsigned char *)0) { printf("SD_RPL: Attempt to free a zero ptr.\n"); printf("Exiting.\n"); exit(1); } free(ptr); } #include "sdl_l.c" int sdl_flush_lex_buffers() { YY_FLUSH_BUFFER; } /* storage < ----- | ----- > values */ page(ts1,ts2,ss) unsigned char *ts1; unsigned char *ts2; unsigned char *ss; { int i,j,k; for (k=0; ss[k]; k++) { if (isdigit(ss[k])) ts1[k] = ss[k]; else break; } ts1[k++] = '\0'; for (j=0;ss[k];j++,k++) { if (isdigit(ss[k])) ts2[j] = ss[k]; else break; } ts2[k] = '\0'; } int data_file_size(fd) FILE *fd; { /* assume newly opened fd */ int i,size; unsigned char buf[500]; data_lines = 0; size = 0; for (i=0;fgets(buf,400,fd);i++) { size += strlen(buf); data_lines++; } fseek(fd,0,0); return size; /* ... set records count in read_data. make user-accesible. */ } int card_field_index(field_name,card_type) unsigned char *field_name; unsigned char *card_type; { int c_index, f_index; if (!strcmp(field_name,"Card")) return 0; for (c_index = 0;strlen(card_types[c_index].name);c_index++) if (!strcmp(card_types[c_index].name,card_type)) break; if (!strlen(card_types[c_index].name)) { printf("SDL: Couldn't find card type %s. Line %d. Exiting.\n", card_type,file_lineno); exit(1); } for (f_index = 0;strlen(card_types[c_index].field_names[f_index]);f_index++) if (!strcmp(card_types[c_index].field_names[f_index],field_name)) break; if (!strlen(card_types[c_index].field_names[f_index])) { printf("SDL: Couldn't find field_name %s in card type %s. Line %d. Exiting.\n", field_name,card_type,file_lineno); exit(1); } return f_index; } int entry_field_index(field_name,card_type) unsigned char *field_name; unsigned char *card_type; { int c_index, f_index; for (c_index = 0;strlen(card_types[c_index].name);c_index++) if (!strcmp(card_types[c_index].name,card_type)) break; if (!strlen(card_types[c_index].name)) { printf("SDL: Couldn't find card type %s. Line %d. Exiting.\n", card_type,file_lineno); exit(1); } for (f_index = 0;strlen(card_types[c_index].list_field_names[f_index]);f_index++) if (!strcmp(card_types[c_index].list_field_names[f_index],field_name)) break; if (!strlen(card_types[c_index].list_field_names[f_index])) { printf("SDL: Couldn't find list_field_name %s in card type %s. Line %d. Exiting.\n", field_name,card_type,file_lineno); exit(1); } return f_index; } int get_rpl_number(stack_number) unsigned char *stack_number; { int index, i; index = global_field_index("StackNum"); for (i=0;ifields[index]) continue; if (!strcmp(stack_number,rpl_list[i]->fields[index])) return i; } printf("SDL: could not find requested stack number among rpls.\n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } struct Card *get_card(rpl_number,card_index) int rpl_number; int card_index; { struct Card *temp_card; temp_card = rpl_list[rpl_number]->cards[card_index]; if (!temp_card) { printf("SDL: Couldn't find CARD %d in rpl stack %d. Line %d. Exiting.\n", card_index,rpl_number,file_lineno); exit(1); } return temp_card; } struct Entry *get_entry(card,entry_index) struct Card *card; int entry_index; { struct Entry *temp_entry; temp_entry = card->entries[entry_index]; if (!temp_entry){ printf("SDL: Couldn't find entry %d given card ptr %d. Line %d. Exiting.\n", entry_index,card,file_lineno); exit(1); } return temp_entry; } extern unsigned char country[]; read_sdl() { int i; assign_stack = 0; assign_card = (struct Card *) 0; assign_entry = (struct Entry *) 0; assign_name = 0; in_new_stack = 0; in_new_card = 0; in_new_entry = 0; do_not_execute = 0; A.rplnum = -1; B.rplnum = -1; #ifdef SD_DEBUG4 printf("%5d ",1); #endif /* zero A and B */ memset(&A,0,sizeof(A)); memset(&B,0,sizeof(B)); memset(&C,0,sizeof(C)); ptl_index = 0; memset(page_total_list,0,sizeof(page_total_list)); card_book_count = 1; A.rplnum = -1; B.rplnum = -1; // sdl_debug = 1; // sdl_restart(sdl_fd); sdl_parse(); } int data_field_index(field_name) unsigned char *field_name; { int i; for (i=0; strlen(field_names[i]); i++) if (!strcmp(field_names[i],field_name)) return i; printf("Could not find field name %s. Line %d. Exiting. \n", field_name,file_lineno); exit(1); } int global_field_index(s) unsigned char *s; { int g_index; for (g_index=0;strlen(global_defs[g_index]);g_index++) if (!strcmp(global_defs[g_index],s)) return g_index; printf("SDL: could not find global %s. Line %d. Exiting.\n",s,file_lineno); exit(1); } #define SYMTABSIZE (200) struct pairs { int used; unsigned char name[50]; unsigned char value[100]; } symbol_table[SYMTABSIZE]; int symbol_table_index = 0; int user_exist(s) unsigned char *s; { int i; for (i=0; i SYMTABSIZE) { printf("\nSymbol table overflow on line %d: %s Exiting\n",file_lineno,yytext); exit(1); } } yyerror(char *s) { printf("\nSyntax error on line %d: %s Exiting\n",file_lineno,yytext); printf("(yacc message -- %s)\n",s); exit(1); } unsigned char *data_field(index,field) unsigned int index; unsigned int field; { int i,j,k; int count = 0; unsigned char buf[1000]; #if 1 if (index <= data_records) { unsigned char *m; unsigned char *s = data_ptr[index]; while (1) { if (count == field) { unsigned char *b = s; while (*s && *s != '|') { s++; } m = my_malloc(s-b+1); strncpy(m,b,s-b); m[s-b] = 0; return m; } while (*s && *s != '|') { s++; } if (!*s) { #if 0 printf("SDL: Couldn't get data. Line %d. Exiting. \n",file_lineno); exit(1); #else return (unsigned char *) strcpy(my_malloc(3),""); #endif } s++; count++; } } #else for (i=0;data_ptr[index][i];i++) { if (count == field) { for (j=i,k=0;(data_ptr[index][j] != '|') && (data_ptr[index][j]); j++,k++) { if (k>1000) { printf("SDL: copy too big. Line %d. Exiting. \n",file_lineno); exit(1); } buf[k] = data_ptr[index][j]; } buf[k] = '\0'; return (unsigned char *) strcpy(my_malloc(k+2),buf); } if (data_ptr[index][i] == '|') { count++; } } #endif #if 0 printf("SDL: Couldn't get data. Line %d. Exiting. \n",file_lineno); exit(1); #else return (unsigned char *) strcpy(my_malloc(3),""); #endif } erase_keys() { int i; for (i=0;i s2 */ return 1; } } int alpha_compare(s1,s2) unsigned char *s1; unsigned char *s2; { int result; result = strcmp(s1,s2); if (!result) return 0; if (result < 0) { /* s1 < s2 */ return 1; } else { /* s1 > s2 -- out of order */ return 2; } } unsigned char *forks[] = { (unsigned char *) "F58D", (unsigned char *) "F596", (unsigned char *) "F58C", (unsigned char *) "F595", (unsigned char *) "F58B", (unsigned char *) "F594", (unsigned char *) "F58A", (unsigned char *) "F241", (unsigned char *) "F589", (unsigned char *) "F371", (unsigned char *) "F0BF", (unsigned char *) "" }; int fork_compare(s1,s2) unsigned char *s1; unsigned char *s2; { int rank1, rank2, i; for (i=0; i< 10; i++) { if (!strcmp(s1,forks[i])) break; } rank1 = i; for (i=0; i< 10; i++) { if (!strcmp(s2,forks[i])) break; } rank2 = i; if (rank1 == rank2) return 0; if (rank1 < rank2) { /* s1 < s2 */ return 1; } else { /* s1 > s2 -- out of order */ return 2; } } unsigned char *pavs[] = { (unsigned char *) "F592", (unsigned char *) "F580", (unsigned char *) "F591", (unsigned char *) "F583", (unsigned char *) "F590", (unsigned char *) "F5A8", (unsigned char *) "F58F", (unsigned char *) "F39C", (unsigned char *) "F58E", (unsigned char *) "F38E", (unsigned char *) "F0CC", (unsigned char *) "" }; int pav_compare(s1,s2) unsigned char *s1; unsigned char *s2; { int rank1, rank2, i; for (i=0; i< 11; i++) { if (!strcmp(s1,pavs[i])) break; } rank1 = i; for (i=0; i< 11; i++) { if (!strcmp(s2,pavs[i])) break; } rank2 = i; if (rank1 == rank2) return 0; if (rank1 < rank2) { /* s1 < s2 */ return 1; } else { /* s1 > s2 -- out of order */ return 2; } } unsigned char *date[] = { (unsigned char *) "Januar/Februar", (unsigned char *) "März/April", (unsigned char *) "Mai/Juni", (unsigned char *) "Juli/August", (unsigned char *) "September/Oktober", (unsigned char *) "November/Dezember", (unsigned char *) "January", (unsigned char *) "February", (unsigned char *) "February-March", (unsigned char *) "March", (unsigned char *) "April", (unsigned char *) "May", (unsigned char *) "Spring", (unsigned char *) "June", (unsigned char *) "July", (unsigned char *) "July-August", (unsigned char *) "August", (unsigned char *) "Summer", (unsigned char *) "September", (unsigned char *) "October", (unsigned char *) "November", (unsigned char *) "Fall", (unsigned char *) "December", (unsigned char *) "Winter", (unsigned char *) "Year-Round", (unsigned char *) "Olympic Events", (unsigned char *) "Ongoing", (unsigned char *) "" }; unsigned char *fleurs[] = { (unsigned char *) "F598", (unsigned char *) "F597", (unsigned char *) "F0A6", (unsigned char *) "F0CD", (unsigned char *) "" }; int fleur_compare(s1,s2) unsigned char *s1; unsigned char *s2; { int rank1, rank2, i; for (i=0; i< 3; i++) { if (!strcmp(s1,fleurs[i])) break; } rank1 = i; for (i=0; i< 3; i++) { if (!strcmp(s2,fleurs[i])) break; } rank2 = i; if (rank1 == rank2) return 0; if (rank1 < rank2) { /* s1 < s2 */ return 1; } else { /* s1 > s2 -- out of order */ return 2; } } int qcompare(unsigned char** a,unsigned char** b) { int index1 = ((a-data_ptr)); int index2 = ((b-data_ptr)); int cr; int field_index; int rank1, rank2, i; for (i=0;i=NFORKS) { printf("whoops forks %s!\n",s1); exit(1); } rank1 = i; for (i=0; i< NFORKS; i++) { if (!strcasecmp(s2,forks[i])) break; } if (i>=NFORKS) { printf("whoops forks %s!\n",s2); exit(1); } rank2 = i; my_free(s1);my_free(s2); if (rank1 == rank2) break; if (rank1 < rank2) { /* s1 < s2 */ return -1; } else { /* s1 > s2 */ return 1; } } break; case PAV: { unsigned char *s1= data_field(index1,field_index); unsigned char *s2= data_field(index2,field_index); int rank1, rank2, i; #define NPAVS (sizeof(pavs)/sizeof(pavs[0])) for (i=0; i< NPAVS; i++) { if (!strcasecmp(s1,pavs[i])) break; } if (i>=NPAVS) { printf("whoops pavs %s!\n",s1); exit(1); } rank1 = i; for (i=0; i< NPAVS; i++) { if (!strcasecmp(s2,pavs[i])) break; } if (i>=NPAVS) { printf("whoops pavs %s!\n",s2); exit(1); } rank2 = i; my_free(s1);my_free(s2); if (rank1 == rank2) break; if (rank1 < rank2) { /* s1 < s2 */ return -1; } else { /* s1 > s2 */ return 1; } } break; case DATE: { unsigned char *s1= data_field(index1,field_index); unsigned char *s2= data_field(index2,field_index); int rank1, rank2, i; #define NDATE (sizeof(date)/sizeof(date[0])) for (i=0; i< NDATE; i++) { if (!strcasecmp(s1,date[i])) break; } if (i>=NDATE) { printf("whoops DATE %s!\n",s1); exit(1); } rank1 = i; for (i=0; i< NDATE; i++) { if (!strcasecmp(s2,date[i])) break; } if (i>=NDATE) { printf("whoops date %s!\n",s2); exit(1); } rank2 = i; my_free(s1);my_free(s2); if (rank1 == rank2) break; if (rank1 < rank2) { /* s1 < s2 */ return -1; } else { /* s1 > s2 */ return 1; } } break; case FLEUR: { unsigned char *s1= data_field(index1,field_index); unsigned char *s2= data_field(index2,field_index); int rank1, rank2, i; #define NFLEURS (sizeof(fleurs)/sizeof(fleurs[0])) for (i=0; i< NFLEURS; i++) { if (!strcasecmp(s1,fleurs[i])) break; } if (i>=NFLEURS) { printf("whoops pfleurs %s!\n",s1); exit(1); } rank1 = i; for (i=0; i< NFLEURS; i++) { if (!strcasecmp(s2,fleurs[i])) break; } if (i>=NFLEURS) { printf("whoops pfleurs %s!\n",s2); exit(1); } rank2 = i; my_free(s1);my_free(s2); if (rank1 == rank2) break; if (rank1 < rank2) { /* s1 < s2 */ return -1; } else { /* s1 > s2 */ return 1; } } break; default: printf("whoops bad key type %d\n",key_type[i]); exit(1); break; } } return 0; } sort() { qsort(data_ptr,data_records-1,sizeof(unsigned char*),(int (*)(const void *, const void *))&qcompare); } unsigned char *itoa(n,s) int n; unsigned char *s; { int i, sign; if ((sign = n) < 0) n = -n; i=0; do { s[i++] = n % 10 + '0'; } while ((n/= 10) > 0); if (sign < 0) s[i++] = '-'; s[i] = '\0'; reverse(s); return s; } reverse(s) unsigned char *s; { int c,i,j; for (i=0, j = strlen(s)-1; icard_index;a++) { for (b=0; bcards[a])) { break; } } if (b!=A.card_condition_total){ continue; } for (c=0; rpl_list[A.rplnum]->cards[a]->entries[c] && rpl_list[A.rplnum]->cards[a]->entries[c]->used; c++) { for (d=0; d cards[a]->entries[c])) break; } if (d != A.entry_condition_total) { continue; } /* All hoops jumped: we have an entry. */ A.entry_list[A.list_index] = rpl_list[A.rplnum]-> cards[a]->entries[c]; A.list_index++; if (!(A.list_index%ENTRY_PTR_BLOCK)) { int blocks, size; blocks = A.list_index/ENTRY_PTR_BLOCK; size = (blocks+1)*ENTRY_PTR_BLOCK*(sizeof(struct Entry *)); if ((A.entry_list = (struct Entry **) realloc(A.entry_list,size))==NULL) { printf("REALLOC FAILS. Exiting.\n"); exit(1); } memset(&A.entry_list[A.list_index],0,ENTRY_PTR_BLOCK*(sizeof(struct Entry *))); } } } } else { if (!A.cards) { printf("When-link error: no card or entry conditions found.\n"); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!A.rplnum_exists) { printf("When-link error: currently must provide stack number.\n"); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } /* initialize list */ A.card_list = (struct Card **) my_malloc(CARD_PTR_BLOCK*sizeof(struct Card *)); A.list_index = 0; /* find or make list of entry pointers for that stack. */ for (a=1;acard_index;a++) { for (b=0; bcards[a])) { break; } } if (b!=A.card_condition_total){ continue; } /* We have a card. */ A.card_list[A.list_index] = rpl_list[A.rplnum]->cards[a]; A.list_index++; if (!(A.list_index%CARD_PTR_BLOCK)) { int blocks, size; blocks = A.list_index/CARD_PTR_BLOCK; size = (blocks+1)*CARD_PTR_BLOCK*(sizeof(struct Card *)); if ((A.card_list = (struct Card **) realloc(A.card_list,size))==NULL) { printf("REALLOC FAILS. Exiting.\n"); exit(1); } memset(&A.card_list[A.list_index],0,CARD_PTR_BLOCK*(sizeof(struct Card *))); } } } } void create_b() { int a,b,c,d; if (B.entries) { if (!B.rplnum_exists) { printf("When-link error: currently must provide stack number.\n"); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } /* initialize list */ B.entry_list = (struct Entry **) my_malloc(ENTRY_PTR_BLOCK*sizeof(struct Entry *)); B.list_index = 0; /* find or make list of entry pointers for that stack. */ for (a=1;acard_index;a++) { for (b=0; bcards[a])) { break; } } if (b!=B.card_condition_total){ continue; } for (c=0; rpl_list[B.rplnum]->cards[a]->entries[c] && rpl_list[B.rplnum]->cards[a]->entries[c]->used; c++) { for (d=0; d cards[a]->entries[c])) break; } if (d != B.entry_condition_total) { continue; } /* All hoops jumped: we have an entry. */ B.entry_list[B.list_index] = rpl_list[B.rplnum]-> cards[a]->entries[c]; B.list_index++; if (!(B.list_index%ENTRY_PTR_BLOCK)) { int blocks, size; blocks = B.list_index/ENTRY_PTR_BLOCK; size = (blocks+1)*ENTRY_PTR_BLOCK*(sizeof(struct Entry *)); if ((B.entry_list = (struct Entry **) realloc(B.entry_list,size))==NULL) { printf("REALLOC FAILS. Exiting.\n"); exit(1); } memset(&B.entry_list[B.list_index],0,ENTRY_PTR_BLOCK*(sizeof(struct Entry *))); } } } } else { if (!B.cards) { printf("When-link error: no card or entry conditions found.\n"); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!B.rplnum_exists) { printf("When-link error: currently must provide stack number.\n"); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } /* initialize list */ B.card_list = (struct Card **) my_malloc(CARD_PTR_BLOCK*sizeof(struct Card *)); B.list_index = 0; /* find or make list of entry pointers for that stack. */ for (a=1;acard_index;a++) { for (b=0; bcards[a])) { break; } } if (b!=B.card_condition_total){ continue; } /* We have a card. */ B.card_list[B.list_index] = rpl_list[B.rplnum]->cards[a]; B.list_index++; if (!(B.list_index%CARD_PTR_BLOCK)) { int blocks, size; blocks = B.list_index/CARD_PTR_BLOCK; size = (blocks+1)*CARD_PTR_BLOCK*(sizeof(struct Card *)); if ((B.card_list = (struct Card **) realloc(B.card_list,size))==NULL) { printf("REALLOC FAILS. Exiting.\n"); exit(1); } memset(&B.card_list[B.list_index],0,CARD_PTR_BLOCK*(sizeof(struct Card *))); } } } } /* Sort these sets by ALL keys in (c) conditions. Make sure that (whether borrowing a sort or making a new one) the sorting keys are in exactly the same order for a and b: the order found. */ void sort_a() { if (A.entries) { qsort(A.entry_list,A.list_index,sizeof(struct Entry *),(int (*)(const void *, const void *))&A_entry_compare); } else { qsort(A.card_list,A.list_index,sizeof(struct Card *),(int (*)(const void *, const void *))&A_card_compare); } } void sort_b() { if (B.entries) { qsort(B.entry_list,B.list_index,sizeof(struct Entry *),(int (*)(const void *, const void *))&B_entry_compare); } else { qsort(B.card_list,B.list_index,sizeof(struct Card *),(int (*)(const void *, const void *))&B_card_compare); } } int A_entry_compare(struct Entry** entry1, struct Entry** entry2) { int a,val; for (a=0; afields[A.c_condition[a].field] ) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A entry field.\n"); printf("field number %d, card type %s\n", A.c_condition[a].field, (*entry1)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!(*entry2)->fields[A.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A entry field.\n"); printf("field number %d, card type %s\n", A.c_condition[a].field, (*entry2)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (val = strcmp((*entry1)->fields[A.c_condition[a].field], (*entry2)->fields[A.c_condition[a].field])) { return val; } continue; } if (A.c_condition[a].type == CARD) { if (!(*entry1)->card->fields[A.c_condition[a].field] ) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A Card field.\n"); printf("field number %d, card type %s\n", A.c_condition[a].field, (*entry1)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!(*entry2)->card->fields[A.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A Card field.\n"); printf("Line: %d. Exiting.\n",file_lineno); printf("field number %d, card type %s\n", A.c_condition[a].field, (*entry2)->card->name); exit(1); } if (val = strcmp((*entry1)->card->fields[A.c_condition[a].field], (*entry2)->card->fields[A.c_condition[a].field])) { return val; } } } return 0; } int A_card_compare(struct Card ** card1, struct Card** card2) { int a,val; for (a=0; afields[A.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A Card field.\n"); printf("field number %d, card type %s\n", A.c_condition[a].field, (*card1)->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!(*card2)->fields[A.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A Card field.\n"); printf("field number %d, card type %s\n", A.c_condition[a].field, (*card2)->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (val = strcmp((*card1)->fields[A.c_condition[a].field], (*card2)->fields[A.c_condition[a].field])) { return val; } } return 0; } int B_entry_compare(struct Entry** entry1, struct Entry** entry2) { int a,val; for (a=0; afields[B.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B entry field.\n"); printf("field number %d, card type %s\n", B.c_condition[a].field, (*entry1)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!(*entry2)->fields[B.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B entry field.\n"); printf("field number %d, card type %s\n", B.c_condition[a].field, (*entry2)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (val = strcmp((*entry1)->fields[B.c_condition[a].field], (*entry2)->fields[B.c_condition[a].field])) { return val; } continue; } if (B.c_condition[a].type == CARD) { if (!(*entry1)->card->fields[B.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B card field.\n"); printf("field number %d, card type %s\n", B.c_condition[a].field, (*entry1)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!(*entry2)->card->fields[B.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B card field.\n"); printf("field number %d, card type %s\n", B.c_condition[a].field, (*entry2)->card->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (val = strcmp((*entry1)->card->fields[B.c_condition[a].field], (*entry2)->card->fields[B.c_condition[a].field])) { return val; } } } return 0; } int B_card_compare(struct Card ** card1, struct Card** card2) { int a,val; for (a=0; afields[B.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B card field.\n"); printf("field number %d, card type %s\n", B.c_condition[a].field, (*card1)->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (!(*card2)->fields[B.c_condition[a].field]) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B card field.\n"); printf("field number %d, card type %s\n", B.c_condition[a].field, (*card2)->name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (val = strcmp((*card1)->fields[B.c_condition[a].field], (*card2)->fields[B.c_condition[a].field])) { return val; } } return 0; } /* after the sorting is taken care of, the search begins. It's the same loop for all cases. Simply execute the appropriate assignments with the appropriate values. Simply traverse the pre-built condition tree. */ void a_b_compare() { int i,j, k, a, b, val, skip; unsigned char *string1, *string2, *error_name; /* !!!Hopefully all the 'equals' comparisons are stored first, since they determine the range of an efficient search, whereas 'not equals' only eliminates a single found case. */ k=0; for (i=0;ifields[C.conditions[a].fieldA]; error_name = A.entry_list[i]->card->name; } else { string1 = A.entry_list[i]->card->fields[C.conditions[a].fieldA]; error_name = A.entry_list[i]->card->name; } } else { string1 = A.card_list[i]->fields[C.conditions[a].fieldA]; error_name = A.card_list[i]->name; } if (B.entries) { if (C.conditions[a].typeB == ENTRY) string2 = B.entry_list[j]->fields[C.conditions[a].fieldB]; else string2 = B.entry_list[j]->card->fields[C.conditions[a].fieldB]; error_name = B.entry_list[j]->card->name; } else { string2 = B.card_list[j]->fields[C.conditions[a].fieldB]; error_name = B.card_list[j]->name; } if (string1== NULL) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified A card field.\n"); printf("field number %d, card type %s\n", C.conditions[a].fieldA, error_name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } if (string2 == NULL) { printf("FATAL ERROR IN WHEN-LINK JOINT CLAUSE.\n"); printf("There is no data in the specified B card field.\n"); printf("field number %d, card type %s\n", C.conditions[a].fieldB, error_name); printf("Line: %d. Exiting.\n",file_lineno); exit(1); } val = strcmp(string1,string2); switch(C.conditions[a].comparison) { case EQUAL: if (!val) continue; if (val < 0) { skip = 1; k=j; j = B.list_index; } if (val > 0) { skip = 1; } break; case NOT_EQUAL: if (val) continue; if (!val) { skip = 1; } break; default: printf("BAD comparison type in when_else.\n"); printf("Line %d. Exiting. \n",file_lineno); exit(1); } } if (!skip) do_links(i,j); } } } void do_links(int a, int b) { int i; unsigned char * value; printf("\n%% Starting a link\n"); for (i=0;ifields[C.links[i].field] = (unsigned char *) strcpy(my_malloc(20),value); printf("Setting A entry field. Card_type %s , cardnum %s , field number %d , value %s\n", A.entry_list[a]->card->name, A.entry_list[a]->card->fields[0], C.links[i].field, value ); } if (C.links[i].list == 'B') { B.entry_list[b]->fields[C.links[i].field] = (unsigned char *) strcpy(my_malloc(20),value); printf("Setting B entry field. Card_type %s , cardnum %s , field number %d , value %s\n", B.entry_list[b]->card->name, B.entry_list[b]->card->fields[0], C.links[i].field, value ); } break; case CARD: if (C.links[i].list == 'A') { if (A.entries) { A.entry_list[a]->card->fields[C.links[i].field] = (unsigned char *) strcpy(my_malloc(20),value); printf("Setting A card field. Card_type %s , cardnum %s , field number %d , value %s\n", A.entry_list[a]->card->name, A.entry_list[a]->card->fields[0], C.links[i].field, value ); } else { A.card_list[a]->fields[C.links[i].field] = (unsigned char *) strcpy(my_malloc(20),value); printf("Setting A card field. Card_type %s , cardnum %s , field number %d , value %s\n", A.card_list[a]->name, A.card_list[a]->fields[0], C.links[i].field, value ); } } if (C.links[i].list == 'B') { if (B.entries) { B.entry_list[b]->card->fields[C.links[i].field] = (unsigned char *) strcpy(my_malloc(20),value); printf("Setting B card field. Card_type %s , cardnum %s , field number %d , value %s\n", B.entry_list[b]->card->name, B.entry_list[b]->card->fields[0], C.links[i].field, value ); } else { B.card_list[b]->fields[C.links[i].field] = (unsigned char *) strcpy(my_malloc(20),value); printf("Setting B card field. Card_type %s , cardnum %s , field number %d , value %s\n", B.card_list[b]->name, B.card_list[b]->fields[0], C.links[i].field, value ); } } break; case STACK: if (C.links[i].list == 'A') { strcpy(rpl_list[A.rplnum]->fields[C.links[i].field],value); printf("Stack field\n"); } if (C.links[i].list == 'B') { strcpy(rpl_list[B.rplnum]->fields[C.links[i].field],value); printf("Stack field\n"); } break; default: printf("BAD link type in when_else.\n"); printf("Line %d. Exiting. \n",file_lineno); exit(1); } #if 0 printf("\nSetting Link type:%d card %d entry %d set %c\n", C.links[i].type,a,b,C.links[i].list); #endif } printf("%% Finishing a link\n\n"); } unsigned char *link_eval( struct LinkNode * node, int a, int b) { unsigned char *left, *right; static unsigned char buf[100]; unsigned char *return_string; switch(node->type) { case OPERATOR: left = link_eval(node->left,a,b); right = link_eval(node->right,a,b); break; case ENTRY: if (node->list == 'A') { return_string = A.entry_list[a]->fields[node->field]; if (!return_string) { printf("Something's wrong in link side of when-link.\n"); printf("I was getting an entry field (double empty brackets)\n"); printf("but the field has no value\n"); printf("From the A set.\n"); printf("Card type %s, number %s , field %d. \n", A.entry_list[a]->card->name, A.entry_list[a]->card->fields[0], node->field); printf("Line %d. Exiting.\n",file_lineno); exit(0); } return return_string; } if (node->list == 'B') { return_string = B.entry_list[b]->fields[node->field]; if (!return_string) { printf("Something's wrong in link side of when-link.\n"); printf("I was getting an entry field (double empty brackets)\n"); printf("but the field has no value\n"); printf("From the B set.\n"); printf("Card type %s, number %s , field %d. \n", B.entry_list[b]->card->name, B.entry_list[b]->card->fields[0], node->field); printf("Line %d. Exiting.\n",file_lineno); exit(0); } return return_string; } printf("Bad case in Link.Line %d. Exiting.\n",file_lineno); exit(1); case CARD: if (node->list == 'A') { if (A.entries) { return_string = A.entry_list[a]->card->fields[node->field]; if (!return_string) { printf("Something's wrong in link side of when-link.\n"); printf("I was getting a card field (single empty bracket)\n"); printf("(one found through an entry-level search)"); printf("but the field has no value\n"); printf("From the A set.\n"); printf("Card type %s, number %s , field %d. \n", A.entry_list[a]->card->name, A.entry_list[a]->card->fields[0], node->field); printf("Line %d. Exiting.\n",file_lineno); exit(0); } return return_string; } else { return_string = A.card_list[a]->fields[node->field]; if (!return_string) { printf("Something's wrong in link side of when-link.\n"); printf("I was getting a card field (single empty bracket)\n"); printf("(one found through an card-level search)"); printf("but the field has no value\n"); printf("From the A set.\n"); printf("Card type %s, number %s , field %d. \n", A.card_list[a]->name, A.card_list[a]->fields[0], node->field); printf("Line %d. Exiting.\n",file_lineno); exit(0); } return return_string; } } if (node->list == 'B') { if (B.entries) { return_string = B.entry_list[b]->card->fields[node->field]; if (!return_string) { printf("Something's wrong in link side of when-link.\n"); printf("I was getting a card field (single empty bracket)\n"); printf("(one found through an entry-level search)"); printf("but the field has no value\n"); printf("From the B set.\n"); printf("Card type %s, number %s , field %d. \n", B.entry_list[b]->card->name, B.entry_list[b]->card->fields[0], node->field); printf("Line %d. Exiting.\n",file_lineno); exit(0); } return return_string; } else { return_string = B.card_list[b]->fields[node->field]; if (!return_string) { printf("Something's wrong in link side of when-link.\n"); printf("I was getting a card field (single empty bracket)\n"); printf("(one found through an card-level search)"); printf("but the field has no value\n"); printf("From the B set.\n"); printf("Card type %s, number %s , field %d. \n", B.card_list[b]->name, B.card_list[b]->fields[0], node->field); printf("Line %d. Exiting.\n",file_lineno); exit(0); } return return_string; } } printf("Bad case in Link.Line %d. Exiting.\n",file_lineno); exit(1); case STACK: if (node->list == 'A') { return_string = rpl_list[A.rplnum]->fields[node->field]; return return_string; } if (node->list == 'B') { return_string = rpl_list[B.rplnum]->fields[node->field]; return return_string; } printf("Bad case in Link.Line %d. Exiting.\n",file_lineno); exit(1); case VALUE: return node->value; default: printf("BAD comparison type in when_else.\n"); printf("Line %d. Exiting. \n",file_lineno); exit(1); } switch(node->operator) { case PLUS: return itoa(atoi(left)+atoi(right),buf); case MINUS: return itoa(atoi(left)-atoi(right),buf); default: printf("BAD operator in when_else.\n"); printf("Line %d. Exiting. \n",file_lineno); exit(1); } } int card_eval(struct Condition *condition, struct Card *card) { int val; /* equal or not equal to a field value */ if (condition->field==-1) { val = strcmp(card->name, condition->value); } else { val = strcmp(card->fields[condition->field], condition->value); } switch (condition->comparison) { case EQUAL: if (val) return 0; else return 1; case NOT_EQUAL: if (val) return 1; else return 0; default: printf("BAD comparison type in when_else.\n"); printf("Line %d. Exiting. \n",file_lineno); exit(1); } } int entry_eval(struct Condition *condition, struct Entry *entry) { /* equal or not equal to a field value */ int val; /* equal or not equal to a field value */ val = strcmp(entry->fields[condition->field], condition->value); switch (condition->comparison) { case EQUAL: if (val) return 0; else return 1; case NOT_EQUAL: if (val) return 1; else return 0; default: printf("BAD comparison type in when_else.\n"); printf("Line %d. Exiting. \n",file_lineno); exit(1); } } /* afterwards, we clean up by resetting the trees and other structures for passsing up information to this level. */ void clean_a_b() { int i; /* free lists */ if (A.entries) free(A.entry_list); else free(A.card_list); if (B.entries) free(B.entry_list); else free(B.card_list); /* Walk C links */ for (i=0;i<20;i++) { node_free(C.links[i].node); } /* zero A and B */ memset(&A,0,sizeof(A)); memset(&B,0,sizeof(B)); memset(&C,0,sizeof(C)); A.rplnum = -1; B.rplnum = -1; } node_free(struct LinkNode *node) { if (!node) return; node_free(node->left); node_free(node->right); my_free(node); } int A_card_lookup(unsigned char *field) { int i; for (i=0;ifields[0] = (unsigned char *) 0; /* create its initial entry */ entry_index = 0; current_card->entries = (struct Entry **) my_malloc(100*sizeof(struct Entry *)); current_card->entries[entry_index] = (struct Entry *) my_malloc(sizeof(struct Entry)); current_entry = current_card->entries[entry_index]; current_entry->card = current_card; entry_index++; /* add card to list of cards for this stack */ rpl_list[current_rpl]->cards[rpl_list[current_rpl]->card_index] = current_card; rpl_list[current_rpl]->card_index++; /* make that list longer if necessary */ if (!(rpl_list[current_rpl]->card_index%CARD_PTR_BLOCK)) { int blocks, size; blocks = rpl_list[current_rpl]->card_index/CARD_PTR_BLOCK; size = (blocks+1)*CARD_PTR_BLOCK*(sizeof(struct Card *)); if ((rpl_list[current_rpl]->cards = (struct Card **) realloc(rpl_list[current_rpl]->cards,size))==NULL) { printf("REALLOC FAILS. Exiting.\n"); exit(1); } memset(&rpl_list[current_rpl]->cards[rpl_list[current_rpl]->card_index], 0,CARD_PTR_BLOCK*(sizeof(struct Card *))); } # ifdef SD_DEBUG3 printf("NEW_CARD %d\n",rpl_list[current_rpl]->card_index); # endif /* increment CARDNUM */ u_card_num++; set_local_value("CARDNUM",itoa(u_card_num,buf)); /* make sure this agrees with OUR cardnum */ if (u_card_num != rpl_list[current_rpl]->card_index-1) { printf("Card numbers out of sync. Internal error. \n"); printf("Line %d. Exiting.\n",file_lineno); exit(1); } /* if in given, add to skip_list for undo. The extensible array doesn't matter. */ if (current_given) { for (i=0; ientries; skip_list[i][skip_list_index[i]++] = (unsigned char *) current_entry; } } } make_new_entry() { int i; if (current_entry) current_entry->used = 1; current_entry = (struct Entry *) my_malloc(sizeof(struct Entry)); current_card->entries[entry_index] = current_entry; current_entry->card = current_card; entry_index++; /* if in given, add to skip_list for undo */ if (current_given) { for (i=0; ientries[entry_index] = 0; if (current_given) { for (i=0; ientries[entry_index-1]; } given_undo() { int i; unsigned char buf[1000]; if (current_given) { /* the card/entries/entry triplet we'll reset to is not stored on this list */ /* undo this given */ for (i=0; ifields[0] = (unsigned char *) 0; entry_index = 0; current_card->entries = skip_entries[current_given-1]; memset(current_card->entries,0,(100*sizeof(struct Entry *))); current_card->entries[entry_index] = skip_entry[current_given-1]; memset(current_card->entries[entry_index],0,(sizeof(struct Entry))); current_entry = current_card->entries[entry_index]; current_entry->card = current_card; entry_index++; rpl_list[current_rpl]->card_index = skip_card_index[current_given-1] - 1; rpl_list[current_rpl]->cards[rpl_list[current_rpl]->card_index] = current_card; rpl_list[current_rpl]->card_index++; u_card_num = skip_card_num[current_given-1]; set_local_value("CARDNUM",itoa(u_card_num,buf)); ptl_index = 0; memset(page_total_list,0,sizeof(page_total_list)); } } clear_skip_list() { /* Reset skip index for current given */ skip_list_index[current_given-1] = 0; } set_u_page_total(stack_block *block) { int i, j, k, len, l_index; unsigned char buf[1000], field_name_list[10][50], field_value_list[10][100], *ptr; int entry_limit, entry_count, field_index, starting_point; memset(field_name_list,0,sizeof(field_name_list)); memset(field_value_list,0,sizeof(field_value_list)); entry_limit = get_entry_limit(block); max_book_entries = entry_limit; /* an entry_limit of -1 indicates that the maximum number of entries was not defined by the user. */ if (max_book_entries == -1) { set_local_value("PAGETOTAL",itoa(max_book_entries,buf)); return; } /* items on the line we get from given_list and book_list are separated by blanks */ len = strlen(block->value); l_index = 0; j=0; for (i=0; block->value[i] ; i++) { if (block->value[i] == '$') continue; if (block->value[i] == ' ') { field_name_list[l_index][j] = '\0'; j=0; l_index++; continue; } else { field_name_list[l_index][j] = block->value[i]; j++; } } field_name_list[l_index][0] = '\0'; /* clear number */ /* if in given, start at given data index. Else 0. */ if (current_given) { entry_count = 1; starting_point = given_data_index[current_given-1]; /* get initial values */ for (j=0; strlen(field_name_list[j]); j++) { field_index = data_field_index(field_name_list[j]); strcpy(field_value_list[j],(ptr=data_field( starting_point, field_index))); my_free(ptr); } for (i=starting_point; within_given_range(i,current_given-1); i++) { for (j=0; strlen(field_name_list[j]); j++) { field_index = data_field_index(field_name_list[j]); strcpy(buf,(ptr=data_field( i, field_index))); my_free(ptr); if (strcmp(field_value_list[j],buf)) { entry_count++; for (k=0; strlen(field_name_list[k]); k++) { field_index = data_field_index(field_name_list[k]); strcpy(field_value_list[k],(ptr=data_field( i, field_index))); my_free(ptr); } break; } } } u_page_total = (entry_count + (entry_limit - 1))/ entry_limit; } else { entry_count = 1; starting_point = 0; /* get initial values */ for (j=0; strlen(field_name_list[j]); j++) { field_index = data_field_index(field_name_list[j]); strcpy(field_value_list[j],(ptr=data_field( starting_point, field_index))); my_free(ptr); } for (i=starting_point; real_data(i); i++) { for (j=0; strlen(field_name_list[j]); j++) { field_index = data_field_index(field_name_list[j]); strcpy(buf,(ptr=data_field( i, field_index))); my_free(ptr); if (strcmp(field_value_list[j],buf)) { entry_count++; for (k=0; strlen(field_name_list[k]); k++) { field_index = data_field_index(field_name_list[k]); strcpy(field_value_list[k],(ptr=data_field( i, field_index))); my_free(ptr); } break; } } } u_page_total = (entry_count + (entry_limit - 1))/ entry_limit; } set_local_value("PAGETOTAL",itoa(u_page_total,buf)); } /* you have to give within_given_range every index from given_data_index[current_range-1] so that you can see it fail. */ int within_given_range(int index, int given) { int j,k,field_index; unsigned char *ptr, buf[1000]; # ifdef SD_DEBUG3 printf("S:WGR\n"); # endif if (index > data_records) { # ifdef SD_DEBUG3 printf("F:WGR\n"); # endif return 0; } for (k=given; k >= 0; k--) { for (j=0; strlen(given_field_name_list[k][j]); j++) { field_index = data_field_index(given_field_name_list[k][j]); strcpy(buf,(ptr=data_field( index, field_index))); my_free(ptr); if (strcmp(given_field_value_list[k][j],buf)) { # ifdef SD_DEBUG3 printf("F:WGR\n"); # endif return 0; } } } # ifdef SD_DEBUG3 printf("F:WGR\n"); # endif return 1; } int real_data(int index) { unsigned char *ptr1, *ptr2; ptr1 = (unsigned char *) 0; ptr2 = (unsigned char *) 0; if (!strlen(ptr1=data_field(index,0)) && !strlen(ptr2=data_field(index,1))) { my_free(ptr1); my_free(ptr2); return 0; } if (ptr1) my_free(ptr1); if (ptr2) my_free(ptr2); return 1; } int get_entry_limit(stack_block *block) { int len, i, j; unsigned char buf[1000]; len = strlen(block->value); for (i=len; block->value[i] != ' ' && i > 0; i--); for (j=0;ivalue[i]; buf[j] = '\0'; return atoi(buf); } int given_advance(stack_block *block) { int i, j, k, field_index; unsigned char *ptr, buf[1000]; starting_point = given_data_index[current_given-1]; for (i=starting_point;1; i++) { if (current_given-1 > 0) { if (!within_given_range(i,current_given-2)) return 0; } if (!real_data(i)) return 0; for (j=0; strlen(given_field_name_list[current_given-1][j]); j++) { field_index = data_field_index(given_field_name_list[current_given-1][j]); strcpy(buf,(ptr=data_field( i, field_index))); my_free(ptr); if (strcmp(given_field_value_list[current_given-1][j],buf)) { for (k=0; strlen(given_field_name_list[current_given-1][k]); k++) { field_index = data_field_index(given_field_name_list[current_given-1][k]); strcpy(given_field_value_list[current_given-1][k],(ptr=data_field( i, field_index))); my_free(ptr); } given_data_index[current_given-1] = i; return 1; } } } } void init_given_fields(stack_block *block) { int len, i, j, k, field_index, l_index; unsigned char *ptr; len = strlen(block->value); l_index = 0; j=0; for (i=0; block->value[i] ; i++) { if (block->value[i] == '$') continue; if (block->value[i] == ' ') { given_field_name_list[current_given][l_index][j] = '\0'; j=0; l_index++; continue; } else { given_field_name_list[current_given][l_index][j] = block->value[i]; j++; } } given_field_name_list[current_given][l_index][j] = '\0'; given_field_name_list[current_given][l_index+1][0] = '\0'; for (k=0; strlen(given_field_name_list[current_given][k]); k++) { field_index = data_field_index(given_field_name_list[current_given][k]); strcpy(given_field_value_list[current_given][k],(ptr=data_field( given_data_index[current_given], field_index))); my_free(ptr); } } void init_cb_fields(stack_block *block) { int len, i, j, k, field_index, l_index; unsigned char *ptr; len = strlen(block->value); l_index = 0; j=0; for (i=0; block->value[i] ; i++) { if (block->value[i] == '$') continue; if (block->value[i] == ' ') { cb_field_name_list[l_index][j] = '\0'; j=0; l_index++; continue; } else { cb_field_name_list[l_index][j] = block->value[i]; j++; } } cb_field_name_list[l_index][0] = '\0'; /* clear number */ for (k=0; strlen(cb_field_name_list[k]); k++) { field_index = data_field_index(cb_field_name_list[k]); strcpy(cb_field_value_list[k],(ptr=data_field( card_book_data_index, field_index))); my_free(ptr); } } int card_book_advance() { unsigned char buf[100000], *ptr; int field_index =0, starting_point =0; int i =0,j =0,k =0; /* if in given, start at given data index. Else 0. */ if (current_given) { starting_point = card_book_data_index; for (i=starting_point; within_given_range(i, current_given-1); i++) { for (j=0; strlen(cb_field_name_list[j]); j++) { field_index = data_field_index(cb_field_name_list[j]); strcpy(buf,(ptr=data_field( i, field_index))); my_free(ptr); if (strcmp(cb_field_value_list[j],buf)) { for (k=0; strlen(cb_field_name_list[k]); k++) { field_index = data_field_index(cb_field_name_list[k]); strcpy(cb_field_value_list[k],(ptr=data_field( i, field_index))); my_free(ptr); } card_book_data_index = i; /* Set Global User variable DATA_INDEX */ set_local_value("DATA_INDEX",itoa(card_book_data_index,buf)); return 1; } } } } else { starting_point = card_book_data_index; for (i=starting_point; real_data(i); i++) { for (j=0; strlen(cb_field_name_list[j]); j++) { field_index = data_field_index(cb_field_name_list[j]); strcpy(buf,(ptr=data_field( i, field_index))); my_free(ptr); if (strcmp(cb_field_value_list[j],buf)) { for (k=0; strlen(cb_field_name_list[k]); k++) { field_index = data_field_index(cb_field_name_list[k]); strcpy(cb_field_value_list[k],(ptr=data_field( i, field_index))); my_free(ptr); } card_book_data_index = i; /* Set Global User variable DATA_INDEX */ set_local_value("DATA_INDEX",itoa(card_book_data_index,buf)); return 1; } } } } return 0; } make_and_push_card() { pushed_current_card = current_card; pushed_current_entry = current_entry; pushed_u_entry_total = u_entry_total; pushed_entry_index = entry_index; /* do not push any rpl_list information. This is maintained independent of current_card & co. above. */ make_new_card(); } finish_and_pop_card() { unsigned char buf[100]; current_card = pushed_current_card; current_entry = pushed_current_entry; u_entry_total = pushed_u_entry_total; set_local_value("ENTRYTOTAL",itoa(u_entry_total,buf)); entry_index = pushed_entry_index; }