Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/subst?V=44
QUERY_STRINGV=44
CONTENT_TYPE
DOCUMENT_URI/revision/subst
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.135.161
REMOTE_PORT57658
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip
HTTP_CF_IPCOUNTRYUS
HTTP_X_FORWARDED_FOR34.231.247.88
HTTP_CF_RAY70e367996a9657f4-IAD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_CF_CONNECTING_IP34.231.247.88
HTTP_CDN_LOOPcloudflare

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit subst {
    :   '''subst''' ?'''-nobackslashes'''? ?'''-nocommands'''? ?'''-novariables'''? ''string''



   [http://www.tcl.tk/man/tcl/TclCmd/subst.htm%|%official manpage%|%]:   



'''`subst`'''  performs the first stage of Tcl script evaluation, i.e. 
'''[[subst]'''  performs the first stage of Tcl script evalution, performing
evaluating the commands contained at the top level of the script. 
evaluating the commands contained at the top level of the script. 
According to [Joe English]:  `subst` is massively handy in text-processing

According to [Joe English]:  [[subst] is massively handy in text-processing
applications, especially [SGML] and [XML] down-translators.  [[subst]] and
[[[string map]]] make Tcl particularly well-suited for this type of task.  Many
expression] substitution, Tcl does as [regular expression%|%REs] whose results are subst-ituted.
expression] substitution, Tcl does as REs whose results are subst-ituted.



Simple example of using `subst` with XML/[HTML].
Simple example of using [[subst] with XML/HTML.
======
set html   {<html><head>$title</head></html>}
set title  "Hello, World!"
set output [subst -nocommands $html]
set output ;# -> <html><head>Hello, World!</head></html>
======

Another alternative would be to use [XPath]





[RS] most often uses `subst` for expanding [Unicode%|%Unicodes]: cross-platform, in mostly 8-bit environments, 
[RS] most often uses [subst] for expanding Unicodes: cross-platform, in mostly 8-bit environments, 
it is most robust to output Unicodes in the \u.... notation - such snippets can be pasted into a text widget and visualized by
======
subst [$t get 1.0 end]
======



Even when the `-nocommands` option is used, variable substitution triggers any command substitutions necessary to complete the variable substitution:
Even when the `-nocommands` option is used, variable substitution will trigger any command substitutions necessary to complete the variable substitution:
======none
set var "code inclusion perverse \$tcl_platform(os\[puts OUCH!\])"
puts [subst -nocommands $var] 
==> OUCH!
======

reference: [http://groups.google.fr/group/fr.comp.lang.tcl/msg/b0038cac3c0cfa04%|%Eric Hassold, fr.comp.lang.tcl, 2008-12-30%|%]
reference: [http://groups.google.fr/group/fr.comp.lang.tcl/msg/b0038cac3c0cfa04%|%Eric Hassold ,fr.comp.lang.tcl ,2008-12-30%|%]
reference: [http://sourceforge.net/tracker/?func=detail&aid=536838&group_id=10894&atid=110894%|%Tcl bug 536838%|%]



-- Ok, I saw [http://core.tcl.tk/tcl/tktview?name=536831%|%Bug 536831] above. I think a '''big warning''' should be inserted in the manual.
-- Ok, I saw Bug 536831 above. I think a '''big warning''' should be inserted in the manual.
[Lars H]: What has Bug 536831 to do with this? I see nothing about -nocommands in that report.

The problem with `[puts] OUCH!` rather seems to be that variable substitution can trigger command substitution in the array index part, or to put it differently, once one type of substitution has triggered, [subst] has no control of what happens until that substitution is complete:
The problem with `[[puts OUCH!]]` rather seems to be that variable substitution can trigger command substitution in the array index part, or to put it differently, once one type of substitution has triggered, [subst] has no control of what happens until that substitution is complete:
======none
% subst -nobackslashes {$tcl_platform(threade\x64)\x64}
1\x64
======

A warning indeed seems appropriate.


** History **

What changed in Tcl 8.4.0 with regards to how subst treats break and continue during command substitution?

See Tcl Bug 536831, [http://core.tcl.tk/tcl/tktview?name=684982%|%Tcl Feature Request 684982], and the changes in the tests subst-10.*.
See Tcl Bug 536831, Tcl Feature Request 684982, and the changes in the tests subst-10.*.
Without checking every byte, I think the incompatible changes are limited to those uses
of `subst` that attempt command substitution on a string that is not a syntactically
of [subst] that attempt command substitution on a string that is not a syntactically




[jcw] 2004-05-03:  It would be useful to extend `subst` so it lets one catch variable accesses, and perhaps even command executions.  What I mean is that when you `subst` text with "... $var ..." then sometimes it is useful to be able to intercept the expansion, by turning it into a call such as `myhandler var` for example, the result of which then gets used as substitution.  
[jcw] 2004-05-03:  It would be useful to extend subst so it lets one catch variable accesses, and perhaps even command executions.  What I mean is that when you subst text with "... $var ..." then sometimes it is useful to be able to intercept the expansion, by turning it into a call such as "myhandler var" for example, the result of which then gets used as substitution.  
The same (perhaps less important) might apply to "... [[cmd ...]] ..." expansions.
This makes it simpler to implement tiny languages which also use `$var` and `$var(item)` as 
This makes it simpler to implement tiny languages which also use "$var" and "$var(item)" as 

Would it be an idea to extend subst so it optionally passes each of its substitutions to a command?  
Could be a "-command ..." option, or simply the presence of more args.

'''[DGP]''' Am I missing something?  Aren't you asking
for variable and command [trace]s?  Which exist?

D'oh!  I'm missing that in this case you want to set a trace
on a whole set of variables/commands whose names you do not
know.  OK, something to think about...

Anyhow, I think that's the right way to address the issue
generally... add more types of traces that can be used
everywhere.  I'd be shy about
diverging the implementation of `subst` from the implementation
diverging the implementation of [subst] from the implementation

[jcw]: Yes, that's exactly the scenario.  `subst` on a string to expand names which are not known up front.  Looks like there is no way to catch this right now.  
[jcw] - Yes, that's exactly the scenario.  Subst on a string to expand names which are not known up front.  Looks like there is no way to catch this right now.  
The key is to intercept between the parse for var/cmd expansions and the lookup for existing ones.



[AMG]: Am I correct in my understanding that:

======
[subst {anything at all}]
subst {anything at all}

is always equivalent to:

======
"anything at all"
======

for absolutely any value of "anything at all"?

It occurred to me that if this is indeed the case, then maybe this equivalence could be the reason why backslash-newline-whitespace inside braces is replaced with a single space, in the interest of mirroring the way double quotes work.  But then I experimented and found that `subst` internally will do this replacement and does not need the Tcl interpreter to preprocess its input in this way.
It occurred to me that if this is indeed the case, then maybe this equivalence could be the reason why backslash-newline-whitespace inside braces is replaced with a single space, in the interest of mirroring the way double quotes work.  But then I experimented and found that [[subst]] internally will do this replacement and does not need the Tcl interpreter to preprocess its input in this way.
[PYK]: Could you elaborate on what you mean by "internally will do this replacement"?

[AMG]: `subst` internally replaces backslash-newline-whitespace with a single space.  It's as simple as that.  Here's a demonstration:

   [eval]:   
   * [eval]
   * [regsub]
   * [string map]
   [regsub]:   } regexp2} CALL {my render subst {
    :   '''subst''' ?'''-nobackslashes'''? ?'''-nocommands'''? ?'''-novariables'''? ''string''



   [http://www.tcl.tk/man/tcl/TclCmd/subst.htm%|%official manpage%|%]:   



'''`subst`'''  performs the first stage of Tcl script evaluation, i.e. 
'''[[subst]'''  performs the first stage of Tcl script evalution, performing
evaluating the commands contained at the top level of the script. 
evaluating the commands contained at the top level of the script. 
According to [Joe English]:  `subst` is massively handy in text-processing

According to [Joe English]:  [[subst] is massively handy in text-processing
applications, especially [SGML] and [XML] down-translators.  [[subst]] and
[[[string map]]] make Tcl particularly well-suited for this type of task.  Many
expression] substitution, Tcl does as [regular expression%|%REs] whose results are subst-ituted.
expression] substitution, Tcl does as REs whose results are subst-ituted.



Simple example of using `subst` with XML/[HTML].
Simple example of using [[subst] with XML/HTML.
======
set html   {<html><head>$title</head></html>}
set title  "Hello, World!"
set output [subst -nocommands $html]
set output ;# -> <html><head>Hello, World!</head></html>
======

Another alternative would be to use [XPath]





[RS] most often uses `subst` for expanding [Unicode%|%Unicodes]: cross-platform, in mostly 8-bit environments, 
[RS] most often uses [subst] for expanding Unicodes: cross-platform, in mostly 8-bit environments, 
it is most robust to output Unicodes in the \u.... notation - such snippets can be pasted into a text widget and visualized by
======
subst [$t get 1.0 end]
======



Even when the `-nocommands` option is used, variable substitution triggers any command substitutions necessary to complete the variable substitution:
Even when the `-nocommands` option is used, variable substitution will trigger any command substitutions necessary to complete the variable substitution:
======none
set var "code inclusion perverse \$tcl_platform(os\[puts OUCH!\])"
puts [subst -nocommands $var] 
==> OUCH!
======

reference: [http://groups.google.fr/group/fr.comp.lang.tcl/msg/b0038cac3c0cfa04%|%Eric Hassold, fr.comp.lang.tcl, 2008-12-30%|%]
reference: [http://groups.google.fr/group/fr.comp.lang.tcl/msg/b0038cac3c0cfa04%|%Eric Hassold ,fr.comp.lang.tcl ,2008-12-30%|%]
reference: [http://sourceforge.net/tracker/?func=detail&aid=536838&group_id=10894&atid=110894%|%Tcl bug 536838%|%]



-- Ok, I saw [http://core.tcl.tk/tcl/tktview?name=536831%|%Bug 536831] above. I think a '''big warning''' should be inserted in the manual.
-- Ok, I saw Bug 536831 above. I think a '''big warning''' should be inserted in the manual.
[Lars H]: What has Bug 536831 to do with this? I see nothing about -nocommands in that report.

The problem with `[puts] OUCH!` rather seems to be that variable substitution can trigger command substitution in the array index part, or to put it differently, once one type of substitution has triggered, [subst] has no control of what happens until that substitution is complete:
The problem with `[[puts OUCH!]]` rather seems to be that variable substitution can trigger command substitution in the array index part, or to put it differently, once one type of substitution has triggered, [subst] has no control of what happens until that substitution is complete:
======none
% subst -nobackslashes {$tcl_platform(threade\x64)\x64}
1\x64
======

A warning indeed seems appropriate.


** History **

What changed in Tcl 8.4.0 with regards to how subst treats break and continue during command substitution?

See Tcl Bug 536831, [http://core.tcl.tk/tcl/tktview?name=684982%|%Tcl Feature Request 684982], and the changes in the tests subst-10.*.
See Tcl Bug 536831, Tcl Feature Request 684982, and the changes in the tests subst-10.*.
Without checking every byte, I think the incompatible changes are limited to those uses
of `subst` that attempt command substitution on a string that is not a syntactically
of [subst] that attempt command substitution on a string that is not a syntactically




[jcw] 2004-05-03:  It would be useful to extend `subst` so it lets one catch variable accesses, and perhaps even command executions.  What I mean is that when you `subst` text with "... $var ..." then sometimes it is useful to be able to intercept the expansion, by turning it into a call such as `myhandler var` for example, the result of which then gets used as substitution.  
[jcw] 2004-05-03:  It would be useful to extend subst so it lets one catch variable accesses, and perhaps even command executions.  What I mean is that when you subst text with "... $var ..." then sometimes it is useful to be able to intercept the expansion, by turning it into a call such as "myhandler var" for example, the result of which then gets used as substitution.  
The same (perhaps less important) might apply to "... [[cmd ...]] ..." expansions.
This makes it simpler to implement tiny languages which also use `$var` and `$var(item)` as 
This makes it simpler to implement tiny languages which also use "$var" and "$var(item)" as 

Would it be an idea to extend subst so it optionally passes each of its substitutions to a command?  
Could be a "-command ..." option, or simply the presence of more args.

'''[DGP]''' Am I missing something?  Aren't you asking
for variable and command [trace]s?  Which exist?

D'oh!  I'm missing that in this case you want to set a trace
on a whole set of variables/commands whose names you do not
know.  OK, something to think about...

Anyhow, I think that's the right way to address the issue
generally... add more types of traces that can be used
everywhere.  I'd be shy about
diverging the implementation of `subst` from the implementation
diverging the implementation of [subst] from the implementation

[jcw]: Yes, that's exactly the scenario.  `subst` on a string to expand names which are not known up front.  Looks like there is no way to catch this right now.  
[jcw] - Yes, that's exactly the scenario.  Subst on a string to expand names which are not known up front.  Looks like there is no way to catch this right now.  
The key is to intercept between the parse for var/cmd expansions and the lookup for existing ones.



[AMG]: Am I correct in my understanding that:

======
[subst {anything at all}]
subst {anything at all}

is always equivalent to:

======
"anything at all"
======

for absolutely any value of "anything at all"?

It occurred to me that if this is indeed the case, then maybe this equivalence could be the reason why backslash-newline-whitespace inside braces is replaced with a single space, in the interest of mirroring the way double quotes work.  But then I experimented and found that `subst` internally will do this replacement and does not need the Tcl interpreter to preprocess its input in this way.
It occurred to me that if this is indeed the case, then maybe this equivalence could be the reason why backslash-newline-whitespace inside braces is replaced with a single space, in the interest of mirroring the way double quotes work.  But then I experimented and found that [[subst]] internally will do this replacement and does not need the Tcl interpreter to preprocess its input in this way.
[PYK]: Could you elaborate on what you mean by "internally will do this replacement"?

[AMG]: `subst` internally replaces backslash-newline-whitespace with a single space.  It's as simple as that.  Here's a demonstration:

   [eval]:   
   * [eval]
   * [regsub]
   * [string map]
   [regsub]:   }} CALL {my revision subst} CALL {::oo::Obj2728039 process revision/subst} CALL {::oo::Obj2728037 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 51)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4