You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by mx...@apache.org on 2011/09/06 23:33:45 UTC

svn commit: r1165867 - in /tcl/rivet/trunk: ChangeLog Makefile.in src/apache-2/TclWebapache.c src/apache-2/mod_rivet.c src/apache-2/rivetCore.c

Author: mxmanghi
Date: Tue Sep  6 21:33:45 2011
New Revision: 1165867

URL: http://svn.apache.org/viewvc?rev=1165867&view=rev
Log:
2011-09-06 Massimo Manghi <mx...@apache.org>
    * src/apache-2/mod_rivet.c: Add Id svn keyword.
    * src/apache-2/TclWebapache.c: Command load_env and load_headers now resolve 
    the array name parameter following the default method (removed 
    TCL_NAMESPACE_ONLY flag that prevented creation of an array in a
    proc's scope). Still default values for the arguments create such arrays
    in the ::request namespace 
    * src/apache-2/rivetCode.c: preprocess macros ENV_ARRAY_NAME and HEADERS_ARRAY_NAME
    modified to explicitly put in ::request namespace the default arrays. 
    Procedure Rivet_MakeURL chages so that command 'makeurl' now accepts 
    relative paths and prepends them with the value of the SCRIPT_NAME environment 
    variable. When run without arguments 'makeurl' returns the value in the
    SCRIPT_NAME env variable.


Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/Makefile.in
    tcl/rivet/trunk/src/apache-2/TclWebapache.c
    tcl/rivet/trunk/src/apache-2/mod_rivet.c   (contents, props changed)
    tcl/rivet/trunk/src/apache-2/rivetCore.c   (contents, props changed)

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1165867&r1=1165866&r2=1165867&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Tue Sep  6 21:33:45 2011
@@ -1,3 +1,17 @@
+2011-09-06 Massimo Manghi <mx...@apache.org>
+    * src/apache-2/mod_rivet.c: Add Id svn keyword.
+    * src/apache-2/TclWebapache.c: Command load_env and load_headers now resolve 
+    the array name parameter following the default method (removed 
+    TCL_NAMESPACE_ONLY flag that prevented creation of an array in a
+    proc's scope). Still default values for the arguments create such arrays
+    in the ::request namespace 
+    * src/apache-2/rivetCode.c: preprocess macros ENV_ARRAY_NAME and HEADERS_ARRAY_NAME
+    modified to explicitly put in ::request namespace the default arrays. 
+    Procedure Rivet_MakeURL chages so that command 'makeurl' now accepts 
+    relative paths and prepends them with the value of the SCRIPT_NAME environment 
+    variable. When run without arguments 'makeurl' returns the value in the
+    SCRIPT_NAME env variable.
+     
 2011-06-03 Massimo Manghi <mx...@apache.org>
     * tclconfig/ltmain.sh: new version shipped with libtool 
 

Modified: tcl/rivet/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/Makefile.in?rev=1165867&r1=1165866&r2=1165867&view=diff
==============================================================================
--- tcl/rivet/trunk/Makefile.in (original)
+++ tcl/rivet/trunk/Makefile.in Tue Sep  6 21:33:45 2011
@@ -147,29 +147,26 @@ CFLAGS_WARNING = @CFLAGS_WARNING@
 CLEANFILES = @CLEANFILES@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
 CYGPATH = @CYGPATH@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
-ECHO = @ECHO@
+DUMPBIN = @DUMPBIN@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@
 LD_LIBRARY_PATH_VAR = @LD_LIBRARY_PATH_VAR@
@@ -177,6 +174,7 @@ LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
@@ -184,11 +182,16 @@ MAKE_LIB = @MAKE_LIB@
 MAKE_SHARED_LIB = @MAKE_SHARED_LIB@
 MAKE_STATIC_LIB = @MAKE_STATIC_LIB@
 MAKE_STUB_LIB = @MAKE_STUB_LIB@
+MANIFEST_TOOL = @MANIFEST_TOOL@
 MATH_LIBS = @MATH_LIBS@
 MAX_POST = @MAX_POST@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -247,9 +250,9 @@ abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
 ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@

Modified: tcl/rivet/trunk/src/apache-2/TclWebapache.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/TclWebapache.c?rev=1165867&r1=1165866&r2=1165867&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/TclWebapache.c (original)
+++ tcl/rivet/trunk/src/apache-2/TclWebapache.c Tue Sep  6 21:33:45 2011
@@ -444,7 +444,17 @@ TclWeb_GetEnvVars(Tcl_Obj *envvar, TclWe
 	val = TclWeb_StringToUtfToObj(env[i].val, req);
 	Tcl_IncrRefCount(key);
 	Tcl_IncrRefCount(val);
-	Tcl_ObjSetVar2(req->interp, envvar, key, val, TCL_NAMESPACE_ONLY);
+
+    /* Variable scope resolution changed to default (flags: 0)
+     * to enable creation of the array in the caller's local scope.
+     * Default behavior (creation in the ::request namespace)
+     * is now more consistently constrained by fully qualifying
+     * the default array names (see rivetCore.c). This should fix
+     * Bug 48963 
+     */
+
+        Tcl_ObjSetVar2(req->interp, envvar, key, val, 0);
+
  	Tcl_DecrRefCount(key);
 	Tcl_DecrRefCount(val);
     }
@@ -478,8 +488,10 @@ TclWeb_GetHeaderVars(Tcl_Obj *headersvar
 	val = TclWeb_StringToUtfToObj(hdrs[i].val, req);
 	Tcl_IncrRefCount(key);
 	Tcl_IncrRefCount(val);
-	Tcl_ObjSetVar2(req->interp, headersvar,
-		       key, val, TCL_NAMESPACE_ONLY);
+
+        /* See comment in TclWeb_GetEnvVars concerning Bug 48963*/
+
+        Tcl_ObjSetVar2(req->interp, headersvar, key, val, 0);
  	Tcl_DecrRefCount(key);
 	Tcl_DecrRefCount(val);
     }

Modified: tcl/rivet/trunk/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/mod_rivet.c?rev=1165867&r1=1165866&r2=1165867&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/trunk/src/apache-2/mod_rivet.c Tue Sep  6 21:33:45 2011
@@ -15,6 +15,7 @@
    limitations under the License.
 */
 
+/* $Id$ */
 
 /* Rivet config */
 #ifdef HAVE_CONFIG_H
@@ -451,7 +452,7 @@ Rivet_ParseExecFile(TclWebRequest *req, 
                     rsc->objCacheList[ct]);
             if (delEntry != NULL) {
                 Tcl_DecrRefCount((Tcl_Obj *)Tcl_GetHashValue(delEntry));
-        }
+            }
             Tcl_DeleteHashEntry(delEntry);
 
             free(rsc->objCacheList[ct]);
@@ -1390,8 +1391,7 @@ Rivet_ChildHandlers(server_rec *s, int i
     for (sr = s; sr; sr = sr->next)
     {
         rsc = RIVET_SERVER_CONF(sr->module_config);
-        function = init ? rsc->rivet_child_init_script :
-            rsc->rivet_child_exit_script;
+        function = init ? rsc->rivet_child_init_script : rsc->rivet_child_exit_script;
 
         if (!init && sr == s) {
             Tcl_Preserve(rsc->server_interp);
@@ -1399,10 +1399,11 @@ Rivet_ChildHandlers(server_rec *s, int i
 
         /* Execute it if it exists and it's the top level, separate
          * virtual interps are turned on, or it's different than the
-         * main script. */
-        if(function &&
-                ( sr == s || rsc->separate_virtual_interps ||
-                  function != parentfunction))
+         * main script. 
+         */
+
+        if  (function &&
+             ( sr == s || rsc->separate_virtual_interps || function != parentfunction))
         {
             Tcl_Preserve (rsc->server_interp);
             if (Tcl_EvalObjEx(rsc->server_interp,function, 0) != TCL_OK) {
@@ -1487,6 +1488,7 @@ Rivet_CreateTclInterp (server_rec* s)
                 "Error in Tcl_CreateInterp, aborting\n");
         exit(1);
     }
+
     if (Tcl_Init(interp) == TCL_ERROR)
     {
         ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
@@ -1674,8 +1676,8 @@ Rivet_SendContent(request_rec *r)
     static Tcl_Obj  *request_cleanup = NULL;
 
     rivet_interp_globals *globals = NULL;
-    rivet_server_conf   *rsc = NULL;
-    rivet_server_conf   *rdc;
+    rivet_server_conf    *rsc = NULL;
+    rivet_server_conf    *rdc;
 
     ctype = Rivet_CheckType(r);  
     if (ctype == CTYPE_NOT_HANDLED) {
@@ -1713,10 +1715,8 @@ Rivet_SendContent(request_rec *r)
     if (r->finfo.filetype == 0)
     {
         ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, r->server,
-                "File does not exist: %s",
-                (r->path_info
-                 ? (char*)apr_pstrcat(r->pool, r->filename, r->path_info, NULL)
-                 : r->filename));
+                        "File does not exist: %s",
+        (r->path_info ? (char*)apr_pstrcat(r->pool, r->filename, r->path_info, NULL) : r->filename));
         retval = HTTP_NOT_FOUND;
         goto sendcleanup;
     }
@@ -1729,13 +1729,16 @@ Rivet_SendContent(request_rec *r)
 //    apr_cpystrn(error, DEFAULT_ERROR_MSG, sizeof(error));
 //    apr_cpystrn(timefmt, DEFAULT_TIME_FORMAT, sizeof(timefmt));
 
-    /* This one is the big catch when it comes to moving towards
-       Apache 2.0, or one of them, at least. */
+    /* 
+     * This one is the big catch when it comes to moving towards
+     * Apache 2.0, or one of them, at least.
+     */
+
     if (Rivet_chdir_file(r->filename) < 0)
     {
         /* something went wrong doing chdir into r->filename, we are not specific
-        at this. We simply emit an internal server error and print a log message
-        */
+         * at this. We simply emit an internal server error and print a log message
+         */
         ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, r->server, 
                     "Error accessing %s, could not chdir into directory", r->filename);
 
@@ -1752,6 +1755,7 @@ Rivet_SendContent(request_rec *r)
         request_init = Tcl_NewStringObj("::Rivet::initialize_request\n", -1);
         Tcl_IncrRefCount(request_init);
     }
+
     if (Tcl_EvalObjEx(interp, request_init, 0) == TCL_ERROR)
     {
         ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server,

Propchange: tcl/rivet/trunk/src/apache-2/mod_rivet.c
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: tcl/rivet/trunk/src/apache-2/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/apache-2/rivetCore.c?rev=1165867&r1=1165866&r2=1165867&view=diff
==============================================================================
--- tcl/rivet/trunk/src/apache-2/rivetCore.c (original)
+++ tcl/rivet/trunk/src/apache-2/rivetCore.c Tue Sep  6 21:33:45 2011
@@ -17,7 +17,7 @@
    limitations under the License.
 */
 
-/* $Id: rivetCore.c,v 1.45 2005/08/21 15:31:38 davidw Exp $ */
+/* $Id$ */
 
 /* Rivet config */
 #ifdef HAVE_CONFIG_H
@@ -42,14 +42,15 @@
 #include <string.h>
 #include <stdio.h>
 #include <apr_errno.h>
+#include <apr_strings.h>
 
 #include "apache_request.h"
 #include "mod_rivet.h"
 #include "rivet.h"
 #include "TclWeb.h"
 
-#define ENV_ARRAY_NAME "env"
-#define HEADERS_ARRAY_NAME "headers"
+#define ENV_ARRAY_NAME     "::request::env"
+#define HEADERS_ARRAY_NAME "::request::headers"
 #define COOKIES_ARRAY_NAME "cookies"
 
 extern module rivet_module;
@@ -75,17 +76,64 @@ extern char* TclWeb_GetRawPost (TclWebRe
 
 TCL_CMD_HEADER( Rivet_MakeURL )
 {
-    Tcl_Obj *result = NULL;
-    rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
+    Tcl_Obj*                result  = NULL;
+    rivet_interp_globals*   globals = Tcl_GetAssocData(interp,"rivet",NULL);
+    char*                   url_target_name;
+    int                     target_length;
 
-    if (objc != 2)
+    if (objc > 2)
     {
 	Tcl_WrongNumArgs(interp, 1, objv, "filename");
 	return TCL_ERROR;
     }
-    result = Tcl_NewObj();
-    TclWeb_MakeURL(result, Tcl_GetString(objv[1]), globals->req);
+
+    if (objc == 1)
+    {
+        url_target_name = TclWeb_GetEnvVar (globals->req,"SCRIPT_NAME");
+    }
+    else
+    {
+        url_target_name = Tcl_GetStringFromObj(objv[1],&target_length);
+
+        // we check the first character for a '/' (absolute path)
+        // If we are dealing with a relative path we prepend it with
+        // the SCRIPT_NAME environment variable
+
+        if (url_target_name[0] != '/')
+        {
+            /* relative path */
+            char* script_name = TclWeb_GetEnvVar (globals->req,"SCRIPT_NAME");
+            int   script_name_l = strlen(script_name);
+
+            // regardless the reason for a SCRIPT_NAME being undefined we
+            // prevent a segfault and we revert the behavior of makeurl
+            // to the case of an absolute path
+
+            if (script_name_l > 0)
+            {
+                // script name may have the form a directory path (and mod_rewrite 
+                // could have mapped it to a .tcl or .rvt script
+                
+                if (script_name[script_name_l-1] == '/')
+                {
+                    url_target_name = apr_pstrcat(globals->req->req->pool,script_name,url_target_name,NULL);
+                }
+                else
+                {
+                    url_target_name = apr_pstrcat(globals->req->req->pool,script_name,"/",url_target_name,NULL);
+                }
+            }
+            else
+            {
+                url_target_name = apr_pstrcat(globals->req->req->pool,"/",url_target_name,NULL);
+            }
+        }
+    }
+
+    result = Tcl_NewObj();   
+    TclWeb_MakeURL(result, url_target_name, globals->req);
     Tcl_SetObjResult(interp, result);
+
     return TCL_OK;
 }
 

Propchange: tcl/rivet/trunk/src/apache-2/rivetCore.c
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org