parse.y (87052) | parse.y (87243) |
---|---|
1%{ 2/*- 3 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua> 4 * at Electronni Visti IA, Kiev, Ukraine. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 10 unchanged lines hidden (view full) --- 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. | 1%{ 2/*- 3 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua> 4 * at Electronni Visti IA, Kiev, Ukraine. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 10 unchanged lines hidden (view full) --- 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. |
27 * 28 * $FreeBSD: head/usr.bin/colldef/parse.y 87052 2001-11-28 09:50:24Z ache $ | |
29 */ 30 | 27 */ 28 |
29#include <sys/cdefs.h> 30 31__FBSDID("$FreeBSD: head/usr.bin/colldef/parse.y 87243 2001-12-02 23:40:46Z markm $"); 32 |
|
31#include <err.h> 32#include <stdarg.h> 33#include <stdio.h> 34#include <string.h> 35#include <stdlib.h> 36#include <unistd.h> 37#include <sysexits.h> 38#include "collate.h" 39#include "common.h" 40 41extern FILE *yyin; | 33#include <err.h> 34#include <stdarg.h> 35#include <stdio.h> 36#include <string.h> 37#include <stdlib.h> 38#include <unistd.h> 39#include <sysexits.h> 40#include "collate.h" 41#include "common.h" 42 43extern FILE *yyin; |
42void yyerror(char *fmt, ...) __printflike(1, 2); | 44void yyerror(const char *fmt, ...) __printflike(1, 2); |
43int yyparse(void); 44int yylex(void); | 45int yyparse(void); 46int yylex(void); |
45static void usage __P((void)); | 47static void usage(void); 48static void collate_print_tables(void); |
46 47char map_name[FILENAME_MAX] = "."; 48 49char __collate_version[STR_LEN]; 50u_char charmap_table[UCHAR_MAX + 1][CHARMAP_SYMBOL_LEN]; 51u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; 52struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; 53struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; 54int chain_index; 55int prim_pri = 1, sec_pri = 1; 56#ifdef COLLATE_DEBUG 57int debug; 58#endif 59 | 49 50char map_name[FILENAME_MAX] = "."; 51 52char __collate_version[STR_LEN]; 53u_char charmap_table[UCHAR_MAX + 1][CHARMAP_SYMBOL_LEN]; 54u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; 55struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; 56struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; 57int chain_index; 58int prim_pri = 1, sec_pri = 1; 59#ifdef COLLATE_DEBUG 60int debug; 61#endif 62 |
60char *out_file = "LC_COLLATE"; | 63const char *out_file = "LC_COLLATE"; |
61%} 62%union { 63 u_char ch; 64 u_char str[BUFSIZE]; 65} 66%token SUBSTITUTE WITH ORDER RANGE 67%token <str> STRING 68%token <str> CHAIN --- 157 unchanged lines hidden (view full) --- 226 strcpy(__collate_chain_pri_table[chain_index].str, $1); 227 __collate_chain_pri_table[chain_index].prim = prim_pri; 228 __collate_chain_pri_table[chain_index++].sec = sec_pri++; 229} 230; 231%% 232int 233main(ac, av) | 64%} 65%union { 66 u_char ch; 67 u_char str[BUFSIZE]; 68} 69%token SUBSTITUTE WITH ORDER RANGE 70%token <str> STRING 71%token <str> CHAIN --- 157 unchanged lines hidden (view full) --- 229 strcpy(__collate_chain_pri_table[chain_index].str, $1); 230 __collate_chain_pri_table[chain_index].prim = prim_pri; 231 __collate_chain_pri_table[chain_index++].sec = sec_pri++; 232} 233; 234%% 235int 236main(ac, av) |
237 int ac; |
|
234 char **av; 235{ 236 int ch; 237 238#ifdef COLLATE_DEBUG 239 while((ch = getopt(ac, av, ":do:I:")) != EOF) { 240#else 241 while((ch = getopt(ac, av, ":o:I:")) != EOF) { --- 31 unchanged lines hidden (view full) --- 273 274static void 275usage() 276{ 277 fprintf(stderr, "usage: colldef [-o out_file] [-I map_dir] [filename]\n"); 278 exit(EX_USAGE); 279} 280 | 238 char **av; 239{ 240 int ch; 241 242#ifdef COLLATE_DEBUG 243 while((ch = getopt(ac, av, ":do:I:")) != EOF) { 244#else 245 while((ch = getopt(ac, av, ":o:I:")) != EOF) { --- 31 unchanged lines hidden (view full) --- 277 278static void 279usage() 280{ 281 fprintf(stderr, "usage: colldef [-o out_file] [-I map_dir] [filename]\n"); 282 exit(EX_USAGE); 283} 284 |
281void yyerror(char *fmt, ...) | 285void 286yyerror(const char *fmt, ...) |
282{ 283 va_list ap; 284 char msg[128]; 285 286 va_start(ap, fmt); 287 vsnprintf(msg, sizeof(msg), fmt, ap); 288 va_end(ap); 289 errx(EX_UNAVAILABLE, "%s near line %d", msg, line_no); 290} 291 292#ifdef COLLATE_DEBUG | 287{ 288 va_list ap; 289 char msg[128]; 290 291 va_start(ap, fmt); 292 vsnprintf(msg, sizeof(msg), fmt, ap); 293 va_end(ap); 294 errx(EX_UNAVAILABLE, "%s near line %d", msg, line_no); 295} 296 297#ifdef COLLATE_DEBUG |
293void 294collate_print_tables() | 298static void 299collate_print_tables(void) |
295{ 296 int i; 297 struct __collate_st_chain_pri *p2; 298 299 printf("Substitute table:\n"); 300 for (i = 0; i < UCHAR_MAX + 1; i++) 301 if (i != *__collate_substitute_table[i]) 302 printf("\t'%c' --> \"%s\"\n", i, 303 __collate_substitute_table[i]); 304 printf("Chain priority table:\n"); 305 for (p2 = __collate_chain_pri_table; p2->str[0]; p2++) 306 printf("\t\"%s\" : %d %d\n\n", p2->str, p2->prim, p2->sec); 307 printf("Char priority table:\n"); 308 for (i = 0; i < UCHAR_MAX + 1; i++) 309 printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim, 310 __collate_char_pri_table[i].sec); 311} 312#endif | 300{ 301 int i; 302 struct __collate_st_chain_pri *p2; 303 304 printf("Substitute table:\n"); 305 for (i = 0; i < UCHAR_MAX + 1; i++) 306 if (i != *__collate_substitute_table[i]) 307 printf("\t'%c' --> \"%s\"\n", i, 308 __collate_substitute_table[i]); 309 printf("Chain priority table:\n"); 310 for (p2 = __collate_chain_pri_table; p2->str[0]; p2++) 311 printf("\t\"%s\" : %d %d\n\n", p2->str, p2->prim, p2->sec); 312 printf("Char priority table:\n"); 313 for (i = 0; i < UCHAR_MAX + 1; i++) 314 printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim, 315 __collate_char_pri_table[i].sec); 316} 317#endif |