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
29#include <sys/cdefs.h>
30
31__FBSDID("$FreeBSD: head/usr.bin/colldef/parse.y 87243 2001-12-02 23:40:46Z markm $");
32
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;
44void yyerror(const char *fmt, ...) __printflike(1, 2);
45int yyparse(void);
46int yylex(void);
47static void usage(void);
48static void collate_print_tables(void);
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
63const char *out_file = "LC_COLLATE";
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;
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
285void
286yyerror(const char *fmt, ...)
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
298static void
299collate_print_tables(void)
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