You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2015/02/03 00:12:47 UTC

svn commit: r1656602 - in /tcl/rivet/branches/2.2: ChangeLog src/apache-2/mod_rivet.c src/config/TclWebapache.c src/rivetcmds/rivetCore.c

Author: mxmanghi
Date: Mon Feb  2 23:12:47 2015
New Revision: 1656602

URL: http://svn.apache.org/r1656602
Log:
    * src/rivetcmds/rivetCore.c: in Rivet_Parse returned value of 
    Rivet_ParseExecFile is propagated up to the caller. Probably unnecessary
    now, but just in case we want to have special handling of TCL_CONTINUE or
    TCL_BREAK
    * src/apache-2/mod_rivet.c: moving call to after_every_script out
    of Rivet_ParseExecFile and into Rivet_SendContent. Any call to 
    ::rivet::abort_page is now trapped by abort_script
    * src/config/TclWebapache.c: if charset is set in the configuration
    then it's set in the headers just before HTTP headers are sent (moved
    from mod_rivet.c


Modified:
    tcl/rivet/branches/2.2/ChangeLog
    tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c
    tcl/rivet/branches/2.2/src/config/TclWebapache.c
    tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c

Modified: tcl/rivet/branches/2.2/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/ChangeLog?rev=1656602&r1=1656601&r2=1656602&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/ChangeLog (original)
+++ tcl/rivet/branches/2.2/ChangeLog Mon Feb  2 23:12:47 2015
@@ -1,3 +1,15 @@
+2015-02-02 Massimo Manghi <mx...@apache.org>
+    * src/rivetcmds/rivetCore.c: in Rivet_Parse returned value of 
+    Rivet_ParseExecFile is propagated up to the caller. Probably unnecessary
+    now, but just in case we want to have special handling of TCL_CONTINUE or
+    TCL_BREAK
+    * src/apache-2/mod_rivet.c: moving call to after_every_script out
+    of Rivet_ParseExecFile and into Rivet_SendContent. Any call to 
+    ::rivet::abort_page is now trapped by abort_script
+    * src/config/TclWebapache.c: if charset is set in the configuration
+    then it's set in the headers just before HTTP headers are sent (moved
+    from mod_rivet.c
+
 2015-01-12 Massimo Manghi <mx...@apache.org>
     * tests/redirect.test,channel.test: adding tests for new features of Rivet 2.2.1
 

Modified: tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c?rev=1656602&r1=1656601&r2=1656602&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/branches/2.2/src/apache-2/mod_rivet.c Mon Feb  2 23:12:47 2015
@@ -328,15 +328,19 @@ Rivet_InitServerVariables( Tcl_Interp *i
 static int
 Rivet_ExecuteAndCheck(Tcl_Interp *interp, Tcl_Obj *tcl_script_obj, request_rec *req)
 {
-    rivet_server_conf *conf = Rivet_GetConf(req);
-    rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
+    int                     result;
+    rivet_server_conf*      conf = Rivet_GetConf(req);
+    rivet_interp_globals*   globals = Tcl_GetAssocData(interp, "rivet", NULL);
 
     Tcl_Preserve (interp);
-    if ( Tcl_EvalObjEx(interp, tcl_script_obj, 0) == TCL_ERROR ) {
-        Tcl_Obj *errscript;
-        Tcl_Obj *errorCodeListObj;
-        Tcl_Obj *errorCodeElementObj;
-        char *errorCodeSubString;
+    result = Tcl_EvalObjEx(interp, tcl_script_obj, 0);
+
+    if (result == TCL_ERROR) {
+
+        Tcl_Obj*    errscript;
+        Tcl_Obj*    errorCodeListObj;
+        Tcl_Obj*    errorCodeElementObj;
+        char*       errorCodeSubString;
 
         /* There was an error, see if it's from Rivet and it was caused
          * by abort_page.
@@ -376,7 +380,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
                     {
                         CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
                         TclWeb_PrintError("<b>Rivet AbortScript failed!</b>",1,globals->req);
-                        TclWeb_PrintError( errorinfo, 0, globals->req );
+                        TclWeb_PrintError(errorinfo,0,globals->req);
                     }
                 }
                 goto good;
@@ -386,7 +390,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
         Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( tcl_script_obj, NULL ),TCL_GLOBAL_ONLY );
 
         /* If we don't have an error script, use the default error handler. */
-        if (conf->rivet_error_script ) {
+        if (conf->rivet_error_script) {
             errscript = conf->rivet_error_script;
         } else {
             errscript = conf->rivet_default_error_script;
@@ -404,27 +408,13 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
         Tcl_DecrRefCount(errscript);
     }
 
-    /* Make sure to flush the output if buffer_add was the only output */
 good:
     
-    if (conf->after_every_script) {
-        if (Tcl_EvalObjEx(interp,conf->after_every_script,0) == TCL_ERROR)
-        {
-            CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
-            TclWeb_PrintError("<b>Rivet AfterEveryScript failed!</b>",1,globals->req);
-            TclWeb_PrintError( errorinfo, 0, globals->req );
-        }
-    }
-
-    if (!globals->req->headers_set && (globals->req->charset != NULL)) {
-        TclWeb_SetHeaderType (apr_pstrcat(globals->req->req->pool,"text/html;",globals->req->charset,NULL),globals->req);
-    }
-
     /* Tcl_Flush moved to the end of Rivet_SendContent */
 
     Tcl_Release(interp);
 
-    return TCL_OK;
+    return result;
 }
 
 /*
@@ -605,12 +595,10 @@ Rivet_ParseExecFile(TclWebRequest *req,
     }
 
     rsc->user_scripts_updated = 0;
-    {
-        int res = 0;
-        res = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
-        Tcl_DecrRefCount(outbuf);
-        return res;
-    }
+    result = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
+    Tcl_DecrRefCount(outbuf);
+
+    return result;
 }
 
 /*
@@ -629,7 +617,7 @@ Rivet_ParseExecFile(TclWebRequest *req,
 int
 Rivet_ParseExecString (TclWebRequest* req, Tcl_Obj* inbuf)
 {
-    int res = 0;
+    int result;
     Tcl_Obj* outbuf = Tcl_NewObj();
     Tcl_Interp *interp = req->interp;
 
@@ -644,10 +632,10 @@ Rivet_ParseExecString (TclWebRequest* re
 
     Tcl_AppendToObj(outbuf, "\n", -1);
 
-    res = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
+    result = Rivet_ExecuteAndCheck(interp, outbuf, req->req);
     Tcl_DecrRefCount(outbuf);
 
-    return res;
+    return result;
 }
 
 static void
@@ -1505,8 +1493,19 @@ Rivet_SendContent(request_rec *r)
                      Tcl_GetVar(interp, "errorInfo", 0));
     }
 
+    /* We execute also the AfterEveryScript if one was set */
+
+    if (rsc->after_every_script) {
+        if (Tcl_EvalObjEx(interp,rsc->after_every_script,0) == TCL_ERROR)
+        {
+            CONST84 char *errorinfo = Tcl_GetVar( interp, "errorInfo", 0 );
+            TclWeb_PrintError("<b>Rivet AfterEveryScript failed!</b>",1,globals->req);
+            TclWeb_PrintError( errorinfo, 0, globals->req );
+        }
+    }
+
     /* Reset globals */
-    Rivet_CleanupRequest( r );
+    Rivet_CleanupRequest(r);
 
     retval = OK;
 sendcleanup:

Modified: tcl/rivet/branches/2.2/src/config/TclWebapache.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/config/TclWebapache.c?rev=1656602&r1=1656601&r2=1656602&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/config/TclWebapache.c (original)
+++ tcl/rivet/branches/2.2/src/config/TclWebapache.c Mon Feb  2 23:12:47 2015
@@ -135,7 +135,7 @@ TclWeb_SetHeaderType(char *header, TclWe
     if (req->headers_set)
         return TCL_ERROR;
 
-//    req->req->content_type = (char *) apr_pstrdup(req->req->pool, header);
+//  req->req->content_type = (char *) apr_pstrdup(req->req->pool, header);
 
     ap_set_content_type(req->req,apr_pstrdup(req->req->pool, header));
     req->headers_set = 1;
@@ -149,9 +149,16 @@ TclWeb_PrintHeaders(TclWebRequest *req)
     if (req->headers_printed)
         return TCL_ERROR;
 
+    /* Let's set the charset in the headers if one was set in the configuration  */
+
+    if (!req->headers_set && (req->charset != NULL))
+    {
+        TclWeb_SetHeaderType(apr_pstrcat(req->req->pool,"text/html;",req->charset,NULL),req);
+    }
+
     if (req->headers_set == 0)
     {
-        TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, req);
+        TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE,req);
     }
     
     /*

Modified: tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c?rev=1656602&r1=1656601&r2=1656602&view=diff
==============================================================================
--- tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c (original)
+++ tcl/rivet/branches/2.2/src/rivetcmds/rivetCore.c Mon Feb  2 23:12:47 2015
@@ -241,11 +241,7 @@ TCL_CMD_HEADER( Rivet_Parse )
         return TCL_ERROR;
     }
 
-    if (Rivet_ParseExecFile(globals->req, filename, 0) == TCL_OK) {
-        return TCL_OK;
-    } else {
-        return TCL_ERROR;
-    }
+    return Rivet_ParseExecFile(globals->req, filename, 0); 
 }
 
 /*



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