Skip to content

Commit

Permalink
fix #65
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Lvov committed May 30, 2016
1 parent 744fb08 commit ed366ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tempesta_fw/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ typedef struct {
/* Length of @lit (the @lit is not terminated). */
int lit_len;
int prev_lit_len;
int line;

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

Expand Down Expand Up @@ -389,6 +390,8 @@ do { \
ps->c = *(++ps->pos); \
TFW_DBG3("tfsm move: '%c' -> '%c'\n", ps->prev_c, ps->c); \
FSM_JMP(to_state); \
if ( ps->prev_c == '\n'){\
++ps->line; } \
} while (0)

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

ps->err = entry_set_name(&ps->e, ps->lit, ps->lit_len);
ps->e.line = ps->line;
FSM_COND_JMP(ps->err, PS_EXIT);

PFSM_MOVE(PS_VAL_OR_ATTR);
Expand Down Expand Up @@ -1386,13 +1390,9 @@ mod_stop(TfwCfgMod *mod)
static void
print_parse_error(const TfwCfgParserState *ps)
{
const char *start = max((ps->pos - 80), ps->in);
int len = ps->pos - start;

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

/*
Expand Down
1 change: 1 addition & 0 deletions tempesta_fw/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ typedef struct {
bool have_children;
size_t val_n;
size_t attr_n;
int line; /* The current line */
const char *name;
const char *vals[TFW_CFG_ENTRY_VAL_MAX];
struct {
Expand Down

0 comments on commit ed366ef

Please sign in to comment.