You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by da...@apache.org on 2003/12/21 00:29:05 UTC
cvs commit: tcl-rivet/tests parsepackage.test rivet.test
davidw 2003/12/20 15:29:05
Modified: . ChangeLog INSTALL README
rivet pkgIndex.tcl
src parserPkgInit.c rivetParser.c
tests rivet.test
Added: rivet/packages/tclrivet README parse.tcl pkgIndex.tcl
tclrivet.tcl tclrivetparser.tcl
tests parsepackage.test
Log:
* tests/parsepackage.test: Added tests for the Rivet parser standalone
package and pure Tcl Rivet parser.
* INSTALL: Added basic configuration directives to INSTALL file.
* rivet/packages/tclrivet/tclrivetparser.tcl: Added pure Tcl Rivet
parser. This doesn't have all the Rivet commands available, it just
parses a <? ?> style Rivet file into the corresponding Tcl script.
* src/parserPkgInit.c (Parse_RivetData): We no longer automatically
add the namespace. The user ought to be able to add that should
they so choose. This makes the command more flexible.
* src/rivetParser.c (Rivet_Parser): Removed an unnecessary Tcl_UtfNext
from the parser. (Rivet_GetRivetFile): Removed useless 'inside'
variable from this function.
Revision Changes Path
1.153 +19 -0 tcl-rivet/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /home/cvs/tcl-rivet/ChangeLog,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -r1.152 -r1.153
--- ChangeLog 20 Dec 2003 09:52:54 -0000 1.152
+++ ChangeLog 20 Dec 2003 23:29:04 -0000 1.153
@@ -1,5 +1,24 @@
2003-12-20 David N. Welton <da...@dedasys.com>
+ * tests/parsepackage.test: Added tests for the Rivet parser
+ standalone package and pure Tcl Rivet parser.
+
+ * INSTALL: Added basic configuration directives to INSTALL file.
+
+ * rivet/packages/tclrivet/tclrivetparser.tcl: Added pure Tcl Rivet
+ parser. This doesn't have all the Rivet commands available, it
+ just parses a <? ?> style Rivet file into the corresponding Tcl
+ script.
+
+ * src/parserPkgInit.c (Parse_RivetData): We no longer
+ automatically add the namespace. The user ought to be able to add
+ that should they so choose. This makes the command more flexible.
+
+ * src/rivetParser.c (Rivet_Parser): Removed an unnecessary
+ Tcl_UtfNext from the parser.
+ (Rivet_GetRivetFile): Removed useless 'inside' variable from this
+ function.
+
* doc/rivet.xml: Add abort_page, no_body and env commands,
reordered the load_* commands.
1.9 +13 -1 tcl-rivet/INSTALL
Index: INSTALL
===================================================================
RCS file: /home/cvs/tcl-rivet/INSTALL,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- INSTALL 26 Aug 2003 08:31:22 -0000 1.8
+++ INSTALL 20 Dec 2003 23:29:04 -0000 1.9
@@ -1,3 +1,8 @@
+ Rivet Installation
+ ==================
+
+For more detailed instructions, see the docs/html/ directory.
+
The only thing you need to install Rivet is a C compiler, linker, and
of course, Tcl (8.4 or newer).
@@ -14,4 +19,11 @@
tclsh ./make.tcl shared
tclsh ./make.tcl install
-For more detailed instructions, see the docs/html/ directory.
+Basic Apache configuration directives that are needed:
+
+# Loads the module.
+LoadModule rivet_module /path/to/your/copy/of/mod_rivet.so
+
+# Let the module handle .rvt and .tcl files.
+AddType application/x-httpd-rivet .rvt
+AddType application/x-rivet-tcl .tcl
\ No newline at end of file
1.4 +4 -1 tcl-rivet/README
Index: README
===================================================================
RCS file: /home/cvs/tcl-rivet/README,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- README 11 Nov 2002 19:10:36 -0000 1.3
+++ README 20 Dec 2003 23:29:04 -0000 1.4
@@ -3,6 +3,9 @@
See the doc/html/ directory for installation and usage instructions.
+See INSTALL for brief installation instructions - although the above
+docs in HTML are more thorough and extensive.
+
See LICENSE for licensing terms.
$Id$
1.4 +1 -0 tcl-rivet/rivet/pkgIndex.tcl
Index: pkgIndex.tcl
===================================================================
RCS file: /home/cvs/tcl-rivet/rivet/pkgIndex.tcl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pkgIndex.tcl 29 Sep 2003 13:09:35 -0000 1.3
+++ pkgIndex.tcl 20 Dec 2003 23:29:05 -0000 1.4
@@ -17,3 +17,4 @@
package ifneeded rivetparser 0.1 [list source [file join $dir packages/tclrivet/tclrivet.tcl]]
package ifneeded simpledb 0.1 [list source [file join $dir packages/simpledb/simpledb.tcl]]
package ifneeded tclrivet 0.1 [list source [file join $dir packages/tclrivet/tclrivet.tcl]]
+package ifneeded tclrivetparser 0.1 [list source [file join $dir packages/tclrivet/tclrivetparser.tcl]]
1.1 tcl-rivet/rivet/packages/tclrivet/README
Index: README
===================================================================
This package provides "Rivet" for tclsh. In other words, for Tcl
scripts not executed inside Apache.
$Id: README,v 1.1 2003/12/20 23:29:05 davidw Exp $
1.1 tcl-rivet/rivet/packages/tclrivet/parse.tcl
Index: parse.tcl
===================================================================
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
# Parse a rivet file and execute it.
set auto_path "[file dirname [info script]] $auto_path"
package require tclrivet
proc main {} {
global argv
for {set i 0} {$i < [llength $argv] - 1} {incr i} {
source [lindex $argv $i]
}
set script [rivet::parserivet [lindex $argv end]]
if { [catch {eval $script } err] } {
puts "Error: $err"
}
}
main
1.1 tcl-rivet/rivet/packages/tclrivet/pkgIndex.tcl
Index: pkgIndex.tcl
===================================================================
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script. It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands. When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.
package ifneeded tclrivet 0.1 [list source [file join $dir tclrivet.tcl]]
1.1 tcl-rivet/rivet/packages/tclrivet/tclrivet.tcl
Index: tclrivet.tcl
===================================================================
# Tcl versions of Rivet commands.
# $Id: tclrivet.tcl,v 1.1 2003/12/20 23:29:05 davidw Exp $
package provide tclrivet 0.1
load [file join [file dirname [info script]] .. .. .. src \
librivetparser[info sharedlibextension]]
proc include { filename } {
set fl [ open $filename ]
fconfigure $fl -translation binary
puts -nonewline [ read $fl ]
close $fl
}
# We need to fill these in, of course.
proc makeurl {} {}
proc headers {} {}
proc load_env {} {}
proc load_headers {} {}
proc var {} {}
proc var_qs {} {}
proc var_post {} {}
proc upload {} {}
proc include {} {}
proc parse {} {}
proc no_body {} {}
proc env {} {}
proc abort_page {} {}
proc virtual_filename {} {}
1.1 tcl-rivet/rivet/packages/tclrivet/tclrivetparser.tcl
Index: tclrivetparser.tcl
===================================================================
# tclrivetparser.tcl -- parse Rivet files in pure Tcl.
# $Id: tclrivetparser.tcl,v 1.1 2003/12/20 23:29:05 davidw Exp $
package provide tclrivetparser 0.1
namespace eval tclrivetparser {
set starttag <?
set endtag ?>
namespace export parserivetdata
}
# tclrivetparser::parse --
#
# Parse a buffer, transforming <? and ?> into the appropriate
# Tcl strings. Note that initial 'puts "' is not performed
# here.
#
# Arguments:
# data - data to scan.
# outbufvar - name of the output buffer.
#
# Side Effects:
# None.
#
# Results:
# Returns the $inside variable - 1 if we are inside a <? ?>
# section, 0 if we outside.
proc tclrivetparser::parse { data outbufvar } {
variable starttag
variable endtag
set inside 0
upvar $outbufvar outbuf
set i 0
set p 0
set len [expr {[string length $data] + 1}]
set next [string index $data 0]
while {$i < $len} {
incr i
set cur $next
set next [string index $data $i]
if { $inside == 0 } {
# Outside the delimiting tags.
if { $cur == [string index $starttag $p] } {
incr p
if { $p == [string length $starttag] } {
append outbuf "\"\n"
set inside 1
set p 0
continue
}
} else {
if { $p > 0 } {
append outbuf [string range $starttag 0 [expr {$p - 1}]]
set p 0
}
switch -exact -- $cur {
"\{" {
append outbuf "\\{"
}
"\}" {
append outbuf "\\}"
}
"\$" {
append outbuf "\\$"
}
"\[" {
append outbuf "\\["
}
"\]" {
append outbuf "\\]"
}
"\"" {
append outbuf "\\\""
}
"\\" {
append outbuf "\\\\"
}
default {
append outbuf $cur
}
}
continue
}
} else {
# Inside the delimiting tags.
if { $cur == [string index $endtag $p] } {
incr p
if { $p == [string length $endtag] } {
append outbuf "\nputs -nonewline \""
set inside 0
set p 0
}
} else {
if { $p > 0 } {
append outbuf [string range $endtag 0 $p]
set p 0
}
append outbuf $cur
}
}
}
return $inside
}
# tclrivetparser::parserivetdata --
#
# Parse a rivet script, and add the relavant opening and closing
# bits.
#
# Arguments:
# data - data to parse.
#
# Side Effects:
# None.
#
# Results:
# Returns the parsed script.
proc tclrivetparser::parserivetdata { data } {
set outbuf {}
append outbuf "puts -nonewline \""
if { [parse $data outbuf] == 0 } {
append outbuf "\"\n"
}
return $outbuf
}
1.4 +21 -8 tcl-rivet/src/parserPkgInit.c
Index: parserPkgInit.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/parserPkgInit.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- parserPkgInit.c 13 Dec 2003 20:42:26 -0000 1.3
+++ parserPkgInit.c 20 Dec 2003 23:29:05 -0000 1.4
@@ -47,11 +47,27 @@
return TCL_OK;
}
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Parse_RivetData --
+ *
+ * Takes a Rivet script as an argument, and returns the parsed
+ * tcl script version.
+ *
+ * Results:
+ * A normal Tcl result.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
static int
Parse_RivetData(ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
- int inside = 0;
Tcl_Obj *outbuf;
outbuf = Tcl_NewObj();
@@ -63,22 +79,19 @@
}
Tcl_IncrRefCount(outbuf);
- Tcl_AppendToObj(outbuf, "namespace eval request {\n", -1);
Tcl_AppendToObj(outbuf, "puts -nonewline \"", -1);
- inside = Rivet_Parser(outbuf, objv[1]);
-
- if (inside == 0)
+ if (Rivet_Parser(outbuf, objv[1]) == 0)
{
Tcl_AppendToObj(outbuf, "\"\n", 2);
}
- Tcl_AppendToObj(outbuf, "\n}\n", -1);
-
Tcl_SetObjResult(interp, outbuf);
Tcl_DecrRefCount(outbuf);
return TCL_OK;
}
+
+/* Package init for standalone parser package. */
EXTERN int
Rivetparser_Init( Tcl_Interp *interp )
1.12 +3 -6 tcl-rivet/src/rivetParser.c
Index: rivetParser.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/rivetParser.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- rivetParser.c 13 Dec 2003 20:42:26 -0000 1.11
+++ rivetParser.c 20 Dec 2003 23:29:05 -0000 1.12
@@ -75,7 +75,6 @@
Rivet_GetRivetFile(char *filename, int toplevel,
Tcl_Obj *outbuf, Tcl_Interp *interp)
{
- int inside = 0; /* are we inside the starting/ending delimiters */
int sz = 0;
Tcl_Obj *inbuf;
Tcl_Channel rivetfile;
@@ -106,9 +105,8 @@
return TCL_ERROR;
}
- inside = Rivet_Parser(outbuf, inbuf);
-
- if (inside == 0)
+ /* If we are not inside a <? ?> section, add the closing ". */
+ if (Rivet_Parser(outbuf, inbuf) == 0)
{
Tcl_AppendToObj(outbuf, "\"\n", 2);
}
@@ -174,7 +172,6 @@
Tcl_AppendToObj(outbuf, "\"\n", 2);
inside = 1;
p = 0;
- cur = (char *)Tcl_UtfNext(cur);
continue;
}
} else {
1.21 +7 -4 tcl-rivet/tests/rivet.test
Index: rivet.test
===================================================================
RCS file: /home/cvs/tcl-rivet/tests/rivet.test,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- rivet.test 30 Sep 2003 18:27:47 -0000 1.20
+++ rivet.test 20 Dec 2003 23:29:05 -0000 1.21
@@ -11,6 +11,7 @@
package require tcltest
package require http
+lappend auto_path [file join [pwd] rivet]
set urlbase "http://localhost:8081/"
# Use this to start and stop the server:
@@ -41,7 +42,7 @@
puts " done"
}
-# Run each test in its own server
+# Run each test in its own server.
if { $testgroup2 } {
foreach Test $TestList {
@@ -53,10 +54,12 @@
}
-# These tests start the server on their own
+# These tests start the server on their own, or don't need the server
+# at all.
if { $testgroup3 } {
- foreach Test {broken.test config.test lang.test} {
+ foreach Test {broken.test config.test lang.test parsepackage.test} {
+ puts "Running $Test"
source $Test
}
}
1.1 tcl-rivet/tests/parsepackage.test
Index: parsepackage.test
===================================================================
# $Id: parsepackage.test,v 1.1 2003/12/20 23:29:05 davidw Exp $
puts stderr "Auto path is $auto_path"
package require tcltest
package require tclrivetparser
load [file join [pwd] .. src librivetparser[info sharedlibext]]
::tcltest::test parserivetdata-1.1 {parserivetdata command} {
set fl [open hello.rvt]
set data [rivet::parserivetdata [read $fl]]
close $fl
set data
} {puts -nonewline ""
# hello-1.1
puts "Hello, World\n"
# i18n-1.1
puts "� � � � � � - El Burro Sabe M�s Que T�!\n"
puts -nonewline "
<p>���ܸ�(EUC-JP Japanese text)</p>
"
}
::tcltest::test parserivet-1.1 {parserivet command} {
rivet::parserivet hello.rvt
} {namespace eval request {
puts -nonewline ""
# hello-1.1
puts "Hello, World\n"
# i18n-1.1
puts "� � � � � � - El Burro Sabe M�s Que T�!\n"
puts -nonewline "
<p>���ܸ�(EUC-JP Japanese text)</p>
"
}
}
# Make sure that the Tcl version is identical to the C version.
::tcltest::test tclrivetparser-1.1 {tclparsedata command} {
set fl [open hello.rvt]
set data1 [tclrivetparser::parserivetdata [read $fl]]
close $fl
set fl [open hello.rvt]
set data2 [rivet::parserivetdata [read $fl]]
close $fl
set data2
string compare $data1 $data2
} {0}
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org