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 mx...@apache.org on 2012/05/13 01:44:05 UTC
svn commit: r1337739 - in /tcl/rivet/branches/2.0: ChangeLog
rivet/packages/tclrivet/tclrivetparser.tcl
Author: mxmanghi
Date: Sat May 12 23:44:05 2012
New Revision: 1337739
URL: http://svn.apache.org/viewvc?rev=1337739&view=rev
Log:
* rivet/packages/tclrivet/tclrivetparser.tcl: Tcl parser implements new shorthand echo syntax (closes bug #53217)
Modified:
tcl/rivet/branches/2.0/ChangeLog
tcl/rivet/branches/2.0/rivet/packages/tclrivet/tclrivetparser.tcl
Modified: tcl/rivet/branches/2.0/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.0/ChangeLog?rev=1337739&r1=1337738&r2=1337739&view=diff
==============================================================================
--- tcl/rivet/branches/2.0/ChangeLog (original)
+++ tcl/rivet/branches/2.0/ChangeLog Sat May 12 23:44:05 2012
@@ -1,3 +1,7 @@
+2012-05-13 Massimo Manghi <mx...@apache.org>
+ * rivet/packages/tclrivet/tclrivetparser.tcl: Tcl parser implements new shorthand echo syntax (closes
+ bug #53217)
+
2012-05-12 Massimo Manghi <mx...@apache.org>
* src/rivetParser.c: add shorthand expression <?= ... ?> for <? puts -nonewline "..." ?> (contributed
by Jeff Lawson,addresses #53217, tclrivetparser yet to be fixed)
Modified: tcl/rivet/branches/2.0/rivet/packages/tclrivet/tclrivetparser.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/2.0/rivet/packages/tclrivet/tclrivetparser.tcl?rev=1337739&r1=1337738&r2=1337739&view=diff
==============================================================================
--- tcl/rivet/branches/2.0/rivet/packages/tclrivet/tclrivetparser.tcl (original)
+++ tcl/rivet/branches/2.0/rivet/packages/tclrivet/tclrivetparser.tcl Sat May 12 23:44:05 2012
@@ -45,7 +45,7 @@ proc tclrivetparser::setoutputcmd { {new
variable outputcmd
if { $outputcmd == "" } {
- return $outputcmd
+ return $outputcmd
}
set outputcmd $newcmd
}
@@ -71,7 +71,8 @@ proc tclrivetparser::parse { data outbuf
variable outputcmd
variable starttag
variable endtag
- set inside 0
+ set inside 0
+ set shorthand 0
upvar $outbufvar outbuf
@@ -80,69 +81,83 @@ proc tclrivetparser::parse { data outbuf
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 "\n$outputcmd \""
- set inside 0
- set p 0
- }
- } else {
- if { $p > 0 } {
- append outbuf [string range $endtag 0 $p]
- set p 0
- }
- append outbuf $cur
- }
- }
+ 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] } {
+
+ if {$next == "="} {
+# puts stderr "shorthand begin detected"
+ append outbuf "\"\n $outputcmd "
+ set shorthand 1
+ incr i
+ set next [string index $data $i]
+ } else {
+ 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 \ $cur
+ }
+ "\}" {
+ append outbuf \ $cur
+ }
+ "\$" {
+ 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] } {
+ if {$shorthand} {
+# puts stderr "shorthand end detected"
+ set shorthand 0
+ }
+ append outbuf "\n$outputcmd \""
+ 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
}
@@ -167,7 +182,7 @@ proc tclrivetparser::parserivetdata { da
set outbuf {}
append outbuf "$outputcmd \""
if { [parse $data outbuf] == 0 } {
- append outbuf "\"\n"
+ append outbuf "\"\n"
}
return $outbuf
}
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org