Skip to content

Commit ed366ef

Browse files
author
Sergey Lvov
committed
fix #65
1 parent 744fb08 commit ed366ef

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tempesta_fw/cfg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ typedef struct {
348348
/* Length of @lit (the @lit is not terminated). */
349349
int lit_len;
350350
int prev_lit_len;
351+
int line;
351352

352353
int err; /* The latest error code. */
353354

@@ -389,6 +390,8 @@ do { \
389390
ps->c = *(++ps->pos); \
390391
TFW_DBG3("tfsm move: '%c' -> '%c'\n", ps->prev_c, ps->c); \
391392
FSM_JMP(to_state); \
393+
if ( ps->prev_c == '\n'){\
394+
++ps->line; } \
392395
} while (0)
393396

394397
#define TFSM_MOVE_EXIT(token_type) \
@@ -609,6 +612,7 @@ parse_cfg_entry(TfwCfgParserState *ps)
609612
TFW_DBG3("set name: %.*s\n", ps->lit_len, ps->lit);
610613

611614
ps->err = entry_set_name(&ps->e, ps->lit, ps->lit_len);
615+
ps->e.line = ps->line;
612616
FSM_COND_JMP(ps->err, PS_EXIT);
613617

614618
PFSM_MOVE(PS_VAL_OR_ATTR);
@@ -1386,13 +1390,9 @@ mod_stop(TfwCfgMod *mod)
13861390
static void
13871391
print_parse_error(const TfwCfgParserState *ps)
13881392
{
1389-
const char *start = max((ps->pos - 80), ps->in);
1390-
int len = ps->pos - start;
13911393

1392-
TFW_ERR("configuration parsing error:\n"
1393-
"%.*s\n"
1394-
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
1395-
len, start);
1394+
TFW_ERR("configuration parsing error: str:%d;w:%s\n", ps->e.line + 1,
1395+
ps->e.name);
13961396
}
13971397

13981398
/*

tempesta_fw/cfg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ typedef struct {
9393
bool have_children;
9494
size_t val_n;
9595
size_t attr_n;
96+
int line; /* The current line */
9697
const char *name;
9798
const char *vals[TFW_CFG_ENTRY_VAL_MAX];
9899
struct {

0 commit comments

Comments
 (0)