httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r728539 - in /httpd/httpd/trunk/modules/lua: lua_apr.c lua_config.c lua_request.c lua_vmprep.c mod_lua.c
Date Sun, 21 Dec 2008 22:38:07 GMT
Author: pquerna
Date: Sun Dec 21 14:38:07 2008
New Revision: 728539

URL: http://svn.apache.org/viewvc?rev=728539&view=rev
Log:
Attempt to make mod_lua compile under a strict c89 compiler by moving all variable declarations
to be before code.

Modified:
    httpd/httpd/trunk/modules/lua/lua_apr.c
    httpd/httpd/trunk/modules/lua/lua_config.c
    httpd/httpd/trunk/modules/lua/lua_request.c
    httpd/httpd/trunk/modules/lua/lua_vmprep.c
    httpd/httpd/trunk/modules/lua/mod_lua.c

Modified: httpd/httpd/trunk/modules/lua/lua_apr.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_apr.c?rev=728539&r1=728538&r2=728539&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_apr.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_apr.c Sun Dec 21 14:38:07 2008
@@ -34,8 +34,9 @@
 
 apr_table_t *check_apr_table(lua_State *L, int index)
 {
+    apr_table_t *t;
     luaL_checkudata(L, index, "Apr.Table");
-    apr_table_t *t = (apr_table_t *) lua_unboxpointer(L, index);
+    t = (apr_table_t *) lua_unboxpointer(L, index);
     return t;
 }
 

Modified: httpd/httpd/trunk/modules/lua/lua_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_config.c?rev=728539&r1=728538&r2=728539&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_config.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_config.c Sun Dec 21 14:38:07 2008
@@ -20,15 +20,17 @@
 
 static apl_dir_cfg *check_dir_config(lua_State *L, int index)
 {
+    apl_dir_cfg *cfg;
     luaL_checkudata(L, index, "Apache2.DirConfig");
-    apl_dir_cfg *cfg = (apl_dir_cfg *) lua_unboxpointer(L, index);
+    cfg = (apl_dir_cfg *) lua_unboxpointer(L, index);
     return cfg;
 }
 
 static cmd_parms *check_cmd_parms(lua_State *L, int index)
 {
+    cmd_parms *cmd;
     luaL_checkudata(L, index, "Apache2.CommandParameters");
-    cmd_parms *cmd = (cmd_parms *) lua_unboxpointer(L, index);
+    cmd = (cmd_parms *) lua_unboxpointer(L, index);
     return cmd;
 }
 

Modified: httpd/httpd/trunk/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.c?rev=728539&r1=728538&r2=728539&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.c Sun Dec 21 14:38:07 2008
@@ -92,8 +92,9 @@
  */
 static request_rec *apl_check_request_rec(lua_State *L, int index)
 {
+    request_rec *r;
     luaL_checkudata(L, index, "Apache2.Request");
-    request_rec *r = (request_rec *) lua_unboxpointer(L, index);
+    r = (request_rec *) lua_unboxpointer(L, index);
     return r;
 }
 
@@ -102,6 +103,7 @@
 static int req_aprtable2luatable_cb(void *l, const char *key,
                                     const char *value)
 {
+    int t;
     lua_State *L = (lua_State *) l;     /* [table<s,t>, table<s,s>] */
     /* rstack_dump(L, RRR, "start of cb"); */
     /* L is [table<s,t>, table<s,s>] */
@@ -109,7 +111,7 @@
 
     lua_getfield(L, -1, key);   /* [VALUE, table<s,t>, table<s,s>] */
     /* rstack_dump(L, RRR, "after getfield"); */
-    int t = lua_type(L, -1);
+    t = lua_type(L, -1);
     switch (t) {
     case LUA_TNIL:
     case LUA_TNONE:{
@@ -149,10 +151,10 @@
 /* r:parseargs() returning a lua table */
 static int req_parseargs(lua_State *L)
 {
+    apr_table_t *form_table;
     request_rec *r = apl_check_request_rec(L, 1);
     lua_newtable(L);
     lua_newtable(L);            /* [table, table] */
-    apr_table_t *form_table;
     ap_args_to_table(r, &form_table);
     apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);
     return 2;                   /* [table<string, string>, table<string, array<string>>]
*/

Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_vmprep.c?rev=728539&r1=728538&r2=728539&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_vmprep.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_vmprep.c Sun Dec 21 14:38:07 2008
@@ -26,10 +26,11 @@
 static void pstack_dump(lua_State *L, apr_pool_t *r, int level,
                         const char *msg)
 {
-    ap_log_perror(APLOG_MARK, level, 0, r, "Lua Stack Dump: [%s]", msg);
-
     int i;
     int top = lua_gettop(L);
+
+    ap_log_perror(APLOG_MARK, level, 0, r, "Lua Stack Dump: [%s]", msg);
+
     for (i = 1; i <= top; i++) {
         int t = lua_type(L, i);
         switch (t) {
@@ -235,19 +236,25 @@
                        apr_pool_t *pool,
                        apr_array_header_t *paths, const char *file)
 {
+    const char *current;
+    const char *parent_dir;
+    const char *pattern;
+    const char *modified;
+    char *part;
+    int i;
+
     lua_getglobal(L, "package");
     lua_getfield(L, -1, field);
-    const char *current = lua_tostring(L, -1);
-    const char *parent_dir = ap_make_dirstr_parent(pool, file);
-    const char *pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
+    current = lua_tostring(L, -1);
+    parent_dir = ap_make_dirstr_parent(pool, file);
+    pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
     luaL_gsub(L, current, rep_pat, pattern);
     lua_setfield(L, -3, field);
     lua_getfield(L, -2, field);
-    const char *modified = lua_tostring(L, -1);
+    modified = lua_tostring(L, -1);
     lua_pop(L, 2);
 
-    char *part = apr_pstrdup(pool, modified);
-    int i;
+    part = apr_pstrdup(pool, modified);
     for (i = 0; i < paths->nelts; i++) {
         const char *new_path = ((const char **) paths->elts)[i];
         part = apr_pstrcat(pool, part, ";", new_path, NULL);
@@ -272,12 +279,14 @@
         /* not available, so create */
         L = luaL_newstate();
         luaL_openlibs(L);
-        if (package_paths)
+        if (package_paths) {
             munge_path(L, "path", "?.lua", "./?.lua", lifecycle_pool,
                        package_paths, spec->file);
-        if (package_cpaths)
+        }
+        if (package_cpaths) {
             munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool,
                        package_cpaths, spec->file);
+        }
 
         if (cb) {
             cb(L, lifecycle_pool, btn);

Modified: httpd/httpd/trunk/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.c?rev=728539&r1=728538&r2=728539&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.c (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.c Sun Dec 21 14:38:07 2008
@@ -39,12 +39,13 @@
  */
 static void report_lua_error(lua_State *L, request_rec *r)
 {
+    const char *lua_response;
     r->status = 500;
     r->content_type = "text/html";
 
     ap_rputs("<b>Error!</b>\n", r);
     ap_rputs("<p>", r);
-    const char *lua_response = lua_tostring(L, -1);
+    lua_response = lua_tostring(L, -1);
     ap_rputs(lua_response, r);
     ap_rputs("</p>\n", r);
 
@@ -107,10 +108,14 @@
     apl_dir_cfg *dcfg = ap_get_module_config(r->per_dir_config, &lua_module);
 
     if (!r->header_only) {
+        lua_State *L;
+        const apl_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
+                                                      &lua_module);
         apl_request_cfg *rcfg =
             ap_get_module_config(r->request_config, &lua_module);
         mapped_request_details *d = rcfg->mapped_request_details;
         apl_vm_spec *spec = NULL;
+
         if (!d) {
             d = apr_palloc(r->pool, sizeof(mapped_request_details));
             spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
@@ -121,16 +126,15 @@
             d->spec = spec;
             d->function_name = "handle";
         }
+
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                       "request details scope:%u, cache:%u", d->spec->scope,
                       d->spec->code_cache_style);
-        const apl_dir_cfg *cfg =
-            ap_get_module_config(r->per_dir_config, &lua_module);
-        lua_State *L = apl_get_lua_state(r->pool,
-                                         d->spec,
-                                         cfg->package_paths,
-                                         cfg->package_cpaths,
-                                         &lua_open_callback, NULL);
+        L = apl_get_lua_state(r->pool,
+                              d->spec,
+                              cfg->package_paths,
+                              cfg->package_cpaths,
+                              &lua_open_callback, NULL);
 
         ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "got a vm!");
         if (!L) {
@@ -154,22 +158,24 @@
  */
 static int apl_alias_munger(request_rec *r)
 {
+    apl_vm_spec *spec;
+    apl_request_cfg *rcfg = ap_get_module_config(r->request_config,
+                                                 &lua_module);
     const apl_dir_cfg *cfg =
         ap_get_module_config(r->per_dir_config, &lua_module);
-
     int i;
     ap_regmatch_t matches[AP_MAX_REG_MATCH];
 
     for (i = 0; i < cfg->mapped_handlers->nelts; i++) {
         const apl_mapped_handler_spec *cnd =
-            ((const apl_mapped_handler_spec **) cfg->mapped_handlers->
-             elts)[i];
+            ((const apl_mapped_handler_spec **) cfg->mapped_handlers->elts)[i];
+
         if (OK ==
             ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH, matches,
                        0)) {
             r->handler = "lua-script";
 
-            apl_vm_spec *spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
+            spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
             spec->file =
                 ap_pregsub(r->pool, cnd->file_name, r->uri, AP_MAX_REG_MATCH,
                            matches);
@@ -191,8 +197,6 @@
 
             /* now do replacement on method name where? */
             r->filename = apr_pstrdup(r->pool, spec->file);
-            apl_request_cfg *rcfg =
-                ap_get_module_config(r->request_config, &lua_module);
             rcfg->mapped_request_details = d;
             return OK;
         }
@@ -206,6 +210,8 @@
 
 static int lua_request_rec_hook_harness(request_rec *r, const char *name)
 {
+    lua_State *L;
+    apl_vm_spec *spec;
     apl_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
                                                       &lua_module);
     const apl_dir_cfg *cfg =
@@ -223,7 +229,7 @@
             if (hook_spec == NULL) {
                 continue;
             }
-            apl_vm_spec *spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
+            spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
 
             spec->file = hook_spec->file_name;
             spec->code_cache_style = hook_spec->code_cache_style;
@@ -234,11 +240,11 @@
 
             apr_filepath_merge(&spec->file, server_cfg->root_path,
                                spec->file, APR_FILEPATH_NOTRELATIVE, r->pool);
-            lua_State *L = apl_get_lua_state(r->pool,
-                                             spec,
-                                             cfg->package_paths,
-                                             cfg->package_cpaths,
-                                             &lua_open_callback, NULL);
+            L = apl_get_lua_state(r->pool,
+                                  spec,
+                                  cfg->package_paths,
+                                  cfg->package_cpaths,
+                                  &lua_open_callback, NULL);
 
 
 
@@ -446,6 +452,7 @@
         lua_State *lvm;
         char *tmp;
         int rv;
+        ap_directive_t **current;
 
         apr_snprintf(buf, sizeof(buf), "%u", cmd->config_file->line_number);
         spec->file_name =
@@ -491,7 +498,7 @@
             lua_close(lvm);
         }
 
-        ap_directive_t **current = mconfig;
+        current = mconfig;
 
         /* Here, we have to replace our current config node for the next pass */
         if (!*current) {
@@ -520,6 +527,7 @@
                                                      const char *file,
                                                      const char *function)
 {
+    apl_mapped_handler_spec *spec;
     apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
 
     apr_array_header_t *hook_specs =
@@ -531,8 +539,7 @@
                      APR_HASH_KEY_STRING, hook_specs);
     }
 
-    apl_mapped_handler_spec *spec =
-        apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
+    spec = apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
     spec->file_name = apr_pstrdup(cmd->pool, file);
     spec->function_name = apr_pstrdup(cmd->pool, function);
     spec->scope = cfg->vm_scope;
@@ -823,10 +830,9 @@
                                    const char *function)
 {
     apl_dir_cfg *cfg = (apl_dir_cfg *) _cfg;
-
+    apr_status_t rv;
     const char *function_name;
     function_name = function ? function : "handle";
-    apr_status_t rv;
     rv = apl_lua_map_handler(cfg, file, function_name, path, "once");
     if (rv != APR_SUCCESS) {
         return apr_psprintf(cmd->pool,



Mime
View raw message