You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2018/11/19 22:46:32 UTC

[tcl-rivet] branch 2.3 updated: backporting fixes about ::rivet::var_qs and ::rivet::var_post, backporting also src/librivet/rivetPkgInit.c

This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a commit to branch 2.3
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git


The following commit(s) were added to refs/heads/2.3 by this push:
     new 60e4232  backporting fixes about ::rivet::var_qs and ::rivet::var_post, backporting also src/librivet/rivetPkgInit.c
60e4232 is described below

commit 60e42322831260ae9dc03e6bd19907494b2887ff
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Mon Nov 19 23:46:09 2018 +0100

    backporting fixes about ::rivet::var_qs and ::rivet::var_post, backporting also src/librivet/rivetPkgInit.c
---
 .gitignore                  | 31 +++++++++++++++++++++++++++++++
 ChangeLog                   |  9 +++++++++
 Makefile.in                 | 17 ++++++++++-------
 VERSION                     |  2 +-
 configure.ac                |  2 +-
 src/librivet/rivetPkgInit.c | 42 +++++++++++++++++-------------------------
 src/rivetcmds/rivetCore.c   | 21 +++++++++++++++++++++
 tests/fqrivet_var.tcl       | 40 ++++++++++++++++++++++++++++++++++++++++
 tests/post.test             | 23 +++++++++++++++++++++++
 9 files changed, 153 insertions(+), 34 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..36d207d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,31 @@
+Makefile.in
+doc/Makefile.in
+src/Makefile.in
+aclocal.m4
+autom4te.cache/
+configure
+Makefile
+_configs.sed
+config.h
+config.h.in
+config.log
+config.status
+rivet_config.h
+doc/Makefile
+doc/convert_examples.tcl
+doc/graphics
+doc/html/
+libtool
+src/Makefile
+src/librivet/.deps/
+src/mod_rivet_ng/.deps/
+src/parser/.deps/
+src/request/.deps/
+stamp-h1
+*~
+*.libs/
+*.dirstamp
+*.lo
+*.la
+*.swp
+tags
diff --git a/ChangeLog b/ChangeLog
index 31f9945..c7e98d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-19 Massimo Manghi <mx...@apache.org>
+    * VERSION,configure.ac: bumping version to 2.3.7
+    * src/rivetcmds/rivetCore.c: fix wrong discrimination between
+    ::rivet::var_qs,::rivet::var_post that lead to overlapping
+    functionalities
+    * src/librivet/rivetPkgInit.c: merging from 3.0 new namespace
+    determination that makes librivet independent from the module
+    globals
+
 2018-04-01 Massimo Manghi <mx...@apache.org>
     * VERSION,configure.ac: bumping version to 2.3.6
 
diff --git a/Makefile.in b/Makefile.in
index c92760a..e3d7a6d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@
 #
 # top-level Makefile.am for Apache Rivet: gets turned into a Makefile.in by automake
 #
-# $Id: Makefile.am 1517859 2013-08-27 16:08:31Z mxmanghi $
+# $Id$
 #
 # 2007/12/25: Added target uninistall-local that removes the tcl stuff (mxmanghi)
 # 2010/06/22: target instal-data-local searches for pkgIndex.tcl files and deletes them
@@ -149,7 +149,7 @@ am__recursive_targets = \
   $(RECURSIVE_CLEAN_TARGETS) \
   $(am__extra_recursive_targets)
 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
-	cscope distdir dist dist-all distcheck
+	cscope distdir distdir-am dist dist-all distcheck
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
 	$(LISP)config.h.in
 # Read a list of newline-separated strings from the standard input,
@@ -456,8 +456,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' $(SHELL) ./config.status'; \
 	    $(SHELL) ./config.status;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -601,7 +601,10 @@ distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	$(am__remove_distdir)
 	test -d "$(distdir)" || mkdir "$(distdir)"
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
diff --git a/VERSION b/VERSION
index e75da3e..00355e2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.6
+2.3.7
diff --git a/configure.ac b/configure.ac
index 5cd2e34..85b1440 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
 # so you can encode the package version directly into the source files.
 #-----------------------------------------------------------------------
 
-AC_INIT([Rivet],[2.3.6])
+AC_INIT([Rivet],[2.3.7])
 TEA_INIT([3.9])
 
 # we are storing here the configure command line, as recursive
diff --git a/src/librivet/rivetPkgInit.c b/src/librivet/rivetPkgInit.c
index d96cf48..17fd31e 100644
--- a/src/librivet/rivetPkgInit.c
+++ b/src/librivet/rivetPkgInit.c
@@ -23,8 +23,14 @@
 #endif
 
 #include <tcl.h>
+/* Function prototypes are defined with EXTERN. Since we are in the same DLL,
+ * no need to keep this extern... */
+#ifdef EXTERN
+#   undef EXTERN
+#   define EXTERN
+#endif /* EXTERN */
 #include "rivet.h"
-#include "mod_rivet.h"
+//#include "mod_rivet.h"
 
 /*-----------------------------------------------------------------------------
  * Rivet_GetNamespace --
@@ -49,25 +55,16 @@
 
 #if RIVET_NAMESPACE_EXPORT == 1
 
-Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp)
+Tcl_Namespace* 
+Rivet_GetNamespace( Tcl_Interp* interp)
 {
-    rivet_interp_globals *globals; 
     Tcl_Namespace *rivet_ns;
 
-    globals = Tcl_GetAssocData(interp, "rivet", NULL);
-    if (globals != NULL)
+    rivet_ns = Tcl_FindNamespace(interp,RIVET_NS,NULL,TCL_GLOBAL_ONLY);
+    if (rivet_ns == NULL) 
     {
-        rivet_ns = globals->rivet_ns;
-    }
-    else
-    {
-//      fprintf(stderr,"no Associated data found, running standalone\n");
-        rivet_ns = Tcl_FindNamespace(interp, RIVET_NS, NULL, TCL_GLOBAL_ONLY);
-        if (rivet_ns == NULL) {
-            /* The namespace does not exist, create it */
-            rivet_ns = Tcl_CreateNamespace (interp, RIVET_NS, NULL,
-                                            (Tcl_NamespaceDeleteProc *)NULL);
-        }
+        rivet_ns = Tcl_CreateNamespace (interp,RIVET_NS,NULL,
+                                        (Tcl_NamespaceDeleteProc *)NULL);
     }
 
     return rivet_ns;
@@ -86,12 +83,9 @@ Tcl_Namespace* Rivet_GetNamespace( Tcl_Interp* interp)
  *-----------------------------------------------------------------------------
  */
 
-int
+DLLEXPORT int
 Rivetlib_Init( Tcl_Interp *interp )
 {
-#if RIVET_NAMESPACE_EXPORT == 1
-    //Tcl_Namespace *rivet_ns; 
-#endif
 
 #ifdef USE_TCL_STUBS
     if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { 
@@ -104,16 +98,13 @@ Rivetlib_Init( Tcl_Interp *interp )
     Rivet_InitList (interp);
     Rivet_InitCrypt(interp);
     Rivet_InitWWW  (interp);
-#if RIVET_NAMESPACE_EXPORT == 1
-    //rivet_ns = Rivet_GetNamespace(interp);
-    //Tcl_Export(interp,rivet_ns,"*",0);
-#endif
 
     return Tcl_PkgProvide( interp, RIVETLIB_TCL_PACKAGE, RIVET_VERSION );
 }
 
 /*-----------------------------------------------------------------------------
  * Rivetlib_SafeInit --
+ *
  *   Install the commands provided by librivet that are believed to be
  *   safe for use in safe interpreters, into a safe interpreter.
  *
@@ -124,9 +115,10 @@ Rivetlib_Init( Tcl_Interp *interp )
  *-----------------------------------------------------------------------------
  */
 
-int
+DLLEXPORT int
 Rivetlib_SafeInit( Tcl_Interp *interp )
 {
+
 #ifdef USE_TCL_STUBS
     if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { 
 #else
diff --git a/src/rivetcmds/rivetCore.c b/src/rivetcmds/rivetCore.c
index 2e2dd29..2d31dc3 100644
--- a/src/rivetcmds/rivetCore.c
+++ b/src/rivetcmds/rivetCore.c
@@ -560,6 +560,7 @@ TCL_CMD_HEADER ( Rivet_LoadHeaders )
 TCL_CMD_HEADER ( Rivet_Var )
 {
     char *cmd;
+    char *p;
     char *command;
     Tcl_Obj *result = NULL;
     int source;
@@ -578,6 +579,26 @@ TCL_CMD_HEADER ( Rivet_Var )
     result = Tcl_NewObj();
 
     /* determine if var_qs, var_post or var was called */
+
+    /* first of all we have to skip the namespace string at the beginning of the command:
+     * 
+     * This fragment of code is taken from tcl 8.6.6 (tclNamesp.c) and it's part of the
+     * function implementing Tcl "namespace tail", as such it should be authoritative
+     * regarding the determination of the namespace stripped command name 
+     */
+
+    for (p = cmd;  *p != '\0';  p++) {
+	    /* empty body */
+    }
+    
+    while (--p > cmd) {
+        if ((*p == ':') && (*(p-1) == ':')) {
+            p++;			/* Just after the last "::" */
+            break;
+        }
+    }
+    cmd = p;
+
     if (!strcmp(cmd, "var_qs")) source = VAR_SRC_QUERYSTRING;
     else if (!strcmp(cmd, "var_post")) source = VAR_SRC_POST;
     else source = VAR_SRC_ALL;
diff --git a/tests/fqrivet_var.tcl b/tests/fqrivet_var.tcl
new file mode 100644
index 0000000..8a5eedf
--- /dev/null
+++ b/tests/fqrivet_var.tcl
@@ -0,0 +1,40 @@
+switch [::rivet::var_qs get t1] {
+
+    1 {
+        set qsvariables   [dict create {*}[::rivet::var_qs all]]
+        set postvariables [dict create {*}[::rivet::var_post all]]
+
+        set qsvar   {qsarg1 qsarg2}
+        set postvar {postarg1 postarg2}
+
+        set qs ""
+        set post ""
+        foreach v $qsvar {lappend qs $v [dict get $qsvariables $v]}
+        foreach v $postvar {lappend post $v [dict get $postvariables $v]}
+        puts -nonewline "var_qs = $qs\nvar_post = $post"
+    }
+    2 {
+        #::rivet::parray server
+        # GET request: no var_post variables are supposed to be returned 
+
+        set qsvariables   [dict create {*}[::rivet::var_qs all]]
+        set postvariables [dict create {*}[::rivet::var_post all]]
+
+        if {[dict exists $postvariables qsarg1] || [dict exists $postvariables qsarg2]} { 
+            puts "KO: [::rivet::var_post all]" 
+        } else {
+            puts -nonewline "OK"
+        }
+
+    }
+    3 {
+        set qsvariables   [dict create {*}[::rivet::var_qs all]]
+        set postvariables [dict create {*}[::rivet::var_post all]]
+
+        if {[dict exists $qsvariables postarg1] || [dict exists $qsvariables postarg2]} { 
+            puts "KO: $qsvariables" 
+        } else {
+            puts -nonewline "OK"
+        }
+    }
+}
diff --git a/tests/post.test b/tests/post.test
index 77e9bf8..8fed8dc 100644
--- a/tests/post.test
+++ b/tests/post.test
@@ -37,3 +37,26 @@ set testfilename1 post.rvt
     regexp -line {^\[::rivet::var_post get foobar\] = goober$} [ ::http::data $page ] match
     set match
 } {[::rivet::var_post get foobar] = goober}
+
+set rivetscript "${urlbase}fqrivet_var.tcl"
+
+::tcltest::test postvariables-5.1 {::rivet::var_qs and ::rivet::var_post} {
+    set page [::http::geturl "${rivetscript}?qsarg1=val1&qsarg2=val2&t1=1" \
+                            -query [::http::formatQuery postarg1 val1 postarg2 val2]]
+    set match [::http::data $page]
+    set match
+} {var_qs = qsarg1 val1 qsarg2 val2
+var_post = postarg1 val1 postarg2 val2}
+
+::tcltest::test postvariables-5.2 {::rivet::var_post and ::rivet::var_qs crosstalk 1} {
+    set page [::http::geturl "${rivetscript}?qsarg1=val1&qsarg2=val2&t1=2"]
+    set match [::http::data $page]
+    set match
+} {OK}
+
+::tcltest::test postvariables-5.3 {::rivet::var_post and ::rivet::var_qs crosstalk 2} {
+    set page [::http::geturl "${rivetscript}?t1=3" \
+                              -query [::http::formatQuery postarg1 val1 postarg2 val2]]
+    set match [::http::data $page]
+    set match
+} {OK}


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