fix English

detect recursive substitutions
allow substituted character not present in the order
This commit is contained in:
Andrey A. Chernov 1999-02-12 20:39:06 +00:00
parent f8ee1a074a
commit 366b60bfed
2 changed files with 26 additions and 19 deletions
usr.bin/colldef

View File

@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: parse.y,v 1.10 1997/06/30 11:24:18 charnier Exp $
* $Id: parse.y,v 1.11 1998/12/06 22:58:17 archie Exp $
*/
#include <err.h>
@ -84,7 +84,11 @@ charmap : DEFN CHAR {
}
;
substitute : SUBSTITUTE STRING WITH STRING {
strcpy(__collate_substitute_table[$2[0]], $4);
u_char ch = $2[0];
if (strchr($4, ch) != NULL)
yyerror("Char 0x%02x substitution is recursive", ch);
strcpy(__collate_substitute_table[ch], $4);
}
;
order : ORDER order_list {
@ -92,8 +96,11 @@ order : ORDER order_list {
int ch;
for (ch = 0; ch < UCHAR_MAX + 1; ch++)
if (!__collate_char_pri_table[ch].prim)
yyerror("Char 0x%02x not present", ch);
if ( !__collate_char_pri_table[ch].prim
&& __collate_substitute_table[ch][0] == ch
&& __collate_substitute_table[ch][1] == '\0'
)
yyerror("Char 0x%02x not found", ch);
fp = fopen(out_file, "w");
if(!fp)

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: scan.l,v 1.7 1997/02/22 19:54:32 peter Exp $
*/
#include <ctype.h>
@ -101,7 +101,7 @@ YYSTYPE yylval;
return CHAR;
}
if(yyleng > STR_LEN - 1)
errx(EX_UNAVAILABLE, "chain buffer overflaw near line %u",
errx(EX_UNAVAILABLE, "chain buffer overflow near line %u",
line_no);
strcpy(yylval.str, yytext);
return CHAIN;
@ -121,19 +121,19 @@ YYSTYPE yylval;
}
<name>\/\/ {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "name buffer overflaw near line %u, character '/'",
errx(EX_UNAVAILABLE, "name buffer overflow near line %u, character '/'",
line_no);
*ptr++ = '/';
}
<name>\/\> {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "name buffer overflaw near line %u, character '>'",
errx(EX_UNAVAILABLE, "name buffer overflow near line %u, character '>'",
line_no);
*ptr++ = '>';
}
<string>\\\" {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\"'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\"'",
line_no);
*ptr++ = '"';
}
@ -167,49 +167,49 @@ YYSTYPE yylval;
errx(EX_UNAVAILABLE, "non-ASCII or non-printable character 0x%02x not allowed in the map/name near line %u of %s",
*yytext, line_no, s);
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "map/name buffer overflaw near line %u of %s, character '%c'",
errx(EX_UNAVAILABLE, "map/name buffer overflow near line %u of %s, character '%c'",
line_no, s, *yytext);
*ptr++ = *yytext;
}
<string>\\t {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\t'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\t'",
line_no);
*ptr++ = '\t';
}
<string>\\b {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\b'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\b'",
line_no);
*ptr++ = '\b';
}
<string>\\f {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\f'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\f'",
line_no);
*ptr++ = '\f';
}
<string>\\v {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\v'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\v'",
line_no);
*ptr++ = '\v';
}
<string>\\n {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\n'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\n'",
line_no);
*ptr++ = '\n';
}
<string>\\r {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\r'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\r'",
line_no);
*ptr++ = '\r';
}
<string>\\a {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\a'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\a'",
line_no);
*ptr++ = '\a';
}
@ -237,13 +237,13 @@ YYSTYPE yylval;
}
<string>\\. {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '%c'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '%c'",
line_no, yytext[1]);
*ptr++ = yytext[1];
}
<string>. {
if(ptr >= buf + sizeof(buf) - 1)
errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '%c'",
errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '%c'",
line_no, *yytext);
*ptr++ = *yytext;
}