Fix .asciz <expr>... where an overzealous parsing wants to parse too much of the remaining text

In particular, the example was
	.asciz <cr><lf>/<SOH>/
where it tried to make a division betweem <lf> and the delimited
string /<SOH>/.
This commit is contained in:
Olaf Seibert 2015-05-10 17:32:44 +02:00
parent 2c091595e9
commit fcc85aa5f5
3 changed files with 27 additions and 1 deletions

View File

@ -1077,7 +1077,7 @@ static int assemble(
cp = skipwhite(cp);
if (*cp == '<' || *cp == '^') {
/* A byte value */
value = parse_expr(cp, 0);
value = parse_unary_expr(cp, 0);
cp = value->cp;
store_value(stack, tr, 1, value);
free_tree(value);

23
parse.c
View File

@ -863,3 +863,26 @@ EX_TREE *parse_expr(
return value;
}
/*
parse_unary_expr It parses and evaluates
an arithmetic expression but only a unary: (op)value or <expr>.
In particular, it doesn't try to divide in <lf>/SOH/.
*/
EX_TREE *parse_unary_expr(
char *cp,
int undef)
{
EX_TREE *expr;
EX_TREE *value;
expr = parse_unary(cp); /* Parse into a tree */
value = evaluate(expr, undef); /* Perform the arithmetic */
value->cp = expr->cp; /* Pointer to end of text is part of
the rootmost node */
free_tree(expr); /* Discard parse in favor of
evaluation */
return value;
}

View File

@ -35,6 +35,9 @@ int get_mode(
EX_TREE *parse_expr(
char *cp,
int undef);
EX_TREE *parse_unary_expr(
char *cp,
int undef);
int parse_float(
char *cp,
char **endp,