Index: ossp-pkg/cfg/00TODO RCS File: /v/ossp/cvs/ossp-pkg/cfg/Attic/00TODO,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/cfg/Attic/00TODO,v' 2>/dev/null --- 00TODO 2002/07/03 13:25:34 1.1 +++ 00TODO 2002/07/05 14:33:10 1.2 @@ -1,4 +1,17 @@ +- newline in error message +$ ./cfg_test sample2.cfg +ERROR: quu'> + + +cfg_test in free(): warning: modified (chunk-) pointer + - cfg_t -- cfg_data.c -- cfg_node_dump() - cfg_node_destroy() for whole tree + +rewrite-uri { } + +rewrite-uri ^/(.*) /path/$1 --redirect=permanent "{ + %{SOURCE} != "x" +}"; + Index: ossp-pkg/cfg/cfg_syn.c RCS File: /v/ossp/cvs/ossp-pkg/cfg/cfg_syn.c,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/cfg/cfg_syn.c,v' 2>/dev/null --- cfg_syn.c 2002/07/04 14:51:21 1.2 +++ cfg_syn.c 2002/07/05 14:33:10 1.3 @@ -144,8 +144,8 @@ *cp++ = '\0'; /* remember parsing error: part I (context part) */ - cfg_fmt_sprintf(ctx->err_buf, sizeof(ctx->err_len), - "line %d, column %d: `%s'; %s", + cfg_fmt_sprintf(ctx->err_buf, ctx->err_len, + "line %d, column %d: `%s'", line, column, cpBuf); free(cpBuf); Index: ossp-pkg/cfg/cfg_syn_scan.l RCS File: /v/ossp/cvs/ossp-pkg/cfg/cfg_syn_scan.l,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/cfg/cfg_syn_scan.l,v' 2>/dev/null --- cfg_syn_scan.l 2002/07/03 13:25:34 1.1 +++ cfg_syn_scan.l 2002/07/05 14:33:10 1.2 @@ -57,6 +57,8 @@ yylloc->last += yyleng; #define YY_USER_ACTION_ROLLBACK \ yylloc->last = yylloc->first + +static char closing_brace(char open); %} /* scanner options */ @@ -69,6 +71,8 @@ /* scanner states */ %x SS_DQ %x SS_SQ +%x SS_FQ +%x SS_PT %x SS_CO_C %% @@ -76,6 +80,9 @@ /* local variables */ char caStr[1024]; char *cpStr = NULL; + int nQuoteOpen; + char cQuoteOpen; + char cQuoteClose; /* whitespaces */ [ \t\n]+ { @@ -172,20 +179,70 @@ *cpStr++ = yytext[1]; } - /* plain text word */ -[^ \t\n;{}"']+ { - yylval->cpString = strdup(yytext); - return T_STRING; + /* flexible-quoted word (q(.)[^\1]\1) + the delimiting character has to one a special character c, i.e., + one of !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ or in C code: + isprint(c) && !isspace(c) && !iscntrl(c) && !isalpha(i) && !isdigit(i) + */ +"q"[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~] { + cpStr = caStr; + nQuoteOpen = 1; + cQuoteOpen = yytext[1]; + cQuoteClose = closing_brace(yytext[1]); + BEGIN(SS_FQ); +} +\\[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~] { + if (yytext[1] == cQuoteOpen || yytext[1] == cQuoteClose) { + *cpStr++ = yytext[1]; + } + else { + *cpStr++ = yytext[0]; + *cpStr++ = yytext[1]; + } +} +[^\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~] { + char *cp = yytext; + while (*cp != '\0') + *cpStr++ = *cp++; +} +(.|\n) { + if (yytext[0] == cQuoteOpen) + nQuoteOpen++; + else if (yytext[0] == cQuoteClose) + nQuoteOpen--; + if (yytext[0] == cQuoteClose && nQuoteOpen == 0) { + *cpStr = '\0'; + yylval->cpString = strdup(caStr); + BEGIN(INITIAL); + return T_STRING; + } + else { + *cpStr++ = yytext[0]; + } } /* special tokens */ -";" { return T_SEP; } -"{" { return T_OPEN; } +";" { return T_SEP; } +"{" { return T_OPEN; } "}" { return T_CLOSE; } - /* anything else is returned as is... */ -.|\n { - return yytext[0]; + /* plain text word */ +(.|\n) { + cpStr = caStr; + *cpStr++ = yytext[0]; + BEGIN(SS_PT); +} +[^ \t\n;{}"']+ { + char *cp = yytext; + while (*cp != '\0') + *cpStr++ = *cp++; +} +(.|\n) { + *cpStr = '\0'; + yylval->cpString = strdup(caStr); + yyless(0); + BEGIN(INITIAL); + return T_STRING; } %% @@ -218,3 +275,25 @@ return n; } +/* closing brace */ +static char closing_brace(char open) +{ + static struct { + char open; + char close; + } openclose[] = { + { '(', ')' }, + { '{', '}' }, + { '{', ']' }, + { '<', '>' }, + { '`', '\'' }, + }; + int i; + + for (i = 0; i < sizeof(openclose)/sizeof(openclose[0]); i++) { + if (openclose[i].open == open) + return (char)openclose[i].close; + } + return open; +} + Index: ossp-pkg/cfg/sample2.cfg RCS File: /v/ossp/cvs/ossp-pkg/cfg/Attic/sample2.cfg,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/cfg/Attic/sample2.cfg,v' 2>/dev/null --- sample2.cfg 2002/07/04 14:51:21 1.1 +++ sample2.cfg 2002/07/05 14:33:10 1.2 @@ -1,6 +1,6 @@ foo; -bar1 "bar2 bar2b"; +bar1 q{ f{o}o } 'foo;' "bar2 bar2b"; quux1 { quux1a; quux1b;