Error processing request
Parameters
CONTENT_LENGTH | 0 |
REQUEST_METHOD | GET |
REQUEST_URI | /revision/HOW+TO+%2D+Remove+C+style+comments?V=8 |
QUERY_STRING | V=8 |
CONTENT_TYPE | |
DOCUMENT_URI | /revision/HOW+TO+-+Remove+C+style+comments |
DOCUMENT_ROOT | /var/www/nikit/nikit/nginx/../docroot |
SCGI | 1 |
SERVER_PROTOCOL | HTTP/1.1 |
HTTPS | on |
REMOTE_ADDR | 172.70.126.238 |
REMOTE_PORT | 13932 |
SERVER_PORT | 4443 |
SERVER_NAME | wiki.tcl-lang.org |
HTTP_HOST | wiki.tcl-lang.org |
HTTP_CONNECTION | Keep-Alive |
HTTP_ACCEPT_ENCODING | gzip, br |
HTTP_X_FORWARDED_FOR | 3.137.171.121 |
HTTP_CF_RAY | 878d37f2fa542aba-ORD |
HTTP_X_FORWARDED_PROTO | https |
HTTP_CF_VISITOR | {"scheme":"https"} |
HTTP_ACCEPT | */* |
HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected]) |
HTTP_CF_CONNECTING_IP | 3.137.171.121 |
HTTP_CDN_LOOP | cloudflare |
HTTP_CF_IPCOUNTRY | US |
Body
Error
Unknow state transition: LINE -> END
-code
1
-level
0
-errorstack
INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {HOW TO - Remove C style comments} {The following procedure will remove C style comments (i.e. /* .... */ ) from text.
proc removeComments { text {replacement ""} } {
regsub -all {[/][*].*?[*][/]} $text ${replacement} text
return $text
}
----
If you need to remove C style comments that are imbedded (i.e. /* ... /* ... */ ... */) use the following procedure.
proc removeImbeddedComments { text {replacement ""} } {
set text [string map {"/*" \x80 "*/" \x81} $text]
while {[regsub -all {\x80[^\x80\x81]*?\x81} $text ${replacement} text]} {continue}
set text [string map {\x80 "/*" \x81 "*/"} $text]
return $text
}
----
Use Examples:
removeComments ${data} "#comment-removed#"
removeImbeddedComments ${data} "#comment-removed#"
----
Test Cases:
##### Simple Comments #####
# test-1
/**/
/* */
/* text1 */
# test-2
text1 /**/ text2 /* */ text3 /* comment */
# test-3
/*
*/
text1
/*
*/
text2
/*
*/
# test-4
text1 /*
*/ text2
text1 /*
*/ text2
# test-5
/* comment
*/
/*
comment
*/
/*
comment */
##### Imbedded Comments #####
# test-1
text1 /*/*/**/*/*/ text2
# test-2
text1 /*/**//**//*/**//**//**/*/*/ text2
# test-3
text1 /* comment /* comment /* comment */ comment */ comment */ text2
# test-4
text1
/*
text2
text3 /* comment */
text4 /*
comment
comment /* comment */
comment
*/
text5
*/
text5
# test-5
text1
/*
comment ///
/*
comment ///
/*
comment ///
comment ***
*/
comment ***
*/
comment ***
*/
text2
# test-6
text1 * / / *
/*
comment ///
/*
comment ///
/*
comment ///
comment ***
*/
comment ***
*/
comment ***
comment ///
/*
comment ///
/*
comment ///
comment ***
*/
comment ***
comment ///
/*
comment ///
comment ***
*/
comment ***
*/
comment ***
*/
text2
# test-7 (dangling comments)
*/ /*
----
Test results from the removeImbeddedComments procedure were as follows.
##### Simple Comments #####
# test-1
#comment-removed#
#comment-removed#
#comment-removed#
# test-2
text1 #comment-removed# text2 #comment-removed# text3 #comment-removed#
# test-3
#comment-removed#
text1
#comment-removed#
text2
#comment-removed#
# test-4
text1 #comment-removed# text2
text1 #comment-removed# text2
# test-5
#comment-removed#
#comment-removed#
#comment-removed#
##### Imbedded Comments #####
# test-1
text1 #comment-removed# text2
# test-2
text1 #comment-removed# text2
# test-3
text1 #comment-removed# text2
# test-4
text1
#comment-removed#
text5
# test-5
text1
#comment-removed#
text2
# test-6
text1 * / / *
#comment-removed#
text2
# test-7 (dangling comments)
*/ /*
----
[Tom Krehbiel]
----
Pierre Coueffin (03 Sept. 2005):
You do have to be careful if you try to use this on actual comments in C code.
if 0 {
removeComments {printf ("/* %s */\n", "Comment to print"); /* Prints a comment to stdout */}
returns:
printf (" \n ", "Comment to print");
where you might expect to see:
printf ("/* %s */\n", "Comment to print");
}
----
'''[tbtietc] - 2009-06-25 11:19:05'''
======
regsub -all {('([^\']|[\\].)')|("([^\"]|[\\].)*")|(//[^\n]*)|(/\*([^*]|[*][^/])*\*/)} $text "\\1\\3" text;
======
This detects:
A. Character in single quotes
B. String in double quotes
C. C style comments.
And replaces:
A, B with themselves (quotes intact).
C with null-string (comments deleted).
======
!!!!!!
%| [Category Dev. Tools] |%
!!!!!!} regexp2} CALL {my render {HOW TO - Remove C style comments} {The following procedure will remove C style comments (i.e. /* .... */ ) from text.
proc removeComments { text {replacement ""} } {
regsub -all {[/][*].*?[*][/]} $text ${replacement} text
return $text
}
----
If you need to remove C style comments that are imbedded (i.e. /* ... /* ... */ ... */) use the following procedure.
proc removeImbeddedComments { text {replacement ""} } {
set text [string map {"/*" \x80 "*/" \x81} $text]
while {[regsub -all {\x80[^\x80\x81]*?\x81} $text ${replacement} text]} {continue}
set text [string map {\x80 "/*" \x81 "*/"} $text]
return $text
}
----
Use Examples:
removeComments ${data} "#comment-removed#"
removeImbeddedComments ${data} "#comment-removed#"
----
Test Cases:
##### Simple Comments #####
# test-1
/**/
/* */
/* text1 */
# test-2
text1 /**/ text2 /* */ text3 /* comment */
# test-3
/*
*/
text1
/*
*/
text2
/*
*/
# test-4
text1 /*
*/ text2
text1 /*
*/ text2
# test-5
/* comment
*/
/*
comment
*/
/*
comment */
##### Imbedded Comments #####
# test-1
text1 /*/*/**/*/*/ text2
# test-2
text1 /*/**//**//*/**//**//**/*/*/ text2
# test-3
text1 /* comment /* comment /* comment */ comment */ comment */ text2
# test-4
text1
/*
text2
text3 /* comment */
text4 /*
comment
comment /* comment */
comment
*/
text5
*/
text5
# test-5
text1
/*
comment ///
/*
comment ///
/*
comment ///
comment ***
*/
comment ***
*/
comment ***
*/
text2
# test-6
text1 * / / *
/*
comment ///
/*
comment ///
/*
comment ///
comment ***
*/
comment ***
*/
comment ***
comment ///
/*
comment ///
/*
comment ///
comment ***
*/
comment ***
comment ///
/*
comment ///
comment ***
*/
comment ***
*/
comment ***
*/
text2
# test-7 (dangling comments)
*/ /*
----
Test results from the removeImbeddedComments procedure were as follows.
##### Simple Comments #####
# test-1
#comment-removed#
#comment-removed#
#comment-removed#
# test-2
text1 #comment-removed# text2 #comment-removed# text3 #comment-removed#
# test-3
#comment-removed#
text1
#comment-removed#
text2
#comment-removed#
# test-4
text1 #comment-removed# text2
text1 #comment-removed# text2
# test-5
#comment-removed#
#comment-removed#
#comment-removed#
##### Imbedded Comments #####
# test-1
text1 #comment-removed# text2
# test-2
text1 #comment-removed# text2
# test-3
text1 #comment-removed# text2
# test-4
text1
#comment-removed#
text5
# test-5
text1
#comment-removed#
text2
# test-6
text1 * / / *
#comment-removed#
text2
# test-7 (dangling comments)
*/ /*
----
[Tom Krehbiel]
----
Pierre Coueffin (03 Sept. 2005):
You do have to be careful if you try to use this on actual comments in C code.
if 0 {
removeComments {printf ("/* %s */\n", "Comment to print"); /* Prints a comment to stdout */}
returns:
printf (" \n ", "Comment to print");
where you might expect to see:
printf ("/* %s */\n", "Comment to print");
}
----
'''[tbtietc] - 2009-06-25 11:19:05'''
======
regsub -all {('([^\']|[\\].)')|("([^\"]|[\\].)*")|(//[^\n]*)|(/\*([^*]|[*][^/])*\*/)} $text "\\1\\3" text;
======
This detects:
A. Character in single quotes
B. String in double quotes
C. C style comments.
And replaces:
A, B with themselves (quotes intact).
C with null-string (comments deleted).
======
!!!!!!
%| [Category Dev. Tools] |%
!!!!!!}} CALL {my revision {HOW TO - Remove C style comments}} CALL {::oo::Obj5296667 process revision/HOW+TO+%2D+Remove+C+style+comments} CALL {::oo::Obj5296665 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 56)
invoked from within
"$server process [string trim $uri /]"
-errorline
4