You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by hu...@apache.org on 2012/08/01 09:28:22 UTC
svn commit: r1367875 - /httpd/httpd/trunk/modules/lua/mod_lua.c
Author: humbedooh
Date: Wed Aug 1 07:28:22 2012
New Revision: 1367875
URL: http://svn.apache.org/viewvc?rev=1367875&view=rev
Log:
mod_lua:
Clean up style
use apr_pstrcat instead of apr_psprintf
fix a bug that was causing bad string interpolations.
Modified:
httpd/httpd/trunk/modules/lua/mod_lua.c
Modified: httpd/httpd/trunk/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.c?rev=1367875&r1=1367874&r2=1367875&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.c (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.c Wed Aug 1 07:28:22 2012
@@ -183,18 +183,23 @@ static const char* ap_lua_interpolate_st
if (x-y > 0) {
stringBetween = apr_pstrndup(pool, string+y, x-y);
}
- else stringBetween = "";
- int v = atoi(apr_pstrndup(pool,string+x+1, 1));
- ret = apr_psprintf(pool, "%s%s%s", ret, stringBetween, values[v]);
- y = ++x;
+ else {
+ stringBetween = "";
+ }
+ int v = *(string+x+1) - '0';
+ ret = apr_pstrcat(pool, ret, stringBetween, values[v], NULL);
+ y = ++x+1;
}
}
if (x-y > 0 && y > 0) {
- stringBetween = apr_pstrndup(pool, string+y+1, x-y);
- ret = apr_psprintf(pool, "%s%s", ret, stringBetween);
+ stringBetween = apr_pstrndup(pool, string+y, x-y);
+ ret = apr_pstrcat(pool, ret, stringBetween, NULL);
+ }
+ /* If no replacement was made, just return the original string */
+ else if (y==0) {
+ return string;
}
- else if (y==0) return string; /* If no replacement was made, just return the original str. */
return ret;
}
@@ -362,7 +367,6 @@ static int lua_map_handler(request_rec *
hook_spec->bytecode_len,
function_name,
"mapped handler");
-
L = ap_lua_get_lua_state(pool, spec, r);
if (!L) {