@@ -348,6 +348,7 @@ typedef struct {
348
348
/* Length of @lit (the @lit is not terminated). */
349
349
int lit_len ;
350
350
int prev_lit_len ;
351
+ int line ;
351
352
352
353
int err ; /* The latest error code. */
353
354
@@ -389,6 +390,8 @@ do { \
389
390
ps->c = *(++ps->pos); \
390
391
TFW_DBG3("tfsm move: '%c' -> '%c'\n", ps->prev_c, ps->c); \
391
392
FSM_JMP(to_state); \
393
+ if ( ps->prev_c == '\n'){\
394
+ ++ps->line; } \
392
395
} while (0)
393
396
394
397
#define TFSM_MOVE_EXIT (token_type ) \
@@ -609,6 +612,7 @@ parse_cfg_entry(TfwCfgParserState *ps)
609
612
TFW_DBG3 ("set name: %.*s\n" , ps -> lit_len , ps -> lit );
610
613
611
614
ps -> err = entry_set_name (& ps -> e , ps -> lit , ps -> lit_len );
615
+ ps -> e .line = ps -> line ;
612
616
FSM_COND_JMP (ps -> err , PS_EXIT );
613
617
614
618
PFSM_MOVE (PS_VAL_OR_ATTR );
@@ -1386,13 +1390,9 @@ mod_stop(TfwCfgMod *mod)
1386
1390
static void
1387
1391
print_parse_error (const TfwCfgParserState * ps )
1388
1392
{
1389
- const char * start = max ((ps -> pos - 80 ), ps -> in );
1390
- int len = ps -> pos - start ;
1391
1393
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 );
1396
1396
}
1397
1397
1398
1398
/*
0 commit comments