Print useful error message on invalid design name

This commit is contained in:
Thomas Jensen 2023-04-30 17:44:32 +02:00
parent b7e3549d15
commit 34759334f7
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
4 changed files with 39 additions and 11 deletions

View File

@ -695,7 +695,6 @@ int action_parent_config(pass_to_bison *bison_args, bxstr_t *filepath)
int action_add_design(pass_to_bison *bison_args, char *design_primary_name, char *name_at_end) int action_add_design(pass_to_bison *bison_args, char *design_primary_name, char *name_at_end)
{ {
design_t *tmp; design_t *tmp;
char *p;
#ifdef PARSER_DEBUG #ifdef PARSER_DEBUG
fprintf(stderr, "--------- ADDING DESIGN \"%s\".\n", design_primary_name); fprintf(stderr, "--------- ADDING DESIGN \"%s\".\n", design_primary_name);
@ -714,15 +713,6 @@ int action_add_design(pass_to_bison *bison_args, char *design_primary_name, char
return RC_ERROR; return RC_ERROR;
} }
p = design_primary_name;
while (*p) {
if (*p < 32 || *p > 126) { /* CHECK this check may be unnecessary due to lexer's ASCII_ID */
yyerror(bison_args, "box design name must consist of printable standard ASCII characters.");
return RC_ERROR;
}
++p;
}
bison_args->num_mandatory = 0; bison_args->num_mandatory = 0;
bison_args->time_for_se_check = 0; bison_args->time_for_se_check = 0;
bison_args->num_shapespec = 0; bison_args->num_shapespec = 0;

View File

@ -222,7 +222,14 @@ alias: ASCII_ID
alias_list: alias | alias_list ',' alias; alias_list: alias | alias_list ',' alias;
design_id: ASCII_ID | ASCII_ID ',' alias_list; design_id: ASCII_ID | ASCII_ID ',' alias_list
| WORD
{
yyerror(bison_args, "box design name must consist of printable standard ASCII characters.");
YYERROR;
}
;
design: YBOX design_id design: YBOX design_id
{ {

View File

@ -0,0 +1,20 @@
BOX käse
sample
cheese
ends
shapes {
w ("cheese")
}
elastic (
w
)
padding {
left 1
}
END käse

View File

@ -0,0 +1,11 @@
:ARGS
-f 174_non_ascii_design_name.cfg
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED-ERROR 1
boxes: 174_non_ascii_design_name.cfg: line 2: box design name must consist of printable standard ASCII characters.
boxes: 174_non_ascii_design_name.cfg: line 2: skipping to next design
boxes: no valid data in config file -- 174_non_ascii_design_name.cfg
boxes: no valid designs found
:EOF