mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Properly fix printing of ^-- here in error diagnosis.
All checks were successful
Remind unit tests / tests (push) Successful in 1m36s
All checks were successful
Remind unit tests / tests (push) Successful in 1m36s
This commit is contained in:
54
src/expr.c
54
src/expr.c
@@ -199,6 +199,46 @@ static UserFunc *CurrentUserFunc = NULL;
|
|||||||
/* How many expr_node objects to allocate at a time */
|
/* How many expr_node objects to allocate at a time */
|
||||||
#define ALLOC_CHUNK 64
|
#define ALLOC_CHUNK 64
|
||||||
|
|
||||||
|
static char const *
|
||||||
|
find_end_of_expr(char const *s)
|
||||||
|
{
|
||||||
|
char const *e = s;
|
||||||
|
int in_quoted_string = 0;
|
||||||
|
int escaped = 0;
|
||||||
|
|
||||||
|
while(*e) {
|
||||||
|
if (in_quoted_string) {
|
||||||
|
if (escaped) {
|
||||||
|
escaped = 0;
|
||||||
|
e++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*e == '\\') {
|
||||||
|
escaped = 1;
|
||||||
|
e++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*e == '"') {
|
||||||
|
in_quoted_string = 0;
|
||||||
|
e++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
e++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*e == '"') {
|
||||||
|
in_quoted_string = 1;
|
||||||
|
e++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*e == ']') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
e++;
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* alloc_expr_node - allocate an expr_node object */
|
/* alloc_expr_node - allocate an expr_node object */
|
||||||
@@ -2501,6 +2541,7 @@ expr_node *parse_expression(char const **e, int *r, Var *locals)
|
|||||||
{
|
{
|
||||||
char const *orig = *e;
|
char const *orig = *e;
|
||||||
char const *o2 = *e;
|
char const *o2 = *e;
|
||||||
|
char const *end_of_expr;
|
||||||
if (ExpressionEvaluationDisabled) {
|
if (ExpressionEvaluationDisabled) {
|
||||||
*r = E_EXPR_DISABLED;
|
*r = E_EXPR_DISABLED;
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -2536,16 +2577,17 @@ expr_node *parse_expression(char const **e, int *r, Var *locals)
|
|||||||
*r == E_BAD_DATE ||
|
*r == E_BAD_DATE ||
|
||||||
*r == E_BAD_TIME ||
|
*r == E_BAD_TIME ||
|
||||||
*r == E_ILLEGAL_CHAR) {
|
*r == E_ILLEGAL_CHAR) {
|
||||||
orig = o2;
|
end_of_expr = find_end_of_expr(orig);
|
||||||
while (*orig) {
|
while (**e && isempty(**e)) {
|
||||||
|
(*e)++;
|
||||||
|
}
|
||||||
|
while (*orig && ((orig < end_of_expr) || (orig <= *e))) {
|
||||||
if (*orig == '\n') {
|
if (*orig == '\n') {
|
||||||
fprintf(ErrFp, " ");
|
fprintf(ErrFp, " ");
|
||||||
orig++;
|
|
||||||
} else if (*orig == ']' && ! *(orig+1)) {
|
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(ErrFp, "%c", *orig++);
|
fprintf(ErrFp, "%c", *orig);
|
||||||
}
|
}
|
||||||
|
orig++;
|
||||||
}
|
}
|
||||||
fprintf(ErrFp, "\n");
|
fprintf(ErrFp, "\n");
|
||||||
orig = o2;
|
orig = o2;
|
||||||
|
|||||||
@@ -633,6 +633,14 @@ fi
|
|||||||
# Torture test #2
|
# Torture test #2
|
||||||
../src/remind ../tests/torture2.rem >> ../tests/test.out 2>&1
|
../src/remind ../tests/torture2.rem >> ../tests/test.out 2>&1
|
||||||
|
|
||||||
|
# Expression error-reporting
|
||||||
|
../src/remind -de - 1 Feb 2024 <<'EOF' >> ../tests/test.out 2>&1
|
||||||
|
set a 8 * "]]]" & 6
|
||||||
|
msg [8 * "]]]" & 6] is weird
|
||||||
|
set a 9 *
|
||||||
|
set a 9 * ]
|
||||||
|
EOF
|
||||||
|
|
||||||
# Languages
|
# Languages
|
||||||
for i in ../include/lang/??.rem ; do
|
for i in ../include/lang/??.rem ; do
|
||||||
../src/remind -r -q "-ii=\"$i\"" ../tests/tstlang.rem 1 Feb 2024 13:34 >> ../tests/test.out 2>&1
|
../src/remind -r -q "-ii=\"$i\"" ../tests/tstlang.rem 1 Feb 2024 13:34 >> ../tests/test.out 2>&1
|
||||||
|
|||||||
@@ -23410,7 +23410,7 @@ max(6, 9, 50) => 50
|
|||||||
Parsed expression: max(1,
|
Parsed expression: max(1,
|
||||||
=> Error: Illegal character
|
=> Error: Illegal character
|
||||||
Unparsed: ,1)
|
Unparsed: ,1)
|
||||||
max(1,,1)
|
,1)
|
||||||
^-- here
|
^-- here
|
||||||
Parsed expression: 5%0
|
Parsed expression: 5%0
|
||||||
=> (% 5 0)
|
=> (% 5 0)
|
||||||
@@ -24312,6 +24312,26 @@ Translation hash table statistics:
|
|||||||
Expression nodes high-water: 300000
|
Expression nodes high-water: 300000
|
||||||
Expression nodes leaked: 0
|
Expression nodes leaked: 0
|
||||||
Parse level high-water: 7
|
Parse level high-water: 7
|
||||||
|
set a 8 * "]]]" & 6
|
||||||
|
-stdin-(1): Parse error `&' (did you mean `&&'?)
|
||||||
|
8 * "]]]" & 6
|
||||||
|
^-- here
|
||||||
|
msg [8 * "]]]" & 6] is weird
|
||||||
|
-stdin-(2): Parse error `&' (did you mean `&&'?)
|
||||||
|
8 * "]]]" & 6
|
||||||
|
^-- here
|
||||||
|
set a 9 *
|
||||||
|
-stdin-(3): Unexpected end of line
|
||||||
|
9 *
|
||||||
|
^-- here
|
||||||
|
set a 9 * ]
|
||||||
|
-stdin-(4): Illegal character `]'
|
||||||
|
9 * ]
|
||||||
|
^-- here
|
||||||
|
|
||||||
|
Reminders for Thursday, 1st February, 2024:
|
||||||
|
|
||||||
|
No reminders.
|
||||||
Agenda pel dijous, 1 de febrer de 2024:
|
Agenda pel dijous, 1 de febrer de 2024:
|
||||||
|
|
||||||
Language: ca
|
Language: ca
|
||||||
|
|||||||
Reference in New Issue
Block a user