... | ... |
@@ -113,13 +113,12 @@ |
113 | 113 |
struct sr_yy_fname *next; |
114 | 114 |
} *sr_yy_fname_list = 0; |
115 | 115 |
|
116 |
- str *pp_define_get(int len, const char * text); |
|
117 | 116 |
static int pp_ifdef_type(int pos); |
118 | 117 |
static void pp_ifdef_var(int len, const char * text); |
119 | 118 |
static void pp_ifdef(); |
120 | 119 |
static void pp_else(); |
121 | 120 |
static void pp_endif(); |
122 |
- static void ksr_print_cfg_part(char *text); |
|
121 |
+ static void ksr_cfg_print_part(char *text); |
|
123 | 122 |
|
124 | 123 |
%} |
125 | 124 |
|
... | ... |
@@ -1285,56 +1284,48 @@ IMPORTFILE "import_file" |
1285 | 1284 |
sr_cfg_compat=SR_COMPAT_MAX;} |
1286 | 1285 |
|
1287 | 1286 |
<INITIAL,CFGPRINTMODE>{PREP_START}{DEFINE}{EAT_ABLE}+ { count(); |
1288 |
- ksr_print_cfg_part(yytext); |
|
1287 |
+ ksr_cfg_print_part(yytext); |
|
1289 | 1288 |
pp_define_set_type(0); |
1290 | 1289 |
state = DEFINE_S; BEGIN(DEFINE_ID); } |
1291 | 1290 |
<INITIAL,CFGPRINTMODE>{PREP_START}{TRYDEF}{EAT_ABLE}+ { count(); |
1292 |
- ksr_print_cfg_part(yytext); |
|
1291 |
+ ksr_cfg_print_part(yytext); |
|
1293 | 1292 |
pp_define_set_type(1); |
1294 | 1293 |
state = DEFINE_S; BEGIN(DEFINE_ID); } |
1295 | 1294 |
<INITIAL,CFGPRINTMODE>{PREP_START}{REDEF}{EAT_ABLE}+ { count(); |
1296 |
- ksr_print_cfg_part(yytext); |
|
1295 |
+ ksr_cfg_print_part(yytext); |
|
1297 | 1296 |
pp_define_set_type(2); |
1298 | 1297 |
state = DEFINE_S; BEGIN(DEFINE_ID); } |
1299 | 1298 |
<DEFINE_ID>{ID}{MINUS} { count(); |
1300 |
- ksr_print_cfg_part(yytext); |
|
1299 |
+ ksr_cfg_print_part(yytext); |
|
1301 | 1300 |
LM_CRIT( |
1302 | 1301 |
"error at %s line %d: '-' not allowed\n", |
1303 | 1302 |
(finame)?finame:"cfg", line); |
1304 | 1303 |
exit(-1); |
1305 | 1304 |
} |
1306 | 1305 |
<DEFINE_ID>{ID} { count(); |
1307 |
- ksr_print_cfg_part(yytext); |
|
1306 |
+ ksr_cfg_print_part(yytext); |
|
1308 | 1307 |
if (pp_define(yyleng, yytext)) return 1; |
1309 | 1308 |
state = DEFINE_EOL_S; BEGIN(DEFINE_EOL); } |
1310 |
-<DEFINE_EOL>{EAT_ABLE} { count(); ksr_print_cfg_part(yytext); } |
|
1309 |
+<DEFINE_EOL>{EAT_ABLE} { count(); ksr_cfg_print_part(yytext); } |
|
1311 | 1310 |
<DEFINE_EOL>{CR} { count(); |
1312 |
- ksr_print_cfg_part(yytext); |
|
1311 |
+ ksr_cfg_print_part(yytext); |
|
1313 | 1312 |
state = INITIAL; |
1314 |
- if(ksr_cfg_print_mode == 1) { |
|
1315 |
- BEGIN(CFGPRINTMODE); |
|
1316 |
- } else { |
|
1317 |
- BEGIN(INITIAL); |
|
1318 |
- } |
|
1313 |
+ ksr_cfg_print_initial_state(); |
|
1319 | 1314 |
} |
1320 | 1315 |
<DEFINE_EOL>. { count(); |
1321 |
- ksr_print_cfg_part(yytext); |
|
1316 |
+ ksr_cfg_print_part(yytext); |
|
1322 | 1317 |
addstr(&s_buf, yytext, yyleng); |
1323 | 1318 |
state = DEFINE_DATA_S; BEGIN(DEFINE_DATA); } |
1324 |
-<DEFINE_DATA>\\{CR} { count(); ksr_print_cfg_part(yytext); } /* eat the escaped CR */ |
|
1319 |
+<DEFINE_DATA>\\{CR} { count(); ksr_cfg_print_part(yytext); } /* eat the escaped CR */ |
|
1325 | 1320 |
<DEFINE_DATA>{CR} { count(); |
1326 |
- ksr_print_cfg_part(yytext); |
|
1321 |
+ ksr_cfg_print_part(yytext); |
|
1327 | 1322 |
if (pp_define_set(strlen(s_buf.s), s_buf.s)) return 1; |
1328 | 1323 |
memset(&s_buf, 0, sizeof(s_buf)); |
1329 | 1324 |
state = INITIAL; |
1330 |
- if(ksr_cfg_print_mode == 1) { |
|
1331 |
- BEGIN(CFGPRINTMODE); |
|
1332 |
- } else { |
|
1333 |
- BEGIN(INITIAL); |
|
1334 |
- } |
|
1325 |
+ ksr_cfg_print_initial_state(); |
|
1335 | 1326 |
} |
1336 | 1327 |
<DEFINE_DATA>. { count(); |
1337 |
- ksr_print_cfg_part(yytext); |
|
1328 |
+ ksr_cfg_print_part(yytext); |
|
1338 | 1329 |
addstr(&s_buf, yytext, yyleng); } |
1339 | 1330 |
|
1340 | 1331 |
<INITIAL>{PREP_START}{SUBST} { count(); return SUBST;} |
... | ... |
@@ -1401,11 +1392,7 @@ IMPORTFILE "import_file" |
1401 | 1392 |
exit(-1); |
1402 | 1393 |
} |
1403 | 1394 |
memset(&s_buf, 0, sizeof(s_buf)); |
1404 |
- if(ksr_cfg_print_mode == 1) { |
|
1405 |
- BEGIN(CFGPRINTMODE); |
|
1406 |
- } else { |
|
1407 |
- BEGIN(INITIAL); |
|
1408 |
- } |
|
1395 |
+ ksr_cfg_print_initial_state(); |
|
1409 | 1396 |
} |
1410 | 1397 |
|
1411 | 1398 |
<IMPTF>[ \t]* /* eat the whitespace */ |
... | ... |
@@ -1419,11 +1406,7 @@ IMPORTFILE "import_file" |
1419 | 1406 |
exit(-1); |
1420 | 1407 |
} |
1421 | 1408 |
memset(&s_buf, 0, sizeof(s_buf)); |
1422 |
- if(ksr_cfg_print_mode == 1) { |
|
1423 |
- BEGIN(CFGPRINTMODE); |
|
1424 |
- } else { |
|
1425 |
- BEGIN(INITIAL); |
|
1426 |
- } |
|
1409 |
+ ksr_cfg_print_initial_state(); |
|
1427 | 1410 |
} |
1428 | 1411 |
|
1429 | 1412 |
<CFGPRINTMODE>.|{CR} { count(); printf("%s", yytext); } |
... | ... |
@@ -1479,13 +1462,22 @@ IMPORTFILE "import_file" |
1479 | 1462 |
|
1480 | 1463 |
%% |
1481 | 1464 |
|
1482 |
-static void ksr_print_cfg_part(char *text) |
|
1465 |
+static void ksr_cfg_print_part(char *text) |
|
1483 | 1466 |
{ |
1484 | 1467 |
if(ksr_cfg_print_mode == 1) { |
1485 | 1468 |
printf("%s", text); |
1486 | 1469 |
} |
1487 | 1470 |
} |
1488 | 1471 |
|
1472 |
+void ksr_cfg_print_initial_state(void) |
|
1473 |
+{ |
|
1474 |
+ if(ksr_cfg_print_mode == 1) { |
|
1475 |
+ BEGIN(CFGPRINTMODE); |
|
1476 |
+ } else { |
|
1477 |
+ BEGIN(INITIAL); |
|
1478 |
+ } |
|
1479 |
+} |
|
1480 |
+ |
|
1489 | 1481 |
static char* addchar(struct str_buf* dst, char c) |
1490 | 1482 |
{ |
1491 | 1483 |
return addstr(dst, &c, 1); |
... | ... |
@@ -2001,11 +1993,8 @@ static void pp_update_state() |
2001 | 1993 |
return; |
2002 | 1994 |
} |
2003 | 1995 |
|
2004 |
- if(ksr_cfg_print_mode == 1) { |
|
2005 |
- state = CFGPRINTMODE; BEGIN(CFGPRINTMODE); |
|
2006 |
- } else { |
|
2007 |
- state = INITIAL; BEGIN(INITIAL); |
|
2008 |
- } |
|
1996 |
+ state = INITIAL; |
|
1997 |
+ ksr_cfg_print_initial_state(); |
|
2009 | 1998 |
} |
2010 | 1999 |
|
2011 | 2000 |
static void pp_ifdef() |