Allow chains in any form like <name1><name2> or \xf1\xf2, not binary
representation only.
This commit is contained in:
parent
31582c4e81
commit
79458607f6
@ -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
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user