Deleted Added
sdiff udiff text old ( 87052 ) new ( 87243 )
full compact
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
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;
42void yyerror(char *fmt, ...) __printflike(1, 2);
43int yyparse(void);
44int yylex(void);
45static void usage __P((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
60char *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)
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
281void yyerror(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
293void
294collate_print_tables()
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