tcl-websh-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@dedasys.com (David N. Welton)
Subject new committers, big patch
Date Tue, 20 Nov 2001 11:08:59 GMT

Brian has taken the time to add Simon Hefti and Ronnie Brunner as
committers to the Apache Tcl project.  Good news:-)

I have a large patch, which I will post here, with commentary.

Index: src/generic/cfg.c

These changes regard making the cmdurltimestamp a 'global' option.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4725

===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/cfg.c,v
retrieving revision 1.3
diff -u -r1.3 cfg.c
--- src/generic/cfg.c	2001/10/25 17:50:13	1.3
+++ src/generic/cfg.c	2001/11/20 10:07:59
@@ -124,20 +124,22 @@
 	NULL
     };
 
-    static char *subCmd1[] = { "uploadfilesize",
-	"encryptchain",
-	"decryptchain",
-	"cmdparam",
-	"timeparam",
-	"putxmarkup",
-	"logsubst",
-	"version",
-	"copyright",
-	NULL
+    static char *subCmd1[] = { "uploadfilesize",			       
+			       "encryptchain",
+			       "decryptchain",
+			       "cmdparam",
+			       "timeparam",
+			       "putxmarkup",
+			       "logsubst",
+			       "version",
+			       "copyright",
+			       "cmdurltimestamp",
+			       NULL
     };
 
     enum subCmd1
-    { UPLOADFILESIZE,
+    { 
+	UPLOADFILESIZE,
 	ENCRYPTCHAIN,
 	DECRYPTCHAIN,
 	CMDTAG,
@@ -145,7 +147,8 @@
 	PUTXMARKUP,
 	LOGSUBST,
 	WEBSHVERSION,
-	WEBSHCOPYRIGHT
+	WEBSHCOPYRIGHT,
+	CMDURLTIMESTAMP
     };
 
 
@@ -403,6 +406,42 @@
 			     NULL);
 	    return TCL_OK;
 	}
+    case CMDURLTIMESTAMP: {
+	int tmpbool = 1;
+	WebAssertData(interp, cfgData->requestData,
+		      "web::config cmdurltimestamp", TCL_ERROR);
+	
+	WebAssertData(interp, cfgData->requestData->cmdUrlTimestamp,
+			  "web::config cmdurltimestamp", TCL_ERROR);
+	Tcl_SetObjResult(interp,
+			 Tcl_DuplicateObj(cfgData->requestData->cmdUrlTimestamp));
+	switch (objc) {
+	case 2:
+	    return TCL_OK;
+	    break;
+	case 3:
+	    if (Tcl_GetBooleanFromObj(interp, objv[2], &tmpbool) ==
+		TCL_ERROR) {
+		LOG_MSG(interp, WRITE_LOG | SET_RESULT, __FILE__,
+			__LINE__, "web::config cmdurltimestamp",
+			WEBLOG_ERROR,
+			"web::config cmdurltimestamp only accepts boolean but ",
+			"got \"", Tcl_GetString(objv[2]), "\"", NULL);
+		return TCL_ERROR;
+	    }
+	    WebDecrOldIncrNew(cfgData->requestData->cmdUrlTimestamp,
+			      Tcl_DuplicateObj(objv[2]));
+	    return TCL_OK;
+	    break;
+	default:
+	    LOG_MSG(interp, WRITE_LOG | SET_RESULT,
+		    __FILE__, __LINE__,
+		    "web::config cmdurltimestamp", WEBLOG_INFO,
+		    "usage: web::config cmdurltimestamp ?boolean?", NULL);
+	    return TCL_ERROR;
+	}
+	return TCL_OK;
+    }
     default:
 	break;
     }

Index: src/generic/dispatch.c

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4719

This propogates the error generated in parsePostData.  This causes
websh to behave differently, making it fail some tests it otherwise
passes.

===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/dispatch.c,v
retrieving revision 1.3
diff -u -r1.3 dispatch.c
--- src/generic/dispatch.c	2001/10/25 17:50:13	1.3
+++ src/generic/dispatch.c	2001/11/20 10:08:00
@@ -138,24 +138,31 @@
 		    /* ------------------------------------------------------------------
 		     * -postdata channel
 		     * --------------------------------------------------------------- */
-		    parsePostData(interp, objv[idx1 + 1], NULL, NULL,
-				  requestData);
+		    if (parsePostData(interp, objv[idx1 + 1], NULL, NULL,
+				      requestData) == TCL_ERROR) {
+			return TCL_ERROR;
+		    }
+
 		    break;
 		case 3:
 		    /* ------------------------------------------------------------------
 		     * -postdata channel length
 		     * --------------------------------------------------------------- */
 		    /* log is handled by parsePostData */
-		    parsePostData(interp, objv[idx1 + 1], objv[idx1 + 2],
-				  NULL, requestData);
+		    if (parsePostData(interp, objv[idx1 + 1], objv[idx1 + 2],
+				      NULL, requestData) == TCL_ERROR) {
+			return TCL_ERROR;
+		    }
 		    break;
 		case 4:
 		    /* ------------------------------------------------------------------
 		     * -postdata channel length type
 		     * --------------------------------------------------------------- */
 		    /* log is handled by parsePostData */
-		    parsePostData(interp, objv[idx1 + 1], objv[idx1 + 2],
-				  objv[idx1 + 3], requestData);
+		    if (parsePostData(interp, objv[idx1 + 1], objv[idx1 + 2],
+				      objv[idx1 + 3], requestData) == TCL_ERROR) {
+			return TCL_ERROR;
+		    }
 		    break;
 		default:
 		    Tcl_WrongNumArgs(interp, 1, objv,

Index: src/generic/request.c

More changes necessary to make cmdurltimestamp global.

===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/request.c,v
retrieving revision 1.3
diff -u -r1.3 request.c
--- src/generic/request.c	2001/10/25 17:50:13	1.3
+++ src/generic/request.c	2001/11/20 10:08:03
@@ -116,6 +116,8 @@
 
 	WebNewStringObjFromStringIncr(requestData->cmdTag, "cmd");
 	WebNewStringObjFromStringIncr(requestData->timeTag, "t");
+	requestData->cmdUrlTimestamp = Tcl_NewBooleanObj(1);
+	Tcl_IncrRefCount(requestData->cmdUrlTimestamp);
 
 	HashUtlAllocInit(requestData->request, TCL_STRING_KEYS);
 
@@ -175,6 +177,10 @@
     WebDecrRefCountIfNotNullAndSetNull(requestData->cmdTag);
     WebNewStringObjFromStringIncr(requestData->cmdTag, "cmd");
 
+    WebDecrRefCountIfNotNullAndSetNull(requestData->cmdUrlTimestamp);
+    requestData->cmdUrlTimestamp = Tcl_NewBooleanObj(1);
+    Tcl_IncrRefCount(requestData->cmdUrlTimestamp);
+
     requestData->requestIsInitialized = 0;
     return TCL_OK;
 }
@@ -232,7 +238,7 @@
 
 	WebDecrRefCountIfNotNull(requestData->cmdTag);
 	WebDecrRefCountIfNotNull(requestData->timeTag);
-
+	WebDecrRefCountIfNotNull(requestData->cmdUrlTimestamp);
 	destroyParamList(requestData->request);
 
 	WebDecrRefCountIfNotNull(requestData->upLoadFileSize);

Index: src/generic/request.h

More changes necessary to make cmdurltimestamp global.

===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/request.h,v
retrieving revision 1.3
diff -u -r1.3 request.h
--- src/generic/request.h	2001/10/25 17:50:13	1.3
+++ src/generic/request.h	2001/11/20 10:08:03
@@ -81,6 +81,8 @@
     /* default: cmd */
     Tcl_Obj *timeTag;		/* key to be used for param in URL (web::cmdurl) */
     /* default: t */
+    Tcl_Obj *cmdUrlTimestamp;   /* send timestamp with url's */
+    /* default: true */
     /* ............ */
     Tcl_HashTable *request;	/* everything from the request obj */
     /* e.g. server_port, server_name and so on */

Index: src/generic/url.c

More timestamp changes.

===================================================================
RCS file: /home/cvs/tcl-websh/src/generic/url.c,v
retrieving revision 1.3
diff -u -r1.3 url.c
--- src/generic/url.c	2001/10/25 17:50:13	1.3
+++ src/generic/url.c	2001/11/20 10:08:05
@@ -489,6 +489,7 @@
     int plistLen = 0;
     int i = 0;
     int flag = 0;
+    int bool = 1;
     int urlformat = 0;
     Tcl_Obj *urlFmt = NULL;
     Tcl_Obj *res = NULL;
@@ -535,6 +536,10 @@
     }
 
     if (argIndexOfKey(objc, objv, params[NOTIMESTAMP]) > 0)
+	flag = (flag | WEB_URL_NOTIMESTAMP);
+
+    Tcl_GetBooleanFromObj(interp, urlData->requestData->cmdUrlTimestamp, &bool);
+    if (bool == 0)
 	flag = (flag | WEB_URL_NOTIMESTAMP);
 
     /* --------------------------------------------------------------------------

Index: src/tests/cfg.test

Fix wrong subcommand test to include cmdurltimestamp.

===================================================================
RCS file: /home/cvs/tcl-websh/src/tests/cfg.test,v
retrieving revision 1.2
diff -u -r1.2 cfg.test
--- src/tests/cfg.test	2001/10/25 11:04:29	1.2
+++ src/tests/cfg.test	2001/11/20 10:08:05
@@ -26,7 +26,7 @@
 test cfg-1.1 {wrong subcommand} {
     catch {web::config foo bar} msg
     set msg
-} {bad subcommand "foo": must be uploadfilesize, encryptchain, decryptchain, cmdparam, timeparam,
putxmarkup, logsubst, version, or copyright}
+} {bad subcommand "foo": must be uploadfilesize, encryptchain, decryptchain, cmdparam, timeparam,
putxmarkup, logsubst, version, copyright, or cmdurltimestamp}
 
 
 test cfg-1.2 {invalid value} {

Index: src/tests/cmdurl.test




===================================================================
RCS file: /home/cvs/tcl-websh/src/tests/cmdurl.test,v
retrieving revision 1.2
diff -u -r1.2 cmdurl.test
--- src/tests/cmdurl.test	2001/10/25 11:04:29	1.2
+++ src/tests/cmdurl.test	2001/11/20 10:08:06
@@ -378,6 +378,25 @@
     set res
 } "v319 {} {}"
 
+test cmdurl-3.191 {no time and no cmd tag} {
+
+    cleanParam    
+
+    web::config cmdurltimestamp 0
+    web::config timeparam "t"
+    web::config cmdparam "cmd"
+
+    set url [web::cmdurl "" k3191 v3191]
+    set tmp [web::querystring::getfromurl $url]
+    web::dispatch -cmd "" -postdata "" -querystring $tmp
+    set res [web::param k3191]
+    lappend res [web::param t]
+    lappend res [web::param cmd]
+    unset url
+    unset tmp
+    set res
+} "v3191 {} {}"
+
 
 test cmdurl-3.20 {full web::param syntax for web::cmdurlcfg, all-in-one} {
 

Index: src/tests/dispatch.test

It's now necessary to catch errors, because the error is propogated.

===================================================================
RCS file: /home/cvs/tcl-websh/src/tests/dispatch.test,v
retrieving revision 1.2
diff -a -u -r1.2 dispatch.test
--- src/tests/dispatch.test     2001/10/25 11:04:29     1.2
+++ src/tests/dispatch.test     2001/11/20 10:51:30
@@ -134,7 +134,6 @@
     close $fileId
 }
 
-
 proc setAndParsePostDataFormData9 {} {
 
     cleanParam
@@ -401,7 +400,7 @@
     file delete "./formvar-multipart-formdata8.tst"
     file delete "./formvar-multipart-formdata9.tst"
 
-    puts "gonna delete $dispatchTestLogFilter, $dispatchTestLogDest" 
+    puts "will delete $dispatchTestLogFilter, $dispatchTestLogDest" 
     puts "filters are: [web::logfilter names]"
     puts "dests   are: [web::logdest names]"
 
@@ -580,9 +579,11 @@
 
     cleanParam
 
+    catch {
     web::dispatch -cmd "" -querystring "" \
         -postdata stdout 10 "multipart/form-data; boundary=xxx"
-    getLastCatchedLogMsg
+    } err
+    set err
 } {web::dispatch -postdata: channel "stdout" not open for reading}
 
 test dispatch-5.0b {parse multipart/form-data from stdout} {

Index: src/tests/request.test

Reset request, or else funny things happen...

===================================================================
RCS file: /home/cvs/tcl-websh/src/tests/request.test,v
retrieving revision 1.2
diff -u -r1.2 request.test
--- src/tests/request.test	2001/10/25 11:04:29	1.2
+++ src/tests/request.test	2001/11/20 10:08:17
@@ -27,6 +27,7 @@
     web::cmdurlcfg -unset
     web::formvar -unset
     web::param -unset
+    web::request -reset
 }
 
 # -----------------------------------------------------------------------------

Any comments or questions before I commit these?

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

Mime
View raw message