You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-cvs@tcl.apache.org by ro...@apache.org on 2002/11/26 18:52:36 UTC

cvs commit: tcl-websh/src/generic weboutint.c

ronnie      2002/11/26 09:52:36

  Modified:    src/tests script.test
               src/generic weboutint.c
  Log:
  - bug fix for web::putx and web::putxfile (patch by D. Welton)
  
  Revision  Changes    Path
  1.4       +40 -1     tcl-websh/src/tests/script.test
  
  Index: script.test
  ===================================================================
  RCS file: /home/cvs/tcl-websh/src/tests/script.test,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- script.test	25 Apr 2002 14:29:39 -0000	1.3
  +++ script.test	26 Nov 2002 17:52:36 -0000	1.4
  @@ -108,6 +108,45 @@
   } {0}
   
   
  +test script-evalfile-1.3 {web::putxfile and web::putx of 8-bit stuff} {
  +
  +    if {[info exists ws3_test_script_evalfile]} {
  +	unset ws3_test_script_evalfile
  +    }
  +    web::response -select \#ws3_test_script_evalfile
  +    web::response -sendheader 0
  +
  +    ## make a temp file with a test script
  +    set curTim [clock seconds]
  +    set fileName $curTim-[pid]-evalfile.tcl
  +    set fileId [open $fileName "w"]
  +    
  +    set text "�������"
  +    puts -nonewline $fileId $text
  +    close $fileId
  +
  +    ## now source it
  +    web::putxfile \#ws3_test_script_evalfile $fileName
  +
  +    ## add a test for include
  +    web::readfile $fileName f
  +    web::putx \#ws3_test_script_evalfile $f
  +
  +    ## and send $text directly
  +    web::putx $text
  +
  +    ## remove file
  +    file delete $fileName
  +
  +    set res [string compare $ws3_test_script_evalfile $text$text$text]
  +    if {$res != 0 } {
  +        puts "expected: $text."
  +        puts "found:    $ws3_test_script_evalfile."
  +    }
  +    set res
  +} {0}
  +
  +
   # -----------------------------------------------------------------------------
   # readfile
   # -----------------------------------------------------------------------------
  
  
  
  1.7       +3 -10     tcl-websh/src/generic/weboutint.c
  
  Index: weboutint.c
  ===================================================================
  RCS file: /home/cvs/tcl-websh/src/generic/weboutint.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- weboutint.c	11 Sep 2002 13:54:01 -0000	1.6
  +++ weboutint.c	26 Nov 2002 17:52:36 -0000	1.7
  @@ -417,7 +417,6 @@
   		    Tcl_Obj * in, const char *strstart, const char *strend)
   {
       Tcl_DString dstr;
  -    Tcl_DString convdstr;
       Tcl_Obj *tclo = NULL;
   
       int inLen;
  @@ -517,11 +516,6 @@
   	cur ++;
       }
   
  -    Tcl_ExternalToUtfDString(NULL,
  -			     Tcl_DStringValue(&dstr),
  -			     Tcl_DStringLength(&dstr),
  -			     &convdstr);
  -
       /* build up the web::put with the name of the channel. */
       if (begin) {
   	tclo = Tcl_NewStringObj("web::put \"", -1);
  @@ -529,15 +523,14 @@
   	tclo = Tcl_NewStringObj("", -1);
       }
   
  -    Tcl_AppendToObj(tclo, Tcl_DStringValue(&convdstr),
  -		    Tcl_DStringLength(&convdstr));
  +    Tcl_AppendToObj(tclo, Tcl_DStringValue(&dstr),
  +		    Tcl_DStringLength(&dstr));
   
       if (cntOpen < 1) {
   	Tcl_AppendToObj(tclo, "\"\n", 2);
       }
   
       Tcl_DStringFree(&dstr); 
  -    Tcl_DStringFree(&convdstr); 
       res = Tcl_EvalObjEx(interp, tclo, TCL_EVAL_DIRECT);
       return res;
   }
  
  
  

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


Re: cvs commit: tcl-websh/src/generic weboutint.c

Posted by "David N. Welton" <da...@dedasys.com>.
ronnie@apache.org writes:

Glad to see it worked.

>   +    ## make a temp file with a test script
>   +    set curTim [clock seconds]
>   +    set fileName $curTim-[pid]-evalfile.tcl
>   +    set fileId [open $fileName "w"]

Just FYI, there is a tcltest command to make temporary files that will
automatically be cleaned up (even if the script crashes halfway
through, for instance):

       tcltest::makeFile contents name ?directory?

although in this case it's really not worth bothering.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

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