[Tkabber-dev] r1154 - in trunk/tkabber: . jabberlib-tclxml/tclxml

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Jul 12 01:01:03 MSD 2007


Author: sergei
Date: 2007-07-12 01:01:02 +0400 (Thu, 12 Jul 2007)
New Revision: 1154

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/jabberlib-tclxml/tclxml/sgmlparser.tcl
Log:
	* jabberlib-tclxml/tclxml/sgmlparser.tcl: Fixed default xmlns
	  processing (popping from stack). Also made code more readable
	  and removed some pre 8.1 code.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-07-11 20:03:03 UTC (rev 1153)
+++ trunk/tkabber/ChangeLog	2007-07-11 21:01:02 UTC (rev 1154)
@@ -6,6 +6,10 @@
 	  jabberlib-tclxml/jlibcomponent.tcl: Made XML namespace prefixes
 	  converted to xmlns attributes. Still ignore invalid prefixes.
 
+	* jabberlib-tclxml/tclxml/sgmlparser.tcl: Fixed default xmlns
+	  processing (popping from stack). Also made code more readable
+	  and removed some pre 8.1 code.
+
 2007-07-09  Sergei Golovan  <sgolovan at nes.ru>
 
 	* hooks.tcl: Allowed hook priority to take real value instead of

Modified: trunk/tkabber/jabberlib-tclxml/tclxml/sgmlparser.tcl
===================================================================
--- trunk/tkabber/jabberlib-tclxml/tclxml/sgmlparser.tcl	2007-07-11 20:03:03 UTC (rev 1153)
+++ trunk/tkabber/jabberlib-tclxml/tclxml/sgmlparser.tcl	2007-07-11 21:01:02 UTC (rev 1154)
@@ -561,40 +561,14 @@
 			    # We can do the parsing in one step with Tcl 8.1 RE's
 			    # This has the benefit of performing better WF checking
 
-			    set adv_re [format {^[%s]*version[%s]*=[%s]*("|')(-+|[a-zA-Z0-9_.:]+)\1([%s]+encoding[%s]*=[%s]*("|')([A-Za-z][-A-Za-z0-9._]*)\4)?([%s]*standalone[%s]*=[%s]*("|')(yes|no)\7)?[%s]*\?$} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp]
+			    set adv_re [format {^[%s]*version[%s]*=[%s]*(\"|')(-+|[a-zA-Z0-9_.:]+)\1([%s]+encoding[%s]*=[%s]*("|')([A-Za-z][-A-Za-z0-9._]*)\4)?([%s]*standalone[%s]*=[%s]*("|')(yes|no)\7)?[%s]*\?$} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp]
 
-			    if {[catch {regexp $adv_re $param discard delimiter version discard delimiter encoding discard delimiter standalone} matches]} {
-				# Otherwise we must fallback to 8.0.
-				# This won't detect certain well-formedness errors
-
-				# Get the version number
-				if {[regexp [format {[%s]*version[%s]*=[%s]*"(-+|[a-zA-Z0-9_.:]+)"[%s]*} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp] $param discard version] || [regexp [format {[%s]*version[%s]*=[%s]*'(-+|[a-zA-Z0-9_.:]+)'[%s]*} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp] $param discard version]} {
-				    if {[string compare $version "1.0"]} {
-					# Should we support future versions?
-					# At least 1.X?
-					uplevel #0 $options(-errorcommand) [list versionincompatibility "document XML version \"$version\" is incompatible with XML version 1.0"]
-				    }
-				} else {
-				    uplevel #0 $options(-errorcommand) [list missingversion "XML Declaration missing version information around line $state(line)"]
-				}
-
-				# Get the encoding declaration
-				set encoding {}
-				regexp [format {[%s]*encoding[%s]*=[%s]*"([A-Za-z]([A-Za-z0-9._]|-)*)"[%s]*} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp] $param discard encoding
-				regexp [format {[%s]*encoding[%s]*=[%s]*'([A-Za-z]([A-Za-z0-9._]|-)*)'[%s]*} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp] $param discard encoding
-
-				# Get the standalone declaration
-				set standalone {}
-				regexp [format {[%s]*standalone[%s]*=[%s]*"(yes|no)"[%s]*} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp] $param discard standalone
-				regexp [format {[%s]*standalone[%s]*=[%s]*'(yes|no)'[%s]*} $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp $::sgml::Wsp] $param discard standalone
-
-				# Invoke the callback
-				uplevel #0 $options(-xmldeclcommand) [list $version $encoding $standalone]
-
-			    } elseif {$matches == 0} {
-				uplevel #0 $options(-errorcommand) [list illformeddeclaration "XML Declaration not well-formed around line $state(line)"]
+			    if {![regexp $adv_re $param discard delimiter version discard \
+							delimiter encoding discard delimiter standalone]} {
+				uplevel #0 $options(-errorcommand) \
+				    [list illformeddeclaration \
+					  "XML Declaration not well-formed around line $state(line)"]
 			    } else {
-
 				# Invoke the callback
 				uplevel #0 $options(-xmldeclcommand) [list $version $encoding $standalone]
 
@@ -609,16 +583,25 @@
 			set tag [string range $tag 1 end]
 			if {[regsub {\?$} $tag {} tag]} {
 			    if {[string length [string trim $param]]} {
-				uplevel #0 $options(-errorcommand) [list [list unexpectedtext "unexpected text \"$param\" in processing instruction around line $state(line)"]]
+				uplevel #0 $options(-errorcommand) \
+				    [list [list unexpectedtext "unexpected text \"$param\"\
+					in processing instruction around line $state(line)"]]
 			    }
 			} elseif {![regexp ^$Name\$ $tag]} {
-			    uplevel #0 $options(-errorcommand) [list illegalcharacter "illegal character in processing instruction target \"$tag\""]
+			    uplevel #0 $options(-errorcommand) \
+				[list illegalcharacter "illegal character in processing instruction target \"$tag\""]
 			} elseif {[regexp {^[xX][mM][lL]$} $tag]} {
-			    uplevel #0 $options(-errorcommand) [list illegalcharacters "characters \"xml\" not permitted in processing instruction target \"$tag\""]
+			    uplevel #0 $options(-errorcommand) \
+				[list illegalcharacters "characters \"xml\" not\
+				    permitted in processing instruction target \"$tag\""]
 			} elseif {![regsub {\?$} $param {} param]} {
-			    uplevel #0 $options(-errorcommand) [list missingquestion "PI: expected '?' character around line $state(line)"]
+			    uplevel #0 $options(-errorcommand) \
+				[list missingquestion "PI: expected '?' character around line $state(line)"]
 			}
-			set code [catch {uplevel #0 $options(-processinginstructioncommand) [list $tag [string trimleft $param]]} msg]
+			set code [catch {
+				    uplevel #0 $options(-processinginstructioncommand) \
+					[list $tag [string trimleft $param]]
+				  } msg]
 			switch $code {
 			    0 {# OK}
 			    3 {
@@ -652,21 +635,29 @@
 			if {[regexp -nocase ^[cl $Wsp]*(SYSTEM|PUBLIC)(.*) $param x id param]} {
 			    switch [string toupper $id] {
 				SYSTEM {
-				    if {[regexp ^[cl $Wsp]+"([cl ^"]*)"(.*) $param x systemlit param] || [regexp ^[cl $Wsp]+'([cl ^']*)'(.*) $param x systemlit param]} {
+				    if {[regexp ^[cl $Wsp]+\"([cl ^\"]*)\"(.*) $param x systemlit param] || \
+					    [regexp ^[cl $Wsp]+'([cl ^']*)'(.*) $param x systemlit param]} {
 					set externalID [list SYSTEM $systemlit] ;# "
 				    } else {
-					uplevel #0 $options(-errorcommand) {XXX {syntax error: SYSTEM identifier not followed by literal}}
+					uplevel #0 $options(-errorcommand) \
+					    [list XXX "syntax error: SYSTEM identifier not followed by literal"]
 				    }
 				}
 				PUBLIC {
-				    if {[regexp ^[cl $Wsp]+"([cl ^"]*)"(.*) $param x pubidlit param] || [regexp ^[cl $Wsp]+'([cl ^']*)'(.*) $param x pubidlit param]} {
-					if {[regexp ^[cl $Wsp]+"([cl ^"]*)"(.*) $param x systemlit param] || [regexp ^[cl $Wsp]+'([cl ^']*)'(.*) $param x systemlit param]} {
+				    if {[regexp ^[cl $Wsp]+\"([cl ^\"]*)\"(.*) $param x pubidlit param] || \
+					    [regexp ^[cl $Wsp]+'([cl ^']*)'(.*) $param x pubidlit param]} {
+					if {[regexp ^[cl $Wsp]+\"([cl ^\"]*)\"(.*) $param x systemlit param] || \
+						[regexp ^[cl $Wsp]+'([cl ^']*)'(.*) $param x systemlit param]} {
 					    set externalID [list PUBLIC $pubidlit $systemlit]
 					} else {
-					    uplevel #0 $options(-errorcommand) [list syntaxerror "syntax error: PUBLIC identifier not followed by system literal around line $state(line)"]
+					    uplevel #0 $options(-errorcommand) \
+						[list syntaxerror "syntax error: PUBLIC identifier\
+						    not followed by system literal around line $state(line)"]
 					}
 				    } else {
-					uplevel #0 $options(-errorcommand) [list syntaxerror "syntax error: PUBLIC identifier not followed by literal around line $state(line)"]
+					uplevel #0 $options(-errorcommand) \
+					    [list syntaxerror "syntax error: PUBLIC identifier\
+						not followed by literal around line $state(line)"]
 				    }
 				}
 			    }
@@ -677,7 +668,8 @@
 
 			set state(inDTD) 1
 
-			ParseEvent:DocTypeDecl [array get options] $state(doc_name) $pubidlit $systemlit $options(-internaldtd)
+			ParseEvent:DocTypeDecl [array get options] $state(doc_name) \
+			    $pubidlit $systemlit $options(-internaldtd)
 
 			set state(inDTD) 0
 
@@ -717,12 +709,14 @@
 			} elseif {[regexp {(.*)]]$} $param discard cdata2]} {
 			    # processed CDATA (end in attribute)
 			    # Backslashes in param are quoted at this stage
-			    uplevel #0 $options(-characterdatacommand) [list $cdata1[subst -novariable -nocommand $cdata2]]
+			    uplevel #0 $options(-characterdatacommand) \
+				[list $cdata1[subst -novariable -nocommand $cdata2]]
 			    set text [subst -novariable -nocommand $text]
 			} elseif {[regexp {(.*)]]>(.*)} $text discard cdata2 text]} {
 			    # processed CDATA (end in text)
 			    # Backslashes in param and text are quoted at this stage
-			    uplevel #0 $options(-characterdatacommand) [list $cdata1[subst -novariable -nocommand $param]$empty>[subst -novariable -nocommand $cdata2]]
+			    uplevel #0 $options(-characterdatacommand) \
+				[list $cdata1[subst -novariable -nocommand $param]$empty>[subst -novariable -nocommand $cdata2]]
 			    set text [subst -novariable -nocommand $text]
 			} else {
 			    # start CDATA
@@ -737,18 +731,24 @@
 		    !ATTLIST -
 		    !ENTITY -
 		    !NOTATION {
-			uplevel #0 $options(-errorcommand) [list illegaldeclaration "[string range $tag 1 end] declaration not expected in document instance around line $state(line)"]
+			uplevel #0 $options(-errorcommand) \
+			    [list illegaldeclaration "[string range $tag 1 end] declaration\
+				not expected in document instance around line $state(line)"]
 		    }
 
 		    default {
-			uplevel #0 $options(-errorcommand) [list unknowninstruction "unknown processing instruction \"<$tag>\" around line $state(line)"]
+			uplevel #0 $options(-errorcommand) \
+			    [list unknowninstruction "unknown processing\
+				instruction \"<$tag>\" around line $state(line)"]
 		    }
 		}
 	    }
 	    *,1,* -
 	    *,0,/,/ {
 		# Syntax error
-	    	uplevel #0 $options(-errorcommand) [list syntaxerror "syntax error: closed/empty tag: tag $tag param $param empty $empty close $close around line $state(line)"]
+	    	uplevel #0 $options(-errorcommand) \
+		    [list syntaxerror "syntax error: closed/empty tag:\
+			tag $tag param $param empty $empty close $close around line $state(line)"]
 	    }
 	}
 
@@ -771,7 +771,15 @@
 		regsub -all {([][$\\{}])} $text {\\\1} text
 
 		# Mark entity references
-		regsub -all {&([^;]+);} $text [format {%s; %s {\1} ; %s %s} \}\} [namespace code [list Entity [array get options] $options(-entityreferencecommand) $options(-characterdatacommand) $options(entities)]] [namespace code [list DeProtect $options(-characterdatacommand)]] \{\{] text
+		regsub -all {&([^;]+);} $text \
+		    [format {%s; %s {\1} ; %s %s} \}\} \
+			[namespace code \
+			    [list Entity [array get options] \
+				  $options(-entityreferencecommand) \
+				  $options(-characterdatacommand) \
+				  $options(entities)]] \
+			[namespace code [list DeProtect $options(-characterdatacommand)]] \
+			\{\{] text
 		set text "uplevel #0 [namespace code [list DeProtect1 $options(-characterdatacommand)]] {{$text}}"
 		eval $text
 	    } else {
@@ -781,14 +789,16 @@
 		uplevel #0 $options(-characterdatacommand) [list $text]
 	    }
 	} elseif {[string length [string trim $text]]} {
-	    uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$text\" in document prolog around line $state(line)"]
+	    uplevel #0 $options(-errorcommand) \
+		[list unexpectedtext "unexpected text \"$text\" in document prolog around line $state(line)"]
 	}
 
     }
 
     # If this is the end of the document, close all open containers
     if {$options(-final) && [llength $state(stack)]} {
-	eval $options(-errorcommand) [list unclosedelement "element [lindex $state(stack) end] remains unclosed around line $state(line)"]
+	eval $options(-errorcommand) \
+	    [list unclosedelement "element [lindex $state(stack) end] remains unclosed around line $state(line)"]
     }
 
     return {}
@@ -886,7 +896,8 @@
     if {[string compare $options(-parseattributelistcommand) {}]} {
 	if {[catch {uplevel #0 $options(-parseattributelistcommand) [list $opts $attr]} attr]} {
 	    if {[string compare [lindex $attr 0] "unterminated attribute value"]} {
-		uplevel #0 $options(-errorcommand) [list unterminatedattribute "$attr around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list unterminatedattribute "$attr around line $state(line)"]
 		set attr {}
 	    } else {
 
@@ -910,7 +921,10 @@
 		    lappend attlist $attname $attvalue
 
 		    # Complete parsing the attribute list
-		    if {[catch {uplevel #0 $options(-parseattributelistcommand) [list $options(-statevariable) $remattlist]} attr]} {
+		    if {[catch {
+			    uplevel #0 $options(-parseattributelistcommand) \
+				       [list $options(-statevariable) $remattlist]
+			 } attr]} {
 			uplevel #0 $options(-errorcommand) [list $attr around line $state(line)]
 			set attr {}
 			set attlist {}
@@ -921,7 +935,8 @@
 		    set attr $attlist
 
 		} else {
-		    uplevel #0 $options(-errorcommand) [list unterminatedattribute "$attr around line $state(line)"]
+		    uplevel #0 $options(-errorcommand) \
+			[list unterminatedattribute "$attr around line $state(line)"]
 		    set attr {}
 		}
 	    }
@@ -1023,16 +1038,27 @@
 
     # WF check
     if {[string compare $tag [lindex $state(stack) end]]} {
-	uplevel #0 $options(-errorcommand) [list illegalendtag "end tag \"$tag\" does not match open element \"[lindex $state(stack) end]\" around line $state(line)"]
+	uplevel #0 $options(-errorcommand) \
+	    [list illegalendtag "end tag \"$tag\" does not match open\
+		element \"[lindex $state(stack) end]\" around line $state(line)"]
 	return
     }
 
     # Check whether this element has an expanded name
     upvar #0 $options(namespaces) namespaces
     set ns {}
-    if {0 && [regexp {([^:]+):(.*)$} $tag discard prefix tag]} {
-	set nsuri $namespaces([lindex [lsort -dictionary -decreasing [array names namespaces $prefix,*]] 0])
-	set ns [list -namespace $nsuri]
+    if {[regexp {([^:]+):(.*)$} $tag discard prefix tag1]} {
+	set nsspec [lsort -dictionary -decreasing [array names namespaces $prefix,*]]
+	if {[llength $nsspec]} {
+	    set tag $tag1
+	    set nsuri $namespaces([lindex $nsspec 0])
+	    set ns [list -namespace $nsuri]
+	} else {
+	    # HACK: ignore undeclared namespace (and replace it by default one)
+	    if {[llength $state(defaultNSURI)]} {
+		set ns [list -namespace [lindex $state(defaultNSURI) end]]
+	    }
+	}
     } elseif {[llength $state(defaultNSURI)]} {
 	set ns [list -namespace [lindex $state(defaultNSURI) end]]
     }
@@ -1041,6 +1067,7 @@
     if {[llength $state(defaultNS)]} {
 	if {[llength $state(stack)] == [lindex $state(defaultNS) end]} {
 	    set state(defaultNS) [lreplace $state(defaultNS) end end]
+	    set state(defaultNSURI) [lreplace $state(defaultNSURI) end end]
 	}
     }
     foreach nsspec [array names namespaces *,[llength $state(stack)]] {
@@ -1166,7 +1193,8 @@
 
 		# Reconstitute entity reference
 
-		uplevel #0 $options(-errorcommand) [list illegalentity "undefined entity reference \"$ref\""]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegalentity "undefined entity reference \"$ref\""]
 
 		return {}
 
@@ -1306,7 +1334,8 @@
 	    set PElist [lreplace $PElist end end]
 	    foreach {text entref} $PElist {
 		if {[string length [string trim $text]]} {
-		    uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text in internal DTD subset around line $state(line)"]
+		    uplevel #0 $options(-errorcommand) \
+			[list unexpectedtext "unexpected text in internal DTD subset around line $state(line)"]
 		}
 
 		# Expand parameter entity and recursively parse
@@ -1320,7 +1349,8 @@
 		    $externalParser parse $ExtPEnts($entref) -dtdsubset external
 		    #$externalParser free
 		} else {
-		    uplevel #0 $options(-errorcommand) [list illegalreference "reference to undeclared parameter entity \"$entref\""]
+		    uplevel #0 $options(-errorcommand) \
+			[list illegalreference "reference to undeclared parameter entity \"$entref\""]
 		}
 	    }
 
@@ -1484,7 +1514,8 @@
 	    if {[regexp $declExpr $value discard tag cmodel]} {
 		DTD:ELEMENT [array get options] $tag $cmodel
 	    } else {
-		uplevel #0 $options(-errorcommand) [list illegaldeclaration "malformed element declaration around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegaldeclaration "malformed element declaration around line $state(line)"]
 	    }
 	}
 
@@ -1499,7 +1530,8 @@
 		    return {}
 		}
 	    } else {
-		uplevel #0 $options(-errorcommand) [list illegaldeclaration "malformed attribute list declaration around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegaldeclaration "malformed attribute list declaration around line $state(line)"]
 	    }
 	}
 
@@ -1517,23 +1549,26 @@
 
 		if {[regexp $ExternalEntityExpr $value]} {
 		    DTD:ENTITY [array get options] $name [string trim $param] $value
-		} elseif {[regexp ("|')(.*?)\\1(.*) $value discard delimiter replText value]} {
+		} elseif {[regexp (\"|')(.*?)\\1(.*) $value discard delimiter replText value]} {
 
 		    if {[string length [string trim $value]]} {
-			uplevel #0 $options(-errorcommand) [list illegaldeclaration "malformed entity declaration around line $state(line)"]
+			uplevel #0 $options(-errorcommand) \
+			    [list illegaldeclaration "malformed entity declaration around line $state(line)"]
 		    } else {
 			DTD:ENTITY [array get options] $name [string trim $param] $delimiter$replText$delimiter
 		    }
-		} elseif {[regexp ("|')(.*) $value discard delimiter replText]} {
+		} elseif {[regexp (\"|')(.*) $value discard delimiter replText]} {
 		    append replText >$text
 		    set text {}
 		    set mode entity
 		} else {
-		    uplevel #0 $options(-errorcommand) [list illegaldeclaration "no delimiter for entity declaration around line $state(line)"]
+		    uplevel #0 $options(-errorcommand) \
+			[list illegaldeclaration "no delimiter for entity declaration around line $state(line)"]
 		}
 
 	    } else {
-		uplevel #0 $options(-errorcommand) [list illegaldeclaration "malformed entity declaration around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegaldeclaration "malformed entity declaration around line $state(line)"]
 	    }
 	}
 
@@ -1542,7 +1577,8 @@
 	    if {[regexp $declExpr param discard tag notation]} {
 		DTD:ENTITY [array get options] $tag $notation
 	    } else {
-		uplevel #0 $options(-errorcommand) [list illegaldeclaration "malformed entity declaration around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegaldeclaration "malformed entity declaration around line $state(line)"]
 	    }
 	}
 
@@ -1580,7 +1616,9 @@
 	!*INCLUDE* -
 	!*IGNORE* {
 	    if {$state(inInternalDTD)} {
-		uplevel #0 $options(-errorcommand) [list illegalsection "conditional section not permitted in internal DTD subset around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegalsection "conditional section not permitted in internal DTD\
+			subset around line $state(line)"]
 	    }
 
 	    if {[regexp {^!\[INCLUDE\[(.*)} $decl discard remainder]} {
@@ -1589,15 +1627,18 @@
 		if {[regexp {(.*?)]]$} $remainder discard r2]} {
 		    # section closed immediately
 		    if {[string length [string trim $r2]]} {
-			uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
+			uplevel #0 $options(-errorcommand) \
+			    [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
 		    }
 		} elseif {[regexp {(.*?)]](.*)} $value discard r2 r3]} {
 		    # section closed immediately
 		    if {[string length [string trim $r2]]} {
-			uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
+			uplevel #0 $options(-errorcommand) \
+			    [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
 		    }
 		    if {[string length [string trim $r3]]} {
-			uplevel #0 $options(-errorcommand) [list "unexpected text \"$r3\" in conditional section"]
+			uplevel #0 $options(-errorcommand) \
+			    [list "unexpected text \"$r3\" in conditional section"]
 		    }
 		} else {
 
@@ -1612,7 +1653,8 @@
 			    uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$t1\""]
 			}
 			if {![llength $state(condSections)]} {
-			    uplevel #0 $options(-errorcommand) [list illegalsection "extraneous conditional section close"]
+			    uplevel #0 $options(-errorcommand) \
+				[list illegalsection "extraneous conditional section close"]
 			}
 			set state(condSections) [lreplace $state(condSections) end end]
 			set text $t2
@@ -1626,15 +1668,18 @@
 		if {[regexp {(.*?)]]$} $remainder discard r2]} {
 		    # section closed immediately
 		    if {[string length [string trim $r2]]} {
-			uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
+			uplevel #0 $options(-errorcommand) \
+			    [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
 		    }
 		} elseif {[regexp {(.*?)]](.*)} $value discard r2 r3]} {
 		    # section closed immediately
 		    if {[string length [string trim $r2]]} {
-			uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
+			uplevel #0 $options(-errorcommand) \
+			    [list unexpectedtext "unexpected text \"$r2\" in conditional section"]
 		    }
 		    if {[string length [string trim $r3]]} {
-			uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$r3\" in conditional section"]
+			uplevel #0 $options(-errorcommand) \
+			    [list unexpectedtext "unexpected text \"$r3\" in conditional section"]
 		    }
 		} else {
 		    
@@ -1645,7 +1690,8 @@
 			    uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$t1\""]
 			}
 			if {![llength $state(condSections)]} {
-			    uplevel #0 $options(-errorcommand) [list illegalsection "extraneous conditional section close"]
+			    uplevel #0 $options(-errorcommand) \
+				[list illegalsection "extraneous conditional section close"]
 			}
 			set state(condSections) [lreplace $state(condSections) end end]
 			set text $t2
@@ -1653,7 +1699,8 @@
 
 		}
 	    } else {
-		uplevel #0 $options(-errorcommand) [list illegaldeclaration "illegal markup declaration \"$decl\" around line $state(line)"]
+		uplevel #0 $options(-errorcommand) \
+		    [list illegaldeclaration "illegal markup declaration \"$decl\" around line $state(line)"]
 	    }
 
 	}
@@ -1721,7 +1768,8 @@
 		set state(condSections) [lreplace $state(condSections) end end]
 		continue
 	    } else {
-		uplevel #0 $options(-errorcommand) [list missingdelimiter "IGNORE conditional section closing delimiter not found"]
+		uplevel #0 $options(-errorcommand) \
+		    [list missingdelimiter "IGNORE conditional section closing delimiter not found"]
 	    }
 	} elseif {[regexp ^(.*?)%($::sgml::Name)\;(.*)\$ $dtd discard data PEref remainder]} {
 	    set progress 1
@@ -1751,17 +1799,20 @@
 			# check for conditional section close
 			if {[regexp {]]>(.*)$} $text discard text]} {
 			    if {[string length [string trim $text]]} {
-				uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$text\""]
+				uplevel #0 $options(-errorcommand) \
+				    [list unexpectedtext "unexpected text \"$text\""]
 			    }
 			    if {![llength $state(condSections)]} {
-				uplevel #0 $options(-errorcommand) [list illegalsection "extraneous conditional section close"]
+				uplevel #0 $options(-errorcommand) \
+				    [list illegalsection "extraneous conditional section close"]
 			    }
 			    set state(condSections) [lreplace $state(condSections) end end]
 			    if {![string compare $mode "ignore"]} {
 				set mode {} ;# normal
 			    }
 			} else {
-			    uplevel #0 $options(-errorcommand) [list unexpectedtext "unexpected text \"$text\""]
+			    uplevel #0 $options(-errorcommand) \
+				[list unexpectedtext "unexpected text \"$text\""]
 			}
 		    }
 		}
@@ -1794,7 +1845,8 @@
 			$externalParser parse $ExtPEnts($PEref) -dtdsubset external
 			#$externalParser free
 		    } else {
-			uplevel #0 $options(-errorcommand) [list entityundeclared "parameter entity \"$PEref\" not declared"]
+			uplevel #0 $options(-errorcommand) \
+			    [list entityundeclared "parameter entity \"$PEref\" not declared"]
 		    }
 		}
 		set dtd $data$remainder
@@ -1806,7 +1858,8 @@
 			$externalParser parse $ExtPEnts($PEref) -dtdsubset external
 			#$externalParser free
 		    } else {
-			uplevel #0 $options(-errorcommand) [list entityundeclared "parameter entity \"$PEref\" not declared"]
+			uplevel #0 $options(-errorcommand) \
+			    [list entityundeclared "parameter entity \"$PEref\" not declared"]
 		    }
 		}
 		set dtd $text$remainder
@@ -1835,7 +1888,8 @@
 	    # No parameter entity references were found and 
 	    # the text does not contain a well-formed markup declaration
 	    # Avoid going into an infinite loop
-	    upvar #0 $options(-errorcommand) [list syntaxerror "external entity does not contain well-formed markup declaration"]
+	    upvar #0 $options(-errorcommand) \
+		[list syntaxerror "external entity does not contain well-formed markup declaration"]
 	    break
 	}
     }
@@ -1844,7 +1898,8 @@
 
     # Check that conditional sections have been closed properly
     if {[llength $state(condSections)] > $startCondSectionDepth} {
-	uplevel #0 $options(-errorcommand) [list syntaxerror "[lindex $state(condSections) end] conditional section not closed"]
+	uplevel #0 $options(-errorcommand) \
+	    [list syntaxerror "[lindex $state(condSections) end] conditional section not closed"]
     }
     if {[llength $state(condSections)] < $startCondSectionDepth} {
 	uplevel #0 $options(-errorcommand) [list syntaxerror "too many conditional section closures"]
@@ -1906,7 +1961,8 @@
 	    default {
 		# Don't parse the content model for now,
 		# just pass the model to the application
-		if {0 && [regexp [format {^\([%s]*#PCDATA[%s]*(\|([^)]+))?[%s]*\)*[%s]*$} $Wsp $Wsp $Wsp $Wsp] discard discard mtoks]} {
+		if {0 && [regexp [format {^\([%s]*#PCDATA[%s]*(\|([^)]+))?[%s]*\)*[%s]*$} $Wsp $Wsp $Wsp $Wsp] \
+				discard discard mtoks]} {
 		    set cm($name) [list MIXED [split $mtoks |]]
 		} elseif {0} {
 		    if {[catch {CModelParse $state(state) $value} result]} {
@@ -1987,9 +2043,11 @@
 	return -code error "illegal characters in specification"
     }
 
-    regsub -all [format {(%s)[%s]*(\?|\*|\+)?[%s]*(,|\|)?} $name $Wsp $Wsp] $spec [format {%sCModelSTname %s {\1} {\2} {\3}} \n $state] spec
+    regsub -all [format {(%s)[%s]*(\?|\*|\+)?[%s]*(,|\|)?} $name $Wsp $Wsp] $spec \
+	[format {%sCModelSTname %s {\1} {\2} {\3}} \n $state] spec
     regsub -all {\(} $spec "\nCModelSTopenParen $state " spec
-    regsub -all [format {\)[%s]*(\?|\*|\+)?[%s]*(,|\|)?} $Wsp $Wsp] $spec [format {%sCModelSTcloseParen %s {\1} {\2}} \n $state] spec
+    regsub -all [format {\)[%s]*(\?|\*|\+)?[%s]*(,|\|)?} $Wsp $Wsp] $spec \
+	[format {%sCModelSTcloseParen %s {\1} {\2}} \n $state] spec
 
     array set var {stack {} state start}
     eval $spec
@@ -2059,7 +2117,9 @@
 	}
 	:choice=, -
 	:seq=| {
-	    return -code error "syntax error in specification: incorrect delimiter after \"$cp\", should be \"[expr {$cs == "," ? "|" : ","}]\""
+	    return -code error \
+		"syntax error in specification: incorrect delimiter\
+		 after \"$cp\", should be \"[expr {$cs == "," ? "|" : ","}]\""
 	}
 	end=* {
 	    return -code error "syntax error in specification: no delimiter before \"$cp\""



More information about the Tkabber-dev mailing list