summaryrefslogtreecommitdiffstats
path: root/usr.bin/colldef
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2002-08-23 04:18:26 +0000
committerache <ache@FreeBSD.org>2002-08-23 04:18:26 +0000
commite528806f994ecb3c23bf174011c94e71abaf5073 (patch)
tree2cda2e38523c261703b020223df90f38fef297dc /usr.bin/colldef
parente1124db23a589e1d1236be6a72665e1315adacbd (diff)
downloadFreeBSD-src-e528806f994ecb3c23bf174011c94e71abaf5073.zip
FreeBSD-src-e528806f994ecb3c23bf174011c94e71abaf5073.tar.gz
Allow chains in any form like <name1><name2> or \xf1\xf2, not binary
representation only.
Diffstat (limited to 'usr.bin/colldef')
-rw-r--r--usr.bin/colldef/colldef.116
-rw-r--r--usr.bin/colldef/parse.y38
-rw-r--r--usr.bin/colldef/scan.l20
3 files changed, 37 insertions, 37 deletions
diff --git a/usr.bin/colldef/colldef.1 b/usr.bin/colldef/colldef.1
index 47a7584..8136b4f 100644
--- a/usr.bin/colldef/colldef.1
+++ b/usr.bin/colldef/colldef.1
@@ -175,15 +175,12 @@ The symbol itself (for example,
for the lower-case letter
.Ar a )
.It
-The symbol chain (for example,
-.Ar abc )
-.It
-In octal representation (for example,
+The symbol in octal representation (for example,
.Ar \e141
for the letter
.Ar a )
.It
-In hexadecimal representation (for example,
+The symbol in hexadecimal representation (for example,
.Ar \ex61
for the letter
.Ar a )
@@ -191,9 +188,9 @@ for the letter
The symbol name as defined in the
.Ar charmap
file (for example,
-.Ar <abc>
+.Ar <letterA>
for
-.Ar abc \e023
+.Ar letterA \e023
record in
.Ar charmapfile ) .
If character map name have
@@ -214,6 +211,11 @@ Symbols
.Ar \ev
are permitted in its usual C-language meaning
.It
+The symbol chain (for example:
+.Ar abc ,
+.Ar <letterA><letterB> ,
+.Ar \exf1\exf2 )
+.It
The symbol range (for example,
.Ar a;...;z )
.It
diff --git a/usr.bin/colldef/parse.y b/usr.bin/colldef/parse.y
index d3abb18..3d5f7bc 100644
--- a/usr.bin/colldef/parse.y
+++ b/usr.bin/colldef/parse.y
@@ -47,6 +47,7 @@ static void usage(void);
static void collate_print_tables(void);
char map_name[FILENAME_MAX] = ".";
+char curr_chain[STR_LEN];
char __collate_version[STR_LEN];
u_char charmap_table[UCHAR_MAX + 1][CHARMAP_SYMBOL_LEN];
@@ -72,7 +73,6 @@ const char *out_file = "LC_COLLATE";
}
%token SUBSTITUTE WITH ORDER RANGE
%token <str> STRING
-%token <str> CHAIN
%token <str> DEFN
%token <ch> CHAR
%%
@@ -139,17 +139,33 @@ order : ORDER order_list {
order_list : item
| order_list ';' item
;
+chain : CHAR CHAR {
+ curr_chain[0] = $1;
+ curr_chain[1] = $2;
+ if (curr_chain[0] == '\0' || curr_chain[1] == '\0')
+ yyerror("\\0 can't be chained");
+ curr_chain[2] = '\0';
+}
+ | chain CHAR {
+ static char tb[2];
+
+ tb[0] = $2;
+ if (tb[0] == '\0')
+ yyerror("\\0 can't be chained");
+ if (strlen(curr_chain) + 2 > STR_LEN)
+ yyerror("Chain '%s' grows too long", curr_chain);
+ (void)strcat(curr_chain, tb);
+}
+;
item : CHAR {
if (__collate_char_pri_table[$1].prim)
yyerror("Char 0x%02x duplicated", $1);
__collate_char_pri_table[$1].prim = prim_pri++;
}
- | CHAIN {
+ | chain {
if (chain_index >= TABLE_SIZE - 1)
yyerror("__collate_chain_pri_table overflow");
- if (strlen($1) + 1 > STR_LEN)
- yyerror("Chain %d is too long", chain_index);
- strcpy(__collate_chain_pri_table[chain_index].str, $1);
+ (void)strcpy(__collate_chain_pri_table[chain_index].str, curr_chain);
__collate_chain_pri_table[chain_index++].prim = prim_pri++;
}
| CHAR RANGE CHAR {
@@ -196,12 +212,10 @@ prim_sub_item : CHAR {
__collate_char_pri_table[(u_char)i].prim = prim_pri;
}
}
- | CHAIN {
+ | chain {
if (chain_index >= TABLE_SIZE - 1)
yyerror("__collate_chain_pri_table overflow");
- if (strlen($1) + 1 > STR_LEN)
- yyerror("Chain %d is too long", chain_index);
- strcpy(__collate_chain_pri_table[chain_index].str, $1);
+ (void)strcpy(__collate_chain_pri_table[chain_index].str, curr_chain);
__collate_chain_pri_table[chain_index++].prim = prim_pri;
}
;
@@ -225,12 +239,10 @@ sec_sub_item : CHAR {
__collate_char_pri_table[(u_char)i].sec = sec_pri++;
}
}
- | CHAIN {
+ | chain {
if (chain_index >= TABLE_SIZE - 1)
yyerror("__collate_chain_pri_table overflow");
- if (strlen($1) + 1 > STR_LEN)
- yyerror("Chain %d is too long", chain_index);
- strcpy(__collate_chain_pri_table[chain_index].str, $1);
+ (void)strcpy(__collate_chain_pri_table[chain_index].str, curr_chain);
__collate_chain_pri_table[chain_index].prim = prim_pri;
__collate_chain_pri_table[chain_index++].sec = sec_pri++;
}
diff --git a/usr.bin/colldef/scan.l b/usr.bin/colldef/scan.l
index 10b17c8..aeeff14 100644
--- a/usr.bin/colldef/scan.l
+++ b/usr.bin/colldef/scan.l
@@ -63,7 +63,6 @@ int yylex(void);
<INITIAL,nchar,subs>\\v { yylval.ch = '\v'; return CHAR; }
<INITIAL,nchar,subs>\\r { yylval.ch = '\r'; return CHAR; }
<INITIAL,nchar,subs>\\a { yylval.ch = '\a'; return CHAR; }
-<INITIAL,nchar,subs>\\. { yylval.ch = yytext[1]; return CHAR; }
<subs2>\n {
line_no++;
BEGIN(INITIAL);
@@ -90,28 +89,15 @@ int yylex(void);
yylval.ch = (u_char)v;
return CHAR;
}
-<INITIAL,nchar,subs>\\x[0-9a-z]{2} {
+<INITIAL,nchar,subs>\\x[0-9a-fA-F]{2} {
u_int v;
sscanf(&yytext[2], "%x", &v);
yylval.ch = (u_char)v;
return CHAR;
}
-<INITIAL>[^;,{}() \t\n"<]+ {
- if(yyleng == 1) {
- yylval.ch = *yytext;
- return CHAR;
- }
- if(yyleng > BUFSIZE - 1)
- errx(EX_UNAVAILABLE, "chain buffer overflow near line %u",
- line_no);
- strcpy(yylval.str, yytext);
- return CHAIN;
-}
-<nchar,subs>. {
- yylval.ch = *yytext;
- return CHAR;
-}
+<INITIAL,nchar,subs>\\. { yylval.ch = yytext[1]; return CHAR; }
+<INITIAL,nchar,subs>. { yylval.ch = *yytext; return CHAR; }
<defn>^#.*\n line_no++;
<defn>[ \t]+ {
if (ptr == buf)
OpenPOWER on IntegriCloud