httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rüdiger Plüm <ruediger.pl...@vodafone.com>
Subject Fwd: svn commit: r1367725 - /httpd/httpd/trunk/modules/lua/mod_lua.c
Date Wed, 01 Aug 2012 06:38:40 GMT


-------- Original Message --------
Subject: 	svn commit: r1367725 - /httpd/httpd/trunk/modules/lua/mod_lua.c
Date: 	Tue, 31 Jul 2012 19:43:30 GMT
From: 	humbedooh@apache.org



Author: humbedooh
Date: Tue Jul 31 19:43:29 2012
New Revision: 1367725

URL: http://svn.apache.org/viewvc?rev=1367725&view=rev
Log:
mod_lua: Add the (missing) LuaMapHandler directive to the fold.
This should work as the existing documentation describes.

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=1367725&r1=1367724&r2=1367725&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.c (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.c Tue Jul 31 19:43:29 2012
@@ -170,6 +170,35 @@ static ap_lua_vm_spec *create_vm_spec(ap
       return spec;
   }

+static const char* ap_lua_interpolate_string(apr_pool_t* pool, const char* string, const
char** values)
+{
+    char *stringBetween;
+    const char* ret;
+    int srclen,x,y;
+    srclen = strlen(string);
+    ret = "";
+    y = 0;
+    for (x=0; x<  srclen; x++) {
+        if (string[x] == '
    &&  x != srclen-1&&  string[x+1]>= '0'&&
string[x+1]<= '9') {
+            if (x-y>  0) {
+                stringBetween = apr_pstrndup(pool, string+y, x-y);
+            }
+            else stringBetween = "";

Style. Please review the style guide (code should be on the next line)

+            int v = atoi(apr_pstrndup(pool,string+x+1, 1));

As this is only one digit you can convert directly, e.g. *(string+x+1) - '0' and avoid
copying the string.

+            ret = apr_psprintf(pool, "%s%s%s", ret, stringBetween, values[v]);

As you only concat strings here use apr_pstrcat here.

+            y = ++x;
+        }
+    }
+
+    if (x-y>  0&&  y>  0) {
+        stringBetween = apr_pstrndup(pool, string+y+1, x-y);
+        ret = apr_psprintf(pool, "%s%s", ret, stringBetween);


As you only concat strings here use apr_pstrcat here.

+    }
+    else if (y==0) return string; /* If no replacement was made, just return the original
str. */

Style. Please review the style guide (comment should be on a separate line, code on the next
line)

+    return ret;
+}
+
+

Regards

Rüdiger



Mime
View raw message