From 6ef1911acc7e848d88e3ff505cc2a018f41cd903 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sun, 21 Nov 2010 17:22:26 +0000 Subject: ap_expr related fixes/enhancements: - implement regex backreferences and make them available for setting envvars in SetEnvIfExpr - implement nested function calls in %-syntax: %{func1:%{func2:arg}} - actually implement evaluation of concatenation operator (oops...) - Fix treating an internal error as success git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1037504 13f79535-47bb-0310-9956-ffa450edef68 --- server/util_expr_scan.l | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'server/util_expr_scan.l') diff --git a/server/util_expr_scan.l b/server/util_expr_scan.l index 05ff3a116b..79bdbc16f9 100644 --- a/server/util_expr_scan.l +++ b/server/util_expr_scan.l @@ -142,14 +142,30 @@ *str_ptr++ = yytext[1]; } -[^\\\n"'%}]+ { + /* regexp backref inside string/arg */ +[$][0-9] { + if (str_ptr != str_buf) { + /* return what we have so far and scan '$x' again */ + *str_ptr = '\0'; + yylval->cpVal = apr_pstrdup(yyextra->pool, str_buf); + str_ptr = str_buf; + yyless(0); + return T_STRING; + } + else { + yylval->num = yytext[1] - '0'; + return T_REGEX_BACKREF; + } +} + +[^\\\n"'%}$]+ { char *cp = yytext; while (*cp != '\0') *str_ptr++ = *cp++; } - /* variable inside string */ -%\{ { + /* variable inside string/arg */ +%\{ { if (str_ptr != str_buf) { /* return what we have so far and scan '%{' again */ *str_ptr = '\0'; @@ -164,11 +180,11 @@ } } -% { +[%$] { *str_ptr++ = yytext[0]; } -[%}] { +[%}$] { *str_ptr++ = yytext[0]; } @@ -177,6 +193,11 @@ return T_VAR_BEGIN; } +[$][0-9] { + yylval->num = yytext[1] - '0'; + return T_REGEX_BACKREF; +} + /* * fixed name variable expansion %{XXX} and function call in %{func:arg} syntax */ -- cgit v1.2.3