You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_dtcl@tcl.apache.org by Valerio Gionco <va...@most.it> on 2001/06/04 11:54:59 UTC

Tcl error control - patch for mod_dtcl

I just noticed that mod_dtcl checks for errors (and prints
the error buffer to HTML) only when parsing
inline scripts. Since we use standalone Tcl scripts, I've
moved the code block that performs the execution and
the check (if result == TCL_ERROR then blabla...) in
a function called execute_and_check().

Here are the patches for mod_dtcl.c and mod_dtcl.h,
against mod_dtcl 0.11.0.

Regards,

--
Valerio Gionco   [valerio@most.it]
MOST s.r.l.      Via Bezzecca, 9 - 10131 Torino
************************************************************************
            "Life's not fair, but the root password helps."

-----------------diff mod_dtcl.h mod_dtcl_patched.h
------------------------------
59a60
> int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec
*r);
66d66
<
-----------------diff  mod_dtcl.c
mod_dtcl_patched.c------------------------------
428c428
<       Tcl_EvalObj(interp, (cmdObjPtr));
---
>       execute_and_check(interp, (cmdObjPtr), r);
430c430
<       Tcl_EvalObj(interp, (Tcl_Obj *)Tcl_GetHashValue(entry));
---
>       execute_and_check(interp, (cmdObjPtr), r);
641a642,652
>     return(execute_and_check(interp, outbuf, r));
> }
>
> /* Calls Tcl_EvalObj() and checks for errors; prints the error buffer
if any. */
> int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec
*r)
> {
>  char *errorinfo;
>  dtcl_server_conf *dsc = NULL;
>
>  dsc = (dtcl_server_conf *)
ap_get_module_config(r->server->module_config, &dtcl_module);
>
643,658c654,669
<     {
<       print_headers(global_rr);
<       flush_output_buffer(global_rr);
<       if (dsc->dtcl_error_script)
<       {
<           if (Tcl_EvalObj(interp, dsc->dtcl_error_script) ==
TCL_ERROR)
<               print_error(r, 1, "<b>Tcl_ErrorScript failed!</b>");
<       } else {
<           /* default action  */
<           errorinfo = Tcl_GetVar(interp, "errorInfo", 0);
<           print_error(r, 0, errorinfo);
<           print_error(r, 1, "<p><b>OUTPUT BUFFER:</b></p>");
<           print_error(r, 0, Tcl_GetStringFromObj(outbuf, (int
*)NULL));
<       }
< /*                "</pre><b>OUTPUT BUFFER</b><pre>\n",
<                   Tcl_GetStringFromObj(outbuf, (int *)NULL));  */
---
>     {
>         print_headers(global_rr);
>         flush_output_buffer(global_rr);
>         if (dsc->dtcl_error_script)
>         {
>              if (Tcl_EvalObj(interp, dsc->dtcl_error_script) ==
TCL_ERROR)
>                 print_error(r, 1, "<b>Tcl_ErrorScript failed!</b>");
>         } else {
>             /* default action  */
>             errorinfo = Tcl_GetVar(interp, "errorInfo", 0);
>             print_error(r, 0, errorinfo);
>             print_error(r, 1, "<p><b>OUTPUT BUFFER:</b></p>");
>             print_error(r, 0, Tcl_GetStringFromObj(outbuf, (int
*)NULL));
>         }
> /*                  "</pre><b>OUTPUT BUFFER</b><pre>\n",
>                     Tcl_GetStringFromObj(outbuf, (int *)NULL));  */
660,662c671,673
<       /* We make sure to flush the output if buffer_add was the only
output */
<       print_headers(global_rr);
<       flush_output_buffer(global_rr);
---
>         /* We make sure to flush the output if buffer_add was the only
output */
>         print_headers(global_rr);
>         flush_output_buffer(global_rr);
665a677,678
>
>

Re: Tcl error control - patch for mod_dtcl

Posted by "David N. Welton" <da...@apache.org>.
> -----------------diff mod_dtcl.h mod_dtcl_patched.h
> ------------------------------
> 59a60
> > int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec
> *r);
> 66d66
> <

Just a reminder - the best way to do patches is with CVS:

cd tcl-moddtcl/
cvs diff -u > ../mod_dtcl.diff
         ^^

This is a much nicer format.

Thanks,
-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/
         Work: http://www.innominate.com/