Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch schema Excluding Merge-Ins
This is equivalent to a diff from 1be47b3755 to 0b386f3852
2020-08-21
| ||
01:27 | Added the tdom::schema command. check-in: e4f2396201 user: rolf tags: trunk | |
01:22 | Merged from trunk. Closed-Leaf check-in: 0b386f3852 user: rolf tags: schema | |
00:53 | Merged proofreding work into. check-in: ee5267cf88 user: rolf tags: schema | |
00:07 | Added -onlyContents and -breakLines to asHTML. check-in: 59ab627f46 user: rolf tags: trunk | |
2018-12-06
| ||
22:13 | Renamed structure to schema. check-in: 084cbc63a1 user: rolf tags: schema | |
12:45 | wip Closed-Leaf check-in: 1be47b3755 user: rolf tags: structure | |
2018-12-03
| ||
21:55 | No need for the (deprecated) Tcl_VarEval(), just use Tcl_EvalObjv(). check-in: ef60fd49f4 user: rolf tags: structure | |
Changes to CHANGES.
1 +2020-08-21 Rolf Ade <rolf@pointsman.de> 2 + 3 + Added -onlyContents and -breakLines to asHTML. 4 + 5 +2020-08-17 Rolf Ade <rolf@pointsman.de> 6 + 7 + Updated TEA. 8 + 9 +2020-07-23 Rolf Ade <rolf@pointsman.de> 10 + 11 + Added -indent value "tab" to asXML and asJSON. 12 + 13 +2020-07-03 Rolf Ade <rolf@pointsman.de> 14 + 15 + User configurable separator character between namespace URI 16 + and local name for XML namespace-aware SAX parser: Added the 17 + option -namespaceseparator to the expat command. 18 + 19 +2020-05-14 Rolf Ade <rolf@pointsman.de> 20 + 21 + Added method clearString to the dom command. 22 + 23 +2019-12-31 Rolf Ade <rolf@pointsman.de> 24 + 25 + Updated to expat 2.2.9. 26 + 1 27 2018-10-12 Rolf Ade <rolf@pointsman.de> 2 28 3 29 Updated to expat 2.2.6. 4 30 5 31 2018-08-08 Rolf Ade <rolf@pointsman.de> 6 32 7 33 Changed the license to MPL 2.0.
Deleted README.
1 - 2 - 3 - tDOM - a XML/DOM/XPath/XSLT/HTML/JSON implementation for Tcl 4 - (Version 0.9.2) 5 - 6 - 7 -This directory contains a freely distributable thread-safe extension 8 -to Tcl/Tk called tDOM. 9 - 10 -tDOM contains: 11 - 12 - * for convenience expat 2.2.5, the XML parser originated from 13 - James Clark, although you're able to link tDOM with other 14 - expat versions or the library provided by the system. 15 - 16 - * building a DOM tree from XML in one go implemented in C for 17 - maximum performance and minimum memory usage, and DOM I and II 18 - methods to work on such a tree using either a OO-like or a 19 - handle syntax. 20 - 21 - * a Tcl interface to expat for event-like (SAX-like) XML parsing. 22 - 23 - * a complete, compliant and fast XPath implementation in C 24 - following the November 99 W3C recommendation for navigating and 25 - data extraction. 26 - 27 - * a fast XSLT implementation in C following the W3C Recommendation 28 - 16 November 1999. 29 - 30 - * optional DTD validation. 31 - 32 - * a JSON parser which parses any possible JSON input into a DOM 33 - tree without losing information. 34 - 35 - * an efficient and Tcl'ish way to create XML and HTML documents 36 - and JSON string. 37 - 38 - * as build option an interface to the gumbo HTML5 parser, which 39 - also digests almost any other HTML. 40 - 41 - * an even faster simple XML parser for trusted XML input. 42 - 43 - * A slim Tcl interface to use expat as pull-parser. 44 - 45 - * additional convenience methods. 46 - 47 - * and more. 48 - 49 - 50 -DOCUMENTATION 51 - 52 - The documentation is included into the source distribution in HTML 53 - and man format. Alternatively, read it online starting at 54 - http://tdom.org/index.html/doc/trunk/doc/index.html 55 - 56 - 57 -GETTING THE CODE 58 - 59 - The development repository is hosted at http://tdom.org and is 60 - mirrored at http://core.tcl.tk/tdom. You are encouraged to use 61 - trunk. 62 - 63 - If you insist on using an older tDOM with lesser features and 64 - probably more bugs, you should use the latest release 0.9.1. Get 65 - the source code release from 66 - http://tdom.org/downloads/tdom-0.9.1-src.tgz or 67 - http://tdom.org/downloads/tdom-0.9.1-src.zip 68 - 69 - Windows binaries (32 bit as well as 64 bit) of the 0.9.1 release 70 - are also available. Get it from 71 - http://tdom.org/downloads/tdom-0.9.1-windows-x64.zip and 72 - http://tdom.org/downloads/tdom-0.9.1-windows-x86.zip 73 - 74 - The provided windows binaries include (statically linked) the 75 - HTML5 parser. 76 - 77 - 78 -COMPILING tDOM 79 - 80 - Depending on your platform (unix/mac or win), go to the 81 - corresponding directory and invoke the configure script: 82 - 83 - ../configure 84 - make 85 - make test 86 - make install 87 - 88 - Alternatively, you can build the tDOM package in just about any 89 - directory elsewhere on the filesystem (since TEA-compatible). 90 - 91 - You might also want to do "../configure --help" to get a list of 92 - all supported options of the configure script. In the "unix" 93 - directory there is a "CONFIG" file containing some examples on how 94 - to invoke the "configure" script for some common cases. You can 95 - peek there. This file also includes a short description of the 96 - tDOM specific configure options. 97 - 98 - Since tDOM is TEA-compatible you should be able to build it using 99 - the MinGW build environment for Windows. There is also the MSVC 100 - nmake file so you can compile the package with Microsoft tools. 101 - Refer to the README in the win directory for more details about 102 - building on Windows. 103 - 104 - The compile process will build the tDOM shared library suitable for 105 - loading into the Tcl shell using standard "package require" mechanism. 106 - 107 - 108 -REPORTING BUGS 109 - 110 - Please head to http://tdom.org/index.html/ticket and click on "New 111 - Ticket". Log in as anonymous and report your findings. If you 112 - prefer to have an individual login write Rolf a mail. 113 - 114 - 115 -HISTORY 116 - 117 - tDOM was started by Jochen Loewer (loewerj@hotmail.com) and 118 - developed by Jochen and Rolf Ade (rolf@pointsman.de) with 119 - contributions by Zoran Vasiljevic (zv@archiware.com). Since more 120 - than a dozen years it is maintained and developed by Rolf Ade.
Added README.md.
1 + 2 +## tDOM - a XML / DOM / XPath / XSLT / HTML / JSON implementation for Tcl Version 0.9.2 3 + 4 +### tDOM contains: 5 + 6 + * for convenience expat 2.2.9, the XML parser originated from 7 + James Clark, although you're able to link tDOM with other 8 + expat versions or the library provided by the system. 9 + 10 + * building a DOM tree from XML in one go implemented in C for 11 + maximum performance and minimum memory usage, and DOM I and II 12 + methods to work on such a tree using either a OO-like or a 13 + handle syntax. 14 + 15 + * a Tcl interface to expat for event-like (SAX-like) XML parsing. 16 + 17 + * a complete, compliant and fast XPath implementation in C 18 + following the November 99 W3C recommendation for navigating and 19 + data extraction. 20 + 21 + * a fast XSLT implementation in C following the W3C Recommendation 22 + 16 November 1999. 23 + 24 + * optional DTD validation. 25 + 26 + * a rich and Tcl'ish language to describe structures and to 27 + validate XML data or DOM trees or other forms of hierarchically 28 + data with that. 29 + 30 + * a JSON parser which parses any possible JSON input into a DOM 31 + tree without losing information. 32 + 33 + * an efficient and Tcl'ish way to create XML and HTML documents 34 + and JSON strings. 35 + 36 + * as build option an interface to the gumbo HTML5 parser, which 37 + also digests almost any other HTML. 38 + 39 + * an even faster simple XML parser for trusted XML input. 40 + 41 + * a slim Tcl interface to use expat as pull-parser. 42 + 43 + * a secure way to share DOM trees by threads 44 + 45 + * additional convenience methods. 46 + 47 + * and more. 48 + 49 + 50 +### Documentation 51 + 52 +The documentation is included into the source distribution in HTML and 53 +man format. Alternatively, read it 54 +[online](http://tdom.org/index.html/doc/trunk/doc/index.html). 55 + 56 + 57 +### Getting the code 58 + 59 +The development repository is hosted at <http://tdom.org> and is 60 +mirrored at <http://core.tcl.tk/tdom>. You are invited to use trunk 61 +which you get as 62 +[tarball](http://tdom.org/index.html/tarball/trunk/tdom-trunk.tar.gz) 63 +or as [zip archive](http://tdom.org/index.html/zip/trunk/tdom-trunk.zip) 64 + 65 +The latest release is 0.9.2. Get the source code as 66 +[tarball](http://tdom.org/downloads/tdom-0.9.2-src.tgz) or 67 +as [zip archive](http://tdom.org/downloads/tdom-0.9.2-src.zip). 68 + 69 +Windows binaries of the 0.9.2 release are also available. Get it for 70 +[64 bit](http://tdom.org/downloads/tdom-0.9.2-windows-x64.zip) or [32 71 +bit](http://tdom.org/downloads/tdom-0.9.2-windows-x86.zip). 72 + 73 +The provided windows binaries include (statically linked) the 74 +HTML5 parser. 75 + 76 + 77 +### Compiling tdom 78 + 79 +Depending on your platform (unix/mac or win), go to the 80 +corresponding directory and invoke the configure script: 81 + 82 + ../configure 83 + make 84 + make test 85 + make install 86 + 87 +Alternatively, you can build the tDOM package in just about any 88 +directory elsewhere on the filesystem (since TEA-compatible). 89 + 90 +You might also want to do "../configure --help" to get a list of 91 +all supported options of the configure script. In the "unix" 92 +directory there is a "CONFIG" file containing some examples on how 93 +to invoke the "configure" script for some common cases. You can 94 +peek there. This file also includes a short description of the 95 +tDOM specific configure options. 96 + 97 +Since tDOM is TEA-compatible you should be able to build it using 98 +the MinGW build environment for Windows. There is also the MSVC 99 +nmake file so you can compile the package with Microsoft tools. 100 +Refer to the README in the win directory for more details about 101 +building on Windows. 102 + 103 +The compile process will build the tDOM shared library suitable for 104 +loading into the Tcl shell using standard "package require" mechanism. 105 + 106 + 107 +### Reporting bugs 108 + 109 +Open a [ticket](http://tdom.org/index.html/ticket). Log in as 110 +anonymous and report your findings. If you prefer to have an 111 +individual login write Rolf a mail. 112 + 113 + 114 +### History 115 + 116 +tDOM was started by Jochen Loewer (loewerj@hotmail.com) and 117 +developed by Jochen and Rolf Ade (rolf@pointsman.de) with 118 +contributions by Zoran Vasiljevic (zv@archiware.com). Since more 119 +than a dozen years it is maintained and developed by Rolf Ade. 120 + 121 + 122 +### ... ahh, Licensing!! 123 + 124 +Sigh. See LICENSE file.
Added apps/toschema.tcl.
1 + 2 +package require tdom 3 +package require uri 4 + 5 +variable dtdStart "" 6 +variable dtdFinished 0 7 +variable indent 4 8 + 9 +proc indent {} { 10 + variable indent 11 + upvar level level 12 + return [string repeat " " [expr {$indent * $level}]] 13 +} 14 + 15 +proc fromDTD_serialize {level type quant name content} { 16 + variable nslookup 17 + 18 + switch $type { 19 + "NAME" { 20 + set parts [split $name :] 21 + if {[llength $parts] == 2 && [info exists nslookup([lindex $parts 0])]} { 22 + puts "[indent]namespace $nslookup([lindex $parts 0]) {" 23 + incr level 24 + puts "[indent]element [lindex $parts 1] $quant" 25 + incr level -1 26 + puts "[indent]}" 27 + } else { 28 + puts "[indent]element $name $quant" 29 + } 30 + return 31 + } 32 + "MIXED" { 33 + if {[llength $content] == 0} { 34 + puts "[indent]text" 35 + return 36 + } 37 + puts "[indent]mixed \{" 38 + } 39 + "EMPTY" { 40 + return 41 + } 42 + "ANY" { 43 + puts "[indent]ANY\}" 44 + return 45 + } 46 + "SEQ" { 47 + if {$level == 1 && $quant eq ""} { 48 + # At least directly below defelement there isn't any 49 + # need to wrap a ! SEQ into a group container - 50 + # defelement childs are already processed as sequence 51 + # while validating. 52 + foreach cp $content { 53 + fromDTD_serialize $level {*}$cp 54 + } 55 + return 56 + } else { 57 + puts "[indent]group $quant \{" 58 + } 59 + } 60 + "CHOICE" { 61 + puts "[indent]choice $quant \{" 62 + } 63 + } 64 + foreach cp $content { 65 + fromDTD_serialize [expr {$level +1}] {*}$cp 66 + } 67 + puts "[indent]\}" 68 +} 69 + 70 +proc fromDTD_generate {} { 71 + variable dtdStart 72 + variable dtdElements 73 + variable dtdAttributes 74 + variable nslookup 75 + 76 + if {$dtdStart ne ""} { 77 + if {![info exists dtdElements($dtdStart)]} { 78 + puts "Document element not defined." 79 + exit 1 80 + } 81 + puts "start $dtdStart" 82 + } 83 + set elements [lsort [array names dtdElements]] 84 + set startInd [lsearch -exact $elements $dtdStart] 85 + set elements [lreplace $elements $startInd $startInd] 86 + set elements [linsert $elements 0 $dtdStart] 87 + set level 1 88 + foreach name $elements { 89 + # First round over attributes to get possible namespace 90 + # declarations 91 + foreach {attkey attDef} [array get dtdAttributes $name,*] { 92 + lassign $attDef attname type default isRequired 93 + if {$attname eq "xmlns"} { 94 + if {$default ne ""} { 95 + set nslookup(:default) $default 96 + } 97 + } else { 98 + set parts [split $attname ":"] 99 + if {[llength $parts] == 2} { 100 + switch [lindex $parts 0] { 101 + "xml" { 102 + set nslookup(xml) "http://www.w3.org/XML/1998/namespace" 103 + } 104 + "xmlns" { 105 + if {$default ne ""} { 106 + set nslookup([lindex $parts 1]) $default 107 + } 108 + } 109 + } 110 + } 111 + } 112 + } 113 + # Heuristic to get namespace right 114 + set namespace "" 115 + if {[info exists nslookup(:default)] && $nslookup(:default) ne ""} { 116 + set namespace $nslookup(:default) 117 + } 118 + set parts [split $name ":"] 119 + set schemaName $name 120 + if {[llength $parts] == 2} { 121 + set prefix [lindex $parts 0] 122 + if {[info exists nslookup($prefix)]} { 123 + set namespace $nslookup($prefix) 124 + set schemaName [lindex $parts 1] 125 + } else { 126 + # Hmmm. Either dtd error or the namespace is 127 + # defined somewhere on the ancestors. To be 128 + # handled. TODO 129 + } 130 + } 131 + if {$namespace ne ""} { 132 + puts "defelement $schemaName $namespace \{" 133 + } else { 134 + puts "defelement $schemaName \{" 135 + } 136 + # Second round over attributes for the actualy attribute 137 + # declarations. 138 + foreach {attkey attDef} [array get dtdAttributes $name,*] { 139 + lassign $attDef attname type default isRequired 140 + set parts [split $attname ":"] 141 + if {[llength $parts] == 2} { 142 + set prefix [lindex $parts 0] 143 + if {![info exists nslookup($prefix)]} { 144 + # Hmmm. Either dtd error or the namespace is 145 + # defined somewhere on the ancestors. To be 146 + # handled. TODO 147 + set cmd "attribute $attname" 148 + } else { 149 + set cmd "nsattribute [lindex $parts 1] $nslookup($prefix)" 150 + } 151 + } else { 152 + set cmd "attribute $attname" 153 + } 154 + if {$isRequired && $default != ""} { 155 + puts "[indent]$cmd ? {[list "fixed" $default]}" 156 + continue 157 + } 158 + switch $type { 159 + "ENTITY" - 160 + "ENTITIES" - 161 + "NOTATION" { 162 + # All above to be done 163 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}]" 164 + } 165 + "NMTOKEN" { 166 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}] \{nmtoken\}" 167 + } 168 + "ID" { 169 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}] \{nmtoken;id\}" 170 + } 171 + "IDREF" { 172 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}] \{idref\}" 173 + } 174 + "IDREFS" { 175 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}] \{split \{idref\}\}" 176 + } 177 + "NMTOKENS" { 178 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}] \{nmtokens\}" 179 + } 180 + "CDATA" { 181 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}]" 182 + } 183 + default { 184 + if {[string index $type 0] ne "("} { 185 + # Ups. Should not happen. 186 + error "Unexpeced (invalid) attribute type '$type'" 187 + } 188 + puts "[indent]$cmd [expr {$isRequired ? "" : "?"}] {enumeration {[split [string trim $type "()"] "|"]}}" 189 + } 190 + } 191 + } 192 + fromDTD_serialize 1 {*}$dtdElements($name) 193 + puts "\}" 194 + } 195 +} 196 + 197 +proc fromDTD_startDoctypeDecl {name systemID publicID hasInternalSubset} { 198 + variable dtdStart $name 199 + variable dtdFinished 0 200 +} 201 + 202 +proc fromDTD_endDoctypeDecl {args} { 203 + variable dtdFinished 1 204 + 205 + fromDTD_generate 206 +} 207 + 208 +proc fromDTD_elementDecl {name content} { 209 + variable dtdElements 210 + 211 + set dtdElements($name) $content 212 +} 213 + 214 +proc fromDTD_attlistDecl {elname name type default isRequired} { 215 + variable dtdAttributes 216 + 217 + set dtdAttributes($elname,$name) [list $name $type $default $isRequired] 218 +} 219 + 220 +proc fromDTD {file} { 221 + 222 + ::xml::parser p \ 223 + -baseurl [tdom::baseURL $file] \ 224 + -paramentityparsing always \ 225 + -externalentitycommand tdom::extRefHandler \ 226 + -startdoctypedeclcommand fromDTD_startDoctypeDecl \ 227 + -enddoctypedeclcommand fromDTD_endDoctypeDecl \ 228 + -elementdeclcommand fromDTD_elementDecl \ 229 + -attlistdeclcommand fromDTD_attlistDecl 230 + 231 + p parse [tdom::xmlReadFile $file] 232 +} 233 + 234 +proc usage {} { 235 + puts "$argv0 ?options? file" 236 +} 237 + 238 +proc run {args} { 239 + if {[llength $args] == 1} { 240 + set file [lindex $args 0] 241 + if {![file readable $file] || ![file isfile $file]} { 242 + puts stderr "Can't open '$file'" 243 + exit 1 244 + } 245 + set needToGuess 0 246 + switch [file extension $file] { 247 + ".xml" { 248 + fromDTD $file 249 + } 250 + default { 251 + set needToGuess 1 252 + } 253 + } 254 + if {$needToGuess} { 255 + # Just probe everything we have in no specific order 256 + foreach reader { 257 + fromDTD 258 + } { 259 + if {![catch {$reader $file}]} { 260 + return 261 + } 262 + } 263 + } 264 + return 265 + } 266 + usage 267 +} 268 + 269 +run {*}$argv 270 +
Changes to configure.
615 615 # include <stdint.h> 616 616 #endif 617 617 #ifdef HAVE_UNISTD_H 618 618 # include <unistd.h> 619 619 #endif" 620 620 621 621 ac_subst_vars='LTLIBOBJS 622 -LIBOBJS 623 622 PKG_STUB_LIB_PATH 624 623 PKG_BUILD_STUB_LIB_PATH 625 624 PKG_STUB_LIB_SPEC 626 625 PKG_BUILD_STUB_LIB_SPEC 627 626 TDOMSHELL 628 627 TCLSH_PROG 629 628 VC_MANIFEST_EMBED_EXE 630 629 VC_MANIFEST_EMBED_DLL 631 630 RANLIB_STUB 632 631 MAKE_STUB_LIB 633 632 MAKE_STATIC_LIB 634 633 MAKE_SHARED_LIB 635 634 MAKE_LIB 636 -TCL_DBGX 637 635 LDFLAGS_DEFAULT 638 636 CFLAGS_DEFAULT 639 637 TDOM_LD_SEARCH_FLAGS 640 638 LD_LIBRARY_PATH_VAR 641 639 SHLIB_CFLAGS 642 640 SHLIB_LD_LIBS 643 641 SHLIB_LD 644 642 STLIB_LD 643 +LDFLAGS_OPTIMIZE 644 +LDFLAGS_DEBUG 645 645 CFLAGS_WARNING 646 646 CFLAGS_OPTIMIZE 647 647 CFLAGS_DEBUG 648 +LIBOBJS 648 649 RC 649 -CELIB_DIR 650 650 AR 651 651 STUBS_BUILD 652 652 SHARED_BUILD 653 653 TCL_THREADS 654 654 TCL_INCLUDES 655 +PKG_CONFIG 655 656 PKG_OBJECTS 656 657 PKG_SOURCES 657 658 EGREP 658 659 GREP 659 660 RANLIB 660 661 SET_MAKE 661 662 CPP ................................................................................ 713 714 pdfdir 714 715 dvidir 715 716 htmldir 716 717 infodir 717 718 docdir 718 719 oldincludedir 719 720 includedir 721 +runstatedir 720 722 localstatedir 721 723 sharedstatedir 722 724 sysconfdir 723 725 datadir 724 726 datarootdir 725 727 libexecdir 726 728 sbindir ................................................................................ 747 749 with_tclinclude 748 750 enable_threads 749 751 enable_shared 750 752 enable_stubs 751 753 enable_64bit 752 754 enable_64bit_vis 753 755 enable_rpath 754 -enable_wince 755 -with_celib 756 756 enable_symbols 757 757 enable_dtd 758 758 enable_ns 759 759 enable_ucmd 760 760 enable_tdomalloc 761 761 enable_lessns 762 +enable_schema 762 763 ' 763 764 ac_precious_vars='build_alias 764 765 host_alias 765 766 target_alias 766 767 CC 767 768 CFLAGS 768 769 LDFLAGS ................................................................................ 803 804 sbindir='${exec_prefix}/sbin' 804 805 libexecdir='${exec_prefix}/libexec' 805 806 datarootdir='${prefix}/share' 806 807 datadir='${datarootdir}' 807 808 sysconfdir='${prefix}/etc' 808 809 sharedstatedir='${prefix}/com' 809 810 localstatedir='${prefix}/var' 811 +runstatedir='${localstatedir}/run' 810 812 includedir='${prefix}/include' 811 813 oldincludedir='/usr/include' 812 814 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' 813 815 infodir='${datarootdir}/info' 814 816 htmldir='${docdir}' 815 817 dvidir='${docdir}' 816 818 pdfdir='${docdir}' ................................................................................ 1054 1056 ac_prev=psdir ;; 1055 1057 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) 1056 1058 psdir=$ac_optarg ;; 1057 1059 1058 1060 -q | -quiet | --quiet | --quie | --qui | --qu | --q \ 1059 1061 | -silent | --silent | --silen | --sile | --sil) 1060 1062 silent=yes ;; 1063 + 1064 + -runstatedir | --runstatedir | --runstatedi | --runstated \ 1065 + | --runstate | --runstat | --runsta | --runst | --runs \ 1066 + | --run | --ru | --r) 1067 + ac_prev=runstatedir ;; 1068 + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ 1069 + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ 1070 + | --run=* | --ru=* | --r=*) 1071 + runstatedir=$ac_optarg ;; 1061 1072 1062 1073 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) 1063 1074 ac_prev=sbindir ;; 1064 1075 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ 1065 1076 | --sbi=* | --sb=*) 1066 1077 sbindir=$ac_optarg ;; 1067 1078 ................................................................................ 1192 1203 esac 1193 1204 fi 1194 1205 1195 1206 # Check all directory arguments for consistency. 1196 1207 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ 1197 1208 datadir sysconfdir sharedstatedir localstatedir includedir \ 1198 1209 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ 1199 - libdir localedir mandir 1210 + libdir localedir mandir runstatedir 1200 1211 do 1201 1212 eval ac_val=\$$ac_var 1202 1213 # Remove trailing slashes. 1203 1214 case $ac_val in 1204 1215 */ ) 1205 1216 ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` 1206 1217 eval $ac_var=\$ac_val;; ................................................................................ 1345 1356 Fine tuning of the installation directories: 1346 1357 --bindir=DIR user executables [EPREFIX/bin] 1347 1358 --sbindir=DIR system admin executables [EPREFIX/sbin] 1348 1359 --libexecdir=DIR program executables [EPREFIX/libexec] 1349 1360 --sysconfdir=DIR read-only single-machine data [PREFIX/etc] 1350 1361 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 1351 1362 --localstatedir=DIR modifiable single-machine data [PREFIX/var] 1363 + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] 1352 1364 --libdir=DIR object code libraries [EPREFIX/lib] 1353 1365 --includedir=DIR C header files [PREFIX/include] 1354 1366 --oldincludedir=DIR C header files for non-gcc [/usr/include] 1355 1367 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 1356 1368 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 1357 1369 --infodir=DIR info documentation [DATAROOTDIR/info] 1358 1370 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] ................................................................................ 1382 1394 --enable-threads build with threads (default: on) 1383 1395 --enable-shared build and link with shared libraries (default: on) 1384 1396 --enable-stubs build and link with stub libraries. Always true for 1385 1397 shared builds (default: on) 1386 1398 --enable-64bit enable 64bit support (default: off) 1387 1399 --enable-64bit-vis enable 64bit Sparc VIS support (default: off) 1388 1400 --disable-rpath disable rpath support (default: on) 1389 - --enable-wince enable Win/CE support (where applicable) 1390 1401 --enable-symbols build with debugging symbols (default: off) 1391 1402 --enable-dtd build with dtd support (default: on) 1392 1403 --enable-ns build with XML namespace support (default: on) 1393 1404 --enable-unknown enable built-in unknown command (default: off) 1394 1405 --enable-tdomalloc build with the tDOM allocator (default: off) 1395 1406 --enable-lessns build with lower limit for XML ns declarations 1396 1407 (default: off) 1408 + --enable-schema build with valiation features (default: on) 1397 1409 1398 1410 Optional Packages: 1399 1411 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 1400 1412 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 1401 1413 --with-tcl directory containing tcl configuration 1402 1414 (tclConfig.sh) 1403 1415 --with-aolserver directory with AOLserver distribution 1404 1416 --with-expat directory with expat installation 1405 1417 --with-entropy source of entropy to use 1406 1418 --with-tclinclude directory containing the public Tcl header files 1407 - --with-celib=DIR use Windows/CE support library from DIR 1408 1419 1409 1420 Some influential environment variables: 1410 1421 CC C compiler command 1411 1422 CFLAGS C compiler flags 1412 1423 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a 1413 1424 nonstandard directory <lib dir> 1414 1425 LIBS libraries to pass to the linker, e.g. -l<library> ................................................................................ 1752 1763 fi 1753 1764 eval ac_res=\$$3 1754 1765 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1755 1766 $as_echo "$ac_res" >&6; } 1756 1767 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1757 1768 1758 1769 } # ac_fn_c_check_func 1770 + 1771 +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES 1772 +# ------------------------------------------- 1773 +# Tests whether TYPE exists after having included INCLUDES, setting cache 1774 +# variable VAR accordingly. 1775 +ac_fn_c_check_type () 1776 +{ 1777 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1778 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1779 +$as_echo_n "checking for $2... " >&6; } 1780 +if eval \${$3+:} false; then : 1781 + $as_echo_n "(cached) " >&6 1782 +else 1783 + eval "$3=no" 1784 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1785 +/* end confdefs.h. */ 1786 +$4 1787 +int 1788 +main () 1789 +{ 1790 +if (sizeof ($2)) 1791 + return 0; 1792 + ; 1793 + return 0; 1794 +} 1795 +_ACEOF 1796 +if ac_fn_c_try_compile "$LINENO"; then : 1797 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1798 +/* end confdefs.h. */ 1799 +$4 1800 +int 1801 +main () 1802 +{ 1803 +if (sizeof (($2))) 1804 + return 0; 1805 + ; 1806 + return 0; 1807 +} 1808 +_ACEOF 1809 +if ac_fn_c_try_compile "$LINENO"; then : 1810 + 1811 +else 1812 + eval "$3=yes" 1813 +fi 1814 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 1815 +fi 1816 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 1817 +fi 1818 +eval ac_res=\$$3 1819 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1820 +$as_echo "$ac_res" >&6; } 1821 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1822 + 1823 +} # ac_fn_c_check_type 1824 + 1825 +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES 1826 +# ------------------------------------------------------- 1827 +# Tests whether HEADER exists, giving a warning if it cannot be compiled using 1828 +# the include files in INCLUDES and setting the cache variable VAR 1829 +# accordingly. 1830 +ac_fn_c_check_header_mongrel () 1831 +{ 1832 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1833 + if eval \${$3+:} false; then : 1834 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1835 +$as_echo_n "checking for $2... " >&6; } 1836 +if eval \${$3+:} false; then : 1837 + $as_echo_n "(cached) " >&6 1838 +fi 1839 +eval ac_res=\$$3 1840 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1841 +$as_echo "$ac_res" >&6; } 1842 +else 1843 + # Is the header compilable? 1844 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 1845 +$as_echo_n "checking $2 usability... " >&6; } 1846 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1847 +/* end confdefs.h. */ 1848 +$4 1849 +#include <$2> 1850 +_ACEOF 1851 +if ac_fn_c_try_compile "$LINENO"; then : 1852 + ac_header_compiler=yes 1853 +else 1854 + ac_header_compiler=no 1855 +fi 1856 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 1857 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 1858 +$as_echo "$ac_header_compiler" >&6; } 1859 + 1860 +# Is the header present? 1861 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 1862 +$as_echo_n "checking $2 presence... " >&6; } 1863 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1864 +/* end confdefs.h. */ 1865 +#include <$2> 1866 +_ACEOF 1867 +if ac_fn_c_try_cpp "$LINENO"; then : 1868 + ac_header_preproc=yes 1869 +else 1870 + ac_header_preproc=no 1871 +fi 1872 +rm -f conftest.err conftest.i conftest.$ac_ext 1873 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 1874 +$as_echo "$ac_header_preproc" >&6; } 1875 + 1876 +# So? What about this header? 1877 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( 1878 + yes:no: ) 1879 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 1880 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} 1881 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 1882 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} 1883 + ;; 1884 + no:yes:* ) 1885 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 1886 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} 1887 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 1888 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} 1889 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 1890 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} 1891 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 1892 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} 1893 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 1894 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} 1895 + ;; 1896 +esac 1897 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1898 +$as_echo_n "checking for $2... " >&6; } 1899 +if eval \${$3+:} false; then : 1900 + $as_echo_n "(cached) " >&6 1901 +else 1902 + eval "$3=\$ac_header_compiler" 1903 +fi 1904 +eval ac_res=\$$3 1905 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1906 +$as_echo "$ac_res" >&6; } 1907 +fi 1908 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1909 + 1910 +} # ac_fn_c_check_header_mongrel 1759 1911 cat >config.log <<_ACEOF 1760 1912 This file contains any messages produced by compilers while 1761 1913 running configure, to aid debugging if configure makes a mistake. 1762 1914 1763 1915 It was created by tdom $as_me 0.9.2, which was 1764 1916 generated by GNU Autoconf 2.69. Invocation command line was 1765 1917 ................................................................................ 2130 2282 # If the user did not set CFLAGS, set it now to keep macros 2131 2283 # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2". 2132 2284 if test "${CFLAGS+set}" != "set" ; then 2133 2285 CFLAGS="" 2134 2286 fi 2135 2287 2136 2288 case "`uname -s`" in 2137 - *win32*|*WIN32*|*MINGW32_*|*MINGW64_*) 2289 + *win32*|*WIN32*|*MINGW32_*|*MINGW64_*|*MSYS_*) 2138 2290 # Extract the first word of "cygpath", so it can be a program name with args. 2139 2291 set dummy cygpath; ac_word=$2 2140 2292 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2141 2293 $as_echo_n "checking for $ac_word... " >&6; } 2142 2294 if ${ac_cv_prog_CYGPATH+:} false; then : 2143 2295 $as_echo_n "(cached) " >&6 2144 2296 else ................................................................................ 2249 2401 if test "$?" -ne 0 ; then 2250 2402 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 2251 2403 $as_echo "$as_me: WARNING: can't find uname command" >&2;} 2252 2404 tcl_cv_sys_version=unknown 2253 2405 else 2254 2406 if test "`uname -s`" = "AIX" ; then 2255 2407 tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 2408 + fi 2409 + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then 2410 + tcl_cv_sys_version=NetBSD-Debian 2256 2411 fi 2257 2412 fi 2258 2413 fi 2259 2414 2260 2415 fi 2261 2416 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 2262 2417 $as_echo "$tcl_cv_sys_version" >&6; } ................................................................................ 2379 2534 fi 2380 2535 2381 2536 # on Darwin, check in Framework installation locations 2382 2537 if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then 2383 2538 for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ 2384 2539 `ls -d /Library/Frameworks 2>/dev/null` \ 2385 2540 `ls -d /Network/Library/Frameworks 2>/dev/null` \ 2386 - `ls -d /System/Library/Frameworks 2>/dev/null` \ 2387 2541 `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2388 2542 `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Network/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2389 2543 `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2390 2544 ; do 2391 2545 if test -f "$i/Tcl.framework/tclConfig.sh" ; then 2392 2546 ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" 2393 2547 break ................................................................................ 3264 3418 $as_echo "loading" >&6; } 3265 3419 . "${TCL_BIN_DIR}/tclConfig.sh" 3266 3420 else 3267 3421 { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5 3268 3422 $as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; } 3269 3423 fi 3270 3424 3271 - # eval is required to do the TCL_DBGX substitution 3272 - eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" 3273 - eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" 3274 - 3275 3425 # If the TCL_BIN_DIR is the build directory (not the install directory), 3276 3426 # then set the common variable name to the value of the build variables. 3277 3427 # For example, the variable TCL_LIB_SPEC will be set to the value 3278 3428 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC 3279 3429 # instead of TCL_BUILD_LIB_SPEC since it will work with both an 3280 3430 # installed and uninstalled version of Tcl. 3281 3431 if test -f "${TCL_BIN_DIR}/Makefile" ; then ................................................................................ 3301 3451 TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}" 3302 3452 TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}" 3303 3453 fi 3304 3454 ;; 3305 3455 esac 3306 3456 fi 3307 3457 3308 - # eval is required to do the TCL_DBGX substitution 3309 - eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" 3310 - eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" 3311 - eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" 3312 - eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" 3313 - 3314 3458 3315 3459 3316 3460 3317 3461 3318 3462 3319 3463 3320 3464 ................................................................................ 3340 3484 3341 3485 ; 3342 3486 return 0; 3343 3487 } 3344 3488 _ACEOF 3345 3489 if ac_fn_c_try_compile "$LINENO"; then : 3346 3490 3347 - TEA_PLATFORM="unix" 3491 + # first test we've already retrieved platform (cross-compile), fallback to unix otherwise: 3492 + TEA_PLATFORM="${TEA_PLATFORM-unix}" 3348 3493 CYGPATH=echo 3349 3494 3350 3495 else 3351 3496 3352 3497 TEA_PLATFORM="windows" 3353 3498 # Extract the first word of "cygpath", so it can be a program name with args. 3354 3499 set dummy cygpath; ac_word=$2 ................................................................................ 4925 5070 4926 5071 if test x"${ac_cv_c_expat}" = x ; then 4927 5072 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using bundled expat distribution" >&5 4928 5073 $as_echo "Using bundled expat distribution" >&6; } 4929 5074 4930 5075 vars="expat/xmlrole.c \ 4931 5076 expat/xmltok.c \ 4932 - expat/xmlparse.c \ 4933 - expat/loadlibrary.c" 5077 + expat/xmlparse.c" 4934 5078 for i in $vars; do 4935 5079 case $i in 4936 5080 \$*) 4937 5081 # allow $-var names 4938 5082 PKG_SOURCES="$PKG_SOURCES $i" 4939 5083 PKG_OBJECTS="$PKG_OBJECTS $i" 4940 5084 ;; ................................................................................ 4985 5129 4986 5130 4987 5131 4988 5132 vars="-lexpat" 4989 5133 for i in $vars; do 4990 5134 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 4991 5135 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 4992 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 5136 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 4993 5137 fi 4994 5138 PKG_LIBS="$PKG_LIBS $i" 4995 5139 done 4996 5140 4997 5141 4998 5142 fi 4999 5143 ................................................................................ 5178 5322 $as_echo "#define XML_POOR_ENTROPY 1" >>confdefs.h 5179 5323 5180 5324 ;; 5181 5325 *) 5182 5326 as_fn_error $? "${with_entropy} not known." "$LINENO" 5 5183 5327 esac 5184 5328 5329 + 5330 +#-------------------------------------------------------------------- 5331 +# We need the UINT2PTR and PTR2UINT macros, so make sure that intptr_t 5332 +# is defined. 5333 +#-------------------------------------------------------------------- 5334 + 5335 +ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default" 5336 +if test "x$ac_cv_type_uintptr_t" = xyes; then : 5337 + 5338 + 5339 +$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h 5340 + 5341 +else 5342 + 5343 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pointer-size unsigned integer type" >&5 5344 +$as_echo_n "checking for pointer-size unsigned integer type... " >&6; } 5345 +if ${tcl_cv_uintptr_t+:} false; then : 5346 + $as_echo_n "(cached) " >&6 5347 +else 5348 + 5349 + for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \ 5350 + none; do 5351 + if test "$tcl_cv_uintptr_t" != none; then 5352 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5353 +/* end confdefs.h. */ 5354 +$ac_includes_default 5355 +int 5356 +main () 5357 +{ 5358 +static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($tcl_cv_uintptr_t))]; 5359 +test_array [0] = 0; 5360 +return test_array [0]; 5361 + 5362 + ; 5363 + return 0; 5364 +} 5365 +_ACEOF 5366 +if ac_fn_c_try_compile "$LINENO"; then : 5367 + tcl_ok=yes 5368 +else 5369 + tcl_ok=no 5370 +fi 5371 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 5372 + test "$tcl_ok" = yes && break; fi 5373 + done 5374 +fi 5375 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_uintptr_t" >&5 5376 +$as_echo "$tcl_cv_uintptr_t" >&6; } 5377 + if test "$tcl_cv_uintptr_t" != none; then 5378 + 5379 +cat >>confdefs.h <<_ACEOF 5380 +#define uintptr_t $tcl_cv_uintptr_t 5381 +_ACEOF 5382 + 5383 + fi 5384 + 5385 +fi 5386 + 5185 5387 5186 5388 #-------------------------------------------------------------------- 5187 5389 # Add HTML5 parsing support. 5188 5390 #-------------------------------------------------------------------- 5189 5391 5392 + 5393 + if test -n "$ac_tool_prefix"; then 5394 + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. 5395 +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 5396 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 5397 +$as_echo_n "checking for $ac_word... " >&6; } 5398 +if ${ac_cv_path_PKG_CONFIG+:} false; then : 5399 + $as_echo_n "(cached) " >&6 5400 +else 5401 + case $PKG_CONFIG in 5402 + [\\/]* | ?:[\\/]*) 5403 + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. 5404 + ;; 5405 + *) 5406 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 5407 +for as_dir in $PATH 5408 +do 5409 + IFS=$as_save_IFS 5410 + test -z "$as_dir" && as_dir=. 5411 + for ac_exec_ext in '' $ac_executable_extensions; do 5412 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5413 + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" 5414 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 5415 + break 2 5416 + fi 5417 +done 5418 + done 5419 +IFS=$as_save_IFS 5420 + 5421 + ;; 5422 +esac 5423 +fi 5424 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG 5425 +if test -n "$PKG_CONFIG"; then 5426 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 5427 +$as_echo "$PKG_CONFIG" >&6; } 5428 +else 5429 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5430 +$as_echo "no" >&6; } 5431 +fi 5432 + 5433 + 5434 +fi 5435 +if test -z "$ac_cv_path_PKG_CONFIG"; then 5436 + ac_pt_PKG_CONFIG=$PKG_CONFIG 5437 + # Extract the first word of "pkg-config", so it can be a program name with args. 5438 +set dummy pkg-config; ac_word=$2 5439 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 5440 +$as_echo_n "checking for $ac_word... " >&6; } 5441 +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : 5442 + $as_echo_n "(cached) " >&6 5443 +else 5444 + case $ac_pt_PKG_CONFIG in 5445 + [\\/]* | ?:[\\/]*) 5446 + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. 5447 + ;; 5448 + *) 5449 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 5450 +for as_dir in $PATH 5451 +do 5452 + IFS=$as_save_IFS 5453 + test -z "$as_dir" && as_dir=. 5454 + for ac_exec_ext in '' $ac_executable_extensions; do 5455 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5456 + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" 5457 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 5458 + break 2 5459 + fi 5460 +done 5461 + done 5462 +IFS=$as_save_IFS 5463 + 5464 + ;; 5465 +esac 5466 +fi 5467 +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG 5468 +if test -n "$ac_pt_PKG_CONFIG"; then 5469 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 5470 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } 5471 +else 5472 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5473 +$as_echo "no" >&6; } 5474 +fi 5475 + 5476 + if test "x$ac_pt_PKG_CONFIG" = x; then 5477 + PKG_CONFIG="" 5478 + else 5479 + case $cross_compiling:$ac_tool_warned in 5480 +yes:) 5481 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 5482 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 5483 +ac_tool_warned=yes ;; 5484 +esac 5485 + PKG_CONFIG=$ac_pt_PKG_CONFIG 5486 + fi 5487 +else 5488 + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" 5489 +fi 5190 5490 5191 5491 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable support for HTML5 parsing (using gumbo)" >&5 5192 5492 $as_echo_n "checking whether to enable support for HTML5 parsing (using gumbo)... " >&6; } 5193 5493 # Check whether --enable-html5 was given. 5194 5494 if test "${enable_html5+set}" = set; then : 5195 5495 enableval=$enable_html5; tcl_ok=$enableval 5196 5496 else ................................................................................ 5204 5504 else 5205 5505 tcl_ok=no 5206 5506 fi 5207 5507 HTML5_LIBS="" 5208 5508 HTML5_INCLUDES="" 5209 5509 if test "$tcl_ok" = "yes" ; then 5210 5510 # Check if pkg-config is available 5211 - PKGCONFIG=no 5212 - pkg-config --version > /dev/null 2>&1 && PKGCONFIG=yes 5213 - if test "$PKGCONFIG" = no; then 5511 + if test "x$PKG_CONFIG" = x; then 5214 5512 tcl_ok=no 5215 5513 as_fn_error $? "cannot find pkg-config needed for --enable-html5." "$LINENO" 5 5216 5514 fi 5217 5515 fi 5218 5516 if test "$tcl_ok" = "yes" ; then 5219 - HAVEGUMBO=`pkg-config --exists gumbo && echo "1"` 5517 + HAVEGUMBO=`$PKG_CONFIG --exists gumbo && echo "1"` 5220 5518 if test "$HAVEGUMBO" = "1" ; then 5221 5519 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 5222 5520 $as_echo "yes" >&6; } 5223 5521 $as_echo "#define TDOM_HAVE_GUMBO 1" >>confdefs.h 5224 5522 5225 5523 if test "${TEA_PLATFORM}" = "windows" ; then 5226 - HTML5_LIBS="-Wl,-Bstatic `pkg-config --static --libs gumbo` -Wl,-Bdynamic" 5524 + HTML5_LIBS="-Wl,-Bstatic `$PKG_CONFIG --static --libs gumbo` -Wl,-Bdynamic" 5227 5525 else 5228 - HTML5_LIBS="`pkg-config --libs gumbo`" 5526 + HTML5_LIBS="`$PKG_CONFIG --libs gumbo`" 5229 5527 fi 5230 - HTML5_INCLUDES="`pkg-config --cflags gumbo`" 5528 + HTML5_INCLUDES="`$PKG_CONFIG --cflags gumbo`" 5231 5529 else 5232 5530 as_fn_error $? "The required lib gumbo not found" "$LINENO" 5 5233 5531 fi 5234 5532 else 5235 5533 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5236 5534 $as_echo "no" >&6; } 5237 5535 fi ................................................................................ 5257 5555 generic/domxslt.c \ 5258 5556 generic/domlock.c \ 5259 5557 generic/tcldom.c \ 5260 5558 generic/nodecmd.c \ 5261 5559 generic/tdominit.c \ 5262 5560 generic/tclexpat.c \ 5263 5561 generic/tclpull.c \ 5264 - generic/structure.c \ 5562 + generic/schema.c \ 5265 5563 generic/tdomStubInit.c" 5266 5564 for i in $vars; do 5267 5565 case $i in 5268 5566 \$*) 5269 5567 # allow $-var names 5270 5568 PKG_SOURCES="$PKG_SOURCES $i" 5271 5569 PKG_OBJECTS="$PKG_OBJECTS $i" ................................................................................ 5315 5613 5316 5614 5317 5615 5318 5616 vars="${AOL_LIBS} ${HTML5_LIBS}" 5319 5617 for i in $vars; do 5320 5618 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 5321 5619 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 5322 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 5620 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 5323 5621 fi 5324 5622 PKG_LIBS="$PKG_LIBS $i" 5325 5623 done 5326 5624 5327 5625 5328 5626 5329 5627 PKG_CFLAGS="$PKG_CFLAGS " ................................................................................ 5798 6096 Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 5799 6097 that IS thread-enabled. It is recommended to use --enable-threads." >&5 5800 6098 $as_echo "$as_me: WARNING: 5801 6099 Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 5802 6100 that IS thread-enabled. It is recommended to use --enable-threads." >&2;} 5803 6101 fi 5804 6102 ;; 5805 - *) 5806 - if test "${TCL_THREADS}" = "1"; then 5807 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 5808 - --enable-threads requested, but building against a Tcl that is NOT 5809 - thread-enabled. This is an OK configuration that will also run in 5810 - a thread-enabled core." >&5 5811 -$as_echo "$as_me: WARNING: 5812 - --enable-threads requested, but building against a Tcl that is NOT 5813 - thread-enabled. This is an OK configuration that will also run in 5814 - a thread-enabled core." >&2;} 5815 - fi 5816 - ;; 5817 6103 esac 5818 6104 5819 6105 5820 6106 5821 6107 #-------------------------------------------------------------------- 5822 6108 # The statement below defines a collection of symbols related to 5823 6109 # building as a shared library instead of a static library. ................................................................................ 6081 6367 else 6082 6368 doRpath=yes 6083 6369 fi 6084 6370 6085 6371 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doRpath" >&5 6086 6372 $as_echo "$doRpath" >&6; } 6087 6373 6088 - # TEA specific: Cross-compiling options for Windows/CE builds? 6089 - 6090 - if test "${TEA_PLATFORM}" = windows; then : 6091 - 6092 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Windows/CE build is requested" >&5 6093 -$as_echo_n "checking if Windows/CE build is requested... " >&6; } 6094 - # Check whether --enable-wince was given. 6095 -if test "${enable_wince+set}" = set; then : 6096 - enableval=$enable_wince; doWince=$enableval 6097 -else 6098 - doWince=no 6099 -fi 6100 - 6101 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doWince" >&5 6102 -$as_echo "$doWince" >&6; } 6103 - 6104 -fi 6105 - 6106 6374 # Set the variable "system" to hold the name and version number 6107 6375 # for the system. 6108 6376 6109 6377 6110 6378 { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 6111 6379 $as_echo_n "checking system version... " >&6; } 6112 6380 if ${tcl_cv_sys_version+:} false; then : ................................................................................ 6121 6389 if test "$?" -ne 0 ; then 6122 6390 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 6123 6391 $as_echo "$as_me: WARNING: can't find uname command" >&2;} 6124 6392 tcl_cv_sys_version=unknown 6125 6393 else 6126 6394 if test "`uname -s`" = "AIX" ; then 6127 6395 tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 6396 + fi 6397 + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then 6398 + tcl_cv_sys_version=NetBSD-Debian 6128 6399 fi 6129 6400 fi 6130 6401 fi 6131 6402 6132 6403 fi 6133 6404 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 6134 6405 $as_echo "$tcl_cv_sys_version" >&6; } ................................................................................ 6265 6536 SHLIB_VERSION="" 6266 6537 else 6267 6538 SHLIB_VERSION=".$SHLIB_VERSION" 6268 6539 fi 6269 6540 case $system in 6270 6541 # TEA specific: 6271 6542 windows) 6272 - # This is a 2-stage check to make sure we have the 64-bit SDK 6273 - # We have to know where the SDK is installed. 6274 - # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs 6275 - # MACHINE is IX86 for LINK, but this is used by the manifest, 6276 - # which requires x86|amd64|ia64. 6277 6543 MACHINE="X86" 6278 6544 if test "$do64bit" != "no" ; then 6279 - if test "x${MSSDK}x" = "xx" ; then 6280 - MSSDK="C:/Progra~1/Microsoft Platform SDK" 6281 - fi 6282 - MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'` 6283 - PATH64="" 6284 6545 case "$do64bit" in 6285 6546 amd64|x64|yes) 6286 6547 MACHINE="AMD64" ; # default to AMD64 64-bit build 6287 - PATH64="${MSSDK}/Bin/Win64/x86/AMD64" 6288 6548 ;; 6289 6549 ia64) 6290 6550 MACHINE="IA64" 6291 - PATH64="${MSSDK}/Bin/Win64" 6292 6551 ;; 6293 6552 esac 6294 - if test "$GCC" != "yes" -a ! -d "${PATH64}" ; then 6295 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&5 6296 -$as_echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&2;} 6297 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ensure latest Platform SDK is installed" >&5 6298 -$as_echo "$as_me: WARNING: Ensure latest Platform SDK is installed" >&2;} 6299 - do64bit="no" 6300 - else 6301 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using 64-bit $MACHINE mode" >&5 6302 -$as_echo " Using 64-bit $MACHINE mode" >&6; } 6303 - do64bit_ok="yes" 6304 - fi 6305 - fi 6306 - 6307 - if test "$doWince" != "no" ; then 6308 - if test "$do64bit" != "no" ; then 6309 - as_fn_error $? "Windows/CE and 64-bit builds incompatible" "$LINENO" 5 6310 - fi 6311 - if test "$GCC" = "yes" ; then 6312 - as_fn_error $? "Windows/CE and GCC builds incompatible" "$LINENO" 5 6313 - fi 6314 - 6315 - # First, look for one uninstalled. 6316 - # the alternative search directory is invoked by --with-celib 6317 - 6318 - if test x"${no_celib}" = x ; then 6319 - # we reset no_celib in case something fails here 6320 - no_celib=true 6321 - 6322 -# Check whether --with-celib was given. 6323 -if test "${with_celib+set}" = set; then : 6324 - withval=$with_celib; with_celibconfig=${withval} 6325 -fi 6326 - 6327 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows/CE celib directory" >&5 6328 -$as_echo_n "checking for Windows/CE celib directory... " >&6; } 6329 - if ${ac_cv_c_celibconfig+:} false; then : 6330 - $as_echo_n "(cached) " >&6 6331 -else 6332 - 6333 - # First check to see if --with-celibconfig was specified. 6334 - if test x"${with_celibconfig}" != x ; then 6335 - if test -d "${with_celibconfig}/inc" ; then 6336 - ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)` 6337 - else 6338 - as_fn_error $? "${with_celibconfig} directory doesn't contain inc directory" "$LINENO" 5 6339 - fi 6340 - fi 6341 - 6342 - # then check for a celib library 6343 - if test x"${ac_cv_c_celibconfig}" = x ; then 6344 - for i in \ 6345 - ../celib-palm-3.0 \ 6346 - ../celib \ 6347 - ../../celib-palm-3.0 \ 6348 - ../../celib \ 6349 - `ls -dr ../celib-*3.[0-9]* 2>/dev/null` \ 6350 - ${srcdir}/../celib-palm-3.0 \ 6351 - ${srcdir}/../celib \ 6352 - `ls -dr ${srcdir}/../celib-*3.[0-9]* 2>/dev/null` \ 6353 - ; do 6354 - if test -d "$i/inc" ; then 6355 - ac_cv_c_celibconfig=`(cd $i; pwd)` 6356 - break 6357 - fi 6358 - done 6359 - fi 6360 - 6361 -fi 6362 - 6363 - if test x"${ac_cv_c_celibconfig}" = x ; then 6364 - as_fn_error $? "Cannot find celib support library directory" "$LINENO" 5 6365 - else 6366 - no_celib= 6367 - CELIB_DIR=${ac_cv_c_celibconfig} 6368 - CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` 6369 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $CELIB_DIR" >&5 6370 -$as_echo "found $CELIB_DIR" >&6; } 6371 - fi 6372 - fi 6373 - 6374 - # Set defaults for common evc4/PPC2003 setup 6375 - # Currently Tcl requires 300+, possibly 420+ for sockets 6376 - CEVERSION=420; # could be 211 300 301 400 420 ... 6377 - TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... 6378 - ARCH=ARM; # could be ARM MIPS X86EM ... 6379 - PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" 6380 - if test "$doWince" != "yes"; then 6381 - # If !yes then the user specified something 6382 - # Reset ARCH to allow user to skip specifying it 6383 - ARCH= 6384 - eval `echo $doWince | awk -F, '{ \ 6385 - if (length($1)) { printf "CEVERSION=\"%s\"\n", $1; \ 6386 - if ($1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ 6387 - if (length($2)) { printf "TARGETCPU=\"%s\"\n", toupper($2) }; \ 6388 - if (length($3)) { printf "ARCH=\"%s\"\n", toupper($3) }; \ 6389 - if (length($4)) { printf "PLATFORM=\"%s\"\n", $4 }; \ 6390 - }'` 6391 - if test "x${ARCH}" = "x" ; then 6392 - ARCH=$TARGETCPU; 6393 - fi 6394 - fi 6395 - OSVERSION=WCE$CEVERSION; 6396 - if test "x${WCEROOT}" = "x" ; then 6397 - WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" 6398 - if test ! -d "${WCEROOT}" ; then 6399 - WCEROOT="C:/Program Files/Microsoft eMbedded Tools" 6400 - fi 6401 - fi 6402 - if test "x${SDKROOT}" = "x" ; then 6403 - SDKROOT="C:/Program Files/Windows CE Tools" 6404 - if test ! -d "${SDKROOT}" ; then 6405 - SDKROOT="C:/Windows CE Tools" 6406 - fi 6407 - fi 6408 - WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` 6409 - SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` 6410 - if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \ 6411 - -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then 6412 - as_fn_error $? "could not find PocketPC SDK or target compiler to enable WinCE mode $CEVERSION,$TARGETCPU,$ARCH,$PLATFORM" "$LINENO" 5 6413 - doWince="no" 6414 - else 6415 - # We could PATH_NOSPACE these, but that's not important, 6416 - # as long as we quote them when used. 6417 - CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" 6418 - if test -d "${CEINCLUDE}/${TARGETCPU}" ; then 6419 - CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" 6420 - fi 6421 - CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" 6422 - fi 6423 6553 fi 6424 6554 6425 6555 if test "$GCC" != "yes" ; then 6426 6556 if test "${SHARED_BUILD}" = "0" ; then 6427 6557 runtime=-MT 6428 6558 else 6429 6559 runtime=-MD ................................................................................ 6432 6562 x1[4-9]*) 6433 6563 lflags="${lflags} -nodefaultlib:libucrt.lib" 6434 6564 6435 6565 vars="ucrt.lib" 6436 6566 for i in $vars; do 6437 6567 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 6438 6568 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 6439 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 6569 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 6440 6570 fi 6441 6571 PKG_LIBS="$PKG_LIBS $i" 6442 6572 done 6443 6573 6444 6574 6445 6575 ;; 6446 6576 *) 6447 6577 ;; 6448 6578 esac 6449 6579 6450 6580 if test "$do64bit" != "no" ; then 6451 - # All this magic is necessary for the Win64 SDK RC1 - hobbs 6452 - CC="\"${PATH64}/cl.exe\"" 6453 - CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\"" 6454 - RC="\"${MSSDK}/bin/rc.exe\"" 6455 - lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\"" 6456 - LINKBIN="\"${PATH64}/link.exe\"" 6581 + CC="cl.exe" 6582 + RC="rc.exe" 6583 + lflags="${lflags} -nologo -MACHINE:${MACHINE} " 6584 + LINKBIN="link.exe" 6457 6585 CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d" 6458 6586 CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 6459 6587 # Avoid 'unresolved external symbol __security_cookie' 6460 6588 # errors, c.f. http://support.microsoft.com/?id=894573 6461 6589 6462 6590 vars="bufferoverflowU.lib" 6463 6591 for i in $vars; do 6464 6592 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 6465 6593 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 6466 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 6594 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 6467 6595 fi 6468 6596 PKG_LIBS="$PKG_LIBS $i" 6469 6597 done 6470 6598 6471 6599 6472 - elif test "$doWince" != "no" ; then 6473 - CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" 6474 - if test "${TARGETCPU}" = "X86"; then 6475 - CC="\"${CEBINROOT}/cl.exe\"" 6476 - else 6477 - CC="\"${CEBINROOT}/cl${ARCH}.exe\"" 6478 - fi 6479 - CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" 6480 - RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" 6481 - arch=`echo ${ARCH} | awk '{print tolower($0)}'` 6482 - defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS" 6483 - if test "${SHARED_BUILD}" = "1" ; then 6484 - # Static CE builds require static celib as well 6485 - defs="${defs} _DLL" 6486 - fi 6487 - for i in $defs ; do 6488 - 6489 -cat >>confdefs.h <<_ACEOF 6490 -#define $i 1 6491 -_ACEOF 6492 - 6493 - done 6494 - 6495 -cat >>confdefs.h <<_ACEOF 6496 -#define _WIN32_WCE $CEVERSION 6497 -_ACEOF 6498 - 6499 - 6500 -cat >>confdefs.h <<_ACEOF 6501 -#define UNDER_CE $CEVERSION 6502 -_ACEOF 6503 - 6504 - CFLAGS_DEBUG="-nologo -Zi -Od" 6505 - CFLAGS_OPTIMIZE="-nologo -Ox" 6506 - lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` 6507 - lflags="${lflags} -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" 6508 - LINKBIN="\"${CEBINROOT}/link.exe\"" 6509 - 6510 6600 else 6511 6601 RC="rc" 6512 6602 lflags="${lflags} -nologo" 6513 6603 LINKBIN="link" 6514 6604 CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d" 6515 6605 CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 6516 6606 fi ................................................................................ 6646 6736 6647 6737 fi 6648 6738 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cross" >&5 6649 6739 $as_echo "$ac_cv_cross" >&6; } 6650 6740 if test "$ac_cv_cross" = "yes"; then 6651 6741 case "$do64bit" in 6652 6742 amd64|x64|yes) 6653 - CC="x86_64-w64-mingw32-gcc" 6743 + CC="x86_64-w64-mingw32-${CC}" 6654 6744 LD="x86_64-w64-mingw32-ld" 6655 6745 AR="x86_64-w64-mingw32-ar" 6656 6746 RANLIB="x86_64-w64-mingw32-ranlib" 6657 6747 RC="x86_64-w64-mingw32-windres" 6658 6748 ;; 6659 6749 *) 6660 - CC="i686-w64-mingw32-gcc" 6750 + CC="i686-w64-mingw32-${CC}" 6661 6751 LD="i686-w64-mingw32-ld" 6662 6752 AR="i686-w64-mingw32-ar" 6663 6753 RANLIB="i686-w64-mingw32-ranlib" 6664 6754 RC="i686-w64-mingw32-windres" 6665 6755 ;; 6666 6756 esac 6667 6757 fi ................................................................................ 6675 6765 # For information on what debugtype is most useful, see: 6676 6766 # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp 6677 6767 # and also 6678 6768 # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx 6679 6769 # This essentially turns it all on. 6680 6770 LDFLAGS_DEBUG="-debug -debugtype:cv" 6681 6771 LDFLAGS_OPTIMIZE="-release" 6682 - if test "$doWince" != "no" ; then 6683 - LDFLAGS_CONSOLE="-link ${lflags}" 6684 - LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} 6685 - else 6686 - LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 6687 - LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 6688 - fi 6772 + LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 6773 + LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 6689 6774 fi 6690 6775 6691 6776 SHLIB_SUFFIX=".dll" 6692 6777 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll' 6693 6778 6694 6779 TCL_LIB_VERSIONS_OK=nodots 6695 6780 ;; 6696 6781 AIX-*) 6697 - if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"; then : 6782 + if test "$GCC" != "yes"; then : 6698 6783 6699 6784 # AIX requires the _r compiler when gcc isn't being used 6700 6785 case "${CC}" in 6701 6786 *_r|*_r\ *) 6702 6787 # ok ... 6703 6788 ;; 6704 6789 *) ................................................................................ 6739 6824 6740 6825 if test "`uname -m`" = ia64; then : 6741 6826 6742 6827 # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC 6743 6828 SHLIB_LD="/usr/ccs/bin/ld -G -z text" 6744 6829 if test "$GCC" = yes; then : 6745 6830 6746 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 6831 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 6747 6832 6748 6833 else 6749 6834 6750 - CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}' 6835 + CC_SEARCH_FLAGS='"-R${LIB_RUNTIME_DIR}"' 6751 6836 6752 6837 fi 6753 - LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 6838 + LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 6754 6839 6755 6840 else 6756 6841 6757 6842 if test "$GCC" = yes; then : 6758 6843 6759 6844 SHLIB_LD='${CC} -shared -Wl,-bexpall' 6760 6845 ................................................................................ 6761 6846 else 6762 6847 6763 6848 SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry" 6764 6849 LDFLAGS="$LDFLAGS -brtl" 6765 6850 6766 6851 fi 6767 6852 SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}" 6768 - CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}' 6853 + CC_SEARCH_FLAGS='"-L${LIB_RUNTIME_DIR}"' 6769 6854 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6770 6855 6771 6856 fi 6772 6857 ;; 6773 6858 BeOS*) 6774 6859 SHLIB_CFLAGS="-fPIC" 6775 6860 SHLIB_LD='${CC} -nostart' ................................................................................ 6817 6902 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_inet_ntoa" >&5 6818 6903 $as_echo "$ac_cv_lib_bind_inet_ntoa" >&6; } 6819 6904 if test "x$ac_cv_lib_bind_inet_ntoa" = xyes; then : 6820 6905 LIBS="$LIBS -lbind -lsocket" 6821 6906 fi 6822 6907 6823 6908 ;; 6909 + BSD/OS-2.1*|BSD/OS-3*) 6910 + SHLIB_CFLAGS="" 6911 + SHLIB_LD="shlicc -r" 6912 + SHLIB_SUFFIX=".so" 6913 + CC_SEARCH_FLAGS="" 6914 + LD_SEARCH_FLAGS="" 6915 + ;; 6824 6916 BSD/OS-4.*) 6825 6917 SHLIB_CFLAGS="-export-dynamic -fPIC" 6826 6918 SHLIB_LD='${CC} -shared' 6827 6919 SHLIB_SUFFIX=".so" 6828 6920 LDFLAGS="$LDFLAGS -export-dynamic" 6829 6921 CC_SEARCH_FLAGS="" 6830 6922 LD_SEARCH_FLAGS="" 6831 6923 ;; 6832 6924 CYGWIN_*) 6833 6925 SHLIB_CFLAGS="" 6834 6926 SHLIB_LD='${CC} -shared' 6835 - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a" 6836 6927 SHLIB_SUFFIX=".dll" 6928 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a" 6837 6929 EXEEXT=".exe" 6838 6930 do64bit_ok=yes 6931 + CC_SEARCH_FLAGS="" 6932 + LD_SEARCH_FLAGS="" 6933 + ;; 6934 + dgux*) 6935 + SHLIB_CFLAGS="-K PIC" 6936 + SHLIB_LD='${CC} -G' 6937 + SHLIB_LD_LIBS="" 6938 + SHLIB_SUFFIX=".so" 6839 6939 CC_SEARCH_FLAGS="" 6840 6940 LD_SEARCH_FLAGS="" 6841 6941 ;; 6842 6942 Haiku*) 6843 6943 LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 6844 6944 SHLIB_CFLAGS="-fPIC" 6845 6945 SHLIB_SUFFIX=".so" ................................................................................ 6893 6993 # TEA specific: Needed by Tcl, but not most extensions 6894 6994 #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?]) 6895 6995 #LIBS="$LIBS -lxnet" # Use the XOPEN network library 6896 6996 6897 6997 if test "`uname -m`" = ia64; then : 6898 6998 6899 6999 SHLIB_SUFFIX=".so" 6900 - # Use newer C++ library for C++ extensions 6901 - #if test "$GCC" != "yes" ; then 6902 - # CPPFLAGS="-AA" 6903 - #fi 6904 7000 6905 7001 else 6906 7002 6907 7003 SHLIB_SUFFIX=".sl" 6908 7004 6909 7005 fi 6910 7006 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 ................................................................................ 6947 7043 tcl_ok=yes 6948 7044 else 6949 7045 tcl_ok=no 6950 7046 fi 6951 7047 6952 7048 if test "$tcl_ok" = yes; then : 6953 7049 7050 + SHLIB_CFLAGS="+z" 7051 + SHLIB_LD="ld -b" 6954 7052 LDFLAGS="$LDFLAGS -Wl,-E" 6955 - CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.' 6956 - LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.' 7053 + CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."' 7054 + LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."' 6957 7055 LD_LIBRARY_PATH_VAR="SHLIB_PATH" 6958 7056 6959 7057 fi 6960 7058 if test "$GCC" = yes; then : 6961 7059 6962 7060 SHLIB_LD='${CC} -shared' 6963 7061 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6964 7062 6965 7063 else 6966 7064 6967 7065 CFLAGS="$CFLAGS -z" 6968 - # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc 6969 - #CFLAGS="$CFLAGS +DAportable" 6970 - SHLIB_CFLAGS="+z" 6971 - SHLIB_LD="ld -b" 6972 7066 6973 7067 fi 6974 7068 6975 7069 # Check to enable 64-bit flags for compiler/linker 6976 7070 if test "$do64bit" = "yes"; then : 6977 7071 6978 7072 if test "$GCC" = yes; then : ................................................................................ 6980 7074 case `${CC} -dumpmachine` in 6981 7075 hppa64*) 6982 7076 # 64-bit gcc in use. Fix flags for GNU ld. 6983 7077 do64bit_ok=yes 6984 7078 SHLIB_LD='${CC} -shared' 6985 7079 if test $doRpath = yes; then : 6986 7080 6987 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7081 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 6988 7082 fi 6989 7083 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6990 7084 ;; 6991 7085 *) 6992 7086 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 6993 7087 $as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;} 6994 7088 ;; ................................................................................ 6999 7093 do64bit_ok=yes 7000 7094 CFLAGS="$CFLAGS +DD64" 7001 7095 LDFLAGS_ARCH="+DD64" 7002 7096 7003 7097 fi 7004 7098 7005 7099 fi ;; 7100 + HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*) 7101 + SHLIB_SUFFIX=".sl" 7102 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 7103 +$as_echo_n "checking for shl_load in -ldld... " >&6; } 7104 +if ${ac_cv_lib_dld_shl_load+:} false; then : 7105 + $as_echo_n "(cached) " >&6 7106 +else 7107 + ac_check_lib_save_LIBS=$LIBS 7108 +LIBS="-ldld $LIBS" 7109 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7110 +/* end confdefs.h. */ 7111 + 7112 +/* Override any GCC internal prototype to avoid an error. 7113 + Use char because int might match the return type of a GCC 7114 + builtin and then its argument prototype would still apply. */ 7115 +#ifdef __cplusplus 7116 +extern "C" 7117 +#endif 7118 +char shl_load (); 7119 +int 7120 +main () 7121 +{ 7122 +return shl_load (); 7123 + ; 7124 + return 0; 7125 +} 7126 +_ACEOF 7127 +if ac_fn_c_try_link "$LINENO"; then : 7128 + ac_cv_lib_dld_shl_load=yes 7129 +else 7130 + ac_cv_lib_dld_shl_load=no 7131 +fi 7132 +rm -f core conftest.err conftest.$ac_objext \ 7133 + conftest$ac_exeext conftest.$ac_ext 7134 +LIBS=$ac_check_lib_save_LIBS 7135 +fi 7136 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 7137 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } 7138 +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : 7139 + tcl_ok=yes 7140 +else 7141 + tcl_ok=no 7142 +fi 7143 + 7144 + if test "$tcl_ok" = yes; then : 7145 + 7146 + SHLIB_CFLAGS="+z" 7147 + SHLIB_LD="ld -b" 7148 + SHLIB_LD_LIBS="" 7149 + LDFLAGS="$LDFLAGS -Wl,-E" 7150 + CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."' 7151 + LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."' 7152 + LD_LIBRARY_PATH_VAR="SHLIB_PATH" 7153 + 7154 +fi ;; 7155 + IRIX-5.*) 7156 + SHLIB_CFLAGS="" 7157 + SHLIB_LD="ld -shared -rdata_shared" 7158 + SHLIB_SUFFIX=".so" 7159 + case " $LIBOBJS " in 7160 + *" mkstemp.$ac_objext "* ) ;; 7161 + *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext" 7162 + ;; 7163 +esac 7164 + 7165 + if test $doRpath = yes; then : 7166 + 7167 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7168 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"' 7169 +fi 7170 + ;; 7006 7171 IRIX-6.*) 7007 7172 SHLIB_CFLAGS="" 7008 7173 SHLIB_LD="ld -n32 -shared -rdata_shared" 7009 7174 SHLIB_SUFFIX=".so" 7010 7175 if test $doRpath = yes; then : 7011 7176 7012 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7013 - LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 7177 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7178 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"' 7014 7179 fi 7015 7180 if test "$GCC" = yes; then : 7016 7181 7017 7182 CFLAGS="$CFLAGS -mabi=n32" 7018 7183 LDFLAGS="$LDFLAGS -mabi=n32" 7019 7184 7020 7185 else ................................................................................ 7034 7199 ;; 7035 7200 IRIX64-6.*) 7036 7201 SHLIB_CFLAGS="" 7037 7202 SHLIB_LD="ld -n32 -shared -rdata_shared" 7038 7203 SHLIB_SUFFIX=".so" 7039 7204 if test $doRpath = yes; then : 7040 7205 7041 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7042 - LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 7206 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7207 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"' 7043 7208 fi 7044 7209 7045 7210 # Check to enable 64-bit flags for compiler/linker 7046 7211 7047 7212 if test "$do64bit" = yes; then : 7048 7213 7049 7214 if test "$GCC" = yes; then : ................................................................................ 7058 7223 CFLAGS="$CFLAGS -64" 7059 7224 LDFLAGS_ARCH="-64" 7060 7225 7061 7226 fi 7062 7227 7063 7228 fi 7064 7229 ;; 7065 - Linux*|GNU*|NetBSD-Debian) 7230 + Linux*|GNU*|NetBSD-Debian|DragonFly-*|FreeBSD-*) 7066 7231 SHLIB_CFLAGS="-fPIC" 7067 7232 SHLIB_SUFFIX=".so" 7068 7233 7069 7234 # TEA specific: 7070 7235 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" 7071 7236 7072 7237 # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 7073 7238 SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared' 7074 7239 LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 7240 + 7241 + case $system in 7242 + DragonFly-*|FreeBSD-*) 7243 + if test "${TCL_THREADS}" = "1"; then : 7244 + 7245 + # The -pthread needs to go in the LDFLAGS, not LIBS 7246 + LIBS=`echo $LIBS | sed s/-pthread//` 7247 + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 7248 + LDFLAGS="$LDFLAGS $PTHREAD_LIBS" 7249 +fi 7250 + ;; 7251 + esac 7252 + 7075 7253 if test $doRpath = yes; then : 7076 7254 7077 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7255 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7078 7256 fi 7079 7257 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7080 7258 if test "`uname -m`" = "alpha"; then : 7081 7259 CFLAGS="$CFLAGS -mieee" 7082 7260 fi 7083 7261 if test $do64bit = yes; then : 7084 7262 ................................................................................ 7135 7313 SHLIB_CFLAGS="-fPIC" 7136 7314 SHLIB_SUFFIX=".so" 7137 7315 CFLAGS_OPTIMIZE=-02 7138 7316 SHLIB_LD='${CC} -shared' 7139 7317 LD_FLAGS="-Wl,--export-dynamic" 7140 7318 if test $doRpath = yes; then : 7141 7319 7142 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7143 - LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7320 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7321 + LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7144 7322 fi 7145 7323 ;; 7146 7324 OpenBSD-*) 7147 7325 arch=`arch -s` 7148 7326 case "$arch" in 7149 7327 alpha|sparc64) 7150 7328 SHLIB_CFLAGS="-fPIC" ................................................................................ 7153 7331 SHLIB_CFLAGS="-fpic" 7154 7332 ;; 7155 7333 esac 7156 7334 SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 7157 7335 SHLIB_SUFFIX=".so" 7158 7336 if test $doRpath = yes; then : 7159 7337 7160 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7338 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7161 7339 fi 7162 7340 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7163 7341 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}' 7164 - LDFLAGS="-Wl,-export-dynamic" 7342 + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" 7165 7343 CFLAGS_OPTIMIZE="-O2" 7166 - if test "${TCL_THREADS}" = "1"; then : 7167 - 7168 - # On OpenBSD: Compile with -pthread 7169 - # Don't link with -lpthread 7170 - LIBS=`echo $LIBS | sed s/-lpthread//` 7171 - CFLAGS="$CFLAGS -pthread" 7172 - 7173 -fi 7344 + # On OpenBSD: Compile with -pthread 7345 + # Don't link with -lpthread 7346 + LIBS=`echo $LIBS | sed s/-lpthread//` 7347 + CFLAGS="$CFLAGS -pthread" 7174 7348 # OpenBSD doesn't do version numbers with dots. 7175 7349 UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 7176 7350 TCL_LIB_VERSIONS_OK=nodots 7177 7351 ;; 7178 7352 NetBSD-*) 7179 7353 # NetBSD has ELF and can use 'cc -shared' to build shared libs 7180 7354 SHLIB_CFLAGS="-fPIC" 7181 7355 SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 7182 7356 SHLIB_SUFFIX=".so" 7183 7357 LDFLAGS="$LDFLAGS -export-dynamic" 7184 7358 if test $doRpath = yes; then : 7185 7359 7186 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7360 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7187 7361 fi 7188 7362 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7189 - if test "${TCL_THREADS}" = "1"; then : 7190 - 7191 - # The -pthread needs to go in the CFLAGS, not LIBS 7192 - LIBS=`echo $LIBS | sed s/-pthread//` 7193 - CFLAGS="$CFLAGS -pthread" 7194 - LDFLAGS="$LDFLAGS -pthread" 7195 - 7196 -fi 7197 - ;; 7198 - FreeBSD-*) 7199 - # This configuration from FreeBSD Ports. 7200 - SHLIB_CFLAGS="-fPIC" 7201 - SHLIB_LD="${CC} -shared" 7202 - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname,\$@" 7203 - SHLIB_SUFFIX=".so" 7204 - LDFLAGS="" 7205 - if test $doRpath = yes; then : 7206 - 7207 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7208 - LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7209 -fi 7210 - if test "${TCL_THREADS}" = "1"; then : 7211 - 7212 - # The -pthread needs to go in the LDFLAGS, not LIBS 7213 - LIBS=`echo $LIBS | sed s/-pthread//` 7214 - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 7215 - LDFLAGS="$LDFLAGS $PTHREAD_LIBS" 7216 -fi 7217 - case $system in 7218 - FreeBSD-3.*) 7219 - # Version numbers are dot-stripped by system policy. 7220 - TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` 7221 - UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 7222 - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' 7223 - TCL_LIB_VERSIONS_OK=nodots 7224 - ;; 7225 - esac 7363 + # The -pthread needs to go in the CFLAGS, not LIBS 7364 + LIBS=`echo $LIBS | sed s/-pthread//` 7365 + CFLAGS="$CFLAGS -pthread" 7366 + LDFLAGS="$LDFLAGS -pthread" 7226 7367 ;; 7227 7368 Darwin-*) 7228 7369 CFLAGS_OPTIMIZE="-Os" 7229 7370 SHLIB_CFLAGS="-fno-common" 7230 7371 # To avoid discrepancies between what headers configure sees during 7231 7372 # preprocessing tests and compiling tests, move any -isysroot and 7232 7373 # -mmacosx-version-min flags from CFLAGS to CPPFLAGS: ................................................................................ 7365 7506 SHLIB_LD="${SHLIB_LD} -Wl,-single_module" 7366 7507 7367 7508 fi 7368 7509 # TEA specific: link shlib with current and compatibility version flags 7369 7510 vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([0-9]\{1,5\}\)\(\(\.[0-9]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d` 7370 7511 SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}" 7371 7512 SHLIB_SUFFIX=".dylib" 7372 - # Don't use -prebind when building for Mac OS X 10.4 or later only: 7373 - if test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int($2)}'`" -lt 4 -a \ 7374 - "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int($2)}'`" -lt 4; then : 7375 - 7376 - LDFLAGS="$LDFLAGS -prebind" 7377 -fi 7378 7513 LDFLAGS="$LDFLAGS -headerpad_max_install_names" 7379 7514 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5 7380 7515 $as_echo_n "checking if ld accepts -search_paths_first flag... " >&6; } 7381 7516 if ${tcl_cv_ld_search_paths_first+:} false; then : 7382 7517 $as_echo_n "(cached) " >&6 7383 7518 else 7384 7519 ................................................................................ 7534 7669 7535 7670 SHLIB_LD='ld -non_shared -expect_unresolved "*"' 7536 7671 7537 7672 fi 7538 7673 SHLIB_SUFFIX=".so" 7539 7674 if test $doRpath = yes; then : 7540 7675 7541 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7676 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7542 7677 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 7543 7678 fi 7544 7679 if test "$GCC" = yes; then : 7545 7680 CFLAGS="$CFLAGS -mieee" 7546 7681 else 7547 7682 7548 7683 CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee" 7549 7684 fi 7550 7685 # see pthread_intro(3) for pthread support on osf1, k.furukawa 7551 - if test "${TCL_THREADS}" = 1; then : 7686 + CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 7687 + CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 7688 + LIBS=`echo $LIBS | sed s/-lpthreads//` 7689 + if test "$GCC" = yes; then : 7552 7690 7553 - CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 7554 - CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 7555 - LIBS=`echo $LIBS | sed s/-lpthreads//` 7556 - if test "$GCC" = yes; then : 7557 - 7558 - LIBS="$LIBS -lpthread -lmach -lexc" 7691 + LIBS="$LIBS -lpthread -lmach -lexc" 7559 7692 7560 7693 else 7561 7694 7562 - CFLAGS="$CFLAGS -pthread" 7563 - LDFLAGS="$LDFLAGS -pthread" 7564 - 7565 -fi 7695 + CFLAGS="$CFLAGS -pthread" 7696 + LDFLAGS="$LDFLAGS -pthread" 7566 7697 7567 7698 fi 7568 7699 ;; 7569 7700 QNX-6*) 7570 7701 # QNX RTP 7571 7702 # This may work for all QNX, but it was only reported for v6. 7572 7703 SHLIB_CFLAGS="-fPIC" ................................................................................ 7608 7739 7609 7740 7610 7741 SHLIB_CFLAGS="-KPIC" 7611 7742 SHLIB_SUFFIX=".so" 7612 7743 if test "$GCC" = yes; then : 7613 7744 7614 7745 SHLIB_LD='${CC} -shared' 7615 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7746 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 7616 7747 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7617 7748 7618 7749 else 7619 7750 7620 7751 SHLIB_LD="/usr/ccs/bin/ld -G -z text" 7621 - CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 7752 + CC_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 7622 7753 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7623 7754 7624 7755 fi 7625 7756 ;; 7626 7757 SunOS-5*) 7627 7758 # Note: If _REENTRANT isn't defined, then Solaris 7628 7759 # won't define thread-safe library routines. ................................................................................ 7714 7845 7715 7846 fi 7716 7847 7717 7848 SHLIB_SUFFIX=".so" 7718 7849 if test "$GCC" = yes; then : 7719 7850 7720 7851 SHLIB_LD='${CC} -shared' 7721 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7852 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 7722 7853 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7723 7854 if test "$do64bit_ok" = yes; then : 7724 7855 7725 7856 if test "$arch" = "sparcv9 sparc"; then : 7726 7857 7727 7858 # We need to specify -static-libgcc or we need to 7728 7859 # add the path to the sparv9 libgcc. ................................................................................ 7751 7882 case $system in 7752 7883 SunOS-5.[1-9][0-9]*) 7753 7884 # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 7754 7885 SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';; 7755 7886 *) 7756 7887 SHLIB_LD='/usr/ccs/bin/ld -G -z text';; 7757 7888 esac 7758 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7759 - LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 7889 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 7890 + LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 7760 7891 7761 7892 fi 7762 7893 ;; 7763 7894 UNIX_SV* | UnixWare-5*) 7764 7895 SHLIB_CFLAGS="-KPIC" 7765 7896 SHLIB_LD='${CC} -G' 7766 7897 SHLIB_LD_LIBS="" ................................................................................ 7825 7956 # standard manufacturer compiler. 7826 7957 7827 7958 if test "$GCC" = yes; then : 7828 7959 7829 7960 case $system in 7830 7961 AIX-*) ;; 7831 7962 BSD/OS*) ;; 7832 - CYGWIN_*|MINGW32_*|MINGW64_*) ;; 7963 + CYGWIN_*|MINGW32_*|MINGW64_*|MSYS_*) ;; 7833 7964 IRIX*) ;; 7834 - NetBSD-*|FreeBSD-*|OpenBSD-*) ;; 7965 + NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;; 7835 7966 Darwin-*) ;; 7836 7967 SCO_SV-3.2*) ;; 7837 7968 windows) ;; 7838 7969 *) SHLIB_CFLAGS="-fPIC" ;; 7839 7970 esac 7840 7971 fi 7841 7972 ................................................................................ 8030 8161 $as_echo "$tcl_cv_cast_to_union" >&6; } 8031 8162 if test "$tcl_cv_cast_to_union" = "yes"; then 8032 8163 8033 8164 $as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h 8034 8165 8035 8166 fi 8036 8167 8168 + ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" 8169 +if test "x$ac_cv_header_stdbool_h" = xyes; then : 8170 + 8171 +$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h 8172 + 8173 +fi 8174 + 8175 + 8176 + 8177 + 8178 + 8037 8179 8038 8180 8039 8181 8040 8182 8041 8183 8042 8184 8043 8185 ................................................................................ 8223 8365 _ACEOF 8224 8366 if ac_fn_c_try_compile "$LINENO"; then : 8225 8367 tcl_type_64bit=__int64 8226 8368 else 8227 8369 tcl_type_64bit="long long" 8228 8370 fi 8229 8371 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 8230 - # See if we should use long anyway Note that we substitute in the 8372 + # See if we could use long anyway Note that we substitute in the 8231 8373 # type that is our current guess for a 64-bit type inside this check 8232 8374 # program, so it should be modified only carefully... 8233 8375 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8234 8376 /* end confdefs.h. */ 8235 8377 8236 8378 int 8237 8379 main () ................................................................................ 8249 8391 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 8250 8392 fi 8251 8393 8252 8394 if test "${tcl_cv_type_64bit}" = none ; then 8253 8395 8254 8396 $as_echo "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h 8255 8397 8256 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: using long" >&5 8257 -$as_echo "using long" >&6; } 8398 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 8399 +$as_echo "yes" >&6; } 8258 8400 elif test "${tcl_cv_type_64bit}" = "__int64" \ 8259 8401 -a "${TEA_PLATFORM}" = "windows" ; then 8260 8402 # TEA specific: We actually want to use the default tcl.h checks in 8261 8403 # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER* 8262 8404 { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Tcl header defaults" >&5 8263 8405 $as_echo "using Tcl header defaults" >&6; } 8264 8406 else ................................................................................ 8298 8440 fi 8299 8441 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_dirent64" >&5 8300 8442 $as_echo "$tcl_cv_struct_dirent64" >&6; } 8301 8443 if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then 8302 8444 8303 8445 $as_echo "#define HAVE_STRUCT_DIRENT64 1" >>confdefs.h 8304 8446 8447 + fi 8448 + 8449 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DIR64" >&5 8450 +$as_echo_n "checking for DIR64... " >&6; } 8451 +if ${tcl_cv_DIR64+:} false; then : 8452 + $as_echo_n "(cached) " >&6 8453 +else 8454 + 8455 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8456 +/* end confdefs.h. */ 8457 +#include <sys/types.h> 8458 +#include <dirent.h> 8459 +int 8460 +main () 8461 +{ 8462 +struct dirent64 *p; DIR64 d = opendir64("."); 8463 + p = readdir64(d); rewinddir64(d); closedir64(d); 8464 + ; 8465 + return 0; 8466 +} 8467 +_ACEOF 8468 +if ac_fn_c_try_compile "$LINENO"; then : 8469 + tcl_cv_DIR64=yes 8470 +else 8471 + tcl_cv_DIR64=no 8472 +fi 8473 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 8474 +fi 8475 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_DIR64" >&5 8476 +$as_echo "$tcl_cv_DIR64" >&6; } 8477 + if test "x${tcl_cv_DIR64}" = "xyes" ; then 8478 + 8479 +$as_echo "#define HAVE_DIR64 1" >>confdefs.h 8480 + 8305 8481 fi 8306 8482 8307 8483 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct stat64" >&5 8308 8484 $as_echo_n "checking for struct stat64... " >&6; } 8309 8485 if ${tcl_cv_struct_stat64+:} false; then : 8310 8486 $as_echo_n "(cached) " >&6 8311 8487 else ................................................................................ 8405 8581 # Check whether --enable-symbols was given. 8406 8582 if test "${enable_symbols+set}" = set; then : 8407 8583 enableval=$enable_symbols; tcl_ok=$enableval 8408 8584 else 8409 8585 tcl_ok=no 8410 8586 fi 8411 8587 8412 - DBGX="" 8413 8588 if test "$tcl_ok" = "no"; then 8414 8589 CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG" 8415 8590 LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" 8416 8591 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 8417 8592 $as_echo "no" >&6; } 8418 8593 else 8419 8594 CFLAGS_DEFAULT="${CFLAGS_DEBUG}" 8420 8595 LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" 8421 8596 if test "$tcl_ok" = "yes"; then 8422 8597 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5 8423 8598 $as_echo "yes (standard debugging)" >&6; } 8424 8599 fi 8425 8600 fi 8426 - # TEA specific: 8427 - if test "${TEA_PLATFORM}" != "windows" ; then 8428 - LDFLAGS_DEFAULT="${LDFLAGS}" 8429 - fi 8430 - 8431 8601 8432 8602 8433 8603 8434 8604 if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then 8435 8605 8436 8606 $as_echo "#define TCL_MEM_DEBUG 1" >>confdefs.h 8437 8607 ................................................................................ 8453 8623 # depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS, 8454 8624 # and TEA_LOAD_TCLCONFIG macros above. 8455 8625 #-------------------------------------------------------------------- 8456 8626 8457 8627 8458 8628 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then 8459 8629 MAKE_STATIC_LIB="\${STLIB_LD} -out:\$@ \$(PKG_OBJECTS)" 8460 - MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\$@ \$(PKG_OBJECTS)" 8630 + MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -out:\$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8461 8631 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8462 8632 /* end confdefs.h. */ 8463 8633 8464 8634 #if defined(_MSC_VER) && _MSC_VER >= 1400 8465 8635 print("manifest needed") 8466 8636 #endif 8467 8637 ................................................................................ 8479 8649 8480 8650 fi 8481 8651 rm -f conftest* 8482 8652 8483 8653 MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\$@ \$(PKG_STUB_OBJECTS)" 8484 8654 else 8485 8655 MAKE_STATIC_LIB="\${STLIB_LD} \$@ \$(PKG_OBJECTS)" 8486 - MAKE_SHARED_LIB="\${SHLIB_LD} -o \$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8656 + MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -o \$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8487 8657 MAKE_STUB_LIB="\${STLIB_LD} \$@ \$(PKG_STUB_OBJECTS)" 8488 8658 fi 8489 8659 8490 8660 if test "${SHARED_BUILD}" = "1" ; then 8491 8661 MAKE_LIB="${MAKE_SHARED_LIB} " 8492 8662 else 8493 8663 MAKE_LIB="${MAKE_STATIC_LIB} " ................................................................................ 8567 8737 8568 8738 8569 8739 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5 8570 8740 $as_echo_n "checking for tclsh... " >&6; } 8571 8741 if test -f "${TCL_BIN_DIR}/Makefile" ; then 8572 8742 # tclConfig.sh is in Tcl build directory 8573 8743 if test "${TEA_PLATFORM}" = "windows"; then 8574 - if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" ; then 8575 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 8576 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" ; then 8577 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" 8578 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" ; then 8579 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" 8580 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" ; then 8581 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" 8744 + if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" ; then 8745 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" 8746 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" ; then 8747 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" 8748 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" ; then 8749 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" 8750 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" ; then 8751 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" 8582 8752 fi 8583 8753 else 8584 8754 TCLSH_PROG="${TCL_BIN_DIR}/tclsh" 8585 8755 fi 8586 8756 else 8587 8757 # tclConfig.sh is in install location 8588 8758 if test "${TEA_PLATFORM}" = "windows"; then 8589 - TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 8759 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" 8590 8760 else 8591 - TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}" 8761 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" 8592 8762 fi 8593 8763 list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \ 8594 8764 `ls -d ${TCL_BIN_DIR}/.. 2>/dev/null` \ 8595 8765 `ls -d ${TCL_PREFIX}/bin 2>/dev/null`" 8596 8766 for i in $list ; do 8597 8767 if test -f "$i/${TCLSH_PROG}" ; then 8598 8768 REAL_TCL_BIN_DIR="`cd "$i"; pwd`/" ................................................................................ 8782 8952 $as_echo "#define TDOM_LESS_NS 1" >>confdefs.h 8783 8953 8784 8954 else 8785 8955 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 8786 8956 $as_echo "no" >&6; } 8787 8957 fi 8788 8958 8959 + 8960 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable valiation features" >&5 8961 +$as_echo_n "checking whether to enable valiation features... " >&6; } 8962 + # Check whether --enable-schema was given. 8963 +if test "${enable_schema+set}" = set; then : 8964 + enableval=$enable_schema; tcl_ok=$enableval 8965 +else 8966 + tcl_ok=yes 8967 +fi 8968 + 8969 + 8970 + if test "${enable_schema+set}" = set; then 8971 + enableval="$enable_schema" 8972 + tcl_ok=$enableval 8973 + else 8974 + tcl_ok=yes 8975 + fi 8976 + 8977 + if test "$tcl_ok" = "no" ; then 8978 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 8979 +$as_echo "no" >&6; } 8980 + $as_echo "#define TDOM_NO_SCHEMA 1" >>confdefs.h 8981 + 8982 + else 8983 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 8984 +$as_echo "yes" >&6; } 8985 + fi 8986 + 8789 8987 8790 8988 TDOMSHELL=tcldomsh 8791 8989 8792 8990 8793 8991 8794 8992 #-------------------------------------------------------------------- 8795 8993 # These are for ${PACKAGE_NAME}Config.sh
Changes to configure.ac.
75 75 76 76 #-------------------------------------------------------------------- 77 77 # Add shared expat includes and expat entropy 78 78 #-------------------------------------------------------------------- 79 79 80 80 TDOM_PATH_EXPAT 81 81 TDOM_EXPAT_ENTROPY 82 + 83 +#-------------------------------------------------------------------- 84 +# We need the UINT2PTR and PTR2UINT macros, so make sure that intptr_t 85 +# is defined. 86 +#-------------------------------------------------------------------- 87 + 88 +AC_CHECK_TYPE([uintptr_t], [ 89 + AC_DEFINE([HAVE_UINTPTR_T], 1, [Do we have the uintptr_t type?])], [ 90 + AC_CACHE_CHECK([for pointer-size unsigned integer type], tcl_cv_uintptr_t, [ 91 + for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \ 92 + none; do 93 + if test "$tcl_cv_uintptr_t" != none; then 94 + AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT], 95 + [[sizeof (void *) <= sizeof ($tcl_cv_uintptr_t)]])], 96 + [tcl_ok=yes], [tcl_ok=no]) 97 + test "$tcl_ok" = yes && break; fi 98 + done]) 99 + if test "$tcl_cv_uintptr_t" != none; then 100 + AC_DEFINE_UNQUOTED([uintptr_t], [$tcl_cv_uintptr_t], [Unsigned integer 101 + type wide enough to hold a pointer.]) 102 + fi 103 +]) 82 104 83 105 #-------------------------------------------------------------------- 84 106 # Add HTML5 parsing support. 85 107 #-------------------------------------------------------------------- 86 108 87 109 TDOM_ENABLE_HTML5 88 110 ................................................................................ 105 127 generic/domxslt.c \ 106 128 generic/domlock.c \ 107 129 generic/tcldom.c \ 108 130 generic/nodecmd.c \ 109 131 generic/tdominit.c \ 110 132 generic/tclexpat.c \ 111 133 generic/tclpull.c \ 112 - generic/structure.c \ 134 + generic/schema.c \ 113 135 generic/tdomStubInit.c]) 114 136 TEA_ADD_HEADERS([generic/tdom.h]) 115 137 TEA_ADD_INCLUDES([-I${srcdir}/generic ${AOL_INCLUDES} ${HTML5_INCLUDES}]) 116 138 TEA_ADD_LIBS([${AOL_LIBS} ${HTML5_LIBS}]) 117 139 TEA_ADD_CFLAGS([]) 118 140 TEA_ADD_STUB_SOURCES([generic/tdomStubLib.c]) 119 141 TEA_ADD_TCL_SOURCES([lib/tdom.tcl]) ................................................................................ 216 238 #-------------------------------------------------------------------- 217 239 218 240 TDOM_ENABLE_DTD 219 241 TDOM_ENABLE_NS 220 242 TDOM_ENABLE_UNKNOWN 221 243 TDOM_ENABLE_TDOMALLOC 222 244 TDOM_ENABLE_LESS_NS 245 +TDOM_ENABLE_SCHEMA 223 246 224 247 TDOMSHELL=tcldomsh 225 248 AC_SUBST(TDOMSHELL) 226 249 227 250 TDOM_EXPORT_CONFIG 228 251 229 252 #-------------------------------------------------------------------- 230 253 # Finally, substitute all of the various values into the Makefile. 231 254 # You may alternatively have a special pkgIndex.tcl.in or other files 232 255 # which require substituting the AC variables in. Include these here. 233 256 #-------------------------------------------------------------------- 234 257 235 258 AC_OUTPUT([Makefile pkgIndex.tcl tdomConfig.sh])
Changes to doc/INDEX.MAP.
36 36 <MAN id="pullparser" title="pullparser"/> 37 37 <DEF cat="manpage" name="pullparser" manpage="pullparser"/> 38 38 <DEF cat="pullparser" name="tdom::pullparser" manpage="pullparser"/> 39 39 <DEF cat="cmd" name="tdom::pullparser" manpage="pullparser"/> 40 40 <KWD name="XML" manpage="pullparser"/> 41 41 <KWD name="pull" manpage="pullparser"/> 42 42 <KWD name="parsing" manpage="pullparser"/> 43 - <MAN id="structure" title="structure"/> 44 - <DEF cat="manpage" name="structure" manpage="structure"/> 45 - <DEF cat="structure" name="tdom::structure" manpage="structure"/> 46 - <DEF cat="cmd" name="tdom::structure" manpage="structure"/> 43 + <MAN id="schema" title="schema"/> 44 + <DEF cat="manpage" name="schema" manpage="schema"/> 45 + <DEF cat="schema" name="tdom::schema" manpage="schema"/> 46 + <DEF cat="cmd" name="tdom::schema" manpage="schema"/> 47 + <KWD name="Validation" manpage="schema"/> 48 + <KWD name="Postvalidation" manpage="schema"/> 49 + <KWD name="DOM" manpage="schema"/> 50 + <KWD name="SAX" manpage="schema"/> 47 51 <MAN id="tdomcmd" title="tdom"/> 48 52 <DEF cat="manpage" name="tdomcmd" manpage="tdomcmd"/> 49 53 <DEF cat="cmd" name="tdom" manpage="tdomcmd"/> 50 54 <KWD name="DOM" manpage="tdomcmd"/> 51 55 <KWD name="SAX" manpage="tdomcmd"/> 52 56 <KWD name="C handler set" manpage="tdomcmd"/> 53 57 <MAN id="tnc" title="tnc"/> 54 58 <DEF cat="manpage" name="tnc" manpage="tnc"/> 55 59 <DEF cat="cmd" name="tnc" manpage="tnc"/> 56 60 <KWD name="Validation" manpage="tnc"/> 57 61 <KWD name="DTD" manpage="tnc"/> 58 62 </INDEX> 59 63
Changes to doc/category-index.html.
4 4 </head><body> 5 5 <div class="header"> 6 6 <h1 class="title" align="center">tDOM manual: Index</h1><p class="navaid" align="center"> 7 7 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 8 8 </p><hr class="navsep"><div class="navbar"> 9 9 <a href="#cat_cmd">Tcl commands</a> · <a href="#cat_fun">C functions</a> · </div> 10 10 </div><div class="body"> 11 -<h2><a name="cat_cmd">Tcl commands</a></h2><a href="dom.html">dom</a> · <a href="dom.html">dom</a> · <a href="domDoc.html">domDoc</a> · <a href="domNode.html">domNode</a> · <a href="expat.html">expat</a> · <a href="expat.html">expat</a> · <a href="tdomcmd.html">tdom</a> · <a href="pullparser.html">tDOM::pullparser</a> · <a href="tnc.html">tnc</a> · <a href="expat.html">xml::parser</a><h2><a name="cat_fun">C functions</a></h2><a href="expatapi.html">CheckExpatParserObj, CHandlerSetInstall, CHandlerSetRemove, 11 +<h2><a name="cat_cmd">Tcl commands</a></h2><a href="dom.html">dom</a> · <a href="dom.html">dom</a> · <a href="domDoc.html">domDoc</a> · <a href="domNode.html">domNode</a> · <a href="expat.html">expat</a> · <a href="expat.html">expat</a> · <a href="tdomcmd.html">tdom</a> · <a href="pullparser.html">tdom::pullparser</a> · <a href="schema.html">tdom::schema</a> · <a href="tnc.html">tnc</a> · <a href="expat.html">xml::parser</a><h2><a name="cat_fun">C functions</a></h2><a href="expatapi.html">CheckExpatParserObj, CHandlerSetInstall, CHandlerSetRemove, 12 12 CHandlerSetCreate, CHandlerSetGetUserData, GetExpatInfo</a> 13 13 </div><div class="footer"> 14 14 <hr class="navsep"><div class="navbar" align="center"> 15 15 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 16 16 </div> 17 17 </div> 18 18 </body> 19 19 </html>
Changes to doc/dom.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: dom</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0xc37960">NAME</a> · <a href="#SECTid0xbe8eb0">SYNOPSIS</a> · <a href="#SECTid0xb3ad40">DESCRIPTION </a> · <a href="#SECTid0xc83270">KEYWORDS</a> 7 +<a href="#SECTid0x5569427a27e0">NAME</a> · <a href="#SECTid0x556942857580">SYNOPSIS</a> · <a href="#SECTid0x55694284e560">DESCRIPTION </a> · <a href="#SECTid0x556942884430">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0xc37960">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x5569427a27e0">NAME</a></h2><p class="namesection"> 11 11 <b class="names">dom - </b><br>Create an in-memory DOM tree from XML</p> 12 12 13 - <h2><a name="SECTid0xbe8eb0">SYNOPSIS</a></h2><pre class="syntax">package require tdom 13 + <h2><a name="SECTid0x556942857580">SYNOPSIS</a></h2><pre class="syntax">package require tdom 14 14 15 15 <b class="cmd">dom</b> <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre> 16 16 17 - <h2><a name="SECTid0xb3ad40">DESCRIPTION </a></h2><p>This command provides the creation of DOM trees in memory. In 17 + <h2><a name="SECTid0x55694284e560">DESCRIPTION </a></h2><p>This command provides the creation of DOM trees in memory. In 18 18 the usual case a string containing a XML information is parsed and converted 19 19 into a DOM tree. Other possible parse input may be HTML or JSON. 20 20 The <i class="m">method</i> indicates a specific subcommand. </p><p>The valid methods are:</p><dl class="commandlist"> 21 21 22 22 <dt> 23 23 <b class="cmd">dom</b> <b class="method">parse</b> ?<i class="m">options</i>? ?<i class="m">data</i>?</dt> 24 24 <dd>Parses the XML information and builds up the DOM tree in memory ................................................................................ 586 586 <dd>Returns the version of the underlyling expat 587 587 version as string, something like 588 588 "exapt_2.1.0". This is what the expat API 589 589 function XML_ExpatVersion() returns.</dd> 590 590 591 591 592 592 <dt><b>expatmajorversion</b></dt> 593 - <dd>Returns the major version of the at build time 594 - used expat version as integer.</dd> 593 + <dd>Returns the major version of the at build 594 + time used expat version as integer.</dd> 595 595 596 596 597 597 <dt><b>expatminorversion</b></dt> 598 - <dd>Returns the minor version of the at build time 599 - used expat version as integer.</dd> 598 + <dd>Returns the minor version of the at build 599 + time used expat version as integer.</dd> 600 600 601 601 602 602 <dt><b>expatmicroversion</b></dt> 603 - <dd>Returns the micro version of the at build time 604 - used expat version as integer.</dd> 603 + <dd>Returns the micro version of the at build 604 + time used expat version as integer.</dd> 605 605 606 606 607 607 <dt><b>dtd</b></dt> 608 608 <dd>Returns as boolean if build with 609 609 <i class="m">--enable-dtd</i>.</dd> 610 610 611 611 ................................................................................ 643 643 <dd>Returns the fossil repository version hash.</dd> 644 644 645 645 646 646 <dt><b>pullparser</b></dt> 647 647 <dd>Returns as boolean if the pullparser command 648 648 is build in.</dd> 649 649 650 + 651 + <dt><b>schema</b></dt> 652 + <dd>Returns as boolean if the tDOM schema features 653 + are build in.</dd> 654 + 650 655 </dl> 651 656 </dd> 652 657 653 658 </dl> 654 659 655 -<h2><a name="SECTid0xc83270">KEYWORDS</a></h2><p class="keywords"> 660 +<h2><a name="SECTid0x556942884430">KEYWORDS</a></h2><p class="keywords"> 656 661 <a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-document">document</a>, <a class="keyword" href="keyword-index.html#KW-node">node</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</a> 657 662 </p> 658 663 </div><hr class="navsep"><div class="navbar" align="center"> 659 664 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 660 665 </div> 661 666 </body> 662 667 </html>
Changes to doc/dom.n.
623 623 .IP "\fBexpatversion\fR" 624 624 Returns the version of the underlyling expat 625 625 version as string, something like 626 626 "exapt_2.1.0". This is what the expat API 627 627 function XML_ExpatVersion() returns. 628 628 .IP "\fBexpatmajorversion\fR" 629 629 Returns the major version of the at build 630 -time used version as integer. 630 +time used expat version as integer. 631 631 .IP "\fBexpatminorversion\fR" 632 632 Returns the minor version of the at build 633 633 time used expat version as integer. 634 634 .IP "\fBexpatmicroversion\fR" 635 635 Returns the micro version of the at build 636 636 time used expat version as integer. 637 637 .IP "\fBdtd\fR" ................................................................................ 656 656 Returns as boolean, if build with 657 657 \&\fI--enable-html5\fR. 658 658 .IP "\fBversionhash\fR" 659 659 Returns the fossil repository version hash. 660 660 .IP "\fBpullparser\fR" 661 661 Returns as boolean if the pullparser command 662 662 is build in. 663 +.IP "\fBschema\fR" 664 +Returns as boolean if the tDOM schema features 665 +are build in. 663 666 .RE 664 667 .SH KEYWORDS 665 668 XML, DOM, document, node, parsing
Changes to doc/dom.xml.
128 128 investigated or modified with the full range of the 129 129 doc and node methods. Please note that the element 130 130 node names and the text node values within the tree 131 131 may be outside of what the appropriate XML productions 132 132 allow.</desc> 133 133 </optdef> 134 134 135 + <optdef> 136 + <optname>-jsonroot <document element name></optname> 137 + <desc>If given makes the given element name the 138 + document element of the resulting doc. The parsed 139 + content of the JSON string will be the childs of this 140 + document element node.</desc> 141 + </optdef> 142 + 135 143 <optdef> 136 144 <optname>-jsonmaxnesting</optname> 137 145 <optarg>integer</optarg> 138 146 <desc>This option only has effect if used together 139 - with the <m>-json</m> option. The current implementation uses recursive descent JSON parser. In order to avoid using excess stack space, any JSON input that has more than a certain levels of nesting is considered invalid. The default maximum nesting is 2000. The option -jsonmaxnesting allows the user to adjust that.</desc> 147 + with the <m>-json</m> option. The current 148 + implementation uses a recursive descent JSON parser. 149 + In order to avoid using excess stack space, any JSON 150 + input that has more than a certain levels of nesting 151 + is considered invalid. The default maximum nesting is 152 + 2000. The option -jsonmaxnesting allows the user to 153 + adjust that.</desc> 140 154 </optdef> 141 155 142 156 <optdef> 143 157 <optname>--</optname> 144 158 <desc>The option <m>--</m> marks the end of options. 145 159 While respected in general this option is only needed 146 160 in case of parsing JSON data, which may start with a ................................................................................ 286 300 with the <m>-html5</m> option. If this option is 287 301 given, no node within the created DOM tree will be 288 302 internally marked as placed into an XML Namespace, 289 303 even if there is a default namespace in scope for 290 304 un-prefixed elements or even if the element has a 291 305 defined namespace prefix. One consequence is that 292 306 XPath node expressions on such a DOM tree doesn't work 293 - as expected. Prefixed element nodes can't be selected 294 - and element nodes without prefix will be seen by XPath 295 - expressions as if they are not in any namespace (no 296 - matter if they are in fact should be in a default 297 - namespace). 307 + as may be expected. Prefixed element nodes can't be 308 + selected naively and element nodes without prefix will 309 + be seen by XPath expressions as if they are not in any 310 + namespace (no matter if they are in fact should be in 311 + a default namespace). If you need to inject prefixed 312 + node names into an XPath expression use the '%' syntax 313 + described in the documentation of the of the 314 + <command>domNode</command> command method 315 + <method>>selectNodes</method>. 298 316 </desc> 299 317 </optdef> 300 318 301 319 </optlist> 302 320 <p/> 303 321 </desc> 304 322 </commanddef> ................................................................................ 503 521 <command><cmd>dom</cmd> <method>isCharData</method> 504 522 <m>string</m></command> 505 523 <desc>Returns 1 if every character in <m>string</m> is 506 524 a valid XML Char according to production 2 of the <ref href="http://www.w3.org/TR/2000/REC-xml-20001006.html">XML 1.0</ref> 507 525 recommendation. Otherwise it returns 0.</desc> 508 526 </commanddef> 509 527 528 + <commanddef> 529 + <command><cmd>dom</cmd> <method>clearString</method> <m>string</m></command> 530 + <desc>Returns the string given as argument cleared out from any characters not 531 + allowed as XML parsed character data.</desc> 532 + </commanddef> 533 + 510 534 <commanddef> 511 535 <command><cmd>dom</cmd> <method>isBMPCharData</method> 512 536 <m>string</m></command> 513 537 <desc>Returns 1 if every character in <m>string</m> is 514 538 a valid XML Char with a Unicode code point within the Basic 515 539 Multilingual Plane (that means, that every character within the string 516 540 is at most 3 bytes long). Otherwise it returns 0.</desc> ................................................................................ 608 632 <desc>Returns the fossil repository version hash.</desc> 609 633 </optdef> 610 634 <optdef> 611 635 <optname>pullparser</optname> 612 636 <desc>Returns as boolean if the pullparser command 613 637 is build in.</desc> 614 638 </optdef> 639 + <optdef> 640 + <optname>schema</optname> 641 + <desc>Returns as boolean if the tDOM schema features 642 + are build in.</desc> 643 + </optdef> 615 644 </optlist> 616 645 </desc> 617 646 </commanddef> 618 647 </commandlist> 619 648 </section> 620 649 621 650 <keywords>
Changes to doc/domDoc.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: domDoc</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0x1eae960">NAME</a> · <a href="#SECTid0x1e5ff20">SYNOPSIS</a> · <a href="#SECTid0x1e97f70">DESCRIPTION </a> · <a href="#SECTid0x1efaea0">SEE ALSO</a> · <a href="#SECTid0x1efb230">KEYWORDS</a> 7 +<a href="#SECTid0x558e11bed630">NAME</a> · <a href="#SECTid0x558e11b23bb0">SYNOPSIS</a> · <a href="#SECTid0x558e11bcbd50">DESCRIPTION </a> · <a href="#SECTid0x558e11c389e0">SEE ALSO</a> · <a href="#SECTid0x558e11c38d70">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0x1eae960">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x558e11bed630">NAME</a></h2><p class="namesection"> 11 11 <b class="names">domDoc - </b><br>Manipulates an instance of a DOM document object</p> 12 12 13 - <h2><a name="SECTid0x1e5ff20">SYNOPSIS</a></h2><pre class="syntax">domDocObjCmd <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre><pre class="syntax">domDoc <i class="m">docToken</i> <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre> 13 + <h2><a name="SECTid0x558e11b23bb0">SYNOPSIS</a></h2><pre class="syntax">domDocObjCmd <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre><pre class="syntax">domDoc <i class="m">docToken</i> <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre> 14 14 15 - <h2><a name="SECTid0x1e97f70">DESCRIPTION </a></h2><p>This command manipulates one particular instance of a document 15 + <h2><a name="SECTid0x558e11bcbd50">DESCRIPTION </a></h2><p>This command manipulates one particular instance of a document 16 16 object. <i class="m">method</i> indicates a specific method of the document class. These 17 17 methods should closely conform to the W3C recommendation "Document Object Model 18 18 (Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>). Look 19 19 at these documents for a deeper understanding of the functionality.</p><p>The valid methods are:</p><dl class="commandlist"> 20 20 21 21 <dt> 22 22 <b class="method">documentElement</b> ?<i class="m">objVar</i>?</dt> ................................................................................ 106 106 <dt><b class="method">getDefaultOutputMethod</b></dt> 107 107 <dd>Returns the default output method of the document. This is 108 108 usually a result of a XSLT transformation.</dd> 109 109 110 110 111 111 112 112 <dt> 113 -<b class="method">asXML</b> <b class="option">?-indent none/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration <boolean>?</b> <b class="option">-xmlDeclaration <boolean>?</b> <b class="option">-encString <string></b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b> 113 +<b class="method">asXML</b> <b class="option">?-indent none/tabs/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration <boolean>?</b> <b class="option">-xmlDeclaration <boolean>?</b> <b class="option">-encString <string></b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b> 114 114 </dt> 115 115 <dd> 116 116 <p>Returns the DOM tree as an (optional indented) XML 117 117 string or sends the output directly to the given 118 118 channelId.</p> 119 119 120 + <p>The -indent option requires "no", "none", "tabs" or a 121 + natural number betwenn 0 and 8, both included, as value. With 122 + the values "no" or "none" no additional white space outside of 123 + markup will be added to the serialization. I. Otherwise, it's 124 + a "pretty-print" serialization, due to inserting white space 125 + between end and the next start tag according to the nesting 126 + level. The level indentation wide is given with the number. If 127 + the value is "tabs", then indentation is done with tabs, one 128 + tab per level.</p> 129 + 120 130 <p>If the option <i class="m">-escapeNonASCII</i> is given, 121 131 every non 7 bit ASCII character in attribute values or element 122 132 PCDATA content will be escaped as character reference in 123 133 decimal representation.</p> 124 134 125 135 <p>The flag <i class="m">-doctypeDeclaration</i> determines whether 126 136 there will be a DOCTYPE declaration emitted before the first ................................................................................ 337 347 serialized as CDATA section nodes.</dd> 338 348 339 349 340 350 341 351 <dt> 342 352 <b class="method">selectNodesNamespaces</b> <b class="option">?prefixUriList?</b> 343 353 </dt> 344 - <dd>This method allows one to control a document global prefix 345 - to namespace URI mapping, which will be used for selectNodes 354 + <dd>This method gives control to a document global prefix to 355 + namespace URI mapping, which will be used for selectNodes 346 356 method calls (on document as well as on all nodes, which 347 - belongs to the document) if it is not overwritten by using 348 - the -namespaces option of the selectNodes method. Any 349 - namespace prefix within an xpath expression will be first 350 - resolved against this list. If the list binds the same prefix 351 - to different namespaces, then the first binding will win. If a 357 + belongs to the document) if it is not overwritten by using the 358 + -namespaces option of the selectNodes method. Any namespace 359 + prefix within an xpath expression will be first resolved 360 + against this list. If the list binds the same prefix to 361 + different namespaces, then the first binding will win. If a 352 362 prefix could not resolved against the document global prefix / 353 363 namespaces list, then the namespace definitions in scope of 354 364 the context node will be used to resolve the prefix, as usual. 355 365 If the optional argument <i class="m">prefixUriList</i> is given, then 356 366 the global prefix / namespace list is set to this list and 357 367 returns it. Without the optional argument the method returns 358 368 the current list. The default is the empty list.</dd> ................................................................................ 586 596 <i class="m">xpathQuery</i> to the document. The context node of the query is the root 587 597 node in the sense of the XPath recommendation (not the document element). The 588 598 result can be a string/value, a list of strings, a list of nodes or a list 589 599 of attribute name / value pairs. If <i class="m">typeVar</i> is given 590 600 the result type name is stored into that variable (empty, 591 601 bool, number, string, nodes, attrnodes or mixed).</p> 592 602 593 -<p>The argument <i class="m">xpathQuery</i> has to be a valid XPath 594 -expression. However, there is one exception to that rule. Tcl variable 595 -names can appear in the XPath statement at any position where it is 596 -legal according to the rules of the XPath syntax to put an XPath 597 -variable. The value of the variable is substituted for the variable 598 -name. Ignoring the syntax rules of XPath the Tcl variable name may be 599 -any legal Tcl var name: local variables, global variables, array 600 -entries and so on. The value will always be seen as string literal by 601 -the xpath engine. Cast the value explicitly with the according xpath 602 -functions (number(), boolean()) to another data type, if needed.</p> 603 - 604 -<p>The option <i class="m">-namespaces</i> expects a tcl list with prefix / 605 -namespace pairs as argument. If this option is not given, then any 606 -namespace prefix within the xpath expression will be first resolved 607 -against the list of prefix / namespace pairs set with the 608 -selectNodesNamespaces method for the document the node belongs to. If 609 -this fails, then the namespace definitions in scope of the context 610 -node will be used to resolve the prefix. If this option is given, any 611 -namespace prefix within the xpath expression will be first resolved 612 -against that given list (and ignoring the document global prefix / 613 -namespace list). If the list binds the same prefix to different 614 -namespaces, then the first binding will win. If this fails, then the 615 -namespace definitions in scope of the context node will be used to 616 -resolve the prefix, as usual.</p> 617 - 618 -<p>If the <i class="m">-cache</i> option is used with a true value, then the 619 -<i class="m">xpathQuery</i> will be looked up in a document specific cache. If 620 -the query is found, then the stored pre-compiled query will be used. 621 -If the query isn't found, it will be compiled and stored in the cache, 622 -for use in further calls. Please notice, that the <i class="m">xpathQuery</i> as 623 -given as string is used as key for the cache. This means that equal 624 -XPath expressions, which differ only in white space, are treated as 625 -different cache entries. Special care is needed if the XPath 626 -expression includes namespace prefixes or references to tcl variables. 627 -Both namespace prefixes and tcl variable references will be resolved 628 -according to the XML prefix namespace mappings and tcl variable values 629 -at expression compilation time. If the same XPath expression is used 630 -later on in a context with other XML prefix namespace mappings or 631 -values of the used tcl variables, make sure to first remove the 632 -compiled expression from the cache with the help of the 633 -<b class="method">deleteXPathCache</b> method, to force a recompilation. 634 -Without using the <i class="m">-cache</i> option such consideration is never 635 -needed.</p> 636 - 637 -<p>Examples:</p> 638 - <pre class="example">set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ] 639 -foreach paragraph $paragraphNodes { 640 - lappend values [$paragraph selectNodes attribute::type] 641 -} 642 - 643 -set doc [dom parse {<doc xmlns="http://www.defaultnamespace.org"><child/></doc>}] 644 -set root [$doc documentElement] 645 -set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child]</pre> 646 - 603 + <p>See the documentation of the of the 604 + <b class="command">domNode</b> command method 605 + <b class="method">selectNodes</b> for a detailed description of 606 + the arguments.</p> 647 607 </dd> 648 608 649 609 650 610 651 611 <dt> 652 612 <b class="method">baseURI</b> <i class="m">?URI?</i> 653 613 </dt> ................................................................................ 688 648 689 649 </dl><p>Otherwise, if an unknown method name is given, the command with the 690 650 same name as the given method within the namespace <tt class="samp">::dom::domDoc</tt> is 691 651 tried to be executed. This allows quick method additions on Tcl level.</p><p>Newly created nodes are appended to a hidden fragment list. If they 692 652 are not moved into the tree they are automatically deleted as soon as the whole 693 653 document gets deleted.</p> 694 654 695 - <h2><a name="SECTid0x1efaea0">SEE ALSO</a></h2><p class="seealso">dom, domNode</p> 655 + <h2><a name="SECTid0x558e11c389e0">SEE ALSO</a></h2><p class="seealso">dom, domNode</p> 696 656 697 - <h2><a name="SECTid0x1efb230">KEYWORDS</a></h2><p class="keywords"> 657 + <h2><a name="SECTid0x558e11c38d70">KEYWORDS</a></h2><p class="keywords"> 698 658 <a class="keyword" href="keyword-index.html#KW-DOMnodecreation">DOM node creation</a>, <a class="keyword" href="keyword-index.html#KW-documentelement">document element</a> 699 659 </p> 700 660 701 661 </div><hr class="navsep"><div class="navbar" align="center"> 702 662 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 703 663 </div> 704 664 </body> 705 665 </html>
Changes to doc/domDoc.n.
233 233 Tcl object commands (for nodes, fragment/new nodes, the document object itself) 234 234 and the underlying DOM tree. 235 235 .TP 236 236 \&\fB\fBgetDefaultOutputMethod\fP 237 237 \&\fRReturns the default output method of the document. This is 238 238 usually a result of a XSLT transformation. 239 239 .TP 240 -\&\fB\fBasXML\fP \fB?-indent none/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-doctypeDeclaration <boolean>?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP 240 +\&\fB\fBasXML\fP \fB?-indent none/tabs/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-doctypeDeclaration <boolean>?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP 241 241 \&\fR 242 242 .RS 243 243 .PP 244 244 Returns the DOM tree as an (optional indented) XML 245 245 string or sends the output directly to the given 246 246 channelId. 247 +.PP 248 +The -indent option requires "no", "none", "tabs" or a 249 +natural number betwenn 0 and 8, both included, as value. With 250 +the values "no" or "none" no additional white space outside of 251 +markup will be added to the serialization. I. Otherwise, it's 252 +a "pretty-print" serialization, due to inserting white space 253 +between end and the next start tag according to the nesting 254 +level. The level indentation wide is given with the number. If 255 +the value is "tabs", then indentation is done with tabs, one 256 +tab per level. 247 257 .PP 248 258 If the option \fI-escapeNonASCII\fR is given, 249 259 every non 7 bit ASCII character in attribute values or element 250 260 PCDATA content will be escaped as character reference in 251 261 decimal representation. 252 262 .PP 253 263 The flag \fI-doctypeDeclaration\fR determines whether ................................................................................ 434 444 section elements (return value 1) or not (return value 0). If the 435 445 method is called with only one argument and that argument is an 436 446 asterisk ('*'), then the method returns an unordered list of all 437 447 element names of the document, for which the text node children will be 438 448 serialized as CDATA section nodes. 439 449 .TP 440 450 \&\fB\fBselectNodesNamespaces\fP \fB?prefixUriList?\fP 441 -\&\fRThis method allows one to control a document global prefix 442 -to namespace URI mapping, which will be used for selectNodes 451 +\&\fRThis method gives control to a document global prefix to 452 +namespace URI mapping, which will be used for selectNodes 443 453 method calls (on document as well as on all nodes, which 444 -belongs to the document) if it is not overwritten by using 445 -the -namespaces option of the selectNodes method. Any 446 -namespace prefix within an xpath expression will be first 447 -resolved against this list. If the list binds the same prefix 448 -to different namespaces, then the first binding will win. If a 454 +belongs to the document) if it is not overwritten by using the 455 +-namespaces option of the selectNodes method. Any namespace 456 +prefix within an xpath expression will be first resolved 457 +against this list. If the list binds the same prefix to 458 +different namespaces, then the first binding will win. If a 449 459 prefix could not resolved against the document global prefix / 450 460 namespaces list, then the namespace definitions in scope of 451 461 the context node will be used to resolve the prefix, as usual. 452 462 If the optional argument \fIprefixUriList\fR is given, then 453 463 the global prefix / namespace list is set to this list and 454 464 returns it. Without the optional argument the method returns 455 465 the current list. The default is the empty list. ................................................................................ 615 625 \&\fIxpathQuery\fR to the document. The context node of the query is the root 616 626 node in the sense of the XPath recommendation (not the document element). The 617 627 result can be a string/value, a list of strings, a list of nodes or a list 618 628 of attribute name / value pairs. If \fItypeVar\fR is given 619 629 the result type name is stored into that variable (empty, 620 630 bool, number, string, nodes, attrnodes or mixed). 621 631 .PP 622 -The argument \fIxpathQuery\fR has to be a valid XPath 623 -expression. However, there is one exception to that rule. Tcl variable 624 -names can appear in the XPath statement at any position where it is 625 -legal according to the rules of the XPath syntax to put an XPath 626 -variable. The value of the variable is substituted for the variable 627 -name. Ignoring the syntax rules of XPath the Tcl variable name may be 628 -any legal Tcl var name: local variables, global variables, array 629 -entries and so on. The value will always be seen as string literal by 630 -the xpath engine. Cast the value explicitly with the according xpath 631 -functions (number(), boolean()) to another data type, if needed. 632 -.PP 633 -The option \fI-namespaces\fR expects a tcl list with prefix / 634 -namespace pairs as argument. If this option is not given, then any 635 -namespace prefix within the xpath expression will be first resolved 636 -against the list of prefix / namespace pairs set with the 637 -selectNodesNamespaces method for the document the node belongs to. If 638 -this fails, then the namespace definitions in scope of the context 639 -node will be used to resolve the prefix. If this option is given, any 640 -namespace prefix within the xpath expression will be first resolved 641 -against that given list (and ignoring the document global prefix / 642 -namespace list). If the list binds the same prefix to different 643 -namespaces, then the first binding will win. If this fails, then the 644 -namespace definitions in scope of the context node will be used to 645 -resolve the prefix, as usual. 646 -.PP 647 -If the \fI-cache\fR option is used with a true value, then the 648 -\&\fIxpathQuery\fR will be looked up in a document specific cache. If 649 -the query is found, then the stored pre-compiled query will be used. 650 -If the query isn't found, it will be compiled and stored in the cache, 651 -for use in further calls. Please notice, that the \fIxpathQuery\fR as 652 -given as string is used as key for the cache. This means that equal 653 -XPath expressions, which differ only in white space, are treated as 654 -different cache entries. Special care is needed if the XPath 655 -expression includes namespace prefixes or references to tcl variables. 656 -Both namespace prefixes and tcl variable references will be resolved 657 -according to the XML prefix namespace mappings and tcl variable values 658 -at expression compilation time. If the same XPath expression is used 659 -later on in a context with other XML prefix namespace mappings or 660 -values of the used tcl variables, make sure to first remove the 661 -compiled expression from the cache with the help of the 662 -\&\fBdeleteXPathCache\fP method, to force a recompilation. 663 -Without using the \fI-cache\fR option such consideration is never 664 -needed. 665 -.PP 666 -Examples: 667 - 668 - 669 -.CS 670 -set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ] 671 -foreach paragraph $paragraphNodes { 672 - lappend values [$paragraph selectNodes attribute::type] 673 -} 674 - 675 -set doc [dom parse {<doc xmlns="http://www.defaultnamespace.org"><child/></doc>}] 676 -set root [$doc documentElement] 677 -set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child] 678 -.CE 632 +See the documentation of the of the 633 +.TP 634 +\&\fBdomNode 635 +\&\fR command method 636 +\&\fBselectNodes\fP for a detailed description of 637 +the arguments. 679 638 .RE 680 639 .TP 681 640 \&\fB\fBbaseURI\fP \fI?URI?\fB 682 641 \&\fRReturns the present baseURI of the document. If the optional 683 642 argument URI is given, sets the base URI of the document to the given URI. 684 643 .TP 685 644 \&\fB\fBappendFromScript\fP \fItclScript\fB
Changes to doc/domDoc.xml.
107 107 <commanddef> 108 108 <command><method>getDefaultOutputMethod</method></command> 109 109 <desc>Returns the default output method of the document. This is 110 110 usually a result of a XSLT transformation.</desc> 111 111 </commanddef> 112 112 113 113 <commanddef> 114 - <command><method>asXML</method> <option>?-indent none/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>?-doctypeDeclaration <boolean>?</option> <option>-xmlDeclaration <boolean>?</option> <option>-encString <string></option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command> 114 + <command><method>asXML</method> <option>?-indent none/tabs/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>?-doctypeDeclaration <boolean>?</option> <option>-xmlDeclaration <boolean>?</option> <option>-encString <string></option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command> 115 115 <desc><p>Returns the DOM tree as an (optional indented) XML 116 116 string or sends the output directly to the given 117 117 channelId.</p> 118 118 119 + <p>The -indent option requires "no", "none", "tabs" or a 120 + natural number betwenn 0 and 8, both included, as value. With 121 + the values "no" or "none" no additional white space outside of 122 + markup will be added to the serialization. I. Otherwise, it's 123 + a "pretty-print" serialization, due to inserting white space 124 + between end and the next start tag according to the nesting 125 + level. The level indentation wide is given with the number. If 126 + the value is "tabs", then indentation is done with tabs, one 127 + tab per level.</p> 128 + 119 129 <p>If the option <m>-escapeNonASCII</m> is given, 120 130 every non 7 bit ASCII character in attribute values or element 121 131 PCDATA content will be escaped as character reference in 122 132 decimal representation.</p> 123 133 124 134 <p>The flag <m>-doctypeDeclaration</m> determines whether 125 135 there will be a DOCTYPE declaration emitted before the first ................................................................................ 159 169 empty content it will be serialized with an element start tag 160 170 and an immediately following element end tag.</p></desc> 161 171 162 172 </commanddef> 163 173 164 174 <commanddef> 165 175 <command><method>asHTML</method> <option>?-channel 166 -channelId?</option> <option>?-escapeNonASCII?</option> <option>?-htmlEntities?</option> <option>?-doctypeDeclaration <boolean>?</option></command> 167 - <desc>Returns the DOM tree serialized according to HTML rules 176 +channelId?</option> <option>?-escapeNonASCII?</option> <option>?-htmlEntities?</option> <option>?-doctypeDeclaration <boolean>?</option> <option>?-breakLines?</option> <option>?-onlyContents?</option></command> 177 + <desc><p>Returns the DOM tree serialized according to HTML rules 168 178 (HTML elements are recognized regardless of case, without end 169 179 tags for empty HTML elements etc.) as string or sends the 170 - output directly to the given channelId. If the option 171 - <m>-escapeNonASCII</m> is given, every non 7 bit ASCII 172 - character in attribute values or element PCDATA content will 173 - be escaped as character reference in decimal representation. 174 - If the option <m>-htmlEntities</m> is given, a character is 180 + output directly to the given channelId.</p> 181 + 182 + <p>If the option <m>-escapeNonASCII</m> is given, every non 7 183 + bit ASCII character in attribute values or element PCDATA 184 + content will be escaped as character reference in decimal 185 + representation.</p> 186 + 187 + <p>If the option <m>-htmlEntities</m> is given, a character is 175 188 written using its HTML 4.01 character entity reference, if it 176 - has one. If the flag <m>-doctypeDeclaration</m> is given there 177 - will be a DOCTYPE declaration emitted before the first node of 178 - the document. The default is, to do not. The DOCTYPE name will 189 + has one.</p> 190 + 191 + <p>If the option <m>-breakLines</m> is given the serialization 192 + outputs "\n>" instead of ">" for the opening tags of 193 + elements.</p> 194 + 195 + <p>If the option <m>-onlyContents</m> is given only all child 196 + nodes are serialized. This option is ignored by document 197 + nodes.</p> 198 + 199 + <p>If the flag <m>-doctypeDeclaration</m> is given there will 200 + be a DOCTYPE declaration emitted before the first node of the 201 + document. The default is, to do not. The DOCTYPE name will 179 202 always be the element name of the document element without 180 203 case normalization. An external entity declaration of the 181 204 external subset is only emitted, if the document has a system 182 205 identifier. The doctype declaration will be written from the 183 - available information, without check, if this is a known 184 - (w3c) HTML version information or if the document confirms to 185 - the given HTML version.</desc> 206 + available information, without check, if this is a known (w3c) 207 + HTML version information or if the document confirms to the 208 + given HTML version. All nodes types other than document nodes 209 + ignore this option.</p></desc> 186 210 </commanddef> 187 211 188 212 <commanddef> 189 213 <command><method>asText</method></command> 190 214 <desc>The asText method returns the tree by serializing the 191 215 string-value of every text node in document order without 192 216 any escaping. In effect, this is what the xslt output method ................................................................................ 318 342 asterisk ('*'), then the method returns an unordered list of all 319 343 element names of the document, for which the text node children will be 320 344 serialized as CDATA section nodes.</desc> 321 345 </commanddef> 322 346 323 347 <commanddef> 324 348 <command><method>selectNodesNamespaces</method> <option>?prefixUriList?</option></command> 325 - <desc>This method allows one to control a document global prefix 326 - to namespace URI mapping, which will be used for selectNodes 349 + <desc>This method gives control to a document global prefix to 350 + namespace URI mapping, which will be used for selectNodes 327 351 method calls (on document as well as on all nodes, which 328 - belongs to the document) if it is not overwritten by using 329 - the -namespaces option of the selectNodes method. Any 330 - namespace prefix within an xpath expression will be first 331 - resolved against this list. If the list binds the same prefix 332 - to different namespaces, then the first binding will win. If a 352 + belongs to the document) if it is not overwritten by using the 353 + -namespaces option of the selectNodes method. Any namespace 354 + prefix within an xpath expression will be first resolved 355 + against this list. If the list binds the same prefix to 356 + different namespaces, then the first binding will win. If a 333 357 prefix could not resolved against the document global prefix / 334 358 namespaces list, then the namespace definitions in scope of 335 359 the context node will be used to resolve the prefix, as usual. 336 360 If the optional argument <m>prefixUriList</m> is given, then 337 361 the global prefix / namespace list is set to this list and 338 362 returns it. Without the optional argument the method returns 339 363 the current list. The default is the empty list.</desc> ................................................................................ 537 561 <m>xpathQuery</m> to the document. The context node of the query is the root 538 562 node in the sense of the XPath recommendation (not the document element). The 539 563 result can be a string/value, a list of strings, a list of nodes or a list 540 564 of attribute name / value pairs. If <m>typeVar</m> is given 541 565 the result type name is stored into that variable (empty, 542 566 bool, number, string, nodes, attrnodes or mixed).</p> 543 567 544 -<p>The argument <m>xpathQuery</m> has to be a valid XPath 545 -expression. However, there is one exception to that rule. Tcl variable 546 -names can appear in the XPath statement at any position where it is 547 -legal according to the rules of the XPath syntax to put an XPath 548 -variable. The value of the variable is substituted for the variable 549 -name. Ignoring the syntax rules of XPath the Tcl variable name may be 550 -any legal Tcl var name: local variables, global variables, array 551 -entries and so on. The value will always be seen as string literal by 552 -the xpath engine. Cast the value explicitly with the according xpath 553 -functions (number(), boolean()) to another data type, if needed.</p> 554 - 555 -<p>The option <m>-namespaces</m> expects a tcl list with prefix / 556 -namespace pairs as argument. If this option is not given, then any 557 -namespace prefix within the xpath expression will be first resolved 558 -against the list of prefix / namespace pairs set with the 559 -selectNodesNamespaces method for the document the node belongs to. If 560 -this fails, then the namespace definitions in scope of the context 561 -node will be used to resolve the prefix. If this option is given, any 562 -namespace prefix within the xpath expression will be first resolved 563 -against that given list (and ignoring the document global prefix / 564 -namespace list). If the list binds the same prefix to different 565 -namespaces, then the first binding will win. If this fails, then the 566 -namespace definitions in scope of the context node will be used to 567 -resolve the prefix, as usual.</p> 568 - 569 -<p>If the <m>-cache</m> option is used with a true value, then the 570 -<m>xpathQuery</m> will be looked up in a document specific cache. If 571 -the query is found, then the stored pre-compiled query will be used. 572 -If the query isn't found, it will be compiled and stored in the cache, 573 -for use in further calls. Please notice, that the <m>xpathQuery</m> as 574 -given as string is used as key for the cache. This means that equal 575 -XPath expressions, which differ only in white space, are treated as 576 -different cache entries. Special care is needed if the XPath 577 -expression includes namespace prefixes or references to tcl variables. 578 -Both namespace prefixes and tcl variable references will be resolved 579 -according to the XML prefix namespace mappings and tcl variable values 580 -at expression compilation time. If the same XPath expression is used 581 -later on in a context with other XML prefix namespace mappings or 582 -values of the used tcl variables, make sure to first remove the 583 -compiled expression from the cache with the help of the 584 -<method>deleteXPathCache</method> method, to force a recompilation. 585 -Without using the <m>-cache</m> option such consideration is never 586 -needed.</p> 587 - 588 -<p>Examples:</p> 589 - <example>set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ] 590 -foreach paragraph $paragraphNodes { 591 - lappend values [$paragraph selectNodes attribute::type] 592 -} 593 - 594 -set doc [dom parse {<doc xmlns="http://www.defaultnamespace.org"><child/></doc>}] 595 -set root [$doc documentElement] 596 -set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child]</example> 597 - 568 + <p>See the documentation of the of the 569 + <command>domNode</command> command method 570 + <method>selectNodes</method> for a detailed description of 571 + the arguments.</p> 598 572 </desc> 599 573 </commanddef> 600 574 601 575 <commanddef> 602 576 <command><method>baseURI</method> <m>?URI?</m></command> 603 577 <desc>Returns the present baseURI of the document. If the optional 604 578 argument URI is given, sets the base URI of the document to the given URI.</desc>
Changes to doc/domNode.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: domNode</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0xd75c60">NAME</a> · <a href="#SECTid0xc89db0">SYNOPSIS</a> · <a href="#SECTid0xd6fd90"> DESCRIPTION </a> · <a href="#SECTid0xdd72b0">SEE ALSO</a> · <a href="#SECTid0xdd7640">KEYWORDS</a> 7 +<a href="#SECTid0x55d13d94e630">NAME</a> · <a href="#SECTid0x55d13d884bb0">SYNOPSIS</a> · <a href="#SECTid0x55d13d92cc90"> DESCRIPTION </a> · <a href="#SECTid0x55d13d99ded0">SEE ALSO</a> · <a href="#SECTid0x55d13d99e260">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0xd75c60">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x55d13d94e630">NAME</a></h2><p class="namesection"> 11 11 <b class="names">domNode - </b><br>Manipulates an instance of a DOM node object</p> 12 12 13 13 14 14 15 - <h2><a name="SECTid0xc89db0">SYNOPSIS</a></h2><pre class="syntax">$nodeObject <i class="m">method</i> <i class="m">arg arg ...</i> 15 + <h2><a name="SECTid0x55d13d884bb0">SYNOPSIS</a></h2><pre class="syntax">$nodeObject <i class="m">method</i> <i class="m">arg arg ...</i> 16 16 </pre><pre class="syntax">domNode <i class="m">nodeToken</i> <i class="m">method</i> <i class="m">arg arg ...</i> 17 17 </pre> 18 - <h2><a name="SECTid0xd6fd90"> DESCRIPTION </a></h2><p>This command manipulates one particular instance of a DOM node object. 18 + <h2><a name="SECTid0x55d13d92cc90"> DESCRIPTION </a></h2><p>This command manipulates one particular instance of a DOM node object. 19 19 <i class="m">method</i> indicates a specific method of the node class. These methods 20 20 should closely conform to the W3C recommendation "Document Object Model 21 21 (Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>) 22 22 as well to parts of the W3C draft "XML Pointer Language (XPointer)" 23 23 (<a href="http://www.w3.org/TR/1998/WD-xptr-19980303">http://www.w3.org/TR/1998/WD-xptr-19980303</a>). 24 24 Please note, that the XPointer methods are deprecated. Use DOM methods 25 25 or XPath expressions instead of them.</p><p>The selectNodes method implements the "XML Path ................................................................................ 197 197 <dt> 198 198 <b class="method">setAttributeNS</b> <i class="m">uri qualifiedName newValue 199 199 ?uri qualifiedName newValue ...?</i> </dt> 200 200 <dd> 201 201 <p>Sets the value for one or more full qualified 202 202 attributes. Every attribute <i class="m">qualifiedName</i> with the namespace URI 203 203 <i class="m">uri</i> will be set to <i class="m">newValue</i>. This will create a new attribute, if 204 -it wasn't avialble before. If you want to set an attribute within a namespace 204 +it wasn't available before. If you want to set an attribute within a namespace 205 205 you must specify the attribute name with prefix, even if you want to set an 206 206 already existing attribute to a new value. While searching, if the attribute 207 207 already exists, only the given <i class="m">uri</i> and the localname of the 208 208 <i class="m">qualifiedName</i> is used.</p> 209 209 210 210 <pre class="example">$node setAttributeNS "http://some.uri.com/wow" prefix:attr1 attrValue</pre> 211 211 212 -<p>If the uri is the empty string and the attribute name hasn't a prefix, this 213 -method has the same effect as the method <b>setAttribute</b>.</p> 212 +<p>If the uri is the empty string and the attribute name has no 213 +prefix, this method has the same effect as the method 214 +<b>setAttribute</b>.</p> 214 215 215 216 <pre class="example">$node setAttributeNS "" attri "some Value"</pre> 216 217 217 218 <p>With the exceptions of the special prefixes "xmlns" and "xml" you 218 -always must provide a non empty <i class="m">uri</i>, if your <i class="m">qualifiedName</i> has a 219 +always must provide a non empty <i class="m">uri</i> if your <i class="m">qualifiedName</i> has a 219 220 prefix. It is not recommended to set xml namespace declarations. The effects are complicated and not always obvious up to resulting a not well-formed serializations after further processing.</p> 220 221 </dd> 221 222 222 223 223 224 224 225 <dt> 225 226 <b class="method">removeAttributeNS</b> <i class="m">uri</i> <i class="m">localName</i> ................................................................................ 228 229 the namespace <i class="m">uri</i>.</dd> 229 230 230 231 231 232 232 233 <dt> 233 234 <b class="method">attributes</b> <b class="option">?attributeNamePattern?</b> 234 235 </dt> 235 - <dd>Returns information about the attriubtes matching the 236 + <dd>Returns information about the attributes matching the 236 237 <i class="m">attributeNamePattern</i>. If <i class="m">attributeNamePattern</i> 237 238 isn't given, information about all attributes are returned. 238 239 The return value is a Tcl list, the elements just the 239 - attriubute name in case of non namespaced attriubtes and three 240 + attribute name in case of non namespaced attributes and three 240 241 element sublists for namespaced attributes. n case of an 241 242 "ordinary" namespaced attribute, the sublist elements are 242 243 {<localname> <prefix> <namespace_uri>}. In the special case of 243 244 an xml namespace declaration it is {<the prefix defined> 244 245 <localname> ""}. 245 246 </dd> 246 247 ................................................................................ 498 499 <dt><b class="method">asList</b></dt> 499 500 <dd>Returns the DOM substree starting form the current node as a 500 501 nested Tcl list.</dd> 501 502 502 503 503 504 504 505 <dt> 505 -<b class="method">asXML</b> <b class="option">?-indent none/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">-xmlDeclaration <boolean>?</b> <b class="option">-encString <string></b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b> 506 +<b class="method">asXML</b> <b class="option">?-indent none/tabs/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration <boolean>?</b> <b class="option">-xmlDeclaration <boolean>?</b> <b class="option">-encString <string></b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b> 506 507 </dt> 507 508 <dd> 508 509 <p>Returns the DOM substree starting from the current 509 510 node as the root node of the result as an (optional indented) 510 511 XML string or sends the output directly to the given 511 512 channelId.</p> 512 513 513 - <p>If the option <i class="m">-escapeNonASCII</i> is given, 514 - every non 7 bit ASCII character in attribute values or element 515 - PCDATA content will be escaped as character reference in 516 - decimal representation.</p> 517 - 518 - <p>The flag <i class="m">-xmlDeclaration</i> determines whether there 519 - will be an XML Declaration and a newline emitted before 520 - anything else. The default is, to do not. If this flag is 521 - given with a true argument then</p> 522 - 523 - <p> 524 -<i class="m">-encString</i> sets the encoding value in the XML 525 - Declaration. Otherwise, this option is ignored. Please note, 526 - that this option just enhance the string representation of the 527 - generated XML Declaration with an encoding information string, 528 - nothing more. It's up to the user to handle encoding in case 529 - of writing to a channel or reparsing.</p> 530 - 531 - <p>If the option <i class="m">-escapeAllQuot</i> is given, 532 - quotation marks will be escaped with &quot; even in text 533 - content of elements.</p> 534 - 535 - <p>If the option <i class="m">-indentAttrs</i> is 536 - given, then attributes will each be separated with newlines 537 - and indented to the same level as the parent node plus the 538 - value given as argument to <i class="m">-indentAttrs</i> (0..8).</p> 539 - 540 - <p>If the option <i class="m">-nogtescape</i> is given then the 541 - character '>' won't get escaped in attribute values and text 542 - content of elements. The default is to escape this 543 - character.</p> 544 - 545 - <p>If the option <i class="m">-noEmptyElementTag</i> is given then no 546 - empty tag syntax will be used. Instead, if an element has 547 - empty content it will be serialized with an element start tag 548 - and an immediately following element end tag.</p> 549 -</dd> 550 - 514 + <p>See the documentation of the of the <b class="command"> domDoc 515 + </b> command method <b class="method">asXML</b> for a 516 + detailed description of the arguments.</p> 517 + </dd> 551 518 552 519 553 520 554 521 <dt> 555 522 <b class="method">asHTML</b> <b class="option">?-channel channelId?</b> 556 523 <b class="option">?-escapeNonASCII?</b> <b class="option">?-htmlEntities?</b> 557 524 </dt> ................................................................................ 749 716 750 717 751 718 </dl><p>Otherwise, if an unknown method name is given, the command with the same 752 719 name as the given method within the namespace <tt class="l">::dom::domNode</tt> is tried to 753 720 be executed. This allows quick method additions on Tcl level.</p> 754 721 755 722 756 - <h2><a name="SECTid0xdd72b0">SEE ALSO</a></h2><p class="seealso">dom, domDoc</p> 723 + <h2><a name="SECTid0x55d13d99ded0">SEE ALSO</a></h2><p class="seealso">dom, domDoc</p> 757 724 758 - <h2><a name="SECTid0xdd7640">KEYWORDS</a></h2><p class="keywords"> 725 + <h2><a name="SECTid0x55d13d99e260">KEYWORDS</a></h2><p class="keywords"> 759 726 <a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-document">document</a>, <a class="keyword" href="keyword-index.html#KW-node">node</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</a> 760 727 </p> 761 728 762 729 </div><hr class="navsep"><div class="navbar" align="center"> 763 730 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 764 731 </div> 765 732 </body> 766 733 </html>
Changes to doc/domNode.n.
284 284 \&\fB\fBsetAttributeNS\fP \fIuri qualifiedName newValue ?uri qualifiedName newValue ...?\fB 285 285 \&\fR 286 286 .RS 287 287 .PP 288 288 Sets the value for one or more full qualified 289 289 attributes. Every attribute \fIqualifiedName\fR with the namespace URI 290 290 \&\fIuri\fR will be set to \fInewValue\fR. This will create a new attribute, if 291 -it wasn't avialble before. If you want to set an attribute within a namespace 291 +it wasn't available before. If you want to set an attribute within a namespace 292 292 you must specify the attribute name with prefix, even if you want to set an 293 293 already existing attribute to a new value. While searching, if the attribute 294 294 already exists, only the given \fIuri\fR and the localname of the 295 295 \&\fIqualifiedName\fR is used. 296 296 297 297 298 298 299 299 .CS 300 300 $node setAttributeNS "http://some.uri.com/wow" prefix:attr1 attrValue 301 301 .CE 302 302 .PP 303 -If the uri is the empty string and the attribute name hasn't a prefix, this 304 -method has the same effect as the method \fBsetAttribute\fR. 303 +If the uri is the empty string and the attribute name has no 304 +prefix, this method has the same effect as the method 305 +\&\fBsetAttribute\fR. 305 306 306 307 307 308 308 309 .CS 309 310 $node setAttributeNS "" attri "some Value" 310 311 .CE 311 312 .PP 312 313 With the exceptions of the special prefixes "xmlns" and "xml" you 313 -always must provide a non empty \fIuri\fR, if your \fIqualifiedName\fR has a 314 +always must provide a non empty \fIuri\fR if your \fIqualifiedName\fR has a 314 315 prefix. It is not recommended to set xml namespace declarations. The effects are complicated and not always obvious up to resulting a not well-formed serializations after further processing. 315 316 .RE 316 317 .TP 317 318 \&\fB\fBremoveAttributeNS\fP \fIuri\fB \fIlocalName\fB 318 319 \&\fRRemoves the attribute with the local name \fIlocalName\fR within 319 320 the namespace \fIuri\fR. 320 321 .TP 321 322 \&\fB\fBattributes\fP \fB?attributeNamePattern?\fP 322 -\&\fRReturns information about the attriubtes matching the 323 +\&\fRReturns information about the attributes matching the 323 324 \&\fIattributeNamePattern\fR. If \fIattributeNamePattern\fR 324 325 isn't given, information about all attributes are returned. 325 326 The return value is a Tcl list, the elements just the 326 -attriubute name in case of non namespaced attriubtes and three 327 +attribute name in case of non namespaced attributes and three 327 328 element sublists for namespaced attributes. n case of an 328 329 "ordinary" namespaced attribute, the sublist elements are 329 330 {<localname> <prefix> <namespace_uri>}. In the special case of 330 331 an xml namespace declaration it is {<the prefix defined> 331 332 <localname> ""}. 332 333 .TP 333 334 \&\fB\fBattributeNames\fP \fB?attributeNamePattern?\fP ................................................................................ 500 501 \&\fRReturns the column number of that node in the originally parsed 501 502 XML. 502 503 .TP 503 504 \&\fB\fBasList\fP 504 505 \&\fRReturns the DOM substree starting form the current node as a 505 506 nested Tcl list. 506 507 .TP 507 -\&\fB\fBasXML\fP \fB?-indent none/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP 508 +\&\fB\fBasXML\fP \fB?-indent none/tabs/1..8?\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-doctypeDeclaration <boolean>?\fP \fB-xmlDeclaration <boolean>?\fP \fB-encString <string>\fP \fB?-escapeAllQuot?\fP \fB?-indentAttrs?\fP \fB?-nogtescape?\fP \fB?-noEmptyElementTag?\fP 508 509 \&\fR 509 510 .RS 510 511 .PP 511 512 Returns the DOM substree starting from the current 512 513 node as the root node of the result as an (optional indented) 513 514 XML string or sends the output directly to the given 514 515 channelId. 515 516 .PP 516 -If the option \fI-escapeNonASCII\fR is given, 517 -every non 7 bit ASCII character in attribute values or element 518 -PCDATA content will be escaped as character reference in 519 -decimal representation. 520 -.PP 521 -The flag \fI-xmlDeclaration\fR determines whether there 522 -will be an XML Declaration and a newline emitted before 523 -anything else. The default is, to do not. If this flag is 524 -given with a true argument then 525 -.PP 526 -\&\fI-encString\fR sets the encoding value in the XML 527 -Declaration. Otherwise, this option is ignored. Please note, 528 -that this option just enhance the string representation of the 529 -generated XML Declaration with an encoding information string, 530 -nothing more. It's up to the user to handle encoding in case 531 -of writing to a channel or reparsing. 532 -.PP 533 -If the option \fI-escapeAllQuot\fR is given, 534 -quotation marks will be escaped with " even in text 535 -content of elements. 536 -.PP 537 -If the option \fI-indentAttrs\fR is 538 -given, then attributes will each be separated with newlines 539 -and indented to the same level as the parent node plus the 540 -value given as argument to \fI-indentAttrs\fR (0..8). 541 -.PP 542 -If the option \fI-nogtescape\fR is given then the 543 -character '>' won't get escaped in attribute values and text 544 -content of elements. The default is to escape this 545 -character. 546 -.PP 547 -If the option \fI-noEmptyElementTag\fR is given then no 548 -empty tag syntax will be used. Instead, if an element has 549 -empty content it will be serialized with an element start tag 550 -and an immediately following element end tag. 517 +See the documentation of the of the 518 +.TP 519 +\&\fB domDoc 520 +\&\fR command method \fBasXML\fP for a 521 +detailed description of the arguments. 551 522 .RE 552 523 .TP 553 524 \&\fB\fBasHTML\fP \fB?-channel channelId?\fP \fB?-escapeNonASCII?\fP \fB?-htmlEntities?\fP 554 525 \&\fRReturns the DOM substree starting from the current node as the 555 526 root node of the result serialized according to HTML rules (HTML elements are 556 527 recognized regardless of case, without end tags for empty HTML elements etc.), 557 528 as string or sends the output directly to the given channelId. If the option
Changes to doc/domNode.xml.
180 180 181 181 <commanddef> 182 182 <command><method>setAttributeNS</method> <m>uri qualifiedName newValue 183 183 ?uri qualifiedName newValue ...?</m> </command> 184 184 <desc><p>Sets the value for one or more full qualified 185 185 attributes. Every attribute <m>qualifiedName</m> with the namespace URI 186 186 <m>uri</m> will be set to <m>newValue</m>. This will create a new attribute, if 187 -it wasn't avialble before. If you want to set an attribute within a namespace 187 +it wasn't available before. If you want to set an attribute within a namespace 188 188 you must specify the attribute name with prefix, even if you want to set an 189 189 already existing attribute to a new value. While searching, if the attribute 190 190 already exists, only the given <m>uri</m> and the localname of the 191 191 <m>qualifiedName</m> is used.</p> 192 192 193 193 <example>$node setAttributeNS "http://some.uri.com/wow" prefix:attr1 attrValue</example> 194 194 195 -<p>If the uri is the empty string and the attribute name hasn't a prefix, this 196 -method has the same effect as the method <b>setAttribute</b>.</p> 195 +<p>If the uri is the empty string and the attribute name has no 196 +prefix, this method has the same effect as the method 197 +<b>setAttribute</b>.</p> 197 198 198 199 <example>$node setAttributeNS "" attri "some Value"</example> 199 200 200 201 <p>With the exceptions of the special prefixes "xmlns" and "xml" you 201 -always must provide a non empty <m>uri</m>, if your <m>qualifiedName</m> has a 202 +always must provide a non empty <m>uri</m> if your <m>qualifiedName</m> has a 202 203 prefix. It is not recommended to set xml namespace declarations. The effects are complicated and not always obvious up to resulting a not well-formed serializations after further processing.</p></desc> 203 204 </commanddef> 204 205 205 206 <commanddef> 206 207 <command><method>removeAttributeNS</method> <m>uri</m> <m>localName</m></command> 207 208 <desc>Removes the attribute with the local name <m>localName</m> within 208 209 the namespace <m>uri</m>.</desc> 209 210 </commanddef> 210 211 211 212 <commanddef> 212 213 <command><method>attributes</method> <option>?attributeNamePattern?</option></command> 213 - <desc>Returns information about the attriubtes matching the 214 + <desc>Returns information about the attributes matching the 214 215 <m>attributeNamePattern</m>. If <m>attributeNamePattern</m> 215 216 isn't given, information about all attributes are returned. 216 217 The return value is a Tcl list, the elements just the 217 - attriubute name in case of non namespaced attriubtes and three 218 + attribute name in case of non namespaced attributes and three 218 219 element sublists for namespaced attributes. n case of an 219 220 "ordinary" namespaced attribute, the sublist elements are 220 221 {<localname> <prefix> <namespace_uri>}. In the special case of 221 222 an xml namespace declaration it is {<the prefix defined> 222 223 <localname> ""}. 223 224 </desc> 224 225 </commanddef> ................................................................................ 444 445 <commanddef> 445 446 <command><method>asList</method></command> 446 447 <desc>Returns the DOM substree starting form the current node as a 447 448 nested Tcl list.</desc> 448 449 </commanddef> 449 450 450 451 <commanddef> 451 - <command><method>asXML</method> <option>?-indent none/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>-xmlDeclaration <boolean>?</option> <option>-encString <string></option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command> 452 + <command><method>asXML</method> <option>?-indent none/tabs/1..8?</option> <option>?-channel channelId?</option> <option>?-escapeNonASCII?</option> <option>?-doctypeDeclaration <boolean>?</option> <option>-xmlDeclaration <boolean>?</option> <option>-encString <string></option> <option>?-escapeAllQuot?</option> <option>?-indentAttrs?</option> <option>?-nogtescape?</option> <option>?-noEmptyElementTag?</option></command> 452 453 <desc><p>Returns the DOM substree starting from the current 453 454 node as the root node of the result as an (optional indented) 454 455 XML string or sends the output directly to the given 455 456 channelId.</p> 456 457 457 - <p>If the option <m>-escapeNonASCII</m> is given, 458 - every non 7 bit ASCII character in attribute values or element 459 - PCDATA content will be escaped as character reference in 460 - decimal representation.</p> 461 - 462 - <p>The flag <m>-xmlDeclaration</m> determines whether there 463 - will be an XML Declaration and a newline emitted before 464 - anything else. The default is, to do not. If this flag is 465 - given with a true argument then</p> 466 - 467 - <p><m>-encString</m> sets the encoding value in the XML 468 - Declaration. Otherwise, this option is ignored. Please note, 469 - that this option just enhance the string representation of the 470 - generated XML Declaration with an encoding information string, 471 - nothing more. It's up to the user to handle encoding in case 472 - of writing to a channel or reparsing.</p> 473 - 474 - <p>If the option <m>-escapeAllQuot</m> is given, 475 - quotation marks will be escaped with &quot; even in text 476 - content of elements.</p> 477 - 478 - <p>If the option <m>-indentAttrs</m> is 479 - given, then attributes will each be separated with newlines 480 - and indented to the same level as the parent node plus the 481 - value given as argument to <m>-indentAttrs</m> (0..8).</p> 482 - 483 - <p>If the option <m>-nogtescape</m> is given then the 484 - character '>' won't get escaped in attribute values and text 485 - content of elements. The default is to escape this 486 - character.</p> 487 - 488 - <p>If the option <m>-noEmptyElementTag</m> is given then no 489 - empty tag syntax will be used. Instead, if an element has 490 - empty content it will be serialized with an element start tag 491 - and an immediately following element end tag.</p></desc> 492 - 493 - </commanddef> 494 - 495 - <commanddef> 496 - <command><method>asHTML</method> <option>?-channel channelId?</option> 497 -<option>?-escapeNonASCII?</option> <option>?-htmlEntities?</option></command> 498 - <desc>Returns the DOM substree starting from the current node as the 499 -root node of the result serialized according to HTML rules (HTML elements are 500 -recognized regardless of case, without end tags for empty HTML elements etc.), 501 -as string or sends the output directly to the given channelId. If the option 502 -<m>-escapeNonASCII</m> is given, every non 7 bit ASCII character in attribute 503 -values or element PCDATA content will be escaped as character reference in 504 -decimal representation. If the option <m>-htmlEntities</m> is given, a 505 -character is written using its HTML 4.01 character entity reference, if one is 506 -defined for it.</desc> 458 + <p>See the documentation of the of the 459 + <command>domDoc</command> command method 460 + <method>asXML</method> for a detailed description of the 461 + arguments.</p> 462 + </desc> 463 + </commanddef> 464 + 465 + <commanddef> 466 + <command><method>asHTML</method> <option>?-channel 467 +channelId?</option> <option>?-escapeNonASCII?</option> <option>?-htmlEntities?</option> <option>?-doctypeDeclaration <boolean>?</option> <option>?-breakLines?</option> <option>?-onlyContents?</option></command> 468 + <desc><p>Returns the DOM substree starting from the current 469 + node as the root node of the result serialized according to 470 + HTML rules (HTML elements are recognized regardless of case, 471 + without end tags for empty HTML elements etc.), as string or 472 + sends the output directly to the given channelId.</p> 473 + 474 + <p>See the documentation of the the <command>domDoc</command> 475 + method <method>asHTML</method> for a detailed description of 476 + the arguments.</p> 477 + </desc> 507 478 </commanddef> 508 479 509 480 <commanddef> 510 481 <command><method>asText</method></command> 511 482 <desc>For ELEMENT_NODEs, the asText method outputs 512 483 the string-value of every text node descendant of node in document 513 484 order without any escaping. For every other node type, this method outputs the XPath string value of that node.</desc>
Changes to doc/expat.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: expat</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0x1708960">NAME</a> · <a href="#SECTid0x160bf00">SYNOPSIS</a> · <a href="#SECTid0x16ee020">DESCRIPTION</a> · <a href="#SECTid0x16eed60">COMMAND OPTIONS</a> · <a href="#SECTid0x1746b80"> COMMAND METHODS </a> · <a href="#SECTid0x174d660">Callback Command Return Codes</a> · <a href="#SECTid0x174e1f0">SEE ALSO</a> · <a href="#SECTid0x174e5b0">KEYWORDS</a> 7 +<a href="#SECTid0x5575961dc910">NAME</a> · <a href="#SECTid0x55759612bd60">SYNOPSIS</a> · <a href="#SECTid0x5575961d3ef0">DESCRIPTION</a> · <a href="#SECTid0x5575961d4cc0">COMMAND OPTIONS</a> · <a href="#SECTid0x557596234b50"> COMMAND METHODS </a> · <a href="#SECTid0x55759623b630">Callback Command Return Codes</a> · <a href="#SECTid0x55759623c1c0">SEE ALSO</a> · <a href="#SECTid0x55759623c580">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0x1708960">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x5575961dc910">NAME</a></h2><p class="namesection"> 11 11 <b class="names">expat - </b><br>Creates an instance of an expat parser object</p> 12 12 13 13 14 14 15 - <h2><a name="SECTid0x160bf00">SYNOPSIS</a></h2><pre class="syntax">package require tdom 15 + <h2><a name="SECTid0x55759612bd60">SYNOPSIS</a></h2><pre class="syntax">package require tdom 16 16 17 17 <b class="cmd">expat</b> ?<i class="m">parsername</i>? ?<i class="m">-namespace</i>? ?<i class="m">arg arg ..</i> 18 18 19 19 <b class="cmd">xml::parser</b> ?<i class="m">parsername</i>? ?<i class="m">-namespace</i>? ?<i class="m">arg arg ..</i> 20 20 </pre> 21 - <h2><a name="SECTid0x16ee020">DESCRIPTION</a></h2><p>The parser created with <i class="m">expat</i> or <i class="m">xml::parser</i> 21 + <h2><a name="SECTid0x5575961d3ef0">DESCRIPTION</a></h2><p>The parser created with <i class="m">expat</i> or <i class="m">xml::parser</i> 22 22 (which is just another name for the same command in an own namespace) are able 23 23 to parse any kind of well-formed XML. The parsers are stream oriented XML 24 24 parser. This means that you register handler scripts with the parser prior to 25 25 starting the parse. These handler scripts are called when the parser discovers 26 26 the associated structures in the document being parsed. A start tag is an 27 27 example of the kind of structures for which you may register a handler 28 -script.</p><p>The parsers do not validate the XML document. They do parse the internal DTD 29 -and, at request, external DTD and external entities, if you resolve the 30 -identifier of the external entities with the -externalentitycommand script (see 31 -there).</p><p>Additionly, the Tcl extension code that implements this command provides an 28 +script.</p><p>The parsers always check for XML well-formedness of the input (and 29 +report error, if the input isn't well-formed). They parse the internal 30 +DTD and, at request, external DTD and external entities, if you 31 +resolve the identifier of the external entities with the 32 +-externalentitycommand script (see there). If you use the -validateCmd 33 +option (see there), the input is additionally validated.</p><p>Additionly, the Tcl extension code that implements this command provides an 32 34 API for adding C level coded handlers. Up to now, there exists the parser 33 35 extension command "tdom". The handler set installed by this extension build an 34 36 in memory "tDOM" DOM tree, while the parser is parsing the input.</p><p>It is possible to register an arbitrary amount of different handler scripts 35 37 and C level handlers for most of the events. If the event occurs, they are 36 38 called in turn.</p> 37 39 38 - <h2><a name="SECTid0x16eed60">COMMAND OPTIONS</a></h2><dl class="optlist"> 40 + <h2><a name="SECTid0x5575961d4cc0">COMMAND OPTIONS</a></h2><dl class="optlist"> 39 41 40 42 <dt><b>-namespace</b></dt> 41 43 42 44 <dd> 43 45 <p>Enables namespace parsing. You must use this option while 44 46 creating the parser with the <tt class="samp">expat</tt> or <tt class="samp">xml::parser</tt> 45 47 command. You can't enable (nor disable) namespace parsing with 46 48 <tt class="samp"><parserobj> configure ...</tt>.</p> 47 49 </dd> 48 50 49 51 52 + 53 + <dt> 54 +<b>-namespaceseparator</b> <i>char</i> 55 +</dt> 56 + 57 + 58 + <dd><p>This option has only effect, if used together with 59 + the option <i class="m">-namespace</i>. If given, this option 60 + determines the character inserted between namespace URI and 61 + the local name, while reporting an XML element name to a 62 + handler script. The default is the character ':'. The 63 + value must be a one-character string less or equal to 64 + \u00FF, preferably a 7-bit ASCII character or the empty 65 + string. If the value is the empty string (as well, as if the 66 + value is \x00) the namespace URI and the local name will be 67 + concatenated without any separator.</p></dd> 68 + 69 + 50 70 51 71 <dt> 52 72 <b>-final</b> <i>boolean</i> 53 73 </dt> 54 74 55 75 56 76 <dd> ................................................................................ 65 85 until the next call to the parse method, thus delaying the reporting of some of 66 86 the data.</p> 67 87 68 88 <p>If this option is set to "1" then documents which are not well-formed upon 69 89 end of input will generate an error.</p> 70 90 </dd> 71 91 92 + 93 + 94 + <dt> 95 +<b>-validateCmd</b> <i><tdom schema cmd></i> 96 +</dt> 97 + 98 + 99 + <dd><p>This option expects the name of a tDOM schema 100 + command. If this option is given, then the input is also 101 + validated. If the schema command hasn't set a reportcmd then 102 + the first validation error will stop further parsing (as a 103 + well-formedness error).</p></dd> 104 + 72 105 73 106 74 107 <dt> 75 108 <b>-baseurl</b> <i>url</i> 76 109 </dt> 77 110 78 111 ................................................................................ 611 644 -paramentityparsing value of "never" (which is the default) suppresses any call 612 645 to the -externalentitycommand script. Pleace notice, that, if the document also 613 646 doesn't have an internal subset, the -startdoctypedeclcommand and 614 647 enddoctypedeclcommand scripts, if set, are not called.</dd> 615 648 616 649 617 650 </dl> 618 - <h2><a name="SECTid0x1746b80"> COMMAND METHODS </a></h2><dl class="commandlist"> 651 + <h2><a name="SECTid0x557596234b50"> COMMAND METHODS </a></h2><dl class="commandlist"> 619 652 620 653 <dt> 621 654 <b class="cmd">parser</b> <b class="method">configure</b> <i class="m">option value ?option value?</i> 622 655 </dt> 623 656 624 657 <dd><p>Sets configuration options for the parser. Every command 625 658 option, except <i class="m">-namespace</i> can be set or modified with this method.</p></dd> ................................................................................ 771 804 <dd><p>Resets the parser in preparation for parsing another 772 805 document. A parser cannot be reset from within one of its handler callbacks 773 806 (neither directly nor indirectly) and will raise a tcl error in this 774 807 cases.</p></dd> 775 808 776 809 </dl> 777 810 778 - <h2><a name="SECTid0x174d660">Callback Command Return Codes</a></h2><p>A script invoked for any of the parser callback commands, such as 811 + <h2><a name="SECTid0x55759623b630">Callback Command Return Codes</a></h2><p>A script invoked for any of the parser callback commands, such as 779 812 -elementstartcommand, -elementendcommand, etc, may return an error code other 780 813 than "ok" or "error". All callbacks may in addition return 781 814 "break" or "continue".</p><p>If a callback script returns an "error" error code then 782 815 processing of the document is terminated and the error is propagated in the 783 816 usual fashion.</p><p>If a callback script returns a "break" error code then all 784 817 further processing of every handler script out of this Tcl handler set is 785 818 suppressed for the further parsing. This does not influence any other handler 786 819 set.</p><p>If a callback script returns a "continue" error code then 787 820 processing of the current element, and its children, ceases for every handler 788 821 script out of this Tcl handler set and processing continues with the next 789 822 (sibling) element. This does not influence any other handler set.</p><p>If a callback script returns a "return" error 790 823 code then parsing is canceled altogether, but no error is raised.</p> 791 824 792 - <h2><a name="SECTid0x174e1f0">SEE ALSO</a></h2><p class="seealso"> 825 + <h2><a name="SECTid0x55759623c1c0">SEE ALSO</a></h2><p class="seealso"> 793 826 <a href="expatapi.html">expatapi</a>, <a href="tdomcmd.html">tdom</a> 794 827 </p> 795 828 796 - <h2><a name="SECTid0x174e5b0">KEYWORDS</a></h2><p class="keywords"><a class="keyword" href="keyword-index.html#KW-SAX">SAX</a></p> 829 + <h2><a name="SECTid0x55759623c580">KEYWORDS</a></h2><p class="keywords"> 830 +<a class="keyword" href="keyword-index.html#KW-SAX">SAX</a>, <a class="keyword" href="keyword-index.html#KW-push">push</a>, <a class="keyword" href="keyword-index.html#KW-pushparser">pushparser</a> 831 +</p> 797 832 </div><hr class="navsep"><div class="navbar" align="center"> 798 833 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 799 834 </div> 800 835 </body> 801 836 </html>
Changes to doc/expat.n.
177 177 to parse any kind of well-formed XML. The parsers are stream oriented XML 178 178 parser. This means that you register handler scripts with the parser prior to 179 179 starting the parse. These handler scripts are called when the parser discovers 180 180 the associated structures in the document being parsed. A start tag is an 181 181 example of the kind of structures for which you may register a handler 182 182 script. 183 183 .PP 184 -The parsers do not validate the XML document. They do parse the internal DTD 185 -and, at request, external DTD and external entities, if you resolve the 186 -identifier of the external entities with the -externalentitycommand script (see 187 -there). 184 +The parsers always check for XML well-formedness of the input (and 185 +report error, if the input isn't well-formed). They parse the internal 186 +DTD and, at request, external DTD and external entities, if you 187 +resolve the identifier of the external entities with the 188 +-externalentitycommand script (see there). If you use the -validateCmd 189 +option (see there), the input is additionally validated. 188 190 .PP 189 191 Additionly, the Tcl extension code that implements this command provides an 190 192 API for adding C level coded handlers. Up to now, there exists the parser 191 193 extension command "tdom". The handler set installed by this extension build an 192 194 in memory "tDOM" DOM tree, while the parser is parsing the input. 193 195 .PP 194 196 It is possible to register an arbitrary amount of different handler scripts ................................................................................ 199 201 .RS 200 202 .PP 201 203 Enables namespace parsing. You must use this option while 202 204 creating the parser with the \fBexpat\fR or \fBxml::parser\fR 203 205 command. You can't enable (nor disable) namespace parsing with 204 206 \&\fB<parserobj> configure ...\fR. 205 207 .RE 208 +.IP "\fB-namespaceseparator \fIchar\fP\fR" 209 +.RS 210 +.PP 211 +This option has only effect, if used together with 212 +the option \fI-namespace\fR. If given, this option 213 +determines the character inserted between namespace URI and 214 +the local name, while reporting an XML element name to a 215 +handler script. The default is the character ':'. The 216 +value must be a one-character string less or equal to 217 +\&\eu00FF, preferably a 7-bit ASCII character or the empty 218 +string. If the value is the empty string (as well, as if the 219 +value is \ex00) the namespace URI and the local name will be 220 +concatenated without any separator. 221 +.RE 206 222 .IP "\fB-final \fIboolean\fP\fR" 207 223 .RS 208 224 .PP 209 225 This option indicates whether the document data next 210 226 presented to the parse method is the final part of the document. A value of "0" 211 227 indicates that more data is expected. A value of "1" indicates that no more is 212 228 expected. The default value is "1". ................................................................................ 215 231 if the XML data is not well-formed upon end of input, such as unclosed or 216 232 unbalanced start or end tags. Instead some data may be saved by the parser 217 233 until the next call to the parse method, thus delaying the reporting of some of 218 234 the data. 219 235 .PP 220 236 If this option is set to "1" then documents which are not well-formed upon 221 237 end of input will generate an error. 238 +.RE 239 +.IP "\fB-validateCmd \fI<tdom schema cmd>\fP\fR" 240 +.RS 241 +.PP 242 +This option expects the name of a tDOM schema 243 +command. If this option is given, then the input is also 244 +validated. If the schema command hasn't set a reportcmd then 245 +the first validation error will stop further parsing (as a 246 +well-formedness error). 222 247 .RE 223 248 .IP "\fB-baseurl \fIurl\fP\fR" 224 249 .RS 225 250 .PP 226 251 Reports the base url of the document to the 227 252 parser. 228 253 .RE ................................................................................ 867 892 (sibling) element. This does not influence any other handler set. 868 893 .PP 869 894 If a callback script returns a "return" error 870 895 code then parsing is canceled altogether, but no error is raised. 871 896 .SH "SEE ALSO" 872 897 expatapi, tdom 873 898 .SH KEYWORDS 874 -SAX 899 +SAX, push, pushparser
Changes to doc/expat.xml.
28 28 to parse any kind of well-formed XML. The parsers are stream oriented XML 29 29 parser. This means that you register handler scripts with the parser prior to 30 30 starting the parse. These handler scripts are called when the parser discovers 31 31 the associated structures in the document being parsed. A start tag is an 32 32 example of the kind of structures for which you may register a handler 33 33 script.</p> 34 34 35 -<p>The parsers do not validate the XML document. They do parse the internal DTD 36 -and, at request, external DTD and external entities, if you resolve the 37 -identifier of the external entities with the -externalentitycommand script (see 38 -there).</p> 35 +<p>The parsers always check for XML well-formedness of the input (and 36 +report error, if the input isn't well-formed). They parse the internal 37 +DTD and, at request, external DTD and external entities, if you 38 +resolve the identifier of the external entities with the 39 +-externalentitycommand script (see there). If you use the -validateCmd 40 +option (see there), the input is additionally validated.</p> 39 41 40 42 <p>Additionly, the Tcl extension code that implements this command provides an 41 43 API for adding C level coded handlers. Up to now, there exists the parser 42 44 extension command "tdom". The handler set installed by this extension build an 43 45 in memory "tDOM" DOM tree, while the parser is parsing the input.</p> 44 46 45 47 <p>It is possible to register an arbitrary amount of different handler scripts ................................................................................ 58 60 <desc><p>Enables namespace parsing. You must use this option while 59 61 creating the parser with the <samp>expat</samp> or <samp>xml::parser</samp> 60 62 command. You can't enable (nor disable) namespace parsing with 61 63 <samp><parserobj> configure ...</samp>.</p> 62 64 </desc> 63 65 </optdef> 64 66 67 + <optdef> 68 + <optname>-namespaceseparator</optname> 69 + <optarg>char</optarg> 70 + 71 + <desc><p>This option has only effect, if used together with 72 + the option <m>-namespace</m>. If given, this option 73 + determines the character inserted between namespace URI and 74 + the local name, while reporting an XML element name to a 75 + handler script. The default is the character ':'. The 76 + value must be a one-character string less or equal to 77 + \u00FF, preferably a 7-bit ASCII character or the empty 78 + string. If the value is the empty string (as well, as if the 79 + value is \x00) the namespace URI and the local name will be 80 + concatenated without any separator.</p></desc> 81 + </optdef> 82 + 65 83 <optdef> 66 84 <optname>-final</optname> 67 85 <optarg>boolean</optarg> 68 86 69 87 <desc><p>This option indicates whether the document data next 70 88 presented to the parse method is the final part of the document. A value of "0" 71 89 indicates that more data is expected. A value of "1" indicates that no more is ................................................................................ 77 95 until the next call to the parse method, thus delaying the reporting of some of 78 96 the data.</p> 79 97 80 98 <p>If this option is set to "1" then documents which are not well-formed upon 81 99 end of input will generate an error.</p></desc> 82 100 </optdef> 83 101 102 + <optdef> 103 + <optname>-validateCmd</optname> 104 + <optarg><tdom schema cmd></optarg> 105 + 106 + <desc><p>This option expects the name of a tDOM schema 107 + command. If this option is given, then the input is also 108 + validated. If the schema command hasn't set a reportcmd then 109 + the first validation error will stop further parsing (as a 110 + well-formedness error).</p></desc> 111 + </optdef> 112 + 84 113 <optdef> 85 114 <optname>-baseurl</optname> 86 115 <optarg>url</optarg> 87 116 88 117 <desc><p>Reports the base url of the document to the 89 118 parser.</p></desc> 90 119 </optdef>
Changes to doc/expatapi.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: expatapi</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0x1e7b920">NAME</a> · <a href="#SECTid0x1d90950">SYNOPSIS</a> · <a href="#SECTid0x1eef570">ARGUMENTS</a> · <a href="#SECTid0x1ef1660">DESCRIPTION</a> · <a href="#SECTid0x1ea6080">SEE ALSO</a> · <a href="#SECTid0x1ea6320">KEYWORDS</a> 7 +<a href="#SECTid0x5569427a27e0">NAME</a> · <a href="#SECTid0x556942858880">SYNOPSIS</a> · <a href="#SECTid0x556942813080">ARGUMENTS</a> · <a href="#SECTid0x556942815140">DESCRIPTION</a> · <a href="#SECTid0x55694286ee00">SEE ALSO</a> · <a href="#SECTid0x55694286f0a0">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0x1e7b920">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x5569427a27e0">NAME</a></h2><p class="namesection"> 11 11 <b class="names">CheckExpatParserObj, CHandlerSetInstall, CHandlerSetRemove, 12 12 CHandlerSetCreate, CHandlerSetGetUserData, GetExpatInfo - </b><br>Functions to create, install and remove expat parser object 13 13 extensions.</p> 14 - <h2><a name="SECTid0x1d90950">SYNOPSIS</a></h2><pre class="syntax">#include <tclexpat.h> 14 + <h2><a name="SECTid0x556942858880">SYNOPSIS</a></h2><pre class="syntax">#include <tclexpat.h> 15 15 16 16 int 17 17 <b class="fun">CheckExpatParserObj</b> (<a href="#ARG-interp"><i>interp</i></a>, <a href="#ARG-nameObj"><i>nameObj</i></a>) 18 18 19 19 int 20 20 <b class="fun">CHandlerSetInstall</b> (<a href="#ARG-interp"><i>interp</i></a>, <a href="#ARG-expatObj"><i>expatObj</i></a>, <a href="#ARG-handlerSet"><i>handlerSet</i></a>) 21 21 ................................................................................ 31 31 void* 32 32 <b class="fun">CHandlerSetGetUserData</b> (<a href="#ARG-interp"><i>interp</i></a>, <a href="#ARG-expatObj"><i>expatObj</i></a>, <a href="#ARG-handlerSetName"><i>handlerSetName</i></a>) 33 33 34 34 TclGenExpatInfo* 35 35 <b class="fun">GetExpatInfo</b> (<a href="#ARG-interp"><i>interp</i></a>, <a href="#ARG-expatObj"><i>expatObj</i></a>) 36 36 </pre> 37 37 38 - <h2><a name="SECTid0x1eef570">ARGUMENTS</a></h2><div class="arglist"><table width="100%" rules="none" cellpadding="5%"> 38 + <h2><a name="SECTid0x556942813080">ARGUMENTS</a></h2><div class="arglist"><table width="100%" rules="none" cellpadding="5%"> 39 39 <thead><tr class="heading"> 40 40 <th width="20%">Type</th><th width="70%">Name</th><th width="10%">Mode</th> 41 41 </tr></thead><tr class="syntax"> 42 42 <td class="type" width="20%" align="left">Tcl_Interp</td><td class="name" width="70%" align="left"><a name="ARG-interp">*interp</a></td><td class="mode" width="10%" align="center">in</td> 43 43 </tr><tr class="desc"> 44 44 <td class="padding" width="20%"> </td><td class="argdesc" width="80%" align="left" colspan="2">Interpreter with the expat parser object.</td> 45 45 </tr><tr class="syntax"> ................................................................................ 57 57 </tr><tr class="syntax"> 58 58 <td class="type" width="20%" align="left">Tcl_Obj</td><td class="name" width="70%" align="left"><a name="ARG-nameObj">*nameObj</a></td><td class="mode" width="10%" align="center"></td> 59 59 </tr><tr class="desc"> 60 60 <td class="padding" width="20%"> </td><td class="argdesc" width="80%" align="left" colspan="2">A Tcl Object containing the name of a expat parser object</td> 61 61 </tr> 62 62 </table></div> 63 63 64 - <h2><a name="SECTid0x1ef1660">DESCRIPTION</a></h2><p>The functions described in this manual allows one to add C level coded event 64 + <h2><a name="SECTid0x556942815140">DESCRIPTION</a></h2><p>The functions described in this manual allows one to add C level coded event 65 65 handler to an tDOM Tcl expat parser objects. A tDOM Tcl expat parser object is 66 66 able to have several Tcl scripts and C functions associated with an specific 67 67 event. If the event occurs, first the Tcl scripts then the C functions 68 68 associated with the event are called in turn.</p><p>A tDOM Tcl expat parser extension is an ordinary Tcl extension and loaded 69 69 like every other Tcl extension. It must install at least one new Tcl Level 70 70 command, that manipulates a tDOM Tcl expat parser object.</p><p>A C level handler set is a data structure like this:</p><pre class="example"> 71 71 typedef struct CHandlerSet { ................................................................................ 195 195 TclGenExpatInfo structure of the tDOM Tcl expat parser object 196 196 <i class="m">expatObj</i>. The <i class="m">expatObj</i> has to be a tDOM Tcl expat parser object 197 197 in the interpreter <i class="m">interp</i>. This is most useful, to set the application 198 198 status of the parser object.</p><p>See the simple but full functionally example in the extensions/example 199 199 dir or the more complex example tnc in the extensions/tnc dir (a simple DTD 200 200 validation extension).</p> 201 201 202 - <h2><a name="SECTid0x1ea6080">SEE ALSO</a></h2><p class="seealso">expat</p> 202 + <h2><a name="SECTid0x55694286ee00">SEE ALSO</a></h2><p class="seealso">expat</p> 203 203 204 - <h2><a name="SECTid0x1ea6320">KEYWORDS</a></h2><p class="keywords"><a class="keyword" href="keyword-index.html#KW-Chandlerset">C handler set</a></p> 204 + <h2><a name="SECTid0x55694286f0a0">KEYWORDS</a></h2><p class="keywords"><a class="keyword" href="keyword-index.html#KW-Chandlerset">C handler set</a></p> 205 205 </div><hr class="navsep"><div class="navbar" align="center"> 206 206 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 207 207 </div> 208 208 </body> 209 209 </html>
Changes to doc/index.html.
4 4 </head><body> 5 5 <div class="header"> 6 6 <h1 class="title" align="center">tDOM manual: Contents</h1><p class="navaid" align="center"> 7 7 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 8 8 </p><hr class="navsep"> 9 9 </div><div class="body"><ul class="toc"> 10 10 <li class="tocentry"><a href="dom.html">dom - Create an in-memory DOM tree from XML</a></li><li class="tocentry"><a href="domDoc.html">domDoc - Manipulates an instance of a DOM document object</a></li><li class="tocentry"><a href="domNode.html">domNode - Manipulates an instance of a DOM node object</a></li><li class="tocentry"><a href="expat.html">expat - Creates an instance of an expat parser object</a></li><li class="tocentry"><a href="expatapi.html">expatapi - Functions to create, install and remove expat parser object 11 -extensions.</a></li><li class="tocentry"><a href="pullparser.html">pullparser - Create an XML pull parser command</a></li><li class="tocentry"><a href="structure.html">structure - Create an XML structure validation command</a></li><li class="tocentry"><a href="tdomcmd.html">tdom - tdom is an expat parser object extension to create an in-memory 11 +extensions.</a></li><li class="tocentry"><a href="pullparser.html">pullparser - Create an XML pull parser command</a></li><li class="tocentry"><a href="schema.html">schema - Create a schema validation command</a></li><li class="tocentry"><a href="tdomcmd.html">tdom - tdom is an expat parser object extension to create an in-memory 12 12 DOM tree from the input while parsing.</a></li><li class="tocentry"><a href="tnc.html">tnc - tnc is an expat parser object extension, that validates the XML 13 13 stream against the document DTD while parsing.</a></li> 14 14 </ul></div><div class="footer"> 15 15 <hr class="navsep"><div class="navbar" align="center"> 16 16 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 17 17 </div> 18 18 </div> 19 19 </body> 20 20 </html>
Changes to doc/keyword-index.html.
19 19 <td width="35%"><a name="KW-document">document</a></td><td width="65%"> 20 20 <a href="dom.html">dom</a> · <a href="domNode.html">domNode</a> 21 21 </td> 22 22 </tr><tr class="row0"> 23 23 <td width="35%"><a name="KW-documentelement">document element</a></td><td width="65%"><a href="domDoc.html">domDoc</a></td> 24 24 </tr><tr class="row1"> 25 25 <td width="35%"><a name="KW-dom">dom</a></td><td width="65%"> 26 -<a href="dom.html">dom</a> · <a href="domNode.html">domNode</a> · <a href="tdomcmd.html">tdom</a> 26 +<a href="dom.html">dom</a> · <a href="domNode.html">domNode</a> · <a href="schema.html">schema</a> · <a href="tdomcmd.html">tdom</a> 27 27 </td> 28 28 </tr><tr class="row0"> 29 29 <td width="35%"><a name="KW-DOMnodecreation">DOM node creation</a></td><td width="65%"><a href="domDoc.html">domDoc</a></td> 30 30 </tr><tr class="row1"> 31 31 <td width="35%"><a name="KW-domDoc">domDoc</a></td><td width="65%"><a href="domDoc.html">domDoc</a></td> 32 32 </tr><tr class="row0"> 33 33 <td width="35%"><a name="KW-domNode">domNode</a></td><td width="65%"><a href="domNode.html">domNode</a></td> ................................................................................ 42 42 <a href="dom.html">dom</a> · <a href="domNode.html">domNode</a> 43 43 </td> 44 44 </tr><tr class="header"><th colspan="2"><a name="KEYWORDS-P">Keywords: P</a></th></tr><tr class="row1"> 45 45 <td width="35%"><a name="KW-parsing">parsing</a></td><td width="65%"> 46 46 <a href="dom.html">dom</a> · <a href="domNode.html">domNode</a> · <a href="pullparser.html">pullparser</a> 47 47 </td> 48 48 </tr><tr class="row0"> 49 -<td width="35%"><a name="KW-pull">pull</a></td><td width="65%"><a href="pullparser.html">pullparser</a></td> 49 +<td width="35%"><a name="KW-Postvalidation">Postvalidation</a></td><td width="65%"><a href="schema.html">schema</a></td> 50 50 </tr><tr class="row1"> 51 -<td width="35%"><a name="KW-pullparser">pullparser</a></td><td width="65%"><a href="pullparser.html">pullparser</a></td> 51 +<td width="35%"><a name="KW-pull">pull</a></td><td width="65%"><a href="pullparser.html">pullparser</a></td> 52 52 </tr><tr class="row0"> 53 -<td width="35%"><a name="KW-push">push</a></td><td width="65%"><a href="expat.html">expat</a></td> 53 +<td width="35%"><a name="KW-pullparser">pullparser</a></td><td width="65%"><a href="pullparser.html">pullparser</a></td> 54 54 </tr><tr class="row1"> 55 +<td width="35%"><a name="KW-push">push</a></td><td width="65%"><a href="expat.html">expat</a></td> 56 +</tr><tr class="row0"> 55 57 <td width="35%"><a name="KW-pushparser">pushparser</a></td><td width="65%"><a href="expat.html">expat</a></td> 56 -</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-S">Keywords: S</a></th></tr><tr class="row0"> 58 +</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-S">Keywords: S</a></th></tr><tr class="row1"> 57 59 <td width="35%"><a name="KW-SAX">SAX</a></td><td width="65%"> 58 -<a href="expat.html">expat</a> · <a href="tdomcmd.html">tdom</a> 60 +<a href="expat.html">expat</a> · <a href="schema.html">schema</a> · <a href="tdomcmd.html">tdom</a> 59 61 </td> 60 -</tr><tr class="row1"> 61 -<td width="35%"><a name="KW-structure">structure</a></td><td width="65%"><a href="structure.html">structure</a></td> 62 -</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-T">Keywords: T</a></th></tr><tr class="row0"> 62 +</tr><tr class="row0"> 63 +<td width="35%"><a name="KW-schema">schema</a></td><td width="65%"><a href="schema.html">schema</a></td> 64 +</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-T">Keywords: T</a></th></tr><tr class="row1"> 63 65 <td width="35%"><a name="KW-tdom">tdom</a></td><td width="65%"><a href="tdomcmd.html">tdom</a></td> 64 -</tr><tr class="row1"> 66 +</tr><tr class="row0"> 65 67 <td width="35%"><a name="KW-tdom::pullparser">tdom::pullparser</a></td><td width="65%"><a href="pullparser.html">pullparser</a></td> 66 -</tr><tr class="row0"> 67 -<td width="35%"><a name="KW-tdom::structure">tdom::structure</a></td><td width="65%"><a href="structure.html">structure</a></td> 68 68 </tr><tr class="row1"> 69 +<td width="35%"><a name="KW-tdom::schema">tdom::schema</a></td><td width="65%"><a href="schema.html">schema</a></td> 70 +</tr><tr class="row0"> 69 71 <td width="35%"><a name="KW-tdomcmd">tdomcmd</a></td><td width="65%"><a href="tdomcmd.html">tdom</a></td> 70 -</tr><tr class="row0"> 72 +</tr><tr class="row1"> 71 73 <td width="35%"><a name="KW-tnc">tnc</a></td><td width="65%"><a href="tnc.html">tnc</a></td> 72 -</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-V">Keywords: V</a></th></tr><tr class="row1"> 73 -<td width="35%"><a name="KW-Validation">Validation</a></td><td width="65%"><a href="tnc.html">tnc</a></td> 74 -</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-X">Keywords: X</a></th></tr><tr class="row0"> 74 +</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-V">Keywords: V</a></th></tr><tr class="row0"> 75 +<td width="35%"><a name="KW-Validation">Validation</a></td><td width="65%"> 76 +<a href="schema.html">schema</a> · <a href="tnc.html">tnc</a> 77 +</td> 78 +</tr><tr class="header"><th colspan="2"><a name="KEYWORDS-X">Keywords: X</a></th></tr><tr class="row1"> 75 79 <td width="35%"><a name="KW-XML">XML</a></td><td width="65%"> 76 80 <a href="dom.html">dom</a> · <a href="domNode.html">domNode</a> · <a href="pullparser.html">pullparser</a> 77 81 </td> 78 -</tr><tr class="row1"> 82 +</tr><tr class="row0"> 79 83 <td width="35%"><a name="KW-xml::parser">xml::parser</a></td><td width="65%"><a href="expat.html">expat</a></td> 80 84 </tr> 81 85 </table></div></div><div class="footer"> 82 86 <hr class="navsep"><div class="navbar" align="center"> 83 87 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 84 88 </div> 85 89 </div> 86 90 </body> 87 91 </html>
Changes to doc/pullparser.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: pullparser</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0x11bc970">NAME</a> · <a href="#SECTid0x10a6540">SYNOPSIS</a> · <a href="#SECTid0x10bbbc0">DESCRIPTION </a> · <a href="#SECTid0x11e0cb0">KEYWORDS</a> 7 +<a href="#SECTid0x5569427a27e0">NAME</a> · <a href="#SECTid0x5569428aa3f0">SYNOPSIS</a> · <a href="#SECTid0x5569428123e0">DESCRIPTION </a> · <a href="#SECTid0x55694282af70">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0x11bc970">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x5569427a27e0">NAME</a></h2><p class="namesection"> 11 11 <b class="names">tdom::pullparser - </b><br>Create an XML pull parser command</p> 12 12 13 - <h2><a name="SECTid0x10a6540">SYNOPSIS</a></h2><pre class="syntax">package require tdom 13 + <h2><a name="SECTid0x5569428aa3f0">SYNOPSIS</a></h2><pre class="syntax">package require tdom 14 14 15 15 <b class="cmd">tdom::pullparser</b> <i class="m">cmdName</i> ? -ignorewhitecdata ? 16 16 </pre> 17 17 18 - <h2><a name="SECTid0x10bbbc0">DESCRIPTION </a></h2><p>This command creates XML pull parser commands with a simple 18 + <h2><a name="SECTid0x5569428123e0">DESCRIPTION </a></h2><p>This command creates XML pull parser commands with a simple 19 19 API, along the lines of a simple StAX parser. After creation, 20 20 you've to set an input source, to do anything useful with the pull 21 21 parser. For this see the methods <i class="m">input</i>, <i class="m">inputchannel</i> 22 22 and <i class="m">inputfile</i>.</p><p>The parser has always a <i class="m">state</i>. You start parsing the XML 23 23 data until some next state, do what has to be done and skip again 24 24 to the next state. XML well-formedness errors along the way will 25 25 be reported as TCL_ERROR with additional info in the error ................................................................................ 171 171 <dt><b class="method">column</b></dt> 172 172 <dd>This method is valid in all parser states except READY 173 173 and TEXT. It returns the offset, from the beginning of the 174 174 current line, of the parsing position.</dd> 175 175 176 176 </dl> 177 177 178 - <h2><a name="SECTid0x11e0cb0">KEYWORDS</a></h2><p class="keywords"> 178 + <h2><a name="SECTid0x55694282af70">KEYWORDS</a></h2><p class="keywords"> 179 179 <a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-pull">pull</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</a> 180 180 </p> 181 181 </div><hr class="navsep"><div class="navbar" align="center"> 182 182 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 183 183 </div> 184 184 </body> 185 185 </html>
Added doc/schema.html.
1 +<html> 2 +<head> 3 +<link rel="stylesheet" href="manpage.css"><title>tDOM manual: schema</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 +</head><body> 5 +<div class="header"> 6 +<div class="navbar" align="center"> 7 +<a href="#SECTid0x562b0340b630">NAME</a> · <a href="#SECTid0x562b03360120">SYNOPSIS</a> · <a href="#SECTid0x562b033e9810">DESCRIPTION </a> · <a href="#SECTid0x562b0345f9e0">Schema definition scripts</a> · <a href="#SECTid0x562b0346edc0">Quantity specifier</a> · <a href="#SECTid0x562b03470d20">Text constraint scripts</a> · <a href="#SECTid0x562b03483fa0">Local key constraints</a> · <a href="#SECTid0x562b03485db0">Recovering</a> · <a href="#SECTid0x562b03487d50">Examples</a> · <a href="#SECTid0x562b03489cc0">KEYWORDS</a> 8 +</div><hr class="navsep"> 9 +</div><div class="body"> 10 + <h2><a name="SECTid0x562b0340b630">NAME</a></h2><p class="namesection"> 11 +<b class="names">tdom::schema - </b><br>Create a schema validation command</p> 12 + 13 + <h2><a name="SECTid0x562b03360120">SYNOPSIS</a></h2><pre class="syntax">package require tdom 14 + 15 +<b class="cmd">tdom::schema</b> <i class="m">?create?</i> <i class="m">cmdName</i> 16 + </pre> 17 + 18 + <h2><a name="SECTid0x562b033e9810">DESCRIPTION </a></h2><p>Every call of this command creates a new validation command. A 19 + validation command has methods to define a schema and is able 20 + to validate XML data or to post-validate a tDOM DOM tree (and to 21 + some degree other kind of hierarchical data) against this 22 + schema.</p><p>Additionally, a validation command may be used as argument to 23 + the <i class="m">-validateCmd</i> option of the <i class="m">dom parse</i> and the 24 + <i class="m">expat</i> commands to enable validation additional to what they 25 + do otherwise.</p><p>The methods of created commands are:</p><dl class="commandlist"> 26 + 27 + <dt> 28 +<b class="method">prefixns</b> <i class="m">?prefixUriList?</i> 29 +</dt> 30 + <dd>This method gives control to a prefix (or 31 + abbreviation) to namespace URI mapping. Wherever a namespace 32 + argument is expected in the schema command methods you may 33 + use the "prefix" pointing to the namespace URI in 34 + the current prefixUriList, set by this method. If the list 35 + maps the same prefix to different namespace URIs, the first 36 + one win. If there is no such a prefix the namespace argument 37 + is used literally as namespace URI. If the method is called 38 + without argument it returns the current prefixUriList. If 39 + the method is called with the empty string any namespace URI 40 + arguments are used literally. This is the default. 41 + </dd> 42 + 43 + 44 + 45 + <dt> 46 +<b class="method">defelement</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 47 +</dt> 48 + <dd>This method defines the element <i class="m">name</i> (optional in 49 + the namespace <i class="m">namespace</i>) in the schema. The 50 + <i class="m">definition script</i> is evaluated and defines the content 51 + model of the element. If the <i class="m">namespace</i> argument is 52 + given, any <i class="m">element</i> or <i class="m">ref</i> references in the 53 + definition script not wrapped inside a <i class="m">namespace</i> 54 + command are resolved in that namespace. If there is already a 55 + element definition for the name/namespace combination the 56 + command raises error.</dd> 57 + 58 + 59 + 60 + <dt> 61 +<b class="method">defelementtype</b> <i class="m">typename</i> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 62 +</dt> 63 + <dd>This method defines the element type <i class="m">typename</i> 64 + (optional in the namespace <i class="m">namespace</i>) in the schema. If 65 + the element type is used in a definition script with the 66 + schema command elementtype, the validation engine expects an 67 + element named <i class="m">name</i> (in the namespace <i class="m">namespace</i>, 68 + if given) and the content model <i class="m">definition script</i>. 69 + Defining element types seems only sensible if you really have 70 + elements with the same name and namespace but different 71 + content models. The <i class="m">definition script</i> is evaluated and 72 + defines the content model of the element. If the 73 + <i class="m">namespace</i> argument is given, any <i class="m">element</i> or 74 + <i class="m">ref</i> references in the definition script not wrapped 75 + inside a <i class="m">namespace</i> command are resolved in that 76 + namespace. If there is already a elementtype definition for 77 + the name/namespace combination the command raises error. The 78 + document element of any XML to validate cannot be a 79 + <i class="m">defelementtype</i> defined element.</dd> 80 + 81 + 82 + 83 + <dt> 84 +<b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 85 +</dt> 86 + <dd>This method defines a (maybe complex) content particle 87 + with the <i class="m">name</i> (optional in the namespace 88 + <i class="m">namespace</i>) in the schema, to be used in other 89 + definition scripts with the definition command <i class="m">ref</i>. The 90 + <i class="m">definition script</i> is evaluated and defines the content 91 + model of the content particle. If the <i class="m">namespace</i> 92 + argument is given, any <i class="m">element</i> or <i class="m">ref</i> references 93 + in the definition script not wrapped inside a <i class="m">namespace</i> 94 + command are resolved in that namespace. If there is already a 95 + pattern definition for the name/namespace combination the 96 + command raises error.</dd> 97 + 98 + 99 + 100 + <dt> 101 +<b class="method">deftexttype</b> <i class="m">name</i> <i class="m"><constraint script></i> 102 +</dt> 103 + <dd>This method defines a bundle of text constraints that 104 + can be referred to by <i class="m">name</i> while defining constrains on 105 + text element or attribute values. If there is already a text 106 + type definition with this name, the command raises error. A 107 + text type must be defined before it can be used in schema 108 + definition scripts.</dd> 109 + 110 + 111 + 112 + <dt> 113 +<b class="method">start</b> <i class="m">documentElement</i> <i class="m">?namespace?</i> 114 +</dt> 115 + <dd>This method defines the name and namespace of the root 116 + element of a tree to validate. If this method is used, then 117 + the root element must match for validity. If <i class="m">start</i> is 118 + not used, any element defined by <i class="m">defelement</i> may be the 119 + root of a valid document. The <i class="m">start</i> method may be used 120 + several times with varying arguments during the lifetime of a 121 + validation command. If the command is called with just the 122 + empty string (and no namespace argument), the validation 123 + constraint for the root element is removed and any defined 124 + element will be valid as root of a tree to validate.</dd> 125 + 126 + 127 + 128 + <dt> 129 +<b class="method">define</b> <i class="m"><definition script></i> 130 +</dt> 131 + <dd>This method allows to define several elements or pattern 132 + or a whole schema with one call. All schema command methods so 133 + far (<i class="m">prefixns</i>, <i class="m">defelement</i>, 134 + <i class="m">defelementtype</i>, <i class="m">defpattern</i>, <i class="m">deftexttype</i> and 135 + <i class="m">start</i>) are allowed top level in the <i class="m">definition 136 + script</i>. The <i class="m">define</i> method itself isn't allowed 137 + recursively.</dd> 138 + 139 + 140 + 141 + <dt> 142 +<b class="method">event</b> <i class="m">(start|end|text)</i> <i class="m">?event specific data?</i> 143 +</dt> 144 + <dd>This method allows to validate hierarchical data against 145 + the content constrains of the validation command. 146 + 147 + <dl class="optlist"> 148 + 149 + <dt> 150 +<b>start</b> <i>name ?attributes? ?namespace? </i> 151 +</dt> 152 + 153 + <dd>Checks if the current validation state allows the 154 + element <i class="m">name</i> in the <i class="m">namespace</i> to start here. 155 + It raises error if not.</dd> 156 + 157 + 158 + 159 + <dt><b>end</b></dt> 160 + <dd>Checks if the current innermost open element may end 161 + here in the current state without violation of validation 162 + constrains. It raises error if not.</dd> 163 + 164 + 165 + 166 + <dt> 167 +<b>text</b> <i>text</i> 168 +</dt> 169 + 170 + <dd>Checks if the current validation state allows the 171 + given text content. It raises error if not.</dd> 172 + 173 + </dl> 174 + </dd> 175 + 176 + 177 + 178 + <dt> 179 +<b class="method">validate</b> <i class="m"><XML string></i> <i class="m">?objVar?</i> 180 +</dt> 181 + <dd>Returns true if the <i class="m"><XML string></i> is valid or 182 + false otherwise. If validation has failed and the optional 183 + <i class="m">objVar</i> argument is given, the variable with that 184 + name is set to a validation error message. If the XML string 185 + is valid and the optional <i class="m">objVar</i> argument is given, 186 + the variable with that name is set to the empty string.</dd> 187 + 188 + 189 + 190 + <dt> 191 +<b class="method">validatefile</b> <i class="m">filename</i> <i class="m">?objVar?</i> 192 +</dt> 193 + <dd>Returns true if the content of <i class="m">filename</i> is valid 194 + or false otherwise. The given file is feeded as binary stream 195 + to expat, therefore only US-ASCII, ISO-8859-1, UTF-8 or UTF-16 196 + encoded data will work with this method. If validation failed 197 + and the optional <i class="m">objVar</i> argument is given, the variable 198 + with that name is set to a validation error message. If the 199 + XML string is valid and the optional <i class="m">objVar</i> argument is 200 + given, the variable with that name is set to the empty 201 + string.</dd> 202 + 203 + 204 + 205 + <dt> 206 +<b class="method">validatechannel</b> <i class="m">channel</i> <i class="m">?objVar?</i> 207 +</dt> 208 + <dd>Returns true if the content read from the Tcl channel 209 + <i class="m">channel</i> is valid or false otherwise. Since data read 210 + out of a Tcl channel is UTF-8 encoded, any misleading encoding 211 + declaration at the beginning of the data will lead to errors. 212 + If the validation fails and the optional <i class="m">objVar</i> 213 + argument is given, the variable with that name is set to a 214 + validation error message. If the XML string is valid and the 215 + optional <i class="m">objVar</i> argument is given, the variable with 216 + that name is set to the empty string.</dd> 217 + 218 + 219 + 220 + <dt> 221 +<b class="method">domvalidate</b> <i class="m">domNode</i> <i class="m">?objVar?</i> 222 +</dt> 223 + <dd>Returns true if the first argument is a valid tree or 224 + false otherwise. If validation failed and the optional 225 + <i class="m">objVar</i> argument is given, the variable with that name 226 + is set to a validation error message. If the dom tree is valid 227 + and the optional <i class="m">objVar</i> argument is given, the variable 228 + with that name is set to the empty string. </dd> 229 + 230 + 231 + 232 + <dt> 233 +<b class="method">reportcmd</b> <i class="m">?cmd?</i> 234 +</dt> 235 + <dd>This method expects the name of a Tcl command to be 236 + called in case of validation error. This command will be 237 + called with two arguments appended: the schema command which 238 + raises the validation error, and a validation error code. 239 + 240 + <p>The possible error codes are:</p> 241 + <dl> 242 + <dt>MISSING_ELEMENT</dt><dd></dd> 243 + <dt>MISSING_TEXT</dt><dd></dd> 244 + <dt>UNEXPECTED_ELEMENT</dt><dd></dd> 245 + <dt>UNEXPECTED_ROOT_ELEMENT</dt><dd></dd> 246 + <dt>UNEXPECTED_TEXT</dt><dd></dd> 247 + <dt>UNKNOWN_ROOT_ELEMENT</dt><dd></dd> 248 + <dt>UNKNOWN_ATTRIBUTE</dt><dd></dd> 249 + <dt>MISSING_ATTRIBUTE</dt><dd></dd> 250 + <dt>INVALID_ATTRIBUTE_VALUE</dt><dd></dd> 251 + <dt>DOM_KEYCONSTRAINT</dt><dd></dd> 252 + <dt>DOM_XPATH_BOOLEAN</dt><dd></dd> 253 + <dt>INVALID_KEYREF</dt><dd></dd> 254 + <dt>INVALID_VALUE</dt><dd></dd> 255 + <dt>UNKOWN_GLOBAL_ID</dt><dd></dd> 256 + <dt>UNKOWN_ID</dt><dd></dd> 257 + </dl> 258 + <p> For more detailed information see section <a href="#SECTid0x562b03485db0">Recovering</a>.</p> 259 + </dd> 260 + 261 + 262 + 263 + <dt><b class="method">delete</b></dt> 264 + <dd>This method deletes the validation command.</dd> 265 + 266 + 267 + 268 + <dt> 269 +<b class="method">info</b> <i class="m">?args?</i> 270 +</dt> 271 + <dd>This method bundles methods to query the state of and 272 + details about the schema command. 273 + <dl class="optlist"> 274 + 275 + <dt><b>validationstate</b></dt> 276 + <dd>This method returns the state of the validation command 277 + with respect to validation state. The possible return values 278 + and their meanings are: 279 + <dl> 280 + <dt>READY</dt><dd>The validation command is ready to start 281 + validation</dd> 282 + <dt>VALIDATING</dt><dd>The validation command is in the 283 + process of validating input.</dd> 284 + <dt>FINISHED</dt><dd>The validation has finished, no further 285 + events are expected.</dd> 286 + </dl> 287 + </dd> 288 + 289 + 290 + <dt><b>vstate</b></dt> 291 + <dd>This method is a shorter alias for validationstate; see there.</dd> 292 + 293 + 294 + <dt><b>line</b></dt> 295 + <dd>If the schema command is currently validating, 296 + this method returns the line part of the parsing 297 + position information and the empty string in all 298 + other cases. If the schema command is currently 299 + post-validating a DOM tree there may be no position 300 + information stored at some or all nodes. The 301 + empty string is returned in these cases.</dd> 302 + 303 + 304 + <dt><b>column</b></dt> 305 + <dd>If the schema command is currently validating 306 + this method returns the column part of the parsing 307 + position information and the empty string in all 308 + other cases. If the schema command is currently 309 + post-validating a DOM tree there may be no position 310 + information stored at some or all nodes. The 311 + empty string is returned in these cases.</dd> 312 + 313 + 314 + <dt><b>domNode</b></dt> 315 + <dd>If the schema command isn't currently 316 + post-validating a DOM tree this method returns the 317 + empty string. Otherwise, if the schema command waits 318 + for the reportcmd script to finish while recovering 319 + from a validation error it returns the node on which 320 + the validation engine is currently looking at in 321 + case the node is an ELEMENT_NODE or, if not, its 322 + parent node. It is recommended that you do not use 323 + this method. Or at least leave the DOM tree alone, 324 + use it read-only.</dd> 325 + 326 + 327 + <dt><b>nrForwardDefinitions</b></dt> 328 + <dd>Returns how much element, elementtype and ref 329 + pattern are referenced that aren't defined so far 330 + (summed together).</dd> 331 + 332 + 333 + <dt><b>definedElements</b></dt> 334 + <dd>Returns in no particular order the defined 335 + elements in the grammar as list. If an element is 336 + namespaced its list entry will be itself a list with 337 + two elements, with the name as first and the 338 + namespace as second element.</dd> 339 + 340 + 341 + <dt><b>definedElementtypes</b></dt> 342 + <dd>Returns in no particular order the defined 343 + element types in the grammar as list. If an element 344 + type is namespaced its list entry will be itself a 345 + list with two elements, with the name as first and 346 + the namespace as second element.</dd> 347 + 348 + 349 + <dt><b>definedPatterns</b></dt> 350 + <dd>Returns in no particular order the defined 351 + named pattern in the grammar as list. If a named 352 + pattern is namespaced its list entry will be itself 353 + a list with two elements, with the name as first and 354 + the namespace as second element.</dd> 355 + 356 + 357 + <dt><b>expected</b></dt> 358 + <dd>Returns in no particular order all possible 359 + next events (since the last successful event match, 360 + if there was one) as a list. If an element is 361 + namespaced its list entry will be itself a list with 362 + two elements, with the name as first and the 363 + namespace as second element. If text is a possible 364 + next event the list entry will be a two elements 365 + list, with #text as first element and the empty 366 + space as second. If an any element constraint is 367 + possible the list entry will be a two elements list, 368 + with <any> as first element and the empty space 369 + as second. If an any element in a certain namespace 370 + constraint is possible the list entry will be a two 371 + elements list, with <any> as first element and 372 + the namespace as second. If element end is a 373 + possible event the list entry will be a two elements 374 + list with <elementend> as first element and the 375 + empty string as second element.</dd> 376 + 377 + 378 + <dt><b>definition name ?namespace?</b></dt> 379 + <dd>Returns the code that defines the given 380 + element. The command raises error if there isn't a 381 + definition of that element. 382 + </dd> 383 + 384 + 385 + <dt><b>typedefinition name ?namespace?</b></dt> 386 + <dd>Returns the code that defines the given 387 + element type definition. The command raises error if 388 + there isn't a definition of that element. 389 + </dd> 390 + 391 + 392 + <dt><b>patterndefinition name ?namespace?</b></dt> 393 + <dd>Returns the code that defines the given 394 + pattern definition. The command raises error if 395 + there isn't a definition of a pattern with that name 396 + and, if given, namespace. 397 + </dd> 398 + 399 + 400 + <dt><b>vaction ?name|namespace|text?</b></dt> 401 + <dd> 402 +<p>This method returns useful information only if 403 + the schema command waits for the reportcmd script to 404 + finish while recovering from a validation error. 405 + Otherwise it returns NONE.</p> 406 + <p>If the command is called without the optional 407 + argument the possible return values and their 408 + meanings are:</p> 409 + <dl> 410 + <dt>NONE</dt><dd>The schema command currently 411 + doesn't recover from a validation event.</dd> 412 + <dt>MATCH_ELEMENT_START</dt><dd>Element start event, which includes looking for missing or unknown attributes.</dd> 413 + <dt>MATCH_ELEMENT_END</dt><dd>Element end event.</dd> 414 + <dt>MATCH_TEXT</dt><dd>Validating text between tags.</dd> 415 + <dt>MATCH_ATTRIBUTE_TEXT</dt><dd>Attribute text value constraint check</dd> 416 + <dt>MATCH_GLOBAL</dt><dd>Checking global IDs</dd> 417 + <dt>MATCH_DOM_KEYCONSTRAINT</dt><dd>Checking domunique constraint</dd> 418 + <dt>MATCH_DOM_XPATH_BOOLEAN</dt><dd>Checking domxpathboolean constant</dd> 419 + </dl> 420 + <p>If called with one of the possible optional 421 + arguments, the command returns detail information 422 + depending on current action.</p> 423 + <dl> 424 + <dt>name</dt><dd>Returns the name of the element 425 + that has to match in case of 426 + MATCH_ELEMENT_START. Return the name of the 427 + closed element in case of MATCH_ELEMENT_END. 428 + Returns the name of the attribute in case of 429 + MATCH_ATTRIBUTE_TEXT. Return the name of the 430 + parent element in case of MATCH_TEXT.</dd> 431 + 432 + <dt>namespace</dt><dd>Returns the namespace of 433 + the element that has to match in case of 434 + MATCH_ELEMENT_START. Return the namespace of the 435 + closed element in case of MATCH_ELEMENT_END. 436 + Returns the namespace of the attribute in case 437 + of MATCH_ATTRIBUTE_TEXT. Return the namespace of 438 + the parent element in case of MATCH_TEXT.</dd> 439 + 440 + <dt>text</dt><dd>Returns the text to match in 441 + case of MATCH_TEXT. Returns the value of the 442 + attribute in case of MATCH_ATTRIBUTE_TEXT.</dd> 443 + </dl> 444 + </dd> 445 + 446 + 447 + <dt><b>stack top|inside|associated</b></dt> 448 + <dd>In Tcl scripts evaluated by validation this method 449 + provides information about the current validation stack. 450 + Called outside this context the method returns the empty 451 + string. 452 + <dl class="optlist"> 453 + 454 + <dt><b>top</b></dt> 455 + <dd>Returns the element whose content is currently 456 + checked (the open element tag at this moment). 457 + </dd> 458 + 459 + 460 + 461 + <dt><b>inside</b></dt> 462 + <dd>Returns all currently open elements as a list.</dd> 463 + 464 + 465 + 466 + <dt><b>associated</b></dt> 467 + <dd>Returns the data associated with the 468 + current top most stack content particle or 469 + the empty string it there isn't any. 470 + </dd> 471 + 472 + </dl> 473 + </dd> 474 + 475 + </dl> 476 + </dd> 477 + 478 + 479 + 480 + <dt><b class="method">reset</b></dt> 481 + <dd>This method resets the validation command into state 482 + READY (while preserving the defined grammar).</dd> 483 + 484 + 485 + </dl> 486 + 487 + <h2><a name="SECTid0x562b0345f9e0">Schema definition scripts</a></h2><p>Schema definition scripts are ordinary Tcl scripts evaluated in 488 + the namespace tdom::schema. The schema definition commands listed 489 + below in this Tcl namespace allow to define a wide variety of 490 + document structures. Every schema definition command establishes a 491 + validation constraint on the content which has to match or must be 492 + optional to qualify the content as valid. It is a validation error 493 + if there is additional (not matched) content. White space only 494 + text (in the XML sense of white space) between any different tags 495 + is ignored, with the exception of text only elements (for which 496 + even white space only text will be considered as significant 497 + content).</p><p>The schema definition commands are:</p><dl class="commandlist"> 498 + 499 + <dt> 500 +<b class="method">element</b> <i class="m">name</i> <i class="m">?quant?</i> <i class="m">?<definition script>?</i> 501 +</dt> 502 + <dd>If the optional argument <i class="m">definition script</i> is not 503 + given this command refers to the element defined with 504 + <i class="m">defelement</i> with the name <i class="m">name</i> in the current 505 + context namespace. If the <i class="m">defelement script</i> argument is 506 + given, then the validation constraint expects an element with 507 + the name <i class="m">name</i> in the current namespace with content 508 + "locally" defined by the <i class="m">definition script</i>. Forward 509 + references to so far not defined elements or patterns or other 510 + local definitions of the same name inside the <i class="m">definition 511 + script</i> are allowed. If a forward referenced element is not 512 + defined until validation then only an empty element with name 513 + <i class="m">name</i> and namespace <i class="m">namespace</i> and no attributes 514 + matches. </dd> 515 + 516 + 517 + 518 + <dt> 519 +<b class="method">elementtype</b> <i class="m">name</i> <i class="m">?quant?</i> 520 +</dt> 521 + <dd>This command refers to the element defined with 522 + <i class="m">defelementtype</i> with the type name <i class="m">name</i> in the 523 + current context namespace. Forward references to so far not 524 + defined element types or recursive references are allowed. If 525 + a forward referenced element type is not defined until 526 + validation any empty element without attributes will be 527 + accepted.</dd> 528 + 529 + 530 + 531 + <dt> 532 +<b class="method">ref</b> <i class="m">name</i> <i class="m">?quant?</i> 533 +</dt> 534 + <dd>This command refers to the content particle defined with 535 + <i class="m">defpattern</i> with the name <i class="m">name</i> in the current 536 + context namespace. Forward references to a so far not defined 537 + pattern and recursive references are allowed. If a forward 538 + referenced pattern is not defined until validation no content 539 + whatsoever is expected ("empty match").</dd> 540 + 541 + 542 + 543 + <dt> 544 +<b class="method">group</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 545 +</dt> 546 + <dd>This method allows to group a sequence of content 547 + particles defined by the <i class="m">definition script></i>, which have 548 + to match in this sequence order.</dd> 549 + 550 + 551 + 552 + <dt> 553 +<b class="method">choice</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 554 +</dt> 555 + <dd>This schema constraint match if one of the top level 556 + content particles defined by the <i class="m">definition script></i> 557 + matches. If one of this top level content particle is optional 558 + this constraint matches the "empty match". 559 + </dd> 560 + 561 + 562 + 563 + <dt> 564 +<b class="method">interleave</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 565 +</dt> 566 + <dd>This schema constraint match after every of the required 567 + top level content particles defined by the <i class="m">definition 568 + script></i> have matched (and, optional, some or all other) in 569 + any arbitrary order.</dd> 570 + 571 + 572 + 573 + <dt> 574 +<b class="method">mixed</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 575 +</dt> 576 + <dd>This schema constraint matches for any text (including the 577 + empty one) and every top level content particle defined by the 578 + <i class="m">definition script></i> with default quantifier *.</dd> 579 + 580 + 581 + 582 + <dt> 583 +<b class="method">text</b> <i class="m">?<constraint script>|"type" typename?</i> 584 +</dt> 585 + <dd>Without the optional constraint script this validation 586 + constraint matches every string (including the empty one). 587 + With <i class="m">constraint script</i> or with a given text type 588 + argument a text matching this script or the text type is 589 + expected. </dd> 590 + 591 + 592 + 593 + <dt> 594 +<b class="method">any</b> <i class="m">?namespace?</i> <i class="m">?quant?</i> 595 +</dt> 596 + <dd>The any command matches every element (in the namespace 597 + <i class="m">namespace</i>, if that is given) (with whatever attributes) 598 + or subtree, no matter if known within the schema or not. 599 + Please note that in case of no <i class="m">namespace</i> argument is 600 + given that means that the quantifier * and + will eat up any 601 + elements until the enclosing element ends. If you really have 602 + a namespace that looks like a valid tDOM schema quantifier 603 + you will have to spell out always both arguments.</dd> 604 + 605 + 606 + 607 + <dt> 608 +<b class="method">attribute</b> <i class="m">name</i> <i class="m">?quant?</i> <i class="m">(?<constraint script>|"type" typename?)</i> 609 +</dt> 610 + <dd>The attribute command defines an attribute (in no 611 + namespace) to the enclosing element. The first definition of 612 + <i class="m">name</i> inside an element definition wins; later 613 + definitions of the same name are silently ignored. After the 614 + <i class="m">name</i> argument there may be one of the quantifiers ? or 615 + !. If there is, it will be used. Otherwise the attribute will 616 + be required (must be present in the XML source). If there is 617 + one argument more this argument is evaluated as constraint 618 + script, defining the value constrains of the attribute. 619 + Otherwise, if there are two more arguments and the first of 620 + them is the bare-word "type" the following argument is used as 621 + a text type name. This command is only allowed at top level in 622 + the definition script of an defelement/element script.</dd> 623 + 624 + 625 + 626 + <dt> 627 +<b class="method">nsattribute</b> <i class="m">name</i> <i class="m">namespace</i> <i class="m">?quant?</i> <i class="m">(?<constraint script>|"type" typename?)</i> 628 +</dt> 629 + <dd>This command does the same as the command 630 + <i class="m">attribute</i>, for the attribute <i class="m">name</i> in the 631 + namespace <i class="m">namespace</i>.</dd> 632 + 633 + 634 + 635 + <dt> 636 +<b class="method">namespace</b> <i class="m">URI</i> <i class="m"><definition script></i> 637 +</dt> 638 + <dd>Evaluates the <i class="m">definition script</i> with context 639 + namespace <i class="m">URI</i>. Every element, element type or ref 640 + command name will be looked up in the namespace <i class="m">URI</i>, 641 + and local defined elements will be in that namespace. An 642 + empty string as <i class="m">URI</i> means no namespace.</dd> 643 + 644 + 645 + 646 + <dt> 647 +<b class="method">tcl</b> <i class="m">tclcmd</i> <i class="m">?arg arg ...?</i> 648 +</dt> 649 + <dd>Evaluates the Tcl script <i class="m">tclcmd arg arg ... </i>. 650 + This validation command is only allowed in strict sequential 651 + context (not in choice, mixed and interleave). If the return 652 + code is something else than 0 (TCL_OK) this is an error (which 653 + is not catched and reported by reportcmd).</dd> 654 + 655 + 656 + 657 + <dt><b class="method">self</b></dt> 658 + <dd>Returns the schema command.</dd> 659 + 660 + 661 + 662 + <dt> 663 +<b class="method">associate</b> <i class="m">data</i> 664 +</dt> 665 + <dd>This command is only allowed top-level inside definition 666 + scripts of the element, elementtype, pattern or interleave 667 + content particles. Associates the <i class="m">data</i> given as argument 668 + with the currently defined content particle and may be 669 + requested in scripts evaluated while validating the content of 670 + that particle with the schema command method call <i class="m">info 671 + stack associated</i>.</dd> 672 + 673 + 674 + 675 + <dt> 676 +<b class="method">domunique</b> <i class="m">selector</i> <i class="m">fieldlist</i> <i class="m">?name?</i> <i class="m">?"IGNORE_EMPTY_FIELD_SET"|("EMPTY_FIELD_SET_VALUE" emptyFieldSetValue)?</i> 677 +</dt> 678 + <dd>If not postvalidating a DOM tree with <i class="m">domvalidate</i> 679 + this constraint always matches. If postvalidating this 680 + constraint resembles the xsd key/keyref mechanism. The 681 + <i class="m">selector</i> argument may be any valid XPath expression 682 + (without the xsd limits). Several <i class="m">domunique</i> commands 683 + within one element definition are allowed. They are checked in 684 + definition order. The argument name is available in the 685 + recovering script per <i class="m">info vaction name</i>. If the 686 + <i class="m">fieldlist</i> doesn't select something for a node of the 687 + result set of the <i class="m">selector</i> the key value will be the 688 + empty string by default. If the arguments 689 + <i class="m">EMPTY_FIELD_SET_VALUE <value></i> are given an empty 690 + node set will have the key value <i class="m">value</i>. If instead the 691 + flag <i class="m">IGNORE_EMPTY_FIELD_SET</i> flag is given an empty 692 + node set result will not have any key value.</dd> 693 + 694 + 695 + 696 + <dt> 697 +<b class="method">domxpathboolean</b> <i class="m">XPath_expr</i> <i class="m">?name?</i> 698 +</dt> 699 + <dd> 700 +<p>If not postvalidating a DOM tree with 701 + <i class="m">domvalidate</i> this constraint always matches. If 702 + postvalidating the <i class="m">XPath_expr</i> argument is evaluated 703 + (with the node matching the schema parent of the 704 + <i class="m">domxpathboolean</i> command as context node). The 705 + constraint maches if the result of this XPath expression, 706 + converted to boolean by XPath rules, is true. Several 707 + <i class="m">domxpathboolean</i> commands within one element definition 708 + are allowed. They are checked in definition order.</p> 709 + 710 + <p>This enables checks depending on more than one element. Consider</p> 711 + 712 + <pre class="example"> 713 +tdom::schema s 714 +s define { 715 + defelement doc { 716 + element a ! text 717 + element b ! text 718 + element c ! text 719 + domxpathboolean "a * b * c >= 20000" volume 720 + domxpathboolean "a > b and b > c" sequence 721 + } 722 +} 723 + </pre> 724 + </dd> 725 + 726 + 727 + 728 + <dt> 729 +<b class="method">prefixns</b> <i class="m">?prefixUriList?</i> 730 +</dt> 731 + <dd>This defines a prefix to namespace URI mapping exactly 732 + as a <i>schemacmd prefixns</i> call. This is meant as top-level 733 + command of a <i>schemacmd define</i> script. This command is 734 + not allowed nested in another definition script command and 735 + will raise error, if you call it there.</dd> 736 + 737 + 738 + 739 + <dt> 740 +<b class="method">defelement</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 741 +</dt> 742 + <dd>This defines an element exactly as a <i>schemacmd 743 + defelement</i> call. This is meant as top-level command of a 744 + <i>schemacmd define</i> script. This command is not allowed 745 + nested in another definition script command and will raise 746 + error, if you call it there.</dd> 747 + 748 + 749 + 750 + <dt> 751 +<b class="method">defelementtype</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 752 +</dt> 753 + <dd>This defines an elementtype exactly as a <i>schemacmd 754 + defelementtype</i> call. This is meant as top-level command of a 755 + <i>schemacmd define</i> script. This command is not allowed 756 + nested in another definition script command and will raise 757 + error, if you call it there.</dd> 758 + 759 + 760 + 761 + <dt> 762 +<b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 763 +</dt> 764 + <dd>This defines a named pattern exactly as a <i>schemacmd 765 + defpattern</i> call. This is meant as top-level command of a 766 + <i>schemacmd define</i> script. This command is not allowed 767 + nested in another definition script command and will raise 768 + error, if you call it there.</dd> 769 + 770 + 771 + 772 + <dt> 773 +<b class="method">deftexttype</b> <i class="m">name</i> <i class="m"><constraint script></i> 774 +</dt> 775 + <dd>This defines a named bundle of text constraints exactly 776 + as a <i>schemacmd deftexttype</i> call. This is meant as top-level 777 + command of a <i>schemacmd define</i> script. This command is 778 + not allowed nested in another definition script command and 779 + will raise error, if you call it there.</dd> 780 + 781 + 782 + 783 + <dt> 784 +<b class="method">start</b> <i class="m">name</i> <i class="m">?namespace?</i> 785 +</dt> 786 + <dd>This command works exactly as a <i>schemacmd start</i> 787 + call. This is meant as top-level command of a <i>schemacmd 788 + define</i> script. This command is not allowed nested in 789 + another definition script command and will raise error, if you 790 + call it there.</dd> 791 + 792 + </dl> 793 + 794 + <h2><a name="SECTid0x562b0346edc0">Quantity specifier</a></h2><p>Several schema definition commands expects a quantifier as 795 + one of their arguments, which determines how often the content 796 + particle specified by the command is expected. The valid values 797 + for a <i class="m">quant</i> argument are:</p><dl class="optlist"> 798 + 799 + <dt><b>!</b></dt> 800 + <dd>The content particle must occur exactly once in valid 801 + documents.</dd> 802 + 803 + 804 + 805 + <dt><b>?</b></dt> 806 + <dd>The content particle must occur at most once in valid 807 + documents.</dd> 808 + 809 + 810 + 811 + <dt><b>*</b></dt> 812 + <dd>The content particle may occur zero or more times in a 813 + row in valid documents.</dd> 814 + 815 + 816 + 817 + <dt><b>+</b></dt> 818 + <dd>The content particle may occur one or more times in a 819 + row in valid documents.</dd> 820 + 821 + 822 + 823 + <dt><b>n</b></dt> 824 + <dd>The content particle must occur n times in a row in 825 + valid documents. The quantifier must be an integer greater 826 + zero.</dd> 827 + 828 + 829 + 830 + <dt><b>{n m}</b></dt> <dd>The content particle must occur 831 + n to m times (both inclusive) in a row in valid documents. The 832 + quantifier must be a Tcl list with two elements. Both elements 833 + must be integers, with n >= 0 and n < m.</dd> 834 + 835 + </dl><p>If an optional quantifier is not given then it defaults to * in 836 + case of the <i class="m">mixed</i> command and to ! for all other commands.</p> 837 + 838 + <h2><a name="SECTid0x562b03470d20">Text constraint scripts</a></h2><p>Text - parsed character data, as XML calls it - must sometimes 839 + be of a certain kind, must comply to some rules etc to be valid. 840 + The text constraint script arguments to the text, attribute, 841 + nsattribute and deftexttype commands are evaluated in the Tcl 842 + namespace <i class="m">tdom::schema::text</i> namespace and allow the 843 + following text constraint commands to check text for certain 844 + properties. The commands are defined in the Tcl namespace 845 + <i class="m">tdom::schema::text</i>. They raise error in case they are 846 + called outside of a text constraint script.</p><p>A few of the following text type commands are exposed as 847 + general Tcl commands. They are defined in the namespace tdom::type 848 + and are called as documented below with the text to check appended 849 + to the argument list. They return a logical value. Please note, 850 + that the commands may not accept starting or ending white space. It 851 + is noted with the command documentation, if the command is 852 + available in the tdom::type namespace. 853 + </p> 854 + <h3><a name="SECTid0x562b03471730">The tcl text constraint command</a></h3> 855 + <p>The <i class="m">tcl</i> text constraint command dispatches the check 856 + to an arbitrary Tcl command, thus enable any programmable 857 + decision rules.</p> 858 + <dl class="commandlist"> 859 + 860 + <dt> 861 +<b class="cmd">tcl</b> <i class="m">tclcmd</i> <i class="m">?arg arg ...?</i> 862 +</dt> 863 + <dd>Evaluates the Tcl script <i class="m">tclcmd arg arg ... </i> and 864 + the text to validate appended to the argument list. The return 865 + value of the Tcl command is interpreted as a boolean.</dd> 866 + 867 + </dl> 868 + 869 + <h3><a name="SECTid0x562b03472510">Basic XML types</a></h3> 870 + <dl class="commandlist"> 871 + 872 + <dt><b class="cmd">name</b></dt> 873 + <dd>This text constraint match if the text value match the 874 + XML name production 875 + <a href="https://www.w3.org/TR/xml/#NT-Name">https://www.w3.org/TR/xml/#NT-Name</a>. This means the 876 + text value must start with a letter, underscore (_), or colon (:), 877 + and may contain only letters, digits, underscores (_), colons 878 + (:), hyphens (-), and periods (.).</dd> 879 + 880 + 881 + <dt><b class="cmd">ncname</b></dt> 882 + <dd>This text constraint match if the text value match the 883 + XML ncname production 884 + <a href="https://www.w3.org/TR/xml-names/#NT-NCName">https://www.w3.org/TR/xml-names/#NT-NCName</a>. This 885 + means the text value must start with a letter or underscore (_), 886 + and may contain only letters, digits, underscores (_), hyphens 887 + (-), and periods (.) (The only difference to the name 888 + constraint is that colons are not permitted.)</dd> 889 + 890 + 891 + <dt><b class="cmd">qname</b></dt> 892 + <dd>This text constraint match if the text value match the 893 + XML qname production 894 + <a href="https://www.w3.org/TR/xml-names/#NT-QName">https://www.w3.org/TR/xml-names/#NT-QName</a>. This 895 + means the text value is either a ncname or two ncnames joined 896 + by a colon (:).</dd> 897 + 898 + 899 + <dt><b class="cmd">nmtoken</b></dt> 900 + <dd>This text constraint match if the text value match the 901 + XML nmtoken production 902 + <a href="https://www.w3.org/TR/xml/#NT-Nmtoken">https://www.w3.org/TR/xml/#NT-Nmtoken</a> 903 +</dd> 904 + 905 + 906 + <dt><b class="cmd">nmtokens</b></dt> 907 + <dd>This text constraint match if the text value match the 908 + XML nmtokens production 909 + <a href="https://www.w3.org/TR/xml/#NT-Nmtokens">https://www.w3.org/TR/xml/#NT-Nmtokens</a> 910 +</dd> 911 + 912 + </dl> 913 + 914 + <h3><a name="SECTid0x562b034744e0">Basic type tests</a></h3> 915 + <p> 916 + </p> 917 + <dl class="commandlist"> 918 + 919 + <dt> 920 +<b class="cmd">integer</b> <i class="m">?(xsd|tcl)?</i> 921 +</dt> 922 + <dd>This text constraint match if the text value could be 923 + parsed as an integer. If the optional argument to the command 924 + is <i class="m">tcl</i> everything that returns TCL_OK if feeded into 925 + Tcl_GetInt() matches. If the optional argument to the command 926 + is <i class="m">xsd</i> then the constraint match if the value is a 927 + valid xsd:integer. Without argument <i class="m">xsd</i> is the 928 + default.</dd> 929 + 930 + 931 + 932 + <dt> 933 +<b class="cmd">negativeInteger</b> <i class="m">?(xsd|tcl)?</i> 934 +</dt> 935 + <dd>This text constraint match the same text values as the 936 + <i class="m">integer</i> text constraint (see there) with the additional 937 + constraint that the value must be < zero.</dd> 938 + 939 + 940 + 941 + <dt> 942 +<b class="cmd">nonNegativeInteger</b> <i class="m">?(xsd|tcl)?</i> 943 +</dt> 944 + <dd>This text constraint match the same text values as the 945 + <i class="m">integer</i> text constraint (see there) with the additional 946 + constraint that the value must be >= zero.</dd> 947 + 948 + 949 + 950 + <dt> 951 +<b class="cmd">nonPositiveInteger</b> <i class="m">?(xsd|tcl)?</i> 952 +</dt> 953 + <dd>This text constraint match the same text values as the 954 + <i class="m">integer</i> text constraint (see there) with the additional 955 + constraint that the value must be <= zero.</dd> 956 + 957 + 958 + 959 + <dt> 960 +<b class="cmd">positiveInteger</b> <i class="m">?(xsd|tcl)?</i> 961 +</dt> 962 + <dd>This text constraint match the same text values as the 963 + <i class="m">integer</i> text constraint (see there) with the additional 964 + constraint that the value must be > zero.</dd> 965 + 966 + 967 + 968 + <dt> 969 +<b class="cmd">number</b> <i class="m">?(xsd|tcl)?</i> 970 +</dt> 971 + <dd>This text constraint match if the text value could be 972 + parsed as a number. If the optional argument to the command is 973 + <i class="m">tcl</i> everything that returns TCL_OK if feeded into 974 + Tcl_GetDouble() matches. If the optional argument to the command 975 + is <i class="m">xsd</i> then the constraint match if the value is a 976 + valid xsd:decimal. Without argument <i class="m">xsd</i> is the 977 + default.</dd> 978 + 979 + 980 + <dt> 981 +<b class="cmd">boolean</b> <i class="m">?(xsd|tcl)?</i> 982 +</dt> 983 + <dd>This text constraint match if the text value could be 984 + parsed as a boolean. If the optional argument to the command is 985 + <i class="m">tcl</i> everything that returns TCL_OK if feeded into 986 + Tcl_GetBoolean() matches. If the optional argument to the command 987 + is <i class="m">xsd</i> then the constraint match if the value is a 988 + valid xsd:boolean. Without argument <i class="m">xsd</i> is the 989 + default.</dd> 990 + 991 + 992 + <dt><b class="cmd">date</b></dt> 993 + <dd>This text constraint match if the text value is 994 + a xsd:date. This is basically like an ISO 8601 date of 995 + the form YYYY-MM-DD, with optional time zone part 996 + (either the letter Z or plus (+) or minus (-) followed 997 + by hh:mm and with maximum allowed positive or negative 998 + time zone 14:00). It follows the date rules of the 999 + Gregorian calendar for all dates. A preceding minus 1000 + sign for bce dates is allowed. There is no year 0. The 1001 + year may have more than 4 digits, but only if needed 1002 + (no extra leading zeros). This is available as common 1003 + Tcl command tdom::type::date.</dd> 1004 + 1005 + 1006 + <dt><b class="cmd">time</b></dt> 1007 + <dd>This text constraint match if the text value is 1008 + a xsd:time. This is basically like an ISO 8601 time of 1009 + the form hh:mm:ss with optional time zone part. The 1010 + time zone part follow the rules of the <i class="m">date</i> 1011 + command; see there. All three parts of the time value 1012 + (hours, minutes, seconds) must be spelled out with 2 1013 + digits. Additional fractional seconds (with a point 1014 + ('.') as separator) are allowed, but not just a 1015 + dangling point. The time value 24:00:00 (without 1016 + fractional part) is allowed. This is available as 1017 + common Tcl command tdom::type::time.</dd> 1018 + 1019 + 1020 + <dt><b class="cmd">dateTime</b></dt> 1021 + <dd>This text constraint match if the text value is 1022 + a xsd:dateTime. This is basically like an ISO 8601 1023 + date time of the form YYYY-MM-DDThh:mm:ss with 1024 + optional time zone part. The date and time zone parts 1025 + follow the rules of the <i class="m">date</i> command; see 1026 + there. The time part (including the signaling 'T' 1027 + character) is mandatory and follow the rules of the 1028 + <i class="m">time</i> command, see there. This is available as 1029 + common Tcl command tdom::type::dateTime.</dd> 1030 + 1031 + 1032 + <dt><b class="cmd">duration</b></dt> 1033 + <dd>This text constraint match if the text value is 1034 + a xsd:duration. This is basically like an ISO 8601 1035 + duration of the form PnYnMnDTnHnMnS. All parts other 1036 + then the starting P and - if one of H, M or S is given 1037 + - T are optional. In case the following sign letter is 1038 + S n may be a decimal (with at least one digit before 1039 + and after the dot), otherwise it must be a (positive) 1040 + integer. This is available as common Tcl command 1041 + tdom::type::duration.</dd> 1042 + 1043 + 1044 + <dt><b class="cmd">base64</b></dt> 1045 + <dd>This text constraint match if text is valid according to 1046 + RFC 4648.</dd> 1047 + 1048 + 1049 + <dt><b class="cmd">hexBinary</b></dt> 1050 + <dd>This text constraint match if text is a sequence of 1051 + binary octets in hexadecimal encoding, where each binary octet 1052 + is a two-character hexadecimal number. Lowercase and uppercase 1053 + letters A through F are permitted.</dd> 1054 + 1055 + 1056 + <dt><b class="cmd">unsignedByte</b></dt> 1057 + <dd>This text constraint match if the text value is a 1058 + xsd:unsignedByte. This is an integer between 0 and 255, both 1059 + included, optionally preceded by a + sign and leading 1060 + zeros.</dd> 1061 + 1062 + 1063 + <dt><b class="cmd">unsignedShort</b></dt> 1064 + <dd>This text constraint match if the text value is a 1065 + xsd:unsignedShort. This is an integer between 0 and 65535, 1066 + both included, optionally preceded by a + sign and leading 1067 + zeros.</dd> 1068 + 1069 + 1070 + <dt><b class="cmd">unsignedInt</b></dt> 1071 + <dd>This text constraint match if the text value is a 1072 + xsd:unsignedInt. This is an integer between 0 and 4294967295, 1073 + both included, optionally preceded by a + sign and leading 1074 + zeros.</dd> 1075 + 1076 + 1077 + <dt><b class="cmd">unsignedLong</b></dt> 1078 + <dd>This text constraint match if the text value is a 1079 + xsd:unsignedLong. This is an integer between 0 and 1080 + 18446744073709551615, both included, optionally preceded by a 1081 + + sign and leading zeros.</dd> 1082 + 1083 + </dl> 1084 + 1085 + <h3><a name="SECTid0x562b0347b750">Logical constructs</a></h3> 1086 + <dl class="commandlist"> 1087 + 1088 + <dt> 1089 +<b class="cmd">oneOf</b> <i class="m"><constraint script></i> 1090 +</dt> 1091 + <dd>This text constraint match if one of the text 1092 + constraints defined in the argument <i class="m">constraint script</i> 1093 + match the text. It stops after the first match and probes the 1094 + text constraints in the order of definition.</dd> 1095 + 1096 + 1097 + <dt> 1098 +<b class="cmd">allOf</b> <i class="m"><constraint script></i> 1099 +</dt> 1100 + <dd>This text constraint match if all of the text 1101 + constraints defined in the argument <i class="m">constraint script</i> 1102 + match the text. It stops after the first match failure and 1103 + probes the text constraints in the order of definition. Since 1104 + the schema definition command <i class="m">text</i> also expects all 1105 + text constraints to match the text constraint <i class="m">allOf</i> is 1106 + useful mostly together with the <i class="m">oneOf</i> text constraint 1107 + command.</dd> 1108 + 1109 + 1110 + <dt> 1111 +<b class="cmd">not</b> <i class="m"><constraint script></i> 1112 +</dt> 1113 + <dd>This text constraint match if none of the text 1114 + constraints defined in the argument <i class="m">constraint 1115 + script</i> match the text. It stops after the first 1116 + matching constraint in the <i class="m">constraint script</i> and 1117 + reports validation error. The text constraints in the 1118 + <i class="m">constraint script</i> are probed in the order of 1119 + definition.</dd> 1120 + 1121 + </dl> 1122 + 1123 + <h3><a name="SECTid0x562b0347d580">Constraints on processed text value</a></h3> 1124 + <dl class="commandlist"> 1125 + 1126 + <dt> 1127 +<b class="cmd">whitespace</b> <i class="m">(preserve|replace|collapse)</i> <i class="m"><constraint script></i> 1128 +</dt> 1129 + <dd>This text constraint command does white-space (#x20 1130 + (space, ' '), #x9 (tab, \t), #xA (linefeed, \n), and #xD 1131 + (carriage return, \r) normalization to the text value and 1132 + checks the resulting text with the text constraints of the 1133 + constraint script argument. The normalization method 1134 + <i class="m">preserve</i> keeps everything as it is; this is another way 1135 + to say <i class="m">allOf</i>. The <i class="m">replace</i> normalization method 1136 + replaces any single white-space character (as above) to a 1137 + space. The <i class="m">collapse</i> normalization method removes all 1138 + leading and trailing white-space and all the other sequences of 1139 + contiguous white-space are replaced by a single space.</dd> 1140 + 1141 + 1142 + <dt> 1143 +<b class="cmd">split</b> <i class="m">?type ?args??</i><i class="m"><constraint script></i> 1144 +</dt> 1145 + <dd> 1146 +<p>This text constraint command splits the text to test 1147 + into a list of values and tests all elements of that list for 1148 + the text constraints in the evaluated <i class="m">constraint 1149 + script></i>.</p> 1150 + <p>The available types are:</p> 1151 + <dl> 1152 + <dt>whitespace</dt><dd>The text to split is striped of all 1153 + white space at start and end splited into a list at any 1154 + successive white space.</dd> 1155 + <dt>tcl tclcmd ?arg ...?</dt><dd>The text to split is 1156 + handed to the <i class="m">tclcmd</i>, which is evaluated on global 1157 + level, appended with every given arg and the text to split 1158 + as last argument. This call must return a valid Tcl list, 1159 + which elements are tested.</dd> 1160 + </dl> 1161 + <p>The default in case no split type argument is given is 1162 + <i class="m">whitespace</i>.</p> 1163 +</dd> 1164 + 1165 + 1166 + <dt> 1167 +<b class="cmd">strip</b> <i class="m"><constraint script></i> 1168 +</dt> 1169 + <dd>This text constraint command tests all text constraints 1170 + in the evaluated <i class="m">constraint script></i> with the text to 1171 + test striped of all white space at start and end.</dd> 1172 + 1173 + </dl> 1174 + 1175 + <h3><a name="SECTid0x562b0347ff40">Various other string properties</a></h3> 1176 + <dl class="commandlist"> 1177 + 1178 + <dt> 1179 +<b class="cmd">fixed</b> <i class="m">value</i> 1180 +</dt> 1181 + <dd>The text constraint only match if the text value is 1182 + string equal to the given value.</dd> 1183 + 1184 + 1185 + 1186 + <dt> 1187 +<b class="cmd">enumeration</b> <i class="m">list</i> 1188 +</dt> 1189 + <dd>This text constraint match if the text value is equal to 1190 + one element (respecting case and any white-space) of the 1191 + argument <i class="m">list</i>, which has to be a valid Tcl list. 1192 + </dd> 1193 + 1194 + 1195 + <dt> 1196 +<b class="cmd">match</b> <i class="m">?-nocase?</i> <i class="m">glob_style_match_pattern></i> 1197 +</dt> 1198 + <dd>This text constraint match if the text value match the 1199 + glob style pattern given as argument. It follows the rules of 1200 + the Tcl [string match] command, see 1201 + <a href="https://www.tcl.tk/man/tcl8.6/TclCmd/string.htm#M35">https://www.tcl.tk/man/tcl8.6/TclCmd/string.htm#M35</a>.</dd> 1202 + 1203 + 1204 + <dt> 1205 +<b class="cmd">regexp</b> <i class="m">expression</i> 1206 +</dt> 1207 + <dd>This text constraint match if the text value match the 1208 + regular expression given as argument. <a href="https://www.tcl.tk/man/tcl8.6/TclCmd/re_syntax.htm">https://www.tcl.tk/man/tcl8.6/TclCmd/re_syntax.htm</a> describes the regular expression syntax</dd> 1209 + 1210 + 1211 + <dt> 1212 +<b class="cmd">length</b> <i class="m">length</i> 1213 +</dt> 1214 + <dd>This text constraint match if the length of the text 1215 + value (in characters, not bytes) is <i class="m">length</i>. The 1216 + length argument must be a positive integer or zero.</dd> 1217 + 1218 + 1219 + <dt> 1220 +<b class="cmd">maxLength</b> <i class="m">length</i> 1221 +</dt> 1222 + <dd>This text constraint match if the length of the text 1223 + value (in characters, not bytes) is at most <i class="m">length</i>. The 1224 + length argument must be an integer greater zero.</dd> 1225 + 1226 + 1227 + <dt> 1228 +<b class="cmd">minLength</b> <i class="m">length</i> 1229 +</dt> 1230 + <dd>This text constraint match if the length of the text 1231 + value (in characters, not bytes) is at least <i class="m">length</i>. 1232 + The length argument must be an integer greater zero.</dd> 1233 + 1234 + 1235 + <dt> 1236 +<b class="cmd">id</b> <i class="m">?keySpace?</i> 1237 +</dt> 1238 + <dd>This text constraint command marks the text as a 1239 + document wide ID (to be referenced by an idref). Every ID 1240 + value within a document must be unique. It isn't an error if 1241 + the ID isn't actually referenced within the document. The 1242 + optional argument <i class="m">keySpace</i> does all this for a named 1243 + key space. The key space "" (the empty sting) is another key 1244 + space as the <i class="m">id</i> command without keySpace 1245 + argument.</dd> 1246 + 1247 + 1248 + <dt> 1249 +<b class="cmd">idref</b> <i class="m">?keySpace?</i> 1250 +</dt> 1251 + <dd>This text constraint command expects the text to be a 1252 + reference to an ID within the document. The referenced ID may 1253 + be later in the document, that the reference. Several 1254 + references within the document to one ID are possible.</dd> 1255 + 1256 + </dl> 1257 + 1258 + 1259 + <h2><a name="SECTid0x562b03483fa0">Local key constraints</a></h2><p>Document wide uniqueness and foreign key constraints are 1260 + available with the text constraint commands id and idref. 1261 + Keyspaces allow for sub-tree local uniqueness and foreign key 1262 + constraints.</p><dl class="commandlist"> 1263 + 1264 + <dt> 1265 +<b class="cmd">keyspace</b> <i class="m"><names list></i> <i class="m"><constraint script></i> 1266 +</dt> 1267 + <dd>Any number of keyspaces are possible. A keyspace is 1268 + either active or not. An inside a <i class="m">constraint 1269 + script</i> called keyspace with the same name does 1270 + nothing.</dd> 1271 + 1272 + </dl><p>This text constraint commands work with keyspaces:</p><dl class="commandlist"> 1273 + 1274 + <dt> 1275 +<b class="cmd">key</b> <i class="m"><name></i> 1276 +</dt> 1277 + <dd>If the keyspace with the name <i class="m"><name></i> is not 1278 + active always matches. If the keyspace is active then 1279 + reports error if there is already a key with the value. 1280 + Otherwise, stores the value as key in this keyspace and 1281 + matches.</dd> 1282 + 1283 + 1284 + <dt> 1285 +<b class="cmd">keyref</b> <i class="m"><name></i> 1286 +</dt> 1287 + <dd>If the keyspace with the name <i class="m"><name></i> is not 1288 + active always matches. If the keyspace is active then 1289 + reports error if there is still no key as the value at the 1290 + end of the keyspace <i class="m"><name></i>. Otherwise it 1291 + matches.</dd> 1292 + 1293 + </dl> 1294 + 1295 + <h2><a name="SECTid0x562b03485db0">Recovering</a></h2><p>By default the validation engine stops at the first detected 1296 + validation violation and report that finding. It does so by 1297 + return false (and set, if given, the result variable with an 1298 + error message) in case the schema command itself is used to 1299 + validate input. If the schema command is used by a SAX parser or 1300 + the DOM parser it does so by throwing error.</p><p>If a <i class="m">reportcmd</i> is set this command is called on global 1301 + level appended with the schema command and an error type as 1302 + arguments if a validation violation is detected. Then the 1303 + validation recovers from the error and continues. For some 1304 + validation errors the recover strategy can be determined with 1305 + the script result of the reportcmd.</p><p>With a <i class="m">reportcmd</i> (which doesen&t throw error if 1306 + called) the validation engine will never report validation 1307 + failure to its caller. The validation engine recovers, continues 1308 + and report the next error, if one happen and so until the end of 1309 + the input. The schema command will return true and the SAX 1310 + parser and DOM builder will process normally until the end of 1311 + the input, as if there would not have been validation.</p><p>Please note, that this happens only for validation errors. It 1312 + isn't possible to recover from well-formedness errors. If the 1313 + input isn't well-formed the schema command returns false and 1314 + set, if given, the result variable with an error message about 1315 + the well-formedness error.</p><p>If the <i class="m">reportcmd</i> throws error while called by the 1316 + validation engine then validation stops and the schema command 1317 + throws error with the error message of the script.</p><p>While validating basically three events happen: an element 1318 + start tag has to match, a piece of text has to match or an 1319 + element end tag has to match. The method <i class="m">info vaction</i> 1320 + called in the recovering script or any script code called from 1321 + there returns, which event triggered the error report 1322 + (MATCH_ELEMENT_START, MATCH_TEXT, MATCH_ELEMENT_END, 1323 + respectively). While the command walks throu the schema looking 1324 + if the event matches other, data driven events (as, for example 1325 + checking, if any keyref within a keyspace exists).</p><p>Several of the validation error codes appended as second 1326 + argument to the <i class="m">reportcmd</i> calls may happen at more than 1327 + one kind of validation event. The <i class="m">info vaction</i> method and 1328 + its subcommands provide information about the current validation 1329 + event and the 1330 + </p><p>If a structural validation error happens, the default 1331 + recovering strategy is to ignore any following (or missing) 1332 + content within the current subtree and to continue with the 1333 + element end event of the subtree.</p><p>Returning "ignore" from the recovering script in case of 1334 + error type MISSING_ELEMENT recovers by ignoring the failed 1335 + contraint and continues to match the event further against the 1336 + schema.</p><p>Returing "vanish" from the recover script In case of the 1337 + error types MISSING_ELEMENT and UNEXPECTED_ELEMENT recovers by 1338 + ignoring the event.</p> 1339 + 1340 + <h2><a name="SECTid0x562b03487d50">Examples</a></h2><p>The XML Schema Part 0: Primer Second Edition 1341 + (<a href="https://www.w3.org/TR/xmlschema-0/">https://www.w3.org/TR/xmlschema-0/</a>) starts with this 1342 + example schema:</p><pre class="example"> 1343 +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1344 + 1345 + <xsd:annotation> 1346 + <xsd:documentation xml:lang="en"> 1347 + Purchase order schema for Example.com. 1348 + Copyright 2000 Example.com. All rights reserved. 1349 + </xsd:documentation> 1350 + </xsd:annotation> 1351 + 1352 + <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> 1353 + 1354 + <xsd:element name="comment" type="xsd:string"/> 1355 + 1356 + <xsd:complexType name="PurchaseOrderType"> 1357 + <xsd:sequence> 1358 + <xsd:element name="shipTo" type="USAddress"/> 1359 + <xsd:element name="billTo" type="USAddress"/> 1360 + <xsd:element ref="comment" minOccurs="0"/> 1361 + <xsd:element name="items" type="Items"/> 1362 + </xsd:sequence> 1363 + <xsd:attribute name="orderDate" type="xsd:date"/> 1364 + </xsd:complexType> 1365 + 1366 + <xsd:complexType name="USAddress"> 1367 + <xsd:sequence> 1368 + <xsd:element name="name" type="xsd:string"/> 1369 + <xsd:element name="street" type="xsd:string"/> 1370 + <xsd:element name="city" type="xsd:string"/> 1371 + <xsd:element name="state" type="xsd:string"/> 1372 + <xsd:element name="zip" type="xsd:decimal"/> 1373 + </xsd:sequence> 1374 + <xsd:attribute name="country" type="xsd:NMTOKEN" 1375 + fixed="US"/> 1376 + </xsd:complexType> 1377 + 1378 + <xsd:complexType name="Items"> 1379 + <xsd:sequence> 1380 + <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> 1381 + <xsd:complexType> 1382 + <xsd:sequence> 1383 + <xsd:element name="productName" type="xsd:string"/> 1384 + <xsd:element name="quantity"> 1385 + <xsd:simpleType> 1386 + <xsd:restriction base="xsd:positiveInteger"> 1387 + <xsd:maxExclusive value="100"/> 1388 + </xsd:restriction> 1389 + </xsd:simpleType> 1390 + </xsd:element> 1391 + <xsd:element name="USPrice" type="xsd:decimal"/> 1392 + <xsd:element ref="comment" minOccurs="0"/> 1393 + <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> 1394 + </xsd:sequence> 1395 + <xsd:attribute name="partNum" type="SKU" use="required"/> 1396 + </xsd:complexType> 1397 + </xsd:element> 1398 + </xsd:sequence> 1399 + </xsd:complexType> 1400 + 1401 + <!-- Stock Keeping Unit, a code for identifying products --> 1402 + <xsd:simpleType name="SKU"> 1403 + <xsd:restriction base="xsd:string"> 1404 + <xsd:pattern value="\d{3}-[A-Z]{2}"/> 1405 + </xsd:restriction> 1406 + </xsd:simpleType> 1407 + 1408 +</xsd:schema> 1409 + </pre><p>A somewhat one-to-one translation of that into a tDOM schema 1410 + definition script would be:</p><pre class="example"> 1411 +tdom::schema schema 1412 +schema define { 1413 + 1414 + # Purchase order schema for Example.com. 1415 + # Copyright 2000 Example.com. All rights reserved. 1416 + 1417 + defelement purchaseOrder {ref PurchaseOrderType} 1418 + 1419 + foreach elm {comment name street city state product} { 1420 + defelement $elm text 1421 + } 1422 + 1423 + defpattern PurchaseOrderType { 1424 + element shipTo ! {ref USAddress} 1425 + element billTo ! {ref USAddress} 1426 + element comment ? 1427 + element items 1428 + attribute orderDate date 1429 + } 1430 + 1431 + defpattern USAddress { 1432 + element name 1433 + element street 1434 + element city 1435 + element state 1436 + element zip ! {text number} 1437 + attribute country ! {fixed "US"} 1438 + } 1439 + 1440 + defelement items { 1441 + element item * { 1442 + element product 1443 + element quantity ! {text integer} 1444 + element USPrice ! {text number} 1445 + element comment 1446 + element shipDate ? {text date} 1447 + attribute partNum ! {pattern "^\d{3}-[A-Z]{2}$"} 1448 + } 1449 + } 1450 +} 1451 + 1452 + </pre><p>The RELAX NG Tutorial 1453 + (<a href="http://relaxng.org/tutorial-20011203.html">http://relaxng.org/tutorial-20011203.html</a>) starts with 1454 + this example:</p><pre class="example"> 1455 +Consider a simple XML representation of an email address book: 1456 + 1457 +<addressBook> 1458 + <card> 1459 + <name>John Smith</name> 1460 + <email>js@example.com</email> 1461 + </card> 1462 + <card> 1463 + <name>Fred Bloggs</name> 1464 + <email>fb@example.net</email> 1465 + </card> 1466 +</addressBook> 1467 + 1468 +The DTD would be as follows: 1469 + 1470 +<!DOCTYPE addressBook [ 1471 +<!ELEMENT addressBook (card*)> 1472 +<!ELEMENT card (name, email)> 1473 +<!ELEMENT name (#PCDATA)> 1474 +<!ELEMENT email (#PCDATA)> 1475 +]> 1476 + 1477 +A RELAX NG pattern for this could be written as follows: 1478 + 1479 +<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> 1480 + <zeroOrMore> 1481 + <element name="card"> 1482 + <element name="name"> 1483 + <text/> 1484 + </element> 1485 + <element name="email"> 1486 + <text/> 1487 + </element> 1488 + </element> 1489 + </zeroOrMore> 1490 +</element> 1491 + 1492 + </pre><p>This schema definition script will do the same:</p><pre class="example"> 1493 +tdom::schema schema 1494 +schema define { 1495 + defelement addressBook { 1496 + element card * 1497 + } 1498 + defelement card { 1499 + element name 1500 + element email 1501 + } 1502 + foreach e {name email} { 1503 + defelement $e text 1504 + } 1505 +} 1506 + 1507 + </pre> 1508 + 1509 +<h2><a name="SECTid0x562b03489cc0">KEYWORDS</a></h2><p class="keywords"> 1510 +<a class="keyword" href="keyword-index.html#KW-Validation">Validation</a>, <a class="keyword" href="keyword-index.html#KW-Postvalidation">Postvalidation</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-SAX">SAX</a> 1511 +</p> 1512 +</div><hr class="navsep"><div class="navbar" align="center"> 1513 +<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 1514 +</div> 1515 +</body> 1516 +</html>
Added doc/schema.n.
1 +'\" 2 +'\" Generated from schema.xml 3 +'\" 4 +'\" BEGIN man.macros 5 +.if t .wh -1.3i ^B 6 +.nr ^l \n(.l 7 +.ad b 8 +.de AP 9 +.ie !"\\$4"" .TP \\$4 10 +.el \{\ 11 +. ie !"\\$2"" .TP \\n()Cu 12 +. el .TP 15 13 +.\} 14 +.ta \\n()Au \\n()Bu 15 +.ie !"\\$3"" \{\ 16 +\&\\$1 \\fI\\$2\\fP (\\$3) 17 +.\".b 18 +.\} 19 +.el \{\ 20 +.br 21 +.ie !"\\$2"" \{\ 22 +\&\\$1 \\fI\\$2\\fP 23 +.\} 24 +.el \{\ 25 +\&\\fI\\$1\\fP 26 +.\} 27 +.\} 28 +.. 29 +.de AS 30 +.nr )A 10n 31 +.if !"\\$1"" .nr )A \\w'\\$1'u+3n 32 +.nr )B \\n()Au+15n 33 +.\" 34 +.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n 35 +.nr )C \\n()Bu+\\w'(in/out)'u+2n 36 +.. 37 +.AS Tcl_Interp Tcl_CreateInterp in/out 38 +.de BS 39 +.br 40 +.mk ^y 41 +.nr ^b 1u 42 +.if n .nf 43 +.if n .ti 0 44 +.if n \l'\\n(.lu\(ul' 45 +.if n .fi 46 +.. 47 +.de BE 48 +.nf 49 +.ti 0 50 +.mk ^t 51 +.ie n \l'\\n(^lu\(ul' 52 +.el \{\ 53 +.\" Draw four-sided box normally, but don't draw top of 54 +.\" box if the box started on an earlier page. 55 +.ie !\\n(^b-1 \{\ 56 +\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' 57 +.\} 58 +.el \}\ 59 +\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' 60 +.\} 61 +.\} 62 +.fi 63 +.br 64 +.nr ^b 0 65 +.. 66 +.de VS 67 +.if !"\\$2"" .br 68 +.mk ^Y 69 +.ie n 'mc \s12\(br\s0 70 +.el .nr ^v 1u 71 +.. 72 +.de VE 73 +.ie n 'mc 74 +.el \{\ 75 +.ev 2 76 +.nf 77 +.ti 0 78 +.mk ^t 79 +\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' 80 +.sp -1 81 +.fi 82 +.ev 83 +.\} 84 +.nr ^v 0 85 +.. 86 +.de ^B 87 +.ev 2 88 +'ti 0 89 +'nf 90 +.mk ^t 91 +.if \\n(^b \{\ 92 +.\" Draw three-sided box if this is the box's first page, 93 +.\" draw two sides but no top otherwise. 94 +.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c 95 +.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c 96 +.\} 97 +.if \\n(^v \{\ 98 +.nr ^x \\n(^tu+1v-\\n(^Yu 99 +\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c 100 +.\} 101 +.bp 102 +'fi 103 +.ev 104 +.if \\n(^b \{\ 105 +.mk ^y 106 +.nr ^b 2 107 +.\} 108 +.if \\n(^v \{\ 109 +.mk ^Y 110 +.\} 111 +.. 112 +.de DS 113 +.RS 114 +.nf 115 +.sp 116 +.. 117 +.de DE 118 +.fi 119 +.RE 120 +.sp 121 +.. 122 +.de SO 123 +.SH "STANDARD OPTIONS" 124 +.LP 125 +.nf 126 +.ta 5.5c 11c 127 +.ft B 128 +.. 129 +.de SE 130 +.fi 131 +.ft R 132 +.LP 133 +See the \\fBoptions\\fR manual entry for details on the standard options. 134 +.. 135 +.de OP 136 +.LP 137 +.nf 138 +.ta 4c 139 +Command-Line Name: \\fB\\$1\\fR 140 +Database Name: \\fB\\$2\\fR 141 +Database Class: \\fB\\$3\\fR 142 +.fi 143 +.IP 144 +.. 145 +.de CS 146 +.RS 147 +.nf 148 +.ta .25i .5i .75i 1i 149 +.if t .ft C 150 +.. 151 +.de CE 152 +.fi 153 +.if t .ft R 154 +.RE 155 +.. 156 +.de UL 157 +\\$1\l'|0\(ul'\\$2 158 +.. 159 +'\" END man.macros 160 +.TH schema n "" Tcl "" 161 +.BS 162 +.SH NAME 163 +tdom::schema \- Create a schema validation command 164 +.SH SYNOPSIS 165 +.nf 166 +package require tdom 167 + 168 +\&\fBtdom::schema\fP \fI?create?\fR \fIcmdName\fR 169 + 170 +.fi 171 +.BE 172 +.SH "DESCRIPTION " 173 +.PP 174 +This command creates validation commands with a simple API. The 175 +validation commands have methods to define a schema and are able 176 +to validate XML data or to post-validate a tDOM DOM tree (and to 177 +some degree other kind of hierarchical data) against this 178 +schema. 179 +.PP 180 +Additionally, a validation command may be used as argument to 181 +the \fI-validateCmd\fR option of the \fIdom parse\fR and the 182 +\&\fIexpat\fR commands to enable validation additional to what they 183 +otherwise do. 184 +.PP 185 +The methods of the created commands are: 186 +.TP 187 +\&\fB\fBprefixns\fP \fI?prefixUriList?\fB 188 +\&\fRThis method gives control to a prefix (or 189 +abbreviation) to namespace URI mapping. Everywhere a 190 +namespace argument is expected in the schema command methods 191 +you may use the "prefix" pointing to the namespace 192 +URI in the current prefixUriList, set by this method. If the 193 +list map the same prefix to different namespace URIs the 194 +first one win. If there isn't such a prefix the namespace 195 +argument is used literally as namespace URI. If the method 196 +is called without argument it returns the current 197 +prefixUriList. If the method is called with the empty string 198 +any namespace URI arguments are used literally. This is the 199 +default. 200 +.TP 201 +\&\fB\fBdefelement\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 202 +\&\fRThis method defines the element \fIname\fR (optional in 203 +the namespace \fInamespace\fR) in the schema. The 204 +\&\fIdefinition script\fR is evaluated and defines the content 205 +model of the element. If the \fInamespace\fR argument is 206 +given, any \fIelement\fR or \fIref\fR references in the 207 +definition script not wrapped inside a \fInamespace\fR 208 +command are resolved in that namespace. If there is already a 209 +element definition for the name/namespace combination the 210 +command raises error. 211 +.TP 212 +\&\fB\fBdefelementtype\fP \fItypename\fB \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 213 +\&\fRThis method defines the element type \fItypename\fR 214 +(optional in the namespace \fInamespace\fR) in the schema. If 215 +the element type is referred in a definition script with the 216 +schema command elementtype the validation engine expects an 217 +element named \fIname\fR (in the namespace \fInamespace\fR, 218 +if given) and the content model \fIdefinition script\fR. 219 +Defining element types seems only sensible if you really have 220 +elements with the same name and namespace but different 221 +content models. The \fIdefinition script\fR is evaluated and 222 +defines the content model of the element. If the 223 +\&\fInamespace\fR argument is given, any \fIelement\fR or 224 +\&\fIref\fR references in the definition script not wrapped 225 +inside a \fInamespace\fR command are resolved in that 226 +namespace. If there is already a elementtype definition for 227 +the name/namespace combination the command raises error. The 228 +document element of any XML to validate cannot be a 229 +\&\fIdefelementtype\fR defined element. 230 +.TP 231 +\&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 232 +\&\fRThis method defines a (maybe complex) content particle 233 +with the \fIname\fR (optional in the namespace 234 +\&\fInamespace\fR) in the schema, to be referenced in other 235 +definition scripts with the definition command \fIref\fR. The 236 +\&\fIdefinition script\fR is evaluated and defines the content 237 +model of the content particle. If the \fInamespace\fR 238 +argument is given, any \fIelement\fR or \fIref\fR references 239 +in the definition script not wrapped inside a \fInamespace\fR 240 +command are resolved in that namespace. If there is already a 241 +pattern definition for the name/namespace combination the 242 +command raises error. 243 +.TP 244 +\&\fB\fBdeftexttype\fP \fIname\fB \fI<constraint script>\fB 245 +\&\fRThis method defines a bundle of text constraints, that 246 +can be referred by \fIname\fR while defining constrains on 247 +text element or attribute values. If there is already a text 248 +type definition with this name, the command raises error. A 249 +text type must be defined before it can be used in schema 250 +definition scripts. 251 +.TP 252 +\&\fB\fBstart\fP \fIdocumentElement\fB \fI?namespace?\fB 253 +\&\fRThis method defines the name and namespace of the root 254 +element of a tree to validate. If this method is used then the 255 +root element must match for validity. If \fIstart\fR isn't 256 +used, any with \fIdefelement\fR defined element may be the 257 +root of a valid document. The \fIstart\fR method may be used 258 +several times with varying arguments during the lifetime of a 259 +validation command. If the command is called with just the 260 +empty string (and no namespace argument), the validation 261 +constrain for the root element is removed and any defined 262 +element will be valid as root of a tree to validate. 263 +.TP 264 +\&\fB\fBdefine\fP \fI<definition script>\fB 265 +\&\fRThis method allows to define several elements or pattern 266 +or a whole schema with one call. All schema command methods so 267 +far (\fIprefixns\fR, \fIdefelement\fR, 268 +\&\fIdefelementtype\fR, \fIdefpattern\fR, \fIdeftexttype\fR and 269 +\&\fIstart\fR) are allowed top level in the \fIdefinition 270 +script\fR. The \fIdefine\fR method itself isn't allowed 271 +recursively. 272 +.TP 273 +\&\fB\fBevent\fP \fI(start|end|text)\fB \fI?event specific data?\fB 274 +\&\fRThis method allows to validate hierarchical data against 275 +the content constrains of the validation command. 276 +.RS 277 +.IP "\fBstart \fIname ?attributes? ?namespace? \fP\fR" 278 +Checks if the current validation state allows the 279 +element \fIname\fR in the \fInamespace\fR to start here. 280 +It raises error, if not. 281 +.IP "\fBend\fR" 282 +Checks if the current innermost open element may end 283 +here in the current state without violate validation 284 +constrains. It raises error, if not. 285 +.IP "\fBtext \fItext\fP\fR" 286 +Checks if the current validation state allows the 287 +given text content. It raises error, if not. 288 +.RE 289 +.TP 290 +\&\fB\fBvalidate\fP \fI<XML string>\fB \fI?objVar?\fB 291 +\&\fRReturns true if the \fI<XML string>\fR is valid or 292 +false otherwise. If validation failed and the optional 293 +\&\fIobjVar\fR argument is given, then the variable with that 294 +name is set to a validation error message. If the XML string 295 +is valid and the optional \fIobjVar\fR argument is given, 296 +then the variable with that name is set to the empty string. 297 +.TP 298 +\&\fB\fBvalidatefile\fP \fIfilename\fB \fI?objVar?\fB 299 +\&\fRReturns true if the content of \fIfilename\fR is valid 300 +or false otherwise. The given file is feeded as binary stream 301 +to expat, therefor only US-ASCII, ISO-8859-1, UTF-8 or UTF-16 302 +encoded data will work with this method. If validation failed 303 +and the optional \fIobjVar\fR argument is given, then the 304 +variable with that name is set to a validation error message. 305 +If the XML string is valid and the optional \fIobjVar\fR 306 +argument is given, then the variable with that name is set to 307 +the empty string. 308 +.TP 309 +\&\fB\fBvalidatechannel\fP \fIchannel\fB \fI?objVar?\fB 310 +\&\fRReturns true if the content read out of the tcl channel 311 +\&\fIchannel\fR is valid or false otherwise. Since data read 312 +out of a tcl channel is UTF-8 encoded any misleading encoding 313 +declaration at the beginning of the data will lead to errors. 314 +If the validation failed and the optional \fIobjVar\fR 315 +argument is given, then the variable with that name is set to 316 +a validation error message. If the XML string is valid and the 317 +optional \fIobjVar\fR argument is given, then the variable 318 +with that name is set to the empty string. 319 +.TP 320 +\&\fB\fBdomvalidate\fP \fIdomNode\fB \fI?objVar?\fB 321 +\&\fRReturns true if the first argument is a valid tree or 322 +false otherwise. If validation failed and the optional 323 +\&\fIobjVar\fR argument is given, then the variable with that 324 +name is set to a validation error message. If the dom tree is 325 +valid and the optional \fIobjVar\fR argument is given, then 326 +the variable with that name is set to the empty string. 327 +.TP 328 +\&\fB\fBreportcmd\fP \fI?cmd?\fB 329 +\&\fRThis method expects the name of a tcl command to be 330 +called in case of validation error. This command will be 331 +called with two arguments appended: the schema command, that 332 +raises the validation error, and a validation error code. 333 +For more detailed information see Recovering.The possible error codes 334 +are: 335 +.RS 336 +.TP 337 +MISSING_ELEMENT 338 +.TP 339 +MISSING_TEXT 340 +.TP 341 +UNEXPECTED_ELEMENT 342 +.TP 343 +UNEXPECTED_ROOT_ELEMENT 344 +.TP 345 +UNEXPECTED_TEXT 346 +.TP 347 +UNKNOWN_ROOT_ELEMENT 348 +.TP 349 +UNKNOWN_ATTRIBUTE 350 +.TP 351 +MISSING_ATTRIBUTE 352 +.TP 353 +INVALID_ATTRIBUTE_VALUE 354 +.TP 355 +DOM_KEYCONSTRAINT 356 +.TP 357 +DOM_XPATH_BOOLEAN 358 +.TP 359 +INVALID_KEYREF 360 +.TP 361 +INVALID_VALUE 362 +.TP 363 +UNKOWN_GLOBAL_ID 364 +.TP 365 +UNKOWN_ID 366 +.PP 367 +For more detailed information see section Recovering. 368 +.RE 369 +.TP 370 +\&\fB\fBdelete\fP 371 +\&\fRThis method deletes the validation command. 372 +.TP 373 +\&\fB\fBinfo\fP \fI?args?\fB 374 +\&\fRThis method bundles methods to query the state of and 375 +details about the schema command. 376 +.RS 377 +.IP "\fBvalidationstate\fR" 378 +This method returns the state of the validation command 379 +with respect to validation state. The possible return values 380 +and their meanings are: 381 +.RS 382 +.TP 383 +READY 384 +The validation command is ready to start 385 +validation 386 +.TP 387 +VALIDATING 388 +The validation command is in the 389 +process of validating input. 390 +.TP 391 +FINISHED 392 +The validation has finished, no further 393 +events are expected. 394 +.RE 395 +.IP "\fBvstate\fR" 396 +This method is a shorter alias for validationstate; see there. 397 +.IP "\fBline\fR" 398 +If the schema command is currently validating 399 +this method returns the line part of the parsing 400 +position information and the empty string in all 401 +other cases. If the schema command is currently 402 +post-validating a DOM tree there may be no position 403 +information stored at certain or all nodes. The 404 +empty string is returned in this cases. 405 +.IP "\fBcolumn\fR" 406 +If the schema command is currently validating 407 +this method returns the column part of the parsing 408 +position information and the empty string in all 409 +other cases. If the schema command is currently 410 +post-validating a DOM tree there may be no position 411 +information stored at certain or all nodes. The 412 +empty string is returned in this cases. 413 +.IP "\fBdomNode\fR" 414 +If the schema command isn't currently 415 +post-validating a DOM tree this method returns the 416 +empty string. Otherwise, if the schema command waits 417 +for the reportcmd script to finish while recovering 418 +from a validation error it returns the node on which 419 +the validation engine is currently looking at in 420 +case, the node is an ELEMENT_NODE or the parent 421 +node, if not. It is recommended that you don't use 422 +this method. Or at least leave the DOM tree alone, 423 +use it read-only. 424 +.IP "\fBnrForwardDefinitions\fR" 425 +Returns how much element, elementtype and ref 426 +pattern are referenced that aren't defined so far 427 +(summed together). 428 +.IP "\fBdefinedElements\fR" 429 +Returns in no particular order the defined 430 +elements in the grammar as list. If an element is 431 +namespaced its list entry will be itself a list with 432 +two elements, with the name as first and the 433 +namespace as second element. 434 +.IP "\fBdefinedElementtypes\fR" 435 +Returns in no particular order the defined 436 +element types in the grammar as list. If an element 437 +type is namespaced its list entry will be itself a 438 +list with two elements, with the name as first and 439 +the namespace as second element. 440 +.IP "\fBdefinedPatterns\fR" 441 +Returns in no particular order the defined 442 +named pattern in the grammar as list. If a named 443 +pattern is namespaced its list entry will be itself 444 +a list with two elements, with the name as first and 445 +the namespace as second element. 446 +.IP "\fBexpected\fR" 447 +Returns in no particular order all possible 448 +next events (since the last successful event match, 449 +if there was one) as a list. If an element is 450 +namespaced its list entry will be itself a list with 451 +two elements, with the name as first and the 452 +namespace as second element. If text is a possible 453 +next event the list entry will be a two elements 454 +list, with #text as first element and the empty 455 +space as second. If an any element constraint is 456 +possible the list entry will be a two elements list, 457 +with <any> as first element and the empty space 458 +as second. If an any element in a certain namespace 459 +constraint is possible the list entry will be a two 460 +elements list, with <any> as first element and 461 +the namespace as second. If element end is a 462 +possible event the list entry will be a two elements 463 +list with <elementend> as first element and the 464 +empty string as second element. 465 +.IP "\fBdefinition name ?namespace?\fR" 466 +Returns the code that defines the given 467 +element. The command raises error if there isn't a 468 +definition of that element. 469 +.IP "\fBtypedefinition name ?namespace?\fR" 470 +Returns the code that defines the given 471 +element type definition. The command raises error if 472 +there isn't a definition of that element. 473 +.IP "\fBpatterndefinition name ?namespace?\fR" 474 +Returns the code that defines the given 475 +pattern definition. The command raises error if 476 +there isn't a definition of a pattern with that name 477 +and, if given, namespace. 478 +.IP "\fBvaction ?name|namespace|text?\fR" 479 +.RS 480 +.PP 481 +This method returns useful information only if 482 +the schema command waits for the reportcmd script to 483 +finish while recovering from a validation error. 484 +Otherwise it returns NONE. 485 +.PP 486 +If the command is called without the optional 487 +argument the possible return values and their 488 +meanings are: 489 +.TP 490 +NONE 491 +The schema command currently 492 +doesn't recover from a validation event. 493 +.TP 494 +MATCH_ELEMENT_START 495 +Element start event, which includes looking for missing or unknown attributes. 496 +.TP 497 +MATCH_ELEMENT_END 498 +Element end event. 499 +.TP 500 +MATCH_TEXT 501 +Validating text between tags. 502 +.TP 503 +MATCH_ATTRIBUTE_TEXT 504 +Attribute text value constraint check 505 +.TP 506 +MATCH_GLOBAL 507 +Checking global IDs 508 +.TP 509 +MATCH_DOM_KEYCONSTRAINT 510 +Checking domunique constraint 511 +.TP 512 +MATCH_DOM_XPATH_BOOLEAN 513 +Checking domxpathboolean constant 514 +.PP 515 +If called with one of the possible optional 516 +arguments the command returns detail information 517 +depending on current action. 518 +.TP 519 +name 520 +Return the name of the element 521 +that has to match in case of 522 +MATCH_ELEMENT_START. Return the name of the 523 +closed element in case of MATCH_ELEMENT_END. 524 +Returns the name of the attribute in case of 525 +MATCH_ATTRIBUTE_TEXT. Return the name of the 526 +parent element in case of MATCH_TEXT. 527 +.TP 528 +namespace 529 +Return the namespace of 530 +the element that has to match in case of 531 +MATCH_ELEMENT_START. Return the namespace of the 532 +closed element in case of MATCH_ELEMENT_END. 533 +Returns the namespace of the attribute in case 534 +of MATCH_ATTRIBUTE_TEXT. Return the namespace of 535 +the parent element in case of MATCH_TEXT. 536 +.TP 537 +text 538 +Return the text to match in 539 +case of MATCH_TEXT. Returns the value of the 540 +attribute in case of MATCH_ATTRIBUTE_TEXT. 541 +.RE 542 +.IP "\fBstack top|inside|associated\fR" 543 +In Tcl scripts evaluated by validation this method 544 +provides information about the current validation stack. 545 +Called outside this context the method returns the empty 546 +string. 547 +.RS 548 +.IP "\fBtop\fR" 549 +Returns the element which content is currently 550 +checked (the at the moment open element tag). 551 +.IP "\fBinside\fR" 552 +Returns all currently open elements as a list. 553 +.IP "\fBassociated\fR" 554 +Returns the data associated with the current top 555 +most stack content particle or the empty string it there isn't. 556 +.RE 557 +.RE 558 +.TP 559 +\&\fB\fBreset\fP 560 +\&\fRThis method resets the validation command into state 561 +READY (while preserving the defined grammar). 562 +.SH "Schema definition scripts" 563 +.PP 564 +Schema definition scripts are ordinary Tcl scripts that are 565 +evaluated in the namespace tdom::schema. The below listed schema 566 +definition commands in this tcl namespace allow to define a wide 567 +variety of document structures. Every schema definition command 568 +establish a validation constraint on the content which has to 569 +match or must be optional to qualify the content as valid. It is a 570 +validation error if there is additional (not matched) content. 571 +White space only text (in the XML sense of white space) between 572 +any different tags is ignored, with the exception of text only 573 +elements (for which even white space only text will be considered 574 +as significant content). 575 +.PP 576 +The schema definition commands are: 577 +.TP 578 +\&\fB\fBelement\fP \fIname\fB \fI?quant?\fB \fI?<definition script>?\fB 579 +\&\fRIf the optional argument \fIdefinition script\fR isn't 580 +given this command refers to the element defined with 581 +\&\fIdefelement\fR with the name \fIname\fR in the current 582 +context namespace. If the \fIdefelement script\fR argument is 583 +given, then the validation constraint expects an element with 584 +the name \fIname\fR in the current namespace with content 585 +"locally" defined by the \fIdefinition script\fR. Forward 586 +references to so far not defined elements or pattern or other 587 +local definitions of the same name inside the \fIdefinition 588 +script\fR are allowed. If a forward referenced element isn't 589 +defined until validation then only an empty element with name 590 +\&\fIname\fR and namespace \fInamespace\fR and no attributes 591 +matches. 592 +.TP 593 +\&\fB\fBelementtype\fP \fIname\fB \fI?quant?\fB 594 +\&\fRThis command refers to the element defined with 595 +\&\fIdefelementtype\fR with the type name \fIname\fR in the 596 +current context namespace. Forward references to a so far not 597 +defined element types or recursive references are allowed. If 598 +a forward referenced element type isn't defined until 599 +validation no content or attributes are expected. 600 +.TP 601 +\&\fB\fBref\fP \fIname\fB \fI?quant?\fB 602 +\&\fRThis command refers to the content particle defined with 603 +\&\fIdefpattern\fR with the name \fIname\fR in the current 604 +context namespace. Forward references to a so far not defined 605 +pattern or recursive references are allowed. If a forward 606 +referenced pattern isn't defined until validation no content 607 +whatsoever is expected ("empty match"). 608 +.TP 609 +\&\fB\fBgroup\fP \fI?quant?\fB \fI<definition script>\fB 610 +\&\fRThis method allows to group a sequence of content 611 +particle, defined by the \fIdefinition script>\fR, that have 612 +to match in this sequence order. 613 +.TP 614 +\&\fB\fBchoice\fP \fI?quant?\fB \fI<definition script>\fB 615 +\&\fRThis schema constraint match if one of the top level 616 +content particle defined by the \fIdefinition script>\fR 617 +match. If one of this top level content particle is optional 618 +this constraint matches the "empty match". 619 +.TP 620 +\&\fB\fBinterleave\fP \fI?quant?\fB \fI<definition script>\fB 621 +\&\fRThis schema constraint match after every of the top 622 +level content particle with quant must defined by the 623 +\&\fIdefinition script>\fR have matched in any arbitrary 624 +order. 625 +.TP 626 +\&\fB\fBmixed\fP \fI?quant?\fB \fI<definition script>\fB 627 +\&\fRThis schema constraint match for any text (including the 628 +empty one) and every top level content particle defined by the 629 +\&\fIdefinition script>\fR with default quantifier *. 630 +.TP 631 +\&\fB\fBtext\fP \fI?<constraint script>|\*(lqtype\*(lq typename?\fB 632 +\&\fRWithout the optional constraint script this validation 633 +constraint matches every string (including the empty one). 634 +With \fIconstraint script\fR or with a given text type 635 +argument a text matching this script or the text type is 636 +expected. 637 +.TP 638 +\&\fB\fBany\fP \fI?namespace?\fB \fI?quant?\fB 639 +\&\fRThe any command matches every element (in the namespace 640 +\&\fInamespace\fR, if that is given) (with whatever attributes) 641 +or subtree, no matter if known within the schema or not. 642 +Please notice, that in case of no \fInamespace\fR argument is 643 +given this mean the quantifier * and + will eat up any 644 +elements until the enclosing element ends. If you really have 645 +a namespace that looks like a valid tDOM schema quantifier 646 +you'll have to spell out always all two arguments. 647 +.TP 648 +\&\fB\fBattribute\fP \fIname\fB \fI?quant?\fB \fI(?<constraint script>|\*(lqtype\*(lq typename?)\fB 649 +\&\fRThe attribute command defines a attribute (in no 650 +namespace) to the enclosing element. The first definition of 651 +\&\fIname\fR inside an element definition wins; later 652 +definitions of the same name are silently ignored. After the 653 +\&\fIname\fR argument there may be one of the quantifiers ? or 654 +!. If there is, this will be used. Otherwise the attribute 655 +will be required (must be present in the XML source). If there 656 +is one argument more this argument is evaluated as constraint 657 +script, defining the value constrains of the attribute. 658 +Otherwise, if there are two more arguments and the first of 659 +them is the bare-word "type" then the following is used as a 660 +text type name. This command is only allowed at top level in 661 +the definition script of an defelement/element script. 662 +.TP 663 +\&\fB\fBnsattribute\fP \fIname\fB \fInamespace\fB \fI?quant?\fB \fI(?<constraint script>|\*(lqtype\*(lq typename?)\fB 664 +\&\fRThis command does the same as the command 665 +\&\fIattribute\fR, just for the attribute \fIname\fR in the 666 +namespace \fInamespace\fR. 667 +.TP 668 +\&\fB\fBnamespace\fP \fIURI\fB \fI<definition script>\fB 669 +\&\fREvaluates the \fIdefinition script\fR with context 670 +namespace \fIURI\fR. Every element, element type or ref 671 +command name will be looked up in the namespace \fIURI\fR and 672 +local defined element will be in that namespace. The empty 673 +string as \fIURI\fR means no namespace. 674 +.TP 675 +\&\fB\fBtcl\fP \fItclcmd\fB \fI?arg arg ...?\fB 676 +\&\fREvaluates the Tcl script \fItclcmd arg arg ... \fR. This 677 +validation command is only allowed in strict sequential 678 +context (not in choice, mixed and interleave). If the return 679 +code is something else than 0 (TCL_OK) then this is an 680 +error (which isn't catched and reported by reportcmd). 681 +.TP 682 +\&\fB\fBself\fP 683 +\&\fRReturns the schema command. 684 +.TP 685 +\&\fB\fBassociate\fP \fIdata\fB 686 +\&\fRThis command is only allowed top-level inside the 687 +definition scripts of the element, elementtype, pattern or 688 +interleave content particle. Associate the as argument given 689 +\&\fIdata\fR with the currently defined content particle and 690 +may be requested in scripts evaluated while validating the 691 +content of that particle with the schema command method call 692 +\&\fIinfo stack associated\fR. 693 +.TP 694 +\&\fB\fBdomunique\fP \fIselector\fB \fIfieldlist\fB \fI?name?\fB \fI?\*(lqIGNORE_EMPTY_FIELD_SET\*(lq|(\*(lqEMPTY_FIELD_SET_VALUE\*(lq emptyFieldSetValue)?\fB 695 +\&\fRIf not postvalidating a DOM tree with \fIdomvalidate\fR 696 +this constraint always match. If postvalidating this 697 +constraint resembles the xsd key/keyref mechanism. The 698 +\&\fIselector\fR argument may be any valid XPath expression 699 +(without the xsd limits). Several \fIdomunique\fR command 700 +within one element definition are allowed. They are checked in 701 +definition order. The argument name is available in the 702 +recovering script per \fIinfo vaction name\fR. If the 703 +\&\fIfieldlist\fR doesn't select something for a node of the 704 +result set of the \fIselector\fR then the key value will be 705 +the empty string, by default. If the arguments 706 +\&\fIEMPTY_FIELD_SET_VALUE <value>\fR are given a empty node 707 +set will have the key value \fIvalue\fR. If instead the flag 708 +\&\fIIGNORE_EMPTY_FIELD_SET\fR flag is given then an empty node 709 +set result will not have any key value. 710 +.TP 711 +\&\fB\fBdomxpathboolean\fP \fIXPath_expr\fB \fI?name?\fB 712 +\&\fR 713 +.RS 714 +.PP 715 +If not postvalidating a DOM tree with 716 +\&\fIdomvalidate\fR this constraint always match. If 717 +postvalidating this constraint matches if the result of the 718 +\&\fIXPath_expr\fR argument (with the node matching the schema 719 +parent of the \fIdomxpathboolean\fR command as context node) 720 +- converted to a boolean by XPath rules - is true. Several 721 +\&\fIdomxpathboolean\fR command within one element definition 722 +are allowed. They are checked in definition order. 723 +.PP 724 +This enables if-then checks depending on more than one element. Consider 725 + 726 + 727 + 728 +.CS 729 + 730 +tdom::schema s 731 +s define { 732 + defelement doc { 733 + element a ! text 734 + element b ! text 735 + element c ! text 736 + domxpathboolean "a * b * c >= 20000" volume 737 + domxpathboolean "a > b and b > c" sequence 738 + } 739 +} 740 + 741 +.CE 742 +.RE 743 +.TP 744 +\&\fB\fBprefixns\fP \fI?prefixUriList?\fB 745 +\&\fRThis defines a prefix to namespace URI mapping exactly 746 +as a \fIschemacmd prefixns\fR call. This is meant as top-level 747 +command of a \fIschemacmd define\fR script. This command is 748 +not allowed nested in an other definition script command and 749 +will raise error, if you call it there. 750 +.TP 751 +\&\fB\fBdefelement\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 752 +\&\fRThis defines an element exactly as a \fIschemacmd 753 +defelement\fR call. This is meant as top-level command of a 754 +\&\fIschemacmd define\fR script. This command is not allowed 755 +nested in an other definition script command and will raise 756 +error, if you call it there. 757 +.TP 758 +\&\fB\fBdefelementtype\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 759 +\&\fRThis defines an elementtype exactly as a \fIschemacmd 760 +defelementtype\fR call. This is meant as top-level command of a 761 +\&\fIschemacmd define\fR script. This command is not allowed 762 +nested in an other definition script command and will raise 763 +error, if you call it there. 764 +.TP 765 +\&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 766 +\&\fRThis defines a named pattern exactly as a \fIschemacmd 767 +defpattern\fR call. This is meant as top-level command of a 768 +\&\fIschemacmd define\fR script. This command is not allowed 769 +nested in an other definition script command and will raise 770 +error, if you call it there. 771 +.TP 772 +\&\fB\fBdeftexttype\fP \fIname\fB \fI<constraint script>\fB 773 +\&\fRThis defines a named bundle of text constraints exactly 774 +as a \fIschemacmd deftexttype\fR call. This is meant as top-level 775 +command of a \fIschemacmd define\fR script. This command is 776 +not allowed nested in an other definition script command and 777 +will raise error, if you call it there. 778 +.TP 779 +\&\fB\fBstart\fP \fIname\fB \fI?namespace?\fB 780 +\&\fRThis command works exactly as a \fIschemacmd start\fR 781 +call. This is meant as top-level command of a \fIschemacmd 782 +define\fR script. This command is not allowed nested in an 783 +other definition script command and will raise error, if you 784 +call it there. 785 +.SH "Quantity specifier" 786 +.PP 787 +Several schema definition commands expects a quantifier as 788 +one of their arguments, which specifies how often the content 789 +particle specified by the command is expected. The valid values 790 +for a \fIquant\fR argument are: 791 +.IP "\fB!\fR" 792 +The content particle must occur exactly once in valid 793 +documents. 794 +.IP "\fB?\fR" 795 +The content particle must occur at most once in valid 796 +documents. 797 +.IP "\fB*\fR" 798 +The content particle may occur zero or more times in a 799 +row in valid documents. 800 +.IP "\fB+\fR" 801 +The content particle may occur one or more times in a 802 +row in valid documents. 803 +.IP "\fBn\fR" 804 +The content particle must occur n times in a row in 805 +valid documents. The quantifier must be an integer greater 806 +zero. 807 +.IP "\fB{n m}\fR" 808 +The content particle must occur 809 +n to m times (both inclusive) in a row in valid documents. The 810 +quantifier must be a tcl list with two elements. Both elements 811 +must be integers, with n >= 0 and n < m. 812 +.PP 813 +If an optional quantifier is not given then it defaults to * in 814 +case of the \fImixed\fR command and to ! for all other commands. 815 +.SH "Text constraint scripts" 816 +.PP 817 +Text - parsed character data, as XML calls it - must sometimes 818 +be of a certain kind, must comply to some rules etc to be valid. 819 +The text constraint script arguments to the text, attribute, 820 +nsattribute and deftexttype commands are evaluated in the Tcl 821 +namespace \fItdom::schema::text\fR namespace and allow the 822 +following text constraint commands to check text for certain 823 +properties. The commands are defined in the Tcl namespace 824 +\&\fItdom::schema::text\fR. They raise error in case they are 825 +called outside of a text constraint script. 826 +.PP 827 +A few of the following text type commands are exposed as 828 +general Tcl commands. They are defined in the namespace tdom::type 829 +and are called as documented below with the text to check appended 830 +to the argument list. They return a logical value. Please note, 831 +that the commands may not accept starting or ending white space. It 832 +is noted with the command documentation, if the command is 833 +available in the tdom::type namespace. 834 +.SS "The tcl text constraint command" 835 +.PP 836 +The \fItcl\fR text constraint command dispatches the check 837 +to an arbitrary Tcl command, thus enable any programmable 838 +decision rules. 839 +.TP 840 +\&\fB\fBtcl\fP \fItclcmd\fB \fI?arg arg ...?\fB 841 +\&\fREvaluates the tcl script \fItclcmd arg arg ... \fR and 842 +the text to validate appended to the argument list. The return 843 +value of the tcl command is interpreted as a boolean. 844 +.SS "Basic XML types" 845 +.TP 846 +\&\fB\fBname\fP 847 +.UR "https://www.w3.org/TR/xml/#NT-Name" 848 +<URL: https://www.w3.org/TR/xml/#NT-Name> 849 +.UE 850 +\&\fRThis text constraint match if the text value match the 851 +XML name production 852 +\&. This means the 853 +text value must start with a letter, underscore (_), or colon (:), 854 +and may contain only letters, digits, underscores (_), colons 855 +(:), hyphens (-), and periods (.). 856 +.TP 857 +\&\fB\fBncname\fP 858 +.UR "https://www.w3.org/TR/xml-names/#NT-NCName" 859 +<URL: https://www.w3.org/TR/xml-names/#NT-NCName> 860 +.UE 861 +\&\fRThis text constraint match if the text value match the 862 +XML ncname production 863 +\&. This 864 +means the text value must start with a letter or underscore (_), 865 +and may contain only letters, digits, underscores (_), hyphens 866 +(-), and periods (.) (The only difference to the name 867 +constraint is that colons are not permitted.) 868 +.TP 869 +\&\fB\fBqname\fP 870 +.UR "https://www.w3.org/TR/xml-names/#NT-QName" 871 +<URL: https://www.w3.org/TR/xml-names/#NT-QName> 872 +.UE 873 +\&\fRThis text constraint match if the text value match the 874 +XML qname production 875 +\&. This 876 +means the text value is either a ncname or two ncnames joined 877 +by a colon (:). 878 +.TP 879 +\&\fB\fBnmtoken\fP 880 +.UR "https://www.w3.org/TR/xml/#NT-Nmtoken" 881 +<URL: https://www.w3.org/TR/xml/#NT-Nmtoken> 882 +.UE 883 +\&\fRThis text constraint match if the text value match the 884 +XML nmtoken production 885 +.TP 886 +\&\fB\fBnmtokens\fP 887 +.UR "https://www.w3.org/TR/xml/#NT-Nmtokens" 888 +<URL: https://www.w3.org/TR/xml/#NT-Nmtokens> 889 +.UE 890 +\&\fRThis text constraint match if the text value match the 891 +XML nmtokens production 892 +.SS "Basic type tests" 893 +.PP 894 +.TP 895 +\&\fB\fBinteger\fP \fI?(xsd|tcl)?\fB 896 +\&\fRThis text constraint match if the text value could be 897 +parsed as an integer. If the optional argument to the command 898 +is \fItcl\fR everything that returns TCL_OK if feeded into 899 +Tcl_GetInt() matches. If the optional argument to the command 900 +is \fIxsd\fR then the constraint match if the value is a 901 +valid xsd:integer. Without argument \fIxsd\fR is the 902 +default. 903 +.TP 904 +\&\fB\fBnegativeInteger\fP \fI?(xsd|tcl)?\fB 905 +\&\fRThis text constraint match the same text values as the 906 +\&\fIinteger\fR text constraint (see there) with the additional 907 +constraint that the value must be < zero. 908 +.TP 909 +\&\fB\fBnonNegativeInteger\fP \fI?(xsd|tcl)?\fB 910 +\&\fRThis text constraint match the same text values as the 911 +\&\fIinteger\fR text constraint (see there) with the additional 912 +constraint that the value must be >= zero. 913 +.TP 914 +\&\fB\fBnonPositiveInteger\fP \fI?(xsd|tcl)?\fB 915 +\&\fRThis text constraint match the same text values as the 916 +\&\fIinteger\fR text constraint (see there) with the additional 917 +constraint that the value must be <= zero. 918 +.TP 919 +\&\fB\fBpositiveInteger\fP \fI?(xsd|tcl)?\fB 920 +\&\fRThis text constraint match the same text values as the 921 +\&\fIinteger\fR text constraint (see there) with the additional 922 +constraint that the value must be > zero. 923 +.TP 924 +\&\fB\fBnumber\fP \fI?(xsd|tcl)?\fB 925 +\&\fRThis text constraint match if the text value could be 926 +parsed as a number. If the optional argument to the command is 927 +\&\fItcl\fR everything that returns TCL_OK if feeded into 928 +Tcl_GetDouble() matches. If the optional argument to the command 929 +is \fIxsd\fR then the constraint match if the value is a 930 +valid xsd:decimal. Without argument \fIxsd\fR is the 931 +default. 932 +.TP 933 +\&\fB\fBboolean\fP \fI?(xsd|tcl)?\fB 934 +\&\fRThis text constraint match if the text value could be 935 +parsed as a boolean. If the optional argument to the command is 936 +\&\fItcl\fR everything that returns TCL_OK if feeded into 937 +Tcl_GetBoolean() matches. If the optional argument to the command 938 +is \fIxsd\fR then the constraint match if the value is a 939 +valid xsd:boolean. Without argument \fIxsd\fR is the 940 +default. 941 +.TP 942 +\&\fB\fBdate\fP 943 +\&\fRThis text constraint match if the text value is 944 +a xsd:date. This is basically like an ISO 8601 date of 945 +the form YYYY-MM-DD, with optional time zone part 946 +(either the letter Z or plus (+) or minus (-) followed 947 +by hh:mm and with maximum allowed positive or negative 948 +time zone 14:00). It follows the date rules of the 949 +Gregorian calendar for all dates. A preceding minus 950 +sign for bce dates is allowed. There is no year 0. The 951 +year may have more than 4 digits, but only if needed 952 +(no extra leading zeros). This is available as common 953 +tcl command tdom::type::date. 954 +.TP 955 +\&\fB\fBtime\fP 956 +\&\fRThis text constraint match if the text value is 957 +a xsd:time. This is basically like an ISO 8601 time of 958 +the form hh:mm:ss with optional time zone part. The 959 +time zone part follow the rules of the \fIdate\fR 960 +command; see there. All three parts of the time value 961 +(hours, minutes, seconds) must be spelled out with 2 962 +digits. Additional fractional seconds (with a point 963 +('.') as separator) are allowed, but not just a 964 +dangling point. The time value 24:00:00 (without 965 +fractional part) is allowed. This is available as 966 +common tcl command tdom::type::time. 967 +.TP 968 +\&\fB\fBdateTime\fP 969 +\&\fRThis text constraint match if the text value is 970 +a xsd:dateTime. This is basically like an ISO 8601 971 +date time of the form YYYY-MM-DDThh:mm:ss with 972 +optional time zone part. The date and time zone parts 973 +follow the rules of the \fIdate\fR command; see 974 +there. The time part (including the signaling 'T' 975 +character) is mandatory and follow the rules of the 976 +\&\fItime\fR command, see there. This is available as 977 +common tcl command tdom::type::dateTime. 978 +.TP 979 +\&\fB\fBduration\fP 980 +\&\fRThis text constraint match if the text value is 981 +a xsd:duration. This is basically like an ISO 8601 982 +duration of the form PnYnMnDTnHnMnS. All parts other 983 +then the starting P and - if one of H, M or S is given 984 +- T are optional. In case the following sign letter is 985 +S n may be a decimal (with at least one digit before 986 +and after the dot), otherwise it must be a (positive) 987 +integer. This is available as common tcl command 988 +tdom::type::duration. 989 +.TP 990 +\&\fB\fBbase64\fP 991 +\&\fRThis text constraint match if text is valid according to 992 +RFC 4648. 993 +.TP 994 +\&\fB\fBhexBinary\fP 995 +\&\fRThis text constraint match if text is a sequence of 996 +binary octets in hexadecimal encoding, where each binary octet 997 +is a two-character hexadecimal number. Lowercase and uppercase 998 +letters A through F are permitted. 999 +.TP 1000 +\&\fB\fBunsignedByte\fP 1001 +\&\fRThis text constraint match if the text value is a 1002 +xsd:unsignedByte. This is an integer between 0 and 255, both 1003 +included, optionally preceded by a + sign and leading 1004 +zeros. 1005 +.TP 1006 +\&\fB\fBunsignedShort\fP 1007 +\&\fRThis text constraint match if the text value is a 1008 +xsd:unsignedShort. This is an integer between 0 and 65535, 1009 +both included, optionally preceded by a + sign and leading 1010 +zeros. 1011 +.TP 1012 +\&\fB\fBunsignedInt\fP 1013 +\&\fRThis text constraint match if the text value is a 1014 +xsd:unsignedInt. This is an integer between 0 and 4294967295, 1015 +both included, optionally preceded by a + sign and leading 1016 +zeros. 1017 +.TP 1018 +\&\fB\fBunsignedLong\fP 1019 +\&\fRThis text constraint match if the text value is a 1020 +xsd:unsignedLong. This is an integer between 0 and 1021 +18446744073709551615, both included, optionally preceded by a 1022 ++ sign and leading zeros. 1023 +.SS "Logical constructs" 1024 +.TP 1025 +\&\fB\fBoneOf\fP \fI<constraint script>\fB 1026 +\&\fRThis text constraint match if one of the text 1027 +constraints defined in the argument \fIconstraint script\fR 1028 +match the text. It stops after the first match and probes the 1029 +text constraints in the order of definition. 1030 +.TP 1031 +\&\fB\fBallOf\fP \fI<constraint script>\fB 1032 +\&\fRThis text constraint match if all of the text 1033 +constraints defined in the argument \fIconstraint script\fR 1034 +match the text. It stops after the first match failure and 1035 +probes the text constraints in the order of definition. Since 1036 +the schema definition command \fItext\fR also expects all 1037 +text constraints to match the text constraint \fIallOf\fR is 1038 +useful mostly together with the \fIoneOf\fR text constraint 1039 +command. 1040 +.TP 1041 +\&\fB\fBnot\fP \fI<constraint script>\fB 1042 +\&\fRThis text constraint match if none of the text 1043 +constraints defined in the argument \fIconstraint 1044 +script\fR match the text. It stops after the first 1045 +matching constraint in the \fIconstraint script\fR and 1046 +reports validation error. The text constraints in the 1047 +\&\fIconstraint script\fR are probed in the order of 1048 +definition. 1049 +.SS "Constraints on processed text value" 1050 +.TP 1051 +\&\fB\fBwhitespace\fP \fI(preserve|replace|collapse)\fB \fI<constraint script>\fB 1052 +\&\fRThis text constraint command does white-space (#x20 1053 +(space, ' '), #x9 (tab, \et), #xA (linefeed, \en), and #xD 1054 +(carriage return, \er) normalization to the text value and 1055 +checks the resulting text with the text constraints of the 1056 +constraint script argument. The normalization method 1057 +\&\fIpreserve\fR keeps everything as it is; this is another way 1058 +to say \fIallOf\fR. The \fIreplace\fR normalization method 1059 +replaces any single white-space character (as above) to a 1060 +space. The \fIcollapse\fR normalization method removes all 1061 +leading and trailing white-space and all the other sequences of 1062 +contiguous white-space are replaced by a single space. 1063 +.TP 1064 +\&\fB\fBsplit\fP \fI?type ?args??\fB\fI<constraint script>\fB 1065 +\&\fR 1066 +.RS 1067 +.PP 1068 +This text constraint command splits the text to test 1069 +into a list of values and tests all elements of that list for 1070 +the text constraints in the evaluated \fIconstraint 1071 +script>\fR. 1072 +.PP 1073 +The available types are: 1074 +.TP 1075 +whitespace 1076 +The text to split is striped of all 1077 +white space at start and end splited into a list at any 1078 +successive white space. 1079 +.TP 1080 +tcl tclcmd ?arg ...? 1081 +The text to split is 1082 +handed to the \fItclcmd\fR, which is evaluated on global 1083 +level, appended with every given arg and the text to split 1084 +as last argument. This call must return a valid tcl list, 1085 +which elements are tested. 1086 +.PP 1087 +The default in case no split type argument is given is 1088 +\&\fIwhitespace\fR. 1089 +.RE 1090 +.TP 1091 +\&\fB\fBstrip\fP \fI<constraint script>\fB 1092 +\&\fRThis text constraint command tests all text constraints 1093 +in the evaluated \fIconstraint script>\fR with the text to 1094 +test striped of all white space at start and end. 1095 +.SS "Various other string properties" 1096 +.TP 1097 +\&\fB\fBfixed\fP \fIvalue\fB 1098 +\&\fRThe text constraint only match if the text value is 1099 +string equal to the given value. 1100 +.TP 1101 +\&\fB\fBenumeration\fP \fIlist\fB 1102 +\&\fRThis text constraint match if the text value is equal to 1103 +one element (respecting case and any white-space) of the 1104 +argument \fIlist\fR, which has to be a valid Tcl list. 1105 +.TP 1106 +\&\fB\fBmatch\fP \fI?-nocase?\fB \fIglob_style_match_pattern>\fB 1107 +.UR "https://www.tcl.tk/man/tcl8.6/TclCmd/string.htm#M35" 1108 +<URL: https://www.tcl.tk/man/tcl8.6/TclCmd/string.htm#M35> 1109 +.UE 1110 +\&\fRThis text constraint match if the text value match the 1111 +glob style pattern given as argument. It follows the rules of 1112 +the Tcl [string match] command, see 1113 +\&. 1114 +.TP 1115 +\&\fB\fBregexp\fP \fIexpression\fB 1116 +.UR "https://www.tcl.tk/man/tcl8.6/TclCmd/re_syntax.htm" 1117 +<URL: https://www.tcl.tk/man/tcl8.6/TclCmd/re_syntax.htm> 1118 +.UE 1119 +\&\fRThis text constraint match if the text value match the 1120 +regular expression given as argument. describes the regular expression syntax 1121 +.TP 1122 +\&\fB\fBlength\fP \fIlength\fB 1123 +\&\fRThis text constraint match if the length of the text 1124 +value (in characters, not bytes) is \fIlength\fR. The 1125 +length argument must be a positive integer or zero. 1126 +.TP 1127 +\&\fB\fBmaxLength\fP \fIlength\fB 1128 +\&\fRThis text constraint match if the length of the text 1129 +value (in characters, not bytes) is at most \fIlength\fR. The 1130 +length argument must be an integer greater zero. 1131 +.TP 1132 +\&\fB\fBminLength\fP \fIlength\fB 1133 +\&\fRThis text constraint match if the length of the text 1134 +value (in characters, not bytes) is at least \fIlength\fR. 1135 +The length argument must be an integer greater zero. 1136 +.TP 1137 +\&\fB\fBid\fP \fI?keySpace?\fB 1138 +\&\fRThis text constraint command marks the text as a 1139 +document wide ID (to be referenced by an idref). Every ID 1140 +value within a document must be unique. It isn't an error if 1141 +the ID isn't actually referenced within the document. The 1142 +optional argument \fIkeySpace\fR does all this for a named 1143 +key space. The key space "" (the empty sting) is another key 1144 +space as the \fIid\fR command without keySpace 1145 +argument. 1146 +.TP 1147 +\&\fB\fBidref\fP \fI?keySpace?\fB 1148 +\&\fRThis text constraint command expects the text to be a 1149 +reference to an ID within the document. The referenced ID may 1150 +be later in the document, that the reference. Several 1151 +references within the document to one ID are possible. 1152 +.SH "Local key constraints" 1153 +.PP 1154 +Document wide uniqueness and foreign key constraints are 1155 +available with the text constraint commands id and idref. 1156 +Keyspaces allow for sub-tree local uniqueness and foreign key 1157 +constraints. 1158 +.TP 1159 +\&\fB\fBkeyspace\fP \fI<names list>\fB \fI<constraint script>\fB 1160 +\&\fRAny number of keyspaces are possible. A keyspace is 1161 +either active or not. An inside a \fIconstraint 1162 +script\fR called keyspace with the same name does 1163 +nothing. 1164 +.PP 1165 +This text constraint commands work with keyspaces: 1166 +.TP 1167 +\&\fB\fBkey\fP \fI<name>\fB 1168 +\&\fRIf the keyspace with the name \fI<name>\fR is not 1169 +active always matches. If the keyspace is active then 1170 +reports error if there is already a key with the value. 1171 +Otherwise, stores the value as key in this keyspace and 1172 +matches. 1173 +.TP 1174 +\&\fB\fBkeyref\fP \fI<name>\fB 1175 +\&\fRIf the keyspace with the name \fI<name>\fR is not 1176 +active always matches. If the keyspace is active then 1177 +reports error if there is still no key as the value at the 1178 +end of the keyspace \fI<name>\fR. Otherwise it 1179 +matches. 1180 +.SH Recovering 1181 +.PP 1182 +By default the validation engine stops at the first detected 1183 +validation violation and report that finding. It does so by 1184 +return false (and set, if given, the result variable with an 1185 +error message) in case the schema command itself is used to 1186 +validate input. If the schema command is used by a SAX parser or 1187 +the DOM parser it does so by throwing error. 1188 +.PP 1189 +If a \fIreportcmd\fR is set this command is called on global 1190 +level appended with the schema command and an error type as 1191 +arguments if a validation violation is detected. Then the 1192 +validation recovers from the error and continues. For some 1193 +validation errors the recover strategy can be determined with 1194 +the script result of the reportcmd. 1195 +.PP 1196 +With a \fIreportcmd\fR (which doesen&t throw error if 1197 +called) the validation engine will never report validation 1198 +failure to its caller. The validation engine recovers, continues 1199 +and report the next error, if one happen and so until the end of 1200 +the input. The schema command will return true and the SAX 1201 +parser and DOM builder will process normally until the end of 1202 +the input, as if there would not have been validation. 1203 +.PP 1204 +Please note, that this happens only for validation errors. It 1205 +isn't possible to recover from well-formedness errors. If the 1206 +input isn't well-formed the schema command returns false and 1207 +set, if given, the result variable with an error message about 1208 +the well-formedness error. 1209 +.PP 1210 +If the \fIreportcmd\fR throws error while called by the 1211 +validation engine then validation stops and the schema command 1212 +throws error with the error message of the script. 1213 +.SH Examples 1214 +.PP 1215 +.UR "https://www.w3.org/TR/xmlschema-0/" 1216 +<URL: https://www.w3.org/TR/xmlschema-0/> 1217 +.UE 1218 +The XML Schema Part 0: Primer Second Edition 1219 +() starts with this 1220 +example schema: 1221 +.CS 1222 + 1223 +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1224 + 1225 + <xsd:annotation> 1226 + <xsd:documentation xml:lang="en"> 1227 + Purchase order schema for Example.com. 1228 + Copyright 2000 Example.com. All rights reserved. 1229 + </xsd:documentation> 1230 + </xsd:annotation> 1231 + 1232 + <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> 1233 + 1234 + <xsd:element name="comment" type="xsd:string"/> 1235 + 1236 + <xsd:complexType name="PurchaseOrderType"> 1237 + <xsd:sequence> 1238 + <xsd:element name="shipTo" type="USAddress"/> 1239 + <xsd:element name="billTo" type="USAddress"/> 1240 + <xsd:element ref="comment" minOccurs="0"/> 1241 + <xsd:element name="items" type="Items"/> 1242 + </xsd:sequence> 1243 + <xsd:attribute name="orderDate" type="xsd:date"/> 1244 + </xsd:complexType> 1245 + 1246 + <xsd:complexType name="USAddress"> 1247 + <xsd:sequence> 1248 + <xsd:element name="name" type="xsd:string"/> 1249 + <xsd:element name="street" type="xsd:string"/> 1250 + <xsd:element name="city" type="xsd:string"/> 1251 + <xsd:element name="state" type="xsd:string"/> 1252 + <xsd:element name="zip" type="xsd:decimal"/> 1253 + </xsd:sequence> 1254 + <xsd:attribute name="country" type="xsd:NMTOKEN" 1255 + fixed="US"/> 1256 + </xsd:complexType> 1257 + 1258 + <xsd:complexType name="Items"> 1259 + <xsd:sequence> 1260 + <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> 1261 + <xsd:complexType> 1262 + <xsd:sequence> 1263 + <xsd:element name="productName" type="xsd:string"/> 1264 + <xsd:element name="quantity"> 1265 + <xsd:simpleType> 1266 + <xsd:restriction base="xsd:positiveInteger"> 1267 + <xsd:maxExclusive value="100"/> 1268 + </xsd:restriction> 1269 + </xsd:simpleType> 1270 + </xsd:element> 1271 + <xsd:element name="USPrice" type="xsd:decimal"/> 1272 + <xsd:element ref="comment" minOccurs="0"/> 1273 + <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> 1274 + </xsd:sequence> 1275 + <xsd:attribute name="partNum" type="SKU" use="required"/> 1276 + </xsd:complexType> 1277 + </xsd:element> 1278 + </xsd:sequence> 1279 + </xsd:complexType> 1280 + 1281 + <!-- Stock Keeping Unit, a code for identifying products --> 1282 + <xsd:simpleType name="SKU"> 1283 + <xsd:restriction base="xsd:string"> 1284 + <xsd:pattern value="\ed{3}-[A-Z]{2}"/> 1285 + </xsd:restriction> 1286 + </xsd:simpleType> 1287 + 1288 +</xsd:schema> 1289 + 1290 +.CE 1291 +.PP 1292 +A somewhat one-to-one translation of that into a tDOM schema 1293 +definition script would be: 1294 +.CS 1295 + 1296 +tdom::schema schema 1297 +schema define { 1298 + 1299 + # Purchase order schema for Example.com. 1300 + # Copyright 2000 Example.com. All rights reserved. 1301 + 1302 + defelement purchaseOrder {ref PurchaseOrderType} 1303 + 1304 + foreach elm {comment name street city state product} { 1305 + defelement $elm text 1306 + } 1307 + 1308 + defpattern PurchaseOrderType { 1309 + element shipTo ! {ref USAddress} 1310 + element billTo ! {ref USAddress} 1311 + element comment ? 1312 + element items 1313 + attribute orderDate date 1314 + } 1315 + 1316 + defpattern USAddress { 1317 + element name 1318 + element street 1319 + element city 1320 + element state 1321 + element zip ! {text number} 1322 + attribute country ! {fixed "US"} 1323 + } 1324 + 1325 + defelement items { 1326 + element item * { 1327 + element product 1328 + element quantity ! {text integer} 1329 + element USPrice ! {text number} 1330 + element comment 1331 + element shipDate ? {text date} 1332 + attribute partNum ! {pattern "^\ed{3}-[A-Z]{2}$"} 1333 + } 1334 + } 1335 +} 1336 + 1337 + 1338 +.CE 1339 +.PP 1340 +.UR "http://relaxng.org/tutorial-20011203.html" 1341 +<URL: http://relaxng.org/tutorial-20011203.html> 1342 +.UE 1343 +The RELAX NG Tutorial 1344 +() starts with 1345 +this example: 1346 +.CS 1347 + 1348 +Consider a simple XML representation of an email address book: 1349 + 1350 +<addressBook> 1351 + <card> 1352 + <name>John Smith</name> 1353 + <email>js@example.com</email> 1354 + </card> 1355 + <card> 1356 + <name>Fred Bloggs</name> 1357 + <email>fb@example.net</email> 1358 + </card> 1359 +</addressBook> 1360 + 1361 +The DTD would be as follows: 1362 + 1363 +<!DOCTYPE addressBook [ 1364 +<!ELEMENT addressBook (card*)> 1365 +<!ELEMENT card (name, email)> 1366 +<!ELEMENT name (#PCDATA)> 1367 +<!ELEMENT email (#PCDATA)> 1368 +]> 1369 + 1370 +A RELAX NG pattern for this could be written as follows: 1371 + 1372 +<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> 1373 + <zeroOrMore> 1374 + <element name="card"> 1375 + <element name="name"> 1376 + <text/> 1377 + </element> 1378 + <element name="email"> 1379 + <text/> 1380 + </element> 1381 + </element> 1382 + </zeroOrMore> 1383 +</element> 1384 + 1385 + 1386 +.CE 1387 +.PP 1388 +This schema definition script will do the same: 1389 +.CS 1390 + 1391 +tdom::schema schema 1392 +schema define { 1393 + defelement addressBook { 1394 + element card * 1395 + } 1396 + defelement card { 1397 + element name 1398 + element email 1399 + } 1400 + foreach e {name email} { 1401 + defelement $e {text} 1402 + } 1403 +} 1404 + 1405 + 1406 +.CE 1407 +.SH KEYWORDS 1408 +Validation, Postvalidation, DOM, SAX
Added doc/schema.xml.
1 +<?xml version="1.0" encoding="utf-8"?> 2 +<manpage id="schema" cat="schema" title="schema"> 3 + <namesection> 4 + <name>tdom::schema</name> 5 + <desc>Create a schema validation command</desc> 6 + </namesection> 7 + 8 + <synopsis> 9 + <syntax>package require tdom 10 + 11 +<cmd>tdom::schema</cmd> <m>?create?</m> <m>cmdName</m> 12 + </syntax> 13 + </synopsis> 14 + 15 + <section> 16 + <title>DESCRIPTION </title> 17 + 18 + <p>Every call of this command creates a new validation command. A 19 + validation command has methods to define a schema and is able 20 + to validate XML data or to post-validate a tDOM DOM tree (and to 21 + some degree other kind of hierarchical data) against this 22 + schema.</p> 23 + 24 + <p>Additionally, a validation command may be used as argument to 25 + the <m>-validateCmd</m> option of the <m>dom parse</m> and the 26 + <m>expat</m> commands to enable validation additional to what they 27 + do otherwise.</p> 28 + 29 + <p>The methods of created commands are:</p> 30 + 31 + <commandlist> 32 + <commanddef> 33 + <command><method>prefixns</method> <m>?prefixUriList?</m></command> 34 + <desc>This method gives control to a prefix (or 35 + abbreviation) to namespace URI mapping. Wherever a namespace 36 + argument is expected in the schema command methods you may 37 + use the "prefix" pointing to the namespace URI in 38 + the current prefixUriList, set by this method. If the list 39 + maps the same prefix to different namespace URIs, the first 40 + one win. If there is no such a prefix the namespace argument 41 + is used literally as namespace URI. If the method is called 42 + without argument it returns the current prefixUriList. If 43 + the method is called with the empty string any namespace URI 44 + arguments are used literally. This is the default. 45 + </desc> 46 + </commanddef> 47 + 48 + <commanddef> 49 + <command><method>defelement</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 50 + <desc>This method defines the element <m>name</m> (optional in 51 + the namespace <m>namespace</m>) in the schema. The 52 + <m>definition script</m> is evaluated and defines the content 53 + model of the element. If the <m>namespace</m> argument is 54 + given, any <m>element</m> or <m>ref</m> references in the 55 + definition script not wrapped inside a <m>namespace</m> 56 + command are resolved in that namespace. If there is already a 57 + element definition for the name/namespace combination the 58 + command raises error.</desc> 59 + </commanddef> 60 + 61 + <commanddef> 62 + <command><method>defelementtype</method> <m>typename</m> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 63 + <desc>This method defines the element type <m>typename</m> 64 + (optional in the namespace <m>namespace</m>) in the schema. If 65 + the element type is used in a definition script with the 66 + schema command elementtype, the validation engine expects an 67 + element named <m>name</m> (in the namespace <m>namespace</m>, 68 + if given) and the content model <m>definition script</m>. 69 + Defining element types seems only sensible if you really have 70 + elements with the same name and namespace but different 71 + content models. The <m>definition script</m> is evaluated and 72 + defines the content model of the element. If the 73 + <m>namespace</m> argument is given, any <m>element</m> or 74 + <m>ref</m> references in the definition script not wrapped 75 + inside a <m>namespace</m> command are resolved in that 76 + namespace. If there is already a elementtype definition for 77 + the name/namespace combination the command raises error. The 78 + document element of any XML to validate cannot be a 79 + <m>defelementtype</m> defined element.</desc> 80 + </commanddef> 81 + 82 + <commanddef> 83 + <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 84 + <desc>This method defines a (maybe complex) content particle 85 + with the <m>name</m> (optional in the namespace 86 + <m>namespace</m>) in the schema, to be used in other 87 + definition scripts with the definition command <m>ref</m>. The 88 + <m>definition script</m> is evaluated and defines the content 89 + model of the content particle. If the <m>namespace</m> 90 + argument is given, any <m>element</m> or <m>ref</m> references 91 + in the definition script not wrapped inside a <m>namespace</m> 92 + command are resolved in that namespace. If there is already a 93 + pattern definition for the name/namespace combination the 94 + command raises error.</desc> 95 + </commanddef> 96 + 97 + <commanddef> 98 + <command><method>deftexttype</method> <m>name</m> <m><constraint script></m></command> 99 + <desc>This method defines a bundle of text constraints that 100 + can be referred to by <m>name</m> while defining constrains on 101 + text element or attribute values. If there is already a text 102 + type definition with this name, the command raises error. A 103 + text type must be defined before it can be used in schema 104 + definition scripts.</desc> 105 + </commanddef> 106 + 107 + <commanddef> 108 + <command><method>start</method> <m>documentElement</m> <m>?namespace?</m></command> 109 + <desc>This method defines the name and namespace of the root 110 + element of a tree to validate. If this method is used, then 111 + the root element must match for validity. If <m>start</m> is 112 + not used, any element defined by <m>defelement</m> may be the 113 + root of a valid document. The <m>start</m> method may be used 114 + several times with varying arguments during the lifetime of a 115 + validation command. If the command is called with just the 116 + empty string (and no namespace argument), the validation 117 + constraint for the root element is removed and any defined 118 + element will be valid as root of a tree to validate.</desc> 119 + </commanddef> 120 + 121 + <commanddef> 122 + <command><method>define</method> <m><definition script></m></command> 123 + <desc>This method allows to define several elements or pattern 124 + or a whole schema with one call. All schema command methods so 125 + far (<m>prefixns</m>, <m>defelement</m>, 126 + <m>defelementtype</m>, <m>defpattern</m>, <m>deftexttype</m> and 127 + <m>start</m>) are allowed top level in the <m>definition 128 + script</m>. The <m>define</m> method itself isn't allowed 129 + recursively.</desc> 130 + </commanddef> 131 + 132 + <commanddef> 133 + <command><method>event</method> <m>(start|end|text)</m> <m>?event specific data?</m></command> 134 + <desc>This method allows to validate hierarchical data against 135 + the content constrains of the validation command. 136 + 137 + <optlist> 138 + <optdef> 139 + <optname>start</optname> 140 + <optarg>name ?attributes? ?namespace? </optarg> 141 + <desc>Checks if the current validation state allows the 142 + element <m>name</m> in the <m>namespace</m> to start here. 143 + It raises error if not.</desc> 144 + </optdef> 145 + 146 + <optdef> 147 + <optname>end</optname> 148 + <desc>Checks if the current innermost open element may end 149 + here in the current state without violation of validation 150 + constrains. It raises error if not.</desc> 151 + </optdef> 152 + 153 + <optdef> 154 + <optname>text</optname> 155 + <optarg>text</optarg> 156 + <desc>Checks if the current validation state allows the 157 + given text content. It raises error if not.</desc> 158 + </optdef> 159 + </optlist> 160 + </desc> 161 + </commanddef> 162 + 163 + <commanddef> 164 + <command><method>validate</method> <m><XML string></m> <m>?objVar?</m></command> 165 + <desc>Returns true if the <m><XML string></m> is valid or 166 + false otherwise. If validation has failed and the optional 167 + <m>objVar</m> argument is given, the variable with that 168 + name is set to a validation error message. If the XML string 169 + is valid and the optional <m>objVar</m> argument is given, 170 + the variable with that name is set to the empty string.</desc> 171 + </commanddef> 172 + 173 + <commanddef> 174 + <command><method>validatefile</method> <m>filename</m> <m>?objVar?</m></command> 175 + <desc>Returns true if the content of <m>filename</m> is valid 176 + or false otherwise. The given file is feeded as binary stream 177 + to expat, therefore only US-ASCII, ISO-8859-1, UTF-8 or UTF-16 178 + encoded data will work with this method. If validation failed 179 + and the optional <m>objVar</m> argument is given, the variable 180 + with that name is set to a validation error message. If the 181 + XML string is valid and the optional <m>objVar</m> argument is 182 + given, the variable with that name is set to the empty 183 + string.</desc> 184 + </commanddef> 185 + 186 + <commanddef> 187 + <command><method>validatechannel</method> <m>channel</m> <m>?objVar?</m></command> 188 + <desc>Returns true if the content read from the Tcl channel 189 + <m>channel</m> is valid or false otherwise. Since data read 190 + out of a Tcl channel is UTF-8 encoded, any misleading encoding 191 + declaration at the beginning of the data will lead to errors. 192 + If the validation fails and the optional <m>objVar</m> 193 + argument is given, the variable with that name is set to a 194 + validation error message. If the XML string is valid and the 195 + optional <m>objVar</m> argument is given, the variable with 196 + that name is set to the empty string.</desc> 197 + </commanddef> 198 + 199 + <commanddef> 200 + <command><method>domvalidate</method> <m>domNode</m> <m>?objVar?</m></command> 201 + <desc>Returns true if the first argument is a valid tree or 202 + false otherwise. If validation failed and the optional 203 + <m>objVar</m> argument is given, the variable with that name 204 + is set to a validation error message. If the dom tree is valid 205 + and the optional <m>objVar</m> argument is given, the variable 206 + with that name is set to the empty string. </desc> 207 + </commanddef> 208 + 209 + <commanddef> 210 + <command><method>reportcmd</method> <m>?cmd?</m></command> 211 + <desc>This method expects the name of a Tcl command to be 212 + called in case of validation error. This command will be 213 + called with two arguments appended: the schema command which 214 + raises the validation error, and a validation error code. 215 + 216 + <p>The possible error codes are:</p> 217 + <dl> 218 + <dt>MISSING_ELEMENT</dt><dd></dd> 219 + <dt>MISSING_TEXT</dt><dd></dd> 220 + <dt>UNEXPECTED_ELEMENT</dt><dd></dd> 221 + <dt>UNEXPECTED_ROOT_ELEMENT</dt><dd></dd> 222 + <dt>UNEXPECTED_TEXT</dt><dd></dd> 223 + <dt>UNKNOWN_ROOT_ELEMENT</dt><dd></dd> 224 + <dt>UNKNOWN_ATTRIBUTE</dt><dd></dd> 225 + <dt>MISSING_ATTRIBUTE</dt><dd></dd> 226 + <dt>INVALID_ATTRIBUTE_VALUE</dt><dd></dd> 227 + <dt>DOM_KEYCONSTRAINT</dt><dd></dd> 228 + <dt>DOM_XPATH_BOOLEAN</dt><dd></dd> 229 + <dt>INVALID_KEYREF</dt><dd></dd> 230 + <dt>INVALID_VALUE</dt><dd></dd> 231 + <dt>UNKOWN_GLOBAL_ID</dt><dd></dd> 232 + <dt>UNKOWN_ID</dt><dd></dd> 233 + </dl> 234 + <p> For more detailed information see section <ref 235 + refid="recovering">Recovering</ref>.</p> 236 + </desc> 237 + </commanddef> 238 + 239 + <commanddef> 240 + <command><method>delete</method></command> 241 + <desc>This method deletes the validation command.</desc> 242 + </commanddef> 243 + 244 + <commanddef> 245 + <command><method>info</method> <m>?args?</m></command> 246 + <desc>This method bundles methods to query the state of and 247 + details about the schema command. 248 + <optlist> 249 + <optdef> 250 + <optname>validationstate</optname> 251 + <desc>This method returns the state of the validation command 252 + with respect to validation state. The possible return values 253 + and their meanings are: 254 + <dl> 255 + <dt>READY</dt><dd>The validation command is ready to start 256 + validation</dd> 257 + <dt>VALIDATING</dt><dd>The validation command is in the 258 + process of validating input.</dd> 259 + <dt>FINISHED</dt><dd>The validation has finished, no further 260 + events are expected.</dd> 261 + </dl> 262 + </desc> 263 + </optdef> 264 + <optdef> 265 + <optname>vstate</optname> 266 + <desc>This method is a shorter alias for validationstate; see there.</desc> 267 + </optdef> 268 + <optdef> 269 + <optname>line</optname> 270 + <desc>If the schema command is currently validating, 271 + this method returns the line part of the parsing 272 + position information and the empty string in all 273 + other cases. If the schema command is currently 274 + post-validating a DOM tree there may be no position 275 + information stored at some or all nodes. The 276 + empty string is returned in these cases.</desc> 277 + </optdef> 278 + <optdef> 279 + <optname>column</optname> 280 + <desc>If the schema command is currently validating 281 + this method returns the column part of the parsing 282 + position information and the empty string in all 283 + other cases. If the schema command is currently 284 + post-validating a DOM tree there may be no position 285 + information stored at some or all nodes. The 286 + empty string is returned in these cases.</desc> 287 + </optdef> 288 + <optdef> 289 + <optname>domNode</optname> 290 + <desc>If the schema command isn't currently 291 + post-validating a DOM tree this method returns the 292 + empty string. Otherwise, if the schema command waits 293 + for the reportcmd script to finish while recovering 294 + from a validation error it returns the node on which 295 + the validation engine is currently looking at in 296 + case the node is an ELEMENT_NODE or, if not, its 297 + parent node. It is recommended that you do not use 298 + this method. Or at least leave the DOM tree alone, 299 + use it read-only.</desc> 300 + </optdef> 301 + <optdef> 302 + <optname>nrForwardDefinitions</optname> 303 + <desc>Returns how much element, elementtype and ref 304 + pattern are referenced that aren't defined so far 305 + (summed together).</desc> 306 + </optdef> 307 + <optdef> 308 + <optname>definedElements</optname> 309 + <desc>Returns in no particular order the defined 310 + elements in the grammar as list. If an element is 311 + namespaced its list entry will be itself a list with 312 + two elements, with the name as first and the 313 + namespace as second element.</desc> 314 + </optdef> 315 + <optdef> 316 + <optname>definedElementtypes</optname> 317 + <desc>Returns in no particular order the defined 318 + element types in the grammar as list. If an element 319 + type is namespaced its list entry will be itself a 320 + list with two elements, with the name as first and 321 + the namespace as second element.</desc> 322 + </optdef> 323 + <optdef> 324 + <optname>definedPatterns</optname> 325 + <desc>Returns in no particular order the defined 326 + named pattern in the grammar as list. If a named 327 + pattern is namespaced its list entry will be itself 328 + a list with two elements, with the name as first and 329 + the namespace as second element.</desc> 330 + </optdef> 331 + <optdef> 332 + <optname>expected</optname> 333 + <desc>Returns in no particular order all possible 334 + next events (since the last successful event match, 335 + if there was one) as a list. If an element is 336 + namespaced its list entry will be itself a list with 337 + two elements, with the name as first and the 338 + namespace as second element. If text is a possible 339 + next event the list entry will be a two elements 340 + list, with #text as first element and the empty 341 + space as second. If an any element constraint is 342 + possible the list entry will be a two elements list, 343 + with <any> as first element and the empty space 344 + as second. If an any element in a certain namespace 345 + constraint is possible the list entry will be a two 346 + elements list, with <any> as first element and 347 + the namespace as second. If element end is a 348 + possible event the list entry will be a two elements 349 + list with <elementend> as first element and the 350 + empty string as second element.</desc> 351 + </optdef> 352 + <optdef> 353 + <optname>definition name ?namespace?</optname> 354 + <desc>Returns the code that defines the given 355 + element. The command raises error if there isn't a 356 + definition of that element. 357 + </desc> 358 + </optdef> 359 + <optdef> 360 + <optname>typedefinition name ?namespace?</optname> 361 + <desc>Returns the code that defines the given 362 + element type definition. The command raises error if 363 + there isn't a definition of that element. 364 + </desc> 365 + </optdef> 366 + <optdef> 367 + <optname>patterndefinition name ?namespace?</optname> 368 + <desc>Returns the code that defines the given 369 + pattern definition. The command raises error if 370 + there isn't a definition of a pattern with that name 371 + and, if given, namespace. 372 + </desc> 373 + </optdef> 374 + <optdef> 375 + <optname>vaction ?name|namespace|text?</optname> 376 + <desc><p>This method returns useful information only if 377 + the schema command waits for the reportcmd script to 378 + finish while recovering from a validation error. 379 + Otherwise it returns NONE.</p> 380 + <p>If the command is called without the optional 381 + argument the possible return values and their 382 + meanings are:</p> 383 + <dl> 384 + <dt>NONE</dt><dd>The schema command currently 385 + doesn't recover from a validation event.</dd> 386 + <dt>MATCH_ELEMENT_START</dt><dd>Element start event, which includes looking for missing or unknown attributes.</dd> 387 + <dt>MATCH_ELEMENT_END</dt><dd>Element end event.</dd> 388 + <dt>MATCH_TEXT</dt><dd>Validating text between tags.</dd> 389 + <dt>MATCH_ATTRIBUTE_TEXT</dt><dd>Attribute text value constraint check</dd> 390 + <dt>MATCH_GLOBAL</dt><dd>Checking global IDs</dd> 391 + <dt>MATCH_DOM_KEYCONSTRAINT</dt><dd>Checking domunique constraint</dd> 392 + <dt>MATCH_DOM_XPATH_BOOLEAN</dt><dd>Checking domxpathboolean constant</dd> 393 + </dl> 394 + <p>If called with one of the possible optional 395 + arguments, the command returns detail information 396 + depending on current action.</p> 397 + <dl> 398 + <dt>name</dt><dd>Returns the name of the element 399 + that has to match in case of 400 + MATCH_ELEMENT_START. Return the name of the 401 + closed element in case of MATCH_ELEMENT_END. 402 + Returns the name of the attribute in case of 403 + MATCH_ATTRIBUTE_TEXT. Return the name of the 404 + parent element in case of MATCH_TEXT.</dd> 405 + 406 + <dt>namespace</dt><dd>Returns the namespace of 407 + the element that has to match in case of 408 + MATCH_ELEMENT_START. Return the namespace of the 409 + closed element in case of MATCH_ELEMENT_END. 410 + Returns the namespace of the attribute in case 411 + of MATCH_ATTRIBUTE_TEXT. Return the namespace of 412 + the parent element in case of MATCH_TEXT.</dd> 413 + 414 + <dt>text</dt><dd>Returns the text to match in 415 + case of MATCH_TEXT. Returns the value of the 416 + attribute in case of MATCH_ATTRIBUTE_TEXT.</dd> 417 + </dl> 418 + </desc> 419 + </optdef> 420 + <optdef> 421 + <optname>stack top|inside|associated</optname> 422 + <desc>In Tcl scripts evaluated by validation this method 423 + provides information about the current validation stack. 424 + Called outside this context the method returns the empty 425 + string. 426 + <optlist> 427 + <optdef> 428 + <optname>top</optname> 429 + <desc>Returns the element whose content is currently 430 + checked (the open element tag at this moment). 431 + </desc> 432 + </optdef> 433 + 434 + <optdef> 435 + <optname>inside</optname> 436 + <desc>Returns all currently open elements as a list.</desc> 437 + </optdef> 438 + 439 + <optdef> 440 + <optname>associated</optname> 441 + <desc>Returns the data associated with the 442 + current top most stack content particle or 443 + the empty string it there isn't any. 444 + </desc> 445 + </optdef> 446 + </optlist> 447 + </desc> 448 + </optdef> 449 + </optlist> 450 + </desc> 451 + </commanddef> 452 + 453 + <commanddef> 454 + <command><method>reset</method></command> 455 + <desc>This method resets the validation command into state 456 + READY (while preserving the defined grammar).</desc> 457 + </commanddef> 458 + 459 + </commandlist> 460 + </section> 461 + 462 + <section> 463 + <title>Schema definition scripts</title> 464 + 465 + <p>Schema definition scripts are ordinary Tcl scripts evaluated in 466 + the namespace tdom::schema. The schema definition commands listed 467 + below in this Tcl namespace allow to define a wide variety of 468 + document structures. Every schema definition command establishes a 469 + validation constraint on the content which has to match or must be 470 + optional to qualify the content as valid. It is a validation error 471 + if there is additional (not matched) content. White space only 472 + text (in the XML sense of white space) between any different tags 473 + is ignored, with the exception of text only elements (for which 474 + even white space only text will be considered as significant 475 + content).</p> 476 + 477 + <p>The schema definition commands are:</p> 478 + 479 + <commandlist> 480 + <commanddef> 481 + <command><method>element</method> <m>name</m> <m>?quant?</m> <m>?<definition script>?</m></command> 482 + <desc>If the optional argument <m>definition script</m> is not 483 + given this command refers to the element defined with 484 + <m>defelement</m> with the name <m>name</m> in the current 485 + context namespace. If the <m>defelement script</m> argument is 486 + given, then the validation constraint expects an element with 487 + the name <m>name</m> in the current namespace with content 488 + "locally" defined by the <m>definition script</m>. Forward 489 + references to so far not defined elements or patterns or other 490 + local definitions of the same name inside the <m>definition 491 + script</m> are allowed. If a forward referenced element is not 492 + defined until validation then only an empty element with name 493 + <m>name</m> and namespace <m>namespace</m> and no attributes 494 + matches. </desc> 495 + </commanddef> 496 + 497 + <commanddef> 498 + <command><method>elementtype</method> <m>name</m> <m>?quant?</m></command> 499 + <desc>This command refers to the element defined with 500 + <m>defelementtype</m> with the type name <m>name</m> in the 501 + current context namespace. Forward references to so far not 502 + defined element types or recursive references are allowed. If 503 + a forward referenced element type is not defined until 504 + validation any empty element without attributes will be 505 + accepted.</desc> 506 + </commanddef> 507 + 508 + <commanddef> 509 + <command><method>ref</method> <m>name</m> <m>?quant?</m></command> 510 + <desc>This command refers to the content particle defined with 511 + <m>defpattern</m> with the name <m>name</m> in the current 512 + context namespace. Forward references to a so far not defined 513 + pattern and recursive references are allowed. If a forward 514 + referenced pattern is not defined until validation no content 515 + whatsoever is expected ("empty match").</desc> 516 + </commanddef> 517 + 518 + <commanddef> 519 + <command><method>group</method> <m>?quant?</m> <m><definition script></m></command> 520 + <desc>This method allows to group a sequence of content 521 + particles defined by the <m>definition script></m>, which have 522 + to match in this sequence order.</desc> 523 + </commanddef> 524 + 525 + <commanddef> 526 + <command><method>choice</method> <m>?quant?</m> <m><definition script></m></command> 527 + <desc>This schema constraint match if one of the top level 528 + content particles defined by the <m>definition script></m> 529 + matches. If one of this top level content particle is optional 530 + this constraint matches the "empty match". 531 + </desc> 532 + </commanddef> 533 + 534 + <commanddef> 535 + <command><method>interleave</method> <m>?quant?</m> <m><definition script></m></command> 536 + <desc>This schema constraint match after every of the required 537 + top level content particles defined by the <m>definition 538 + script></m> have matched (and, optional, some or all other) in 539 + any arbitrary order.</desc> 540 + </commanddef> 541 + 542 + <commanddef> 543 + <command><method>mixed</method> <m>?quant?</m> <m><definition script></m></command> 544 + <desc>This schema constraint matches for any text (including the 545 + empty one) and every top level content particle defined by the 546 + <m>definition script></m> with default quantifier *.</desc> 547 + </commanddef> 548 + 549 + <commanddef> 550 + <command><method>text</method> <m>?<constraint script>|"type" typename?</m></command> 551 + <desc>Without the optional constraint script this validation 552 + constraint matches every string (including the empty one). 553 + With <m>constraint script</m> or with a given text type 554 + argument a text matching this script or the text type is 555 + expected. </desc> 556 + </commanddef> 557 + 558 + <commanddef> 559 + <command><method>any</method> <m>?namespace?</m> <m>?quant?</m></command> 560 + <desc>The any command matches every element (in the namespace 561 + <m>namespace</m>, if that is given) (with whatever attributes) 562 + or subtree, no matter if known within the schema or not. 563 + Please note that in case of no <m>namespace</m> argument is 564 + given that means that the quantifier * and + will eat up any 565 + elements until the enclosing element ends. If you really have 566 + a namespace that looks like a valid tDOM schema quantifier 567 + you will have to spell out always both arguments.</desc> 568 + </commanddef> 569 + 570 + <commanddef> 571 + <command><method>attribute</method> <m>name</m> <m>?quant?</m> <m>(?<constraint script>|"type" typename?)</m></command> 572 + <desc>The attribute command defines an attribute (in no 573 + namespace) to the enclosing element. The first definition of 574 + <m>name</m> inside an element definition wins; later 575 + definitions of the same name are silently ignored. After the 576 + <m>name</m> argument there may be one of the quantifiers ? or 577 + !. If there is, it will be used. Otherwise the attribute will 578 + be required (must be present in the XML source). If there is 579 + one argument more this argument is evaluated as constraint 580 + script, defining the value constrains of the attribute. 581 + Otherwise, if there are two more arguments and the first of 582 + them is the bare-word "type" the following argument is used as 583 + a text type name. This command is only allowed at top level in 584 + the definition script of an defelement/element script.</desc> 585 + </commanddef> 586 + 587 + <commanddef> 588 + <command><method>nsattribute</method> <m>name</m> <m>namespace</m> <m>?quant?</m> <m>(?<constraint script>|"type" typename?)</m></command> 589 + <desc>This command does the same as the command 590 + <m>attribute</m>, for the attribute <m>name</m> in the 591 + namespace <m>namespace</m>.</desc> 592 + </commanddef> 593 + 594 + <commanddef> 595 + <command><method>namespace</method> <m>URI</m> <m><definition script></m></command> 596 + <desc>Evaluates the <m>definition script</m> with context 597 + namespace <m>URI</m>. Every element, element type or ref 598 + command name will be looked up in the namespace <m>URI</m>, 599 + and local defined elements will be in that namespace. An 600 + empty string as <m>URI</m> means no namespace.</desc> 601 + </commanddef> 602 + 603 + <commanddef> 604 + <command><method>tcl</method> <m>tclcmd</m> <m>?arg arg ...?</m></command> 605 + <desc>Evaluates the Tcl script <m>tclcmd arg arg ... </m>. 606 + This validation command is only allowed in strict sequential 607 + context (not in choice, mixed and interleave). If the return 608 + code is something else than 0 (TCL_OK) this is an error (which 609 + is not catched and reported by reportcmd).</desc> 610 + </commanddef> 611 + 612 + <commanddef> 613 + <command><method>self</method></command> 614 + <desc>Returns the schema command.</desc> 615 + </commanddef> 616 + 617 + <commanddef> 618 + <command><method>associate</method> <m>data</m></command> 619 + <desc>This command is only allowed top-level inside definition 620 + scripts of the element, elementtype, pattern or interleave 621 + content particles. Associates the <m>data</m> given as argument 622 + with the currently defined content particle and may be 623 + requested in scripts evaluated while validating the content of 624 + that particle with the schema command method call <m>info 625 + stack associated</m>.</desc> 626 + </commanddef> 627 + 628 + <commanddef> 629 + <command><method>domunique</method> <m>selector</m> <m>fieldlist</m> <m>?name?</m> <m>?"IGNORE_EMPTY_FIELD_SET"|("EMPTY_FIELD_SET_VALUE" emptyFieldSetValue)?</m></command> 630 + <desc>If not postvalidating a DOM tree with <m>domvalidate</m> 631 + this constraint always matches. If postvalidating this 632 + constraint resembles the xsd key/keyref mechanism. The 633 + <m>selector</m> argument may be any valid XPath expression 634 + (without the xsd limits). Several <m>domunique</m> commands 635 + within one element definition are allowed. They are checked in 636 + definition order. The argument name is available in the 637 + recovering script per <m>info vaction name</m>. If the 638 + <m>fieldlist</m> doesn't select something for a node of the 639 + result set of the <m>selector</m> the key value will be the 640 + empty string by default. If the arguments 641 + <m>EMPTY_FIELD_SET_VALUE <value></m> are given an empty 642 + node set will have the key value <m>value</m>. If instead the 643 + flag <m>IGNORE_EMPTY_FIELD_SET</m> flag is given an empty 644 + node set result will not have any key value.</desc> 645 + </commanddef> 646 + 647 + <commanddef> 648 + <command><method>domxpathboolean</method> <m>XPath_expr</m> <m>?name?</m></command> 649 + <desc><p>If not postvalidating a DOM tree with 650 + <m>domvalidate</m> this constraint always matches. If 651 + postvalidating the <m>XPath_expr</m> argument is evaluated 652 + (with the node matching the schema parent of the 653 + <m>domxpathboolean</m> command as context node). The 654 + constraint maches if the result of this XPath expression, 655 + converted to boolean by XPath rules, is true. Several 656 + <m>domxpathboolean</m> commands within one element definition 657 + are allowed. They are checked in definition order.</p> 658 + 659 + <p>This enables checks depending on more than one element. Consider</p> 660 + 661 + <example> 662 +tdom::schema s 663 +s define { 664 + defelement doc { 665 + element a ! text 666 + element b ! text 667 + element c ! text 668 + domxpathboolean "a * b * c >= 20000" volume 669 + domxpathboolean "a > b and b > c" sequence 670 + } 671 +} 672 + </example> 673 + </desc> 674 + </commanddef> 675 + 676 + <commanddef> 677 + <command><method>prefixns</method> <m>?prefixUriList?</m></command> 678 + <desc>This defines a prefix to namespace URI mapping exactly 679 + as a <i>schemacmd prefixns</i> call. This is meant as top-level 680 + command of a <i>schemacmd define</i> script. This command is 681 + not allowed nested in another definition script command and 682 + will raise error, if you call it there.</desc> 683 + </commanddef> 684 + 685 + <commanddef> 686 + <command><method>defelement</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 687 + <desc>This defines an element exactly as a <i>schemacmd 688 + defelement</i> call. This is meant as top-level command of a 689 + <i>schemacmd define</i> script. This command is not allowed 690 + nested in another definition script command and will raise 691 + error, if you call it there.</desc> 692 + </commanddef> 693 + 694 + <commanddef> 695 + <command><method>defelementtype</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 696 + <desc>This defines an elementtype exactly as a <i>schemacmd 697 + defelementtype</i> call. This is meant as top-level command of a 698 + <i>schemacmd define</i> script. This command is not allowed 699 + nested in another definition script command and will raise 700 + error, if you call it there.</desc> 701 + </commanddef> 702 + 703 + <commanddef> 704 + <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 705 + <desc>This defines a named pattern exactly as a <i>schemacmd 706 + defpattern</i> call. This is meant as top-level command of a 707 + <i>schemacmd define</i> script. This command is not allowed 708 + nested in another definition script command and will raise 709 + error, if you call it there.</desc> 710 + </commanddef> 711 + 712 + <commanddef> 713 + <command><method>deftexttype</method> <m>name</m> <m><constraint script></m></command> 714 + <desc>This defines a named bundle of text constraints exactly 715 + as a <i>schemacmd deftexttype</i> call. This is meant as top-level 716 + command of a <i>schemacmd define</i> script. This command is 717 + not allowed nested in another definition script command and 718 + will raise error, if you call it there.</desc> 719 + </commanddef> 720 + 721 + <commanddef> 722 + <command><method>start</method> <m>name</m> <m>?namespace?</m></command> 723 + <desc>This command works exactly as a <i>schemacmd start</i> 724 + call. This is meant as top-level command of a <i>schemacmd 725 + define</i> script. This command is not allowed nested in 726 + another definition script command and will raise error, if you 727 + call it there.</desc> 728 + </commanddef> 729 + </commandlist> 730 + 731 + </section> 732 + 733 + <section> 734 + <title>Quantity specifier</title> 735 + 736 + <p>Several schema definition commands expects a quantifier as 737 + one of their arguments, which determines how often the content 738 + particle specified by the command is expected. The valid values 739 + for a <m>quant</m> argument are:</p> 740 + 741 + <optlist> 742 + <optdef> 743 + <optname>!</optname> 744 + <desc>The content particle must occur exactly once in valid 745 + documents.</desc> 746 + </optdef> 747 + 748 + <optdef> 749 + <optname>?</optname> 750 + <desc>The content particle must occur at most once in valid 751 + documents.</desc> 752 + </optdef> 753 + 754 + <optdef> 755 + <optname>*</optname> 756 + <desc>The content particle may occur zero or more times in a 757 + row in valid documents.</desc> 758 + </optdef> 759 + 760 + <optdef> 761 + <optname>+</optname> 762 + <desc>The content particle may occur one or more times in a 763 + row in valid documents.</desc> 764 + </optdef> 765 + 766 + <optdef> 767 + <optname>n</optname> 768 + <desc>The content particle must occur n times in a row in 769 + valid documents. The quantifier must be an integer greater 770 + zero.</desc> 771 + </optdef> 772 + 773 + <optdef> 774 + <optname>{n m}</optname> <desc>The content particle must occur 775 + n to m times (both inclusive) in a row in valid documents. The 776 + quantifier must be a Tcl list with two elements. Both elements 777 + must be integers, with n >= 0 and n < m.</desc> 778 + </optdef> 779 + </optlist> 780 + 781 + <p>If an optional quantifier is not given then it defaults to * in 782 + case of the <m>mixed</m> command and to ! for all other commands.</p> 783 + </section> 784 + 785 + <section> 786 + <title>Text constraint scripts</title> 787 + 788 + <p>Text - parsed character data, as XML calls it - must sometimes 789 + be of a certain kind, must comply to some rules etc to be valid. 790 + The text constraint script arguments to the text, attribute, 791 + nsattribute and deftexttype commands are evaluated in the Tcl 792 + namespace <m>tdom::schema::text</m> namespace and allow the 793 + following text constraint commands to check text for certain 794 + properties. The commands are defined in the Tcl namespace 795 + <m>tdom::schema::text</m>. They raise error in case they are 796 + called outside of a text constraint script.</p> 797 + 798 + <p>A few of the following text type commands are exposed as 799 + general Tcl commands. They are defined in the namespace tdom::type 800 + and are called as documented below with the text to check appended 801 + to the argument list. They return a logical value. Please note, 802 + that the commands may not accept starting or ending white space. It 803 + is noted with the command documentation, if the command is 804 + available in the tdom::type namespace. 805 + </p> 806 + 807 + <subsection> 808 + <title>The tcl text constraint command</title> 809 + <p>The <m>tcl</m> text constraint command dispatches the check 810 + to an arbitrary Tcl command, thus enable any programmable 811 + decision rules.</p> 812 + <commandlist> 813 + <commanddef> 814 + <command><cmd>tcl</cmd> <m>tclcmd</m> <m>?arg arg ...?</m></command> 815 + <desc>Evaluates the Tcl script <m>tclcmd arg arg ... </m> and 816 + the text to validate appended to the argument list. The return 817 + value of the Tcl command is interpreted as a boolean.</desc> 818 + </commanddef> 819 + </commandlist> 820 + </subsection> 821 + 822 + <subsection> 823 + <title>Basic XML types</title> 824 + <commandlist> 825 + <commanddef> 826 + <command><cmd>name</cmd></command> 827 + <desc>This text constraint match if the text value match the 828 + XML name production 829 + <url>https://www.w3.org/TR/xml/#NT-Name</url>. This means the 830 + text value must start with a letter, underscore (_), or colon (:), 831 + and may contain only letters, digits, underscores (_), colons 832 + (:), hyphens (-), and periods (.).</desc> 833 + </commanddef> 834 + <commanddef> 835 + <command><cmd>ncname</cmd></command> 836 + <desc>This text constraint match if the text value match the 837 + XML ncname production 838 + <url>https://www.w3.org/TR/xml-names/#NT-NCName</url>. This 839 + means the text value must start with a letter or underscore (_), 840 + and may contain only letters, digits, underscores (_), hyphens 841 + (-), and periods (.) (The only difference to the name 842 + constraint is that colons are not permitted.)</desc> 843 + </commanddef> 844 + <commanddef> 845 + <command><cmd>qname</cmd></command> 846 + <desc>This text constraint match if the text value match the 847 + XML qname production 848 + <url>https://www.w3.org/TR/xml-names/#NT-QName</url>. This 849 + means the text value is either a ncname or two ncnames joined 850 + by a colon (:).</desc> 851 + </commanddef> 852 + <commanddef> 853 + <command><cmd>nmtoken</cmd></command> 854 + <desc>This text constraint match if the text value match the 855 + XML nmtoken production 856 + <url>https://www.w3.org/TR/xml/#NT-Nmtoken</url></desc> 857 + </commanddef> 858 + <commanddef> 859 + <command><cmd>nmtokens</cmd></command> 860 + <desc>This text constraint match if the text value match the 861 + XML nmtokens production 862 + <url>https://www.w3.org/TR/xml/#NT-Nmtokens</url></desc> 863 + </commanddef> 864 + </commandlist> 865 + </subsection> 866 + 867 + <subsection> 868 + <title>Basic type tests</title> 869 + <p> 870 + </p> 871 + <commandlist> 872 + <commanddef> 873 + <command><cmd>integer</cmd> <m>?(xsd|tcl)?</m></command> 874 + <desc>This text constraint match if the text value could be 875 + parsed as an integer. If the optional argument to the command 876 + is <m>tcl</m> everything that returns TCL_OK if feeded into 877 + Tcl_GetInt() matches. If the optional argument to the command 878 + is <m>xsd</m> then the constraint match if the value is a 879 + valid xsd:integer. Without argument <m>xsd</m> is the 880 + default.</desc> 881 + </commanddef> 882 + 883 + <commanddef> 884 + <command><cmd>negativeInteger</cmd> <m>?(xsd|tcl)?</m></command> 885 + <desc>This text constraint match the same text values as the 886 + <m>integer</m> text constraint (see there) with the additional 887 + constraint that the value must be < zero.</desc> 888 + </commanddef> 889 + 890 + <commanddef> 891 + <command><cmd>nonNegativeInteger</cmd> <m>?(xsd|tcl)?</m></command> 892 + <desc>This text constraint match the same text values as the 893 + <m>integer</m> text constraint (see there) with the additional 894 + constraint that the value must be >= zero.</desc> 895 + </commanddef> 896 + 897 + <commanddef> 898 + <command><cmd>nonPositiveInteger</cmd> <m>?(xsd|tcl)?</m></command> 899 + <desc>This text constraint match the same text values as the 900 + <m>integer</m> text constraint (see there) with the additional 901 + constraint that the value must be <= zero.</desc> 902 + </commanddef> 903 + 904 + <commanddef> 905 + <command><cmd>positiveInteger</cmd> <m>?(xsd|tcl)?</m></command> 906 + <desc>This text constraint match the same text values as the 907 + <m>integer</m> text constraint (see there) with the additional 908 + constraint that the value must be > zero.</desc> 909 + </commanddef> 910 + 911 + <commanddef> 912 + <command><cmd>number</cmd> <m>?(xsd|tcl)?</m></command> 913 + <desc>This text constraint match if the text value could be 914 + parsed as a number. If the optional argument to the command is 915 + <m>tcl</m> everything that returns TCL_OK if feeded into 916 + Tcl_GetDouble() matches. If the optional argument to the command 917 + is <m>xsd</m> then the constraint match if the value is a 918 + valid xsd:decimal. Without argument <m>xsd</m> is the 919 + default.</desc> 920 + </commanddef> 921 + <commanddef> 922 + <command><cmd>boolean</cmd> <m>?(xsd|tcl)?</m></command> 923 + <desc>This text constraint match if the text value could be 924 + parsed as a boolean. If the optional argument to the command is 925 + <m>tcl</m> everything that returns TCL_OK if feeded into 926 + Tcl_GetBoolean() matches. If the optional argument to the command 927 + is <m>xsd</m> then the constraint match if the value is a 928 + valid xsd:boolean. Without argument <m>xsd</m> is the 929 + default.</desc> 930 + </commanddef> 931 + <commanddef> 932 + <command><cmd>date</cmd></command> 933 + <desc>This text constraint match if the text value is 934 + a xsd:date. This is basically like an ISO 8601 date of 935 + the form YYYY-MM-DD, with optional time zone part 936 + (either the letter Z or plus (+) or minus (-) followed 937 + by hh:mm and with maximum allowed positive or negative 938 + time zone 14:00). It follows the date rules of the 939 + Gregorian calendar for all dates. A preceding minus 940 + sign for bce dates is allowed. There is no year 0. The 941 + year may have more than 4 digits, but only if needed 942 + (no extra leading zeros). This is available as common 943 + Tcl command tdom::type::date.</desc> 944 + </commanddef> 945 + <commanddef> 946 + <command><cmd>time</cmd></command> 947 + <desc>This text constraint match if the text value is 948 + a xsd:time. This is basically like an ISO 8601 time of 949 + the form hh:mm:ss with optional time zone part. The 950 + time zone part follow the rules of the <m>date</m> 951 + command; see there. All three parts of the time value 952 + (hours, minutes, seconds) must be spelled out with 2 953 + digits. Additional fractional seconds (with a point 954 + ('.') as separator) are allowed, but not just a 955 + dangling point. The time value 24:00:00 (without 956 + fractional part) is allowed. This is available as 957 + common Tcl command tdom::type::time.</desc> 958 + </commanddef> 959 + <commanddef> 960 + <command><cmd>dateTime</cmd></command> 961 + <desc>This text constraint match if the text value is 962 + a xsd:dateTime. This is basically like an ISO 8601 963 + date time of the form YYYY-MM-DDThh:mm:ss with 964 + optional time zone part. The date and time zone parts 965 + follow the rules of the <m>date</m> command; see 966 + there. The time part (including the signaling 'T' 967 + character) is mandatory and follow the rules of the 968 + <m>time</m> command, see there. This is available as 969 + common Tcl command tdom::type::dateTime.</desc> 970 + </commanddef> 971 + <commanddef> 972 + <command><cmd>duration</cmd></command> 973 + <desc>This text constraint match if the text value is 974 + a xsd:duration. This is basically like an ISO 8601 975 + duration of the form PnYnMnDTnHnMnS. All parts other 976 + then the starting P and - if one of H, M or S is given 977 + - T are optional. In case the following sign letter is 978 + S n may be a decimal (with at least one digit before 979 + and after the dot), otherwise it must be a (positive) 980 + integer. This is available as common Tcl command 981 + tdom::type::duration.</desc> 982 + </commanddef> 983 + <commanddef> 984 + <command><cmd>base64</cmd></command> 985 + <desc>This text constraint match if text is valid according to 986 + RFC 4648.</desc> 987 + </commanddef> 988 + <commanddef> 989 + <command><cmd>hexBinary</cmd></command> 990 + <desc>This text constraint match if text is a sequence of 991 + binary octets in hexadecimal encoding, where each binary octet 992 + is a two-character hexadecimal number. Lowercase and uppercase 993 + letters A through F are permitted.</desc> 994 + </commanddef> 995 + <commanddef> 996 + <command><cmd>unsignedByte</cmd></command> 997 + <desc>This text constraint match if the text value is a 998 + xsd:unsignedByte. This is an integer between 0 and 255, both 999 + included, optionally preceded by a + sign and leading 1000 + zeros.</desc> 1001 + </commanddef> 1002 + <commanddef> 1003 + <command><cmd>unsignedShort</cmd></command> 1004 + <desc>This text constraint match if the text value is a 1005 + xsd:unsignedShort. This is an integer between 0 and 65535, 1006 + both included, optionally preceded by a + sign and leading 1007 + zeros.</desc> 1008 + </commanddef> 1009 + <commanddef> 1010 + <command><cmd>unsignedInt</cmd></command> 1011 + <desc>This text constraint match if the text value is a 1012 + xsd:unsignedInt. This is an integer between 0 and 4294967295, 1013 + both included, optionally preceded by a + sign and leading 1014 + zeros.</desc> 1015 + </commanddef> 1016 + <commanddef> 1017 + <command><cmd>unsignedLong</cmd></command> 1018 + <desc>This text constraint match if the text value is a 1019 + xsd:unsignedLong. This is an integer between 0 and 1020 + 18446744073709551615, both included, optionally preceded by a 1021 + + sign and leading zeros.</desc> 1022 + </commanddef> 1023 + </commandlist> 1024 + </subsection> 1025 + 1026 + <subsection> 1027 + <title>Logical constructs</title> 1028 + <commandlist> 1029 + <commanddef> 1030 + <command><cmd>oneOf</cmd> <m><constraint script></m></command> 1031 + <desc>This text constraint match if one of the text 1032 + constraints defined in the argument <m>constraint script</m> 1033 + match the text. It stops after the first match and probes the 1034 + text constraints in the order of definition.</desc> 1035 + </commanddef> 1036 + <commanddef> 1037 + <command><cmd>allOf</cmd> <m><constraint script></m></command> 1038 + <desc>This text constraint match if all of the text 1039 + constraints defined in the argument <m>constraint script</m> 1040 + match the text. It stops after the first match failure and 1041 + probes the text constraints in the order of definition. Since 1042 + the schema definition command <m>text</m> also expects all 1043 + text constraints to match the text constraint <m>allOf</m> is 1044 + useful mostly together with the <m>oneOf</m> text constraint 1045 + command.</desc> 1046 + </commanddef> 1047 + <commanddef> 1048 + <command><cmd>not</cmd> <m><constraint script></m></command> 1049 + <desc>This text constraint match if none of the text 1050 + constraints defined in the argument <m>constraint 1051 + script</m> match the text. It stops after the first 1052 + matching constraint in the <m>constraint script</m> and 1053 + reports validation error. The text constraints in the 1054 + <m>constraint script</m> are probed in the order of 1055 + definition.</desc> 1056 + </commanddef> 1057 + </commandlist> 1058 + </subsection> 1059 + 1060 + <subsection> 1061 + <title>Constraints on processed text value</title> 1062 + <commandlist> 1063 + <commanddef> 1064 + <command><cmd>whitespace</cmd> <m>(preserve|replace|collapse)</m> <m><constraint script></m></command> 1065 + <desc>This text constraint command does white-space (#x20 1066 + (space, ' '), #x9 (tab, \t), #xA (linefeed, \n), and #xD 1067 + (carriage return, \r) normalization to the text value and 1068 + checks the resulting text with the text constraints of the 1069 + constraint script argument. The normalization method 1070 + <m>preserve</m> keeps everything as it is; this is another way 1071 + to say <m>allOf</m>. The <m>replace</m> normalization method 1072 + replaces any single white-space character (as above) to a 1073 + space. The <m>collapse</m> normalization method removes all 1074 + leading and trailing white-space and all the other sequences of 1075 + contiguous white-space are replaced by a single space.</desc> 1076 + </commanddef> 1077 + <commanddef> 1078 + <command><cmd>split</cmd> <m>?type ?args??</m><m><constraint script></m></command> 1079 + <desc><p>This text constraint command splits the text to test 1080 + into a list of values and tests all elements of that list for 1081 + the text constraints in the evaluated <m>constraint 1082 + script></m>.</p> 1083 + <p>The available types are:</p> 1084 + <dl> 1085 + <dt>whitespace</dt><dd>The text to split is striped of all 1086 + white space at start and end splited into a list at any 1087 + successive white space.</dd> 1088 + <dt>tcl tclcmd ?arg ...?</dt><dd>The text to split is 1089 + handed to the <m>tclcmd</m>, which is evaluated on global 1090 + level, appended with every given arg and the text to split 1091 + as last argument. This call must return a valid Tcl list, 1092 + which elements are tested.</dd> 1093 + </dl> 1094 + <p>The default in case no split type argument is given is 1095 + <m>whitespace</m>.</p></desc> 1096 + </commanddef> 1097 + <commanddef> 1098 + <command><cmd>strip</cmd> <m><constraint script></m></command> 1099 + <desc>This text constraint command tests all text constraints 1100 + in the evaluated <m>constraint script></m> with the text to 1101 + test striped of all white space at start and end.</desc> 1102 + </commanddef> 1103 + </commandlist> 1104 + </subsection> 1105 + 1106 + <subsection> 1107 + <title>Various other string properties</title> 1108 + <commandlist> 1109 + <commanddef> 1110 + <command><cmd>fixed</cmd> <m>value</m></command> 1111 + <desc>The text constraint only match if the text value is 1112 + string equal to the given value.</desc> 1113 + </commanddef> 1114 + 1115 + <commanddef> 1116 + <command><cmd>enumeration</cmd> <m>list</m></command> 1117 + <desc>This text constraint match if the text value is equal to 1118 + one element (respecting case and any white-space) of the 1119 + argument <m>list</m>, which has to be a valid Tcl list. 1120 + </desc> 1121 + </commanddef> 1122 + <commanddef> 1123 + <command><cmd>match</cmd> <m>?-nocase?</m> <m>glob_style_match_pattern></m></command> 1124 + <desc>This text constraint match if the text value match the 1125 + glob style pattern given as argument. It follows the rules of 1126 + the Tcl [string match] command, see 1127 + <url>https://www.tcl.tk/man/tcl8.6/TclCmd/string.htm#M35</url>.</desc> 1128 + </commanddef> 1129 + <commanddef> 1130 + <command><cmd>regexp</cmd> <m>expression</m></command> 1131 + <desc>This text constraint match if the text value match the 1132 + regular expression given as argument. <url>https://www.tcl.tk/man/tcl8.6/TclCmd/re_syntax.htm</url> describes the regular expression syntax</desc> 1133 + </commanddef> 1134 + <commanddef> 1135 + <command><cmd>length</cmd> <m>length</m></command> 1136 + <desc>This text constraint match if the length of the text 1137 + value (in characters, not bytes) is <m>length</m>. The 1138 + length argument must be a positive integer or zero.</desc> 1139 + </commanddef> 1140 + <commanddef> 1141 + <command><cmd>maxLength</cmd> <m>length</m></command> 1142 + <desc>This text constraint match if the length of the text 1143 + value (in characters, not bytes) is at most <m>length</m>. The 1144 + length argument must be an integer greater zero.</desc> 1145 + </commanddef> 1146 + <commanddef> 1147 + <command><cmd>minLength</cmd> <m>length</m></command> 1148 + <desc>This text constraint match if the length of the text 1149 + value (in characters, not bytes) is at least <m>length</m>. 1150 + The length argument must be an integer greater zero.</desc> 1151 + </commanddef> 1152 + <commanddef> 1153 + <command><cmd>id</cmd> <m>?keySpace?</m></command> 1154 + <desc>This text constraint command marks the text as a 1155 + document wide ID (to be referenced by an idref). Every ID 1156 + value within a document must be unique. It isn't an error if 1157 + the ID isn't actually referenced within the document. The 1158 + optional argument <m>keySpace</m> does all this for a named 1159 + key space. The key space "" (the empty sting) is another key 1160 + space as the <m>id</m> command without keySpace 1161 + argument.</desc> 1162 + </commanddef> 1163 + <commanddef> 1164 + <command><cmd>idref</cmd> <m>?keySpace?</m></command> 1165 + <desc>This text constraint command expects the text to be a 1166 + reference to an ID within the document. The referenced ID may 1167 + be later in the document, that the reference. Several 1168 + references within the document to one ID are possible.</desc> 1169 + </commanddef> 1170 + </commandlist> 1171 + </subsection> 1172 + </section> 1173 + 1174 + <section> 1175 + <title>Local key constraints</title> 1176 + 1177 + <p>Document wide uniqueness and foreign key constraints are 1178 + available with the text constraint commands id and idref. 1179 + Keyspaces allow for sub-tree local uniqueness and foreign key 1180 + constraints.</p> 1181 + 1182 + <commandlist> 1183 + <commanddef> 1184 + <command><cmd>keyspace</cmd> <m><names list></m> <m><constraint script></m></command> 1185 + <desc>Any number of keyspaces are possible. A keyspace is 1186 + either active or not. An inside a <m>constraint 1187 + script</m> called keyspace with the same name does 1188 + nothing.</desc> 1189 + </commanddef> 1190 + </commandlist> 1191 + 1192 + <p>This text constraint commands work with keyspaces:</p> 1193 + 1194 + <commandlist> 1195 + <commanddef> 1196 + <command><cmd>key</cmd> <m><name></m></command> 1197 + <desc>If the keyspace with the name <m><name></m> is not 1198 + active always matches. If the keyspace is active then 1199 + reports error if there is already a key with the value. 1200 + Otherwise, stores the value as key in this keyspace and 1201 + matches.</desc> 1202 + </commanddef> 1203 + <commanddef> 1204 + <command><cmd>keyref</cmd> <m><name></m></command> 1205 + <desc>If the keyspace with the name <m><name></m> is not 1206 + active always matches. If the keyspace is active then 1207 + reports error if there is still no key as the value at the 1208 + end of the keyspace <m><name></m>. Otherwise it 1209 + matches.</desc> 1210 + </commanddef> 1211 + </commandlist> 1212 + 1213 + </section> 1214 + 1215 + <section id="recovering"> 1216 + <title>Recovering</title> 1217 + 1218 + <p>By default the validation engine stops at the first detected 1219 + validation violation and report that finding. It does so by 1220 + return false (and set, if given, the result variable with an 1221 + error message) in case the schema command itself is used to 1222 + validate input. If the schema command is used by a SAX parser or 1223 + the DOM parser it does so by throwing error.</p> 1224 + 1225 + <p>If a <m>reportcmd</m> is set this command is called on global 1226 + level appended with the schema command and an error type as 1227 + arguments if a validation violation is detected. Then the 1228 + validation recovers from the error and continues. For some 1229 + validation errors the recover strategy can be determined with 1230 + the script result of the reportcmd.</p> 1231 + 1232 + <p>With a <m>reportcmd</m> (which doesen&t throw error if 1233 + called) the validation engine will never report validation 1234 + failure to its caller. The validation engine recovers, continues 1235 + and report the next error, if one happen and so until the end of 1236 + the input. The schema command will return true and the SAX 1237 + parser and DOM builder will process normally until the end of 1238 + the input, as if there would not have been validation.</p> 1239 + 1240 + <p>Please note, that this happens only for validation errors. It 1241 + isn't possible to recover from well-formedness errors. If the 1242 + input isn't well-formed the schema command returns false and 1243 + set, if given, the result variable with an error message about 1244 + the well-formedness error.</p> 1245 + 1246 + <p>If the <m>reportcmd</m> throws error while called by the 1247 + validation engine then validation stops and the schema command 1248 + throws error with the error message of the script.</p> 1249 + 1250 + <p>While validating basically three events happen: an element 1251 + start tag has to match, a piece of text has to match or an 1252 + element end tag has to match. The method <m>info vaction</m> 1253 + called in the recovering script or any script code called from 1254 + there returns, which event triggered the error report 1255 + (MATCH_ELEMENT_START, MATCH_TEXT, MATCH_ELEMENT_END, 1256 + respectively). While the command walks throu the schema looking 1257 + if the event matches other, data driven events (as, for example 1258 + checking, if any keyref within a keyspace exists).</p> 1259 + 1260 + <p>Several of the validation error codes appended as second 1261 + argument to the <m>reportcmd</m> calls may happen at more than 1262 + one kind of validation event. The <m>info vaction</m> method and 1263 + its subcommands provide information about the current validation 1264 + event and the 1265 + </p> 1266 + 1267 + <p>If a structural validation error happens, the default 1268 + recovering strategy is to ignore any following (or missing) 1269 + content within the current subtree and to continue with the 1270 + element end event of the subtree.</p> 1271 + 1272 + <p>Returning "ignore" from the recovering script in case of 1273 + error type MISSING_ELEMENT recovers by ignoring the failed 1274 + contraint and continues to match the event further against the 1275 + schema.</p> 1276 + 1277 + <p>Returing "vanish" from the recover script In case of the 1278 + error types MISSING_ELEMENT and UNEXPECTED_ELEMENT recovers by 1279 + ignoring the event.</p> 1280 + 1281 + </section> 1282 + 1283 + <section> 1284 + <title>Examples</title> 1285 + 1286 + <p>The XML Schema Part 0: Primer Second Edition 1287 + (<url>https://www.w3.org/TR/xmlschema-0/</url>) starts with this 1288 + example schema:</p> 1289 + 1290 + <example> 1291 +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 1292 + 1293 + <xsd:annotation> 1294 + <xsd:documentation xml:lang="en"> 1295 + Purchase order schema for Example.com. 1296 + Copyright 2000 Example.com. All rights reserved. 1297 + </xsd:documentation> 1298 + </xsd:annotation> 1299 + 1300 + <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> 1301 + 1302 + <xsd:element name="comment" type="xsd:string"/> 1303 + 1304 + <xsd:complexType name="PurchaseOrderType"> 1305 + <xsd:sequence> 1306 + <xsd:element name="shipTo" type="USAddress"/> 1307 + <xsd:element name="billTo" type="USAddress"/> 1308 + <xsd:element ref="comment" minOccurs="0"/> 1309 + <xsd:element name="items" type="Items"/> 1310 + </xsd:sequence> 1311 + <xsd:attribute name="orderDate" type="xsd:date"/> 1312 + </xsd:complexType> 1313 + 1314 + <xsd:complexType name="USAddress"> 1315 + <xsd:sequence> 1316 + <xsd:element name="name" type="xsd:string"/> 1317 + <xsd:element name="street" type="xsd:string"/> 1318 + <xsd:element name="city" type="xsd:string"/> 1319 + <xsd:element name="state" type="xsd:string"/> 1320 + <xsd:element name="zip" type="xsd:decimal"/> 1321 + </xsd:sequence> 1322 + <xsd:attribute name="country" type="xsd:NMTOKEN" 1323 + fixed="US"/> 1324 + </xsd:complexType> 1325 + 1326 + <xsd:complexType name="Items"> 1327 + <xsd:sequence> 1328 + <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> 1329 + <xsd:complexType> 1330 + <xsd:sequence> 1331 + <xsd:element name="productName" type="xsd:string"/> 1332 + <xsd:element name="quantity"> 1333 + <xsd:simpleType> 1334 + <xsd:restriction base="xsd:positiveInteger"> 1335 + <xsd:maxExclusive value="100"/> 1336 + </xsd:restriction> 1337 + </xsd:simpleType> 1338 + </xsd:element> 1339 + <xsd:element name="USPrice" type="xsd:decimal"/> 1340 + <xsd:element ref="comment" minOccurs="0"/> 1341 + <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> 1342 + </xsd:sequence> 1343 + <xsd:attribute name="partNum" type="SKU" use="required"/> 1344 + </xsd:complexType> 1345 + </xsd:element> 1346 + </xsd:sequence> 1347 + </xsd:complexType> 1348 + 1349 + <!-- Stock Keeping Unit, a code for identifying products --> 1350 + <xsd:simpleType name="SKU"> 1351 + <xsd:restriction base="xsd:string"> 1352 + <xsd:pattern value="\d{3}-[A-Z]{2}"/> 1353 + </xsd:restriction> 1354 + </xsd:simpleType> 1355 + 1356 +</xsd:schema> 1357 + </example> 1358 + 1359 + <p>A somewhat one-to-one translation of that into a tDOM schema 1360 + definition script would be:</p> 1361 + 1362 + <example> 1363 +tdom::schema schema 1364 +schema define { 1365 + 1366 + # Purchase order schema for Example.com. 1367 + # Copyright 2000 Example.com. All rights reserved. 1368 + 1369 + defelement purchaseOrder {ref PurchaseOrderType} 1370 + 1371 + foreach elm {comment name street city state product} { 1372 + defelement $elm text 1373 + } 1374 + 1375 + defpattern PurchaseOrderType { 1376 + element shipTo ! {ref USAddress} 1377 + element billTo ! {ref USAddress} 1378 + element comment ? 1379 + element items 1380 + attribute orderDate date 1381 + } 1382 + 1383 + defpattern USAddress { 1384 + element name 1385 + element street 1386 + element city 1387 + element state 1388 + element zip ! {text number} 1389 + attribute country ! {fixed "US"} 1390 + } 1391 + 1392 + defelement items { 1393 + element item * { 1394 + element product 1395 + element quantity ! {text integer} 1396 + element USPrice ! {text number} 1397 + element comment 1398 + element shipDate ? {text date} 1399 + attribute partNum ! {pattern "^\d{3}-[A-Z]{2}$"} 1400 + } 1401 + } 1402 +} 1403 + 1404 + </example> 1405 + 1406 + <p>The RELAX NG Tutorial 1407 + (<url>http://relaxng.org/tutorial-20011203.html</url>) starts with 1408 + this example:</p> 1409 + 1410 + <example> 1411 +Consider a simple XML representation of an email address book: 1412 + 1413 +<addressBook> 1414 + <card> 1415 + <name>John Smith</name> 1416 + <email>js@example.com</email> 1417 + </card> 1418 + <card> 1419 + <name>Fred Bloggs</name> 1420 + <email>fb@example.net</email> 1421 + </card> 1422 +</addressBook> 1423 + 1424 +The DTD would be as follows: 1425 + 1426 +<!DOCTYPE addressBook [ 1427 +<!ELEMENT addressBook (card*)> 1428 +<!ELEMENT card (name, email)> 1429 +<!ELEMENT name (#PCDATA)> 1430 +<!ELEMENT email (#PCDATA)> 1431 +]> 1432 + 1433 +A RELAX NG pattern for this could be written as follows: 1434 + 1435 +<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> 1436 + <zeroOrMore> 1437 + <element name="card"> 1438 + <element name="name"> 1439 + <text/> 1440 + </element> 1441 + <element name="email"> 1442 + <text/> 1443 + </element> 1444 + </element> 1445 + </zeroOrMore> 1446 +</element> 1447 + 1448 + </example> 1449 + 1450 + <p>This schema definition script will do the same:</p> 1451 + 1452 + <example> 1453 +tdom::schema schema 1454 +schema define { 1455 + defelement addressBook { 1456 + element card * 1457 + } 1458 + defelement card { 1459 + element name 1460 + element email 1461 + } 1462 + foreach e {name email} { 1463 + defelement $e text 1464 + } 1465 +} 1466 + 1467 + </example> 1468 +</section> 1469 + 1470 +<keywords> 1471 + <keyword>Validation</keyword> 1472 + <keyword>Postvalidation</keyword> 1473 + <keyword>DOM</keyword> 1474 + <keyword>SAX</keyword> 1475 +</keywords> 1476 +</manpage>
Deleted doc/structure.html.
1 -<html> 2 -<head> 3 -<link rel="stylesheet" href="manpage.css"><title>tDOM manual: structure</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 -</head><body> 5 -<div class="header"> 6 -<div class="navbar" align="center"> 7 -<a href="#SECTid0x24391d0">NAME</a> · <a href="#SECTid0x23792c0">SYNOPSIS</a> · <a href="#SECTid0x24e32a0">DESCRIPTION </a> · <a href="#SECTid0x24ea820">Structure definition scripts</a> · <a href="#SECTid0x24f0040">Quantity specifier</a> · <a href="#SECTid0x24f1e90">Exampels</a> 8 -</div><hr class="navsep"> 9 -</div><div class="body"> 10 - <h2><a name="SECTid0x24391d0">NAME</a></h2><p class="namesection"> 11 -<b class="names">tdom::structure - </b><br>Create an XML structure validation command</p> 12 - 13 - <h2><a name="SECTid0x23792c0">SYNOPSIS</a></h2><pre class="syntax">package require tdom 14 - 15 - <b class="cmd">tdom::structure</b> <i class="m">cmdName</i> 16 - </pre> 17 - 18 - <h2><a name="SECTid0x24e32a0">DESCRIPTION </a></h2><p>This command creates validation commands with a simple API. The 19 - validation commands have methods to define an XML grammer and are 20 - able to validate XML or DOM trees against this grammer.</p><p>Additionaly, a validation command may be used as argument to 21 - the <i class="m">-validateCmd</i> option of the <i class="m">dom parse</i> and the 22 - <i class="m">expat</i> commands to enable validation additional to what they 23 - otherwise do.</p><p>The valid methods of the created commands are:</p><dl class="commandlist"> 24 - 25 - <dt> 26 -<b class="method">defelement</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 27 -</dt> 28 - <dd>This method defines the element <i class="m">name</i> (optional in 29 - the namespace <i class="m">namespace</i>) in the grammar. The 30 - <i class="m">definition script</i> is evaluated and defines the content 31 - model of the element. If the <i class="m">namespace</i> argument is 32 - given, any <i class="m">element</i> or <i class="m">ref</i> references in the 33 - definition script not wrapped inside a <i class="m">namespace</i> 34 - command are resolved in that namespace. If there is already a 35 - element definition for the name/namespace combination the 36 - command raises error.</dd> 37 - 38 - 39 - 40 - <dt> 41 -<b class="method">defpattern</b> <i class="m">name</i> <i class="m"><definition script></i> 42 -</dt> 43 - <dd>This method defines a (maybe complex) content particle 44 - with the <i class="m">name</i> (optional in the namespace 45 - <i class="m">namespace</i>) in the grammar, to be referenced in other 46 - definition scripts with the definition command <i class="m">ref</i>. The 47 - <i class="m">definition script</i> is evaluated and defines the content 48 - model of the content particle. If the <i class="m">namespace</i> 49 - argument is given, any <i class="m">element</i> or <i class="m">ref</i> references 50 - in the definition script not wrapped inside a <i class="m">namespace</i> 51 - command are resolved in that namespace. If there is already a 52 - pattern definition for the name/namespace combination the 53 - command raises error.</dd> 54 - 55 - 56 - 57 - <dt> 58 -<b class="method">define</b> <i class="m"><definition script></i> 59 -</dt> 60 - <dd>This method allows to define several elements or pattern 61 - or a whole grammar with one call.</dd> 62 - 63 - 64 - 65 - <dt> 66 -<b class="method">start</b> <i class="m">documentElement</i> <i class="m">?namespace?</i> 67 -</dt> 68 - <dd>This method defines the name and namespace of the root 69 - element of a tree to validate. If this method is used then the 70 - root element must match for validity. If <i class="m">start</i> isn't 71 - used, any with <i class="m">defelement</i> defined element may be the 72 - root of a valid document. The <i class="m">start</i> method may be used 73 - serveral times with varying arguments during the lifetime of a 74 - validation command. If the command is called with just the 75 - empty string (and no namespace argument), the validation 76 - constrain for the root element is removed and any defined 77 - element will be valid as root of a tree to validate.</dd> 78 - 79 - 80 - 81 - <dt> 82 -<b class="method">event</b> <i class="m">(start|end|text)</i> <i class="m">?event specific data?</i> 83 -</dt> 84 - <dd>This method allows to validate hierarchical data against 85 - the so far defined content constrains of the validation 86 - command. 87 - 88 - <dl class="optlist"> 89 - 90 - <dt> 91 -<b>start</b> <i>name ?attributes? ?namespace? </i> 92 -</dt> 93 - 94 - <dd>Checks if the current validation state allows the 95 - element <i class="m">name</i> in the <i class="m">namespace</i> is allowed to 96 - start here. It raises error, if not.</dd> 97 - 98 - 99 - 100 - <dt><b>end</b></dt> 101 - <dd>Checks if the current innermost open element may be 102 - end here in the current state without violate validation 103 - constrains. It raises error, if not.</dd> 104 - 105 - 106 - 107 - <dt> 108 -<b>text</b> <i>text</i> 109 -</dt> 110 - 111 - <dd>Checks if the current validation state allows the 112 - given text content. It raises error, if not.</dd> 113 - 114 - 115 - </dl> 116 - </dd> 117 - 118 - 119 - 120 - <dt> 121 -<b class="method">validate</b> <i class="m"><XML string></i> <i class="m">?objVar?</i> 122 -</dt> 123 - <dd>Returns true if the <i class="m"><XML string></i> is valid or 124 - false otherwise. If validation failed and the optional 125 - <i class="m">objVar</i> argument is given, then the variable with that 126 - name is set to a validation error message.</dd> 127 - 128 - 129 - 130 - <dt><b class="method">delete</b></dt> 131 - <dd>This method deletes the validation command.</dd> 132 - 133 - 134 - 135 - <dt><b class="method">state</b></dt> 136 - <dd>This method returns the state of the validation command with respect to validation state. The possible return values and their meanings are: 137 - <dl> 138 - <dt>READY</dt><dd>The validation command is ready to start 139 - validation</dd> 140 - <dt>VALIDATING</dt><dd>The validation command is in the 141 - process of validating input.</dd> 142 - <dt>FINISHED</dt><dd>The validation has finished, no futher 143 - events are expected.</dd> 144 - </dl> 145 - </dd> 146 - 147 - 148 - 149 - <dt><b class="method">reset</b></dt> 150 - <dd>This method resets the validation command into state 151 - READY (while preserving the defined grammer).</dd> 152 - 153 - 154 - </dl> 155 - 156 - <h2><a name="SECTid0x24ea820">Structure definition scripts</a></h2><p>Structure definition scripts are ordinary Tcl scripts that are 157 - evaluatend in the namespace tdom::structure. Several structure 158 - definition commands in this tcl namespace allow to define a wide 159 - variety of document structures. Every structure definition command 160 - establish a validation constrain on the content which all has to 161 - match, leaving no unmatched content to render the content as 162 - valid.</p><p>The structure definition commands are:</p><dl class="commandlist"> 163 - 164 - <dt> 165 -<b class="method">element</b> <i class="m">name</i> <i class="m">?quant?</i> <i class="m">?<definition script>?</i> 166 -</dt> 167 - <dd>This command refers to the element defined with 168 - <i class="m">defelement</i> with the name <i class="m">name</i> in the current context 169 - namespace. Forward references to a so far not defined element 170 - or recursive references are allowed.</dd> 171 - 172 - 173 - 174 - <dt> 175 -<b class="method">ref</b> <i class="m">name</i> <i class="m">?quant?</i> 176 -</dt> 177 - <dd>This command refers to the content particle defined with 178 - <i class="m">defpattern</i> with the name <i class="m">name</i> in the current context 179 - namespace. Forward references to a so far not defined pattern 180 - or recursive references are allowed.</dd> 181 - 182 - 183 - 184 - <dt> 185 -<b class="method">group</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 186 -</dt> 187 - <dd></dd> 188 - 189 - 190 - 191 - <dt> 192 -<b class="method">choice</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 193 -</dt> 194 - <dd></dd> 195 - 196 - 197 - 198 - <dt> 199 -<b class="method">interleave</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 200 -</dt> 201 - <dd></dd> 202 - 203 - 204 - 205 - <dt> 206 -<b class="method">mixed</b> <i class="m">?quant?</i> <i class="m"><definition script></i> 207 -</dt> 208 - <dd></dd> 209 - 210 - 211 - 212 - <dt> 213 -<b class="method">text</b> <i class="m"><definition script></i> 214 -</dt> 215 - <dd></dd> 216 - 217 - 218 - 219 - <dt><b class="method">any</b></dt> 220 - <dd></dd> 221 - 222 - 223 - 224 - <dt> 225 -<b class="method">attribute</b> <i class="m"><definition script></i> 226 -</dt> 227 - <dd></dd> 228 - 229 - 230 - 231 - <dt> 232 -<b class="method">namespace</b> <i class="m"><definition script></i> 233 -</dt> 234 - <dd></dd> 235 - 236 - 237 - 238 - <dt><b class="method">empty</b></dt> 239 - <dd></dd> 240 - 241 - 242 - 243 - <dt> 244 -<b class="method">defelement</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 245 -</dt> 246 - <dd></dd> 247 - 248 - 249 - 250 - <dt> 251 -<b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> 252 -</dt> 253 - <dd></dd> 254 - 255 - 256 - 257 - <dt> 258 -<b class="method">start</b> <i class="m">name</i> <i class="m">?namespace?</i> 259 -</dt> 260 - <dd></dd> 261 - 262 - </dl> 263 - 264 - <h2><a name="SECTid0x24f0040">Quantity specifier</a></h2><p>Serveral structure definition commands expects a quantifier as 265 - one of their arguments, which specifies how often the content 266 - particle specified by the command is expected. The valid values 267 - for a <i class="m">quant</i> argument are:</p><dl class="optlist"> 268 - 269 - <dt><b>!</b></dt> 270 - <dd>The content particle must occur exactly once in valid 271 - documents.</dd> 272 - 273 - 274 - 275 - <dt><b>?</b></dt> 276 - <dd>The content particle must occur at most once in valid 277 - documents.</dd> 278 - 279 - 280 - 281 - <dt><b>*</b></dt> 282 - <dd>The content particle may occur zero or more times in a 283 - row in valid documents.</dd> 284 - 285 - 286 - 287 - <dt><b>+</b></dt> 288 - <dd>The content particle may occur one or more times in a 289 - row in valid documents.</dd> 290 - 291 - 292 - 293 - <dt><b>n</b></dt> 294 - <dd>The content particle must occur n times in a row in 295 - valid documents. The quantifier must be an integer greater 296 - zero.</dd> 297 - 298 - 299 - 300 - <dt><b>{n m}</b></dt> <dd>The content particle must occur 301 - n to m times (both inclusive) in a row in valid documents. The 302 - quantifier must be a tcl list with two elements. Both elements 303 - must be integers, with n >= 0 and n < m.</dd> 304 - 305 - </dl><p>If an optional quantifier is missing then it defaults to ! - 306 - the content particle must occur exactly once in valid 307 - documents.</p> 308 - 309 - <h2><a name="SECTid0x24f1e90">Exampels</a></h2><p>The XML Schema Part 0: Primer Second Edition 310 - https://www.w3.org/TR/xmlschema-0/ starts with this example schema 311 - or grammar or Structure definition:</p><pre class="example"> 312 -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 313 - 314 - <xsd:annotation> 315 - <xsd:documentation xml:lang="en"> 316 - Purchase order schema for Example.com. 317 - Copyright 2000 Example.com. All rights reserved. 318 - </xsd:documentation> 319 - </xsd:annotation> 320 - 321 - <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> 322 - 323 - <xsd:element name="comment" type="xsd:string"/> 324 - 325 - <xsd:complexType name="PurchaseOrderType"> 326 - <xsd:sequence> 327 - <xsd:element name="shipTo" type="USAddress"/> 328 - <xsd:element name="billTo" type="USAddress"/> 329 - <xsd:element ref="comment" minOccurs="0"/> 330 - <xsd:element name="items" type="Items"/> 331 - </xsd:sequence> 332 - <xsd:attribute name="orderDate" type="xsd:date"/> 333 - </xsd:complexType> 334 - 335 - <xsd:complexType name="USAddress"> 336 - <xsd:sequence> 337 - <xsd:element name="name" type="xsd:string"/> 338 - <xsd:element name="street" type="xsd:string"/> 339 - <xsd:element name="city" type="xsd:string"/> 340 - <xsd:element name="state" type="xsd:string"/> 341 - <xsd:element name="zip" type="xsd:decimal"/> 342 - </xsd:sequence> 343 - <xsd:attribute name="country" type="xsd:NMTOKEN" 344 - fixed="US"/> 345 - </xsd:complexType> 346 - 347 - <xsd:complexType name="Items"> 348 - <xsd:sequence> 349 - <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> 350 - <xsd:complexType> 351 - <xsd:sequence> 352 - <xsd:element name="productName" type="xsd:string"/> 353 - <xsd:element name="quantity"> 354 - <xsd:simpleType> 355 - <xsd:restriction base="xsd:positiveInteger"> 356 - <xsd:maxExclusive value="100"/> 357 - </xsd:restriction> 358 - </xsd:simpleType> 359 - </xsd:element> 360 - <xsd:element name="USPrice" type="xsd:decimal"/> 361 - <xsd:element ref="comment" minOccurs="0"/> 362 - <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> 363 - </xsd:sequence> 364 - <xsd:attribute name="partNum" type="SKU" use="required"/> 365 - </xsd:complexType> 366 - </xsd:element> 367 - </xsd:sequence> 368 - </xsd:complexType> 369 - 370 - <!-- Stock Keeping Unit, a code for identifying products --> 371 - <xsd:simpleType name="SKU"> 372 - <xsd:restriction base="xsd:string"> 373 - <xsd:pattern value="\d{3}-[A-Z]{2}"/> 374 - </xsd:restriction> 375 - </xsd:simpleType> 376 - 377 -</xsd:schema> 378 - </pre><p>A somewhat one-to-one translation of that into a tDOM structure 379 - defintion script would be:</p><pre class="example"> 380 -tdom::structure grammar 381 -grammar define { 382 - 383 - # Purchase order schema for Example.com. 384 - # Copyright 2000 Example.com. All rights reserved. 385 - 386 - element purchaseOrder {ref PurchaseOrderType} 387 - 388 - element comment {text} 389 - 390 - defpattern PurchaseOrderType { 391 - element shipTo {ref USAddress} 392 - element billTo {ref USAddress} 393 - element comment ? 394 - element items 395 - attribute orderDate 396 - } 397 - 398 - defpattern USAddress { 399 - element name ! {text} 400 - element street ! {text} 401 - element city ! {text} 402 - element state ! {text} 403 - element zip ! {text isNumber} 404 - attribute country ! {text {fixed "US"}} 405 - } 406 - 407 - defelement items { 408 - element item * { 409 - element product ! {text} 410 - element quntity ! {text {maxExcluse 100}} 411 - element USPrice ! {text isNumber} 412 - element comment 413 - element shipDate ? {text isDate} 414 - attribute partNum ! {text {pattern "\d{3}-[A-Z]{2}"}} 415 - } 416 - } 417 -} 418 - 419 - </pre><p>The RELAX NG Tutorial http://relaxng.org/tutorial-20011203.html 420 - starts with this example:</p><pre class="example"> 421 -Consider a simple XML representation of an email address book: 422 - 423 -<addressBook> 424 - <card> 425 - <name>John Smith</name> 426 - <email>js@example.com</email> 427 - </card> 428 - <card> 429 - <name>Fred Bloggs</name> 430 - <email>fb@example.net</email> 431 - </card> 432 -</addressBook> 433 - 434 -The DTD would be as follows: 435 - 436 -<!DOCTYPE addressBook [ 437 -<!ELEMENT addressBook (card*)> 438 -<!ELEMENT card (name, email)> 439 -<!ELEMENT name (#PCDATA)> 440 -<!ELEMENT email (#PCDATA)> 441 -]> 442 - 443 -A RELAX NG pattern for this could be written as follows: 444 - 445 -<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> 446 - <zeroOrMore> 447 - <element name="card"> 448 - <element name="name"> 449 - <text/> 450 - </element> 451 - <element name="email"> 452 - <text/> 453 - </element> 454 - </element> 455 - </zeroOrMore> 456 -</element> 457 - 458 - </pre><p>This structure definition script will do the same:</p><pre class="example"> 459 -tdom::structure grammar 460 -grammar define { 461 - defelement addressBook { 462 - element card * 463 - } 464 - defelement card { 465 - element name 466 - element email 467 - } 468 - foreach e {name email} { 469 - defelement $e {text} 470 - } 471 -} 472 - 473 - </pre> 474 -</div><hr class="navsep"><div class="navbar" align="center"> 475 -<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 476 -</div> 477 -</body> 478 -</html>
Deleted doc/structure.n.
1 -'\" 2 -'\" Generated from structure.xml 3 -'\" 4 -'\" BEGIN man.macros 5 -.if t .wh -1.3i ^B 6 -.nr ^l \n(.l 7 -.ad b 8 -.de AP 9 -.ie !"\\$4"" .TP \\$4 10 -.el \{\ 11 -. ie !"\\$2"" .TP \\n()Cu 12 -. el .TP 15 13 -.\} 14 -.ta \\n()Au \\n()Bu 15 -.ie !"\\$3"" \{\ 16 -\&\\$1 \\fI\\$2\\fP (\\$3) 17 -.\".b 18 -.\} 19 -.el \{\ 20 -.br 21 -.ie !"\\$2"" \{\ 22 -\&\\$1 \\fI\\$2\\fP 23 -.\} 24 -.el \{\ 25 -\&\\fI\\$1\\fP 26 -.\} 27 -.\} 28 -.. 29 -.de AS 30 -.nr )A 10n 31 -.if !"\\$1"" .nr )A \\w'\\$1'u+3n 32 -.nr )B \\n()Au+15n 33 -.\" 34 -.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n 35 -.nr )C \\n()Bu+\\w'(in/out)'u+2n 36 -.. 37 -.AS Tcl_Interp Tcl_CreateInterp in/out 38 -.de BS 39 -.br 40 -.mk ^y 41 -.nr ^b 1u 42 -.if n .nf 43 -.if n .ti 0 44 -.if n \l'\\n(.lu\(ul' 45 -.if n .fi 46 -.. 47 -.de BE 48 -.nf 49 -.ti 0 50 -.mk ^t 51 -.ie n \l'\\n(^lu\(ul' 52 -.el \{\ 53 -.\" Draw four-sided box normally, but don't draw top of 54 -.\" box if the box started on an earlier page. 55 -.ie !\\n(^b-1 \{\ 56 -\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' 57 -.\} 58 -.el \}\ 59 -\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' 60 -.\} 61 -.\} 62 -.fi 63 -.br 64 -.nr ^b 0 65 -.. 66 -.de VS 67 -.if !"\\$2"" .br 68 -.mk ^Y 69 -.ie n 'mc \s12\(br\s0 70 -.el .nr ^v 1u 71 -.. 72 -.de VE 73 -.ie n 'mc 74 -.el \{\ 75 -.ev 2 76 -.nf 77 -.ti 0 78 -.mk ^t 79 -\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' 80 -.sp -1 81 -.fi 82 -.ev 83 -.\} 84 -.nr ^v 0 85 -.. 86 -.de ^B 87 -.ev 2 88 -'ti 0 89 -'nf 90 -.mk ^t 91 -.if \\n(^b \{\ 92 -.\" Draw three-sided box if this is the box's first page, 93 -.\" draw two sides but no top otherwise. 94 -.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c 95 -.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c 96 -.\} 97 -.if \\n(^v \{\ 98 -.nr ^x \\n(^tu+1v-\\n(^Yu 99 -\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c 100 -.\} 101 -.bp 102 -'fi 103 -.ev 104 -.if \\n(^b \{\ 105 -.mk ^y 106 -.nr ^b 2 107 -.\} 108 -.if \\n(^v \{\ 109 -.mk ^Y 110 -.\} 111 -.. 112 -.de DS 113 -.RS 114 -.nf 115 -.sp 116 -.. 117 -.de DE 118 -.fi 119 -.RE 120 -.sp 121 -.. 122 -.de SO 123 -.SH "STANDARD OPTIONS" 124 -.LP 125 -.nf 126 -.ta 5.5c 11c 127 -.ft B 128 -.. 129 -.de SE 130 -.fi 131 -.ft R 132 -.LP 133 -See the \\fBoptions\\fR manual entry for details on the standard options. 134 -.. 135 -.de OP 136 -.LP 137 -.nf 138 -.ta 4c 139 -Command-Line Name: \\fB\\$1\\fR 140 -Database Name: \\fB\\$2\\fR 141 -Database Class: \\fB\\$3\\fR 142 -.fi 143 -.IP 144 -.. 145 -.de CS 146 -.RS 147 -.nf 148 -.ta .25i .5i .75i 1i 149 -.if t .ft C 150 -.. 151 -.de CE 152 -.fi 153 -.if t .ft R 154 -.RE 155 -.. 156 -.de UL 157 -\\$1\l'|0\(ul'\\$2 158 -.. 159 -'\" END man.macros 160 -.TH structure n "" Tcl "" 161 -.BS 162 -.SH NAME 163 -tdom::structure \- Create an XML structure validation command 164 -.SH SYNOPSIS 165 -.nf 166 -package require tdom 167 - 168 - \fBtdom::structure\fP \fIcmdName\fR 169 - 170 -.fi 171 -.BE 172 -.SH "DESCRIPTION " 173 -.PP 174 -This command creates validation commands with a simple API. The 175 -validation commands have methods to define an XML grammer and are 176 -able to validate XML or DOM trees against this grammer. 177 -.PP 178 -Additionaly, a validation command may be used as argument to 179 -the \fI-validateCmd\fR option of the \fIdom parse\fR and the 180 -\&\fIexpat\fR commands to enable validation additional to what they 181 -otherwise do. 182 -.PP 183 -The valid methods of the created commands are: 184 -.TP 185 -\&\fB\fBdefelement\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 186 -\&\fRThis method defines the element \fIname\fR (optional in 187 -the namespace \fInamespace\fR) in the grammar. The 188 -\&\fIdefinition script\fR is evaluated and defines the content 189 -model of the element. If the \fInamespace\fR argument is 190 -given, any \fIelement\fR or \fIref\fR references in the 191 -definition script not wrapped inside a \fInamespace\fR 192 -command are resolved in that namespace. If there is already a 193 -element definition for the name/namespace combination the 194 -command raises error. 195 -.TP 196 -\&\fB\fBdefpattern\fP \fIname\fB \fI<definition script>\fB 197 -\&\fRThis method defines a (maybe complex) content particle 198 -with the \fIname\fR (optional in the namespace 199 -\&\fInamespace\fR) in the grammar, to be referenced in other 200 -definition scripts with the definition command \fIref\fR. The 201 -\&\fIdefinition script\fR is evaluated and defines the content 202 -model of the content particle. If the \fInamespace\fR 203 -argument is given, any \fIelement\fR or \fIref\fR references 204 -in the definition script not wrapped inside a \fInamespace\fR 205 -command are resolved in that namespace. If there is already a 206 -pattern definition for the name/namespace combination the 207 -command raises error. 208 -.TP 209 -\&\fB\fBdefine\fP \fI<definition script>\fB 210 -\&\fRThis method allows to define several elements or pattern 211 -or a whole grammar with one call. 212 -.TP 213 -\&\fB\fBstart\fP \fIdocumentElement\fB \fI?namespace?\fB 214 -\&\fRThis method defines the name and namespace of the root 215 -element of a tree to validate. If this method is used then the 216 -root element must match for validity. If \fIstart\fR isn't 217 -used, any with \fIdefelement\fR defined element may be the 218 -root of a valid document. The \fIstart\fR method may be used 219 -serveral times with varying arguments during the lifetime of a 220 -validation command. If the command is called with just the 221 -empty string (and no namespace argument), the validation 222 -constrain for the root element is removed and any defined 223 -element will be valid as root of a tree to validate. 224 -.TP 225 -\&\fB\fBevent\fP \fI(start|end|text)\fB \fI?event specific data?\fB 226 -\&\fRThis method allows to validate hierarchical data against 227 -the so far defined content constrains of the validation 228 -command. 229 -.RS 230 -.IP "\fBstart \fIname ?attributes? ?namespace? \fP\fR" 231 -Checks if the current validation state allows the 232 -element \fIname\fR in the \fInamespace\fR is allowed to 233 -start here. It raises error, if not. 234 -.IP "\fBend\fR" 235 -Checks if the current innermost open element may be 236 -end here in the current state without violate validation 237 -constrains. It raises error, if not. 238 -.IP "\fBtext \fItext\fP\fR" 239 -Checks if the current validation state allows the 240 -given text content. It raises error, if not. 241 -.RE 242 -.TP 243 -\&\fB\fBvalidate\fP \fI<XML string>\fB \fI?objVar?\fB 244 -\&\fRReturns true if the \fI<XML string>\fR is valid or 245 -false otherwise. If validation failed and the optional 246 -\&\fIobjVar\fR argument is given, then the variable with that 247 -name is set to a validation error message. 248 -.TP 249 -\&\fB\fBdelete\fP 250 -\&\fRThis method deletes the validation command. 251 -.TP 252 -\&\fB\fBstate\fP 253 -\&\fRThis method returns the state of the validation command with respect to validation state. The possible return values and their meanings are: 254 -.RS 255 -.TP 256 -READY 257 -The validation command is ready to start 258 -validation 259 -.TP 260 -VALIDATING 261 -The validation command is in the 262 -process of validating input. 263 -.TP 264 -FINISHED 265 -The validation has finished, no futher 266 -events are expected. 267 -.RE 268 -.TP 269 -\&\fB\fBreset\fP 270 -\&\fRThis method resets the validation command into state 271 -READY (while preserving the defined grammer). 272 -.SH "Structure definition scripts" 273 -.PP 274 -Structure definition scripts are ordinary Tcl scripts that are 275 -evaluatend in the namespace tdom::structure. Several structure 276 -definition commands in this tcl namespace allow to define a wide 277 -variety of document structures. Every structure definition command 278 -establish a validation constrain on the content which all has to 279 -match, leaving no unmatched content to render the content as 280 -valid. 281 -.PP 282 -The structure definition commands are: 283 -.TP 284 -\&\fB\fBelement\fP \fIname\fB \fI?quant?\fB \fI?<definition script>?\fB 285 -\&\fRThis command refers to the element defined with 286 -\&\fIdefelement\fR with the name \fIname\fR in the current context 287 -namespace. Forward references to a so far not defined element 288 -or recursive references are allowed. 289 -.TP 290 -\&\fB\fBref\fP \fIname\fB \fI?quant?\fB 291 -\&\fRThis command refers to the content particle defined with 292 -\&\fIdefpattern\fR with the name \fIname\fR in the current context 293 -namespace. Forward references to a so far not defined pattern 294 -or recursive references are allowed. 295 -.TP 296 -\&\fB\fBgroup\fP \fI?quant?\fB \fI<definition script>\fB 297 -\&\fR 298 -.TP 299 -\&\fB\fBchoice\fP \fI?quant?\fB \fI<definition script>\fB 300 -\&\fR 301 -.TP 302 -\&\fB\fBinterleave\fP \fI?quant?\fB \fI<definition script>\fB 303 -\&\fR 304 -.TP 305 -\&\fB\fBmixed\fP \fI?quant?\fB \fI<definition script>\fB 306 -\&\fR 307 -.TP 308 -\&\fB\fBtext\fP \fI<definition script>\fB 309 -\&\fR 310 -.TP 311 -\&\fB\fBany\fP 312 -\&\fR 313 -.TP 314 -\&\fB\fBattribute\fP \fI<definition script>\fB 315 -\&\fR 316 -.TP 317 -\&\fB\fBnamespace\fP \fI<definition script>\fB 318 -\&\fR 319 -.TP 320 -\&\fB\fBempty\fP 321 -\&\fR 322 -.TP 323 -\&\fB\fBdefelement\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 324 -\&\fR 325 -.TP 326 -\&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB 327 -\&\fR 328 -.TP 329 -\&\fB\fBstart\fP \fIname\fB \fI?namespace?\fB 330 -\&\fR 331 -.SH "Quantity specifier" 332 -.PP 333 -Serveral structure definition commands expects a quantifier as 334 -one of their arguments, which specifies how often the content 335 -particle specified by the command is expected. The valid values 336 -for a \fIquant\fR argument are: 337 -.IP "\fB!\fR" 338 -The content particle must occur exactly once in valid 339 -documents. 340 -.IP "\fB?\fR" 341 -The content particle must occur at most once in valid 342 -documents. 343 -.IP "\fB*\fR" 344 -The content particle may occur zero or more times in a 345 -row in valid documents. 346 -.IP "\fB+\fR" 347 -The content particle may occur one or more times in a 348 -row in valid documents. 349 -.IP "\fBn\fR" 350 -The content particle must occur n times in a row in 351 -valid documents. The quantifier must be an integer greater 352 -zero. 353 -.IP "\fB{n m}\fR" 354 -The content particle must occur 355 -n to m times (both inclusive) in a row in valid documents. The 356 -quantifier must be a tcl list with two elements. Both elements 357 -must be integers, with n >= 0 and n < m. 358 -.PP 359 -If an optional quantifier is missing then it defaults to ! - 360 -the content particle must occur exactly once in valid 361 -documents. 362 -.SH Exampels 363 -.PP 364 -The XML Schema Part 0: Primer Second Edition 365 -https://www.w3.org/TR/xmlschema-0/ starts with this example schema 366 -or grammar or Structure definition: 367 -.CS 368 - 369 -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 370 - 371 - <xsd:annotation> 372 - <xsd:documentation xml:lang="en"> 373 - Purchase order schema for Example.com. 374 - Copyright 2000 Example.com. All rights reserved. 375 - </xsd:documentation> 376 - </xsd:annotation> 377 - 378 - <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> 379 - 380 - <xsd:element name="comment" type="xsd:string"/> 381 - 382 - <xsd:complexType name="PurchaseOrderType"> 383 - <xsd:sequence> 384 - <xsd:element name="shipTo" type="USAddress"/> 385 - <xsd:element name="billTo" type="USAddress"/> 386 - <xsd:element ref="comment" minOccurs="0"/> 387 - <xsd:element name="items" type="Items"/> 388 - </xsd:sequence> 389 - <xsd:attribute name="orderDate" type="xsd:date"/> 390 - </xsd:complexType> 391 - 392 - <xsd:complexType name="USAddress"> 393 - <xsd:sequence> 394 - <xsd:element name="name" type="xsd:string"/> 395 - <xsd:element name="street" type="xsd:string"/> 396 - <xsd:element name="city" type="xsd:string"/> 397 - <xsd:element name="state" type="xsd:string"/> 398 - <xsd:element name="zip" type="xsd:decimal"/> 399 - </xsd:sequence> 400 - <xsd:attribute name="country" type="xsd:NMTOKEN" 401 - fixed="US"/> 402 - </xsd:complexType> 403 - 404 - <xsd:complexType name="Items"> 405 - <xsd:sequence> 406 - <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> 407 - <xsd:complexType> 408 - <xsd:sequence> 409 - <xsd:element name="productName" type="xsd:string"/> 410 - <xsd:element name="quantity"> 411 - <xsd:simpleType> 412 - <xsd:restriction base="xsd:positiveInteger"> 413 - <xsd:maxExclusive value="100"/> 414 - </xsd:restriction> 415 - </xsd:simpleType> 416 - </xsd:element> 417 - <xsd:element name="USPrice" type="xsd:decimal"/> 418 - <xsd:element ref="comment" minOccurs="0"/> 419 - <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> 420 - </xsd:sequence> 421 - <xsd:attribute name="partNum" type="SKU" use="required"/> 422 - </xsd:complexType> 423 - </xsd:element> 424 - </xsd:sequence> 425 - </xsd:complexType> 426 - 427 - <!-- Stock Keeping Unit, a code for identifying products --> 428 - <xsd:simpleType name="SKU"> 429 - <xsd:restriction base="xsd:string"> 430 - <xsd:pattern value="\ed{3}-[A-Z]{2}"/> 431 - </xsd:restriction> 432 - </xsd:simpleType> 433 - 434 -</xsd:schema> 435 - 436 -.CE 437 -.PP 438 -A somewhat one-to-one translation of that into a tDOM structure 439 -defintion script would be: 440 -.CS 441 - 442 -tdom::structure grammar 443 -grammar define { 444 - 445 - # Purchase order schema for Example.com. 446 - # Copyright 2000 Example.com. All rights reserved. 447 - 448 - element purchaseOrder {ref PurchaseOrderType} 449 - 450 - element comment {text} 451 - 452 - defpattern PurchaseOrderType { 453 - element shipTo {ref USAddress} 454 - element billTo {ref USAddress} 455 - element comment ? 456 - element items 457 - attribute orderDate 458 - } 459 - 460 - defpattern USAddress { 461 - element name ! {text} 462 - element street ! {text} 463 - element city ! {text} 464 - element state ! {text} 465 - element zip ! {text isNumber} 466 - attribute country ! {text {fixed "US"}} 467 - } 468 - 469 - defelement items { 470 - element item * { 471 - element product ! {text} 472 - element quntity ! {text {maxExcluse 100}} 473 - element USPrice ! {text isNumber} 474 - element comment 475 - element shipDate ? {text isDate} 476 - attribute partNum ! {text {pattern "\ed{3}-[A-Z]{2}"}} 477 - } 478 - } 479 -} 480 - 481 - 482 -.CE 483 -.PP 484 -The RELAX NG Tutorial http://relaxng.org/tutorial-20011203.html 485 -starts with this example: 486 -.CS 487 - 488 -Consider a simple XML representation of an email address book: 489 - 490 -<addressBook> 491 - <card> 492 - <name>John Smith</name> 493 - <email>js@example.com</email> 494 - </card> 495 - <card> 496 - <name>Fred Bloggs</name> 497 - <email>fb@example.net</email> 498 - </card> 499 -</addressBook> 500 - 501 -The DTD would be as follows: 502 - 503 -<!DOCTYPE addressBook [ 504 -<!ELEMENT addressBook (card*)> 505 -<!ELEMENT card (name, email)> 506 -<!ELEMENT name (#PCDATA)> 507 -<!ELEMENT email (#PCDATA)> 508 -]> 509 - 510 -A RELAX NG pattern for this could be written as follows: 511 - 512 -<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> 513 - <zeroOrMore> 514 - <element name="card"> 515 - <element name="name"> 516 - <text/> 517 - </element> 518 - <element name="email"> 519 - <text/> 520 - </element> 521 - </element> 522 - </zeroOrMore> 523 -</element> 524 - 525 - 526 -.CE 527 -.PP 528 -This structure definition script will do the same: 529 -.CS 530 - 531 -tdom::structure grammar 532 -grammar define { 533 - defelement addressBook { 534 - element card * 535 - } 536 - defelement card { 537 - element name 538 - element email 539 - } 540 - foreach e {name email} { 541 - defelement $e {text} 542 - } 543 -} 544 - 545 - 546 -.CE 547 -
Deleted doc/structure.xml.
1 -<manpage id="structure" cat="structure" title="structure"> 2 - <namesection> 3 - <name>tdom::structure</name> 4 - <desc>Create a structure validation command</desc> 5 - </namesection> 6 - 7 - <synopsis> 8 - <syntax>package require tdom 9 - 10 - <cmd>tdom::structure</cmd> <m>cmdName</m> 11 - </syntax> 12 - </synopsis> 13 - 14 - <section> 15 - <title>DESCRIPTION </title> 16 - 17 - <p>This command creates validation commands with a simple API. The 18 - validation commands have methods to define a grammer and are able 19 - to validate XML or DOM trees (and to some degree other kind of 20 - hierarchical data) against this grammer.</p> 21 - 22 - <p>Additionally, a validation command may be used as argument to 23 - the <m>-validateCmd</m> option of the <m>dom parse</m> and the 24 - <m>expat</m> commands to enable validation additional to what they 25 - otherwise do.</p> 26 - 27 - <p>The valid methods of the created commands are:</p> 28 - 29 - <commandlist> 30 - <commanddef> 31 - <command><method>defelement</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 32 - <desc>This method defines the element <m>name</m> (optional in 33 - the namespace <m>namespace</m>) in the grammar. The 34 - <m>definition script</m> is evaluated and defines the content 35 - model of the element. If the <m>namespace</m> argument is 36 - given, any <m>element</m> or <m>ref</m> references in the 37 - definition script not wrapped inside a <m>namespace</m> 38 - command are resolved in that namespace. If there is already a 39 - element definition for the name/namespace combination the 40 - command raises error.</desc> 41 - </commanddef> 42 - 43 - <commanddef> 44 - <command><method>defpattern</method> <m>name</m> <m><definition script></m></command> 45 - <desc>This method defines a (maybe complex) content particle 46 - with the <m>name</m> (optional in the namespace 47 - <m>namespace</m>) in the grammar, to be referenced in other 48 - definition scripts with the definition command <m>ref</m>. The 49 - <m>definition script</m> is evaluated and defines the content 50 - model of the content particle. If the <m>namespace</m> 51 - argument is given, any <m>element</m> or <m>ref</m> references 52 - in the definition script not wrapped inside a <m>namespace</m> 53 - command are resolved in that namespace. If there is already a 54 - pattern definition for the name/namespace combination the 55 - command raises error.</desc> 56 - </commanddef> 57 - 58 - <commanddef> 59 - <command><method>define</method> <m><definition script></m></command> 60 - <desc>This method allows to define several elements or pattern 61 - or a whole grammar with one call.</desc> 62 - </commanddef> 63 - 64 - <commanddef> 65 - <command><method>start</method> <m>documentElement</m> <m>?namespace?</m></command> 66 - <desc>This method defines the name and namespace of the root 67 - element of a tree to validate. If this method is used then the 68 - root element must match for validity. If <m>start</m> isn't 69 - used, any with <m>defelement</m> defined element may be the 70 - root of a valid document. The <m>start</m> method may be used 71 - serveral times with varying arguments during the lifetime of a 72 - validation command. If the command is called with just the 73 - empty string (and no namespace argument), the validation 74 - constrain for the root element is removed and any defined 75 - element will be valid as root of a tree to validate.</desc> 76 - </commanddef> 77 - 78 - <commanddef> 79 - <command><method>event</method> <m>(start|end|text)</m> <m>?event specific data?</m></command> 80 - <desc>This method allows to validate hierarchical data against 81 - the so far defined content constrains of the validation 82 - command. 83 - 84 - <optlist> 85 - <optdef> 86 - <optname>start</optname> 87 - <optarg>name ?attributes? ?namespace? </optarg> 88 - <desc>Checks if the current validation state allows the 89 - element <m>name</m> in the <m>namespace</m> is allowed to 90 - start here. It raises error, if not.</desc> 91 - </optdef> 92 - 93 - <optdef> 94 - <optname>end</optname> 95 - <desc>Checks if the current innermost open element may end 96 - here in the current state without violate validation 97 - constrains. It raises error, if not.</desc> 98 - </optdef> 99 - 100 - <optdef> 101 - <optname>text</optname> 102 - <optarg>text</optarg> 103 - <desc>Checks if the current validation state allows the 104 - given text content. It raises error, if not.</desc> 105 - </optdef> 106 - 107 - </optlist> 108 - </desc> 109 - </commanddef> 110 - 111 - <commanddef> 112 - <command><method>validate</method> <m><XML string></m> <m>?objVar?</m></command> 113 - <desc>Returns true if the <m><XML string></m> is valid or 114 - false otherwise. If validation failed and the optional 115 - <m>objVar</m> argument is given, then the variable with that 116 - name is set to a validation error message.</desc> 117 - </commanddef> 118 - 119 - <commanddef> 120 - <command><method>delete</method></command> 121 - <desc>This method deletes the validation command.</desc> 122 - </commanddef> 123 - 124 - <commanddef> 125 - <command><method>state</method></command> 126 - <desc>This method returns the state of the validation command with respect to validation state. The possible return values and their meanings are: 127 - <dl> 128 - <dt>READY</dt><dd>The validation command is ready to start 129 - validation</dd> 130 - <dt>VALIDATING</dt><dd>The validation command is in the 131 - process of validating input.</dd> 132 - <dt>FINISHED</dt><dd>The validation has finished, no futher 133 - events are expected.</dd> 134 - </dl> 135 - </desc> 136 - </commanddef> 137 - 138 - <commanddef> 139 - <command><method>reset</method></command> 140 - <desc>This method resets the validation command into state 141 - READY (while preserving the defined grammer).</desc> 142 - </commanddef> 143 - 144 - </commandlist> 145 - </section> 146 - 147 - <section> 148 - <title>Structure definition scripts</title> 149 - 150 - <p>Structure definition scripts are ordinary Tcl scripts that are 151 - evaluatend in the namespace tdom::structure. Several structure 152 - definition commands in this tcl namespace allow to define a wide 153 - variety of document structures. Every structure definition command 154 - establish a validation constrain on the content which all has to 155 - match, leaving no unmatched content to render the content as 156 - valid.</p> 157 - 158 - <p>The structure definition commands are:</p> 159 - 160 - <commandlist> 161 - <commanddef> 162 - <command><method>element</method> <m>name</m> <m>?quant?</m> <m>?<definition script>?</m></command> 163 - <desc>This command refers to the element defined with 164 - <m>defelement</m> with the name <m>name</m> in the current context 165 - namespace. Forward references to a so far not defined element 166 - or recursive references are allowed.</desc> 167 - </commanddef> 168 - 169 - <commanddef> 170 - <command><method>ref</method> <m>name</m> <m>?quant?</m></command> 171 - <desc>This command refers to the content particle defined with 172 - <m>defpattern</m> with the name <m>name</m> in the current context 173 - namespace. Forward references to a so far not defined pattern 174 - or recursive references are allowed.</desc> 175 - </commanddef> 176 - 177 - <commanddef> 178 - <command><method>group</method> <m>?quant?</m> <m><definition script></m></command> 179 - <desc></desc> 180 - </commanddef> 181 - 182 - <commanddef> 183 - <command><method>choice</method> <m>?quant?</m> <m><definition script></m></command> 184 - <desc></desc> 185 - </commanddef> 186 - 187 - <commanddef> 188 - <command><method>interleave</method> <m>?quant?</m> <m><definition script></m></command> 189 - <desc></desc> 190 - </commanddef> 191 - 192 - <commanddef> 193 - <command><method>mixed</method> <m>?quant?</m> <m><definition script></m></command> 194 - <desc></desc> 195 - </commanddef> 196 - 197 - <commanddef> 198 - <command><method>text</method> <m><definition script></m></command> 199 - <desc></desc> 200 - </commanddef> 201 - 202 - <commanddef> 203 - <command><method>any</method></command> 204 - <desc></desc> 205 - </commanddef> 206 - 207 - <commanddef> 208 - <command><method>attribute</method> <m><definition script></m></command> 209 - <desc></desc> 210 - </commanddef> 211 - 212 - <commanddef> 213 - <command><method>namespace</method> <m><definition script></m></command> 214 - <desc></desc> 215 - </commanddef> 216 - 217 - <commanddef> 218 - <command><method>empty</method></command> 219 - <desc></desc> 220 - </commanddef> 221 - 222 - <commanddef> 223 - <command><method>defelement</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 224 - <desc></desc> 225 - </commanddef> 226 - 227 - <commanddef> 228 - <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> 229 - <desc></desc> 230 - </commanddef> 231 - 232 - <commanddef> 233 - <command><method>start</method> <m>name</m> <m>?namespace?</m></command> 234 - <desc></desc> 235 - </commanddef> 236 - </commandlist> 237 - 238 - </section> 239 - 240 - <section> 241 - <title>Quantity specifier</title> 242 - 243 - <p>Serveral structure definition commands expects a quantifier as 244 - one of their arguments, which specifies how often the content 245 - particle specified by the command is expected. The valid values 246 - for a <m>quant</m> argument are:</p> 247 - 248 - <optlist> 249 - <optdef> 250 - <optname>!</optname> 251 - <desc>The content particle must occur exactly once in valid 252 - documents.</desc> 253 - </optdef> 254 - 255 - <optdef> 256 - <optname>?</optname> 257 - <desc>The content particle must occur at most once in valid 258 - documents.</desc> 259 - </optdef> 260 - 261 - <optdef> 262 - <optname>*</optname> 263 - <desc>The content particle may occur zero or more times in a 264 - row in valid documents.</desc> 265 - </optdef> 266 - 267 - <optdef> 268 - <optname>+</optname> 269 - <desc>The content particle may occur one or more times in a 270 - row in valid documents.</desc> 271 - </optdef> 272 - 273 - <optdef> 274 - <optname>n</optname> 275 - <desc>The content particle must occur n times in a row in 276 - valid documents. The quantifier must be an integer greater 277 - zero.</desc> 278 - </optdef> 279 - 280 - <optdef> 281 - <optname>{n m}</optname> <desc>The content particle must occur 282 - n to m times (both inclusive) in a row in valid documents. The 283 - quantifier must be a tcl list with two elements. Both elements 284 - must be integers, with n >= 0 and n < m.</desc> 285 - </optdef> 286 - </optlist> 287 - 288 - <p>If an optional quantifier is missing then it defaults to ! - 289 - the content particle must occur exactly once in valid 290 - documents.</p> 291 - 292 - </section> 293 - 294 - <section> 295 - <title>Exampels</title> 296 - 297 - <p>The XML Schema Part 0: Primer Second Edition 298 - (<url>https://www.w3.org/TR/xmlschema-0/</url>) starts with this 299 - example schema:</p> 300 - 301 - <example> 302 -<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 303 - 304 - <xsd:annotation> 305 - <xsd:documentation xml:lang="en"> 306 - Purchase order schema for Example.com. 307 - Copyright 2000 Example.com. All rights reserved. 308 - </xsd:documentation> 309 - </xsd:annotation> 310 - 311 - <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> 312 - 313 - <xsd:element name="comment" type="xsd:string"/> 314 - 315 - <xsd:complexType name="PurchaseOrderType"> 316 - <xsd:sequence> 317 - <xsd:element name="shipTo" type="USAddress"/> 318 - <xsd:element name="billTo" type="USAddress"/> 319 - <xsd:element ref="comment" minOccurs="0"/> 320 - <xsd:element name="items" type="Items"/> 321 - </xsd:sequence> 322 - <xsd:attribute name="orderDate" type="xsd:date"/> 323 - </xsd:complexType> 324 - 325 - <xsd:complexType name="USAddress"> 326 - <xsd:sequence> 327 - <xsd:element name="name" type="xsd:string"/> 328 - <xsd:element name="street" type="xsd:string"/> 329 - <xsd:element name="city" type="xsd:string"/> 330 - <xsd:element name="state" type="xsd:string"/> 331 - <xsd:element name="zip" type="xsd:decimal"/> 332 - </xsd:sequence> 333 - <xsd:attribute name="country" type="xsd:NMTOKEN" 334 - fixed="US"/> 335 - </xsd:complexType> 336 - 337 - <xsd:complexType name="Items"> 338 - <xsd:sequence> 339 - <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> 340 - <xsd:complexType> 341 - <xsd:sequence> 342 - <xsd:element name="productName" type="xsd:string"/> 343 - <xsd:element name="quantity"> 344 - <xsd:simpleType> 345 - <xsd:restriction base="xsd:positiveInteger"> 346 - <xsd:maxExclusive value="100"/> 347 - </xsd:restriction> 348 - </xsd:simpleType> 349 - </xsd:element> 350 - <xsd:element name="USPrice" type="xsd:decimal"/> 351 - <xsd:element ref="comment" minOccurs="0"/> 352 - <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> 353 - </xsd:sequence> 354 - <xsd:attribute name="partNum" type="SKU" use="required"/> 355 - </xsd:complexType> 356 - </xsd:element> 357 - </xsd:sequence> 358 - </xsd:complexType> 359 - 360 - <!-- Stock Keeping Unit, a code for identifying products --> 361 - <xsd:simpleType name="SKU"> 362 - <xsd:restriction base="xsd:string"> 363 - <xsd:pattern value="\d{3}-[A-Z]{2}"/> 364 - </xsd:restriction> 365 - </xsd:simpleType> 366 - 367 -</xsd:schema> 368 - </example> 369 - 370 - <p>A somewhat one-to-one translation of that into a tDOM structure 371 - defintion script would be:</p> 372 - 373 - <example> 374 -tdom::structure grammar 375 -grammar define { 376 - 377 - # Purchase order schema for Example.com. 378 - # Copyright 2000 Example.com. All rights reserved. 379 - 380 - element purchaseOrder {ref PurchaseOrderType} 381 - 382 - element comment {text} 383 - 384 - defpattern PurchaseOrderType { 385 - element shipTo {ref USAddress} 386 - element billTo {ref USAddress} 387 - element comment ? 388 - element items 389 - attribute orderDate 390 - } 391 - 392 - defpattern USAddress { 393 - element name ! {text} 394 - element street ! {text} 395 - element city ! {text} 396 - element state ! {text} 397 - element zip ! {text isNumber} 398 - attribute country ! {text {fixed "US"}} 399 - } 400 - 401 - defelement items { 402 - element item * { 403 - element product ! {text} 404 - element quntity ! {text {maxExcluse 100}} 405 - element USPrice ! {text isNumber} 406 - element comment 407 - element shipDate ? {text isDate} 408 - attribute partNum ! {text {pattern "\d{3}-[A-Z]{2}"}} 409 - } 410 - } 411 -} 412 - 413 - </example> 414 - 415 - <p>The RELAX NG Tutorial 416 - (<url>http://relaxng.org/tutorial-20011203.html</url>) starts with 417 - this example:</p> 418 - 419 - <example> 420 -Consider a simple XML representation of an email address book: 421 - 422 -<addressBook> 423 - <card> 424 - <name>John Smith</name> 425 - <email>js@example.com</email> 426 - </card> 427 - <card> 428 - <name>Fred Bloggs</name> 429 - <email>fb@example.net</email> 430 - </card> 431 -</addressBook> 432 - 433 -The DTD would be as follows: 434 - 435 -<!DOCTYPE addressBook [ 436 -<!ELEMENT addressBook (card*)> 437 -<!ELEMENT card (name, email)> 438 -<!ELEMENT name (#PCDATA)> 439 -<!ELEMENT email (#PCDATA)> 440 -]> 441 - 442 -A RELAX NG pattern for this could be written as follows: 443 - 444 -<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> 445 - <zeroOrMore> 446 - <element name="card"> 447 - <element name="name"> 448 - <text/> 449 - </element> 450 - <element name="email"> 451 - <text/> 452 - </element> 453 - </element> 454 - </zeroOrMore> 455 -</element> 456 - 457 - </example> 458 - 459 - <p>This structure definition script will do the same:</p> 460 - 461 - <example> 462 -tdom::structure grammar 463 -grammar define { 464 - defelement addressBook { 465 - element card * 466 - } 467 - defelement card { 468 - element name 469 - element email 470 - } 471 - foreach e {name email} { 472 - defelement $e {text} 473 - } 474 -} 475 - 476 - </example> 477 - </section> 478 -</manpage>
Changes to doc/tDOM.xml.
1 1 <!DOCTYPE manual PUBLIC "-//jenglish//DTD TMML 0.5//EN" "tmml.dtd" [ 2 2 <!ENTITY dom SYSTEM "dom.xml"> 3 3 <!ENTITY domDoc SYSTEM "domDoc.xml"> 4 4 <!ENTITY domNode SYSTEM "domNode.xml"> 5 5 <!ENTITY expat SYSTEM "expat.xml"> 6 6 <!ENTITY expatapi SYSTEM "expatapi.xml"> 7 7 <!ENTITY pullparser SYSTEM "pullparser.xml"> 8 -<!ENTITY structure SYSTEM "structure.xml"> 8 +<!ENTITY schema SYSTEM "schema.xml"> 9 9 <!ENTITY tdomcmd SYSTEM "tdomcmd.xml"> 10 10 <!ENTITY tnc SYSTEM "tnc.xml"> 11 11 ]> 12 12 <manual package="tDOM"> 13 13 <title>tDOM manual</title> 14 14 15 15 &dom; ................................................................................ 20 20 21 21 &expat; 22 22 23 23 &expatapi; 24 24 25 25 &pullparser; 26 26 27 -&structure; 27 +&schema; 28 28 29 29 &tdomcmd; 30 30 31 31 &tnc; 32 32 33 33 </manual> 34 34
Changes to doc/tdomcmd.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: tdom</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0x1e30200">NAME</a> · <a href="#SECTid0x1f5add0">SYNOPSIS</a> · <a href="#SECTid0x1e4db90">DESCRIPTION</a> · <a href="#SECTid0x1f20b70">SEE ALSO</a> · <a href="#SECTid0x1f20f00">KEYWORDS</a> 7 +<a href="#SECTid0x5569427af2d0">NAME</a> · <a href="#SECTid0x556942762ce0">SYNOPSIS</a> · <a href="#SECTid0x5569428a4a30">DESCRIPTION</a> · <a href="#SECTid0x55694282bb80">SEE ALSO</a> · <a href="#SECTid0x55694282bf40">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0x1e30200">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x5569427af2d0">NAME</a></h2><p class="namesection"> 11 11 <b class="names">tdom - </b><br>tdom is an expat parser object extension to create an in-memory 12 12 DOM tree from the input while parsing.</p> 13 13 14 14 15 - <h2><a name="SECTid0x1f5add0">SYNOPSIS</a></h2><pre class="syntax">package require tdom 15 + <h2><a name="SECTid0x556942762ce0">SYNOPSIS</a></h2><pre class="syntax">package require tdom 16 16 17 17 set parser [expat] 18 18 19 19 tdom $parser enable</pre> 20 20 21 - <h2><a name="SECTid0x1e4db90">DESCRIPTION</a></h2><p> 21 + <h2><a name="SECTid0x5569428a4a30">DESCRIPTION</a></h2><p> 22 22 <i class="m">tdom</i> adds the C handler set "tdom" to an tcl expat 23 23 parser obj. This handler set builds an in-memory DOM tree out of the input, 24 24 parsed by the parser. A DOM tree created this way behave exactly like a DOM 25 25 tree created by the "dom" command (see there). In fact, tdom is only 26 26 another interface to the same functionality; it uses the code behind the 27 27 <tt class="samp">dom</tt> code for building the DOM tree.</p><dl class="commandlist"> 28 28 ................................................................................ 73 73 <b class="cmd">tdom</b> <i class="m">parserObj</i> <b class="method">setExternalEntityResolver</b> <i class="m">script</i> 74 74 </dt> 75 75 <dd></dd> 76 76 77 77 78 78 </dl> 79 79 80 - <h2><a name="SECTid0x1f20b70">SEE ALSO</a></h2><p class="seealso">dom, expat</p> 80 + <h2><a name="SECTid0x55694282bb80">SEE ALSO</a></h2><p class="seealso">dom, expat</p> 81 81 82 - <h2><a name="SECTid0x1f20f00">KEYWORDS</a></h2><p class="keywords"> 82 + <h2><a name="SECTid0x55694282bf40">KEYWORDS</a></h2><p class="keywords"> 83 83 <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-SAX">SAX</a>, <a class="keyword" href="keyword-index.html#KW-Chandlerset">C handler set</a> 84 84 </p> 85 85 86 86 </div><hr class="navsep"><div class="navbar" align="center"> 87 87 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 88 88 </div> 89 89 </body> 90 90 </html>
Added doc/tmml.schema.
1 +start manpage 2 +defelement manpage { 3 + attribute version ? 4 + attribute title 5 + attribute id 6 + attribute cat 7 + attribute package ? 8 + element head ? 9 + element namesection 10 + element synopsis ? 11 + element section * 12 + element seealso ? 13 + element keywords ? 14 +} 15 +defelement DEF { 16 + attribute cat ? 17 + attribute name 18 + attribute package ? 19 + attribute subpart ? 20 + attribute manpage ? 21 +} 22 +defelement INDEX { 23 + attribute package ? 24 + attribute standalone ? 25 + attribute title 26 + element head ? 27 + choice * { 28 + element MAN 29 + element DEF 30 + element KWD 31 + } 32 +} 33 +defelement KWD { 34 + attribute manpage ? 35 + attribute name 36 +} 37 +defelement MAN { 38 + attribute id 39 + attribute title 40 +} 41 +defelement argdef { 42 + attribute version ? 43 + element argtype 44 + element name 45 + element argmode ? 46 + element desc 47 +} 48 +defelement arglist { 49 + element argdef + 50 +} 51 +defelement argmode { 52 + text 53 +} 54 +defelement argtype { 55 + text 56 +} 57 +defelement b { 58 + attribute cat ? 59 + mixed { 60 + element emph 61 + element ref 62 + element url 63 + element samp 64 + element command 65 + element new 66 + element m 67 + element l 68 + element o 69 + element i 70 + element b 71 + element br 72 + element term 73 + element cmd 74 + element variable 75 + element method 76 + element option 77 + element file 78 + element syscmd 79 + element fun 80 + element widget 81 + element package 82 + element type 83 + element class 84 + } 85 +} 86 +defelement br { 87 +} 88 +defelement categories { 89 + element category + 90 +} 91 +defelement category { 92 + attribute title ? 93 + attribute id 94 +} 95 +defelement class { 96 + text 97 +} 98 +defelement cmd { 99 + text 100 +} 101 +defelement command { 102 + mixed { 103 + element new 104 + element m 105 + element l 106 + element o 107 + element i 108 + element b 109 + element br 110 + element term 111 + element cmd 112 + element variable 113 + element method 114 + element option 115 + element file 116 + element syscmd 117 + element fun 118 + element widget 119 + element package 120 + element type 121 + element class 122 + } 123 +} 124 +defelement commanddef { 125 + attribute version ? 126 + element command 127 + element desc 128 +} 129 +defelement commandlist { 130 + element commanddef + 131 +} 132 +defelement dbclass { 133 + text 134 +} 135 +defelement dbname { 136 + text 137 +} 138 +defelement dd { 139 + mixed { 140 + element emph 141 + element ref 142 + element url 143 + element samp 144 + element command 145 + element new 146 + element m 147 + element l 148 + element o 149 + element i 150 + element b 151 + element br 152 + element term 153 + element cmd 154 + element variable 155 + element method 156 + element option 157 + element file 158 + element syscmd 159 + element fun 160 + element widget 161 + element package 162 + element type 163 + element class 164 + element p 165 + element ul 166 + element ol 167 + element dl 168 + element sl 169 + element xl 170 + element example 171 + element syntax 172 + element commandlist 173 + element optlist 174 + } 175 +} 176 +defelement desc { 177 + mixed { 178 + element emph 179 + element ref 180 + element url 181 + element samp 182 + element command 183 + element new 184 + element m 185 + element l 186 + element o 187 + element i 188 + element b 189 + element br 190 + element term 191 + element cmd 192 + element variable 193 + element method 194 + element option 195 + element file 196 + element syscmd 197 + element fun 198 + element widget 199 + element package 200 + element type 201 + element class 202 + element p 203 + element ul 204 + element ol 205 + element dl 206 + element sl 207 + element xl 208 + element example 209 + element syntax 210 + element commandlist 211 + element optlist 212 + } 213 +} 214 +defelement division { 215 + element title 216 + choice { 217 + element division * 218 + choice * { 219 + element manpage 220 + element subdoc 221 + element extref 222 + } 223 + } 224 +} 225 +defelement dl { 226 + attribute cat ? 227 + attribute scope ? {enumeration {local global}} 228 + choice + { 229 + element dle 230 + group { 231 + element dt 232 + element dd 233 + } 234 + } 235 +} 236 +defelement dle { 237 + attribute version ? 238 + element dt + 239 + element dd 240 +} 241 +defelement dt { 242 + mixed { 243 + element emph 244 + element ref 245 + element url 246 + element samp 247 + element command 248 + element new 249 + element m 250 + element l 251 + element o 252 + element i 253 + element b 254 + element br 255 + element term 256 + element cmd 257 + element variable 258 + element method 259 + element option 260 + element file 261 + element syscmd 262 + element fun 263 + element widget 264 + element package 265 + element type 266 + element class 267 + } 268 +} 269 +defelement emph { 270 + mixed { 271 + element emph 272 + element ref 273 + element url 274 + element samp 275 + element command 276 + element new 277 + element m 278 + element l 279 + element o 280 + element i 281 + element b 282 + element br 283 + element term 284 + element cmd 285 + element variable 286 + element method 287 + element option 288 + element file 289 + element syscmd 290 + element fun 291 + element widget 292 + element package 293 + element type 294 + element class 295 + } 296 +} 297 +defelement example { 298 + mixed { 299 + element new 300 + element m 301 + element l 302 + element o 303 + element i 304 + element b 305 + element br 306 + element term 307 + element cmd 308 + element variable 309 + element method 310 + element option 311 + element file 312 + element syscmd 313 + element fun 314 + element widget 315 + element package 316 + element type 317 + element class 318 + } 319 +} 320 +defelement extension { 321 + attribute gi 322 + attribute tmml 323 +} 324 +defelement extensions { 325 + choice * { 326 + element extension 327 + element xlh 328 + } 329 +} 330 +defelement extref { 331 + attribute title 332 + attribute href 333 + attribute type 334 +} 335 +defelement file { 336 + text 337 +} 338 +defelement fun { 339 + text 340 +} 341 +defelement head { 342 + choice * { 343 + element extensions 344 + element info 345 + element link 346 + element category 347 + } 348 +} 349 +defelement i { 350 + attribute cat ? 351 + mixed { 352 + element emph 353 + element ref 354 + element url 355 + element samp 356 + element command 357 + element new 358 + element m 359 + element l 360 + element o 361 + element i 362 + element b 363 + element br 364 + element term 365 + element cmd 366 + element variable 367 + element method 368 + element option 369 + element file 370 + element syscmd 371 + element fun 372 + element widget 373 + element package 374 + element type 375 + element class 376 + } 377 +} 378 +defelement info { 379 + attribute key 380 + attribute value 381 +} 382 +defelement keyword { 383 + text 384 +} 385 +defelement keywords { 386 + element keyword + 387 +} 388 +defelement l { 389 + text 390 +} 391 +defelement li { 392 + attribute version ? 393 + mixed { 394 + element emph 395 + element ref 396 + element url 397 + element samp 398 + element command 399 + element new 400 + element m 401 + element l 402 + element o 403 + element i 404 + element b 405 + element br 406 + element term 407 + element cmd 408 + element variable 409 + element method 410 + element option 411 + element file 412 + element syscmd 413 + element fun 414 + element widget 415 + element package 416 + element type 417 + element class 418 + element p 419 + element ul 420 + element ol 421 + element dl 422 + element sl 423 + element xl 424 + element example 425 + element syntax 426 + element commandlist 427 + element optlist 428 + } 429 +} 430 +defelement link { 431 + attribute href 432 + attribute rel 433 +} 434 +defelement m { 435 + text 436 +} 437 +defelement manual { 438 + attribute version ? 439 + attribute package 440 + element title 441 + element head ? 442 + choice { 443 + element division * 444 + choice * { 445 + element manpage 446 + element subdoc 447 + element extref 448 + } 449 + } 450 +} 451 +defelement method { 452 + text 453 +} 454 +defelement name { 455 + attribute cat ? 456 + attribute name ? 457 + text 458 +} 459 +defelement namesection { 460 + choice { 461 + element name + 462 + group { 463 + element title 464 + element name * 465 + } 466 + } 467 + element desc 468 +} 469 +defelement new { 470 + attribute version 471 + mixed { 472 + element emph 473 + element ref 474 + element url 475 + element samp 476 + element command 477 + element new 478 + element m 479 + element l 480 + element o 481 + element i 482 + element b 483 + element br 484 + element term 485 + element cmd 486 + element variable 487 + element method 488 + element option 489 + element file 490 + element syscmd 491 + element fun 492 + element widget 493 + element package 494 + element type 495 + element class 496 + } 497 +} 498 +defelement o { 499 + mixed { 500 + element new 501 + element m 502 + element l 503 + element o 504 + element i 505 + element b 506 + element br 507 + element term 508 + element cmd 509 + element variable 510 + element method 511 + element option 512 + element file 513 + element syscmd 514 + element fun 515 + element widget 516 + element package 517 + element type 518 + element class 519 + } 520 +} 521 +defelement ol { 522 + element li + 523 +} 524 +defelement optarg { 525 + text 526 +} 527 +defelement optdef { 528 + element optname 529 + element optarg ? 530 + element desc 531 +} 532 +defelement option { 533 + text 534 +} 535 +defelement optiondef { 536 + attribute version ? 537 + element name 538 + element dbname 539 + element dbclass 540 + element desc 541 +} 542 +defelement optionlist { 543 + attribute cat ? 544 + attribute scope ? {enumeration {local global}} 545 + element optiondef + 546 +} 547 +defelement optlist { 548 + element optdef + 549 +} 550 +defelement optname { 551 + text 552 +} 553 +defelement p { 554 + attribute version ? 555 + mixed { 556 + element emph 557 + element ref 558 + element url 559 + element samp 560 + element command 561 + element new 562 + element m 563 + element l 564 + element o 565 + element i 566 + element b 567 + element br 568 + element term 569 + element cmd 570 + element variable 571 + element method 572 + element option 573 + element file 574 + element syscmd 575 + element fun 576 + element widget 577 + element package 578 + element type 579 + element class 580 + } 581 +} 582 +defelement package { 583 + text 584 +} 585 +defelement ref { 586 + attribute cat ? 587 + attribute href ? 588 + attribute refid ? 589 + mixed { 590 + element emph 591 + element ref 592 + element url 593 + element samp 594 + element command 595 + element new 596 + element m 597 + element l 598 + element o 599 + element i 600 + element b 601 + element br 602 + element term 603 + element cmd 604 + element variable 605 + element method 606 + element option 607 + element file 608 + element syscmd 609 + element fun 610 + element widget 611 + element package 612 + element type 613 + element class 614 + } 615 +} 616 +defelement samp { 617 + mixed { 618 + element new 619 + element m 620 + element l 621 + element o 622 + element i 623 + element b 624 + element br 625 + element term 626 + element cmd 627 + element variable 628 + element method 629 + element option 630 + element file 631 + element syscmd 632 + element fun 633 + element widget 634 + element package 635 + element type 636 + element class 637 + } 638 +} 639 +defelement section { 640 + attribute id ? 641 + attribute version ? 642 + element title 643 + choice * { 644 + element p 645 + element ul 646 + element ol 647 + element dl 648 + element sl 649 + element xl 650 + element example 651 + element syntax 652 + element commandlist 653 + element optlist 654 + element arglist 655 + element optionlist 656 + } 657 + element subsection * 658 +} 659 +defelement seealso { 660 + choice + { 661 + element ref 662 + element url 663 + } 664 +} 665 +defelement sl { 666 + attribute cols ? 667 + attribute cat ? 668 + element li + 669 +} 670 +defelement subdoc { 671 + attribute href 672 +} 673 +defelement subsection { 674 + attribute id ? 675 + attribute version ? 676 + element title 677 + choice * { 678 + element p 679 + element ul 680 + element ol 681 + element dl 682 + element sl 683 + element xl 684 + element example 685 + element syntax 686 + element commandlist 687 + element optlist 688 + element arglist 689 + element optionlist 690 + } 691 +} 692 +defelement synopsis { 693 + choice + { 694 + element syntax 695 + element example 696 + } 697 +} 698 +defelement syntax { 699 + attribute name ? 700 + attribute scope ? {enumeration {local global}} 701 + attribute cat ? 702 + mixed { 703 + element new 704 + element m 705 + element l 706 + element o 707 + element i 708 + element b 709 + element br 710 + element term 711 + element cmd 712 + element variable 713 + element method 714 + element option 715 + element file 716 + element syscmd 717 + element fun 718 + element widget 719 + element package 720 + element type 721 + element class 722 + } 723 +} 724 +defelement syscmd { 725 + text 726 +} 727 +defelement term { 728 + attribute cat ? 729 + text 730 +} 731 +defelement title { 732 + text 733 +} 734 +defelement type { 735 + text 736 +} 737 +defelement ul { 738 + element li + 739 +} 740 +defelement url { 741 + text 742 +} 743 +defelement variable { 744 + text 745 +} 746 +defelement widget { 747 + text 748 +} 749 +defelement xh { 750 + mixed { 751 + element emph 752 + element ref 753 + element url 754 + element samp 755 + element command 756 + element new 757 + element m 758 + element l 759 + element o 760 + element i 761 + element b 762 + element br 763 + element term 764 + element cmd 765 + element variable 766 + element method 767 + element option 768 + element file 769 + element syscmd 770 + element fun 771 + element widget 772 + element package 773 + element type 774 + element class 775 + } 776 +} 777 +defelement xl { 778 + element xlh ? 779 + element xle + 780 +} 781 +defelement xle { 782 + element xt + 783 + element desc ? 784 +} 785 +defelement xlh { 786 + attribute gi ? 787 + element xh + 788 +} 789 +defelement xt { 790 + mixed { 791 + element emph 792 + element ref 793 + element url 794 + element samp 795 + element command 796 + element new 797 + element m 798 + element l 799 + element o 800 + element i 801 + element b 802 + element br 803 + element term 804 + element cmd 805 + element variable 806 + element method 807 + element option 808 + element file 809 + element syscmd 810 + element fun 811 + element widget 812 + element package 813 + element type 814 + element class 815 + } 816 +}
Changes to doc/tnc.html.
1 1 <html> 2 2 <head> 3 3 <link rel="stylesheet" href="manpage.css"><title>tDOM manual: tnc</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> 4 4 </head><body> 5 5 <div class="header"> 6 6 <div class="navbar" align="center"> 7 -<a href="#SECTid0x1ee4b70">NAME</a> · <a href="#SECTid0x1d90950">SYNOPSIS</a> · <a href="#SECTid0x1ec21b0">DESCRIPTION</a> · <a href="#SECTid0x1ebb7b0">BUGS</a> · <a href="#SECTid0x1ebc120">KEYWORDS</a> 7 +<a href="#SECTid0x556942859350">NAME</a> · <a href="#SECTid0x5569427635a0">SYNOPSIS</a> · <a href="#SECTid0x556942762640">DESCRIPTION</a> · <a href="#SECTid0x556942954d40">BUGS</a> · <a href="#SECTid0x5569429556b0">KEYWORDS</a> 8 8 </div><hr class="navsep"> 9 9 </div><div class="body"> 10 - <h2><a name="SECTid0x1ee4b70">NAME</a></h2><p class="namesection"> 10 + <h2><a name="SECTid0x556942859350">NAME</a></h2><p class="namesection"> 11 11 <b class="names">tnc - </b><br>tnc is an expat parser object extension, that validates the XML 12 12 stream against the document DTD while parsing.</p> 13 13 14 - <h2><a name="SECTid0x1d90950">SYNOPSIS</a></h2><pre class="syntax">package require tdom 14 + <h2><a name="SECTid0x5569427635a0">SYNOPSIS</a></h2><pre class="syntax">package require tdom 15 15 package require tnc 16 16 17 17 set parser [expat] 18 18 19 19 tnc $parser enable</pre> 20 20 21 - <h2><a name="SECTid0x1ec21b0">DESCRIPTION</a></h2><p> 21 + <h2><a name="SECTid0x556942762640">DESCRIPTION</a></h2><p> 22 22 <i class="m">tnc</i> adds the C handler set "tnc" to a tcl expat parser 23 23 obj. This handler set is a simple DTD validator. If the validator detects a 24 24 validation error, it sets the interp result, signals error and stops 25 25 parsing. There isn't any validation error recovering. As a consequence, only 26 26 valid documents are completely parsed.</p><p>This handler set has only three methods:</p><dl class="commandlist"> 27 27 28 28 <dt> ................................................................................ 116 116 117 117 118 118 </dl> 119 119 </dd> 120 120 121 121 </dl> 122 122 123 - <h2><a name="SECTid0x1ebb7b0">BUGS</a></h2><p>The validation error reports could be much more informative and 123 + <h2><a name="SECTid0x556942954d40">BUGS</a></h2><p>The validation error reports could be much more informative and 124 124 user-friendly.</p><p>The validator doesn't detect ambiguous content models (see XML 125 125 recomendation Section 3.2.1 and Appendix E). Most Java validators also doesn't, 126 126 but handle such content models right anyhow. Tnc does not; if your DTD has 127 127 such ambiguous content models, tnc can not used to validate documents against 128 128 such (not completely XML spec compliant) DTDs.</p><p>It isn't possible to validate XML documents with standalone="yes" in the 129 129 XML Declaration</p><p>Violations of the validity constraints Proper Group/PE Nesting and 130 130 Proper Conditional Section/PE Nesting are not detected. They could only happen 131 131 inside a invalid DTD, not in the content of a document.</p> 132 - <h2><a name="SECTid0x1ebc120">KEYWORDS</a></h2><p class="keywords"> 132 + <h2><a name="SECTid0x5569429556b0">KEYWORDS</a></h2><p class="keywords"> 133 133 <a class="keyword" href="keyword-index.html#KW-Validation">Validation</a>, <a class="keyword" href="keyword-index.html#KW-DTD">DTD</a> 134 134 </p> 135 135 136 136 </div><hr class="navsep"><div class="navbar" align="center"> 137 137 <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> 138 138 </div> 139 139 </body> 140 140 </html>
Changes to expat/Changes.
1 1 NOTE: We are looking for help with a few things: 2 2 https://github.com/libexpat/libexpat/labels/help%20wanted 3 3 If you can help, please get in touch. Thanks! 4 + 5 +Release 2.2.9 Wed Septemper 25 2019 6 + Other changes: 7 + examples: Drop executable bits from elements.c 8 + #349 Windows: Change the name of the Windows DLLs from expat*.dll 9 + to libexpat*.dll once more (regression from 2.2.8, first 10 + fixed in 1.95.3, issue #61 on SourceForge today, 11 + was issue #432456 back then); needs a fix due 12 + case-insensitive file systems on Windows and the fact that 13 + Perl's XML::Parser::Expat compiles into Expat.dll. 14 + #347 Windows: Only define _CRT_RAND_S if not defined 15 + Version info bumped from 7:10:6 to 7:11:6 16 + 17 + Special thanks to: 18 + Ben Wagner 19 + 20 +Release 2.2.8 Fri Septemper 13 2019 21 + Security fixes: 22 + #317 #318 CVE-2019-15903 -- Fix heap overflow triggered by 23 + XML_GetCurrentLineNumber (or XML_GetCurrentColumnNumber), 24 + and deny internal entities closing the doctype; 25 + fixed in commit c20b758c332d9a13afbbb276d30db1d183a85d43 26 + 27 + Bug fixes: 28 + #240 Fix cases where XML_StopParser did not have any effect 29 + when called from inside of an end element handler 30 + #341 xmlwf: Fix exit code for operation without "-d DIRECTORY"; 31 + previously, only "-d DIRECTORY" would give you a proper 32 + exit code: 33 + # xmlwf -d . <<<'<not well-formed>' 2>/dev/null ; echo $? 34 + 2 35 + # xmlwf <<<'<not well-formed>' 2>/dev/null ; echo $? 36 + 0 37 + Now both cases return exit code 2. 38 + 39 + Other changes: 40 + #299 #302 Windows: Replace LoadLibrary hack to access 41 + unofficial API function SystemFunction036 (RtlGenRandom) 42 + by using official API function rand_s (needs WinXP+) 43 + #325 Windows: Drop support for Visual Studio <=7.1/2003 44 + and document supported compilers in README.md 45 + #286 Windows: Remove COM code from xmlwf; in case it turns 46 + out needed later, there will be a dedicated repository 47 + below https://github.com/libexpat/ for that code 48 + #322 Windows: Remove explicit MSVC solution and project files. 49 + You can generate Visual Studio solution files through 50 + CMake, e.g.: cmake -G"Visual Studio 15 2017" . 51 + #338 xmlwf: Make "xmlwf -h" help output more friendly 52 + #339 examples: Improve elements.c 53 + #244 #264 Autotools: Add argument --enable-xml-attr-info 54 + #239 #301 Autotools: Add arguments 55 + --with-getrandom 56 + --without-getrandom 57 + --with-sys-getrandom 58 + --without-sys-getrandom 59 + #312 #343 Autotools: Fix linking issues with "./configure LD=clang" 60 + Autotools: Fix "make run-xmltest" for out-of-source builds 61 + #329 #336 CMake: Pull all options from Expat <=2.2.7 into namespace 62 + prefix EXPAT_ with the exception of DOCBOOK_TO_MAN: 63 + - BUILD_doc -> EXPAT_BUILD_DOCS (plural) 64 + - BUILD_examples -> EXPAT_BUILD_EXAMPLES 65 + - BUILD_shared -> EXPAT_SHARED_LIBS 66 + - BUILD_tests -> EXPAT_BUILD_TESTS 67 + - BUILD_tools -> EXPAT_BUILD_TOOLS 68 + - DOCBOOK_TO_MAN -> DOCBOOK_TO_MAN (unchanged) 69 + - INSTALL -> EXPAT_ENABLE_INSTALL 70 + - MSVC_USE_STATIC_CRT -> EXPAT_MSVC_STATIC_CRT 71 + - USE_libbsd -> EXPAT_WITH_LIBBSD 72 + - WARNINGS_AS_ERRORS -> EXPAT_WARNINGS_AS_ERRORS 73 + - XML_CONTEXT_BYTES -> EXPAT_CONTEXT_BYTES 74 + - XML_DEV_URANDOM -> EXPAT_DEV_URANDOM 75 + - XML_DTD -> EXPAT_DTD 76 + - XML_NS -> EXPAT_NS 77 + - XML_UNICODE -> EXPAT_CHAR_TYPE=ushort (!) 78 + - XML_UNICODE_WCHAR_T -> EXPAT_CHAR_TYPE=wchar_t (!) 79 + #244 #264 CMake: Add argument -DEXPAT_ATTR_INFO=(ON|OFF), 80 + default OFF 81 + #326 CMake: Add argument -DEXPAT_LARGE_SIZE=(ON|OFF), 82 + default OFF 83 + #328 CMake: Add argument -DEXPAT_MIN_SIZE=(ON|OFF), 84 + default OFF 85 + #239 #277 CMake: Add arguments 86 + -DEXPAT_WITH_GETRANDOM=(ON|OFF|AUTO), default AUTO 87 + -DEXPAT_WITH_SYS_GETRANDOM=(ON|OFF|AUTO), default AUTO 88 + #326 CMake: Install expat_config.h to include directory 89 + #326 CMake: Generate and install configuration files for 90 + future find_package(expat [..] CONFIG [..]) 91 + CMake: Now produces a summary of applied configuration 92 + CMake: Require C++ compiler only when tests are enabled 93 + #330 CMake: Fix compilation for 16bit character types, 94 + i.e. ex -DXML_UNICODE=ON (and ex -DXML_UNICODE_WCHAR_T=ON) 95 + #265 CMake: Fix linking with MinGW 96 + #330 CMake: Add full support for MinGW; to enable, use 97 + -DCMAKE_TOOLCHAIN_FILE=[expat]/cmake/mingw-toolchain.cmake 98 + #330 CMake: Port "make run-xmltest" from GNU Autotools to CMake 99 + #316 CMake: Windows: Make binary postfix match MSVC 100 + Old: expat[d].lib 101 + New: expat[w][d][MD|MT].lib 102 + CMake: Migrate files from Windows to Unix line endings 103 + #308 CMake: Integrate OSS-Fuzz fuzzers, option 104 + -DEXPAT_BUILD_FUZZERS=(ON|OFF), default OFF 105 + #14 Drop an OpenVMS support leftover 106 + #235 #268 .. 107 + #270 #310 .. 108 + #313 #331 #333 Address compiler warnings 109 + #282 #283 .. 110 + #284 #285 Address cppcheck warnings 111 + #294 #295 Address Clang Static Analyzer warnings 112 + #24 #293 Mass-apply clang-format 9 (and ensure conformance during CI) 113 + Version info bumped from 7:9:6 to 7:10:6 114 + 115 + Special thanks to: 116 + David Loffredo 117 + Joonun Jang 118 + Khajapasha Mohammed 119 + Kishore Kunche 120 + Marco Maggi 121 + Mitch Phillips 122 + Rolf Ade 123 + xantares 124 + Zhongyuan Zhou 125 + 126 +Release 2.2.7 Wed June 19 2019 127 + Security fixes: 128 + #186 #262 CVE-2018-20843 -- Fix extraction of namespace prefixes from 129 + XML names; XML names with multiple colons could end up in 130 + the wrong namespace, and take a high amount of RAM and CPU 131 + resources while processing, opening the door to 132 + use for denial-of-service attacks 133 + 134 + Other changes: 135 + #195 #197 Autotools/CMake: Utilize -fvisibility=hidden to stop 136 + exporting non-API symbols 137 + #227 Autotools: Add --without-examples and --without-tests 138 + #228 Autotools: Modernize configure.ac 139 + #245 #246 Autotools: Fix check for -fvisibility=hidden for Clang 140 + #247 #248 Autotools: Fix compilation for lack of docbook2x-man 141 + #236 #258 Autotools: Produce .tar.{gz,lz,xz} release archives 142 + #212 CMake: Make libdir of pkgconfig expat.pc support multilib 143 + #158 #263 CMake: Build man page in PROJECT_BINARY_DIR not _SOURCE_DIR 144 + #219 Remove fallback to bcopy, assume that memmove(3) exists 145 + #257 Use portable "/usr/bin/env bash" shebang (e.g. for OpenBSD) 146 + #243 Windows: Fix syntax of .def module definition files 147 + Version info bumped from 7:8:6 to 7:9:6 148 + 149 + Special thanks to: 150 + Benjamin Peterson 151 + Caolán McNamara 152 + Hanno Böck 153 + KangLin 154 + Kishore Kunche 155 + Marco Maggi 156 + Rhodri James 157 + Sebastian Dröge 158 + userwithuid 159 + Yury Gribov 160 + 161 +Release 2.2.6 Sun August 12 2018 162 + Bug fixes: 163 + #170 #206 Avoid doing arithmetic with NULL pointers in XML_GetBuffer 164 + #204 #205 Fix 2.2.5 regression with suspend-resume while parsing 165 + a document like '<root/>' 166 + 167 + Other changes: 168 + #165 #168 Autotools: Fix docbook-related configure syntax error 169 + #166 Autotools: Avoid grep option `-q` for Solaris 170 + #167 Autotools: Support 171 + ./configure DOCBOOK_TO_MAN="xmlto man --skip-validation" 172 + #159 #167 Autotools: Support DOCBOOK_TO_MAN command which produces 173 + xmlwf.1 rather than XMLWF.1; also covers case insensitive 174 + file systems 175 + #181 Autotools: Drop -rpath option passed to libtool 176 + #188 Autotools: Detect and deny SGML docbook2man as ours is XML 177 + #188 Autotools/CMake: Support command db2x_docbook2man as well 178 + #174 CMake: Introduce option WARNINGS_AS_ERRORS, defaults to OFF 179 + #184 #185 CMake: Introduce option MSVC_USE_STATIC_CRT, defaults to OFF 180 + #207 #208 CMake: Introduce option XML_UNICODE and XML_UNICODE_WCHAR_T, 181 + both defaulting to OFF 182 + #175 CMake: Prefer check_symbol_exists over check_function_exists 183 + #176 CMake: Create the same pkg-config file as with GNU Autotools 184 + #178 #179 CMake: Use GNUInstallDirs module to set proper defaults for 185 + install directories 186 + #208 CMake: Utilize expat_config.h.cmake for XML_DEV_URANDOM 187 + #180 Windows: Fix compilation of test suite for Visual Studio 2008 188 + #131 #173 #202 Address compiler warnings 189 + #187 #190 #200 Fix miscellaneous typos 190 + Version info bumped from 7:7:6 to 7:8:6 191 + 192 + Special thanks to: 193 + Anton Maklakov 194 + Benjamin Peterson 195 + Brad King 196 + Franek Korta 197 + Frank Rast 198 + Joe Orton 199 + luzpaz 200 + Pedro Vicente 201 + Rainer Jung 202 + Rhodri James 203 + Rolf Ade 204 + Rolf Eike Beer 205 + Thomas Beutlich 206 + Tomasz Kłoczko 4 207 5 208 Release 2.2.5 Tue October 31 2017 6 209 Bug fixes: 7 210 #8 If the parser runs out of memory, make sure its internal 8 211 state reflects the memory it actually has, not the memory 9 212 it wanted to have. 10 213 #11 The default handler wasn't being called when it should for ................................................................................ 18 221 19 222 Other changes: 20 223 #106 xmlwf: Add argument -N adding notation declarations 21 224 #75 #106 Test suite: Resolve expected failure cases where xmlwf 22 225 output was incomplete 23 226 #127 Windows: Fix test suite compilation 24 227 #126 #127 Windows: Fix compilation for Visual Studio 2012 228 + Windows: Upgrade shipped project files to Visual Studio 2017 25 229 #33 #132 tests: Mass-fix compilation for XML_UNICODE_WCHAR_T 26 230 #129 examples: Fix compilation for XML_UNICODE_WCHAR_T 27 231 #130 benchmark: Fix compilation for XML_UNICODE_WCHAR_T 28 232 #144 xmlwf: Fix compilation for XML_UNICODE_WCHAR_T; still needs 29 233 Windows or MinGW for 2-byte wchar_t 30 234 #9 Address two Clang Static Analyzer false positives 31 235 #59 Resolve troublesome macros hiding parser struct membership
Changes to expat/README.md.
1 1 [](https://travis-ci.org/libexpat/libexpat) 2 2 [](https://ci.appveyor.com/project/libexpat/libexpat) 3 +[](https://repology.org/metapackage/expat/versions) 3 4 4 5 5 -# Expat, Release 2.2.5 6 +# Expat, Release 2.2.9 6 7 7 8 This is Expat, a C library for parsing XML, started by 8 9 [James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997. 9 10 Expat is a stream-oriented XML parser. This means that you register 10 11 handlers with the parser before starting the parse. These handlers 11 12 are called when the parser discovers the associated structures in the 12 13 document being parsed. A start tag is an example of the kind of 13 14 structures for which you may register handlers. 15 + 16 +Expat supports the following compilers: 17 +- GNU GCC >=4.5 18 +- LLVM Clang >=3.5 19 +- Microsoft Visual Studio >=8.0/2005 14 20 15 21 Windows users should use the 16 22 [`expat_win32` package](https://sourceforge.net/projects/expat/files/expat_win32/), 17 23 which includes both precompiled libraries and executables, and source code for 18 24 developers. 19 25 20 26 Expat is [free software](https://www.gnu.org/philosophy/free-sw.en.html). ................................................................................ 120 126 When using Expat with a project using autoconf for configuration, you 121 127 can use the probing macro in `conftools/expat.m4` to determine how to 122 128 include Expat. See the comments at the top of that file for more 123 129 information. 124 130 125 131 A reference manual is available in the file `doc/reference.html` in this 126 132 distribution. 133 + 134 + 135 +The CMake build system is still *experimental* and will replace the primary 136 +build system based on GNU Autotools at some point when it is ready. 137 +For an idea of the available (non-advanced) options for building with CMake: 138 + 139 +```console 140 +# rm -f CMakeCache.txt ; cmake -D_EXPAT_HELP=ON -LH . | grep -B1 ':.*=' | sed 's,^--$,,' 141 +// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ... 142 +CMAKE_BUILD_TYPE:STRING= 143 + 144 +// Install path prefix, prepended onto install directories. 145 +CMAKE_INSTALL_PREFIX:PATH=/usr/local 146 + 147 +// Path to a program. 148 +DOCBOOK_TO_MAN:FILEPATH=/usr/bin/docbook2x-man 149 + 150 +// build man page for xmlwf 151 +EXPAT_BUILD_DOCS:BOOL=ON 152 + 153 +// build the examples for expat library 154 +EXPAT_BUILD_EXAMPLES:BOOL=ON 155 + 156 +// build fuzzers for the expat library 157 +EXPAT_BUILD_FUZZERS:BOOL=OFF 158 + 159 +// build the tests for expat library 160 +EXPAT_BUILD_TESTS:BOOL=ON 161 + 162 +// build the xmlwf tool for expat library 163 +EXPAT_BUILD_TOOLS:BOOL=ON 164 + 165 +// Character type to use (char|ushort|wchar_t) [default=char] 166 +EXPAT_CHAR_TYPE:STRING=char 167 + 168 +// install expat files in cmake install target 169 +EXPAT_ENABLE_INSTALL:BOOL=ON 170 + 171 +// Use /MT flag (static CRT) when compiling in MSVC 172 +EXPAT_MSVC_STATIC_CRT:BOOL=OFF 173 + 174 +// build a shared expat library 175 +EXPAT_SHARED_LIBS:BOOL=ON 176 + 177 +// Treat all compiler warnings as errors 178 +EXPAT_WARNINGS_AS_ERRORS:BOOL=OFF 179 + 180 +// Make use of getrandom function (ON|OFF|AUTO) [default=AUTO] 181 +EXPAT_WITH_GETRANDOM:STRING=AUTO 182 + 183 +// utilize libbsd (for arc4random_buf) 184 +EXPAT_WITH_LIBBSD:BOOL=OFF 185 + 186 +// Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO] 187 +EXPAT_WITH_SYS_GETRANDOM:STRING=AUTO 188 +```
Changes to expat/VERSION.
1 -expat-2.2.5 1 +expat-2.2.9
Changes to expat/asciitab.h.
27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 34 -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 35 -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, 36 -/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, 37 -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 38 -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 39 -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 40 -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 41 -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, 42 -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, 43 -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, 44 -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, 45 -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 46 -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 47 -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, 48 -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, 49 -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 50 -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 51 -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 52 -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 53 -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 54 -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 55 -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, 56 -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, 57 -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 58 -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 59 -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 60 -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 61 -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 62 -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 63 -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 64 -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, 34 + /* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 35 + /* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, 36 + /* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, 37 + /* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 38 + /* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 39 + /* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 40 + /* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 41 + /* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, 42 + /* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, 43 + /* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, 44 + /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, 45 + /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 46 + /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 47 + /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, 48 + /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, 49 + /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 50 + /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 51 + /* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 52 + /* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 53 + /* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 54 + /* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 55 + /* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, 56 + /* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, 57 + /* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 58 + /* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 59 + /* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 60 + /* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 61 + /* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 62 + /* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 63 + /* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 64 + /* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
Changes to expat/expat.h.
29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 #ifndef Expat_INCLUDED 34 34 #define Expat_INCLUDED 1 35 35 36 -#ifdef __VMS 37 -/* 0 1 2 3 0 1 2 3 38 - 1234567890123456789012345678901 1234567890123456789012345678901 */ 39 -#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler 40 -#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler 41 -#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler 42 -#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg 43 -#endif 44 - 45 36 #include <stdlib.h> 46 37 #include "expat_external.h" 47 38 48 39 #ifdef __cplusplus 49 40 extern "C" { 50 41 #endif 51 42 52 43 struct XML_ParserStruct; 53 44 typedef struct XML_ParserStruct *XML_Parser; 54 45 55 46 typedef unsigned char XML_Bool; 56 -#define XML_TRUE ((XML_Bool) 1) 57 -#define XML_FALSE ((XML_Bool) 0) 47 +#define XML_TRUE ((XML_Bool)1) 48 +#define XML_FALSE ((XML_Bool)0) 58 49 59 50 /* The XML_Status enum gives the possible return values for several 60 51 API functions. The preprocessor #defines are included so this 61 52 stanza can be added to code that still needs to support older 62 53 versions of Expat 1.95.x: 63 54 64 55 #ifndef XML_STATUS_OK ................................................................................ 160 151 161 152 The EMPTY, ANY, and MIXED types will only occur at top level. 162 153 */ 163 154 164 155 typedef struct XML_cp XML_Content; 165 156 166 157 struct XML_cp { 167 - enum XML_Content_Type type; 168 - enum XML_Content_Quant quant; 169 - XML_Char * name; 170 - unsigned int numchildren; 171 - XML_Content * children; 158 + enum XML_Content_Type type; 159 + enum XML_Content_Quant quant; 160 + XML_Char *name; 161 + unsigned int numchildren; 162 + XML_Content *children; 172 163 }; 173 - 174 164 175 165 /* This is called for an element declaration. See above for 176 166 description of the model argument. It's the caller's responsibility 177 167 to free model when finished with it. 178 168 */ 179 -typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData, 180 - const XML_Char *name, 181 - XML_Content *model); 169 +typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData, 170 + const XML_Char *name, 171 + XML_Content *model); 182 172 183 173 XMLPARSEAPI(void) 184 -XML_SetElementDeclHandler(XML_Parser parser, 185 - XML_ElementDeclHandler eldecl); 174 +XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl); 186 175 187 176 /* The Attlist declaration handler is called for *each* attribute. So 188 177 a single Attlist declaration with multiple attributes declared will 189 178 generate multiple calls to this handler. The "default" parameter 190 179 may be NULL in the case of the "#IMPLIED" or "#REQUIRED" 191 180 keyword. The "isrequired" parameter will be true and the default 192 181 value will be NULL in the case of "#REQUIRED". If "isrequired" is 193 182 true and default is non-NULL, then this is a "#FIXED" default. 194 183 */ 195 -typedef void (XMLCALL *XML_AttlistDeclHandler) ( 196 - void *userData, 197 - const XML_Char *elname, 198 - const XML_Char *attname, 199 - const XML_Char *att_type, 200 - const XML_Char *dflt, 201 - int isrequired); 184 +typedef void(XMLCALL *XML_AttlistDeclHandler)( 185 + void *userData, const XML_Char *elname, const XML_Char *attname, 186 + const XML_Char *att_type, const XML_Char *dflt, int isrequired); 202 187 203 188 XMLPARSEAPI(void) 204 -XML_SetAttlistDeclHandler(XML_Parser parser, 205 - XML_AttlistDeclHandler attdecl); 189 +XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl); 206 190 207 191 /* The XML declaration handler is called for *both* XML declarations 208 192 and text declarations. The way to distinguish is that the version 209 193 parameter will be NULL for text declarations. The encoding 210 194 parameter may be NULL for XML declarations. The standalone 211 195 parameter will be -1, 0, or 1 indicating respectively that there 212 196 was no standalone parameter in the declaration, that it was given 213 197 as no, or that it was given as yes. 214 198 */ 215 -typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData, 216 - const XML_Char *version, 217 - const XML_Char *encoding, 218 - int standalone); 199 +typedef void(XMLCALL *XML_XmlDeclHandler)(void *userData, 200 + const XML_Char *version, 201 + const XML_Char *encoding, 202 + int standalone); 219 203 220 204 XMLPARSEAPI(void) 221 -XML_SetXmlDeclHandler(XML_Parser parser, 222 - XML_XmlDeclHandler xmldecl); 223 - 205 +XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl); 224 206 225 207 typedef struct { 226 208 void *(*malloc_fcn)(size_t size); 227 209 void *(*realloc_fcn)(void *ptr, size_t size); 228 210 void (*free_fcn)(void *ptr); 229 211 } XML_Memory_Handling_Suite; 230 212 ................................................................................ 243 225 name. If the namespace separator is '\0' then the namespace URI 244 226 and the local part will be concatenated without any separator. 245 227 It is a programming error to use the separator '\0' with namespace 246 228 triplets (see XML_SetReturnNSTriplet). 247 229 */ 248 230 XMLPARSEAPI(XML_Parser) 249 231 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); 250 - 251 232 252 233 /* Constructs a new parser using the memory management suite referred to 253 234 by memsuite. If memsuite is NULL, then use the standard library memory 254 235 suite. If namespaceSeparator is non-NULL it creates a parser with 255 236 namespace processing as described above. The character pointed at 256 237 will serve as the namespace separator. 257 238 ................................................................................ 274 255 */ 275 256 XMLPARSEAPI(XML_Bool) 276 257 XML_ParserReset(XML_Parser parser, const XML_Char *encoding); 277 258 278 259 /* atts is array of name/value pairs, terminated by 0; 279 260 names and values are 0 terminated. 280 261 */ 281 -typedef void (XMLCALL *XML_StartElementHandler) (void *userData, 282 - const XML_Char *name, 283 - const XML_Char **atts); 262 +typedef void(XMLCALL *XML_StartElementHandler)(void *userData, 263 + const XML_Char *name, 264 + const XML_Char **atts); 284 265 285 -typedef void (XMLCALL *XML_EndElementHandler) (void *userData, 286 - const XML_Char *name); 287 - 266 +typedef void(XMLCALL *XML_EndElementHandler)(void *userData, 267 + const XML_Char *name); 288 268 289 269 /* s is not 0 terminated. */ 290 -typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData, 291 - const XML_Char *s, 292 - int len); 270 +typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData, 271 + const XML_Char *s, int len); 293 272 294 273 /* target and data are 0 terminated */ 295 -typedef void (XMLCALL *XML_ProcessingInstructionHandler) ( 296 - void *userData, 297 - const XML_Char *target, 298 - const XML_Char *data); 274 +typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData, 275 + const XML_Char *target, 276 + const XML_Char *data); 299 277 300 278 /* data is 0 terminated */ 301 -typedef void (XMLCALL *XML_CommentHandler) (void *userData, 302 - const XML_Char *data); 279 +typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data); 303 280 304 -typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData); 305 -typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData); 281 +typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData); 282 +typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData); 306 283 307 284 /* This is called for any characters in the XML document for which 308 285 there is no applicable handler. This includes both characters that 309 286 are part of markup which is of a kind that is not reported 310 287 (comments, markup declarations), or characters that are part of a 311 288 construct which could be reported but for which no handler has been 312 289 supplied. The characters are passed exactly as they were in the XML ................................................................................ 313 290 document except that they will be encoded in UTF-8 or UTF-16. 314 291 Line boundaries are not normalized. Note that a byte order mark 315 292 character is not passed to the default handler. There are no 316 293 guarantees about how characters are divided between calls to the 317 294 default handler: for example, a comment might be split between 318 295 multiple calls. 319 296 */ 320 -typedef void (XMLCALL *XML_DefaultHandler) (void *userData, 321 - const XML_Char *s, 322 - int len); 297 +typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s, 298 + int len); 323 299 324 300 /* This is called for the start of the DOCTYPE declaration, before 325 301 any DTD or internal subset is parsed. 326 302 */ 327 -typedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( 328 - void *userData, 329 - const XML_Char *doctypeName, 330 - const XML_Char *sysid, 331 - const XML_Char *pubid, 332 - int has_internal_subset); 303 +typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData, 304 + const XML_Char *doctypeName, 305 + const XML_Char *sysid, 306 + const XML_Char *pubid, 307 + int has_internal_subset); 333 308 334 309 /* This is called for the start of the DOCTYPE declaration when the 335 310 closing > is encountered, but after processing any external 336 311 subset. 337 312 */ 338 -typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); 313 +typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); 339 314 340 315 /* This is called for entity declarations. The is_parameter_entity 341 316 argument will be non-zero if the entity is a parameter entity, zero 342 317 otherwise. 343 318 344 319 For internal entities (<!ENTITY foo "bar">), value will 345 320 be non-NULL and systemId, publicID, and notationName will be NULL. ................................................................................ 351 326 non-NULL. The publicId argument will be NULL unless a public 352 327 identifier was provided. The notationName argument will have a 353 328 non-NULL value only for unparsed entity declarations. 354 329 355 330 Note that is_parameter_entity can't be changed to XML_Bool, since 356 331 that would break binary compatibility. 357 332 */ 358 -typedef void (XMLCALL *XML_EntityDeclHandler) ( 359 - void *userData, 360 - const XML_Char *entityName, 361 - int is_parameter_entity, 362 - const XML_Char *value, 363 - int value_length, 364 - const XML_Char *base, 365 - const XML_Char *systemId, 366 - const XML_Char *publicId, 367 - const XML_Char *notationName); 333 +typedef void(XMLCALL *XML_EntityDeclHandler)( 334 + void *userData, const XML_Char *entityName, int is_parameter_entity, 335 + const XML_Char *value, int value_length, const XML_Char *base, 336 + const XML_Char *systemId, const XML_Char *publicId, 337 + const XML_Char *notationName); 368 338 369 339 XMLPARSEAPI(void) 370 -XML_SetEntityDeclHandler(XML_Parser parser, 371 - XML_EntityDeclHandler handler); 340 +XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler); 372 341 373 342 /* OBSOLETE -- OBSOLETE -- OBSOLETE 374 343 This handler has been superseded by the EntityDeclHandler above. 375 344 It is provided here for backward compatibility. 376 345 377 346 This is called for a declaration of an unparsed (NDATA) entity. 378 347 The base argument is whatever was set by XML_SetBase. The 379 348 entityName, systemId and notationName arguments will never be 380 349 NULL. The other arguments may be. 381 350 */ 382 -typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) ( 383 - void *userData, 384 - const XML_Char *entityName, 385 - const XML_Char *base, 386 - const XML_Char *systemId, 387 - const XML_Char *publicId, 388 - const XML_Char *notationName); 351 +typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)( 352 + void *userData, const XML_Char *entityName, const XML_Char *base, 353 + const XML_Char *systemId, const XML_Char *publicId, 354 + const XML_Char *notationName); 389 355 390 356 /* This is called for a declaration of notation. The base argument is 391 357 whatever was set by XML_SetBase. The notationName will never be 392 358 NULL. The other arguments can be. 393 359 */ 394 -typedef void (XMLCALL *XML_NotationDeclHandler) ( 395 - void *userData, 396 - const XML_Char *notationName, 397 - const XML_Char *base, 398 - const XML_Char *systemId, 399 - const XML_Char *publicId); 360 +typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData, 361 + const XML_Char *notationName, 362 + const XML_Char *base, 363 + const XML_Char *systemId, 364 + const XML_Char *publicId); 400 365 401 366 /* When namespace processing is enabled, these are called once for 402 367 each namespace declaration. The call to the start and end element 403 368 handlers occur between the calls to the start and end namespace 404 369 declaration handlers. For an xmlns attribute, prefix will be 405 370 NULL. For an xmlns="" attribute, uri will be NULL. 406 371 */ 407 -typedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( 408 - void *userData, 409 - const XML_Char *prefix, 410 - const XML_Char *uri); 372 +typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData, 373 + const XML_Char *prefix, 374 + const XML_Char *uri); 411 375 412 -typedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( 413 - void *userData, 414 - const XML_Char *prefix); 376 +typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData, 377 + const XML_Char *prefix); 415 378 416 379 /* This is called if the document is not standalone, that is, it has an 417 380 external subset or a reference to a parameter entity, but does not 418 381 have standalone="yes". If this handler returns XML_STATUS_ERROR, 419 382 then processing will not continue, and the parser will return a 420 383 XML_ERROR_NOT_STANDALONE error. 421 384 If parameter entity parsing is enabled, then in addition to the 422 385 conditions above this handler will only be called if the referenced 423 386 entity was actually read. 424 387 */ 425 -typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData); 388 +typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData); 426 389 427 390 /* This is called for a reference to an external parsed general 428 391 entity. The referenced entity is not automatically parsed. The 429 392 application can parse it immediately or later using 430 393 XML_ExternalEntityParserCreate. 431 394 432 395 The parser argument is the parser parsing the entity containing the ................................................................................ 454 417 continue because of a fatal error in the handling of the external 455 418 entity. In this case the calling parser will return an 456 419 XML_ERROR_EXTERNAL_ENTITY_HANDLING error. 457 420 458 421 Note that unlike other handlers the first argument is the parser, 459 422 not userData. 460 423 */ 461 -typedef int (XMLCALL *XML_ExternalEntityRefHandler) ( 462 - XML_Parser parser, 463 - const XML_Char *context, 464 - const XML_Char *base, 465 - const XML_Char *systemId, 466 - const XML_Char *publicId); 424 +typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser, 425 + const XML_Char *context, 426 + const XML_Char *base, 427 + const XML_Char *systemId, 428 + const XML_Char *publicId); 467 429 468 430 /* This is called in two situations: 469 431 1) An entity reference is encountered for which no declaration 470 432 has been read *and* this is not an error. 471 433 2) An internal entity reference is read, but not expanded, because 472 434 XML_SetDefaultHandler has been called. 473 435 Note: skipped parameter entities in declarations and skipped general 474 436 entities in attribute values cannot be reported, because 475 437 the event would be out of sync with the reporting of the 476 438 declarations or attribute values 477 439 */ 478 -typedef void (XMLCALL *XML_SkippedEntityHandler) ( 479 - void *userData, 480 - const XML_Char *entityName, 481 - int is_parameter_entity); 440 +typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData, 441 + const XML_Char *entityName, 442 + int is_parameter_entity); 482 443 483 444 /* This structure is filled in by the XML_UnknownEncodingHandler to 484 445 provide information to the parser about encodings that are unknown 485 446 to the parser. 486 447 487 448 The map[b] member gives information about byte sequences whose 488 449 first byte is b. ................................................................................ 531 492 532 493 4. No Unicode character may be encoded by more than one distinct 533 494 sequence of bytes. 534 495 */ 535 496 typedef struct { 536 497 int map[256]; 537 498 void *data; 538 - int (XMLCALL *convert)(void *data, const char *s); 539 - void (XMLCALL *release)(void *data); 499 + int(XMLCALL *convert)(void *data, const char *s); 500 + void(XMLCALL *release)(void *data); 540 501 } XML_Encoding; 541 502 542 503 /* This is called for an encoding that is unknown to the parser. 543 504 544 505 The encodingHandlerData argument is that which was passed as the 545 506 second argument to XML_SetUnknownEncodingHandler. 546 507 ................................................................................ 550 511 If the callback can provide information about the encoding, it must 551 512 fill in the XML_Encoding structure, and return XML_STATUS_OK. 552 513 Otherwise it must return XML_STATUS_ERROR. 553 514 554 515 If info does not describe a suitable encoding, then the parser will 555 516 return an XML_UNKNOWN_ENCODING error. 556 517 */ 557 -typedef int (XMLCALL *XML_UnknownEncodingHandler) ( 558 - void *encodingHandlerData, 559 - const XML_Char *name, 560 - XML_Encoding *info); 518 +typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData, 519 + const XML_Char *name, 520 + XML_Encoding *info); 561 521 562 522 XMLPARSEAPI(void) 563 -XML_SetElementHandler(XML_Parser parser, 564 - XML_StartElementHandler start, 523 +XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, 565 524 XML_EndElementHandler end); 566 525 567 526 XMLPARSEAPI(void) 568 -XML_SetStartElementHandler(XML_Parser parser, 569 - XML_StartElementHandler handler); 527 +XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler); 570 528 571 529 XMLPARSEAPI(void) 572 -XML_SetEndElementHandler(XML_Parser parser, 573 - XML_EndElementHandler handler); 530 +XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler); 574 531 575 532 XMLPARSEAPI(void) 576 533 XML_SetCharacterDataHandler(XML_Parser parser, 577 534 XML_CharacterDataHandler handler); 578 535 579 536 XMLPARSEAPI(void) 580 537 XML_SetProcessingInstructionHandler(XML_Parser parser, 581 538 XML_ProcessingInstructionHandler handler); 582 539 XMLPARSEAPI(void) 583 -XML_SetCommentHandler(XML_Parser parser, 584 - XML_CommentHandler handler); 540 +XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler); 585 541 586 542 XMLPARSEAPI(void) 587 543 XML_SetCdataSectionHandler(XML_Parser parser, 588 544 XML_StartCdataSectionHandler start, 589 545 XML_EndCdataSectionHandler end); 590 546 591 547 XMLPARSEAPI(void) ................................................................................ 597 553 XML_EndCdataSectionHandler end); 598 554 599 555 /* This sets the default handler and also inhibits expansion of 600 556 internal entities. These entity references will be passed to the 601 557 default handler, or to the skipped entity handler, if one is set. 602 558 */ 603 559 XMLPARSEAPI(void) 604 -XML_SetDefaultHandler(XML_Parser parser, 605 - XML_DefaultHandler handler); 560 +XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler); 606 561 607 562 /* This sets the default handler but does not inhibit expansion of 608 563 internal entities. The entity reference will not be passed to the 609 564 default handler. 610 565 */ 611 566 XMLPARSEAPI(void) 612 -XML_SetDefaultHandlerExpand(XML_Parser parser, 613 - XML_DefaultHandler handler); 567 +XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler); 614 568 615 569 XMLPARSEAPI(void) 616 -XML_SetDoctypeDeclHandler(XML_Parser parser, 617 - XML_StartDoctypeDeclHandler start, 570 +XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, 618 571 XML_EndDoctypeDeclHandler end); 619 572 620 573 XMLPARSEAPI(void) 621 574 XML_SetStartDoctypeDeclHandler(XML_Parser parser, 622 575 XML_StartDoctypeDeclHandler start); 623 576 624 577 XMLPARSEAPI(void) 625 -XML_SetEndDoctypeDeclHandler(XML_Parser parser, 626 - XML_EndDoctypeDeclHandler end); 578 +XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end); 627 579 628 580 XMLPARSEAPI(void) 629 581 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, 630 582 XML_UnparsedEntityDeclHandler handler); 631 583 632 584 XMLPARSEAPI(void) 633 -XML_SetNotationDeclHandler(XML_Parser parser, 634 - XML_NotationDeclHandler handler); 585 +XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler); 635 586 636 587 XMLPARSEAPI(void) 637 588 XML_SetNamespaceDeclHandler(XML_Parser parser, 638 589 XML_StartNamespaceDeclHandler start, 639 590 XML_EndNamespaceDeclHandler end); 640 591 641 592 XMLPARSEAPI(void) ................................................................................ 655 606 XML_ExternalEntityRefHandler handler); 656 607 657 608 /* If a non-NULL value for arg is specified here, then it will be 658 609 passed as the first argument to the external entity ref handler 659 610 instead of the parser object. 660 611 */ 661 612 XMLPARSEAPI(void) 662 -XML_SetExternalEntityRefHandlerArg(XML_Parser parser, 663 - void *arg); 613 +XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg); 664 614 665 615 XMLPARSEAPI(void) 666 616 XML_SetSkippedEntityHandler(XML_Parser parser, 667 617 XML_SkippedEntityHandler handler); 668 618 669 619 XMLPARSEAPI(void) 670 620 XML_SetUnknownEncodingHandler(XML_Parser parser, ................................................................................ 736 686 Note: If XML_DTD is not defined when Expat is compiled, returns 737 687 XML_ERROR_FEATURE_REQUIRES_XML_DTD. 738 688 Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT. 739 689 */ 740 690 XMLPARSEAPI(enum XML_Error) 741 691 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); 742 692 743 - 744 693 /* Sets the base to be used for resolving relative URIs in system 745 694 identifiers in declarations. Resolving relative identifiers is 746 695 left to the application: this value will be passed through as the 747 696 base argument to the XML_ExternalEntityRefHandler, 748 697 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base 749 698 argument will be copied. Returns XML_STATUS_ERROR if out of memory, 750 699 XML_STATUS_OK otherwise. ................................................................................ 776 725 #ifdef XML_ATTR_INFO 777 726 /* Source file byte offsets for the start and end of attribute names and values. 778 727 The value indices are exclusive of surrounding quotes; thus in a UTF-8 source 779 728 file an attribute value of "blah" will yield: 780 729 info->valueEnd - info->valueStart = 4 bytes. 781 730 */ 782 731 typedef struct { 783 - XML_Index nameStart; /* Offset to beginning of the attribute name. */ 784 - XML_Index nameEnd; /* Offset after the attribute name's last byte. */ 785 - XML_Index valueStart; /* Offset to beginning of the attribute value. */ 786 - XML_Index valueEnd; /* Offset after the attribute value's last byte. */ 732 + XML_Index nameStart; /* Offset to beginning of the attribute name. */ 733 + XML_Index nameEnd; /* Offset after the attribute name's last byte. */ 734 + XML_Index valueStart; /* Offset to beginning of the attribute value. */ 735 + XML_Index valueEnd; /* Offset after the attribute value's last byte. */ 787 736 } XML_AttrInfo; 788 737 789 738 /* Returns an array of XML_AttrInfo structures for the attribute/value pairs 790 739 passed in last call to the XML_StartElementHandler that were specified 791 740 in the start-tag rather than defaulted. Each attribute/value pair counts 792 741 as 1; thus the number of entries in the array is 793 742 XML_GetSpecifiedAttributeCount(parser) / 2. ................................................................................ 815 764 XML_ParseBuffer(XML_Parser parser, int len, int isFinal); 816 765 817 766 /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. 818 767 Must be called from within a call-back handler, except when aborting 819 768 (resumable = 0) an already suspended parser. Some call-backs may 820 769 still follow because they would otherwise get lost. Examples: 821 770 - endElementHandler() for empty elements when stopped in 822 - startElementHandler(), 823 - - endNameSpaceDeclHandler() when stopped in endElementHandler(), 771 + startElementHandler(), 772 + - endNameSpaceDeclHandler() when stopped in endElementHandler(), 824 773 and possibly others. 825 774 826 775 Can be called from most handlers, including DTD related call-backs, 827 776 except when parsing an external parameter entity and resumable != 0. 828 777 Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. 829 - Possible error codes: 778 + Possible error codes: 830 779 - XML_ERROR_SUSPENDED: when suspending an already suspended parser. 831 780 - XML_ERROR_FINISHED: when the parser has already finished. 832 781 - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. 833 782 834 - When resumable != 0 (true) then parsing is suspended, that is, 835 - XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 783 + When resumable != 0 (true) then parsing is suspended, that is, 784 + XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 836 785 Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() 837 786 return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. 838 787 839 788 *Note*: 840 789 This will be applied to the current parser instance only, that is, if 841 790 there is a parent parser then it will continue parsing when the 842 791 externalEntityRefHandler() returns. It is up to the implementation of 843 792 the externalEntityRefHandler() to call XML_StopParser() on the parent 844 793 parser (recursively), if one wants to stop parsing altogether. 845 794 846 - When suspended, parsing can be resumed by calling XML_ResumeParser(). 795 + When suspended, parsing can be resumed by calling XML_ResumeParser(). 847 796 */ 848 797 XMLPARSEAPI(enum XML_Status) 849 798 XML_StopParser(XML_Parser parser, XML_Bool resumable); 850 799 851 800 /* Resumes parsing after it has been suspended with XML_StopParser(). 852 801 Must not be called from within a handler call-back. Returns same 853 802 status codes as XML_Parse() or XML_ParseBuffer(). 854 - Additional error code XML_ERROR_NOT_SUSPENDED possible. 803 + Additional error code XML_ERROR_NOT_SUSPENDED possible. 855 804 856 805 *Note*: 857 806 This must be called on the most deeply nested child parser instance 858 807 first, and on its parent parser only after the child parser has finished, 859 808 to be applied recursively until the document entity's parser is restarted. 860 809 That is, the parent parser will not resume by itself and it is up to the 861 810 application to call XML_ResumeParser() on it at the appropriate moment. 862 811 */ 863 812 XMLPARSEAPI(enum XML_Status) 864 813 XML_ResumeParser(XML_Parser parser); 865 814 866 -enum XML_Parsing { 867 - XML_INITIALIZED, 868 - XML_PARSING, 869 - XML_FINISHED, 870 - XML_SUSPENDED 871 -}; 815 +enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED }; 872 816 873 817 typedef struct { 874 818 enum XML_Parsing parsing; 875 819 XML_Bool finalBuffer; 876 820 } XML_ParsingStatus; 877 821 878 822 /* Returns status of parser with respect to being initialized, parsing, ................................................................................ 896 840 an ExternalEntityRefHandler so longer as the parser has not yet 897 841 been freed. The new parser is completely independent and may 898 842 safely be used in a separate thread. The handlers and userData are 899 843 initialized from the parser argument. Returns NULL if out of memory. 900 844 Otherwise returns a new XML_Parser object. 901 845 */ 902 846 XMLPARSEAPI(XML_Parser) 903 -XML_ExternalEntityParserCreate(XML_Parser parser, 904 - const XML_Char *context, 847 +XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context, 905 848 const XML_Char *encoding); 906 849 907 850 enum XML_ParamEntityParsing { 908 851 XML_PARAM_ENTITY_PARSING_NEVER, 909 852 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, 910 853 XML_PARAM_ENTITY_PARSING_ALWAYS 911 854 }; ................................................................................ 941 884 /* Sets the hash salt to use for internal hash calculations. 942 885 Helps in preventing DoS attacks based on predicting hash 943 886 function behavior. This must be called before parsing is started. 944 887 Returns 1 if successful, 0 when called after parsing has started. 945 888 Note: If parser == NULL, the function will do nothing and return 0. 946 889 */ 947 890 XMLPARSEAPI(int) 948 -XML_SetHashSalt(XML_Parser parser, 949 - unsigned long hash_salt); 891 +XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt); 950 892 951 893 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then 952 894 XML_GetErrorCode returns information about the error. 953 895 */ 954 896 XMLPARSEAPI(enum XML_Error) 955 897 XML_GetErrorCode(XML_Parser parser); 956 898 ................................................................................ 959 901 some parse event; in this case the location is the location of the 960 902 first of the sequence of characters that generated the event. When 961 903 called from callbacks generated by declarations in the document 962 904 prologue, the location identified isn't as neatly defined, but will 963 905 be within the relevant markup. When called outside of the callback 964 906 functions, the position indicated will be just past the last parse 965 907 event (regardless of whether there was an associated callback). 966 - 908 + 967 909 They may also be called after returning from a call to XML_Parse 968 910 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then 969 911 the location is the location of the character at which the error 970 912 was detected; otherwise the location is the location of the last 971 913 parse event, as described above. 972 914 973 915 Note: XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber ................................................................................ 991 933 returns a NULL pointer. Also returns a NULL pointer if a parse isn't 992 934 active. 993 935 994 936 NOTE: The character pointer returned should not be used outside 995 937 the handler that makes the call. 996 938 */ 997 939 XMLPARSEAPI(const char *) 998 -XML_GetInputContext(XML_Parser parser, 999 - int *offset, 1000 - int *size); 940 +XML_GetInputContext(XML_Parser parser, int *offset, int *size); 1001 941 1002 942 /* For backwards compatibility with previous versions. */ 1003 -#define XML_GetErrorLineNumber XML_GetCurrentLineNumber 943 +#define XML_GetErrorLineNumber XML_GetCurrentLineNumber 1004 944 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber 1005 -#define XML_GetErrorByteIndex XML_GetCurrentByteIndex 945 +#define XML_GetErrorByteIndex XML_GetCurrentByteIndex 1006 946 1007 947 /* Frees the content model passed to the element declaration handler */ 1008 948 XMLPARSEAPI(void) 1009 949 XML_FreeContentModel(XML_Parser parser, XML_Content *model); 1010 950 1011 951 /* Exposing the memory handling functions used in Expat */ 1012 952 XMLPARSEAPI(void *) ................................................................................ 1058 998 XML_FEATURE_NS, 1059 999 XML_FEATURE_LARGE_SIZE, 1060 1000 XML_FEATURE_ATTR_INFO 1061 1001 /* Additional features must be added to the end of this enum. */ 1062 1002 }; 1063 1003 1064 1004 typedef struct { 1065 - enum XML_FeatureEnum feature; 1066 - const XML_LChar *name; 1067 - long int value; 1005 + enum XML_FeatureEnum feature; 1006 + const XML_LChar *name; 1007 + long int value; 1068 1008 } XML_Feature; 1069 1009 1070 1010 XMLPARSEAPI(const XML_Feature *) 1071 1011 XML_GetFeatureList(void); 1072 - 1073 1012 1074 1013 /* Expat follows the semantic versioning convention. 1075 1014 See http://semver.org. 1076 1015 */ 1077 1016 #define XML_MAJOR_VERSION 2 1078 1017 #define XML_MINOR_VERSION 2 1079 -#define XML_MICRO_VERSION 6 1018 +#define XML_MICRO_VERSION 9 1080 1019 1081 1020 #ifdef __cplusplus 1082 1021 } 1083 1022 #endif 1084 1023 1085 1024 #endif /* not Expat_INCLUDED */
Changes to expat/expat_external.h.
31 31 */ 32 32 33 33 #ifndef Expat_External_INCLUDED 34 34 #define Expat_External_INCLUDED 1 35 35 36 36 /* External API definitions */ 37 37 38 -#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) 39 -# define XML_USE_MSC_EXTENSIONS 1 40 -#endif 41 - 42 38 /* Expat tries very hard to make the API boundary very specifically 43 39 defined. There are two macros defined to control this boundary; 44 40 each of these can be defined before including this header to 45 41 achieve some different behavior, but doing so it not recommended or 46 42 tested frequently. 47 43 48 44 XMLCALL - The calling convention to use for all calls across the ................................................................................ 58 54 expected to be directly useful in client code is XMLCALL. 59 55 60 56 Note that on at least some Unix versions, the Expat library must be 61 57 compiled with the cdecl calling convention as the default since 62 58 system headers may assume the cdecl convention. 63 59 */ 64 60 #ifndef XMLCALL 65 -# if defined(_MSC_VER) 66 -# define XMLCALL __cdecl 67 -# elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) 68 -# define XMLCALL __attribute__((cdecl)) 69 -# else 61 +# if defined(_MSC_VER) 62 +# define XMLCALL __cdecl 63 +# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER) 64 +# define XMLCALL __attribute__((cdecl)) 65 +# else 70 66 /* For any platform which uses this definition and supports more than 71 67 one calling convention, we need to extend this definition to 72 68 declare the convention used on that platform, if it's possible to 73 69 do so. 74 70 75 71 If this is the case for your platform, please file a bug report 76 72 with information on how to identify your platform via the C 77 73 pre-processor and how to specify the same calling convention as the 78 74 platform's malloc() implementation. 79 75 */ 80 -# define XMLCALL 81 -# endif 82 -#endif /* not defined XMLCALL */ 76 +# define XMLCALL 77 +# endif 78 +#endif /* not defined XMLCALL */ 83 79 84 - 85 -#if !defined(XML_STATIC) && !defined(XMLIMPORT) 86 -# ifndef XML_BUILDING_EXPAT 80 +#if ! defined(XML_STATIC) && ! defined(XMLIMPORT) 81 +# ifndef XML_BUILDING_EXPAT 87 82 /* using Expat from an application */ 88 83 89 -# ifdef XML_USE_MSC_EXTENSIONS 90 -# define XMLIMPORT __declspec(dllimport) 84 +# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__) 85 +# define XMLIMPORT __declspec(dllimport) 86 +# endif 87 + 91 88 # endif 89 +#endif /* not defined XML_STATIC */ 92 90 93 -# endif 94 -#endif /* not defined XML_STATIC */ 91 +#ifndef XML_ENABLE_VISIBILITY 92 +# define XML_ENABLE_VISIBILITY 0 93 +#endif 95 94 96 -#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4) 97 -# define XMLIMPORT __attribute__ ((visibility ("default"))) 95 +#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY 96 +# define XMLIMPORT __attribute__((visibility("default"))) 98 97 #endif 99 98 100 99 /* If we didn't define it above, define it away: */ 101 100 #ifndef XMLIMPORT 102 -# define XMLIMPORT 101 +# define XMLIMPORT 103 102 #endif 104 103 105 -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) 106 -# define XML_ATTR_MALLOC __attribute__((__malloc__)) 104 +#if defined(__GNUC__) \ 105 + && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) 106 +# define XML_ATTR_MALLOC __attribute__((__malloc__)) 107 107 #else 108 -# define XML_ATTR_MALLOC 108 +# define XML_ATTR_MALLOC 109 109 #endif 110 110 111 -#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) 112 -# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) 111 +#if defined(__GNUC__) \ 112 + && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) 113 +# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) 113 114 #else 114 -# define XML_ATTR_ALLOC_SIZE(x) 115 +# define XML_ATTR_ALLOC_SIZE(x) 115 116 #endif 116 117 117 118 #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL 118 119 119 120 #ifdef __cplusplus 120 121 extern "C" { 121 122 #endif 122 123 123 124 #ifdef XML_UNICODE_WCHAR_T 124 -# ifndef XML_UNICODE 125 -# define XML_UNICODE 126 -# endif 127 -# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2) 128 -# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc" 129 -# endif 125 +# ifndef XML_UNICODE 126 +# define XML_UNICODE 127 +# endif 128 +# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2) 129 +# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc" 130 +# endif 130 131 #endif 131 132 132 -#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ 133 -# ifdef XML_UNICODE_WCHAR_T 133 +#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ 134 +# ifdef XML_UNICODE_WCHAR_T 134 135 typedef wchar_t XML_Char; 135 136 typedef wchar_t XML_LChar; 136 -# else 137 +# else 137 138 typedef unsigned short XML_Char; 138 139 typedef char XML_LChar; 139 -# endif /* XML_UNICODE_WCHAR_T */ 140 -#else /* Information is UTF-8 encoded. */ 140 +# endif /* XML_UNICODE_WCHAR_T */ 141 +#else /* Information is UTF-8 encoded. */ 141 142 typedef char XML_Char; 142 143 typedef char XML_LChar; 143 -#endif /* XML_UNICODE */ 144 +#endif /* XML_UNICODE */ 144 145 145 -#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ 146 -# if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 147 -typedef __int64 XML_Index; 148 -typedef unsigned __int64 XML_Size; 149 -# else 146 +#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ 150 147 typedef long long XML_Index; 151 148 typedef unsigned long long XML_Size; 152 -# endif 153 149 #else 154 150 typedef long XML_Index; 155 151 typedef unsigned long XML_Size; 156 152 #endif /* XML_LARGE_SIZE */ 157 153 158 154 #ifdef __cplusplus 159 155 } 160 156 #endif 161 157 162 158 #endif /* not Expat_External_INCLUDED */
Changes to expat/iasciitab.h.
28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ 34 34 /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 35 -/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 36 -/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, 37 -/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML, 38 -/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 39 -/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 40 -/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 41 -/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 42 -/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, 43 -/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, 44 -/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, 45 -/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, 46 -/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 47 -/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 48 -/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, 49 -/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, 50 -/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 51 -/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 52 -/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 53 -/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 54 -/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 55 -/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 56 -/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, 57 -/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, 58 -/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 59 -/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 60 -/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 61 -/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 62 -/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 63 -/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 64 -/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 65 -/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, 35 + /* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 36 + /* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, 37 + /* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML, 38 + /* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 39 + /* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 40 + /* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 41 + /* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 42 + /* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, 43 + /* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, 44 + /* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, 45 + /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, 46 + /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 47 + /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 48 + /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, 49 + /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, 50 + /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 51 + /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 52 + /* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 53 + /* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 54 + /* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 55 + /* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 56 + /* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, 57 + /* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, 58 + /* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 59 + /* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 60 + /* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 61 + /* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 62 + /* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 63 + /* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 64 + /* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 65 + /* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
Changes to expat/internal.h.
45 45 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 46 46 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 47 47 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 48 48 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 49 49 USE OR OTHER DEALINGS IN THE SOFTWARE. 50 50 */ 51 51 52 -#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) 52 +#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__) 53 53 /* We'll use this version by default only where we know it helps. 54 54 55 55 regparm() generates warnings on Solaris boxes. See SF bug #692878. 56 56 57 57 Instability reported with egcs on a RedHat Linux 7.3. 58 58 Let's comment out: 59 59 #define FASTCALL __attribute__((stdcall, regparm(3))) 60 60 and let's try this: 61 61 */ 62 -#define FASTCALL __attribute__((regparm(3))) 63 -#define PTRFASTCALL __attribute__((regparm(3))) 62 +# define FASTCALL __attribute__((regparm(3))) 63 +# define PTRFASTCALL __attribute__((regparm(3))) 64 64 #endif 65 65 66 66 /* Using __fastcall seems to have an unexpected negative effect under 67 67 MS VC++, especially for function pointers, so we won't use it for 68 68 now on that platform. It may be reconsidered for a future release 69 69 if it can be made more effective. 70 70 Likely reason: __fastcall on Windows is like stdcall, therefore 71 71 the compiler cannot perform stack optimizations for call clusters. 72 72 */ 73 73 74 74 /* Make sure all of these are defined if they aren't already. */ 75 75 76 76 #ifndef FASTCALL 77 -#define FASTCALL 77 +# define FASTCALL 78 78 #endif 79 79 80 80 #ifndef PTRCALL 81 -#define PTRCALL 81 +# define PTRCALL 82 82 #endif 83 83 84 84 #ifndef PTRFASTCALL 85 -#define PTRFASTCALL 85 +# define PTRFASTCALL 86 86 #endif 87 87 88 88 #ifndef XML_MIN_SIZE 89 -#if !defined(__cplusplus) && !defined(inline) 90 -#ifdef __GNUC__ 91 -#define inline __inline 92 -#endif /* __GNUC__ */ 93 -#endif 89 +# if ! defined(__cplusplus) && ! defined(inline) 90 +# ifdef __GNUC__ 91 +# define inline __inline 92 +# endif /* __GNUC__ */ 93 +# endif 94 94 #endif /* XML_MIN_SIZE */ 95 95 96 96 #ifdef __cplusplus 97 -#define inline inline 97 +# define inline inline 98 98 #else 99 -#ifndef inline 100 -#define inline 101 -#endif 99 +# ifndef inline 100 +# define inline 101 +# endif 102 102 #endif 103 103 104 104 #ifndef UNUSED_P 105 -# ifdef __GNUC__ 106 -# define UNUSED_P(p) UNUSED_ ## p __attribute__((__unused__)) 107 -# else 108 -# define UNUSED_P(p) UNUSED_ ## p 109 -# endif 105 +# define UNUSED_P(p) (void)p 110 106 #endif 111 - 112 107 113 108 #ifdef __cplusplus 114 109 extern "C" { 115 110 #endif 116 111 117 - 112 +#ifdef XML_ENABLE_VISIBILITY 113 +# if XML_ENABLE_VISIBILITY 114 +__attribute__((visibility("default"))) 115 +# endif 116 +#endif 118 117 void 119 -_INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef); 120 - 118 +_INTERNAL_trim_to_complete_utf8_characters(const char *from, 119 + const char **fromLimRef); 121 120 122 121 #ifdef __cplusplus 123 122 } 124 123 #endif
Changes to expat/latin1tab.h.
27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 34 -/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 35 -/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 36 -/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 37 -/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 38 -/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 39 -/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 40 -/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 41 -/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 42 -/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 43 -/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, 44 -/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 45 -/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 46 -/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, 47 -/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, 48 -/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 49 -/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 50 -/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 51 -/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 52 -/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 53 -/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 54 -/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 55 -/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 56 -/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 57 -/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 58 -/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 59 -/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 60 -/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 61 -/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 62 -/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 63 -/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 64 -/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 34 + /* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 35 + /* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 36 + /* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 37 + /* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 38 + /* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 39 + /* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 40 + /* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 41 + /* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 42 + /* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 43 + /* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, 44 + /* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 45 + /* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 46 + /* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, 47 + /* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, 48 + /* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 49 + /* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 50 + /* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 51 + /* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 52 + /* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 53 + /* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 54 + /* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 55 + /* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 56 + /* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 57 + /* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 58 + /* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 59 + /* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 60 + /* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 61 + /* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 62 + /* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 63 + /* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 64 + /* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
Deleted expat/loadlibrary.c.
1 -/*************************************************************************** 2 - * _ _ ____ _ 3 - * Project ___| | | | _ \| | 4 - * / __| | | | |_) | | 5 - * | (__| |_| | _ <| |___ 6 - * \___|\___/|_| \_\_____| 7 - * 8 - * Copyright (C) 2016 - 2017, Steve Holme, <steve_holme@hotmail.com>. 9 - * Copyright (C) 2017, Expat development team 10 - * 11 - * All rights reserved. 12 - * Licensed under the MIT license: 13 - * 14 - * Permission to use, copy, modify, and distribute this software for any 15 - * purpose with or without fee is hereby granted, provided that the above 16 - * copyright notice and this permission notice appear in all copies. 17 - * 18 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 21 - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 24 - * THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 - * 26 - * Except as contained in this notice, the name of a copyright holder shall 27 - * not be used in advertising or otherwise to promote the sale, use or other 28 - * dealings in this Software without prior written authorization of the 29 - * copyright holder. 30 - * 31 - ***************************************************************************/ 32 - 33 -#if defined(_WIN32) 34 - 35 -#include <windows.h> 36 -#include <tchar.h> 37 - 38 - 39 -HMODULE _Expat_LoadLibrary(LPCTSTR filename); 40 - 41 - 42 -#if !defined(LOAD_WITH_ALTERED_SEARCH_PATH) 43 -#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008 44 -#endif 45 - 46 -#if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32) 47 -#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 48 -#endif 49 - 50 -/* We use our own typedef here since some headers might lack these */ 51 -typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD); 52 - 53 -/* See function definitions in winbase.h */ 54 -#ifdef UNICODE 55 -# ifdef _WIN32_WCE 56 -# define LOADLIBARYEX L"LoadLibraryExW" 57 -# else 58 -# define LOADLIBARYEX "LoadLibraryExW" 59 -# endif 60 -#else 61 -# define LOADLIBARYEX "LoadLibraryExA" 62 -#endif 63 - 64 - 65 -/* 66 - * _Expat_LoadLibrary() 67 - * 68 - * This is used to dynamically load DLLs using the most secure method available 69 - * for the version of Windows that we are running on. 70 - * 71 - * Parameters: 72 - * 73 - * filename [in] - The filename or full path of the DLL to load. If only the 74 - * filename is passed then the DLL will be loaded from the 75 - * Windows system directory. 76 - * 77 - * Returns the handle of the module on success; otherwise NULL. 78 - */ 79 -HMODULE _Expat_LoadLibrary(LPCTSTR filename) 80 -{ 81 - HMODULE hModule = NULL; 82 - LOADLIBRARYEX_FN pLoadLibraryEx = NULL; 83 - 84 - /* Get a handle to kernel32 so we can access it's functions at runtime */ 85 - HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32")); 86 - if(!hKernel32) 87 - return NULL; /* LCOV_EXCL_LINE */ 88 - 89 - /* Attempt to find LoadLibraryEx() which is only available on Windows 2000 90 - and above */ 91 - pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX); 92 - 93 - /* Detect if there's already a path in the filename and load the library if 94 - there is. Note: Both back slashes and forward slashes have been supported 95 - since the earlier days of DOS at an API level although they are not 96 - supported by command prompt */ 97 - if(_tcspbrk(filename, TEXT("\\/"))) { 98 - /** !checksrc! disable BANNEDFUNC 1 **/ 99 - hModule = pLoadLibraryEx ? 100 - pLoadLibraryEx(filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : 101 - LoadLibrary(filename); 102 - } 103 - /* Detect if KB2533623 is installed, as LOAD_LIBARY_SEARCH_SYSTEM32 is only 104 - supported on Windows Vista, Windows Server 2008, Windows 7 and Windows 105 - Server 2008 R2 with this patch or natively on Windows 8 and above */ 106 - else if(pLoadLibraryEx && GetProcAddress(hKernel32, "AddDllDirectory")) { 107 - /* Load the DLL from the Windows system directory */ 108 - hModule = pLoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); 109 - } 110 - else { 111 - /* Attempt to get the Windows system path */ 112 - UINT systemdirlen = GetSystemDirectory(NULL, 0); 113 - if(systemdirlen) { 114 - /* Allocate space for the full DLL path (Room for the null terminator 115 - is included in systemdirlen) */ 116 - size_t filenamelen = _tcslen(filename); 117 - TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen)); 118 - if(path && GetSystemDirectory(path, systemdirlen)) { 119 - /* Calculate the full DLL path */ 120 - _tcscpy(path + _tcslen(path), TEXT("\\")); 121 - _tcscpy(path + _tcslen(path), filename); 122 - 123 - /* Load the DLL from the Windows system directory */ 124 - /** !checksrc! disable BANNEDFUNC 1 **/ 125 - hModule = pLoadLibraryEx ? 126 - pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : 127 - LoadLibrary(path); 128 - 129 - } 130 - free(path); 131 - } 132 - } 133 - 134 - return hModule; 135 -} 136 - 137 -#else /* defined(_WIN32) */ 138 - 139 -/* ISO C requires a translation unit to contain at least one declaration 140 - [-Wempty-translation-unit] */ 141 -typedef int _TRANSLATION_UNIT_LOAD_LIBRARY_C_NOT_EMTPY; 142 - 143 -#endif /* defined(_WIN32) */
Changes to expat/nametab.h.
27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 static const unsigned namingBitmap[] = { 34 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 35 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 36 -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 37 -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 38 -0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE, 39 -0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, 40 -0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 41 -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF, 42 -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 43 -0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 44 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 45 -0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, 46 -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 47 -0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 48 -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, 49 -0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 50 -0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000, 51 -0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, 52 -0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 53 -0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003, 54 -0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, 55 -0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 56 -0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003, 57 -0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, 58 -0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 59 -0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003, 60 -0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, 61 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 62 -0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000, 63 -0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, 64 -0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 65 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 66 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 67 -0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 68 -0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB, 69 -0x40000000, 0xF580C900, 0x00000007, 0x02010800, 70 -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 71 -0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, 72 -0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, 73 -0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 74 -0x00000000, 0x00004C40, 0x00000000, 0x00000000, 75 -0x00000007, 0x00000000, 0x00000000, 0x00000000, 76 -0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 77 -0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF, 78 -0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, 79 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 80 -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 81 -0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, 82 -0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 83 -0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000, 84 -0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, 85 -0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 86 -0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 87 -0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, 88 -0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 89 -0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, 90 -0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 91 -0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 92 -0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, 93 -0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF, 94 -0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 95 -0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF, 96 -0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF, 97 -0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 98 -0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0, 99 -0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1, 100 -0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 101 -0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80, 102 -0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3, 103 -0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 104 -0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3, 105 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 106 -0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 107 -0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000, 108 -0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF, 109 -0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 110 -0x00000000, 0x00000000, 0x00000000, 0x00000000, 111 -0x00000000, 0x00000000, 0x1FFF0000, 0x00000002, 112 -0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 113 -0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF, 34 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 35 + 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 36 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x04000000, 37 + 0x87FFFFFE, 0x07FFFFFE, 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, 38 + 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 39 + 0xFFFFE00F, 0xFC31FFFF, 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 40 + 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 41 + 0x00000000, 0x00000000, 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, 42 + 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFF0003, 0xFFFFFFFF, 43 + 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, 44 + 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0x00000000, 0x07FFFFFE, 45 + 0x000007FE, 0xFFFE0000, 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, 46 + 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0xFFF99FE0, 0x03C5FDFF, 47 + 0xB0000000, 0x00030003, 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, 48 + 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0xFFF99FE0, 0x23CDFDFF, 49 + 0xB0000000, 0x00000003, 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, 50 + 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFDDFE0, 0x03EFFDFF, 51 + 0x40000000, 0x00000003, 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, 52 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x000D7FFF, 53 + 0x0000003F, 0x00000000, 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, 54 + 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000, 55 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 56 + 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x0007DAED, 0x50000000, 57 + 0x82315001, 0x002C62AB, 0x40000000, 0xF580C900, 0x00000007, 0x02010800, 58 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0FFFFFFF, 0xFFFFFFFF, 59 + 0xFFFFFFFF, 0x03FFFFFF, 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, 60 + 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x00000000, 0x00004C40, 61 + 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000, 62 + 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0x001FFFFF, 0xFFFFFFFE, 63 + 0xFFFFFFFF, 0x07FFFFFF, 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, 64 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 65 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, 66 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F, 67 + 0x00000000, 0x00000000, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, 68 + 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00FFFFFF, 0x00000000, 69 + 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, 70 + 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 0xFFFFD7C0, 0xFFFFFFFB, 71 + 0x547F7FFF, 0x000FFFFD, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 72 + 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 73 + 0x027FFFFF, 0xFFFFFFFE, 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF, 74 + 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 0xFFFFFFFF, 0x7CFFFFFF, 75 + 0xFFEF7FFF, 0x03FF3DFF, 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF, 76 + 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 0xFFF987E4, 0xD36DFDFF, 77 + 0x5E003987, 0x001FFFC0, 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1, 78 + 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 0xD63DC7EC, 0xC3BFC718, 79 + 0x00803DC7, 0x0000FF80, 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3, 80 + 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 0xFFFDDFEC, 0xC3FFFDFF, 81 + 0x00803DCF, 0x0000FFC3, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 82 + 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 0xFEF02596, 0x3BFF6CAE, 83 + 0x03FF3F5F, 0x00000000, 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF, 84 + 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 85 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002, 86 + 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 0x661FFFFF, 0xFFFFFFFE, 87 + 0xFFFFFFFF, 0x77FFFFFF, 114 88 }; 115 89 static const unsigned char nmstrtPages[] = { 116 -0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 117 -0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 118 -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 119 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 120 -0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 -0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 124 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 125 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 126 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 127 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 128 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 129 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 130 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 131 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 132 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 133 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 134 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 135 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 136 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 137 -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 138 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 139 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 140 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 141 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 142 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, 143 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 144 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 145 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 146 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 147 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 90 + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x09, 0x0A, 0x0B, 91 + 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 92 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x14, 0x00, 0x00, 93 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 94 + 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 95 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 96 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 97 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 98 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 99 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 100 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 101 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 102 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 103 + 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 104 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 105 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 106 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 107 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, 108 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 110 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 111 + 0x00, 0x00, 0x00, 0x00, 148 112 }; 149 113 static const unsigned char namePages[] = { 150 -0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 151 -0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 152 -0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 153 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 154 -0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 155 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 156 -0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 157 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 158 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 159 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 160 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 161 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 162 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 163 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 164 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 165 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 166 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 167 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 168 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 169 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 170 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 171 -0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 172 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 173 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 174 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 175 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 176 -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, 177 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 178 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 179 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 180 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 181 -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 114 + 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x00, 0x1F, 0x20, 0x21, 115 + 0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 116 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x26, 0x14, 0x00, 0x00, 117 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 118 + 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 119 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 120 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 121 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 122 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 123 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 124 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 125 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 126 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 127 + 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 128 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 129 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 130 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 131 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18, 132 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 133 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 134 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 135 + 0x00, 0x00, 0x00, 0x00, 182 136 };
Changes to expat/siphash.h.
7 7 * Licensed under the CC0 Public Domain Dedication license. 8 8 * 9 9 * 1. https://www.131002.net/siphash/siphash24.c 10 10 * 2. https://www.131002.net/siphash/ 11 11 * -------------------------------------------------------------------------- 12 12 * HISTORY: 13 13 * 14 + * 2019-08-03 (Sebastian Pipping) 15 + * - Mark part of sip24_valid as to be excluded from clang-format 16 + * - Re-format code using clang-format 9 17 + * 14 18 * 2018-07-08 (Anton Maklakov) 15 19 * - Add "fall through" markers for GCC's -Wimplicit-fallthrough 16 20 * 17 21 * 2017-11-03 (Sebastian Pipping) 18 22 * - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined 19 23 * 20 24 * 2017-07-25 (Vadim Zeitlin) ................................................................................ 90 94 */ 91 95 #ifndef SIPHASH_H 92 96 #define SIPHASH_H 93 97 94 98 #include <stddef.h> /* size_t */ 95 99 96 100 #if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600) 97 - /* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */ 98 - typedef unsigned __int8 uint8_t; 99 - typedef unsigned __int32 uint32_t; 100 - typedef unsigned __int64 uint64_t; 101 +/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */ 102 +typedef unsigned __int8 uint8_t; 103 +typedef unsigned __int32 uint32_t; 104 +typedef unsigned __int64 uint64_t; 101 105 #else 102 - #include <stdint.h> /* uint64_t uint32_t uint8_t */ 106 +# include <stdint.h> /* uint64_t uint32_t uint8_t */ 103 107 #endif 104 - 105 108 106 109 /* 107 110 * Workaround to not require a C++11 compiler for using ULL suffix 108 111 * if this code is included and compiled as C++; related GCC warning is: 109 112 * warning: use of C++11 long long integer constant [-Wlong-long] 110 113 */ 111 -#define _SIP_ULL(high, low) (((uint64_t)high << 32) | low) 112 - 113 - 114 -#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ( (x) >> (64 - (b)))) 115 - 116 -#define SIP_U32TO8_LE(p, v) \ 117 - (p)[0] = (uint8_t)((v) >> 0); (p)[1] = (uint8_t)((v) >> 8); \ 118 - (p)[2] = (uint8_t)((v) >> 16); (p)[3] = (uint8_t)((v) >> 24); 119 - 120 -#define SIP_U64TO8_LE(p, v) \ 121 - SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \ 122 - SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32)); 123 - 124 -#define SIP_U8TO64_LE(p) \ 125 - (((uint64_t)((p)[0]) << 0) | \ 126 - ((uint64_t)((p)[1]) << 8) | \ 127 - ((uint64_t)((p)[2]) << 16) | \ 128 - ((uint64_t)((p)[3]) << 24) | \ 129 - ((uint64_t)((p)[4]) << 32) | \ 130 - ((uint64_t)((p)[5]) << 40) | \ 131 - ((uint64_t)((p)[6]) << 48) | \ 132 - ((uint64_t)((p)[7]) << 56)) 133 - 134 - 135 -#define SIPHASH_INITIALIZER { 0, 0, 0, 0, { 0 }, 0, 0 } 114 +#define _SIP_ULL(high, low) (((uint64_t)high << 32) | low) 115 + 116 +#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) 117 + 118 +#define SIP_U32TO8_LE(p, v) \ 119 + (p)[0] = (uint8_t)((v) >> 0); \ 120 + (p)[1] = (uint8_t)((v) >> 8); \ 121 + (p)[2] = (uint8_t)((v) >> 16); \ 122 + (p)[3] = (uint8_t)((v) >> 24); 123 + 124 +#define SIP_U64TO8_LE(p, v) \ 125 + SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \ 126 + SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32)); 127 + 128 +#define SIP_U8TO64_LE(p) \ 129 + (((uint64_t)((p)[0]) << 0) | ((uint64_t)((p)[1]) << 8) \ 130 + | ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) \ 131 + | ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \ 132 + | ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56)) 133 + 134 +#define SIPHASH_INITIALIZER \ 135 + { 0, 0, 0, 0, {0}, 0, 0 } 136 136 137 137 struct siphash { 138 - uint64_t v0, v1, v2, v3; 138 + uint64_t v0, v1, v2, v3; 139 139 140 - unsigned char buf[8], *p; 141 - uint64_t c; 140 + unsigned char buf[8], *p; 141 + uint64_t c; 142 142 }; /* struct siphash */ 143 - 144 143 145 144 #define SIP_KEYLEN 16 146 145 147 146 struct sipkey { 148 - uint64_t k[2]; 147 + uint64_t k[2]; 149 148 }; /* struct sipkey */ 150 149 151 -#define sip_keyof(k) sip_tokey(&(struct sipkey){ { 0 } }, (k)) 150 +#define sip_keyof(k) sip_tokey(&(struct sipkey){{0}}, (k)) 152 151 153 -static struct sipkey *sip_tokey(struct sipkey *key, const void *src) { 154 - key->k[0] = SIP_U8TO64_LE((const unsigned char *)src); 155 - key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8); 156 - return key; 152 +static struct sipkey * 153 +sip_tokey(struct sipkey *key, const void *src) { 154 + key->k[0] = SIP_U8TO64_LE((const unsigned char *)src); 155 + key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8); 156 + return key; 157 157 } /* sip_tokey() */ 158 - 159 158 160 159 #ifdef SIPHASH_TOBIN 161 160 162 -#define sip_binof(v) sip_tobin((unsigned char[8]){ 0 }, (v)) 161 +# define sip_binof(v) sip_tobin((unsigned char[8]){0}, (v)) 163 162 164 -static void *sip_tobin(void *dst, uint64_t u64) { 165 - SIP_U64TO8_LE((unsigned char *)dst, u64); 166 - return dst; 163 +static void * 164 +sip_tobin(void *dst, uint64_t u64) { 165 + SIP_U64TO8_LE((unsigned char *)dst, u64); 166 + return dst; 167 167 } /* sip_tobin() */ 168 168 169 -#endif /* SIPHASH_TOBIN */ 170 - 171 - 172 -static void sip_round(struct siphash *H, const int rounds) { 173 - int i; 174 - 175 - for (i = 0; i < rounds; i++) { 176 - H->v0 += H->v1; 177 - H->v1 = SIP_ROTL(H->v1, 13); 178 - H->v1 ^= H->v0; 179 - H->v0 = SIP_ROTL(H->v0, 32); 180 - 181 - H->v2 += H->v3; 182 - H->v3 = SIP_ROTL(H->v3, 16); 183 - H->v3 ^= H->v2; 184 - 185 - H->v0 += H->v3; 186 - H->v3 = SIP_ROTL(H->v3, 21); 187 - H->v3 ^= H->v0; 188 - 189 - H->v2 += H->v1; 190 - H->v1 = SIP_ROTL(H->v1, 17); 191 - H->v1 ^= H->v2; 192 - H->v2 = SIP_ROTL(H->v2, 32); 193 - } 169 +#endif /* SIPHASH_TOBIN */ 170 + 171 +static void 172 +sip_round(struct siphash *H, const int rounds) { 173 + int i; 174 + 175 + for (i = 0; i < rounds; i++) { 176 + H->v0 += H->v1; 177 + H->v1 = SIP_ROTL(H->v1, 13); 178 + H->v1 ^= H->v0; 179 + H->v0 = SIP_ROTL(H->v0, 32); 180 + 181 + H->v2 += H->v3; 182 + H->v3 = SIP_ROTL(H->v3, 16); 183 + H->v3 ^= H->v2; 184 + 185 + H->v0 += H->v3; 186 + H->v3 = SIP_ROTL(H->v3, 21); 187 + H->v3 ^= H->v0; 188 + 189 + H->v2 += H->v1; 190 + H->v1 = SIP_ROTL(H->v1, 17); 191 + H->v1 ^= H->v2; 192 + H->v2 = SIP_ROTL(H->v2, 32); 193 + } 194 194 } /* sip_round() */ 195 195 196 +static struct siphash * 197 +sip24_init(struct siphash *H, const struct sipkey *key) { 198 + H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0]; 199 + H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1]; 200 + H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0]; 201 + H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1]; 196 202 197 -static struct siphash *sip24_init(struct siphash *H, 198 - const struct sipkey *key) { 199 - H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0]; 200 - H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1]; 201 - H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0]; 202 - H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1]; 203 + H->p = H->buf; 204 + H->c = 0; 203 205 204 - H->p = H->buf; 205 - H->c = 0; 206 - 207 - return H; 206 + return H; 208 207 } /* sip24_init() */ 209 208 210 - 211 -#define sip_endof(a) (&(a)[sizeof (a) / sizeof *(a)]) 212 - 213 -static struct siphash *sip24_update(struct siphash *H, const void *src, 214 - size_t len) { 215 - const unsigned char *p = (const unsigned char *)src, *pe = p + len; 216 - uint64_t m; 217 - 218 - do { 219 - while (p < pe && H->p < sip_endof(H->buf)) 220 - *H->p++ = *p++; 221 - 222 - if (H->p < sip_endof(H->buf)) 223 - break; 224 - 225 - m = SIP_U8TO64_LE(H->buf); 226 - H->v3 ^= m; 227 - sip_round(H, 2); 228 - H->v0 ^= m; 229 - 230 - H->p = H->buf; 231 - H->c += 8; 232 - } while (p < pe); 233 - 234 - return H; 209 +#define sip_endof(a) (&(a)[sizeof(a) / sizeof *(a)]) 210 + 211 +static struct siphash * 212 +sip24_update(struct siphash *H, const void *src, size_t len) { 213 + const unsigned char *p = (const unsigned char *)src, *pe = p + len; 214 + uint64_t m; 215 + 216 + do { 217 + while (p < pe && H->p < sip_endof(H->buf)) 218 + *H->p++ = *p++; 219 + 220 + if (H->p < sip_endof(H->buf)) 221 + break; 222 + 223 + m = SIP_U8TO64_LE(H->buf); 224 + H->v3 ^= m; 225 + sip_round(H, 2); 226 + H->v0 ^= m; 227 + 228 + H->p = H->buf; 229 + H->c += 8; 230 + } while (p < pe); 231 + 232 + return H; 235 233 } /* sip24_update() */ 236 234 237 - 238 -static uint64_t sip24_final(struct siphash *H) { 239 - const char left = (char)(H->p - H->buf); 240 - uint64_t b = (H->c + left) << 56; 241 - 242 - switch (left) { 243 - case 7: b |= (uint64_t)H->buf[6] << 48; 244 - /* fall through */ 245 - case 6: b |= (uint64_t)H->buf[5] << 40; 246 - /* fall through */ 247 - case 5: b |= (uint64_t)H->buf[4] << 32; 248 - /* fall through */ 249 - case 4: b |= (uint64_t)H->buf[3] << 24; 250 - /* fall through */ 251 - case 3: b |= (uint64_t)H->buf[2] << 16; 252 - /* fall through */ 253 - case 2: b |= (uint64_t)H->buf[1] << 8; 254 - /* fall through */ 255 - case 1: b |= (uint64_t)H->buf[0] << 0; 256 - /* fall through */ 257 - case 0: break; 258 - } 259 - 260 - H->v3 ^= b; 261 - sip_round(H, 2); 262 - H->v0 ^= b; 263 - H->v2 ^= 0xff; 264 - sip_round(H, 4); 265 - 266 - return H->v0 ^ H->v1 ^ H->v2 ^ H->v3; 235 +static uint64_t 236 +sip24_final(struct siphash *H) { 237 + const char left = (char)(H->p - H->buf); 238 + uint64_t b = (H->c + left) << 56; 239 + 240 + switch (left) { 241 + case 7: 242 + b |= (uint64_t)H->buf[6] << 48; 243 + /* fall through */ 244 + case 6: 245 + b |= (uint64_t)H->buf[5] << 40; 246 + /* fall through */ 247 + case 5: 248 + b |= (uint64_t)H->buf[4] << 32; 249 + /* fall through */ 250 + case 4: 251 + b |= (uint64_t)H->buf[3] << 24; 252 + /* fall through */ 253 + case 3: 254 + b |= (uint64_t)H->buf[2] << 16; 255 + /* fall through */ 256 + case 2: 257 + b |= (uint64_t)H->buf[1] << 8; 258 + /* fall through */ 259 + case 1: 260 + b |= (uint64_t)H->buf[0] << 0; 261 + /* fall through */ 262 + case 0: 263 + break; 264 + } 265 + 266 + H->v3 ^= b; 267 + sip_round(H, 2); 268 + H->v0 ^= b; 269 + H->v2 ^= 0xff; 270 + sip_round(H, 4); 271 + 272 + return H->v0 ^ H->v1 ^ H->v2 ^ H->v3; 267 273 } /* sip24_final() */ 268 274 269 - 270 -static uint64_t siphash24(const void *src, size_t len, 271 - const struct sipkey *key) { 272 - struct siphash state = SIPHASH_INITIALIZER; 273 - return sip24_final(sip24_update(sip24_init(&state, key), src, len)); 275 +static uint64_t 276 +siphash24(const void *src, size_t len, const struct sipkey *key) { 277 + struct siphash state = SIPHASH_INITIALIZER; 278 + return sip24_final(sip24_update(sip24_init(&state, key), src, len)); 274 279 } /* siphash24() */ 275 - 276 280 277 281 /* 278 282 * SipHash-2-4 output with 279 283 * k = 00 01 02 ... 280 284 * and 281 285 * in = (empty string) 282 286 * in = 00 (1 byte) 283 287 * in = 00 01 (2 bytes) 284 288 * in = 00 01 02 (3 bytes) 285 289 * ... 286 290 * in = 00 01 02 ... 3e (63 bytes) 287 291 */ 288 -static int sip24_valid(void) { 289 - static const unsigned char vectors[64][8] = { 290 - { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, }, 291 - { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, }, 292 - { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, }, 293 - { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, }, 294 - { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, }, 295 - { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, }, 296 - { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, }, 297 - { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, }, 298 - { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, }, 299 - { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, }, 300 - { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, }, 301 - { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, }, 302 - { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, }, 303 - { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, }, 304 - { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, }, 305 - { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, }, 306 - { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, }, 307 - { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, }, 308 - { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, }, 309 - { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, }, 310 - { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, }, 311 - { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, }, 312 - { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, }, 313 - { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, }, 314 - { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, }, 315 - { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, }, 316 - { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, }, 317 - { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, }, 318 - { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, }, 319 - { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, }, 320 - { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, }, 321 - { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, }, 322 - { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, }, 323 - { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, }, 324 - { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, }, 325 - { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, }, 326 - { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, }, 327 - { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, }, 328 - { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, }, 329 - { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, }, 330 - { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, }, 331 - { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, }, 332 - { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, }, 333 - { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, }, 334 - { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, }, 335 - { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, }, 336 - { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, }, 337 - { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, }, 338 - { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, }, 339 - { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, }, 340 - { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, }, 341 - { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, }, 342 - { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, }, 343 - { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, }, 344 - { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, }, 345 - { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, }, 346 - { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, }, 347 - { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, }, 348 - { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, }, 349 - { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, }, 350 - { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, }, 351 - { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, }, 352 - { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, }, 353 - { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, } 354 - }; 355 - unsigned char in[64]; 356 - struct sipkey k; 357 - size_t i; 292 +static int 293 +sip24_valid(void) { 294 + /* clang-format off */ 295 + static const unsigned char vectors[64][8] = { 296 + { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, }, 297 + { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, }, 298 + { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, }, 299 + { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, }, 300 + { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, }, 301 + { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, }, 302 + { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, }, 303 + { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, }, 304 + { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, }, 305 + { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, }, 306 + { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, }, 307 + { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, }, 308 + { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, }, 309 + { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, }, 310 + { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, }, 311 + { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, }, 312 + { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, }, 313 + { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, }, 314 + { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, }, 315 + { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, }, 316 + { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, }, 317 + { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, }, 318 + { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, }, 319 + { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, }, 320 + { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, }, 321 + { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, }, 322 + { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, }, 323 + { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, }, 324 + { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, }, 325 + { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, }, 326 + { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, }, 327 + { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, }, 328 + { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, }, 329 + { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, }, 330 + { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, }, 331 + { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, }, 332 + { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, }, 333 + { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, }, 334 + { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, }, 335 + { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, }, 336 + { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, }, 337 + { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, }, 338 + { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, }, 339 + { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, }, 340 + { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, }, 341 + { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, }, 342 + { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, }, 343 + { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, }, 344 + { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, }, 345 + { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, }, 346 + { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, }, 347 + { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, }, 348 + { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, }, 349 + { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, }, 350 + { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, }, 351 + { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, }, 352 + { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, }, 353 + { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, }, 354 + { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, }, 355 + { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, }, 356 + { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, }, 357 + { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, }, 358 + { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, }, 359 + { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, } 360 + }; 361 + /* clang-format on */ 362 + 363 + unsigned char in[64]; 364 + struct sipkey k; 365 + size_t i; 366 + 367 + sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011" 368 + "\012\013\014\015\016\017"); 369 + 370 + for (i = 0; i < sizeof in; ++i) { 371 + in[i] = (unsigned char)i; 372 + 373 + if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i])) 374 + return 0; 375 + } 358 376 359 - sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011" 360 - "\012\013\014\015\016\017"); 361 - 362 - for (i = 0; i < sizeof in; ++i) { 363 - in[i] = (unsigned char)i; 364 - 365 - if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i])) 366 - return 0; 367 - } 368 - 369 - return 1; 377 + return 1; 370 378 } /* sip24_valid() */ 371 - 372 379 373 380 #ifdef SIPHASH_MAIN 374 381 375 -#include <stdio.h> 382 +# include <stdio.h> 376 383 377 -int main(void) { 378 - const int ok = sip24_valid(); 384 +int 385 +main(void) { 386 + const int ok = sip24_valid(); 379 387 380 - if (ok) 381 - puts("OK"); 382 - else 383 - puts("FAIL"); 388 + if (ok) 389 + puts("OK"); 390 + else 391 + puts("FAIL"); 384 392 385 - return !ok; 393 + return ! ok; 386 394 } /* main() */ 387 395 388 396 #endif /* SIPHASH_MAIN */ 389 - 390 397 391 398 #endif /* SIPHASH_H */
Changes to expat/utf8tab.h.
27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 /* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 34 -/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 35 -/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 36 -/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 37 -/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 38 -/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 39 -/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 40 -/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 41 -/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 42 -/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 43 -/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 44 -/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 45 -/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 46 -/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 47 -/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 48 -/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 49 -/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 50 -/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 51 -/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 52 -/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 53 -/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 54 -/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 55 -/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 56 -/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 57 -/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 58 -/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 59 -/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 60 -/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 61 -/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4, 62 -/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML, 63 -/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 64 -/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM, 34 + /* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 35 + /* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 36 + /* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 37 + /* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 38 + /* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 39 + /* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 40 + /* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 41 + /* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 42 + /* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 43 + /* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 44 + /* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 45 + /* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 46 + /* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 47 + /* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 48 + /* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 49 + /* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 50 + /* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 51 + /* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 52 + /* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 53 + /* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 54 + /* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 55 + /* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 56 + /* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 57 + /* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 58 + /* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 59 + /* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 60 + /* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 61 + /* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4, 62 + /* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML, 63 + /* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 64 + /* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
Changes to expat/winconfig.h.
36 36 #define WIN32_LEAN_AND_MEAN 37 37 #include <windows.h> 38 38 #undef WIN32_LEAN_AND_MEAN 39 39 40 40 #include <memory.h> 41 41 #include <string.h> 42 42 43 - 44 -#if defined(HAVE_EXPAT_CONFIG_H) /* e.g. MinGW */ 45 -# include <expat_config.h> 46 -#else /* !defined(HAVE_EXPAT_CONFIG_H) */ 43 +#if defined(HAVE_EXPAT_CONFIG_H) /* e.g. MinGW */ 44 +# include <expat_config.h> 45 +#else /* !defined(HAVE_EXPAT_CONFIG_H) */ 47 46 48 - 49 -#define XML_NS 1 50 -#define XML_DTD 1 51 -#define XML_CONTEXT_BYTES 1024 47 +# define XML_NS 1 48 +# define XML_DTD 1 49 +# define XML_CONTEXT_BYTES 1024 52 50 53 51 /* we will assume all Windows platforms are little endian */ 54 -#define BYTEORDER 1234 55 - 56 -/* Windows has memmove() available. */ 57 -#define HAVE_MEMMOVE 58 - 52 +# define BYTEORDER 1234 59 53 60 54 #endif /* !defined(HAVE_EXPAT_CONFIG_H) */ 61 - 62 55 63 56 #endif /* ndef WINCONFIG_H */
Changes to expat/xmlparse.c.
1 -/* 19ac4776051591216f1874e34ee99b6a43a3784c8bd7d70efeb9258dd22b906a (2.2.6+) 1 +/* f519f27c7c3b79fee55aeb8b1e53b7384b079d9118bf3a62eb3a60986a6742f2 (2.2.9+) 2 2 __ __ _ 3 3 ___\ \/ /_ __ __ _| |_ 4 4 / _ \\ /| '_ \ / _` | __| 5 5 | __// \| |_) | (_| | |_ 6 6 \___/_/\_\ .__/ \__,_|\__| 7 7 |_| XML parser 8 8 ................................................................................ 26 26 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 -#if !defined(_GNU_SOURCE) 34 -# define _GNU_SOURCE 1 /* syscall prototype */ 33 +#if ! defined(_GNU_SOURCE) 34 +# define _GNU_SOURCE 1 /* syscall prototype */ 35 +#endif 36 + 37 +#ifdef _WIN32 38 +/* force stdlib to define rand_s() */ 39 +# if ! defined(_CRT_RAND_S) 40 +# define _CRT_RAND_S 41 +# endif 35 42 #endif 36 43 37 44 #include <stddef.h> 38 -#include <string.h> /* memset(), memcpy() */ 45 +#include <string.h> /* memset(), memcpy() */ 39 46 #include <assert.h> 40 -#include <limits.h> /* UINT_MAX */ 41 -#include <stdio.h> /* fprintf */ 42 -#include <stdlib.h> /* getenv */ 47 +#include <limits.h> /* UINT_MAX */ 48 +#include <stdio.h> /* fprintf */ 49 +#include <stdlib.h> /* getenv, rand_s */ 43 50 44 51 #ifdef _WIN32 45 -#define getpid GetCurrentProcessId 52 +# define getpid GetCurrentProcessId 46 53 #else 47 -#include <sys/time.h> /* gettimeofday() */ 48 -#include <sys/types.h> /* getpid() */ 49 -#include <unistd.h> /* getpid() */ 50 -#include <fcntl.h> /* O_RDONLY */ 51 -#include <errno.h> 54 +# include <sys/time.h> /* gettimeofday() */ 55 +# include <sys/types.h> /* getpid() */ 56 +# include <unistd.h> /* getpid() */ 57 +# include <fcntl.h> /* O_RDONLY */ 58 +# include <errno.h> 52 59 #endif 53 60 54 61 #define XML_BUILDING_EXPAT 1 55 62 56 63 #ifdef _WIN32 57 -#include "winconfig.h" 64 +# include "winconfig.h" 58 65 #elif defined(HAVE_EXPAT_CONFIG_H) 59 -#include <expat_config.h> 66 +# include <expat_config.h> 60 67 #endif /* ndef _WIN32 */ 61 68 62 69 #include "ascii.h" 63 70 #include "expat.h" 64 71 #include "siphash.h" 65 72 66 73 #if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) 67 -# if defined(HAVE_GETRANDOM) 68 -# include <sys/random.h> /* getrandom */ 69 -# else 70 -# include <unistd.h> /* syscall */ 71 -# include <sys/syscall.h> /* SYS_getrandom */ 72 -# endif 73 -# if ! defined(GRND_NONBLOCK) 74 -# define GRND_NONBLOCK 0x0001 75 -# endif /* defined(GRND_NONBLOCK) */ 76 -#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ 74 +# if defined(HAVE_GETRANDOM) 75 +# include <sys/random.h> /* getrandom */ 76 +# else 77 +# include <unistd.h> /* syscall */ 78 +# include <sys/syscall.h> /* SYS_getrandom */ 79 +# endif 80 +# if ! defined(GRND_NONBLOCK) 81 +# define GRND_NONBLOCK 0x0001 82 +# endif /* defined(GRND_NONBLOCK) */ 83 +#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ 77 84 78 -#if defined(HAVE_LIBBSD) \ 85 +#if defined(HAVE_LIBBSD) \ 79 86 && (defined(HAVE_ARC4RANDOM_BUF) || defined(HAVE_ARC4RANDOM)) 80 -# include <bsd/stdlib.h> 87 +# include <bsd/stdlib.h> 81 88 #endif 82 89 83 -#if defined(_WIN32) && !defined(LOAD_LIBRARY_SEARCH_SYSTEM32) 84 -# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 90 +#if defined(_WIN32) && ! defined(LOAD_LIBRARY_SEARCH_SYSTEM32) 91 +# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 85 92 #endif 86 93 87 -#if !defined(HAVE_GETRANDOM) && !defined(HAVE_SYSCALL_GETRANDOM) \ 88 - && !defined(HAVE_ARC4RANDOM_BUF) && !defined(HAVE_ARC4RANDOM) \ 89 - && !defined(XML_DEV_URANDOM) \ 90 - && !defined(_WIN32) \ 91 - && !defined(XML_POOR_ENTROPY) 92 -# error \ 93 - You do not have support for any sources of high quality entropy \ 94 +#if ! defined(HAVE_GETRANDOM) && ! defined(HAVE_SYSCALL_GETRANDOM) \ 95 + && ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) \ 96 + && ! defined(XML_DEV_URANDOM) && ! defined(_WIN32) \ 97 + && ! defined(XML_POOR_ENTROPY) 98 +# error You do not have support for any sources of high quality entropy \ 94 99 enabled. For end user security, that is probably not what you want. \ 95 100 \ 96 101 Your options include: \ 97 102 * Linux + glibc >=2.25 (getrandom): HAVE_GETRANDOM, \ 98 103 * Linux + glibc <2.25 (syscall SYS_getrandom): HAVE_SYSCALL_GETRANDOM, \ 99 104 * BSD / macOS >=10.7 (arc4random_buf): HAVE_ARC4RANDOM_BUF, \ 100 105 * BSD / macOS <10.7 (arc4random): HAVE_ARC4RANDOM, \ 101 106 * libbsd (arc4random_buf): HAVE_ARC4RANDOM_BUF + HAVE_LIBBSD, \ 102 107 * libbsd (arc4random): HAVE_ARC4RANDOM + HAVE_LIBBSD, \ 103 108 * Linux / BSD / macOS (/dev/urandom): XML_DEV_URANDOM \ 104 - * Windows (RtlGenRandom): _WIN32. \ 109 + * Windows (rand_s): _WIN32. \ 105 110 \ 106 111 If insist on not using any of these, bypass this error by defining \ 107 112 XML_POOR_ENTROPY; you have been warned. \ 108 113 \ 109 114 If you have reasons to patch this detection code away or need changes \ 110 115 to the build system, please open a bug. Thank you! 111 116 #endif 112 117 113 - 114 118 #ifdef XML_UNICODE 115 -#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX 116 -#define XmlConvert XmlUtf16Convert 117 -#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding 118 -#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS 119 -#define XmlEncode XmlUtf16Encode 119 +# define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX 120 +# define XmlConvert XmlUtf16Convert 121 +# define XmlGetInternalEncoding XmlGetUtf16InternalEncoding 122 +# define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS 123 +# define XmlEncode XmlUtf16Encode 120 124 /* Using pointer subtraction to convert to integer type. */ 121 -#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) 125 +# define MUST_CONVERT(enc, s) \ 126 + (! (enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) 122 127 typedef unsigned short ICHAR; 123 128 #else 124 -#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX 125 -#define XmlConvert XmlUtf8Convert 126 -#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding 127 -#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS 128 -#define XmlEncode XmlUtf8Encode 129 -#define MUST_CONVERT(enc, s) (!(enc)->isUtf8) 129 +# define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX 130 +# define XmlConvert XmlUtf8Convert 131 +# define XmlGetInternalEncoding XmlGetUtf8InternalEncoding 132 +# define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS 133 +# define XmlEncode XmlUtf8Encode 134 +# define MUST_CONVERT(enc, s) (! (enc)->isUtf8) 130 135 typedef char ICHAR; 131 136 #endif 132 137 133 - 134 138 #ifndef XML_NS 135 139 136 -#define XmlInitEncodingNS XmlInitEncoding 137 -#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding 138 -#undef XmlGetInternalEncodingNS 139 -#define XmlGetInternalEncodingNS XmlGetInternalEncoding 140 -#define XmlParseXmlDeclNS XmlParseXmlDecl 140 +# define XmlInitEncodingNS XmlInitEncoding 141 +# define XmlInitUnknownEncodingNS XmlInitUnknownEncoding 142 +# undef XmlGetInternalEncodingNS 143 +# define XmlGetInternalEncodingNS XmlGetInternalEncoding 144 +# define XmlParseXmlDeclNS XmlParseXmlDecl 141 145 142 146 #endif 143 147 144 148 #ifdef XML_UNICODE 145 149 146 -#ifdef XML_UNICODE_WCHAR_T 147 -#define XML_T(x) (const wchar_t)x 148 -#define XML_L(x) L ## x 149 -#else 150 -#define XML_T(x) (const unsigned short)x 151 -#define XML_L(x) x 152 -#endif 150 +# ifdef XML_UNICODE_WCHAR_T 151 +# define XML_T(x) (const wchar_t) x 152 +# define XML_L(x) L##x 153 +# else 154 +# define XML_T(x) (const unsigned short)x 155 +# define XML_L(x) x 156 +# endif 153 157 154 158 #else 155 159 156 -#define XML_T(x) x 157 -#define XML_L(x) x 160 +# define XML_T(x) x 161 +# define XML_L(x) x 158 162 159 163 #endif 160 164 161 165 /* Round up n to be a multiple of sz, where sz is a power of 2. */ 162 -#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) 166 +#define ROUND_UP(n, sz) (((n) + ((sz)-1)) & ~((sz)-1)) 163 167 164 168 /* Do safe (NULL-aware) pointer arithmetic */ 165 169 #define EXPAT_SAFE_PTR_DIFF(p, q) (((p) && (q)) ? ((p) - (q)) : 0) 166 170 167 -/* Handle the case where memmove() doesn't exist. */ 168 -#ifndef HAVE_MEMMOVE 169 -#ifdef HAVE_BCOPY 170 -#define memmove(d,s,l) bcopy((s),(d),(l)) 171 -#else 172 -#error memmove does not exist on this platform, nor is a substitute available 173 -#endif /* HAVE_BCOPY */ 174 -#endif /* HAVE_MEMMOVE */ 175 - 176 171 #include "internal.h" 177 172 #include "xmltok.h" 178 173 #include "xmlrole.h" 179 174 180 175 typedef const XML_Char *KEY; 181 176 182 177 typedef struct { ................................................................................ 187 182 NAMED **v; 188 183 unsigned char power; 189 184 size_t size; 190 185 size_t used; 191 186 const XML_Memory_Handling_Suite *mem; 192 187 } HASH_TABLE; 193 188 194 -static size_t 195 -keylen(KEY s); 189 +static size_t keylen(KEY s); 196 190 197 -static void 198 -copy_salt_to_sipkey(XML_Parser parser, struct sipkey * key); 191 +static void copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key); 199 192 200 193 /* For probing (after a collision) we need a step size relative prime 201 194 to the hash table size, which is a power of 2. We use double-hashing, 202 195 since we can calculate a second hash value cheaply by taking those bits 203 196 of the first hash value that were discarded (masked out) when the table 204 197 index was calculated: index = hash & mask, where mask = table->size - 1. 205 198 We limit the maximum step size to table->size / 4 (mask >> 2) and make 206 199 it odd, since odd numbers are always relative prime to a power of 2. 207 200 */ 208 -#define SECOND_HASH(hash, mask, power) \ 209 - ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2)) 210 -#define PROBE_STEP(hash, mask, power) \ 201 +#define SECOND_HASH(hash, mask, power) \ 202 + ((((hash) & ~(mask)) >> ((power)-1)) & ((mask) >> 2)) 203 +#define PROBE_STEP(hash, mask, power) \ 211 204 ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1)) 212 205 213 206 typedef struct { 214 207 NAMED **p; 215 208 NAMED **end; 216 209 } HASH_TABLE_ITER; 217 210 218 -#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ 211 +#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ 219 212 #define INIT_DATA_BUF_SIZE 1024 220 213 #define INIT_ATTS_SIZE 16 221 214 #define INIT_ATTS_VERSION 0xFFFFFFFF 222 215 #define INIT_BLOCK_SIZE 1024 223 216 #define INIT_BUFFER_SIZE 1024 224 217 225 218 #define EXPAND_SPARE 24 ................................................................................ 258 251 XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to 259 252 contain the 'raw' name as well. 260 253 261 254 A parser re-uses these structures, maintaining a list of allocated 262 255 TAG objects in a free list. 263 256 */ 264 257 typedef struct tag { 265 - struct tag *parent; /* parent of this element */ 266 - const char *rawName; /* tagName in the original encoding */ 258 + struct tag *parent; /* parent of this element */ 259 + const char *rawName; /* tagName in the original encoding */ 267 260 int rawNameLength; 268 - TAG_NAME name; /* tagName in the API encoding */ 269 - char *buf; /* buffer for name components */ 270 - char *bufEnd; /* end of the buffer */ 261 + TAG_NAME name; /* tagName in the API encoding */ 262 + char *buf; /* buffer for name components */ 263 + char *bufEnd; /* end of the buffer */ 271 264 BINDING *bindings; 272 265 } TAG; 273 266 274 267 typedef struct { 275 268 const XML_Char *name; 276 269 const XML_Char *textPtr; 277 - int textLen; /* length in XML_Chars */ 278 - int processed; /* # of processed bytes - when suspended */ 270 + int textLen; /* length in XML_Chars */ 271 + int processed; /* # of processed bytes - when suspended */ 279 272 const XML_Char *systemId; 280 273 const XML_Char *base; 281 274 const XML_Char *publicId; 282 275 const XML_Char *notation; 283 276 XML_Bool open; 284 277 XML_Bool is_param; 285 278 XML_Bool is_internal; /* true if declared in internal subset outside PE */ 286 279 } ENTITY; 287 280 288 281 typedef struct { 289 - enum XML_Content_Type type; 290 - enum XML_Content_Quant quant; 291 - const XML_Char * name; 292 - int firstchild; 293 - int lastchild; 294 - int childcnt; 295 - int nextsib; 282 + enum XML_Content_Type type; 283 + enum XML_Content_Quant quant; 284 + const XML_Char *name; 285 + int firstchild; 286 + int lastchild; 287 + int childcnt; 288 + int nextsib; 296 289 } CONTENT_SCAFFOLD; 297 290 298 291 #define INIT_SCAFFOLD_ELEMENTS 32 299 292 300 293 typedef struct block { 301 294 struct block *next; 302 295 int size; ................................................................................ 376 369 const char *internalEventEndPtr; 377 370 struct open_internal_entity *next; 378 371 ENTITY *entity; 379 372 int startTagLevel; 380 373 XML_Bool betweenDecl; /* WFC: PE Between Declarations */ 381 374 } OPEN_INTERNAL_ENTITY; 382 375 383 -typedef enum XML_Error PTRCALL Processor(XML_Parser parser, 384 - const char *start, 385 - const char *end, 386 - const char **endPtr); 376 +typedef enum XML_Error PTRCALL Processor(XML_Parser parser, const char *start, 377 + const char *end, const char **endPtr); 387 378 388 379 static Processor prologProcessor; 389 380 static Processor prologInitProcessor; 390 381 static Processor contentProcessor; 391 382 static Processor cdataSectionProcessor; 392 383 #ifdef XML_DTD 393 384 static Processor ignoreSectionProcessor; ................................................................................ 400 391 static Processor errorProcessor; 401 392 static Processor externalEntityInitProcessor; 402 393 static Processor externalEntityInitProcessor2; 403 394 static Processor externalEntityInitProcessor3; 404 395 static Processor externalEntityContentProcessor; 405 396 static Processor internalEntityProcessor; 406 397 407 -static enum XML_Error 408 -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); 409 -static enum XML_Error 410 -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, 411 - const char *s, const char *next); 412 -static enum XML_Error 413 -initializeEncoding(XML_Parser parser); 414 -static enum XML_Error 415 -doProlog(XML_Parser parser, const ENCODING *enc, const char *s, 416 - const char *end, int tok, const char *next, const char **nextPtr, 417 - XML_Bool haveMore); 418 -static enum XML_Error 419 -processInternalEntity(XML_Parser parser, ENTITY *entity, 420 - XML_Bool betweenDecl); 421 -static enum XML_Error 422 -doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, 423 - const char *start, const char *end, const char **endPtr, 424 - XML_Bool haveMore); 425 -static enum XML_Error 426 -doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, 427 - const char *end, const char **nextPtr, XML_Bool haveMore); 428 -#ifdef XML_DTD 429 -static enum XML_Error 430 -doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, 431 - const char *end, const char **nextPtr, XML_Bool haveMore); 432 -#endif /* XML_DTD */ 433 - 434 -static void 435 -freeBindings(XML_Parser parser, BINDING *bindings); 436 -static enum XML_Error 437 -storeAtts(XML_Parser parser, const ENCODING *, const char *s, 438 - TAG_NAME *tagNamePtr, BINDING **bindingsPtr); 439 -static enum XML_Error 440 -addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, 441 - const XML_Char *uri, BINDING **bindingsPtr); 442 -static int 443 -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, 444 - XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); 445 -static enum XML_Error 446 -storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, 447 - const char *, const char *, STRING_POOL *); 448 -static enum XML_Error 449 -appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, 450 - const char *, const char *, STRING_POOL *); 451 -static ATTRIBUTE_ID * 452 -getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, 453 - const char *end); 454 -static int 455 -setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); 456 -static enum XML_Error 457 -storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, 458 - const char *end); 459 -static int 460 -reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, 461 - const char *start, const char *end); 462 -static int 463 -reportComment(XML_Parser parser, const ENCODING *enc, const char *start, 464 - const char *end); 465 -static void 466 -reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, 467 - const char *end); 468 - 469 -static const XML_Char * getContext(XML_Parser parser); 470 -static XML_Bool 471 -setContext(XML_Parser parser, const XML_Char *context); 398 +static enum XML_Error handleUnknownEncoding(XML_Parser parser, 399 + const XML_Char *encodingName); 400 +static enum XML_Error processXmlDecl(XML_Parser parser, int isGeneralTextEntity, 401 + const char *s, const char *next); 402 +static enum XML_Error initializeEncoding(XML_Parser parser); 403 +static enum XML_Error doProlog(XML_Parser parser, const ENCODING *enc, 404 + const char *s, const char *end, int tok, 405 + const char *next, const char **nextPtr, 406 + XML_Bool haveMore, XML_Bool allowClosingDoctype); 407 +static enum XML_Error processInternalEntity(XML_Parser parser, ENTITY *entity, 408 + XML_Bool betweenDecl); 409 +static enum XML_Error doContent(XML_Parser parser, int startTagLevel, 410 + const ENCODING *enc, const char *start, 411 + const char *end, const char **endPtr, 412 + XML_Bool haveMore); 413 +static enum XML_Error doCdataSection(XML_Parser parser, const ENCODING *, 414 + const char **startPtr, const char *end, 415 + const char **nextPtr, XML_Bool haveMore); 416 +#ifdef XML_DTD 417 +static enum XML_Error doIgnoreSection(XML_Parser parser, const ENCODING *, 418 + const char **startPtr, const char *end, 419 + const char **nextPtr, XML_Bool haveMore); 420 +#endif /* XML_DTD */ 421 + 422 +static void freeBindings(XML_Parser parser, BINDING *bindings); 423 +static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *, 424 + const char *s, TAG_NAME *tagNamePtr, 425 + BINDING **bindingsPtr); 426 +static enum XML_Error addBinding(XML_Parser parser, PREFIX *prefix, 427 + const ATTRIBUTE_ID *attId, const XML_Char *uri, 428 + BINDING **bindingsPtr); 429 +static int defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, 430 + XML_Bool isId, const XML_Char *dfltValue, 431 + XML_Parser parser); 432 +static enum XML_Error storeAttributeValue(XML_Parser parser, const ENCODING *, 433 + XML_Bool isCdata, const char *, 434 + const char *, STRING_POOL *); 435 +static enum XML_Error appendAttributeValue(XML_Parser parser, const ENCODING *, 436 + XML_Bool isCdata, const char *, 437 + const char *, STRING_POOL *); 438 +static ATTRIBUTE_ID *getAttributeId(XML_Parser parser, const ENCODING *enc, 439 + const char *start, const char *end); 440 +static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); 441 +static enum XML_Error storeEntityValue(XML_Parser parser, const ENCODING *enc, 442 + const char *start, const char *end); 443 +static int reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, 444 + const char *start, const char *end); 445 +static int reportComment(XML_Parser parser, const ENCODING *enc, 446 + const char *start, const char *end); 447 +static void reportDefault(XML_Parser parser, const ENCODING *enc, 448 + const char *start, const char *end); 449 + 450 +static const XML_Char *getContext(XML_Parser parser); 451 +static XML_Bool setContext(XML_Parser parser, const XML_Char *context); 472 452 473 453 static void FASTCALL normalizePublicId(XML_Char *s); 474 454 475 -static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); 455 +static DTD *dtdCreate(const XML_Memory_Handling_Suite *ms); 476 456 /* do not call if m_parentParser != NULL */ 477 457 static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); 478 -static void 479 -dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); 480 -static int 481 -dtdCopy(XML_Parser oldParser, 482 - DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); 483 -static int 484 -copyEntityTable(XML_Parser oldParser, 485 - HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); 486 -static NAMED * 487 -lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize); 488 -static void FASTCALL 489 -hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); 458 +static void dtdDestroy(DTD *p, XML_Bool isDocEntity, 459 + const XML_Memory_Handling_Suite *ms); 460 +static int dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, 461 + const XML_Memory_Handling_Suite *ms); 462 +static int copyEntityTable(XML_Parser oldParser, HASH_TABLE *, STRING_POOL *, 463 + const HASH_TABLE *); 464 +static NAMED *lookup(XML_Parser parser, HASH_TABLE *table, KEY name, 465 + size_t createSize); 466 +static void FASTCALL hashTableInit(HASH_TABLE *, 467 + const XML_Memory_Handling_Suite *ms); 490 468 static void FASTCALL hashTableClear(HASH_TABLE *); 491 469 static void FASTCALL hashTableDestroy(HASH_TABLE *); 492 -static void FASTCALL 493 -hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); 494 -static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *); 470 +static void FASTCALL hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); 471 +static NAMED *FASTCALL hashTableIterNext(HASH_TABLE_ITER *); 495 472 496 -static void FASTCALL 497 -poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms); 473 +static void FASTCALL poolInit(STRING_POOL *, 474 + const XML_Memory_Handling_Suite *ms); 498 475 static void FASTCALL poolClear(STRING_POOL *); 499 476 static void FASTCALL poolDestroy(STRING_POOL *); 500 -static XML_Char * 501 -poolAppend(STRING_POOL *pool, const ENCODING *enc, 502 - const char *ptr, const char *end); 503 -static XML_Char * 504 -poolStoreString(STRING_POOL *pool, const ENCODING *enc, 505 - const char *ptr, const char *end); 477 +static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc, 478 + const char *ptr, const char *end); 479 +static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc, 480 + const char *ptr, const char *end); 506 481 static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); 507 -static const XML_Char * FASTCALL 508 -poolCopyString(STRING_POOL *pool, const XML_Char *s); 509 -static const XML_Char * 510 -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); 511 -static const XML_Char * FASTCALL 512 -poolAppendString(STRING_POOL *pool, const XML_Char *s); 482 +static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool, 483 + const XML_Char *s); 484 +static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, 485 + int n); 486 +static const XML_Char *FASTCALL poolAppendString(STRING_POOL *pool, 487 + const XML_Char *s); 513 488 514 489 static int FASTCALL nextScaffoldPart(XML_Parser parser); 515 -static XML_Content * build_model(XML_Parser parser); 516 -static ELEMENT_TYPE * 517 -getElementType(XML_Parser parser, const ENCODING *enc, 518 - const char *ptr, const char *end); 490 +static XML_Content *build_model(XML_Parser parser); 491 +static ELEMENT_TYPE *getElementType(XML_Parser parser, const ENCODING *enc, 492 + const char *ptr, const char *end); 519 493 520 494 static XML_Char *copyString(const XML_Char *s, 521 495 const XML_Memory_Handling_Suite *memsuite); 522 496 523 497 static unsigned long generate_hash_secret_salt(XML_Parser parser); 524 498 static XML_Bool startParsing(XML_Parser parser); 525 499 526 -static XML_Parser 527 -parserCreate(const XML_Char *encodingName, 528 - const XML_Memory_Handling_Suite *memsuite, 529 - const XML_Char *nameSep, 530 - DTD *dtd); 500 +static XML_Parser parserCreate(const XML_Char *encodingName, 501 + const XML_Memory_Handling_Suite *memsuite, 502 + const XML_Char *nameSep, DTD *dtd); 531 503 532 -static void 533 -parserInit(XML_Parser parser, const XML_Char *encodingName); 504 +static void parserInit(XML_Parser parser, const XML_Char *encodingName); 534 505 535 506 #define poolStart(pool) ((pool)->start) 536 507 #define poolEnd(pool) ((pool)->ptr) 537 508 #define poolLength(pool) ((pool)->ptr - (pool)->start) 538 509 #define poolChop(pool) ((void)--(pool->ptr)) 539 510 #define poolLastChar(pool) (((pool)->ptr)[-1]) 540 511 #define poolDiscard(pool) ((pool)->ptr = (pool)->start) 541 512 #define poolFinish(pool) ((pool)->start = (pool)->ptr) 542 -#define poolAppendChar(pool, c) \ 543 - (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ 544 - ? 0 \ 545 - : ((*((pool)->ptr)++ = c), 1)) 513 +#define poolAppendChar(pool, c) \ 514 + (((pool)->ptr == (pool)->end && ! poolGrow(pool)) \ 515 + ? 0 \ 516 + : ((*((pool)->ptr)++ = c), 1)) 546 517 547 518 struct XML_ParserStruct { 548 519 /* The first member must be m_userData so that the XML_GetUserData 549 520 macro works. */ 550 521 void *m_userData; 551 522 void *m_handlerArg; 552 523 char *m_buffer; ................................................................................ 589 560 const ENCODING *m_internalEncoding; 590 561 const XML_Char *m_protocolEncodingName; 591 562 XML_Bool m_ns; 592 563 XML_Bool m_ns_triplets; 593 564 void *m_unknownEncodingMem; 594 565 void *m_unknownEncodingData; 595 566 void *m_unknownEncodingHandlerData; 596 - void (XMLCALL *m_unknownEncodingRelease)(void *); 567 + void(XMLCALL *m_unknownEncodingRelease)(void *); 597 568 PROLOG_STATE m_prologState; 598 569 Processor *m_processor; 599 570 enum XML_Error m_errorCode; 600 571 const char *m_eventPtr; 601 572 const char *m_eventEndPtr; 602 573 const char *m_positionPtr; 603 574 OPEN_INTERNAL_ENTITY *m_openInternalEntities; ................................................................................ 643 614 XML_Bool m_isParamEntity; 644 615 XML_Bool m_useForeignDTD; 645 616 enum XML_ParamEntityParsing m_paramEntityParsing; 646 617 #endif 647 618 unsigned long m_hash_secret_salt; 648 619 }; 649 620 650 -#define MALLOC(parser, s) (parser->m_mem.malloc_fcn((s))) 651 -#define REALLOC(parser, p, s) (parser->m_mem.realloc_fcn((p),(s))) 652 -#define FREE(parser, p) (parser->m_mem.free_fcn((p))) 653 - 621 +#define MALLOC(parser, s) (parser->m_mem.malloc_fcn((s))) 622 +#define REALLOC(parser, p, s) (parser->m_mem.realloc_fcn((p), (s))) 623 +#define FREE(parser, p) (parser->m_mem.free_fcn((p))) 654 624 655 625 XML_Parser XMLCALL 656 -XML_ParserCreate(const XML_Char *encodingName) 657 -{ 626 +XML_ParserCreate(const XML_Char *encodingName) { 658 627 return XML_ParserCreate_MM(encodingName, NULL, NULL); 659 628 } 660 629 661 630 XML_Parser XMLCALL 662 -XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) 663 -{ 631 +XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) { 664 632 XML_Char tmp[2]; 665 633 *tmp = nsSep; 666 634 return XML_ParserCreate_MM(encodingName, NULL, tmp); 667 635 } 668 636 669 -static const XML_Char implicitContext[] = { 670 - ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p, 671 - ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, 672 - ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, 673 - ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, 674 - ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, 675 - ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0' 676 -}; 677 - 637 +static const XML_Char implicitContext[] 638 + = {ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, 639 + ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, 640 + ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, 641 + ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, 642 + ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, 643 + ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, 644 + ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, 645 + ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, 646 + '\0'}; 678 647 679 648 /* To avoid warnings about unused functions: */ 680 649 #if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) 681 650 682 -#if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) 651 +# if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) 683 652 684 653 /* Obtain entropy on Linux 3.17+ */ 685 654 static int 686 -writeRandomBytes_getrandom_nonblock(void * target, size_t count) { 687 - int success = 0; /* full count bytes written? */ 655 +writeRandomBytes_getrandom_nonblock(void *target, size_t count) { 656 + int success = 0; /* full count bytes written? */ 688 657 size_t bytesWrittenTotal = 0; 689 658 const unsigned int getrandomFlags = GRND_NONBLOCK; 690 659 691 660 do { 692 - void * const currentTarget = (void*)((char*)target + bytesWrittenTotal); 661 + void *const currentTarget = (void *)((char *)target + bytesWrittenTotal); 693 662 const size_t bytesToWrite = count - bytesWrittenTotal; 694 663 695 664 const int bytesWrittenMore = 696 -#if defined(HAVE_GETRANDOM) 665 +# if defined(HAVE_GETRANDOM) 697 666 getrandom(currentTarget, bytesToWrite, getrandomFlags); 698 -#else 667 +# else 699 668 syscall(SYS_getrandom, currentTarget, bytesToWrite, getrandomFlags); 700 -#endif 669 +# endif 701 670 702 671 if (bytesWrittenMore > 0) { 703 672 bytesWrittenTotal += bytesWrittenMore; 704 673 if (bytesWrittenTotal >= count) 705 674 success = 1; 706 675 } 707 676 } while (! success && (errno == EINTR)); 708 677 709 678 return success; 710 679 } 711 680 712 -#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ 681 +# endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ 713 682 714 - 715 -#if ! defined(_WIN32) && defined(XML_DEV_URANDOM) 683 +# if ! defined(_WIN32) && defined(XML_DEV_URANDOM) 716 684 717 685 /* Extract entropy from /dev/urandom */ 718 686 static int 719 -writeRandomBytes_dev_urandom(void * target, size_t count) { 720 - int success = 0; /* full count bytes written? */ 687 +writeRandomBytes_dev_urandom(void *target, size_t count) { 688 + int success = 0; /* full count bytes written? */ 721 689 size_t bytesWrittenTotal = 0; 722 690 723 691 const int fd = open("/dev/urandom", O_RDONLY); 724 692 if (fd < 0) { 725 693 return 0; 726 694 } 727 695 728 696 do { 729 - void * const currentTarget = (void*)((char*)target + bytesWrittenTotal); 697 + void *const currentTarget = (void *)((char *)target + bytesWrittenTotal); 730 698 const size_t bytesToWrite = count - bytesWrittenTotal; 731 699 732 700 const ssize_t bytesWrittenMore = read(fd, currentTarget, bytesToWrite); 733 701 734 702 if (bytesWrittenMore > 0) { 735 703 bytesWrittenTotal += bytesWrittenMore; 736 704 if (bytesWrittenTotal >= count) ................................................................................ 738 706 } 739 707 } while (! success && (errno == EINTR)); 740 708 741 709 close(fd); 742 710 return success; 743 711 } 744 712 745 -#endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ 713 +# endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ 746 714 747 -#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */ 715 +#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */ 748 716 749 - 750 -#if defined(HAVE_ARC4RANDOM) 717 +#if defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF) 751 718 752 719 static void 753 -writeRandomBytes_arc4random(void * target, size_t count) { 720 +writeRandomBytes_arc4random(void *target, size_t count) { 754 721 size_t bytesWrittenTotal = 0; 755 722 756 723 while (bytesWrittenTotal < count) { 757 724 const uint32_t random32 = arc4random(); 758 725 size_t i = 0; 759 726 760 727 for (; (i < sizeof(random32)) && (bytesWrittenTotal < count); 761 - i++, bytesWrittenTotal++) { 728 + i++, bytesWrittenTotal++) { 729 + const uint8_t random8 = (uint8_t)(random32 >> (i * 8)); 730 + ((uint8_t *)target)[bytesWrittenTotal] = random8; 731 + } 732 + } 733 +} 734 + 735 +#endif /* defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF) */ 736 + 737 +#ifdef _WIN32 738 + 739 +/* Obtain entropy on Windows using the rand_s() function which 740 + * generates cryptographically secure random numbers. Internally it 741 + * uses RtlGenRandom API which is present in Windows XP and later. 742 + */ 743 +static int 744 +writeRandomBytes_rand_s(void *target, size_t count) { 745 + size_t bytesWrittenTotal = 0; 746 + 747 + while (bytesWrittenTotal < count) { 748 + unsigned int random32 = 0; 749 + size_t i = 0; 750 + 751 + if (rand_s(&random32)) 752 + return 0; /* failure */ 753 + 754 + for (; (i < sizeof(random32)) && (bytesWrittenTotal < count); 755 + i++, bytesWrittenTotal++) { 762 756 const uint8_t random8 = (uint8_t)(random32 >> (i * 8)); 763 757 ((uint8_t *)target)[bytesWrittenTotal] = random8; 764 758 } 765 759 } 766 -} 767 - 768 -#endif /* defined(HAVE_ARC4RANDOM) */ 769 - 770 - 771 -#ifdef _WIN32 772 - 773 -typedef BOOLEAN (APIENTRY *RTLGENRANDOM_FUNC)(PVOID, ULONG); 774 -HMODULE _Expat_LoadLibrary(LPCTSTR filename); /* see loadlibrary.c */ 775 - 776 -/* Obtain entropy on Windows XP / Windows Server 2003 and later. 777 - * Hint on RtlGenRandom and the following article from libsodium. 778 - * 779 - * Michael Howard: Cryptographically Secure Random number on Windows without using CryptoAPI 780 - * https://blogs.msdn.microsoft.com/michael_howard/2005/01/14/cryptographically-secure-random-number-on-windows-without-using-cryptoapi/ 781 - */ 782 -static int 783 -writeRandomBytes_RtlGenRandom(void * target, size_t count) { 784 - int success = 0; /* full count bytes written? */ 785 - const HMODULE advapi32 = _Expat_LoadLibrary(TEXT("ADVAPI32.DLL")); 786 - 787 - if (advapi32) { 788 - const RTLGENRANDOM_FUNC RtlGenRandom 789 - = (RTLGENRANDOM_FUNC)GetProcAddress(advapi32, "SystemFunction036"); 790 - if (RtlGenRandom) { 791 - if (RtlGenRandom((PVOID)target, (ULONG)count) == TRUE) { 792 - success = 1; 793 - } 794 - } 795 - FreeLibrary(advapi32); 796 - } 797 - 798 - return success; 760 + return 1; /* success */ 799 761 } 800 762 801 763 #endif /* _WIN32 */ 802 764 803 - 804 765 #if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) 805 766 806 767 static unsigned long 807 -gather_time_entropy(void) 808 -{ 809 -#ifdef _WIN32 768 +gather_time_entropy(void) { 769 +# ifdef _WIN32 810 770 FILETIME ft; 811 771 GetSystemTimeAsFileTime(&ft); /* never fails */ 812 772 return ft.dwHighDateTime ^ ft.dwLowDateTime; 813 -#else 773 +# else 814 774 struct timeval tv; 815 775 int gettimeofday_res; 816 776 817 777 gettimeofday_res = gettimeofday(&tv, NULL); 818 778 819 -#if defined(NDEBUG) 779 +# if defined(NDEBUG) 820 780 (void)gettimeofday_res; 821 -#else 822 - assert (gettimeofday_res == 0); 823 -#endif /* defined(NDEBUG) */ 781 +# else 782 + assert(gettimeofday_res == 0); 783 +# endif /* defined(NDEBUG) */ 824 784 825 785 /* Microseconds time is <20 bits entropy */ 826 786 return tv.tv_usec; 827 -#endif 787 +# endif 828 788 } 829 789 830 -#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */ 831 - 790 +#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */ 832 791 833 792 static unsigned long 834 -ENTROPY_DEBUG(const char * label, unsigned long entropy) { 835 - const char * const EXPAT_ENTROPY_DEBUG = getenv("EXPAT_ENTROPY_DEBUG"); 793 +ENTROPY_DEBUG(const char *label, unsigned long entropy) { 794 + const char *const EXPAT_ENTROPY_DEBUG = getenv("EXPAT_ENTROPY_DEBUG"); 836 795 if (EXPAT_ENTROPY_DEBUG && ! strcmp(EXPAT_ENTROPY_DEBUG, "1")) { 837 - fprintf(stderr, "Entropy: %s --> 0x%0*lx (%lu bytes)\n", 838 - label, 839 - (int)sizeof(entropy) * 2, entropy, 840 - (unsigned long)sizeof(entropy)); 796 + fprintf(stderr, "Entropy: %s --> 0x%0*lx (%lu bytes)\n", label, 797 + (int)sizeof(entropy) * 2, entropy, (unsigned long)sizeof(entropy)); 841 798 } 842 799 return entropy; 843 800 } 844 801 845 802 static unsigned long 846 -generate_hash_secret_salt(XML_Parser parser) 847 -{ 803 +generate_hash_secret_salt(XML_Parser parser) { 848 804 unsigned long entropy; 849 805 (void)parser; 850 806 851 807 /* "Failproof" high quality providers: */ 852 808 #if defined(HAVE_ARC4RANDOM_BUF) 853 809 arc4random_buf(&entropy, sizeof(entropy)); 854 810 return ENTROPY_DEBUG("arc4random_buf", entropy); 855 811 #elif defined(HAVE_ARC4RANDOM) 856 812 writeRandomBytes_arc4random((void *)&entropy, sizeof(entropy)); 857 813 return ENTROPY_DEBUG("arc4random", entropy); 858 814 #else 859 815 /* Try high quality providers first .. */ 860 -#ifdef _WIN32 861 - if (writeRandomBytes_RtlGenRandom((void *)&entropy, sizeof(entropy))) { 862 - return ENTROPY_DEBUG("RtlGenRandom", entropy); 816 +# ifdef _WIN32 817 + if (writeRandomBytes_rand_s((void *)&entropy, sizeof(entropy))) { 818 + return ENTROPY_DEBUG("rand_s", entropy); 863 819 } 864 -#elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) 820 +# elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) 865 821 if (writeRandomBytes_getrandom_nonblock((void *)&entropy, sizeof(entropy))) { 866 822 return ENTROPY_DEBUG("getrandom", entropy); 867 823 } 868 -#endif 869 -#if ! defined(_WIN32) && defined(XML_DEV_URANDOM) 824 +# endif 825 +# if ! defined(_WIN32) && defined(XML_DEV_URANDOM) 870 826 if (writeRandomBytes_dev_urandom((void *)&entropy, sizeof(entropy))) { 871 827 return ENTROPY_DEBUG("/dev/urandom", entropy); 872 828 } 873 -#endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ 829 +# endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ 874 830 /* .. and self-made low quality for backup: */ 875 831 876 832 /* Process ID is 0 bits entropy if attacker has local access */ 877 833 entropy = gather_time_entropy() ^ getpid(); 878 834 879 835 /* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */ 880 836 if (sizeof(unsigned long) == 4) { 881 837 return ENTROPY_DEBUG("fallback(4)", entropy * 2147483647); 882 838 } else { 883 839 return ENTROPY_DEBUG("fallback(8)", 884 - entropy * (unsigned long)2305843009213693951ULL); 840 + entropy * (unsigned long)2305843009213693951ULL); 885 841 } 886 842 #endif 887 843 } 888 844 889 845 static unsigned long 890 846 get_hash_secret_salt(XML_Parser parser) { 891 847 if (parser->m_parentParser != NULL) 892 848 return get_hash_secret_salt(parser->m_parentParser); 893 849 return parser->m_hash_secret_salt; 894 850 } 895 851 896 -static XML_Bool /* only valid for root parser */ 897 -startParsing(XML_Parser parser) 898 -{ 899 - /* hash functions must be initialized before setContext() is called */ 900 - if (parser->m_hash_secret_salt == 0) 901 - parser->m_hash_secret_salt = generate_hash_secret_salt(parser); 902 - if (parser->m_ns) { 903 - /* implicit context only set for root parser, since child 904 - parsers (i.e. external entity parsers) will inherit it 905 - */ 906 - return setContext(parser, implicitContext); 907 - } 908 - return XML_TRUE; 852 +static XML_Bool /* only valid for root parser */ 853 +startParsing(XML_Parser parser) { 854 + /* hash functions must be initialized before setContext() is called */ 855 + if (parser->m_hash_secret_salt == 0) 856 + parser->m_hash_secret_salt = generate_hash_secret_salt(parser); 857 + if (parser->m_ns) { 858 + /* implicit context only set for root parser, since child 859 + parsers (i.e. external entity parsers) will inherit it 860 + */ 861 + return setContext(parser, implicitContext); 862 + } 863 + return XML_TRUE; 909 864 } 910 865 911 866 XML_Parser XMLCALL 912 867 XML_ParserCreate_MM(const XML_Char *encodingName, 913 868 const XML_Memory_Handling_Suite *memsuite, 914 - const XML_Char *nameSep) 915 -{ 869 + const XML_Char *nameSep) { 916 870 return parserCreate(encodingName, memsuite, nameSep, NULL); 917 871 } 918 872 919 873 static XML_Parser 920 874 parserCreate(const XML_Char *encodingName, 921 - const XML_Memory_Handling_Suite *memsuite, 922 - const XML_Char *nameSep, 923 - DTD *dtd) 924 -{ 875 + const XML_Memory_Handling_Suite *memsuite, const XML_Char *nameSep, 876 + DTD *dtd) { 925 877 XML_Parser parser; 926 878 927 879 if (memsuite) { 928 880 XML_Memory_Handling_Suite *mtemp; 929 - parser = (XML_Parser) 930 - memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); 881 + parser = (XML_Parser)memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); 931 882 if (parser != NULL) { 932 883 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); 933 884 mtemp->malloc_fcn = memsuite->malloc_fcn; 934 885 mtemp->realloc_fcn = memsuite->realloc_fcn; 935 886 mtemp->free_fcn = memsuite->free_fcn; 936 887 } 937 - } 938 - else { 888 + } else { 939 889 XML_Memory_Handling_Suite *mtemp; 940 890 parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); 941 891 if (parser != NULL) { 942 892 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); 943 893 mtemp->malloc_fcn = malloc; 944 894 mtemp->realloc_fcn = realloc; 945 895 mtemp->free_fcn = free; 946 896 } 947 897 } 948 898 949 - if (!parser) 899 + if (! parser) 950 900 return parser; 951 901 952 902 parser->m_buffer = NULL; 953 903 parser->m_bufferLim = NULL; 954 904 955 905 parser->m_attsSize = INIT_ATTS_SIZE; 956 - parser->m_atts = (ATTRIBUTE *)MALLOC(parser, parser->m_attsSize * sizeof(ATTRIBUTE)); 906 + parser->m_atts 907 + = (ATTRIBUTE *)MALLOC(parser, parser->m_attsSize * sizeof(ATTRIBUTE)); 957 908 if (parser->m_atts == NULL) { 958 909 FREE(parser, parser); 959 910 return NULL; 960 911 } 961 912 #ifdef XML_ATTR_INFO 962 - parser->m_attInfo = (XML_AttrInfo*)MALLOC(parser, parser->m_attsSize * sizeof(XML_AttrInfo)); 913 + parser->m_attInfo = (XML_AttrInfo *)MALLOC( 914 + parser, parser->m_attsSize * sizeof(XML_AttrInfo)); 963 915 if (parser->m_attInfo == NULL) { 964 916 FREE(parser, parser->m_atts); 965 917 FREE(parser, parser); 966 918 return NULL; 967 919 } 968 920 #endif 969 - parser->m_dataBuf = (XML_Char *)MALLOC(parser, INIT_DATA_BUF_SIZE * sizeof(XML_Char)); 921 + parser->m_dataBuf 922 + = (XML_Char *)MALLOC(parser, INIT_DATA_BUF_SIZE * sizeof(XML_Char)); 970 923 if (parser->m_dataBuf == NULL) { 971 924 FREE(parser, parser->m_atts); 972 925 #ifdef XML_ATTR_INFO 973 926 FREE(parser, parser->m_attInfo); 974 927 #endif 975 928 FREE(parser, parser); 976 929 return NULL; ................................................................................ 1012 965 1013 966 parser->m_protocolEncodingName = NULL; 1014 967 1015 968 poolInit(&parser->m_tempPool, &(parser->m_mem)); 1016 969 poolInit(&parser->m_temp2Pool, &(parser->m_mem)); 1017 970 parserInit(parser, encodingName); 1018 971 1019 - if (encodingName && !parser->m_protocolEncodingName) { 972 + if (encodingName && ! parser->m_protocolEncodingName) { 1020 973 XML_ParserFree(parser); 1021 974 return NULL; 1022 975 } 1023 976 1024 977 if (nameSep) { 1025 978 parser->m_ns = XML_TRUE; 1026 979 parser->m_internalEncoding = XmlGetInternalEncodingNS(); 1027 980 parser->m_namespaceSeparator = *nameSep; 1028 - } 1029 - else { 981 + } else { 1030 982 parser->m_internalEncoding = XmlGetInternalEncoding(); 1031 983 } 1032 984 1033 985 return parser; 1034 986 } 1035 987 1036 988 static void 1037 -parserInit(XML_Parser parser, const XML_Char *encodingName) 1038 -{ 989 +parserInit(XML_Parser parser, const XML_Char *encodingName) { 1039 990 parser->m_processor = prologInitProcessor; 1040 991 XmlPrologStateInit(&parser->m_prologState); 1041 992 if (encodingName != NULL) { 1042 993 parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem)); 1043 994 } 1044 995 parser->m_curBase = NULL; 1045 996 XmlInitEncoding(&parser->m_initEncoding, &parser->m_encoding, 0); ................................................................................ 1104 1055 parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; 1105 1056 #endif 1106 1057 parser->m_hash_secret_salt = 0; 1107 1058 } 1108 1059 1109 1060 /* moves list of bindings to m_freeBindingList */ 1110 1061 static void FASTCALL 1111 -moveToFreeBindingList(XML_Parser parser, BINDING *bindings) 1112 -{ 1062 +moveToFreeBindingList(XML_Parser parser, BINDING *bindings) { 1113 1063 while (bindings) { 1114 1064 BINDING *b = bindings; 1115 1065 bindings = bindings->nextTagBinding; 1116 1066 b->nextTagBinding = parser->m_freeBindingList; 1117 1067 parser->m_freeBindingList = b; 1118 1068 } 1119 1069 } 1120 1070 1121 1071 XML_Bool XMLCALL 1122 -XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) 1123 -{ 1072 +XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) { 1124 1073 TAG *tStk; 1125 1074 OPEN_INTERNAL_ENTITY *openEntityList; 1126 1075 1127 1076 if (parser == NULL) 1128 - return XML_FALSE; 1077 + return XML_FALSE; 1129 1078 1130 1079 if (parser->m_parentParser) 1131 1080 return XML_FALSE; 1132 1081 /* move m_tagStack to m_freeTagList */ 1133 1082 tStk = parser->m_tagStack; 1134 1083 while (tStk) { 1135 1084 TAG *tag = tStk; ................................................................................ 1157 1106 parser->m_protocolEncodingName = NULL; 1158 1107 parserInit(parser, encodingName); 1159 1108 dtdReset(parser->m_dtd, &parser->m_mem); 1160 1109 return XML_TRUE; 1161 1110 } 1162 1111 1163 1112 enum XML_Status XMLCALL 1164 -XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) 1165 -{ 1113 +XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) { 1166 1114 if (parser == NULL) 1167 - return XML_STATUS_ERROR; 1115 + return XML_STATUS_ERROR; 1168 1116 /* Block after XML_Parse()/XML_ParseBuffer() has been called. 1169 1117 XXX There's no way for the caller to determine which of the 1170 1118 XXX possible error cases caused the XML_STATUS_ERROR return. 1171 1119 */ 1172 - if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1120 + if (parser->m_parsingStatus.parsing == XML_PARSING 1121 + || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1173 1122 return XML_STATUS_ERROR; 1174 1123 1175 1124 /* Get rid of any previous encoding name */ 1176 1125 FREE(parser, (void *)parser->m_protocolEncodingName); 1177 1126 1178 1127 if (encodingName == NULL) 1179 1128 /* No new encoding name */ 1180 1129 parser->m_protocolEncodingName = NULL; 1181 1130 else { 1182 1131 /* Copy the new encoding name into allocated memory */ 1183 1132 parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem)); 1184 - if (!parser->m_protocolEncodingName) 1133 + if (! parser->m_protocolEncodingName) 1185 1134 return XML_STATUS_ERROR; 1186 1135 } 1187 1136 return XML_STATUS_OK; 1188 1137 } 1189 1138 1190 1139 XML_Parser XMLCALL 1191 -XML_ExternalEntityParserCreate(XML_Parser oldParser, 1192 - const XML_Char *context, 1193 - const XML_Char *encodingName) 1194 -{ 1140 +XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context, 1141 + const XML_Char *encodingName) { 1195 1142 XML_Parser parser = oldParser; 1196 1143 DTD *newDtd = NULL; 1197 1144 DTD *oldDtd; 1198 1145 XML_StartElementHandler oldStartElementHandler; 1199 1146 XML_EndElementHandler oldEndElementHandler; 1200 1147 XML_CharacterDataHandler oldCharacterDataHandler; 1201 1148 XML_ProcessingInstructionHandler oldProcessingInstructionHandler; ................................................................................ 1211 1158 XML_ExternalEntityRefHandler oldExternalEntityRefHandler; 1212 1159 XML_SkippedEntityHandler oldSkippedEntityHandler; 1213 1160 XML_UnknownEncodingHandler oldUnknownEncodingHandler; 1214 1161 XML_ElementDeclHandler oldElementDeclHandler; 1215 1162 XML_AttlistDeclHandler oldAttlistDeclHandler; 1216 1163 XML_EntityDeclHandler oldEntityDeclHandler; 1217 1164 XML_XmlDeclHandler oldXmlDeclHandler; 1218 - ELEMENT_TYPE * oldDeclElementType; 1165 + ELEMENT_TYPE *oldDeclElementType; 1219 1166 1220 1167 void *oldUserData; 1221 1168 void *oldHandlerArg; 1222 1169 XML_Bool oldDefaultExpandInternalEntities; 1223 1170 XML_Parser oldExternalEntityRefHandlerArg; 1224 1171 #ifdef XML_DTD 1225 1172 enum XML_ParamEntityParsing oldParamEntityParsing; ................................................................................ 1274 1221 parser, so that dtdCopy and copyEntityTable can lookup values 1275 1222 from hash tables associated with either parser without us having 1276 1223 to worry which hash secrets each table has. 1277 1224 */ 1278 1225 oldhash_secret_salt = parser->m_hash_secret_salt; 1279 1226 1280 1227 #ifdef XML_DTD 1281 - if (!context) 1228 + if (! context) 1282 1229 newDtd = oldDtd; 1283 1230 #endif /* XML_DTD */ 1284 1231 1285 1232 /* Note that the magical uses of the pre-processor to make field 1286 1233 access look more like C++ require that `parser' be overwritten 1287 1234 here. This makes this function more painful to follow than it 1288 1235 would be otherwise. 1289 1236 */ 1290 1237 if (parser->m_ns) { 1291 1238 XML_Char tmp[2]; 1292 1239 *tmp = parser->m_namespaceSeparator; 1293 1240 parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); 1294 - } 1295 - else { 1241 + } else { 1296 1242 parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); 1297 1243 } 1298 1244 1299 - if (!parser) 1245 + if (! parser) 1300 1246 return NULL; 1301 1247 1302 1248 parser->m_startElementHandler = oldStartElementHandler; 1303 1249 parser->m_endElementHandler = oldEndElementHandler; 1304 1250 parser->m_characterDataHandler = oldCharacterDataHandler; 1305 1251 parser->m_processingInstructionHandler = oldProcessingInstructionHandler; 1306 1252 parser->m_commentHandler = oldCommentHandler; ................................................................................ 1332 1278 parser->m_hash_secret_salt = oldhash_secret_salt; 1333 1279 parser->m_parentParser = oldParser; 1334 1280 #ifdef XML_DTD 1335 1281 parser->m_paramEntityParsing = oldParamEntityParsing; 1336 1282 parser->m_prologState.inEntityValue = oldInEntityValue; 1337 1283 if (context) { 1338 1284 #endif /* XML_DTD */ 1339 - if (!dtdCopy(oldParser, parser->m_dtd, oldDtd, &parser->m_mem) 1340 - || !setContext(parser, context)) { 1285 + if (! dtdCopy(oldParser, parser->m_dtd, oldDtd, &parser->m_mem) 1286 + || ! setContext(parser, context)) { 1341 1287 XML_ParserFree(parser); 1342 1288 return NULL; 1343 1289 } 1344 1290 parser->m_processor = externalEntityInitProcessor; 1345 1291 #ifdef XML_DTD 1346 - } 1347 - else { 1348 - /* The DTD instance referenced by parser->m_dtd is shared between the document's 1349 - root parser and external PE parsers, therefore one does not need to 1350 - call setContext. In addition, one also *must* not call setContext, 1351 - because this would overwrite existing prefix->binding pointers in 1352 - parser->m_dtd with ones that get destroyed with the external PE parser. 1353 - This would leave those prefixes with dangling pointers. 1292 + } else { 1293 + /* The DTD instance referenced by parser->m_dtd is shared between the 1294 + document's root parser and external PE parsers, therefore one does not 1295 + need to call setContext. In addition, one also *must* not call 1296 + setContext, because this would overwrite existing prefix->binding 1297 + pointers in parser->m_dtd with ones that get destroyed with the external 1298 + PE parser. This would leave those prefixes with dangling pointers. 1354 1299 */ 1355 1300 parser->m_isParamEntity = XML_TRUE; 1356 1301 XmlPrologStateInitExternalEntity(&parser->m_prologState); 1357 1302 parser->m_processor = externalParEntInitProcessor; 1358 1303 } 1359 1304 #endif /* XML_DTD */ 1360 1305 return parser; 1361 1306 } 1362 1307 1363 1308 static void FASTCALL 1364 -destroyBindings(BINDING *bindings, XML_Parser parser) 1365 -{ 1309 +destroyBindings(BINDING *bindings, XML_Parser parser) { 1366 1310 for (;;) { 1367 1311 BINDING *b = bindings; 1368 - if (!b) 1312 + if (! b) 1369 1313 break; 1370 1314 bindings = b->nextTagBinding; 1371 1315 FREE(parser, b->uri); 1372 1316 FREE(parser, b); 1373 1317 } 1374 1318 } 1375 1319 1376 1320 void XMLCALL 1377 -XML_ParserFree(XML_Parser parser) 1378 -{ 1321 +XML_ParserFree(XML_Parser parser) { 1379 1322 TAG *tagList; 1380 1323 OPEN_INTERNAL_ENTITY *entityList; 1381 1324 if (parser == NULL) 1382 1325 return; 1383 1326 /* free m_tagStack and m_freeTagList */ 1384 1327 tagList = parser->m_tagStack; 1385 1328 for (;;) { ................................................................................ 1416 1359 poolDestroy(&parser->m_tempPool); 1417 1360 poolDestroy(&parser->m_temp2Pool); 1418 1361 FREE(parser, (void *)parser->m_protocolEncodingName); 1419 1362 #ifdef XML_DTD 1420 1363 /* external parameter entity parsers share the DTD structure 1421 1364 parser->m_dtd with the root parser, so we must not destroy it 1422 1365 */ 1423 - if (!parser->m_isParamEntity && parser->m_dtd) 1366 + if (! parser->m_isParamEntity && parser->m_dtd) 1424 1367 #else 1425 1368 if (parser->m_dtd) 1426 1369 #endif /* XML_DTD */ 1427 - dtdDestroy(parser->m_dtd, (XML_Bool)!parser->m_parentParser, &parser->m_mem); 1370 + dtdDestroy(parser->m_dtd, (XML_Bool)! parser->m_parentParser, 1371 + &parser->m_mem); 1428 1372 FREE(parser, (void *)parser->m_atts); 1429 1373 #ifdef XML_ATTR_INFO 1430 1374 FREE(parser, (void *)parser->m_attInfo); 1431 1375 #endif 1432 1376 FREE(parser, parser->m_groupConnector); 1433 1377 FREE(parser, parser->m_buffer); 1434 1378 FREE(parser, parser->m_dataBuf); ................................................................................ 1436 1380 FREE(parser, parser->m_unknownEncodingMem); 1437 1381 if (parser->m_unknownEncodingRelease) 1438 1382 parser->m_unknownEncodingRelease(parser->m_unknownEncodingData); 1439 1383 FREE(parser, parser); 1440 1384 } 1441 1385 1442 1386 void XMLCALL 1443 -XML_UseParserAsHandlerArg(XML_Parser parser) 1444 -{ 1387 +XML_UseParserAsHandlerArg(XML_Parser parser) { 1445 1388 if (parser != NULL) 1446 1389 parser->m_handlerArg = parser; 1447 1390 } 1448 1391 1449 1392 enum XML_Error XMLCALL 1450 -XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) 1451 -{ 1393 +XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) { 1452 1394 if (parser == NULL) 1453 1395 return XML_ERROR_INVALID_ARGUMENT; 1454 1396 #ifdef XML_DTD 1455 1397 /* block after XML_Parse()/XML_ParseBuffer() has been called */ 1456 - if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1398 + if (parser->m_parsingStatus.parsing == XML_PARSING 1399 + || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1457 1400 return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; 1458 1401 parser->m_useForeignDTD = useDTD; 1459 1402 return XML_ERROR_NONE; 1460 1403 #else 1461 1404 return XML_ERROR_FEATURE_REQUIRES_XML_DTD; 1462 1405 #endif 1463 1406 } 1464 1407 1465 1408 void XMLCALL 1466 -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) 1467 -{ 1409 +XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) { 1468 1410 if (parser == NULL) 1469 1411 return; 1470 1412 /* block after XML_Parse()/XML_ParseBuffer() has been called */ 1471 - if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1413 + if (parser->m_parsingStatus.parsing == XML_PARSING 1414 + || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1472 1415 return; 1473 1416 parser->m_ns_triplets = do_nst ? XML_TRUE : XML_FALSE; 1474 1417 } 1475 1418 1476 1419 void XMLCALL 1477 -XML_SetUserData(XML_Parser parser, void *p) 1478 -{ 1420 +XML_SetUserData(XML_Parser parser, void *p) { 1479 1421 if (parser == NULL) 1480 1422 return; 1481 1423 if (parser->m_handlerArg == parser->m_userData) 1482 1424 parser->m_handlerArg = parser->m_userData = p; 1483 1425 else 1484 1426 parser->m_userData = p; 1485 1427 } 1486 1428 1487 1429 enum XML_Status XMLCALL 1488 -XML_SetBase(XML_Parser parser, const XML_Char *p) 1489 -{ 1430 +XML_SetBase(XML_Parser parser, const XML_Char *p) { 1490 1431 if (parser == NULL) 1491 1432 return XML_STATUS_ERROR; 1492 1433 if (p) { 1493 1434 p = poolCopyString(&parser->m_dtd->pool, p); 1494 - if (!p) 1435 + if (! p) 1495 1436 return XML_STATUS_ERROR; 1496 1437 parser->m_curBase = p; 1497 - } 1498 - else 1438 + } else 1499 1439 parser->m_curBase = NULL; 1500 1440 return XML_STATUS_OK; 1501 1441 } 1502 1442 1503 -const XML_Char * XMLCALL 1504 -XML_GetBase(XML_Parser parser) 1505 -{ 1443 +const XML_Char *XMLCALL 1444 +XML_GetBase(XML_Parser parser) { 1506 1445 if (parser == NULL) 1507 1446 return NULL; 1508 1447 return parser->m_curBase; 1509 1448 } 1510 1449 1511 1450 int XMLCALL 1512 -XML_GetSpecifiedAttributeCount(XML_Parser parser) 1513 -{ 1451 +XML_GetSpecifiedAttributeCount(XML_Parser parser) { 1514 1452 if (parser == NULL) 1515 1453 return -1; 1516 1454 return parser->m_nSpecifiedAtts; 1517 1455 } 1518 1456 1519 1457 int XMLCALL 1520 -XML_GetIdAttributeIndex(XML_Parser parser) 1521 -{ 1458 +XML_GetIdAttributeIndex(XML_Parser parser) { 1522 1459 if (parser == NULL) 1523 1460 return -1; 1524 1461 return parser->m_idAttIndex; 1525 1462 } 1526 1463 1527 1464 #ifdef XML_ATTR_INFO 1528 -const XML_AttrInfo * XMLCALL 1529 -XML_GetAttributeInfo(XML_Parser parser) 1530 -{ 1465 +const XML_AttrInfo *XMLCALL 1466 +XML_GetAttributeInfo(XML_Parser parser) { 1531 1467 if (parser == NULL) 1532 1468 return NULL; 1533 1469 return parser->m_attInfo; 1534 1470 } 1535 1471 #endif 1536 1472 1537 1473 void XMLCALL 1538 -XML_SetElementHandler(XML_Parser parser, 1539 - XML_StartElementHandler start, 1540 - XML_EndElementHandler end) 1541 -{ 1474 +XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, 1475 + XML_EndElementHandler end) { 1542 1476 if (parser == NULL) 1543 1477 return; 1544 1478 parser->m_startElementHandler = start; 1545 1479 parser->m_endElementHandler = end; 1546 1480 } 1547 1481 1548 1482 void XMLCALL 1549 -XML_SetStartElementHandler(XML_Parser parser, 1550 - XML_StartElementHandler start) { 1483 +XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler start) { 1551 1484 if (parser != NULL) 1552 1485 parser->m_startElementHandler = start; 1553 1486 } 1554 1487 1555 1488 void XMLCALL 1556 -XML_SetEndElementHandler(XML_Parser parser, 1557 - XML_EndElementHandler end) { 1489 +XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler end) { 1558 1490 if (parser != NULL) 1559 1491 parser->m_endElementHandler = end; 1560 1492 } 1561 1493 1562 1494 void XMLCALL 1563 1495 XML_SetCharacterDataHandler(XML_Parser parser, 1564 - XML_CharacterDataHandler handler) 1565 -{ 1496 + XML_CharacterDataHandler handler) { 1566 1497 if (parser != NULL) 1567 1498 parser->m_characterDataHandler = handler; 1568 1499 } 1569 1500 1570 1501 void XMLCALL 1571 1502 XML_SetProcessingInstructionHandler(XML_Parser parser, 1572 - XML_ProcessingInstructionHandler handler) 1573 -{ 1503 + XML_ProcessingInstructionHandler handler) { 1574 1504 if (parser != NULL) 1575 1505 parser->m_processingInstructionHandler = handler; 1576 1506 } 1577 1507 1578 1508 void XMLCALL 1579 -XML_SetCommentHandler(XML_Parser parser, 1580 - XML_CommentHandler handler) 1581 -{ 1509 +XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler) { 1582 1510 if (parser != NULL) 1583 1511 parser->m_commentHandler = handler; 1584 1512 } 1585 1513 1586 1514 void XMLCALL 1587 1515 XML_SetCdataSectionHandler(XML_Parser parser, 1588 1516 XML_StartCdataSectionHandler start, 1589 - XML_EndCdataSectionHandler end) 1590 -{ 1517 + XML_EndCdataSectionHandler end) { 1591 1518 if (parser == NULL) 1592 1519 return; 1593 1520 parser->m_startCdataSectionHandler = start; 1594 1521 parser->m_endCdataSectionHandler = end; 1595 1522 } 1596 1523 1597 1524 void XMLCALL ................................................................................ 1605 1532 XML_SetEndCdataSectionHandler(XML_Parser parser, 1606 1533 XML_EndCdataSectionHandler end) { 1607 1534 if (parser != NULL) 1608 1535 parser->m_endCdataSectionHandler = end; 1609 1536 } 1610 1537 1611 1538 void XMLCALL 1612 -XML_SetDefaultHandler(XML_Parser parser, 1613 - XML_DefaultHandler handler) 1614 -{ 1539 +XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler) { 1615 1540 if (parser == NULL) 1616 1541 return; 1617 1542 parser->m_defaultHandler = handler; 1618 1543 parser->m_defaultExpandInternalEntities = XML_FALSE; 1619 1544 } 1620 1545 1621 1546 void XMLCALL 1622 -XML_SetDefaultHandlerExpand(XML_Parser parser, 1623 - XML_DefaultHandler handler) 1624 -{ 1547 +XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler) { 1625 1548 if (parser == NULL) 1626 1549 return; 1627 1550 parser->m_defaultHandler = handler; 1628 1551 parser->m_defaultExpandInternalEntities = XML_TRUE; 1629 1552 } 1630 1553 1631 1554 void XMLCALL 1632 -XML_SetDoctypeDeclHandler(XML_Parser parser, 1633 - XML_StartDoctypeDeclHandler start, 1634 - XML_EndDoctypeDeclHandler end) 1635 -{ 1555 +XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, 1556 + XML_EndDoctypeDeclHandler end) { 1636 1557 if (parser == NULL) 1637 1558 return; 1638 1559 parser->m_startDoctypeDeclHandler = start; 1639 1560 parser->m_endDoctypeDeclHandler = end; 1640 1561 } 1641 1562 1642 1563 void XMLCALL ................................................................................ 1643 1564 XML_SetStartDoctypeDeclHandler(XML_Parser parser, 1644 1565 XML_StartDoctypeDeclHandler start) { 1645 1566 if (parser != NULL) 1646 1567 parser->m_startDoctypeDeclHandler = start; 1647 1568 } 1648 1569 1649 1570 void XMLCALL 1650 -XML_SetEndDoctypeDeclHandler(XML_Parser parser, 1651 - XML_EndDoctypeDeclHandler end) { 1571 +XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end) { 1652 1572 if (parser != NULL) 1653 1573 parser->m_endDoctypeDeclHandler = end; 1654 1574 } 1655 1575 1656 1576 void XMLCALL 1657 1577 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, 1658 - XML_UnparsedEntityDeclHandler handler) 1659 -{ 1578 + XML_UnparsedEntityDeclHandler handler) { 1660 1579 if (parser != NULL) 1661 1580 parser->m_unparsedEntityDeclHandler = handler; 1662 1581 } 1663 1582 1664 1583 void XMLCALL 1665 -XML_SetNotationDeclHandler(XML_Parser parser, 1666 - XML_NotationDeclHandler handler) 1667 -{ 1584 +XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler) { 1668 1585 if (parser != NULL) 1669 1586 parser->m_notationDeclHandler = handler; 1670 1587 } 1671 1588 1672 1589 void XMLCALL 1673 1590 XML_SetNamespaceDeclHandler(XML_Parser parser, 1674 1591 XML_StartNamespaceDeclHandler start, 1675 - XML_EndNamespaceDeclHandler end) 1676 -{ 1592 + XML_EndNamespaceDeclHandler end) { 1677 1593 if (parser == NULL) 1678 1594 return; 1679 1595 parser->m_startNamespaceDeclHandler = start; 1680 1596 parser->m_endNamespaceDeclHandler = end; 1681 1597 } 1682 1598 1683 1599 void XMLCALL ................................................................................ 1692 1608 XML_EndNamespaceDeclHandler end) { 1693 1609 if (parser != NULL) 1694 1610 parser->m_endNamespaceDeclHandler = end; 1695 1611 } 1696 1612 1697 1613 void XMLCALL 1698 1614 XML_SetNotStandaloneHandler(XML_Parser parser, 1699 - XML_NotStandaloneHandler handler) 1700 -{ 1615 + XML_NotStandaloneHandler handler) { 1701 1616 if (parser != NULL) 1702 1617 parser->m_notStandaloneHandler = handler; 1703 1618 } 1704 1619 1705 1620 void XMLCALL 1706 1621 XML_SetExternalEntityRefHandler(XML_Parser parser, 1707 - XML_ExternalEntityRefHandler handler) 1708 -{ 1622 + XML_ExternalEntityRefHandler handler) { 1709 1623 if (parser != NULL) 1710 1624 parser->m_externalEntityRefHandler = handler; 1711 1625 } 1712 1626 1713 1627 void XMLCALL 1714 -XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) 1715 -{ 1628 +XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) { 1716 1629 if (parser == NULL) 1717 1630 return; 1718 1631 if (arg) 1719 1632 parser->m_externalEntityRefHandlerArg = (XML_Parser)arg; 1720 1633 else 1721 1634 parser->m_externalEntityRefHandlerArg = parser; 1722 1635 } 1723 1636 1724 1637 void XMLCALL 1725 1638 XML_SetSkippedEntityHandler(XML_Parser parser, 1726 - XML_SkippedEntityHandler handler) 1727 -{ 1639 + XML_SkippedEntityHandler handler) { 1728 1640 if (parser != NULL) 1729 1641 parser->m_skippedEntityHandler = handler; 1730 1642 } 1731 1643 1732 1644 void XMLCALL 1733 1645 XML_SetUnknownEncodingHandler(XML_Parser parser, 1734 - XML_UnknownEncodingHandler handler, 1735 - void *data) 1736 -{ 1646 + XML_UnknownEncodingHandler handler, void *data) { 1737 1647 if (parser == NULL) 1738 1648 return; 1739 1649 parser->m_unknownEncodingHandler = handler; 1740 1650 parser->m_unknownEncodingHandlerData = data; 1741 1651 } 1742 1652 1743 1653 void XMLCALL 1744 -XML_SetElementDeclHandler(XML_Parser parser, 1745 - XML_ElementDeclHandler eldecl) 1746 -{ 1654 +XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl) { 1747 1655 if (parser != NULL) 1748 1656 parser->m_elementDeclHandler = eldecl; 1749 1657 } 1750 1658 1751 1659 void XMLCALL 1752 -XML_SetAttlistDeclHandler(XML_Parser parser, 1753 - XML_AttlistDeclHandler attdecl) 1754 -{ 1660 +XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl) { 1755 1661 if (parser != NULL) 1756 1662 parser->m_attlistDeclHandler = attdecl; 1757 1663 } 1758 1664 1759 1665 void XMLCALL 1760 -XML_SetEntityDeclHandler(XML_Parser parser, 1761 - XML_EntityDeclHandler handler) 1762 -{ 1666 +XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler) { 1763 1667 if (parser != NULL) 1764 1668 parser->m_entityDeclHandler = handler; 1765 1669 } 1766 1670 1767 1671 void XMLCALL 1768 -XML_SetXmlDeclHandler(XML_Parser parser, 1769 - XML_XmlDeclHandler handler) { 1672 +XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler handler) { 1770 1673 if (parser != NULL) 1771 1674 parser->m_xmlDeclHandler = handler; 1772 1675 } 1773 1676 1774 1677 int XMLCALL 1775 1678 XML_SetParamEntityParsing(XML_Parser parser, 1776 - enum XML_ParamEntityParsing peParsing) 1777 -{ 1679 + enum XML_ParamEntityParsing peParsing) { 1778 1680 if (parser == NULL) 1779 1681 return 0; 1780 1682 /* block after XML_Parse()/XML_ParseBuffer() has been called */ 1781 - if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1683 + if (parser->m_parsingStatus.parsing == XML_PARSING 1684 + || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1782 1685 return 0; 1783 1686 #ifdef XML_DTD 1784 1687 parser->m_paramEntityParsing = peParsing; 1785 1688 return 1; 1786 1689 #else 1787 1690 return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; 1788 1691 #endif 1789 1692 } 1790 1693 1791 1694 int XMLCALL 1792 -XML_SetHashSalt(XML_Parser parser, 1793 - unsigned long hash_salt) 1794 -{ 1695 +XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) { 1795 1696 if (parser == NULL) 1796 1697 return 0; 1797 1698 if (parser->m_parentParser) 1798 1699 return XML_SetHashSalt(parser->m_parentParser, hash_salt); 1799 1700 /* block after XML_Parse()/XML_ParseBuffer() has been called */ 1800 - if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1701 + if (parser->m_parsingStatus.parsing == XML_PARSING 1702 + || parser->m_parsingStatus.parsing == XML_SUSPENDED) 1801 1703 return 0; 1802 1704 parser->m_hash_secret_salt = hash_salt; 1803 1705 return 1; 1804 1706 } 1805 1707 1806 1708 enum XML_Status XMLCALL 1807 -XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) 1808 -{ 1709 +XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) { 1809 1710 if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) { 1810 1711 if (parser != NULL) 1811 1712 parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT; 1812 1713 return XML_STATUS_ERROR; 1813 1714 } 1814 1715 switch (parser->m_parsingStatus.parsing) { 1815 1716 case XML_SUSPENDED: 1816 1717 parser->m_errorCode = XML_ERROR_SUSPENDED; 1817 1718 return XML_STATUS_ERROR; 1818 1719 case XML_FINISHED: 1819 1720 parser->m_errorCode = XML_ERROR_FINISHED; 1820 1721 return XML_STATUS_ERROR; 1821 1722 case XML_INITIALIZED: 1822 - if (parser->m_parentParser == NULL && !startParsing(parser)) { 1723 + if (parser->m_parentParser == NULL && ! startParsing(parser)) { 1823 1724 parser->m_errorCode = XML_ERROR_NO_MEMORY; 1824 1725 return XML_STATUS_ERROR; 1825 1726 } 1826 1727 /* fall through */ 1827 1728 default: 1828 1729 parser->m_parsingStatus.parsing = XML_PARSING; 1829 1730 } 1830 1731 1831 1732 if (len == 0) { 1832 1733 parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; 1833 - if (!isFinal) 1734 + if (! isFinal) 1834 1735 return XML_STATUS_OK; 1835 1736 parser->m_positionPtr = parser->m_bufferPtr; 1836 1737 parser->m_parseEndPtr = parser->m_bufferEnd; 1837 1738 1838 1739 /* If data are left over from last buffer, and we now know that these 1839 1740 data are the final chunk of input, then we have to check them again 1840 1741 to detect errors based on that fact. 1841 1742 */ 1842 - parser->m_errorCode = parser->m_processor(parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr); 1743 + parser->m_errorCode 1744 + = parser->m_processor(parser, parser->m_bufferPtr, 1745 + parser->m_parseEndPtr, &parser->m_bufferPtr); 1843 1746 1844 1747 if (parser->m_errorCode == XML_ERROR_NONE) { 1845 1748 switch (parser->m_parsingStatus.parsing) { 1846 1749 case XML_SUSPENDED: 1847 1750 /* It is hard to be certain, but it seems that this case 1848 1751 * cannot occur. This code is cleaning up a previous parse 1849 1752 * with no new data (since len == 0). Changing the parsing ................................................................................ 1852 1755 * this circumstance. 1853 1756 * 1854 1757 * Given the uncertainty, we retain the code but exclude it 1855 1758 * from coverage tests. 1856 1759 * 1857 1760 * LCOV_EXCL_START 1858 1761 */ 1859 - XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); 1762 + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, 1763 + parser->m_bufferPtr, &parser->m_position); 1860 1764 parser->m_positionPtr = parser->m_bufferPtr; 1861 1765 return XML_STATUS_SUSPENDED; 1862 1766 /* LCOV_EXCL_STOP */ 1863 1767 case XML_INITIALIZED: 1864 1768 case XML_PARSING: 1865 1769 parser->m_parsingStatus.parsing = XML_FINISHED; 1866 1770 /* fall through */ ................................................................................ 1875 1779 #ifndef XML_CONTEXT_BYTES 1876 1780 else if (parser->m_bufferPtr == parser->m_bufferEnd) { 1877 1781 const char *end; 1878 1782 int nLeftOver; 1879 1783 enum XML_Status result; 1880 1784 /* Detect overflow (a+b > MAX <==> b > MAX-a) */ 1881 1785 if (len > ((XML_Size)-1) / 2 - parser->m_parseEndByteIndex) { 1882 - parser->m_errorCode = XML_ERROR_NO_MEMORY; 1883 - parser->m_eventPtr = parser->m_eventEndPtr = NULL; 1884 - parser->m_processor = errorProcessor; 1885 - return XML_STATUS_ERROR; 1786 + parser->m_errorCode = XML_ERROR_NO_MEMORY; 1787 + parser->m_eventPtr = parser->m_eventEndPtr = NULL; 1788 + parser->m_processor = errorProcessor; 1789 + return XML_STATUS_ERROR; 1886 1790 } 1887 1791 parser->m_parseEndByteIndex += len; 1888 1792 parser->m_positionPtr = s; 1889 1793 parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; 1890 1794 1891 - parser->m_errorCode = parser->m_processor(parser, s, parser->m_parseEndPtr = s + len, &end); 1795 + parser->m_errorCode 1796 + = parser->m_processor(parser, s, parser->m_parseEndPtr = s + len, &end); 1892 1797 1893 1798 if (parser->m_errorCode != XML_ERROR_NONE) { 1894 1799 parser->m_eventEndPtr = parser->m_eventPtr; 1895 1800 parser->m_processor = errorProcessor; 1896 1801 return XML_STATUS_ERROR; 1897 - } 1898 - else { 1802 + } else { 1899 1803 switch (parser->m_parsingStatus.parsing) { 1900 1804 case XML_SUSPENDED: 1901 1805 result = XML_STATUS_SUSPENDED; 1902 1806 break; 1903 1807 case XML_INITIALIZED: 1904 1808 case XML_PARSING: 1905 1809 if (isFinal) { ................................................................................ 1908 1812 } 1909 1813 /* fall through */ 1910 1814 default: 1911 1815 result = XML_STATUS_OK; 1912 1816 } 1913 1817 } 1914 1818 1915 - XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, end, &parser->m_position); 1819 + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, end, 1820 + &parser->m_position); 1916 1821 nLeftOver = s + len - end; 1917 1822 if (nLeftOver) { 1918 - if (parser->m_buffer == NULL || nLeftOver > parser->m_bufferLim - parser->m_buffer) { 1823 + if (parser->m_buffer == NULL 1824 + || nLeftOver > parser->m_bufferLim - parser->m_buffer) { 1919 1825 /* avoid _signed_ integer overflow */ 1920 1826 char *temp = NULL; 1921 1827 const int bytesToAllocate = (int)((unsigned)len * 2U); 1922 1828 if (bytesToAllocate > 0) { 1923 1829 temp = (char *)REALLOC(parser, parser->m_buffer, bytesToAllocate); 1924 1830 } 1925 1831 if (temp == NULL) { ................................................................................ 1937 1843 parser->m_bufferEnd = parser->m_buffer + nLeftOver; 1938 1844 parser->m_positionPtr = parser->m_bufferPtr; 1939 1845 parser->m_parseEndPtr = parser->m_bufferEnd; 1940 1846 parser->m_eventPtr = parser->m_bufferPtr; 1941 1847 parser->m_eventEndPtr = parser->m_bufferPtr; 1942 1848 return result; 1943 1849 } 1944 -#endif /* not defined XML_CONTEXT_BYTES */ 1850 +#endif /* not defined XML_CONTEXT_BYTES */ 1945 1851 else { 1946 1852 void *buff = XML_GetBuffer(parser, len); 1947 1853 if (buff == NULL) 1948 1854 return XML_STATUS_ERROR; 1949 1855 else { 1950 1856 memcpy(buff, s, len); 1951 1857 return XML_ParseBuffer(parser, len, isFinal); 1952 1858 } 1953 1859 } 1954 1860 } 1955 1861 1956 1862 enum XML_Status XMLCALL 1957 -XML_ParseBuffer(XML_Parser parser, int len, int isFinal) 1958 -{ 1863 +XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { 1959 1864 const char *start; 1960 1865 enum XML_Status result = XML_STATUS_OK; 1961 1866 1962 1867 if (parser == NULL) 1963 1868 return XML_STATUS_ERROR; 1964 1869 switch (parser->m_parsingStatus.parsing) { 1965 1870 case XML_SUSPENDED: 1966 1871 parser->m_errorCode = XML_ERROR_SUSPENDED; 1967 1872 return XML_STATUS_ERROR; 1968 1873 case XML_FINISHED: 1969 1874 parser->m_errorCode = XML_ERROR_FINISHED; 1970 1875 return XML_STATUS_ERROR; 1971 1876 case XML_INITIALIZED: 1972 - if (parser->m_parentParser == NULL && !startParsing(parser)) { 1877 + if (parser->m_parentParser == NULL && ! startParsing(parser)) { 1973 1878 parser->m_errorCode = XML_ERROR_NO_MEMORY; 1974 1879 return XML_STATUS_ERROR; 1975 1880 } 1976 1881 /* fall through */ 1977 1882 default: 1978 1883 parser->m_parsingStatus.parsing = XML_PARSING; 1979 1884 } ................................................................................ 1981 1886 start = parser->m_bufferPtr; 1982 1887 parser->m_positionPtr = start; 1983 1888 parser->m_bufferEnd += len; 1984 1889 parser->m_parseEndPtr = parser->m_bufferEnd; 1985 1890 parser->m_parseEndByteIndex += len; 1986 1891 parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; 1987 1892 1988 - parser->m_errorCode = parser->m_processor(parser, start, parser->m_parseEndPtr, &parser->m_bufferPtr); 1893 + parser->m_errorCode = parser->m_processor( 1894 + parser, start, parser->m_parseEndPtr, &parser->m_bufferPtr); 1989 1895 1990 1896 if (parser->m_errorCode != XML_ERROR_NONE) { 1991 1897 parser->m_eventEndPtr = parser->m_eventPtr; 1992 1898 parser->m_processor = errorProcessor; 1993 1899 return XML_STATUS_ERROR; 1994 - } 1995 - else { 1900 + } else { 1996 1901 switch (parser->m_parsingStatus.parsing) { 1997 1902 case XML_SUSPENDED: 1998 1903 result = XML_STATUS_SUSPENDED; 1999 1904 break; 2000 1905 case XML_INITIALIZED: 2001 1906 case XML_PARSING: 2002 1907 if (isFinal) { 2003 1908 parser->m_parsingStatus.parsing = XML_FINISHED; 2004 1909 return result; 2005 1910 } 2006 - default: ; /* should not happen */ 1911 + default:; /* should not happen */ 2007 1912 } 2008 1913 } 2009 1914 2010 - XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); 1915 + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, 1916 + parser->m_bufferPtr, &parser->m_position); 2011 1917 parser->m_positionPtr = parser->m_bufferPtr; 2012 1918 return result; 2013 1919 } 2014 1920 2015 -void * XMLCALL 2016 -XML_GetBuffer(XML_Parser parser, int len) 2017 -{ 1921 +void *XMLCALL 1922 +XML_GetBuffer(XML_Parser parser, int len) { 2018 1923 if (parser == NULL) 2019 1924 return NULL; 2020 1925 if (len < 0) { 2021 1926 parser->m_errorCode = XML_ERROR_NO_MEMORY; 2022 1927 return NULL; 2023 1928 } 2024 1929 switch (parser->m_parsingStatus.parsing) { 2025 1930 case XML_SUSPENDED: 2026 1931 parser->m_errorCode = XML_ERROR_SUSPENDED; 2027 1932 return NULL; 2028 1933 case XML_FINISHED: 2029 1934 parser->m_errorCode = XML_ERROR_FINISHED; 2030 1935 return NULL; 2031 - default: ; 1936 + default:; 2032 1937 } 2033 1938 2034 1939 if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)) { 2035 1940 #ifdef XML_CONTEXT_BYTES 2036 1941 int keep; 2037 -#endif /* defined XML_CONTEXT_BYTES */ 1942 +#endif /* defined XML_CONTEXT_BYTES */ 2038 1943 /* Do not invoke signed arithmetic overflow: */ 2039 - int neededSize = (int) ((unsigned)len + 2040 - (unsigned)EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, 2041 - parser->m_bufferPtr)); 1944 + int neededSize = (int)((unsigned)len 1945 + + (unsigned)EXPAT_SAFE_PTR_DIFF( 1946 + parser->m_bufferEnd, parser->m_bufferPtr)); 2042 1947 if (neededSize < 0) { 2043 1948 parser->m_errorCode = XML_ERROR_NO_MEMORY; 2044 1949 return NULL; 2045 1950 } 2046 1951 #ifdef XML_CONTEXT_BYTES 2047 1952 keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer); 2048 1953 if (keep > XML_CONTEXT_BYTES) 2049 1954 keep = XML_CONTEXT_BYTES; 2050 1955 neededSize += keep; 2051 -#endif /* defined XML_CONTEXT_BYTES */ 2052 - if (neededSize <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) { 1956 +#endif /* defined XML_CONTEXT_BYTES */ 1957 + if (neededSize 1958 + <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) { 2053 1959 #ifdef XML_CONTEXT_BYTES 2054 1960 if (keep < EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)) { 2055 - int offset = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer) - keep; 2056 - /* The buffer pointers cannot be NULL here; we have at least some bytes in the buffer */ 2057 - memmove(parser->m_buffer, &parser->m_buffer[offset], parser->m_bufferEnd - parser->m_bufferPtr + keep); 1961 + int offset 1962 + = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer) 1963 + - keep; 1964 + /* The buffer pointers cannot be NULL here; we have at least some bytes 1965 + * in the buffer */ 1966 + memmove(parser->m_buffer, &parser->m_buffer[offset], 1967 + parser->m_bufferEnd - parser->m_bufferPtr + keep); 2058 1968 parser->m_bufferEnd -= offset; 2059 1969 parser->m_bufferPtr -= offset; 2060 1970 } 2061 1971 #else 2062 1972 if (parser->m_buffer && parser->m_bufferPtr) { 2063 1973 memmove(parser->m_buffer, parser->m_bufferPtr, 2064 1974 EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)); 2065 - parser->m_bufferEnd = parser->m_buffer + 2066 - EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); 1975 + parser->m_bufferEnd 1976 + = parser->m_buffer 1977 + + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); 2067 1978 parser->m_bufferPtr = parser->m_buffer; 2068 1979 } 2069 -#endif /* not defined XML_CONTEXT_BYTES */ 2070 - } 2071 - else { 1980 +#endif /* not defined XML_CONTEXT_BYTES */ 1981 + } else { 2072 1982 char *newBuf; 2073 - int bufferSize = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferPtr); 1983 + int bufferSize 1984 + = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferPtr); 2074 1985 if (bufferSize == 0) 2075 1986 bufferSize = INIT_BUFFER_SIZE; 2076 1987 do { 2077 1988 /* Do not invoke signed arithmetic overflow: */ 2078 - bufferSize = (int) (2U * (unsigned) bufferSize); 1989 + bufferSize = (int)(2U * (unsigned)bufferSize); 2079 1990 } while (bufferSize < neededSize && bufferSize > 0); 2080 1991 if (bufferSize <= 0) { 2081 1992 parser->m_errorCode = XML_ERROR_NO_MEMORY; 2082 1993 return NULL; 2083 1994 } 2084 1995 newBuf = (char *)MALLOC(parser, bufferSize); 2085 1996 if (newBuf == 0) { 2086 1997 parser->m_errorCode = XML_ERROR_NO_MEMORY; 2087 1998 return NULL; 2088 1999 } 2089 2000 parser->m_bufferLim = newBuf + bufferSize; 2090 2001 #ifdef XML_CONTEXT_BYTES 2091 2002 if (parser->m_bufferPtr) { 2092 - int keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer); 2093 - if (keep > XML_CONTEXT_BYTES) 2094 - keep = XML_CONTEXT_BYTES; 2095 2003 memcpy(newBuf, &parser->m_bufferPtr[-keep], 2096 - EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) + keep); 2004 + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) 2005 + + keep); 2097 2006 FREE(parser, parser->m_buffer); 2098 2007 parser->m_buffer = newBuf; 2099 - parser->m_bufferEnd = parser->m_buffer + 2100 - EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) + keep; 2008 + parser->m_bufferEnd 2009 + = parser->m_buffer 2010 + + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) 2011 + + keep; 2101 2012 parser->m_bufferPtr = parser->m_buffer + keep; 2102 - } 2103 - else { 2013 + } else { 2104 2014 /* This must be a brand new buffer with no data in it yet */ 2105 2015 parser->m_bufferEnd = newBuf; 2106 2016 parser->m_bufferPtr = parser->m_buffer = newBuf; 2107 2017 } 2108 2018 #else 2109 2019 if (parser->m_bufferPtr) { 2110 2020 memcpy(newBuf, parser->m_bufferPtr, 2111 2021 EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)); 2112 2022 FREE(parser, parser->m_buffer); 2113 - parser->m_bufferEnd = newBuf + 2114 - EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); 2115 - } 2116 - else { 2023 + parser->m_bufferEnd 2024 + = newBuf 2025 + + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); 2026 + } else { 2117 2027 /* This must be a brand new buffer with no data in it yet */ 2118 2028 parser->m_bufferEnd = newBuf; 2119 2029 } 2120 2030 parser->m_bufferPtr = parser->m_buffer = newBuf; 2121 -#endif /* not defined XML_CONTEXT_BYTES */ 2031 +#endif /* not defined XML_CONTEXT_BYTES */ 2122 2032 } 2123 2033 parser->m_eventPtr = parser->m_eventEndPtr = NULL; 2124 2034 parser->m_positionPtr = NULL; 2125 2035 } 2126 2036 return parser->m_bufferEnd; 2127 2037 } 2128 2038 2129 2039 enum XML_Status XMLCALL 2130 -XML_StopParser(XML_Parser parser, XML_Bool resumable) 2131 -{ 2040 +XML_StopParser(XML_Parser parser, XML_Bool resumable) { 2132 2041 if (parser == NULL) 2133 2042 return XML_STATUS_ERROR; 2134 2043 switch (parser->m_parsingStatus.parsing) { 2135 2044 case XML_SUSPENDED: 2136 2045 if (resumable) { 2137 2046 parser->m_errorCode = XML_ERROR_SUSPENDED; 2138 2047 return XML_STATUS_ERROR; ................................................................................ 2147 2056 #ifdef XML_DTD 2148 2057 if (parser->m_isParamEntity) { 2149 2058 parser->m_errorCode = XML_ERROR_SUSPEND_PE; 2150 2059 return XML_STATUS_ERROR; 2151 2060 } 2152 2061 #endif 2153 2062 parser->m_parsingStatus.parsing = XML_SUSPENDED; 2154 - } 2155 - else 2063 + } else 2156 2064 parser->m_parsingStatus.parsing = XML_FINISHED; 2157 2065 } 2158 2066 return XML_STATUS_OK; 2159 2067 } 2160 2068 2161 2069 enum XML_Status XMLCALL 2162 -XML_ResumeParser(XML_Parser parser) 2163 -{ 2070 +XML_ResumeParser(XML_Parser parser) { 2164 2071 enum XML_Status result = XML_STATUS_OK; 2165 2072 2166 2073 if (parser == NULL) 2167 2074 return XML_STATUS_ERROR; 2168 2075 if (parser->m_parsingStatus.parsing != XML_SUSPENDED) { 2169 2076 parser->m_errorCode = XML_ERROR_NOT_SUSPENDED; 2170 2077 return XML_STATUS_ERROR; 2171 2078 } 2172 2079 parser->m_parsingStatus.parsing = XML_PARSING; 2173 2080 2174 - parser->m_errorCode = parser->m_processor(parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr); 2081 + parser->m_errorCode = parser->m_processor( 2082 + parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr); 2175 2083 2176 2084 if (parser->m_errorCode != XML_ERROR_NONE) { 2177 2085 parser->m_eventEndPtr = parser->m_eventPtr; 2178 2086 parser->m_processor = errorProcessor; 2179 2087 return XML_STATUS_ERROR; 2180 - } 2181 - else { 2088 + } else { 2182 2089 switch (parser->m_parsingStatus.parsing) { 2183 2090 case XML_SUSPENDED: 2184 2091 result = XML_STATUS_SUSPENDED; 2185 2092 break; 2186 2093 case XML_INITIALIZED: 2187 2094 case XML_PARSING: 2188 2095 if (parser->m_parsingStatus.finalBuffer) { 2189 2096 parser->m_parsingStatus.parsing = XML_FINISHED; 2190 2097 return result; 2191 2098 } 2192 - default: ; 2099 + default:; 2193 2100 } 2194 2101 } 2195 2102 2196 - XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); 2103 + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, 2104 + parser->m_bufferPtr, &parser->m_position); 2197 2105 parser->m_positionPtr = parser->m_bufferPtr; 2198 2106 return result; 2199 2107 } 2200 2108 2201 2109 void XMLCALL 2202 -XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) 2203 -{ 2110 +XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) { 2204 2111 if (parser == NULL) 2205 2112 return; 2206 2113 assert(status != NULL); 2207 2114 *status = parser->m_parsingStatus; 2208 2115 } 2209 2116 2210 2117 enum XML_Error XMLCALL 2211 -XML_GetErrorCode(XML_Parser parser) 2212 -{ 2118 +XML_GetErrorCode(XML_Parser parser) { 2213 2119 if (parser == NULL) 2214 2120 return XML_ERROR_INVALID_ARGUMENT; 2215 2121 return parser->m_errorCode; 2216 2122 } 2217 2123 2218 2124 XML_Index XMLCALL 2219 -XML_GetCurrentByteIndex(XML_Parser parser) 2220 -{ 2125 +XML_GetCurrentByteIndex(XML_Parser parser) { 2221 2126 if (parser == NULL) 2222 2127 return -1; 2223 2128 if (parser->m_eventPtr) 2224 - return (XML_Index)(parser->m_parseEndByteIndex - (parser->m_parseEndPtr - parser->m_eventPtr)); 2129 + return (XML_Index)(parser->m_parseEndByteIndex 2130 + - (parser->m_parseEndPtr - parser->m_eventPtr)); 2225 2131 return -1; 2226 2132 } 2227 2133 2228 2134 int XMLCALL 2229 -XML_GetCurrentByteCount(XML_Parser parser) 2230 -{ 2135 +XML_GetCurrentByteCount(XML_Parser parser) { 2231 2136 if (parser == NULL) 2232 2137 return 0; 2233 2138 if (parser->m_eventEndPtr && parser->m_eventPtr) 2234 2139 return (int)(parser->m_eventEndPtr - parser->m_eventPtr); 2235 2140 return 0; 2236 2141 } 2237 2142 2238 -const char * XMLCALL 2239 -XML_GetInputContext(XML_Parser parser, int *offset, int *size) 2240 -{ 2143 +const char *XMLCALL 2144 +XML_GetInputContext(XML_Parser parser, int *offset, int *size) { 2241 2145 #ifdef XML_CONTEXT_BYTES 2242 2146 if (parser == NULL) 2243 2147 return NULL; 2244 2148 if (parser->m_eventPtr && parser->m_buffer) { 2245 2149 if (offset != NULL) 2246 2150 *offset = (int)(parser->m_eventPtr - parser->m_buffer); 2247 2151 if (size != NULL) 2248 - *size = (int)(parser->m_bufferEnd - parser->m_buffer); 2152 + *size = (int)(parser->m_bufferEnd - parser->m_buffer); 2249 2153 return parser->m_buffer; 2250 2154 } 2251 2155 #else 2252 2156 (void)parser; 2253 2157 (void)offset; 2254 2158 (void)size; 2255 2159 #endif /* defined XML_CONTEXT_BYTES */ 2256 - return (char *) 0; 2160 + return (char *)0; 2257 2161 } 2258 2162 2259 2163 XML_Size XMLCALL 2260 -XML_GetCurrentLineNumber(XML_Parser parser) 2261 -{ 2164 +XML_GetCurrentLineNumber(XML_Parser parser) { 2262 2165 if (parser == NULL) 2263 2166 return 0; 2264 2167 if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) { 2265 - XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_eventPtr, &parser->m_position); 2168 + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, 2169 + parser->m_eventPtr, &parser->m_position); 2266 2170 parser->m_positionPtr = parser->m_eventPtr; 2267 2171 } 2268 2172 return parser->m_position.lineNumber + 1; 2269 2173 } 2270 2174 2271 2175 XML_Size XMLCALL 2272 -XML_GetCurrentColumnNumber(XML_Parser parser) 2273 -{ 2176 +XML_GetCurrentColumnNumber(XML_Parser parser) { 2274 2177 if (parser == NULL) 2275 2178 return 0; 2276 2179 if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) { 2277 - XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_eventPtr, &parser->m_position); 2180 + XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, 2181 + parser->m_eventPtr, &parser->m_position); 2278 2182 parser->m_positionPtr = parser->m_eventPtr; 2279 2183 } 2280 2184 return parser->m_position.columnNumber; 2281 2185 } 2282 2186 2283 2187 void XMLCALL 2284 -XML_FreeContentModel(XML_Parser parser, XML_Content *model) 2285 -{ 2188 +XML_FreeContentModel(XML_Parser parser, XML_Content *model) { 2286 2189 if (parser != NULL) 2287 2190 FREE(parser, model); 2288 2191 } 2289 2192 2290 -void * XMLCALL 2291 -XML_MemMalloc(XML_Parser parser, size_t size) 2292 -{ 2193 +void *XMLCALL 2194 +XML_MemMalloc(XML_Parser parser, size_t size) { 2293 2195 if (parser == NULL) 2294 2196 return NULL; 2295 2197 return MALLOC(parser, size); 2296 2198 } 2297 2199 2298 -void * XMLCALL 2299 -XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) 2300 -{ 2200 +void *XMLCALL 2201 +XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) { 2301 2202 if (parser == NULL) 2302 2203 return NULL; 2303 2204 return REALLOC(parser, ptr, size); 2304 2205 } 2305 2206 2306 2207 void XMLCALL 2307 -XML_MemFree(XML_Parser parser, void *ptr) 2308 -{ 2208 +XML_MemFree(XML_Parser parser, void *ptr) { 2309 2209 if (parser != NULL) 2310 2210 FREE(parser, ptr); 2311 2211 } 2312 2212 2313 2213 void XMLCALL 2314 -XML_DefaultCurrent(XML_Parser parser) 2315 -{ 2214 +XML_DefaultCurrent(XML_Parser parser) { 2316 2215 if (parser == NULL) 2317 2216 return; 2318 2217 if (parser->m_defaultHandler) { 2319 2218 if (parser->m_openInternalEntities) 2320 - reportDefault(parser, 2321 - parser->m_internalEncoding, 2219 + reportDefault(parser, parser->m_internalEncoding, 2322 2220 parser->m_openInternalEntities->internalEventPtr, 2323 2221 parser->m_openInternalEntities->internalEventEndPtr); 2324 2222 else 2325 - reportDefault(parser, parser->m_encoding, parser->m_eventPtr, parser->m_eventEndPtr); 2223 + reportDefault(parser, parser->m_encoding, parser->m_eventPtr, 2224 + parser->m_eventEndPtr); 2326 2225 } 2327 2226 } 2328 2227 2329 -const XML_LChar * XMLCALL 2330 -XML_ErrorString(enum XML_Error code) 2331 -{ 2228 +const XML_LChar *XMLCALL 2229 +XML_ErrorString(enum XML_Error code) { 2332 2230 switch (code) { 2333 2231 case XML_ERROR_NONE: 2334 2232 return NULL; 2335 2233 case XML_ERROR_NO_MEMORY: 2336 2234 return XML_L("out of memory"); 2337 2235 case XML_ERROR_SYNTAX: 2338 2236 return XML_L("syntax error"); ................................................................................ 2406 2304 return XML_L("parsing aborted"); 2407 2305 case XML_ERROR_FINISHED: 2408 2306 return XML_L("parsing finished"); 2409 2307 case XML_ERROR_SUSPEND_PE: 2410 2308 return XML_L("cannot suspend in external parameter entity"); 2411 2309 /* Added in 2.0.0. */ 2412 2310 case XML_ERROR_RESERVED_PREFIX_XML: 2413 - return XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"); 2311 + return XML_L( 2312 + "reserved prefix (xml) must not be undeclared or bound to another namespace name"); 2414 2313 case XML_ERROR_RESERVED_PREFIX_XMLNS: 2415 2314 return XML_L("reserved prefix (xmlns) must not be declared or undeclared"); 2416 2315 case XML_ERROR_RESERVED_NAMESPACE_URI: 2417 - return XML_L("prefix must not be bound to one of the reserved namespace names"); 2316 + return XML_L( 2317 + "prefix must not be bound to one of the reserved namespace names"); 2418 2318 /* Added in 2.2.5. */ 2419 - case XML_ERROR_INVALID_ARGUMENT: /* Constant added in 2.2.1, already */ 2319 + case XML_ERROR_INVALID_ARGUMENT: /* Constant added in 2.2.1, already */ 2420 2320 return XML_L("invalid argument"); 2421 2321 } 2422 2322 return NULL; 2423 2323 } 2424 2324 2425 -const XML_LChar * XMLCALL 2325 +const XML_LChar *XMLCALL 2426 2326 XML_ExpatVersion(void) { 2427 - 2428 2327 /* V1 is used to string-ize the version number. However, it would 2429 2328 string-ize the actual version macro *names* unless we get them 2430 2329 substituted before being passed to V1. CPP is defined to expand 2431 2330 a macro, then rescan for more expansions. Thus, we use V2 to expand 2432 2331 the version macros, then CPP will expand the resulting V1() macro 2433 2332 with the correct numerals. */ 2434 2333 /* ### I'm assuming cpp is portable in this respect... */ 2435 2334 2436 -#define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) 2437 -#define V2(a,b,c) XML_L("expat_")V1(a,b,c) 2335 +#define V1(a, b, c) XML_L(#a) XML_L(".") XML_L(#b) XML_L(".") XML_L(#c) 2336 +#define V2(a, b, c) XML_L("expat_") V1(a, b, c) 2438 2337 2439 2338 return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); 2440 2339 2441 2340 #undef V1 2442 2341 #undef V2 2443 2342 } 2444 2343 2445 2344 XML_Expat_Version XMLCALL 2446 -XML_ExpatVersionInfo(void) 2447 -{ 2345 +XML_ExpatVersionInfo(void) { 2448 2346 XML_Expat_Version version; 2449 2347 2450 2348 version.major = XML_MAJOR_VERSION; 2451 2349 version.minor = XML_MINOR_VERSION; 2452 2350 version.micro = XML_MICRO_VERSION; 2453 2351 2454 2352 return version; 2455 2353 } 2456 2354 2457 -const XML_Feature * XMLCALL 2458 -XML_GetFeatureList(void) 2459 -{ 2460 - static const XML_Feature features[] = { 2461 - {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), 2462 - sizeof(XML_Char)}, 2463 - {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), 2464 - sizeof(XML_LChar)}, 2355 +const XML_Feature *XMLCALL 2356 +XML_GetFeatureList(void) { 2357 + static const XML_Feature features[] 2358 + = {{XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), 2359 + sizeof(XML_Char)}, 2360 + {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), 2361 + sizeof(XML_LChar)}, 2465 2362 #ifdef XML_UNICODE 2466 - {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0}, 2363 + {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0}, 2467 2364 #endif 2468 2365 #ifdef XML_UNICODE_WCHAR_T 2469 - {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0}, 2366 + {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0}, 2470 2367 #endif 2471 2368 #ifdef XML_DTD 2472 - {XML_FEATURE_DTD, XML_L("XML_DTD"), 0}, 2369 + {XML_FEATURE_DTD, XML_L("XML_DTD"), 0}, 2473 2370 #endif 2474 2371 #ifdef XML_CONTEXT_BYTES 2475 - {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), 2476 - XML_CONTEXT_BYTES}, 2372 + {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), 2373 + XML_CONTEXT_BYTES}, 2477 2374 #endif 2478 2375 #ifdef XML_MIN_SIZE 2479 - {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, 2376 + {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, 2480 2377 #endif 2481 2378 #ifdef XML_NS 2482 - {XML_FEATURE_NS, XML_L("XML_NS"), 0}, 2379 + {XML_FEATURE_NS, XML_L("XML_NS"), 0}, 2483 2380 #endif 2484 2381 #ifdef XML_LARGE_SIZE 2485 - {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, 2382 + {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, 2486 2383 #endif 2487 2384 #ifdef XML_ATTR_INFO 2488 - {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0}, 2385 + {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0}, 2489 2386 #endif 2490 - {XML_FEATURE_END, NULL, 0} 2491 - }; 2387 + {XML_FEATURE_END, NULL, 0}}; 2492 2388 2493 2389 return features; 2494 2390 } 2495 2391 2496 2392 /* Initially tag->rawName always points into the parse buffer; 2497 2393 for those TAG instances opened while the current parse buffer was 2498 2394 processed, and not yet closed, we need to store tag->rawName in a more 2499 2395 permanent location, since the parse buffer is about to be discarded. 2500 2396 */ 2501 2397 static XML_Bool 2502 -storeRawNames(XML_Parser parser) 2503 -{ 2398 +storeRawNames(XML_Parser parser) { 2504 2399 TAG *tag = parser->m_tagStack; 2505 2400 while (tag) { 2506 2401 int bufSize; 2507 2402 int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); 2508 2403 char *rawNameBuf = tag->buf + nameLen; 2509 2404 /* Stop if already stored. Since m_tagStack is a stack, we can stop 2510 2405 at the first entry that has already been copied; everything ................................................................................ 2526 2421 */ 2527 2422 if (tag->name.str == (XML_Char *)tag->buf) 2528 2423 tag->name.str = (XML_Char *)temp; 2529 2424 /* if tag->name.localPart is set (when namespace processing is on) 2530 2425 then update it as well, since it will always point into tag->buf 2531 2426 */ 2532 2427 if (tag->name.localPart) 2533 - tag->name.localPart = (XML_Char *)temp + (tag->name.localPart - 2534 - (XML_Char *)tag->buf); 2428 + tag->name.localPart 2429 + = (XML_Char *)temp + (tag->name.localPart - (XML_Char *)tag->buf); 2535 2430 tag->buf = temp; 2536 2431 tag->bufEnd = temp + bufSize; 2537 2432 rawNameBuf = temp + nameLen; 2538 2433 } 2539 2434 memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); 2540 2435 tag->rawName = rawNameBuf; 2541 2436 tag = tag->parent; 2542 2437 } 2543 2438 return XML_TRUE; 2544 2439 } 2545 2440 2546 2441 static enum XML_Error PTRCALL 2547 -contentProcessor(XML_Parser parser, 2548 - const char *start, 2549 - const char *end, 2550 - const char **endPtr) 2551 -{ 2552 - enum XML_Error result = doContent(parser, 0, parser->m_encoding, start, end, 2553 - endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 2442 +contentProcessor(XML_Parser parser, const char *start, const char *end, 2443 + const char **endPtr) { 2444 + enum XML_Error result 2445 + = doContent(parser, 0, parser->m_encoding, start, end, endPtr, 2446 + (XML_Bool)! parser->m_parsingStatus.finalBuffer); 2554 2447 if (result == XML_ERROR_NONE) { 2555 - if (!storeRawNames(parser)) 2448 + if (! storeRawNames(parser)) 2556 2449 return XML_ERROR_NO_MEMORY; 2557 2450 } 2558 2451 return result; 2559 2452 } 2560 2453 2561 2454 static enum XML_Error PTRCALL 2562 -externalEntityInitProcessor(XML_Parser parser, 2563 - const char *start, 2564 - const char *end, 2565 - const char **endPtr) 2566 -{ 2455 +externalEntityInitProcessor(XML_Parser parser, const char *start, 2456 + const char *end, const char **endPtr) { 2567 2457 enum XML_Error result = initializeEncoding(parser); 2568 2458 if (result != XML_ERROR_NONE) 2569 2459 return result; 2570 2460 parser->m_processor = externalEntityInitProcessor2; 2571 2461 return externalEntityInitProcessor2(parser, start, end, endPtr); 2572 2462 } 2573 2463 2574 2464 static enum XML_Error PTRCALL 2575 -externalEntityInitProcessor2(XML_Parser parser, 2576 - const char *start, 2577 - const char *end, 2578 - const char **endPtr) 2579 -{ 2465 +externalEntityInitProcessor2(XML_Parser parser, const char *start, 2466 + const char *end, const char **endPtr) { 2580 2467 const char *next = start; /* XmlContentTok doesn't always set the last arg */ 2581 2468 int tok = XmlContentTok(parser->m_encoding, start, end, &next); 2582 2469 switch (tok) { 2583 2470 case XML_TOK_BOM: 2584 2471 /* If we are at the end of the buffer, this would cause the next stage, 2585 2472 i.e. externalEntityInitProcessor3, to pass control directly to 2586 2473 doContent (by detecting XML_TOK_NONE) without processing any xml text 2587 2474 declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. 2588 2475 */ 2589 - if (next == end && !parser->m_parsingStatus.finalBuffer) { 2476 + if (next == end && ! parser->m_parsingStatus.finalBuffer) { 2590 2477 *endPtr = next; 2591 2478 return XML_ERROR_NONE; 2592 2479 } 2593 2480 start = next; 2594 2481 break; 2595 2482 case XML_TOK_PARTIAL: 2596 - if (!parser->m_parsingStatus.finalBuffer) { 2483 + if (! parser->m_parsingStatus.finalBuffer) { 2597 2484 *endPtr = start; 2598 2485 return XML_ERROR_NONE; 2599 2486 } 2600 2487 parser->m_eventPtr = start; 2601 2488 return XML_ERROR_UNCLOSED_TOKEN; 2602 2489 case XML_TOK_PARTIAL_CHAR: 2603 - if (!parser->m_parsingStatus.finalBuffer) { 2490 + if (! parser->m_parsingStatus.finalBuffer) { 2604 2491 *endPtr = start; 2605 2492 return XML_ERROR_NONE; 2606 2493 } 2607 2494 parser->m_eventPtr = start; 2608 2495 return XML_ERROR_PARTIAL_CHAR; 2609 2496 } 2610 2497 parser->m_processor = externalEntityInitProcessor3; 2611 2498 return externalEntityInitProcessor3(parser, start, end, endPtr); 2612 2499 } 2613 2500 2614 2501 static enum XML_Error PTRCALL 2615 -externalEntityInitProcessor3(XML_Parser parser, 2616 - const char *start, 2617 - const char *end, 2618 - const char **endPtr) 2619 -{ 2502 +externalEntityInitProcessor3(XML_Parser parser, const char *start, 2503 + const char *end, const char **endPtr) { 2620 2504 int tok; 2621 2505 const char *next = start; /* XmlContentTok doesn't always set the last arg */ 2622 2506 parser->m_eventPtr = start; 2623 2507 tok = XmlContentTok(parser->m_encoding, start, end, &next); 2624 2508 parser->m_eventEndPtr = next; 2625 2509 2626 2510 switch (tok) { 2627 - case XML_TOK_XML_DECL: 2628 - { 2629 - enum XML_Error result; 2630 - result = processXmlDecl(parser, 1, start, next); 2631 - if (result != XML_ERROR_NONE) 2632 - return result; 2633 - switch (parser->m_parsingStatus.parsing) { 2634 - case XML_SUSPENDED: 2635 - *endPtr = next; 2636 - return XML_ERROR_NONE; 2637 - case XML_FINISHED: 2638 - return XML_ERROR_ABORTED; 2639 - default: 2640 - start = next; 2641 - } 2511 + case XML_TOK_XML_DECL: { 2512 + enum XML_Error result; 2513 + result = processXmlDecl(parser, 1, start, next); 2514 + if (result != XML_ERROR_NONE) 2515 + return result; 2516 + switch (parser->m_parsingStatus.parsing) { 2517 + case XML_SUSPENDED: 2518 + *endPtr = next; 2519 + return XML_ERROR_NONE; 2520 + case XML_FINISHED: 2521 + return XML_ERROR_ABORTED; 2522 + default: 2523 + start = next; 2642 2524 } 2643 - break; 2525 + } break; 2644 2526 case XML_TOK_PARTIAL: 2645 - if (!parser->m_parsingStatus.finalBuffer) { 2527 + if (! parser->m_parsingStatus.finalBuffer) { 2646 2528 *endPtr = start; 2647 2529 return XML_ERROR_NONE; 2648 2530 } 2649 2531 return XML_ERROR_UNCLOSED_TOKEN; 2650 2532 case XML_TOK_PARTIAL_CHAR: 2651 - if (!parser->m_parsingStatus.finalBuffer) { 2533 + if (! parser->m_parsingStatus.finalBuffer) { 2652 2534 *endPtr = start; 2653 2535 return XML_ERROR_NONE; 2654 2536 } 2655 2537 return XML_ERROR_PARTIAL_CHAR; 2656 2538 } 2657 2539 parser->m_processor = externalEntityContentProcessor; 2658 2540 parser->m_tagLevel = 1; 2659 2541 return externalEntityContentProcessor(parser, start, end, endPtr); 2660 2542 } 2661 2543 2662 2544 static enum XML_Error PTRCALL 2663 -externalEntityContentProcessor(XML_Parser parser, 2664 - const char *start, 2665 - const char *end, 2666 - const char **endPtr) 2667 -{ 2668 - enum XML_Error result = doContent(parser, 1, parser->m_encoding, start, end, 2669 - endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 2545 +externalEntityContentProcessor(XML_Parser parser, const char *start, 2546 + const char *end, const char **endPtr) { 2547 + enum XML_Error result 2548 + = doContent(parser, 1, parser->m_encoding, start, end, endPtr, 2549 + (XML_Bool)! parser->m_parsingStatus.finalBuffer); 2670 2550 if (result == XML_ERROR_NONE) { 2671 - if (!storeRawNames(parser)) 2551 + if (! storeRawNames(parser)) 2672 2552 return XML_ERROR_NO_MEMORY; 2673 2553 } 2674 2554 return result; 2675 2555 } 2676 2556 2677 2557 static enum XML_Error 2678 -doContent(XML_Parser parser, 2679 - int startTagLevel, 2680 - const ENCODING *enc, 2681 - const char *s, 2682 - const char *end, 2683 - const char **nextPtr, 2684 - XML_Bool haveMore) 2685 -{ 2558 +doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, 2559 + const char *s, const char *end, const char **nextPtr, 2560 + XML_Bool haveMore) { 2686 2561 /* save one level of indirection */ 2687 - DTD * const dtd = parser->m_dtd; 2562 + DTD *const dtd = parser->m_dtd; 2688 2563 2689 2564 const char **eventPP; 2690 2565 const char **eventEndPP; 2691 2566 if (enc == parser->m_encoding) { 2692 2567 eventPP = &parser->m_eventPtr; 2693 2568 eventEndPP = &parser->m_eventEndPtr; 2694 - } 2695 - else { 2569 + } else { 2696 2570 eventPP = &(parser->m_openInternalEntities->internalEventPtr); 2697 2571 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); 2698 2572 } 2699 2573 *eventPP = s; 2700 2574 2701 2575 for (;;) { 2702 2576 const char *next = s; /* XmlContentTok doesn't always set the last arg */ ................................................................................ 2708 2582 *nextPtr = s; 2709 2583 return XML_ERROR_NONE; 2710 2584 } 2711 2585 *eventEndPP = end; 2712 2586 if (parser->m_characterDataHandler) { 2713 2587 XML_Char c = 0xA; 2714 2588 parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); 2715 - } 2716 - else if (parser->m_defaultHandler) 2589 + } else if (parser->m_defaultHandler) 2717 2590 reportDefault(parser, enc, s, end); 2718 2591 /* We are at the end of the final buffer, should we check for 2719 2592 XML_SUSPENDED, XML_FINISHED? 2720 2593 */ 2721 2594 if (startTagLevel == 0) 2722 2595 return XML_ERROR_NO_ELEMENTS; 2723 2596 if (parser->m_tagLevel != startTagLevel) ................................................................................ 2747 2620 return XML_ERROR_UNCLOSED_TOKEN; 2748 2621 case XML_TOK_PARTIAL_CHAR: 2749 2622 if (haveMore) { 2750 2623 *nextPtr = s; 2751 2624 return XML_ERROR_NONE; 2752 2625 } 2753 2626 return XML_ERROR_PARTIAL_CHAR; 2754 - case XML_TOK_ENTITY_REF: 2755 - { 2756 - const XML_Char *name; 2757 - ENTITY *entity; 2758 - XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, 2759 - s + enc->minBytesPerChar, 2760 - next - enc->minBytesPerChar); 2761 - if (ch) { 2762 - if (parser->m_characterDataHandler) 2763 - parser->m_characterDataHandler(parser->m_handlerArg, &ch, 1); 2764 - else if (parser->m_defaultHandler) 2765 - reportDefault(parser, enc, s, next); 2766 - break; 2767 - } 2768 - name = poolStoreString(&dtd->pool, enc, 2769 - s + enc->minBytesPerChar, 2770 - next - enc->minBytesPerChar); 2771 - if (!name) 2772 - return XML_ERROR_NO_MEMORY; 2773 - entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); 2774 - poolDiscard(&dtd->pool); 2775 - /* First, determine if a check for an existing declaration is needed; 2776 - if yes, check that the entity exists, and that it is internal, 2777 - otherwise call the skipped entity or default handler. 2778 - */ 2779 - if (!dtd->hasParamEntityRefs || dtd->standalone) { 2780 - if (!entity) 2781 - return XML_ERROR_UNDEFINED_ENTITY; 2782 - else if (!entity->is_internal) 2783 - return XML_ERROR_ENTITY_DECLARED_IN_PE; 2784 - } 2785 - else if (!entity) { 2786 - if (parser->m_skippedEntityHandler) 2787 - parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); 2788 - else if (parser->m_defaultHandler) 2789 - reportDefault(parser, enc, s, next); 2790 - break; 2791 - } 2792 - if (entity->open) 2793 - return XML_ERROR_RECURSIVE_ENTITY_REF; 2794 - if (entity->notation) 2795 - return XML_ERROR_BINARY_ENTITY_REF; 2796 - if (entity->textPtr) { 2797 - enum XML_Error result; 2798 - if (!parser->m_defaultExpandInternalEntities) { 2799 - if (parser->m_skippedEntityHandler) 2800 - parser->m_skippedEntityHandler(parser->m_handlerArg, entity->name, 0); 2801 - else if (parser->m_defaultHandler) 2802 - reportDefault(parser, enc, s, next); 2803 - break; 2804 - } 2805 - result = processInternalEntity(parser, entity, XML_FALSE); 2806 - if (result != XML_ERROR_NONE) 2807 - return result; 2808 - } 2809 - else if (parser->m_externalEntityRefHandler) { 2810 - const XML_Char *context; 2811 - entity->open = XML_TRUE; 2812 - context = getContext(parser); 2813 - entity->open = XML_FALSE; 2814 - if (!context) 2815 - return XML_ERROR_NO_MEMORY; 2816 - if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, 2817 - context, 2818 - entity->base, 2819 - entity->systemId, 2820 - entity->publicId)) 2821 - return XML_ERROR_EXTERNAL_ENTITY_HANDLING; 2822 - poolDiscard(&parser->m_tempPool); 2823 - } 2627 + case XML_TOK_ENTITY_REF: { 2628 + const XML_Char *name; 2629 + ENTITY *entity; 2630 + XML_Char ch = (XML_Char)XmlPredefinedEntityName( 2631 + enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar); 2632 + if (ch) { 2633 + if (parser->m_characterDataHandler) 2634 + parser->m_characterDataHandler(parser->m_handlerArg, &ch, 1); 2635 + else if (parser->m_defaultHandler) 2636 + reportDefault(parser, enc, s, next); 2637 + break; 2638 + } 2639 + name = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, 2640 + next - enc->minBytesPerChar); 2641 + if (! name) 2642 + return XML_ERROR_NO_MEMORY; 2643 + entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); 2644 + poolDiscard(&dtd->pool); 2645 + /* First, determine if a check for an existing declaration is needed; 2646 + if yes, check that the entity exists, and that it is internal, 2647 + otherwise call the skipped entity or default handler. 2648 + */ 2649 + if (! dtd->hasParamEntityRefs || dtd->standalone) { 2650 + if (! entity) 2651 + return XML_ERROR_UNDEFINED_ENTITY; 2652 + else if (! entity->is_internal) 2653 + return XML_ERROR_ENTITY_DECLARED_IN_PE; 2654 + } else if (! entity) { 2655 + if (parser->m_skippedEntityHandler) 2656 + parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); 2824 2657 else if (parser->m_defaultHandler) 2825 2658 reportDefault(parser, enc, s, next); 2826 2659 break; 2827 2660 } 2661 + if (entity->open) 2662 + return XML_ERROR_RECURSIVE_ENTITY_REF; 2663 + if (entity->notation) 2664 + return XML_ERROR_BINARY_ENTITY_REF; 2665 + if (entity->textPtr) { 2666 + enum XML_Error result; 2667 + if (! parser->m_defaultExpandInternalEntities) { 2668 + if (parser->m_skippedEntityHandler) 2669 + parser->m_skippedEntityHandler(parser->m_handlerArg, entity->name, 2670 + 0); 2671 + else if (parser->m_defaultHandler) 2672 + reportDefault(parser, enc, s, next); 2673 + break; 2674 + } 2675 + result = processInternalEntity(parser, entity, XML_FALSE); 2676 + if (result != XML_ERROR_NONE) 2677 + return result; 2678 + } else if (parser->m_externalEntityRefHandler) { 2679 + const XML_Char *context; 2680 + entity->open = XML_TRUE; 2681 + context = getContext(parser); 2682 + entity->open = XML_FALSE; 2683 + if (! context) 2684 + return XML_ERROR_NO_MEMORY; 2685 + if (! parser->m_externalEntityRefHandler( 2686 + parser->m_externalEntityRefHandlerArg, context, entity->base, 2687 + entity->systemId, entity->publicId)) 2688 + return XML_ERROR_EXTERNAL_ENTITY_HANDLING; 2689 + poolDiscard(&parser->m_tempPool); 2690 + } else if (parser->m_defaultHandler) 2691 + reportDefault(parser, enc, s, next); 2692 + break; 2693 + } 2828 2694 case XML_TOK_START_TAG_NO_ATTS: 2829 2695 /* fall through */ 2830 - case XML_TOK_START_TAG_WITH_ATTS: 2696 + case XML_TOK_START_TAG_WITH_ATTS: { 2697 + TAG *tag; 2698 + enum XML_Error result; 2699 + XML_Char *toPtr; 2700 + if (parser->m_freeTagList) { 2701 + tag = parser->m_freeTagList; 2702 + parser->m_freeTagList = parser->m_freeTagList->parent; 2703 + } else { 2704 + tag = (TAG *)MALLOC(parser, sizeof(TAG)); 2705 + if (! tag) 2706 + return XML_ERROR_NO_MEMORY; 2707 + tag->buf = (char *)MALLOC(parser, INIT_TAG_BUF_SIZE); 2708 + if (! tag->buf) { 2709 + FREE(parser, tag); 2710 + return XML_ERROR_NO_MEMORY; 2711 + } 2712 + tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; 2713 + } 2714 + tag->bindings = NULL; 2715 + tag->parent = parser->m_tagStack; 2716 + parser->m_tagStack = tag; 2717 + tag->name.localPart = NULL; 2718 + tag->name.prefix = NULL; 2719 + tag->rawName = s + enc->minBytesPerChar; 2720 + tag->rawNameLength = XmlNameLength(enc, tag->rawName); 2721 + ++parser->m_tagLevel; 2831 2722 { 2832 - TAG *tag; 2833 - enum XML_Error result; 2834 - XML_Char *toPtr; 2835 - if (parser->m_freeTagList) { 2836 - tag = parser->m_freeTagList; 2837 - parser->m_freeTagList = parser->m_freeTagList->parent; 2838 - } 2839 - else { 2840 - tag = (TAG *)MALLOC(parser, sizeof(TAG)); 2841 - if (!tag) 2842 - return XML_ERROR_NO_MEMORY; 2843 - tag->buf = (char *)MALLOC(parser, INIT_TAG_BUF_SIZE); 2844 - if (!tag->buf) { 2845 - FREE(parser, tag); 2846 - return XML_ERROR_NO_MEMORY; 2847 - } 2848 - tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; 2849 - } 2850 - tag->bindings = NULL; 2851 - tag->parent = parser->m_tagStack; 2852 - parser->m_tagStack = tag; 2853 - tag->name.localPart = NULL; 2854 - tag->name.prefix = NULL; 2855 - tag->rawName = s + enc->minBytesPerChar; 2856 - tag->rawNameLength = XmlNameLength(enc, tag->rawName); 2857 - ++parser->m_tagLevel; 2858 - { 2859 - const char *rawNameEnd = tag->rawName + tag->rawNameLength; 2860 - const char *fromPtr = tag->rawName; 2861 - toPtr = (XML_Char *)tag->buf; 2862 - for (;;) { 2863 - int bufSize; 2864 - int convLen; 2865 - const enum XML_Convert_Result convert_res = XmlConvert(enc, 2866 - &fromPtr, rawNameEnd, 2867 - (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); 2868 - convLen = (int)(toPtr - (XML_Char *)tag->buf); 2869 - if ((fromPtr >= rawNameEnd) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) { 2870 - tag->name.strLen = convLen; 2871 - break; 2872 - } 2873 - bufSize = (int)(tag->bufEnd - tag->buf) << 1; 2874 - { 2875 - char *temp = (char *)REALLOC(parser, tag->buf, bufSize); 2876 - if (temp == NULL) 2877 - return XML_ERROR_NO_MEMORY; 2878 - tag->buf = temp; 2879 - tag->bufEnd = temp + bufSize; 2880 - toPtr = (XML_Char *)temp + convLen; 2881 - } 2882 - } 2883 - } 2884 - tag->name.str = (XML_Char *)tag->buf; 2885 - *toPtr = XML_T('\0'); 2886 - result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); 2887 - if (result) 2888 - return result; 2889 - if (parser->m_startElementHandler) 2890 - parser->m_startElementHandler(parser->m_handlerArg, tag->name.str, 2891 - (const XML_Char **)parser->m_atts); 2892 - else if (parser->m_defaultHandler) 2893 - reportDefault(parser, enc, s, next); 2894 - poolClear(&parser->m_tempPool); 2895 - break; 2896 - } 2723 + const char *rawNameEnd = tag->rawName + tag->rawNameLength; 2724 + const char *fromPtr = tag->rawName; 2725 + toPtr = (XML_Char *)tag->buf; 2726 + for (;;) { 2727 + int bufSize; 2728 + int convLen; 2729 + const enum XML_Convert_Result convert_res 2730 + = XmlConvert(enc, &fromPtr, rawNameEnd, (ICHAR **)&toPtr, 2731 + (ICHAR *)tag->bufEnd - 1); 2732 + convLen = (int)(toPtr - (XML_Char *)tag->buf); 2733 + if ((fromPtr >= rawNameEnd) 2734 + || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) { 2735 + tag->name.strLen = convLen; 2736 + break; 2737 + } 2738 + bufSize = (int)(tag->bufEnd - tag->buf) << 1; 2739 + { 2740 + char *temp = (char *)REALLOC(parser, tag->buf, bufSize); 2741 + if (temp == NULL) 2742 + return XML_ERROR_NO_MEMORY; 2743 + tag->buf = temp; 2744 + tag->bufEnd = temp + bufSize; 2745 + toPtr = (XML_Char *)temp + convLen; 2746 + } 2747 + } 2748 + } 2749 + tag->name.str = (XML_Char *)tag->buf; 2750 + *toPtr = XML_T('\0'); 2751 + result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); 2752 + if (result) 2753 + return result; 2754 + if (parser->m_startElementHandler) 2755 + parser->m_startElementHandler(parser->m_handlerArg, tag->name.str, 2756 + (const XML_Char **)parser->m_atts); 2757 + else if (parser->m_defaultHandler) 2758 + reportDefault(parser, enc, s, next); 2759 + poolClear(&parser->m_tempPool); 2760 + break; 2761 + } 2897 2762 case XML_TOK_EMPTY_ELEMENT_NO_ATTS: 2898 2763 /* fall through */ 2899 - case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: 2900 - { 2901 - const char *rawName = s + enc->minBytesPerChar; 2902 - enum XML_Error result; 2903 - BINDING *bindings = NULL; 2904 - XML_Bool noElmHandlers = XML_TRUE; 2905 - TAG_NAME name; 2906 - name.str = poolStoreString(&parser->m_tempPool, enc, rawName, 2907 - rawName + XmlNameLength(enc, rawName)); 2908 - if (!name.str) 2909 - return XML_ERROR_NO_MEMORY; 2910 - poolFinish(&parser->m_tempPool); 2911 - result = storeAtts(parser, enc, s, &name, &bindings); 2912 - if (result != XML_ERROR_NONE) { 2913 - freeBindings(parser, bindings); 2914 - return result; 2915 - } 2916 - poolFinish(&parser->m_tempPool); 2917 - if (parser->m_startElementHandler) { 2918 - parser->m_startElementHandler(parser->m_handlerArg, name.str, (const XML_Char **)parser->m_atts); 2919 - noElmHandlers = XML_FALSE; 2920 - } 2921 - if (parser->m_endElementHandler) { 2922 - if (parser->m_startElementHandler) 2923 - *eventPP = *eventEndPP; 2924 - parser->m_endElementHandler(parser->m_handlerArg, name.str); 2925 - noElmHandlers = XML_FALSE; 2926 - } 2927 - if (noElmHandlers && parser->m_defaultHandler) 2928 - reportDefault(parser, enc, s, next); 2929 - poolClear(&parser->m_tempPool); 2764 + case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: { 2765 + const char *rawName = s + enc->minBytesPerChar; 2766 + enum XML_Error result; 2767 + BINDING *bindings = NULL; 2768 + XML_Bool noElmHandlers = XML_TRUE; 2769 + TAG_NAME name; 2770 + name.str = poolStoreString(&parser->m_tempPool, enc, rawName, 2771 + rawName + XmlNameLength(enc, rawName)); 2772 + if (! name.str) 2773 + return XML_ERROR_NO_MEMORY; 2774 + poolFinish(&parser->m_tempPool); 2775 + result = storeAtts(parser, enc, s, &name, &bindings); 2776 + if (result != XML_ERROR_NONE) { 2930 2777 freeBindings(parser, bindings); 2778 + return result; 2931 2779 } 2932 - if ((parser->m_tagLevel == 0) && (parser->m_parsingStatus.parsing != XML_FINISHED)) { 2780 + poolFinish(&parser->m_tempPool); 2781 + if (parser->m_startElementHandler) { 2782 + parser->m_startElementHandler(parser->m_handlerArg, name.str, 2783 + (const XML_Char **)parser->m_atts); 2784 + noElmHandlers = XML_FALSE; 2785 + } 2786 + if (parser->m_endElementHandler) { 2787 + if (parser->m_startElementHandler) 2788 + *eventPP = *eventEndPP; 2789 + parser->m_endElementHandler(parser->m_handlerArg, name.str); 2790 + noElmHandlers = XML_FALSE; 2791 + } 2792 + if (noElmHandlers && parser->m_defaultHandler) 2793 + reportDefault(parser, enc, s, next); 2794 + poolClear(&parser->m_tempPool); 2795 + freeBindings(parser, bindings); 2796 + } 2797 + if ((parser->m_tagLevel == 0) 2798 + && (parser->m_parsingStatus.parsing != XML_FINISHED)) { 2933 2799 if (parser->m_parsingStatus.parsing == XML_SUSPENDED) 2934 2800 parser->m_processor = epilogProcessor; 2935 2801 else 2936 2802 return epilogProcessor(parser, next, end, nextPtr); 2937 2803 } 2938 2804 break; 2939 2805 case XML_TOK_END_TAG: ................................................................................ 2942 2808 else { 2943 2809 int len; 2944 2810 const char *rawName; 2945 2811 TAG *tag = parser->m_tagStack; 2946 2812 parser->m_tagStack = tag->parent; 2947 2813 tag->parent = parser->m_freeTagList; 2948 2814 parser->m_freeTagList = tag; 2949 - rawName = s + enc->minBytesPerChar*2; 2815 + rawName = s + enc->minBytesPerChar * 2; 2950 2816 len = XmlNameLength(enc, rawName); 2951 2817 if (len != tag->rawNameLength 2952 2818 || memcmp(tag->rawName, rawName, len) != 0) { 2953 2819 *eventPP = rawName; 2954 2820 return XML_ERROR_TAG_MISMATCH; 2955 2821 } 2956 2822 --parser->m_tagLevel; ................................................................................ 2962 2828 if (parser->m_ns && localPart) { 2963 2829 /* localPart and prefix may have been overwritten in 2964 2830 tag->name.str, since this points to the binding->uri 2965 2831 buffer which gets re-used; so we have to add them again 2966 2832 */ 2967 2833 uri = (XML_Char *)tag->name.str + tag->name.uriLen; 2968 2834 /* don't need to check for space - already done in storeAtts() */ 2969 - while (*localPart) *uri++ = *localPart++; 2835 + while (*localPart) 2836 + *uri++ = *localPart++; 2970 2837 prefix = (XML_Char *)tag->name.prefix; 2971 2838 if (parser->m_ns_triplets && prefix) { 2972 2839 *uri++ = parser->m_namespaceSeparator; 2973 - while (*prefix) *uri++ = *prefix++; 2974 - } 2840 + while (*prefix) 2841 + *uri++ = *prefix++; 2842 + } 2975 2843 *uri = XML_T('\0'); 2976 2844 } 2977 2845 parser->m_endElementHandler(parser->m_handlerArg, tag->name.str); 2978 - } 2979 - else if (parser->m_defaultHandler) 2846 + } else if (parser->m_defaultHandler) 2980 2847 reportDefault(parser, enc, s, next); 2981 2848 while (tag->bindings) { 2982 2849 BINDING *b = tag->bindings; 2983 2850 if (parser->m_endNamespaceDeclHandler) 2984 - parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name); 2851 + parser->m_endNamespaceDeclHandler(parser->m_handlerArg, 2852 + b->prefix->name); 2985 2853 tag->bindings = tag->bindings->nextTagBinding; 2986 2854 b->nextTagBinding = parser->m_freeBindingList; 2987 2855 parser->m_freeBindingList = b; 2988 2856 b->prefix->binding = b->prevPrefixBinding; 2989 2857 } 2990 - if (parser->m_tagLevel == 0) 2991 - return epilogProcessor(parser, next, end, nextPtr); 2858 + if ((parser->m_tagLevel == 0) 2859 + && (parser->m_parsingStatus.parsing != XML_FINISHED)) { 2860 + if (parser->m_parsingStatus.parsing == XML_SUSPENDED) 2861 + parser->m_processor = epilogProcessor; 2862 + else 2863 + return epilogProcessor(parser, next, end, nextPtr); 2864 + } 2992 2865 } 2993 2866 break; 2994 - case XML_TOK_CHAR_REF: 2995 - { 2996 - int n = XmlCharRefNumber(enc, s); 2997 - if (n < 0) 2998 - return XML_ERROR_BAD_CHAR_REF; 2999 - if (parser->m_characterDataHandler) { 3000 - XML_Char buf[XML_ENCODE_MAX]; 3001 - parser->m_characterDataHandler(parser->m_handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); 3002 - } 3003 - else if (parser->m_defaultHandler) 3004 - reportDefault(parser, enc, s, next); 3005 - } 3006 - break; 2867 + case XML_TOK_CHAR_REF: { 2868 + int n = XmlCharRefNumber(enc, s); 2869 + if (n < 0) 2870 + return XML_ERROR_BAD_CHAR_REF; 2871 + if (parser->m_characterDataHandler) { 2872 + XML_Char buf[XML_ENCODE_MAX]; 2873 + parser->m_characterDataHandler(parser->m_handlerArg, buf, 2874 + XmlEncode(n, (ICHAR *)buf)); 2875 + } else if (parser->m_defaultHandler) 2876 + reportDefault(parser, enc, s, next); 2877 + } break; 3007 2878 case XML_TOK_XML_DECL: 3008 2879 return XML_ERROR_MISPLACED_XML_PI; 3009 2880 case XML_TOK_DATA_NEWLINE: 3010 2881 if (parser->m_characterDataHandler) { 3011 2882 XML_Char c = 0xA; 3012 2883 parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); 3013 - } 2884 + } else if (parser->m_defaultHandler) 2885 + reportDefault(parser, enc, s, next); 2886 + break; 2887 + case XML_TOK_CDATA_SECT_OPEN: { 2888 + enum XML_Error result; 2889 + if (parser->m_startCdataSectionHandler) 2890 + parser->m_startCdataSectionHandler(parser->m_handlerArg); 2891 + /* BEGIN disabled code */ 2892 + /* Suppose you doing a transformation on a document that involves 2893 + changing only the character data. You set up a defaultHandler 2894 + and a characterDataHandler. The defaultHandler simply copies 2895 + characters through. The characterDataHandler does the 2896 + transformation and writes the characters out escaping them as 2897 + necessary. This case will fail to work if we leave out the 2898 + following two lines (because & and < inside CDATA sections will 2899 + be incorrectly escaped). 2900 + 2901 + However, now we have a start/endCdataSectionHandler, so it seems 2902 + easier to let the user deal with this. 2903 + */ 2904 + else if (0 && parser->m_characterDataHandler) 2905 + parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 2906 + 0); 2907 + /* END disabled code */ 3014 2908 else if (parser->m_defaultHandler) 3015 2909 reportDefault(parser, enc, s, next); 3016 - break; 3017 - case XML_TOK_CDATA_SECT_OPEN: 3018 - { 3019 - enum XML_Error result; 3020 - if (parser->m_startCdataSectionHandler) 3021 - parser->m_startCdataSectionHandler(parser->m_handlerArg); 3022 -#if 0 3023 - /* Suppose you doing a transformation on a document that involves 3024 - changing only the character data. You set up a defaultHandler 3025 - and a characterDataHandler. The defaultHandler simply copies 3026 - characters through. The characterDataHandler does the 3027 - transformation and writes the characters out escaping them as 3028 - necessary. This case will fail to work if we leave out the 3029 - following two lines (because & and < inside CDATA sections will 3030 - be incorrectly escaped). 3031 - 3032 - However, now we have a start/endCdataSectionHandler, so it seems 3033 - easier to let the user deal with this. 3034 - */ 3035 - else if (parser->m_characterDataHandler) 3036 - parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 0); 3037 -#endif 3038 - else if (parser->m_defaultHandler) 3039 - reportDefault(parser, enc, s, next); 3040 - result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); 3041 - if (result != XML_ERROR_NONE) 3042 - return result; 3043 - else if (!next) { 3044 - parser->m_processor = cdataSectionProcessor; 3045 - return result; 3046 - } 2910 + result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); 2911 + if (result != XML_ERROR_NONE) 2912 + return result; 2913 + else if (! next) { 2914 + parser->m_processor = cdataSectionProcessor; 2915 + return result; 3047 2916 } 3048 - break; 2917 + } break; 3049 2918 case XML_TOK_TRAILING_RSQB: 3050 2919 if (haveMore) { 3051 2920 *nextPtr = s; 3052 2921 return XML_ERROR_NONE; 3053 2922 } 3054 2923 if (parser->m_characterDataHandler) { 3055 2924 if (MUST_CONVERT(enc, s)) { 3056 2925 ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; 3057 2926 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 3058 - parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 3059 - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 3060 - } 3061 - else 3062 - parser->m_characterDataHandler(parser->m_handlerArg, 3063 - (XML_Char *)s, 3064 - (int)((XML_Char *)end - (XML_Char *)s)); 3065 - } 3066 - else if (parser->m_defaultHandler) 2927 + parser->m_characterDataHandler( 2928 + parser->m_handlerArg, parser->m_dataBuf, 2929 + (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 2930 + } else 2931 + parser->m_characterDataHandler( 2932 + parser->m_handlerArg, (XML_Char *)s, 2933 + (int)((XML_Char *)end - (XML_Char *)s)); 2934 + } else if (parser->m_defaultHandler) 3067 2935 reportDefault(parser, enc, s, end); 3068 2936 /* We are at the end of the final buffer, should we check for 3069 2937 XML_SUSPENDED, XML_FINISHED? 3070 2938 */ 3071 2939 if (startTagLevel == 0) { 3072 2940 *eventPP = end; 3073 2941 return XML_ERROR_NO_ELEMENTS; ................................................................................ 3074 2942 } 3075 2943 if (parser->m_tagLevel != startTagLevel) { 3076 2944 *eventPP = end; 3077 2945 return XML_ERROR_ASYNC_ENTITY; 3078 2946 } 3079 2947 *nextPtr = end; 3080 2948 return XML_ERROR_NONE; 3081 - case XML_TOK_DATA_CHARS: 3082 - { 3083 - XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; 3084 - if (charDataHandler) { 3085 - if (MUST_CONVERT(enc, s)) { 3086 - for (;;) { 3087 - ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; 3088 - const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 3089 - *eventEndPP = s; 3090 - charDataHandler(parser->m_handlerArg, parser->m_dataBuf, 3091 - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 3092 - if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) 3093 - break; 3094 - *eventPP = s; 3095 - } 3096 - } 3097 - else 3098 - charDataHandler(parser->m_handlerArg, 3099 - (XML_Char *)s, 3100 - (int)((XML_Char *)next - (XML_Char *)s)); 3101 - } 3102 - else if (parser->m_defaultHandler) 3103 - reportDefault(parser, enc, s, next); 3104 - } 3105 - break; 2949 + case XML_TOK_DATA_CHARS: { 2950 + XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; 2951 + if (charDataHandler) { 2952 + if (MUST_CONVERT(enc, s)) { 2953 + for (;;) { 2954 + ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; 2955 + const enum XML_Convert_Result convert_res = XmlConvert( 2956 + enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 2957 + *eventEndPP = s; 2958 + charDataHandler(parser->m_handlerArg, parser->m_dataBuf, 2959 + (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 2960 + if ((convert_res == XML_CONVERT_COMPLETED) 2961 + || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) 2962 + break; 2963 + *eventPP = s; 2964 + } 2965 + } else 2966 + charDataHandler(parser->m_handlerArg, (XML_Char *)s, 2967 + (int)((XML_Char *)next - (XML_Char *)s)); 2968 + } else if (parser->m_defaultHandler) 2969 + reportDefault(parser, enc, s, next); 2970 + } break; 3106 2971 case XML_TOK_PI: 3107 - if (!reportProcessingInstruction(parser, enc, s, next)) 2972 + if (! reportProcessingInstruction(parser, enc, s, next)) 3108 2973 return XML_ERROR_NO_MEMORY; 3109 2974 break; 3110 2975 case XML_TOK_COMMENT: 3111 - if (!reportComment(parser, enc, s, next)) 2976 + if (! reportComment(parser, enc, s, next)) 3112 2977 return XML_ERROR_NO_MEMORY; 3113 2978 break; 3114 2979 default: 3115 2980 /* All of the tokens produced by XmlContentTok() have their own 3116 2981 * explicit cases, so this default is not strictly necessary. 3117 2982 * However it is a useful safety net, so we retain the code and 3118 2983 * simply exclude it from the coverage tests. ................................................................................ 3127 2992 *eventPP = s = next; 3128 2993 switch (parser->m_parsingStatus.parsing) { 3129 2994 case XML_SUSPENDED: 3130 2995 *nextPtr = next; 3131 2996 return XML_ERROR_NONE; 3132 2997 case XML_FINISHED: 3133 2998 return XML_ERROR_ABORTED; 3134 - default: ; 2999 + default:; 3135 3000 } 3136 3001 } 3137 3002 /* not reached */ 3138 3003 } 3139 3004 3140 3005 /* This function does not call free() on the allocated memory, merely 3141 3006 * moving it to the parser's m_freeBindingList where it can be freed or 3142 3007 * reused as appropriate. 3143 3008 */ 3144 3009 static void 3145 -freeBindings(XML_Parser parser, BINDING *bindings) 3146 -{ 3010 +freeBindings(XML_Parser parser, BINDING *bindings) { 3147 3011 while (bindings) { 3148 3012 BINDING *b = bindings; 3149 3013 3150 3014 /* m_startNamespaceDeclHandler will have been called for this 3151 3015 * binding in addBindings(), so call the end handler now. 3152 3016 */ 3153 3017 if (parser->m_endNamespaceDeclHandler) 3154 - parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name); 3018 + parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name); 3155 3019 3156 3020 bindings = bindings->nextTagBinding; 3157 3021 b->nextTagBinding = parser->m_freeBindingList; 3158 3022 parser->m_freeBindingList = b; 3159 3023 b->prefix->binding = b->prevPrefixBinding; 3160 3024 } 3161 3025 } ................................................................................ 3167 3031 - generate namespace aware attribute names (URI, prefix) 3168 3032 - build list of attributes for startElementHandler 3169 3033 - default attributes 3170 3034 - process namespace declarations (check and report them) 3171 3035 - generate namespace aware element name (URI, prefix) 3172 3036 */ 3173 3037 static enum XML_Error 3174 -storeAtts(XML_Parser parser, const ENCODING *enc, 3175 - const char *attStr, TAG_NAME *tagNamePtr, 3176 - BINDING **bindingsPtr) 3177 -{ 3178 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 3038 +storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, 3039 + TAG_NAME *tagNamePtr, BINDING **bindingsPtr) { 3040 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 3179 3041 ELEMENT_TYPE *elementType; 3180 3042 int nDefaultAtts; 3181 - const XML_Char **appAtts; /* the attribute list for the application */ 3043 + const XML_Char **appAtts; /* the attribute list for the application */ 3182 3044 int attIndex = 0; 3183 3045 int prefixLen; 3184 3046 int i; 3185 3047 int n; 3186 3048 XML_Char *uri; 3187 3049 int nPrefixes = 0; 3188 3050 BINDING *binding; 3189 3051 const XML_Char *localPart; 3190 3052 3191 3053 /* lookup the element type name */ 3192 - elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str,0); 3193 - if (!elementType) { 3054 + elementType 3055 + = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str, 0); 3056 + if (! elementType) { 3194 3057 const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); 3195 - if (!name) 3058 + if (! name) 3196 3059 return XML_ERROR_NO_MEMORY; 3197 3060 elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name, 3198 3061 sizeof(ELEMENT_TYPE)); 3199 - if (!elementType) 3062 + if (! elementType) 3200 3063 return XML_ERROR_NO_MEMORY; 3201 - if (parser->m_ns && !setElementTypePrefix(parser, elementType)) 3064 + if (parser->m_ns && ! setElementTypePrefix(parser, elementType)) 3202 3065 return XML_ERROR_NO_MEMORY; 3203 3066 } 3204 3067 nDefaultAtts = elementType->nDefaultAtts; 3205 3068 3206 3069 /* get the attributes from the tokenizer */ 3207 3070 n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts); 3208 3071 if (n + nDefaultAtts > parser->m_attsSize) { 3209 3072 int oldAttsSize = parser->m_attsSize; 3210 3073 ATTRIBUTE *temp; 3211 3074 #ifdef XML_ATTR_INFO 3212 3075 XML_AttrInfo *temp2; 3213 3076 #endif 3214 3077 parser->m_attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; 3215 - temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts, parser->m_attsSize * sizeof(ATTRIBUTE)); 3078 + temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts, 3079 + parser->m_attsSize * sizeof(ATTRIBUTE)); 3216 3080 if (temp == NULL) { 3217 3081 parser->m_attsSize = oldAttsSize; 3218 3082 return XML_ERROR_NO_MEMORY; 3219 3083 } 3220 3084 parser->m_atts = temp; 3221 3085 #ifdef XML_ATTR_INFO 3222 - temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo, parser->m_attsSize * sizeof(XML_AttrInfo)); 3086 + temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo, 3087 + parser->m_attsSize * sizeof(XML_AttrInfo)); 3223 3088 if (temp2 == NULL) { 3224 3089 parser->m_attsSize = oldAttsSize; 3225 3090 return XML_ERROR_NO_MEMORY; 3226 3091 } 3227 3092 parser->m_attInfo = temp2; 3228 3093 #endif 3229 3094 if (n > oldAttsSize) ................................................................................ 3233 3098 appAtts = (const XML_Char **)parser->m_atts; 3234 3099 for (i = 0; i < n; i++) { 3235 3100 ATTRIBUTE *currAtt = &parser->m_atts[i]; 3236 3101 #ifdef XML_ATTR_INFO 3237 3102 XML_AttrInfo *currAttInfo = &parser->m_attInfo[i]; 3238 3103 #endif 3239 3104 /* add the name and value to the attribute list */ 3240 - ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, 3241 - currAtt->name 3242 - + XmlNameLength(enc, currAtt->name)); 3243 - if (!attId) 3105 + ATTRIBUTE_ID *attId 3106 + = getAttributeId(parser, enc, currAtt->name, 3107 + currAtt->name + XmlNameLength(enc, currAtt->name)); 3108 + if (! attId) 3244 3109 return XML_ERROR_NO_MEMORY; 3245 3110 #ifdef XML_ATTR_INFO 3246 - currAttInfo->nameStart = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->name); 3247 - currAttInfo->nameEnd = currAttInfo->nameStart + 3248 - XmlNameLength(enc, currAtt->name); 3249 - currAttInfo->valueStart = parser->m_parseEndByteIndex - 3250 - (parser->m_parseEndPtr - currAtt->valuePtr); 3251 - currAttInfo->valueEnd = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->valueEnd); 3111 + currAttInfo->nameStart 3112 + = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->name); 3113 + currAttInfo->nameEnd 3114 + = currAttInfo->nameStart + XmlNameLength(enc, currAtt->name); 3115 + currAttInfo->valueStart = parser->m_parseEndByteIndex 3116 + - (parser->m_parseEndPtr - currAtt->valuePtr); 3117 + currAttInfo->valueEnd = parser->m_parseEndByteIndex 3118 + - (parser->m_parseEndPtr - currAtt->valueEnd); 3252 3119 #endif 3253 3120 /* Detect duplicate attributes by their QNames. This does not work when 3254 3121 namespace processing is turned on and different prefixes for the same 3255 3122 namespace are used. For this case we have a check further down. 3256 3123 */ 3257 3124 if ((attId->name)[-1]) { 3258 3125 if (enc == parser->m_encoding) 3259 3126 parser->m_eventPtr = parser->m_atts[i].name; 3260 3127 return XML_ERROR_DUPLICATE_ATTRIBUTE; 3261 3128 } 3262 3129 (attId->name)[-1] = 1; 3263 3130 appAtts[attIndex++] = attId->name; 3264 - if (!parser->m_atts[i].normalized) { 3131 + if (! parser->m_atts[i].normalized) { 3265 3132 enum XML_Error result; 3266 3133 XML_Bool isCdata = XML_TRUE; 3267 3134 3268 3135 /* figure out whether declared as other than CDATA */ 3269 3136 if (attId->maybeTokenized) { 3270 3137 int j; 3271 3138 for (j = 0; j < nDefaultAtts; j++) { ................................................................................ 3273 3140 isCdata = elementType->defaultAtts[j].isCdata; 3274 3141 break; 3275 3142 } 3276 3143 } 3277 3144 } 3278 3145 3279 3146 /* normalize the attribute value */ 3280 - result = storeAttributeValue(parser, enc, isCdata, 3281 - parser->m_atts[i].valuePtr, parser->m_atts[i].valueEnd, 3282 - &parser->m_tempPool); 3147 + result = storeAttributeValue( 3148 + parser, enc, isCdata, parser->m_atts[i].valuePtr, 3149 + parser->m_atts[i].valueEnd, &parser->m_tempPool); 3283 3150 if (result) 3284 3151 return result; 3285 3152 appAtts[attIndex] = poolStart(&parser->m_tempPool); 3286 3153 poolFinish(&parser->m_tempPool); 3287 - } 3288 - else { 3154 + } else { 3289 3155 /* the value did not need normalizing */ 3290 - appAtts[attIndex] = poolStoreString(&parser->m_tempPool, enc, parser->m_atts[i].valuePtr, 3156 + appAtts[attIndex] = poolStoreString(&parser->m_tempPool, enc, 3157 + parser->m_atts[i].valuePtr, 3291 3158 parser->m_atts[i].valueEnd); 3292 3159 if (appAtts[attIndex] == 0) 3293 3160 return XML_ERROR_NO_MEMORY; 3294 3161 poolFinish(&parser->m_tempPool); 3295 3162 } 3296 3163 /* handle prefixed attribute names */ 3297 3164 if (attId->prefix) { ................................................................................ 3298 3165 if (attId->xmlns) { 3299 3166 /* deal with namespace declarations here */ 3300 3167 enum XML_Error result = addBinding(parser, attId->prefix, attId, 3301 3168 appAtts[attIndex], bindingsPtr); 3302 3169 if (result) 3303 3170 return result; 3304 3171 --attIndex; 3305 - } 3306 - else { 3172 + } else { 3307 3173 /* deal with other prefixed names later */ 3308 3174 attIndex++; 3309 3175 nPrefixes++; 3310 3176 (attId->name)[-1] = 2; 3311 3177 } 3312 - } 3313 - else 3178 + } else 3314 3179 attIndex++; 3315 3180 } 3316 3181 3317 3182 /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ 3318 3183 parser->m_nSpecifiedAtts = attIndex; 3319 3184 if (elementType->idAtt && (elementType->idAtt->name)[-1]) { 3320 3185 for (i = 0; i < attIndex; i += 2) 3321 3186 if (appAtts[i] == elementType->idAtt->name) { 3322 3187 parser->m_idAttIndex = i; 3323 3188 break; 3324 3189 } 3325 - } 3326 - else 3190 + } else 3327 3191 parser->m_idAttIndex = -1; 3328 3192 3329 3193 /* do attribute defaulting */ 3330 3194 for (i = 0; i < nDefaultAtts; i++) { 3331 3195 const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i; 3332 - if (!(da->id->name)[-1] && da->value) { 3196 + if (! (da->id->name)[-1] && da->value) { 3333 3197 if (da->id->prefix) { 3334 3198 if (da->id->xmlns) { 3335 3199 enum XML_Error result = addBinding(parser, da->id->prefix, da->id, 3336 3200 da->value, bindingsPtr); 3337 3201 if (result) 3338 3202 return result; 3339 - } 3340 - else { 3203 + } else { 3341 3204 (da->id->name)[-1] = 2; 3342 3205 nPrefixes++; 3343 3206 appAtts[attIndex++] = da->id->name; 3344 3207 appAtts[attIndex++] = da->value; 3345 3208 } 3346 - } 3347 - else { 3209 + } else { 3348 3210 (da->id->name)[-1] = 1; 3349 3211 appAtts[attIndex++] = da->id->name; 3350 3212 appAtts[attIndex++] = da->value; 3351 3213 } 3352 3214 } 3353 3215 } 3354 3216 appAtts[attIndex] = 0; 3355 3217 3356 3218 /* expand prefixed attribute names, check for duplicates, 3357 3219 and clear flags that say whether attributes were specified */ 3358 3220 i = 0; 3359 3221 if (nPrefixes) { 3360 - int j; /* hash table index */ 3222 + int j; /* hash table index */ 3361 3223 unsigned long version = parser->m_nsAttsVersion; 3362 3224 int nsAttsSize = (int)1 << parser->m_nsAttsPower; 3363 3225 unsigned char oldNsAttsPower = parser->m_nsAttsPower; 3364 3226 /* size of hash table must be at least 2 * (# of prefixed attributes) */ 3365 - if ((nPrefixes << 1) >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */ 3227 + if ((nPrefixes << 1) 3228 + >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */ 3366 3229 NS_ATT *temp; 3367 3230 /* hash table size must also be a power of 2 and >= 8 */ 3368 - while (nPrefixes >> parser->m_nsAttsPower++); 3231 + while (nPrefixes >> parser->m_nsAttsPower++) 3232 + ; 3369 3233 if (parser->m_nsAttsPower < 3) 3370 3234 parser->m_nsAttsPower = 3; 3371 3235 nsAttsSize = (int)1 << parser->m_nsAttsPower; 3372 - temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts, nsAttsSize * sizeof(NS_ATT)); 3373 - if (!temp) { 3236 + temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts, 3237 + nsAttsSize * sizeof(NS_ATT)); 3238 + if (! temp) { 3374 3239 /* Restore actual size of memory in m_nsAtts */ 3375 3240 parser->m_nsAttsPower = oldNsAttsPower; 3376 3241 return XML_ERROR_NO_MEMORY; 3377 3242 } 3378 3243 parser->m_nsAtts = temp; 3379 - version = 0; /* force re-initialization of m_nsAtts hash table */ 3244 + version = 0; /* force re-initialization of m_nsAtts hash table */ 3380 3245 } 3381 3246 /* using a version flag saves us from initializing m_nsAtts every time */ 3382 - if (!version) { /* initialize version flags when version wraps around */ 3247 + if (! version) { /* initialize version flags when version wraps around */ 3383 3248 version = INIT_ATTS_VERSION; 3384 - for (j = nsAttsSize; j != 0; ) 3249 + for (j = nsAttsSize; j != 0;) 3385 3250 parser->m_nsAtts[--j].version = version; 3386 3251 } 3387 3252 parser->m_nsAttsVersion = --version; 3388 3253 3389 3254 /* expand prefixed names and check for duplicates */ 3390 3255 for (; i < attIndex; i += 2) { 3391 3256 const XML_Char *s = appAtts[i]; 3392 - if (s[-1] == 2) { /* prefixed */ 3257 + if (s[-1] == 2) { /* prefixed */ 3393 3258 ATTRIBUTE_ID *id; 3394 3259 const BINDING *b; 3395 3260 unsigned long uriHash; 3396 3261 struct siphash sip_state; 3397 3262 struct sipkey sip_key; 3398 3263 3399 3264 copy_salt_to_sipkey(parser, &sip_key); 3400 3265 sip24_init(&sip_state, &sip_key); 3401 3266 3402 - ((XML_Char *)s)[-1] = 0; /* clear flag */ 3267 + ((XML_Char *)s)[-1] = 0; /* clear flag */ 3403 3268 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); 3404 - if (!id || !id->prefix) { 3269 + if (! id || ! id->prefix) { 3405 3270 /* This code is walking through the appAtts array, dealing 3406 3271 * with (in this case) a prefixed attribute name. To be in 3407 3272 * the array, the attribute must have already been bound, so 3408 3273 * has to have passed through the hash table lookup once 3409 3274 * already. That implies that an entry for it already 3410 3275 * exists, so the lookup above will return a pointer to 3411 3276 * already allocated memory. There is no opportunaity for ................................................................................ 3415 3280 * Since it is difficult to be certain that the above 3416 3281 * analysis is complete, we retain the test and merely 3417 3282 * remove the code from coverage tests. 3418 3283 */ 3419 3284 return XML_ERROR_NO_MEMORY; /* LCOV_EXCL_LINE */ 3420 3285 } 3421 3286 b = id->prefix->binding; 3422 - if (!b) 3287 + if (! b) 3423 3288 return XML_ERROR_UNBOUND_PREFIX; 3424 3289 3425 3290 for (j = 0; j < b->uriLen; j++) { 3426 3291 const XML_Char c = b->uri[j]; 3427 - if (!poolAppendChar(&parser->m_tempPool, c)) 3292 + if (! poolAppendChar(&parser->m_tempPool, c)) 3428 3293 return XML_ERROR_NO_MEMORY; 3429 3294 } 3430 3295 3431 3296 sip24_update(&sip_state, b->uri, b->uriLen * sizeof(XML_Char)); 3432 3297 3433 3298 while (*s++ != XML_T(ASCII_COLON)) 3434 3299 ; 3435 3300 3436 3301 sip24_update(&sip_state, s, keylen(s) * sizeof(XML_Char)); 3437 3302 3438 - do { /* copies null terminator */ 3439 - if (!poolAppendChar(&parser->m_tempPool, *s)) 3303 + do { /* copies null terminator */ 3304 + if (! poolAppendChar(&parser->m_tempPool, *s)) 3440 3305 return XML_ERROR_NO_MEMORY; 3441 3306 } while (*s++); 3442 3307 3443 3308 uriHash = (unsigned long)sip24_final(&sip_state); 3444 3309 3445 3310 { /* Check hash table for duplicate of expanded name (uriName). 3446 3311 Derived from code in lookup(parser, HASH_TABLE *table, ...). 3447 3312 */ 3448 3313 unsigned char step = 0; 3449 3314 unsigned long mask = nsAttsSize - 1; 3450 - j = uriHash & mask; /* index into hash table */ 3315 + j = uriHash & mask; /* index into hash table */ 3451 3316 while (parser->m_nsAtts[j].version == version) { 3452 3317 /* for speed we compare stored hash values first */ 3453 3318 if (uriHash == parser->m_nsAtts[j].hash) { 3454 3319 const XML_Char *s1 = poolStart(&parser->m_tempPool); 3455 3320 const XML_Char *s2 = parser->m_nsAtts[j].uriName; 3456 3321 /* s1 is null terminated, but not s2 */ 3457 - for (; *s1 == *s2 && *s1 != 0; s1++, s2++); 3322 + for (; *s1 == *s2 && *s1 != 0; s1++, s2++) 3323 + ; 3458 3324 if (*s1 == 0) 3459 3325 return XML_ERROR_DUPLICATE_ATTRIBUTE; 3460 3326 } 3461 - if (!step) 3327 + if (! step) 3462 3328 step = PROBE_STEP(uriHash, mask, parser->m_nsAttsPower); 3463 3329 j < step ? (j += nsAttsSize - step) : (j -= step); 3464 3330 } 3465 3331 } 3466 3332 3467 - if (parser->m_ns_triplets) { /* append namespace separator and prefix */ 3333 + if (parser->m_ns_triplets) { /* append namespace separator and prefix */ 3468 3334 parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator; 3469 3335 s = b->prefix->name; 3470 3336 do { 3471 - if (!poolAppendChar(&parser->m_tempPool, *s)) 3337 + if (! poolAppendChar(&parser->m_tempPool, *s)) 3472 3338 return XML_ERROR_NO_MEMORY; 3473 3339 } while (*s++); 3474 3340 } 3475 3341 3476 3342 /* store expanded name in attribute list */ 3477 3343 s = poolStart(&parser->m_tempPool); 3478 3344 poolFinish(&parser->m_tempPool); ................................................................................ 3479 3345 appAtts[i] = s; 3480 3346 3481 3347 /* fill empty slot with new version, uriName and hash value */ 3482 3348 parser->m_nsAtts[j].version = version; 3483 3349 parser->m_nsAtts[j].hash = uriHash; 3484 3350 parser->m_nsAtts[j].uriName = s; 3485 3351 3486 - if (!--nPrefixes) { 3352 + if (! --nPrefixes) { 3487 3353 i += 2; 3488 3354 break; 3489 3355 } 3490 - } 3491 - else /* not prefixed */ 3492 - ((XML_Char *)s)[-1] = 0; /* clear flag */ 3356 + } else /* not prefixed */ 3357 + ((XML_Char *)s)[-1] = 0; /* clear flag */ 3493 3358 } 3494 3359 } 3495 3360 /* clear flags for the remaining attributes */ 3496 3361 for (; i < attIndex; i += 2) 3497 3362 ((XML_Char *)(appAtts[i]))[-1] = 0; 3498 3363 for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) 3499 3364 binding->attId->name[-1] = 0; 3500 3365 3501 - if (!parser->m_ns) 3366 + if (! parser->m_ns) 3502 3367 return XML_ERROR_NONE; 3503 3368 3504 3369 /* expand the element type name */ 3505 3370 if (elementType->prefix) { 3506 3371 binding = elementType->prefix->binding; 3507 - if (!binding) 3372 + if (! binding) 3508 3373 return XML_ERROR_UNBOUND_PREFIX; 3509 3374 localPart = tagNamePtr->str; 3510 3375 while (*localPart++ != XML_T(ASCII_COLON)) 3511 3376 ; 3512 - } 3513 - else if (dtd->defaultPrefix.binding) { 3377 + } else if (dtd->defaultPrefix.binding) { 3514 3378 binding = dtd->defaultPrefix.binding; 3515 3379 localPart = tagNamePtr->str; 3516 - } 3517 - else 3380 + } else 3518 3381 return XML_ERROR_NONE; 3519 3382 prefixLen = 0; 3520 3383 if (parser->m_ns_triplets && binding->prefix->name) { 3521 3384 for (; binding->prefix->name[prefixLen++];) 3522 - ; /* prefixLen includes null terminator */ 3385 + ; /* prefixLen includes null terminator */ 3523 3386 } 3524 3387 tagNamePtr->localPart = localPart; 3525 3388 tagNamePtr->uriLen = binding->uriLen; 3526 3389 tagNamePtr->prefix = binding->prefix->name; 3527 3390 tagNamePtr->prefixLen = prefixLen; 3528 3391 for (i = 0; localPart[i++];) 3529 - ; /* i includes null terminator */ 3392 + ; /* i includes null terminator */ 3530 3393 n = i + binding->uriLen + prefixLen; 3531 3394 if (n > binding->uriAlloc) { 3532 3395 TAG *p; 3533 3396 uri = (XML_Char *)MALLOC(parser, (n + EXPAND_SPARE) * sizeof(XML_Char)); 3534 - if (!uri) 3397 + if (! uri) 3535 3398 return XML_ERROR_NO_MEMORY; 3536 3399 binding->uriAlloc = n + EXPAND_SPARE; 3537 3400 memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); 3538 3401 for (p = parser->m_tagStack; p; p = p->parent) 3539 3402 if (p->name.str == binding->uri) 3540 3403 p->name.str = uri; 3541 3404 FREE(parser, binding->uri); ................................................................................ 3543 3406 } 3544 3407 /* if m_namespaceSeparator != '\0' then uri includes it already */ 3545 3408 uri = binding->uri + binding->uriLen; 3546 3409 memcpy(uri, localPart, i * sizeof(XML_Char)); 3547 3410 /* we always have a namespace separator between localPart and prefix */ 3548 3411 if (prefixLen) { 3549 3412 uri += i - 1; 3550 - *uri = parser->m_namespaceSeparator; /* replace null terminator */ 3413 + *uri = parser->m_namespaceSeparator; /* replace null terminator */ 3551 3414 memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); 3552 3415 } 3553 3416 tagNamePtr->str = binding->uri; 3554 3417 return XML_ERROR_NONE; 3555 3418 } 3556 3419 3557 3420 /* addBinding() overwrites the value of prefix->binding without checking. 3558 3421 Therefore one must keep track of the old value outside of addBinding(). 3559 3422 */ 3560 3423 static enum XML_Error 3561 3424 addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, 3562 - const XML_Char *uri, BINDING **bindingsPtr) 3563 -{ 3564 - static const XML_Char xmlNamespace[] = { 3565 - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, 3566 - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, 3567 - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, 3568 - ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH, 3569 - ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, 3570 - ASCII_e, '\0' 3571 - }; 3572 - static const int xmlLen = 3573 - (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; 3574 - static const XML_Char xmlnsNamespace[] = { 3575 - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, 3576 - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, 3577 - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, 3578 - ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, 3579 - ASCII_SLASH, '\0' 3580 - }; 3581 - static const int xmlnsLen = 3582 - (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; 3425 + const XML_Char *uri, BINDING **bindingsPtr) { 3426 + static const XML_Char xmlNamespace[] 3427 + = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, 3428 + ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, 3429 + ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, 3430 + ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, 3431 + ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, 3432 + ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, 3433 + ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, 3434 + ASCII_e, '\0'}; 3435 + static const int xmlLen = (int)sizeof(xmlNamespace) / sizeof(XML_Char) - 1; 3436 + static const XML_Char xmlnsNamespace[] 3437 + = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, 3438 + ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, 3439 + ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, 3440 + ASCII_2, ASCII_0, ASCII_0, ASCII_0, ASCII_SLASH, ASCII_x, 3441 + ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'}; 3442 + static const int xmlnsLen 3443 + = (int)sizeof(xmlnsNamespace) / sizeof(XML_Char) - 1; 3583 3444 3584 3445 XML_Bool mustBeXML = XML_FALSE; 3585 3446 XML_Bool isXML = XML_TRUE; 3586 3447 XML_Bool isXMLNS = XML_TRUE; 3587 3448 3588 3449 BINDING *b; 3589 3450 int len; 3590 3451 3591 3452 /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */ 3592 3453 if (*uri == XML_T('\0') && prefix->name) 3593 3454 return XML_ERROR_UNDECLARING_PREFIX; 3594 3455 3595 - if (prefix->name 3596 - && prefix->name[0] == XML_T(ASCII_x) 3456 + if (prefix->name && prefix->name[0] == XML_T(ASCII_x) 3597 3457 && prefix->name[1] == XML_T(ASCII_m) 3598 3458 && prefix->name[2] == XML_T(ASCII_l)) { 3599 - 3600 3459 /* Not allowed to bind xmlns */ 3601 - if (prefix->name[3] == XML_T(ASCII_n) 3602 - && prefix->name[4] == XML_T(ASCII_s) 3460 + if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s) 3603 3461 && prefix->name[5] == XML_T('\0')) 3604 3462 return XML_ERROR_RESERVED_PREFIX_XMLNS; 3605 3463 3606 3464 if (prefix->name[3] == XML_T('\0')) 3607 3465 mustBeXML = XML_TRUE; 3608 3466 } 3609 3467 3610 3468 for (len = 0; uri[len]; len++) { 3611 3469 if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) 3612 3470 isXML = XML_FALSE; 3613 3471 3614 - if (!mustBeXML && isXMLNS 3472 + if (! mustBeXML && isXMLNS 3615 3473 && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) 3616 3474 isXMLNS = XML_FALSE; 3617 3475 } 3618 3476 isXML = isXML && len == xmlLen; 3619 3477 isXMLNS = isXMLNS && len == xmlnsLen; 3620 3478 3621 3479 if (mustBeXML != isXML) ................................................................................ 3626 3484 return XML_ERROR_RESERVED_NAMESPACE_URI; 3627 3485 3628 3486 if (parser->m_namespaceSeparator) 3629 3487 len++; 3630 3488 if (parser->m_freeBindingList) { 3631 3489 b = parser->m_freeBindingList; 3632 3490 if (len > b->uriAlloc) { 3633 - XML_Char *temp = (XML_Char *)REALLOC(parser, b->uri, 3634 - sizeof(XML_Char) * (len + EXPAND_SPARE)); 3491 + XML_Char *temp = (XML_Char *)REALLOC( 3492 + parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE)); 3635 3493 if (temp == NULL) 3636 3494 return XML_ERROR_NO_MEMORY; 3637 3495 b->uri = temp; 3638 3496 b->uriAlloc = len + EXPAND_SPARE; 3639 3497 } 3640 3498 parser->m_freeBindingList = b->nextTagBinding; 3641 - } 3642 - else { 3499 + } else { 3643 3500 b = (BINDING *)MALLOC(parser, sizeof(BINDING)); 3644 - if (!b) 3501 + if (! b) 3645 3502 return XML_ERROR_NO_MEMORY; 3646 - b->uri = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE)); 3647 - if (!b->uri) { 3503 + b->uri 3504 + = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE)); 3505 + if (! b->uri) { 3648 3506 FREE(parser, b); 3649 3507 return XML_ERROR_NO_MEMORY; 3650 3508 } 3651 3509 b->uriAlloc = len + EXPAND_SPARE; 3652 3510 } 3653 3511 b->uriLen = len; 3654 3512 memcpy(b->uri, uri, len * sizeof(XML_Char)); ................................................................................ 3663 3521 else 3664 3522 prefix->binding = b; 3665 3523 b->nextTagBinding = *bindingsPtr; 3666 3524 *bindingsPtr = b; 3667 3525 /* if attId == NULL then we are not starting a namespace scope */ 3668 3526 if (attId && parser->m_startNamespaceDeclHandler) 3669 3527 parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name, 3670 - prefix->binding ? uri : 0); 3528 + prefix->binding ? uri : 0); 3671 3529 return XML_ERROR_NONE; 3672 3530 } 3673 3531 3674 3532 /* The idea here is to avoid using stack for each CDATA section when 3675 3533 the whole file is parsed with one call. 3676 3534 */ 3677 3535 static enum XML_Error PTRCALL 3678 -cdataSectionProcessor(XML_Parser parser, 3679 - const char *start, 3680 - const char *end, 3681 - const char **endPtr) 3682 -{ 3683 - enum XML_Error result = doCdataSection(parser, parser->m_encoding, &start, end, 3684 - endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 3536 +cdataSectionProcessor(XML_Parser parser, const char *start, const char *end, 3537 + const char **endPtr) { 3538 + enum XML_Error result 3539 + = doCdataSection(parser, parser->m_encoding, &start, end, endPtr, 3540 + (XML_Bool)! parser->m_parsingStatus.finalBuffer); 3685 3541 if (result != XML_ERROR_NONE) 3686 3542 return result; 3687 3543 if (start) { 3688 - if (parser->m_parentParser) { /* we are parsing an external entity */ 3544 + if (parser->m_parentParser) { /* we are parsing an external entity */ 3689 3545 parser->m_processor = externalEntityContentProcessor; 3690 3546 return externalEntityContentProcessor(parser, start, end, endPtr); 3691 - } 3692 - else { 3547 + } else { 3693 3548 parser->m_processor = contentProcessor; 3694 3549 return contentProcessor(parser, start, end, endPtr); 3695 3550 } 3696 3551 } 3697 3552 return result; 3698 3553 } 3699 3554 3700 3555 /* startPtr gets set to non-null if the section is closed, and to null if 3701 3556 the section is not yet closed. 3702 3557 */ 3703 3558 static enum XML_Error 3704 -doCdataSection(XML_Parser parser, 3705 - const ENCODING *enc, 3706 - const char **startPtr, 3707 - const char *end, 3708 - const char **nextPtr, 3709 - XML_Bool haveMore) 3710 -{ 3559 +doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, 3560 + const char *end, const char **nextPtr, XML_Bool haveMore) { 3711 3561 const char *s = *startPtr; 3712 3562 const char **eventPP; 3713 3563 const char **eventEndPP; 3714 3564 if (enc == parser->m_encoding) { 3715 3565 eventPP = &parser->m_eventPtr; 3716 3566 *eventPP = s; 3717 3567 eventEndPP = &parser->m_eventEndPtr; 3718 - } 3719 - else { 3568 + } else { 3720 3569 eventPP = &(parser->m_openInternalEntities->internalEventPtr); 3721 3570 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); 3722 3571 } 3723 3572 *eventPP = s; 3724 3573 *startPtr = NULL; 3725 3574 3726 3575 for (;;) { ................................................................................ 3727 3576 const char *next; 3728 3577 int tok = XmlCdataSectionTok(enc, s, end, &next); 3729 3578 *eventEndPP = next; 3730 3579 switch (tok) { 3731 3580 case XML_TOK_CDATA_SECT_CLOSE: 3732 3581 if (parser->m_endCdataSectionHandler) 3733 3582 parser->m_endCdataSectionHandler(parser->m_handlerArg); 3734 -#if 0 3583 + /* BEGIN disabled code */ 3735 3584 /* see comment under XML_TOK_CDATA_SECT_OPEN */ 3736 - else if (parser->m_characterDataHandler) 3737 - parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 0); 3738 -#endif 3585 + else if (0 && parser->m_characterDataHandler) 3586 + parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 3587 + 0); 3588 + /* END disabled code */ 3739 3589 else if (parser->m_defaultHandler) 3740 3590 reportDefault(parser, enc, s, next); 3741 3591 *startPtr = next; 3742 3592 *nextPtr = next; 3743 3593 if (parser->m_parsingStatus.parsing == XML_FINISHED) 3744 3594 return XML_ERROR_ABORTED; 3745 3595 else 3746 3596 return XML_ERROR_NONE; 3747 3597 case XML_TOK_DATA_NEWLINE: 3748 3598 if (parser->m_characterDataHandler) { 3749 3599 XML_Char c = 0xA; 3750 3600 parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); 3751 - } 3752 - else if (parser->m_defaultHandler) 3601 + } else if (parser->m_defaultHandler) 3602 + reportDefault(parser, enc, s, next); 3603 + break; 3604 + case XML_TOK_DATA_CHARS: { 3605 + XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; 3606 + if (charDataHandler) { 3607 + if (MUST_CONVERT(enc, s)) { 3608 + for (;;) { 3609 + ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; 3610 + const enum XML_Convert_Result convert_res = XmlConvert( 3611 + enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 3612 + *eventEndPP = next; 3613 + charDataHandler(parser->m_handlerArg, parser->m_dataBuf, 3614 + (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 3615 + if ((convert_res == XML_CONVERT_COMPLETED) 3616 + || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) 3617 + break; 3618 + *eventPP = s; 3619 + } 3620 + } else 3621 + charDataHandler(parser->m_handlerArg, (XML_Char *)s, 3622 + (int)((XML_Char *)next - (XML_Char *)s)); 3623 + } else if (parser->m_defaultHandler) 3753 3624 reportDefault(parser, enc, s, next); 3754 - break; 3755 - case XML_TOK_DATA_CHARS: 3756 - { 3757 - XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; 3758 - if (charDataHandler) { 3759 - if (MUST_CONVERT(enc, s)) { 3760 - for (;;) { 3761 - ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; 3762 - const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 3763 - *eventEndPP = next; 3764 - charDataHandler(parser->m_handlerArg, parser->m_dataBuf, 3765 - (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 3766 - if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) 3767 - break; 3768 - *eventPP = s; 3769 - } 3770 - } 3771 - else 3772 - charDataHandler(parser->m_handlerArg, 3773 - (XML_Char *)s, 3774 - (int)((XML_Char *)next - (XML_Char *)s)); 3775 - } 3776 - else if (parser->m_defaultHandler) 3777 - reportDefault(parser, enc, s, next); 3778 - } 3779 - break; 3625 + } break; 3780 3626 case XML_TOK_INVALID: 3781 3627 *eventPP = next; 3782 3628 return XML_ERROR_INVALID_TOKEN; 3783 3629 case XML_TOK_PARTIAL_CHAR: 3784 3630 if (haveMore) { 3785 3631 *nextPtr = s; 3786 3632 return XML_ERROR_NONE; ................................................................................ 3796 3642 default: 3797 3643 /* Every token returned by XmlCdataSectionTok() has its own 3798 3644 * explicit case, so this default case will never be executed. 3799 3645 * We retain it as a safety net and exclude it from the coverage 3800 3646 * statistics. 3801 3647 * 3802 3648 * LCOV_EXCL_START 3803 - */ 3649 + */ 3804 3650 *eventPP = next; 3805 3651 return XML_ERROR_UNEXPECTED_STATE; 3806 3652 /* LCOV_EXCL_STOP */ 3807 3653 } 3808 3654 3809 3655 *eventPP = s = next; 3810 3656 switch (parser->m_parsingStatus.parsing) { 3811 3657 case XML_SUSPENDED: 3812 3658 *nextPtr = next; 3813 3659 return XML_ERROR_NONE; 3814 3660 case XML_FINISHED: 3815 3661 return XML_ERROR_ABORTED; 3816 - default: ; 3662 + default:; 3817 3663 } 3818 3664 } 3819 3665 /* not reached */ 3820 3666 } 3821 3667 3822 3668 #ifdef XML_DTD 3823 3669 3824 3670 /* The idea here is to avoid using stack for each IGNORE section when 3825 3671 the whole file is parsed with one call. 3826 3672 */ 3827 3673 static enum XML_Error PTRCALL 3828 -ignoreSectionProcessor(XML_Parser parser, 3829 - const char *start, 3830 - const char *end, 3831 - const char **endPtr) 3832 -{ 3833 - enum XML_Error result = doIgnoreSection(parser, parser->m_encoding, &start, end, 3834 - endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 3674 +ignoreSectionProcessor(XML_Parser parser, const char *start, const char *end, 3675 + const char **endPtr) { 3676 + enum XML_Error result 3677 + = doIgnoreSection(parser, parser->m_encoding, &start, end, endPtr, 3678 + (XML_Bool)! parser->m_parsingStatus.finalBuffer); 3835 3679 if (result != XML_ERROR_NONE) 3836 3680 return result; 3837 3681 if (start) { 3838 3682 parser->m_processor = prologProcessor; 3839 3683 return prologProcessor(parser, start, end, endPtr); 3840 3684 } 3841 3685 return result; 3842 3686 } 3843 3687 3844 3688 /* startPtr gets set to non-null is the section is closed, and to null 3845 3689 if the section is not yet closed. 3846 3690 */ 3847 3691 static enum XML_Error 3848 -doIgnoreSection(XML_Parser parser, 3849 - const ENCODING *enc, 3850 - const char **startPtr, 3851 - const char *end, 3852 - const char **nextPtr, 3853 - XML_Bool haveMore) 3854 -{ 3692 +doIgnoreSection(XML_Parser parser, const ENCODING *enc, const char **startPtr, 3693 + const char *end, const char **nextPtr, XML_Bool haveMore) { 3855 3694 const char *next; 3856 3695 int tok; 3857 3696 const char *s = *startPtr; 3858 3697 const char **eventPP; 3859 3698 const char **eventEndPP; 3860 3699 if (enc == parser->m_encoding) { 3861 3700 eventPP = &parser->m_eventPtr; 3862 3701 *eventPP = s; 3863 3702 eventEndPP = &parser->m_eventEndPtr; 3864 - } 3865 - else { 3703 + } else { 3866 3704 /* It's not entirely clear, but it seems the following two lines 3867 3705 * of code cannot be executed. The only occasions on which 'enc' 3868 3706 * is not 'encoding' are when this function is called 3869 3707 * from the internal entity processing, and IGNORE sections are an 3870 3708 * error in internal entities. 3871 3709 * 3872 3710 * Since it really isn't clear that this is true, we keep the code ................................................................................ 3922 3760 } 3923 3761 /* not reached */ 3924 3762 } 3925 3763 3926 3764 #endif /* XML_DTD */ 3927 3765 3928 3766 static enum XML_Error 3929 -initializeEncoding(XML_Parser parser) 3930 -{ 3767 +initializeEncoding(XML_Parser parser) { 3931 3768 const char *s; 3932 3769 #ifdef XML_UNICODE 3933 3770 char encodingBuf[128]; 3934 3771 /* See comments abount `protoclEncodingName` in parserInit() */ 3935 - if (!parser->m_protocolEncodingName) 3772 + if (! parser->m_protocolEncodingName) 3936 3773 s = NULL; 3937 3774 else { 3938 3775 int i; 3939 3776 for (i = 0; parser->m_protocolEncodingName[i]; i++) { 3940 3777 if (i == sizeof(encodingBuf) - 1 3941 3778 || (parser->m_protocolEncodingName[i] & ~0x7f) != 0) { 3942 3779 encodingBuf[0] = '\0'; ................................................................................ 3946 3783 } 3947 3784 encodingBuf[i] = '\0'; 3948 3785 s = encodingBuf; 3949 3786 } 3950 3787 #else 3951 3788 s = parser->m_protocolEncodingName; 3952 3789 #endif 3953 - if ((parser->m_ns ? XmlInitEncodingNS : XmlInitEncoding)(&parser->m_initEncoding, &parser->m_encoding, s)) 3790 + if ((parser->m_ns ? XmlInitEncodingNS : XmlInitEncoding)( 3791 + &parser->m_initEncoding, &parser->m_encoding, s)) 3954 3792 return XML_ERROR_NONE; 3955 3793 return handleUnknownEncoding(parser, parser->m_protocolEncodingName); 3956 3794 } 3957 3795 3958 3796 static enum XML_Error 3959 -processXmlDecl(XML_Parser parser, int isGeneralTextEntity, 3960 - const char *s, const char *next) 3961 -{ 3797 +processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *s, 3798 + const char *next) { 3962 3799 const char *encodingName = NULL; 3963 3800 const XML_Char *storedEncName = NULL; 3964 3801 const ENCODING *newEncoding = NULL; 3965 3802 const char *version = NULL; 3966 3803 const char *versionend; 3967 3804 const XML_Char *storedversion = NULL; 3968 3805 int standalone = -1; 3969 - if (!(parser->m_ns 3970 - ? XmlParseXmlDeclNS 3971 - : XmlParseXmlDecl)(isGeneralTextEntity, 3972 - parser->m_encoding, 3973 - s, 3974 - next, 3975 - &parser->m_eventPtr, 3976 - &version, 3977 - &versionend, 3978 - &encodingName, 3979 - &newEncoding, 3980 - &standalone)) { 3806 + if (! (parser->m_ns ? XmlParseXmlDeclNS : XmlParseXmlDecl)( 3807 + isGeneralTextEntity, parser->m_encoding, s, next, &parser->m_eventPtr, 3808 + &version, &versionend, &encodingName, &newEncoding, &standalone)) { 3981 3809 if (isGeneralTextEntity) 3982 3810 return XML_ERROR_TEXT_DECL; 3983 3811 else 3984 3812 return XML_ERROR_XML_DECL; 3985 3813 } 3986 - if (!isGeneralTextEntity && standalone == 1) { 3814 + if (! isGeneralTextEntity && standalone == 1) { 3987 3815 parser->m_dtd->standalone = XML_TRUE; 3988 3816 #ifdef XML_DTD 3989 - if (parser->m_paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) 3817 + if (parser->m_paramEntityParsing 3818 + == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) 3990 3819 parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; 3991 3820 #endif /* XML_DTD */ 3992 3821 } 3993 3822 if (parser->m_xmlDeclHandler) { 3994 3823 if (encodingName != NULL) { 3995 - storedEncName = poolStoreString(&parser->m_temp2Pool, 3996 - parser->m_encoding, 3997 - encodingName, 3998 - encodingName 3999 - + XmlNameLength(parser->m_encoding, encodingName)); 4000 - if (!storedEncName) 4001 - return XML_ERROR_NO_MEMORY; 3824 + storedEncName = poolStoreString( 3825 + &parser->m_temp2Pool, parser->m_encoding, encodingName, 3826 + encodingName + XmlNameLength(parser->m_encoding, encodingName)); 3827 + if (! storedEncName) 3828 + return XML_ERROR_NO_MEMORY; 4002 3829 poolFinish(&parser->m_temp2Pool); 4003 3830 } 4004 3831 if (version) { 4005 - storedversion = poolStoreString(&parser->m_temp2Pool, 4006 - parser->m_encoding, 4007 - version, 4008 - versionend - parser->m_encoding->minBytesPerChar); 4009 - if (!storedversion) 3832 + storedversion 3833 + = poolStoreString(&parser->m_temp2Pool, parser->m_encoding, version, 3834 + versionend - parser->m_encoding->minBytesPerChar); 3835 + if (! storedversion) 4010 3836 return XML_ERROR_NO_MEMORY; 4011 3837 } 4012 - parser->m_xmlDeclHandler(parser->m_handlerArg, storedversion, storedEncName, standalone); 4013 - } 4014 - else if (parser->m_defaultHandler) 3838 + parser->m_xmlDeclHandler(parser->m_handlerArg, storedversion, storedEncName, 3839 + standalone); 3840 + } else if (parser->m_defaultHandler) 4015 3841 reportDefault(parser, parser->m_encoding, s, next); 4016 3842 if (parser->m_protocolEncodingName == NULL) { 4017 3843 if (newEncoding) { 4018 3844 /* Check that the specified encoding does not conflict with what 4019 3845 * the parser has already deduced. Do we have the same number 4020 3846 * of bytes in the smallest representation of a character? If 4021 3847 * this is UTF-16, is it the same endianness? 4022 3848 */ 4023 3849 if (newEncoding->minBytesPerChar != parser->m_encoding->minBytesPerChar 4024 - || (newEncoding->minBytesPerChar == 2 && 4025 - newEncoding != parser->m_encoding)) { 3850 + || (newEncoding->minBytesPerChar == 2 3851 + && newEncoding != parser->m_encoding)) { 4026 3852 parser->m_eventPtr = encodingName; 4027 3853 return XML_ERROR_INCORRECT_ENCODING; 4028 3854 } 4029 3855 parser->m_encoding = newEncoding; 4030 - } 4031 - else if (encodingName) { 3856 + } else if (encodingName) { 4032 3857 enum XML_Error result; 4033 - if (!storedEncName) { 3858 + if (! storedEncName) { 4034 3859 storedEncName = poolStoreString( 4035 - &parser->m_temp2Pool, parser->m_encoding, encodingName, 4036 - encodingName + XmlNameLength(parser->m_encoding, encodingName)); 4037 - if (!storedEncName) 3860 + &parser->m_temp2Pool, parser->m_encoding, encodingName, 3861 + encodingName + XmlNameLength(parser->m_encoding, encodingName)); 3862 + if (! storedEncName) 4038 3863 return XML_ERROR_NO_MEMORY; 4039 3864 } 4040 3865 result = handleUnknownEncoding(parser, storedEncName); 4041 3866 poolClear(&parser->m_temp2Pool); 4042 3867 if (result == XML_ERROR_UNKNOWN_ENCODING) 4043 3868 parser->m_eventPtr = encodingName; 4044 3869 return result; ................................................................................ 4048 3873 if (storedEncName || storedversion) 4049 3874 poolClear(&parser->m_temp2Pool); 4050 3875 4051 3876 return XML_ERROR_NONE; 4052 3877 } 4053 3878 4054 3879 static enum XML_Error 4055 -handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) 4056 -{ 3880 +handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) { 4057 3881 if (parser->m_unknownEncodingHandler) { 4058 3882 XML_Encoding info; 4059 3883 int i; 4060 3884 for (i = 0; i < 256; i++) 4061 3885 info.map[i] = -1; 4062 3886 info.convert = NULL; 4063 3887 info.data = NULL; 4064 3888 info.release = NULL; 4065 - if (parser->m_unknownEncodingHandler(parser->m_unknownEncodingHandlerData, encodingName, 4066 - &info)) { 3889 + if (parser->m_unknownEncodingHandler(parser->m_unknownEncodingHandlerData, 3890 + encodingName, &info)) { 4067 3891 ENCODING *enc; 4068 3892 parser->m_unknownEncodingMem = MALLOC(parser, XmlSizeOfUnknownEncoding()); 4069 - if (!parser->m_unknownEncodingMem) { 3893 + if (! parser->m_unknownEncodingMem) { 4070 3894 if (info.release) 4071 3895 info.release(info.data); 4072 3896 return XML_ERROR_NO_MEMORY; 4073 3897 } 4074 - enc = (parser->m_ns 4075 - ? XmlInitUnknownEncodingNS 4076 - : XmlInitUnknownEncoding)(parser->m_unknownEncodingMem, 4077 - info.map, 4078 - info.convert, 4079 - info.data); 3898 + enc = (parser->m_ns ? XmlInitUnknownEncodingNS : XmlInitUnknownEncoding)( 3899 + parser->m_unknownEncodingMem, info.map, info.convert, info.data); 4080 3900 if (enc) { 4081 3901 parser->m_unknownEncodingData = info.data; 4082 3902 parser->m_unknownEncodingRelease = info.release; 4083 3903 parser->m_encoding = enc; 4084 3904 return XML_ERROR_NONE; 4085 3905 } 4086 3906 } ................................................................................ 4087 3907 if (info.release != NULL) 4088 3908 info.release(info.data); 4089 3909 } 4090 3910 return XML_ERROR_UNKNOWN_ENCODING; 4091 3911 } 4092 3912 4093 3913 static enum XML_Error PTRCALL 4094 -prologInitProcessor(XML_Parser parser, 4095 - const char *s, 4096 - const char *end, 4097 - const char **nextPtr) 4098 -{ 3914 +prologInitProcessor(XML_Parser parser, const char *s, const char *end, 3915 + const char **nextPtr) { 4099 3916 enum XML_Error result = initializeEncoding(parser); 4100 3917 if (result != XML_ERROR_NONE) 4101 3918 return result; 4102 3919 parser->m_processor = prologProcessor; 4103 3920 return prologProcessor(parser, s, end, nextPtr); 4104 3921 } 4105 3922 4106 3923 #ifdef XML_DTD 4107 3924 4108 3925 static enum XML_Error PTRCALL 4109 -externalParEntInitProcessor(XML_Parser parser, 4110 - const char *s, 4111 - const char *end, 4112 - const char **nextPtr) 4113 -{ 3926 +externalParEntInitProcessor(XML_Parser parser, const char *s, const char *end, 3927 + const char **nextPtr) { 4114 3928 enum XML_Error result = initializeEncoding(parser); 4115 3929 if (result != XML_ERROR_NONE) 4116 3930 return result; 4117 3931 4118 3932 /* we know now that XML_Parse(Buffer) has been called, 4119 3933 so we consider the external parameter entity read */ 4120 3934 parser->m_dtd->paramEntityRead = XML_TRUE; 4121 3935 4122 3936 if (parser->m_prologState.inEntityValue) { 4123 3937 parser->m_processor = entityValueInitProcessor; 4124 3938 return entityValueInitProcessor(parser, s, end, nextPtr); 4125 - } 4126 - else { 3939 + } else { 4127 3940 parser->m_processor = externalParEntProcessor; 4128 3941 return externalParEntProcessor(parser, s, end, nextPtr); 4129 3942 } 4130 3943 } 4131 3944 4132 3945 static enum XML_Error PTRCALL 4133 -entityValueInitProcessor(XML_Parser parser, 4134 - const char *s, 4135 - const char *end, 4136 - const char **nextPtr) 4137 -{ 3946 +entityValueInitProcessor(XML_Parser parser, const char *s, const char *end, 3947 + const char **nextPtr) { 4138 3948 int tok; 4139 3949 const char *start = s; 4140 3950 const char *next = start; 4141 3951 parser->m_eventPtr = start; 4142 3952 4143 3953 for (;;) { 4144 3954 tok = XmlPrologTok(parser->m_encoding, start, end, &next); 4145 3955 parser->m_eventEndPtr = next; 4146 3956 if (tok <= 0) { 4147 - if (!parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { 3957 + if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { 4148 3958 *nextPtr = s; 4149 3959 return XML_ERROR_NONE; 4150 3960 } 4151 3961 switch (tok) { 4152 3962 case XML_TOK_INVALID: 4153 3963 return XML_ERROR_INVALID_TOKEN; 4154 3964 case XML_TOK_PARTIAL: 4155 3965 return XML_ERROR_UNCLOSED_TOKEN; 4156 3966 case XML_TOK_PARTIAL_CHAR: 4157 3967 return XML_ERROR_PARTIAL_CHAR; 4158 - case XML_TOK_NONE: /* start == end */ 3968 + case XML_TOK_NONE: /* start == end */ 4159 3969 default: 4160 3970 break; 4161 3971 } 4162 3972 /* found end of entity value - can store it now */ 4163 3973 return storeEntityValue(parser, parser->m_encoding, s, end); 4164 - } 4165 - else if (tok == XML_TOK_XML_DECL) { 3974 + } else if (tok == XML_TOK_XML_DECL) { 4166 3975 enum XML_Error result; 4167 3976 result = processXmlDecl(parser, 0, start, next); 4168 3977 if (result != XML_ERROR_NONE) 4169 3978 return result; 4170 - /* At this point, m_parsingStatus.parsing cannot be XML_SUSPENDED. For that 4171 - * to happen, a parameter entity parsing handler must have 4172 - * attempted to suspend the parser, which fails and raises an 4173 - * error. The parser can be aborted, but can't be suspended. 3979 + /* At this point, m_parsingStatus.parsing cannot be XML_SUSPENDED. For 3980 + * that to happen, a parameter entity parsing handler must have attempted 3981 + * to suspend the parser, which fails and raises an error. The parser can 3982 + * be aborted, but can't be suspended. 4174 3983 */ 4175 3984 if (parser->m_parsingStatus.parsing == XML_FINISHED) 4176 3985 return XML_ERROR_ABORTED; 4177 3986 *nextPtr = next; 4178 3987 /* stop scanning for text declaration - we found one */ 4179 3988 parser->m_processor = entityValueProcessor; 4180 3989 return entityValueProcessor(parser, next, end, nextPtr); ................................................................................ 4182 3991 /* If we are at the end of the buffer, this would cause XmlPrologTok to 4183 3992 return XML_TOK_NONE on the next call, which would then cause the 4184 3993 function to exit with *nextPtr set to s - that is what we want for other 4185 3994 tokens, but not for the BOM - we would rather like to skip it; 4186 3995 then, when this routine is entered the next time, XmlPrologTok will 4187 3996 return XML_TOK_INVALID, since the BOM is still in the buffer 4188 3997 */ 4189 - else if (tok == XML_TOK_BOM && next == end && !parser->m_parsingStatus.finalBuffer) { 3998 + else if (tok == XML_TOK_BOM && next == end 3999 + && ! parser->m_parsingStatus.finalBuffer) { 4190 4000 *nextPtr = next; 4191 4001 return XML_ERROR_NONE; 4192 4002 } 4193 4003 /* If we get this token, we have the start of what might be a 4194 4004 normal tag, but not a declaration (i.e. it doesn't begin with 4195 4005 "<!"). In a DTD context, that isn't legal. 4196 4006 */ ................................................................................ 4200 4010 } 4201 4011 start = next; 4202 4012 parser->m_eventPtr = start; 4203 4013 } 4204 4014 } 4205 4015 4206 4016 static enum XML_Error PTRCALL 4207 -externalParEntProcessor(XML_Parser parser, 4208 - const char *s, 4209 - const char *end, 4210 - const char **nextPtr) 4211 -{ 4017 +externalParEntProcessor(XML_Parser parser, const char *s, const char *end, 4018 + const char **nextPtr) { 4212 4019 const char *next = s; 4213 4020 int tok; 4214 4021 4215 4022 tok = XmlPrologTok(parser->m_encoding, s, end, &next); 4216 4023 if (tok <= 0) { 4217 - if (!parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { 4024 + if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { 4218 4025 *nextPtr = s; 4219 4026 return XML_ERROR_NONE; 4220 4027 } 4221 4028 switch (tok) { 4222 4029 case XML_TOK_INVALID: 4223 4030 return XML_ERROR_INVALID_TOKEN; 4224 4031 case XML_TOK_PARTIAL: 4225 4032 return XML_ERROR_UNCLOSED_TOKEN; 4226 4033 case XML_TOK_PARTIAL_CHAR: 4227 4034 return XML_ERROR_PARTIAL_CHAR; 4228 - case XML_TOK_NONE: /* start == end */ 4035 + case XML_TOK_NONE: /* start == end */ 4229 4036 default: 4230 4037 break; 4231 4038 } 4232 4039 } 4233 4040 /* This would cause the next stage, i.e. doProlog to be passed XML_TOK_BOM. 4234 4041 However, when parsing an external subset, doProlog will not accept a BOM 4235 4042 as valid, and report a syntax error, so we have to skip the BOM ................................................................................ 4236 4043 */ 4237 4044 else if (tok == XML_TOK_BOM) { 4238 4045 s = next; 4239 4046 tok = XmlPrologTok(parser->m_encoding, s, end, &next); 4240 4047 } 4241 4048 4242 4049 parser->m_processor = prologProcessor; 4243 - return doProlog(parser, parser->m_encoding, s, end, tok, next, 4244 - nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 4050 + return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, 4051 + (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE); 4245 4052 } 4246 4053 4247 4054 static enum XML_Error PTRCALL 4248 -entityValueProcessor(XML_Parser parser, 4249 - const char *s, 4250 - const char *end, 4251 - const char **nextPtr) 4252 -{ 4055 +entityValueProcessor(XML_Parser parser, const char *s, const char *end, 4056 + const char **nextPtr) { 4253 4057 const char *start = s; 4254 4058 const char *next = s; 4255 4059 const ENCODING *enc = parser->m_encoding; 4256 4060 int tok; 4257 4061 4258 4062 for (;;) { 4259 4063 tok = XmlPrologTok(enc, start, end, &next); 4260 4064 if (tok <= 0) { 4261 - if (!parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { 4065 + if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { 4262 4066 *nextPtr = s; 4263 4067 return XML_ERROR_NONE; 4264 4068 } 4265 4069 switch (tok) { 4266 4070 case XML_TOK_INVALID: 4267 4071 return XML_ERROR_INVALID_TOKEN; 4268 4072 case XML_TOK_PARTIAL: 4269 4073 return XML_ERROR_UNCLOSED_TOKEN; 4270 4074 case XML_TOK_PARTIAL_CHAR: 4271 4075 return XML_ERROR_PARTIAL_CHAR; 4272 - case XML_TOK_NONE: /* start == end */ 4076 + case XML_TOK_NONE: /* start == end */ 4273 4077 default: 4274 4078 break; 4275 4079 } 4276 4080 /* found end of entity value - can store it now */ 4277 4081 return storeEntityValue(parser, enc, s, end); 4278 4082 } 4279 4083 start = next; 4280 4084 } 4281 4085 } 4282 4086 4283 4087 #endif /* XML_DTD */ 4284 4088 4285 4089 static enum XML_Error PTRCALL 4286 -prologProcessor(XML_Parser parser, 4287 - const char *s, 4288 - const char *end, 4289 - const char **nextPtr) 4290 -{ 4090 +prologProcessor(XML_Parser parser, const char *s, const char *end, 4091 + const char **nextPtr) { 4291 4092 const char *next = s; 4292 4093 int tok = XmlPrologTok(parser->m_encoding, s, end, &next); 4293 - return doProlog(parser, parser->m_encoding, s, end, tok, next, 4294 - nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 4094 + return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, 4095 + (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE); 4295 4096 } 4296 4097 4297 4098 static enum XML_Error 4298 -doProlog(XML_Parser parser, 4299 - const ENCODING *enc, 4300 - const char *s, 4301 - const char *end, 4302 - int tok, 4303 - const char *next, 4304 - const char **nextPtr, 4305 - XML_Bool haveMore) 4306 -{ 4307 -#ifdef XML_DTD 4308 - static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' }; 4309 -#endif /* XML_DTD */ 4310 - static const XML_Char atypeCDATA[] = 4311 - { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; 4312 - static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' }; 4313 - static const XML_Char atypeIDREF[] = 4314 - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; 4315 - static const XML_Char atypeIDREFS[] = 4316 - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; 4317 - static const XML_Char atypeENTITY[] = 4318 - { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; 4319 - static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N, 4320 - ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; 4321 - static const XML_Char atypeNMTOKEN[] = { 4322 - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; 4323 - static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, 4324 - ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; 4325 - static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T, 4326 - ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' }; 4327 - static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' }; 4328 - static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; 4099 +doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, 4100 + int tok, const char *next, const char **nextPtr, XML_Bool haveMore, 4101 + XML_Bool allowClosingDoctype) { 4102 +#ifdef XML_DTD 4103 + static const XML_Char externalSubsetName[] = {ASCII_HASH, '\0'}; 4104 +#endif /* XML_DTD */ 4105 + static const XML_Char atypeCDATA[] 4106 + = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'}; 4107 + static const XML_Char atypeID[] = {ASCII_I, ASCII_D, '\0'}; 4108 + static const XML_Char atypeIDREF[] 4109 + = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0'}; 4110 + static const XML_Char atypeIDREFS[] 4111 + = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0'}; 4112 + static const XML_Char atypeENTITY[] 4113 + = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0'}; 4114 + static const XML_Char atypeENTITIES[] 4115 + = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, 4116 + ASCII_I, ASCII_E, ASCII_S, '\0'}; 4117 + static const XML_Char atypeNMTOKEN[] 4118 + = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0'}; 4119 + static const XML_Char atypeNMTOKENS[] 4120 + = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, 4121 + ASCII_E, ASCII_N, ASCII_S, '\0'}; 4122 + static const XML_Char notationPrefix[] 4123 + = {ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, 4124 + ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0'}; 4125 + static const XML_Char enumValueSep[] = {ASCII_PIPE, '\0'}; 4126 + static const XML_Char enumValueStart[] = {ASCII_LPAREN, '\0'}; 4329 4127 4330 4128 /* save one level of indirection */ 4331 - DTD * const dtd = parser->m_dtd; 4129 + DTD *const dtd = parser->m_dtd; 4332 4130 4333 4131 const char **eventPP; 4334 4132 const char **eventEndPP; 4335 4133 enum XML_Content_Quant quant; 4336 4134 4337 4135 if (enc == parser->m_encoding) { 4338 4136 eventPP = &parser->m_eventPtr; 4339 4137 eventEndPP = &parser->m_eventEndPtr; 4340 - } 4341 - else { 4138 + } else { 4342 4139 eventPP = &(parser->m_openInternalEntities->internalEventPtr); 4343 4140 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); 4344 4141 } 4345 4142 4346 4143 for (;;) { 4347 4144 int role; 4348 4145 XML_Bool handleDefault = XML_TRUE; ................................................................................ 4363 4160 return XML_ERROR_PARTIAL_CHAR; 4364 4161 case -XML_TOK_PROLOG_S: 4365 4162 tok = -tok; 4366 4163 break; 4367 4164 case XML_TOK_NONE: 4368 4165 #ifdef XML_DTD 4369 4166 /* for internal PE NOT referenced between declarations */ 4370 - if (enc != parser->m_encoding && !parser->m_openInternalEntities->betweenDecl) { 4167 + if (enc != parser->m_encoding 4168 + && ! parser->m_openInternalEntities->betweenDecl) { 4371 4169 *nextPtr = s; 4372 4170 return XML_ERROR_NONE; 4373 4171 } 4374 4172 /* WFC: PE Between Declarations - must check that PE contains 4375 4173 complete markup, not only for external PEs, but also for 4376 4174 internal PEs if the reference occurs between declarations. 4377 4175 */ ................................................................................ 4388 4186 tok = -tok; 4389 4187 next = end; 4390 4188 break; 4391 4189 } 4392 4190 } 4393 4191 role = XmlTokenRole(&parser->m_prologState, tok, s, next, enc); 4394 4192 switch (role) { 4395 - case XML_ROLE_XML_DECL: 4396 - { 4397 - enum XML_Error result = processXmlDecl(parser, 0, s, next); 4398 - if (result != XML_ERROR_NONE) 4399 - return result; 4400 - enc = parser->m_encoding; 4401 - handleDefault = XML_FALSE; 4402 - } 4403 - break; 4193 + case XML_ROLE_XML_DECL: { 4194 + enum XML_Error result = processXmlDecl(parser, 0, s, next); 4195 + if (result != XML_ERROR_NONE) 4196 + return result; 4197 + enc = parser->m_encoding; 4198 + handleDefault = XML_FALSE; 4199 + } break; 4404 4200 case XML_ROLE_DOCTYPE_NAME: 4405 4201 if (parser->m_startDoctypeDeclHandler) { 4406 - parser->m_doctypeName = poolStoreString(&parser->m_tempPool, enc, s, next); 4407 - if (!parser->m_doctypeName) 4202 + parser->m_doctypeName 4203 + = poolStoreString(&parser->m_tempPool, enc, s, next); 4204 + if (! parser->m_doctypeName) 4408 4205 return XML_ERROR_NO_MEMORY; 4409 4206 poolFinish(&parser->m_tempPool); 4410 4207 parser->m_doctypePubid = NULL; 4411 4208 handleDefault = XML_FALSE; 4412 4209 } 4413 4210 parser->m_doctypeSysid = NULL; /* always initialize to NULL */ 4414 4211 break; 4415 4212 case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: 4416 4213 if (parser->m_startDoctypeDeclHandler) { 4417 - parser->m_startDoctypeDeclHandler(parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid, 4418 - parser->m_doctypePubid, 1); 4214 + parser->m_startDoctypeDeclHandler( 4215 + parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid, 4216 + parser->m_doctypePubid, 1); 4419 4217 parser->m_doctypeName = NULL; 4420 4218 poolClear(&parser->m_tempPool); 4421 4219 handleDefault = XML_FALSE; 4422 4220 } 4423 4221 break; 4424 4222 #ifdef XML_DTD 4425 - case XML_ROLE_TEXT_DECL: 4426 - { 4427 - enum XML_Error result = processXmlDecl(parser, 1, s, next); 4428 - if (result != XML_ERROR_NONE) 4429 - return result; 4430 - enc = parser->m_encoding; 4431 - handleDefault = XML_FALSE; 4432 - } 4433 - break; 4223 + case XML_ROLE_TEXT_DECL: { 4224 + enum XML_Error result = processXmlDecl(parser, 1, s, next); 4225 + if (result != XML_ERROR_NONE) 4226 + return result; 4227 + enc = parser->m_encoding; 4228 + handleDefault = XML_FALSE; 4229 + } break; 4434 4230 #endif /* XML_DTD */ 4435 4231 case XML_ROLE_DOCTYPE_PUBLIC_ID: 4436 4232 #ifdef XML_DTD 4437 4233 parser->m_useForeignDTD = XML_FALSE; 4438 - parser->m_declEntity = (ENTITY *)lookup(parser, 4439 - &dtd->paramEntities, 4440 - externalSubsetName, 4441 - sizeof(ENTITY)); 4442 - if (!parser->m_declEntity) 4234 + parser->m_declEntity = (ENTITY *)lookup( 4235 + parser, &dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); 4236 + if (! parser->m_declEntity) 4443 4237 return XML_ERROR_NO_MEMORY; 4444 4238 #endif /* XML_DTD */ 4445 4239 dtd->hasParamEntityRefs = XML_TRUE; 4446 4240 if (parser->m_startDoctypeDeclHandler) { 4447 4241 XML_Char *pubId; 4448 - if (!XmlIsPublicId(enc, s, next, eventPP)) 4242 + if (! XmlIsPublicId(enc, s, next, eventPP)) 4449 4243 return XML_ERROR_PUBLICID; 4450 4244 pubId = poolStoreString(&parser->m_tempPool, enc, 4451 4245 s + enc->minBytesPerChar, 4452 4246 next - enc->minBytesPerChar); 4453 - if (!pubId) 4247 + if (! pubId) 4454 4248 return XML_ERROR_NO_MEMORY; 4455 4249 normalizePublicId(pubId); 4456 4250 poolFinish(&parser->m_tempPool); 4457 4251 parser->m_doctypePubid = pubId; 4458 4252 handleDefault = XML_FALSE; 4459 4253 goto alreadyChecked; 4460 4254 } 4461 4255 /* fall through */ 4462 4256 case XML_ROLE_ENTITY_PUBLIC_ID: 4463 - if (!XmlIsPublicId(enc, s, next, eventPP)) 4257 + if (! XmlIsPublicId(enc, s, next, eventPP)) 4464 4258 return XML_ERROR_PUBLICID; 4465 4259 alreadyChecked: 4466 4260 if (dtd->keepProcessing && parser->m_declEntity) { 4467 - XML_Char *tem = poolStoreString(&dtd->pool, 4468 - enc, 4469 - s + enc->minBytesPerChar, 4470 - next - enc->minBytesPerChar); 4471 - if (!tem) 4261 + XML_Char *tem 4262 + = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, 4263 + next - enc->minBytesPerChar); 4264 + if (! tem) 4472 4265 return XML_ERROR_NO_MEMORY; 4473 4266 normalizePublicId(tem); 4474 4267 parser->m_declEntity->publicId = tem; 4475 4268 poolFinish(&dtd->pool); 4476 4269 /* Don't suppress the default handler if we fell through from 4477 4270 * the XML_ROLE_DOCTYPE_PUBLIC_ID case. 4478 4271 */ 4479 4272 if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_PUBLIC_ID) 4480 4273 handleDefault = XML_FALSE; 4481 4274 } 4482 4275 break; 4483 4276 case XML_ROLE_DOCTYPE_CLOSE: 4277 + if (allowClosingDoctype != XML_TRUE) { 4278 + /* Must not close doctype from within expanded parameter entities */ 4279 + return XML_ERROR_INVALID_TOKEN; 4280 + } 4281 + 4484 4282 if (parser->m_doctypeName) { 4485 - parser->m_startDoctypeDeclHandler(parser->m_handlerArg, parser->m_doctypeName, 4486 - parser->m_doctypeSysid, parser->m_doctypePubid, 0); 4283 + parser->m_startDoctypeDeclHandler( 4284 + parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid, 4285 + parser->m_doctypePubid, 0); 4487 4286 poolClear(&parser->m_tempPool); 4488 4287 handleDefault = XML_FALSE; 4489 4288 } 4490 4289 /* parser->m_doctypeSysid will be non-NULL in the case of a previous 4491 4290 XML_ROLE_DOCTYPE_SYSTEM_ID, even if parser->m_startDoctypeDeclHandler 4492 4291 was not set, indicating an external subset 4493 4292 */ 4494 4293 #ifdef XML_DTD 4495 4294 if (parser->m_doctypeSysid || parser->m_useForeignDTD) { 4496 4295 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; 4497 4296 dtd->hasParamEntityRefs = XML_TRUE; 4498 - if (parser->m_paramEntityParsing && parser->m_externalEntityRefHandler) { 4499 - ENTITY *entity = (ENTITY *)lookup(parser, 4500 - &dtd->paramEntities, 4501 - externalSubsetName, 4502 - sizeof(ENTITY)); 4503 - if (!entity) { 4297 + if (parser->m_paramEntityParsing 4298 + && parser->m_externalEntityRefHandler) { 4299 + ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, 4300 + externalSubsetName, sizeof(ENTITY)); 4301 + if (! entity) { 4504 4302 /* The external subset name "#" will have already been 4505 4303 * inserted into the hash table at the start of the 4506 4304 * external entity parsing, so no allocation will happen 4507 4305 * and lookup() cannot fail. 4508 4306 */ 4509 4307 return XML_ERROR_NO_MEMORY; /* LCOV_EXCL_LINE */ 4510 4308 } 4511 4309 if (parser->m_useForeignDTD) 4512 4310 entity->base = parser->m_curBase; 4513 4311 dtd->paramEntityRead = XML_FALSE; 4514 - if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, 4515 - 0, 4516 - entity->base, 4517 - entity->systemId, 4518 - entity->publicId)) 4312 + if (! parser->m_externalEntityRefHandler( 4313 + parser->m_externalEntityRefHandlerArg, 0, entity->base, 4314 + entity->systemId, entity->publicId)) 4519 4315 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; 4520 4316 if (dtd->paramEntityRead) { 4521 - if (!dtd->standalone && 4522 - parser->m_notStandaloneHandler && 4523 - !parser->m_notStandaloneHandler(parser->m_handlerArg)) 4317 + if (! dtd->standalone && parser->m_notStandaloneHandler 4318 + && ! parser->m_notStandaloneHandler(parser->m_handlerArg)) 4524 4319 return XML_ERROR_NOT_STANDALONE; 4525 4320 } 4526 4321 /* if we didn't read the foreign DTD then this means that there 4527 4322 is no external subset and we must reset dtd->hasParamEntityRefs 4528 4323 */ 4529 - else if (!parser->m_doctypeSysid) 4324 + else if (! parser->m_doctypeSysid) 4530 4325 dtd->hasParamEntityRefs = hadParamEntityRefs; 4531 4326 /* end of DTD - no need to update dtd->keepProcessing */ 4532 4327 } 4533 4328 parser->m_useForeignDTD = XML_FALSE; 4534 4329 } 4535 4330 #endif /* XML_DTD */ 4536 4331 if (parser->m_endDoctypeDeclHandler) { ................................................................................ 4542 4337 #ifdef XML_DTD 4543 4338 /* if there is no DOCTYPE declaration then now is the 4544 4339 last chance to read the foreign DTD 4545 4340 */ 4546 4341 if (parser->m_useForeignDTD) { 4547 4342 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; 4548 4343 dtd->hasParamEntityRefs = XML_TRUE; 4549 - if (parser->m_paramEntityParsing && parser->m_externalEntityRefHandler) { 4344 + if (parser->m_paramEntityParsing 4345 + && parser->m_externalEntityRefHandler) { 4550 4346 ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, 4551 - externalSubsetName, 4552 - sizeof(ENTITY)); 4553 - if (!entity) 4347 + externalSubsetName, sizeof(ENTITY)); 4348 + if (! entity) 4554 4349 return XML_ERROR_NO_MEMORY; 4555 4350 entity->base = parser->m_curBase; 4556 4351 dtd->paramEntityRead = XML_FALSE; 4557 - if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, 4558 - 0, 4559 - entity->base, 4560 - entity->systemId, 4561 - entity->publicId)) 4352 + if (! parser->m_externalEntityRefHandler( 4353 + parser->m_externalEntityRefHandlerArg, 0, entity->base, 4354 + entity->systemId, entity->publicId)) 4562 4355 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; 4563 4356 if (dtd->paramEntityRead) { 4564 - if (!dtd->standalone && 4565 - parser->m_notStandaloneHandler && 4566 - !parser->m_notStandaloneHandler(parser->m_handlerArg)) 4357 + if (! dtd->standalone && parser->m_notStandaloneHandler 4358 + && ! parser->m_notStandaloneHandler(parser->m_handlerArg)) 4567 4359 return XML_ERROR_NOT_STANDALONE; 4568 4360 } 4569 4361 /* if we didn't read the foreign DTD then this means that there 4570 4362 is no external subset and we must reset dtd->hasParamEntityRefs 4571 4363 */ 4572 4364 else 4573 4365 dtd->hasParamEntityRefs = hadParamEntityRefs; ................................................................................ 4575 4367 } 4576 4368 } 4577 4369 #endif /* XML_DTD */ 4578 4370 parser->m_processor = contentProcessor; 4579 4371 return contentProcessor(parser, s, end, nextPtr); 4580 4372 case XML_ROLE_ATTLIST_ELEMENT_NAME: 4581 4373 parser->m_declElementType = getElementType(parser, enc, s, next); 4582 - if (!parser->m_declElementType) 4374 + if (! parser->m_declElementType) 4583 4375 return XML_ERROR_NO_MEMORY; 4584 4376 goto checkAttListDeclHandler; 4585 4377 case XML_ROLE_ATTRIBUTE_NAME: 4586 4378 parser->m_declAttributeId = getAttributeId(parser, enc, s, next); 4587 - if (!parser->m_declAttributeId) 4379 + if (! parser->m_declAttributeId) 4588 4380 return XML_ERROR_NO_MEMORY; 4589 4381 parser->m_declAttributeIsCdata = XML_FALSE; 4590 4382 parser->m_declAttributeType = NULL; 4591 4383 parser->m_declAttributeIsId = XML_FALSE; 4592 4384 goto checkAttListDeclHandler; 4593 4385 case XML_ROLE_ATTRIBUTE_TYPE_CDATA: 4594 4386 parser->m_declAttributeIsCdata = XML_TRUE; ................................................................................ 4621 4413 break; 4622 4414 case XML_ROLE_ATTRIBUTE_ENUM_VALUE: 4623 4415 case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: 4624 4416 if (dtd->keepProcessing && parser->m_attlistDeclHandler) { 4625 4417 const XML_Char *prefix; 4626 4418 if (parser->m_declAttributeType) { 4627 4419 prefix = enumValueSep; 4420 + } else { 4421 + prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE ? notationPrefix 4422 + : enumValueStart); 4628 4423 } 4629 - else { 4630 - prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE 4631 - ? notationPrefix 4632 - : enumValueStart); 4633 - } 4634 - if (!poolAppendString(&parser->m_tempPool, prefix)) 4424 + if (! poolAppendString(&parser->m_tempPool, prefix)) 4635 4425 return XML_ERROR_NO_MEMORY; 4636 - if (!poolAppend(&parser->m_tempPool, enc, s, next)) 4426 + if (! poolAppend(&parser->m_tempPool, enc, s, next)) 4637 4427 return XML_ERROR_NO_MEMORY; 4638 4428 parser->m_declAttributeType = parser->m_tempPool.start; 4639 4429 handleDefault = XML_FALSE; 4640 4430 } 4641 4431 break; 4642 4432 case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: 4643 4433 case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: 4644 4434 if (dtd->keepProcessing) { 4645 - if (!defineAttribute(parser->m_declElementType, parser->m_declAttributeId, 4646 - parser->m_declAttributeIsCdata, parser->m_declAttributeIsId, 4647 - 0, parser)) 4435 + if (! defineAttribute(parser->m_declElementType, 4436 + parser->m_declAttributeId, 4437 + parser->m_declAttributeIsCdata, 4438 + parser->m_declAttributeIsId, 0, parser)) 4648 4439 return XML_ERROR_NO_MEMORY; 4649 4440 if (parser->m_attlistDeclHandler && parser->m_declAttributeType) { 4650 4441 if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN) 4651 4442 || (*parser->m_declAttributeType == XML_T(ASCII_N) 4652 4443 && parser->m_declAttributeType[1] == XML_T(ASCII_O))) { 4653 4444 /* Enumerated or Notation type */ 4654 - if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN)) 4655 - || !poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 4445 + if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN)) 4446 + || ! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 4656 4447 return XML_ERROR_NO_MEMORY; 4657 4448 parser->m_declAttributeType = parser->m_tempPool.start; 4658 4449 poolFinish(&parser->m_tempPool); 4659 4450 } 4660 4451 *eventEndPP = s; 4661 - parser->m_attlistDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, 4662 - parser->m_declAttributeId->name, parser->m_declAttributeType, 4663 - 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); 4452 + parser->m_attlistDeclHandler( 4453 + parser->m_handlerArg, parser->m_declElementType->name, 4454 + parser->m_declAttributeId->name, parser->m_declAttributeType, 0, 4455 + role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); 4664 4456 poolClear(&parser->m_tempPool); 4665 4457 handleDefault = XML_FALSE; 4666 4458 } 4667 4459 } 4668 4460 break; 4669 4461 case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: 4670 4462 case XML_ROLE_FIXED_ATTRIBUTE_VALUE: 4671 4463 if (dtd->keepProcessing) { 4672 4464 const XML_Char *attVal; 4673 - enum XML_Error result = 4674 - storeAttributeValue(parser, enc, parser->m_declAttributeIsCdata, 4675 - s + enc->minBytesPerChar, 4676 - next - enc->minBytesPerChar, 4677 - &dtd->pool); 4465 + enum XML_Error result = storeAttributeValue( 4466 + parser, enc, parser->m_declAttributeIsCdata, 4467 + s + enc->minBytesPerChar, next - enc->minBytesPerChar, &dtd->pool); 4678 4468 if (result) 4679 4469 return result; 4680 4470 attVal = poolStart(&dtd->pool); 4681 4471 poolFinish(&dtd->pool); 4682 4472 /* ID attributes aren't allowed to have a default */ 4683 - if (!defineAttribute(parser->m_declElementType, parser->m_declAttributeId, 4684 - parser->m_declAttributeIsCdata, XML_FALSE, attVal, parser)) 4473 + if (! defineAttribute( 4474 + parser->m_declElementType, parser->m_declAttributeId, 4475 + parser->m_declAttributeIsCdata, XML_FALSE, attVal, parser)) 4685 4476 return XML_ERROR_NO_MEMORY; 4686 4477 if (parser->m_attlistDeclHandler && parser->m_declAttributeType) { 4687 4478 if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN) 4688 4479 || (*parser->m_declAttributeType == XML_T(ASCII_N) 4689 4480 && parser->m_declAttributeType[1] == XML_T(ASCII_O))) { 4690 4481 /* Enumerated or Notation type */ 4691 - if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN)) 4692 - || !poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 4482 + if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN)) 4483 + || ! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 4693 4484 return XML_ERROR_NO_MEMORY; 4694 4485 parser->m_declAttributeType = parser->m_tempPool.start; 4695 4486 poolFinish(&parser->m_tempPool); 4696 4487 } 4697 4488 *eventEndPP = s; 4698 - parser->m_attlistDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, 4699 - parser->m_declAttributeId->name, parser->m_declAttributeType, 4700 - attVal, 4701 - role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); 4489 + parser->m_attlistDeclHandler( 4490 + parser->m_handlerArg, parser->m_declElementType->name, 4491 + parser->m_declAttributeId->name, parser->m_declAttributeType, 4492 + attVal, role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); 4702 4493 poolClear(&parser->m_tempPool); 4703 4494 handleDefault = XML_FALSE; 4704 4495 } 4705 4496 } 4706 4497 break; 4707 4498 case XML_ROLE_ENTITY_VALUE: 4708 4499 if (dtd->keepProcessing) { 4709 - enum XML_Error result = storeEntityValue(parser, enc, 4710 - s + enc->minBytesPerChar, 4711 - next - enc->minBytesPerChar); 4500 + enum XML_Error result = storeEntityValue( 4501 + parser, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar); 4712 4502 if (parser->m_declEntity) { 4713 4503 parser->m_declEntity->textPtr = poolStart(&dtd->entityValuePool); 4714 - parser->m_declEntity->textLen = (int)(poolLength(&dtd->entityValuePool)); 4504 + parser->m_declEntity->textLen 4505 + = (int)(poolLength(&dtd->entityValuePool)); 4715 4506 poolFinish(&dtd->entityValuePool); 4716 4507 if (parser->m_entityDeclHandler) { 4717 4508 *eventEndPP = s; 4718 - parser->m_entityDeclHandler(parser->m_handlerArg, 4719 - parser->m_declEntity->name, 4720 - parser->m_declEntity->is_param, 4721 - parser->m_declEntity->textPtr, 4722 - parser->m_declEntity->textLen, 4723 - parser->m_curBase, 0, 0, 0); 4509 + parser->m_entityDeclHandler( 4510 + parser->m_handlerArg, parser->m_declEntity->name, 4511 + parser->m_declEntity->is_param, parser->m_declEntity->textPtr, 4512 + parser->m_declEntity->textLen, parser->m_curBase, 0, 0, 0); 4724 4513 handleDefault = XML_FALSE; 4725 4514 } 4726 - } 4727 - else 4515 + } else 4728 4516 poolDiscard(&dtd->entityValuePool); 4729 4517 if (result != XML_ERROR_NONE) 4730 4518 return result; 4731 4519 } 4732 4520 break; 4733 4521 case XML_ROLE_DOCTYPE_SYSTEM_ID: 4734 4522 #ifdef XML_DTD 4735 4523 parser->m_useForeignDTD = XML_FALSE; 4736 4524 #endif /* XML_DTD */ 4737 4525 dtd->hasParamEntityRefs = XML_TRUE; 4738 4526 if (parser->m_startDoctypeDeclHandler) { 4739 4527 parser->m_doctypeSysid = poolStoreString(&parser->m_tempPool, enc, 4740 - s + enc->minBytesPerChar, 4741 - next - enc->minBytesPerChar); 4528 + s + enc->minBytesPerChar, 4529 + next - enc->minBytesPerChar); 4742 4530 if (parser->m_doctypeSysid == NULL) 4743 4531 return XML_ERROR_NO_MEMORY; 4744 4532 poolFinish(&parser->m_tempPool); 4745 4533 handleDefault = XML_FALSE; 4746 4534 } 4747 4535 #ifdef XML_DTD 4748 4536 else 4749 4537 /* use externalSubsetName to make parser->m_doctypeSysid non-NULL 4750 4538 for the case where no parser->m_startDoctypeDeclHandler is set */ 4751 4539 parser->m_doctypeSysid = externalSubsetName; 4752 4540 #endif /* XML_DTD */ 4753 - if (!dtd->standalone 4541 + if (! dtd->standalone 4754 4542 #ifdef XML_DTD 4755 - && !parser->m_paramEntityParsing 4543 + && ! parser->m_paramEntityParsing 4756 4544 #endif /* XML_DTD */ 4757 4545 && parser->m_notStandaloneHandler 4758 - && !parser->m_notStandaloneHandler(parser->m_handlerArg)) 4546 + && ! parser->m_notStandaloneHandler(parser->m_handlerArg)) 4759 4547 return XML_ERROR_NOT_STANDALONE; 4760 4548 #ifndef XML_DTD 4761 4549 break; 4762 -#else /* XML_DTD */ 4763 - if (!parser->m_declEntity) { 4764 - parser->m_declEntity = (ENTITY *)lookup(parser, 4765 - &dtd->paramEntities, 4766 - externalSubsetName, 4767 - sizeof(ENTITY)); 4768 - if (!parser->m_declEntity) 4550 +#else /* XML_DTD */ 4551 + if (! parser->m_declEntity) { 4552 + parser->m_declEntity = (ENTITY *)lookup( 4553 + parser, &dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); 4554 + if (! parser->m_declEntity) 4769 4555 return XML_ERROR_NO_MEMORY; 4770 4556 parser->m_declEntity->publicId = NULL; 4771 4557 } 4772 4558 #endif /* XML_DTD */ 4773 4559 /* fall through */ 4774 4560 case XML_ROLE_ENTITY_SYSTEM_ID: 4775 4561 if (dtd->keepProcessing && parser->m_declEntity) { 4776 - parser->m_declEntity->systemId = poolStoreString(&dtd->pool, enc, 4777 - s + enc->minBytesPerChar, 4778 - next - enc->minBytesPerChar); 4779 - if (!parser->m_declEntity->systemId) 4562 + parser->m_declEntity->systemId 4563 + = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, 4564 + next - enc->minBytesPerChar); 4565 + if (! parser->m_declEntity->systemId) 4780 4566 return XML_ERROR_NO_MEMORY; 4781 4567 parser->m_declEntity->base = parser->m_curBase; 4782 4568 poolFinish(&dtd->pool); 4783 4569 /* Don't suppress the default handler if we fell through from 4784 4570 * the XML_ROLE_DOCTYPE_SYSTEM_ID case. 4785 4571 */ 4786 4572 if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_SYSTEM_ID) 4787 4573 handleDefault = XML_FALSE; 4788 4574 } 4789 4575 break; 4790 4576 case XML_ROLE_ENTITY_COMPLETE: 4791 - if (dtd->keepProcessing && parser->m_declEntity && parser->m_entityDeclHandler) { 4577 + if (dtd->keepProcessing && parser->m_declEntity 4578 + && parser->m_entityDeclHandler) { 4792 4579 *eventEndPP = s; 4793 - parser->m_entityDeclHandler(parser->m_handlerArg, 4794 - parser->m_declEntity->name, 4795 - parser->m_declEntity->is_param, 4796 - 0,0, 4797 - parser->m_declEntity->base, 4798 - parser->m_declEntity->systemId, 4799 - parser->m_declEntity->publicId, 4800 - 0); 4580 + parser->m_entityDeclHandler( 4581 + parser->m_handlerArg, parser->m_declEntity->name, 4582 + parser->m_declEntity->is_param, 0, 0, parser->m_declEntity->base, 4583 + parser->m_declEntity->systemId, parser->m_declEntity->publicId, 0); 4801 4584 handleDefault = XML_FALSE; 4802 4585 } 4803 4586 break; 4804 4587 case XML_ROLE_ENTITY_NOTATION_NAME: 4805 4588 if (dtd->keepProcessing && parser->m_declEntity) { 4806 - parser->m_declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); 4807 - if (!parser->m_declEntity->notation) 4589 + parser->m_declEntity->notation 4590 + = poolStoreString(&dtd->pool, enc, s, next); 4591 + if (! parser->m_declEntity->notation) 4808 4592 return XML_ERROR_NO_MEMORY; 4809 4593 poolFinish(&dtd->pool); 4810 4594 if (parser->m_unparsedEntityDeclHandler) { 4811 4595 *eventEndPP = s; 4812 - parser->m_unparsedEntityDeclHandler(parser->m_handlerArg, 4813 - parser->m_declEntity->name, 4814 - parser->m_declEntity->base, 4815 - parser->m_declEntity->systemId, 4816 - parser->m_declEntity->publicId, 4817 - parser->m_declEntity->notation); 4596 + parser->m_unparsedEntityDeclHandler( 4597 + parser->m_handlerArg, parser->m_declEntity->name, 4598 + parser->m_declEntity->base, parser->m_declEntity->systemId, 4599 + parser->m_declEntity->publicId, parser->m_declEntity->notation); 4818 4600 handleDefault = XML_FALSE; 4819 - } 4820 - else if (parser->m_entityDeclHandler) { 4601 + } else if (parser->m_entityDeclHandler) { 4821 4602 *eventEndPP = s; 4822 - parser->m_entityDeclHandler(parser->m_handlerArg, 4823 - parser->m_declEntity->name, 4824 - 0,0,0, 4825 - parser->m_declEntity->base, 4826 - parser->m_declEntity->systemId, 4827 - parser->m_declEntity->publicId, 4828 - parser->m_declEntity->notation); 4603 + parser->m_entityDeclHandler( 4604 + parser->m_handlerArg, parser->m_declEntity->name, 0, 0, 0, 4605 + parser->m_declEntity->base, parser->m_declEntity->systemId, 4606 + parser->m_declEntity->publicId, parser->m_declEntity->notation); 4829 4607 handleDefault = XML_FALSE; 4830 4608 } 4831 4609 } 4832 4610 break; 4833 - case XML_ROLE_GENERAL_ENTITY_NAME: 4834 - { 4835 - if (XmlPredefinedEntityName(enc, s, next)) { 4836 - parser->m_declEntity = NULL; 4837 - break; 4838 - } 4839 - if (dtd->keepProcessing) { 4840 - const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); 4841 - if (!name) 4842 - return XML_ERROR_NO_MEMORY; 4843 - parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 4844 - sizeof(ENTITY)); 4845 - if (!parser->m_declEntity) 4846 - return XML_ERROR_NO_MEMORY; 4847 - if (parser->m_declEntity->name != name) { 4848 - poolDiscard(&dtd->pool); 4849 - parser->m_declEntity = NULL; 4850 - } 4851 - else { 4852 - poolFinish(&dtd->pool); 4853 - parser->m_declEntity->publicId = NULL; 4854 - parser->m_declEntity->is_param = XML_FALSE; 4855 - /* if we have a parent parser or are reading an internal parameter 4856 - entity, then the entity declaration is not considered "internal" 4857 - */ 4858 - parser->m_declEntity->is_internal = !(parser->m_parentParser || parser->m_openInternalEntities); 4859 - if (parser->m_entityDeclHandler) 4860 - handleDefault = XML_FALSE; 4861 - } 4862 - } 4863 - else { 4611 + case XML_ROLE_GENERAL_ENTITY_NAME: { 4612 + if (XmlPredefinedEntityName(enc, s, next)) { 4613 + parser->m_declEntity = NULL; 4614 + break; 4615 + } 4616 + if (dtd->keepProcessing) { 4617 + const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); 4618 + if (! name) 4619 + return XML_ERROR_NO_MEMORY; 4620 + parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, 4621 + name, sizeof(ENTITY)); 4622 + if (! parser->m_declEntity) 4623 + return XML_ERROR_NO_MEMORY; 4624 + if (parser->m_declEntity->name != name) { 4864 4625 poolDiscard(&dtd->pool); 4865 4626 parser->m_declEntity = NULL; 4627 + } else { 4628 + poolFinish(&dtd->pool); 4629 + parser->m_declEntity->publicId = NULL; 4630 + parser->m_declEntity->is_param = XML_FALSE; 4631 + /* if we have a parent parser or are reading an internal parameter 4632 + entity, then the entity declaration is not considered "internal" 4633 + */ 4634 + parser->m_declEntity->is_internal 4635 + = ! (parser->m_parentParser || parser->m_openInternalEntities); 4636 + if (parser->m_entityDeclHandler) 4637 + handleDefault = XML_FALSE; 4866 4638 } 4639 + } else { 4640 + poolDiscard(&dtd->pool); 4641 + parser->m_declEntity = NULL; 4867 4642 } 4868 - break; 4643 + } break; 4869 4644 case XML_ROLE_PARAM_ENTITY_NAME: 4870 4645 #ifdef XML_DTD 4871 4646 if (dtd->keepProcessing) { 4872 4647 const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); 4873 - if (!name) 4648 + if (! name) 4874 4649 return XML_ERROR_NO_MEMORY; 4875 4650 parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities, 4876 - name, sizeof(ENTITY)); 4877 - if (!parser->m_declEntity) 4651 + name, sizeof(ENTITY)); 4652 + if (! parser->m_declEntity) 4878 4653 return XML_ERROR_NO_MEMORY; 4879 4654 if (parser->m_declEntity->name != name) { 4880 4655 poolDiscard(&dtd->pool); 4881 4656 parser->m_declEntity = NULL; 4882 - } 4883 - else { 4657 + } else { 4884 4658 poolFinish(&dtd->pool); 4885 4659 parser->m_declEntity->publicId = NULL; 4886 4660 parser->m_declEntity->is_param = XML_TRUE; 4887 4661 /* if we have a parent parser or are reading an internal parameter 4888 4662 entity, then the entity declaration is not considered "internal" 4889 4663 */ 4890 - parser->m_declEntity->is_internal = !(parser->m_parentParser || parser->m_openInternalEntities); 4664 + parser->m_declEntity->is_internal 4665 + = ! (parser->m_parentParser || parser->m_openInternalEntities); 4891 4666 if (parser->m_entityDeclHandler) 4892 4667 handleDefault = XML_FALSE; 4893 4668 } 4894 - } 4895 - else { 4669 + } else { 4896 4670 poolDiscard(&dtd->pool); 4897 4671 parser->m_declEntity = NULL; 4898 4672 } 4899 -#else /* not XML_DTD */ 4673 +#else /* not XML_DTD */ 4900 4674 parser->m_declEntity = NULL; 4901 4675 #endif /* XML_DTD */ 4902 4676 break; 4903 4677 case XML_ROLE_NOTATION_NAME: 4904 4678 parser->m_declNotationPublicId = NULL; 4905 4679 parser->m_declNotationName = NULL; 4906 4680 if (parser->m_notationDeclHandler) { 4907 - parser->m_declNotationName = poolStoreString(&parser->m_tempPool, enc, s, next); 4908 - if (!parser->m_declNotationName) 4681 + parser->m_declNotationName 4682 + = poolStoreString(&parser->m_tempPool, enc, s, next); 4683 + if (! parser->m_declNotationName) 4909 4684 return XML_ERROR_NO_MEMORY; 4910 4685 poolFinish(&parser->m_tempPool); 4911 4686 handleDefault = XML_FALSE; 4912 4687 } 4913 4688 break; 4914 4689 case XML_ROLE_NOTATION_PUBLIC_ID: 4915 - if (!XmlIsPublicId(enc, s, next, eventPP)) 4690 + if (! XmlIsPublicId(enc, s, next, eventPP)) 4916 4691 return XML_ERROR_PUBLICID; 4917 - if (parser->m_declNotationName) { /* means m_notationDeclHandler != NULL */ 4918 - XML_Char *tem = poolStoreString(&parser->m_tempPool, 4919 - enc, 4692 + if (parser 4693 + ->m_declNotationName) { /* means m_notationDeclHandler != NULL */ 4694 + XML_Char *tem = poolStoreString(&parser->m_tempPool, enc, 4920 4695 s + enc->minBytesPerChar, 4921 4696 next - enc->minBytesPerChar); 4922 - if (!tem) 4697 + if (! tem) 4923 4698 return XML_ERROR_NO_MEMORY; 4924 4699 normalizePublicId(tem); 4925 4700 parser->m_declNotationPublicId = tem; 4926 4701 poolFinish(&parser->m_tempPool); 4927 4702 handleDefault = XML_FALSE; 4928 4703 } 4929 4704 break; 4930 4705 case XML_ROLE_NOTATION_SYSTEM_ID: 4931 4706 if (parser->m_declNotationName && parser->m_notationDeclHandler) { 4932 - const XML_Char *systemId 4933 - = poolStoreString(&parser->m_tempPool, enc, 4934 - s + enc->minBytesPerChar, 4935 - next - enc->minBytesPerChar); 4936 - if (!systemId) 4707 + const XML_Char *systemId = poolStoreString(&parser->m_tempPool, enc, 4708 + s + enc->minBytesPerChar, 4709 + next - enc->minBytesPerChar); 4710 + if (! systemId) 4937 4711 return XML_ERROR_NO_MEMORY; 4938 4712 *eventEndPP = s; 4939 - parser->m_notationDeclHandler(parser->m_handlerArg, 4940 - parser->m_declNotationName, 4941 - parser->m_curBase, 4942 - systemId, 4943 - parser->m_declNotationPublicId); 4713 + parser->m_notationDeclHandler( 4714 + parser->m_handlerArg, parser->m_declNotationName, parser->m_curBase, 4715 + systemId, parser->m_declNotationPublicId); 4944 4716 handleDefault = XML_FALSE; 4945 4717 } 4946 4718 poolClear(&parser->m_tempPool); 4947 4719 break; 4948 4720 case XML_ROLE_NOTATION_NO_SYSTEM_ID: 4949 4721 if (parser->m_declNotationPublicId && parser->m_notationDeclHandler) { 4950 4722 *eventEndPP = s; 4951 - parser->m_notationDeclHandler(parser->m_handlerArg, 4952 - parser->m_declNotationName, 4953 - parser->m_curBase, 4954 - 0, 4955 - parser->m_declNotationPublicId); 4723 + parser->m_notationDeclHandler( 4724 + parser->m_handlerArg, parser->m_declNotationName, parser->m_curBase, 4725 + 0, parser->m_declNotationPublicId); 4956 4726 handleDefault = XML_FALSE; 4957 4727 } 4958 4728 poolClear(&parser->m_tempPool); 4959 4729 break; 4960 4730 case XML_ROLE_ERROR: 4961 4731 switch (tok) { 4962 4732 case XML_TOK_PARAM_ENTITY_REF: ................................................................................ 4965 4735 return XML_ERROR_PARAM_ENTITY_REF; 4966 4736 case XML_TOK_XML_DECL: 4967 4737 return XML_ERROR_MISPLACED_XML_PI; 4968 4738 default: 4969 4739 return XML_ERROR_SYNTAX; 4970 4740 } 4971 4741 #ifdef XML_DTD 4972 - case XML_ROLE_IGNORE_SECT: 4973 - { 4974 - enum XML_Error result; 4975 - if (parser->m_defaultHandler) 4976 - reportDefault(parser, enc, s, next); 4977 - handleDefault = XML_FALSE; 4978 - result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); 4979 - if (result != XML_ERROR_NONE) 4980 - return result; 4981 - else if (!next) { 4982 - parser->m_processor = ignoreSectionProcessor; 4983 - return result; 4984 - } 4742 + case XML_ROLE_IGNORE_SECT: { 4743 + enum XML_Error result; 4744 + if (parser->m_defaultHandler) 4745 + reportDefault(parser, enc, s, next); 4746 + handleDefault = XML_FALSE; 4747 + result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); 4748 + if (result != XML_ERROR_NONE) 4749 + return result; 4750 + else if (! next) { 4751 + parser->m_processor = ignoreSectionProcessor; 4752 + return result; 4985 4753 } 4986 - break; 4754 + } break; 4987 4755 #endif /* XML_DTD */ 4988 4756 case XML_ROLE_GROUP_OPEN: 4989 4757 if (parser->m_prologState.level >= parser->m_groupSize) { 4990 4758 if (parser->m_groupSize) { 4991 - char *temp = (char *)REALLOC(parser, parser->m_groupConnector, parser->m_groupSize *= 2); 4992 - if (temp == NULL) { 4993 - parser->m_groupSize /= 2; 4994 - return XML_ERROR_NO_MEMORY; 4759 + { 4760 + char *const new_connector = (char *)REALLOC( 4761 + parser, parser->m_groupConnector, parser->m_groupSize *= 2); 4762 + if (new_connector == NULL) { 4763 + parser->m_groupSize /= 2; 4764 + return XML_ERROR_NO_MEMORY; 4765 + } 4766 + parser->m_groupConnector = new_connector; 4995 4767 } 4996 - parser->m_groupConnector = temp; 4768 + 4997 4769 if (dtd->scaffIndex) { 4998 - int *temp = (int *)REALLOC(parser, dtd->scaffIndex, 4999 - parser->m_groupSize * sizeof(int)); 5000 - if (temp == NULL) 4770 + int *const new_scaff_index = (int *)REALLOC( 4771 + parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int)); 4772 + if (new_scaff_index == NULL) 5001 4773 return XML_ERROR_NO_MEMORY; 5002 - dtd->scaffIndex = temp; 4774 + dtd->scaffIndex = new_scaff_index; 5003 4775 } 5004 - } 5005 - else { 5006 - parser->m_groupConnector = (char *)MALLOC(parser, parser->m_groupSize = 32); 5007 - if (!parser->m_groupConnector) { 4776 + } else { 4777 + parser->m_groupConnector 4778 + = (char *)MALLOC(parser, parser->m_groupSize = 32); 4779 + if (! parser->m_groupConnector) { 5008 4780 parser->m_groupSize = 0; 5009 4781 return XML_ERROR_NO_MEMORY; 5010 4782 } 5011 4783 } 5012 4784 } 5013 4785 parser->m_groupConnector[parser->m_prologState.level] = 0; 5014 4786 if (dtd->in_eldecl) { 5015 4787 int myindex = nextScaffoldPart(parser); 5016 4788 if (myindex < 0) 5017 4789 return XML_ERROR_NO_MEMORY; 4790 + assert(dtd->scaffIndex != NULL); 5018 4791 dtd->scaffIndex[dtd->scaffLevel] = myindex; 5019 4792 dtd->scaffLevel++; 5020 4793 dtd->scaffold[myindex].type = XML_CTYPE_SEQ; 5021 4794 if (parser->m_elementDeclHandler) 5022 4795 handleDefault = XML_FALSE; 5023 4796 } 5024 4797 break; ................................................................................ 5029 4802 if (dtd->in_eldecl && parser->m_elementDeclHandler) 5030 4803 handleDefault = XML_FALSE; 5031 4804 break; 5032 4805 case XML_ROLE_GROUP_CHOICE: 5033 4806 if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_COMMA) 5034 4807 return XML_ERROR_SYNTAX; 5035 4808 if (dtd->in_eldecl 5036 - && !parser->m_groupConnector[parser->m_prologState.level] 4809 + && ! parser->m_groupConnector[parser->m_prologState.level] 5037 4810 && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type 5038 - != XML_CTYPE_MIXED) 5039 - ) { 4811 + != XML_CTYPE_MIXED)) { 5040 4812 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type 5041 4813 = XML_CTYPE_CHOICE; 5042 4814 if (parser->m_elementDeclHandler) 5043 4815 handleDefault = XML_FALSE; 5044 4816 } 5045 4817 parser->m_groupConnector[parser->m_prologState.level] = ASCII_PIPE; 5046 4818 break; 5047 4819 case XML_ROLE_PARAM_ENTITY_REF: 5048 4820 #ifdef XML_DTD 5049 4821 case XML_ROLE_INNER_PARAM_ENTITY_REF: 5050 4822 dtd->hasParamEntityRefs = XML_TRUE; 5051 - if (!parser->m_paramEntityParsing) 4823 + if (! parser->m_paramEntityParsing) 5052 4824 dtd->keepProcessing = dtd->standalone; 5053 4825 else { 5054 4826 const XML_Char *name; 5055 4827 ENTITY *entity; 5056 - name = poolStoreString(&dtd->pool, enc, 5057 - s + enc->minBytesPerChar, 5058 - next - enc->minBytesPerChar); 5059 - if (!name) 4828 + name = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, 4829 + next - enc->minBytesPerChar); 4830 + if (! name) 5060 4831 return XML_ERROR_NO_MEMORY; 5061 4832 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); 5062 4833 poolDiscard(&dtd->pool); 5063 4834 /* first, determine if a check for an existing declaration is needed; 5064 4835 if yes, check that the entity exists, and that it is internal, 5065 4836 otherwise call the skipped entity handler 5066 4837 */ 5067 - if (parser->m_prologState.documentEntity && 5068 - (dtd->standalone 5069 - ? !parser->m_openInternalEntities 5070 - : !dtd->hasParamEntityRefs)) { 5071 - if (!entity) 4838 + if (parser->m_prologState.documentEntity 4839 + && (dtd->standalone ? ! parser->m_openInternalEntities 4840 + : ! dtd->hasParamEntityRefs)) { 4841 + if (! entity) 5072 4842 return XML_ERROR_UNDEFINED_ENTITY; 5073 - else if (!entity->is_internal) { 4843 + else if (! entity->is_internal) { 5074 4844 /* It's hard to exhaustively search the code to be sure, 5075 4845 * but there doesn't seem to be a way of executing the 5076 4846 * following line. There are two cases: 5077 4847 * 5078 4848 * If 'standalone' is false, the DTD must have no 5079 4849 * parameter entities or we wouldn't have passed the outer 5080 4850 * 'if' statement. That measn the only entity in the hash ................................................................................ 5089 4859 * 5090 4860 * Because this analysis is very uncertain, the code is 5091 4861 * being left in place and merely removed from the 5092 4862 * coverage test statistics. 5093 4863 */ 5094 4864 return XML_ERROR_ENTITY_DECLARED_IN_PE; /* LCOV_EXCL_LINE */ 5095 4865 } 5096 - } 5097 - else if (!entity) { 4866 + } else if (! entity) { 5098 4867 dtd->keepProcessing = dtd->standalone; 5099 4868 /* cannot report skipped entities in declarations */ 5100 - if ((role == XML_ROLE_PARAM_ENTITY_REF) && parser->m_skippedEntityHandler) { 4869 + if ((role == XML_ROLE_PARAM_ENTITY_REF) 4870 + && parser->m_skippedEntityHandler) { 5101 4871 parser->m_skippedEntityHandler(parser->m_handlerArg, name, 1); 5102 4872 handleDefault = XML_FALSE; 5103 4873 } 5104 4874 break; 5105 4875 } 5106 4876 if (entity->open) 5107 4877 return XML_ERROR_RECURSIVE_ENTITY_REF; 5108 4878 if (entity->textPtr) { 5109 4879 enum XML_Error result; 5110 - XML_Bool betweenDecl = 5111 - (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); 4880 + XML_Bool betweenDecl 4881 + = (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); 5112 4882 result = processInternalEntity(parser, entity, betweenDecl); 5113 4883 if (result != XML_ERROR_NONE) 5114 4884 return result; 5115 4885 handleDefault = XML_FALSE; 5116 4886 break; 5117 4887 } 5118 4888 if (parser->m_externalEntityRefHandler) { 5119 4889 dtd->paramEntityRead = XML_FALSE; 5120 4890 entity->open = XML_TRUE; 5121 - if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, 5122 - 0, 5123 - entity->base, 5124 - entity->systemId, 5125 - entity->publicId)) { 4891 + if (! parser->m_externalEntityRefHandler( 4892 + parser->m_externalEntityRefHandlerArg, 0, entity->base, 4893 + entity->systemId, entity->publicId)) { 5126 4894 entity->open = XML_FALSE; 5127 4895 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; 5128 4896 } 5129 4897 entity->open = XML_FALSE; 5130 4898 handleDefault = XML_FALSE; 5131 - if (!dtd->paramEntityRead) { 4899 + if (! dtd->paramEntityRead) { 5132 4900 dtd->keepProcessing = dtd->standalone; 5133 4901 break; 5134 4902 } 5135 - } 5136 - else { 4903 + } else { 5137 4904 dtd->keepProcessing = dtd->standalone; 5138 4905 break; 5139 4906 } 5140 4907 } 5141 4908 #endif /* XML_DTD */ 5142 - if (!dtd->standalone && 5143 - parser->m_notStandaloneHandler && 5144 - !parser->m_notStandaloneHandler(parser->m_handlerArg)) 4909 + if (! dtd->standalone && parser->m_notStandaloneHandler 4910 + && ! parser->m_notStandaloneHandler(parser->m_handlerArg)) 5145 4911 return XML_ERROR_NOT_STANDALONE; 5146 4912 break; 5147 4913 5148 - /* Element declaration stuff */ 4914 + /* Element declaration stuff */ 5149 4915 5150 4916 case XML_ROLE_ELEMENT_NAME: 5151 4917 if (parser->m_elementDeclHandler) { 5152 4918 parser->m_declElementType = getElementType(parser, enc, s, next); 5153 - if (!parser->m_declElementType) 4919 + if (! parser->m_declElementType) 5154 4920 return XML_ERROR_NO_MEMORY; 5155 4921 dtd->scaffLevel = 0; 5156 4922 dtd->scaffCount = 0; 5157 4923 dtd->in_eldecl = XML_TRUE; 5158 4924 handleDefault = XML_FALSE; 5159 4925 } 5160 4926 break; 5161 4927 5162 4928 case XML_ROLE_CONTENT_ANY: 5163 4929 case XML_ROLE_CONTENT_EMPTY: 5164 4930 if (dtd->in_eldecl) { 5165 4931 if (parser->m_elementDeclHandler) { 5166 - XML_Content * content = (XML_Content *) MALLOC(parser, sizeof(XML_Content)); 5167 - if (!content) 4932 + XML_Content *content 4933 + = (XML_Content *)MALLOC(parser, sizeof(XML_Content)); 4934 + if (! content) 5168 4935 return XML_ERROR_NO_MEMORY; 5169 4936 content->quant = XML_CQUANT_NONE; 5170 4937 content->name = NULL; 5171 4938 content->numchildren = 0; 5172 4939 content->children = NULL; 5173 - content->type = ((role == XML_ROLE_CONTENT_ANY) ? 5174 - XML_CTYPE_ANY : 5175 - XML_CTYPE_EMPTY); 4940 + content->type = ((role == XML_ROLE_CONTENT_ANY) ? XML_CTYPE_ANY 4941 + : XML_CTYPE_EMPTY); 5176 4942 *eventEndPP = s; 5177 - parser->m_elementDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, content); 4943 + parser->m_elementDeclHandler( 4944 + parser->m_handlerArg, parser->m_declElementType->name, content); 5178 4945 handleDefault = XML_FALSE; 5179 4946 } 5180 4947 dtd->in_eldecl = XML_FALSE; 5181 4948 } 5182 4949 break; 5183 4950 5184 4951 case XML_ROLE_CONTENT_PCDATA: ................................................................................ 5202 4969 case XML_ROLE_CONTENT_ELEMENT_PLUS: 5203 4970 quant = XML_CQUANT_PLUS; 5204 4971 elementContent: 5205 4972 if (dtd->in_eldecl) { 5206 4973 ELEMENT_TYPE *el; 5207 4974 const XML_Char *name; 5208 4975 int nameLen; 5209 - const char *nxt = (quant == XML_CQUANT_NONE 5210 - ? next 5211 - : next - enc->minBytesPerChar); 4976 + const char *nxt 4977 + = (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar); 5212 4978 int myindex = nextScaffoldPart(parser); 5213 4979 if (myindex < 0) 5214 4980 return XML_ERROR_NO_MEMORY; 5215 4981 dtd->scaffold[myindex].type = XML_CTYPE_NAME; 5216 4982 dtd->scaffold[myindex].quant = quant; 5217 4983 el = getElementType(parser, enc, s, nxt); 5218 - if (!el) 4984 + if (! el) 5219 4985 return XML_ERROR_NO_MEMORY; 5220 4986 name = el->name; 5221 4987 dtd->scaffold[myindex].name = name; 5222 4988 nameLen = 0; 5223 - for (; name[nameLen++]; ); 5224 - dtd->contentStringLen += nameLen; 4989 + for (; name[nameLen++];) 4990 + ; 4991 + dtd->contentStringLen += nameLen; 5225 4992 if (parser->m_elementDeclHandler) 5226 4993 handleDefault = XML_FALSE; 5227 4994 } 5228 4995 break; 5229 4996 5230 4997 case XML_ROLE_GROUP_CLOSE: 5231 4998 quant = XML_CQUANT_NONE; ................................................................................ 5241 5008 closeGroup: 5242 5009 if (dtd->in_eldecl) { 5243 5010 if (parser->m_elementDeclHandler) 5244 5011 handleDefault = XML_FALSE; 5245 5012 dtd->scaffLevel--; 5246 5013 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; 5247 5014 if (dtd->scaffLevel == 0) { 5248 - if (!handleDefault) { 5015 + if (! handleDefault) { 5249 5016 XML_Content *model = build_model(parser); 5250 - if (!model) 5017 + if (! model) 5251 5018 return XML_ERROR_NO_MEMORY; 5252 5019 *eventEndPP = s; 5253 - parser->m_elementDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, model); 5020 + parser->m_elementDeclHandler( 5021 + parser->m_handlerArg, parser->m_declElementType->name, model); 5254 5022 } 5255 5023 dtd->in_eldecl = XML_FALSE; 5256 5024 dtd->contentStringLen = 0; 5257 5025 } 5258 5026 } 5259 5027 break; 5260 5028 /* End element declaration stuff */ 5261 5029 5262 5030 case XML_ROLE_PI: 5263 - if (!reportProcessingInstruction(parser, enc, s, next)) 5031 + if (! reportProcessingInstruction(parser, enc, s, next)) 5264 5032 return XML_ERROR_NO_MEMORY; 5265 5033 handleDefault = XML_FALSE; 5266 5034 break; 5267 5035 case XML_ROLE_COMMENT: 5268 - if (!reportComment(parser, enc, s, next)) 5036 + if (! reportComment(parser, enc, s, next)) 5269 5037 return XML_ERROR_NO_MEMORY; 5270 5038 handleDefault = XML_FALSE; 5271 5039 break; 5272 5040 case XML_ROLE_NONE: 5273 5041 switch (tok) { 5274 5042 case XML_TOK_BOM: 5275 5043 handleDefault = XML_FALSE; ................................................................................ 5312 5080 tok = XmlPrologTok(enc, s, end, &next); 5313 5081 } 5314 5082 } 5315 5083 /* not reached */ 5316 5084 } 5317 5085 5318 5086 static enum XML_Error PTRCALL 5319 -epilogProcessor(XML_Parser parser, 5320 - const char *s, 5321 - const char *end, 5322 - const char **nextPtr) 5323 -{ 5087 +epilogProcessor(XML_Parser parser, const char *s, const char *end, 5088 + const char **nextPtr) { 5324 5089 parser->m_processor = epilogProcessor; 5325 5090 parser->m_eventPtr = s; 5326 5091 for (;;) { 5327 5092 const char *next = NULL; 5328 5093 int tok = XmlPrologTok(parser->m_encoding, s, end, &next); 5329 5094 parser->m_eventEndPtr = next; 5330 5095 switch (tok) { ................................................................................ 5341 5106 *nextPtr = s; 5342 5107 return XML_ERROR_NONE; 5343 5108 case XML_TOK_PROLOG_S: 5344 5109 if (parser->m_defaultHandler) 5345 5110 reportDefault(parser, parser->m_encoding, s, next); 5346 5111 break; 5347 5112 case XML_TOK_PI: 5348 - if (!reportProcessingInstruction(parser, parser->m_encoding, s, next)) 5113 + if (! reportProcessingInstruction(parser, parser->m_encoding, s, next)) 5349 5114 return XML_ERROR_NO_MEMORY; 5350 5115 break; 5351 5116 case XML_TOK_COMMENT: 5352 - if (!reportComment(parser, parser->m_encoding, s, next)) 5117 + if (! reportComment(parser, parser->m_encoding, s, next)) 5353 5118 return XML_ERROR_NO_MEMORY; 5354 5119 break; 5355 5120 case XML_TOK_INVALID: 5356 5121 parser->m_eventPtr = next; 5357 5122 return XML_ERROR_INVALID_TOKEN; 5358 5123 case XML_TOK_PARTIAL: 5359 - if (!parser->m_parsingStatus.finalBuffer) { 5124 + if (! parser->m_parsingStatus.finalBuffer) { 5360 5125 *nextPtr = s; 5361 5126 return XML_ERROR_NONE; 5362 5127 } 5363 5128 return XML_ERROR_UNCLOSED_TOKEN; 5364 5129 case XML_TOK_PARTIAL_CHAR: 5365 - if (!parser->m_parsingStatus.finalBuffer) { 5130 + if (! parser->m_parsingStatus.finalBuffer) { 5366 5131 *nextPtr = s; 5367 5132 return XML_ERROR_NONE; 5368 5133 } 5369 5134 return XML_ERROR_PARTIAL_CHAR; 5370 5135 default: 5371 5136 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; 5372 5137 } ................................................................................ 5373 5138 parser->m_eventPtr = s = next; 5374 5139 switch (parser->m_parsingStatus.parsing) { 5375 5140 case XML_SUSPENDED: 5376 5141 *nextPtr = next; 5377 5142 return XML_ERROR_NONE; 5378 5143 case XML_FINISHED: 5379 5144 return XML_ERROR_ABORTED; 5380 - default: ; 5145 + default:; 5381 5146 } 5382 5147 } 5383 5148 } 5384 5149 5385 5150 static enum XML_Error 5386 -processInternalEntity(XML_Parser parser, ENTITY *entity, 5387 - XML_Bool betweenDecl) 5388 -{ 5151 +processInternalEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl) { 5389 5152 const char *textStart, *textEnd; 5390 5153 const char *next; 5391 5154 enum XML_Error result; 5392 5155 OPEN_INTERNAL_ENTITY *openEntity; 5393 5156 5394 5157 if (parser->m_freeInternalEntities) { 5395 5158 openEntity = parser->m_freeInternalEntities; 5396 5159 parser->m_freeInternalEntities = openEntity->next; 5397 - } 5398 - else { 5399 - openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(parser, sizeof(OPEN_INTERNAL_ENTITY)); 5400 - if (!openEntity) 5160 + } else { 5161 + openEntity 5162 + = (OPEN_INTERNAL_ENTITY *)MALLOC(parser, sizeof(OPEN_INTERNAL_ENTITY)); 5163 + if (! openEntity) 5401 5164 return XML_ERROR_NO_MEMORY; 5402 5165 } 5403 5166 entity->open = XML_TRUE; 5404 5167 entity->processed = 0; 5405 5168 openEntity->next = parser->m_openInternalEntities; 5406 5169 parser->m_openInternalEntities = openEntity; 5407 5170 openEntity->entity = entity; ................................................................................ 5412 5175 textStart = (char *)entity->textPtr; 5413 5176 textEnd = (char *)(entity->textPtr + entity->textLen); 5414 5177 /* Set a safe default value in case 'next' does not get set */ 5415 5178 next = textStart; 5416 5179 5417 5180 #ifdef XML_DTD 5418 5181 if (entity->is_param) { 5419 - int tok = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); 5420 - result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, tok, 5421 - next, &next, XML_FALSE); 5422 - } 5423 - else 5182 + int tok 5183 + = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); 5184 + result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, 5185 + tok, next, &next, XML_FALSE, XML_FALSE); 5186 + } else 5424 5187 #endif /* XML_DTD */ 5425 - result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding, textStart, 5426 - textEnd, &next, XML_FALSE); 5188 + result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding, 5189 + textStart, textEnd, &next, XML_FALSE); 5427 5190 5428 5191 if (result == XML_ERROR_NONE) { 5429 5192 if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) { 5430 5193 entity->processed = (int)(next - textStart); 5431 5194 parser->m_processor = internalEntityProcessor; 5432 - } 5433 - else { 5195 + } else { 5434 5196 entity->open = XML_FALSE; 5435 5197 parser->m_openInternalEntities = openEntity->next; 5436 5198 /* put openEntity back in list of free instances */ 5437 5199 openEntity->next = parser->m_freeInternalEntities; 5438 5200 parser->m_freeInternalEntities = openEntity; 5439 5201 } 5440 5202 } 5441 5203 return result; 5442 5204 } 5443 5205 5444 5206 static enum XML_Error PTRCALL 5445 -internalEntityProcessor(XML_Parser parser, 5446 - const char *s, 5447 - const char *end, 5448 - const char **nextPtr) 5449 -{ 5207 +internalEntityProcessor(XML_Parser parser, const char *s, const char *end, 5208 + const char **nextPtr) { 5450 5209 ENTITY *entity; 5451 5210 const char *textStart, *textEnd; 5452 5211 const char *next; 5453 5212 enum XML_Error result; 5454 5213 OPEN_INTERNAL_ENTITY *openEntity = parser->m_openInternalEntities; 5455 - if (!openEntity) 5214 + if (! openEntity) 5456 5215 return XML_ERROR_UNEXPECTED_STATE; 5457 5216 5458 5217 entity = openEntity->entity; 5459 5218 textStart = ((char *)entity->textPtr) + entity->processed; 5460 5219 textEnd = (char *)(entity->textPtr + entity->textLen); 5461 5220 /* Set a safe default value in case 'next' does not get set */ 5462 5221 next = textStart; 5463 5222 5464 5223 #ifdef XML_DTD 5465 5224 if (entity->is_param) { 5466 - int tok = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); 5467 - result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, tok, 5468 - next, &next, XML_FALSE); 5469 - } 5470 - else 5225 + int tok 5226 + = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); 5227 + result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, 5228 + tok, next, &next, XML_FALSE, XML_TRUE); 5229 + } else 5471 5230 #endif /* XML_DTD */ 5472 - result = doContent(parser, openEntity->startTagLevel, parser->m_internalEncoding, 5473 - textStart, textEnd, &next, XML_FALSE); 5231 + result = doContent(parser, openEntity->startTagLevel, 5232 + parser->m_internalEncoding, textStart, textEnd, &next, 5233 + XML_FALSE); 5474 5234 5475 5235 if (result != XML_ERROR_NONE) 5476 5236 return result; 5477 - else if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) { 5237 + else if (textEnd != next 5238 + && parser->m_parsingStatus.parsing == XML_SUSPENDED) { 5478 5239 entity->processed = (int)(next - (char *)entity->textPtr); 5479 5240 return result; 5480 - } 5481 - else { 5241 + } else { 5482 5242 entity->open = XML_FALSE; 5483 5243 parser->m_openInternalEntities = openEntity->next; 5484 5244 /* put openEntity back in list of free instances */ 5485 5245 openEntity->next = parser->m_freeInternalEntities; 5486 5246 parser->m_freeInternalEntities = openEntity; 5487 5247 } 5488 5248 5489 5249 #ifdef XML_DTD 5490 5250 if (entity->is_param) { 5491 5251 int tok; 5492 5252 parser->m_processor = prologProcessor; 5493 5253 tok = XmlPrologTok(parser->m_encoding, s, end, &next); 5494 5254 return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, 5495 - (XML_Bool)!parser->m_parsingStatus.finalBuffer); 5496 - } 5497 - else 5255 + (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE); 5256 + } else 5498 5257 #endif /* XML_DTD */ 5499 5258 { 5500 5259 parser->m_processor = contentProcessor; 5501 5260 /* see externalEntityContentProcessor vs contentProcessor */ 5502 - return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, s, end, 5503 - nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); 5261 + return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, 5262 + s, end, nextPtr, 5263 + (XML_Bool)! parser->m_parsingStatus.finalBuffer); 5504 5264 } 5505 5265 } 5506 5266 5507 5267 static enum XML_Error PTRCALL 5508 -errorProcessor(XML_Parser parser, 5509 - const char *UNUSED_P(s), 5510 - const char *UNUSED_P(end), 5511 - const char **UNUSED_P(nextPtr)) 5512 -{ 5268 +errorProcessor(XML_Parser parser, const char *s, const char *end, 5269 + const char **nextPtr) { 5270 + UNUSED_P(s); 5271 + UNUSED_P(end); 5272 + UNUSED_P(nextPtr); 5513 5273 return parser->m_errorCode; 5514 5274 } 5515 5275 5516 5276 static enum XML_Error 5517 5277 storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, 5518 - const char *ptr, const char *end, 5519 - STRING_POOL *pool) 5520 -{ 5521 - enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, 5522 - end, pool); 5278 + const char *ptr, const char *end, STRING_POOL *pool) { 5279 + enum XML_Error result 5280 + = appendAttributeValue(parser, enc, isCdata, ptr, end, pool); 5523 5281 if (result) 5524 5282 return result; 5525 - if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) 5283 + if (! isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) 5526 5284 poolChop(pool); 5527 - if (!poolAppendChar(pool, XML_T('\0'))) 5285 + if (! poolAppendChar(pool, XML_T('\0'))) 5528 5286 return XML_ERROR_NO_MEMORY; 5529 5287 return XML_ERROR_NONE; 5530 5288 } 5531 5289 5532 5290 static enum XML_Error 5533 5291 appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, 5534 - const char *ptr, const char *end, 5535 - STRING_POOL *pool) 5536 -{ 5537 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 5292 + const char *ptr, const char *end, STRING_POOL *pool) { 5293 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 5538 5294 for (;;) { 5539 5295 const char *next; 5540 5296 int tok = XmlAttributeValueTok(enc, ptr, end, &next); 5541 5297 switch (tok) { 5542 5298 case XML_TOK_NONE: 5543 5299 return XML_ERROR_NONE; 5544 5300 case XML_TOK_INVALID: ................................................................................ 5545 5301 if (enc == parser->m_encoding) 5546 5302 parser->m_eventPtr = next; 5547 5303 return XML_ERROR_INVALID_TOKEN; 5548 5304 case XML_TOK_PARTIAL: 5549 5305 if (enc == parser->m_encoding) 5550 5306 parser->m_eventPtr = ptr; 5551 5307 return XML_ERROR_INVALID_TOKEN; 5552 - case XML_TOK_CHAR_REF: 5553 - { 5554 - XML_Char buf[XML_ENCODE_MAX]; 5555 - int i; 5556 - int n = XmlCharRefNumber(enc, ptr); 5557 - if (n < 0) { 5558 - if (enc == parser->m_encoding) 5559 - parser->m_eventPtr = ptr; 5560 - return XML_ERROR_BAD_CHAR_REF; 5561 - } 5562 - if (!isCdata 5563 - && n == 0x20 /* space */ 5564 - && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) 5565 - break; 5566 - n = XmlEncode(n, (ICHAR *)buf); 5567 - /* The XmlEncode() functions can never return 0 here. That 5568 - * error return happens if the code point passed in is either 5569 - * negative or greater than or equal to 0x110000. The 5570 - * XmlCharRefNumber() functions will all return a number 5571 - * strictly less than 0x110000 or a negative value if an error 5572 - * occurred. The negative value is intercepted above, so 5573 - * XmlEncode() is never passed a value it might return an 5574 - * error for. 5575 - */ 5576 - for (i = 0; i < n; i++) { 5577 - if (!poolAppendChar(pool, buf[i])) 5578 - return XML_ERROR_NO_MEMORY; 5579 - } 5580 - } 5581 - break; 5308 + case XML_TOK_CHAR_REF: { 5309 + XML_Char buf[XML_ENCODE_MAX]; 5310 + int i; 5311 + int n = XmlCharRefNumber(enc, ptr); 5312 + if (n < 0) { 5313 + if (enc == parser->m_encoding) 5314 + parser->m_eventPtr = ptr; 5315 + return XML_ERROR_BAD_CHAR_REF; 5316 + } 5317 + if (! isCdata && n == 0x20 /* space */ 5318 + && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) 5319 + break; 5320 + n = XmlEncode(n, (ICHAR *)buf); 5321 + /* The XmlEncode() functions can never return 0 here. That 5322 + * error return happens if the code point passed in is either 5323 + * negative or greater than or equal to 0x110000. The 5324 + * XmlCharRefNumber() functions will all return a number 5325 + * strictly less than 0x110000 or a negative value if an error 5326 + * occurred. The negative value is intercepted above, so 5327 + * XmlEncode() is never passed a value it might return an 5328 + * error for. 5329 + */ 5330 + for (i = 0; i < n; i++) { 5331 + if (! poolAppendChar(pool, buf[i])) 5332 + return XML_ERROR_NO_MEMORY; 5333 + } 5334 + } break; 5582 5335 case XML_TOK_DATA_CHARS: 5583 - if (!poolAppend(pool, enc, ptr, next)) 5336 + if (! poolAppend(pool, enc, ptr, next)) 5584 5337 return XML_ERROR_NO_MEMORY; 5585 5338 break; 5586 5339 case XML_TOK_TRAILING_CR: 5587 5340 next = ptr + enc->minBytesPerChar; 5588 5341 /* fall through */ 5589 5342 case XML_TOK_ATTRIBUTE_VALUE_S: 5590 5343 case XML_TOK_DATA_NEWLINE: 5591 - if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) 5344 + if (! isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) 5592 5345 break; 5593 - if (!poolAppendChar(pool, 0x20)) 5346 + if (! poolAppendChar(pool, 0x20)) 5594 5347 return XML_ERROR_NO_MEMORY; 5595 5348 break; 5596 - case XML_TOK_ENTITY_REF: 5597 - { 5598 - const XML_Char *name; 5599 - ENTITY *entity; 5600 - char checkEntityDecl; 5601 - XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, 5602 - ptr + enc->minBytesPerChar, 5603 - next - enc->minBytesPerChar); 5604 - if (ch) { 5605 - if (!poolAppendChar(pool, ch)) 5606 - return XML_ERROR_NO_MEMORY; 5607 - break; 5608 - } 5609 - name = poolStoreString(&parser->m_temp2Pool, enc, 5610 - ptr + enc->minBytesPerChar, 5611 - next - enc->minBytesPerChar); 5612 - if (!name) 5349 + case XML_TOK_ENTITY_REF: { 5350 + const XML_Char *name; 5351 + ENTITY *entity; 5352 + char checkEntityDecl; 5353 + XML_Char ch = (XML_Char)XmlPredefinedEntityName( 5354 + enc, ptr + enc->minBytesPerChar, next - enc->minBytesPerChar); 5355 + if (ch) { 5356 + if (! poolAppendChar(pool, ch)) 5613 5357 return XML_ERROR_NO_MEMORY; 5614 - entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); 5615 - poolDiscard(&parser->m_temp2Pool); 5616 - /* First, determine if a check for an existing declaration is needed; 5617 - if yes, check that the entity exists, and that it is internal. 5618 - */ 5619 - if (pool == &dtd->pool) /* are we called from prolog? */ 5620 - checkEntityDecl = 5358 + break; 5359 + } 5360 + name = poolStoreString(&parser->m_temp2Pool, enc, 5361 + ptr + enc->minBytesPerChar, 5362 + next - enc->minBytesPerChar); 5363 + if (! name) 5364 + return XML_ERROR_NO_MEMORY; 5365 + entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); 5366 + poolDiscard(&parser->m_temp2Pool); 5367 + /* First, determine if a check for an existing declaration is needed; 5368 + if yes, check that the entity exists, and that it is internal. 5369 + */ 5370 + if (pool == &dtd->pool) /* are we called from prolog? */ 5371 + checkEntityDecl = 5621 5372 #ifdef XML_DTD 5622 - parser->m_prologState.documentEntity && 5373 + parser->m_prologState.documentEntity && 5623 5374 #endif /* XML_DTD */ 5624 - (dtd->standalone 5625 - ? !parser->m_openInternalEntities 5626 - : !dtd->hasParamEntityRefs); 5627 - else /* if (pool == &parser->m_tempPool): we are called from content */ 5628 - checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; 5629 - if (checkEntityDecl) { 5630 - if (!entity) 5631 - return XML_ERROR_UNDEFINED_ENTITY; 5632 - else if (!entity->is_internal) 5633 - return XML_ERROR_ENTITY_DECLARED_IN_PE; 5634 - } 5635 - else if (!entity) { 5636 - /* Cannot report skipped entity here - see comments on 5637 - parser->m_skippedEntityHandler. 5638 - if (parser->m_skippedEntityHandler) 5639 - parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); 5640 - */ 5641 - /* Cannot call the default handler because this would be 5642 - out of sync with the call to the startElementHandler. 5643 - if ((pool == &parser->m_tempPool) && parser->m_defaultHandler) 5644 - reportDefault(parser, enc, ptr, next); 5645 - */ 5646 - break; 5647 - } 5648 - if (entity->open) { 5649 - if (enc == parser->m_encoding) { 5650 - /* It does not appear that this line can be executed. 5651 - * 5652 - * The "if (entity->open)" check catches recursive entity 5653 - * definitions. In order to be called with an open 5654 - * entity, it must have gone through this code before and 5655 - * been through the recursive call to 5656 - * appendAttributeValue() some lines below. That call 5657 - * sets the local encoding ("enc") to the parser's 5658 - * internal encoding (internal_utf8 or internal_utf16), 5659 - * which can never be the same as the principle encoding. 5660 - * It doesn't appear there is another code path that gets 5661 - * here with entity->open being TRUE. 5662 - * 5663 - * Since it is not certain that this logic is watertight, 5664 - * we keep the line and merely exclude it from coverage 5665 - * tests. 5666 - */ 5667 - parser->m_eventPtr = ptr; /* LCOV_EXCL_LINE */ 5668 - } 5669 - return XML_ERROR_RECURSIVE_ENTITY_REF; 5375 + (dtd->standalone ? ! parser->m_openInternalEntities 5376 + : ! dtd->hasParamEntityRefs); 5377 + else /* if (pool == &parser->m_tempPool): we are called from content */ 5378 + checkEntityDecl = ! dtd->hasParamEntityRefs || dtd->standalone; 5379 + if (checkEntityDecl) { 5380 + if (! entity) 5381 + return XML_ERROR_UNDEFINED_ENTITY; 5382 + else if (! entity->is_internal) 5383 + return XML_ERROR_ENTITY_DECLARED_IN_PE; 5384 + } else if (! entity) { 5385 + /* Cannot report skipped entity here - see comments on 5386 + parser->m_skippedEntityHandler. 5387 + if (parser->m_skippedEntityHandler) 5388 + parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); 5389 + */ 5390 + /* Cannot call the default handler because this would be 5391 + out of sync with the call to the startElementHandler. 5392 + if ((pool == &parser->m_tempPool) && parser->m_defaultHandler) 5393 + reportDefault(parser, enc, ptr, next); 5394 + */ 5395 + break; 5396 + } 5397 + if (entity->open) { 5398 + if (enc == parser->m_encoding) { 5399 + /* It does not appear that this line can be executed. 5400 + * 5401 + * The "if (entity->open)" check catches recursive entity 5402 + * definitions. In order to be called with an open 5403 + * entity, it must have gone through this code before and 5404 + * been through the recursive call to 5405 + * appendAttributeValue() some lines below. That call 5406 + * sets the local encoding ("enc") to the parser's 5407 + * internal encoding (internal_utf8 or internal_utf16), 5408 + * which can never be the same as the principle encoding. 5409 + * It doesn't appear there is another code path that gets 5410 + * here with entity->open being TRUE. 5411 + * 5412 + * Since it is not certain that this logic is watertight, 5413 + * we keep the line and merely exclude it from coverage 5414 + * tests. 5415 + */ 5416 + parser->m_eventPtr = ptr; /* LCOV_EXCL_LINE */ 5670 5417 } 5671 - if (entity->notation) { 5672 - if (enc == parser->m_encoding) 5673 - parser->m_eventPtr = ptr; 5674 - return XML_ERROR_BINARY_ENTITY_REF; 5675 - } 5676 - if (!entity->textPtr) { 5677 - if (enc == parser->m_encoding) 5678 - parser->m_eventPtr = ptr; 5679 - return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; 5680 - } 5681 - else { 5682 - enum XML_Error result; 5683 - const XML_Char *textEnd = entity->textPtr + entity->textLen; 5684 - entity->open = XML_TRUE; 5685 - result = appendAttributeValue(parser, parser->m_internalEncoding, isCdata, 5686 - (char *)entity->textPtr, 5687 - (char *)textEnd, pool); 5688 - entity->open = XML_FALSE; 5689 - if (result) 5690 - return result; 5691 - } 5692 - } 5693 - break; 5418 + return XML_ERROR_RECURSIVE_ENTITY_REF; 5419 + } 5420 + if (entity->notation) { 5421 + if (enc == parser->m_encoding) 5422 + parser->m_eventPtr = ptr; 5423 + return XML_ERROR_BINARY_ENTITY_REF; 5424 + } 5425 + if (! entity->textPtr) { 5426 + if (enc == parser->m_encoding) 5427 + parser->m_eventPtr = ptr; 5428 + return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; 5429 + } else { 5430 + enum XML_Error result; 5431 + const XML_Char *textEnd = entity->textPtr + entity->textLen; 5432 + entity->open = XML_TRUE; 5433 + result = appendAttributeValue(parser, parser->m_internalEncoding, 5434 + isCdata, (char *)entity->textPtr, 5435 + (char *)textEnd, pool); 5436 + entity->open = XML_FALSE; 5437 + if (result) 5438 + return result; 5439 + } 5440 + } break; 5694 5441 default: 5695 5442 /* The only token returned by XmlAttributeValueTok() that does 5696 5443 * not have an explicit case here is XML_TOK_PARTIAL_CHAR. 5697 5444 * Getting that would require an entity name to contain an 5698 5445 * incomplete XML character (e.g. \xE2\x82); however previous 5699 5446 * tokenisers will have already recognised and rejected such 5700 5447 * names before XmlAttributeValueTok() gets a look-in. This ................................................................................ 5710 5457 } 5711 5458 ptr = next; 5712 5459 } 5713 5460 /* not reached */ 5714 5461 } 5715 5462 5716 5463 static enum XML_Error 5717 -storeEntityValue(XML_Parser parser, 5718 - const ENCODING *enc, 5719 - const char *entityTextPtr, 5720 - const char *entityTextEnd) 5721 -{ 5722 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 5464 +storeEntityValue(XML_Parser parser, const ENCODING *enc, 5465 + const char *entityTextPtr, const char *entityTextEnd) { 5466 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 5723 5467 STRING_POOL *pool = &(dtd->entityValuePool); 5724 5468 enum XML_Error result = XML_ERROR_NONE; 5725 5469 #ifdef XML_DTD 5726 5470 int oldInEntityValue = parser->m_prologState.inEntityValue; 5727 5471 parser->m_prologState.inEntityValue = 1; 5728 5472 #endif /* XML_DTD */ 5729 5473 /* never return Null for the value argument in EntityDeclHandler, 5730 5474 since this would indicate an external entity; therefore we 5731 5475 have to make sure that entityValuePool.start is not null */ 5732 - if (!pool->blocks) { 5733 - if (!poolGrow(pool)) 5476 + if (! pool->blocks) { 5477 + if (! poolGrow(pool)) 5734 5478 return XML_ERROR_NO_MEMORY; 5735 5479 } 5736 5480 5737 5481 for (;;) { 5738 5482 const char *next; 5739 5483 int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); 5740 5484 switch (tok) { ................................................................................ 5742 5486 #ifdef XML_DTD 5743 5487 if (parser->m_isParamEntity || enc != parser->m_encoding) { 5744 5488 const XML_Char *name; 5745 5489 ENTITY *entity; 5746 5490 name = poolStoreString(&parser->m_tempPool, enc, 5747 5491 entityTextPtr + enc->minBytesPerChar, 5748 5492 next - enc->minBytesPerChar); 5749 - if (!name) { 5493 + if (! name) { 5750 5494 result = XML_ERROR_NO_MEMORY; 5751 5495 goto endEntityValue; 5752 5496 } 5753 5497 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); 5754 5498 poolDiscard(&parser->m_tempPool); 5755 - if (!entity) { 5499 + if (! entity) { 5756 5500 /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ 5757 5501 /* cannot report skipped entity here - see comments on 5758 5502 parser->m_skippedEntityHandler 5759 5503 if (parser->m_skippedEntityHandler) 5760 5504 parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); 5761 5505 */ 5762 5506 dtd->keepProcessing = dtd->standalone; ................................................................................ 5768 5512 result = XML_ERROR_RECURSIVE_ENTITY_REF; 5769 5513 goto endEntityValue; 5770 5514 } 5771 5515 if (entity->systemId) { 5772 5516 if (parser->m_externalEntityRefHandler) { 5773 5517 dtd->paramEntityRead = XML_FALSE; 5774 5518 entity->open = XML_TRUE; 5775 - if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, 5776 - 0, 5777 - entity->base, 5778 - entity->systemId, 5779 - entity->publicId)) { 5519 + if (! parser->m_externalEntityRefHandler( 5520 + parser->m_externalEntityRefHandlerArg, 0, entity->base, 5521 + entity->systemId, entity->publicId)) { 5780 5522 entity->open = XML_FALSE; 5781 5523 result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; 5782 5524 goto endEntityValue; 5783 5525 } 5784 5526 entity->open = XML_FALSE; 5785 - if (!dtd->paramEntityRead) 5527 + if (! dtd->paramEntityRead) 5786 5528 dtd->keepProcessing = dtd->standalone; 5787 - } 5788 - else 5529 + } else 5789 5530 dtd->keepProcessing = dtd->standalone; 5790 - } 5791 - else { 5531 + } else { 5792 5532 entity->open = XML_TRUE; 5793 - result = storeEntityValue(parser, 5794 - parser->m_internalEncoding, 5795 - (char *)entity->textPtr, 5796 - (char *)(entity->textPtr 5797 - + entity->textLen)); 5533 + result = storeEntityValue( 5534 + parser, parser->m_internalEncoding, (char *)entity->textPtr, 5535 + (char *)(entity->textPtr + entity->textLen)); 5798 5536 entity->open = XML_FALSE; 5799 5537 if (result) 5800 5538 goto endEntityValue; 5801 5539 } 5802 5540 break; 5803 5541 } 5804 5542 #endif /* XML_DTD */ ................................................................................ 5808 5546 result = XML_ERROR_PARAM_ENTITY_REF; 5809 5547 goto endEntityValue; 5810 5548 case XML_TOK_NONE: 5811 5549 result = XML_ERROR_NONE; 5812 5550 goto endEntityValue; 5813 5551 case XML_TOK_ENTITY_REF: 5814 5552 case XML_TOK_DATA_CHARS: 5815 - if (!poolAppend(pool, enc, entityTextPtr, next)) { 5553 + if (! poolAppend(pool, enc, entityTextPtr, next)) { 5816 5554 result = XML_ERROR_NO_MEMORY; 5817 5555 goto endEntityValue; 5818 5556 } 5819 5557 break; 5820 5558 case XML_TOK_TRAILING_CR: 5821 5559 next = entityTextPtr + enc->minBytesPerChar; 5822 5560 /* fall through */ 5823 5561 case XML_TOK_DATA_NEWLINE: 5824 - if (pool->end == pool->ptr && !poolGrow(pool)) { 5825 - result = XML_ERROR_NO_MEMORY; 5562 + if (pool->end == pool->ptr && ! poolGrow(pool)) { 5563 + result = XML_ERROR_NO_MEMORY; 5826 5564 goto endEntityValue; 5827 5565 } 5828 5566 *(pool->ptr)++ = 0xA; 5829 5567 break; 5830 - case XML_TOK_CHAR_REF: 5831 - { 5832 - XML_Char buf[XML_ENCODE_MAX]; 5833 - int i; 5834 - int n = XmlCharRefNumber(enc, entityTextPtr); 5835 - if (n < 0) { 5836 - if (enc == parser->m_encoding) 5837 - parser->m_eventPtr = entityTextPtr; 5838 - result = XML_ERROR_BAD_CHAR_REF; 5568 + case XML_TOK_CHAR_REF: { 5569 + XML_Char buf[XML_ENCODE_MAX]; 5570 + int i; 5571 + int n = XmlCharRefNumber(enc, entityTextPtr); 5572 + if (n < 0) { 5573 + if (enc == parser->m_encoding) 5574 + parser->m_eventPtr = entityTextPtr; 5575 + result = XML_ERROR_BAD_CHAR_REF; 5576 + goto endEntityValue; 5577 + } 5578 + n = XmlEncode(n, (ICHAR *)buf); 5579 + /* The XmlEncode() functions can never return 0 here. That 5580 + * error return happens if the code point passed in is either 5581 + * negative or greater than or equal to 0x110000. The 5582 + * XmlCharRefNumber() functions will all return a number 5583 + * strictly less than 0x110000 or a negative value if an error 5584 + * occurred. The negative value is intercepted above, so 5585 + * XmlEncode() is never passed a value it might return an 5586 + * error for. 5587 + */ 5588 + for (i = 0; i < n; i++) { 5589 + if (pool->end == pool->ptr && ! poolGrow(pool)) { 5590 + result = XML_ERROR_NO_MEMORY; 5839 5591 goto endEntityValue; 5840 5592 } 5841 - n = XmlEncode(n, (ICHAR *)buf); 5842 - /* The XmlEncode() functions can never return 0 here. That 5843 - * error return happens if the code point passed in is either 5844 - * negative or greater than or equal to 0x110000. The 5845 - * XmlCharRefNumber() functions will all return a number 5846 - * strictly less than 0x110000 or a negative value if an error 5847 - * occurred. The negative value is intercepted above, so 5848 - * XmlEncode() is never passed a value it might return an 5849 - * error for. 5850 - */ 5851 - for (i = 0; i < n; i++) { 5852 - if (pool->end == pool->ptr && !poolGrow(pool)) { 5853 - result = XML_ERROR_NO_MEMORY; 5854 - goto endEntityValue; 5855 - } 5856 - *(pool->ptr)++ = buf[i]; 5857 - } 5593 + *(pool->ptr)++ = buf[i]; 5858 5594 } 5859 - break; 5595 + } break; 5860 5596 case XML_TOK_PARTIAL: 5861 5597 if (enc == parser->m_encoding) 5862 5598 parser->m_eventPtr = entityTextPtr; 5863 5599 result = XML_ERROR_INVALID_TOKEN; 5864 5600 goto endEntityValue; 5865 5601 case XML_TOK_INVALID: 5866 5602 if (enc == parser->m_encoding) ................................................................................ 5887 5623 #ifdef XML_DTD 5888 5624 parser->m_prologState.inEntityValue = oldInEntityValue; 5889 5625 #endif /* XML_DTD */ 5890 5626 return result; 5891 5627 } 5892 5628 5893 5629 static void FASTCALL 5894 -normalizeLines(XML_Char *s) 5895 -{ 5630 +normalizeLines(XML_Char *s) { 5896 5631 XML_Char *p; 5897 5632 for (;; s++) { 5898 5633 if (*s == XML_T('\0')) 5899 5634 return; 5900 5635 if (*s == 0xD) 5901 5636 break; 5902 5637 } 5903 5638 p = s; 5904 5639 do { 5905 5640 if (*s == 0xD) { 5906 5641 *p++ = 0xA; 5907 5642 if (*++s == 0xA) 5908 5643 s++; 5909 - } 5910 - else 5644 + } else 5911 5645 *p++ = *s++; 5912 5646 } while (*s); 5913 5647 *p = XML_T('\0'); 5914 5648 } 5915 5649 5916 5650 static int 5917 5651 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, 5918 - const char *start, const char *end) 5919 -{ 5652 + const char *start, const char *end) { 5920 5653 const XML_Char *target; 5921 5654 XML_Char *data; 5922 5655 const char *tem; 5923 - if (!parser->m_processingInstructionHandler) { 5656 + if (! parser->m_processingInstructionHandler) { 5924 5657 if (parser->m_defaultHandler) 5925 5658 reportDefault(parser, enc, start, end); 5926 5659 return 1; 5927 5660 } 5928 5661 start += enc->minBytesPerChar * 2; 5929 5662 tem = start + XmlNameLength(enc, start); 5930 5663 target = poolStoreString(&parser->m_tempPool, enc, start, tem); 5931 - if (!target) 5664 + if (! target) 5932 5665 return 0; 5933 5666 poolFinish(&parser->m_tempPool); 5934 - data = poolStoreString(&parser->m_tempPool, enc, 5935 - XmlSkipS(enc, tem), 5936 - end - enc->minBytesPerChar*2); 5937 - if (!data) 5667 + data = poolStoreString(&parser->m_tempPool, enc, XmlSkipS(enc, tem), 5668 + end - enc->minBytesPerChar * 2); 5669 + if (! data) 5938 5670 return 0; 5939 5671 normalizeLines(data); 5940 5672 parser->m_processingInstructionHandler(parser->m_handlerArg, target, data); 5941 5673 poolClear(&parser->m_tempPool); 5942 5674 return 1; 5943 5675 } 5944 5676 5945 5677 static int 5946 -reportComment(XML_Parser parser, const ENCODING *enc, 5947 - const char *start, const char *end) 5948 -{ 5678 +reportComment(XML_Parser parser, const ENCODING *enc, const char *start, 5679 + const char *end) { 5949 5680 XML_Char *data; 5950 - if (!parser->m_commentHandler) { 5681 + if (! parser->m_commentHandler) { 5951 5682 if (parser->m_defaultHandler) 5952 5683 reportDefault(parser, enc, start, end); 5953 5684 return 1; 5954 5685 } 5955 - data = poolStoreString(&parser->m_tempPool, 5956 - enc, 5686 + data = poolStoreString(&parser->m_tempPool, enc, 5957 5687 start + enc->minBytesPerChar * 4, 5958 5688 end - enc->minBytesPerChar * 3); 5959 - if (!data) 5689 + if (! data) 5960 5690 return 0; 5961 5691 normalizeLines(data); 5962 5692 parser->m_commentHandler(parser->m_handlerArg, data); 5963 5693 poolClear(&parser->m_tempPool); 5964 5694 return 1; 5965 5695 } 5966 5696 5967 5697 static void 5968 -reportDefault(XML_Parser parser, const ENCODING *enc, 5969 - const char *s, const char *end) 5970 -{ 5698 +reportDefault(XML_Parser parser, const ENCODING *enc, const char *s, 5699 + const char *end) { 5971 5700 if (MUST_CONVERT(enc, s)) { 5972 5701 enum XML_Convert_Result convert_res; 5973 5702 const char **eventPP; 5974 5703 const char **eventEndPP; 5975 5704 if (enc == parser->m_encoding) { 5976 5705 eventPP = &parser->m_eventPtr; 5977 5706 eventEndPP = &parser->m_eventEndPtr; 5978 - } 5979 - else { 5707 + } else { 5980 5708 /* To get here, two things must be true; the parser must be 5981 5709 * using a character encoding that is not the same as the 5982 5710 * encoding passed in, and the encoding passed in must need 5983 5711 * conversion to the internal format (UTF-8 unless XML_UNICODE 5984 5712 * is defined). The only occasions on which the encoding passed 5985 5713 * in is not the same as the parser's encoding are when it is 5986 5714 * the internal encoding (e.g. a previously defined parameter ................................................................................ 5995 5723 */ 5996 5724 eventPP = &(parser->m_openInternalEntities->internalEventPtr); 5997 5725 eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); 5998 5726 /* LCOV_EXCL_STOP */ 5999 5727 } 6000 5728 do { 6001 5729 ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; 6002 - convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 5730 + convert_res 5731 + = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); 6003 5732 *eventEndPP = s; 6004 - parser->m_defaultHandler(parser->m_handlerArg, parser->m_dataBuf, (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 5733 + parser->m_defaultHandler(parser->m_handlerArg, parser->m_dataBuf, 5734 + (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); 6005 5735 *eventPP = s; 6006 - } while ((convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE)); 6007 - } 6008 - else 6009 - parser->m_defaultHandler(parser->m_handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); 5736 + } while ((convert_res != XML_CONVERT_COMPLETED) 5737 + && (convert_res != XML_CONVERT_INPUT_INCOMPLETE)); 5738 + } else 5739 + parser->m_defaultHandler(parser->m_handlerArg, (XML_Char *)s, 5740 + (int)((XML_Char *)end - (XML_Char *)s)); 6010 5741 } 6011 - 6012 5742 6013 5743 static int 6014 5744 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, 6015 - XML_Bool isId, const XML_Char *value, XML_Parser parser) 6016 -{ 5745 + XML_Bool isId, const XML_Char *value, XML_Parser parser) { 6017 5746 DEFAULT_ATTRIBUTE *att; 6018 5747 if (value || isId) { 6019 5748 /* The handling of default attributes gets messed up if we have 6020 5749 a default which duplicates a non-default. */ 6021 5750 int i; 6022 5751 for (i = 0; i < type->nDefaultAtts; i++) 6023 5752 if (attId == type->defaultAtts[i].id) 6024 5753 return 1; 6025 - if (isId && !type->idAtt && !attId->xmlns) 5754 + if (isId && ! type->idAtt && ! attId->xmlns) 6026 5755 type->idAtt = attId; 6027 5756 } 6028 5757 if (type->nDefaultAtts == type->allocDefaultAtts) { 6029 5758 if (type->allocDefaultAtts == 0) { 6030 5759 type->allocDefaultAtts = 8; 6031 - type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(parser, type->allocDefaultAtts 6032 - * sizeof(DEFAULT_ATTRIBUTE)); 6033 - if (!type->defaultAtts) { 5760 + type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC( 5761 + parser, type->allocDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); 5762 + if (! type->defaultAtts) { 6034 5763 type->allocDefaultAtts = 0; 6035 5764 return 0; 6036 5765 } 6037 - } 6038 - else { 5766 + } else { 6039 5767 DEFAULT_ATTRIBUTE *temp; 6040 5768 int count = type->allocDefaultAtts * 2; 6041 - temp = (DEFAULT_ATTRIBUTE *) 6042 - REALLOC(parser, type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); 5769 + temp = (DEFAULT_ATTRIBUTE *)REALLOC(parser, type->defaultAtts, 5770 + (count * sizeof(DEFAULT_ATTRIBUTE))); 6043 5771 if (temp == NULL) 6044 5772 return 0; 6045 5773 type->allocDefaultAtts = count; 6046 5774 type->defaultAtts = temp; 6047 5775 } 6048 5776 } 6049 5777 att = type->defaultAtts + type->nDefaultAtts; 6050 5778 att->id = attId; 6051 5779 att->value = value; 6052 5780 att->isCdata = isCdata; 6053 - if (!isCdata) 5781 + if (! isCdata) 6054 5782 attId->maybeTokenized = XML_TRUE; 6055 5783 type->nDefaultAtts += 1; 6056 5784 return 1; 6057 5785 } 6058 5786 6059 5787 static int 6060 -setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) 6061 -{ 6062 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 5788 +setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) { 5789 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 6063 5790 const XML_Char *name; 6064 5791 for (name = elementType->name; *name; name++) { 6065 5792 if (*name == XML_T(ASCII_COLON)) { 6066 5793 PREFIX *prefix; 6067 5794 const XML_Char *s; 6068 5795 for (s = elementType->name; s != name; s++) { 6069 - if (!poolAppendChar(&dtd->pool, *s)) 5796 + if (! poolAppendChar(&dtd->pool, *s)) 6070 5797 return 0; 6071 5798 } 6072 - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) 5799 + if (! poolAppendChar(&dtd->pool, XML_T('\0'))) 6073 5800 return 0; 6074 5801 prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), 6075 5802 sizeof(PREFIX)); 6076 - if (!prefix) 5803 + if (! prefix) 6077 5804 return 0; 6078 5805 if (prefix->name == poolStart(&dtd->pool)) 6079 5806 poolFinish(&dtd->pool); 6080 5807 else 6081 5808 poolDiscard(&dtd->pool); 6082 5809 elementType->prefix = prefix; 6083 - 5810 + break; 6084 5811 } 6085 5812 } 6086 5813 return 1; 6087 5814 } 6088 5815 6089 5816 static ATTRIBUTE_ID * 6090 -getAttributeId(XML_Parser parser, const ENCODING *enc, 6091 - const char *start, const char *end) 6092 -{ 6093 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 5817 +getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, 5818 + const char *end) { 5819 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 6094 5820 ATTRIBUTE_ID *id; 6095 5821 const XML_Char *name; 6096 - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) 5822 + if (! poolAppendChar(&dtd->pool, XML_T('\0'))) 6097 5823 return NULL; 6098 5824 name = poolStoreString(&dtd->pool, enc, start, end); 6099 - if (!name) 5825 + if (! name) 6100 5826 return NULL; 6101 5827 /* skip quotation mark - its storage will be re-used (like in name[-1]) */ 6102 5828 ++name; 6103 - id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); 6104 - if (!id) 5829 + id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, 5830 + sizeof(ATTRIBUTE_ID)); 5831 + if (! id) 6105 5832 return NULL; 6106 5833 if (id->name != name) 6107 5834 poolDiscard(&dtd->pool); 6108 5835 else { 6109 5836 poolFinish(&dtd->pool); 6110 - if (!parser->m_ns) 5837 + if (! parser->m_ns) 6111 5838 ; 6112 - else if (name[0] == XML_T(ASCII_x) 6113 - && name[1] == XML_T(ASCII_m) 6114 - && name[2] == XML_T(ASCII_l) 6115 - && name[3] == XML_T(ASCII_n) 6116 - && name[4] == XML_T(ASCII_s) 6117 - && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { 5839 + else if (name[0] == XML_T(ASCII_x) && name[1] == XML_T(ASCII_m) 5840 + && name[2] == XML_T(ASCII_l) && name[3] == XML_T(ASCII_n) 5841 + && name[4] == XML_T(ASCII_s) 5842 + && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { 6118 5843 if (name[5] == XML_T('\0')) 6119 5844 id->prefix = &dtd->defaultPrefix; 6120 5845 else 6121 - id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX)); 5846 + id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, 5847 + sizeof(PREFIX)); 6122 5848 id->xmlns = XML_TRUE; 6123 - } 6124 - else { 5849 + } else { 6125 5850 int i; 6126 5851 for (i = 0; name[i]; i++) { 6127 5852 /* attributes without prefix are *not* in the default namespace */ 6128 5853 if (name[i] == XML_T(ASCII_COLON)) { 6129 5854 int j; 6130 5855 for (j = 0; j < i; j++) { 6131 - if (!poolAppendChar(&dtd->pool, name[j])) 5856 + if (! poolAppendChar(&dtd->pool, name[j])) 6132 5857 return NULL; 6133 5858 } 6134 - if (!poolAppendChar(&dtd->pool, XML_T('\0'))) 5859 + if (! poolAppendChar(&dtd->pool, XML_T('\0'))) 6135 5860 return NULL; 6136 - id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), 6137 - sizeof(PREFIX)); 6138 - if (!id->prefix) 5861 + id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, 5862 + poolStart(&dtd->pool), sizeof(PREFIX)); 5863 + if (! id->prefix) 6139 5864 return NULL; 6140 5865 if (id->prefix->name == poolStart(&dtd->pool)) 6141 5866 poolFinish(&dtd->pool); 6142 5867 else 6143 5868 poolDiscard(&dtd->pool); 6144 5869 break; 6145 5870 } ................................................................................ 6148 5873 } 6149 5874 return id; 6150 5875 } 6151 5876 6152 5877 #define CONTEXT_SEP XML_T(ASCII_FF) 6153 5878 6154 5879 static const XML_Char * 6155 -getContext(XML_Parser parser) 6156 -{ 6157 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 5880 +getContext(XML_Parser parser) { 5881 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 6158 5882 HASH_TABLE_ITER iter; 6159 5883 XML_Bool needSep = XML_FALSE; 6160 5884 6161 5885 if (dtd->defaultPrefix.binding) { 6162 5886 int i; 6163 5887 int len; 6164 - if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) 5888 + if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) 6165 5889 return NULL; 6166 5890 len = dtd->defaultPrefix.binding->uriLen; 6167 5891 if (parser->m_namespaceSeparator) 6168 5892 len--; 6169 5893 for (i = 0; i < len; i++) { 6170 - if (!poolAppendChar(&parser->m_tempPool, dtd->defaultPrefix.binding->uri[i])) { 5894 + if (! poolAppendChar(&parser->m_tempPool, 5895 + dtd->defaultPrefix.binding->uri[i])) { 6171 5896 /* Because of memory caching, I don't believe this line can be 6172 5897 * executed. 6173 5898 * 6174 5899 * This is part of a loop copying the default prefix binding 6175 5900 * URI into the parser's temporary string pool. Previously, 6176 5901 * that URI was copied into the same string pool, with a 6177 5902 * terminating NUL character, as part of setContext(). When ................................................................................ 6195 5920 6196 5921 hashTableIterInit(&iter, &(dtd->prefixes)); 6197 5922 for (;;) { 6198 5923 int i; 6199 5924 int len; 6200 5925 const XML_Char *s; 6201 5926 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); 6202 - if (!prefix) 5927 + if (! prefix) 6203 5928 break; 6204 - if (!prefix->binding) { 5929 + if (! prefix->binding) { 6205 5930 /* This test appears to be (justifiable) paranoia. There does 6206 5931 * not seem to be a way of injecting a prefix without a binding 6207 5932 * that doesn't get errored long before this function is called. 6208 5933 * The test should remain for safety's sake, so we instead 6209 5934 * exclude the following line from the coverage statistics. 6210 5935 */ 6211 5936 continue; /* LCOV_EXCL_LINE */ 6212 5937 } 6213 - if (needSep && !poolAppendChar(&parser->m_tempPool, CONTEXT_SEP)) 5938 + if (needSep && ! poolAppendChar(&parser->m_tempPool, CONTEXT_SEP)) 6214 5939 return NULL; 6215 5940 for (s = prefix->name; *s; s++) 6216 - if (!poolAppendChar(&parser->m_tempPool, *s)) 5941 + if (! poolAppendChar(&parser->m_tempPool, *s)) 6217 5942 return NULL; 6218 - if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) 5943 + if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) 6219 5944 return NULL; 6220 5945 len = prefix->binding->uriLen; 6221 5946 if (parser->m_namespaceSeparator) 6222 5947 len--; 6223 5948 for (i = 0; i < len; i++) 6224 - if (!poolAppendChar(&parser->m_tempPool, prefix->binding->uri[i])) 5949 + if (! poolAppendChar(&parser->m_tempPool, prefix->binding->uri[i])) 6225 5950 return NULL; 6226 5951 needSep = XML_TRUE; 6227 5952 } 6228 - 6229 5953 6230 5954 hashTableIterInit(&iter, &(dtd->generalEntities)); 6231 5955 for (;;) { 6232 5956 const XML_Char *s; 6233 5957 ENTITY *e = (ENTITY *)hashTableIterNext(&iter); 6234 - if (!e) 5958 + if (! e) 6235 5959 break; 6236 - if (!e->open) 5960 + if (! e->open) 6237 5961 continue; 6238 - if (needSep && !poolAppendChar(&parser->m_tempPool, CONTEXT_SEP)) 5962 + if (needSep && ! poolAppendChar(&parser->m_tempPool, CONTEXT_SEP)) 6239 5963 return NULL; 6240 5964 for (s = e->name; *s; s++) 6241 - if (!poolAppendChar(&parser->m_tempPool, *s)) 5965 + if (! poolAppendChar(&parser->m_tempPool, *s)) 6242 5966 return 0; 6243 5967 needSep = XML_TRUE; 6244 5968 } 6245 5969 6246 - if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 5970 + if (! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 6247 5971 return NULL; 6248 5972 return parser->m_tempPool.start; 6249 5973 } 6250 5974 6251 5975 static XML_Bool 6252 -setContext(XML_Parser parser, const XML_Char *context) 6253 -{ 6254 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 5976 +setContext(XML_Parser parser, const XML_Char *context) { 5977 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 6255 5978 const XML_Char *s = context; 6256 5979 6257 5980 while (*context != XML_T('\0')) { 6258 5981 if (*s == CONTEXT_SEP || *s == XML_T('\0')) { 6259 5982 ENTITY *e; 6260 - if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 5983 + if (! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 6261 5984 return XML_FALSE; 6262 - e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&parser->m_tempPool), 0); 5985 + e = (ENTITY *)lookup(parser, &dtd->generalEntities, 5986 + poolStart(&parser->m_tempPool), 0); 6263 5987 if (e) 6264 5988 e->open = XML_TRUE; 6265 5989 if (*s != XML_T('\0')) 6266 5990 s++; 6267 5991 context = s; 6268 5992 poolDiscard(&parser->m_tempPool); 6269 - } 6270 - else if (*s == XML_T(ASCII_EQUALS)) { 5993 + } else if (*s == XML_T(ASCII_EQUALS)) { 6271 5994 PREFIX *prefix; 6272 5995 if (poolLength(&parser->m_tempPool) == 0) 6273 5996 prefix = &dtd->defaultPrefix; 6274 5997 else { 6275 - if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 5998 + if (! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 6276 5999 return XML_FALSE; 6277 - prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&parser->m_tempPool), 6278 - sizeof(PREFIX)); 6279 - if (!prefix) 6000 + prefix 6001 + = (PREFIX *)lookup(parser, &dtd->prefixes, 6002 + poolStart(&parser->m_tempPool), sizeof(PREFIX)); 6003 + if (! prefix) 6280 6004 return XML_FALSE; 6281 6005 if (prefix->name == poolStart(&parser->m_tempPool)) { 6282 6006 prefix->name = poolCopyString(&dtd->pool, prefix->name); 6283 - if (!prefix->name) 6007 + if (! prefix->name) 6284 6008 return XML_FALSE; 6285 6009 } 6286 6010 poolDiscard(&parser->m_tempPool); 6287 6011 } 6288 - for (context = s + 1; 6289 - *context != CONTEXT_SEP && *context != XML_T('\0'); 6012 + for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0'); 6290 6013 context++) 6291 - if (!poolAppendChar(&parser->m_tempPool, *context)) 6014 + if (! poolAppendChar(&parser->m_tempPool, *context)) 6292 6015 return XML_FALSE; 6293 - if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 6016 + if (! poolAppendChar(&parser->m_tempPool, XML_T('\0'))) 6294 6017 return XML_FALSE; 6295 6018 if (addBinding(parser, prefix, NULL, poolStart(&parser->m_tempPool), 6296 - &parser->m_inheritedBindings) != XML_ERROR_NONE) 6019 + &parser->m_inheritedBindings) 6020 + != XML_ERROR_NONE) 6297 6021 return XML_FALSE; 6298 6022 poolDiscard(&parser->m_tempPool); 6299 6023 if (*context != XML_T('\0')) 6300 6024 ++context; 6301 6025 s = context; 6302 - } 6303 - else { 6304 - if (!poolAppendChar(&parser->m_tempPool, *s)) 6026 + } else { 6027 + if (! poolAppendChar(&parser->m_tempPool, *s)) 6305 6028 return XML_FALSE; 6306 6029 s++; 6307 6030 } 6308 6031 } 6309 6032 return XML_TRUE; 6310 6033 } 6311 6034 6312 6035 static void FASTCALL 6313 -normalizePublicId(XML_Char *publicId) 6314 -{ 6036 +normalizePublicId(XML_Char *publicId) { 6315 6037 XML_Char *p = publicId; 6316 6038 XML_Char *s; 6317 6039 for (s = publicId; *s; s++) { 6318 6040 switch (*s) { 6319 6041 case 0x20: 6320 6042 case 0xD: 6321 6043 case 0xA: ................................................................................ 6328 6050 } 6329 6051 if (p != publicId && p[-1] == 0x20) 6330 6052 --p; 6331 6053 *p = XML_T('\0'); 6332 6054 } 6333 6055 6334 6056 static DTD * 6335 -dtdCreate(const XML_Memory_Handling_Suite *ms) 6336 -{ 6057 +dtdCreate(const XML_Memory_Handling_Suite *ms) { 6337 6058 DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD)); 6338 6059 if (p == NULL) 6339 6060 return p; 6340 6061 poolInit(&(p->pool), ms); 6341 6062 poolInit(&(p->entityValuePool), ms); 6342 6063 hashTableInit(&(p->generalEntities), ms); 6343 6064 hashTableInit(&(p->elementTypes), ms); ................................................................................ 6361 6082 p->keepProcessing = XML_TRUE; 6362 6083 p->hasParamEntityRefs = XML_FALSE; 6363 6084 p->standalone = XML_FALSE; 6364 6085 return p; 6365 6086 } 6366 6087 6367 6088 static void 6368 -dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) 6369 -{ 6089 +dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) { 6370 6090 HASH_TABLE_ITER iter; 6371 6091 hashTableIterInit(&iter, &(p->elementTypes)); 6372 6092 for (;;) { 6373 6093 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); 6374 - if (!e) 6094 + if (! e) 6375 6095 break; 6376 6096 if (e->allocDefaultAtts != 0) 6377 6097 ms->free_fcn(e->defaultAtts); 6378 6098 } 6379 6099 hashTableClear(&(p->generalEntities)); 6380 6100 #ifdef XML_DTD 6381 6101 p->paramEntityRead = XML_FALSE; ................................................................................ 6403 6123 6404 6124 p->keepProcessing = XML_TRUE; 6405 6125 p->hasParamEntityRefs = XML_FALSE; 6406 6126 p->standalone = XML_FALSE; 6407 6127 } 6408 6128 6409 6129 static void 6410 -dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) 6411 -{ 6130 +dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) { 6412 6131 HASH_TABLE_ITER iter; 6413 6132 hashTableIterInit(&iter, &(p->elementTypes)); 6414 6133 for (;;) { 6415 6134 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); 6416 - if (!e) 6135 + if (! e) 6417 6136 break; 6418 6137 if (e->allocDefaultAtts != 0) 6419 6138 ms->free_fcn(e->defaultAtts); 6420 6139 } 6421 6140 hashTableDestroy(&(p->generalEntities)); 6422 6141 #ifdef XML_DTD 6423 6142 hashTableDestroy(&(p->paramEntities)); ................................................................................ 6434 6153 ms->free_fcn(p); 6435 6154 } 6436 6155 6437 6156 /* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. 6438 6157 The new DTD has already been initialized. 6439 6158 */ 6440 6159 static int 6441 -dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) 6442 -{ 6160 +dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, 6161 + const XML_Memory_Handling_Suite *ms) { 6443 6162 HASH_TABLE_ITER iter; 6444 6163 6445 6164 /* Copy the prefix table. */ 6446 6165 6447 6166 hashTableIterInit(&iter, &(oldDtd->prefixes)); 6448 6167 for (;;) { 6449 6168 const XML_Char *name; 6450 6169 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); 6451 - if (!oldP) 6170 + if (! oldP) 6452 6171 break; 6453 6172 name = poolCopyString(&(newDtd->pool), oldP->name); 6454 - if (!name) 6173 + if (! name) 6455 6174 return 0; 6456 - if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX))) 6175 + if (! lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX))) 6457 6176 return 0; 6458 6177 } 6459 6178 6460 6179 hashTableIterInit(&iter, &(oldDtd->attributeIds)); 6461 6180 6462 6181 /* Copy the attribute id table. */ 6463 6182 6464 6183 for (;;) { 6465 6184 ATTRIBUTE_ID *newA; 6466 6185 const XML_Char *name; 6467 6186 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); 6468 6187 6469 - if (!oldA) 6188 + if (! oldA) 6470 6189 break; 6471 6190 /* Remember to allocate the scratch byte before the name. */ 6472 - if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) 6191 + if (! poolAppendChar(&(newDtd->pool), XML_T('\0'))) 6473 6192 return 0; 6474 6193 name = poolCopyString(&(newDtd->pool), oldA->name); 6475 - if (!name) 6194 + if (! name) 6476 6195 return 0; 6477 6196 ++name; 6478 6197 newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name, 6479 6198 sizeof(ATTRIBUTE_ID)); 6480 - if (!newA) 6199 + if (! newA) 6481 6200 return 0; 6482 6201 newA->maybeTokenized = oldA->maybeTokenized; 6483 6202 if (oldA->prefix) { 6484 6203 newA->xmlns = oldA->xmlns; 6485 6204 if (oldA->prefix == &oldDtd->defaultPrefix) 6486 6205 newA->prefix = &newDtd->defaultPrefix; 6487 6206 else ................................................................................ 6495 6214 hashTableIterInit(&iter, &(oldDtd->elementTypes)); 6496 6215 6497 6216 for (;;) { 6498 6217 int i; 6499 6218 ELEMENT_TYPE *newE; 6500 6219 const XML_Char *name; 6501 6220 const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); 6502 - if (!oldE) 6221 + if (! oldE) 6503 6222 break; 6504 6223 name = poolCopyString(&(newDtd->pool), oldE->name); 6505 - if (!name) 6224 + if (! name) 6506 6225 return 0; 6507 6226 newE = (ELEMENT_TYPE *)lookup(oldParser, &(newDtd->elementTypes), name, 6508 6227 sizeof(ELEMENT_TYPE)); 6509 - if (!newE) 6228 + if (! newE) 6510 6229 return 0; 6511 6230 if (oldE->nDefaultAtts) { 6512 - newE->defaultAtts = (DEFAULT_ATTRIBUTE *) 6513 - ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); 6514 - if (!newE->defaultAtts) { 6231 + newE->defaultAtts = (DEFAULT_ATTRIBUTE *)ms->malloc_fcn( 6232 + oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); 6233 + if (! newE->defaultAtts) { 6515 6234 return 0; 6516 6235 } 6517 6236 } 6518 6237 if (oldE->idAtt) 6519 - newE->idAtt = (ATTRIBUTE_ID *) 6520 - lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0); 6238 + newE->idAtt = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), 6239 + oldE->idAtt->name, 0); 6521 6240 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; 6522 6241 if (oldE->prefix) 6523 6242 newE->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), 6524 6243 oldE->prefix->name, 0); 6525 6244 for (i = 0; i < newE->nDefaultAtts; i++) { 6526 - newE->defaultAtts[i].id = (ATTRIBUTE_ID *) 6527 - lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); 6245 + newE->defaultAtts[i].id = (ATTRIBUTE_ID *)lookup( 6246 + oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); 6528 6247 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; 6529 6248 if (oldE->defaultAtts[i].value) { 6530 6249 newE->defaultAtts[i].value 6531 6250 = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value); 6532 - if (!newE->defaultAtts[i].value) 6251 + if (! newE->defaultAtts[i].value) 6533 6252 return 0; 6534 - } 6535 - else 6253 + } else 6536 6254 newE->defaultAtts[i].value = NULL; 6537 6255 } 6538 6256 } 6539 6257 6540 6258 /* Copy the entity tables. */ 6541 - if (!copyEntityTable(oldParser, 6542 - &(newDtd->generalEntities), 6543 - &(newDtd->pool), 6544 - &(oldDtd->generalEntities))) 6545 - return 0; 6259 + if (! copyEntityTable(oldParser, &(newDtd->generalEntities), &(newDtd->pool), 6260 + &(oldDtd->generalEntities))) 6261 + return 0; 6546 6262 6547 6263 #ifdef XML_DTD 6548 - if (!copyEntityTable(oldParser, 6549 - &(newDtd->paramEntities), 6550 - &(newDtd->pool), 6551 - &(oldDtd->paramEntities))) 6552 - return 0; 6264 + if (! copyEntityTable(oldParser, &(newDtd->paramEntities), &(newDtd->pool), 6265 + &(oldDtd->paramEntities))) 6266 + return 0; 6553 6267 newDtd->paramEntityRead = oldDtd->paramEntityRead; 6554 6268 #endif /* XML_DTD */ 6555 6269 6556 6270 newDtd->keepProcessing = oldDtd->keepProcessing; 6557 6271 newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; 6558 6272 newDtd->standalone = oldDtd->standalone; 6559 6273 ................................................................................ 6562 6276 newDtd->scaffold = oldDtd->scaffold; 6563 6277 newDtd->contentStringLen = oldDtd->contentStringLen; 6564 6278 newDtd->scaffSize = oldDtd->scaffSize; 6565 6279 newDtd->scaffLevel = oldDtd->scaffLevel; 6566 6280 newDtd->scaffIndex = oldDtd->scaffIndex; 6567 6281 6568 6282 return 1; 6569 -} /* End dtdCopy */ 6283 +} /* End dtdCopy */ 6570 6284 6571 6285 static int 6572 -copyEntityTable(XML_Parser oldParser, 6573 - HASH_TABLE *newTable, 6574 - STRING_POOL *newPool, 6575 - const HASH_TABLE *oldTable) 6576 -{ 6286 +copyEntityTable(XML_Parser oldParser, HASH_TABLE *newTable, 6287 + STRING_POOL *newPool, const HASH_TABLE *oldTable) { 6577 6288 HASH_TABLE_ITER iter; 6578 6289 const XML_Char *cachedOldBase = NULL; 6579 6290 const XML_Char *cachedNewBase = NULL; 6580 6291 6581 6292 hashTableIterInit(&iter, oldTable); 6582 6293 6583 6294 for (;;) { 6584 6295 ENTITY *newE; 6585 6296 const XML_Char *name; 6586 6297 const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); 6587 - if (!oldE) 6298 + if (! oldE) 6588 6299 break; 6589 6300 name = poolCopyString(newPool, oldE->name); 6590 - if (!name) 6301 + if (! name) 6591 6302 return 0; 6592 6303 newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY)); 6593 - if (!newE) 6304 + if (! newE) 6594 6305 return 0; 6595 6306 if (oldE->systemId) { 6596 6307 const XML_Char *tem = poolCopyString(newPool, oldE->systemId); 6597 - if (!tem) 6308 + if (! tem) 6598 6309 return 0; 6599 6310 newE->systemId = tem; 6600 6311 if (oldE->base) { 6601 6312 if (oldE->base == cachedOldBase) 6602 6313 newE->base = cachedNewBase; 6603 6314 else { 6604 6315 cachedOldBase = oldE->base; 6605 6316 tem = poolCopyString(newPool, cachedOldBase); 6606 - if (!tem) 6317 + if (! tem) 6607 6318 return 0; 6608 6319 cachedNewBase = newE->base = tem; 6609 6320 } 6610 6321 } 6611 6322 if (oldE->publicId) { 6612 6323 tem = poolCopyString(newPool, oldE->publicId); 6613 - if (!tem) 6324 + if (! tem) 6614 6325 return 0; 6615 6326 newE->publicId = tem; 6616 6327 } 6617 - } 6618 - else { 6619 - const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, 6620 - oldE->textLen); 6621 - if (!tem) 6328 + } else { 6329 + const XML_Char *tem 6330 + = poolCopyStringN(newPool, oldE->textPtr, oldE->textLen); 6331 + if (! tem) 6622 6332 return 0; 6623 6333 newE->textPtr = tem; 6624 6334 newE->textLen = oldE->textLen; 6625 6335 } 6626 6336 if (oldE->notation) { 6627 6337 const XML_Char *tem = poolCopyString(newPool, oldE->notation); 6628 - if (!tem) 6338 + if (! tem) 6629 6339 return 0; 6630 6340 newE->notation = tem; 6631 6341 } 6632 6342 newE->is_param = oldE->is_param; 6633 6343 newE->is_internal = oldE->is_internal; 6634 6344 } 6635 6345 return 1; 6636 6346 } 6637 6347 6638 6348 #define INIT_POWER 6 6639 6349 6640 6350 static XML_Bool FASTCALL 6641 -keyeq(KEY s1, KEY s2) 6642 -{ 6351 +keyeq(KEY s1, KEY s2) { 6643 6352 for (; *s1 == *s2; s1++, s2++) 6644 6353 if (*s1 == 0) 6645 6354 return XML_TRUE; 6646 6355 return XML_FALSE; 6647 6356 } 6648 6357 6649 6358 static size_t 6650 -keylen(KEY s) 6651 -{ 6359 +keylen(KEY s) { 6652 6360 size_t len = 0; 6653 - for (; *s; s++, len++); 6361 + for (; *s; s++, len++) 6362 + ; 6654 6363 return len; 6655 6364 } 6656 6365 6657 6366 static void 6658 -copy_salt_to_sipkey(XML_Parser parser, struct sipkey * key) 6659 -{ 6367 +copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key) { 6660 6368 key->k[0] = 0; 6661 6369 key->k[1] = get_hash_secret_salt(parser); 6662 6370 } 6663 6371 6664 6372 static unsigned long FASTCALL 6665 -hash(XML_Parser parser, KEY s) 6666 -{ 6373 +hash(XML_Parser parser, KEY s) { 6667 6374 struct siphash state; 6668 6375 struct sipkey key; 6669 6376 (void)sip24_valid; 6670 6377 copy_salt_to_sipkey(parser, &key); 6671 6378 sip24_init(&state, &key); 6672 6379 sip24_update(&state, s, keylen(s) * sizeof(XML_Char)); 6673 6380 return (unsigned long)sip24_final(&state); 6674 6381 } 6675 6382 6676 6383 static NAMED * 6677 -lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) 6678 -{ 6384 +lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) { 6679 6385 size_t i; 6680 6386 if (table->size == 0) { 6681 6387 size_t tsize; 6682 - if (!createSize) 6388 + if (! createSize) 6683 6389 return NULL; 6684 6390 table->power = INIT_POWER; 6685 6391 /* table->size is a power of 2 */ 6686 6392 table->size = (size_t)1 << INIT_POWER; 6687 6393 tsize = table->size * sizeof(NAMED *); 6688 6394 table->v = (NAMED **)table->mem->malloc_fcn(tsize); 6689 - if (!table->v) { 6395 + if (! table->v) { 6690 6396 table->size = 0; 6691 6397 return NULL; 6692 6398 } 6693 6399 memset(table->v, 0, tsize); 6694 6400 i = hash(parser, name) & ((unsigned long)table->size - 1); 6695 - } 6696 - else { 6401 + } else { 6697 6402 unsigned long h = hash(parser, name); 6698 6403 unsigned long mask = (unsigned long)table->size - 1; 6699 6404 unsigned char step = 0; 6700 6405 i = h & mask; 6701 6406 while (table->v[i]) { 6702 6407 if (keyeq(name, table->v[i]->name)) 6703 6408 return table->v[i]; 6704 - if (!step) 6409 + if (! step) 6705 6410 step = PROBE_STEP(h, mask, table->power); 6706 6411 i < step ? (i += table->size - step) : (i -= step); 6707 6412 } 6708 - if (!createSize) 6413 + if (! createSize) 6709 6414 return NULL; 6710 6415 6711 6416 /* check for overflow (table is half full) */ 6712 6417 if (table->used >> (table->power - 1)) { 6713 6418 unsigned char newPower = table->power + 1; 6714 6419 size_t newSize = (size_t)1 << newPower; 6715 6420 unsigned long newMask = (unsigned long)newSize - 1; 6716 6421 size_t tsize = newSize * sizeof(NAMED *); 6717 6422 NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); 6718 - if (!newV) 6423 + if (! newV) 6719 6424 return NULL; 6720 6425 memset(newV, 0, tsize); 6721 6426 for (i = 0; i < table->size; i++) 6722 6427 if (table->v[i]) { 6723 6428 unsigned long newHash = hash(parser, table->v[i]->name); 6724 6429 size_t j = newHash & newMask; 6725 6430 step = 0; 6726 6431 while (newV[j]) { 6727 - if (!step) 6432 + if (! step) 6728 6433 step = PROBE_STEP(newHash, newMask, newPower); 6729 6434 j < step ? (j += newSize - step) : (j -= step); 6730 6435 } 6731 6436 newV[j] = table->v[i]; 6732 6437 } 6733 6438 table->mem->free_fcn(table->v); 6734 6439 table->v = newV; 6735 6440 table->power = newPower; 6736 6441 table->size = newSize; 6737 6442 i = h & newMask; 6738 6443 step = 0; 6739 6444 while (table->v[i]) { 6740 - if (!step) 6445 + if (! step) 6741 6446 step = PROBE_STEP(h, newMask, newPower); 6742 6447 i < step ? (i += newSize - step) : (i -= step); 6743 6448 } 6744 6449 } 6745 6450 } 6746 6451 table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); 6747 - if (!table->v[i]) 6452 + if (! table->v[i]) 6748 6453 return NULL; 6749 6454 memset(table->v[i], 0, createSize); 6750 6455 table->v[i]->name = name; 6751 6456 (table->used)++; 6752 6457 return table->v[i]; 6753 6458 } 6754 6459 6755 6460 static void FASTCALL 6756 -hashTableClear(HASH_TABLE *table) 6757 -{ 6461 +hashTableClear(HASH_TABLE *table) { 6758 6462 size_t i; 6759 6463 for (i = 0; i < table->size; i++) { 6760 6464 table->mem->free_fcn(table->v[i]); 6761 6465 table->v[i] = NULL; 6762 6466 } 6763 6467 table->used = 0; 6764 6468 } 6765 6469 6766 6470 static void FASTCALL 6767 -hashTableDestroy(HASH_TABLE *table) 6768 -{ 6471 +hashTableDestroy(HASH_TABLE *table) { 6769 6472 size_t i; 6770 6473 for (i = 0; i < table->size; i++) 6771 6474 table->mem->free_fcn(table->v[i]); 6772 6475 table->mem->free_fcn(table->v); 6773 6476 } 6774 6477 6775 6478 static void FASTCALL 6776 -hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) 6777 -{ 6479 +hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) { 6778 6480 p->power = 0; 6779 6481 p->size = 0; 6780 6482 p->used = 0; 6781 6483 p->v = NULL; 6782 6484 p->mem = ms; 6783 6485 } 6784 6486 6785 6487 static void FASTCALL 6786 -hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) 6787 -{ 6488 +hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) { 6788 6489 iter->p = table->v; 6789 6490 iter->end = iter->p + table->size; 6790 6491 } 6791 6492 6792 -static NAMED * FASTCALL 6793 -hashTableIterNext(HASH_TABLE_ITER *iter) 6794 -{ 6493 +static NAMED *FASTCALL 6494 +hashTableIterNext(HASH_TABLE_ITER *iter) { 6795 6495 while (iter->p != iter->end) { 6796 6496 NAMED *tem = *(iter->p)++; 6797 6497 if (tem) 6798 6498 return tem; 6799 6499 } 6800 6500 return NULL; 6801 6501 } 6802 6502 6803 6503 static void FASTCALL 6804 -poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) 6805 -{ 6504 +poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) { 6806 6505 pool->blocks = NULL; 6807 6506 pool->freeBlocks = NULL; 6808 6507 pool->start = NULL; 6809 6508 pool->ptr = NULL; 6810 6509 pool->end = NULL; 6811 6510 pool->mem = ms; 6812 6511 } 6813 6512 6814 6513 static void FASTCALL 6815 -poolClear(STRING_POOL *pool) 6816 -{ 6817 - if (!pool->freeBlocks) 6514 +poolClear(STRING_POOL *pool) { 6515 + if (! pool->freeBlocks) 6818 6516 pool->freeBlocks = pool->blocks; 6819 6517 else { 6820 6518 BLOCK *p = pool->blocks; 6821 6519 while (p) { 6822 6520 BLOCK *tem = p->next; 6823 6521 p->next = pool->freeBlocks; 6824 6522 pool->freeBlocks = p; ................................................................................ 6828 6526 pool->blocks = NULL; 6829 6527 pool->start = NULL; 6830 6528 pool->ptr = NULL; 6831 6529 pool->end = NULL; 6832 6530 } 6833 6531 6834 6532 static void FASTCALL 6835 -poolDestroy(STRING_POOL *pool) 6836 -{ 6533 +poolDestroy(STRING_POOL *pool) { 6837 6534 BLOCK *p = pool->blocks; 6838 6535 while (p) { 6839 6536 BLOCK *tem = p->next; 6840 6537 pool->mem->free_fcn(p); 6841 6538 p = tem; 6842 6539 } 6843 6540 p = pool->freeBlocks; ................................................................................ 6845 6542 BLOCK *tem = p->next; 6846 6543 pool->mem->free_fcn(p); 6847 6544 p = tem; 6848 6545 } 6849 6546 } 6850 6547 6851 6548 static XML_Char * 6852 -poolAppend(STRING_POOL *pool, const ENCODING *enc, 6853 - const char *ptr, const char *end) 6854 -{ 6855 - if (!pool->ptr && !poolGrow(pool)) 6549 +poolAppend(STRING_POOL *pool, const ENCODING *enc, const char *ptr, 6550 + const char *end) { 6551 + if (! pool->ptr && ! poolGrow(pool)) 6856 6552 return NULL; 6857 6553 for (;;) { 6858 - const enum XML_Convert_Result convert_res = XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); 6859 - if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) 6554 + const enum XML_Convert_Result convert_res = XmlConvert( 6555 + enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); 6556 + if ((convert_res == XML_CONVERT_COMPLETED) 6557 + || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) 6860 6558 break; 6861 - if (!poolGrow(pool)) 6559 + if (! poolGrow(pool)) 6862 6560 return NULL; 6863 6561 } 6864 6562 return pool->start; 6865 6563 } 6866 6564 6867 -static const XML_Char * FASTCALL 6868 -poolCopyString(STRING_POOL *pool, const XML_Char *s) 6869 -{ 6565 +static const XML_Char *FASTCALL 6566 +poolCopyString(STRING_POOL *pool, const XML_Char *s) { 6870 6567 do { 6871 - if (!poolAppendChar(pool, *s)) 6568 + if (! poolAppendChar(pool, *s)) 6872 6569 return NULL; 6873 6570 } while (*s++); 6874 6571 s = pool->start; 6875 6572 poolFinish(pool); 6876 6573 return s; 6877 6574 } 6878 6575 6879 6576 static const XML_Char * 6880 -poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) 6881 -{ 6882 - if (!pool->ptr && !poolGrow(pool)) { 6577 +poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) { 6578 + if (! pool->ptr && ! poolGrow(pool)) { 6883 6579 /* The following line is unreachable given the current usage of 6884 6580 * poolCopyStringN(). Currently it is called from exactly one 6885 6581 * place to copy the text of a simple general entity. By that 6886 6582 * point, the name of the entity is already stored in the pool, so 6887 6583 * pool->ptr cannot be NULL. 6888 6584 * 6889 6585 * If poolCopyStringN() is used elsewhere as it well might be, ................................................................................ 6890 6586 * this line may well become executable again. Regardless, this 6891 6587 * sort of check shouldn't be removed lightly, so we just exclude 6892 6588 * it from the coverage statistics. 6893 6589 */ 6894 6590 return NULL; /* LCOV_EXCL_LINE */ 6895 6591 } 6896 6592 for (; n > 0; --n, s++) { 6897 - if (!poolAppendChar(pool, *s)) 6593 + if (! poolAppendChar(pool, *s)) 6898 6594 return NULL; 6899 6595 } 6900 6596 s = pool->start; 6901 6597 poolFinish(pool); 6902 6598 return s; 6903 6599 } 6904 6600 6905 -static const XML_Char * FASTCALL 6906 -poolAppendString(STRING_POOL *pool, const XML_Char *s) 6907 -{ 6601 +static const XML_Char *FASTCALL 6602 +poolAppendString(STRING_POOL *pool, const XML_Char *s) { 6908 6603 while (*s) { 6909 - if (!poolAppendChar(pool, *s)) 6604 + if (! poolAppendChar(pool, *s)) 6910 6605 return NULL; 6911 6606 s++; 6912 6607 } 6913 6608 return pool->start; 6914 6609 } 6915 6610 6916 6611 static XML_Char * 6917 -poolStoreString(STRING_POOL *pool, const ENCODING *enc, 6918 - const char *ptr, const char *end) 6919 -{ 6920 - if (!poolAppend(pool, enc, ptr, end)) 6612 +poolStoreString(STRING_POOL *pool, const ENCODING *enc, const char *ptr, 6613 + const char *end) { 6614 + if (! poolAppend(pool, enc, ptr, end)) 6921 6615 return NULL; 6922 - if (pool->ptr == pool->end && !poolGrow(pool)) 6616 + if (pool->ptr == pool->end && ! poolGrow(pool)) 6923 6617 return NULL; 6924 6618 *(pool->ptr)++ = 0; 6925 6619 return pool->start; 6926 6620 } 6927 6621 6928 6622 static size_t 6929 -poolBytesToAllocateFor(int blockSize) 6930 -{ 6623 +poolBytesToAllocateFor(int blockSize) { 6931 6624 /* Unprotected math would be: 6932 6625 ** return offsetof(BLOCK, s) + blockSize * sizeof(XML_Char); 6933 6626 ** 6934 6627 ** Detect overflow, avoiding _signed_ overflow undefined behavior 6935 6628 ** For a + b * c we check b * c in isolation first, so that addition of a 6936 6629 ** on top has no chance of making us accept a small non-negative number 6937 6630 */ 6938 - const size_t stretch = sizeof(XML_Char); /* can be 4 bytes */ 6631 + const size_t stretch = sizeof(XML_Char); /* can be 4 bytes */ 6939 6632 6940 6633 if (blockSize <= 0) 6941 6634 return 0; 6942 6635 6943 6636 if (blockSize > (int)(INT_MAX / stretch)) 6944 6637 return 0; 6945 6638 6946 6639 { 6947 6640 const int stretchedBlockSize = blockSize * (int)stretch; 6948 - const int bytesToAllocate = (int)( 6949 - offsetof(BLOCK, s) + (unsigned)stretchedBlockSize); 6641 + const int bytesToAllocate 6642 + = (int)(offsetof(BLOCK, s) + (unsigned)stretchedBlockSize); 6950 6643 if (bytesToAllocate < 0) 6951 6644 return 0; 6952 6645 6953 6646 return (size_t)bytesToAllocate; 6954 6647 } 6955 6648 } 6956 6649 6957 6650 static XML_Bool FASTCALL 6958 -poolGrow(STRING_POOL *pool) 6959 -{ 6651 +poolGrow(STRING_POOL *pool) { 6960 6652 if (pool->freeBlocks) { 6961 6653 if (pool->start == 0) { 6962 6654 pool->blocks = pool->freeBlocks; 6963 6655 pool->freeBlocks = pool->freeBlocks->next; 6964 6656 pool->blocks->next = NULL; 6965 6657 pool->start = pool->blocks->s; 6966 6658 pool->end = pool->start + pool->blocks->size; ................................................................................ 6978 6670 pool->start = pool->blocks->s; 6979 6671 pool->end = pool->start + pool->blocks->size; 6980 6672 return XML_TRUE; 6981 6673 } 6982 6674 } 6983 6675 if (pool->blocks && pool->start == pool->blocks->s) { 6984 6676 BLOCK *temp; 6985 - int blockSize = (int)((unsigned)(pool->end - pool->start)*2U); 6677 + int blockSize = (int)((unsigned)(pool->end - pool->start) * 2U); 6986 6678 size_t bytesToAllocate; 6987 6679 6988 6680 /* NOTE: Needs to be calculated prior to calling `realloc` 6989 6681 to avoid dangling pointers: */ 6990 6682 const ptrdiff_t offsetInsideBlock = pool->ptr - pool->start; 6991 6683 6992 6684 if (blockSize < 0) { ................................................................................ 6999 6691 return XML_FALSE; /* LCOV_EXCL_LINE */ 7000 6692 } 7001 6693 7002 6694 bytesToAllocate = poolBytesToAllocateFor(blockSize); 7003 6695 if (bytesToAllocate == 0) 7004 6696 return XML_FALSE; 7005 6697 7006 - temp = (BLOCK *) 7007 - pool->mem->realloc_fcn(pool->blocks, (unsigned)bytesToAllocate); 6698 + temp = (BLOCK *)pool->mem->realloc_fcn(pool->blocks, 6699 + (unsigned)bytesToAllocate); 7008 6700 if (temp == NULL) 7009 6701 return XML_FALSE; 7010 6702 pool->blocks = temp; 7011 6703 pool->blocks->size = blockSize; 7012 6704 pool->ptr = pool->blocks->s + offsetInsideBlock; 7013 6705 pool->start = pool->blocks->s; 7014 6706 pool->end = pool->start + blockSize; 7015 - } 7016 - else { 6707 + } else { 7017 6708 BLOCK *tem; 7018 6709 int blockSize = (int)(pool->end - pool->start); 7019 6710 size_t bytesToAllocate; 7020 6711 7021 6712 if (blockSize < 0) { 7022 6713 /* This condition traps a situation where either more than 7023 6714 * INT_MAX bytes have already been allocated (which is prevented ................................................................................ 7024 6715 * by various pieces of program logic, not least this one, never 7025 6716 * mind the unlikelihood of actually having that much memory) or 7026 6717 * the pool control fields have been corrupted (which could 7027 6718 * conceivably happen in an extremely buggy user handler 7028 6719 * function). Either way it isn't readily testable, so we 7029 6720 * exclude it from the coverage statistics. 7030 6721 */ 7031 - return XML_FALSE; /* LCOV_EXCL_LINE */ 6722 + return XML_FALSE; /* LCOV_EXCL_LINE */ 7032 6723 } 7033 6724 7034 6725 if (blockSize < INIT_BLOCK_SIZE) 7035 6726 blockSize = INIT_BLOCK_SIZE; 7036 6727 else { 7037 6728 /* Detect overflow, avoiding _signed_ overflow undefined behavior */ 7038 6729 if ((int)((unsigned)blockSize * 2U) < 0) { ................................................................................ 7042 6733 } 7043 6734 7044 6735 bytesToAllocate = poolBytesToAllocateFor(blockSize); 7045 6736 if (bytesToAllocate == 0) 7046 6737 return XML_FALSE; 7047 6738 7048 6739 tem = (BLOCK *)pool->mem->malloc_fcn(bytesToAllocate); 7049 - if (!tem) 6740 + if (! tem) 7050 6741 return XML_FALSE; 7051 6742 tem->size = blockSize; 7052 6743 tem->next = pool->blocks; 7053 6744 pool->blocks = tem; 7054 6745 if (pool->ptr != pool->start) 7055 - memcpy(tem->s, pool->start, 7056 - (pool->ptr - pool->start) * sizeof(XML_Char)); 6746 + memcpy(tem->s, pool->start, (pool->ptr - pool->start) * sizeof(XML_Char)); 7057 6747 pool->ptr = tem->s + (pool->ptr - pool->start); 7058 6748 pool->start = tem->s; 7059 6749 pool->end = tem->s + blockSize; 7060 6750 } 7061 6751 return XML_TRUE; 7062 6752 } 7063 6753 7064 6754 static int FASTCALL 7065 -nextScaffoldPart(XML_Parser parser) 7066 -{ 7067 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 7068 - CONTENT_SCAFFOLD * me; 6755 +nextScaffoldPart(XML_Parser parser) { 6756 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 6757 + CONTENT_SCAFFOLD *me; 7069 6758 int next; 7070 6759 7071 - if (!dtd->scaffIndex) { 6760 + if (! dtd->scaffIndex) { 7072 6761 dtd->scaffIndex = (int *)MALLOC(parser, parser->m_groupSize * sizeof(int)); 7073 - if (!dtd->scaffIndex) 6762 + if (! dtd->scaffIndex) 7074 6763 return -1; 7075 6764 dtd->scaffIndex[0] = 0; 7076 6765 } 7077 6766 7078 6767 if (dtd->scaffCount >= dtd->scaffSize) { 7079 6768 CONTENT_SCAFFOLD *temp; 7080 6769 if (dtd->scaffold) { 7081 - temp = (CONTENT_SCAFFOLD *) 7082 - REALLOC(parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); 6770 + temp = (CONTENT_SCAFFOLD *)REALLOC( 6771 + parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); 7083 6772 if (temp == NULL) 7084 6773 return -1; 7085 6774 dtd->scaffSize *= 2; 7086 - } 7087 - else { 6775 + } else { 7088 6776 temp = (CONTENT_SCAFFOLD *)MALLOC(parser, INIT_SCAFFOLD_ELEMENTS 7089 - * sizeof(CONTENT_SCAFFOLD)); 6777 + * sizeof(CONTENT_SCAFFOLD)); 7090 6778 if (temp == NULL) 7091 6779 return -1; 7092 6780 dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; 7093 6781 } 7094 6782 dtd->scaffold = temp; 7095 6783 } 7096 6784 next = dtd->scaffCount++; 7097 6785 me = &dtd->scaffold[next]; 7098 6786 if (dtd->scaffLevel) { 7099 - CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; 6787 + CONTENT_SCAFFOLD *parent 6788 + = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]]; 7100 6789 if (parent->lastchild) { 7101 6790 dtd->scaffold[parent->lastchild].nextsib = next; 7102 6791 } 7103 - if (!parent->childcnt) 6792 + if (! parent->childcnt) 7104 6793 parent->firstchild = next; 7105 6794 parent->lastchild = next; 7106 6795 parent->childcnt++; 7107 6796 } 7108 6797 me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; 7109 6798 return next; 7110 6799 } 7111 6800 7112 6801 static void 7113 -build_node(XML_Parser parser, 7114 - int src_node, 7115 - XML_Content *dest, 7116 - XML_Content **contpos, 7117 - XML_Char **strpos) 7118 -{ 7119 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 6802 +build_node(XML_Parser parser, int src_node, XML_Content *dest, 6803 + XML_Content **contpos, XML_Char **strpos) { 6804 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 7120 6805 dest->type = dtd->scaffold[src_node].type; 7121 6806 dest->quant = dtd->scaffold[src_node].quant; 7122 6807 if (dest->type == XML_CTYPE_NAME) { 7123 6808 const XML_Char *src; 7124 6809 dest->name = *strpos; 7125 6810 src = dtd->scaffold[src_node].name; 7126 6811 for (;;) { 7127 6812 *(*strpos)++ = *src; 7128 - if (!*src) 6813 + if (! *src) 7129 6814 break; 7130 6815 src++; 7131 6816 } 7132 6817 dest->numchildren = 0; 7133 6818 dest->children = NULL; 7134 - } 7135 - else { 6819 + } else { 7136 6820 unsigned int i; 7137 6821 int cn; 7138 6822 dest->numchildren = dtd->scaffold[src_node].childcnt; 7139 6823 dest->children = *contpos; 7140 6824 *contpos += dest->numchildren; 7141 - for (i = 0, cn = dtd->scaffold[src_node].firstchild; 7142 - i < dest->numchildren; 6825 + for (i = 0, cn = dtd->scaffold[src_node].firstchild; i < dest->numchildren; 7143 6826 i++, cn = dtd->scaffold[cn].nextsib) { 7144 6827 build_node(parser, cn, &(dest->children[i]), contpos, strpos); 7145 6828 } 7146 6829 dest->name = NULL; 7147 6830 } 7148 6831 } 7149 6832 7150 6833 static XML_Content * 7151 -build_model (XML_Parser parser) 7152 -{ 7153 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 6834 +build_model(XML_Parser parser) { 6835 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 7154 6836 XML_Content *ret; 7155 6837 XML_Content *cpos; 7156 - XML_Char * str; 6838 + XML_Char *str; 7157 6839 int allocsize = (dtd->scaffCount * sizeof(XML_Content) 7158 6840 + (dtd->contentStringLen * sizeof(XML_Char))); 7159 6841 7160 6842 ret = (XML_Content *)MALLOC(parser, allocsize); 7161 - if (!ret) 6843 + if (! ret) 7162 6844 return NULL; 7163 6845 7164 - str = (XML_Char *) (&ret[dtd->scaffCount]); 6846 + str = (XML_Char *)(&ret[dtd->scaffCount]); 7165 6847 cpos = &ret[1]; 7166 6848 7167 6849 build_node(parser, 0, ret, &cpos, &str); 7168 6850 return ret; 7169 6851 } 7170 6852 7171 6853 static ELEMENT_TYPE * 7172 -getElementType(XML_Parser parser, 7173 - const ENCODING *enc, 7174 - const char *ptr, 7175 - const char *end) 7176 -{ 7177 - DTD * const dtd = parser->m_dtd; /* save one level of indirection */ 6854 +getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr, 6855 + const char *end) { 6856 + DTD *const dtd = parser->m_dtd; /* save one level of indirection */ 7178 6857 const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); 7179 6858 ELEMENT_TYPE *ret; 7180 6859 7181 - if (!name) 6860 + if (! name) 7182 6861 return NULL; 7183 - ret = (ELEMENT_TYPE *) lookup(parser, &dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); 7184 - if (!ret) 6862 + ret = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name, 6863 + sizeof(ELEMENT_TYPE)); 6864 + if (! ret) 7185 6865 return NULL; 7186 6866 if (ret->name != name) 7187 6867 poolDiscard(&dtd->pool); 7188 6868 else { 7189 6869 poolFinish(&dtd->pool); 7190 - if (!setElementTypePrefix(parser, ret)) 6870 + if (! setElementTypePrefix(parser, ret)) 7191 6871 return NULL; 7192 6872 } 7193 6873 return ret; 7194 6874 } 7195 6875 7196 6876 static XML_Char * 7197 -copyString(const XML_Char *s, 7198 - const XML_Memory_Handling_Suite *memsuite) 7199 -{ 7200 - int charsRequired = 0; 7201 - XML_Char *result; 6877 +copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) { 6878 + int charsRequired = 0; 6879 + XML_Char *result; 7202 6880 7203 - /* First determine how long the string is */ 7204 - while (s[charsRequired] != 0) { 7205 - charsRequired++; 7206 - } 7207 - /* Include the terminator */ 6881 + /* First determine how long the string is */ 6882 + while (s[charsRequired] != 0) { 7208 6883 charsRequired++; 6884 + } 6885 + /* Include the terminator */ 6886 + charsRequired++; 7209 6887 7210 - /* Now allocate space for the copy */ 7211 - result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char)); 7212 - if (result == NULL) 7213 - return NULL; 7214 - /* Copy the original into place */ 7215 - memcpy(result, s, charsRequired * sizeof(XML_Char)); 7216 - return result; 6888 + /* Now allocate space for the copy */ 6889 + result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char)); 6890 + if (result == NULL) 6891 + return NULL; 6892 + /* Copy the original into place */ 6893 + memcpy(result, s, charsRequired * sizeof(XML_Char)); 6894 + return result; 7217 6895 }
Changes to expat/xmlrole.c.
29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 #include <stddef.h> 34 34 35 35 #ifdef _WIN32 36 -#include "winconfig.h" 36 +# include "winconfig.h" 37 37 #else 38 -#ifdef HAVE_EXPAT_CONFIG_H 39 -#include <expat_config.h> 40 -#endif 38 +# ifdef HAVE_EXPAT_CONFIG_H 39 +# include <expat_config.h> 40 +# endif 41 41 #endif /* ndef _WIN32 */ 42 42 43 43 #include "expat_external.h" 44 44 #include "internal.h" 45 45 #include "xmlrole.h" 46 46 #include "ascii.h" 47 47 ................................................................................ 48 48 /* Doesn't check: 49 49 50 50 that ,| are not mixed in a model group 51 51 content of literals 52 52 53 53 */ 54 54 55 -static const char KW_ANY[] = { 56 - ASCII_A, ASCII_N, ASCII_Y, '\0' }; 57 -static const char KW_ATTLIST[] = { 58 - ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' }; 59 -static const char KW_CDATA[] = { 60 - ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; 61 -static const char KW_DOCTYPE[] = { 62 - ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' }; 63 -static const char KW_ELEMENT[] = { 64 - ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' }; 65 -static const char KW_EMPTY[] = { 66 - ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' }; 67 -static const char KW_ENTITIES[] = { 68 - ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, 69 - '\0' }; 70 -static const char KW_ENTITY[] = { 71 - ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; 72 -static const char KW_FIXED[] = { 73 - ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' }; 74 -static const char KW_ID[] = { 75 - ASCII_I, ASCII_D, '\0' }; 76 -static const char KW_IDREF[] = { 77 - ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; 78 -static const char KW_IDREFS[] = { 79 - ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; 55 +static const char KW_ANY[] = {ASCII_A, ASCII_N, ASCII_Y, '\0'}; 56 +static const char KW_ATTLIST[] 57 + = {ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0'}; 58 +static const char KW_CDATA[] 59 + = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'}; 60 +static const char KW_DOCTYPE[] 61 + = {ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0'}; 62 +static const char KW_ELEMENT[] 63 + = {ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0'}; 64 +static const char KW_EMPTY[] 65 + = {ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0'}; 66 +static const char KW_ENTITIES[] = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, 67 + ASCII_I, ASCII_E, ASCII_S, '\0'}; 68 +static const char KW_ENTITY[] 69 + = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0'}; 70 +static const char KW_FIXED[] 71 + = {ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0'}; 72 +static const char KW_ID[] = {ASCII_I, ASCII_D, '\0'}; 73 +static const char KW_IDREF[] 74 + = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0'}; 75 +static const char KW_IDREFS[] 76 + = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0'}; 77 +#ifdef XML_DTD 78 +static const char KW_IGNORE[] 79 + = {ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0'}; 80 +#endif 81 +static const char KW_IMPLIED[] 82 + = {ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0'}; 80 83 #ifdef XML_DTD 81 -static const char KW_IGNORE[] = { 82 - ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; 84 +static const char KW_INCLUDE[] 85 + = {ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0'}; 83 86 #endif 84 -static const char KW_IMPLIED[] = { 85 - ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; 86 -#ifdef XML_DTD 87 -static const char KW_INCLUDE[] = { 88 - ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; 89 -#endif 90 -static const char KW_NDATA[] = { 91 - ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; 92 -static const char KW_NMTOKEN[] = { 93 - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; 94 -static const char KW_NMTOKENS[] = { 95 - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, 96 - '\0' }; 97 -static const char KW_NOTATION[] = 98 - { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, 99 - '\0' }; 100 -static const char KW_PCDATA[] = { 101 - ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; 102 -static const char KW_PUBLIC[] = { 103 - ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' }; 104 -static const char KW_REQUIRED[] = { 105 - ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, 106 - '\0' }; 107 -static const char KW_SYSTEM[] = { 108 - ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' }; 87 +static const char KW_NDATA[] 88 + = {ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'}; 89 +static const char KW_NMTOKEN[] 90 + = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0'}; 91 +static const char KW_NMTOKENS[] = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, 92 + ASCII_E, ASCII_N, ASCII_S, '\0'}; 93 +static const char KW_NOTATION[] = {ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, 94 + ASCII_I, ASCII_O, ASCII_N, '\0'}; 95 +static const char KW_PCDATA[] 96 + = {ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'}; 97 +static const char KW_PUBLIC[] 98 + = {ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0'}; 99 +static const char KW_REQUIRED[] = {ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, 100 + ASCII_R, ASCII_E, ASCII_D, '\0'}; 101 +static const char KW_SYSTEM[] 102 + = {ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0'}; 109 103 110 104 #ifndef MIN_BYTES_PER_CHAR 111 -#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar) 105 +# define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar) 112 106 #endif 113 107 114 108 #ifdef XML_DTD 115 -#define setTopLevel(state) \ 116 - ((state)->handler = ((state)->documentEntity \ 117 - ? internalSubset \ 118 - : externalSubset1)) 109 +# define setTopLevel(state) \ 110 + ((state)->handler \ 111 + = ((state)->documentEntity ? internalSubset : externalSubset1)) 119 112 #else /* not XML_DTD */ 120 -#define setTopLevel(state) ((state)->handler = internalSubset) 113 +# define setTopLevel(state) ((state)->handler = internalSubset) 121 114 #endif /* not XML_DTD */ 122 115 123 -typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, 124 - int tok, 125 - const char *ptr, 126 - const char *end, 116 +typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, int tok, 117 + const char *ptr, const char *end, 127 118 const ENCODING *enc); 128 119 129 -static PROLOG_HANDLER 130 - prolog0, prolog1, prolog2, 131 - doctype0, doctype1, doctype2, doctype3, doctype4, doctype5, 132 - internalSubset, 133 - entity0, entity1, entity2, entity3, entity4, entity5, entity6, 134 - entity7, entity8, entity9, entity10, 135 - notation0, notation1, notation2, notation3, notation4, 136 - attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6, 137 - attlist7, attlist8, attlist9, 138 - element0, element1, element2, element3, element4, element5, element6, 139 - element7, 120 +static PROLOG_HANDLER prolog0, prolog1, prolog2, doctype0, doctype1, doctype2, 121 + doctype3, doctype4, doctype5, internalSubset, entity0, entity1, entity2, 122 + entity3, entity4, entity5, entity6, entity7, entity8, entity9, entity10, 123 + notation0, notation1, notation2, notation3, notation4, attlist0, attlist1, 124 + attlist2, attlist3, attlist4, attlist5, attlist6, attlist7, attlist8, 125 + attlist9, element0, element1, element2, element3, element4, element5, 126 + element6, element7, 140 127 #ifdef XML_DTD 141 - externalSubset0, externalSubset1, 142 - condSect0, condSect1, condSect2, 128 + externalSubset0, externalSubset1, condSect0, condSect1, condSect2, 143 129 #endif /* XML_DTD */ 144 - declClose, 145 - error; 130 + declClose, error; 146 131 147 132 static int FASTCALL common(PROLOG_STATE *state, int tok); 148 133 149 134 static int PTRCALL 150 -prolog0(PROLOG_STATE *state, 151 - int tok, 152 - const char *ptr, 153 - const char *end, 154 - const ENCODING *enc) 155 -{ 135 +prolog0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 136 + const ENCODING *enc) { 156 137 switch (tok) { 157 138 case XML_TOK_PROLOG_S: 158 139 state->handler = prolog1; 159 140 return XML_ROLE_NONE; 160 141 case XML_TOK_XML_DECL: 161 142 state->handler = prolog1; 162 143 return XML_ROLE_XML_DECL; ................................................................................ 165 146 return XML_ROLE_PI; 166 147 case XML_TOK_COMMENT: 167 148 state->handler = prolog1; 168 149 return XML_ROLE_COMMENT; 169 150 case XML_TOK_BOM: 170 151 return XML_ROLE_NONE; 171 152 case XML_TOK_DECL_OPEN: 172 - if (!XmlNameMatchesAscii(enc, 173 - ptr + 2 * MIN_BYTES_PER_CHAR(enc), 174 - end, 175 - KW_DOCTYPE)) 153 + if (! XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, 154 + KW_DOCTYPE)) 176 155 break; 177 156 state->handler = doctype0; 178 157 return XML_ROLE_DOCTYPE_NONE; 179 158 case XML_TOK_INSTANCE_START: 180 159 state->handler = error; 181 160 return XML_ROLE_INSTANCE_START; 182 161 } 183 162 return common(state, tok); 184 163 } 185 164 186 165 static int PTRCALL 187 -prolog1(PROLOG_STATE *state, 188 - int tok, 189 - const char *ptr, 190 - const char *end, 191 - const ENCODING *enc) 192 -{ 166 +prolog1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 167 + const ENCODING *enc) { 193 168 switch (tok) { 194 169 case XML_TOK_PROLOG_S: 195 170 return XML_ROLE_NONE; 196 171 case XML_TOK_PI: 197 172 return XML_ROLE_PI; 198 173 case XML_TOK_COMMENT: 199 174 return XML_ROLE_COMMENT; ................................................................................ 203 178 * some form of input, even if only a space. At that point, a 204 179 * byte order mark is no longer a valid character (though 205 180 * technically it should be interpreted as a non-breaking space), 206 181 * so will be rejected by the tokenizing stages. 207 182 */ 208 183 return XML_ROLE_NONE; /* LCOV_EXCL_LINE */ 209 184 case XML_TOK_DECL_OPEN: 210 - if (!XmlNameMatchesAscii(enc, 211 - ptr + 2 * MIN_BYTES_PER_CHAR(enc), 212 - end, 213 - KW_DOCTYPE)) 185 + if (! XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, 186 + KW_DOCTYPE)) 214 187 break; 215 188 state->handler = doctype0; 216 189 return XML_ROLE_DOCTYPE_NONE; 217 190 case XML_TOK_INSTANCE_START: 218 191 state->handler = error; 219 192 return XML_ROLE_INSTANCE_START; 220 193 } 221 194 return common(state, tok); 222 195 } 223 196 224 197 static int PTRCALL 225 -prolog2(PROLOG_STATE *state, 226 - int tok, 227 - const char *UNUSED_P(ptr), 228 - const char *UNUSED_P(end), 229 - const ENCODING *UNUSED_P(enc)) 230 -{ 198 +prolog2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 199 + const ENCODING *enc) { 200 + UNUSED_P(ptr); 201 + UNUSED_P(end); 202 + UNUSED_P(enc); 231 203 switch (tok) { 232 204 case XML_TOK_PROLOG_S: 233 205 return XML_ROLE_NONE; 234 206 case XML_TOK_PI: 235 207 return XML_ROLE_PI; 236 208 case XML_TOK_COMMENT: 237 209 return XML_ROLE_COMMENT; ................................................................................ 239 211 state->handler = error; 240 212 return XML_ROLE_INSTANCE_START; 241 213 } 242 214 return common(state, tok); 243 215 } 244 216 245 217 static int PTRCALL 246 -doctype0(PROLOG_STATE *state, 247 - int tok, 248 - const char *UNUSED_P(ptr), 249 - const char *UNUSED_P(end), 250 - const ENCODING *UNUSED_P(enc)) 251 -{ 218 +doctype0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 219 + const ENCODING *enc) { 220 + UNUSED_P(ptr); 221 + UNUSED_P(end); 222 + UNUSED_P(enc); 252 223 switch (tok) { 253 224 case XML_TOK_PROLOG_S: 254 225 return XML_ROLE_DOCTYPE_NONE; 255 226 case XML_TOK_NAME: 256 227 case XML_TOK_PREFIXED_NAME: 257 228 state->handler = doctype1; 258 229 return XML_ROLE_DOCTYPE_NAME; 259 230 } 260 231 return common(state, tok); 261 232 } 262 233 263 234 static int PTRCALL 264 -doctype1(PROLOG_STATE *state, 265 - int tok, 266 - const char *ptr, 267 - const char *end, 268 - const ENCODING *enc) 269 -{ 235 +doctype1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 236 + const ENCODING *enc) { 270 237 switch (tok) { 271 238 case XML_TOK_PROLOG_S: 272 239 return XML_ROLE_DOCTYPE_NONE; 273 240 case XML_TOK_OPEN_BRACKET: 274 241 state->handler = internalSubset; 275 242 return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; 276 243 case XML_TOK_DECL_CLOSE: ................................................................................ 287 254 } 288 255 break; 289 256 } 290 257 return common(state, tok); 291 258 } 292 259 293 260 static int PTRCALL 294 -doctype2(PROLOG_STATE *state, 295 - int tok, 296 - const char *UNUSED_P(ptr), 297 - const char *UNUSED_P(end), 298 - const ENCODING *UNUSED_P(enc)) 299 -{ 261 +doctype2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 262 + const ENCODING *enc) { 263 + UNUSED_P(ptr); 264 + UNUSED_P(end); 265 + UNUSED_P(enc); 300 266 switch (tok) { 301 267 case XML_TOK_PROLOG_S: 302 268 return XML_ROLE_DOCTYPE_NONE; 303 269 case XML_TOK_LITERAL: 304 270 state->handler = doctype3; 305 271 return XML_ROLE_DOCTYPE_PUBLIC_ID; 306 272 } 307 273 return common(state, tok); 308 274 } 309 275 310 276 static int PTRCALL 311 -doctype3(PROLOG_STATE *state, 312 - int tok, 313 - const char *UNUSED_P(ptr), 314 - const char *UNUSED_P(end), 315 - const ENCODING *UNUSED_P(enc)) 316 -{ 277 +doctype3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 278 + const ENCODING *enc) { 279 + UNUSED_P(ptr); 280 + UNUSED_P(end); 281 + UNUSED_P(enc); 317 282 switch (tok) { 318 283 case XML_TOK_PROLOG_S: 319 284 return XML_ROLE_DOCTYPE_NONE; 320 285 case XML_TOK_LITERAL: 321 286 state->handler = doctype4; 322 287 return XML_ROLE_DOCTYPE_SYSTEM_ID; 323 288 } 324 289 return common(state, tok); 325 290 } 326 291 327 292 static int PTRCALL 328 -doctype4(PROLOG_STATE *state, 329 - int tok, 330 - const char *UNUSED_P(ptr), 331 - const char *UNUSED_P(end), 332 - const ENCODING *UNUSED_P(enc)) 333 -{ 293 +doctype4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 294 + const ENCODING *enc) { 295 + UNUSED_P(ptr); 296 + UNUSED_P(end); 297 + UNUSED_P(enc); 334 298 switch (tok) { 335 299 case XML_TOK_PROLOG_S: 336 300 return XML_ROLE_DOCTYPE_NONE; 337 301 case XML_TOK_OPEN_BRACKET: 338 302 state->handler = internalSubset; 339 303 return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; 340 304 case XML_TOK_DECL_CLOSE: ................................................................................ 341 305 state->handler = prolog2; 342 306 return XML_ROLE_DOCTYPE_CLOSE; 343 307 } 344 308 return common(state, tok); 345 309 } 346 310 347 311 static int PTRCALL 348 -doctype5(PROLOG_STATE *state, 349 - int tok, 350 - const char *UNUSED_P(ptr), 351 - const char *UNUSED_P(end), 352 - const ENCODING *UNUSED_P(enc)) 353 -{ 312 +doctype5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 313 + const ENCODING *enc) { 314 + UNUSED_P(ptr); 315 + UNUSED_P(end); 316 + UNUSED_P(enc); 354 317 switch (tok) { 355 318 case XML_TOK_PROLOG_S: 356 319 return XML_ROLE_DOCTYPE_NONE; 357 320 case XML_TOK_DECL_CLOSE: 358 321 state->handler = prolog2; 359 322 return XML_ROLE_DOCTYPE_CLOSE; 360 323 } 361 324 return common(state, tok); 362 325 } 363 326 364 327 static int PTRCALL 365 -internalSubset(PROLOG_STATE *state, 366 - int tok, 367 - const char *ptr, 368 - const char *end, 369 - const ENCODING *enc) 370 -{ 328 +internalSubset(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 329 + const ENCODING *enc) { 371 330 switch (tok) { 372 331 case XML_TOK_PROLOG_S: 373 332 return XML_ROLE_NONE; 374 333 case XML_TOK_DECL_OPEN: 375 - if (XmlNameMatchesAscii(enc, 376 - ptr + 2 * MIN_BYTES_PER_CHAR(enc), 377 - end, 334 + if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, 378 335 KW_ENTITY)) { 379 336 state->handler = entity0; 380 337 return XML_ROLE_ENTITY_NONE; 381 338 } 382 - if (XmlNameMatchesAscii(enc, 383 - ptr + 2 * MIN_BYTES_PER_CHAR(enc), 384 - end, 339 + if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, 385 340 KW_ATTLIST)) { 386 341 state->handler = attlist0; 387 342 return XML_ROLE_ATTLIST_NONE; 388 343 } 389 - if (XmlNameMatchesAscii(enc, 390 - ptr + 2 * MIN_BYTES_PER_CHAR(enc), 391 - end, 344 + if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, 392 345 KW_ELEMENT)) { 393 346 state->handler = element0; 394 347 return XML_ROLE_ELEMENT_NONE; 395 348 } 396 - if (XmlNameMatchesAscii(enc, 397 - ptr + 2 * MIN_BYTES_PER_CHAR(enc), 398 - end, 349 + if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, 399 350 KW_NOTATION)) { 400 351 state->handler = notation0; 401 352 return XML_ROLE_NOTATION_NONE; 402 353 } 403 354 break; 404 355 case XML_TOK_PI: 405 356 return XML_ROLE_PI; ................................................................................ 415 366 } 416 367 return common(state, tok); 417 368 } 418 369 419 370 #ifdef XML_DTD 420 371 421 372 static int PTRCALL 422 -externalSubset0(PROLOG_STATE *state, 423 - int tok, 424 - const char *ptr, 425 - const char *end, 426 - const ENCODING *enc) 427 -{ 373 +externalSubset0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 374 + const ENCODING *enc) { 428 375 state->handler = externalSubset1; 429 376 if (tok == XML_TOK_XML_DECL) 430 377 return XML_ROLE_TEXT_DECL; 431 378 return externalSubset1(state, tok, ptr, end, enc); 432 379 } 433 380 434 381 static int PTRCALL 435 -externalSubset1(PROLOG_STATE *state, 436 - int tok, 437 - const char *ptr, 438 - const char *end, 439 - const ENCODING *enc) 440 -{ 382 +externalSubset1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 383 + const ENCODING *enc) { 441 384 switch (tok) { 442 385 case XML_TOK_COND_SECT_OPEN: 443 386 state->handler = condSect0; 444 387 return XML_ROLE_NONE; 445 388 case XML_TOK_COND_SECT_CLOSE: 446 389 if (state->includeLevel == 0) 447 390 break; ................................................................................ 460 403 } 461 404 return common(state, tok); 462 405 } 463 406 464 407 #endif /* XML_DTD */ 465 408 466 409 static int PTRCALL 467 -entity0(PROLOG_STATE *state, 468 - int tok, 469 - const char *UNUSED_P(ptr), 470 - const char *UNUSED_P(end), 471 - const ENCODING *UNUSED_P(enc)) 472 -{ 410 +entity0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 411 + const ENCODING *enc) { 412 + UNUSED_P(ptr); 413 + UNUSED_P(end); 414 + UNUSED_P(enc); 473 415 switch (tok) { 474 416 case XML_TOK_PROLOG_S: 475 417 return XML_ROLE_ENTITY_NONE; 476 418 case XML_TOK_PERCENT: 477 419 state->handler = entity1; 478 420 return XML_ROLE_ENTITY_NONE; 479 421 case XML_TOK_NAME: ................................................................................ 480 422 state->handler = entity2; 481 423 return XML_ROLE_GENERAL_ENTITY_NAME; 482 424 } 483 425 return common(state, tok); 484 426 } 485 427 486 428 static int PTRCALL 487 -entity1(PROLOG_STATE *state, 488 - int tok, 489 - const char *UNUSED_P(ptr), 490 - const char *UNUSED_P(end), 491 - const ENCODING *UNUSED_P(enc)) 492 -{ 429 +entity1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 430 + const ENCODING *enc) { 431 + UNUSED_P(ptr); 432 + UNUSED_P(end); 433 + UNUSED_P(enc); 493 434 switch (tok) { 494 435 case XML_TOK_PROLOG_S: 495 436 return XML_ROLE_ENTITY_NONE; 496 437 case XML_TOK_NAME: 497 438 state->handler = entity7; 498 439 return XML_ROLE_PARAM_ENTITY_NAME; 499 440 } 500 441 return common(state, tok); 501 442 } 502 443 503 444 static int PTRCALL 504 -entity2(PROLOG_STATE *state, 505 - int tok, 506 - const char *ptr, 507 - const char *end, 508 - const ENCODING *enc) 509 -{ 445 +entity2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 446 + const ENCODING *enc) { 510 447 switch (tok) { 511 448 case XML_TOK_PROLOG_S: 512 449 return XML_ROLE_ENTITY_NONE; 513 450 case XML_TOK_NAME: 514 451 if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { 515 452 state->handler = entity4; 516 453 return XML_ROLE_ENTITY_NONE; ................................................................................ 525 462 state->role_none = XML_ROLE_ENTITY_NONE; 526 463 return XML_ROLE_ENTITY_VALUE; 527 464 } 528 465 return common(state, tok); 529 466 } 530 467 531 468 static int PTRCALL 532 -entity3(PROLOG_STATE *state, 533 - int tok, 534 - const char *UNUSED_P(ptr), 535 - const char *UNUSED_P(end), 536 - const ENCODING *UNUSED_P(enc)) 537 -{ 469 +entity3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 470 + const ENCODING *enc) { 471 + UNUSED_P(ptr); 472 + UNUSED_P(end); 473 + UNUSED_P(enc); 538 474 switch (tok) { 539 475 case XML_TOK_PROLOG_S: 540 476 return XML_ROLE_ENTITY_NONE; 541 477 case XML_TOK_LITERAL: 542 478 state->handler = entity4; 543 479 return XML_ROLE_ENTITY_PUBLIC_ID; 544 480 } 545 481 return common(state, tok); 546 482 } 547 483 548 484 static int PTRCALL 549 -entity4(PROLOG_STATE *state, 550 - int tok, 551 - const char *UNUSED_P(ptr), 552 - const char *UNUSED_P(end), 553 - const ENCODING *UNUSED_P(enc)) 554 -{ 485 +entity4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 486 + const ENCODING *enc) { 487 + UNUSED_P(ptr); 488 + UNUSED_P(end); 489 + UNUSED_P(enc); 555 490 switch (tok) { 556 491 case XML_TOK_PROLOG_S: 557 492 return XML_ROLE_ENTITY_NONE; 558 493 case XML_TOK_LITERAL: 559 494 state->handler = entity5; 560 495 return XML_ROLE_ENTITY_SYSTEM_ID; 561 496 } 562 497 return common(state, tok); 563 498 } 564 499 565 500 static int PTRCALL 566 -entity5(PROLOG_STATE *state, 567 - int tok, 568 - const char *ptr, 569 - const char *end, 570 - const ENCODING *enc) 571 -{ 501 +entity5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 502 + const ENCODING *enc) { 572 503 switch (tok) { 573 504 case XML_TOK_PROLOG_S: 574 505 return XML_ROLE_ENTITY_NONE; 575 506 case XML_TOK_DECL_CLOSE: 576 507 setTopLevel(state); 577 508 return XML_ROLE_ENTITY_COMPLETE; 578 509 case XML_TOK_NAME: ................................................................................ 582 513 } 583 514 break; 584 515 } 585 516 return common(state, tok); 586 517 } 587 518 588 519 static int PTRCALL 589 -entity6(PROLOG_STATE *state, 590 - int tok, 591 - const char *UNUSED_P(ptr), 592 - const char *UNUSED_P(end), 593 - const ENCODING *UNUSED_P(enc)) 594 -{ 520 +entity6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 521 + const ENCODING *enc) { 522 + UNUSED_P(ptr); 523 + UNUSED_P(end); 524 + UNUSED_P(enc); 595 525 switch (tok) { 596 526 case XML_TOK_PROLOG_S: 597 527 return XML_ROLE_ENTITY_NONE; 598 528 case XML_TOK_NAME: 599 529 state->handler = declClose; 600 530 state->role_none = XML_ROLE_ENTITY_NONE; 601 531 return XML_ROLE_ENTITY_NOTATION_NAME; 602 532 } 603 533 return common(state, tok); 604 534 } 605 535 606 536 static int PTRCALL 607 -entity7(PROLOG_STATE *state, 608 - int tok, 609 - const char *ptr, 610 - const char *end, 611 - const ENCODING *enc) 612 -{ 537 +entity7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 538 + const ENCODING *enc) { 613 539 switch (tok) { 614 540 case XML_TOK_PROLOG_S: 615 541 return XML_ROLE_ENTITY_NONE; 616 542 case XML_TOK_NAME: 617 543 if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { 618 544 state->handler = entity9; 619 545 return XML_ROLE_ENTITY_NONE; ................................................................................ 628 554 state->role_none = XML_ROLE_ENTITY_NONE; 629 555 return XML_ROLE_ENTITY_VALUE; 630 556 } 631 557 return common(state, tok); 632 558 } 633 559 634 560 static int PTRCALL 635 -entity8(PROLOG_STATE *state, 636 - int tok, 637 - const char *UNUSED_P(ptr), 638 - const char *UNUSED_P(end), 639 - const ENCODING *UNUSED_P(enc)) 640 -{ 561 +entity8(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 562 + const ENCODING *enc) { 563 + UNUSED_P(ptr); 564 + UNUSED_P(end); 565 + UNUSED_P(enc); 641 566 switch (tok) { 642 567 case XML_TOK_PROLOG_S: 643 568 return XML_ROLE_ENTITY_NONE; 644 569 case XML_TOK_LITERAL: 645 570 state->handler = entity9; 646 571 return XML_ROLE_ENTITY_PUBLIC_ID; 647 572 } 648 573 return common(state, tok); 649 574 } 650 575 651 576 static int PTRCALL 652 -entity9(PROLOG_STATE *state, 653 - int tok, 654 - const char *UNUSED_P(ptr), 655 - const char *UNUSED_P(end), 656 - const ENCODING *UNUSED_P(enc)) 657 -{ 577 +entity9(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 578 + const ENCODING *enc) { 579 + UNUSED_P(ptr); 580 + UNUSED_P(end); 581 + UNUSED_P(enc); 658 582 switch (tok) { 659 583 case XML_TOK_PROLOG_S: 660 584 return XML_ROLE_ENTITY_NONE; 661 585 case XML_TOK_LITERAL: 662 586 state->handler = entity10; 663 587 return XML_ROLE_ENTITY_SYSTEM_ID; 664 588 } 665 589 return common(state, tok); 666 590 } 667 591 668 592 static int PTRCALL 669 -entity10(PROLOG_STATE *state, 670 - int tok, 671 - const char *UNUSED_P(ptr), 672 - const char *UNUSED_P(end), 673 - const ENCODING *UNUSED_P(enc)) 674 -{ 593 +entity10(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 594 + const ENCODING *enc) { 595 + UNUSED_P(ptr); 596 + UNUSED_P(end); 597 + UNUSED_P(enc); 675 598 switch (tok) { 676 599 case XML_TOK_PROLOG_S: 677 600 return XML_ROLE_ENTITY_NONE; 678 601 case XML_TOK_DECL_CLOSE: 679 602 setTopLevel(state); 680 603 return XML_ROLE_ENTITY_COMPLETE; 681 604 } 682 605 return common(state, tok); 683 606 } 684 607 685 608 static int PTRCALL 686 -notation0(PROLOG_STATE *state, 687 - int tok, 688 - const char *UNUSED_P(ptr), 689 - const char *UNUSED_P(end), 690 - const ENCODING *UNUSED_P(enc)) 691 -{ 609 +notation0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 610 + const ENCODING *enc) { 611 + UNUSED_P(ptr); 612 + UNUSED_P(end); 613 + UNUSED_P(enc); 692 614 switch (tok) { 693 615 case XML_TOK_PROLOG_S: 694 616 return XML_ROLE_NOTATION_NONE; 695 617 case XML_TOK_NAME: 696 618 state->handler = notation1; 697 619 return XML_ROLE_NOTATION_NAME; 698 620 } 699 621 return common(state, tok); 700 622 } 701 623 702 624 static int PTRCALL 703 -notation1(PROLOG_STATE *state, 704 - int tok, 705 - const char *ptr, 706 - const char *end, 707 - const ENCODING *enc) 708 -{ 625 +notation1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 626 + const ENCODING *enc) { 709 627 switch (tok) { 710 628 case XML_TOK_PROLOG_S: 711 629 return XML_ROLE_NOTATION_NONE; 712 630 case XML_TOK_NAME: 713 631 if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { 714 632 state->handler = notation3; 715 633 return XML_ROLE_NOTATION_NONE; ................................................................................ 720 638 } 721 639 break; 722 640 } 723 641 return common(state, tok); 724 642 } 725 643 726 644 static int PTRCALL 727 -notation2(PROLOG_STATE *state, 728 - int tok, 729 - const char *UNUSED_P(ptr), 730 - const char *UNUSED_P(end), 731 - const ENCODING *UNUSED_P(enc)) 732 -{ 645 +notation2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 646 + const ENCODING *enc) { 647 + UNUSED_P(ptr); 648 + UNUSED_P(end); 649 + UNUSED_P(enc); 733 650 switch (tok) { 734 651 case XML_TOK_PROLOG_S: 735 652 return XML_ROLE_NOTATION_NONE; 736 653 case XML_TOK_LITERAL: 737 654 state->handler = notation4; 738 655 return XML_ROLE_NOTATION_PUBLIC_ID; 739 656 } 740 657 return common(state, tok); 741 658 } 742 659 743 660 static int PTRCALL 744 -notation3(PROLOG_STATE *state, 745 - int tok, 746 - const char *UNUSED_P(ptr), 747 - const char *UNUSED_P(end), 748 - const ENCODING *UNUSED_P(enc)) 749 -{ 661 +notation3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 662 + const ENCODING *enc) { 663 + UNUSED_P(ptr); 664 + UNUSED_P(end); 665 + UNUSED_P(enc); 750 666 switch (tok) { 751 667 case XML_TOK_PROLOG_S: 752 668 return XML_ROLE_NOTATION_NONE; 753 669 case XML_TOK_LITERAL: 754 670 state->handler = declClose; 755 671 state->role_none = XML_ROLE_NOTATION_NONE; 756 672 return XML_ROLE_NOTATION_SYSTEM_ID; 757 673 } 758 674 return common(state, tok); 759 675 } 760 676 761 677 static int PTRCALL 762 -notation4(PROLOG_STATE *state, 763 - int tok, 764 - const char *UNUSED_P(ptr), 765 - const char *UNUSED_P(end), 766 - const ENCODING *UNUSED_P(enc)) 767 -{ 678 +notation4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 679 + const ENCODING *enc) { 680 + UNUSED_P(ptr); 681 + UNUSED_P(end); 682 + UNUSED_P(enc); 768 683 switch (tok) { 769 684 case XML_TOK_PROLOG_S: 770 685 return XML_ROLE_NOTATION_NONE; 771 686 case XML_TOK_LITERAL: 772 687 state->handler = declClose; 773 688 state->role_none = XML_ROLE_NOTATION_NONE; 774 689 return XML_ROLE_NOTATION_SYSTEM_ID; ................................................................................ 776 691 setTopLevel(state); 777 692 return XML_ROLE_NOTATION_NO_SYSTEM_ID; 778 693 } 779 694 return common(state, tok); 780 695 } 781 696 782 697 static int PTRCALL 783 -attlist0(PROLOG_STATE *state, 784 - int tok, 785 - const char *UNUSED_P(ptr), 786 - const char *UNUSED_P(end), 787 - const ENCODING *UNUSED_P(enc)) 788 -{ 698 +attlist0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 699 + const ENCODING *enc) { 700 + UNUSED_P(ptr); 701 + UNUSED_P(end); 702 + UNUSED_P(enc); 789 703 switch (tok) { 790 704 case XML_TOK_PROLOG_S: 791 705 return XML_ROLE_ATTLIST_NONE; 792 706 case XML_TOK_NAME: 793 707 case XML_TOK_PREFIXED_NAME: 794 708 state->handler = attlist1; 795 709 return XML_ROLE_ATTLIST_ELEMENT_NAME; 796 710 } 797 711 return common(state, tok); 798 712 } 799 713 800 714 static int PTRCALL 801 -attlist1(PROLOG_STATE *state, 802 - int tok, 803 - const char *UNUSED_P(ptr), 804 - const char *UNUSED_P(end), 805 - const ENCODING *UNUSED_P(enc)) 806 -{ 715 +attlist1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 716 + const ENCODING *enc) { 717 + UNUSED_P(ptr); 718 + UNUSED_P(end); 719 + UNUSED_P(enc); 807 720 switch (tok) { 808 721 case XML_TOK_PROLOG_S: 809 722 return XML_ROLE_ATTLIST_NONE; 810 723 case XML_TOK_DECL_CLOSE: 811 724 setTopLevel(state); 812 725 return XML_ROLE_ATTLIST_NONE; 813 726 case XML_TOK_NAME: ................................................................................ 815 728 state->handler = attlist2; 816 729 return XML_ROLE_ATTRIBUTE_NAME; 817 730 } 818 731 return common(state, tok); 819 732 } 820 733 821 734 static int PTRCALL 822 -attlist2(PROLOG_STATE *state, 823 - int tok, 824 - const char *ptr, 825 - const char *end, 826 - const ENCODING *enc) 827 -{ 828 - switch (tok) { 829 - case XML_TOK_PROLOG_S: 830 - return XML_ROLE_ATTLIST_NONE; 831 - case XML_TOK_NAME: 832 - { 833 - static const char * const types[] = { 834 - KW_CDATA, 835 - KW_ID, 836 - KW_IDREF, 837 - KW_IDREFS, 838 - KW_ENTITY, 839 - KW_ENTITIES, 840 - KW_NMTOKEN, 841 - KW_NMTOKENS, 842 - }; 843 - int i; 844 - for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++) 845 - if (XmlNameMatchesAscii(enc, ptr, end, types[i])) { 846 - state->handler = attlist8; 847 - return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i; 848 - } 849 - } 735 +attlist2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 736 + const ENCODING *enc) { 737 + switch (tok) { 738 + case XML_TOK_PROLOG_S: 739 + return XML_ROLE_ATTLIST_NONE; 740 + case XML_TOK_NAME: { 741 + static const char *const types[] = { 742 + KW_CDATA, KW_ID, KW_IDREF, KW_IDREFS, 743 + KW_ENTITY, KW_ENTITIES, KW_NMTOKEN, KW_NMTOKENS, 744 + }; 745 + int i; 746 + for (i = 0; i < (int)(sizeof(types) / sizeof(types[0])); i++) 747 + if (XmlNameMatchesAscii(enc, ptr, end, types[i])) { 748 + state->handler = attlist8; 749 + return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i; 750 + } 751 + } 850 752 if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) { 851 753 state->handler = attlist5; 852 754 return XML_ROLE_ATTLIST_NONE; 853 755 } 854 756 break; 855 757 case XML_TOK_OPEN_PAREN: 856 758 state->handler = attlist3; 857 759 return XML_ROLE_ATTLIST_NONE; 858 760 } 859 761 return common(state, tok); 860 762 } 861 763 862 764 static int PTRCALL 863 -attlist3(PROLOG_STATE *state, 864 - int tok, 865 - const char *UNUSED_P(ptr), 866 - const char *UNUSED_P(end), 867 - const ENCODING *UNUSED_P(enc)) 868 -{ 765 +attlist3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 766 + const ENCODING *enc) { 767 + UNUSED_P(ptr); 768 + UNUSED_P(end); 769 + UNUSED_P(enc); 869 770 switch (tok) { 870 771 case XML_TOK_PROLOG_S: 871 772 return XML_ROLE_ATTLIST_NONE; 872 773 case XML_TOK_NMTOKEN: 873 774 case XML_TOK_NAME: 874 775 case XML_TOK_PREFIXED_NAME: 875 776 state->handler = attlist4; 876 777 return XML_ROLE_ATTRIBUTE_ENUM_VALUE; 877 778 } 878 779 return common(state, tok); 879 780 } 880 781 881 782 static int PTRCALL 882 -attlist4(PROLOG_STATE *state, 883 - int tok, 884 - const char *UNUSED_P(ptr), 885 - const char *UNUSED_P(end), 886 - const ENCODING *UNUSED_P(enc)) 887 -{ 783 +attlist4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 784 + const ENCODING *enc) { 785 + UNUSED_P(ptr); 786 + UNUSED_P(end); 787 + UNUSED_P(enc); 888 788 switch (tok) { 889 789 case XML_TOK_PROLOG_S: 890 790 return XML_ROLE_ATTLIST_NONE; 891 791 case XML_TOK_CLOSE_PAREN: 892 792 state->handler = attlist8; 893 793 return XML_ROLE_ATTLIST_NONE; 894 794 case XML_TOK_OR: ................................................................................ 895 795 state->handler = attlist3; 896 796 return XML_ROLE_ATTLIST_NONE; 897 797 } 898 798 return common(state, tok); 899 799 } 900 800 901 801 static int PTRCALL 902 -attlist5(PROLOG_STATE *state, 903 - int tok, 904 - const char *UNUSED_P(ptr), 905 - const char *UNUSED_P(end), 906 - const ENCODING *UNUSED_P(enc)) 907 -{ 802 +attlist5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 803 + const ENCODING *enc) { 804 + UNUSED_P(ptr); 805 + UNUSED_P(end); 806 + UNUSED_P(enc); 908 807 switch (tok) { 909 808 case XML_TOK_PROLOG_S: 910 809 return XML_ROLE_ATTLIST_NONE; 911 810 case XML_TOK_OPEN_PAREN: 912 811 state->handler = attlist6; 913 812 return XML_ROLE_ATTLIST_NONE; 914 813 } 915 814 return common(state, tok); 916 815 } 917 816 918 817 static int PTRCALL 919 -attlist6(PROLOG_STATE *state, 920 - int tok, 921 - const char *UNUSED_P(ptr), 922 - const char *UNUSED_P(end), 923 - const ENCODING *UNUSED_P(enc)) 924 -{ 818 +attlist6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 819 + const ENCODING *enc) { 820 + UNUSED_P(ptr); 821 + UNUSED_P(end); 822 + UNUSED_P(enc); 925 823 switch (tok) { 926 824 case XML_TOK_PROLOG_S: 927 825 return XML_ROLE_ATTLIST_NONE; 928 826 case XML_TOK_NAME: 929 827 state->handler = attlist7; 930 828 return XML_ROLE_ATTRIBUTE_NOTATION_VALUE; 931 829 } 932 830 return common(state, tok); 933 831 } 934 832 935 833 static int PTRCALL 936 -attlist7(PROLOG_STATE *state, 937 - int tok, 938 - const char *UNUSED_P(ptr), 939 - const char *UNUSED_P(end), 940 - const ENCODING *UNUSED_P(enc)) 941 -{ 834 +attlist7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 835 + const ENCODING *enc) { 836 + UNUSED_P(ptr); 837 + UNUSED_P(end); 838 + UNUSED_P(enc); 942 839 switch (tok) { 943 840 case XML_TOK_PROLOG_S: 944 841 return XML_ROLE_ATTLIST_NONE; 945 842 case XML_TOK_CLOSE_PAREN: 946 843 state->handler = attlist8; 947 844 return XML_ROLE_ATTLIST_NONE; 948 845 case XML_TOK_OR: ................................................................................ 950 847 return XML_ROLE_ATTLIST_NONE; 951 848 } 952 849 return common(state, tok); 953 850 } 954 851 955 852 /* default value */ 956 853 static int PTRCALL 957 -attlist8(PROLOG_STATE *state, 958 - int tok, 959 - const char *ptr, 960 - const char *end, 961 - const ENCODING *enc) 962 -{ 854 +attlist8(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 855 + const ENCODING *enc) { 963 856 switch (tok) { 964 857 case XML_TOK_PROLOG_S: 965 858 return XML_ROLE_ATTLIST_NONE; 966 859 case XML_TOK_POUND_NAME: 967 - if (XmlNameMatchesAscii(enc, 968 - ptr + MIN_BYTES_PER_CHAR(enc), 969 - end, 860 + if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end, 970 861 KW_IMPLIED)) { 971 862 state->handler = attlist1; 972 863 return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE; 973 864 } 974 - if (XmlNameMatchesAscii(enc, 975 - ptr + MIN_BYTES_PER_CHAR(enc), 976 - end, 865 + if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end, 977 866 KW_REQUIRED)) { 978 867 state->handler = attlist1; 979 868 return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE; 980 869 } 981 - if (XmlNameMatchesAscii(enc, 982 - ptr + MIN_BYTES_PER_CHAR(enc), 983 - end, 870 + if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end, 984 871 KW_FIXED)) { 985 872 state->handler = attlist9; 986 873 return XML_ROLE_ATTLIST_NONE; 987 874 } 988 875 break; 989 876 case XML_TOK_LITERAL: 990 877 state->handler = attlist1; 991 878 return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE; 992 879 } 993 880 return common(state, tok); 994 881 } 995 882 996 883 static int PTRCALL 997 -attlist9(PROLOG_STATE *state, 998 - int tok, 999 - const char *UNUSED_P(ptr), 1000 - const char *UNUSED_P(end), 1001 - const ENCODING *UNUSED_P(enc)) 1002 -{ 884 +attlist9(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 885 + const ENCODING *enc) { 886 + UNUSED_P(ptr); 887 + UNUSED_P(end); 888 + UNUSED_P(enc); 1003 889 switch (tok) { 1004 890 case XML_TOK_PROLOG_S: 1005 891 return XML_ROLE_ATTLIST_NONE; 1006 892 case XML_TOK_LITERAL: 1007 893 state->handler = attlist1; 1008 894 return XML_ROLE_FIXED_ATTRIBUTE_VALUE; 1009 895 } 1010 896 return common(state, tok); 1011 897 } 1012 898 1013 899 static int PTRCALL 1014 -element0(PROLOG_STATE *state, 1015 - int tok, 1016 - const char *UNUSED_P(ptr), 1017 - const char *UNUSED_P(end), 1018 - const ENCODING *UNUSED_P(enc)) 1019 -{ 900 +element0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 901 + const ENCODING *enc) { 902 + UNUSED_P(ptr); 903 + UNUSED_P(end); 904 + UNUSED_P(enc); 1020 905 switch (tok) { 1021 906 case XML_TOK_PROLOG_S: 1022 907 return XML_ROLE_ELEMENT_NONE; 1023 908 case XML_TOK_NAME: 1024 909 case XML_TOK_PREFIXED_NAME: 1025 910 state->handler = element1; 1026 911 return XML_ROLE_ELEMENT_NAME; 1027 912 } 1028 913 return common(state, tok); 1029 914 } 1030 915 1031 916 static int PTRCALL 1032 -element1(PROLOG_STATE *state, 1033 - int tok, 1034 - const char *ptr, 1035 - const char *end, 1036 - const ENCODING *enc) 1037 -{ 917 +element1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 918 + const ENCODING *enc) { 1038 919 switch (tok) { 1039 920 case XML_TOK_PROLOG_S: 1040 921 return XML_ROLE_ELEMENT_NONE; 1041 922 case XML_TOK_NAME: 1042 923 if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) { 1043 924 state->handler = declClose; 1044 925 state->role_none = XML_ROLE_ELEMENT_NONE; ................................................................................ 1055 936 state->level = 1; 1056 937 return XML_ROLE_GROUP_OPEN; 1057 938 } 1058 939 return common(state, tok); 1059 940 } 1060 941 1061 942 static int PTRCALL 1062 -element2(PROLOG_STATE *state, 1063 - int tok, 1064 - const char *ptr, 1065 - const char *end, 1066 - const ENCODING *enc) 1067 -{ 943 +element2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 944 + const ENCODING *enc) { 1068 945 switch (tok) { 1069 946 case XML_TOK_PROLOG_S: 1070 947 return XML_ROLE_ELEMENT_NONE; 1071 948 case XML_TOK_POUND_NAME: 1072 - if (XmlNameMatchesAscii(enc, 1073 - ptr + MIN_BYTES_PER_CHAR(enc), 1074 - end, 949 + if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end, 1075 950 KW_PCDATA)) { 1076 951 state->handler = element3; 1077 952 return XML_ROLE_CONTENT_PCDATA; 1078 953 } 1079 954 break; 1080 955 case XML_TOK_OPEN_PAREN: 1081 956 state->level = 2; ................................................................................ 1095 970 state->handler = element7; 1096 971 return XML_ROLE_CONTENT_ELEMENT_PLUS; 1097 972 } 1098 973 return common(state, tok); 1099 974 } 1100 975 1101 976 static int PTRCALL 1102 -element3(PROLOG_STATE *state, 1103 - int tok, 1104 - const char *UNUSED_P(ptr), 1105 - const char *UNUSED_P(end), 1106 - const ENCODING *UNUSED_P(enc)) 1107 -{ 977 +element3(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 978 + const ENCODING *enc) { 979 + UNUSED_P(ptr); 980 + UNUSED_P(end); 981 + UNUSED_P(enc); 1108 982 switch (tok) { 1109 983 case XML_TOK_PROLOG_S: 1110 984 return XML_ROLE_ELEMENT_NONE; 1111 985 case XML_TOK_CLOSE_PAREN: 1112 986 state->handler = declClose; 1113 987 state->role_none = XML_ROLE_ELEMENT_NONE; 1114 988 return XML_ROLE_GROUP_CLOSE; ................................................................................ 1120 994 state->handler = element4; 1121 995 return XML_ROLE_ELEMENT_NONE; 1122 996 } 1123 997 return common(state, tok); 1124 998 } 1125 999 1126 1000 static int PTRCALL 1127 -element4(PROLOG_STATE *state, 1128 - int tok, 1129 - const char *UNUSED_P(ptr), 1130 - const char *UNUSED_P(end), 1131 - const ENCODING *UNUSED_P(enc)) 1132 -{ 1001 +element4(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1002 + const ENCODING *enc) { 1003 + UNUSED_P(ptr); 1004 + UNUSED_P(end); 1005 + UNUSED_P(enc); 1133 1006 switch (tok) { 1134 1007 case XML_TOK_PROLOG_S: 1135 1008 return XML_ROLE_ELEMENT_NONE; 1136 1009 case XML_TOK_NAME: 1137 1010 case XML_TOK_PREFIXED_NAME: 1138 1011 state->handler = element5; 1139 1012 return XML_ROLE_CONTENT_ELEMENT; 1140 1013 } 1141 1014 return common(state, tok); 1142 1015 } 1143 1016 1144 1017 static int PTRCALL 1145 -element5(PROLOG_STATE *state, 1146 - int tok, 1147 - const char *UNUSED_P(ptr), 1148 - const char *UNUSED_P(end), 1149 - const ENCODING *UNUSED_P(enc)) 1150 -{ 1018 +element5(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1019 + const ENCODING *enc) { 1020 + UNUSED_P(ptr); 1021 + UNUSED_P(end); 1022 + UNUSED_P(enc); 1151 1023 switch (tok) { 1152 1024 case XML_TOK_PROLOG_S: 1153 1025 return XML_ROLE_ELEMENT_NONE; 1154 1026 case XML_TOK_CLOSE_PAREN_ASTERISK: 1155 1027 state->handler = declClose; 1156 1028 state->role_none = XML_ROLE_ELEMENT_NONE; 1157 1029 return XML_ROLE_GROUP_CLOSE_REP; ................................................................................ 1159 1031 state->handler = element4; 1160 1032 return XML_ROLE_ELEMENT_NONE; 1161 1033 } 1162 1034 return common(state, tok); 1163 1035 } 1164 1036 1165 1037 static int PTRCALL 1166 -element6(PROLOG_STATE *state, 1167 - int tok, 1168 - const char *UNUSED_P(ptr), 1169 - const char *UNUSED_P(end), 1170 - const ENCODING *UNUSED_P(enc)) 1171 -{ 1038 +element6(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1039 + const ENCODING *enc) { 1040 + UNUSED_P(ptr); 1041 + UNUSED_P(end); 1042 + UNUSED_P(enc); 1172 1043 switch (tok) { 1173 1044 case XML_TOK_PROLOG_S: 1174 1045 return XML_ROLE_ELEMENT_NONE; 1175 1046 case XML_TOK_OPEN_PAREN: 1176 1047 state->level += 1; 1177 1048 return XML_ROLE_GROUP_OPEN; 1178 1049 case XML_TOK_NAME: ................................................................................ 1189 1060 state->handler = element7; 1190 1061 return XML_ROLE_CONTENT_ELEMENT_PLUS; 1191 1062 } 1192 1063 return common(state, tok); 1193 1064 } 1194 1065 1195 1066 static int PTRCALL 1196 -element7(PROLOG_STATE *state, 1197 - int tok, 1198 - const char *UNUSED_P(ptr), 1199 - const char *UNUSED_P(end), 1200 - const ENCODING *UNUSED_P(enc)) 1201 -{ 1067 +element7(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1068 + const ENCODING *enc) { 1069 + UNUSED_P(ptr); 1070 + UNUSED_P(end); 1071 + UNUSED_P(enc); 1202 1072 switch (tok) { 1203 1073 case XML_TOK_PROLOG_S: 1204 1074 return XML_ROLE_ELEMENT_NONE; 1205 1075 case XML_TOK_CLOSE_PAREN: 1206 1076 state->level -= 1; 1207 1077 if (state->level == 0) { 1208 1078 state->handler = declClose; ................................................................................ 1239 1109 } 1240 1110 return common(state, tok); 1241 1111 } 1242 1112 1243 1113 #ifdef XML_DTD 1244 1114 1245 1115 static int PTRCALL 1246 -condSect0(PROLOG_STATE *state, 1247 - int tok, 1248 - const char *ptr, 1249 - const char *end, 1250 - const ENCODING *enc) 1251 -{ 1116 +condSect0(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1117 + const ENCODING *enc) { 1252 1118 switch (tok) { 1253 1119 case XML_TOK_PROLOG_S: 1254 1120 return XML_ROLE_NONE; 1255 1121 case XML_TOK_NAME: 1256 1122 if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) { 1257 1123 state->handler = condSect1; 1258 1124 return XML_ROLE_NONE; ................................................................................ 1263 1129 } 1264 1130 break; 1265 1131 } 1266 1132 return common(state, tok); 1267 1133 } 1268 1134 1269 1135 static int PTRCALL 1270 -condSect1(PROLOG_STATE *state, 1271 - int tok, 1272 - const char *UNUSED_P(ptr), 1273 - const char *UNUSED_P(end), 1274 - const ENCODING *UNUSED_P(enc)) 1275 -{ 1136 +condSect1(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1137 + const ENCODING *enc) { 1138 + UNUSED_P(ptr); 1139 + UNUSED_P(end); 1140 + UNUSED_P(enc); 1276 1141 switch (tok) { 1277 1142 case XML_TOK_PROLOG_S: 1278 1143 return XML_ROLE_NONE; 1279 1144 case XML_TOK_OPEN_BRACKET: 1280 1145 state->handler = externalSubset1; 1281 1146 state->includeLevel += 1; 1282 1147 return XML_ROLE_NONE; 1283 1148 } 1284 1149 return common(state, tok); 1285 1150 } 1286 1151 1287 1152 static int PTRCALL 1288 -condSect2(PROLOG_STATE *state, 1289 - int tok, 1290 - const char *UNUSED_P(ptr), 1291 - const char *UNUSED_P(end), 1292 - const ENCODING *UNUSED_P(enc)) 1293 -{ 1153 +condSect2(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1154 + const ENCODING *enc) { 1155 + UNUSED_P(ptr); 1156 + UNUSED_P(end); 1157 + UNUSED_P(enc); 1294 1158 switch (tok) { 1295 1159 case XML_TOK_PROLOG_S: 1296 1160 return XML_ROLE_NONE; 1297 1161 case XML_TOK_OPEN_BRACKET: 1298 1162 state->handler = externalSubset1; 1299 1163 return XML_ROLE_IGNORE_SECT; 1300 1164 } 1301 1165 return common(state, tok); 1302 1166 } 1303 1167 1304 1168 #endif /* XML_DTD */ 1305 1169 1306 1170 static int PTRCALL 1307 -declClose(PROLOG_STATE *state, 1308 - int tok, 1309 - const char *UNUSED_P(ptr), 1310 - const char *UNUSED_P(end), 1311 - const ENCODING *UNUSED_P(enc)) 1312 -{ 1171 +declClose(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1172 + const ENCODING *enc) { 1173 + UNUSED_P(ptr); 1174 + UNUSED_P(end); 1175 + UNUSED_P(enc); 1313 1176 switch (tok) { 1314 1177 case XML_TOK_PROLOG_S: 1315 1178 return state->role_none; 1316 1179 case XML_TOK_DECL_CLOSE: 1317 1180 setTopLevel(state); 1318 1181 return state->role_none; 1319 1182 } ................................................................................ 1337 1200 * therefore we shouldn't be able to provoke it simply by using the 1338 1201 * library. It is a necessary backstop, however, so we merely exclude 1339 1202 * it from the coverage statistics. 1340 1203 * 1341 1204 * LCOV_EXCL_START 1342 1205 */ 1343 1206 static int PTRCALL 1344 -error(PROLOG_STATE *UNUSED_P(state), 1345 - int UNUSED_P(tok), 1346 - const char *UNUSED_P(ptr), 1347 - const char *UNUSED_P(end), 1348 - const ENCODING *UNUSED_P(enc)) 1349 -{ 1207 +error(PROLOG_STATE *state, int tok, const char *ptr, const char *end, 1208 + const ENCODING *enc) { 1209 + UNUSED_P(state); 1210 + UNUSED_P(tok); 1211 + UNUSED_P(ptr); 1212 + UNUSED_P(end); 1213 + UNUSED_P(enc); 1350 1214 return XML_ROLE_NONE; 1351 1215 } 1352 1216 /* LCOV_EXCL_STOP */ 1353 1217 1354 1218 static int FASTCALL 1355 -common(PROLOG_STATE *state, int tok) 1356 -{ 1219 +common(PROLOG_STATE *state, int tok) { 1357 1220 #ifdef XML_DTD 1358 - if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF) 1221 + if (! state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF) 1359 1222 return XML_ROLE_INNER_PARAM_ENTITY_REF; 1360 1223 #endif 1361 1224 state->handler = error; 1362 1225 return XML_ROLE_ERROR; 1363 1226 } 1364 1227 1365 1228 void 1366 -XmlPrologStateInit(PROLOG_STATE *state) 1367 -{ 1229 +XmlPrologStateInit(PROLOG_STATE *state) { 1368 1230 state->handler = prolog0; 1369 1231 #ifdef XML_DTD 1370 1232 state->documentEntity = 1; 1371 1233 state->includeLevel = 0; 1372 1234 state->inEntityValue = 0; 1373 1235 #endif /* XML_DTD */ 1374 1236 } 1375 1237 1376 1238 #ifdef XML_DTD 1377 1239 1378 1240 void 1379 -XmlPrologStateInitExternalEntity(PROLOG_STATE *state) 1380 -{ 1241 +XmlPrologStateInitExternalEntity(PROLOG_STATE *state) { 1381 1242 state->handler = externalSubset0; 1382 1243 state->documentEntity = 0; 1383 1244 state->includeLevel = 0; 1384 1245 } 1385 1246 1386 1247 #endif /* XML_DTD */
Changes to expat/xmlrole.h.
32 32 33 33 #ifndef XmlRole_INCLUDED 34 34 #define XmlRole_INCLUDED 1 35 35 36 36 #ifdef __VMS 37 37 /* 0 1 2 3 0 1 2 3 38 38 1234567890123456789012345678901 1234567890123456789012345678901 */ 39 -#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt 39 +# define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt 40 40 #endif 41 41 42 42 #include "xmltok.h" 43 43 44 44 #ifdef __cplusplus 45 45 extern "C" { 46 46 #endif ................................................................................ 109 109 XML_ROLE_IGNORE_SECT, 110 110 XML_ROLE_INNER_PARAM_ENTITY_REF, 111 111 #endif /* XML_DTD */ 112 112 XML_ROLE_PARAM_ENTITY_REF 113 113 }; 114 114 115 115 typedef struct prolog_state { 116 - int (PTRCALL *handler) (struct prolog_state *state, 117 - int tok, 118 - const char *ptr, 119 - const char *end, 120 - const ENCODING *enc); 116 + int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr, 117 + const char *end, const ENCODING *enc); 121 118 unsigned level; 122 119 int role_none; 123 120 #ifdef XML_DTD 124 121 unsigned includeLevel; 125 122 int documentEntity; 126 123 int inEntityValue; 127 124 #endif /* XML_DTD */ ................................................................................ 128 125 } PROLOG_STATE; 129 126 130 127 void XmlPrologStateInit(PROLOG_STATE *); 131 128 #ifdef XML_DTD 132 129 void XmlPrologStateInitExternalEntity(PROLOG_STATE *); 133 130 #endif /* XML_DTD */ 134 131 135 -#define XmlTokenRole(state, tok, ptr, end, enc) \ 136 - (((state)->handler)(state, tok, ptr, end, enc)) 132 +#define XmlTokenRole(state, tok, ptr, end, enc) \ 133 + (((state)->handler)(state, tok, ptr, end, enc)) 137 134 138 135 #ifdef __cplusplus 139 136 } 140 137 #endif 141 138 142 139 #endif /* not XmlRole_INCLUDED */
Changes to expat/xmltok.c.
27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 #include <stddef.h> 34 -#include <string.h> /* memcpy */ 34 +#include <string.h> /* memcpy */ 35 35 36 36 #if defined(_MSC_VER) && (_MSC_VER <= 1700) 37 - /* for vs2012/11.0/1700 and earlier Visual Studio compilers */ 38 -# define bool int 39 -# define false 0 40 -# define true 1 37 +/* for vs2012/11.0/1700 and earlier Visual Studio compilers */ 38 +# define bool int 39 +# define false 0 40 +# define true 1 41 41 #else 42 -# include <stdbool.h> 42 +# include <stdbool.h> 43 43 #endif 44 - 45 44 46 45 #ifdef _WIN32 47 -#include "winconfig.h" 46 +# include "winconfig.h" 48 47 #else 49 -#ifdef HAVE_EXPAT_CONFIG_H 50 -#include <expat_config.h> 51 -#endif 48 +# ifdef HAVE_EXPAT_CONFIG_H 49 +# include <expat_config.h> 50 +# endif 52 51 #endif /* ndef _WIN32 */ 53 52 54 53 #include "expat_external.h" 55 54 #include "internal.h" 56 55 #include "xmltok.h" 57 56 #include "nametab.h" 58 57 59 58 #ifdef XML_DTD 60 -#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) 59 +# define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) 61 60 #else 62 -#define IGNORE_SECTION_TOK_VTABLE /* as nothing */ 61 +# define IGNORE_SECTION_TOK_VTABLE /* as nothing */ 63 62 #endif 64 63 65 -#define VTABLE1 \ 66 - { PREFIX(prologTok), PREFIX(contentTok), \ 67 - PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ 68 - { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ 69 - PREFIX(nameMatchesAscii), \ 70 - PREFIX(nameLength), \ 71 - PREFIX(skipS), \ 72 - PREFIX(getAtts), \ 73 - PREFIX(charRefNumber), \ 74 - PREFIX(predefinedEntityName), \ 75 - PREFIX(updatePosition), \ 76 - PREFIX(isPublicId) 64 +#define VTABLE1 \ 65 + {PREFIX(prologTok), PREFIX(contentTok), \ 66 + PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE}, \ 67 + {PREFIX(attributeValueTok), PREFIX(entityValueTok)}, \ 68 + PREFIX(nameMatchesAscii), PREFIX(nameLength), PREFIX(skipS), \ 69 + PREFIX(getAtts), PREFIX(charRefNumber), PREFIX(predefinedEntityName), \ 70 + PREFIX(updatePosition), PREFIX(isPublicId) 77 71 78 72 #define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16) 79 73 80 -#define UCS2_GET_NAMING(pages, hi, lo) \ 81 - (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo) & 0x1F))) 74 +#define UCS2_GET_NAMING(pages, hi, lo) \ 75 + (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F))) 82 76 83 77 /* A 2 byte UTF-8 representation splits the characters 11 bits between 84 78 the bottom 5 and 6 bits of the bytes. We need 8 bits to index into 85 79 pages, 3 bits to add to that index and 5 bits to generate the mask. 86 80 */ 87 -#define UTF8_GET_NAMING2(pages, byte) \ 88 - (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ 89 - + ((((byte)[0]) & 3) << 1) \ 90 - + ((((byte)[1]) >> 5) & 1)] \ 91 - & (1u << (((byte)[1]) & 0x1F))) 81 +#define UTF8_GET_NAMING2(pages, byte) \ 82 + (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ 83 + + ((((byte)[0]) & 3) << 1) + ((((byte)[1]) >> 5) & 1)] \ 84 + & (1u << (((byte)[1]) & 0x1F))) 92 85 93 86 /* A 3 byte UTF-8 representation splits the characters 16 bits between 94 87 the bottom 4, 6 and 6 bits of the bytes. We need 8 bits to index 95 88 into pages, 3 bits to add to that index and 5 bits to generate the 96 89 mask. 97 90 */ 98 -#define UTF8_GET_NAMING3(pages, byte) \ 99 - (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \ 100 - + ((((byte)[1]) >> 2) & 0xF)] \ 101 - << 3) \ 102 - + ((((byte)[1]) & 3) << 1) \ 103 - + ((((byte)[2]) >> 5) & 1)] \ 104 - & (1u << (((byte)[2]) & 0x1F))) 91 +#define UTF8_GET_NAMING3(pages, byte) \ 92 + (namingBitmap \ 93 + [((pages)[((((byte)[0]) & 0xF) << 4) + ((((byte)[1]) >> 2) & 0xF)] \ 94 + << 3) \ 95 + + ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \ 96 + & (1u << (((byte)[2]) & 0x1F))) 105 97 106 -#define UTF8_GET_NAMING(pages, p, n) \ 107 - ((n) == 2 \ 108 - ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ 109 - : ((n) == 3 \ 110 - ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \ 111 - : 0)) 98 +#define UTF8_GET_NAMING(pages, p, n) \ 99 + ((n) == 2 \ 100 + ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ 101 + : ((n) == 3 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) : 0)) 112 102 113 103 /* Detection of invalid UTF-8 sequences is based on Table 3.1B 114 104 of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/ 115 105 with the additional restriction of not allowing the Unicode 116 106 code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE). 117 107 Implementation details: 118 108 (A & 0x80) == 0 means A < 0x80 119 109 and 120 110 (A & 0xC0) == 0xC0 means A > 0xBF 121 111 */ 122 112 123 -#define UTF8_INVALID2(p) \ 113 +#define UTF8_INVALID2(p) \ 124 114 ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0) 125 115 126 -#define UTF8_INVALID3(p) \ 127 - (((p)[2] & 0x80) == 0 \ 128 - || \ 129 - ((*p) == 0xEF && (p)[1] == 0xBF \ 130 - ? \ 131 - (p)[2] > 0xBD \ 132 - : \ 133 - ((p)[2] & 0xC0) == 0xC0) \ 134 - || \ 135 - ((*p) == 0xE0 \ 136 - ? \ 137 - (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \ 138 - : \ 139 - ((p)[1] & 0x80) == 0 \ 140 - || \ 141 - ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0))) 142 - 143 -#define UTF8_INVALID4(p) \ 144 - (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \ 145 - || \ 146 - ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \ 147 - || \ 148 - ((*p) == 0xF0 \ 149 - ? \ 150 - (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \ 151 - : \ 152 - ((p)[1] & 0x80) == 0 \ 153 - || \ 154 - ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) 155 - 156 -static int PTRFASTCALL 157 -isNever(const ENCODING *UNUSED_P(enc), const char *UNUSED_P(p)) 158 -{ 116 +#define UTF8_INVALID3(p) \ 117 + (((p)[2] & 0x80) == 0 \ 118 + || ((*p) == 0xEF && (p)[1] == 0xBF ? (p)[2] > 0xBD \ 119 + : ((p)[2] & 0xC0) == 0xC0) \ 120 + || ((*p) == 0xE0 \ 121 + ? (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \ 122 + : ((p)[1] & 0x80) == 0 \ 123 + || ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0))) 124 + 125 +#define UTF8_INVALID4(p) \ 126 + (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 || ((p)[2] & 0x80) == 0 \ 127 + || ((p)[2] & 0xC0) == 0xC0 \ 128 + || ((*p) == 0xF0 \ 129 + ? (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \ 130 + : ((p)[1] & 0x80) == 0 \ 131 + || ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) 132 + 133 +static int PTRFASTCALL 134 +isNever(const ENCODING *enc, const char *p) { 135 + UNUSED_P(enc); 136 + UNUSED_P(p); 159 137 return 0; 160 138 } 161 139 162 140 static int PTRFASTCALL 163 -utf8_isName2(const ENCODING *UNUSED_P(enc), const char *p) 164 -{ 141 +utf8_isName2(const ENCODING *enc, const char *p) { 142 + UNUSED_P(enc); 165 143 return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); 166 144 } 167 145 168 146 static int PTRFASTCALL 169 -utf8_isName3(const ENCODING *UNUSED_P(enc), const char *p) 170 -{ 147 +utf8_isName3(const ENCODING *enc, const char *p) { 148 + UNUSED_P(enc); 171 149 return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); 172 150 } 173 151 174 152 #define utf8_isName4 isNever 175 153 176 154 static int PTRFASTCALL 177 -utf8_isNmstrt2(const ENCODING *UNUSED_P(enc), const char *p) 178 -{ 155 +utf8_isNmstrt2(const ENCODING *enc, const char *p) { 156 + UNUSED_P(enc); 179 157 return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); 180 158 } 181 159 182 160 static int PTRFASTCALL 183 -utf8_isNmstrt3(const ENCODING *UNUSED_P(enc), const char *p) 184 -{ 161 +utf8_isNmstrt3(const ENCODING *enc, const char *p) { 162 + UNUSED_P(enc); 185 163 return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); 186 164 } 187 165 188 166 #define utf8_isNmstrt4 isNever 189 167 190 168 static int PTRFASTCALL 191 -utf8_isInvalid2(const ENCODING *UNUSED_P(enc), const char *p) 192 -{ 169 +utf8_isInvalid2(const ENCODING *enc, const char *p) { 170 + UNUSED_P(enc); 193 171 return UTF8_INVALID2((const unsigned char *)p); 194 172 } 195 173 196 174 static int PTRFASTCALL 197 -utf8_isInvalid3(const ENCODING *UNUSED_P(enc), const char *p) 198 -{ 175 +utf8_isInvalid3(const ENCODING *enc, const char *p) { 176 + UNUSED_P(enc); 199 177 return UTF8_INVALID3((const unsigned char *)p); 200 178 } 201 179 202 180 static int PTRFASTCALL 203 -utf8_isInvalid4(const ENCODING *UNUSED_P(enc), const char *p) 204 -{ 181 +utf8_isInvalid4(const ENCODING *enc, const char *p) { 182 + UNUSED_P(enc); 205 183 return UTF8_INVALID4((const unsigned char *)p); 206 184 } 207 185 208 186 struct normal_encoding { 209 187 ENCODING enc; 210 188 unsigned char type[256]; 211 189 #ifdef XML_MIN_SIZE 212 - int (PTRFASTCALL *byteType)(const ENCODING *, const char *); 213 - int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *); 214 - int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); 215 - int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); 216 - int (PTRCALL *charMatches)(const ENCODING *, const char *, int); 190 + int(PTRFASTCALL *byteType)(const ENCODING *, const char *); 191 + int(PTRFASTCALL *isNameMin)(const ENCODING *, const char *); 192 + int(PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); 193 + int(PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); 194 + int(PTRCALL *charMatches)(const ENCODING *, const char *, int); 217 195 #endif /* XML_MIN_SIZE */ 218 - int (PTRFASTCALL *isName2)(const ENCODING *, const char *); 219 - int (PTRFASTCALL *isName3)(const ENCODING *, const char *); 220 - int (PTRFASTCALL *isName4)(const ENCODING *, const char *); 221 - int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); 222 - int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); 223 - int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); 224 - int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); 225 - int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); 226 - int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); 196 + int(PTRFASTCALL *isName2)(const ENCODING *, const char *); 197 + int(PTRFASTCALL *isName3)(const ENCODING *, const char *); 198 + int(PTRFASTCALL *isName4)(const ENCODING *, const char *); 199 + int(PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); 200 + int(PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); 201 + int(PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); 202 + int(PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); 203 + int(PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); 204 + int(PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); 227 205 }; 228 206 229 -#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc)) 207 +#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *)(enc)) 230 208 231 209 #ifdef XML_MIN_SIZE 232 210 233 -#define STANDARD_VTABLE(E) \ 234 - E ## byteType, \ 235 - E ## isNameMin, \ 236 - E ## isNmstrtMin, \ 237 - E ## byteToAscii, \ 238 - E ## charMatches, 211 +# define STANDARD_VTABLE(E) \ 212 + E##byteType, E##isNameMin, E##isNmstrtMin, E##byteToAscii, E##charMatches, 239 213 240 214 #else 241 215 242 -#define STANDARD_VTABLE(E) /* as nothing */ 216 +# define STANDARD_VTABLE(E) /* as nothing */ 243 217 244 218 #endif 245 219 246 -#define NORMAL_VTABLE(E) \ 247 - E ## isName2, \ 248 - E ## isName3, \ 249 - E ## isName4, \ 250 - E ## isNmstrt2, \ 251 - E ## isNmstrt3, \ 252 - E ## isNmstrt4, \ 253 - E ## isInvalid2, \ 254 - E ## isInvalid3, \ 255 - E ## isInvalid4 220 +#define NORMAL_VTABLE(E) \ 221 + E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, \ 222 + E##isNmstrt4, E##isInvalid2, E##isInvalid3, E##isInvalid4 256 223 257 -#define NULL_VTABLE \ 258 - /* isName2 */ NULL, \ 259 - /* isName3 */ NULL, \ 260 - /* isName4 */ NULL, \ 261 - /* isNmstrt2 */ NULL, \ 262 - /* isNmstrt3 */ NULL, \ 263 - /* isNmstrt4 */ NULL, \ 264 - /* isInvalid2 */ NULL, \ 265 - /* isInvalid3 */ NULL, \ 266 - /* isInvalid4 */ NULL 224 +#define NULL_VTABLE \ 225 + /* isName2 */ NULL, /* isName3 */ NULL, /* isName4 */ NULL, \ 226 + /* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \ 227 + /* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL 267 228 268 229 static int FASTCALL checkCharRefNumber(int); 269 230 270 231 #include "xmltok_impl.h" 271 232 #include "ascii.h" 272 233 273 234 #ifdef XML_MIN_SIZE 274 -#define sb_isNameMin isNever 275 -#define sb_isNmstrtMin isNever 235 +# define sb_isNameMin isNever 236 +# define sb_isNmstrtMin isNever 276 237 #endif 277 238 278 239 #ifdef XML_MIN_SIZE 279 -#define MINBPC(enc) ((enc)->minBytesPerChar) 240 +# define MINBPC(enc) ((enc)->minBytesPerChar) 280 241 #else 281 242 /* minimum bytes per character */ 282 -#define MINBPC(enc) 1 243 +# define MINBPC(enc) 1 283 244 #endif 284 245 285 -#define SB_BYTE_TYPE(enc, p) \ 246 +#define SB_BYTE_TYPE(enc, p) \ 286 247 (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) 287 248 288 249 #ifdef XML_MIN_SIZE 289 250 static int PTRFASTCALL 290 -sb_byteType(const ENCODING *enc, const char *p) 291 -{ 251 +sb_byteType(const ENCODING *enc, const char *p) { 292 252 return SB_BYTE_TYPE(enc, p); 293 253 } 294 -#define BYTE_TYPE(enc, p) \ 295 - (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) 254 +# define BYTE_TYPE(enc, p) (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) 296 255 #else 297 -#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) 256 +# define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) 298 257 #endif 299 258 300 259 #ifdef XML_MIN_SIZE 301 -#define BYTE_TO_ASCII(enc, p) \ 302 - (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) 260 +# define BYTE_TO_ASCII(enc, p) (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) 303 261 static int PTRFASTCALL 304 -sb_byteToAscii(const ENCODING *enc, const char *p) 305 -{ 262 +sb_byteToAscii(const ENCODING *enc, const char *p) { 263 + UNUSED_P(enc); 306 264 return *p; 307 265 } 308 266 #else 309 -#define BYTE_TO_ASCII(enc, p) (*(p)) 267 +# define BYTE_TO_ASCII(enc, p) (*(p)) 310 268 #endif 311 269 312 -#define IS_NAME_CHAR(enc, p, n) \ 313 - (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p)) 314 -#define IS_NMSTRT_CHAR(enc, p, n) \ 315 - (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p)) 316 -#define IS_INVALID_CHAR(enc, p, n) \ 317 - (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p)) 270 +#define IS_NAME_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isName##n(enc, p)) 271 +#define IS_NMSTRT_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p)) 272 +#define IS_INVALID_CHAR(enc, p, n) \ 273 + (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p)) 318 274 319 275 #ifdef XML_MIN_SIZE 320 -#define IS_NAME_CHAR_MINBPC(enc, p) \ 321 - (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) 322 -#define IS_NMSTRT_CHAR_MINBPC(enc, p) \ 323 - (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) 276 +# define IS_NAME_CHAR_MINBPC(enc, p) \ 277 + (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) 278 +# define IS_NMSTRT_CHAR_MINBPC(enc, p) \ 279 + (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) 324 280 #else 325 -#define IS_NAME_CHAR_MINBPC(enc, p) (0) 326 -#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) 281 +# define IS_NAME_CHAR_MINBPC(enc, p) (0) 282 +# define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) 327 283 #endif 328 284 329 285 #ifdef XML_MIN_SIZE 330 -#define CHAR_MATCHES(enc, p, c) \ 331 - (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) 286 +# define CHAR_MATCHES(enc, p, c) \ 287 + (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) 332 288 static int PTRCALL 333 -sb_charMatches(const ENCODING *enc, const char *p, int c) 334 -{ 289 +sb_charMatches(const ENCODING *enc, const char *p, int c) { 290 + UNUSED_P(enc); 335 291 return *p == c; 336 292 } 337 293 #else 338 294 /* c is an ASCII character */ 339 -#define CHAR_MATCHES(enc, p, c) (*(p) == c) 295 +# define CHAR_MATCHES(enc, p, c) (*(p) == c) 340 296 #endif 341 297 342 -#define PREFIX(ident) normal_ ## ident 298 +#define PREFIX(ident) normal_##ident 343 299 #define XML_TOK_IMPL_C 344 300 #include "xmltok_impl.c" 345 301 #undef XML_TOK_IMPL_C 346 302 347 303 #undef MINBPC 348 304 #undef BYTE_TYPE 349 305 #undef BYTE_TO_ASCII ................................................................................ 350 306 #undef CHAR_MATCHES 351 307 #undef IS_NAME_CHAR 352 308 #undef IS_NAME_CHAR_MINBPC 353 309 #undef IS_NMSTRT_CHAR 354 310 #undef IS_NMSTRT_CHAR_MINBPC 355 311 #undef IS_INVALID_CHAR 356 312 357 -enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ 358 - UTF8_cval1 = 0x00, 359 - UTF8_cval2 = 0xc0, 360 - UTF8_cval3 = 0xe0, 361 - UTF8_cval4 = 0xf0 313 +enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ 314 + UTF8_cval1 = 0x00, 315 + UTF8_cval2 = 0xc0, 316 + UTF8_cval3 = 0xe0, 317 + UTF8_cval4 = 0xf0 362 318 }; 363 319 364 320 void 365 -_INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef) 366 -{ 367 - const char * fromLim = *fromLimRef; 321 +_INTERNAL_trim_to_complete_utf8_characters(const char *from, 322 + const char **fromLimRef) { 323 + const char *fromLim = *fromLimRef; 368 324 size_t walked = 0; 369 325 for (; fromLim > from; fromLim--, walked++) { 370 326 const unsigned char prev = (unsigned char)fromLim[-1]; 371 - if ((prev & 0xf8u) == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */ 327 + if ((prev & 0xf8u) 328 + == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */ 372 329 if (walked + 1 >= 4) { 373 330 fromLim += 4 - 1; 374 331 break; 375 332 } else { 376 333 walked = 0; 377 334 } 378 - } else if ((prev & 0xf0u) == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */ 335 + } else if ((prev & 0xf0u) 336 + == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */ 379 337 if (walked + 1 >= 3) { 380 338 fromLim += 3 - 1; 381 339 break; 382 340 } else { 383 341 walked = 0; 384 342 } 385 - } else if ((prev & 0xe0u) == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */ 343 + } else if ((prev & 0xe0u) 344 + == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */ 386 345 if (walked + 1 >= 2) { 387 346 fromLim += 2 - 1; 388 347 break; 389 348 } else { 390 349 walked = 0; 391 350 } 392 - } else if ((prev & 0x80u) == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */ 351 + } else if ((prev & 0x80u) 352 + == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */ 393 353 break; 394 354 } 395 355 } 396 356 *fromLimRef = fromLim; 397 357 } 398 358 399 359 static enum XML_Convert_Result PTRCALL 400 -utf8_toUtf8(const ENCODING *UNUSED_P(enc), 401 - const char **fromP, const char *fromLim, 402 - char **toP, const char *toLim) 403 -{ 360 +utf8_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, 361 + char **toP, const char *toLim) { 404 362 bool input_incomplete = false; 405 363 bool output_exhausted = false; 406 364 407 365 /* Avoid copying partial characters (due to limited space). */ 408 366 const ptrdiff_t bytesAvailable = fromLim - *fromP; 409 367 const ptrdiff_t bytesStorable = toLim - *toP; 368 + UNUSED_P(enc); 410 369 if (bytesAvailable > bytesStorable) { 411 370 fromLim = *fromP + bytesStorable; 412 371 output_exhausted = true; 413 372 } 414 373 415 374 /* Avoid copying partial characters (from incomplete input). */ 416 375 { 417 - const char * const fromLimBefore = fromLim; 376 + const char *const fromLimBefore = fromLim; 418 377 _INTERNAL_trim_to_complete_utf8_characters(*fromP, &fromLim); 419 378 if (fromLim < fromLimBefore) { 420 379 input_incomplete = true; 421 380 } 422 381 } 423 382 424 383 { 425 384 const ptrdiff_t bytesToCopy = fromLim - *fromP; 426 385 memcpy(*toP, *fromP, bytesToCopy); 427 386 *fromP += bytesToCopy; 428 387 *toP += bytesToCopy; 429 388 } 430 389 431 - if (output_exhausted) /* needs to go first */ 390 + if (output_exhausted) /* needs to go first */ 432 391 return XML_CONVERT_OUTPUT_EXHAUSTED; 433 392 else if (input_incomplete) 434 393 return XML_CONVERT_INPUT_INCOMPLETE; 435 394 else 436 395 return XML_CONVERT_COMPLETED; 437 396 } 438 397 439 398 static enum XML_Convert_Result PTRCALL 440 -utf8_toUtf16(const ENCODING *enc, 441 - const char **fromP, const char *fromLim, 442 - unsigned short **toP, const unsigned short *toLim) 443 -{ 399 +utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, 400 + unsigned short **toP, const unsigned short *toLim) { 444 401 enum XML_Convert_Result res = XML_CONVERT_COMPLETED; 445 402 unsigned short *to = *toP; 446 403 const char *from = *fromP; 447 404 while (from < fromLim && to < toLim) { 448 405 switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { 449 406 case BT_LEAD2: 450 407 if (fromLim - from < 2) { ................................................................................ 455 412 from += 2; 456 413 break; 457 414 case BT_LEAD3: 458 415 if (fromLim - from < 3) { 459 416 res = XML_CONVERT_INPUT_INCOMPLETE; 460 417 goto after; 461 418 } 462 - *to++ = (unsigned short)(((from[0] & 0xf) << 12) 463 - | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f)); 419 + *to++ = (unsigned short)(((from[0] & 0xf) << 12) | ((from[1] & 0x3f) << 6) 420 + | (from[2] & 0x3f)); 464 421 from += 3; 465 422 break; 466 - case BT_LEAD4: 467 - { 468 - unsigned long n; 469 - if (toLim - to < 2) { 470 - res = XML_CONVERT_OUTPUT_EXHAUSTED; 471 - goto after; 472 - } 473 - if (fromLim - from < 4) { 474 - res = XML_CONVERT_INPUT_INCOMPLETE; 475 - goto after; 476 - } 477 - n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) 478 - | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); 479 - n -= 0x10000; 480 - to[0] = (unsigned short)((n >> 10) | 0xD800); 481 - to[1] = (unsigned short)((n & 0x3FF) | 0xDC00); 482 - to += 2; 483 - from += 4; 423 + case BT_LEAD4: { 424 + unsigned long n; 425 + if (toLim - to < 2) { 426 + res = XML_CONVERT_OUTPUT_EXHAUSTED; 427 + goto after; 428 + } 429 + if (fromLim - from < 4) { 430 + res = XML_CONVERT_INPUT_INCOMPLETE; 431 + goto after; 484 432 } 485 - break; 433 + n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) 434 + | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); 435 + n -= 0x10000; 436 + to[0] = (unsigned short)((n >> 10) | 0xD800); 437 + to[1] = (unsigned short)((n & 0x3FF) | 0xDC00); 438 + to += 2; 439 + from += 4; 440 + } break; 486 441 default: 487 442 *to++ = *from++; 488 443 break; 489 444 } 490 445 } 491 446 if (from < fromLim) 492 447 res = XML_CONVERT_OUTPUT_EXHAUSTED; ................................................................................ 493 448 after: 494 449 *fromP = from; 495 450 *toP = to; 496 451 return res; 497 452 } 498 453 499 454 #ifdef XML_NS 500 -static const struct normal_encoding utf8_encoding_ns = { 501 - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, 502 - { 503 -#include "asciitab.h" 504 -#include "utf8tab.h" 505 - }, 506 - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) 507 -}; 455 +static const struct normal_encoding utf8_encoding_ns 456 + = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0}, 457 + { 458 +# include "asciitab.h" 459 +# include "utf8tab.h" 460 + }, 461 + STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)}; 508 462 #endif 509 463 510 -static const struct normal_encoding utf8_encoding = { 511 - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, 512 - { 464 +static const struct normal_encoding utf8_encoding 465 + = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0}, 466 + { 513 467 #define BT_COLON BT_NMSTRT 514 468 #include "asciitab.h" 515 469 #undef BT_COLON 516 470 #include "utf8tab.h" 517 - }, 518 - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) 519 -}; 471 + }, 472 + STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)}; 520 473 521 474 #ifdef XML_NS 522 475 523 -static const struct normal_encoding internal_utf8_encoding_ns = { 524 - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, 525 - { 526 -#include "iasciitab.h" 527 -#include "utf8tab.h" 528 - }, 529 - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) 530 -}; 476 +static const struct normal_encoding internal_utf8_encoding_ns 477 + = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0}, 478 + { 479 +# include "iasciitab.h" 480 +# include "utf8tab.h" 481 + }, 482 + STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)}; 531 483 532 484 #endif 533 485 534 -static const struct normal_encoding internal_utf8_encoding = { 535 - { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, 536 - { 486 +static const struct normal_encoding internal_utf8_encoding 487 + = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0}, 488 + { 537 489 #define BT_COLON BT_NMSTRT 538 490 #include "iasciitab.h" 539 491 #undef BT_COLON 540 492 #include "utf8tab.h" 541 - }, 542 - STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) 543 -}; 493 + }, 494 + STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)}; 544 495 545 496 static enum XML_Convert_Result PTRCALL 546 -latin1_toUtf8(const ENCODING *UNUSED_P(enc), 547 - const char **fromP, const char *fromLim, 548 - char **toP, const char *toLim) 549 -{ 497 +latin1_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, 498 + char **toP, const char *toLim) { 499 + UNUSED_P(enc); 550 500 for (;;) { 551 501 unsigned char c; 552 502 if (*fromP == fromLim) 553 503 return XML_CONVERT_COMPLETED; 554 504 c = (unsigned char)**fromP; 555 505 if (c & 0x80) { 556 506 if (toLim - *toP < 2) 557 507 return XML_CONVERT_OUTPUT_EXHAUSTED; 558 508 *(*toP)++ = (char)((c >> 6) | UTF8_cval2); 559 509 *(*toP)++ = (char)((c & 0x3f) | 0x80); 560 510 (*fromP)++; 561 - } 562 - else { 511 + } else { 563 512 if (*toP == toLim) 564 513 return XML_CONVERT_OUTPUT_EXHAUSTED; 565 514 *(*toP)++ = *(*fromP)++; 566 515 } 567 516 } 568 517 } 569 518 570 519 static enum XML_Convert_Result PTRCALL 571 -latin1_toUtf16(const ENCODING *UNUSED_P(enc), 572 - const char **fromP, const char *fromLim, 573 - unsigned short **toP, const unsigned short *toLim) 574 -{ 520 +latin1_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, 521 + unsigned short **toP, const unsigned short *toLim) { 522 + UNUSED_P(enc); 575 523 while (*fromP < fromLim && *toP < toLim) 576 524 *(*toP)++ = (unsigned char)*(*fromP)++; 577 525 578 526 if ((*toP == toLim) && (*fromP < fromLim)) 579 527 return XML_CONVERT_OUTPUT_EXHAUSTED; 580 528 else 581 529 return XML_CONVERT_COMPLETED; 582 530 } 583 531 584 532 #ifdef XML_NS 585 533 586 -static const struct normal_encoding latin1_encoding_ns = { 587 - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, 588 - { 589 -#include "asciitab.h" 590 -#include "latin1tab.h" 591 - }, 592 - STANDARD_VTABLE(sb_) NULL_VTABLE 593 -}; 534 +static const struct normal_encoding latin1_encoding_ns 535 + = {{VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0}, 536 + { 537 +# include "asciitab.h" 538 +# include "latin1tab.h" 539 + }, 540 + STANDARD_VTABLE(sb_) NULL_VTABLE}; 594 541 595 542 #endif 596 543 597 -static const struct normal_encoding latin1_encoding = { 598 - { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, 599 - { 544 +static const struct normal_encoding latin1_encoding 545 + = {{VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0}, 546 + { 600 547 #define BT_COLON BT_NMSTRT 601 548 #include "asciitab.h" 602 549 #undef BT_COLON 603 550 #include "latin1tab.h" 604 - }, 605 - STANDARD_VTABLE(sb_) NULL_VTABLE 606 -}; 551 + }, 552 + STANDARD_VTABLE(sb_) NULL_VTABLE}; 607 553 608 554 static enum XML_Convert_Result PTRCALL 609 -ascii_toUtf8(const ENCODING *UNUSED_P(enc), 610 - const char **fromP, const char *fromLim, 611 - char **toP, const char *toLim) 612 -{ 555 +ascii_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, 556 + char **toP, const char *toLim) { 557 + UNUSED_P(enc); 613 558 while (*fromP < fromLim && *toP < toLim) 614 559 *(*toP)++ = *(*fromP)++; 615 560 616 561 if ((*toP == toLim) && (*fromP < fromLim)) 617 562 return XML_CONVERT_OUTPUT_EXHAUSTED; 618 563 else 619 564 return XML_CONVERT_COMPLETED; 620 565 } 621 566 622 567 #ifdef XML_NS 623 568 624 -static const struct normal_encoding ascii_encoding_ns = { 625 - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, 626 - { 627 -#include "asciitab.h" 628 -/* BT_NONXML == 0 */ 629 - }, 630 - STANDARD_VTABLE(sb_) NULL_VTABLE 631 -}; 569 +static const struct normal_encoding ascii_encoding_ns 570 + = {{VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0}, 571 + { 572 +# include "asciitab.h" 573 + /* BT_NONXML == 0 */ 574 + }, 575 + STANDARD_VTABLE(sb_) NULL_VTABLE}; 632 576 633 577 #endif 634 578 635 -static const struct normal_encoding ascii_encoding = { 636 - { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, 637 - { 579 +static const struct normal_encoding ascii_encoding 580 + = {{VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0}, 581 + { 638 582 #define BT_COLON BT_NMSTRT 639 583 #include "asciitab.h" 640 584 #undef BT_COLON 641 -/* BT_NONXML == 0 */ 642 - }, 643 - STANDARD_VTABLE(sb_) NULL_VTABLE 644 -}; 585 + /* BT_NONXML == 0 */ 586 + }, 587 + STANDARD_VTABLE(sb_) NULL_VTABLE}; 645 588 646 589 static int PTRFASTCALL 647 -unicode_byte_type(char hi, char lo) 648 -{ 590 +unicode_byte_type(char hi, char lo) { 649 591 switch ((unsigned char)hi) { 650 - case 0xD8: case 0xD9: case 0xDA: case 0xDB: 592 + /* 0xD800–0xDBFF first 16-bit code unit or high surrogate (W1) */ 593 + case 0xD8: 594 + case 0xD9: 595 + case 0xDA: 596 + case 0xDB: 651 597 return BT_LEAD4; 652 - case 0xDC: case 0xDD: case 0xDE: case 0xDF: 598 + /* 0xDC00–0xDFFF second 16-bit code unit or low surrogate (W2) */ 599 + case 0xDC: 600 + case 0xDD: 601 + case 0xDE: 602 + case 0xDF: 653 603 return BT_TRAIL; 654 604 case 0xFF: 655 605 switch ((unsigned char)lo) { 656 - case 0xFF: 657 - case 0xFE: 606 + case 0xFF: /* noncharacter-FFFF */ 607 + case 0xFE: /* noncharacter-FFFE */ 658 608 return BT_NONXML; 659 609 } 660 610 break; 661 611 } 662 612 return BT_NONASCII; 663 613 } 664 614 665 -#define DEFINE_UTF16_TO_UTF8(E) \ 666 -static enum XML_Convert_Result PTRCALL \ 667 -E ## toUtf8(const ENCODING *UNUSED_P(enc), \ 668 - const char **fromP, const char *fromLim, \ 669 - char **toP, const char *toLim) \ 670 -{ \ 671 - const char *from = *fromP; \ 672 - fromLim = from + (((fromLim - from) >> 1) << 1); /* shrink to even */ \ 673 - for (; from < fromLim; from += 2) { \ 674 - int plane; \ 675 - unsigned char lo2; \ 676 - unsigned char lo = GET_LO(from); \ 677 - unsigned char hi = GET_HI(from); \ 678 - switch (hi) { \ 679 - case 0: \ 680 - if (lo < 0x80) { \ 681 - if (*toP == toLim) { \ 682 - *fromP = from; \ 683 - return XML_CONVERT_OUTPUT_EXHAUSTED; \ 684 - } \ 685 - *(*toP)++ = lo; \ 686 - break; \ 687 - } \ 688 - /* fall through */ \ 689 - case 0x1: case 0x2: case 0x3: \ 690 - case 0x4: case 0x5: case 0x6: case 0x7: \ 691 - if (toLim - *toP < 2) { \ 692 - *fromP = from; \ 693 - return XML_CONVERT_OUTPUT_EXHAUSTED; \ 694 - } \ 695 - *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ 696 - *(*toP)++ = ((lo & 0x3f) | 0x80); \ 697 - break; \ 698 - default: \ 699 - if (toLim - *toP < 3) { \ 700 - *fromP = from; \ 701 - return XML_CONVERT_OUTPUT_EXHAUSTED; \ 702 - } \ 703 - /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ 704 - *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ 705 - *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ 706 - *(*toP)++ = ((lo & 0x3f) | 0x80); \ 707 - break; \ 708 - case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ 709 - if (toLim - *toP < 4) { \ 710 - *fromP = from; \ 711 - return XML_CONVERT_OUTPUT_EXHAUSTED; \ 712 - } \ 713 - if (fromLim - from < 4) { \ 714 - *fromP = from; \ 715 - return XML_CONVERT_INPUT_INCOMPLETE; \ 716 - } \ 717 - plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ 718 - *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ 719 - *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ 720 - from += 2; \ 721 - lo2 = GET_LO(from); \ 722 - *(*toP)++ = (((lo & 0x3) << 4) \ 723 - | ((GET_HI(from) & 0x3) << 2) \ 724 - | (lo2 >> 6) \ 725 - | 0x80); \ 726 - *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ 727 - break; \ 728 - } \ 729 - } \ 730 - *fromP = from; \ 731 - if (from < fromLim) \ 732 - return XML_CONVERT_INPUT_INCOMPLETE; \ 733 - else \ 734 - return XML_CONVERT_COMPLETED; \ 735 -} 736 - 737 -#define DEFINE_UTF16_TO_UTF16(E) \ 738 -static enum XML_Convert_Result PTRCALL \ 739 -E ## toUtf16(const ENCODING *UNUSED_P(enc), \ 740 - const char **fromP, const char *fromLim, \ 741 - unsigned short **toP, const unsigned short *toLim) \ 742 -{ \ 743 - enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \ 744 - fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \ 745 - /* Avoid copying first half only of surrogate */ \ 746 - if (fromLim - *fromP > ((toLim - *toP) << 1) \ 747 - && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \ 748 - fromLim -= 2; \ 749 - res = XML_CONVERT_INPUT_INCOMPLETE; \ 750 - } \ 751 - for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \ 752 - *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ 753 - if ((*toP == toLim) && (*fromP < fromLim)) \ 754 - return XML_CONVERT_OUTPUT_EXHAUSTED; \ 755 - else \ 756 - return res; \ 757 -} 758 - 759 -#define SET2(ptr, ch) \ 760 - (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8))) 615 +#define DEFINE_UTF16_TO_UTF8(E) \ 616 + static enum XML_Convert_Result PTRCALL E##toUtf8( \ 617 + const ENCODING *enc, const char **fromP, const char *fromLim, \ 618 + char **toP, const char *toLim) { \ 619 + const char *from = *fromP; \ 620 + UNUSED_P(enc); \ 621 + fromLim = from + (((fromLim - from) >> 1) << 1); /* shrink to even */ \ 622 + for (; from < fromLim; from += 2) { \ 623 + int plane; \ 624 + unsigned char lo2; \ 625 + unsigned char lo = GET_LO(from); \ 626 + unsigned char hi = GET_HI(from); \ 627 + switch (hi) { \ 628 + case 0: \ 629 + if (lo < 0x80) { \ 630 + if (*toP == toLim) { \ 631 + *fromP = from; \ 632 + return XML_CONVERT_OUTPUT_EXHAUSTED; \ 633 + } \ 634 + *(*toP)++ = lo; \ 635 + break; \ 636 + } \ 637 + /* fall through */ \ 638 + case 0x1: \ 639 + case 0x2: \ 640 + case 0x3: \ 641 + case 0x4: \ 642 + case 0x5: \ 643 + case 0x6: \ 644 + case 0x7: \ 645 + if (toLim - *toP < 2) { \ 646 + *fromP = from; \ 647 + return XML_CONVERT_OUTPUT_EXHAUSTED; \ 648 + } \ 649 + *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ 650 + *(*toP)++ = ((lo & 0x3f) | 0x80); \ 651 + break; \ 652 + default: \ 653 + if (toLim - *toP < 3) { \ 654 + *fromP = from; \ 655 + return XML_CONVERT_OUTPUT_EXHAUSTED; \ 656 + } \ 657 + /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ 658 + *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ 659 + *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ 660 + *(*toP)++ = ((lo & 0x3f) | 0x80); \ 661 + break; \ 662 + case 0xD8: \ 663 + case 0xD9: \ 664 + case 0xDA: \ 665 + case 0xDB: \ 666 + if (toLim - *toP < 4) { \ 667 + *fromP = from; \ 668 + return XML_CONVERT_OUTPUT_EXHAUSTED; \ 669 + } \ 670 + if (fromLim - from < 4) { \ 671 + *fromP = from; \ 672 + return XML_CONVERT_INPUT_INCOMPLETE; \ 673 + } \ 674 + plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ 675 + *(*toP)++ = (char)((plane >> 2) | UTF8_cval4); \ 676 + *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ 677 + from += 2; \ 678 + lo2 = GET_LO(from); \ 679 + *(*toP)++ = (((lo & 0x3) << 4) | ((GET_HI(from) & 0x3) << 2) \ 680 + | (lo2 >> 6) | 0x80); \ 681 + *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ 682 + break; \ 683 + } \ 684 + } \ 685 + *fromP = from; \ 686 + if (from < fromLim) \ 687 + return XML_CONVERT_INPUT_INCOMPLETE; \ 688 + else \ 689 + return XML_CONVERT_COMPLETED; \ 690 + } 691 + 692 +#define DEFINE_UTF16_TO_UTF16(E) \ 693 + static enum XML_Convert_Result PTRCALL E##toUtf16( \ 694 + const ENCODING *enc, const char **fromP, const char *fromLim, \ 695 + unsigned short **toP, const unsigned short *toLim) { \ 696 + enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \ 697 + UNUSED_P(enc); \ 698 + fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \ 699 + /* Avoid copying first half only of surrogate */ \ 700 + if (fromLim - *fromP > ((toLim - *toP) << 1) \ 701 + && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \ 702 + fromLim -= 2; \ 703 + res = XML_CONVERT_INPUT_INCOMPLETE; \ 704 + } \ 705 + for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \ 706 + *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ 707 + if ((*toP == toLim) && (*fromP < fromLim)) \ 708 + return XML_CONVERT_OUTPUT_EXHAUSTED; \ 709 + else \ 710 + return res; \ 711 + } 712 + 713 +#define SET2(ptr, ch) (((ptr)[0] = ((ch)&0xff)), ((ptr)[1] = ((ch) >> 8))) 761 714 #define GET_LO(ptr) ((unsigned char)(ptr)[0]) 762 715 #define GET_HI(ptr) ((unsigned char)(ptr)[1]) 763 716 764 717 DEFINE_UTF16_TO_UTF8(little2_) 765 718 DEFINE_UTF16_TO_UTF16(little2_) 766 719 767 720 #undef SET2 768 721 #undef GET_LO 769 722 #undef GET_HI 770 723 771 -#define SET2(ptr, ch) \ 772 - (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF))) 724 +#define SET2(ptr, ch) (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch)&0xFF))) 773 725 #define GET_LO(ptr) ((unsigned char)(ptr)[1]) 774 726 #define GET_HI(ptr) ((unsigned char)(ptr)[0]) 775 727 776 728 DEFINE_UTF16_TO_UTF8(big2_) 777 729 DEFINE_UTF16_TO_UTF16(big2_) 778 730 779 731 #undef SET2 780 732 #undef GET_LO 781 733 #undef GET_HI 782 734 783 -#define LITTLE2_BYTE_TYPE(enc, p) \ 784 - ((p)[1] == 0 \ 785 - ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ 786 - : unicode_byte_type((p)[1], (p)[0])) 787 -#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1) 788 -#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c) 789 -#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \ 735 +#define LITTLE2_BYTE_TYPE(enc, p) \ 736 + ((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ 737 + : unicode_byte_type((p)[1], (p)[0])) 738 +#define LITTLE2_BYTE_TO_ASCII(p) ((p)[1] == 0 ? (p)[0] : -1) 739 +#define LITTLE2_CHAR_MATCHES(p, c) ((p)[1] == 0 && (p)[0] == c) 740 +#define LITTLE2_IS_NAME_CHAR_MINBPC(p) \ 790 741 UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0]) 791 -#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ 742 +#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) \ 792 743 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) 793 744 794 745 #ifdef XML_MIN_SIZE 795 746 796 747 static int PTRFASTCALL 797 -little2_byteType(const ENCODING *enc, const char *p) 798 -{ 748 +little2_byteType(const ENCODING *enc, const char *p) { 799 749 return LITTLE2_BYTE_TYPE(enc, p); 800 750 } 801 751 802 752 static int PTRFASTCALL 803 -little2_byteToAscii(const ENCODING *enc, const char *p) 804 -{ 805 - return LITTLE2_BYTE_TO_ASCII(enc, p); 753 +little2_byteToAscii(const ENCODING *enc, const char *p) { 754 + UNUSED_P(enc); 755 + return LITTLE2_BYTE_TO_ASCII(p); 806 756 } 807 757 808 758 static int PTRCALL 809 -little2_charMatches(const ENCODING *enc, const char *p, int c) 810 -{ 811 - return LITTLE2_CHAR_MATCHES(enc, p, c); 759 +little2_charMatches(const ENCODING *enc, const char *p, int c) { 760 + UNUSED_P(enc); 761 + return LITTLE2_CHAR_MATCHES(p, c); 812 762 } 813 763 814 764 static int PTRFASTCALL 815 -little2_isNameMin(const ENCODING *enc, const char *p) 816 -{ 817 - return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); 765 +little2_isNameMin(const ENCODING *enc, const char *p) { 766 + UNUSED_P(enc); 767 + return LITTLE2_IS_NAME_CHAR_MINBPC(p); 818 768 } 819 769 820 770 static int PTRFASTCALL 821 -little2_isNmstrtMin(const ENCODING *enc, const char *p) 822 -{ 823 - return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); 771 +little2_isNmstrtMin(const ENCODING *enc, const char *p) { 772 + UNUSED_P(enc); 773 + return LITTLE2_IS_NMSTRT_CHAR_MINBPC(p); 824 774 } 825 775 826 -#undef VTABLE 827 -#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 776 +# undef VTABLE 777 +# define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 828 778 829 779 #else /* not XML_MIN_SIZE */ 830 780 831 -#undef PREFIX 832 -#define PREFIX(ident) little2_ ## ident 833 -#define MINBPC(enc) 2 781 +# undef PREFIX 782 +# define PREFIX(ident) little2_##ident 783 +# define MINBPC(enc) 2 834 784 /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ 835 -#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) 836 -#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) 837 -#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c) 838 -#define IS_NAME_CHAR(enc, p, n) 0 839 -#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) 840 -#define IS_NMSTRT_CHAR(enc, p, n) (0) 841 -#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) 842 - 843 -#define XML_TOK_IMPL_C 844 -#include "xmltok_impl.c" 845 -#undef XML_TOK_IMPL_C 846 - 847 -#undef MINBPC 848 -#undef BYTE_TYPE 849 -#undef BYTE_TO_ASCII 850 -#undef CHAR_MATCHES 851 -#undef IS_NAME_CHAR 852 -#undef IS_NAME_CHAR_MINBPC 853 -#undef IS_NMSTRT_CHAR 854 -#undef IS_NMSTRT_CHAR_MINBPC 855 -#undef IS_INVALID_CHAR 785 +# define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) 786 +# define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(p) 787 +# define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(p, c) 788 +# define IS_NAME_CHAR(enc, p, n) 0 789 +# define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(p) 790 +# define IS_NMSTRT_CHAR(enc, p, n) (0) 791 +# define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) 792 + 793 +# define XML_TOK_IMPL_C 794 +# include "xmltok_impl.c" 795 +# undef XML_TOK_IMPL_C 796 + 797 +# undef MINBPC 798 +# undef BYTE_TYPE 799 +# undef BYTE_TO_ASCII 800 +# undef CHAR_MATCHES 801 +# undef IS_NAME_CHAR 802 +# undef IS_NAME_CHAR_MINBPC 803 +# undef IS_NMSTRT_CHAR 804 +# undef IS_NMSTRT_CHAR_MINBPC 805 +# undef IS_INVALID_CHAR 856 806 857 807 #endif /* not XML_MIN_SIZE */ 858 808 859 809 #ifdef XML_NS 860 810 861 -static const struct normal_encoding little2_encoding_ns = { 862 - { VTABLE, 2, 0, 863 -#if BYTEORDER == 1234 864 - 1 865 -#else 866 - 0 867 -#endif 868 - }, 869 - { 870 -#include "asciitab.h" 871 -#include "latin1tab.h" 872 - }, 873 - STANDARD_VTABLE(little2_) NULL_VTABLE 874 -}; 811 +static const struct normal_encoding little2_encoding_ns 812 + = {{VTABLE, 2, 0, 813 +# if BYTEORDER == 1234 814 + 1 815 +# else 816 + 0 817 +# endif 818 + }, 819 + { 820 +# include "asciitab.h" 821 +# include "latin1tab.h" 822 + }, 823 + STANDARD_VTABLE(little2_) NULL_VTABLE}; 875 824 876 825 #endif 877 826 878 -static const struct normal_encoding little2_encoding = { 879 - { VTABLE, 2, 0, 827 +static const struct normal_encoding little2_encoding 828 + = {{VTABLE, 2, 0, 880 829 #if BYTEORDER == 1234 881 - 1 830 + 1 882 831 #else 883 - 0 832 + 0 884 833 #endif 885 - }, 886 - { 834 + }, 835 + { 887 836 #define BT_COLON BT_NMSTRT 888 837 #include "asciitab.h" 889 838 #undef BT_COLON 890 839 #include "latin1tab.h" 891 - }, 892 - STANDARD_VTABLE(little2_) NULL_VTABLE 893 -}; 840 + }, 841 + STANDARD_VTABLE(little2_) NULL_VTABLE}; 894 842 895 843 #if BYTEORDER != 4321 896 844 897 -#ifdef XML_NS 898 - 899 -static const struct normal_encoding internal_little2_encoding_ns = { 900 - { VTABLE, 2, 0, 1 }, 901 - { 902 -#include "iasciitab.h" 903 -#include "latin1tab.h" 904 - }, 905 - STANDARD_VTABLE(little2_) NULL_VTABLE 906 -}; 907 - 908 -#endif 909 - 910 -static const struct normal_encoding internal_little2_encoding = { 911 - { VTABLE, 2, 0, 1 }, 912 - { 913 -#define BT_COLON BT_NMSTRT 914 -#include "iasciitab.h" 915 -#undef BT_COLON 916 -#include "latin1tab.h" 917 - }, 918 - STANDARD_VTABLE(little2_) NULL_VTABLE 919 -}; 845 +# ifdef XML_NS 846 + 847 +static const struct normal_encoding internal_little2_encoding_ns 848 + = {{VTABLE, 2, 0, 1}, 849 + { 850 +# include "iasciitab.h" 851 +# include "latin1tab.h" 852 + }, 853 + STANDARD_VTABLE(little2_) NULL_VTABLE}; 854 + 855 +# endif 856 + 857 +static const struct normal_encoding internal_little2_encoding 858 + = {{VTABLE, 2, 0, 1}, 859 + { 860 +# define BT_COLON BT_NMSTRT 861 +# include "iasciitab.h" 862 +# undef BT_COLON 863 +# include "latin1tab.h" 864 + }, 865 + STANDARD_VTABLE(little2_) NULL_VTABLE}; 920 866 921 867 #endif 922 868 923 - 924 -#define BIG2_BYTE_TYPE(enc, p) \ 925 - ((p)[0] == 0 \ 926 - ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ 927 - : unicode_byte_type((p)[0], (p)[1])) 928 -#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1) 929 -#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c) 930 -#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \ 869 +#define BIG2_BYTE_TYPE(enc, p) \ 870 + ((p)[0] == 0 \ 871 + ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ 872 + : unicode_byte_type((p)[0], (p)[1])) 873 +#define BIG2_BYTE_TO_ASCII(p) ((p)[0] == 0 ? (p)[1] : -1) 874 +#define BIG2_CHAR_MATCHES(p, c) ((p)[0] == 0 && (p)[1] == c) 875 +#define BIG2_IS_NAME_CHAR_MINBPC(p) \ 931 876 UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1]) 932 -#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ 877 +#define BIG2_IS_NMSTRT_CHAR_MINBPC(p) \ 933 878 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) 934 879 935 880 #ifdef XML_MIN_SIZE 936 881 937 882 static int PTRFASTCALL 938 -big2_byteType(const ENCODING *enc, const char *p) 939 -{ 883 +big2_byteType(const ENCODING *enc, const char *p) { 940 884 return BIG2_BYTE_TYPE(enc, p); 941 885 } 942 886 943 887 static int PTRFASTCALL 944 -big2_byteToAscii(const ENCODING *enc, const char *p) 945 -{ 946 - return BIG2_BYTE_TO_ASCII(enc, p); 888 +big2_byteToAscii(const ENCODING *enc, const char *p) { 889 + UNUSED_P(enc); 890 + return BIG2_BYTE_TO_ASCII(p); 947 891 } 948 892 949 893 static int PTRCALL 950 -big2_charMatches(const ENCODING *enc, const char *p, int c) 951 -{ 952 - return BIG2_CHAR_MATCHES(enc, p, c); 894 +big2_charMatches(const ENCODING *enc, const char *p, int c) { 895 + UNUSED_P(enc); 896 + return BIG2_CHAR_MATCHES(p, c); 953 897 } 954 898 955 899 static int PTRFASTCALL 956 -big2_isNameMin(const ENCODING *enc, const char *p) 957 -{ 958 - return BIG2_IS_NAME_CHAR_MINBPC(enc, p); 900 +big2_isNameMin(const ENCODING *enc, const char *p) { 901 + UNUSED_P(enc); 902 + return BIG2_IS_NAME_CHAR_MINBPC(p); 959 903 } 960 904 961 905 static int PTRFASTCALL 962 -big2_isNmstrtMin(const ENCODING *enc, const char *p) 963 -{ 964 - return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); 906 +big2_isNmstrtMin(const ENCODING *enc, const char *p) { 907 + UNUSED_P(enc); 908 + return BIG2_IS_NMSTRT_CHAR_MINBPC(p); 965 909 } 966 910 967 -#undef VTABLE 968 -#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 911 +# undef VTABLE 912 +# define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 969 913 970 914 #else /* not XML_MIN_SIZE */ 971 915 972 -#undef PREFIX 973 -#define PREFIX(ident) big2_ ## ident 974 -#define MINBPC(enc) 2 916 +# undef PREFIX 917 +# define PREFIX(ident) big2_##ident 918 +# define MINBPC(enc) 2 975 919 /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ 976 -#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) 977 -#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) 978 -#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c) 979 -#define IS_NAME_CHAR(enc, p, n) 0 980 -#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p) 981 -#define IS_NMSTRT_CHAR(enc, p, n) (0) 982 -#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) 983 - 984 -#define XML_TOK_IMPL_C 985 -#include "xmltok_impl.c" 986 -#undef XML_TOK_IMPL_C 987 - 988 -#undef MINBPC 989 -#undef BYTE_TYPE 990 -#undef BYTE_TO_ASCII 991 -#undef CHAR_MATCHES 992 -#undef IS_NAME_CHAR 993 -#undef IS_NAME_CHAR_MINBPC 994 -#undef IS_NMSTRT_CHAR 995 -#undef IS_NMSTRT_CHAR_MINBPC 996 -#undef IS_INVALID_CHAR 920 +# define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) 921 +# define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(p) 922 +# define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(p, c) 923 +# define IS_NAME_CHAR(enc, p, n) 0 924 +# define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(p) 925 +# define IS_NMSTRT_CHAR(enc, p, n) (0) 926 +# define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(p) 927 + 928 +# define XML_TOK_IMPL_C 929 +# include "xmltok_impl.c" 930 +# undef XML_TOK_IMPL_C 931 + 932 +# undef MINBPC 933 +# undef BYTE_TYPE 934 +# undef BYTE_TO_ASCII 935 +# undef CHAR_MATCHES 936 +# undef IS_NAME_CHAR 937 +# undef IS_NAME_CHAR_MINBPC 938 +# undef IS_NMSTRT_CHAR 939 +# undef IS_NMSTRT_CHAR_MINBPC 940 +# undef IS_INVALID_CHAR 997 941 998 942 #endif /* not XML_MIN_SIZE */ 999 943 1000 944 #ifdef XML_NS 1001 945 1002 -static const struct normal_encoding big2_encoding_ns = { 1003 - { VTABLE, 2, 0, 1004 -#if BYTEORDER == 4321 1005 - 1 1006 -#else 1007 - 0 1008 -#endif 1009 - }, 1010 - { 1011 -#include "asciitab.h" 1012 -#include "latin1tab.h" 1013 - }, 1014 - STANDARD_VTABLE(big2_) NULL_VTABLE 1015 -}; 946 +static const struct normal_encoding big2_encoding_ns 947 + = {{VTABLE, 2, 0, 948 +# if BYTEORDER == 4321 949 + 1 950 +# else 951 + 0 952 +# endif 953 + }, 954 + { 955 +# include "asciitab.h" 956 +# include "latin1tab.h" 957 + }, 958 + STANDARD_VTABLE(big2_) NULL_VTABLE}; 1016 959 1017 960 #endif 1018 961 1019 -static const struct normal_encoding big2_encoding = { 1020 - { VTABLE, 2, 0, 962 +static const struct normal_encoding big2_encoding 963 + = {{VTABLE, 2, 0, 1021 964 #if BYTEORDER == 4321 1022 - 1 965 + 1 1023 966 #else 1024 - 0 967 + 0 1025 968 #endif 1026 - }, 1027 - { 969 + }, 970 + { 1028 971 #define BT_COLON BT_NMSTRT 1029 972 #include "asciitab.h" 1030 973 #undef BT_COLON 1031 974 #include "latin1tab.h" 1032 - }, 1033 - STANDARD_VTABLE(big2_) NULL_VTABLE 1034 -}; 975 + }, 976 + STANDARD_VTABLE(big2_) NULL_VTABLE}; 1035 977 1036 978 #if BYTEORDER != 1234 1037 979 1038 -#ifdef XML_NS 1039 - 1040 -static const struct normal_encoding internal_big2_encoding_ns = { 1041 - { VTABLE, 2, 0, 1 }, 1042 - { 1043 -#include "iasciitab.h" 1044 -#include "latin1tab.h" 1045 - }, 1046 - STANDARD_VTABLE(big2_) NULL_VTABLE 1047 -}; 1048 - 1049 -#endif 1050 - 1051 -static const struct normal_encoding internal_big2_encoding = { 1052 - { VTABLE, 2, 0, 1 }, 1053 - { 1054 -#define BT_COLON BT_NMSTRT 1055 -#include "iasciitab.h" 1056 -#undef BT_COLON 1057 -#include "latin1tab.h" 1058 - }, 1059 - STANDARD_VTABLE(big2_) NULL_VTABLE 1060 -}; 980 +# ifdef XML_NS 981 + 982 +static const struct normal_encoding internal_big2_encoding_ns 983 + = {{VTABLE, 2, 0, 1}, 984 + { 985 +# include "iasciitab.h" 986 +# include "latin1tab.h" 987 + }, 988 + STANDARD_VTABLE(big2_) NULL_VTABLE}; 989 + 990 +# endif 991 + 992 +static const struct normal_encoding internal_big2_encoding 993 + = {{VTABLE, 2, 0, 1}, 994 + { 995 +# define BT_COLON BT_NMSTRT 996 +# include "iasciitab.h" 997 +# undef BT_COLON 998 +# include "latin1tab.h" 999 + }, 1000 + STANDARD_VTABLE(big2_) NULL_VTABLE}; 1061 1001 1062 1002 #endif 1063 1003 1064 1004 #undef PREFIX 1065 1005 1066 1006 static int FASTCALL 1067 -streqci(const char *s1, const char *s2) 1068 -{ 1007 +streqci(const char *s1, const char *s2) { 1069 1008 for (;;) { 1070 1009 char c1 = *s1++; 1071 1010 char c2 = *s2++; 1072 1011 if (ASCII_a <= c1 && c1 <= ASCII_z) 1073 1012 c1 += ASCII_A - ASCII_a; 1074 1013 if (ASCII_a <= c2 && c2 <= ASCII_z) 1075 1014 /* The following line will never get executed. streqci() is 1076 1015 * only called from two places, both of which guarantee to put 1077 1016 * upper-case strings into s2. 1078 1017 */ 1079 1018 c2 += ASCII_A - ASCII_a; /* LCOV_EXCL_LINE */ 1080 1019 if (c1 != c2) 1081 1020 return 0; 1082 - if (!c1) 1021 + if (! c1) 1083 1022 break; 1084 1023 } 1085 1024 return 1; 1086 1025 } 1087 1026 1088 1027 static void PTRCALL 1089 -initUpdatePosition(const ENCODING *UNUSED_P(enc), const char *ptr, 1090 - const char *end, POSITION *pos) 1091 -{ 1028 +initUpdatePosition(const ENCODING *enc, const char *ptr, const char *end, 1029 + POSITION *pos) { 1030 + UNUSED_P(enc); 1092 1031 normal_updatePosition(&utf8_encoding.enc, ptr, end, pos); 1093 1032 } 1094 1033 1095 1034 static int 1096 -toAscii(const ENCODING *enc, const char *ptr, const char *end) 1097 -{ 1035 +toAscii(const ENCODING *enc, const char *ptr, const char *end) { 1098 1036 char buf[1]; 1099 1037 char *p = buf; 1100 1038 XmlUtf8Convert(enc, &ptr, end, &p, p + 1); 1101 1039 if (p == buf) 1102 1040 return -1; 1103 1041 else 1104 1042 return buf[0]; 1105 1043 } 1106 1044 1107 1045 static int FASTCALL 1108 -isSpace(int c) 1109 -{ 1046 +isSpace(int c) { 1110 1047 switch (c) { 1111 1048 case 0x20: 1112 1049 case 0xD: 1113 1050 case 0xA: 1114 1051 case 0x9: 1115 1052 return 1; 1116 1053 } ................................................................................ 1117 1054 return 0; 1118 1055 } 1119 1056 1120 1057 /* Return 1 if there's just optional white space or there's an S 1121 1058 followed by name=val. 1122 1059 */ 1123 1060 static int 1124 -parsePseudoAttribute(const ENCODING *enc, 1125 - const char *ptr, 1126 - const char *end, 1127 - const char **namePtr, 1128 - const char **nameEndPtr, 1129 - const char **valPtr, 1130 - const char **nextTokPtr) 1131 -{ 1061 +parsePseudoAttribute(const ENCODING *enc, const char *ptr, const char *end, 1062 + const char **namePtr, const char **nameEndPtr, 1063 + const char **valPtr, const char **nextTokPtr) { 1132 1064 int c; 1133 1065 char open; 1134 1066 if (ptr == end) { 1135 1067 *namePtr = NULL; 1136 1068 return 1; 1137 1069 } 1138 - if (!isSpace(toAscii(enc, ptr, end))) { 1070 + if (! isSpace(toAscii(enc, ptr, end))) { 1139 1071 *nextTokPtr = ptr; 1140 1072 return 0; 1141 1073 } 1142 1074 do { 1143 1075 ptr += enc->minBytesPerChar; 1144 1076 } while (isSpace(toAscii(enc, ptr, end))); 1145 1077 if (ptr == end) { ................................................................................ 1187 1119 open = (char)c; 1188 1120 ptr += enc->minBytesPerChar; 1189 1121 *valPtr = ptr; 1190 1122 for (;; ptr += enc->minBytesPerChar) { 1191 1123 c = toAscii(enc, ptr, end); 1192 1124 if (c == open) 1193 1125 break; 1194 - if (!(ASCII_a <= c && c <= ASCII_z) 1195 - && !(ASCII_A <= c && c <= ASCII_Z) 1196 - && !(ASCII_0 <= c && c <= ASCII_9) 1197 - && c != ASCII_PERIOD 1198 - && c != ASCII_MINUS 1199 - && c != ASCII_UNDERSCORE) { 1126 + if (! (ASCII_a <= c && c <= ASCII_z) && ! (ASCII_A <= c && c <= ASCII_Z) 1127 + && ! (ASCII_0 <= c && c <= ASCII_9) && c != ASCII_PERIOD 1128 + && c != ASCII_MINUS && c != ASCII_UNDERSCORE) { 1200 1129 *nextTokPtr = ptr; 1201 1130 return 0; 1202 1131 } 1203 1132 } 1204 1133 *nextTokPtr = ptr + enc->minBytesPerChar; 1205 1134 return 1; 1206 1135 } 1207 1136 1208 -static const char KW_version[] = { 1209 - ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0' 1210 -}; 1137 +static const char KW_version[] 1138 + = {ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0'}; 1211 1139 1212 -static const char KW_encoding[] = { 1213 - ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0' 1214 -}; 1140 +static const char KW_encoding[] = {ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, 1141 + ASCII_i, ASCII_n, ASCII_g, '\0'}; 1215 1142 1216 -static const char KW_standalone[] = { 1217 - ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o, 1218 - ASCII_n, ASCII_e, '\0' 1219 -}; 1143 +static const char KW_standalone[] 1144 + = {ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, 1145 + ASCII_l, ASCII_o, ASCII_n, ASCII_e, '\0'}; 1220 1146 1221 -static const char KW_yes[] = { 1222 - ASCII_y, ASCII_e, ASCII_s, '\0' 1223 -}; 1147 +static const char KW_yes[] = {ASCII_y, ASCII_e, ASCII_s, '\0'}; 1224 1148 1225 -static const char KW_no[] = { 1226 - ASCII_n, ASCII_o, '\0' 1227 -}; 1149 +static const char KW_no[] = {ASCII_n, ASCII_o, '\0'}; 1228 1150 1229 1151 static int 1230 -doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, 1231 - const char *, 1152 +doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *, 1232 1153 const char *), 1233 - int isGeneralTextEntity, 1234 - const ENCODING *enc, 1235 - const char *ptr, 1236 - const char *end, 1237 - const char **badPtr, 1238 - const char **versionPtr, 1239 - const char **versionEndPtr, 1240 - const char **encodingName, 1241 - const ENCODING **encoding, 1242 - int *standalone) 1243 -{ 1154 + int isGeneralTextEntity, const ENCODING *enc, const char *ptr, 1155 + const char *end, const char **badPtr, const char **versionPtr, 1156 + const char **versionEndPtr, const char **encodingName, 1157 + const ENCODING **encoding, int *standalone) { 1244 1158 const char *val = NULL; 1245 1159 const char *name = NULL; 1246 1160 const char *nameEnd = NULL; 1247 1161 ptr += 5 * enc->minBytesPerChar; 1248 1162 end -= 2 * enc->minBytesPerChar; 1249 - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) 1250 - || !name) { 1163 + if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) 1164 + || ! name) { 1251 1165 *badPtr = ptr; 1252 1166 return 0; 1253 1167 } 1254 - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) { 1255 - if (!isGeneralTextEntity) { 1168 + if (! XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) { 1169 + if (! isGeneralTextEntity) { 1256 1170 *badPtr = name; 1257 1171 return 0; 1258 1172 } 1259 - } 1260 - else { 1173 + } else { 1261 1174 if (versionPtr) 1262 1175 *versionPtr = val; 1263 1176 if (versionEndPtr) 1264 1177 *versionEndPtr = ptr; 1265 - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { 1178 + if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { 1266 1179 *badPtr = ptr; 1267 1180 return 0; 1268 1181 } 1269 - if (!name) { 1182 + if (! name) { 1270 1183 if (isGeneralTextEntity) { 1271 1184 /* a TextDecl must have an EncodingDecl */ 1272 1185 *badPtr = ptr; 1273 1186 return 0; 1274 1187 } 1275 1188 return 1; 1276 1189 } 1277 1190 } 1278 1191 if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) { 1279 1192 int c = toAscii(enc, val, end); 1280 - if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) { 1193 + if (! (ASCII_a <= c && c <= ASCII_z) && ! (ASCII_A <= c && c <= ASCII_Z)) { 1281 1194 *badPtr = val; 1282 1195 return 0; 1283 1196 } 1284 1197 if (encodingName) 1285 1198 *encodingName = val; 1286 1199 if (encoding) 1287 1200 *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar); 1288 - if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { 1201 + if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { 1289 1202 *badPtr = ptr; 1290 1203 return 0; 1291 1204 } 1292 - if (!name) 1205 + if (! name) 1293 1206 return 1; 1294 1207 } 1295 - if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) 1208 + if (! XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) 1296 1209 || isGeneralTextEntity) { 1297 1210 *badPtr = name; 1298 1211 return 0; 1299 1212 } 1300 1213 if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) { 1301 1214 if (standalone) 1302 1215 *standalone = 1; 1303 - } 1304 - else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) { 1216 + } else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) { 1305 1217 if (standalone) 1306 1218 *standalone = 0; 1307 - } 1308 - else { 1219 + } else { 1309 1220 *badPtr = val; 1310 1221 return 0; 1311 1222 } 1312 1223 while (isSpace(toAscii(enc, ptr, end))) 1313 1224 ptr += enc->minBytesPerChar; 1314 1225 if (ptr != end) { 1315 1226 *badPtr = ptr; 1316 1227 return 0; 1317 1228 } 1318 1229 return 1; 1319 1230 } 1320 1231 1321 1232 static int FASTCALL 1322 -checkCharRefNumber(int result) 1323 -{ 1233 +checkCharRefNumber(int result) { 1324 1234 switch (result >> 8) { 1325 - case 0xD8: case 0xD9: case 0xDA: case 0xDB: 1326 - case 0xDC: case 0xDD: case 0xDE: case 0xDF: 1235 + case 0xD8: 1236 + case 0xD9: 1237 + case 0xDA: 1238 + case 0xDB: 1239 + case 0xDC: 1240 + case 0xDD: 1241 + case 0xDE: 1242 + case 0xDF: 1327 1243 return -1; 1328 1244 case 0: 1329 1245 if (latin1_encoding.type[result] == BT_NONXML) 1330 1246 return -1; 1331 1247 break; 1332 1248 case 0xFF: 1333 1249 if (result == 0xFFFE || result == 0xFFFF) ................................................................................ 1334 1250 return -1; 1335 1251 break; 1336 1252 } 1337 1253 return result; 1338 1254 } 1339 1255 1340 1256 int FASTCALL 1341 -XmlUtf8Encode(int c, char *buf) 1342 -{ 1257 +XmlUtf8Encode(int c, char *buf) { 1343 1258 enum { 1344 1259 /* minN is minimum legal resulting value for N byte sequence */ 1345 1260 min2 = 0x80, 1346 1261 min3 = 0x800, 1347 1262 min4 = 0x10000 1348 1263 }; 1349 1264 ................................................................................ 1371 1286 buf[3] = (char)((c & 0x3f) | 0x80); 1372 1287 return 4; 1373 1288 } 1374 1289 return 0; /* LCOV_EXCL_LINE: this case too is eliminated before calling */ 1375 1290 } 1376 1291 1377 1292 int FASTCALL 1378 -XmlUtf16Encode(int charNum, unsigned short *buf) 1379 -{ 1293 +XmlUtf16Encode(int charNum, unsigned short *buf) { 1380 1294 if (charNum < 0) 1381 1295 return 0; 1382 1296 if (charNum < 0x10000) { 1383 1297 buf[0] = (unsigned short)charNum; 1384 1298 return 1; 1385 1299 } 1386 1300 if (charNum < 0x110000) { ................................................................................ 1396 1310 struct normal_encoding normal; 1397 1311 CONVERTER convert; 1398 1312 void *userData; 1399 1313 unsigned short utf16[256]; 1400 1314 char utf8[256][4]; 1401 1315 }; 1402 1316 1403 -#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc)) 1317 +#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *)(enc)) 1404 1318 1405 1319 int 1406 -XmlSizeOfUnknownEncoding(void) 1407 -{ 1320 +XmlSizeOfUnknownEncoding(void) { 1408 1321 return sizeof(struct unknown_encoding); 1409 1322 } 1410 1323 1411 1324 static int PTRFASTCALL 1412 -unknown_isName(const ENCODING *enc, const char *p) 1413 -{ 1325 +unknown_isName(const ENCODING *enc, const char *p) { 1414 1326 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); 1415 1327 int c = uenc->convert(uenc->userData, p); 1416 1328 if (c & ~0xFFFF) 1417 1329 return 0; 1418 1330 return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); 1419 1331 } 1420 1332 1421 1333 static int PTRFASTCALL 1422 -unknown_isNmstrt(const ENCODING *enc, const char *p) 1423 -{ 1334 +unknown_isNmstrt(const ENCODING *enc, const char *p) { 1424 1335 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); 1425 1336 int c = uenc->convert(uenc->userData, p); 1426 1337 if (c & ~0xFFFF) 1427 1338 return 0; 1428 1339 return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); 1429 1340 } 1430 1341 1431 1342 static int PTRFASTCALL 1432 -unknown_isInvalid(const ENCODING *enc, const char *p) 1433 -{ 1343 +unknown_isInvalid(const ENCODING *enc, const char *p) { 1434 1344 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); 1435 1345 int c = uenc->convert(uenc->userData, p); 1436 1346 return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; 1437 1347 } 1438 1348 1439 1349 static enum XML_Convert_Result PTRCALL 1440 -unknown_toUtf8(const ENCODING *enc, 1441 - const char **fromP, const char *fromLim, 1442 - char **toP, const char *toLim) 1443 -{ 1350 +unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, 1351 + char **toP, const char *toLim) { 1444 1352 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); 1445 1353 char buf[XML_UTF8_ENCODE_MAX]; 1446 1354 for (;;) { 1447 1355 const char *utf8; 1448 1356 int n; 1449 1357 if (*fromP == fromLim) 1450 1358 return XML_CONVERT_COMPLETED; ................................................................................ 1454 1362 int c = uenc->convert(uenc->userData, *fromP); 1455 1363 n = XmlUtf8Encode(c, buf); 1456 1364 if (n > toLim - *toP) 1457 1365 return XML_CONVERT_OUTPUT_EXHAUSTED; 1458 1366 utf8 = buf; 1459 1367 *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] 1460 1368 - (BT_LEAD2 - 2)); 1461 - } 1462 - else { 1369 + } else { 1463 1370 if (n > toLim - *toP) 1464 1371 return XML_CONVERT_OUTPUT_EXHAUSTED; 1465 1372 (*fromP)++; 1466 1373 } 1467 1374 memcpy(*toP, utf8, n); 1468 1375 *toP += n; 1469 1376 } 1470 1377 } 1471 1378 1472 1379 static enum XML_Convert_Result PTRCALL 1473 -unknown_toUtf16(const ENCODING *enc, 1474 - const char **fromP, const char *fromLim, 1475 - unsigned short **toP, const unsigned short *toLim) 1476 -{ 1380 +unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, 1381 + unsigned short **toP, const unsigned short *toLim) { 1477 1382 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); 1478 1383 while (*fromP < fromLim && *toP < toLim) { 1479 1384 unsigned short c = uenc->utf16[(unsigned char)**fromP]; 1480 1385 if (c == 0) { 1481 - c = (unsigned short) 1482 - uenc->convert(uenc->userData, *fromP); 1386 + c = (unsigned short)uenc->convert(uenc->userData, *fromP); 1483 1387 *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] 1484 1388 - (BT_LEAD2 - 2)); 1485 - } 1486 - else 1389 + } else 1487 1390 (*fromP)++; 1488 1391 *(*toP)++ = c; 1489 1392 } 1490 1393 1491 1394 if ((*toP == toLim) && (*fromP < fromLim)) 1492 1395 return XML_CONVERT_OUTPUT_EXHAUSTED; 1493 1396 else 1494 1397 return XML_CONVERT_COMPLETED; 1495 1398 } 1496 1399 1497 1400 ENCODING * 1498 -XmlInitUnknownEncoding(void *mem, 1499 - int *table, 1500 - CONVERTER convert, 1501 - void *userData) 1502 -{ 1401 +XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert, 1402 + void *userData) { 1503 1403 int i; 1504 1404 struct unknown_encoding *e = (struct unknown_encoding *)mem; 1505 - for (i = 0; i < (int)sizeof(struct normal_encoding); i++) 1506 - ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; 1405 + memcpy(mem, &latin1_encoding, sizeof(struct normal_encoding)); 1507 1406 for (i = 0; i < 128; i++) 1508 1407 if (latin1_encoding.type[i] != BT_OTHER 1509 - && latin1_encoding.type[i] != BT_NONXML 1510 - && table[i] != i) 1408 + && latin1_encoding.type[i] != BT_NONXML && table[i] != i) 1511 1409 return 0; 1512 1410 for (i = 0; i < 256; i++) { 1513 1411 int c = table[i]; 1514 1412 if (c == -1) { 1515 1413 e->normal.type[i] = BT_MALFORM; 1516 1414 /* This shouldn't really get used. */ 1517 1415 e->utf16[i] = 0xFFFF; 1518 1416 e->utf8[i][0] = 1; 1519 1417 e->utf8[i][1] = 0; 1520 - } 1521 - else if (c < 0) { 1418 + } else if (c < 0) { 1522 1419 if (c < -4) 1523 1420 return 0; 1524 1421 /* Multi-byte sequences need a converter function */ 1525 - if (!convert) 1422 + if (! convert) 1526 1423 return 0; 1527 1424 e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2)); 1528 1425 e->utf8[i][0] = 0; 1529 1426 e->utf16[i] = 0; 1530 - } 1531 - else if (c < 0x80) { 1427 + } else if (c < 0x80) { 1532 1428 if (latin1_encoding.type[c] != BT_OTHER 1533 - && latin1_encoding.type[c] != BT_NONXML 1534 - && c != i) 1429 + && latin1_encoding.type[c] != BT_NONXML && c != i) 1535 1430 return 0; 1536 1431 e->normal.type[i] = latin1_encoding.type[c]; 1537 1432 e->utf8[i][0] = 1; 1538 1433 e->utf8[i][1] = (char)c; 1539 1434 e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c); 1540 - } 1541 - else if (checkCharRefNumber(c) < 0) { 1435 + } else if (checkCharRefNumber(c) < 0) { 1542 1436 e->normal.type[i] = BT_NONXML; 1543 1437 /* This shouldn't really get used. */ 1544 1438 e->utf16[i] = 0xFFFF; 1545 1439 e->utf8[i][0] = 1; 1546 1440 e->utf8[i][1] = 0; 1547 - } 1548 - else { 1441 + } else { 1549 1442 if (c > 0xFFFF) 1550 1443 return 0; 1551 1444 if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff)) 1552 1445 e->normal.type[i] = BT_NMSTRT; 1553 1446 else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff)) 1554 1447 e->normal.type[i] = BT_NAME; 1555 1448 else ................................................................................ 1586 1479 UTF_16_ENC, 1587 1480 UTF_16BE_ENC, 1588 1481 UTF_16LE_ENC, 1589 1482 /* must match encodingNames up to here */ 1590 1483 NO_ENC 1591 1484 }; 1592 1485 1593 -static const char KW_ISO_8859_1[] = { 1594 - ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9, 1595 - ASCII_MINUS, ASCII_1, '\0' 1596 -}; 1597 -static const char KW_US_ASCII[] = { 1598 - ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I, 1599 - '\0' 1600 -}; 1601 -static const char KW_UTF_8[] = { 1602 - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0' 1603 -}; 1604 -static const char KW_UTF_16[] = { 1605 - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0' 1606 -}; 1607 -static const char KW_UTF_16BE[] = { 1608 - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E, 1609 - '\0' 1610 -}; 1611 -static const char KW_UTF_16LE[] = { 1612 - ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, 1613 - '\0' 1614 -}; 1486 +static const char KW_ISO_8859_1[] 1487 + = {ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, 1488 + ASCII_5, ASCII_9, ASCII_MINUS, ASCII_1, '\0'}; 1489 +static const char KW_US_ASCII[] 1490 + = {ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, 1491 + ASCII_C, ASCII_I, ASCII_I, '\0'}; 1492 +static const char KW_UTF_8[] 1493 + = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0'}; 1494 +static const char KW_UTF_16[] 1495 + = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0'}; 1496 +static const char KW_UTF_16BE[] 1497 + = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, 1498 + ASCII_6, ASCII_B, ASCII_E, '\0'}; 1499 +static const char KW_UTF_16LE[] 1500 + = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, 1501 + ASCII_6, ASCII_L, ASCII_E, '\0'}; 1615 1502 1616 1503 static int FASTCALL 1617 -getEncodingIndex(const char *name) 1618 -{ 1619 - static const char * const encodingNames[] = { 1620 - KW_ISO_8859_1, 1621 - KW_US_ASCII, 1622 - KW_UTF_8, 1623 - KW_UTF_16, 1624 - KW_UTF_16BE, 1625 - KW_UTF_16LE, 1504 +getEncodingIndex(const char *name) { 1505 + static const char *const encodingNames[] = { 1506 + KW_ISO_8859_1, KW_US_ASCII, KW_UTF_8, KW_UTF_16, KW_UTF_16BE, KW_UTF_16LE, 1626 1507 }; 1627 1508 int i; 1628 1509 if (name == NULL) 1629 1510 return NO_ENC; 1630 - for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++) 1511 + for (i = 0; i < (int)(sizeof(encodingNames) / sizeof(encodingNames[0])); i++) 1631 1512 if (streqci(name, encodingNames[i])) 1632 1513 return i; 1633 1514 return UNKNOWN_ENC; 1634 1515 } 1635 1516 1636 1517 /* For binary compatibility, we store the index of the encoding 1637 1518 specified at initialization in the isUtf16 member. ................................................................................ 1643 1524 /* This is what detects the encoding. encodingTable maps from 1644 1525 encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of 1645 1526 the external (protocol) specified encoding; state is 1646 1527 XML_CONTENT_STATE if we're parsing an external text entity, and 1647 1528 XML_PROLOG_STATE otherwise. 1648 1529 */ 1649 1530 1650 - 1651 1531 static int 1652 -initScan(const ENCODING * const *encodingTable, 1653 - const INIT_ENCODING *enc, 1654 - int state, 1655 - const char *ptr, 1656 - const char *end, 1657 - const char **nextTokPtr) 1658 -{ 1532 +initScan(const ENCODING *const *encodingTable, const INIT_ENCODING *enc, 1533 + int state, const char *ptr, const char *end, const char **nextTokPtr) { 1659 1534 const ENCODING **encPtr; 1660 1535 1661 1536 if (ptr >= end) 1662 1537 return XML_TOK_NONE; 1663 1538 encPtr = enc->encPtr; 1664 1539 if (ptr + 1 == end) { 1665 1540 /* only a single byte available for auto-detection */ ................................................................................ 1676 1551 case UTF_16BE_ENC: 1677 1552 return XML_TOK_PARTIAL; 1678 1553 } 1679 1554 switch ((unsigned char)*ptr) { 1680 1555 case 0xFE: 1681 1556 case 0xFF: 1682 1557 case 0xEF: /* possibly first byte of UTF-8 BOM */ 1683 - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC 1684 - && state == XML_CONTENT_STATE) 1558 + if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC && state == XML_CONTENT_STATE) 1685 1559 break; 1686 1560 /* fall through */ 1687 1561 case 0x00: 1688 1562 case 0x3C: 1689 1563 return XML_TOK_PARTIAL; 1690 1564 } 1691 - } 1692 - else { 1565 + } else { 1693 1566 switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) { 1694 1567 case 0xFEFF: 1695 - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC 1696 - && state == XML_CONTENT_STATE) 1568 + if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC && state == XML_CONTENT_STATE) 1697 1569 break; 1698 1570 *nextTokPtr = ptr + 2; 1699 1571 *encPtr = encodingTable[UTF_16BE_ENC]; 1700 1572 return XML_TOK_BOM; 1701 1573 /* 00 3C is handled in the default case */ 1702 1574 case 0x3C00: 1703 1575 if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC 1704 1576 || INIT_ENC_INDEX(enc) == UTF_16_ENC) 1705 1577 && state == XML_CONTENT_STATE) 1706 1578 break; 1707 1579 *encPtr = encodingTable[UTF_16LE_ENC]; 1708 1580 return XmlTok(*encPtr, state, ptr, end, nextTokPtr); 1709 1581 case 0xFFFE: 1710 - if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC 1711 - && state == XML_CONTENT_STATE) 1582 + if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC && state == XML_CONTENT_STATE) 1712 1583 break; 1713 1584 *nextTokPtr = ptr + 2; 1714 1585 *encPtr = encodingTable[UTF_16LE_ENC]; 1715 1586 return XML_TOK_BOM; 1716 1587 case 0xEFBB: 1717 1588 /* Maybe a UTF-8 BOM (EF BB BF) */ 1718 1589 /* If there's an explicitly specified (external) encoding ................................................................................ 1719 1590 of ISO-8859-1 or some flavour of UTF-16 1720 1591 and this is an external text entity, 1721 1592 don't look for the BOM, 1722 1593 because it might be a legal data. 1723 1594 */ 1724 1595 if (state == XML_CONTENT_STATE) { 1725 1596 int e = INIT_ENC_INDEX(enc); 1726 - if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC 1727 - || e == UTF_16LE_ENC || e == UTF_16_ENC) 1597 + if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC || e == UTF_16LE_ENC 1598 + || e == UTF_16_ENC) 1728 1599 break; 1729 1600 } 1730 1601 if (ptr + 2 == end) 1731 1602 return XML_TOK_PARTIAL; 1732 1603 if ((unsigned char)ptr[2] == 0xBF) { 1733 1604 *nextTokPtr = ptr + 3; 1734 1605 *encPtr = encodingTable[UTF_8_ENC]; ................................................................................ 1743 1614 external parsed general entity that's labelled as 1744 1615 UTF-16LE. 1745 1616 */ 1746 1617 if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC) 1747 1618 break; 1748 1619 *encPtr = encodingTable[UTF_16BE_ENC]; 1749 1620 return XmlTok(*encPtr, state, ptr, end, nextTokPtr); 1750 - } 1751 - else if (ptr[1] == '\0') { 1621 + } else if (ptr[1] == '\0') { 1752 1622 /* We could recover here in the case: 1753 1623 - parsing an external entity 1754 1624 - second byte is 0 1755 1625 - no externally specified encoding 1756 1626 - no encoding declaration 1757 1627 by assuming UTF-16LE. But we don't, because this would mean when 1758 1628 presented just with a single byte, we couldn't reliably determine ................................................................................ 1766 1636 break; 1767 1637 } 1768 1638 } 1769 1639 *encPtr = encodingTable[INIT_ENC_INDEX(enc)]; 1770 1640 return XmlTok(*encPtr, state, ptr, end, nextTokPtr); 1771 1641 } 1772 1642 1773 - 1774 1643 #define NS(x) x 1775 1644 #define ns(x) x 1776 1645 #define XML_TOK_NS_C 1777 1646 #include "xmltok_ns.c" 1778 1647 #undef XML_TOK_NS_C 1779 1648 #undef NS 1780 1649 #undef ns 1781 1650 1782 1651 #ifdef XML_NS 1783 1652 1784 -#define NS(x) x ## NS 1785 -#define ns(x) x ## _ns 1653 +# define NS(x) x##NS 1654 +# define ns(x) x##_ns 1786 1655 1787 -#define XML_TOK_NS_C 1788 -#include "xmltok_ns.c" 1789 -#undef XML_TOK_NS_C 1656 +# define XML_TOK_NS_C 1657 +# include "xmltok_ns.c" 1658 +# undef XML_TOK_NS_C 1790 1659 1791 -#undef NS 1792 -#undef ns 1660 +# undef NS 1661 +# undef ns 1793 1662 1794 1663 ENCODING * 1795 -XmlInitUnknownEncodingNS(void *mem, 1796 - int *table, 1797 - CONVERTER convert, 1798 - void *userData) 1799 -{ 1664 +XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert, 1665 + void *userData) { 1800 1666 ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); 1801 1667 if (enc) 1802 1668 ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON; 1803 1669 return enc; 1804 1670 } 1805 1671 1806 1672 #endif /* XML_NS */
Changes to expat/xmltok.h.
34 34 #define XmlTok_INCLUDED 1 35 35 36 36 #ifdef __cplusplus 37 37 extern "C" { 38 38 #endif 39 39 40 40 /* The following token may be returned by XmlContentTok */ 41 -#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be 42 - start of illegal ]]> sequence */ 41 +#define XML_TOK_TRAILING_RSQB \ 42 + -5 /* ] or ]] at the end of the scan; might be \ 43 + start of illegal ]]> sequence */ 43 44 /* The following tokens may be returned by both XmlPrologTok and 44 45 XmlContentTok. 45 46 */ 46 -#define XML_TOK_NONE -4 /* The string to be scanned is empty */ 47 -#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan; 48 - might be part of CRLF sequence */ 49 -#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */ 50 -#define XML_TOK_PARTIAL -1 /* only part of a token */ 47 +#define XML_TOK_NONE -4 /* The string to be scanned is empty */ 48 +#define XML_TOK_TRAILING_CR \ 49 + -3 /* A CR at the end of the scan; \ 50 + might be part of CRLF sequence */ 51 +#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */ 52 +#define XML_TOK_PARTIAL -1 /* only part of a token */ 51 53 #define XML_TOK_INVALID 0 52 54 53 55 /* The following tokens are returned by XmlContentTok; some are also 54 56 returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok. 55 57 */ 56 58 #define XML_TOK_START_TAG_WITH_ATTS 1 57 59 #define XML_TOK_START_TAG_NO_ATTS 2 ................................................................................ 58 60 #define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */ 59 61 #define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4 60 62 #define XML_TOK_END_TAG 5 61 63 #define XML_TOK_DATA_CHARS 6 62 64 #define XML_TOK_DATA_NEWLINE 7 63 65 #define XML_TOK_CDATA_SECT_OPEN 8 64 66 #define XML_TOK_ENTITY_REF 9 65 -#define XML_TOK_CHAR_REF 10 /* numeric character reference */ 67 +#define XML_TOK_CHAR_REF 10 /* numeric character reference */ 66 68 67 69 /* The following tokens may be returned by both XmlPrologTok and 68 70 XmlContentTok. 69 71 */ 70 -#define XML_TOK_PI 11 /* processing instruction */ 71 -#define XML_TOK_XML_DECL 12 /* XML decl or text decl */ 72 +#define XML_TOK_PI 11 /* processing instruction */ 73 +#define XML_TOK_XML_DECL 12 /* XML decl or text decl */ 72 74 #define XML_TOK_COMMENT 13 73 -#define XML_TOK_BOM 14 /* Byte order mark */ 75 +#define XML_TOK_BOM 14 /* Byte order mark */ 74 76 75 77 /* The following tokens are returned only by XmlPrologTok */ 76 78 #define XML_TOK_PROLOG_S 15 77 -#define XML_TOK_DECL_OPEN 16 /* <!foo */ 78 -#define XML_TOK_DECL_CLOSE 17 /* > */ 79 +#define XML_TOK_DECL_OPEN 16 /* <!foo */ 80 +#define XML_TOK_DECL_CLOSE 17 /* > */ 79 81 #define XML_TOK_NAME 18 80 82 #define XML_TOK_NMTOKEN 19 81 -#define XML_TOK_POUND_NAME 20 /* #name */ 82 -#define XML_TOK_OR 21 /* | */ 83 +#define XML_TOK_POUND_NAME 20 /* #name */ 84 +#define XML_TOK_OR 21 /* | */ 83 85 #define XML_TOK_PERCENT 22 84 86 #define XML_TOK_OPEN_PAREN 23 85 87 #define XML_TOK_CLOSE_PAREN 24 86 88 #define XML_TOK_OPEN_BRACKET 25 87 89 #define XML_TOK_CLOSE_BRACKET 26 88 90 #define XML_TOK_LITERAL 27 89 91 #define XML_TOK_PARAM_ENTITY_REF 28 90 92 #define XML_TOK_INSTANCE_START 29 91 93 92 94 /* The following occur only in element type declarations */ 93 -#define XML_TOK_NAME_QUESTION 30 /* name? */ 94 -#define XML_TOK_NAME_ASTERISK 31 /* name* */ 95 -#define XML_TOK_NAME_PLUS 32 /* name+ */ 96 -#define XML_TOK_COND_SECT_OPEN 33 /* <![ */ 97 -#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */ 98 -#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */ 99 -#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */ 100 -#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */ 95 +#define XML_TOK_NAME_QUESTION 30 /* name? */ 96 +#define XML_TOK_NAME_ASTERISK 31 /* name* */ 97 +#define XML_TOK_NAME_PLUS 32 /* name+ */ 98 +#define XML_TOK_COND_SECT_OPEN 33 /* <![ */ 99 +#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */ 100 +#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */ 101 +#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */ 102 +#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */ 101 103 #define XML_TOK_COMMA 38 102 104 103 105 /* The following token is returned only by XmlAttributeValueTok */ 104 106 #define XML_TOK_ATTRIBUTE_VALUE_S 39 105 107 106 108 /* The following token is returned only by XmlCdataSectionTok */ 107 109 #define XML_TOK_CDATA_SECT_CLOSE 40 ................................................................................ 108 110 109 111 /* With namespace processing this is returned by XmlPrologTok for a 110 112 name with a colon. 111 113 */ 112 114 #define XML_TOK_PREFIXED_NAME 41 113 115 114 116 #ifdef XML_DTD 115 -#define XML_TOK_IGNORE_SECT 42 117 +# define XML_TOK_IGNORE_SECT 42 116 118 #endif /* XML_DTD */ 117 119 118 120 #ifdef XML_DTD 119 -#define XML_N_STATES 4 121 +# define XML_N_STATES 4 120 122 #else /* not XML_DTD */ 121 -#define XML_N_STATES 3 123 +# define XML_N_STATES 3 122 124 #endif /* not XML_DTD */ 123 125 124 126 #define XML_PROLOG_STATE 0 125 127 #define XML_CONTENT_STATE 1 126 128 #define XML_CDATA_SECTION_STATE 2 127 129 #ifdef XML_DTD 128 -#define XML_IGNORE_SECTION_STATE 3 130 +# define XML_IGNORE_SECTION_STATE 3 129 131 #endif /* XML_DTD */ 130 132 131 133 #define XML_N_LITERAL_TYPES 2 132 134 #define XML_ATTRIBUTE_VALUE_LITERAL 0 133 135 #define XML_ENTITY_VALUE_LITERAL 1 134 136 135 137 /* The size of the buffer passed to XmlUtf8Encode must be at least this. */ ................................................................................ 149 151 const char *valueEnd; 150 152 char normalized; 151 153 } ATTRIBUTE; 152 154 153 155 struct encoding; 154 156 typedef struct encoding ENCODING; 155 157 156 -typedef int (PTRCALL *SCANNER)(const ENCODING *, 157 - const char *, 158 - const char *, 159 - const char **); 158 +typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *, 159 + const char **); 160 160 161 161 enum XML_Convert_Result { 162 162 XML_CONVERT_COMPLETED = 0, 163 163 XML_CONVERT_INPUT_INCOMPLETE = 1, 164 - XML_CONVERT_OUTPUT_EXHAUSTED = 2 /* and therefore potentially input remaining as well */ 164 + XML_CONVERT_OUTPUT_EXHAUSTED 165 + = 2 /* and therefore potentially input remaining as well */ 165 166 }; 166 167 167 168 struct encoding { 168 169 SCANNER scanners[XML_N_STATES]; 169 170 SCANNER literalScanners[XML_N_LITERAL_TYPES]; 170 - int (PTRCALL *nameMatchesAscii)(const ENCODING *, 171 - const char *, 172 - const char *, 173 - const char *); 174 - int (PTRFASTCALL *nameLength)(const ENCODING *, const char *); 171 + int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *, 172 + const char *); 173 + int(PTRFASTCALL *nameLength)(const ENCODING *, const char *); 175 174 const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *); 176 - int (PTRCALL *getAtts)(const ENCODING *enc, 177 - const char *ptr, 178 - int attsMax, 179 - ATTRIBUTE *atts); 180 - int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); 181 - int (PTRCALL *predefinedEntityName)(const ENCODING *, 182 - const char *, 183 - const char *); 184 - void (PTRCALL *updatePosition)(const ENCODING *, 185 - const char *ptr, 186 - const char *end, 187 - POSITION *); 188 - int (PTRCALL *isPublicId)(const ENCODING *enc, 189 - const char *ptr, 190 - const char *end, 191 - const char **badPtr); 192 - enum XML_Convert_Result (PTRCALL *utf8Convert)(const ENCODING *enc, 193 - const char **fromP, 194 - const char *fromLim, 195 - char **toP, 196 - const char *toLim); 197 - enum XML_Convert_Result (PTRCALL *utf16Convert)(const ENCODING *enc, 198 - const char **fromP, 199 - const char *fromLim, 200 - unsigned short **toP, 201 - const unsigned short *toLim); 175 + int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax, 176 + ATTRIBUTE *atts); 177 + int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); 178 + int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *, 179 + const char *); 180 + void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr, 181 + const char *end, POSITION *); 182 + int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr, 183 + const char *end, const char **badPtr); 184 + enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc, 185 + const char **fromP, 186 + const char *fromLim, char **toP, 187 + const char *toLim); 188 + enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc, 189 + const char **fromP, 190 + const char *fromLim, 191 + unsigned short **toP, 192 + const unsigned short *toLim); 202 193 int minBytesPerChar; 203 194 char isUtf8; 204 195 char isUtf16; 205 196 }; 206 197 207 198 /* Scan the string starting at ptr until the end of the next complete 208 199 token, but do not scan past eptr. Return an integer giving the ................................................................................ 221 212 set to point to the character following the end of that token. 222 213 223 214 Each data character counts as a single token, but adjacent data 224 215 characters may be returned together. Similarly for characters in 225 216 the prolog outside literals, comments and processing instructions. 226 217 */ 227 218 228 - 229 -#define XmlTok(enc, state, ptr, end, nextTokPtr) \ 219 +#define XmlTok(enc, state, ptr, end, nextTokPtr) \ 230 220 (((enc)->scanners[state])(enc, ptr, end, nextTokPtr)) 231 221 232 -#define XmlPrologTok(enc, ptr, end, nextTokPtr) \ 233 - XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr) 222 +#define XmlPrologTok(enc, ptr, end, nextTokPtr) \ 223 + XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr) 234 224 235 -#define XmlContentTok(enc, ptr, end, nextTokPtr) \ 236 - XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr) 225 +#define XmlContentTok(enc, ptr, end, nextTokPtr) \ 226 + XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr) 237 227 238 -#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \ 239 - XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr) 228 +#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \ 229 + XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr) 240 230 241 231 #ifdef XML_DTD 242 232 243 -#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \ 244 - XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr) 233 +# define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \ 234 + XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr) 245 235 246 236 #endif /* XML_DTD */ 247 237 248 238 /* This is used for performing a 2nd-level tokenization on the content 249 239 of a literal that has already been returned by XmlTok. 250 240 */ 251 -#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \ 241 +#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \ 252 242 (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr)) 253 243 254 -#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \ 255 - XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr) 244 +#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \ 245 + XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr) 256 246 257 -#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ 258 - XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) 247 +#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ 248 + XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) 259 249 260 -#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ 250 +#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ 261 251 (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) 262 252 263 -#define XmlNameLength(enc, ptr) \ 264 - (((enc)->nameLength)(enc, ptr)) 253 +#define XmlNameLength(enc, ptr) (((enc)->nameLength)(enc, ptr)) 265 254 266 -#define XmlSkipS(enc, ptr) \ 267 - (((enc)->skipS)(enc, ptr)) 255 +#define XmlSkipS(enc, ptr) (((enc)->skipS)(enc, ptr)) 268 256 269 -#define XmlGetAttributes(enc, ptr, attsMax, atts) \ 257 +#define XmlGetAttributes(enc, ptr, attsMax, atts) \ 270 258 (((enc)->getAtts)(enc, ptr, attsMax, atts)) 271 259 272 -#define XmlCharRefNumber(enc, ptr) \ 273 - (((enc)->charRefNumber)(enc, ptr)) 260 +#define XmlCharRefNumber(enc, ptr) (((enc)->charRefNumber)(enc, ptr)) 274 261 275 -#define XmlPredefinedEntityName(enc, ptr, end) \ 262 +#define XmlPredefinedEntityName(enc, ptr, end) \ 276 263 (((enc)->predefinedEntityName)(enc, ptr, end)) 277 264 278 -#define XmlUpdatePosition(enc, ptr, end, pos) \ 265 +#define XmlUpdatePosition(enc, ptr, end, pos) \ 279 266 (((enc)->updatePosition)(enc, ptr, end, pos)) 280 267 281 -#define XmlIsPublicId(enc, ptr, end, badPtr) \ 268 +#define XmlIsPublicId(enc, ptr, end, badPtr) \ 282 269 (((enc)->isPublicId)(enc, ptr, end, badPtr)) 283 270 284 -#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \ 271 +#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \ 285 272 (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim)) 286 273 287 -#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \ 274 +#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \ 288 275 (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim)) 289 276 290 277 typedef struct { 291 278 ENCODING initEnc; 292 279 const ENCODING **encPtr; 293 280 } INIT_ENCODING; 294 281 295 -int XmlParseXmlDecl(int isGeneralTextEntity, 296 - const ENCODING *enc, 297 - const char *ptr, 298 - const char *end, 299 - const char **badPtr, 300 - const char **versionPtr, 301 - const char **versionEndPtr, 282 +int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc, 283 + const char *ptr, const char *end, const char **badPtr, 284 + const char **versionPtr, const char **versionEndPtr, 302 285 const char **encodingNamePtr, 303 - const ENCODING **namedEncodingPtr, 304 - int *standalonePtr); 286 + const ENCODING **namedEncodingPtr, int *standalonePtr); 305 287 306 288 int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name); 307 289 const ENCODING *XmlGetUtf8InternalEncoding(void); 308 290 const ENCODING *XmlGetUtf16InternalEncoding(void); 309 291 int FASTCALL XmlUtf8Encode(int charNumber, char *buf); 310 292 int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); 311 293 int XmlSizeOfUnknownEncoding(void); 312 294 313 - 314 -typedef int (XMLCALL *CONVERTER) (void *userData, const char *p); 295 +typedef int(XMLCALL *CONVERTER)(void *userData, const char *p); 315 296 316 -ENCODING * 317 -XmlInitUnknownEncoding(void *mem, 318 - int *table, 319 - CONVERTER convert, 320 - void *userData); 297 +ENCODING *XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert, 298 + void *userData); 321 299 322 -int XmlParseXmlDeclNS(int isGeneralTextEntity, 323 - const ENCODING *enc, 324 - const char *ptr, 325 - const char *end, 326 - const char **badPtr, 327 - const char **versionPtr, 328 - const char **versionEndPtr, 300 +int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc, 301 + const char *ptr, const char *end, const char **badPtr, 302 + const char **versionPtr, const char **versionEndPtr, 329 303 const char **encodingNamePtr, 330 - const ENCODING **namedEncodingPtr, 331 - int *standalonePtr); 304 + const ENCODING **namedEncodingPtr, int *standalonePtr); 332 305 333 306 int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name); 334 307 const ENCODING *XmlGetUtf8InternalEncodingNS(void); 335 308 const ENCODING *XmlGetUtf16InternalEncodingNS(void); 336 -ENCODING * 337 -XmlInitUnknownEncodingNS(void *mem, 338 - int *table, 339 - CONVERTER convert, 340 - void *userData); 309 +ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert, 310 + void *userData); 341 311 #ifdef __cplusplus 342 312 } 343 313 #endif 344 314 345 315 #endif /* not XmlTok_INCLUDED */
Changes to expat/xmltok_impl.c.
28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 #ifdef XML_TOK_IMPL_C 34 34 35 -#ifndef IS_INVALID_CHAR 36 -#define IS_INVALID_CHAR(enc, ptr, n) (0) 37 -#endif 38 - 39 -#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \ 40 - case BT_LEAD ## n: \ 41 - if (end - ptr < n) \ 42 - return XML_TOK_PARTIAL_CHAR; \ 43 - if (IS_INVALID_CHAR(enc, ptr, n)) { \ 44 - *(nextTokPtr) = (ptr); \ 45 - return XML_TOK_INVALID; \ 46 - } \ 47 - ptr += n; \ 48 - break; 49 - 50 -#define INVALID_CASES(ptr, nextTokPtr) \ 51 - INVALID_LEAD_CASE(2, ptr, nextTokPtr) \ 52 - INVALID_LEAD_CASE(3, ptr, nextTokPtr) \ 53 - INVALID_LEAD_CASE(4, ptr, nextTokPtr) \ 54 - case BT_NONXML: \ 55 - case BT_MALFORM: \ 56 - case BT_TRAIL: \ 57 - *(nextTokPtr) = (ptr); \ 58 - return XML_TOK_INVALID; 59 - 60 -#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \ 61 - case BT_LEAD ## n: \ 62 - if (end - ptr < n) \ 63 - return XML_TOK_PARTIAL_CHAR; \ 64 - if (!IS_NAME_CHAR(enc, ptr, n)) { \ 65 - *nextTokPtr = ptr; \ 66 - return XML_TOK_INVALID; \ 67 - } \ 68 - ptr += n; \ 69 - break; 70 - 71 -#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \ 72 - case BT_NONASCII: \ 73 - if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \ 74 - *nextTokPtr = ptr; \ 75 - return XML_TOK_INVALID; \ 76 - } \ 77 - /* fall through */ \ 78 - case BT_NMSTRT: \ 79 - case BT_HEX: \ 80 - case BT_DIGIT: \ 81 - case BT_NAME: \ 82 - case BT_MINUS: \ 83 - ptr += MINBPC(enc); \ 84 - break; \ 85 - CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \ 86 - CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \ 87 - CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr) 88 - 89 -#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \ 90 - case BT_LEAD ## n: \ 91 - if (end - ptr < n) \ 92 - return XML_TOK_PARTIAL_CHAR; \ 93 - if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \ 94 - *nextTokPtr = ptr; \ 95 - return XML_TOK_INVALID; \ 96 - } \ 97 - ptr += n; \ 98 - break; 99 - 100 -#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \ 101 - case BT_NONASCII: \ 102 - if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \ 103 - *nextTokPtr = ptr; \ 104 - return XML_TOK_INVALID; \ 105 - } \ 106 - /* fall through */ \ 107 - case BT_NMSTRT: \ 108 - case BT_HEX: \ 109 - ptr += MINBPC(enc); \ 110 - break; \ 111 - CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \ 112 - CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \ 113 - CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr) 114 - 115 -#ifndef PREFIX 116 -#define PREFIX(ident) ident 117 -#endif 118 - 119 - 120 -#define HAS_CHARS(enc, ptr, end, count) \ 121 - (end - ptr >= count * MINBPC(enc)) 122 - 123 -#define HAS_CHAR(enc, ptr, end) \ 124 - HAS_CHARS(enc, ptr, end, 1) 125 - 126 -#define REQUIRE_CHARS(enc, ptr, end, count) \ 127 - { \ 128 - if (! HAS_CHARS(enc, ptr, end, count)) { \ 129 - return XML_TOK_PARTIAL; \ 130 - } \ 131 - } 132 - 133 -#define REQUIRE_CHAR(enc, ptr, end) \ 134 - REQUIRE_CHARS(enc, ptr, end, 1) 135 - 35 +# ifndef IS_INVALID_CHAR 36 +# define IS_INVALID_CHAR(enc, ptr, n) (0) 37 +# endif 38 + 39 +# define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \ 40 + case BT_LEAD##n: \ 41 + if (end - ptr < n) \ 42 + return XML_TOK_PARTIAL_CHAR; \ 43 + if (IS_INVALID_CHAR(enc, ptr, n)) { \ 44 + *(nextTokPtr) = (ptr); \ 45 + return XML_TOK_INVALID; \ 46 + } \ 47 + ptr += n; \ 48 + break; 49 + 50 +# define INVALID_CASES(ptr, nextTokPtr) \ 51 + INVALID_LEAD_CASE(2, ptr, nextTokPtr) \ 52 + INVALID_LEAD_CASE(3, ptr, nextTokPtr) \ 53 + INVALID_LEAD_CASE(4, ptr, nextTokPtr) \ 54 + case BT_NONXML: \ 55 + case BT_MALFORM: \ 56 + case BT_TRAIL: \ 57 + *(nextTokPtr) = (ptr); \ 58 + return XML_TOK_INVALID; 59 + 60 +# define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \ 61 + case BT_LEAD##n: \ 62 + if (end - ptr < n) \ 63 + return XML_TOK_PARTIAL_CHAR; \ 64 + if (! IS_NAME_CHAR(enc, ptr, n)) { \ 65 + *nextTokPtr = ptr; \ 66 + return XML_TOK_INVALID; \ 67 + } \ 68 + ptr += n; \ 69 + break; 70 + 71 +# define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \ 72 + case BT_NONASCII: \ 73 + if (! IS_NAME_CHAR_MINBPC(enc, ptr)) { \ 74 + *nextTokPtr = ptr; \ 75 + return XML_TOK_INVALID; \ 76 + } \ 77 + /* fall through */ \ 78 + case BT_NMSTRT: \ 79 + case BT_HEX: \ 80 + case BT_DIGIT: \ 81 + case BT_NAME: \ 82 + case BT_MINUS: \ 83 + ptr += MINBPC(enc); \ 84 + break; \ 85 + CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \ 86 + CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \ 87 + CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr) 88 + 89 +# define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \ 90 + case BT_LEAD##n: \ 91 + if (end - ptr < n) \ 92 + return XML_TOK_PARTIAL_CHAR; \ 93 + if (! IS_NMSTRT_CHAR(enc, ptr, n)) { \ 94 + *nextTokPtr = ptr; \ 95 + return XML_TOK_INVALID; \ 96 + } \ 97 + ptr += n; \ 98 + break; 99 + 100 +# define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \ 101 + case BT_NONASCII: \ 102 + if (! IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \ 103 + *nextTokPtr = ptr; \ 104 + return XML_TOK_INVALID; \ 105 + } \ 106 + /* fall through */ \ 107 + case BT_NMSTRT: \ 108 + case BT_HEX: \ 109 + ptr += MINBPC(enc); \ 110 + break; \ 111 + CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \ 112 + CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \ 113 + CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr) 114 + 115 +# ifndef PREFIX 116 +# define PREFIX(ident) ident 117 +# endif 118 + 119 +# define HAS_CHARS(enc, ptr, end, count) (end - ptr >= count * MINBPC(enc)) 120 + 121 +# define HAS_CHAR(enc, ptr, end) HAS_CHARS(enc, ptr, end, 1) 122 + 123 +# define REQUIRE_CHARS(enc, ptr, end, count) \ 124 + { \ 125 + if (! HAS_CHARS(enc, ptr, end, count)) { \ 126 + return XML_TOK_PARTIAL; \ 127 + } \ 128 + } 129 + 130 +# define REQUIRE_CHAR(enc, ptr, end) REQUIRE_CHARS(enc, ptr, end, 1) 136 131 137 132 /* ptr points to character following "<!-" */ 138 133 139 134 static int PTRCALL 140 -PREFIX(scanComment)(const ENCODING *enc, const char *ptr, 141 - const char *end, const char **nextTokPtr) 142 -{ 135 +PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end, 136 + const char **nextTokPtr) { 143 137 if (HAS_CHAR(enc, ptr, end)) { 144 - if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) { 138 + if (! CHAR_MATCHES(enc, ptr, ASCII_MINUS)) { 145 139 *nextTokPtr = ptr; 146 140 return XML_TOK_INVALID; 147 141 } 148 142 ptr += MINBPC(enc); 149 143 while (HAS_CHAR(enc, ptr, end)) { 150 144 switch (BYTE_TYPE(enc, ptr)) { 151 - INVALID_CASES(ptr, nextTokPtr) 145 + INVALID_CASES(ptr, nextTokPtr) 152 146 case BT_MINUS: 153 147 ptr += MINBPC(enc); 154 148 REQUIRE_CHAR(enc, ptr, end); 155 149 if (CHAR_MATCHES(enc, ptr, ASCII_MINUS)) { 156 150 ptr += MINBPC(enc); 157 151 REQUIRE_CHAR(enc, ptr, end); 158 - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { 152 + if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) { 159 153 *nextTokPtr = ptr; 160 154 return XML_TOK_INVALID; 161 155 } 162 156 *nextTokPtr = ptr + MINBPC(enc); 163 157 return XML_TOK_COMMENT; 164 158 } 165 159 break; ................................................................................ 171 165 } 172 166 return XML_TOK_PARTIAL; 173 167 } 174 168 175 169 /* ptr points to character following "<!" */ 176 170 177 171 static int PTRCALL 178 -PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, 179 - const char *end, const char **nextTokPtr) 180 -{ 172 +PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end, 173 + const char **nextTokPtr) { 181 174 REQUIRE_CHAR(enc, ptr, end); 182 175 switch (BYTE_TYPE(enc, ptr)) { 183 176 case BT_MINUS: 184 177 return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr); 185 178 case BT_LSQB: 186 179 *nextTokPtr = ptr + MINBPC(enc); 187 180 return XML_TOK_COND_SECT_OPEN; ................................................................................ 195 188 } 196 189 while (HAS_CHAR(enc, ptr, end)) { 197 190 switch (BYTE_TYPE(enc, ptr)) { 198 191 case BT_PERCNT: 199 192 REQUIRE_CHARS(enc, ptr, end, 2); 200 193 /* don't allow <!ENTITY% foo "whatever"> */ 201 194 switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) { 202 - case BT_S: case BT_CR: case BT_LF: case BT_PERCNT: 195 + case BT_S: 196 + case BT_CR: 197 + case BT_LF: 198 + case BT_PERCNT: 203 199 *nextTokPtr = ptr; 204 200 return XML_TOK_INVALID; 205 201 } 206 202 /* fall through */ 207 - case BT_S: case BT_CR: case BT_LF: 203 + case BT_S: 204 + case BT_CR: 205 + case BT_LF: 208 206 *nextTokPtr = ptr; 209 207 return XML_TOK_DECL_OPEN; 210 208 case BT_NMSTRT: 211 209 case BT_HEX: 212 210 ptr += MINBPC(enc); 213 211 break; 214 212 default: ................................................................................ 216 214 return XML_TOK_INVALID; 217 215 } 218 216 } 219 217 return XML_TOK_PARTIAL; 220 218 } 221 219 222 220 static int PTRCALL 223 -PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr, 224 - const char *end, int *tokPtr) 225 -{ 221 +PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, 222 + int *tokPtr) { 226 223 int upper = 0; 224 + UNUSED_P(enc); 227 225 *tokPtr = XML_TOK_PI; 228 - if (end - ptr != MINBPC(enc)*3) 226 + if (end - ptr != MINBPC(enc) * 3) 229 227 return 1; 230 228 switch (BYTE_TO_ASCII(enc, ptr)) { 231 229 case ASCII_x: 232 230 break; 233 231 case ASCII_X: 234 232 upper = 1; 235 233 break; ................................................................................ 261 259 *tokPtr = XML_TOK_XML_DECL; 262 260 return 1; 263 261 } 264 262 265 263 /* ptr points to character following "<?" */ 266 264 267 265 static int PTRCALL 268 -PREFIX(scanPi)(const ENCODING *enc, const char *ptr, 269 - const char *end, const char **nextTokPtr) 270 -{ 266 +PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end, 267 + const char **nextTokPtr) { 271 268 int tok; 272 269 const char *target = ptr; 273 270 REQUIRE_CHAR(enc, ptr, end); 274 271 switch (BYTE_TYPE(enc, ptr)) { 275 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 272 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 276 273 default: 277 274 *nextTokPtr = ptr; 278 275 return XML_TOK_INVALID; 279 276 } 280 277 while (HAS_CHAR(enc, ptr, end)) { 281 278 switch (BYTE_TYPE(enc, ptr)) { 282 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 283 - case BT_S: case BT_CR: case BT_LF: 284 - if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) { 279 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 280 + case BT_S: 281 + case BT_CR: 282 + case BT_LF: 283 + if (! PREFIX(checkPiTarget)(enc, target, ptr, &tok)) { 285 284 *nextTokPtr = ptr; 286 285 return XML_TOK_INVALID; 287 286 } 288 287 ptr += MINBPC(enc); 289 288 while (HAS_CHAR(enc, ptr, end)) { 290 289 switch (BYTE_TYPE(enc, ptr)) { 291 - INVALID_CASES(ptr, nextTokPtr) 290 + INVALID_CASES(ptr, nextTokPtr) 292 291 case BT_QUEST: 293 292 ptr += MINBPC(enc); 294 293 REQUIRE_CHAR(enc, ptr, end); 295 294 if (CHAR_MATCHES(enc, ptr, ASCII_GT)) { 296 295 *nextTokPtr = ptr + MINBPC(enc); 297 296 return tok; 298 297 } ................................................................................ 300 299 default: 301 300 ptr += MINBPC(enc); 302 301 break; 303 302 } 304 303 } 305 304 return XML_TOK_PARTIAL; 306 305 case BT_QUEST: 307 - if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) { 306 + if (! PREFIX(checkPiTarget)(enc, target, ptr, &tok)) { 308 307 *nextTokPtr = ptr; 309 308 return XML_TOK_INVALID; 310 309 } 311 310 ptr += MINBPC(enc); 312 311 REQUIRE_CHAR(enc, ptr, end); 313 312 if (CHAR_MATCHES(enc, ptr, ASCII_GT)) { 314 313 *nextTokPtr = ptr + MINBPC(enc); ................................................................................ 320 319 return XML_TOK_INVALID; 321 320 } 322 321 } 323 322 return XML_TOK_PARTIAL; 324 323 } 325 324 326 325 static int PTRCALL 327 -PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr, 328 - const char *end, const char **nextTokPtr) 329 -{ 330 - static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A, 331 - ASCII_T, ASCII_A, ASCII_LSQB }; 326 +PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end, 327 + const char **nextTokPtr) { 328 + static const char CDATA_LSQB[] 329 + = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB}; 332 330 int i; 331 + UNUSED_P(enc); 333 332 /* CDATA[ */ 334 333 REQUIRE_CHARS(enc, ptr, end, 6); 335 334 for (i = 0; i < 6; i++, ptr += MINBPC(enc)) { 336 - if (!CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) { 335 + if (! CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) { 337 336 *nextTokPtr = ptr; 338 337 return XML_TOK_INVALID; 339 338 } 340 339 } 341 340 *nextTokPtr = ptr; 342 341 return XML_TOK_CDATA_SECT_OPEN; 343 342 } 344 343 345 344 static int PTRCALL 346 -PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, 347 - const char *end, const char **nextTokPtr) 348 -{ 345 +PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end, 346 + const char **nextTokPtr) { 349 347 if (ptr >= end) 350 348 return XML_TOK_NONE; 351 349 if (MINBPC(enc) > 1) { 352 350 size_t n = end - ptr; 353 351 if (n & (MINBPC(enc) - 1)) { 354 352 n &= ~(MINBPC(enc) - 1); 355 353 if (n == 0) ................................................................................ 357 355 end = ptr + n; 358 356 } 359 357 } 360 358 switch (BYTE_TYPE(enc, ptr)) { 361 359 case BT_RSQB: 362 360 ptr += MINBPC(enc); 363 361 REQUIRE_CHAR(enc, ptr, end); 364 - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) 362 + if (! CHAR_MATCHES(enc, ptr, ASCII_RSQB)) 365 363 break; 366 364 ptr += MINBPC(enc); 367 365 REQUIRE_CHAR(enc, ptr, end); 368 - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { 366 + if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) { 369 367 ptr -= MINBPC(enc); 370 368 break; 371 369 } 372 370 *nextTokPtr = ptr + MINBPC(enc); 373 371 return XML_TOK_CDATA_SECT_CLOSE; 374 372 case BT_CR: 375 373 ptr += MINBPC(enc); ................................................................................ 377 375 if (BYTE_TYPE(enc, ptr) == BT_LF) 378 376 ptr += MINBPC(enc); 379 377 *nextTokPtr = ptr; 380 378 return XML_TOK_DATA_NEWLINE; 381 379 case BT_LF: 382 380 *nextTokPtr = ptr + MINBPC(enc); 383 381 return XML_TOK_DATA_NEWLINE; 384 - INVALID_CASES(ptr, nextTokPtr) 382 + INVALID_CASES(ptr, nextTokPtr) 385 383 default: 386 384 ptr += MINBPC(enc); 387 385 break; 388 386 } 389 387 while (HAS_CHAR(enc, ptr, end)) { 390 388 switch (BYTE_TYPE(enc, ptr)) { 391 -#define LEAD_CASE(n) \ 392 - case BT_LEAD ## n: \ 393 - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ 394 - *nextTokPtr = ptr; \ 395 - return XML_TOK_DATA_CHARS; \ 396 - } \ 397 - ptr += n; \ 398 - break; 399 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 400 -#undef LEAD_CASE 389 +# define LEAD_CASE(n) \ 390 + case BT_LEAD##n: \ 391 + if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ 392 + *nextTokPtr = ptr; \ 393 + return XML_TOK_DATA_CHARS; \ 394 + } \ 395 + ptr += n; \ 396 + break; 397 + LEAD_CASE(2) 398 + LEAD_CASE(3) 399 + LEAD_CASE(4) 400 +# undef LEAD_CASE 401 401 case BT_NONXML: 402 402 case BT_MALFORM: 403 403 case BT_TRAIL: 404 404 case BT_CR: 405 405 case BT_LF: 406 406 case BT_RSQB: 407 407 *nextTokPtr = ptr; ................................................................................ 414 414 *nextTokPtr = ptr; 415 415 return XML_TOK_DATA_CHARS; 416 416 } 417 417 418 418 /* ptr points to character following "</" */ 419 419 420 420 static int PTRCALL 421 -PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, 422 - const char *end, const char **nextTokPtr) 423 -{ 421 +PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end, 422 + const char **nextTokPtr) { 424 423 REQUIRE_CHAR(enc, ptr, end); 425 424 switch (BYTE_TYPE(enc, ptr)) { 426 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 425 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 427 426 default: 428 427 *nextTokPtr = ptr; 429 428 return XML_TOK_INVALID; 430 429 } 431 430 while (HAS_CHAR(enc, ptr, end)) { 432 431 switch (BYTE_TYPE(enc, ptr)) { 433 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 434 - case BT_S: case BT_CR: case BT_LF: 432 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 433 + case BT_S: 434 + case BT_CR: 435 + case BT_LF: 435 436 for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) { 436 437 switch (BYTE_TYPE(enc, ptr)) { 437 - case BT_S: case BT_CR: case BT_LF: 438 + case BT_S: 439 + case BT_CR: 440 + case BT_LF: 438 441 break; 439 442 case BT_GT: 440 443 *nextTokPtr = ptr + MINBPC(enc); 441 444 return XML_TOK_END_TAG; 442 445 default: 443 446 *nextTokPtr = ptr; 444 447 return XML_TOK_INVALID; 445 448 } 446 449 } 447 450 return XML_TOK_PARTIAL; 448 -#ifdef XML_NS 451 +# ifdef XML_NS 449 452 case BT_COLON: 450 453 /* no need to check qname syntax here, 451 454 since end-tag must match exactly */ 452 455 ptr += MINBPC(enc); 453 456 break; 454 -#endif 457 +# endif 455 458 case BT_GT: 456 459 *nextTokPtr = ptr + MINBPC(enc); 457 460 return XML_TOK_END_TAG; 458 461 default: 459 462 *nextTokPtr = ptr; 460 463 return XML_TOK_INVALID; 461 464 } ................................................................................ 462 465 } 463 466 return XML_TOK_PARTIAL; 464 467 } 465 468 466 469 /* ptr points to character following "&#X" */ 467 470 468 471 static int PTRCALL 469 -PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, 470 - const char *end, const char **nextTokPtr) 471 -{ 472 +PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end, 473 + const char **nextTokPtr) { 472 474 if (HAS_CHAR(enc, ptr, end)) { 473 475 switch (BYTE_TYPE(enc, ptr)) { 474 476 case BT_DIGIT: 475 477 case BT_HEX: 476 478 break; 477 479 default: 478 480 *nextTokPtr = ptr; ................................................................................ 494 496 } 495 497 return XML_TOK_PARTIAL; 496 498 } 497 499 498 500 /* ptr points to character following "&#" */ 499 501 500 502 static int PTRCALL 501 -PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, 502 - const char *end, const char **nextTokPtr) 503 -{ 503 +PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end, 504 + const char **nextTokPtr) { 504 505 if (HAS_CHAR(enc, ptr, end)) { 505 506 if (CHAR_MATCHES(enc, ptr, ASCII_x)) 506 507 return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); 507 508 switch (BYTE_TYPE(enc, ptr)) { 508 509 case BT_DIGIT: 509 510 break; 510 511 default: ................................................................................ 527 528 return XML_TOK_PARTIAL; 528 529 } 529 530 530 531 /* ptr points to character following "&" */ 531 532 532 533 static int PTRCALL 533 534 PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end, 534 - const char **nextTokPtr) 535 -{ 535 + const char **nextTokPtr) { 536 536 REQUIRE_CHAR(enc, ptr, end); 537 537 switch (BYTE_TYPE(enc, ptr)) { 538 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 538 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 539 539 case BT_NUM: 540 540 return PREFIX(scanCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); 541 541 default: 542 542 *nextTokPtr = ptr; 543 543 return XML_TOK_INVALID; 544 544 } 545 545 while (HAS_CHAR(enc, ptr, end)) { 546 546 switch (BYTE_TYPE(enc, ptr)) { 547 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 547 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 548 548 case BT_SEMI: 549 549 *nextTokPtr = ptr + MINBPC(enc); 550 550 return XML_TOK_ENTITY_REF; 551 551 default: 552 552 *nextTokPtr = ptr; 553 553 return XML_TOK_INVALID; 554 554 } ................................................................................ 556 556 return XML_TOK_PARTIAL; 557 557 } 558 558 559 559 /* ptr points to character following first character of attribute name */ 560 560 561 561 static int PTRCALL 562 562 PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, 563 - const char **nextTokPtr) 564 -{ 565 -#ifdef XML_NS 563 + const char **nextTokPtr) { 564 +# ifdef XML_NS 566 565 int hadColon = 0; 567 -#endif 566 +# endif 568 567 while (HAS_CHAR(enc, ptr, end)) { 569 568 switch (BYTE_TYPE(enc, ptr)) { 570 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 571 -#ifdef XML_NS 569 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 570 +# ifdef XML_NS 572 571 case BT_COLON: 573 572 if (hadColon) { 574 573 *nextTokPtr = ptr; 575 574 return XML_TOK_INVALID; 576 575 } 577 576 hadColon = 1; 578 577 ptr += MINBPC(enc); 579 578 REQUIRE_CHAR(enc, ptr, end); 580 579 switch (BYTE_TYPE(enc, ptr)) { 581 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 580 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 582 581 default: 583 582 *nextTokPtr = ptr; 584 583 return XML_TOK_INVALID; 585 584 } 586 585 break; 587 -#endif 588 - case BT_S: case BT_CR: case BT_LF: 586 +# endif 587 + case BT_S: 588 + case BT_CR: 589 + case BT_LF: 589 590 for (;;) { 590 591 int t; 591 592 592 593 ptr += MINBPC(enc); 593 594 REQUIRE_CHAR(enc, ptr, end); 594 595 t = BYTE_TYPE(enc, ptr); 595 596 if (t == BT_EQUALS) ................................................................................ 601 602 break; 602 603 default: 603 604 *nextTokPtr = ptr; 604 605 return XML_TOK_INVALID; 605 606 } 606 607 } 607 608 /* fall through */ 608 - case BT_EQUALS: 609 - { 610 - int open; 611 -#ifdef XML_NS 612 - hadColon = 0; 613 -#endif 614 - for (;;) { 615 - ptr += MINBPC(enc); 616 - REQUIRE_CHAR(enc, ptr, end); 617 - open = BYTE_TYPE(enc, ptr); 618 - if (open == BT_QUOT || open == BT_APOS) 619 - break; 620 - switch (open) { 621 - case BT_S: 622 - case BT_LF: 623 - case BT_CR: 624 - break; 625 - default: 626 - *nextTokPtr = ptr; 627 - return XML_TOK_INVALID; 628 - } 609 + case BT_EQUALS: { 610 + int open; 611 +# ifdef XML_NS 612 + hadColon = 0; 613 +# endif 614 + for (;;) { 615 + ptr += MINBPC(enc); 616 + REQUIRE_CHAR(enc, ptr, end); 617 + open = BYTE_TYPE(enc, ptr); 618 + if (open == BT_QUOT || open == BT_APOS) 619 + break; 620 + switch (open) { 621 + case BT_S: 622 + case BT_LF: 623 + case BT_CR: 624 + break; 625 + default: 626 + *nextTokPtr = ptr; 627 + return XML_TOK_INVALID; 629 628 } 630 - ptr += MINBPC(enc); 631 - /* in attribute value */ 632 - for (;;) { 633 - int t; 634 - REQUIRE_CHAR(enc, ptr, end); 635 - t = BYTE_TYPE(enc, ptr); 636 - if (t == open) 637 - break; 638 - switch (t) { 629 + } 630 + ptr += MINBPC(enc); 631 + /* in attribute value */ 632 + for (;;) { 633 + int t; 634 + REQUIRE_CHAR(enc, ptr, end); 635 + t = BYTE_TYPE(enc, ptr); 636 + if (t == open) 637 + break; 638 + switch (t) { 639 639 INVALID_CASES(ptr, nextTokPtr) 640 - case BT_AMP: 641 - { 642 - int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr); 643 - if (tok <= 0) { 644 - if (tok == XML_TOK_INVALID) 645 - *nextTokPtr = ptr; 646 - return tok; 647 - } 648 - break; 649 - } 650 - case BT_LT: 651 - *nextTokPtr = ptr; 652 - return XML_TOK_INVALID; 653 - default: 654 - ptr += MINBPC(enc); 655 - break; 640 + case BT_AMP: { 641 + int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr); 642 + if (tok <= 0) { 643 + if (tok == XML_TOK_INVALID) 644 + *nextTokPtr = ptr; 645 + return tok; 656 646 } 647 + break; 648 + } 649 + case BT_LT: 650 + *nextTokPtr = ptr; 651 + return XML_TOK_INVALID; 652 + default: 653 + ptr += MINBPC(enc); 654 + break; 657 655 } 656 + } 657 + ptr += MINBPC(enc); 658 + REQUIRE_CHAR(enc, ptr, end); 659 + switch (BYTE_TYPE(enc, ptr)) { 660 + case BT_S: 661 + case BT_CR: 662 + case BT_LF: 663 + break; 664 + case BT_SOL: 665 + goto sol; 666 + case BT_GT: 667 + goto gt; 668 + default: 669 + *nextTokPtr = ptr; 670 + return XML_TOK_INVALID; 671 + } 672 + /* ptr points to closing quote */ 673 + for (;;) { 658 674 ptr += MINBPC(enc); 659 675 REQUIRE_CHAR(enc, ptr, end); 660 676 switch (BYTE_TYPE(enc, ptr)) { 677 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 661 678 case BT_S: 662 679 case BT_CR: 663 680 case BT_LF: 664 - break; 665 - case BT_SOL: 666 - goto sol; 681 + continue; 667 682 case BT_GT: 668 - goto gt; 683 + gt: 684 + *nextTokPtr = ptr + MINBPC(enc); 685 + return XML_TOK_START_TAG_WITH_ATTS; 686 + case BT_SOL: 687 + sol: 688 + ptr += MINBPC(enc); 689 + REQUIRE_CHAR(enc, ptr, end); 690 + if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) { 691 + *nextTokPtr = ptr; 692 + return XML_TOK_INVALID; 693 + } 694 + *nextTokPtr = ptr + MINBPC(enc); 695 + return XML_TOK_EMPTY_ELEMENT_WITH_ATTS; 669 696 default: 670 697 *nextTokPtr = ptr; 671 698 return XML_TOK_INVALID; 672 699 } 673 - /* ptr points to closing quote */ 674 - for (;;) { 675 - ptr += MINBPC(enc); 676 - REQUIRE_CHAR(enc, ptr, end); 677 - switch (BYTE_TYPE(enc, ptr)) { 678 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 679 - case BT_S: case BT_CR: case BT_LF: 680 - continue; 681 - case BT_GT: 682 - gt: 683 - *nextTokPtr = ptr + MINBPC(enc); 684 - return XML_TOK_START_TAG_WITH_ATTS; 685 - case BT_SOL: 686 - sol: 687 - ptr += MINBPC(enc); 688 - REQUIRE_CHAR(enc, ptr, end); 689 - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { 690 - *nextTokPtr = ptr; 691 - return XML_TOK_INVALID; 692 - } 693 - *nextTokPtr = ptr + MINBPC(enc); 694 - return XML_TOK_EMPTY_ELEMENT_WITH_ATTS; 695 - default: 696 - *nextTokPtr = ptr; 697 - return XML_TOK_INVALID; 698 - } 699 - break; 700 - } 701 700 break; 702 701 } 702 + break; 703 + } 703 704 default: 704 705 *nextTokPtr = ptr; 705 706 return XML_TOK_INVALID; 706 707 } 707 708 } 708 709 return XML_TOK_PARTIAL; 709 710 } 710 711 711 712 /* ptr points to character following "<" */ 712 713 713 714 static int PTRCALL 714 715 PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, 715 - const char **nextTokPtr) 716 -{ 717 -#ifdef XML_NS 716 + const char **nextTokPtr) { 717 +# ifdef XML_NS 718 718 int hadColon; 719 -#endif 719 +# endif 720 720 REQUIRE_CHAR(enc, ptr, end); 721 721 switch (BYTE_TYPE(enc, ptr)) { 722 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 722 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 723 723 case BT_EXCL: 724 724 ptr += MINBPC(enc); 725 725 REQUIRE_CHAR(enc, ptr, end); 726 726 switch (BYTE_TYPE(enc, ptr)) { 727 727 case BT_MINUS: 728 728 return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr); 729 729 case BT_LSQB: 730 - return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), 731 - end, nextTokPtr); 730 + return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr); 732 731 } 733 732 *nextTokPtr = ptr; 734 733 return XML_TOK_INVALID; 735 734 case BT_QUEST: 736 735 return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr); 737 736 case BT_SOL: 738 737 return PREFIX(scanEndTag)(enc, ptr + MINBPC(enc), end, nextTokPtr); 739 738 default: 740 739 *nextTokPtr = ptr; 741 740 return XML_TOK_INVALID; 742 741 } 743 -#ifdef XML_NS 742 +# ifdef XML_NS 744 743 hadColon = 0; 745 -#endif 744 +# endif 746 745 /* we have a start-tag */ 747 746 while (HAS_CHAR(enc, ptr, end)) { 748 747 switch (BYTE_TYPE(enc, ptr)) { 749 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 750 -#ifdef XML_NS 748 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 749 +# ifdef XML_NS 751 750 case BT_COLON: 752 751 if (hadColon) { 753 752 *nextTokPtr = ptr; 754 753 return XML_TOK_INVALID; 755 754 } 756 755 hadColon = 1; 757 756 ptr += MINBPC(enc); 758 757 REQUIRE_CHAR(enc, ptr, end); 759 758 switch (BYTE_TYPE(enc, ptr)) { 760 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 759 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 761 760 default: 762 761 *nextTokPtr = ptr; 763 762 return XML_TOK_INVALID; 764 763 } 765 764 break; 766 -#endif 767 - case BT_S: case BT_CR: case BT_LF: 768 - { 769 - ptr += MINBPC(enc); 770 - while (HAS_CHAR(enc, ptr, end)) { 771 - switch (BYTE_TYPE(enc, ptr)) { 765 +# endif 766 + case BT_S: 767 + case BT_CR: 768 + case BT_LF: { 769 + ptr += MINBPC(enc); 770 + while (HAS_CHAR(enc, ptr, end)) { 771 + switch (BYTE_TYPE(enc, ptr)) { 772 772 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 773 - case BT_GT: 774 - goto gt; 775 - case BT_SOL: 776 - goto sol; 777 - case BT_S: case BT_CR: case BT_LF: 778 - ptr += MINBPC(enc); 779 - continue; 780 - default: 781 - *nextTokPtr = ptr; 782 - return XML_TOK_INVALID; 783 - } 784 - return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr); 773 + case BT_GT: 774 + goto gt; 775 + case BT_SOL: 776 + goto sol; 777 + case BT_S: 778 + case BT_CR: 779 + case BT_LF: 780 + ptr += MINBPC(enc); 781 + continue; 782 + default: 783 + *nextTokPtr = ptr; 784 + return XML_TOK_INVALID; 785 785 } 786 - return XML_TOK_PARTIAL; 786 + return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr); 787 787 } 788 + return XML_TOK_PARTIAL; 789 + } 788 790 case BT_GT: 789 791 gt: 790 792 *nextTokPtr = ptr + MINBPC(enc); 791 793 return XML_TOK_START_TAG_NO_ATTS; 792 794 case BT_SOL: 793 795 sol: 794 796 ptr += MINBPC(enc); 795 797 REQUIRE_CHAR(enc, ptr, end); 796 - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { 798 + if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) { 797 799 *nextTokPtr = ptr; 798 800 return XML_TOK_INVALID; 799 801 } 800 802 *nextTokPtr = ptr + MINBPC(enc); 801 803 return XML_TOK_EMPTY_ELEMENT_NO_ATTS; 802 804 default: 803 805 *nextTokPtr = ptr; ................................................................................ 805 807 } 806 808 } 807 809 return XML_TOK_PARTIAL; 808 810 } 809 811 810 812 static int PTRCALL 811 813 PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, 812 - const char **nextTokPtr) 813 -{ 814 + const char **nextTokPtr) { 814 815 if (ptr >= end) 815 816 return XML_TOK_NONE; 816 817 if (MINBPC(enc) > 1) { 817 818 size_t n = end - ptr; 818 819 if (n & (MINBPC(enc) - 1)) { 819 820 n &= ~(MINBPC(enc) - 1); 820 821 if (n == 0) ................................................................................ 838 839 case BT_LF: 839 840 *nextTokPtr = ptr + MINBPC(enc); 840 841 return XML_TOK_DATA_NEWLINE; 841 842 case BT_RSQB: 842 843 ptr += MINBPC(enc); 843 844 if (! HAS_CHAR(enc, ptr, end)) 844 845 return XML_TOK_TRAILING_RSQB; 845 - if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB)) 846 + if (! CHAR_MATCHES(enc, ptr, ASCII_RSQB)) 846 847 break; 847 848 ptr += MINBPC(enc); 848 849 if (! HAS_CHAR(enc, ptr, end)) 849 850 return XML_TOK_TRAILING_RSQB; 850 - if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) { 851 + if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) { 851 852 ptr -= MINBPC(enc); 852 853 break; 853 854 } 854 855 *nextTokPtr = ptr; 855 856 return XML_TOK_INVALID; 856 - INVALID_CASES(ptr, nextTokPtr) 857 + INVALID_CASES(ptr, nextTokPtr) 857 858 default: 858 859 ptr += MINBPC(enc); 859 860 break; 860 861 } 861 862 while (HAS_CHAR(enc, ptr, end)) { 862 863 switch (BYTE_TYPE(enc, ptr)) { 863 -#define LEAD_CASE(n) \ 864 - case BT_LEAD ## n: \ 865 - if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ 866 - *nextTokPtr = ptr; \ 867 - return XML_TOK_DATA_CHARS; \ 868 - } \ 869 - ptr += n; \ 870 - break; 871 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 872 -#undef LEAD_CASE 864 +# define LEAD_CASE(n) \ 865 + case BT_LEAD##n: \ 866 + if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \ 867 + *nextTokPtr = ptr; \ 868 + return XML_TOK_DATA_CHARS; \ 869 + } \ 870 + ptr += n; \ 871 + break; 872 + LEAD_CASE(2) 873 + LEAD_CASE(3) 874 + LEAD_CASE(4) 875 +# undef LEAD_CASE 873 876 case BT_RSQB: 874 877 if (HAS_CHARS(enc, ptr, end, 2)) { 875 - if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) { 876 - ptr += MINBPC(enc); 877 - break; 878 - } 879 - if (HAS_CHARS(enc, ptr, end, 3)) { 880 - if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) { 881 - ptr += MINBPC(enc); 882 - break; 883 - } 884 - *nextTokPtr = ptr + 2*MINBPC(enc); 885 - return XML_TOK_INVALID; 886 - } 878 + if (! CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) { 879 + ptr += MINBPC(enc); 880 + break; 881 + } 882 + if (HAS_CHARS(enc, ptr, end, 3)) { 883 + if (! CHAR_MATCHES(enc, ptr + 2 * MINBPC(enc), ASCII_GT)) { 884 + ptr += MINBPC(enc); 885 + break; 886 + } 887 + *nextTokPtr = ptr + 2 * MINBPC(enc); 888 + return XML_TOK_INVALID; 889 + } 887 890 } 888 891 /* fall through */ 889 892 case BT_AMP: 890 893 case BT_LT: 891 894 case BT_NONXML: 892 895 case BT_MALFORM: 893 896 case BT_TRAIL: ................................................................................ 904 907 return XML_TOK_DATA_CHARS; 905 908 } 906 909 907 910 /* ptr points to character following "%" */ 908 911 909 912 static int PTRCALL 910 913 PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, 911 - const char **nextTokPtr) 912 -{ 914 + const char **nextTokPtr) { 913 915 REQUIRE_CHAR(enc, ptr, end); 914 916 switch (BYTE_TYPE(enc, ptr)) { 915 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 916 - case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: 917 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 918 + case BT_S: 919 + case BT_LF: 920 + case BT_CR: 921 + case BT_PERCNT: 917 922 *nextTokPtr = ptr; 918 923 return XML_TOK_PERCENT; 919 924 default: 920 925 *nextTokPtr = ptr; 921 926 return XML_TOK_INVALID; 922 927 } 923 928 while (HAS_CHAR(enc, ptr, end)) { 924 929 switch (BYTE_TYPE(enc, ptr)) { 925 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 930 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 926 931 case BT_SEMI: 927 932 *nextTokPtr = ptr + MINBPC(enc); 928 933 return XML_TOK_PARAM_ENTITY_REF; 929 934 default: 930 935 *nextTokPtr = ptr; 931 936 return XML_TOK_INVALID; 932 937 } 933 938 } 934 939 return XML_TOK_PARTIAL; 935 940 } 936 941 937 942 static int PTRCALL 938 943 PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, 939 - const char **nextTokPtr) 940 -{ 944 + const char **nextTokPtr) { 941 945 REQUIRE_CHAR(enc, ptr, end); 942 946 switch (BYTE_TYPE(enc, ptr)) { 943 - CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 947 + CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) 944 948 default: 945 949 *nextTokPtr = ptr; 946 950 return XML_TOK_INVALID; 947 951 } 948 952 while (HAS_CHAR(enc, ptr, end)) { 949 953 switch (BYTE_TYPE(enc, ptr)) { 950 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 951 - case BT_CR: case BT_LF: case BT_S: 952 - case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR: 954 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 955 + case BT_CR: 956 + case BT_LF: 957 + case BT_S: 958 + case BT_RPAR: 959 + case BT_GT: 960 + case BT_PERCNT: 961 + case BT_VERBAR: 953 962 *nextTokPtr = ptr; 954 963 return XML_TOK_POUND_NAME; 955 964 default: 956 965 *nextTokPtr = ptr; 957 966 return XML_TOK_INVALID; 958 967 } 959 968 } 960 969 return -XML_TOK_POUND_NAME; 961 970 } 962 971 963 972 static int PTRCALL 964 -PREFIX(scanLit)(int open, const ENCODING *enc, 965 - const char *ptr, const char *end, 966 - const char **nextTokPtr) 967 -{ 973 +PREFIX(scanLit)(int open, const ENCODING *enc, const char *ptr, const char *end, 974 + const char **nextTokPtr) { 968 975 while (HAS_CHAR(enc, ptr, end)) { 969 976 int t = BYTE_TYPE(enc, ptr); 970 977 switch (t) { 971 - INVALID_CASES(ptr, nextTokPtr) 978 + INVALID_CASES(ptr, nextTokPtr) 972 979 case BT_QUOT: 973 980 case BT_APOS: 974 981 ptr += MINBPC(enc); 975 982 if (t != open) 976 983 break; 977 984 if (! HAS_CHAR(enc, ptr, end)) 978 985 return -XML_TOK_LITERAL; 979 986 *nextTokPtr = ptr; 980 987 switch (BYTE_TYPE(enc, ptr)) { 981 - case BT_S: case BT_CR: case BT_LF: 982 - case BT_GT: case BT_PERCNT: case BT_LSQB: 988 + case BT_S: 989 + case BT_CR: 990 + case BT_LF: 991 + case BT_GT: 992 + case BT_PERCNT: 993 + case BT_LSQB: 983 994 return XML_TOK_LITERAL; 984 995 default: 985 996 return XML_TOK_INVALID; 986 997 } 987 998 default: 988 999 ptr += MINBPC(enc); 989 1000 break; ................................................................................ 990 1001 } 991 1002 } 992 1003 return XML_TOK_PARTIAL; 993 1004 } 994 1005 995 1006 static int PTRCALL 996 1007 PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, 997 - const char **nextTokPtr) 998 -{ 1008 + const char **nextTokPtr) { 999 1009 int tok; 1000 1010 if (ptr >= end) 1001 1011 return XML_TOK_NONE; 1002 1012 if (MINBPC(enc) > 1) { 1003 1013 size_t n = end - ptr; 1004 1014 if (n & (MINBPC(enc) - 1)) { 1005 1015 n &= ~(MINBPC(enc) - 1); ................................................................................ 1009 1019 } 1010 1020 } 1011 1021 switch (BYTE_TYPE(enc, ptr)) { 1012 1022 case BT_QUOT: 1013 1023 return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr); 1014 1024 case BT_APOS: 1015 1025 return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr); 1016 - case BT_LT: 1017 - { 1018 - ptr += MINBPC(enc); 1019 - REQUIRE_CHAR(enc, ptr, end); 1020 - switch (BYTE_TYPE(enc, ptr)) { 1021 - case BT_EXCL: 1022 - return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1023 - case BT_QUEST: 1024 - return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1025 - case BT_NMSTRT: 1026 - case BT_HEX: 1027 - case BT_NONASCII: 1028 - case BT_LEAD2: 1029 - case BT_LEAD3: 1030 - case BT_LEAD4: 1031 - *nextTokPtr = ptr - MINBPC(enc); 1032 - return XML_TOK_INSTANCE_START; 1033 - } 1034 - *nextTokPtr = ptr; 1035 - return XML_TOK_INVALID; 1036 - } 1026 + case BT_LT: { 1027 + ptr += MINBPC(enc); 1028 + REQUIRE_CHAR(enc, ptr, end); 1029 + switch (BYTE_TYPE(enc, ptr)) { 1030 + case BT_EXCL: 1031 + return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1032 + case BT_QUEST: 1033 + return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1034 + case BT_NMSTRT: 1035 + case BT_HEX: 1036 + case BT_NONASCII: 1037 + case BT_LEAD2: 1038 + case BT_LEAD3: 1039 + case BT_LEAD4: 1040 + *nextTokPtr = ptr - MINBPC(enc); 1041 + return XML_TOK_INSTANCE_START; 1042 + } 1043 + *nextTokPtr = ptr; 1044 + return XML_TOK_INVALID; 1045 + } 1037 1046 case BT_CR: 1038 1047 if (ptr + MINBPC(enc) == end) { 1039 1048 *nextTokPtr = end; 1040 1049 /* indicate that this might be part of a CR/LF pair */ 1041 1050 return -XML_TOK_PROLOG_S; 1042 1051 } 1043 1052 /* fall through */ 1044 - case BT_S: case BT_LF: 1053 + case BT_S: 1054 + case BT_LF: 1045 1055 for (;;) { 1046 1056 ptr += MINBPC(enc); 1047 1057 if (! HAS_CHAR(enc, ptr, end)) 1048 1058 break; 1049 1059 switch (BYTE_TYPE(enc, ptr)) { 1050 - case BT_S: case BT_LF: 1060 + case BT_S: 1061 + case BT_LF: 1051 1062 break; 1052 1063 case BT_CR: 1053 1064 /* don't split CR/LF pair */ 1054 1065 if (ptr + MINBPC(enc) != end) 1055 1066 break; 1056 1067 /* fall through */ 1057 1068 default: ................................................................................ 1072 1083 case BT_RSQB: 1073 1084 ptr += MINBPC(enc); 1074 1085 if (! HAS_CHAR(enc, ptr, end)) 1075 1086 return -XML_TOK_CLOSE_BRACKET; 1076 1087 if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) { 1077 1088 REQUIRE_CHARS(enc, ptr, end, 2); 1078 1089 if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) { 1079 - *nextTokPtr = ptr + 2*MINBPC(enc); 1090 + *nextTokPtr = ptr + 2 * MINBPC(enc); 1080 1091 return XML_TOK_COND_SECT_CLOSE; 1081 1092 } 1082 1093 } 1083 1094 *nextTokPtr = ptr; 1084 1095 return XML_TOK_CLOSE_BRACKET; 1085 1096 case BT_LPAR: 1086 1097 *nextTokPtr = ptr + MINBPC(enc); ................................................................................ 1095 1106 return XML_TOK_CLOSE_PAREN_ASTERISK; 1096 1107 case BT_QUEST: 1097 1108 *nextTokPtr = ptr + MINBPC(enc); 1098 1109 return XML_TOK_CLOSE_PAREN_QUESTION; 1099 1110 case BT_PLUS: 1100 1111 *nextTokPtr = ptr + MINBPC(enc); 1101 1112 return XML_TOK_CLOSE_PAREN_PLUS; 1102 - case BT_CR: case BT_LF: case BT_S: 1103 - case BT_GT: case BT_COMMA: case BT_VERBAR: 1113 + case BT_CR: 1114 + case BT_LF: 1115 + case BT_S: 1116 + case BT_GT: 1117 + case BT_COMMA: 1118 + case BT_VERBAR: 1104 1119 case BT_RPAR: 1105 1120 *nextTokPtr = ptr; 1106 1121 return XML_TOK_CLOSE_PAREN; 1107 1122 } 1108 1123 *nextTokPtr = ptr; 1109 1124 return XML_TOK_INVALID; 1110 1125 case BT_VERBAR: ................................................................................ 1111 1126 *nextTokPtr = ptr + MINBPC(enc); 1112 1127 return XML_TOK_OR; 1113 1128 case BT_GT: 1114 1129 *nextTokPtr = ptr + MINBPC(enc); 1115 1130 return XML_TOK_DECL_CLOSE; 1116 1131 case BT_NUM: 1117 1132 return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1118 -#define LEAD_CASE(n) \ 1119 - case BT_LEAD ## n: \ 1120 - if (end - ptr < n) \ 1121 - return XML_TOK_PARTIAL_CHAR; \ 1122 - if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ 1123 - ptr += n; \ 1124 - tok = XML_TOK_NAME; \ 1125 - break; \ 1126 - } \ 1127 - if (IS_NAME_CHAR(enc, ptr, n)) { \ 1128 - ptr += n; \ 1129 - tok = XML_TOK_NMTOKEN; \ 1130 - break; \ 1131 - } \ 1132 - *nextTokPtr = ptr; \ 1133 +# define LEAD_CASE(n) \ 1134 + case BT_LEAD##n: \ 1135 + if (end - ptr < n) \ 1136 + return XML_TOK_PARTIAL_CHAR; \ 1137 + if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ 1138 + ptr += n; \ 1139 + tok = XML_TOK_NAME; \ 1140 + break; \ 1141 + } \ 1142 + if (IS_NAME_CHAR(enc, ptr, n)) { \ 1143 + ptr += n; \ 1144 + tok = XML_TOK_NMTOKEN; \ 1145 + break; \ 1146 + } \ 1147 + *nextTokPtr = ptr; \ 1133 1148 return XML_TOK_INVALID; 1134 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 1135 -#undef LEAD_CASE 1149 + LEAD_CASE(2) 1150 + LEAD_CASE(3) 1151 + LEAD_CASE(4) 1152 +# undef LEAD_CASE 1136 1153 case BT_NMSTRT: 1137 1154 case BT_HEX: 1138 1155 tok = XML_TOK_NAME; 1139 1156 ptr += MINBPC(enc); 1140 1157 break; 1141 1158 case BT_DIGIT: 1142 1159 case BT_NAME: 1143 1160 case BT_MINUS: 1144 -#ifdef XML_NS 1161 +# ifdef XML_NS 1145 1162 case BT_COLON: 1146 -#endif 1163 +# endif 1147 1164 tok = XML_TOK_NMTOKEN; 1148 1165 ptr += MINBPC(enc); 1149 1166 break; 1150 1167 case BT_NONASCII: 1151 1168 if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { 1152 1169 ptr += MINBPC(enc); 1153 1170 tok = XML_TOK_NAME; ................................................................................ 1161 1178 /* fall through */ 1162 1179 default: 1163 1180 *nextTokPtr = ptr; 1164 1181 return XML_TOK_INVALID; 1165 1182 } 1166 1183 while (HAS_CHAR(enc, ptr, end)) { 1167 1184 switch (BYTE_TYPE(enc, ptr)) { 1168 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 1169 - case BT_GT: case BT_RPAR: case BT_COMMA: 1170 - case BT_VERBAR: case BT_LSQB: case BT_PERCNT: 1171 - case BT_S: case BT_CR: case BT_LF: 1185 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 1186 + case BT_GT: 1187 + case BT_RPAR: 1188 + case BT_COMMA: 1189 + case BT_VERBAR: 1190 + case BT_LSQB: 1191 + case BT_PERCNT: 1192 + case BT_S: 1193 + case BT_CR: 1194 + case BT_LF: 1172 1195 *nextTokPtr = ptr; 1173 1196 return tok; 1174 -#ifdef XML_NS 1197 +# ifdef XML_NS 1175 1198 case BT_COLON: 1176 1199 ptr += MINBPC(enc); 1177 1200 switch (tok) { 1178 1201 case XML_TOK_NAME: 1179 1202 REQUIRE_CHAR(enc, ptr, end); 1180 1203 tok = XML_TOK_PREFIXED_NAME; 1181 1204 switch (BYTE_TYPE(enc, ptr)) { 1182 - CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 1205 + CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) 1183 1206 default: 1184 1207 tok = XML_TOK_NMTOKEN; 1185 1208 break; 1186 1209 } 1187 1210 break; 1188 1211 case XML_TOK_PREFIXED_NAME: 1189 1212 tok = XML_TOK_NMTOKEN; 1190 1213 break; 1191 1214 } 1192 1215 break; 1193 -#endif 1216 +# endif 1194 1217 case BT_PLUS: 1195 - if (tok == XML_TOK_NMTOKEN) { 1218 + if (tok == XML_TOK_NMTOKEN) { 1196 1219 *nextTokPtr = ptr; 1197 1220 return XML_TOK_INVALID; 1198 1221 } 1199 1222 *nextTokPtr = ptr + MINBPC(enc); 1200 1223 return XML_TOK_NAME_PLUS; 1201 1224 case BT_AST: 1202 - if (tok == XML_TOK_NMTOKEN) { 1225 + if (tok == XML_TOK_NMTOKEN) { 1203 1226 *nextTokPtr = ptr; 1204 1227 return XML_TOK_INVALID; 1205 1228 } 1206 1229 *nextTokPtr = ptr + MINBPC(enc); 1207 1230 return XML_TOK_NAME_ASTERISK; 1208 1231 case BT_QUEST: 1209 - if (tok == XML_TOK_NMTOKEN) { 1232 + if (tok == XML_TOK_NMTOKEN) { 1210 1233 *nextTokPtr = ptr; 1211 1234 return XML_TOK_INVALID; 1212 1235 } 1213 1236 *nextTokPtr = ptr + MINBPC(enc); 1214 1237 return XML_TOK_NAME_QUESTION; 1215 1238 default: 1216 1239 *nextTokPtr = ptr; ................................................................................ 1217 1240 return XML_TOK_INVALID; 1218 1241 } 1219 1242 } 1220 1243 return -tok; 1221 1244 } 1222 1245 1223 1246 static int PTRCALL 1224 -PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, 1225 - const char *end, const char **nextTokPtr) 1226 -{ 1247 +PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, 1248 + const char **nextTokPtr) { 1227 1249 const char *start; 1228 1250 if (ptr >= end) 1229 1251 return XML_TOK_NONE; 1230 1252 else if (! HAS_CHAR(enc, ptr, end)) { 1231 1253 /* This line cannot be executed. The incoming data has already 1232 1254 * been tokenized once, so incomplete characters like this have 1233 1255 * already been eliminated from the input. Retaining the paranoia ................................................................................ 1234 1256 * check is still valuable, however. 1235 1257 */ 1236 1258 return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */ 1237 1259 } 1238 1260 start = ptr; 1239 1261 while (HAS_CHAR(enc, ptr, end)) { 1240 1262 switch (BYTE_TYPE(enc, ptr)) { 1241 -#define LEAD_CASE(n) \ 1242 - case BT_LEAD ## n: ptr += n; break; 1243 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 1244 -#undef LEAD_CASE 1263 +# define LEAD_CASE(n) \ 1264 + case BT_LEAD##n: \ 1265 + ptr += n; \ 1266 + break; 1267 + LEAD_CASE(2) 1268 + LEAD_CASE(3) 1269 + LEAD_CASE(4) 1270 +# undef LEAD_CASE 1245 1271 case BT_AMP: 1246 1272 if (ptr == start) 1247 1273 return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1248 1274 *nextTokPtr = ptr; 1249 1275 return XML_TOK_DATA_CHARS; 1250 1276 case BT_LT: 1251 1277 /* this is for inside entity references */ ................................................................................ 1283 1309 } 1284 1310 } 1285 1311 *nextTokPtr = ptr; 1286 1312 return XML_TOK_DATA_CHARS; 1287 1313 } 1288 1314 1289 1315 static int PTRCALL 1290 -PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, 1291 - const char *end, const char **nextTokPtr) 1292 -{ 1316 +PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, 1317 + const char **nextTokPtr) { 1293 1318 const char *start; 1294 1319 if (ptr >= end) 1295 1320 return XML_TOK_NONE; 1296 1321 else if (! HAS_CHAR(enc, ptr, end)) { 1297 1322 /* This line cannot be executed. The incoming data has already 1298 1323 * been tokenized once, so incomplete characters like this have 1299 1324 * already been eliminated from the input. Retaining the paranoia ................................................................................ 1300 1325 * check is still valuable, however. 1301 1326 */ 1302 1327 return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */ 1303 1328 } 1304 1329 start = ptr; 1305 1330 while (HAS_CHAR(enc, ptr, end)) { 1306 1331 switch (BYTE_TYPE(enc, ptr)) { 1307 -#define LEAD_CASE(n) \ 1308 - case BT_LEAD ## n: ptr += n; break; 1309 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 1310 -#undef LEAD_CASE 1332 +# define LEAD_CASE(n) \ 1333 + case BT_LEAD##n: \ 1334 + ptr += n; \ 1335 + break; 1336 + LEAD_CASE(2) 1337 + LEAD_CASE(3) 1338 + LEAD_CASE(4) 1339 +# undef LEAD_CASE 1311 1340 case BT_AMP: 1312 1341 if (ptr == start) 1313 1342 return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1314 1343 *nextTokPtr = ptr; 1315 1344 return XML_TOK_DATA_CHARS; 1316 1345 case BT_PERCNT: 1317 1346 if (ptr == start) { 1318 - int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), 1319 - end, nextTokPtr); 1347 + int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr); 1320 1348 return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok; 1321 1349 } 1322 1350 *nextTokPtr = ptr; 1323 1351 return XML_TOK_DATA_CHARS; 1324 1352 case BT_LF: 1325 1353 if (ptr == start) { 1326 1354 *nextTokPtr = ptr + MINBPC(enc); ................................................................................ 1345 1373 break; 1346 1374 } 1347 1375 } 1348 1376 *nextTokPtr = ptr; 1349 1377 return XML_TOK_DATA_CHARS; 1350 1378 } 1351 1379 1352 -#ifdef XML_DTD 1380 +# ifdef XML_DTD 1353 1381 1354 1382 static int PTRCALL 1355 -PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, 1356 - const char *end, const char **nextTokPtr) 1357 -{ 1383 +PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, 1384 + const char **nextTokPtr) { 1358 1385 int level = 0; 1359 1386 if (MINBPC(enc) > 1) { 1360 1387 size_t n = end - ptr; 1361 1388 if (n & (MINBPC(enc) - 1)) { 1362 1389 n &= ~(MINBPC(enc) - 1); 1363 1390 end = ptr + n; 1364 1391 } 1365 1392 } 1366 1393 while (HAS_CHAR(enc, ptr, end)) { 1367 1394 switch (BYTE_TYPE(enc, ptr)) { 1368 - INVALID_CASES(ptr, nextTokPtr) 1395 + INVALID_CASES(ptr, nextTokPtr) 1369 1396 case BT_LT: 1370 1397 ptr += MINBPC(enc); 1371 1398 REQUIRE_CHAR(enc, ptr, end); 1372 1399 if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) { 1373 1400 ptr += MINBPC(enc); 1374 1401 REQUIRE_CHAR(enc, ptr, end); 1375 1402 if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) { ................................................................................ 1398 1425 ptr += MINBPC(enc); 1399 1426 break; 1400 1427 } 1401 1428 } 1402 1429 return XML_TOK_PARTIAL; 1403 1430 } 1404 1431 1405 -#endif /* XML_DTD */ 1432 +# endif /* XML_DTD */ 1406 1433 1407 1434 static int PTRCALL 1408 1435 PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, 1409 - const char **badPtr) 1410 -{ 1436 + const char **badPtr) { 1411 1437 ptr += MINBPC(enc); 1412 1438 end -= MINBPC(enc); 1413 1439 for (; HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) { 1414 1440 switch (BYTE_TYPE(enc, ptr)) { 1415 1441 case BT_DIGIT: 1416 1442 case BT_HEX: 1417 1443 case BT_MINUS: ................................................................................ 1426 1452 case BT_CR: 1427 1453 case BT_LF: 1428 1454 case BT_SEMI: 1429 1455 case BT_EXCL: 1430 1456 case BT_AST: 1431 1457 case BT_PERCNT: 1432 1458 case BT_NUM: 1433 -#ifdef XML_NS 1459 +# ifdef XML_NS 1434 1460 case BT_COLON: 1435 -#endif 1461 +# endif 1436 1462 break; 1437 1463 case BT_S: 1438 1464 if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) { 1439 1465 *badPtr = ptr; 1440 1466 return 0; 1441 1467 } 1442 1468 break; 1443 1469 case BT_NAME: 1444 1470 case BT_NMSTRT: 1445 - if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) 1471 + if (! (BYTE_TO_ASCII(enc, ptr) & ~0x7f)) 1446 1472 break; 1447 1473 /* fall through */ 1448 1474 default: 1449 1475 switch (BYTE_TO_ASCII(enc, ptr)) { 1450 1476 case 0x24: /* $ */ 1451 1477 case 0x40: /* @ */ 1452 1478 break; ................................................................................ 1462 1488 1463 1489 /* This must only be called for a well-formed start-tag or empty 1464 1490 element tag. Returns the number of attributes. Pointers to the 1465 1491 first attsMax attributes are stored in atts. 1466 1492 */ 1467 1493 1468 1494 static int PTRCALL 1469 -PREFIX(getAtts)(const ENCODING *enc, const char *ptr, 1470 - int attsMax, ATTRIBUTE *atts) 1471 -{ 1495 +PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax, 1496 + ATTRIBUTE *atts) { 1472 1497 enum { other, inName, inValue } state = inName; 1473 1498 int nAtts = 0; 1474 1499 int open = 0; /* defined when state == inValue; 1475 1500 initialization just to shut up compilers */ 1476 1501 1477 1502 for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) { 1478 1503 switch (BYTE_TYPE(enc, ptr)) { 1479 -#define START_NAME \ 1480 - if (state == other) { \ 1481 - if (nAtts < attsMax) { \ 1482 - atts[nAtts].name = ptr; \ 1483 - atts[nAtts].normalized = 1; \ 1484 - } \ 1485 - state = inName; \ 1486 - } 1487 -#define LEAD_CASE(n) \ 1488 - case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break; 1489 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 1490 -#undef LEAD_CASE 1504 +# define START_NAME \ 1505 + if (state == other) { \ 1506 + if (nAtts < attsMax) { \ 1507 + atts[nAtts].name = ptr; \ 1508 + atts[nAtts].normalized = 1; \ 1509 + } \ 1510 + state = inName; \ 1511 + } 1512 +# define LEAD_CASE(n) \ 1513 + case BT_LEAD##n: \ 1514 + START_NAME ptr += (n - MINBPC(enc)); \ 1515 + break; 1516 + LEAD_CASE(2) 1517 + LEAD_CASE(3) 1518 + LEAD_CASE(4) 1519 +# undef LEAD_CASE 1491 1520 case BT_NONASCII: 1492 1521 case BT_NMSTRT: 1493 1522 case BT_HEX: 1494 1523 START_NAME 1495 1524 break; 1496 -#undef START_NAME 1525 +# undef START_NAME 1497 1526 case BT_QUOT: 1498 1527 if (state != inValue) { 1499 1528 if (nAtts < attsMax) 1500 1529 atts[nAtts].valuePtr = ptr + MINBPC(enc); 1501 1530 state = inValue; 1502 1531 open = BT_QUOT; 1503 - } 1504 - else if (open == BT_QUOT) { 1532 + } else if (open == BT_QUOT) { 1505 1533 state = other; 1506 1534 if (nAtts < attsMax) 1507 1535 atts[nAtts].valueEnd = ptr; 1508 1536 nAtts++; 1509 1537 } 1510 1538 break; 1511 1539 case BT_APOS: 1512 1540 if (state != inValue) { 1513 1541 if (nAtts < attsMax) 1514 1542 atts[nAtts].valuePtr = ptr + MINBPC(enc); 1515 1543 state = inValue; 1516 1544 open = BT_APOS; 1517 - } 1518 - else if (open == BT_APOS) { 1545 + } else if (open == BT_APOS) { 1519 1546 state = other; 1520 1547 if (nAtts < attsMax) 1521 1548 atts[nAtts].valueEnd = ptr; 1522 1549 nAtts++; 1523 1550 } 1524 1551 break; 1525 1552 case BT_AMP: 1526 1553 if (nAtts < attsMax) 1527 1554 atts[nAtts].normalized = 0; 1528 1555 break; 1529 1556 case BT_S: 1530 1557 if (state == inName) 1531 1558 state = other; 1532 - else if (state == inValue 1533 - && nAtts < attsMax 1534 - && atts[nAtts].normalized 1559 + else if (state == inValue && nAtts < attsMax && atts[nAtts].normalized 1535 1560 && (ptr == atts[nAtts].valuePtr 1536 1561 || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE 1537 1562 || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE 1538 1563 || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open)) 1539 1564 atts[nAtts].normalized = 0; 1540 1565 break; 1541 - case BT_CR: case BT_LF: 1566 + case BT_CR: 1567 + case BT_LF: 1542 1568 /* This case ensures that the first attribute name is counted 1543 1569 Apart from that we could just change state on the quote. */ 1544 1570 if (state == inName) 1545 1571 state = other; 1546 1572 else if (state == inValue && nAtts < attsMax) 1547 1573 atts[nAtts].normalized = 0; 1548 1574 break; ................................................................................ 1555 1581 break; 1556 1582 } 1557 1583 } 1558 1584 /* not reached */ 1559 1585 } 1560 1586 1561 1587 static int PTRFASTCALL 1562 -PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr) 1563 -{ 1588 +PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) { 1564 1589 int result = 0; 1565 1590 /* skip &# */ 1566 - ptr += 2*MINBPC(enc); 1591 + UNUSED_P(enc); 1592 + ptr += 2 * MINBPC(enc); 1567 1593 if (CHAR_MATCHES(enc, ptr, ASCII_x)) { 1568 - for (ptr += MINBPC(enc); 1569 - !CHAR_MATCHES(enc, ptr, ASCII_SEMI); 1594 + for (ptr += MINBPC(enc); ! CHAR_MATCHES(enc, ptr, ASCII_SEMI); 1570 1595 ptr += MINBPC(enc)) { 1571 1596 int c = BYTE_TO_ASCII(enc, ptr); 1572 1597 switch (c) { 1573 - case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4: 1574 - case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9: 1598 + case ASCII_0: 1599 + case ASCII_1: 1600 + case ASCII_2: 1601 + case ASCII_3: 1602 + case ASCII_4: 1603 + case ASCII_5: 1604 + case ASCII_6: 1605 + case ASCII_7: 1606 + case ASCII_8: 1607 + case ASCII_9: 1575 1608 result <<= 4; 1576 1609 result |= (c - ASCII_0); 1577 1610 break; 1578 - case ASCII_A: case ASCII_B: case ASCII_C: 1579 - case ASCII_D: case ASCII_E: case ASCII_F: 1611 + case ASCII_A: 1612 + case ASCII_B: 1613 + case ASCII_C: 1614 + case ASCII_D: 1615 + case ASCII_E: 1616 + case ASCII_F: 1580 1617 result <<= 4; 1581 1618 result += 10 + (c - ASCII_A); 1582 1619 break; 1583 - case ASCII_a: case ASCII_b: case ASCII_c: 1584 - case ASCII_d: case ASCII_e: case ASCII_f: 1620 + case ASCII_a: 1621 + case ASCII_b: 1622 + case ASCII_c: 1623 + case ASCII_d: 1624 + case ASCII_e: 1625 + case ASCII_f: 1585 1626 result <<= 4; 1586 1627 result += 10 + (c - ASCII_a); 1587 1628 break; 1588 1629 } 1589 1630 if (result >= 0x110000) 1590 1631 return -1; 1591 1632 } 1592 - } 1593 - else { 1594 - for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { 1633 + } else { 1634 + for (; ! CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { 1595 1635 int c = BYTE_TO_ASCII(enc, ptr); 1596 1636 result *= 10; 1597 1637 result += (c - ASCII_0); 1598 1638 if (result >= 0x110000) 1599 1639 return -1; 1600 1640 } 1601 1641 } 1602 1642 return checkCharRefNumber(result); 1603 1643 } 1604 1644 1605 1645 static int PTRCALL 1606 -PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr, 1607 - const char *end) 1608 -{ 1609 - switch ((end - ptr)/MINBPC(enc)) { 1646 +PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, 1647 + const char *end) { 1648 + UNUSED_P(enc); 1649 + switch ((end - ptr) / MINBPC(enc)) { 1610 1650 case 2: 1611 1651 if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) { 1612 1652 switch (BYTE_TO_ASCII(enc, ptr)) { 1613 1653 case ASCII_l: 1614 1654 return ASCII_LT; 1615 1655 case ASCII_g: 1616 1656 return ASCII_GT; ................................................................................ 1653 1693 break; 1654 1694 } 1655 1695 } 1656 1696 return 0; 1657 1697 } 1658 1698 1659 1699 static int PTRCALL 1660 -PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1, 1661 - const char *end1, const char *ptr2) 1662 -{ 1700 +PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, 1701 + const char *end1, const char *ptr2) { 1702 + UNUSED_P(enc); 1663 1703 for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { 1664 1704 if (end1 - ptr1 < MINBPC(enc)) { 1665 1705 /* This line cannot be executed. The incoming data has already 1666 1706 * been tokenized once, so incomplete characters like this have 1667 1707 * already been eliminated from the input. Retaining the 1668 1708 * paranoia check is still valuable, however. 1669 1709 */ 1670 1710 return 0; /* LCOV_EXCL_LINE */ 1671 1711 } 1672 - if (!CHAR_MATCHES(enc, ptr1, *ptr2)) 1712 + if (! CHAR_MATCHES(enc, ptr1, *ptr2)) 1673 1713 return 0; 1674 1714 } 1675 1715 return ptr1 == end1; 1676 1716 } 1677 1717 1678 1718 static int PTRFASTCALL 1679 -PREFIX(nameLength)(const ENCODING *enc, const char *ptr) 1680 -{ 1719 +PREFIX(nameLength)(const ENCODING *enc, const char *ptr) { 1681 1720 const char *start = ptr; 1682 1721 for (;;) { 1683 1722 switch (BYTE_TYPE(enc, ptr)) { 1684 -#define LEAD_CASE(n) \ 1685 - case BT_LEAD ## n: ptr += n; break; 1686 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 1687 -#undef LEAD_CASE 1723 +# define LEAD_CASE(n) \ 1724 + case BT_LEAD##n: \ 1725 + ptr += n; \ 1726 + break; 1727 + LEAD_CASE(2) 1728 + LEAD_CASE(3) 1729 + LEAD_CASE(4) 1730 +# undef LEAD_CASE 1688 1731 case BT_NONASCII: 1689 1732 case BT_NMSTRT: 1690 -#ifdef XML_NS 1733 +# ifdef XML_NS 1691 1734 case BT_COLON: 1692 -#endif 1735 +# endif 1693 1736 case BT_HEX: 1694 1737 case BT_DIGIT: 1695 1738 case BT_NAME: 1696 1739 case BT_MINUS: 1697 1740 ptr += MINBPC(enc); 1698 1741 break; 1699 1742 default: 1700 1743 return (int)(ptr - start); 1701 1744 } 1702 1745 } 1703 1746 } 1704 1747 1705 -static const char * PTRFASTCALL 1706 -PREFIX(skipS)(const ENCODING *enc, const char *ptr) 1707 -{ 1748 +static const char *PTRFASTCALL 1749 +PREFIX(skipS)(const ENCODING *enc, const char *ptr) { 1708 1750 for (;;) { 1709 1751 switch (BYTE_TYPE(enc, ptr)) { 1710 1752 case BT_LF: 1711 1753 case BT_CR: 1712 1754 case BT_S: 1713 1755 ptr += MINBPC(enc); 1714 1756 break; ................................................................................ 1715 1757 default: 1716 1758 return ptr; 1717 1759 } 1718 1760 } 1719 1761 } 1720 1762 1721 1763 static void PTRCALL 1722 -PREFIX(updatePosition)(const ENCODING *enc, 1723 - const char *ptr, 1724 - const char *end, 1725 - POSITION *pos) 1726 -{ 1764 +PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end, 1765 + POSITION *pos) { 1727 1766 while (HAS_CHAR(enc, ptr, end)) { 1728 1767 switch (BYTE_TYPE(enc, ptr)) { 1729 -#define LEAD_CASE(n) \ 1730 - case BT_LEAD ## n: \ 1731 - ptr += n; \ 1732 - break; 1733 - LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) 1734 -#undef LEAD_CASE 1768 +# define LEAD_CASE(n) \ 1769 + case BT_LEAD##n: \ 1770 + ptr += n; \ 1771 + break; 1772 + LEAD_CASE(2) 1773 + LEAD_CASE(3) 1774 + LEAD_CASE(4) 1775 +# undef LEAD_CASE 1735 1776 case BT_LF: 1736 1777 pos->columnNumber = (XML_Size)-1; 1737 1778 pos->lineNumber++; 1738 1779 ptr += MINBPC(enc); 1739 1780 break; 1740 1781 case BT_CR: 1741 1782 pos->lineNumber++; ................................................................................ 1748 1789 ptr += MINBPC(enc); 1749 1790 break; 1750 1791 } 1751 1792 pos->columnNumber++; 1752 1793 } 1753 1794 } 1754 1795 1755 -#undef DO_LEAD_CASE 1756 -#undef MULTIBYTE_CASES 1757 -#undef INVALID_CASES 1758 -#undef CHECK_NAME_CASE 1759 -#undef CHECK_NAME_CASES 1760 -#undef CHECK_NMSTRT_CASE 1761 -#undef CHECK_NMSTRT_CASES 1796 +# undef DO_LEAD_CASE 1797 +# undef MULTIBYTE_CASES 1798 +# undef INVALID_CASES 1799 +# undef CHECK_NAME_CASE 1800 +# undef CHECK_NAME_CASES 1801 +# undef CHECK_NMSTRT_CASE 1802 +# undef CHECK_NMSTRT_CASES 1762 1803 1763 1804 #endif /* XML_TOK_IMPL_C */
Changes to expat/xmltok_impl.h.
27 27 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 28 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 enum { 34 - BT_NONXML, 35 - BT_MALFORM, 36 - BT_LT, 37 - BT_AMP, 38 - BT_RSQB, 39 - BT_LEAD2, 40 - BT_LEAD3, 41 - BT_LEAD4, 42 - BT_TRAIL, 43 - BT_CR, 44 - BT_LF, 45 - BT_GT, 46 - BT_QUOT, 47 - BT_APOS, 48 - BT_EQUALS, 49 - BT_QUEST, 50 - BT_EXCL, 51 - BT_SOL, 52 - BT_SEMI, 53 - BT_NUM, 54 - BT_LSQB, 55 - BT_S, 56 - BT_NMSTRT, 57 - BT_COLON, 58 - BT_HEX, 59 - BT_DIGIT, 60 - BT_NAME, 61 - BT_MINUS, 62 - BT_OTHER, /* known not to be a name or name start character */ 34 + BT_NONXML, /* e.g. noncharacter-FFFF */ 35 + BT_MALFORM, /* illegal, with regard to encoding */ 36 + BT_LT, /* less than = "<" */ 37 + BT_AMP, /* ampersand = "&" */ 38 + BT_RSQB, /* right square bracket = "[" */ 39 + BT_LEAD2, /* lead byte of a 2-byte UTF-8 character */ 40 + BT_LEAD3, /* lead byte of a 3-byte UTF-8 character */ 41 + BT_LEAD4, /* lead byte of a 4-byte UTF-8 character */ 42 + BT_TRAIL, /* trailing unit, e.g. second 16-bit unit of a 4-byte char. */ 43 + BT_CR, /* carriage return = "\r" */ 44 + BT_LF, /* line feed = "\n" */ 45 + BT_GT, /* greater than = ">" */ 46 + BT_QUOT, /* quotation character = "\"" */ 47 + BT_APOS, /* aposthrophe = "'" */ 48 + BT_EQUALS, /* equal sign = "=" */ 49 + BT_QUEST, /* question mark = "?" */ 50 + BT_EXCL, /* exclamation mark = "!" */ 51 + BT_SOL, /* solidus, slash = "/" */ 52 + BT_SEMI, /* semicolon = ";" */ 53 + BT_NUM, /* number sign = "#" */ 54 + BT_LSQB, /* left square bracket = "[" */ 55 + BT_S, /* white space, e.g. "\t", " "[, "\r"] */ 56 + BT_NMSTRT, /* non-hex name start letter = "G".."Z" + "g".."z" + "_" */ 57 + BT_COLON, /* colon = ":" */ 58 + BT_HEX, /* hex letter = "A".."F" + "a".."f" */ 59 + BT_DIGIT, /* digit = "0".."9" */ 60 + BT_NAME, /* dot and middle dot = "." + chr(0xb7) */ 61 + BT_MINUS, /* minus = "-" */ 62 + BT_OTHER, /* known not to be a name or name start character */ 63 63 BT_NONASCII, /* might be a name or name start character */ 64 - BT_PERCNT, 65 - BT_LPAR, 66 - BT_RPAR, 67 - BT_AST, 68 - BT_PLUS, 69 - BT_COMMA, 70 - BT_VERBAR 64 + BT_PERCNT, /* percent sign = "%" */ 65 + BT_LPAR, /* left parenthesis = "(" */ 66 + BT_RPAR, /* right parenthesis = "(" */ 67 + BT_AST, /* asterisk = "*" */ 68 + BT_PLUS, /* plus sign = "+" */ 69 + BT_COMMA, /* comma = "," */ 70 + BT_VERBAR /* vertical bar = "|" */ 71 71 }; 72 72 73 73 #include <stddef.h>
Changes to expat/xmltok_ns.c.
29 29 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 30 30 USE OR OTHER DEALINGS IN THE SOFTWARE. 31 31 */ 32 32 33 33 #ifdef XML_TOK_NS_C 34 34 35 35 const ENCODING * 36 -NS(XmlGetUtf8InternalEncoding)(void) 37 -{ 36 +NS(XmlGetUtf8InternalEncoding)(void) { 38 37 return &ns(internal_utf8_encoding).enc; 39 38 } 40 39 41 40 const ENCODING * 42 -NS(XmlGetUtf16InternalEncoding)(void) 43 -{ 44 -#if BYTEORDER == 1234 41 +NS(XmlGetUtf16InternalEncoding)(void) { 42 +# if BYTEORDER == 1234 45 43 return &ns(internal_little2_encoding).enc; 46 -#elif BYTEORDER == 4321 44 +# elif BYTEORDER == 4321 47 45 return &ns(internal_big2_encoding).enc; 48 -#else 46 +# else 49 47 const short n = 1; 50 - return (*(const char *)&n 51 - ? &ns(internal_little2_encoding).enc 52 - : &ns(internal_big2_encoding).enc); 53 -#endif 48 + return (*(const char *)&n ? &ns(internal_little2_encoding).enc 49 + : &ns(internal_big2_encoding).enc); 50 +# endif 54 51 } 55 52 56 -static const ENCODING * const NS(encodings)[] = { 57 - &ns(latin1_encoding).enc, 58 - &ns(ascii_encoding).enc, 59 - &ns(utf8_encoding).enc, 60 - &ns(big2_encoding).enc, 61 - &ns(big2_encoding).enc, 62 - &ns(little2_encoding).enc, 63 - &ns(utf8_encoding).enc /* NO_ENC */ 53 +static const ENCODING *const NS(encodings)[] = { 54 + &ns(latin1_encoding).enc, &ns(ascii_encoding).enc, 55 + &ns(utf8_encoding).enc, &ns(big2_encoding).enc, 56 + &ns(big2_encoding).enc, &ns(little2_encoding).enc, 57 + &ns(utf8_encoding).enc /* NO_ENC */ 64 58 }; 65 59 66 60 static int PTRCALL 67 61 NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, 68 - const char **nextTokPtr) 69 -{ 70 - return initScan(NS(encodings), (const INIT_ENCODING *)enc, 71 - XML_PROLOG_STATE, ptr, end, nextTokPtr); 62 + const char **nextTokPtr) { 63 + return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, 64 + ptr, end, nextTokPtr); 72 65 } 73 66 74 67 static int PTRCALL 75 68 NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, 76 - const char **nextTokPtr) 77 -{ 78 - return initScan(NS(encodings), (const INIT_ENCODING *)enc, 79 - XML_CONTENT_STATE, ptr, end, nextTokPtr); 69 + const char **nextTokPtr) { 70 + return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, 71 + ptr, end, nextTokPtr); 80 72 } 81 73 82 74 int 83 75 NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, 84 - const char *name) 85 -{ 76 + const char *name) { 86 77 int i = getEncodingIndex(name); 87 78 if (i == UNKNOWN_ENC) 88 79 return 0; 89 80 SET_INIT_ENC_INDEX(p, i); 90 81 p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog); 91 82 p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent); 92 83 p->initEnc.updatePosition = initUpdatePosition; 93 84 p->encPtr = encPtr; 94 85 *encPtr = &(p->initEnc); 95 86 return 1; 96 87 } 97 88 98 89 static const ENCODING * 99 -NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) 100 -{ 101 -#define ENCODING_MAX 128 90 +NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) { 91 +# define ENCODING_MAX 128 102 92 char buf[ENCODING_MAX]; 103 93 char *p = buf; 104 94 int i; 105 95 XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); 106 96 if (ptr != end) 107 97 return 0; 108 98 *p = 0; ................................................................................ 111 101 i = getEncodingIndex(buf); 112 102 if (i == UNKNOWN_ENC) 113 103 return 0; 114 104 return NS(encodings)[i]; 115 105 } 116 106 117 107 int 118 -NS(XmlParseXmlDecl)(int isGeneralTextEntity, 119 - const ENCODING *enc, 120 - const char *ptr, 121 - const char *end, 122 - const char **badPtr, 123 - const char **versionPtr, 124 - const char **versionEndPtr, 125 - const char **encodingName, 126 - const ENCODING **encoding, 127 - int *standalone) 128 -{ 129 - return doParseXmlDecl(NS(findEncoding), 130 - isGeneralTextEntity, 131 - enc, 132 - ptr, 133 - end, 134 - badPtr, 135 - versionPtr, 136 - versionEndPtr, 137 - encodingName, 138 - encoding, 139 - standalone); 108 +NS(XmlParseXmlDecl)(int isGeneralTextEntity, const ENCODING *enc, 109 + const char *ptr, const char *end, const char **badPtr, 110 + const char **versionPtr, const char **versionEndPtr, 111 + const char **encodingName, const ENCODING **encoding, 112 + int *standalone) { 113 + return doParseXmlDecl(NS(findEncoding), isGeneralTextEntity, enc, ptr, end, 114 + badPtr, versionPtr, versionEndPtr, encodingName, 115 + encoding, standalone); 140 116 } 141 117 142 118 #endif /* XML_TOK_NS_C */
Deleted extensions/example/mkinstalldirs.
1 -#! /bin/sh 2 -# mkinstalldirs --- make directory hierarchy 3 -# Author: Noah Friedman <friedman@prep.ai.mit.edu> 4 -# Created: 1993-05-16 5 -# Public domain 6 - 7 -# $Id$ 8 - 9 -errstatus=0 10 - 11 -for file 12 -do 13 - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 - shift 15 - 16 - pathcomp= 17 - for d 18 - do 19 - pathcomp="$pathcomp$d" 20 - case "$pathcomp" in 21 - -* ) pathcomp=./$pathcomp ;; 22 - esac 23 - 24 - if test ! -d "$pathcomp"; then 25 - echo "mkdir $pathcomp" 26 - 27 - mkdir "$pathcomp" || lasterr=$? 28 - 29 - if test ! -d "$pathcomp"; then 30 - errstatus=$lasterr 31 - fi 32 - fi 33 - 34 - pathcomp="$pathcomp/" 35 - done 36 -done 37 - 38 -exit $errstatus 39 - 40 -# mkinstalldirs ends here
Added extensions/schemadtx/Makefile.in.
1 +# Makefile.in -- 2 +# 3 +# This file is a Makefile for Sample TEA Extension. If it has the name 4 +# "Makefile.in" then it is a template for a Makefile; to generate the 5 +# actual Makefile, run "./configure", which is a configuration script 6 +# generated by the "autoconf" program (constructs like "@foo@" will get 7 +# replaced in the actual Makefile. 8 +# 9 +# Copyright (c) 1999 Scriptics Corporation. 10 +# Copyright (c) 2002-2005 ActiveState Corporation. 11 +# 12 +# See the file "license.terms" for information on usage and redistribution 13 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. 14 + 15 +#======================================================================== 16 +# Add additional lines to handle any additional AC_SUBST cases that 17 +# have been added in a customized configure script. 18 +#======================================================================== 19 + 20 +#SAMPLE_NEW_VAR = @SAMPLE_NEW_VAR@ 21 + 22 +#======================================================================== 23 +# Nothing of the variables below this line should need to be changed. 24 +# Please check the TARGETS section below to make sure the make targets 25 +# are correct. 26 +#======================================================================== 27 + 28 +#======================================================================== 29 +# The names of the source files is defined in the configure script. 30 +# The object files are used for linking into the final library. 31 +# This will be used when a dist target is added to the Makefile. 32 +# It is not important to specify the directory, as long as it is the 33 +# $(srcdir) or in the generic, win or unix subdirectory. 34 +#======================================================================== 35 + 36 +PKG_SOURCES = @PKG_SOURCES@ 37 +PKG_OBJECTS = @PKG_OBJECTS@ 38 + 39 +PKG_STUB_SOURCES = @PKG_STUB_SOURCES@ 40 +PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@ 41 + 42 +#======================================================================== 43 +# PKG_TCL_SOURCES identifies Tcl runtime files that are associated with 44 +# this package that need to be installed, if any. 45 +#======================================================================== 46 + 47 +PKG_TCL_SOURCES = @PKG_TCL_SOURCES@ 48 + 49 +#======================================================================== 50 +# This is a list of public header files to be installed, if any. 51 +#======================================================================== 52 + 53 +PKG_HEADERS = @PKG_HEADERS@ 54 + 55 +#======================================================================== 56 +# "PKG_LIB_FILE" refers to the library (dynamic or static as per 57 +# configuration options) composed of the named objects. 58 +#======================================================================== 59 + 60 +PKG_LIB_FILE = @PKG_LIB_FILE@ 61 +PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@ 62 + 63 +lib_BINARIES = $(PKG_LIB_FILE) 64 +BINARIES = $(lib_BINARIES) 65 + 66 +SHELL = @SHELL@ 67 + 68 +srcdir = @srcdir@ 69 +prefix = @prefix@ 70 +exec_prefix = @exec_prefix@ 71 + 72 +bindir = @bindir@ 73 +libdir = @libdir@ 74 +includedir = @includedir@ 75 +datarootdir = @datarootdir@ 76 +datadir = @datadir@ 77 +mandir = @mandir@ 78 + 79 +DESTDIR = 80 + 81 +PKG_DIR = $(PACKAGE_NAME)$(PACKAGE_VERSION) 82 +pkgdatadir = $(datadir)/$(PKG_DIR) 83 +pkglibdir = $(libdir)/$(PKG_DIR) 84 +pkgincludedir = $(includedir)/$(PKG_DIR) 85 + 86 +top_builddir = . 87 + 88 +INSTALL_OPTIONS = 89 +INSTALL = $(SHELL) $(srcdir)/tclconfig/install-sh -c ${INSTALL_OPTIONS} 90 +INSTALL_DATA_DIR = ${INSTALL} -d -m 755 91 +INSTALL_PROGRAM = ${INSTALL} -m 555 92 +INSTALL_DATA = ${INSTALL} -m 444 93 +INSTALL_SCRIPT = ${INSTALL_PROGRAM} 94 +INSTALL_LIBRARY = ${INSTALL_DATA} 95 + 96 +PACKAGE_NAME = @PACKAGE_NAME@ 97 +PACKAGE_VERSION = @PACKAGE_VERSION@ 98 +CC = @CC@ 99 +CFLAGS_DEFAULT = @CFLAGS_DEFAULT@ 100 +CFLAGS_WARNING = @CFLAGS_WARNING@ 101 +EXEEXT = @EXEEXT@ 102 +LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@ 103 +MAKE_LIB = @MAKE_LIB@ 104 +MAKE_SHARED_LIB = @MAKE_SHARED_LIB@ 105 +MAKE_STATIC_LIB = @MAKE_STATIC_LIB@ 106 +MAKE_STUB_LIB = @MAKE_STUB_LIB@ 107 +OBJEXT = @OBJEXT@ 108 +RANLIB = @RANLIB@ 109 +RANLIB_STUB = @RANLIB_STUB@ 110 +SHLIB_CFLAGS = @SHLIB_CFLAGS@ 111 +SHLIB_LD = @SHLIB_LD@ 112 +SHLIB_LD_LIBS = @SHLIB_LD_LIBS@ 113 +STLIB_LD = @STLIB_LD@ 114 +#TCL_DEFS = @TCL_DEFS@ 115 +TCL_BIN_DIR = @TCL_BIN_DIR@ 116 +TCL_SRC_DIR = @TCL_SRC_DIR@ 117 +#TK_BIN_DIR = @TK_BIN_DIR@ 118 +#TK_SRC_DIR = @TK_SRC_DIR@ 119 + 120 +# Not used, but retained for reference of what libs Tcl required 121 +#TCL_LIBS = @TCL_LIBS@ 122 + 123 +#======================================================================== 124 +# TCLLIBPATH seeds the auto_path in Tcl's init.tcl so we can test our 125 +# package without installing. The other environment variables allow us 126 +# to test against an uninstalled Tcl. Add special env vars that you 127 +# require for testing here (like TCLX_LIBRARY). 128 +#======================================================================== 129 + 130 +EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR) 131 +#EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR):$(TK_BIN_DIR) 132 +TCLLIBPATH = $(top_builddir) 133 +TCLSH_ENV = TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library` 134 +PKG_ENV = @LD_LIBRARY_PATH_VAR@="$(EXTRA_PATH):$(@LD_LIBRARY_PATH_VAR@)" \ 135 + PATH="$(EXTRA_PATH):$(PATH)" \ 136 + TCLLIBPATH="$(TCLLIBPATH)" 137 + 138 +TCLSH_PROG = @TCLSH_PROG@ 139 +TCLSH = $(PKG_ENV) $(TCLSH_ENV) $(TCLSH_PROG) 140 + 141 +#WISH_ENV = TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library` 142 +#WISH_PROG = @WISH_PROG@ 143 +#WISH = $(PKG_ENV) $(TCLSH_ENV) $(WISH_ENV) $(WISH_PROG) 144 + 145 +SHARED_BUILD = @SHARED_BUILD@ 146 + 147 +INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ 148 +#INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ @TK_INCLUDES@ @TK_XINCLUDES@ 149 + 150 +PKG_CFLAGS = @PKG_CFLAGS@ 151 + 152 +# TCL_DEFS is not strictly need here, but if you remove it, then you 153 +# must make sure that configure.in checks for the necessary components 154 +# that your library may use. TCL_DEFS can actually be a problem if 155 +# you do not compile with a similar machine setup as the Tcl core was 156 +# compiled with. 157 +#DEFS = $(TCL_DEFS) @DEFS@ $(PKG_CFLAGS) 158 +DEFS = @DEFS@ $(PKG_CFLAGS) 159 + 160 +# Move pkgIndex.tcl to 'BINARIES' var if it is generated in the Makefile 161 +CONFIG_CLEAN_FILES = Makefile pkgIndex.tcl 162 +CLEANFILES = @CLEANFILES@ 163 + 164 +CPPFLAGS = @CPPFLAGS@ 165 +LIBS = @PKG_LIBS@ @LIBS@ 166 +AR = @AR@ 167 +CFLAGS = @CFLAGS@ 168 +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 169 + 170 +.SUFFIXES: .c .$(OBJEXT) 171 + 172 +#======================================================================== 173 +# Start of user-definable TARGETS section 174 +#======================================================================== 175 + 176 +#======================================================================== 177 +# TEA TARGETS. Please note that the "libraries:" target refers to platform 178 +# independent files, and the "binaries:" target includes executable programs and 179 +# platform-dependent libraries. Modify these targets so that they install 180 +# the various pieces of your package. The make and install rules 181 +# for the BINARIES that you specified above have already been done. 182 +#======================================================================== 183 + 184 +all: binaries libraries doc 185 + 186 +#======================================================================== 187 +# The binaries target builds executable programs, Windows .dll's, unix 188 +# shared/static libraries, and any other platform-dependent files. 189 +# The list of targets to build for "binaries:" is specified at the top 190 +# of the Makefile, in the "BINARIES" variable. 191 +#======================================================================== 192 + 193 +binaries: $(BINARIES) 194 + 195 +libraries: 196 + 197 +#======================================================================== 198 +# Your doc target should differentiate from doc builds (by the developer) 199 +# and doc installs (see install-doc), which just install the docs on the 200 +# end user machine when building from source. 201 +#======================================================================== 202 + 203 +doc: 204 + @echo "If you have documentation to create, place the commands to" 205 + @echo "build the docs in the 'doc:' target. For example:" 206 + @echo " xml2nroff sample.xml > sample.n" 207 + @echo " xml2html sample.xml > sample.html" 208 + 209 +install: all install-binaries install-libraries install-doc 210 + 211 +install-binaries: binaries install-lib-binaries install-bin-binaries 212 + 213 +#======================================================================== 214 +# This rule installs platform-independent files, such as header files. 215 +# The list=...; for p in $$list handles the empty list case x-platform. 216 +#======================================================================== 217 + 218 +install-libraries: libraries 219 + @$(INSTALL_DATA_DIR) $(DESTDIR)$(includedir) 220 + @echo "Installing header files in $(DESTDIR)$(includedir)" 221 + @list='$(PKG_HEADERS)'; for i in $$list; do \ 222 + echo "Installing $(srcdir)/$$i" ; \ 223 + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir) ; \ 224 + done; 225 + 226 +#======================================================================== 227 +# Install documentation. Unix manpages should go in the $(mandir) 228 +# directory. 229 +#======================================================================== 230 + 231 +install-doc: doc 232 + @$(INSTALL_DATA_DIR) $(DESTDIR)$(mandir)/mann 233 + @echo "Installing documentation in $(DESTDIR)$(mandir)" 234 + @list='$(srcdir)/doc/*.n'; for i in $$list; do \ 235 + echo "Installing $$i"; \ 236 + $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/mann ; \ 237 + done 238 + 239 +test: binaries libraries 240 + $(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS) 241 + 242 +shell: binaries libraries 243 + @$(TCLSH) $(SCRIPT) 244 + 245 +gdb: 246 + $(TCLSH_ENV) gdb $(TCLSH_PROG) $(SCRIPT) 247 + 248 +VALGRINDARGS = --tool=memcheck --num-callers=8 --leak-resolution=high \ 249 + --leak-check=yes --show-reachable=yes -v 250 + 251 +valgrind: binaries libraries 252 + $(TCLSH_ENV) valgrind $(VALGRINDARGS) $(TCLSH_PROG) \ 253 + `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS) 254 + 255 +valgrindshell: binaries libraries 256 + $(TCLSH_ENV) valgrind $(VALGRINDARGS) $(TCLSH_PROG) $(SCRIPT) 257 + 258 +depend: 259 + 260 +#======================================================================== 261 +# $(PKG_LIB_FILE) should be listed as part of the BINARIES variable 262 +# mentioned above. That will ensure that this target is built when you 263 +# run "make binaries". 264 +# 265 +# The $(PKG_OBJECTS) objects are created and linked into the final 266 +# library. In most cases these object files will correspond to the 267 +# source files above. 268 +#======================================================================== 269 + 270 +$(PKG_LIB_FILE): $(PKG_OBJECTS) 271 + -rm -f $(PKG_LIB_FILE) 272 + ${MAKE_LIB} 273 + $(RANLIB) $(PKG_LIB_FILE) 274 + 275 +$(PKG_STUB_LIB_FILE): $(PKG_STUB_OBJECTS) 276 + -rm -f $(PKG_STUB_LIB_FILE) 277 + ${MAKE_STUB_LIB} 278 + $(RANLIB_STUB) $(PKG_STUB_LIB_FILE) 279 + 280 +#======================================================================== 281 +# We need to enumerate the list of .c to .o lines here. 282 +# 283 +# In the following lines, $(srcdir) refers to the toplevel directory 284 +# containing your extension. If your sources are in a subdirectory, 285 +# you will have to modify the paths to reflect this: 286 +# 287 +# sample.$(OBJEXT): $(srcdir)/generic/sample.c 288 +# $(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@ 289 +# 290 +# Setting the VPATH variable to a list of paths will cause the makefile 291 +# to look into these paths when resolving .c to .obj dependencies. 292 +# As necessary, add $(srcdir):$(srcdir)/compat:.... 293 +#======================================================================== 294 + 295 +VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win:$(srcdir)/macosx 296 + 297 +.c.@OBJEXT@: 298 + $(COMPILE) -c `@CYGPATH@ $<` -o $@ 299 + 300 +#======================================================================== 301 +# Distribution creation 302 +# You may need to tweak this target to make it work correctly. 303 +#======================================================================== 304 + 305 +#COMPRESS = tar cvf $(PKG_DIR).tar $(PKG_DIR); compress $(PKG_DIR).tar 306 +COMPRESS = tar zcvf $(PKG_DIR).tar.gz $(PKG_DIR) 307 +DIST_ROOT = /tmp/dist 308 +DIST_DIR = $(DIST_ROOT)/$(PKG_DIR) 309 + 310 +dist-clean: 311 + rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.* 312 + 313 +dist: dist-clean 314 + mkdir -p $(DIST_DIR) 315 + cp -p $(srcdir)/ChangeLog $(srcdir)/README* $(srcdir)/license* \ 316 + $(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/*.in \ 317 + $(DIST_DIR)/ 318 + chmod 664 $(DIST_DIR)/Makefile.in $(DIST_DIR)/aclocal.m4 319 + chmod 775 $(DIST_DIR)/configure $(DIST_DIR)/configure.in 320 + 321 + for i in $(srcdir)/*.[ch]; do \ 322 + if [ -f $$i ]; then \ 323 + cp -p $$i $(DIST_DIR)/ ; \ 324 + fi; \ 325 + done; 326 + 327 + mkdir $(DIST_DIR)/tclconfig 328 + cp $(srcdir)/tclconfig/install-sh $(srcdir)/tclconfig/tcl.m4 \ 329 + $(DIST_DIR)/tclconfig/ 330 + chmod 664 $(DIST_DIR)/tclconfig/tcl.m4 331 + chmod +x $(DIST_DIR)/tclconfig/install-sh 332 + 333 + list='demos doc generic library mac tests unix win'; \ 334 + for p in $$list; do \ 335 + if test -d $(srcdir)/$$p ; then \ 336 + mkdir $(DIST_DIR)/$$p; \ 337 + cp -p $(srcdir)/$$p/*.* $(DIST_DIR)/$$p/; \ 338 + fi; \ 339 + done 340 + 341 + (cd $(DIST_ROOT); $(COMPRESS);) 342 + 343 +#======================================================================== 344 +# End of user-definable section 345 +#======================================================================== 346 + 347 +#======================================================================== 348 +# Don't modify the file to clean here. Instead, set the "CLEANFILES" 349 +# variable in configure.in 350 +#======================================================================== 351 + 352 +clean: 353 + -test -z "$(BINARIES)" || rm -f $(BINARIES) 354 + -rm -f *.$(OBJEXT) core *.core 355 + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 356 + 357 +distclean: clean 358 + -rm -f *.tab.c 359 + -rm -f $(CONFIG_CLEAN_FILES) 360 + -rm -f config.cache config.log config.status 361 + 362 +#======================================================================== 363 +# Install binary object libraries. On Windows this includes both .dll and 364 +# .lib files. Because the .lib files are not explicitly listed anywhere, 365 +# we need to deduce their existence from the .dll file of the same name. 366 +# Library files go into the lib directory. 367 +# In addition, this will generate the pkgIndex.tcl 368 +# file in the install location (assuming it can find a usable tclsh shell) 369 +# 370 +# You should not have to modify this target. 371 +#======================================================================== 372 + 373 +install-lib-binaries: binaries 374 + @$(INSTALL_DATA_DIR) $(DESTDIR)$(pkglibdir) 375 + @list='$(lib_BINARIES)'; for p in $$list; do \ 376 + if test -f $$p; then \ 377 + echo " $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p"; \ 378 + $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p; \ 379 + stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \ 380 + if test "x$$stub" = "xstub"; then \ 381 + echo " $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p"; \ 382 + $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p; \ 383 + else \ 384 + echo " $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p"; \ 385 + $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p; \ 386 + fi; \ 387 + ext=`echo $$p|sed -e "s/.*\.//"`; \ 388 + if test "x$$ext" = "xdll"; then \ 389 + lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \ 390 + if test -f $$lib; then \ 391 + echo " $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib"; \ 392 + $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib; \ 393 + fi; \ 394 + fi; \ 395 + fi; \ 396 + done 397 + @list='$(PKG_TCL_SOURCES)'; for p in $$list; do \ 398 + if test -f $(srcdir)/$$p; then \ 399 + destp=`basename $$p`; \ 400 + echo " Install $$destp $(DESTDIR)$(pkglibdir)/$$destp"; \ 401 + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkglibdir)/$$destp; \ 402 + fi; \ 403 + done 404 + @if test "x$(SHARED_BUILD)" = "x1"; then \ 405 + echo " Install pkgIndex.tcl $(DESTDIR)$(pkglibdir)"; \ 406 + $(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir); \ 407 + fi 408 + 409 +#======================================================================== 410 +# Install binary executables (e.g. .exe files and dependent .dll files) 411 +# This is for files that must go in the bin directory (located next to 412 +# wish and tclsh), like dependent .dll files on Windows. 413 +# 414 +# You should not have to modify this target, except to define bin_BINARIES 415 +# above if necessary. 416 +#======================================================================== 417 + 418 +install-bin-binaries: binaries 419 + @$(INSTALL_DATA_DIR) $(DESTDIR)$(bindir) 420 + @list='$(bin_BINARIES)'; for p in $$list; do \ 421 + if test -f $$p; then \ 422 + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p"; \ 423 + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p; \ 424 + fi; \ 425 + done 426 + 427 +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 428 + cd $(top_builddir) \ 429 + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status 430 + 431 +uninstall-binaries: 432 + list='$(lib_BINARIES)'; for p in $$list; do \ 433 + rm -f $(DESTDIR)$(pkglibdir)/$$p; \ 434 + done 435 + list='$(PKG_TCL_SOURCES)'; for p in $$list; do \ 436 + p=`basename $$p`; \ 437 + rm -f $(DESTDIR)$(pkglibdir)/$$p; \ 438 + done 439 + list='$(bin_BINARIES)'; for p in $$list; do \ 440 + rm -f $(DESTDIR)$(bindir)/$$p; \ 441 + done 442 + 443 +.PHONY: all binaries clean depend distclean doc install libraries test 444 + 445 +# Tell versions [3.59,3.63) of GNU make to not export all variables. 446 +# Otherwise a system limit (for SysV at least) may be exceeded. 447 +.NOEXPORT:
Added extensions/schemadtx/aclocal.m4.
1 +# 2 +# Include the TEA standard macro set 3 +# 4 +builtin(include,../../tclconfig/tcl.m4) 5 + 6 +# 7 +# Add here whatever m4 macros you want to define for your package 8 +# 9 +builtin(include,../../tdom.m4)
Added extensions/schemadtx/configure.
1 +#! /bin/sh 2 +# Guess values for system-dependent variables and create Makefiles. 3 +# Generated by GNU Autoconf 2.69 for schemadtx 1.0. 4 +# 5 +# 6 +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. 7 +# 8 +# 9 +# This configure script is free software; the Free Software Foundation 10 +# gives unlimited permission to copy, distribute and modify it. 11 +## -------------------- ## 12 +## M4sh Initialization. ## 13 +## -------------------- ## 14 + 15 +# Be more Bourne compatible 16 +DUALCASE=1; export DUALCASE # for MKS sh 17 +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 18 + emulate sh 19 + NULLCMD=: 20 + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 21 + # is contrary to our usage. Disable this feature. 22 + alias -g '${1+"$@"}'='"$@"' 23 + setopt NO_GLOB_SUBST 24 +else 25 + case `(set -o) 2>/dev/null` in #( 26 + *posix*) : 27 + set -o posix ;; #( 28 + *) : 29 + ;; 30 +esac 31 +fi 32 + 33 + 34 +as_nl=' 35 +' 36 +export as_nl 37 +# Printing a long string crashes Solaris 7 /usr/bin/printf. 38 +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' 39 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo 40 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo 41 +# Prefer a ksh shell builtin over an external printf program on Solaris, 42 +# but without wasting forks for bash or zsh. 43 +if test -z "$BASH_VERSION$ZSH_VERSION" \ 44 + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then 45 + as_echo='print -r --' 46 + as_echo_n='print -rn --' 47 +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then 48 + as_echo='printf %s\n' 49 + as_echo_n='printf %s' 50 +else 51 + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then 52 + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' 53 + as_echo_n='/usr/ucb/echo -n' 54 + else 55 + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' 56 + as_echo_n_body='eval 57 + arg=$1; 58 + case $arg in #( 59 + *"$as_nl"*) 60 + expr "X$arg" : "X\\(.*\\)$as_nl"; 61 + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; 62 + esac; 63 + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" 64 + ' 65 + export as_echo_n_body 66 + as_echo_n='sh -c $as_echo_n_body as_echo' 67 + fi 68 + export as_echo_body 69 + as_echo='sh -c $as_echo_body as_echo' 70 +fi 71 + 72 +# The user is always right. 73 +if test "${PATH_SEPARATOR+set}" != set; then 74 + PATH_SEPARATOR=: 75 + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 76 + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 77 + PATH_SEPARATOR=';' 78 + } 79 +fi 80 + 81 + 82 +# IFS 83 +# We need space, tab and new line, in precisely that order. Quoting is 84 +# there to prevent editors from complaining about space-tab. 85 +# (If _AS_PATH_WALK were called with IFS unset, it would disable word 86 +# splitting by setting IFS to empty value.) 87 +IFS=" "" $as_nl" 88 + 89 +# Find who we are. Look in the path if we contain no directory separator. 90 +as_myself= 91 +case $0 in #(( 92 + *[\\/]* ) as_myself=$0 ;; 93 + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 94 +for as_dir in $PATH 95 +do 96 + IFS=$as_save_IFS 97 + test -z "$as_dir" && as_dir=. 98 + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break 99 + done 100 +IFS=$as_save_IFS 101 + 102 + ;; 103 +esac 104 +# We did not find ourselves, most probably we were run as `sh COMMAND' 105 +# in which case we are not to be found in the path. 106 +if test "x$as_myself" = x; then 107 + as_myself=$0 108 +fi 109 +if test ! -f "$as_myself"; then 110 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 111 + exit 1 112 +fi 113 + 114 +# Unset variables that we do not need and which cause bugs (e.g. in 115 +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" 116 +# suppresses any "Segmentation fault" message there. '((' could 117 +# trigger a bug in pdksh 5.2.14. 118 +for as_var in BASH_ENV ENV MAIL MAILPATH 119 +do eval test x\${$as_var+set} = xset \ 120 + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : 121 +done 122 +PS1='$ ' 123 +PS2='> ' 124 +PS4='+ ' 125 + 126 +# NLS nuisances. 127 +LC_ALL=C 128 +export LC_ALL 129 +LANGUAGE=C 130 +export LANGUAGE 131 + 132 +# CDPATH. 133 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 134 + 135 +# Use a proper internal environment variable to ensure we don't fall 136 + # into an infinite loop, continuously re-executing ourselves. 137 + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then 138 + _as_can_reexec=no; export _as_can_reexec; 139 + # We cannot yet assume a decent shell, so we have to provide a 140 +# neutralization value for shells without unset; and this also 141 +# works around shells that cannot unset nonexistent variables. 142 +# Preserve -v and -x to the replacement shell. 143 +BASH_ENV=/dev/null 144 +ENV=/dev/null 145 +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV 146 +case $- in # (((( 147 + *v*x* | *x*v* ) as_opts=-vx ;; 148 + *v* ) as_opts=-v ;; 149 + *x* ) as_opts=-x ;; 150 + * ) as_opts= ;; 151 +esac 152 +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} 153 +# Admittedly, this is quite paranoid, since all the known shells bail 154 +# out after a failed `exec'. 155 +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 156 +as_fn_exit 255 157 + fi 158 + # We don't want this to propagate to other subprocesses. 159 + { _as_can_reexec=; unset _as_can_reexec;} 160 +if test "x$CONFIG_SHELL" = x; then 161 + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : 162 + emulate sh 163 + NULLCMD=: 164 + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which 165 + # is contrary to our usage. Disable this feature. 166 + alias -g '\${1+\"\$@\"}'='\"\$@\"' 167 + setopt NO_GLOB_SUBST 168 +else 169 + case \`(set -o) 2>/dev/null\` in #( 170 + *posix*) : 171 + set -o posix ;; #( 172 + *) : 173 + ;; 174 +esac 175 +fi 176 +" 177 + as_required="as_fn_return () { (exit \$1); } 178 +as_fn_success () { as_fn_return 0; } 179 +as_fn_failure () { as_fn_return 1; } 180 +as_fn_ret_success () { return 0; } 181 +as_fn_ret_failure () { return 1; } 182 + 183 +exitcode=0 184 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } 185 +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } 186 +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } 187 +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } 188 +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : 189 + 190 +else 191 + exitcode=1; echo positional parameters were not saved. 192 +fi 193 +test x\$exitcode = x0 || exit 1 194 +test -x / || exit 1" 195 + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO 196 + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO 197 + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && 198 + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 199 +test \$(( 1 + 1 )) = 2 || exit 1" 200 + if (eval "$as_required") 2>/dev/null; then : 201 + as_have_required=yes 202 +else 203 + as_have_required=no 204 +fi 205 + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : 206 + 207 +else 208 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 209 +as_found=false 210 +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH 211 +do 212 + IFS=$as_save_IFS 213 + test -z "$as_dir" && as_dir=. 214 + as_found=: 215 + case $as_dir in #( 216 + /*) 217 + for as_base in sh bash ksh sh5; do 218 + # Try only shells that exist, to save several forks. 219 + as_shell=$as_dir/$as_base 220 + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && 221 + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : 222 + CONFIG_SHELL=$as_shell as_have_required=yes 223 + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : 224 + break 2 225 +fi 226 +fi 227 + done;; 228 + esac 229 + as_found=false 230 +done 231 +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && 232 + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : 233 + CONFIG_SHELL=$SHELL as_have_required=yes 234 +fi; } 235 +IFS=$as_save_IFS 236 + 237 + 238 + if test "x$CONFIG_SHELL" != x; then : 239 + export CONFIG_SHELL 240 + # We cannot yet assume a decent shell, so we have to provide a 241 +# neutralization value for shells without unset; and this also 242 +# works around shells that cannot unset nonexistent variables. 243 +# Preserve -v and -x to the replacement shell. 244 +BASH_ENV=/dev/null 245 +ENV=/dev/null 246 +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV 247 +case $- in # (((( 248 + *v*x* | *x*v* ) as_opts=-vx ;; 249 + *v* ) as_opts=-v ;; 250 + *x* ) as_opts=-x ;; 251 + * ) as_opts= ;; 252 +esac 253 +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} 254 +# Admittedly, this is quite paranoid, since all the known shells bail 255 +# out after a failed `exec'. 256 +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 257 +exit 255 258 +fi 259 + 260 + if test x$as_have_required = xno; then : 261 + $as_echo "$0: This script requires a shell more modern than all" 262 + $as_echo "$0: the shells that I found on your system." 263 + if test x${ZSH_VERSION+set} = xset ; then 264 + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" 265 + $as_echo "$0: be upgraded to zsh 4.3.4 or later." 266 + else 267 + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, 268 +$0: including any error possibly output before this 269 +$0: message. Then install a modern shell, or manually run 270 +$0: the script under such a shell if you do have one." 271 + fi 272 + exit 1 273 +fi 274 +fi 275 +fi 276 +SHELL=${CONFIG_SHELL-/bin/sh} 277 +export SHELL 278 +# Unset more variables known to interfere with behavior of common tools. 279 +CLICOLOR_FORCE= GREP_OPTIONS= 280 +unset CLICOLOR_FORCE GREP_OPTIONS 281 + 282 +## --------------------- ## 283 +## M4sh Shell Functions. ## 284 +## --------------------- ## 285 +# as_fn_unset VAR 286 +# --------------- 287 +# Portably unset VAR. 288 +as_fn_unset () 289 +{ 290 + { eval $1=; unset $1;} 291 +} 292 +as_unset=as_fn_unset 293 + 294 +# as_fn_set_status STATUS 295 +# ----------------------- 296 +# Set $? to STATUS, without forking. 297 +as_fn_set_status () 298 +{ 299 + return $1 300 +} # as_fn_set_status 301 + 302 +# as_fn_exit STATUS 303 +# ----------------- 304 +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. 305 +as_fn_exit () 306 +{ 307 + set +e 308 + as_fn_set_status $1 309 + exit $1 310 +} # as_fn_exit 311 + 312 +# as_fn_mkdir_p 313 +# ------------- 314 +# Create "$as_dir" as a directory, including parents if necessary. 315 +as_fn_mkdir_p () 316 +{ 317 + 318 + case $as_dir in #( 319 + -*) as_dir=./$as_dir;; 320 + esac 321 + test -d "$as_dir" || eval $as_mkdir_p || { 322 + as_dirs= 323 + while :; do 324 + case $as_dir in #( 325 + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( 326 + *) as_qdir=$as_dir;; 327 + esac 328 + as_dirs="'$as_qdir' $as_dirs" 329 + as_dir=`$as_dirname -- "$as_dir" || 330 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 331 + X"$as_dir" : 'X\(//\)[^/]' \| \ 332 + X"$as_dir" : 'X\(//\)$' \| \ 333 + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || 334 +$as_echo X"$as_dir" | 335 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 336 + s//\1/ 337 + q 338 + } 339 + /^X\(\/\/\)[^/].*/{ 340 + s//\1/ 341 + q 342 + } 343 + /^X\(\/\/\)$/{ 344 + s//\1/ 345 + q 346 + } 347 + /^X\(\/\).*/{ 348 + s//\1/ 349 + q 350 + } 351 + s/.*/./; q'` 352 + test -d "$as_dir" && break 353 + done 354 + test -z "$as_dirs" || eval "mkdir $as_dirs" 355 + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" 356 + 357 + 358 +} # as_fn_mkdir_p 359 + 360 +# as_fn_executable_p FILE 361 +# ----------------------- 362 +# Test if FILE is an executable regular file. 363 +as_fn_executable_p () 364 +{ 365 + test -f "$1" && test -x "$1" 366 +} # as_fn_executable_p 367 +# as_fn_append VAR VALUE 368 +# ---------------------- 369 +# Append the text in VALUE to the end of the definition contained in VAR. Take 370 +# advantage of any shell optimizations that allow amortized linear growth over 371 +# repeated appends, instead of the typical quadratic growth present in naive 372 +# implementations. 373 +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : 374 + eval 'as_fn_append () 375 + { 376 + eval $1+=\$2 377 + }' 378 +else 379 + as_fn_append () 380 + { 381 + eval $1=\$$1\$2 382 + } 383 +fi # as_fn_append 384 + 385 +# as_fn_arith ARG... 386 +# ------------------ 387 +# Perform arithmetic evaluation on the ARGs, and store the result in the 388 +# global $as_val. Take advantage of shells that can avoid forks. The arguments 389 +# must be portable across $(()) and expr. 390 +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : 391 + eval 'as_fn_arith () 392 + { 393 + as_val=$(( $* )) 394 + }' 395 +else 396 + as_fn_arith () 397 + { 398 + as_val=`expr "$@" || test $? -eq 1` 399 + } 400 +fi # as_fn_arith 401 + 402 + 403 +# as_fn_error STATUS ERROR [LINENO LOG_FD] 404 +# ---------------------------------------- 405 +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are 406 +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the 407 +# script with STATUS, using 1 if that was 0. 408 +as_fn_error () 409 +{ 410 + as_status=$1; test $as_status -eq 0 && as_status=1 411 + if test "$4"; then 412 + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 413 + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 414 + fi 415 + $as_echo "$as_me: error: $2" >&2 416 + as_fn_exit $as_status 417 +} # as_fn_error 418 + 419 +if expr a : '\(a\)' >/dev/null 2>&1 && 420 + test "X`expr 00001 : '.*\(...\)'`" = X001; then 421 + as_expr=expr 422 +else 423 + as_expr=false 424 +fi 425 + 426 +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then 427 + as_basename=basename 428 +else 429 + as_basename=false 430 +fi 431 + 432 +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then 433 + as_dirname=dirname 434 +else 435 + as_dirname=false 436 +fi 437 + 438 +as_me=`$as_basename -- "$0" || 439 +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ 440 + X"$0" : 'X\(//\)$' \| \ 441 + X"$0" : 'X\(/\)' \| . 2>/dev/null || 442 +$as_echo X/"$0" | 443 + sed '/^.*\/\([^/][^/]*\)\/*$/{ 444 + s//\1/ 445 + q 446 + } 447 + /^X\/\(\/\/\)$/{ 448 + s//\1/ 449 + q 450 + } 451 + /^X\/\(\/\).*/{ 452 + s//\1/ 453 + q 454 + } 455 + s/.*/./; q'` 456 + 457 +# Avoid depending upon Character Ranges. 458 +as_cr_letters='abcdefghijklmnopqrstuvwxyz' 459 +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' 460 +as_cr_Letters=$as_cr_letters$as_cr_LETTERS 461 +as_cr_digits='0123456789' 462 +as_cr_alnum=$as_cr_Letters$as_cr_digits 463 + 464 + 465 + as_lineno_1=$LINENO as_lineno_1a=$LINENO 466 + as_lineno_2=$LINENO as_lineno_2a=$LINENO 467 + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && 468 + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { 469 + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) 470 + sed -n ' 471 + p 472 + /[$]LINENO/= 473 + ' <$as_myself | 474 + sed ' 475 + s/[$]LINENO.*/&-/ 476 + t lineno 477 + b 478 + :lineno 479 + N 480 + :loop 481 + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ 482 + t loop 483 + s/-\n.*// 484 + ' >$as_me.lineno && 485 + chmod +x "$as_me.lineno" || 486 + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } 487 + 488 + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have 489 + # already done that, so ensure we don't try to do so again and fall 490 + # in an infinite loop. This has already happened in practice. 491 + _as_can_reexec=no; export _as_can_reexec 492 + # Don't try to exec as it changes $[0], causing all sort of problems 493 + # (the dirname of $[0] is not the place where we might find the 494 + # original and so on. Autoconf is especially sensitive to this). 495 + . "./$as_me.lineno" 496 + # Exit status is that of the last command. 497 + exit 498 +} 499 + 500 +ECHO_C= ECHO_N= ECHO_T= 501 +case `echo -n x` in #((((( 502 +-n*) 503 + case `echo 'xy\c'` in 504 + *c*) ECHO_T=' ';; # ECHO_T is single tab character. 505 + xy) ECHO_C='\c';; 506 + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null 507 + ECHO_T=' ';; 508 + esac;; 509 +*) 510 + ECHO_N='-n';; 511 +esac 512 + 513 +rm -f conf$$ conf$$.exe conf$$.file 514 +if test -d conf$$.dir; then 515 + rm -f conf$$.dir/conf$$.file 516 +else 517 + rm -f conf$$.dir 518 + mkdir conf$$.dir 2>/dev/null 519 +fi 520 +if (echo >conf$$.file) 2>/dev/null; then 521 + if ln -s conf$$.file conf$$ 2>/dev/null; then 522 + as_ln_s='ln -s' 523 + # ... but there are two gotchas: 524 + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. 525 + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. 526 + # In both cases, we have to default to `cp -pR'. 527 + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || 528 + as_ln_s='cp -pR' 529 + elif ln conf$$.file conf$$ 2>/dev/null; then 530 + as_ln_s=ln 531 + else 532 + as_ln_s='cp -pR' 533 + fi 534 +else 535 + as_ln_s='cp -pR' 536 +fi 537 +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file 538 +rmdir conf$$.dir 2>/dev/null 539 + 540 +if mkdir -p . 2>/dev/null; then 541 + as_mkdir_p='mkdir -p "$as_dir"' 542 +else 543 + test -d ./-p && rmdir ./-p 544 + as_mkdir_p=false 545 +fi 546 + 547 +as_test_x='test -x' 548 +as_executable_p=as_fn_executable_p 549 + 550 +# Sed expression to map a string onto a valid CPP name. 551 +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" 552 + 553 +# Sed expression to map a string onto a valid variable name. 554 +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" 555 + 556 + 557 +test -n "$DJDIR" || exec 7<&0 </dev/null 558 +exec 6>&1 559 + 560 +# Name of the host. 561 +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, 562 +# so uname gets run too. 563 +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` 564 + 565 +# 566 +# Initializations. 567 +# 568 +ac_default_prefix=/usr/local 569 +ac_clean_files= 570 +ac_config_libobj_dir=. 571 +LIBOBJS= 572 +cross_compiling=no 573 +subdirs= 574 +MFLAGS= 575 +MAKEFLAGS= 576 + 577 +# Identity of this package. 578 +PACKAGE_NAME='schemadtx' 579 +PACKAGE_TARNAME='schemadtx' 580 +PACKAGE_VERSION='1.0' 581 +PACKAGE_STRING='schemadtx 1.0' 582 +PACKAGE_BUGREPORT='' 583 +PACKAGE_URL='' 584 + 585 +# Factoring default headers for most tests. 586 +ac_includes_default="\ 587 +#include <stdio.h> 588 +#ifdef HAVE_SYS_TYPES_H 589 +# include <sys/types.h> 590 +#endif 591 +#ifdef HAVE_SYS_STAT_H 592 +# include <sys/stat.h> 593 +#endif 594 +#ifdef STDC_HEADERS 595 +# include <stdlib.h> 596 +# include <stddef.h> 597 +#else 598 +# ifdef HAVE_STDLIB_H 599 +# include <stdlib.h> 600 +# endif 601 +#endif 602 +#ifdef HAVE_STRING_H 603 +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H 604 +# include <memory.h> 605 +# endif 606 +# include <string.h> 607 +#endif 608 +#ifdef HAVE_STRINGS_H 609 +# include <strings.h> 610 +#endif 611 +#ifdef HAVE_INTTYPES_H 612 +# include <inttypes.h> 613 +#endif 614 +#ifdef HAVE_STDINT_H 615 +# include <stdint.h> 616 +#endif 617 +#ifdef HAVE_UNISTD_H 618 +# include <unistd.h> 619 +#endif" 620 + 621 +ac_subst_vars='LTLIBOBJS 622 +LIBOBJS 623 +TCLSH_PROG 624 +VC_MANIFEST_EMBED_EXE 625 +VC_MANIFEST_EMBED_DLL 626 +RANLIB_STUB 627 +MAKE_STUB_LIB 628 +MAKE_STATIC_LIB 629 +MAKE_SHARED_LIB 630 +MAKE_LIB 631 +TCL_DBGX 632 +LDFLAGS_DEFAULT 633 +CFLAGS_DEFAULT 634 +LD_LIBRARY_PATH_VAR 635 +SHLIB_CFLAGS 636 +SHLIB_LD_LIBS 637 +SHLIB_LD 638 +STLIB_LD 639 +CFLAGS_WARNING 640 +CFLAGS_OPTIMIZE 641 +CFLAGS_DEBUG 642 +RC 643 +CELIB_DIR 644 +AR 645 +STUBS_BUILD 646 +SHARED_BUILD 647 +TCL_THREADS 648 +TCL_INCLUDES 649 +PKG_OBJECTS 650 +PKG_SOURCES 651 +TDOM_SRC_DIR 652 +TDOM_STUB_LIB_SPEC 653 +TDOM_VERSION 654 +EGREP 655 +GREP 656 +RANLIB 657 +SET_MAKE 658 +CPP 659 +TCL_SHLIB_LD_LIBS 660 +TCL_LD_FLAGS 661 +TCL_EXTRA_CFLAGS 662 +TCL_DEFS 663 +TCL_LIBS 664 +CLEANFILES 665 +OBJEXT 666 +ac_ct_CC 667 +CPPFLAGS 668 +LDFLAGS 669 +CFLAGS 670 +CC 671 +TCL_STUB_LIB_SPEC 672 +TCL_STUB_LIB_FLAG 673 +TCL_STUB_LIB_FILE 674 +TCL_LIB_SPEC 675 +TCL_LIB_FLAG 676 +TCL_LIB_FILE 677 +TCL_SRC_DIR 678 +TCL_BIN_DIR 679 +TCL_PATCH_LEVEL 680 +TCL_VERSION 681 +INSTALL_LIBRARY 682 +INSTALL_SCRIPT 683 +INSTALL_PROGRAM 684 +INSTALL_DATA 685 +INSTALL_DATA_DIR 686 +INSTALL 687 +PKG_CFLAGS 688 +PKG_LIBS 689 +PKG_INCLUDES 690 +PKG_HEADERS 691 +PKG_TCL_SOURCES 692 +PKG_STUB_OBJECTS 693 +PKG_STUB_SOURCES 694 +PKG_STUB_LIB_FILE 695 +PKG_LIB_FILE 696 +EXEEXT 697 +CYGPATH 698 +target_alias 699 +host_alias 700 +build_alias 701 +LIBS 702 +ECHO_T 703 +ECHO_N 704 +ECHO_C 705 +DEFS 706 +mandir 707 +localedir 708 +libdir 709 +psdir 710 +pdfdir 711 +dvidir 712 +htmldir 713 +infodir 714 +docdir 715 +oldincludedir 716 +includedir 717 +runstatedir 718 +localstatedir 719 +sharedstatedir 720 +sysconfdir 721 +datadir 722 +datarootdir 723 +libexecdir 724 +sbindir 725 +bindir 726 +program_transform_name 727 +prefix 728 +exec_prefix 729 +PACKAGE_URL 730 +PACKAGE_BUGREPORT 731 +PACKAGE_STRING 732 +PACKAGE_VERSION 733 +PACKAGE_TARNAME 734 +PACKAGE_NAME 735 +PATH_SEPARATOR 736 +SHELL' 737 +ac_subst_files='' 738 +ac_user_opts=' 739 +enable_option_checking 740 +with_tcl 741 +with_tdom 742 +with_tclinclude 743 +enable_threads 744 +enable_shared 745 +enable_stubs 746 +enable_64bit 747 +enable_64bit_vis 748 +enable_rpath 749 +enable_wince 750 +with_celib 751 +enable_symbols 752 +' 753 + ac_precious_vars='build_alias 754 +host_alias 755 +target_alias 756 +CC 757 +CFLAGS 758 +LDFLAGS 759 +LIBS 760 +CPPFLAGS 761 +CPP' 762 + 763 + 764 +# Initialize some variables set by options. 765 +ac_init_help= 766 +ac_init_version=false 767 +ac_unrecognized_opts= 768 +ac_unrecognized_sep= 769 +# The variables have the same names as the options, with 770 +# dashes changed to underlines. 771 +cache_file=/dev/null 772 +exec_prefix=NONE 773 +no_create= 774 +no_recursion= 775 +prefix=NONE 776 +program_prefix=NONE 777 +program_suffix=NONE 778 +program_transform_name=s,x,x, 779 +silent= 780 +site= 781 +srcdir= 782 +verbose= 783 +x_includes=NONE 784 +x_libraries=NONE 785 + 786 +# Installation directory options. 787 +# These are left unexpanded so users can "make install exec_prefix=/foo" 788 +# and all the variables that are supposed to be based on exec_prefix 789 +# by default will actually change. 790 +# Use braces instead of parens because sh, perl, etc. also accept them. 791 +# (The list follows the same order as the GNU Coding Standards.) 792 +bindir='${exec_prefix}/bin' 793 +sbindir='${exec_prefix}/sbin' 794 +libexecdir='${exec_prefix}/libexec' 795 +datarootdir='${prefix}/share' 796 +datadir='${datarootdir}' 797 +sysconfdir='${prefix}/etc' 798 +sharedstatedir='${prefix}/com' 799 +localstatedir='${prefix}/var' 800 +runstatedir='${localstatedir}/run' 801 +includedir='${prefix}/include' 802 +oldincludedir='/usr/include' 803 +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' 804 +infodir='${datarootdir}/info' 805 +htmldir='${docdir}' 806 +dvidir='${docdir}' 807 +pdfdir='${docdir}' 808 +psdir='${docdir}' 809 +libdir='${exec_prefix}/lib' 810 +localedir='${datarootdir}/locale' 811 +mandir='${datarootdir}/man' 812 + 813 +ac_prev= 814 +ac_dashdash= 815 +for ac_option 816 +do 817 + # If the previous option needs an argument, assign it. 818 + if test -n "$ac_prev"; then 819 + eval $ac_prev=\$ac_option 820 + ac_prev= 821 + continue 822 + fi 823 + 824 + case $ac_option in 825 + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; 826 + *=) ac_optarg= ;; 827 + *) ac_optarg=yes ;; 828 + esac 829 + 830 + # Accept the important Cygnus configure options, so we can diagnose typos. 831 + 832 + case $ac_dashdash$ac_option in 833 + --) 834 + ac_dashdash=yes ;; 835 + 836 + -bindir | --bindir | --bindi | --bind | --bin | --bi) 837 + ac_prev=bindir ;; 838 + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) 839 + bindir=$ac_optarg ;; 840 + 841 + -build | --build | --buil | --bui | --bu) 842 + ac_prev=build_alias ;; 843 + -build=* | --build=* | --buil=* | --bui=* | --bu=*) 844 + build_alias=$ac_optarg ;; 845 + 846 + -cache-file | --cache-file | --cache-fil | --cache-fi \ 847 + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) 848 + ac_prev=cache_file ;; 849 + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ 850 + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) 851 + cache_file=$ac_optarg ;; 852 + 853 + --config-cache | -C) 854 + cache_file=config.cache ;; 855 + 856 + -datadir | --datadir | --datadi | --datad) 857 + ac_prev=datadir ;; 858 + -datadir=* | --datadir=* | --datadi=* | --datad=*) 859 + datadir=$ac_optarg ;; 860 + 861 + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ 862 + | --dataroo | --dataro | --datar) 863 + ac_prev=datarootdir ;; 864 + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ 865 + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) 866 + datarootdir=$ac_optarg ;; 867 + 868 + -disable-* | --disable-*) 869 + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` 870 + # Reject names that are not valid shell variable names. 871 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && 872 + as_fn_error $? "invalid feature name: $ac_useropt" 873 + ac_useropt_orig=$ac_useropt 874 + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` 875 + case $ac_user_opts in 876 + *" 877 +"enable_$ac_useropt" 878 +"*) ;; 879 + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" 880 + ac_unrecognized_sep=', ';; 881 + esac 882 + eval enable_$ac_useropt=no ;; 883 + 884 + -docdir | --docdir | --docdi | --doc | --do) 885 + ac_prev=docdir ;; 886 + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) 887 + docdir=$ac_optarg ;; 888 + 889 + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) 890 + ac_prev=dvidir ;; 891 + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) 892 + dvidir=$ac_optarg ;; 893 + 894 + -enable-* | --enable-*) 895 + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` 896 + # Reject names that are not valid shell variable names. 897 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && 898 + as_fn_error $? "invalid feature name: $ac_useropt" 899 + ac_useropt_orig=$ac_useropt 900 + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` 901 + case $ac_user_opts in 902 + *" 903 +"enable_$ac_useropt" 904 +"*) ;; 905 + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" 906 + ac_unrecognized_sep=', ';; 907 + esac 908 + eval enable_$ac_useropt=\$ac_optarg ;; 909 + 910 + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ 911 + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ 912 + | --exec | --exe | --ex) 913 + ac_prev=exec_prefix ;; 914 + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ 915 + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ 916 + | --exec=* | --exe=* | --ex=*) 917 + exec_prefix=$ac_optarg ;; 918 + 919 + -gas | --gas | --ga | --g) 920 + # Obsolete; use --with-gas. 921 + with_gas=yes ;; 922 + 923 + -help | --help | --hel | --he | -h) 924 + ac_init_help=long ;; 925 + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) 926 + ac_init_help=recursive ;; 927 + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) 928 + ac_init_help=short ;; 929 + 930 + -host | --host | --hos | --ho) 931 + ac_prev=host_alias ;; 932 + -host=* | --host=* | --hos=* | --ho=*) 933 + host_alias=$ac_optarg ;; 934 + 935 + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) 936 + ac_prev=htmldir ;; 937 + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ 938 + | --ht=*) 939 + htmldir=$ac_optarg ;; 940 + 941 + -includedir | --includedir | --includedi | --included | --include \ 942 + | --includ | --inclu | --incl | --inc) 943 + ac_prev=includedir ;; 944 + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ 945 + | --includ=* | --inclu=* | --incl=* | --inc=*) 946 + includedir=$ac_optarg ;; 947 + 948 + -infodir | --infodir | --infodi | --infod | --info | --inf) 949 + ac_prev=infodir ;; 950 + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) 951 + infodir=$ac_optarg ;; 952 + 953 + -libdir | --libdir | --libdi | --libd) 954 + ac_prev=libdir ;; 955 + -libdir=* | --libdir=* | --libdi=* | --libd=*) 956 + libdir=$ac_optarg ;; 957 + 958 + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ 959 + | --libexe | --libex | --libe) 960 + ac_prev=libexecdir ;; 961 + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ 962 + | --libexe=* | --libex=* | --libe=*) 963 + libexecdir=$ac_optarg ;; 964 + 965 + -localedir | --localedir | --localedi | --localed | --locale) 966 + ac_prev=localedir ;; 967 + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) 968 + localedir=$ac_optarg ;; 969 + 970 + -localstatedir | --localstatedir | --localstatedi | --localstated \ 971 + | --localstate | --localstat | --localsta | --localst | --locals) 972 + ac_prev=localstatedir ;; 973 + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ 974 + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) 975 + localstatedir=$ac_optarg ;; 976 + 977 + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) 978 + ac_prev=mandir ;; 979 + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) 980 + mandir=$ac_optarg ;; 981 + 982 + -nfp | --nfp | --nf) 983 + # Obsolete; use --without-fp. 984 + with_fp=no ;; 985 + 986 + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ 987 + | --no-cr | --no-c | -n) 988 + no_create=yes ;; 989 + 990 + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ 991 + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) 992 + no_recursion=yes ;; 993 + 994 + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ 995 + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ 996 + | --oldin | --oldi | --old | --ol | --o) 997 + ac_prev=oldincludedir ;; 998 + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ 999 + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ 1000 + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) 1001 + oldincludedir=$ac_optarg ;; 1002 + 1003 + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) 1004 + ac_prev=prefix ;; 1005 + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) 1006 + prefix=$ac_optarg ;; 1007 + 1008 + -program-prefix | --program-prefix | --program-prefi | --program-pref \ 1009 + | --program-pre | --program-pr | --program-p) 1010 + ac_prev=program_prefix ;; 1011 + -program-prefix=* | --program-prefix=* | --program-prefi=* \ 1012 + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) 1013 + program_prefix=$ac_optarg ;; 1014 + 1015 + -program-suffix | --program-suffix | --program-suffi | --program-suff \ 1016 + | --program-suf | --program-su | --program-s) 1017 + ac_prev=program_suffix ;; 1018 + -program-suffix=* | --program-suffix=* | --program-suffi=* \ 1019 + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) 1020 + program_suffix=$ac_optarg ;; 1021 + 1022 + -program-transform-name | --program-transform-name \ 1023 + | --program-transform-nam | --program-transform-na \ 1024 + | --program-transform-n | --program-transform- \ 1025 + | --program-transform | --program-transfor \ 1026 + | --program-transfo | --program-transf \ 1027 + | --program-trans | --program-tran \ 1028 + | --progr-tra | --program-tr | --program-t) 1029 + ac_prev=program_transform_name ;; 1030 + -program-transform-name=* | --program-transform-name=* \ 1031 + | --program-transform-nam=* | --program-transform-na=* \ 1032 + | --program-transform-n=* | --program-transform-=* \ 1033 + | --program-transform=* | --program-transfor=* \ 1034 + | --program-transfo=* | --program-transf=* \ 1035 + | --program-trans=* | --program-tran=* \ 1036 + | --progr-tra=* | --program-tr=* | --program-t=*) 1037 + program_transform_name=$ac_optarg ;; 1038 + 1039 + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) 1040 + ac_prev=pdfdir ;; 1041 + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) 1042 + pdfdir=$ac_optarg ;; 1043 + 1044 + -psdir | --psdir | --psdi | --psd | --ps) 1045 + ac_prev=psdir ;; 1046 + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) 1047 + psdir=$ac_optarg ;; 1048 + 1049 + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ 1050 + | -silent | --silent | --silen | --sile | --sil) 1051 + silent=yes ;; 1052 + 1053 + -runstatedir | --runstatedir | --runstatedi | --runstated \ 1054 + | --runstate | --runstat | --runsta | --runst | --runs \ 1055 + | --run | --ru | --r) 1056 + ac_prev=runstatedir ;; 1057 + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ 1058 + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ 1059 + | --run=* | --ru=* | --r=*) 1060 + runstatedir=$ac_optarg ;; 1061 + 1062 + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) 1063 + ac_prev=sbindir ;; 1064 + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ 1065 + | --sbi=* | --sb=*) 1066 + sbindir=$ac_optarg ;; 1067 + 1068 + -sharedstatedir | --sharedstatedir | --sharedstatedi \ 1069 + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ 1070 + | --sharedst | --shareds | --shared | --share | --shar \ 1071 + | --sha | --sh) 1072 + ac_prev=sharedstatedir ;; 1073 + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ 1074 + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ 1075 + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ 1076 + | --sha=* | --sh=*) 1077 + sharedstatedir=$ac_optarg ;; 1078 + 1079 + -site | --site | --sit) 1080 + ac_prev=site ;; 1081 + -site=* | --site=* | --sit=*) 1082 + site=$ac_optarg ;; 1083 + 1084 + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) 1085 + ac_prev=srcdir ;; 1086 + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) 1087 + srcdir=$ac_optarg ;; 1088 + 1089 + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ 1090 + | --syscon | --sysco | --sysc | --sys | --sy) 1091 + ac_prev=sysconfdir ;; 1092 + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ 1093 + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) 1094 + sysconfdir=$ac_optarg ;; 1095 + 1096 + -target | --target | --targe | --targ | --tar | --ta | --t) 1097 + ac_prev=target_alias ;; 1098 + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) 1099 + target_alias=$ac_optarg ;; 1100 + 1101 + -v | -verbose | --verbose | --verbos | --verbo | --verb) 1102 + verbose=yes ;; 1103 + 1104 + -version | --version | --versio | --versi | --vers | -V) 1105 + ac_init_version=: ;; 1106 + 1107 + -with-* | --with-*) 1108 + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` 1109 + # Reject names that are not valid shell variable names. 1110 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && 1111 + as_fn_error $? "invalid package name: $ac_useropt" 1112 + ac_useropt_orig=$ac_useropt 1113 + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` 1114 + case $ac_user_opts in 1115 + *" 1116 +"with_$ac_useropt" 1117 +"*) ;; 1118 + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" 1119 + ac_unrecognized_sep=', ';; 1120 + esac 1121 + eval with_$ac_useropt=\$ac_optarg ;; 1122 + 1123 + -without-* | --without-*) 1124 + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` 1125 + # Reject names that are not valid shell variable names. 1126 + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && 1127 + as_fn_error $? "invalid package name: $ac_useropt" 1128 + ac_useropt_orig=$ac_useropt 1129 + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` 1130 + case $ac_user_opts in 1131 + *" 1132 +"with_$ac_useropt" 1133 +"*) ;; 1134 + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" 1135 + ac_unrecognized_sep=', ';; 1136 + esac 1137 + eval with_$ac_useropt=no ;; 1138 + 1139 + --x) 1140 + # Obsolete; use --with-x. 1141 + with_x=yes ;; 1142 + 1143 + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ 1144 + | --x-incl | --x-inc | --x-in | --x-i) 1145 + ac_prev=x_includes ;; 1146 + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ 1147 + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) 1148 + x_includes=$ac_optarg ;; 1149 + 1150 + -x-libraries | --x-libraries | --x-librarie | --x-librari \ 1151 + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) 1152 + ac_prev=x_libraries ;; 1153 + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ 1154 + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) 1155 + x_libraries=$ac_optarg ;; 1156 + 1157 + -*) as_fn_error $? "unrecognized option: \`$ac_option' 1158 +Try \`$0 --help' for more information" 1159 + ;; 1160 + 1161 + *=*) 1162 + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` 1163 + # Reject names that are not valid shell variable names. 1164 + case $ac_envvar in #( 1165 + '' | [0-9]* | *[!_$as_cr_alnum]* ) 1166 + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; 1167 + esac 1168 + eval $ac_envvar=\$ac_optarg 1169 + export $ac_envvar ;; 1170 + 1171 + *) 1172 + # FIXME: should be removed in autoconf 3.0. 1173 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 1174 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && 1175 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 1176 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" 1177 + ;; 1178 + 1179 + esac 1180 +done 1181 + 1182 +if test -n "$ac_prev"; then 1183 + ac_option=--`echo $ac_prev | sed 's/_/-/g'` 1184 + as_fn_error $? "missing argument to $ac_option" 1185 +fi 1186 + 1187 +if test -n "$ac_unrecognized_opts"; then 1188 + case $enable_option_checking in 1189 + no) ;; 1190 + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; 1191 + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; 1192 + esac 1193 +fi 1194 + 1195 +# Check all directory arguments for consistency. 1196 +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ 1197 + datadir sysconfdir sharedstatedir localstatedir includedir \ 1198 + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ 1199 + libdir localedir mandir runstatedir 1200 +do 1201 + eval ac_val=\$$ac_var 1202 + # Remove trailing slashes. 1203 + case $ac_val in 1204 + */ ) 1205 + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` 1206 + eval $ac_var=\$ac_val;; 1207 + esac 1208 + # Be sure to have absolute directory names. 1209 + case $ac_val in 1210 + [\\/$]* | ?:[\\/]* ) continue;; 1211 + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; 1212 + esac 1213 + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" 1214 +done 1215 + 1216 +# There might be people who depend on the old broken behavior: `$host' 1217 +# used to hold the argument of --host etc. 1218 +# FIXME: To remove some day. 1219 +build=$build_alias 1220 +host=$host_alias 1221 +target=$target_alias 1222 + 1223 +# FIXME: To remove some day. 1224 +if test "x$host_alias" != x; then 1225 + if test "x$build_alias" = x; then 1226 + cross_compiling=maybe 1227 + elif test "x$build_alias" != "x$host_alias"; then 1228 + cross_compiling=yes 1229 + fi 1230 +fi 1231 + 1232 +ac_tool_prefix= 1233 +test -n "$host_alias" && ac_tool_prefix=$host_alias- 1234 + 1235 +test "$silent" = yes && exec 6>/dev/null 1236 + 1237 + 1238 +ac_pwd=`pwd` && test -n "$ac_pwd" && 1239 +ac_ls_di=`ls -di .` && 1240 +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || 1241 + as_fn_error $? "working directory cannot be determined" 1242 +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || 1243 + as_fn_error $? "pwd does not report name of working directory" 1244 + 1245 + 1246 +# Find the source files, if location was not specified. 1247 +if test -z "$srcdir"; then 1248 + ac_srcdir_defaulted=yes 1249 + # Try the directory containing this script, then the parent directory. 1250 + ac_confdir=`$as_dirname -- "$as_myself" || 1251 +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 1252 + X"$as_myself" : 'X\(//\)[^/]' \| \ 1253 + X"$as_myself" : 'X\(//\)$' \| \ 1254 + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || 1255 +$as_echo X"$as_myself" | 1256 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 1257 + s//\1/ 1258 + q 1259 + } 1260 + /^X\(\/\/\)[^/].*/{ 1261 + s//\1/ 1262 + q 1263 + } 1264 + /^X\(\/\/\)$/{ 1265 + s//\1/ 1266 + q 1267 + } 1268 + /^X\(\/\).*/{ 1269 + s//\1/ 1270 + q 1271 + } 1272 + s/.*/./; q'` 1273 + srcdir=$ac_confdir 1274 + if test ! -r "$srcdir/$ac_unique_file"; then 1275 + srcdir=.. 1276 + fi 1277 +else 1278 + ac_srcdir_defaulted=no 1279 +fi 1280 +if test ! -r "$srcdir/$ac_unique_file"; then 1281 + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." 1282 + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" 1283 +fi 1284 +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" 1285 +ac_abs_confdir=`( 1286 + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" 1287 + pwd)` 1288 +# When building in place, set srcdir=. 1289 +if test "$ac_abs_confdir" = "$ac_pwd"; then 1290 + srcdir=. 1291 +fi 1292 +# Remove unnecessary trailing slashes from srcdir. 1293 +# Double slashes in file names in object file debugging info 1294 +# mess up M-x gdb in Emacs. 1295 +case $srcdir in 1296 +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; 1297 +esac 1298 +for ac_var in $ac_precious_vars; do 1299 + eval ac_env_${ac_var}_set=\${${ac_var}+set} 1300 + eval ac_env_${ac_var}_value=\$${ac_var} 1301 + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} 1302 + eval ac_cv_env_${ac_var}_value=\$${ac_var} 1303 +done 1304 + 1305 +# 1306 +# Report the --help message. 1307 +# 1308 +if test "$ac_init_help" = "long"; then 1309 + # Omit some internal or obsolete options to make the list less imposing. 1310 + # This message is too long to be a string in the A/UX 3.1 sh. 1311 + cat <<_ACEOF 1312 +\`configure' configures schemadtx 1.0 to adapt to many kinds of systems. 1313 + 1314 +Usage: $0 [OPTION]... [VAR=VALUE]... 1315 + 1316 +To assign environment variables (e.g., CC, CFLAGS...), specify them as 1317 +VAR=VALUE. See below for descriptions of some of the useful variables. 1318 + 1319 +Defaults for the options are specified in brackets. 1320 + 1321 +Configuration: 1322 + -h, --help display this help and exit 1323 + --help=short display options specific to this package 1324 + --help=recursive display the short help of all the included packages 1325 + -V, --version display version information and exit 1326 + -q, --quiet, --silent do not print \`checking ...' messages 1327 + --cache-file=FILE cache test results in FILE [disabled] 1328 + -C, --config-cache alias for \`--cache-file=config.cache' 1329 + -n, --no-create do not create output files 1330 + --srcdir=DIR find the sources in DIR [configure dir or \`..'] 1331 + 1332 +Installation directories: 1333 + --prefix=PREFIX install architecture-independent files in PREFIX 1334 + [$ac_default_prefix] 1335 + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX 1336 + [PREFIX] 1337 + 1338 +By default, \`make install' will install all the files in 1339 +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify 1340 +an installation prefix other than \`$ac_default_prefix' using \`--prefix', 1341 +for instance \`--prefix=\$HOME'. 1342 + 1343 +For better control, use the options below. 1344 + 1345 +Fine tuning of the installation directories: 1346 + --bindir=DIR user executables [EPREFIX/bin] 1347 + --sbindir=DIR system admin executables [EPREFIX/sbin] 1348 + --libexecdir=DIR program executables [EPREFIX/libexec] 1349 + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] 1350 + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 1351 + --localstatedir=DIR modifiable single-machine data [PREFIX/var] 1352 + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] 1353 + --libdir=DIR object code libraries [EPREFIX/lib] 1354 + --includedir=DIR C header files [PREFIX/include] 1355 + --oldincludedir=DIR C header files for non-gcc [/usr/include] 1356 + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 1357 + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 1358 + --infodir=DIR info documentation [DATAROOTDIR/info] 1359 + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] 1360 + --mandir=DIR man documentation [DATAROOTDIR/man] 1361 + --docdir=DIR documentation root [DATAROOTDIR/doc/schemadtx] 1362 + --htmldir=DIR html documentation [DOCDIR] 1363 + --dvidir=DIR dvi documentation [DOCDIR] 1364 + --pdfdir=DIR pdf documentation [DOCDIR] 1365 + --psdir=DIR ps documentation [DOCDIR] 1366 +_ACEOF 1367 + 1368 + cat <<\_ACEOF 1369 +_ACEOF 1370 +fi 1371 + 1372 +if test -n "$ac_init_help"; then 1373 + case $ac_init_help in 1374 + short | recursive ) echo "Configuration of schemadtx 1.0:";; 1375 + esac 1376 + cat <<\_ACEOF 1377 + 1378 +Optional Features: 1379 + --disable-option-checking ignore unrecognized --enable/--with options 1380 + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) 1381 + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] 1382 + --enable-threads build with threads (default: on) 1383 + --enable-shared build and link with shared libraries (default: on) 1384 + --enable-stubs build and link with stub libraries. Always true for 1385 + shared builds (default: on) 1386 + --enable-64bit enable 64bit support (default: off) 1387 + --enable-64bit-vis enable 64bit Sparc VIS support (default: off) 1388 + --disable-rpath disable rpath support (default: on) 1389 + --enable-wince enable Win/CE support (where applicable) 1390 + --enable-symbols build with debugging symbols (default: off) 1391 + 1392 +Optional Packages: 1393 + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 1394 + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 1395 + --with-tcl directory containing tcl configuration 1396 + (tclConfig.sh) 1397 + --with-tdom directory containing tDOM configuration 1398 + (tdomConfig.sh) 1399 + --with-tclinclude directory containing the public Tcl header files 1400 + --with-celib=DIR use Windows/CE support library from DIR 1401 + 1402 +Some influential environment variables: 1403 + CC C compiler command 1404 + CFLAGS C compiler flags 1405 + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a 1406 + nonstandard directory <lib dir> 1407 + LIBS libraries to pass to the linker, e.g. -l<library> 1408 + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if 1409 + you have headers in a nonstandard directory <include dir> 1410 + CPP C preprocessor 1411 + 1412 +Use these variables to override the choices made by `configure' or to help 1413 +it to find libraries and programs with nonstandard names/locations. 1414 + 1415 +Report bugs to the package provider. 1416 +_ACEOF 1417 +ac_status=$? 1418 +fi 1419 + 1420 +if test "$ac_init_help" = "recursive"; then 1421 + # If there are subdirs, report their specific --help. 1422 + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue 1423 + test -d "$ac_dir" || 1424 + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || 1425 + continue 1426 + ac_builddir=. 1427 + 1428 +case "$ac_dir" in 1429 +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; 1430 +*) 1431 + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` 1432 + # A ".." for each directory in $ac_dir_suffix. 1433 + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` 1434 + case $ac_top_builddir_sub in 1435 + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; 1436 + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; 1437 + esac ;; 1438 +esac 1439 +ac_abs_top_builddir=$ac_pwd 1440 +ac_abs_builddir=$ac_pwd$ac_dir_suffix 1441 +# for backward compatibility: 1442 +ac_top_builddir=$ac_top_build_prefix 1443 + 1444 +case $srcdir in 1445 + .) # We are building in place. 1446 + ac_srcdir=. 1447 + ac_top_srcdir=$ac_top_builddir_sub 1448 + ac_abs_top_srcdir=$ac_pwd ;; 1449 + [\\/]* | ?:[\\/]* ) # Absolute name. 1450 + ac_srcdir=$srcdir$ac_dir_suffix; 1451 + ac_top_srcdir=$srcdir 1452 + ac_abs_top_srcdir=$srcdir ;; 1453 + *) # Relative name. 1454 + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix 1455 + ac_top_srcdir=$ac_top_build_prefix$srcdir 1456 + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; 1457 +esac 1458 +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix 1459 + 1460 + cd "$ac_dir" || { ac_status=$?; continue; } 1461 + # Check for guested configure. 1462 + if test -f "$ac_srcdir/configure.gnu"; then 1463 + echo && 1464 + $SHELL "$ac_srcdir/configure.gnu" --help=recursive 1465 + elif test -f "$ac_srcdir/configure"; then 1466 + echo && 1467 + $SHELL "$ac_srcdir/configure" --help=recursive 1468 + else 1469 + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 1470 + fi || ac_status=$? 1471 + cd "$ac_pwd" || { ac_status=$?; break; } 1472 + done 1473 +fi 1474 + 1475 +test -n "$ac_init_help" && exit $ac_status 1476 +if $ac_init_version; then 1477 + cat <<\_ACEOF 1478 +schemadtx configure 1.0 1479 +generated by GNU Autoconf 2.69 1480 + 1481 +Copyright (C) 2012 Free Software Foundation, Inc. 1482 +This configure script is free software; the Free Software Foundation 1483 +gives unlimited permission to copy, distribute and modify it. 1484 +_ACEOF 1485 + exit 1486 +fi 1487 + 1488 +## ------------------------ ## 1489 +## Autoconf initialization. ## 1490 +## ------------------------ ## 1491 + 1492 +# ac_fn_c_try_compile LINENO 1493 +# -------------------------- 1494 +# Try to compile conftest.$ac_ext, and return whether this succeeded. 1495 +ac_fn_c_try_compile () 1496 +{ 1497 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1498 + rm -f conftest.$ac_objext 1499 + if { { ac_try="$ac_compile" 1500 +case "(($ac_try" in 1501 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 1502 + *) ac_try_echo=$ac_try;; 1503 +esac 1504 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 1505 +$as_echo "$ac_try_echo"; } >&5 1506 + (eval "$ac_compile") 2>conftest.err 1507 + ac_status=$? 1508 + if test -s conftest.err; then 1509 + grep -v '^ *+' conftest.err >conftest.er1 1510 + cat conftest.er1 >&5 1511 + mv -f conftest.er1 conftest.err 1512 + fi 1513 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 1514 + test $ac_status = 0; } && { 1515 + test -z "$ac_c_werror_flag" || 1516 + test ! -s conftest.err 1517 + } && test -s conftest.$ac_objext; then : 1518 + ac_retval=0 1519 +else 1520 + $as_echo "$as_me: failed program was:" >&5 1521 +sed 's/^/| /' conftest.$ac_ext >&5 1522 + 1523 + ac_retval=1 1524 +fi 1525 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1526 + as_fn_set_status $ac_retval 1527 + 1528 +} # ac_fn_c_try_compile 1529 + 1530 +# ac_fn_c_try_cpp LINENO 1531 +# ---------------------- 1532 +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. 1533 +ac_fn_c_try_cpp () 1534 +{ 1535 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1536 + if { { ac_try="$ac_cpp conftest.$ac_ext" 1537 +case "(($ac_try" in 1538 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 1539 + *) ac_try_echo=$ac_try;; 1540 +esac 1541 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 1542 +$as_echo "$ac_try_echo"; } >&5 1543 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err 1544 + ac_status=$? 1545 + if test -s conftest.err; then 1546 + grep -v '^ *+' conftest.err >conftest.er1 1547 + cat conftest.er1 >&5 1548 + mv -f conftest.er1 conftest.err 1549 + fi 1550 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 1551 + test $ac_status = 0; } > conftest.i && { 1552 + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || 1553 + test ! -s conftest.err 1554 + }; then : 1555 + ac_retval=0 1556 +else 1557 + $as_echo "$as_me: failed program was:" >&5 1558 +sed 's/^/| /' conftest.$ac_ext >&5 1559 + 1560 + ac_retval=1 1561 +fi 1562 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1563 + as_fn_set_status $ac_retval 1564 + 1565 +} # ac_fn_c_try_cpp 1566 + 1567 +# ac_fn_c_try_run LINENO 1568 +# ---------------------- 1569 +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes 1570 +# that executables *can* be run. 1571 +ac_fn_c_try_run () 1572 +{ 1573 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1574 + if { { ac_try="$ac_link" 1575 +case "(($ac_try" in 1576 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 1577 + *) ac_try_echo=$ac_try;; 1578 +esac 1579 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 1580 +$as_echo "$ac_try_echo"; } >&5 1581 + (eval "$ac_link") 2>&5 1582 + ac_status=$? 1583 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 1584 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' 1585 + { { case "(($ac_try" in 1586 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 1587 + *) ac_try_echo=$ac_try;; 1588 +esac 1589 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 1590 +$as_echo "$ac_try_echo"; } >&5 1591 + (eval "$ac_try") 2>&5 1592 + ac_status=$? 1593 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 1594 + test $ac_status = 0; }; }; then : 1595 + ac_retval=0 1596 +else 1597 + $as_echo "$as_me: program exited with status $ac_status" >&5 1598 + $as_echo "$as_me: failed program was:" >&5 1599 +sed 's/^/| /' conftest.$ac_ext >&5 1600 + 1601 + ac_retval=$ac_status 1602 +fi 1603 + rm -rf conftest.dSYM conftest_ipa8_conftest.oo 1604 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1605 + as_fn_set_status $ac_retval 1606 + 1607 +} # ac_fn_c_try_run 1608 + 1609 +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES 1610 +# ------------------------------------------------------- 1611 +# Tests whether HEADER exists and can be compiled using the include files in 1612 +# INCLUDES, setting the cache variable VAR accordingly. 1613 +ac_fn_c_check_header_compile () 1614 +{ 1615 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1616 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1617 +$as_echo_n "checking for $2... " >&6; } 1618 +if eval \${$3+:} false; then : 1619 + $as_echo_n "(cached) " >&6 1620 +else 1621 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1622 +/* end confdefs.h. */ 1623 +$4 1624 +#include <$2> 1625 +_ACEOF 1626 +if ac_fn_c_try_compile "$LINENO"; then : 1627 + eval "$3=yes" 1628 +else 1629 + eval "$3=no" 1630 +fi 1631 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 1632 +fi 1633 +eval ac_res=\$$3 1634 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1635 +$as_echo "$ac_res" >&6; } 1636 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1637 + 1638 +} # ac_fn_c_check_header_compile 1639 + 1640 +# ac_fn_c_try_link LINENO 1641 +# ----------------------- 1642 +# Try to link conftest.$ac_ext, and return whether this succeeded. 1643 +ac_fn_c_try_link () 1644 +{ 1645 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1646 + rm -f conftest.$ac_objext conftest$ac_exeext 1647 + if { { ac_try="$ac_link" 1648 +case "(($ac_try" in 1649 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 1650 + *) ac_try_echo=$ac_try;; 1651 +esac 1652 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 1653 +$as_echo "$ac_try_echo"; } >&5 1654 + (eval "$ac_link") 2>conftest.err 1655 + ac_status=$? 1656 + if test -s conftest.err; then 1657 + grep -v '^ *+' conftest.err >conftest.er1 1658 + cat conftest.er1 >&5 1659 + mv -f conftest.er1 conftest.err 1660 + fi 1661 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 1662 + test $ac_status = 0; } && { 1663 + test -z "$ac_c_werror_flag" || 1664 + test ! -s conftest.err 1665 + } && test -s conftest$ac_exeext && { 1666 + test "$cross_compiling" = yes || 1667 + test -x conftest$ac_exeext 1668 + }; then : 1669 + ac_retval=0 1670 +else 1671 + $as_echo "$as_me: failed program was:" >&5 1672 +sed 's/^/| /' conftest.$ac_ext >&5 1673 + 1674 + ac_retval=1 1675 +fi 1676 + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information 1677 + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would 1678 + # interfere with the next link command; also delete a directory that is 1679 + # left behind by Apple's compiler. We do this before executing the actions. 1680 + rm -rf conftest.dSYM conftest_ipa8_conftest.oo 1681 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1682 + as_fn_set_status $ac_retval 1683 + 1684 +} # ac_fn_c_try_link 1685 + 1686 +# ac_fn_c_check_func LINENO FUNC VAR 1687 +# ---------------------------------- 1688 +# Tests whether FUNC exists, setting the cache variable VAR accordingly 1689 +ac_fn_c_check_func () 1690 +{ 1691 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1692 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1693 +$as_echo_n "checking for $2... " >&6; } 1694 +if eval \${$3+:} false; then : 1695 + $as_echo_n "(cached) " >&6 1696 +else 1697 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1698 +/* end confdefs.h. */ 1699 +/* Define $2 to an innocuous variant, in case <limits.h> declares $2. 1700 + For example, HP-UX 11i <limits.h> declares gettimeofday. */ 1701 +#define $2 innocuous_$2 1702 + 1703 +/* System header to define __stub macros and hopefully few prototypes, 1704 + which can conflict with char $2 (); below. 1705 + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 1706 + <limits.h> exists even on freestanding compilers. */ 1707 + 1708 +#ifdef __STDC__ 1709 +# include <limits.h> 1710 +#else 1711 +# include <assert.h> 1712 +#endif 1713 + 1714 +#undef $2 1715 + 1716 +/* Override any GCC internal prototype to avoid an error. 1717 + Use char because int might match the return type of a GCC 1718 + builtin and then its argument prototype would still apply. */ 1719 +#ifdef __cplusplus 1720 +extern "C" 1721 +#endif 1722 +char $2 (); 1723 +/* The GNU C library defines this for functions which it implements 1724 + to always fail with ENOSYS. Some functions are actually named 1725 + something starting with __ and the normal name is an alias. */ 1726 +#if defined __stub_$2 || defined __stub___$2 1727 +choke me 1728 +#endif 1729 + 1730 +int 1731 +main () 1732 +{ 1733 +return $2 (); 1734 + ; 1735 + return 0; 1736 +} 1737 +_ACEOF 1738 +if ac_fn_c_try_link "$LINENO"; then : 1739 + eval "$3=yes" 1740 +else 1741 + eval "$3=no" 1742 +fi 1743 +rm -f core conftest.err conftest.$ac_objext \ 1744 + conftest$ac_exeext conftest.$ac_ext 1745 +fi 1746 +eval ac_res=\$$3 1747 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1748 +$as_echo "$ac_res" >&6; } 1749 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1750 + 1751 +} # ac_fn_c_check_func 1752 +cat >config.log <<_ACEOF 1753 +This file contains any messages produced by compilers while 1754 +running configure, to aid debugging if configure makes a mistake. 1755 + 1756 +It was created by schemadtx $as_me 1.0, which was 1757 +generated by GNU Autoconf 2.69. Invocation command line was 1758 + 1759 + $ $0 $@ 1760 + 1761 +_ACEOF 1762 +exec 5>>config.log 1763 +{ 1764 +cat <<_ASUNAME 1765 +## --------- ## 1766 +## Platform. ## 1767 +## --------- ## 1768 + 1769 +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` 1770 +uname -m = `(uname -m) 2>/dev/null || echo unknown` 1771 +uname -r = `(uname -r) 2>/dev/null || echo unknown` 1772 +uname -s = `(uname -s) 2>/dev/null || echo unknown` 1773 +uname -v = `(uname -v) 2>/dev/null || echo unknown` 1774 + 1775 +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` 1776 +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` 1777 + 1778 +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` 1779 +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` 1780 +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` 1781 +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` 1782 +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` 1783 +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` 1784 +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` 1785 + 1786 +_ASUNAME 1787 + 1788 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 1789 +for as_dir in $PATH 1790 +do 1791 + IFS=$as_save_IFS 1792 + test -z "$as_dir" && as_dir=. 1793 + $as_echo "PATH: $as_dir" 1794 + done 1795 +IFS=$as_save_IFS 1796 + 1797 +} >&5 1798 + 1799 +cat >&5 <<_ACEOF 1800 + 1801 + 1802 +## ----------- ## 1803 +## Core tests. ## 1804 +## ----------- ## 1805 + 1806 +_ACEOF 1807 + 1808 + 1809 +# Keep a trace of the command line. 1810 +# Strip out --no-create and --no-recursion so they do not pile up. 1811 +# Strip out --silent because we don't want to record it for future runs. 1812 +# Also quote any args containing shell meta-characters. 1813 +# Make two passes to allow for proper duplicate-argument suppression. 1814 +ac_configure_args= 1815 +ac_configure_args0= 1816 +ac_configure_args1= 1817 +ac_must_keep_next=false 1818 +for ac_pass in 1 2 1819 +do 1820 + for ac_arg 1821 + do 1822 + case $ac_arg in 1823 + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; 1824 + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ 1825 + | -silent | --silent | --silen | --sile | --sil) 1826 + continue ;; 1827 + *\'*) 1828 + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; 1829 + esac 1830 + case $ac_pass in 1831 + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 1832 + 2) 1833 + as_fn_append ac_configure_args1 " '$ac_arg'" 1834 + if test $ac_must_keep_next = true; then 1835 + ac_must_keep_next=false # Got value, back to normal. 1836 + else 1837 + case $ac_arg in 1838 + *=* | --config-cache | -C | -disable-* | --disable-* \ 1839 + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ 1840 + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ 1841 + | -with-* | --with-* | -without-* | --without-* | --x) 1842 + case "$ac_configure_args0 " in 1843 + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; 1844 + esac 1845 + ;; 1846 + -* ) ac_must_keep_next=true ;; 1847 + esac 1848 + fi 1849 + as_fn_append ac_configure_args " '$ac_arg'" 1850 + ;; 1851 + esac 1852 + done 1853 +done 1854 +{ ac_configure_args0=; unset ac_configure_args0;} 1855 +{ ac_configure_args1=; unset ac_configure_args1;} 1856 + 1857 +# When interrupted or exit'd, cleanup temporary files, and complete 1858 +# config.log. We remove comments because anyway the quotes in there 1859 +# would cause problems or look ugly. 1860 +# WARNING: Use '\'' to represent an apostrophe within the trap. 1861 +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. 1862 +trap 'exit_status=$? 1863 + # Save into config.log some information that might help in debugging. 1864 + { 1865 + echo 1866 + 1867 + $as_echo "## ---------------- ## 1868 +## Cache variables. ## 1869 +## ---------------- ##" 1870 + echo 1871 + # The following way of writing the cache mishandles newlines in values, 1872 +( 1873 + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do 1874 + eval ac_val=\$$ac_var 1875 + case $ac_val in #( 1876 + *${as_nl}*) 1877 + case $ac_var in #( 1878 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 1879 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; 1880 + esac 1881 + case $ac_var in #( 1882 + _ | IFS | as_nl) ;; #( 1883 + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( 1884 + *) { eval $ac_var=; unset $ac_var;} ;; 1885 + esac ;; 1886 + esac 1887 + done 1888 + (set) 2>&1 | 1889 + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( 1890 + *${as_nl}ac_space=\ *) 1891 + sed -n \ 1892 + "s/'\''/'\''\\\\'\'''\''/g; 1893 + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" 1894 + ;; #( 1895 + *) 1896 + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" 1897 + ;; 1898 + esac | 1899 + sort 1900 +) 1901 + echo 1902 + 1903 + $as_echo "## ----------------- ## 1904 +## Output variables. ## 1905 +## ----------------- ##" 1906 + echo 1907 + for ac_var in $ac_subst_vars 1908 + do 1909 + eval ac_val=\$$ac_var 1910 + case $ac_val in 1911 + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; 1912 + esac 1913 + $as_echo "$ac_var='\''$ac_val'\''" 1914 + done | sort 1915 + echo 1916 + 1917 + if test -n "$ac_subst_files"; then 1918 + $as_echo "## ------------------- ## 1919 +## File substitutions. ## 1920 +## ------------------- ##" 1921 + echo 1922 + for ac_var in $ac_subst_files 1923 + do 1924 + eval ac_val=\$$ac_var 1925 + case $ac_val in 1926 + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; 1927 + esac 1928 + $as_echo "$ac_var='\''$ac_val'\''" 1929 + done | sort 1930 + echo 1931 + fi 1932 + 1933 + if test -s confdefs.h; then 1934 + $as_echo "## ----------- ## 1935 +## confdefs.h. ## 1936 +## ----------- ##" 1937 + echo 1938 + cat confdefs.h 1939 + echo 1940 + fi 1941 + test "$ac_signal" != 0 && 1942 + $as_echo "$as_me: caught signal $ac_signal" 1943 + $as_echo "$as_me: exit $exit_status" 1944 + } >&5 1945 + rm -f core *.core core.conftest.* && 1946 + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && 1947 + exit $exit_status 1948 +' 0 1949 +for ac_signal in 1 2 13 15; do 1950 + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal 1951 +done 1952 +ac_signal=0 1953 + 1954 +# confdefs.h avoids OS command line length limits that DEFS can exceed. 1955 +rm -f -r conftest* confdefs.h 1956 + 1957 +$as_echo "/* confdefs.h */" > confdefs.h 1958 + 1959 +# Predefined preprocessor variables. 1960 + 1961 +cat >>confdefs.h <<_ACEOF 1962 +#define PACKAGE_NAME "$PACKAGE_NAME" 1963 +_ACEOF 1964 + 1965 +cat >>confdefs.h <<_ACEOF 1966 +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" 1967 +_ACEOF 1968 + 1969 +cat >>confdefs.h <<_ACEOF 1970 +#define PACKAGE_VERSION "$PACKAGE_VERSION" 1971 +_ACEOF 1972 + 1973 +cat >>confdefs.h <<_ACEOF 1974 +#define PACKAGE_STRING "$PACKAGE_STRING" 1975 +_ACEOF 1976 + 1977 +cat >>confdefs.h <<_ACEOF 1978 +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" 1979 +_ACEOF 1980 + 1981 +cat >>confdefs.h <<_ACEOF 1982 +#define PACKAGE_URL "$PACKAGE_URL" 1983 +_ACEOF 1984 + 1985 + 1986 +# Let the site file select an alternate cache file if it wants to. 1987 +# Prefer an explicitly selected file to automatically selected ones. 1988 +ac_site_file1=NONE 1989 +ac_site_file2=NONE 1990 +if test -n "$CONFIG_SITE"; then 1991 + # We do not want a PATH search for config.site. 1992 + case $CONFIG_SITE in #(( 1993 + -*) ac_site_file1=./$CONFIG_SITE;; 1994 + */*) ac_site_file1=$CONFIG_SITE;; 1995 + *) ac_site_file1=./$CONFIG_SITE;; 1996 + esac 1997 +elif test "x$prefix" != xNONE; then 1998 + ac_site_file1=$prefix/share/config.site 1999 + ac_site_file2=$prefix/etc/config.site 2000 +else 2001 + ac_site_file1=$ac_default_prefix/share/config.site 2002 + ac_site_file2=$ac_default_prefix/etc/config.site 2003 +fi 2004 +for ac_site_file in "$ac_site_file1" "$ac_site_file2" 2005 +do 2006 + test "x$ac_site_file" = xNONE && continue 2007 + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then 2008 + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 2009 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} 2010 + sed 's/^/| /' "$ac_site_file" >&5 2011 + . "$ac_site_file" \ 2012 + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 2013 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 2014 +as_fn_error $? "failed to load site script $ac_site_file 2015 +See \`config.log' for more details" "$LINENO" 5; } 2016 + fi 2017 +done 2018 + 2019 +if test -r "$cache_file"; then 2020 + # Some versions of bash will fail to source /dev/null (special files 2021 + # actually), so we avoid doing that. DJGPP emulates it as a regular file. 2022 + if test /dev/null != "$cache_file" && test -f "$cache_file"; then 2023 + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 2024 +$as_echo "$as_me: loading cache $cache_file" >&6;} 2025 + case $cache_file in 2026 + [\\/]* | ?:[\\/]* ) . "$cache_file";; 2027 + *) . "./$cache_file";; 2028 + esac 2029 + fi 2030 +else 2031 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 2032 +$as_echo "$as_me: creating cache $cache_file" >&6;} 2033 + >$cache_file 2034 +fi 2035 + 2036 +# Check that the precious variables saved in the cache have kept the same 2037 +# value. 2038 +ac_cache_corrupted=false 2039 +for ac_var in $ac_precious_vars; do 2040 + eval ac_old_set=\$ac_cv_env_${ac_var}_set 2041 + eval ac_new_set=\$ac_env_${ac_var}_set 2042 + eval ac_old_val=\$ac_cv_env_${ac_var}_value 2043 + eval ac_new_val=\$ac_env_${ac_var}_value 2044 + case $ac_old_set,$ac_new_set in 2045 + set,) 2046 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 2047 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} 2048 + ac_cache_corrupted=: ;; 2049 + ,set) 2050 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 2051 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} 2052 + ac_cache_corrupted=: ;; 2053 + ,);; 2054 + *) 2055 + if test "x$ac_old_val" != "x$ac_new_val"; then 2056 + # differences in whitespace do not lead to failure. 2057 + ac_old_val_w=`echo x $ac_old_val` 2058 + ac_new_val_w=`echo x $ac_new_val` 2059 + if test "$ac_old_val_w" != "$ac_new_val_w"; then 2060 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 2061 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} 2062 + ac_cache_corrupted=: 2063 + else 2064 + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 2065 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} 2066 + eval $ac_var=\$ac_old_val 2067 + fi 2068 + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 2069 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} 2070 + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 2071 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} 2072 + fi;; 2073 + esac 2074 + # Pass precious variables to config.status. 2075 + if test "$ac_new_set" = set; then 2076 + case $ac_new_val in 2077 + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; 2078 + *) ac_arg=$ac_var=$ac_new_val ;; 2079 + esac 2080 + case " $ac_configure_args " in 2081 + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. 2082 + *) as_fn_append ac_configure_args " '$ac_arg'" ;; 2083 + esac 2084 + fi 2085 +done 2086 +if $ac_cache_corrupted; then 2087 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 2088 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 2089 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 2090 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} 2091 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 2092 +fi 2093 +## -------------------- ## 2094 +## Main body of script. ## 2095 +## -------------------- ## 2096 + 2097 +ac_ext=c 2098 +ac_cpp='$CPP $CPPFLAGS' 2099 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 2100 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 2101 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 2102 + 2103 + 2104 + 2105 +#-------------------------------------------------------------------- 2106 +# Call TEA_INIT as the first TEA_ macro to set up initial vars. 2107 +# This will define a ${TEA_PLATFORM} variable == "unix" or "windows" 2108 +# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE. 2109 +#-------------------------------------------------------------------- 2110 + 2111 + 2112 + TEA_VERSION="3.13" 2113 + 2114 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking TEA configuration" >&5 2115 +$as_echo_n "checking TEA configuration... " >&6; } 2116 + if test x"${PACKAGE_NAME}" = x ; then 2117 + as_fn_error $? " 2118 +The PACKAGE_NAME variable must be defined by your TEA configure.ac" "$LINENO" 5 2119 + fi 2120 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok (TEA ${TEA_VERSION})" >&5 2121 +$as_echo "ok (TEA ${TEA_VERSION})" >&6; } 2122 + 2123 + # If the user did not set CFLAGS, set it now to keep macros 2124 + # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2". 2125 + if test "${CFLAGS+set}" != "set" ; then 2126 + CFLAGS="" 2127 + fi 2128 + 2129 + case "`uname -s`" in 2130 + *win32*|*WIN32*|*MINGW32_*|*MINGW64_*) 2131 + # Extract the first word of "cygpath", so it can be a program name with args. 2132 +set dummy cygpath; ac_word=$2 2133 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2134 +$as_echo_n "checking for $ac_word... " >&6; } 2135 +if ${ac_cv_prog_CYGPATH+:} false; then : 2136 + $as_echo_n "(cached) " >&6 2137 +else 2138 + if test -n "$CYGPATH"; then 2139 + ac_cv_prog_CYGPATH="$CYGPATH" # Let the user override the test. 2140 +else 2141 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2142 +for as_dir in $PATH 2143 +do 2144 + IFS=$as_save_IFS 2145 + test -z "$as_dir" && as_dir=. 2146 + for ac_exec_ext in '' $ac_executable_extensions; do 2147 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2148 + ac_cv_prog_CYGPATH="cygpath -m" 2149 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2150 + break 2 2151 + fi 2152 +done 2153 + done 2154 +IFS=$as_save_IFS 2155 + 2156 + test -z "$ac_cv_prog_CYGPATH" && ac_cv_prog_CYGPATH="echo" 2157 +fi 2158 +fi 2159 +CYGPATH=$ac_cv_prog_CYGPATH 2160 +if test -n "$CYGPATH"; then 2161 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5 2162 +$as_echo "$CYGPATH" >&6; } 2163 +else 2164 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2165 +$as_echo "no" >&6; } 2166 +fi 2167 + 2168 + 2169 + EXEEXT=".exe" 2170 + TEA_PLATFORM="windows" 2171 + ;; 2172 + *CYGWIN_*) 2173 + EXEEXT=".exe" 2174 + # CYGPATH and TEA_PLATFORM are determined later in LOAD_TCLCONFIG 2175 + ;; 2176 + *) 2177 + CYGPATH=echo 2178 + # Maybe we are cross-compiling.... 2179 + case ${host_alias} in 2180 + *mingw32*) 2181 + EXEEXT=".exe" 2182 + TEA_PLATFORM="windows" 2183 + ;; 2184 + *) 2185 + EXEEXT="" 2186 + TEA_PLATFORM="unix" 2187 + ;; 2188 + esac 2189 + ;; 2190 + esac 2191 + 2192 + # Check if exec_prefix is set. If not use fall back to prefix. 2193 + # Note when adjusted, so that TEA_PREFIX can correct for this. 2194 + # This is needed for recursive configures, since autoconf propagates 2195 + # $prefix, but not $exec_prefix (doh!). 2196 + if test x$exec_prefix = xNONE ; then 2197 + exec_prefix_default=yes 2198 + exec_prefix=$prefix 2199 + fi 2200 + 2201 + { $as_echo "$as_me:${as_lineno-$LINENO}: configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}" >&5 2202 +$as_echo "$as_me: configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}" >&6;} 2203 + 2204 + 2205 + 2206 + 2207 + # This package name must be replaced statically for AC_SUBST to work 2208 + 2209 + # Substitute STUB_LIB_FILE in case package creates a stub library too. 2210 + 2211 + 2212 + # We AC_SUBST these here to ensure they are subst'ed, 2213 + # in case the user doesn't call TEA_ADD_... 2214 + 2215 + 2216 + 2217 + 2218 + 2219 + 2220 + 2221 + 2222 + # Configure the installer. 2223 + 2224 + INSTALL='$(SHELL) $(srcdir)/tclconfig/install-sh -c' 2225 + INSTALL_DATA_DIR='${INSTALL} -d -m 755' 2226 + INSTALL_DATA='${INSTALL} -m 644' 2227 + INSTALL_PROGRAM='${INSTALL} -m 755' 2228 + INSTALL_SCRIPT='${INSTALL} -m 755' 2229 + 2230 + 2231 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 2232 +$as_echo_n "checking system version... " >&6; } 2233 +if ${tcl_cv_sys_version+:} false; then : 2234 + $as_echo_n "(cached) " >&6 2235 +else 2236 + 2237 + # TEA specific: 2238 + if test "${TEA_PLATFORM}" = "windows" ; then 2239 + tcl_cv_sys_version=windows 2240 + else 2241 + tcl_cv_sys_version=`uname -s`-`uname -r` 2242 + if test "$?" -ne 0 ; then 2243 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 2244 +$as_echo "$as_me: WARNING: can't find uname command" >&2;} 2245 + tcl_cv_sys_version=unknown 2246 + else 2247 + if test "`uname -s`" = "AIX" ; then 2248 + tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 2249 + fi 2250 + fi 2251 + fi 2252 + 2253 +fi 2254 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 2255 +$as_echo "$tcl_cv_sys_version" >&6; } 2256 + system=$tcl_cv_sys_version 2257 + 2258 + case $system in 2259 + HP-UX-*) INSTALL_LIBRARY='${INSTALL} -m 755' ;; 2260 + *) INSTALL_LIBRARY='${INSTALL} -m 644' ;; 2261 + esac 2262 + 2263 + 2264 + 2265 + 2266 + 2267 + 2268 + 2269 + 2270 + 2271 + 2272 +ac_aux_dir= 2273 +for ac_dir in ../../tclconfig "$srcdir"/../../tclconfig; do 2274 + if test -f "$ac_dir/install-sh"; then 2275 + ac_aux_dir=$ac_dir 2276 + ac_install_sh="$ac_aux_dir/install-sh -c" 2277 + break 2278 + elif test -f "$ac_dir/install.sh"; then 2279 + ac_aux_dir=$ac_dir 2280 + ac_install_sh="$ac_aux_dir/install.sh -c" 2281 + break 2282 + elif test -f "$ac_dir/shtool"; then 2283 + ac_aux_dir=$ac_dir 2284 + ac_install_sh="$ac_aux_dir/shtool install -c" 2285 + break 2286 + fi 2287 +done 2288 +if test -z "$ac_aux_dir"; then 2289 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in ../../tclconfig \"$srcdir\"/../../tclconfig" "$LINENO" 5 2290 +fi 2291 + 2292 +# These three variables are undocumented and unsupported, 2293 +# and are intended to be withdrawn in a future Autoconf release. 2294 +# They can cause serious problems if a builder's source tree is in a directory 2295 +# whose full name contains unusual characters. 2296 +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. 2297 +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. 2298 +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. 2299 + 2300 + 2301 + 2302 +#-------------------------------------------------------------------- 2303 +# Load the tclConfig.sh file 2304 +#-------------------------------------------------------------------- 2305 + 2306 + 2307 + 2308 + # 2309 + # Ok, lets find the tcl configuration 2310 + # First, look for one uninstalled. 2311 + # the alternative search directory is invoked by --with-tcl 2312 + # 2313 + 2314 + if test x"${no_tcl}" = x ; then 2315 + # we reset no_tcl in case something fails here 2316 + no_tcl=true 2317 + 2318 +# Check whether --with-tcl was given. 2319 +if test "${with_tcl+set}" = set; then : 2320 + withval=$with_tcl; with_tclconfig="${withval}" 2321 +fi 2322 + 2323 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5 2324 +$as_echo_n "checking for Tcl configuration... " >&6; } 2325 + if ${ac_cv_c_tclconfig+:} false; then : 2326 + $as_echo_n "(cached) " >&6 2327 +else 2328 + 2329 + 2330 + # First check to see if --with-tcl was specified. 2331 + if test x"${with_tclconfig}" != x ; then 2332 + case "${with_tclconfig}" in 2333 + */tclConfig.sh ) 2334 + if test -f "${with_tclconfig}"; then 2335 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5 2336 +$as_echo "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;} 2337 + with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`" 2338 + fi ;; 2339 + esac 2340 + if test -f "${with_tclconfig}/tclConfig.sh" ; then 2341 + ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`" 2342 + else 2343 + as_fn_error $? "${with_tclconfig} directory doesn't contain tclConfig.sh" "$LINENO" 5 2344 + fi 2345 + fi 2346 + 2347 + # then check for a private Tcl installation 2348 + if test x"${ac_cv_c_tclconfig}" = x ; then 2349 + for i in \ 2350 + ../tcl \ 2351 + `ls -dr ../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ 2352 + `ls -dr ../tcl[8-9].[0-9] 2>/dev/null` \ 2353 + `ls -dr ../tcl[8-9].[0-9]* 2>/dev/null` \ 2354 + ../../tcl \ 2355 + `ls -dr ../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ 2356 + `ls -dr ../../tcl[8-9].[0-9] 2>/dev/null` \ 2357 + `ls -dr ../../tcl[8-9].[0-9]* 2>/dev/null` \ 2358 + ../../../tcl \ 2359 + `ls -dr ../../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ 2360 + `ls -dr ../../../tcl[8-9].[0-9] 2>/dev/null` \ 2361 + `ls -dr ../../../tcl[8-9].[0-9]* 2>/dev/null` ; do 2362 + if test "${TEA_PLATFORM}" = "windows" \ 2363 + -a -f "$i/win/tclConfig.sh" ; then 2364 + ac_cv_c_tclconfig="`(cd $i/win; pwd)`" 2365 + break 2366 + fi 2367 + if test -f "$i/unix/tclConfig.sh" ; then 2368 + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" 2369 + break 2370 + fi 2371 + done 2372 + fi 2373 + 2374 + # on Darwin, check in Framework installation locations 2375 + if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then 2376 + for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ 2377 + `ls -d /Library/Frameworks 2>/dev/null` \ 2378 + `ls -d /Network/Library/Frameworks 2>/dev/null` \ 2379 + `ls -d /System/Library/Frameworks 2>/dev/null` \ 2380 + `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2381 + `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Network/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2382 + `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2383 + ; do 2384 + if test -f "$i/Tcl.framework/tclConfig.sh" ; then 2385 + ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" 2386 + break 2387 + fi 2388 + done 2389 + fi 2390 + 2391 + # TEA specific: on Windows, check in common installation locations 2392 + if test "${TEA_PLATFORM}" = "windows" \ 2393 + -a x"${ac_cv_c_tclconfig}" = x ; then 2394 + for i in `ls -d C:/Tcl/lib 2>/dev/null` \ 2395 + `ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \ 2396 + ; do 2397 + if test -f "$i/tclConfig.sh" ; then 2398 + ac_cv_c_tclconfig="`(cd $i; pwd)`" 2399 + break 2400 + fi 2401 + done 2402 + fi 2403 + 2404 + # check in a few common install locations 2405 + if test x"${ac_cv_c_tclconfig}" = x ; then 2406 + for i in `ls -d ${libdir} 2>/dev/null` \ 2407 + `ls -d ${exec_prefix}/lib 2>/dev/null` \ 2408 + `ls -d ${prefix}/lib 2>/dev/null` \ 2409 + `ls -d /usr/local/lib 2>/dev/null` \ 2410 + `ls -d /usr/contrib/lib 2>/dev/null` \ 2411 + `ls -d /usr/pkg/lib 2>/dev/null` \ 2412 + `ls -d /usr/lib 2>/dev/null` \ 2413 + `ls -d /usr/lib64 2>/dev/null` \ 2414 + `ls -d /usr/lib/tcl8.6 2>/dev/null` \ 2415 + `ls -d /usr/lib/tcl8.5 2>/dev/null` \ 2416 + `ls -d /usr/local/lib/tcl8.6 2>/dev/null` \ 2417 + `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \ 2418 + `ls -d /usr/local/lib/tcl/tcl8.6 2>/dev/null` \ 2419 + `ls -d /usr/local/lib/tcl/tcl8.5 2>/dev/null` \ 2420 + ; do 2421 + if test -f "$i/tclConfig.sh" ; then 2422 + ac_cv_c_tclconfig="`(cd $i; pwd)`" 2423 + break 2424 + fi 2425 + done 2426 + fi 2427 + 2428 + # check in a few other private locations 2429 + if test x"${ac_cv_c_tclconfig}" = x ; then 2430 + for i in \ 2431 + ${srcdir}/../tcl \ 2432 + `ls -dr ${srcdir}/../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \ 2433 + `ls -dr ${srcdir}/../tcl[8-9].[0-9] 2>/dev/null` \ 2434 + `ls -dr ${srcdir}/../tcl[8-9].[0-9]* 2>/dev/null` ; do 2435 + if test "${TEA_PLATFORM}" = "windows" \ 2436 + -a -f "$i/win/tclConfig.sh" ; then 2437 + ac_cv_c_tclconfig="`(cd $i/win; pwd)`" 2438 + break 2439 + fi 2440 + if test -f "$i/unix/tclConfig.sh" ; then 2441 + ac_cv_c_tclconfig="`(cd $i/unix; pwd)`" 2442 + break 2443 + fi 2444 + done 2445 + fi 2446 + 2447 +fi 2448 + 2449 + 2450 + if test x"${ac_cv_c_tclconfig}" = x ; then 2451 + TCL_BIN_DIR="# no Tcl configs found" 2452 + as_fn_error $? "Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh" "$LINENO" 5 2453 + else 2454 + no_tcl= 2455 + TCL_BIN_DIR="${ac_cv_c_tclconfig}" 2456 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5 2457 +$as_echo "found ${TCL_BIN_DIR}/tclConfig.sh" >&6; } 2458 + fi 2459 + fi 2460 + 2461 +ac_ext=c 2462 +ac_cpp='$CPP $CPPFLAGS' 2463 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 2464 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 2465 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 2466 +if test -n "$ac_tool_prefix"; then 2467 + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. 2468 +set dummy ${ac_tool_prefix}gcc; ac_word=$2 2469 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2470 +$as_echo_n "checking for $ac_word... " >&6; } 2471 +if ${ac_cv_prog_CC+:} false; then : 2472 + $as_echo_n "(cached) " >&6 2473 +else 2474 + if test -n "$CC"; then 2475 + ac_cv_prog_CC="$CC" # Let the user override the test. 2476 +else 2477 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2478 +for as_dir in $PATH 2479 +do 2480 + IFS=$as_save_IFS 2481 + test -z "$as_dir" && as_dir=. 2482 + for ac_exec_ext in '' $ac_executable_extensions; do 2483 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2484 + ac_cv_prog_CC="${ac_tool_prefix}gcc" 2485 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2486 + break 2 2487 + fi 2488 +done 2489 + done 2490 +IFS=$as_save_IFS 2491 + 2492 +fi 2493 +fi 2494 +CC=$ac_cv_prog_CC 2495 +if test -n "$CC"; then 2496 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 2497 +$as_echo "$CC" >&6; } 2498 +else 2499 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2500 +$as_echo "no" >&6; } 2501 +fi 2502 + 2503 + 2504 +fi 2505 +if test -z "$ac_cv_prog_CC"; then 2506 + ac_ct_CC=$CC 2507 + # Extract the first word of "gcc", so it can be a program name with args. 2508 +set dummy gcc; ac_word=$2 2509 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2510 +$as_echo_n "checking for $ac_word... " >&6; } 2511 +if ${ac_cv_prog_ac_ct_CC+:} false; then : 2512 + $as_echo_n "(cached) " >&6 2513 +else 2514 + if test -n "$ac_ct_CC"; then 2515 + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. 2516 +else 2517 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2518 +for as_dir in $PATH 2519 +do 2520 + IFS=$as_save_IFS 2521 + test -z "$as_dir" && as_dir=. 2522 + for ac_exec_ext in '' $ac_executable_extensions; do 2523 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2524 + ac_cv_prog_ac_ct_CC="gcc" 2525 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2526 + break 2 2527 + fi 2528 +done 2529 + done 2530 +IFS=$as_save_IFS 2531 + 2532 +fi 2533 +fi 2534 +ac_ct_CC=$ac_cv_prog_ac_ct_CC 2535 +if test -n "$ac_ct_CC"; then 2536 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 2537 +$as_echo "$ac_ct_CC" >&6; } 2538 +else 2539 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2540 +$as_echo "no" >&6; } 2541 +fi 2542 + 2543 + if test "x$ac_ct_CC" = x; then 2544 + CC="" 2545 + else 2546 + case $cross_compiling:$ac_tool_warned in 2547 +yes:) 2548 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 2549 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 2550 +ac_tool_warned=yes ;; 2551 +esac 2552 + CC=$ac_ct_CC 2553 + fi 2554 +else 2555 + CC="$ac_cv_prog_CC" 2556 +fi 2557 + 2558 +if test -z "$CC"; then 2559 + if test -n "$ac_tool_prefix"; then 2560 + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. 2561 +set dummy ${ac_tool_prefix}cc; ac_word=$2 2562 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2563 +$as_echo_n "checking for $ac_word... " >&6; } 2564 +if ${ac_cv_prog_CC+:} false; then : 2565 + $as_echo_n "(cached) " >&6 2566 +else 2567 + if test -n "$CC"; then 2568 + ac_cv_prog_CC="$CC" # Let the user override the test. 2569 +else 2570 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2571 +for as_dir in $PATH 2572 +do 2573 + IFS=$as_save_IFS 2574 + test -z "$as_dir" && as_dir=. 2575 + for ac_exec_ext in '' $ac_executable_extensions; do 2576 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2577 + ac_cv_prog_CC="${ac_tool_prefix}cc" 2578 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2579 + break 2 2580 + fi 2581 +done 2582 + done 2583 +IFS=$as_save_IFS 2584 + 2585 +fi 2586 +fi 2587 +CC=$ac_cv_prog_CC 2588 +if test -n "$CC"; then 2589 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 2590 +$as_echo "$CC" >&6; } 2591 +else 2592 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2593 +$as_echo "no" >&6; } 2594 +fi 2595 + 2596 + 2597 + fi 2598 +fi 2599 +if test -z "$CC"; then 2600 + # Extract the first word of "cc", so it can be a program name with args. 2601 +set dummy cc; ac_word=$2 2602 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2603 +$as_echo_n "checking for $ac_word... " >&6; } 2604 +if ${ac_cv_prog_CC+:} false; then : 2605 + $as_echo_n "(cached) " >&6 2606 +else 2607 + if test -n "$CC"; then 2608 + ac_cv_prog_CC="$CC" # Let the user override the test. 2609 +else 2610 + ac_prog_rejected=no 2611 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2612 +for as_dir in $PATH 2613 +do 2614 + IFS=$as_save_IFS 2615 + test -z "$as_dir" && as_dir=. 2616 + for ac_exec_ext in '' $ac_executable_extensions; do 2617 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2618 + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then 2619 + ac_prog_rejected=yes 2620 + continue 2621 + fi 2622 + ac_cv_prog_CC="cc" 2623 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2624 + break 2 2625 + fi 2626 +done 2627 + done 2628 +IFS=$as_save_IFS 2629 + 2630 +if test $ac_prog_rejected = yes; then 2631 + # We found a bogon in the path, so make sure we never use it. 2632 + set dummy $ac_cv_prog_CC 2633 + shift 2634 + if test $# != 0; then 2635 + # We chose a different compiler from the bogus one. 2636 + # However, it has the same basename, so the bogon will be chosen 2637 + # first if we set CC to just the basename; use the full file name. 2638 + shift 2639 + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" 2640 + fi 2641 +fi 2642 +fi 2643 +fi 2644 +CC=$ac_cv_prog_CC 2645 +if test -n "$CC"; then 2646 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 2647 +$as_echo "$CC" >&6; } 2648 +else 2649 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2650 +$as_echo "no" >&6; } 2651 +fi 2652 + 2653 + 2654 +fi 2655 +if test -z "$CC"; then 2656 + if test -n "$ac_tool_prefix"; then 2657 + for ac_prog in cl.exe 2658 + do 2659 + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. 2660 +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 2661 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2662 +$as_echo_n "checking for $ac_word... " >&6; } 2663 +if ${ac_cv_prog_CC+:} false; then : 2664 + $as_echo_n "(cached) " >&6 2665 +else 2666 + if test -n "$CC"; then 2667 + ac_cv_prog_CC="$CC" # Let the user override the test. 2668 +else 2669 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2670 +for as_dir in $PATH 2671 +do 2672 + IFS=$as_save_IFS 2673 + test -z "$as_dir" && as_dir=. 2674 + for ac_exec_ext in '' $ac_executable_extensions; do 2675 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2676 + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" 2677 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2678 + break 2 2679 + fi 2680 +done 2681 + done 2682 +IFS=$as_save_IFS 2683 + 2684 +fi 2685 +fi 2686 +CC=$ac_cv_prog_CC 2687 +if test -n "$CC"; then 2688 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 2689 +$as_echo "$CC" >&6; } 2690 +else 2691 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2692 +$as_echo "no" >&6; } 2693 +fi 2694 + 2695 + 2696 + test -n "$CC" && break 2697 + done 2698 +fi 2699 +if test -z "$CC"; then 2700 + ac_ct_CC=$CC 2701 + for ac_prog in cl.exe 2702 +do 2703 + # Extract the first word of "$ac_prog", so it can be a program name with args. 2704 +set dummy $ac_prog; ac_word=$2 2705 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2706 +$as_echo_n "checking for $ac_word... " >&6; } 2707 +if ${ac_cv_prog_ac_ct_CC+:} false; then : 2708 + $as_echo_n "(cached) " >&6 2709 +else 2710 + if test -n "$ac_ct_CC"; then 2711 + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. 2712 +else 2713 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 2714 +for as_dir in $PATH 2715 +do 2716 + IFS=$as_save_IFS 2717 + test -z "$as_dir" && as_dir=. 2718 + for ac_exec_ext in '' $ac_executable_extensions; do 2719 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2720 + ac_cv_prog_ac_ct_CC="$ac_prog" 2721 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 2722 + break 2 2723 + fi 2724 +done 2725 + done 2726 +IFS=$as_save_IFS 2727 + 2728 +fi 2729 +fi 2730 +ac_ct_CC=$ac_cv_prog_ac_ct_CC 2731 +if test -n "$ac_ct_CC"; then 2732 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 2733 +$as_echo "$ac_ct_CC" >&6; } 2734 +else 2735 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2736 +$as_echo "no" >&6; } 2737 +fi 2738 + 2739 + 2740 + test -n "$ac_ct_CC" && break 2741 +done 2742 + 2743 + if test "x$ac_ct_CC" = x; then 2744 + CC="" 2745 + else 2746 + case $cross_compiling:$ac_tool_warned in 2747 +yes:) 2748 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 2749 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 2750 +ac_tool_warned=yes ;; 2751 +esac 2752 + CC=$ac_ct_CC 2753 + fi 2754 +fi 2755 + 2756 +fi 2757 + 2758 + 2759 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 2760 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 2761 +as_fn_error $? "no acceptable C compiler found in \$PATH 2762 +See \`config.log' for more details" "$LINENO" 5; } 2763 + 2764 +# Provide some information about the compiler. 2765 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 2766 +set X $ac_compile 2767 +ac_compiler=$2 2768 +for ac_option in --version -v -V -qversion; do 2769 + { { ac_try="$ac_compiler $ac_option >&5" 2770 +case "(($ac_try" in 2771 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 2772 + *) ac_try_echo=$ac_try;; 2773 +esac 2774 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 2775 +$as_echo "$ac_try_echo"; } >&5 2776 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err 2777 + ac_status=$? 2778 + if test -s conftest.err; then 2779 + sed '10a\ 2780 +... rest of stderr output deleted ... 2781 + 10q' conftest.err >conftest.er1 2782 + cat conftest.er1 >&5 2783 + fi 2784 + rm -f conftest.er1 conftest.err 2785 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 2786 + test $ac_status = 0; } 2787 +done 2788 + 2789 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 2790 +/* end confdefs.h. */ 2791 + 2792 +int 2793 +main () 2794 +{ 2795 + 2796 + ; 2797 + return 0; 2798 +} 2799 +_ACEOF 2800 +ac_clean_files_save=$ac_clean_files 2801 +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" 2802 +# Try to create an executable without -o first, disregard a.out. 2803 +# It will help us diagnose broken compilers, and finding out an intuition 2804 +# of exeext. 2805 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 2806 +$as_echo_n "checking whether the C compiler works... " >&6; } 2807 +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` 2808 + 2809 +# The possible output files: 2810 +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" 2811 + 2812 +ac_rmfiles= 2813 +for ac_file in $ac_files 2814 +do 2815 + case $ac_file in 2816 + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; 2817 + * ) ac_rmfiles="$ac_rmfiles $ac_file";; 2818 + esac 2819 +done 2820 +rm -f $ac_rmfiles 2821 + 2822 +if { { ac_try="$ac_link_default" 2823 +case "(($ac_try" in 2824 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 2825 + *) ac_try_echo=$ac_try;; 2826 +esac 2827 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 2828 +$as_echo "$ac_try_echo"; } >&5 2829 + (eval "$ac_link_default") 2>&5 2830 + ac_status=$? 2831 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 2832 + test $ac_status = 0; }; then : 2833 + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. 2834 +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' 2835 +# in a Makefile. We should not override ac_cv_exeext if it was cached, 2836 +# so that the user can short-circuit this test for compilers unknown to 2837 +# Autoconf. 2838 +for ac_file in $ac_files '' 2839 +do 2840 + test -f "$ac_file" || continue 2841 + case $ac_file in 2842 + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) 2843 + ;; 2844 + [ab].out ) 2845 + # We found the default executable, but exeext='' is most 2846 + # certainly right. 2847 + break;; 2848 + *.* ) 2849 + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; 2850 + then :; else 2851 + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` 2852 + fi 2853 + # We set ac_cv_exeext here because the later test for it is not 2854 + # safe: cross compilers may not add the suffix if given an `-o' 2855 + # argument, so we may need to know it at that point already. 2856 + # Even if this section looks crufty: it has the advantage of 2857 + # actually working. 2858 + break;; 2859 + * ) 2860 + break;; 2861 + esac 2862 +done 2863 +test "$ac_cv_exeext" = no && ac_cv_exeext= 2864 + 2865 +else 2866 + ac_file='' 2867 +fi 2868 +if test -z "$ac_file"; then : 2869 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 2870 +$as_echo "no" >&6; } 2871 +$as_echo "$as_me: failed program was:" >&5 2872 +sed 's/^/| /' conftest.$ac_ext >&5 2873 + 2874 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 2875 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 2876 +as_fn_error 77 "C compiler cannot create executables 2877 +See \`config.log' for more details" "$LINENO" 5; } 2878 +else 2879 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 2880 +$as_echo "yes" >&6; } 2881 +fi 2882 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 2883 +$as_echo_n "checking for C compiler default output file name... " >&6; } 2884 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 2885 +$as_echo "$ac_file" >&6; } 2886 +ac_exeext=$ac_cv_exeext 2887 + 2888 +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out 2889 +ac_clean_files=$ac_clean_files_save 2890 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 2891 +$as_echo_n "checking for suffix of executables... " >&6; } 2892 +if { { ac_try="$ac_link" 2893 +case "(($ac_try" in 2894 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 2895 + *) ac_try_echo=$ac_try;; 2896 +esac 2897 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 2898 +$as_echo "$ac_try_echo"; } >&5 2899 + (eval "$ac_link") 2>&5 2900 + ac_status=$? 2901 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 2902 + test $ac_status = 0; }; then : 2903 + # If both `conftest.exe' and `conftest' are `present' (well, observable) 2904 +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will 2905 +# work properly (i.e., refer to `conftest.exe'), while it won't with 2906 +# `rm'. 2907 +for ac_file in conftest.exe conftest conftest.*; do 2908 + test -f "$ac_file" || continue 2909 + case $ac_file in 2910 + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; 2911 + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` 2912 + break;; 2913 + * ) break;; 2914 + esac 2915 +done 2916 +else 2917 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 2918 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 2919 +as_fn_error $? "cannot compute suffix of executables: cannot compile and link 2920 +See \`config.log' for more details" "$LINENO" 5; } 2921 +fi 2922 +rm -f conftest conftest$ac_cv_exeext 2923 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 2924 +$as_echo "$ac_cv_exeext" >&6; } 2925 + 2926 +rm -f conftest.$ac_ext 2927 +EXEEXT=$ac_cv_exeext 2928 +ac_exeext=$EXEEXT 2929 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 2930 +/* end confdefs.h. */ 2931 +#include <stdio.h> 2932 +int 2933 +main () 2934 +{ 2935 +FILE *f = fopen ("conftest.out", "w"); 2936 + return ferror (f) || fclose (f) != 0; 2937 + 2938 + ; 2939 + return 0; 2940 +} 2941 +_ACEOF 2942 +ac_clean_files="$ac_clean_files conftest.out" 2943 +# Check that the compiler produces executables we can run. If not, either 2944 +# the compiler is broken, or we cross compile. 2945 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 2946 +$as_echo_n "checking whether we are cross compiling... " >&6; } 2947 +if test "$cross_compiling" != yes; then 2948 + { { ac_try="$ac_link" 2949 +case "(($ac_try" in 2950 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 2951 + *) ac_try_echo=$ac_try;; 2952 +esac 2953 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 2954 +$as_echo "$ac_try_echo"; } >&5 2955 + (eval "$ac_link") 2>&5 2956 + ac_status=$? 2957 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 2958 + test $ac_status = 0; } 2959 + if { ac_try='./conftest$ac_cv_exeext' 2960 + { { case "(($ac_try" in 2961 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 2962 + *) ac_try_echo=$ac_try;; 2963 +esac 2964 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 2965 +$as_echo "$ac_try_echo"; } >&5 2966 + (eval "$ac_try") 2>&5 2967 + ac_status=$? 2968 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 2969 + test $ac_status = 0; }; }; then 2970 + cross_compiling=no 2971 + else 2972 + if test "$cross_compiling" = maybe; then 2973 + cross_compiling=yes 2974 + else 2975 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 2976 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 2977 +as_fn_error $? "cannot run C compiled programs. 2978 +If you meant to cross compile, use \`--host'. 2979 +See \`config.log' for more details" "$LINENO" 5; } 2980 + fi 2981 + fi 2982 +fi 2983 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 2984 +$as_echo "$cross_compiling" >&6; } 2985 + 2986 +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out 2987 +ac_clean_files=$ac_clean_files_save 2988 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 2989 +$as_echo_n "checking for suffix of object files... " >&6; } 2990 +if ${ac_cv_objext+:} false; then : 2991 + $as_echo_n "(cached) " >&6 2992 +else 2993 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 2994 +/* end confdefs.h. */ 2995 + 2996 +int 2997 +main () 2998 +{ 2999 + 3000 + ; 3001 + return 0; 3002 +} 3003 +_ACEOF 3004 +rm -f conftest.o conftest.obj 3005 +if { { ac_try="$ac_compile" 3006 +case "(($ac_try" in 3007 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 3008 + *) ac_try_echo=$ac_try;; 3009 +esac 3010 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 3011 +$as_echo "$ac_try_echo"; } >&5 3012 + (eval "$ac_compile") 2>&5 3013 + ac_status=$? 3014 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 3015 + test $ac_status = 0; }; then : 3016 + for ac_file in conftest.o conftest.obj conftest.*; do 3017 + test -f "$ac_file" || continue; 3018 + case $ac_file in 3019 + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; 3020 + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` 3021 + break;; 3022 + esac 3023 +done 3024 +else 3025 + $as_echo "$as_me: failed program was:" >&5 3026 +sed 's/^/| /' conftest.$ac_ext >&5 3027 + 3028 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 3029 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 3030 +as_fn_error $? "cannot compute suffix of object files: cannot compile 3031 +See \`config.log' for more details" "$LINENO" 5; } 3032 +fi 3033 +rm -f conftest.$ac_cv_objext conftest.$ac_ext 3034 +fi 3035 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 3036 +$as_echo "$ac_cv_objext" >&6; } 3037 +OBJEXT=$ac_cv_objext 3038 +ac_objext=$OBJEXT 3039 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 3040 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } 3041 +if ${ac_cv_c_compiler_gnu+:} false; then : 3042 + $as_echo_n "(cached) " >&6 3043 +else 3044 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3045 +/* end confdefs.h. */ 3046 + 3047 +int 3048 +main () 3049 +{ 3050 +#ifndef __GNUC__ 3051 + choke me 3052 +#endif 3053 + 3054 + ; 3055 + return 0; 3056 +} 3057 +_ACEOF 3058 +if ac_fn_c_try_compile "$LINENO"; then : 3059 + ac_compiler_gnu=yes 3060 +else 3061 + ac_compiler_gnu=no 3062 +fi 3063 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3064 +ac_cv_c_compiler_gnu=$ac_compiler_gnu 3065 + 3066 +fi 3067 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 3068 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } 3069 +if test $ac_compiler_gnu = yes; then 3070 + GCC=yes 3071 +else 3072 + GCC= 3073 +fi 3074 +ac_test_CFLAGS=${CFLAGS+set} 3075 +ac_save_CFLAGS=$CFLAGS 3076 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 3077 +$as_echo_n "checking whether $CC accepts -g... " >&6; } 3078 +if ${ac_cv_prog_cc_g+:} false; then : 3079 + $as_echo_n "(cached) " >&6 3080 +else 3081 + ac_save_c_werror_flag=$ac_c_werror_flag 3082 + ac_c_werror_flag=yes 3083 + ac_cv_prog_cc_g=no 3084 + CFLAGS="-g" 3085 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3086 +/* end confdefs.h. */ 3087 + 3088 +int 3089 +main () 3090 +{ 3091 + 3092 + ; 3093 + return 0; 3094 +} 3095 +_ACEOF 3096 +if ac_fn_c_try_compile "$LINENO"; then : 3097 + ac_cv_prog_cc_g=yes 3098 +else 3099 + CFLAGS="" 3100 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3101 +/* end confdefs.h. */ 3102 + 3103 +int 3104 +main () 3105 +{ 3106 + 3107 + ; 3108 + return 0; 3109 +} 3110 +_ACEOF 3111 +if ac_fn_c_try_compile "$LINENO"; then : 3112 + 3113 +else 3114 + ac_c_werror_flag=$ac_save_c_werror_flag 3115 + CFLAGS="-g" 3116 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3117 +/* end confdefs.h. */ 3118 + 3119 +int 3120 +main () 3121 +{ 3122 + 3123 + ; 3124 + return 0; 3125 +} 3126 +_ACEOF 3127 +if ac_fn_c_try_compile "$LINENO"; then : 3128 + ac_cv_prog_cc_g=yes 3129 +fi 3130 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3131 +fi 3132 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3133 +fi 3134 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3135 + ac_c_werror_flag=$ac_save_c_werror_flag 3136 +fi 3137 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 3138 +$as_echo "$ac_cv_prog_cc_g" >&6; } 3139 +if test "$ac_test_CFLAGS" = set; then 3140 + CFLAGS=$ac_save_CFLAGS 3141 +elif test $ac_cv_prog_cc_g = yes; then 3142 + if test "$GCC" = yes; then 3143 + CFLAGS="-g -O2" 3144 + else 3145 + CFLAGS="-g" 3146 + fi 3147 +else 3148 + if test "$GCC" = yes; then 3149 + CFLAGS="-O2" 3150 + else 3151 + CFLAGS= 3152 + fi 3153 +fi 3154 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 3155 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } 3156 +if ${ac_cv_prog_cc_c89+:} false; then : 3157 + $as_echo_n "(cached) " >&6 3158 +else 3159 + ac_cv_prog_cc_c89=no 3160 +ac_save_CC=$CC 3161 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3162 +/* end confdefs.h. */ 3163 +#include <stdarg.h> 3164 +#include <stdio.h> 3165 +struct stat; 3166 +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ 3167 +struct buf { int x; }; 3168 +FILE * (*rcsopen) (struct buf *, struct stat *, int); 3169 +static char *e (p, i) 3170 + char **p; 3171 + int i; 3172 +{ 3173 + return p[i]; 3174 +} 3175 +static char *f (char * (*g) (char **, int), char **p, ...) 3176 +{ 3177 + char *s; 3178 + va_list v; 3179 + va_start (v,p); 3180 + s = g (p, va_arg (v,int)); 3181 + va_end (v); 3182 + return s; 3183 +} 3184 + 3185 +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has 3186 + function prototypes and stuff, but not '\xHH' hex character constants. 3187 + These don't provoke an error unfortunately, instead are silently treated 3188 + as 'x'. The following induces an error, until -std is added to get 3189 + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an 3190 + array size at least. It's necessary to write '\x00'==0 to get something 3191 + that's true only with -std. */ 3192 +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; 3193 + 3194 +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters 3195 + inside strings and character constants. */ 3196 +#define FOO(x) 'x' 3197 +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; 3198 + 3199 +int test (int i, double x); 3200 +struct s1 {int (*f) (int a);}; 3201 +struct s2 {int (*f) (double a);}; 3202 +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); 3203 +int argc; 3204 +char **argv; 3205 +int 3206 +main () 3207 +{ 3208 +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; 3209 + ; 3210 + return 0; 3211 +} 3212 +_ACEOF 3213 +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ 3214 + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" 3215 +do 3216 + CC="$ac_save_CC $ac_arg" 3217 + if ac_fn_c_try_compile "$LINENO"; then : 3218 + ac_cv_prog_cc_c89=$ac_arg 3219 +fi 3220 +rm -f core conftest.err conftest.$ac_objext 3221 + test "x$ac_cv_prog_cc_c89" != "xno" && break 3222 +done 3223 +rm -f conftest.$ac_ext 3224 +CC=$ac_save_CC 3225 + 3226 +fi 3227 +# AC_CACHE_VAL 3228 +case "x$ac_cv_prog_cc_c89" in 3229 + x) 3230 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 3231 +$as_echo "none needed" >&6; } ;; 3232 + xno) 3233 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 3234 +$as_echo "unsupported" >&6; } ;; 3235 + *) 3236 + CC="$CC $ac_cv_prog_cc_c89" 3237 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 3238 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; 3239 +esac 3240 +if test "x$ac_cv_prog_cc_c89" != xno; then : 3241 + 3242 +fi 3243 + 3244 +ac_ext=c 3245 +ac_cpp='$CPP $CPPFLAGS' 3246 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 3247 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 3248 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 3249 + 3250 + 3251 + 3252 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5 3253 +$as_echo_n "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... " >&6; } 3254 + 3255 + if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then 3256 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5 3257 +$as_echo "loading" >&6; } 3258 + . "${TCL_BIN_DIR}/tclConfig.sh" 3259 + else 3260 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5 3261 +$as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; } 3262 + fi 3263 + 3264 + # eval is required to do the TCL_DBGX substitution 3265 + eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" 3266 + eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" 3267 + 3268 + # If the TCL_BIN_DIR is the build directory (not the install directory), 3269 + # then set the common variable name to the value of the build variables. 3270 + # For example, the variable TCL_LIB_SPEC will be set to the value 3271 + # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC 3272 + # instead of TCL_BUILD_LIB_SPEC since it will work with both an 3273 + # installed and uninstalled version of Tcl. 3274 + if test -f "${TCL_BIN_DIR}/Makefile" ; then 3275 + TCL_LIB_SPEC="${TCL_BUILD_LIB_SPEC}" 3276 + TCL_STUB_LIB_SPEC="${TCL_BUILD_STUB_LIB_SPEC}" 3277 + TCL_STUB_LIB_PATH="${TCL_BUILD_STUB_LIB_PATH}" 3278 + elif test "`uname -s`" = "Darwin"; then 3279 + # If Tcl was built as a framework, attempt to use the libraries 3280 + # from the framework at the given location so that linking works 3281 + # against Tcl.framework installed in an arbitrary location. 3282 + case ${TCL_DEFS} in 3283 + *TCL_FRAMEWORK*) 3284 + if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then 3285 + for i in "`cd "${TCL_BIN_DIR}"; pwd`" \ 3286 + "`cd "${TCL_BIN_DIR}"/../..; pwd`"; do 3287 + if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then 3288 + TCL_LIB_SPEC="-F`dirname "$i" | sed -e 's/ /\\\\ /g'` -framework ${TCL_LIB_FILE}" 3289 + break 3290 + fi 3291 + done 3292 + fi 3293 + if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then 3294 + TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}" 3295 + TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}" 3296 + fi 3297 + ;; 3298 + esac 3299 + fi 3300 + 3301 + # eval is required to do the TCL_DBGX substitution 3302 + eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" 3303 + eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" 3304 + eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" 3305 + eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" 3306 + 3307 + 3308 + 3309 + 3310 + 3311 + 3312 + 3313 + 3314 + 3315 + 3316 + 3317 + 3318 + 3319 + 3320 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking platform" >&5 3321 +$as_echo_n "checking platform... " >&6; } 3322 + hold_cc=$CC; CC="$TCL_CC" 3323 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3324 +/* end confdefs.h. */ 3325 + 3326 +int 3327 +main () 3328 +{ 3329 + 3330 + #ifdef _WIN32 3331 + #error win32 3332 + #endif 3333 + 3334 + ; 3335 + return 0; 3336 +} 3337 +_ACEOF 3338 +if ac_fn_c_try_compile "$LINENO"; then : 3339 + 3340 + TEA_PLATFORM="unix" 3341 + CYGPATH=echo 3342 + 3343 +else 3344 + 3345 + TEA_PLATFORM="windows" 3346 + # Extract the first word of "cygpath", so it can be a program name with args. 3347 +set dummy cygpath; ac_word=$2 3348 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3349 +$as_echo_n "checking for $ac_word... " >&6; } 3350 +if ${ac_cv_prog_CYGPATH+:} false; then : 3351 + $as_echo_n "(cached) " >&6 3352 +else 3353 + if test -n "$CYGPATH"; then 3354 + ac_cv_prog_CYGPATH="$CYGPATH" # Let the user override the test. 3355 +else 3356 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3357 +for as_dir in $PATH 3358 +do 3359 + IFS=$as_save_IFS 3360 + test -z "$as_dir" && as_dir=. 3361 + for ac_exec_ext in '' $ac_executable_extensions; do 3362 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3363 + ac_cv_prog_CYGPATH="cygpath -m" 3364 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3365 + break 2 3366 + fi 3367 +done 3368 + done 3369 +IFS=$as_save_IFS 3370 + 3371 + test -z "$ac_cv_prog_CYGPATH" && ac_cv_prog_CYGPATH="echo" 3372 +fi 3373 +fi 3374 +CYGPATH=$ac_cv_prog_CYGPATH 3375 +if test -n "$CYGPATH"; then 3376 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CYGPATH" >&5 3377 +$as_echo "$CYGPATH" >&6; } 3378 +else 3379 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3380 +$as_echo "no" >&6; } 3381 +fi 3382 + 3383 + 3384 + 3385 +fi 3386 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3387 + CC=$hold_cc 3388 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TEA_PLATFORM" >&5 3389 +$as_echo "$TEA_PLATFORM" >&6; } 3390 + 3391 + # The BUILD_$pkg is to define the correct extern storage class 3392 + # handling when making this package 3393 + 3394 +cat >>confdefs.h <<_ACEOF 3395 +#define BUILD_${PACKAGE_NAME} /**/ 3396 +_ACEOF 3397 + 3398 + # Do this here as we have fully defined TEA_PLATFORM now 3399 + if test "${TEA_PLATFORM}" = "windows" ; then 3400 + EXEEXT=".exe" 3401 + CLEANFILES="$CLEANFILES *.lib *.dll *.pdb *.exp" 3402 + fi 3403 + 3404 + # TEA specific: 3405 + 3406 + 3407 + 3408 + 3409 + 3410 + 3411 + 3412 + 3413 +#-------------------------------------------------------------------- 3414 +# Load the tkConfig.sh file if necessary (Tk extension) 3415 +#-------------------------------------------------------------------- 3416 + 3417 +#TEA_PATH_TKCONFIG 3418 +#TEA_LOAD_TKCONFIG 3419 + 3420 +#----------------------------------------------------------------------- 3421 +# Handle the --prefix=... option by defaulting to what Tcl gave. 3422 +# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER. 3423 +#----------------------------------------------------------------------- 3424 + 3425 + 3426 + if test "${prefix}" = "NONE"; then 3427 + prefix_default=yes 3428 + if test x"${TCL_PREFIX}" != x; then 3429 + { $as_echo "$as_me:${as_lineno-$LINENO}: --prefix defaulting to TCL_PREFIX ${TCL_PREFIX}" >&5 3430 +$as_echo "$as_me: --prefix defaulting to TCL_PREFIX ${TCL_PREFIX}" >&6;} 3431 + prefix=${TCL_PREFIX} 3432 + else 3433 + { $as_echo "$as_me:${as_lineno-$LINENO}: --prefix defaulting to /usr/local" >&5 3434 +$as_echo "$as_me: --prefix defaulting to /usr/local" >&6;} 3435 + prefix=/usr/local 3436 + fi 3437 + fi 3438 + if test "${exec_prefix}" = "NONE" -a x"${prefix_default}" = x"yes" \ 3439 + -o x"${exec_prefix_default}" = x"yes" ; then 3440 + if test x"${TCL_EXEC_PREFIX}" != x; then 3441 + { $as_echo "$as_me:${as_lineno-$LINENO}: --exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}" >&5 3442 +$as_echo "$as_me: --exec-prefix defaulting to TCL_EXEC_PREFIX ${TCL_EXEC_PREFIX}" >&6;} 3443 + exec_prefix=${TCL_EXEC_PREFIX} 3444 + else 3445 + { $as_echo "$as_me:${as_lineno-$LINENO}: --exec-prefix defaulting to ${prefix}" >&5 3446 +$as_echo "$as_me: --exec-prefix defaulting to ${prefix}" >&6;} 3447 + exec_prefix=$prefix 3448 + fi 3449 + fi 3450 + 3451 + 3452 +#----------------------------------------------------------------------- 3453 +# Standard compiler checks. 3454 +# This sets up CC by using the CC env var, or looks for gcc otherwise. 3455 +# This also calls AC_PROG_CC and a few others to create the basic setup 3456 +# necessary to compile executables. 3457 +#----------------------------------------------------------------------- 3458 + 3459 + 3460 + # Don't put any macros that use the compiler (e.g. AC_TRY_COMPILE) 3461 + # in this macro, they need to go into TEA_SETUP_COMPILER instead. 3462 + 3463 + ac_ext=c 3464 +ac_cpp='$CPP $CPPFLAGS' 3465 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 3466 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 3467 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 3468 +if test -n "$ac_tool_prefix"; then 3469 + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. 3470 +set dummy ${ac_tool_prefix}gcc; ac_word=$2 3471 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3472 +$as_echo_n "checking for $ac_word... " >&6; } 3473 +if ${ac_cv_prog_CC+:} false; then : 3474 + $as_echo_n "(cached) " >&6 3475 +else 3476 + if test -n "$CC"; then 3477 + ac_cv_prog_CC="$CC" # Let the user override the test. 3478 +else 3479 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3480 +for as_dir in $PATH 3481 +do 3482 + IFS=$as_save_IFS 3483 + test -z "$as_dir" && as_dir=. 3484 + for ac_exec_ext in '' $ac_executable_extensions; do 3485 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3486 + ac_cv_prog_CC="${ac_tool_prefix}gcc" 3487 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3488 + break 2 3489 + fi 3490 +done 3491 + done 3492 +IFS=$as_save_IFS 3493 + 3494 +fi 3495 +fi 3496 +CC=$ac_cv_prog_CC 3497 +if test -n "$CC"; then 3498 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 3499 +$as_echo "$CC" >&6; } 3500 +else 3501 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3502 +$as_echo "no" >&6; } 3503 +fi 3504 + 3505 + 3506 +fi 3507 +if test -z "$ac_cv_prog_CC"; then 3508 + ac_ct_CC=$CC 3509 + # Extract the first word of "gcc", so it can be a program name with args. 3510 +set dummy gcc; ac_word=$2 3511 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3512 +$as_echo_n "checking for $ac_word... " >&6; } 3513 +if ${ac_cv_prog_ac_ct_CC+:} false; then : 3514 + $as_echo_n "(cached) " >&6 3515 +else 3516 + if test -n "$ac_ct_CC"; then 3517 + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. 3518 +else 3519 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3520 +for as_dir in $PATH 3521 +do 3522 + IFS=$as_save_IFS 3523 + test -z "$as_dir" && as_dir=. 3524 + for ac_exec_ext in '' $ac_executable_extensions; do 3525 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3526 + ac_cv_prog_ac_ct_CC="gcc" 3527 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3528 + break 2 3529 + fi 3530 +done 3531 + done 3532 +IFS=$as_save_IFS 3533 + 3534 +fi 3535 +fi 3536 +ac_ct_CC=$ac_cv_prog_ac_ct_CC 3537 +if test -n "$ac_ct_CC"; then 3538 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 3539 +$as_echo "$ac_ct_CC" >&6; } 3540 +else 3541 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3542 +$as_echo "no" >&6; } 3543 +fi 3544 + 3545 + if test "x$ac_ct_CC" = x; then 3546 + CC="" 3547 + else 3548 + case $cross_compiling:$ac_tool_warned in 3549 +yes:) 3550 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 3551 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 3552 +ac_tool_warned=yes ;; 3553 +esac 3554 + CC=$ac_ct_CC 3555 + fi 3556 +else 3557 + CC="$ac_cv_prog_CC" 3558 +fi 3559 + 3560 +if test -z "$CC"; then 3561 + if test -n "$ac_tool_prefix"; then 3562 + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. 3563 +set dummy ${ac_tool_prefix}cc; ac_word=$2 3564 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3565 +$as_echo_n "checking for $ac_word... " >&6; } 3566 +if ${ac_cv_prog_CC+:} false; then : 3567 + $as_echo_n "(cached) " >&6 3568 +else 3569 + if test -n "$CC"; then 3570 + ac_cv_prog_CC="$CC" # Let the user override the test. 3571 +else 3572 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3573 +for as_dir in $PATH 3574 +do 3575 + IFS=$as_save_IFS 3576 + test -z "$as_dir" && as_dir=. 3577 + for ac_exec_ext in '' $ac_executable_extensions; do 3578 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3579 + ac_cv_prog_CC="${ac_tool_prefix}cc" 3580 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3581 + break 2 3582 + fi 3583 +done 3584 + done 3585 +IFS=$as_save_IFS 3586 + 3587 +fi 3588 +fi 3589 +CC=$ac_cv_prog_CC 3590 +if test -n "$CC"; then 3591 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 3592 +$as_echo "$CC" >&6; } 3593 +else 3594 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3595 +$as_echo "no" >&6; } 3596 +fi 3597 + 3598 + 3599 + fi 3600 +fi 3601 +if test -z "$CC"; then 3602 + # Extract the first word of "cc", so it can be a program name with args. 3603 +set dummy cc; ac_word=$2 3604 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3605 +$as_echo_n "checking for $ac_word... " >&6; } 3606 +if ${ac_cv_prog_CC+:} false; then : 3607 + $as_echo_n "(cached) " >&6 3608 +else 3609 + if test -n "$CC"; then 3610 + ac_cv_prog_CC="$CC" # Let the user override the test. 3611 +else 3612 + ac_prog_rejected=no 3613 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3614 +for as_dir in $PATH 3615 +do 3616 + IFS=$as_save_IFS 3617 + test -z "$as_dir" && as_dir=. 3618 + for ac_exec_ext in '' $ac_executable_extensions; do 3619 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3620 + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then 3621 + ac_prog_rejected=yes 3622 + continue 3623 + fi 3624 + ac_cv_prog_CC="cc" 3625 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3626 + break 2 3627 + fi 3628 +done 3629 + done 3630 +IFS=$as_save_IFS 3631 + 3632 +if test $ac_prog_rejected = yes; then 3633 + # We found a bogon in the path, so make sure we never use it. 3634 + set dummy $ac_cv_prog_CC 3635 + shift 3636 + if test $# != 0; then 3637 + # We chose a different compiler from the bogus one. 3638 + # However, it has the same basename, so the bogon will be chosen 3639 + # first if we set CC to just the basename; use the full file name. 3640 + shift 3641 + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" 3642 + fi 3643 +fi 3644 +fi 3645 +fi 3646 +CC=$ac_cv_prog_CC 3647 +if test -n "$CC"; then 3648 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 3649 +$as_echo "$CC" >&6; } 3650 +else 3651 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3652 +$as_echo "no" >&6; } 3653 +fi 3654 + 3655 + 3656 +fi 3657 +if test -z "$CC"; then 3658 + if test -n "$ac_tool_prefix"; then 3659 + for ac_prog in cl.exe 3660 + do 3661 + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. 3662 +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 3663 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3664 +$as_echo_n "checking for $ac_word... " >&6; } 3665 +if ${ac_cv_prog_CC+:} false; then : 3666 + $as_echo_n "(cached) " >&6 3667 +else 3668 + if test -n "$CC"; then 3669 + ac_cv_prog_CC="$CC" # Let the user override the test. 3670 +else 3671 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3672 +for as_dir in $PATH 3673 +do 3674 + IFS=$as_save_IFS 3675 + test -z "$as_dir" && as_dir=. 3676 + for ac_exec_ext in '' $ac_executable_extensions; do 3677 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3678 + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" 3679 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3680 + break 2 3681 + fi 3682 +done 3683 + done 3684 +IFS=$as_save_IFS 3685 + 3686 +fi 3687 +fi 3688 +CC=$ac_cv_prog_CC 3689 +if test -n "$CC"; then 3690 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 3691 +$as_echo "$CC" >&6; } 3692 +else 3693 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3694 +$as_echo "no" >&6; } 3695 +fi 3696 + 3697 + 3698 + test -n "$CC" && break 3699 + done 3700 +fi 3701 +if test -z "$CC"; then 3702 + ac_ct_CC=$CC 3703 + for ac_prog in cl.exe 3704 +do 3705 + # Extract the first word of "$ac_prog", so it can be a program name with args. 3706 +set dummy $ac_prog; ac_word=$2 3707 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 3708 +$as_echo_n "checking for $ac_word... " >&6; } 3709 +if ${ac_cv_prog_ac_ct_CC+:} false; then : 3710 + $as_echo_n "(cached) " >&6 3711 +else 3712 + if test -n "$ac_ct_CC"; then 3713 + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. 3714 +else 3715 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 3716 +for as_dir in $PATH 3717 +do 3718 + IFS=$as_save_IFS 3719 + test -z "$as_dir" && as_dir=. 3720 + for ac_exec_ext in '' $ac_executable_extensions; do 3721 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3722 + ac_cv_prog_ac_ct_CC="$ac_prog" 3723 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 3724 + break 2 3725 + fi 3726 +done 3727 + done 3728 +IFS=$as_save_IFS 3729 + 3730 +fi 3731 +fi 3732 +ac_ct_CC=$ac_cv_prog_ac_ct_CC 3733 +if test -n "$ac_ct_CC"; then 3734 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 3735 +$as_echo "$ac_ct_CC" >&6; } 3736 +else 3737 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 3738 +$as_echo "no" >&6; } 3739 +fi 3740 + 3741 + 3742 + test -n "$ac_ct_CC" && break 3743 +done 3744 + 3745 + if test "x$ac_ct_CC" = x; then 3746 + CC="" 3747 + else 3748 + case $cross_compiling:$ac_tool_warned in 3749 +yes:) 3750 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 3751 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 3752 +ac_tool_warned=yes ;; 3753 +esac 3754 + CC=$ac_ct_CC 3755 + fi 3756 +fi 3757 + 3758 +fi 3759 + 3760 + 3761 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 3762 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 3763 +as_fn_error $? "no acceptable C compiler found in \$PATH 3764 +See \`config.log' for more details" "$LINENO" 5; } 3765 + 3766 +# Provide some information about the compiler. 3767 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 3768 +set X $ac_compile 3769 +ac_compiler=$2 3770 +for ac_option in --version -v -V -qversion; do 3771 + { { ac_try="$ac_compiler $ac_option >&5" 3772 +case "(($ac_try" in 3773 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 3774 + *) ac_try_echo=$ac_try;; 3775 +esac 3776 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" 3777 +$as_echo "$ac_try_echo"; } >&5 3778 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err 3779 + ac_status=$? 3780 + if test -s conftest.err; then 3781 + sed '10a\ 3782 +... rest of stderr output deleted ... 3783 + 10q' conftest.err >conftest.er1 3784 + cat conftest.er1 >&5 3785 + fi 3786 + rm -f conftest.er1 conftest.err 3787 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 3788 + test $ac_status = 0; } 3789 +done 3790 + 3791 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 3792 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } 3793 +if ${ac_cv_c_compiler_gnu+:} false; then : 3794 + $as_echo_n "(cached) " >&6 3795 +else 3796 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3797 +/* end confdefs.h. */ 3798 + 3799 +int 3800 +main () 3801 +{ 3802 +#ifndef __GNUC__ 3803 + choke me 3804 +#endif 3805 + 3806 + ; 3807 + return 0; 3808 +} 3809 +_ACEOF 3810 +if ac_fn_c_try_compile "$LINENO"; then : 3811 + ac_compiler_gnu=yes 3812 +else 3813 + ac_compiler_gnu=no 3814 +fi 3815 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3816 +ac_cv_c_compiler_gnu=$ac_compiler_gnu 3817 + 3818 +fi 3819 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 3820 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } 3821 +if test $ac_compiler_gnu = yes; then 3822 + GCC=yes 3823 +else 3824 + GCC= 3825 +fi 3826 +ac_test_CFLAGS=${CFLAGS+set} 3827 +ac_save_CFLAGS=$CFLAGS 3828 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 3829 +$as_echo_n "checking whether $CC accepts -g... " >&6; } 3830 +if ${ac_cv_prog_cc_g+:} false; then : 3831 + $as_echo_n "(cached) " >&6 3832 +else 3833 + ac_save_c_werror_flag=$ac_c_werror_flag 3834 + ac_c_werror_flag=yes 3835 + ac_cv_prog_cc_g=no 3836 + CFLAGS="-g" 3837 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3838 +/* end confdefs.h. */ 3839 + 3840 +int 3841 +main () 3842 +{ 3843 + 3844 + ; 3845 + return 0; 3846 +} 3847 +_ACEOF 3848 +if ac_fn_c_try_compile "$LINENO"; then : 3849 + ac_cv_prog_cc_g=yes 3850 +else 3851 + CFLAGS="" 3852 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3853 +/* end confdefs.h. */ 3854 + 3855 +int 3856 +main () 3857 +{ 3858 + 3859 + ; 3860 + return 0; 3861 +} 3862 +_ACEOF 3863 +if ac_fn_c_try_compile "$LINENO"; then : 3864 + 3865 +else 3866 + ac_c_werror_flag=$ac_save_c_werror_flag 3867 + CFLAGS="-g" 3868 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3869 +/* end confdefs.h. */ 3870 + 3871 +int 3872 +main () 3873 +{ 3874 + 3875 + ; 3876 + return 0; 3877 +} 3878 +_ACEOF 3879 +if ac_fn_c_try_compile "$LINENO"; then : 3880 + ac_cv_prog_cc_g=yes 3881 +fi 3882 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3883 +fi 3884 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3885 +fi 3886 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 3887 + ac_c_werror_flag=$ac_save_c_werror_flag 3888 +fi 3889 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 3890 +$as_echo "$ac_cv_prog_cc_g" >&6; } 3891 +if test "$ac_test_CFLAGS" = set; then 3892 + CFLAGS=$ac_save_CFLAGS 3893 +elif test $ac_cv_prog_cc_g = yes; then 3894 + if test "$GCC" = yes; then 3895 + CFLAGS="-g -O2" 3896 + else 3897 + CFLAGS="-g" 3898 + fi 3899 +else 3900 + if test "$GCC" = yes; then 3901 + CFLAGS="-O2" 3902 + else 3903 + CFLAGS= 3904 + fi 3905 +fi 3906 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 3907 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } 3908 +if ${ac_cv_prog_cc_c89+:} false; then : 3909 + $as_echo_n "(cached) " >&6 3910 +else 3911 + ac_cv_prog_cc_c89=no 3912 +ac_save_CC=$CC 3913 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 3914 +/* end confdefs.h. */ 3915 +#include <stdarg.h> 3916 +#include <stdio.h> 3917 +struct stat; 3918 +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ 3919 +struct buf { int x; }; 3920 +FILE * (*rcsopen) (struct buf *, struct stat *, int); 3921 +static char *e (p, i) 3922 + char **p; 3923 + int i; 3924 +{ 3925 + return p[i]; 3926 +} 3927 +static char *f (char * (*g) (char **, int), char **p, ...) 3928 +{ 3929 + char *s; 3930 + va_list v; 3931 + va_start (v,p); 3932 + s = g (p, va_arg (v,int)); 3933 + va_end (v); 3934 + return s; 3935 +} 3936 + 3937 +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has 3938 + function prototypes and stuff, but not '\xHH' hex character constants. 3939 + These don't provoke an error unfortunately, instead are silently treated 3940 + as 'x'. The following induces an error, until -std is added to get 3941 + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an 3942 + array size at least. It's necessary to write '\x00'==0 to get something 3943 + that's true only with -std. */ 3944 +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; 3945 + 3946 +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters 3947 + inside strings and character constants. */ 3948 +#define FOO(x) 'x' 3949 +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; 3950 + 3951 +int test (int i, double x); 3952 +struct s1 {int (*f) (int a);}; 3953 +struct s2 {int (*f) (double a);}; 3954 +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); 3955 +int argc; 3956 +char **argv; 3957 +int 3958 +main () 3959 +{ 3960 +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; 3961 + ; 3962 + return 0; 3963 +} 3964 +_ACEOF 3965 +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ 3966 + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" 3967 +do 3968 + CC="$ac_save_CC $ac_arg" 3969 + if ac_fn_c_try_compile "$LINENO"; then : 3970 + ac_cv_prog_cc_c89=$ac_arg 3971 +fi 3972 +rm -f core conftest.err conftest.$ac_objext 3973 + test "x$ac_cv_prog_cc_c89" != "xno" && break 3974 +done 3975 +rm -f conftest.$ac_ext 3976 +CC=$ac_save_CC 3977 + 3978 +fi 3979 +# AC_CACHE_VAL 3980 +case "x$ac_cv_prog_cc_c89" in 3981 + x) 3982 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 3983 +$as_echo "none needed" >&6; } ;; 3984 + xno) 3985 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 3986 +$as_echo "unsupported" >&6; } ;; 3987 + *) 3988 + CC="$CC $ac_cv_prog_cc_c89" 3989 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 3990 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; 3991 +esac 3992 +if test "x$ac_cv_prog_cc_c89" != xno; then : 3993 + 3994 +fi 3995 + 3996 +ac_ext=c 3997 +ac_cpp='$CPP $CPPFLAGS' 3998 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 3999 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 4000 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 4001 + 4002 + ac_ext=c 4003 +ac_cpp='$CPP $CPPFLAGS' 4004 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 4005 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 4006 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 4007 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 4008 +$as_echo_n "checking how to run the C preprocessor... " >&6; } 4009 +# On Suns, sometimes $CPP names a directory. 4010 +if test -n "$CPP" && test -d "$CPP"; then 4011 + CPP= 4012 +fi 4013 +if test -z "$CPP"; then 4014 + if ${ac_cv_prog_CPP+:} false; then : 4015 + $as_echo_n "(cached) " >&6 4016 +else 4017 + # Double quotes because CPP needs to be expanded 4018 + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" 4019 + do 4020 + ac_preproc_ok=false 4021 +for ac_c_preproc_warn_flag in '' yes 4022 +do 4023 + # Use a header file that comes with gcc, so configuring glibc 4024 + # with a fresh cross-compiler works. 4025 + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 4026 + # <limits.h> exists even on freestanding compilers. 4027 + # On the NeXT, cc -E runs the code through the compiler's parser, 4028 + # not just through cpp. "Syntax error" is here to catch this case. 4029 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4030 +/* end confdefs.h. */ 4031 +#ifdef __STDC__ 4032 +# include <limits.h> 4033 +#else 4034 +# include <assert.h> 4035 +#endif 4036 + Syntax error 4037 +_ACEOF 4038 +if ac_fn_c_try_cpp "$LINENO"; then : 4039 + 4040 +else 4041 + # Broken: fails on valid input. 4042 +continue 4043 +fi 4044 +rm -f conftest.err conftest.i conftest.$ac_ext 4045 + 4046 + # OK, works on sane cases. Now check whether nonexistent headers 4047 + # can be detected and how. 4048 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4049 +/* end confdefs.h. */ 4050 +#include <ac_nonexistent.h> 4051 +_ACEOF 4052 +if ac_fn_c_try_cpp "$LINENO"; then : 4053 + # Broken: success on invalid input. 4054 +continue 4055 +else 4056 + # Passes both tests. 4057 +ac_preproc_ok=: 4058 +break 4059 +fi 4060 +rm -f conftest.err conftest.i conftest.$ac_ext 4061 + 4062 +done 4063 +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. 4064 +rm -f conftest.i conftest.err conftest.$ac_ext 4065 +if $ac_preproc_ok; then : 4066 + break 4067 +fi 4068 + 4069 + done 4070 + ac_cv_prog_CPP=$CPP 4071 + 4072 +fi 4073 + CPP=$ac_cv_prog_CPP 4074 +else 4075 + ac_cv_prog_CPP=$CPP 4076 +fi 4077 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 4078 +$as_echo "$CPP" >&6; } 4079 +ac_preproc_ok=false 4080 +for ac_c_preproc_warn_flag in '' yes 4081 +do 4082 + # Use a header file that comes with gcc, so configuring glibc 4083 + # with a fresh cross-compiler works. 4084 + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 4085 + # <limits.h> exists even on freestanding compilers. 4086 + # On the NeXT, cc -E runs the code through the compiler's parser, 4087 + # not just through cpp. "Syntax error" is here to catch this case. 4088 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4089 +/* end confdefs.h. */ 4090 +#ifdef __STDC__ 4091 +# include <limits.h> 4092 +#else 4093 +# include <assert.h> 4094 +#endif 4095 + Syntax error 4096 +_ACEOF 4097 +if ac_fn_c_try_cpp "$LINENO"; then : 4098 + 4099 +else 4100 + # Broken: fails on valid input. 4101 +continue 4102 +fi 4103 +rm -f conftest.err conftest.i conftest.$ac_ext 4104 + 4105 + # OK, works on sane cases. Now check whether nonexistent headers 4106 + # can be detected and how. 4107 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4108 +/* end confdefs.h. */ 4109 +#include <ac_nonexistent.h> 4110 +_ACEOF 4111 +if ac_fn_c_try_cpp "$LINENO"; then : 4112 + # Broken: success on invalid input. 4113 +continue 4114 +else 4115 + # Passes both tests. 4116 +ac_preproc_ok=: 4117 +break 4118 +fi 4119 +rm -f conftest.err conftest.i conftest.$ac_ext 4120 + 4121 +done 4122 +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. 4123 +rm -f conftest.i conftest.err conftest.$ac_ext 4124 +if $ac_preproc_ok; then : 4125 + 4126 +else 4127 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 4128 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 4129 +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check 4130 +See \`config.log' for more details" "$LINENO" 5; } 4131 +fi 4132 + 4133 +ac_ext=c 4134 +ac_cpp='$CPP $CPPFLAGS' 4135 +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 4136 +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 4137 +ac_compiler_gnu=$ac_cv_c_compiler_gnu 4138 + 4139 + 4140 + #-------------------------------------------------------------------- 4141 + # Checks to see if the make program sets the $MAKE variable. 4142 + #-------------------------------------------------------------------- 4143 + 4144 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 4145 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } 4146 +set x ${MAKE-make} 4147 +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` 4148 +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : 4149 + $as_echo_n "(cached) " >&6 4150 +else 4151 + cat >conftest.make <<\_ACEOF 4152 +SHELL = /bin/sh 4153 +all: 4154 + @echo '@@@%%%=$(MAKE)=@@@%%%' 4155 +_ACEOF 4156 +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. 4157 +case `${MAKE-make} -f conftest.make 2>/dev/null` in 4158 + *@@@%%%=?*=@@@%%%*) 4159 + eval ac_cv_prog_make_${ac_make}_set=yes;; 4160 + *) 4161 + eval ac_cv_prog_make_${ac_make}_set=no;; 4162 +esac 4163 +rm -f conftest.make 4164 +fi 4165 +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then 4166 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 4167 +$as_echo "yes" >&6; } 4168 + SET_MAKE= 4169 +else 4170 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 4171 +$as_echo "no" >&6; } 4172 + SET_MAKE="MAKE=${MAKE-make}" 4173 +fi 4174 + 4175 + 4176 + #-------------------------------------------------------------------- 4177 + # Find ranlib 4178 + #-------------------------------------------------------------------- 4179 + 4180 + if test -n "$ac_tool_prefix"; then 4181 + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. 4182 +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 4183 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 4184 +$as_echo_n "checking for $ac_word... " >&6; } 4185 +if ${ac_cv_prog_RANLIB+:} false; then : 4186 + $as_echo_n "(cached) " >&6 4187 +else 4188 + if test -n "$RANLIB"; then 4189 + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. 4190 +else 4191 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 4192 +for as_dir in $PATH 4193 +do 4194 + IFS=$as_save_IFS 4195 + test -z "$as_dir" && as_dir=. 4196 + for ac_exec_ext in '' $ac_executable_extensions; do 4197 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 4198 + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" 4199 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 4200 + break 2 4201 + fi 4202 +done 4203 + done 4204 +IFS=$as_save_IFS 4205 + 4206 +fi 4207 +fi 4208 +RANLIB=$ac_cv_prog_RANLIB 4209 +if test -n "$RANLIB"; then 4210 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 4211 +$as_echo "$RANLIB" >&6; } 4212 +else 4213 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 4214 +$as_echo "no" >&6; } 4215 +fi 4216 + 4217 + 4218 +fi 4219 +if test -z "$ac_cv_prog_RANLIB"; then 4220 + ac_ct_RANLIB=$RANLIB 4221 + # Extract the first word of "ranlib", so it can be a program name with args. 4222 +set dummy ranlib; ac_word=$2 4223 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 4224 +$as_echo_n "checking for $ac_word... " >&6; } 4225 +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : 4226 + $as_echo_n "(cached) " >&6 4227 +else 4228 + if test -n "$ac_ct_RANLIB"; then 4229 + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. 4230 +else 4231 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 4232 +for as_dir in $PATH 4233 +do 4234 + IFS=$as_save_IFS 4235 + test -z "$as_dir" && as_dir=. 4236 + for ac_exec_ext in '' $ac_executable_extensions; do 4237 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 4238 + ac_cv_prog_ac_ct_RANLIB="ranlib" 4239 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 4240 + break 2 4241 + fi 4242 +done 4243 + done 4244 +IFS=$as_save_IFS 4245 + 4246 +fi 4247 +fi 4248 +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB 4249 +if test -n "$ac_ct_RANLIB"; then 4250 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 4251 +$as_echo "$ac_ct_RANLIB" >&6; } 4252 +else 4253 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 4254 +$as_echo "no" >&6; } 4255 +fi 4256 + 4257 + if test "x$ac_ct_RANLIB" = x; then 4258 + RANLIB="" 4259 + else 4260 + case $cross_compiling:$ac_tool_warned in 4261 +yes:) 4262 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 4263 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 4264 +ac_tool_warned=yes ;; 4265 +esac 4266 + RANLIB=$ac_ct_RANLIB 4267 + fi 4268 +else 4269 + RANLIB="$ac_cv_prog_RANLIB" 4270 +fi 4271 + 4272 + 4273 + #-------------------------------------------------------------------- 4274 + # Determines the correct binary file extension (.o, .obj, .exe etc.) 4275 + #-------------------------------------------------------------------- 4276 + 4277 + 4278 + 4279 + 4280 + 4281 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 4282 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } 4283 +if ${ac_cv_path_GREP+:} false; then : 4284 + $as_echo_n "(cached) " >&6 4285 +else 4286 + if test -z "$GREP"; then 4287 + ac_path_GREP_found=false 4288 + # Loop through the user's path and test for each of PROGNAME-LIST 4289 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 4290 +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin 4291 +do 4292 + IFS=$as_save_IFS 4293 + test -z "$as_dir" && as_dir=. 4294 + for ac_prog in grep ggrep; do 4295 + for ac_exec_ext in '' $ac_executable_extensions; do 4296 + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" 4297 + as_fn_executable_p "$ac_path_GREP" || continue 4298 +# Check for GNU ac_path_GREP and select it if it is found. 4299 + # Check for GNU $ac_path_GREP 4300 +case `"$ac_path_GREP" --version 2>&1` in 4301 +*GNU*) 4302 + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; 4303 +*) 4304 + ac_count=0 4305 + $as_echo_n 0123456789 >"conftest.in" 4306 + while : 4307 + do 4308 + cat "conftest.in" "conftest.in" >"conftest.tmp" 4309 + mv "conftest.tmp" "conftest.in" 4310 + cp "conftest.in" "conftest.nl" 4311 + $as_echo 'GREP' >> "conftest.nl" 4312 + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break 4313 + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break 4314 + as_fn_arith $ac_count + 1 && ac_count=$as_val 4315 + if test $ac_count -gt ${ac_path_GREP_max-0}; then 4316 + # Best one so far, save it but keep looking for a better one 4317 + ac_cv_path_GREP="$ac_path_GREP" 4318 + ac_path_GREP_max=$ac_count 4319 + fi 4320 + # 10*(2^10) chars as input seems more than enough 4321 + test $ac_count -gt 10 && break 4322 + done 4323 + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; 4324 +esac 4325 + 4326 + $ac_path_GREP_found && break 3 4327 + done 4328 + done 4329 + done 4330 +IFS=$as_save_IFS 4331 + if test -z "$ac_cv_path_GREP"; then 4332 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 4333 + fi 4334 +else 4335 + ac_cv_path_GREP=$GREP 4336 +fi 4337 + 4338 +fi 4339 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 4340 +$as_echo "$ac_cv_path_GREP" >&6; } 4341 + GREP="$ac_cv_path_GREP" 4342 + 4343 + 4344 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 4345 +$as_echo_n "checking for egrep... " >&6; } 4346 +if ${ac_cv_path_EGREP+:} false; then : 4347 + $as_echo_n "(cached) " >&6 4348 +else 4349 + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 4350 + then ac_cv_path_EGREP="$GREP -E" 4351 + else 4352 + if test -z "$EGREP"; then 4353 + ac_path_EGREP_found=false 4354 + # Loop through the user's path and test for each of PROGNAME-LIST 4355 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 4356 +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin 4357 +do 4358 + IFS=$as_save_IFS 4359 + test -z "$as_dir" && as_dir=. 4360 + for ac_prog in egrep; do 4361 + for ac_exec_ext in '' $ac_executable_extensions; do 4362 + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" 4363 + as_fn_executable_p "$ac_path_EGREP" || continue 4364 +# Check for GNU ac_path_EGREP and select it if it is found. 4365 + # Check for GNU $ac_path_EGREP 4366 +case `"$ac_path_EGREP" --version 2>&1` in 4367 +*GNU*) 4368 + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; 4369 +*) 4370 + ac_count=0 4371 + $as_echo_n 0123456789 >"conftest.in" 4372 + while : 4373 + do 4374 + cat "conftest.in" "conftest.in" >"conftest.tmp" 4375 + mv "conftest.tmp" "conftest.in" 4376 + cp "conftest.in" "conftest.nl" 4377 + $as_echo 'EGREP' >> "conftest.nl" 4378 + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break 4379 + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break 4380 + as_fn_arith $ac_count + 1 && ac_count=$as_val 4381 + if test $ac_count -gt ${ac_path_EGREP_max-0}; then 4382 + # Best one so far, save it but keep looking for a better one 4383 + ac_cv_path_EGREP="$ac_path_EGREP" 4384 + ac_path_EGREP_max=$ac_count 4385 + fi 4386 + # 10*(2^10) chars as input seems more than enough 4387 + test $ac_count -gt 10 && break 4388 + done 4389 + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; 4390 +esac 4391 + 4392 + $ac_path_EGREP_found && break 3 4393 + done 4394 + done 4395 + done 4396 +IFS=$as_save_IFS 4397 + if test -z "$ac_cv_path_EGREP"; then 4398 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 4399 + fi 4400 +else 4401 + ac_cv_path_EGREP=$EGREP 4402 +fi 4403 + 4404 + fi 4405 +fi 4406 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 4407 +$as_echo "$ac_cv_path_EGREP" >&6; } 4408 + EGREP="$ac_cv_path_EGREP" 4409 + 4410 + 4411 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 4412 +$as_echo_n "checking for ANSI C header files... " >&6; } 4413 +if ${ac_cv_header_stdc+:} false; then : 4414 + $as_echo_n "(cached) " >&6 4415 +else 4416 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4417 +/* end confdefs.h. */ 4418 +#include <stdlib.h> 4419 +#include <stdarg.h> 4420 +#include <string.h> 4421 +#include <float.h> 4422 + 4423 +int 4424 +main () 4425 +{ 4426 + 4427 + ; 4428 + return 0; 4429 +} 4430 +_ACEOF 4431 +if ac_fn_c_try_compile "$LINENO"; then : 4432 + ac_cv_header_stdc=yes 4433 +else 4434 + ac_cv_header_stdc=no 4435 +fi 4436 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4437 + 4438 +if test $ac_cv_header_stdc = yes; then 4439 + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. 4440 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4441 +/* end confdefs.h. */ 4442 +#include <string.h> 4443 + 4444 +_ACEOF 4445 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 4446 + $EGREP "memchr" >/dev/null 2>&1; then : 4447 + 4448 +else 4449 + ac_cv_header_stdc=no 4450 +fi 4451 +rm -f conftest* 4452 + 4453 +fi 4454 + 4455 +if test $ac_cv_header_stdc = yes; then 4456 + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. 4457 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4458 +/* end confdefs.h. */ 4459 +#include <stdlib.h> 4460 + 4461 +_ACEOF 4462 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 4463 + $EGREP "free" >/dev/null 2>&1; then : 4464 + 4465 +else 4466 + ac_cv_header_stdc=no 4467 +fi 4468 +rm -f conftest* 4469 + 4470 +fi 4471 + 4472 +if test $ac_cv_header_stdc = yes; then 4473 + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. 4474 + if test "$cross_compiling" = yes; then : 4475 + : 4476 +else 4477 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4478 +/* end confdefs.h. */ 4479 +#include <ctype.h> 4480 +#include <stdlib.h> 4481 +#if ((' ' & 0x0FF) == 0x020) 4482 +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') 4483 +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) 4484 +#else 4485 +# define ISLOWER(c) \ 4486 + (('a' <= (c) && (c) <= 'i') \ 4487 + || ('j' <= (c) && (c) <= 'r') \ 4488 + || ('s' <= (c) && (c) <= 'z')) 4489 +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) 4490 +#endif 4491 + 4492 +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) 4493 +int 4494 +main () 4495 +{ 4496 + int i; 4497 + for (i = 0; i < 256; i++) 4498 + if (XOR (islower (i), ISLOWER (i)) 4499 + || toupper (i) != TOUPPER (i)) 4500 + return 2; 4501 + return 0; 4502 +} 4503 +_ACEOF 4504 +if ac_fn_c_try_run "$LINENO"; then : 4505 + 4506 +else 4507 + ac_cv_header_stdc=no 4508 +fi 4509 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ 4510 + conftest.$ac_objext conftest.beam conftest.$ac_ext 4511 +fi 4512 + 4513 +fi 4514 +fi 4515 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 4516 +$as_echo "$ac_cv_header_stdc" >&6; } 4517 +if test $ac_cv_header_stdc = yes; then 4518 + 4519 +$as_echo "#define STDC_HEADERS 1" >>confdefs.h 4520 + 4521 +fi 4522 + 4523 +# On IRIX 5.3, sys/types and inttypes.h are conflicting. 4524 +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ 4525 + inttypes.h stdint.h unistd.h 4526 +do : 4527 + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` 4528 +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default 4529 +" 4530 +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : 4531 + cat >>confdefs.h <<_ACEOF 4532 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 4533 +_ACEOF 4534 + 4535 +fi 4536 + 4537 +done 4538 + 4539 + 4540 + 4541 + # Any macros that use the compiler (e.g. AC_TRY_COMPILE) have to go here. 4542 + 4543 + 4544 + #------------------------------------------------------------------------ 4545 + # If we're using GCC, see if the compiler understands -pipe. If so, use it. 4546 + # It makes compiling go faster. (This is only a performance feature.) 4547 + #------------------------------------------------------------------------ 4548 + 4549 + if test -z "$no_pipe" -a -n "$GCC"; then 4550 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5 4551 +$as_echo_n "checking if the compiler understands -pipe... " >&6; } 4552 +if ${tcl_cv_cc_pipe+:} false; then : 4553 + $as_echo_n "(cached) " >&6 4554 +else 4555 + 4556 + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe" 4557 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4558 +/* end confdefs.h. */ 4559 + 4560 +int 4561 +main () 4562 +{ 4563 + 4564 + ; 4565 + return 0; 4566 +} 4567 +_ACEOF 4568 +if ac_fn_c_try_compile "$LINENO"; then : 4569 + tcl_cv_cc_pipe=yes 4570 +else 4571 + tcl_cv_cc_pipe=no 4572 +fi 4573 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4574 + CFLAGS=$hold_cflags 4575 +fi 4576 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5 4577 +$as_echo "$tcl_cv_cc_pipe" >&6; } 4578 + if test $tcl_cv_cc_pipe = yes; then 4579 + CFLAGS="$CFLAGS -pipe" 4580 + fi 4581 + fi 4582 + 4583 + #-------------------------------------------------------------------- 4584 + # Common compiler flag setup 4585 + #-------------------------------------------------------------------- 4586 + 4587 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 4588 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } 4589 +if ${ac_cv_c_bigendian+:} false; then : 4590 + $as_echo_n "(cached) " >&6 4591 +else 4592 + ac_cv_c_bigendian=unknown 4593 + # See if we're dealing with a universal compiler. 4594 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4595 +/* end confdefs.h. */ 4596 +#ifndef __APPLE_CC__ 4597 + not a universal capable compiler 4598 + #endif 4599 + typedef int dummy; 4600 + 4601 +_ACEOF 4602 +if ac_fn_c_try_compile "$LINENO"; then : 4603 + 4604 + # Check for potential -arch flags. It is not universal unless 4605 + # there are at least two -arch flags with different values. 4606 + ac_arch= 4607 + ac_prev= 4608 + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do 4609 + if test -n "$ac_prev"; then 4610 + case $ac_word in 4611 + i?86 | x86_64 | ppc | ppc64) 4612 + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then 4613 + ac_arch=$ac_word 4614 + else 4615 + ac_cv_c_bigendian=universal 4616 + break 4617 + fi 4618 + ;; 4619 + esac 4620 + ac_prev= 4621 + elif test "x$ac_word" = "x-arch"; then 4622 + ac_prev=arch 4623 + fi 4624 + done 4625 +fi 4626 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4627 + if test $ac_cv_c_bigendian = unknown; then 4628 + # See if sys/param.h defines the BYTE_ORDER macro. 4629 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4630 +/* end confdefs.h. */ 4631 +#include <sys/types.h> 4632 + #include <sys/param.h> 4633 + 4634 +int 4635 +main () 4636 +{ 4637 +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ 4638 + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ 4639 + && LITTLE_ENDIAN) 4640 + bogus endian macros 4641 + #endif 4642 + 4643 + ; 4644 + return 0; 4645 +} 4646 +_ACEOF 4647 +if ac_fn_c_try_compile "$LINENO"; then : 4648 + # It does; now see whether it defined to BIG_ENDIAN or not. 4649 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4650 +/* end confdefs.h. */ 4651 +#include <sys/types.h> 4652 + #include <sys/param.h> 4653 + 4654 +int 4655 +main () 4656 +{ 4657 +#if BYTE_ORDER != BIG_ENDIAN 4658 + not big endian 4659 + #endif 4660 + 4661 + ; 4662 + return 0; 4663 +} 4664 +_ACEOF 4665 +if ac_fn_c_try_compile "$LINENO"; then : 4666 + ac_cv_c_bigendian=yes 4667 +else 4668 + ac_cv_c_bigendian=no 4669 +fi 4670 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4671 +fi 4672 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4673 + fi 4674 + if test $ac_cv_c_bigendian = unknown; then 4675 + # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). 4676 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4677 +/* end confdefs.h. */ 4678 +#include <limits.h> 4679 + 4680 +int 4681 +main () 4682 +{ 4683 +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) 4684 + bogus endian macros 4685 + #endif 4686 + 4687 + ; 4688 + return 0; 4689 +} 4690 +_ACEOF 4691 +if ac_fn_c_try_compile "$LINENO"; then : 4692 + # It does; now see whether it defined to _BIG_ENDIAN or not. 4693 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4694 +/* end confdefs.h. */ 4695 +#include <limits.h> 4696 + 4697 +int 4698 +main () 4699 +{ 4700 +#ifndef _BIG_ENDIAN 4701 + not big endian 4702 + #endif 4703 + 4704 + ; 4705 + return 0; 4706 +} 4707 +_ACEOF 4708 +if ac_fn_c_try_compile "$LINENO"; then : 4709 + ac_cv_c_bigendian=yes 4710 +else 4711 + ac_cv_c_bigendian=no 4712 +fi 4713 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4714 +fi 4715 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4716 + fi 4717 + if test $ac_cv_c_bigendian = unknown; then 4718 + # Compile a test program. 4719 + if test "$cross_compiling" = yes; then : 4720 + # Try to guess by grepping values from an object file. 4721 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4722 +/* end confdefs.h. */ 4723 +short int ascii_mm[] = 4724 + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; 4725 + short int ascii_ii[] = 4726 + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; 4727 + int use_ascii (int i) { 4728 + return ascii_mm[i] + ascii_ii[i]; 4729 + } 4730 + short int ebcdic_ii[] = 4731 + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; 4732 + short int ebcdic_mm[] = 4733 + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; 4734 + int use_ebcdic (int i) { 4735 + return ebcdic_mm[i] + ebcdic_ii[i]; 4736 + } 4737 + extern int foo; 4738 + 4739 +int 4740 +main () 4741 +{ 4742 +return use_ascii (foo) == use_ebcdic (foo); 4743 + ; 4744 + return 0; 4745 +} 4746 +_ACEOF 4747 +if ac_fn_c_try_compile "$LINENO"; then : 4748 + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then 4749 + ac_cv_c_bigendian=yes 4750 + fi 4751 + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then 4752 + if test "$ac_cv_c_bigendian" = unknown; then 4753 + ac_cv_c_bigendian=no 4754 + else 4755 + # finding both strings is unlikely to happen, but who knows? 4756 + ac_cv_c_bigendian=unknown 4757 + fi 4758 + fi 4759 +fi 4760 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 4761 +else 4762 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4763 +/* end confdefs.h. */ 4764 +$ac_includes_default 4765 +int 4766 +main () 4767 +{ 4768 + 4769 + /* Are we little or big endian? From Harbison&Steele. */ 4770 + union 4771 + { 4772 + long int l; 4773 + char c[sizeof (long int)]; 4774 + } u; 4775 + u.l = 1; 4776 + return u.c[sizeof (long int) - 1] == 1; 4777 + 4778 + ; 4779 + return 0; 4780 +} 4781 +_ACEOF 4782 +if ac_fn_c_try_run "$LINENO"; then : 4783 + ac_cv_c_bigendian=no 4784 +else 4785 + ac_cv_c_bigendian=yes 4786 +fi 4787 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ 4788 + conftest.$ac_objext conftest.beam conftest.$ac_ext 4789 +fi 4790 + 4791 + fi 4792 +fi 4793 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 4794 +$as_echo "$ac_cv_c_bigendian" >&6; } 4795 + case $ac_cv_c_bigendian in #( 4796 + yes) 4797 + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h 4798 +;; #( 4799 + no) 4800 + ;; #( 4801 + universal) 4802 + 4803 +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h 4804 + 4805 + ;; #( 4806 + *) 4807 + as_fn_error $? "unknown endianness 4808 + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; 4809 + esac 4810 + 4811 + 4812 + 4813 +#-------------------------------------------------------------------- 4814 +# Load the tdomConfig.sh file 4815 +#-------------------------------------------------------------------- 4816 + 4817 + 4818 + if test x"${no_tdom}" = x ; then 4819 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tDOM configuration" >&5 4820 +$as_echo_n "checking for tDOM configuration... " >&6; } 4821 + 4822 +# Check whether --with-tdom was given. 4823 +if test "${with_tdom+set}" = set; then : 4824 + withval=$with_tdom; with_tdomconfig=${withval} 4825 +fi 4826 + 4827 + 4828 + no_tdom=true 4829 + if test "${TEA_PLATFORM}" = "windows" ; then 4830 + tdom_bindir=win 4831 + else 4832 + tdom_bindir=unix 4833 + fi 4834 + 4835 + if ${ac_cv_c_tdomconfig+:} false; then : 4836 + $as_echo_n "(cached) " >&6 4837 +else 4838 + 4839 + 4840 + # First check to see if --with-tdom was specified. 4841 + if test x"${with_tdomconfig}" != x ; then 4842 + if test -f "${with_tdomconfig}/tdomConfig.sh" ; then 4843 + ac_cv_c_tdomconfig=`(cd ${with_tdomconfig}; pwd)` 4844 + else 4845 + as_fn_error $? "${with_tdomconfig} directory doesn't contain tdomConfig.sh" "$LINENO" 5 4846 + fi 4847 + fi 4848 + # Then check for a sibling installation 4849 + if test x"${ac_cv_c_tdomconfig}" = x ; then 4850 + for i in \ 4851 + ../tdom `ls -dr ../tdom-* 2>/dev/null` \ 4852 + ../../tdom `ls -dr ../../tdom-* 2>/dev/null` \ 4853 + ../../../tdom `ls -dr ../../../tdom-* 2>/dev/null` ; do 4854 + if test -f "$i/$tdom_bindir/tdomConfig.sh" ; then 4855 + ac_cv_c_tdomconfig=`(cd $i/$tdom_bindir; pwd)` 4856 + fi 4857 + done 4858 + fi 4859 + # Then check if tnc/tdom are compilied in the source tree 4860 + if test x"${ac_cv_c_tdomconfig}" = x ; then 4861 + if test -f "../../$tdom_bindir/tdomConfig.sh" ; then 4862 + ac_cv_c_tdomconfig=`(cd ../../$tdom_bindir; pwd)` 4863 + fi 4864 + fi 4865 + # Check in a few common install locations 4866 + if test x"${ac_cv_c_tdomconfig}" = x ; then 4867 + for i in \ 4868 + `ls -d ${prefix}/lib 2>/dev/null` \ 4869 + `ls -d /usr/local/lib 2>/dev/null` ; do 4870 + if test -f "$i/tdomConfig.sh" ; then 4871 + ac_cv_c_tdomconfig=`(cd $i; pwd)` 4872 + fi 4873 + done 4874 + fi 4875 + # Check in a few other private locations 4876 + if test x"${ac_cv_c_tdomconfig}" = x ; then 4877 + for i in \ 4878 + ${srcdir}/../tdom \ 4879 + `ls -dr ${srcdir}/../tdom[0-9].[0-9]* 2>/dev/null` ; do 4880 + if test -f "$i/$tdom_bindir/tdomConfig.sh" ; then 4881 + ac_cv_c_tdomconfig=`(cd $i/$tdom_bindir; pwd)` 4882 + fi 4883 + done 4884 + fi 4885 + 4886 +fi 4887 + 4888 + if test x"${ac_cv_c_tdomconfig}" = x ; then 4889 + TDOM_BIN_DIR="# no tDOM configuration file found" 4890 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't find tDOM configuration definitions" >&5 4891 +$as_echo "$as_me: WARNING: Can't find tDOM configuration definitions" >&2;} 4892 + exit 0 4893 + else 4894 + no_tdom= 4895 + TDOM_BIN_DIR=${ac_cv_c_tdomconfig} 4896 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $TDOM_BIN_DIR/tdomConfig.sh" >&5 4897 +$as_echo "found $TDOM_BIN_DIR/tdomConfig.sh" >&6; } 4898 + fi 4899 + fi 4900 + 4901 + 4902 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for existence of $TDOM_BIN_DIR/tdomConfig.sh" >&5 4903 +$as_echo_n "checking for existence of $TDOM_BIN_DIR/tdomConfig.sh... " >&6; } 4904 + if test -f "$TDOM_BIN_DIR/tdomConfig.sh" ; then 4905 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: loading" >&5 4906 +$as_echo "loading" >&6; } 4907 + . $TDOM_BIN_DIR/tdomConfig.sh 4908 + else 4909 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: file not found" >&5 4910 +$as_echo "file not found" >&6; } 4911 + fi 4912 + if test -f "${TDOM_BIN_DIR}/Makefile" ; then 4913 + TDOM_STUB_LIB_SPEC=${TDOM_BUILD_STUB_LIB_SPEC} 4914 + fi 4915 + 4916 + 4917 + 4918 + 4919 + 4920 +#----------------------------------------------------------------------- 4921 +# __CHANGE__ 4922 +# Specify the C source files to compile in TEA_ADD_SOURCES, 4923 +# public headers that need to be installed in TEA_ADD_HEADERS, 4924 +# stub library C source files to compile in TEA_ADD_STUB_SOURCES, 4925 +# and runtime Tcl library files in TEA_ADD_TCL_SOURCES. 4926 +# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS 4927 +# and PKG_TCL_SOURCES. 4928 +#----------------------------------------------------------------------- 4929 + 4930 + 4931 + vars="schemadtx.c" 4932 + for i in $vars; do 4933 + case $i in 4934 + \$*) 4935 + # allow $-var names 4936 + PKG_SOURCES="$PKG_SOURCES $i" 4937 + PKG_OBJECTS="$PKG_OBJECTS $i" 4938 + ;; 4939 + *) 4940 + # check for existence - allows for generic/win/unix VPATH 4941 + # To add more dirs here (like 'src'), you have to update VPATH 4942 + # in Makefile.in as well 4943 + if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ 4944 + -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \ 4945 + -a ! -f "${srcdir}/macosx/$i" \ 4946 + ; then 4947 + as_fn_error $? "could not find source file '$i'" "$LINENO" 5 4948 + fi 4949 + PKG_SOURCES="$PKG_SOURCES $i" 4950 + # this assumes it is in a VPATH dir 4951 + i=`basename $i` 4952 + # handle user calling this before or after TEA_SETUP_COMPILER 4953 + if test x"${OBJEXT}" != x ; then 4954 + j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}" 4955 + else 4956 + j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}" 4957 + fi 4958 + PKG_OBJECTS="$PKG_OBJECTS $j" 4959 + ;; 4960 + esac 4961 + done 4962 + 4963 + 4964 + 4965 + 4966 + vars="" 4967 + for i in $vars; do 4968 + # check for existence, be strict because it is installed 4969 + if test ! -f "${srcdir}/$i" ; then 4970 + as_fn_error $? "could not find header file '${srcdir}/$i'" "$LINENO" 5 4971 + fi 4972 + PKG_HEADERS="$PKG_HEADERS $i" 4973 + done 4974 + 4975 + 4976 + 4977 + vars="-I${srcdir}/../../generic -I${srcdir}/../../expat" 4978 + for i in $vars; do 4979 + PKG_INCLUDES="$PKG_INCLUDES $i" 4980 + done 4981 + 4982 + 4983 + 4984 + vars="${TDOM_STUB_LIB_SPEC}" 4985 + for i in $vars; do 4986 + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 4987 + # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 4988 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 4989 + fi 4990 + PKG_LIBS="$PKG_LIBS $i" 4991 + done 4992 + 4993 + 4994 + 4995 + PKG_CFLAGS="$PKG_CFLAGS -DUSE_TDOM_STUBS=1" 4996 + 4997 + 4998 + 4999 + vars="" 5000 + for i in $vars; do 5001 + # check for existence - allows for generic/win/unix VPATH 5002 + if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ 5003 + -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \ 5004 + -a ! -f "${srcdir}/macosx/$i" \ 5005 + ; then 5006 + as_fn_error $? "could not find stub source file '$i'" "$LINENO" 5 5007 + fi 5008 + PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i" 5009 + # this assumes it is in a VPATH dir 5010 + i=`basename $i` 5011 + # handle user calling this before or after TEA_SETUP_COMPILER 5012 + if test x"${OBJEXT}" != x ; then 5013 + j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}" 5014 + else 5015 + j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}" 5016 + fi 5017 + PKG_STUB_OBJECTS="$PKG_STUB_OBJECTS $j" 5018 + done 5019 + 5020 + 5021 + 5022 + 5023 + vars="" 5024 + for i in $vars; do 5025 + # check for existence, be strict because it is installed 5026 + if test ! -f "${srcdir}/$i" ; then 5027 + as_fn_error $? "could not find tcl source file '${srcdir}/$i'" "$LINENO" 5 5028 + fi 5029 + PKG_TCL_SOURCES="$PKG_TCL_SOURCES $i" 5030 + done 5031 + 5032 + 5033 + 5034 +#-------------------------------------------------------------------- 5035 +# __CHANGE__ 5036 +# 5037 +# You can add more files to clean if your extension creates any extra 5038 +# files by extending CLEANFILES. 5039 +# Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure 5040 +# and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var. 5041 +# 5042 +# A few miscellaneous platform-specific items: 5043 +# TEA_ADD_* any platform specific compiler/build info here. 5044 +#-------------------------------------------------------------------- 5045 + 5046 +#CLEANFILES="$CLEANFILES pkgIndex.tcl" 5047 +if test "${TEA_PLATFORM}" = "windows" ; then 5048 + # Ensure no empty if clauses 5049 + : 5050 + #TEA_ADD_SOURCES([win/winFile.c]) 5051 + #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"]) 5052 +else 5053 + # Ensure no empty else clauses 5054 + : 5055 + #TEA_ADD_SOURCES([unix/unixFile.c]) 5056 + #TEA_ADD_LIBS([-lsuperfly]) 5057 +fi 5058 + 5059 +#-------------------------------------------------------------------- 5060 +# __CHANGE__ 5061 +# Choose which headers you need. Extension authors should try very 5062 +# hard to only rely on the Tcl public header files. Internal headers 5063 +# contain private data structures and are subject to change without 5064 +# notice. 5065 +# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG 5066 +#-------------------------------------------------------------------- 5067 + 5068 + 5069 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl public headers" >&5 5070 +$as_echo_n "checking for Tcl public headers... " >&6; } 5071 + 5072 + 5073 +# Check whether --with-tclinclude was given. 5074 +if test "${with_tclinclude+set}" = set; then : 5075 + withval=$with_tclinclude; with_tclinclude=${withval} 5076 +fi 5077 + 5078 + 5079 + if ${ac_cv_c_tclh+:} false; then : 5080 + $as_echo_n "(cached) " >&6 5081 +else 5082 + 5083 + # Use the value from --with-tclinclude, if it was given 5084 + 5085 + if test x"${with_tclinclude}" != x ; then 5086 + if test -f "${with_tclinclude}/tcl.h" ; then 5087 + ac_cv_c_tclh=${with_tclinclude} 5088 + else 5089 + as_fn_error $? "${with_tclinclude} directory does not contain tcl.h" "$LINENO" 5 5090 + fi 5091 + else 5092 + list="" 5093 + if test "`uname -s`" = "Darwin"; then 5094 + # If Tcl was built as a framework, attempt to use 5095 + # the framework's Headers directory 5096 + case ${TCL_DEFS} in 5097 + *TCL_FRAMEWORK*) 5098 + list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`" 5099 + ;; 5100 + esac 5101 + fi 5102 + 5103 + # Look in the source dir only if Tcl is not installed, 5104 + # and in that situation, look there before installed locations. 5105 + if test -f "${TCL_BIN_DIR}/Makefile" ; then 5106 + list="$list `ls -d ${TCL_SRC_DIR}/generic 2>/dev/null`" 5107 + fi 5108 + 5109 + # Check order: pkg --prefix location, Tcl's --prefix location, 5110 + # relative to directory of tclConfig.sh. 5111 + 5112 + eval "temp_includedir=${includedir}" 5113 + list="$list \ 5114 + `ls -d ${temp_includedir} 2>/dev/null` \ 5115 + `ls -d ${TCL_PREFIX}/include 2>/dev/null` \ 5116 + `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`" 5117 + if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then 5118 + list="$list /usr/local/include /usr/include" 5119 + if test x"${TCL_INCLUDE_SPEC}" != x ; then 5120 + d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'` 5121 + list="$list `ls -d ${d} 2>/dev/null`" 5122 + fi 5123 + fi 5124 + for i in $list ; do 5125 + if test -f "$i/tcl.h" ; then 5126 + ac_cv_c_tclh=$i 5127 + break 5128 + fi 5129 + done 5130 + fi 5131 + 5132 +fi 5133 + 5134 + 5135 + # Print a message based on how we determined the include path 5136 + 5137 + if test x"${ac_cv_c_tclh}" = x ; then 5138 + as_fn_error $? "tcl.h not found. Please specify its location with --with-tclinclude" "$LINENO" 5 5139 + else 5140 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_c_tclh}" >&5 5141 +$as_echo "${ac_cv_c_tclh}" >&6; } 5142 + fi 5143 + 5144 + # Convert to a native path and substitute into the output files. 5145 + 5146 + INCLUDE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclh}` 5147 + 5148 + TCL_INCLUDES=-I\"${INCLUDE_DIR_NATIVE}\" 5149 + 5150 + 5151 + 5152 +#TEA_PRIVATE_TCL_HEADERS 5153 + 5154 +#TEA_PUBLIC_TK_HEADERS 5155 +#TEA_PRIVATE_TK_HEADERS 5156 +#TEA_PATH_X 5157 + 5158 +#-------------------------------------------------------------------- 5159 +# Check whether --enable-threads or --disable-threads was given. 5160 +# This auto-enables if Tcl was compiled threaded. 5161 +#-------------------------------------------------------------------- 5162 + 5163 + 5164 + # Check whether --enable-threads was given. 5165 +if test "${enable_threads+set}" = set; then : 5166 + enableval=$enable_threads; tcl_ok=$enableval 5167 +else 5168 + tcl_ok=yes 5169 +fi 5170 + 5171 + 5172 + if test "${enable_threads+set}" = set; then 5173 + enableval="$enable_threads" 5174 + tcl_ok=$enableval 5175 + else 5176 + tcl_ok=yes 5177 + fi 5178 + 5179 + if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then 5180 + TCL_THREADS=1 5181 + 5182 + if test "${TEA_PLATFORM}" != "windows" ; then 5183 + # We are always OK on Windows, so check what this platform wants: 5184 + 5185 + # USE_THREAD_ALLOC tells us to try the special thread-based 5186 + # allocator that significantly reduces lock contention 5187 + 5188 +$as_echo "#define USE_THREAD_ALLOC 1" >>confdefs.h 5189 + 5190 + 5191 +$as_echo "#define _REENTRANT 1" >>confdefs.h 5192 + 5193 + if test "`uname -s`" = "SunOS" ; then 5194 + 5195 +$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h 5196 + 5197 + fi 5198 + 5199 +$as_echo "#define _THREAD_SAFE 1" >>confdefs.h 5200 + 5201 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lpthread" >&5 5202 +$as_echo_n "checking for pthread_mutex_init in -lpthread... " >&6; } 5203 +if ${ac_cv_lib_pthread_pthread_mutex_init+:} false; then : 5204 + $as_echo_n "(cached) " >&6 5205 +else 5206 + ac_check_lib_save_LIBS=$LIBS 5207 +LIBS="-lpthread $LIBS" 5208 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5209 +/* end confdefs.h. */ 5210 + 5211 +/* Override any GCC internal prototype to avoid an error. 5212 + Use char because int might match the return type of a GCC 5213 + builtin and then its argument prototype would still apply. */ 5214 +#ifdef __cplusplus 5215 +extern "C" 5216 +#endif 5217 +char pthread_mutex_init (); 5218 +int 5219 +main () 5220 +{ 5221 +return pthread_mutex_init (); 5222 + ; 5223 + return 0; 5224 +} 5225 +_ACEOF 5226 +if ac_fn_c_try_link "$LINENO"; then : 5227 + ac_cv_lib_pthread_pthread_mutex_init=yes 5228 +else 5229 + ac_cv_lib_pthread_pthread_mutex_init=no 5230 +fi 5231 +rm -f core conftest.err conftest.$ac_objext \ 5232 + conftest$ac_exeext conftest.$ac_ext 5233 +LIBS=$ac_check_lib_save_LIBS 5234 +fi 5235 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5 5236 +$as_echo "$ac_cv_lib_pthread_pthread_mutex_init" >&6; } 5237 +if test "x$ac_cv_lib_pthread_pthread_mutex_init" = xyes; then : 5238 + tcl_ok=yes 5239 +else 5240 + tcl_ok=no 5241 +fi 5242 + 5243 + if test "$tcl_ok" = "no"; then 5244 + # Check a little harder for __pthread_mutex_init in the same 5245 + # library, as some systems hide it there until pthread.h is 5246 + # defined. We could alternatively do an AC_TRY_COMPILE with 5247 + # pthread.h, but that will work with libpthread really doesn't 5248 + # exist, like AIX 4.2. [Bug: 4359] 5249 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __pthread_mutex_init in -lpthread" >&5 5250 +$as_echo_n "checking for __pthread_mutex_init in -lpthread... " >&6; } 5251 +if ${ac_cv_lib_pthread___pthread_mutex_init+:} false; then : 5252 + $as_echo_n "(cached) " >&6 5253 +else 5254 + ac_check_lib_save_LIBS=$LIBS 5255 +LIBS="-lpthread $LIBS" 5256 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5257 +/* end confdefs.h. */ 5258 + 5259 +/* Override any GCC internal prototype to avoid an error. 5260 + Use char because int might match the return type of a GCC 5261 + builtin and then its argument prototype would still apply. */ 5262 +#ifdef __cplusplus 5263 +extern "C" 5264 +#endif 5265 +char __pthread_mutex_init (); 5266 +int 5267 +main () 5268 +{ 5269 +return __pthread_mutex_init (); 5270 + ; 5271 + return 0; 5272 +} 5273 +_ACEOF 5274 +if ac_fn_c_try_link "$LINENO"; then : 5275 + ac_cv_lib_pthread___pthread_mutex_init=yes 5276 +else 5277 + ac_cv_lib_pthread___pthread_mutex_init=no 5278 +fi 5279 +rm -f core conftest.err conftest.$ac_objext \ 5280 + conftest$ac_exeext conftest.$ac_ext 5281 +LIBS=$ac_check_lib_save_LIBS 5282 +fi 5283 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread___pthread_mutex_init" >&5 5284 +$as_echo "$ac_cv_lib_pthread___pthread_mutex_init" >&6; } 5285 +if test "x$ac_cv_lib_pthread___pthread_mutex_init" = xyes; then : 5286 + tcl_ok=yes 5287 +else 5288 + tcl_ok=no 5289 +fi 5290 + 5291 + fi 5292 + 5293 + if test "$tcl_ok" = "yes"; then 5294 + # The space is needed 5295 + THREADS_LIBS=" -lpthread" 5296 + else 5297 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lpthreads" >&5 5298 +$as_echo_n "checking for pthread_mutex_init in -lpthreads... " >&6; } 5299 +if ${ac_cv_lib_pthreads_pthread_mutex_init+:} false; then : 5300 + $as_echo_n "(cached) " >&6 5301 +else 5302 + ac_check_lib_save_LIBS=$LIBS 5303 +LIBS="-lpthreads $LIBS" 5304 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5305 +/* end confdefs.h. */ 5306 + 5307 +/* Override any GCC internal prototype to avoid an error. 5308 + Use char because int might match the return type of a GCC 5309 + builtin and then its argument prototype would still apply. */ 5310 +#ifdef __cplusplus 5311 +extern "C" 5312 +#endif 5313 +char pthread_mutex_init (); 5314 +int 5315 +main () 5316 +{ 5317 +return pthread_mutex_init (); 5318 + ; 5319 + return 0; 5320 +} 5321 +_ACEOF 5322 +if ac_fn_c_try_link "$LINENO"; then : 5323 + ac_cv_lib_pthreads_pthread_mutex_init=yes 5324 +else 5325 + ac_cv_lib_pthreads_pthread_mutex_init=no 5326 +fi 5327 +rm -f core conftest.err conftest.$ac_objext \ 5328 + conftest$ac_exeext conftest.$ac_ext 5329 +LIBS=$ac_check_lib_save_LIBS 5330 +fi 5331 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_mutex_init" >&5 5332 +$as_echo "$ac_cv_lib_pthreads_pthread_mutex_init" >&6; } 5333 +if test "x$ac_cv_lib_pthreads_pthread_mutex_init" = xyes; then : 5334 + tcl_ok=yes 5335 +else 5336 + tcl_ok=no 5337 +fi 5338 + 5339 + if test "$tcl_ok" = "yes"; then 5340 + # The space is needed 5341 + THREADS_LIBS=" -lpthreads" 5342 + else 5343 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lc" >&5 5344 +$as_echo_n "checking for pthread_mutex_init in -lc... " >&6; } 5345 +if ${ac_cv_lib_c_pthread_mutex_init+:} false; then : 5346 + $as_echo_n "(cached) " >&6 5347 +else 5348 + ac_check_lib_save_LIBS=$LIBS 5349 +LIBS="-lc $LIBS" 5350 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5351 +/* end confdefs.h. */ 5352 + 5353 +/* Override any GCC internal prototype to avoid an error. 5354 + Use char because int might match the return type of a GCC 5355 + builtin and then its argument prototype would still apply. */ 5356 +#ifdef __cplusplus 5357 +extern "C" 5358 +#endif 5359 +char pthread_mutex_init (); 5360 +int 5361 +main () 5362 +{ 5363 +return pthread_mutex_init (); 5364 + ; 5365 + return 0; 5366 +} 5367 +_ACEOF 5368 +if ac_fn_c_try_link "$LINENO"; then : 5369 + ac_cv_lib_c_pthread_mutex_init=yes 5370 +else 5371 + ac_cv_lib_c_pthread_mutex_init=no 5372 +fi 5373 +rm -f core conftest.err conftest.$ac_objext \ 5374 + conftest$ac_exeext conftest.$ac_ext 5375 +LIBS=$ac_check_lib_save_LIBS 5376 +fi 5377 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_pthread_mutex_init" >&5 5378 +$as_echo "$ac_cv_lib_c_pthread_mutex_init" >&6; } 5379 +if test "x$ac_cv_lib_c_pthread_mutex_init" = xyes; then : 5380 + tcl_ok=yes 5381 +else 5382 + tcl_ok=no 5383 +fi 5384 + 5385 + if test "$tcl_ok" = "no"; then 5386 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_init in -lc_r" >&5 5387 +$as_echo_n "checking for pthread_mutex_init in -lc_r... " >&6; } 5388 +if ${ac_cv_lib_c_r_pthread_mutex_init+:} false; then : 5389 + $as_echo_n "(cached) " >&6 5390 +else 5391 + ac_check_lib_save_LIBS=$LIBS 5392 +LIBS="-lc_r $LIBS" 5393 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5394 +/* end confdefs.h. */ 5395 + 5396 +/* Override any GCC internal prototype to avoid an error. 5397 + Use char because int might match the return type of a GCC 5398 + builtin and then its argument prototype would still apply. */ 5399 +#ifdef __cplusplus 5400 +extern "C" 5401 +#endif 5402 +char pthread_mutex_init (); 5403 +int 5404 +main () 5405 +{ 5406 +return pthread_mutex_init (); 5407 + ; 5408 + return 0; 5409 +} 5410 +_ACEOF 5411 +if ac_fn_c_try_link "$LINENO"; then : 5412 + ac_cv_lib_c_r_pthread_mutex_init=yes 5413 +else 5414 + ac_cv_lib_c_r_pthread_mutex_init=no 5415 +fi 5416 +rm -f core conftest.err conftest.$ac_objext \ 5417 + conftest$ac_exeext conftest.$ac_ext 5418 +LIBS=$ac_check_lib_save_LIBS 5419 +fi 5420 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_mutex_init" >&5 5421 +$as_echo "$ac_cv_lib_c_r_pthread_mutex_init" >&6; } 5422 +if test "x$ac_cv_lib_c_r_pthread_mutex_init" = xyes; then : 5423 + tcl_ok=yes 5424 +else 5425 + tcl_ok=no 5426 +fi 5427 + 5428 + if test "$tcl_ok" = "yes"; then 5429 + # The space is needed 5430 + THREADS_LIBS=" -pthread" 5431 + else 5432 + TCL_THREADS=0 5433 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Do not know how to find pthread lib on your system - thread support disabled" >&5 5434 +$as_echo "$as_me: WARNING: Do not know how to find pthread lib on your system - thread support disabled" >&2;} 5435 + fi 5436 + fi 5437 + fi 5438 + fi 5439 + fi 5440 + else 5441 + TCL_THREADS=0 5442 + fi 5443 + # Do checking message here to not mess up interleaved configure output 5444 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for building with threads" >&5 5445 +$as_echo_n "checking for building with threads... " >&6; } 5446 + if test "${TCL_THREADS}" = 1; then 5447 + 5448 +$as_echo "#define TCL_THREADS 1" >>confdefs.h 5449 + 5450 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (default)" >&5 5451 +$as_echo "yes (default)" >&6; } 5452 + else 5453 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5454 +$as_echo "no" >&6; } 5455 + fi 5456 + # TCL_THREADS sanity checking. See if our request for building with 5457 + # threads is the same as the way Tcl was built. If not, warn the user. 5458 + case ${TCL_DEFS} in 5459 + *THREADS=1*) 5460 + if test "${TCL_THREADS}" = "0"; then 5461 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 5462 + Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 5463 + that IS thread-enabled. It is recommended to use --enable-threads." >&5 5464 +$as_echo "$as_me: WARNING: 5465 + Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 5466 + that IS thread-enabled. It is recommended to use --enable-threads." >&2;} 5467 + fi 5468 + ;; 5469 + *) 5470 + if test "${TCL_THREADS}" = "1"; then 5471 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 5472 + --enable-threads requested, but building against a Tcl that is NOT 5473 + thread-enabled. This is an OK configuration that will also run in 5474 + a thread-enabled core." >&5 5475 +$as_echo "$as_me: WARNING: 5476 + --enable-threads requested, but building against a Tcl that is NOT 5477 + thread-enabled. This is an OK configuration that will also run in 5478 + a thread-enabled core." >&2;} 5479 + fi 5480 + ;; 5481 + esac 5482 + 5483 + 5484 + 5485 +#-------------------------------------------------------------------- 5486 +# The statement below defines a collection of symbols related to 5487 +# building as a shared library instead of a static library. 5488 +#-------------------------------------------------------------------- 5489 + 5490 + 5491 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5 5492 +$as_echo_n "checking how to build libraries... " >&6; } 5493 + # Check whether --enable-shared was given. 5494 +if test "${enable_shared+set}" = set; then : 5495 + enableval=$enable_shared; shared_ok=$enableval 5496 +else 5497 + shared_ok=yes 5498 +fi 5499 + 5500 + 5501 + if test "${enable_shared+set}" = set; then 5502 + enableval="$enable_shared" 5503 + shared_ok=$enableval 5504 + else 5505 + shared_ok=yes 5506 + fi 5507 + 5508 + # Check whether --enable-stubs was given. 5509 +if test "${enable_stubs+set}" = set; then : 5510 + enableval=$enable_stubs; stubs_ok=$enableval 5511 +else 5512 + stubs_ok=yes 5513 +fi 5514 + 5515 + 5516 + if test "${enable_stubs+set}" = set; then 5517 + enableval="$enable_stubs" 5518 + stubs_ok=$enableval 5519 + else 5520 + stubs_ok=yes 5521 + fi 5522 + 5523 + # Stubs are always enabled for shared builds 5524 + if test "$shared_ok" = "yes" ; then 5525 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5 5526 +$as_echo "shared" >&6; } 5527 + SHARED_BUILD=1 5528 + STUBS_BUILD=1 5529 + else 5530 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5 5531 +$as_echo "static" >&6; } 5532 + SHARED_BUILD=0 5533 + 5534 +$as_echo "#define STATIC_BUILD 1" >>confdefs.h 5535 + 5536 + if test "$stubs_ok" = "yes" ; then 5537 + STUBS_BUILD=1 5538 + else 5539 + STUBS_BUILD=0 5540 + fi 5541 + fi 5542 + if test "${STUBS_BUILD}" = "1" ; then 5543 + 5544 +$as_echo "#define USE_TCL_STUBS 1" >>confdefs.h 5545 + 5546 + 5547 +$as_echo "#define USE_TCLOO_STUBS 1" >>confdefs.h 5548 + 5549 + if test "${TEA_WINDOWINGSYSTEM}" != ""; then 5550 + 5551 +$as_echo "#define USE_TK_STUBS 1" >>confdefs.h 5552 + 5553 + fi 5554 + fi 5555 + 5556 + 5557 + 5558 + 5559 + 5560 +#-------------------------------------------------------------------- 5561 +# This macro figures out what flags to use with the compiler/linker 5562 +# when building shared/static debug/optimized objects. This information 5563 +# can be taken from the tclConfig.sh file, but this figures it all out. 5564 +#-------------------------------------------------------------------- 5565 + 5566 +if test -n "$ac_tool_prefix"; then 5567 + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. 5568 +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 5569 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 5570 +$as_echo_n "checking for $ac_word... " >&6; } 5571 +if ${ac_cv_prog_RANLIB+:} false; then : 5572 + $as_echo_n "(cached) " >&6 5573 +else 5574 + if test -n "$RANLIB"; then 5575 + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. 5576 +else 5577 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 5578 +for as_dir in $PATH 5579 +do 5580 + IFS=$as_save_IFS 5581 + test -z "$as_dir" && as_dir=. 5582 + for ac_exec_ext in '' $ac_executable_extensions; do 5583 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5584 + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" 5585 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 5586 + break 2 5587 + fi 5588 +done 5589 + done 5590 +IFS=$as_save_IFS 5591 + 5592 +fi 5593 +fi 5594 +RANLIB=$ac_cv_prog_RANLIB 5595 +if test -n "$RANLIB"; then 5596 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 5597 +$as_echo "$RANLIB" >&6; } 5598 +else 5599 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5600 +$as_echo "no" >&6; } 5601 +fi 5602 + 5603 + 5604 +fi 5605 +if test -z "$ac_cv_prog_RANLIB"; then 5606 + ac_ct_RANLIB=$RANLIB 5607 + # Extract the first word of "ranlib", so it can be a program name with args. 5608 +set dummy ranlib; ac_word=$2 5609 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 5610 +$as_echo_n "checking for $ac_word... " >&6; } 5611 +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : 5612 + $as_echo_n "(cached) " >&6 5613 +else 5614 + if test -n "$ac_ct_RANLIB"; then 5615 + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. 5616 +else 5617 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 5618 +for as_dir in $PATH 5619 +do 5620 + IFS=$as_save_IFS 5621 + test -z "$as_dir" && as_dir=. 5622 + for ac_exec_ext in '' $ac_executable_extensions; do 5623 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5624 + ac_cv_prog_ac_ct_RANLIB="ranlib" 5625 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 5626 + break 2 5627 + fi 5628 +done 5629 + done 5630 +IFS=$as_save_IFS 5631 + 5632 +fi 5633 +fi 5634 +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB 5635 +if test -n "$ac_ct_RANLIB"; then 5636 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 5637 +$as_echo "$ac_ct_RANLIB" >&6; } 5638 +else 5639 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5640 +$as_echo "no" >&6; } 5641 +fi 5642 + 5643 + if test "x$ac_ct_RANLIB" = x; then 5644 + RANLIB=":" 5645 + else 5646 + case $cross_compiling:$ac_tool_warned in 5647 +yes:) 5648 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 5649 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 5650 +ac_tool_warned=yes ;; 5651 +esac 5652 + RANLIB=$ac_ct_RANLIB 5653 + fi 5654 +else 5655 + RANLIB="$ac_cv_prog_RANLIB" 5656 +fi 5657 + 5658 + 5659 + 5660 + 5661 + # Step 0.a: Enable 64 bit support? 5662 + 5663 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit support is requested" >&5 5664 +$as_echo_n "checking if 64bit support is requested... " >&6; } 5665 + # Check whether --enable-64bit was given. 5666 +if test "${enable_64bit+set}" = set; then : 5667 + enableval=$enable_64bit; do64bit=$enableval 5668 +else 5669 + do64bit=no 5670 +fi 5671 + 5672 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bit" >&5 5673 +$as_echo "$do64bit" >&6; } 5674 + 5675 + # Step 0.b: Enable Solaris 64 bit VIS support? 5676 + 5677 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 64bit Sparc VIS support is requested" >&5 5678 +$as_echo_n "checking if 64bit Sparc VIS support is requested... " >&6; } 5679 + # Check whether --enable-64bit-vis was given. 5680 +if test "${enable_64bit_vis+set}" = set; then : 5681 + enableval=$enable_64bit_vis; do64bitVIS=$enableval 5682 +else 5683 + do64bitVIS=no 5684 +fi 5685 + 5686 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $do64bitVIS" >&5 5687 +$as_echo "$do64bitVIS" >&6; } 5688 + # Force 64bit on with VIS 5689 + if test "$do64bitVIS" = "yes"; then : 5690 + do64bit=yes 5691 +fi 5692 + 5693 + # Step 0.c: Check if visibility support is available. Do this here so 5694 + # that platform specific alternatives can be used below if this fails. 5695 + 5696 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports visibility \"hidden\"" >&5 5697 +$as_echo_n "checking if compiler supports visibility \"hidden\"... " >&6; } 5698 +if ${tcl_cv_cc_visibility_hidden+:} false; then : 5699 + $as_echo_n "(cached) " >&6 5700 +else 5701 + 5702 + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" 5703 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5704 +/* end confdefs.h. */ 5705 + 5706 + extern __attribute__((__visibility__("hidden"))) void f(void); 5707 + void f(void) {} 5708 +int 5709 +main () 5710 +{ 5711 +f(); 5712 + ; 5713 + return 0; 5714 +} 5715 +_ACEOF 5716 +if ac_fn_c_try_link "$LINENO"; then : 5717 + tcl_cv_cc_visibility_hidden=yes 5718 +else 5719 + tcl_cv_cc_visibility_hidden=no 5720 +fi 5721 +rm -f core conftest.err conftest.$ac_objext \ 5722 + conftest$ac_exeext conftest.$ac_ext 5723 + CFLAGS=$hold_cflags 5724 +fi 5725 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_visibility_hidden" >&5 5726 +$as_echo "$tcl_cv_cc_visibility_hidden" >&6; } 5727 + if test $tcl_cv_cc_visibility_hidden = yes; then : 5728 + 5729 + 5730 +$as_echo "#define MODULE_SCOPE extern __attribute__((__visibility__(\"hidden\")))" >>confdefs.h 5731 + 5732 + 5733 +$as_echo "#define HAVE_HIDDEN 1" >>confdefs.h 5734 + 5735 + 5736 +fi 5737 + 5738 + # Step 0.d: Disable -rpath support? 5739 + 5740 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if rpath support is requested" >&5 5741 +$as_echo_n "checking if rpath support is requested... " >&6; } 5742 + # Check whether --enable-rpath was given. 5743 +if test "${enable_rpath+set}" = set; then : 5744 + enableval=$enable_rpath; doRpath=$enableval 5745 +else 5746 + doRpath=yes 5747 +fi 5748 + 5749 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doRpath" >&5 5750 +$as_echo "$doRpath" >&6; } 5751 + 5752 + # TEA specific: Cross-compiling options for Windows/CE builds? 5753 + 5754 + if test "${TEA_PLATFORM}" = windows; then : 5755 + 5756 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Windows/CE build is requested" >&5 5757 +$as_echo_n "checking if Windows/CE build is requested... " >&6; } 5758 + # Check whether --enable-wince was given. 5759 +if test "${enable_wince+set}" = set; then : 5760 + enableval=$enable_wince; doWince=$enableval 5761 +else 5762 + doWince=no 5763 +fi 5764 + 5765 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doWince" >&5 5766 +$as_echo "$doWince" >&6; } 5767 + 5768 +fi 5769 + 5770 + # Set the variable "system" to hold the name and version number 5771 + # for the system. 5772 + 5773 + 5774 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 5775 +$as_echo_n "checking system version... " >&6; } 5776 +if ${tcl_cv_sys_version+:} false; then : 5777 + $as_echo_n "(cached) " >&6 5778 +else 5779 + 5780 + # TEA specific: 5781 + if test "${TEA_PLATFORM}" = "windows" ; then 5782 + tcl_cv_sys_version=windows 5783 + else 5784 + tcl_cv_sys_version=`uname -s`-`uname -r` 5785 + if test "$?" -ne 0 ; then 5786 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 5787 +$as_echo "$as_me: WARNING: can't find uname command" >&2;} 5788 + tcl_cv_sys_version=unknown 5789 + else 5790 + if test "`uname -s`" = "AIX" ; then 5791 + tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 5792 + fi 5793 + fi 5794 + fi 5795 + 5796 +fi 5797 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 5798 +$as_echo "$tcl_cv_sys_version" >&6; } 5799 + system=$tcl_cv_sys_version 5800 + 5801 + 5802 + # Require ranlib early so we can override it in special cases below. 5803 + 5804 + 5805 + 5806 + # Set configuration options based on system name and version. 5807 + # This is similar to Tcl's unix/tcl.m4 except that we've added a 5808 + # "windows" case and removed some core-only vars. 5809 + 5810 + do64bit_ok=no 5811 + # default to '{$LIBS}' and set to "" on per-platform necessary basis 5812 + SHLIB_LD_LIBS='${LIBS}' 5813 + # When ld needs options to work in 64-bit mode, put them in 5814 + # LDFLAGS_ARCH so they eventually end up in LDFLAGS even if [load] 5815 + # is disabled by the user. [Bug 1016796] 5816 + LDFLAGS_ARCH="" 5817 + UNSHARED_LIB_SUFFIX="" 5818 + # TEA specific: use PACKAGE_VERSION instead of VERSION 5819 + TCL_TRIM_DOTS='`echo ${PACKAGE_VERSION} | tr -d .`' 5820 + ECHO_VERSION='`echo ${PACKAGE_VERSION}`' 5821 + TCL_LIB_VERSIONS_OK=ok 5822 + CFLAGS_DEBUG=-g 5823 + if test "$GCC" = yes; then : 5824 + 5825 + CFLAGS_OPTIMIZE=-O2 5826 + CFLAGS_WARNING="-Wall" 5827 + 5828 +else 5829 + 5830 + CFLAGS_OPTIMIZE=-O 5831 + CFLAGS_WARNING="" 5832 + 5833 +fi 5834 + if test -n "$ac_tool_prefix"; then 5835 + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. 5836 +set dummy ${ac_tool_prefix}ar; ac_word=$2 5837 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 5838 +$as_echo_n "checking for $ac_word... " >&6; } 5839 +if ${ac_cv_prog_AR+:} false; then : 5840 + $as_echo_n "(cached) " >&6 5841 +else 5842 + if test -n "$AR"; then 5843 + ac_cv_prog_AR="$AR" # Let the user override the test. 5844 +else 5845 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 5846 +for as_dir in $PATH 5847 +do 5848 + IFS=$as_save_IFS 5849 + test -z "$as_dir" && as_dir=. 5850 + for ac_exec_ext in '' $ac_executable_extensions; do 5851 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5852 + ac_cv_prog_AR="${ac_tool_prefix}ar" 5853 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 5854 + break 2 5855 + fi 5856 +done 5857 + done 5858 +IFS=$as_save_IFS 5859 + 5860 +fi 5861 +fi 5862 +AR=$ac_cv_prog_AR 5863 +if test -n "$AR"; then 5864 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 5865 +$as_echo "$AR" >&6; } 5866 +else 5867 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5868 +$as_echo "no" >&6; } 5869 +fi 5870 + 5871 + 5872 +fi 5873 +if test -z "$ac_cv_prog_AR"; then 5874 + ac_ct_AR=$AR 5875 + # Extract the first word of "ar", so it can be a program name with args. 5876 +set dummy ar; ac_word=$2 5877 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 5878 +$as_echo_n "checking for $ac_word... " >&6; } 5879 +if ${ac_cv_prog_ac_ct_AR+:} false; then : 5880 + $as_echo_n "(cached) " >&6 5881 +else 5882 + if test -n "$ac_ct_AR"; then 5883 + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. 5884 +else 5885 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 5886 +for as_dir in $PATH 5887 +do 5888 + IFS=$as_save_IFS 5889 + test -z "$as_dir" && as_dir=. 5890 + for ac_exec_ext in '' $ac_executable_extensions; do 5891 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5892 + ac_cv_prog_ac_ct_AR="ar" 5893 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 5894 + break 2 5895 + fi 5896 +done 5897 + done 5898 +IFS=$as_save_IFS 5899 + 5900 +fi 5901 +fi 5902 +ac_ct_AR=$ac_cv_prog_ac_ct_AR 5903 +if test -n "$ac_ct_AR"; then 5904 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 5905 +$as_echo "$ac_ct_AR" >&6; } 5906 +else 5907 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 5908 +$as_echo "no" >&6; } 5909 +fi 5910 + 5911 + if test "x$ac_ct_AR" = x; then 5912 + AR="" 5913 + else 5914 + case $cross_compiling:$ac_tool_warned in 5915 +yes:) 5916 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 5917 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 5918 +ac_tool_warned=yes ;; 5919 +esac 5920 + AR=$ac_ct_AR 5921 + fi 5922 +else 5923 + AR="$ac_cv_prog_AR" 5924 +fi 5925 + 5926 + STLIB_LD='${AR} cr' 5927 + LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" 5928 + if test "x$SHLIB_VERSION" = x; then : 5929 + SHLIB_VERSION="" 5930 +else 5931 + SHLIB_VERSION=".$SHLIB_VERSION" 5932 +fi 5933 + case $system in 5934 + # TEA specific: 5935 + windows) 5936 + # This is a 2-stage check to make sure we have the 64-bit SDK 5937 + # We have to know where the SDK is installed. 5938 + # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs 5939 + # MACHINE is IX86 for LINK, but this is used by the manifest, 5940 + # which requires x86|amd64|ia64. 5941 + MACHINE="X86" 5942 + if test "$do64bit" != "no" ; then 5943 + if test "x${MSSDK}x" = "xx" ; then 5944 + MSSDK="C:/Progra~1/Microsoft Platform SDK" 5945 + fi 5946 + MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'` 5947 + PATH64="" 5948 + case "$do64bit" in 5949 + amd64|x64|yes) 5950 + MACHINE="AMD64" ; # default to AMD64 64-bit build 5951 + PATH64="${MSSDK}/Bin/Win64/x86/AMD64" 5952 + ;; 5953 + ia64) 5954 + MACHINE="IA64" 5955 + PATH64="${MSSDK}/Bin/Win64" 5956 + ;; 5957 + esac 5958 + if test "$GCC" != "yes" -a ! -d "${PATH64}" ; then 5959 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&5 5960 +$as_echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&2;} 5961 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ensure latest Platform SDK is installed" >&5 5962 +$as_echo "$as_me: WARNING: Ensure latest Platform SDK is installed" >&2;} 5963 + do64bit="no" 5964 + else 5965 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using 64-bit $MACHINE mode" >&5 5966 +$as_echo " Using 64-bit $MACHINE mode" >&6; } 5967 + do64bit_ok="yes" 5968 + fi 5969 + fi 5970 + 5971 + if test "$doWince" != "no" ; then 5972 + if test "$do64bit" != "no" ; then 5973 + as_fn_error $? "Windows/CE and 64-bit builds incompatible" "$LINENO" 5 5974 + fi 5975 + if test "$GCC" = "yes" ; then 5976 + as_fn_error $? "Windows/CE and GCC builds incompatible" "$LINENO" 5 5977 + fi 5978 + 5979 + # First, look for one uninstalled. 5980 + # the alternative search directory is invoked by --with-celib 5981 + 5982 + if test x"${no_celib}" = x ; then 5983 + # we reset no_celib in case something fails here 5984 + no_celib=true 5985 + 5986 +# Check whether --with-celib was given. 5987 +if test "${with_celib+set}" = set; then : 5988 + withval=$with_celib; with_celibconfig=${withval} 5989 +fi 5990 + 5991 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows/CE celib directory" >&5 5992 +$as_echo_n "checking for Windows/CE celib directory... " >&6; } 5993 + if ${ac_cv_c_celibconfig+:} false; then : 5994 + $as_echo_n "(cached) " >&6 5995 +else 5996 + 5997 + # First check to see if --with-celibconfig was specified. 5998 + if test x"${with_celibconfig}" != x ; then 5999 + if test -d "${with_celibconfig}/inc" ; then 6000 + ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)` 6001 + else 6002 + as_fn_error $? "${with_celibconfig} directory doesn't contain inc directory" "$LINENO" 5 6003 + fi 6004 + fi 6005 + 6006 + # then check for a celib library 6007 + if test x"${ac_cv_c_celibconfig}" = x ; then 6008 + for i in \ 6009 + ../celib-palm-3.0 \ 6010 + ../celib \ 6011 + ../../celib-palm-3.0 \ 6012 + ../../celib \ 6013 + `ls -dr ../celib-*3.[0-9]* 2>/dev/null` \ 6014 + ${srcdir}/../celib-palm-3.0 \ 6015 + ${srcdir}/../celib \ 6016 + `ls -dr ${srcdir}/../celib-*3.[0-9]* 2>/dev/null` \ 6017 + ; do 6018 + if test -d "$i/inc" ; then 6019 + ac_cv_c_celibconfig=`(cd $i; pwd)` 6020 + break 6021 + fi 6022 + done 6023 + fi 6024 + 6025 +fi 6026 + 6027 + if test x"${ac_cv_c_celibconfig}" = x ; then 6028 + as_fn_error $? "Cannot find celib support library directory" "$LINENO" 5 6029 + else 6030 + no_celib= 6031 + CELIB_DIR=${ac_cv_c_celibconfig} 6032 + CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` 6033 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $CELIB_DIR" >&5 6034 +$as_echo "found $CELIB_DIR" >&6; } 6035 + fi 6036 + fi 6037 + 6038 + # Set defaults for common evc4/PPC2003 setup 6039 + # Currently Tcl requires 300+, possibly 420+ for sockets 6040 + CEVERSION=420; # could be 211 300 301 400 420 ... 6041 + TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... 6042 + ARCH=ARM; # could be ARM MIPS X86EM ... 6043 + PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" 6044 + if test "$doWince" != "yes"; then 6045 + # If !yes then the user specified something 6046 + # Reset ARCH to allow user to skip specifying it 6047 + ARCH= 6048 + eval `echo $doWince | awk -F, '{ \ 6049 + if (length($1)) { printf "CEVERSION=\"%s\"\n", $1; \ 6050 + if ($1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ 6051 + if (length($2)) { printf "TARGETCPU=\"%s\"\n", toupper($2) }; \ 6052 + if (length($3)) { printf "ARCH=\"%s\"\n", toupper($3) }; \ 6053 + if (length($4)) { printf "PLATFORM=\"%s\"\n", $4 }; \ 6054 + }'` 6055 + if test "x${ARCH}" = "x" ; then 6056 + ARCH=$TARGETCPU; 6057 + fi 6058 + fi 6059 + OSVERSION=WCE$CEVERSION; 6060 + if test "x${WCEROOT}" = "x" ; then 6061 + WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" 6062 + if test ! -d "${WCEROOT}" ; then 6063 + WCEROOT="C:/Program Files/Microsoft eMbedded Tools" 6064 + fi 6065 + fi 6066 + if test "x${SDKROOT}" = "x" ; then 6067 + SDKROOT="C:/Program Files/Windows CE Tools" 6068 + if test ! -d "${SDKROOT}" ; then 6069 + SDKROOT="C:/Windows CE Tools" 6070 + fi 6071 + fi 6072 + WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` 6073 + SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` 6074 + if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \ 6075 + -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then 6076 + as_fn_error $? "could not find PocketPC SDK or target compiler to enable WinCE mode $CEVERSION,$TARGETCPU,$ARCH,$PLATFORM" "$LINENO" 5 6077 + doWince="no" 6078 + else 6079 + # We could PATH_NOSPACE these, but that's not important, 6080 + # as long as we quote them when used. 6081 + CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" 6082 + if test -d "${CEINCLUDE}/${TARGETCPU}" ; then 6083 + CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" 6084 + fi 6085 + CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" 6086 + fi 6087 + fi 6088 + 6089 + if test "$GCC" != "yes" ; then 6090 + if test "${SHARED_BUILD}" = "0" ; then 6091 + runtime=-MT 6092 + else 6093 + runtime=-MD 6094 + fi 6095 + case "x`echo \${VisualStudioVersion}`" in 6096 + x1[4-9]*) 6097 + lflags="${lflags} -nodefaultlib:libucrt.lib" 6098 + 6099 + vars="ucrt.lib" 6100 + for i in $vars; do 6101 + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 6102 + # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 6103 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 6104 + fi 6105 + PKG_LIBS="$PKG_LIBS $i" 6106 + done 6107 + 6108 + 6109 + ;; 6110 + *) 6111 + ;; 6112 + esac 6113 + 6114 + if test "$do64bit" != "no" ; then 6115 + # All this magic is necessary for the Win64 SDK RC1 - hobbs 6116 + CC="\"${PATH64}/cl.exe\"" 6117 + CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\"" 6118 + RC="\"${MSSDK}/bin/rc.exe\"" 6119 + lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\"" 6120 + LINKBIN="\"${PATH64}/link.exe\"" 6121 + CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d" 6122 + CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 6123 + # Avoid 'unresolved external symbol __security_cookie' 6124 + # errors, c.f. http://support.microsoft.com/?id=894573 6125 + 6126 + vars="bufferoverflowU.lib" 6127 + for i in $vars; do 6128 + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 6129 + # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 6130 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 6131 + fi 6132 + PKG_LIBS="$PKG_LIBS $i" 6133 + done 6134 + 6135 + 6136 + elif test "$doWince" != "no" ; then 6137 + CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" 6138 + if test "${TARGETCPU}" = "X86"; then 6139 + CC="\"${CEBINROOT}/cl.exe\"" 6140 + else 6141 + CC="\"${CEBINROOT}/cl${ARCH}.exe\"" 6142 + fi 6143 + CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" 6144 + RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" 6145 + arch=`echo ${ARCH} | awk '{print tolower($0)}'` 6146 + defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS" 6147 + if test "${SHARED_BUILD}" = "1" ; then 6148 + # Static CE builds require static celib as well 6149 + defs="${defs} _DLL" 6150 + fi 6151 + for i in $defs ; do 6152 + 6153 +cat >>confdefs.h <<_ACEOF 6154 +#define $i 1 6155 +_ACEOF 6156 + 6157 + done 6158 + 6159 +cat >>confdefs.h <<_ACEOF 6160 +#define _WIN32_WCE $CEVERSION 6161 +_ACEOF 6162 + 6163 + 6164 +cat >>confdefs.h <<_ACEOF 6165 +#define UNDER_CE $CEVERSION 6166 +_ACEOF 6167 + 6168 + CFLAGS_DEBUG="-nologo -Zi -Od" 6169 + CFLAGS_OPTIMIZE="-nologo -Ox" 6170 + lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` 6171 + lflags="${lflags} -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" 6172 + LINKBIN="\"${CEBINROOT}/link.exe\"" 6173 + 6174 + else 6175 + RC="rc" 6176 + lflags="${lflags} -nologo" 6177 + LINKBIN="link" 6178 + CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d" 6179 + CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 6180 + fi 6181 + fi 6182 + 6183 + if test "$GCC" = "yes"; then 6184 + # mingw gcc mode 6185 + if test -n "$ac_tool_prefix"; then 6186 + # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. 6187 +set dummy ${ac_tool_prefix}windres; ac_word=$2 6188 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 6189 +$as_echo_n "checking for $ac_word... " >&6; } 6190 +if ${ac_cv_prog_RC+:} false; then : 6191 + $as_echo_n "(cached) " >&6 6192 +else 6193 + if test -n "$RC"; then 6194 + ac_cv_prog_RC="$RC" # Let the user override the test. 6195 +else 6196 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 6197 +for as_dir in $PATH 6198 +do 6199 + IFS=$as_save_IFS 6200 + test -z "$as_dir" && as_dir=. 6201 + for ac_exec_ext in '' $ac_executable_extensions; do 6202 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 6203 + ac_cv_prog_RC="${ac_tool_prefix}windres" 6204 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 6205 + break 2 6206 + fi 6207 +done 6208 + done 6209 +IFS=$as_save_IFS 6210 + 6211 +fi 6212 +fi 6213 +RC=$ac_cv_prog_RC 6214 +if test -n "$RC"; then 6215 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 6216 +$as_echo "$RC" >&6; } 6217 +else 6218 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 6219 +$as_echo "no" >&6; } 6220 +fi 6221 + 6222 + 6223 +fi 6224 +if test -z "$ac_cv_prog_RC"; then 6225 + ac_ct_RC=$RC 6226 + # Extract the first word of "windres", so it can be a program name with args. 6227 +set dummy windres; ac_word=$2 6228 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 6229 +$as_echo_n "checking for $ac_word... " >&6; } 6230 +if ${ac_cv_prog_ac_ct_RC+:} false; then : 6231 + $as_echo_n "(cached) " >&6 6232 +else 6233 + if test -n "$ac_ct_RC"; then 6234 + ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. 6235 +else 6236 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 6237 +for as_dir in $PATH 6238 +do 6239 + IFS=$as_save_IFS 6240 + test -z "$as_dir" && as_dir=. 6241 + for ac_exec_ext in '' $ac_executable_extensions; do 6242 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 6243 + ac_cv_prog_ac_ct_RC="windres" 6244 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 6245 + break 2 6246 + fi 6247 +done 6248 + done 6249 +IFS=$as_save_IFS 6250 + 6251 +fi 6252 +fi 6253 +ac_ct_RC=$ac_cv_prog_ac_ct_RC 6254 +if test -n "$ac_ct_RC"; then 6255 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5 6256 +$as_echo "$ac_ct_RC" >&6; } 6257 +else 6258 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 6259 +$as_echo "no" >&6; } 6260 +fi 6261 + 6262 + if test "x$ac_ct_RC" = x; then 6263 + RC="" 6264 + else 6265 + case $cross_compiling:$ac_tool_warned in 6266 +yes:) 6267 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 6268 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} 6269 +ac_tool_warned=yes ;; 6270 +esac 6271 + RC=$ac_ct_RC 6272 + fi 6273 +else 6274 + RC="$ac_cv_prog_RC" 6275 +fi 6276 + 6277 + CFLAGS_DEBUG="-g" 6278 + CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" 6279 + SHLIB_LD='${CC} -shared' 6280 + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 6281 + LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}" 6282 + LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}" 6283 + 6284 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cross-compile version of gcc" >&5 6285 +$as_echo_n "checking for cross-compile version of gcc... " >&6; } 6286 +if ${ac_cv_cross+:} false; then : 6287 + $as_echo_n "(cached) " >&6 6288 +else 6289 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6290 +/* end confdefs.h. */ 6291 + 6292 + #ifdef _WIN32 6293 + #error cross-compiler 6294 + #endif 6295 + 6296 +int 6297 +main () 6298 +{ 6299 + 6300 + ; 6301 + return 0; 6302 +} 6303 +_ACEOF 6304 +if ac_fn_c_try_compile "$LINENO"; then : 6305 + ac_cv_cross=yes 6306 +else 6307 + ac_cv_cross=no 6308 +fi 6309 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 6310 + 6311 +fi 6312 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cross" >&5 6313 +$as_echo "$ac_cv_cross" >&6; } 6314 + if test "$ac_cv_cross" = "yes"; then 6315 + case "$do64bit" in 6316 + amd64|x64|yes) 6317 + CC="x86_64-w64-mingw32-gcc" 6318 + LD="x86_64-w64-mingw32-ld" 6319 + AR="x86_64-w64-mingw32-ar" 6320 + RANLIB="x86_64-w64-mingw32-ranlib" 6321 + RC="x86_64-w64-mingw32-windres" 6322 + ;; 6323 + *) 6324 + CC="i686-w64-mingw32-gcc" 6325 + LD="i686-w64-mingw32-ld" 6326 + AR="i686-w64-mingw32-ar" 6327 + RANLIB="i686-w64-mingw32-ranlib" 6328 + RC="i686-w64-mingw32-windres" 6329 + ;; 6330 + esac 6331 + fi 6332 + 6333 + else 6334 + SHLIB_LD="${LINKBIN} -dll ${lflags}" 6335 + # link -lib only works when -lib is the first arg 6336 + STLIB_LD="${LINKBIN} -lib ${lflags}" 6337 + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.lib' 6338 + PATHTYPE=-w 6339 + # For information on what debugtype is most useful, see: 6340 + # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp 6341 + # and also 6342 + # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx 6343 + # This essentially turns it all on. 6344 + LDFLAGS_DEBUG="-debug -debugtype:cv" 6345 + LDFLAGS_OPTIMIZE="-release" 6346 + if test "$doWince" != "no" ; then 6347 + LDFLAGS_CONSOLE="-link ${lflags}" 6348 + LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} 6349 + else 6350 + LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 6351 + LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 6352 + fi 6353 + fi 6354 + 6355 + SHLIB_SUFFIX=".dll" 6356 + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll' 6357 + 6358 + TCL_LIB_VERSIONS_OK=nodots 6359 + ;; 6360 + AIX-*) 6361 + if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"; then : 6362 + 6363 + # AIX requires the _r compiler when gcc isn't being used 6364 + case "${CC}" in 6365 + *_r|*_r\ *) 6366 + # ok ... 6367 + ;; 6368 + *) 6369 + # Make sure only first arg gets _r 6370 + CC=`echo "$CC" | sed -e 's/^\([^ ]*\)/\1_r/'` 6371 + ;; 6372 + esac 6373 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using $CC for compiling with threads" >&5 6374 +$as_echo "Using $CC for compiling with threads" >&6; } 6375 + 6376 +fi 6377 + LIBS="$LIBS -lc" 6378 + SHLIB_CFLAGS="" 6379 + SHLIB_SUFFIX=".so" 6380 + 6381 + LD_LIBRARY_PATH_VAR="LIBPATH" 6382 + 6383 + # Check to enable 64-bit flags for compiler/linker 6384 + if test "$do64bit" = yes; then : 6385 + 6386 + if test "$GCC" = yes; then : 6387 + 6388 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 6389 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;} 6390 + 6391 +else 6392 + 6393 + do64bit_ok=yes 6394 + CFLAGS="$CFLAGS -q64" 6395 + LDFLAGS_ARCH="-q64" 6396 + RANLIB="${RANLIB} -X64" 6397 + AR="${AR} -X64" 6398 + SHLIB_LD_FLAGS="-b64" 6399 + 6400 +fi 6401 + 6402 +fi 6403 + 6404 + if test "`uname -m`" = ia64; then : 6405 + 6406 + # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC 6407 + SHLIB_LD="/usr/ccs/bin/ld -G -z text" 6408 + if test "$GCC" = yes; then : 6409 + 6410 + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 6411 + 6412 +else 6413 + 6414 + CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}' 6415 + 6416 +fi 6417 + LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 6418 + 6419 +else 6420 + 6421 + if test "$GCC" = yes; then : 6422 + 6423 + SHLIB_LD='${CC} -shared -Wl,-bexpall' 6424 + 6425 +else 6426 + 6427 + SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry" 6428 + LDFLAGS="$LDFLAGS -brtl" 6429 + 6430 +fi 6431 + SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}" 6432 + CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}' 6433 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6434 + 6435 +fi 6436 + ;; 6437 + BeOS*) 6438 + SHLIB_CFLAGS="-fPIC" 6439 + SHLIB_LD='${CC} -nostart' 6440 + SHLIB_SUFFIX=".so" 6441 + 6442 + #----------------------------------------------------------- 6443 + # Check for inet_ntoa in -lbind, for BeOS (which also needs 6444 + # -lsocket, even if the network functions are in -lnet which 6445 + # is always linked to, for compatibility. 6446 + #----------------------------------------------------------- 6447 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lbind" >&5 6448 +$as_echo_n "checking for inet_ntoa in -lbind... " >&6; } 6449 +if ${ac_cv_lib_bind_inet_ntoa+:} false; then : 6450 + $as_echo_n "(cached) " >&6 6451 +else 6452 + ac_check_lib_save_LIBS=$LIBS 6453 +LIBS="-lbind $LIBS" 6454 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6455 +/* end confdefs.h. */ 6456 + 6457 +/* Override any GCC internal prototype to avoid an error. 6458 + Use char because int might match the return type of a GCC 6459 + builtin and then its argument prototype would still apply. */ 6460 +#ifdef __cplusplus 6461 +extern "C" 6462 +#endif 6463 +char inet_ntoa (); 6464 +int 6465 +main () 6466 +{ 6467 +return inet_ntoa (); 6468 + ; 6469 + return 0; 6470 +} 6471 +_ACEOF 6472 +if ac_fn_c_try_link "$LINENO"; then : 6473 + ac_cv_lib_bind_inet_ntoa=yes 6474 +else 6475 + ac_cv_lib_bind_inet_ntoa=no 6476 +fi 6477 +rm -f core conftest.err conftest.$ac_objext \ 6478 + conftest$ac_exeext conftest.$ac_ext 6479 +LIBS=$ac_check_lib_save_LIBS 6480 +fi 6481 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_inet_ntoa" >&5 6482 +$as_echo "$ac_cv_lib_bind_inet_ntoa" >&6; } 6483 +if test "x$ac_cv_lib_bind_inet_ntoa" = xyes; then : 6484 + LIBS="$LIBS -lbind -lsocket" 6485 +fi 6486 + 6487 + ;; 6488 + BSD/OS-4.*) 6489 + SHLIB_CFLAGS="-export-dynamic -fPIC" 6490 + SHLIB_LD='${CC} -shared' 6491 + SHLIB_SUFFIX=".so" 6492 + LDFLAGS="$LDFLAGS -export-dynamic" 6493 + CC_SEARCH_FLAGS="" 6494 + LD_SEARCH_FLAGS="" 6495 + ;; 6496 + CYGWIN_*) 6497 + SHLIB_CFLAGS="" 6498 + SHLIB_LD='${CC} -shared' 6499 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a" 6500 + SHLIB_SUFFIX=".dll" 6501 + EXEEXT=".exe" 6502 + do64bit_ok=yes 6503 + CC_SEARCH_FLAGS="" 6504 + LD_SEARCH_FLAGS="" 6505 + ;; 6506 + Haiku*) 6507 + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 6508 + SHLIB_CFLAGS="-fPIC" 6509 + SHLIB_SUFFIX=".so" 6510 + SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared' 6511 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lnetwork" >&5 6512 +$as_echo_n "checking for inet_ntoa in -lnetwork... " >&6; } 6513 +if ${ac_cv_lib_network_inet_ntoa+:} false; then : 6514 + $as_echo_n "(cached) " >&6 6515 +else 6516 + ac_check_lib_save_LIBS=$LIBS 6517 +LIBS="-lnetwork $LIBS" 6518 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6519 +/* end confdefs.h. */ 6520 + 6521 +/* Override any GCC internal prototype to avoid an error. 6522 + Use char because int might match the return type of a GCC 6523 + builtin and then its argument prototype would still apply. */ 6524 +#ifdef __cplusplus 6525 +extern "C" 6526 +#endif 6527 +char inet_ntoa (); 6528 +int 6529 +main () 6530 +{ 6531 +return inet_ntoa (); 6532 + ; 6533 + return 0; 6534 +} 6535 +_ACEOF 6536 +if ac_fn_c_try_link "$LINENO"; then : 6537 + ac_cv_lib_network_inet_ntoa=yes 6538 +else 6539 + ac_cv_lib_network_inet_ntoa=no 6540 +fi 6541 +rm -f core conftest.err conftest.$ac_objext \ 6542 + conftest$ac_exeext conftest.$ac_ext 6543 +LIBS=$ac_check_lib_save_LIBS 6544 +fi 6545 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_inet_ntoa" >&5 6546 +$as_echo "$ac_cv_lib_network_inet_ntoa" >&6; } 6547 +if test "x$ac_cv_lib_network_inet_ntoa" = xyes; then : 6548 + LIBS="$LIBS -lnetwork" 6549 +fi 6550 + 6551 + ;; 6552 + HP-UX-*.11.*) 6553 + # Use updated header definitions where possible 6554 + 6555 +$as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h 6556 + 6557 + # TEA specific: Needed by Tcl, but not most extensions 6558 + #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?]) 6559 + #LIBS="$LIBS -lxnet" # Use the XOPEN network library 6560 + 6561 + if test "`uname -m`" = ia64; then : 6562 + 6563 + SHLIB_SUFFIX=".so" 6564 + # Use newer C++ library for C++ extensions 6565 + #if test "$GCC" != "yes" ; then 6566 + # CPPFLAGS="-AA" 6567 + #fi 6568 + 6569 +else 6570 + 6571 + SHLIB_SUFFIX=".sl" 6572 + 6573 +fi 6574 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 6575 +$as_echo_n "checking for shl_load in -ldld... " >&6; } 6576 +if ${ac_cv_lib_dld_shl_load+:} false; then : 6577 + $as_echo_n "(cached) " >&6 6578 +else 6579 + ac_check_lib_save_LIBS=$LIBS 6580 +LIBS="-ldld $LIBS" 6581 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6582 +/* end confdefs.h. */ 6583 + 6584 +/* Override any GCC internal prototype to avoid an error. 6585 + Use char because int might match the return type of a GCC 6586 + builtin and then its argument prototype would still apply. */ 6587 +#ifdef __cplusplus 6588 +extern "C" 6589 +#endif 6590 +char shl_load (); 6591 +int 6592 +main () 6593 +{ 6594 +return shl_load (); 6595 + ; 6596 + return 0; 6597 +} 6598 +_ACEOF 6599 +if ac_fn_c_try_link "$LINENO"; then : 6600 + ac_cv_lib_dld_shl_load=yes 6601 +else 6602 + ac_cv_lib_dld_shl_load=no 6603 +fi 6604 +rm -f core conftest.err conftest.$ac_objext \ 6605 + conftest$ac_exeext conftest.$ac_ext 6606 +LIBS=$ac_check_lib_save_LIBS 6607 +fi 6608 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 6609 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } 6610 +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : 6611 + tcl_ok=yes 6612 +else 6613 + tcl_ok=no 6614 +fi 6615 + 6616 + if test "$tcl_ok" = yes; then : 6617 + 6618 + LDFLAGS="$LDFLAGS -Wl,-E" 6619 + CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.' 6620 + LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.' 6621 + LD_LIBRARY_PATH_VAR="SHLIB_PATH" 6622 + 6623 +fi 6624 + if test "$GCC" = yes; then : 6625 + 6626 + SHLIB_LD='${CC} -shared' 6627 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6628 + 6629 +else 6630 + 6631 + CFLAGS="$CFLAGS -z" 6632 + # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc 6633 + #CFLAGS="$CFLAGS +DAportable" 6634 + SHLIB_CFLAGS="+z" 6635 + SHLIB_LD="ld -b" 6636 + 6637 +fi 6638 + 6639 + # Check to enable 64-bit flags for compiler/linker 6640 + if test "$do64bit" = "yes"; then : 6641 + 6642 + if test "$GCC" = yes; then : 6643 + 6644 + case `${CC} -dumpmachine` in 6645 + hppa64*) 6646 + # 64-bit gcc in use. Fix flags for GNU ld. 6647 + do64bit_ok=yes 6648 + SHLIB_LD='${CC} -shared' 6649 + if test $doRpath = yes; then : 6650 + 6651 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6652 +fi 6653 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6654 + ;; 6655 + *) 6656 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 6657 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;} 6658 + ;; 6659 + esac 6660 + 6661 +else 6662 + 6663 + do64bit_ok=yes 6664 + CFLAGS="$CFLAGS +DD64" 6665 + LDFLAGS_ARCH="+DD64" 6666 + 6667 +fi 6668 + 6669 +fi ;; 6670 + IRIX-6.*) 6671 + SHLIB_CFLAGS="" 6672 + SHLIB_LD="ld -n32 -shared -rdata_shared" 6673 + SHLIB_SUFFIX=".so" 6674 + if test $doRpath = yes; then : 6675 + 6676 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6677 + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 6678 +fi 6679 + if test "$GCC" = yes; then : 6680 + 6681 + CFLAGS="$CFLAGS -mabi=n32" 6682 + LDFLAGS="$LDFLAGS -mabi=n32" 6683 + 6684 +else 6685 + 6686 + case $system in 6687 + IRIX-6.3) 6688 + # Use to build 6.2 compatible binaries on 6.3. 6689 + CFLAGS="$CFLAGS -n32 -D_OLD_TERMIOS" 6690 + ;; 6691 + *) 6692 + CFLAGS="$CFLAGS -n32" 6693 + ;; 6694 + esac 6695 + LDFLAGS="$LDFLAGS -n32" 6696 + 6697 +fi 6698 + ;; 6699 + IRIX64-6.*) 6700 + SHLIB_CFLAGS="" 6701 + SHLIB_LD="ld -n32 -shared -rdata_shared" 6702 + SHLIB_SUFFIX=".so" 6703 + if test $doRpath = yes; then : 6704 + 6705 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6706 + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 6707 +fi 6708 + 6709 + # Check to enable 64-bit flags for compiler/linker 6710 + 6711 + if test "$do64bit" = yes; then : 6712 + 6713 + if test "$GCC" = yes; then : 6714 + 6715 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported by gcc" >&5 6716 +$as_echo "$as_me: WARNING: 64bit mode not supported by gcc" >&2;} 6717 + 6718 +else 6719 + 6720 + do64bit_ok=yes 6721 + SHLIB_LD="ld -64 -shared -rdata_shared" 6722 + CFLAGS="$CFLAGS -64" 6723 + LDFLAGS_ARCH="-64" 6724 + 6725 +fi 6726 + 6727 +fi 6728 + ;; 6729 + Linux*|GNU*|NetBSD-Debian) 6730 + SHLIB_CFLAGS="-fPIC" 6731 + SHLIB_SUFFIX=".so" 6732 + 6733 + # TEA specific: 6734 + CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" 6735 + 6736 + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 6737 + SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared' 6738 + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 6739 + if test $doRpath = yes; then : 6740 + 6741 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6742 +fi 6743 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6744 + if test "`uname -m`" = "alpha"; then : 6745 + CFLAGS="$CFLAGS -mieee" 6746 +fi 6747 + if test $do64bit = yes; then : 6748 + 6749 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -m64 flag" >&5 6750 +$as_echo_n "checking if compiler accepts -m64 flag... " >&6; } 6751 +if ${tcl_cv_cc_m64+:} false; then : 6752 + $as_echo_n "(cached) " >&6 6753 +else 6754 + 6755 + hold_cflags=$CFLAGS 6756 + CFLAGS="$CFLAGS -m64" 6757 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6758 +/* end confdefs.h. */ 6759 + 6760 +int 6761 +main () 6762 +{ 6763 + 6764 + ; 6765 + return 0; 6766 +} 6767 +_ACEOF 6768 +if ac_fn_c_try_link "$LINENO"; then : 6769 + tcl_cv_cc_m64=yes 6770 +else 6771 + tcl_cv_cc_m64=no 6772 +fi 6773 +rm -f core conftest.err conftest.$ac_objext \ 6774 + conftest$ac_exeext conftest.$ac_ext 6775 + CFLAGS=$hold_cflags 6776 +fi 6777 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_m64" >&5 6778 +$as_echo "$tcl_cv_cc_m64" >&6; } 6779 + if test $tcl_cv_cc_m64 = yes; then : 6780 + 6781 + CFLAGS="$CFLAGS -m64" 6782 + do64bit_ok=yes 6783 + 6784 +fi 6785 + 6786 +fi 6787 + 6788 + # The combo of gcc + glibc has a bug related to inlining of 6789 + # functions like strtod(). The -fno-builtin flag should address 6790 + # this problem but it does not work. The -fno-inline flag is kind 6791 + # of overkill but it works. Disable inlining only when one of the 6792 + # files in compat/*.c is being linked in. 6793 + 6794 + if test x"${USE_COMPAT}" != x; then : 6795 + CFLAGS="$CFLAGS -fno-inline" 6796 +fi 6797 + ;; 6798 + Lynx*) 6799 + SHLIB_CFLAGS="-fPIC" 6800 + SHLIB_SUFFIX=".so" 6801 + CFLAGS_OPTIMIZE=-02 6802 + SHLIB_LD='${CC} -shared' 6803 + LD_FLAGS="-Wl,--export-dynamic" 6804 + if test $doRpath = yes; then : 6805 + 6806 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6807 + LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6808 +fi 6809 + ;; 6810 + OpenBSD-*) 6811 + arch=`arch -s` 6812 + case "$arch" in 6813 + alpha|sparc64) 6814 + SHLIB_CFLAGS="-fPIC" 6815 + ;; 6816 + *) 6817 + SHLIB_CFLAGS="-fpic" 6818 + ;; 6819 + esac 6820 + SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 6821 + SHLIB_SUFFIX=".so" 6822 + if test $doRpath = yes; then : 6823 + 6824 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6825 +fi 6826 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6827 + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}' 6828 + LDFLAGS="-Wl,-export-dynamic" 6829 + CFLAGS_OPTIMIZE="-O2" 6830 + if test "${TCL_THREADS}" = "1"; then : 6831 + 6832 + # On OpenBSD: Compile with -pthread 6833 + # Don't link with -lpthread 6834 + LIBS=`echo $LIBS | sed s/-lpthread//` 6835 + CFLAGS="$CFLAGS -pthread" 6836 + 6837 +fi 6838 + # OpenBSD doesn't do version numbers with dots. 6839 + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 6840 + TCL_LIB_VERSIONS_OK=nodots 6841 + ;; 6842 + NetBSD-*) 6843 + # NetBSD has ELF and can use 'cc -shared' to build shared libs 6844 + SHLIB_CFLAGS="-fPIC" 6845 + SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 6846 + SHLIB_SUFFIX=".so" 6847 + LDFLAGS="$LDFLAGS -export-dynamic" 6848 + if test $doRpath = yes; then : 6849 + 6850 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6851 +fi 6852 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6853 + if test "${TCL_THREADS}" = "1"; then : 6854 + 6855 + # The -pthread needs to go in the CFLAGS, not LIBS 6856 + LIBS=`echo $LIBS | sed s/-pthread//` 6857 + CFLAGS="$CFLAGS -pthread" 6858 + LDFLAGS="$LDFLAGS -pthread" 6859 + 6860 +fi 6861 + ;; 6862 + FreeBSD-*) 6863 + # This configuration from FreeBSD Ports. 6864 + SHLIB_CFLAGS="-fPIC" 6865 + SHLIB_LD="${CC} -shared" 6866 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname,\$@" 6867 + SHLIB_SUFFIX=".so" 6868 + LDFLAGS="" 6869 + if test $doRpath = yes; then : 6870 + 6871 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6872 + LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6873 +fi 6874 + if test "${TCL_THREADS}" = "1"; then : 6875 + 6876 + # The -pthread needs to go in the LDFLAGS, not LIBS 6877 + LIBS=`echo $LIBS | sed s/-pthread//` 6878 + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 6879 + LDFLAGS="$LDFLAGS $PTHREAD_LIBS" 6880 +fi 6881 + case $system in 6882 + FreeBSD-3.*) 6883 + # Version numbers are dot-stripped by system policy. 6884 + TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` 6885 + UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 6886 + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' 6887 + TCL_LIB_VERSIONS_OK=nodots 6888 + ;; 6889 + esac 6890 + ;; 6891 + Darwin-*) 6892 + CFLAGS_OPTIMIZE="-Os" 6893 + SHLIB_CFLAGS="-fno-common" 6894 + # To avoid discrepancies between what headers configure sees during 6895 + # preprocessing tests and compiling tests, move any -isysroot and 6896 + # -mmacosx-version-min flags from CFLAGS to CPPFLAGS: 6897 + CPPFLAGS="${CPPFLAGS} `echo " ${CFLAGS}" | \ 6898 + awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \ 6899 + if ($i~/^(isysroot|mmacosx-version-min)/) print "-"$i}'`" 6900 + CFLAGS="`echo " ${CFLAGS}" | \ 6901 + awk 'BEGIN {FS=" +-";ORS=" "}; {for (i=2;i<=NF;i++) \ 6902 + if (!($i~/^(isysroot|mmacosx-version-min)/)) print "-"$i}'`" 6903 + if test $do64bit = yes; then : 6904 + 6905 + case `arch` in 6906 + ppc) 6907 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch ppc64 flag" >&5 6908 +$as_echo_n "checking if compiler accepts -arch ppc64 flag... " >&6; } 6909 +if ${tcl_cv_cc_arch_ppc64+:} false; then : 6910 + $as_echo_n "(cached) " >&6 6911 +else 6912 + 6913 + hold_cflags=$CFLAGS 6914 + CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5" 6915 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6916 +/* end confdefs.h. */ 6917 + 6918 +int 6919 +main () 6920 +{ 6921 + 6922 + ; 6923 + return 0; 6924 +} 6925 +_ACEOF 6926 +if ac_fn_c_try_link "$LINENO"; then : 6927 + tcl_cv_cc_arch_ppc64=yes 6928 +else 6929 + tcl_cv_cc_arch_ppc64=no 6930 +fi 6931 +rm -f core conftest.err conftest.$ac_objext \ 6932 + conftest$ac_exeext conftest.$ac_ext 6933 + CFLAGS=$hold_cflags 6934 +fi 6935 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_ppc64" >&5 6936 +$as_echo "$tcl_cv_cc_arch_ppc64" >&6; } 6937 + if test $tcl_cv_cc_arch_ppc64 = yes; then : 6938 + 6939 + CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5" 6940 + do64bit_ok=yes 6941 + 6942 +fi;; 6943 + i386) 6944 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler accepts -arch x86_64 flag" >&5 6945 +$as_echo_n "checking if compiler accepts -arch x86_64 flag... " >&6; } 6946 +if ${tcl_cv_cc_arch_x86_64+:} false; then : 6947 + $as_echo_n "(cached) " >&6 6948 +else 6949 + 6950 + hold_cflags=$CFLAGS 6951 + CFLAGS="$CFLAGS -arch x86_64" 6952 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6953 +/* end confdefs.h. */ 6954 + 6955 +int 6956 +main () 6957 +{ 6958 + 6959 + ; 6960 + return 0; 6961 +} 6962 +_ACEOF 6963 +if ac_fn_c_try_link "$LINENO"; then : 6964 + tcl_cv_cc_arch_x86_64=yes 6965 +else 6966 + tcl_cv_cc_arch_x86_64=no 6967 +fi 6968 +rm -f core conftest.err conftest.$ac_objext \ 6969 + conftest$ac_exeext conftest.$ac_ext 6970 + CFLAGS=$hold_cflags 6971 +fi 6972 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_arch_x86_64" >&5 6973 +$as_echo "$tcl_cv_cc_arch_x86_64" >&6; } 6974 + if test $tcl_cv_cc_arch_x86_64 = yes; then : 6975 + 6976 + CFLAGS="$CFLAGS -arch x86_64" 6977 + do64bit_ok=yes 6978 + 6979 +fi;; 6980 + *) 6981 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&5 6982 +$as_echo "$as_me: WARNING: Don't know how enable 64-bit on architecture \`arch\`" >&2;};; 6983 + esac 6984 + 6985 +else 6986 + 6987 + # Check for combined 32-bit and 64-bit fat build 6988 + if echo "$CFLAGS " |grep -E -q -- '-arch (ppc64|x86_64) ' \ 6989 + && echo "$CFLAGS " |grep -E -q -- '-arch (ppc|i386) '; then : 6990 + 6991 + fat_32_64=yes 6992 +fi 6993 + 6994 +fi 6995 + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 6996 + SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}' 6997 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -single_module flag" >&5 6998 +$as_echo_n "checking if ld accepts -single_module flag... " >&6; } 6999 +if ${tcl_cv_ld_single_module+:} false; then : 7000 + $as_echo_n "(cached) " >&6 7001 +else 7002 + 7003 + hold_ldflags=$LDFLAGS 7004 + LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module" 7005 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7006 +/* end confdefs.h. */ 7007 + 7008 +int 7009 +main () 7010 +{ 7011 +int i; 7012 + ; 7013 + return 0; 7014 +} 7015 +_ACEOF 7016 +if ac_fn_c_try_link "$LINENO"; then : 7017 + tcl_cv_ld_single_module=yes 7018 +else 7019 + tcl_cv_ld_single_module=no 7020 +fi 7021 +rm -f core conftest.err conftest.$ac_objext \ 7022 + conftest$ac_exeext conftest.$ac_ext 7023 + LDFLAGS=$hold_ldflags 7024 +fi 7025 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_single_module" >&5 7026 +$as_echo "$tcl_cv_ld_single_module" >&6; } 7027 + if test $tcl_cv_ld_single_module = yes; then : 7028 + 7029 + SHLIB_LD="${SHLIB_LD} -Wl,-single_module" 7030 + 7031 +fi 7032 + # TEA specific: link shlib with current and compatibility version flags 7033 + vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([0-9]\{1,5\}\)\(\(\.[0-9]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d` 7034 + SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}" 7035 + SHLIB_SUFFIX=".dylib" 7036 + # Don't use -prebind when building for Mac OS X 10.4 or later only: 7037 + if test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int($2)}'`" -lt 4 -a \ 7038 + "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int($2)}'`" -lt 4; then : 7039 + 7040 + LDFLAGS="$LDFLAGS -prebind" 7041 +fi 7042 + LDFLAGS="$LDFLAGS -headerpad_max_install_names" 7043 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5 7044 +$as_echo_n "checking if ld accepts -search_paths_first flag... " >&6; } 7045 +if ${tcl_cv_ld_search_paths_first+:} false; then : 7046 + $as_echo_n "(cached) " >&6 7047 +else 7048 + 7049 + hold_ldflags=$LDFLAGS 7050 + LDFLAGS="$LDFLAGS -Wl,-search_paths_first" 7051 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7052 +/* end confdefs.h. */ 7053 + 7054 +int 7055 +main () 7056 +{ 7057 +int i; 7058 + ; 7059 + return 0; 7060 +} 7061 +_ACEOF 7062 +if ac_fn_c_try_link "$LINENO"; then : 7063 + tcl_cv_ld_search_paths_first=yes 7064 +else 7065 + tcl_cv_ld_search_paths_first=no 7066 +fi 7067 +rm -f core conftest.err conftest.$ac_objext \ 7068 + conftest$ac_exeext conftest.$ac_ext 7069 + LDFLAGS=$hold_ldflags 7070 +fi 7071 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_search_paths_first" >&5 7072 +$as_echo "$tcl_cv_ld_search_paths_first" >&6; } 7073 + if test $tcl_cv_ld_search_paths_first = yes; then : 7074 + 7075 + LDFLAGS="$LDFLAGS -Wl,-search_paths_first" 7076 + 7077 +fi 7078 + if test "$tcl_cv_cc_visibility_hidden" != yes; then : 7079 + 7080 + 7081 +$as_echo "#define MODULE_SCOPE __private_extern__" >>confdefs.h 7082 + 7083 + tcl_cv_cc_visibility_hidden=yes 7084 + 7085 +fi 7086 + CC_SEARCH_FLAGS="" 7087 + LD_SEARCH_FLAGS="" 7088 + LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH" 7089 + # TEA specific: for combined 32 & 64 bit fat builds of Tk 7090 + # extensions, verify that 64-bit build is possible. 7091 + if test "$fat_32_64" = yes && test -n "${TK_BIN_DIR}"; then : 7092 + 7093 + if test "${TEA_WINDOWINGSYSTEM}" = x11; then : 7094 + 7095 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit X11" >&5 7096 +$as_echo_n "checking for 64-bit X11... " >&6; } 7097 +if ${tcl_cv_lib_x11_64+:} false; then : 7098 + $as_echo_n "(cached) " >&6 7099 +else 7100 + 7101 + for v in CFLAGS CPPFLAGS LDFLAGS; do 7102 + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' 7103 + done 7104 + CPPFLAGS="$CPPFLAGS -I/usr/X11R6/include" 7105 + LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11" 7106 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7107 +/* end confdefs.h. */ 7108 +#include <X11/Xlib.h> 7109 +int 7110 +main () 7111 +{ 7112 +XrmInitialize(); 7113 + ; 7114 + return 0; 7115 +} 7116 +_ACEOF 7117 +if ac_fn_c_try_link "$LINENO"; then : 7118 + tcl_cv_lib_x11_64=yes 7119 +else 7120 + tcl_cv_lib_x11_64=no 7121 +fi 7122 +rm -f core conftest.err conftest.$ac_objext \ 7123 + conftest$ac_exeext conftest.$ac_ext 7124 + for v in CFLAGS CPPFLAGS LDFLAGS; do 7125 + eval $v'="$hold_'$v'"' 7126 + done 7127 +fi 7128 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_x11_64" >&5 7129 +$as_echo "$tcl_cv_lib_x11_64" >&6; } 7130 + 7131 +fi 7132 + if test "${TEA_WINDOWINGSYSTEM}" = aqua; then : 7133 + 7134 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit Tk" >&5 7135 +$as_echo_n "checking for 64-bit Tk... " >&6; } 7136 +if ${tcl_cv_lib_tk_64+:} false; then : 7137 + $as_echo_n "(cached) " >&6 7138 +else 7139 + 7140 + for v in CFLAGS CPPFLAGS LDFLAGS; do 7141 + eval 'hold_'$v'="$'$v'";'$v'="`echo "$'$v' "|sed -e "s/-arch ppc / /g" -e "s/-arch i386 / /g"`"' 7142 + done 7143 + CPPFLAGS="$CPPFLAGS -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 ${TCL_INCLUDES} ${TK_INCLUDES}" 7144 + LDFLAGS="$LDFLAGS ${TCL_STUB_LIB_SPEC} ${TK_STUB_LIB_SPEC}" 7145 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7146 +/* end confdefs.h. */ 7147 +#include <tk.h> 7148 +int 7149 +main () 7150 +{ 7151 +Tk_InitStubs(NULL, "", 0); 7152 + ; 7153 + return 0; 7154 +} 7155 +_ACEOF 7156 +if ac_fn_c_try_link "$LINENO"; then : 7157 + tcl_cv_lib_tk_64=yes 7158 +else 7159 + tcl_cv_lib_tk_64=no 7160 +fi 7161 +rm -f core conftest.err conftest.$ac_objext \ 7162 + conftest$ac_exeext conftest.$ac_ext 7163 + for v in CFLAGS CPPFLAGS LDFLAGS; do 7164 + eval $v'="$hold_'$v'"' 7165 + done 7166 +fi 7167 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_lib_tk_64" >&5 7168 +$as_echo "$tcl_cv_lib_tk_64" >&6; } 7169 + 7170 +fi 7171 + # remove 64-bit arch flags from CFLAGS et al. if configuration 7172 + # does not support 64-bit. 7173 + if test "$tcl_cv_lib_tk_64" = no -o "$tcl_cv_lib_x11_64" = no; then : 7174 + 7175 + { $as_echo "$as_me:${as_lineno-$LINENO}: Removing 64-bit architectures from compiler & linker flags" >&5 7176 +$as_echo "$as_me: Removing 64-bit architectures from compiler & linker flags" >&6;} 7177 + for v in CFLAGS CPPFLAGS LDFLAGS; do 7178 + eval $v'="`echo "$'$v' "|sed -e "s/-arch ppc64 / /g" -e "s/-arch x86_64 / /g"`"' 7179 + done 7180 +fi 7181 + 7182 +fi 7183 + ;; 7184 + OS/390-*) 7185 + CFLAGS_OPTIMIZE="" # Optimizer is buggy 7186 + 7187 +$as_echo "#define _OE_SOCKETS 1" >>confdefs.h 7188 + 7189 + ;; 7190 + OSF1-V*) 7191 + # Digital OSF/1 7192 + SHLIB_CFLAGS="" 7193 + if test "$SHARED_BUILD" = 1; then : 7194 + 7195 + SHLIB_LD='ld -shared -expect_unresolved "*"' 7196 + 7197 +else 7198 + 7199 + SHLIB_LD='ld -non_shared -expect_unresolved "*"' 7200 + 7201 +fi 7202 + SHLIB_SUFFIX=".so" 7203 + if test $doRpath = yes; then : 7204 + 7205 + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7206 + LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 7207 +fi 7208 + if test "$GCC" = yes; then : 7209 + CFLAGS="$CFLAGS -mieee" 7210 +else 7211 + 7212 + CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee" 7213 +fi 7214 + # see pthread_intro(3) for pthread support on osf1, k.furukawa 7215 + if test "${TCL_THREADS}" = 1; then : 7216 + 7217 + CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 7218 + CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 7219 + LIBS=`echo $LIBS | sed s/-lpthreads//` 7220 + if test "$GCC" = yes; then : 7221 + 7222 + LIBS="$LIBS -lpthread -lmach -lexc" 7223 + 7224 +else 7225 + 7226 + CFLAGS="$CFLAGS -pthread" 7227 + LDFLAGS="$LDFLAGS -pthread" 7228 + 7229 +fi 7230 + 7231 +fi 7232 + ;; 7233 + QNX-6*) 7234 + # QNX RTP 7235 + # This may work for all QNX, but it was only reported for v6. 7236 + SHLIB_CFLAGS="-fPIC" 7237 + SHLIB_LD="ld -Bshareable -x" 7238 + SHLIB_LD_LIBS="" 7239 + SHLIB_SUFFIX=".so" 7240 + CC_SEARCH_FLAGS="" 7241 + LD_SEARCH_FLAGS="" 7242 + ;; 7243 + SCO_SV-3.2*) 7244 + if test "$GCC" = yes; then : 7245 + 7246 + SHLIB_CFLAGS="-fPIC -melf" 7247 + LDFLAGS="$LDFLAGS -melf -Wl,-Bexport" 7248 + 7249 +else 7250 + 7251 + SHLIB_CFLAGS="-Kpic -belf" 7252 + LDFLAGS="$LDFLAGS -belf -Wl,-Bexport" 7253 + 7254 +fi 7255 + SHLIB_LD="ld -G" 7256 + SHLIB_LD_LIBS="" 7257 + SHLIB_SUFFIX=".so" 7258 + CC_SEARCH_FLAGS="" 7259 + LD_SEARCH_FLAGS="" 7260 + ;; 7261 + SunOS-5.[0-6]) 7262 + # Careful to not let 5.10+ fall into this case 7263 + 7264 + # Note: If _REENTRANT isn't defined, then Solaris 7265 + # won't define thread-safe library routines. 7266 + 7267 + 7268 +$as_echo "#define _REENTRANT 1" >>confdefs.h 7269 + 7270 + 7271 +$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h 7272 + 7273 + 7274 + SHLIB_CFLAGS="-KPIC" 7275 + SHLIB_SUFFIX=".so" 7276 + if test "$GCC" = yes; then : 7277 + 7278 + SHLIB_LD='${CC} -shared' 7279 + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7280 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7281 + 7282 +else 7283 + 7284 + SHLIB_LD="/usr/ccs/bin/ld -G -z text" 7285 + CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 7286 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7287 + 7288 +fi 7289 + ;; 7290 + SunOS-5*) 7291 + # Note: If _REENTRANT isn't defined, then Solaris 7292 + # won't define thread-safe library routines. 7293 + 7294 + 7295 +$as_echo "#define _REENTRANT 1" >>confdefs.h 7296 + 7297 + 7298 +$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h 7299 + 7300 + 7301 + SHLIB_CFLAGS="-KPIC" 7302 + 7303 + # Check to enable 64-bit flags for compiler/linker 7304 + if test "$do64bit" = yes; then : 7305 + 7306 + arch=`isainfo` 7307 + if test "$arch" = "sparcv9 sparc"; then : 7308 + 7309 + if test "$GCC" = yes; then : 7310 + 7311 + if test "`${CC} -dumpversion | awk -F. '{print $1}'`" -lt 3; then : 7312 + 7313 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&5 7314 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&2;} 7315 + 7316 +else 7317 + 7318 + do64bit_ok=yes 7319 + CFLAGS="$CFLAGS -m64 -mcpu=v9" 7320 + LDFLAGS="$LDFLAGS -m64 -mcpu=v9" 7321 + SHLIB_CFLAGS="-fPIC" 7322 + 7323 +fi 7324 + 7325 +else 7326 + 7327 + do64bit_ok=yes 7328 + if test "$do64bitVIS" = yes; then : 7329 + 7330 + CFLAGS="$CFLAGS -xarch=v9a" 7331 + LDFLAGS_ARCH="-xarch=v9a" 7332 + 7333 +else 7334 + 7335 + CFLAGS="$CFLAGS -xarch=v9" 7336 + LDFLAGS_ARCH="-xarch=v9" 7337 + 7338 +fi 7339 + # Solaris 64 uses this as well 7340 + #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64" 7341 + 7342 +fi 7343 + 7344 +else 7345 + if test "$arch" = "amd64 i386"; then : 7346 + 7347 + if test "$GCC" = yes; then : 7348 + 7349 + case $system in 7350 + SunOS-5.1[1-9]*|SunOS-5.[2-9][0-9]*) 7351 + do64bit_ok=yes 7352 + CFLAGS="$CFLAGS -m64" 7353 + LDFLAGS="$LDFLAGS -m64";; 7354 + *) 7355 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 7356 +$as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;};; 7357 + esac 7358 + 7359 +else 7360 + 7361 + do64bit_ok=yes 7362 + case $system in 7363 + SunOS-5.1[1-9]*|SunOS-5.[2-9][0-9]*) 7364 + CFLAGS="$CFLAGS -m64" 7365 + LDFLAGS="$LDFLAGS -m64";; 7366 + *) 7367 + CFLAGS="$CFLAGS -xarch=amd64" 7368 + LDFLAGS="$LDFLAGS -xarch=amd64";; 7369 + esac 7370 + 7371 +fi 7372 + 7373 +else 7374 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported for $arch" >&5 7375 +$as_echo "$as_me: WARNING: 64bit mode not supported for $arch" >&2;} 7376 +fi 7377 +fi 7378 + 7379 +fi 7380 + 7381 + SHLIB_SUFFIX=".so" 7382 + if test "$GCC" = yes; then : 7383 + 7384 + SHLIB_LD='${CC} -shared' 7385 + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7386 + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7387 + if test "$do64bit_ok" = yes; then : 7388 + 7389 + if test "$arch" = "sparcv9 sparc"; then : 7390 + 7391 + # We need to specify -static-libgcc or we need to 7392 + # add the path to the sparv9 libgcc. 7393 + # JH: static-libgcc is necessary for core Tcl, but may 7394 + # not be necessary for extensions. 7395 + SHLIB_LD="$SHLIB_LD -m64 -mcpu=v9 -static-libgcc" 7396 + # for finding sparcv9 libgcc, get the regular libgcc 7397 + # path, remove so name and append 'sparcv9' 7398 + #v9gcclibdir="`gcc -print-file-name=libgcc_s.so` | ..." 7399 + #CC_SEARCH_FLAGS="${CC_SEARCH_FLAGS},-R,$v9gcclibdir" 7400 + 7401 +else 7402 + if test "$arch" = "amd64 i386"; then : 7403 + 7404 + # JH: static-libgcc is necessary for core Tcl, but may 7405 + # not be necessary for extensions. 7406 + SHLIB_LD="$SHLIB_LD -m64 -static-libgcc" 7407 + 7408 +fi 7409 +fi 7410 + 7411 +fi 7412 + 7413 +else 7414 + 7415 + case $system in 7416 + SunOS-5.[1-9][0-9]*) 7417 + # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 7418 + SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';; 7419 + *) 7420 + SHLIB_LD='/usr/ccs/bin/ld -G -z text';; 7421 + esac 7422 + CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7423 + LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 7424 + 7425 +fi 7426 + ;; 7427 + UNIX_SV* | UnixWare-5*) 7428 + SHLIB_CFLAGS="-KPIC" 7429 + SHLIB_LD='${CC} -G' 7430 + SHLIB_LD_LIBS="" 7431 + SHLIB_SUFFIX=".so" 7432 + # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers 7433 + # that don't grok the -Bexport option. Test that it does. 7434 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld accepts -Bexport flag" >&5 7435 +$as_echo_n "checking for ld accepts -Bexport flag... " >&6; } 7436 +if ${tcl_cv_ld_Bexport+:} false; then : 7437 + $as_echo_n "(cached) " >&6 7438 +else 7439 + 7440 + hold_ldflags=$LDFLAGS 7441 + LDFLAGS="$LDFLAGS -Wl,-Bexport" 7442 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7443 +/* end confdefs.h. */ 7444 + 7445 +int 7446 +main () 7447 +{ 7448 +int i; 7449 + ; 7450 + return 0; 7451 +} 7452 +_ACEOF 7453 +if ac_fn_c_try_link "$LINENO"; then : 7454 + tcl_cv_ld_Bexport=yes 7455 +else 7456 + tcl_cv_ld_Bexport=no 7457 +fi 7458 +rm -f core conftest.err conftest.$ac_objext \ 7459 + conftest$ac_exeext conftest.$ac_ext 7460 + LDFLAGS=$hold_ldflags 7461 +fi 7462 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_ld_Bexport" >&5 7463 +$as_echo "$tcl_cv_ld_Bexport" >&6; } 7464 + if test $tcl_cv_ld_Bexport = yes; then : 7465 + 7466 + LDFLAGS="$LDFLAGS -Wl,-Bexport" 7467 + 7468 +fi 7469 + CC_SEARCH_FLAGS="" 7470 + LD_SEARCH_FLAGS="" 7471 + ;; 7472 + esac 7473 + 7474 + if test "$do64bit" = yes -a "$do64bit_ok" = no; then : 7475 + 7476 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit support being disabled -- don't know magic for this platform" >&5 7477 +$as_echo "$as_me: WARNING: 64bit support being disabled -- don't know magic for this platform" >&2;} 7478 + 7479 +fi 7480 + 7481 + 7482 + 7483 + # Add in the arch flags late to ensure it wasn't removed. 7484 + # Not necessary in TEA, but this is aligned with core 7485 + LDFLAGS="$LDFLAGS $LDFLAGS_ARCH" 7486 + 7487 + # If we're running gcc, then change the C flags for compiling shared 7488 + # libraries to the right flags for gcc, instead of those for the 7489 + # standard manufacturer compiler. 7490 + 7491 + if test "$GCC" = yes; then : 7492 + 7493 + case $system in 7494 + AIX-*) ;; 7495 + BSD/OS*) ;; 7496 + CYGWIN_*|MINGW32_*|MINGW64_*) ;; 7497 + IRIX*) ;; 7498 + NetBSD-*|FreeBSD-*|OpenBSD-*) ;; 7499 + Darwin-*) ;; 7500 + SCO_SV-3.2*) ;; 7501 + windows) ;; 7502 + *) SHLIB_CFLAGS="-fPIC" ;; 7503 + esac 7504 +fi 7505 + 7506 + if test "$tcl_cv_cc_visibility_hidden" != yes; then : 7507 + 7508 + 7509 +$as_echo "#define MODULE_SCOPE extern" >>confdefs.h 7510 + 7511 + 7512 +fi 7513 + 7514 + if test "$SHARED_LIB_SUFFIX" = ""; then : 7515 + 7516 + # TEA specific: use PACKAGE_VERSION instead of VERSION 7517 + SHARED_LIB_SUFFIX='${PACKAGE_VERSION}${SHLIB_SUFFIX}' 7518 +fi 7519 + if test "$UNSHARED_LIB_SUFFIX" = ""; then : 7520 + 7521 + # TEA specific: use PACKAGE_VERSION instead of VERSION 7522 + UNSHARED_LIB_SUFFIX='${PACKAGE_VERSION}.a' 7523 +fi 7524 + 7525 + if test "${GCC}" = "yes" -a ${SHLIB_SUFFIX} = ".dll"; then 7526 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SEH support in compiler" >&5 7527 +$as_echo_n "checking for SEH support in compiler... " >&6; } 7528 +if ${tcl_cv_seh+:} false; then : 7529 + $as_echo_n "(cached) " >&6 7530 +else 7531 + if test "$cross_compiling" = yes; then : 7532 + tcl_cv_seh=no 7533 +else 7534 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7535 +/* end confdefs.h. */ 7536 + 7537 +#define WIN32_LEAN_AND_MEAN 7538 +#include <windows.h> 7539 +#undef WIN32_LEAN_AND_MEAN 7540 + 7541 + int main(int argc, char** argv) { 7542 + int a, b = 0; 7543 + __try { 7544 + a = 666 / b; 7545 + } 7546 + __except (EXCEPTION_EXECUTE_HANDLER) { 7547 + return 0; 7548 + } 7549 + return 1; 7550 + } 7551 + 7552 +_ACEOF 7553 +if ac_fn_c_try_run "$LINENO"; then : 7554 + tcl_cv_seh=yes 7555 +else 7556 + tcl_cv_seh=no 7557 +fi 7558 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ 7559 + conftest.$ac_objext conftest.beam conftest.$ac_ext 7560 +fi 7561 + 7562 + 7563 +fi 7564 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_seh" >&5 7565 +$as_echo "$tcl_cv_seh" >&6; } 7566 + if test "$tcl_cv_seh" = "no" ; then 7567 + 7568 +$as_echo "#define HAVE_NO_SEH 1" >>confdefs.h 7569 + 7570 + fi 7571 + 7572 + # 7573 + # Check to see if the excpt.h include file provided contains the 7574 + # definition for EXCEPTION_DISPOSITION; if not, which is the case 7575 + # with Cygwin's version as of 2002-04-10, define it to be int, 7576 + # sufficient for getting the current code to work. 7577 + # 7578 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EXCEPTION_DISPOSITION support in include files" >&5 7579 +$as_echo_n "checking for EXCEPTION_DISPOSITION support in include files... " >&6; } 7580 +if ${tcl_cv_eh_disposition+:} false; then : 7581 + $as_echo_n "(cached) " >&6 7582 +else 7583 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7584 +/* end confdefs.h. */ 7585 + 7586 +# define WIN32_LEAN_AND_MEAN 7587 +# include <windows.h> 7588 +# undef WIN32_LEAN_AND_MEAN 7589 + 7590 +int 7591 +main () 7592 +{ 7593 + 7594 + EXCEPTION_DISPOSITION x; 7595 + 7596 + ; 7597 + return 0; 7598 +} 7599 +_ACEOF 7600 +if ac_fn_c_try_compile "$LINENO"; then : 7601 + tcl_cv_eh_disposition=yes 7602 +else 7603 + tcl_cv_eh_disposition=no 7604 +fi 7605 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7606 + 7607 +fi 7608 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_eh_disposition" >&5 7609 +$as_echo "$tcl_cv_eh_disposition" >&6; } 7610 + if test "$tcl_cv_eh_disposition" = "no" ; then 7611 + 7612 +$as_echo "#define EXCEPTION_DISPOSITION int" >>confdefs.h 7613 + 7614 + fi 7615 + 7616 + # Check to see if winnt.h defines CHAR, SHORT, and LONG 7617 + # even if VOID has already been #defined. The win32api 7618 + # used by mingw and cygwin is known to do this. 7619 + 7620 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winnt.h that ignores VOID define" >&5 7621 +$as_echo_n "checking for winnt.h that ignores VOID define... " >&6; } 7622 +if ${tcl_cv_winnt_ignore_void+:} false; then : 7623 + $as_echo_n "(cached) " >&6 7624 +else 7625 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7626 +/* end confdefs.h. */ 7627 + 7628 +#define VOID void 7629 +#define WIN32_LEAN_AND_MEAN 7630 +#include <windows.h> 7631 +#undef WIN32_LEAN_AND_MEAN 7632 + 7633 +int 7634 +main () 7635 +{ 7636 + 7637 + CHAR c; 7638 + SHORT s; 7639 + LONG l; 7640 + 7641 + ; 7642 + return 0; 7643 +} 7644 +_ACEOF 7645 +if ac_fn_c_try_compile "$LINENO"; then : 7646 + tcl_cv_winnt_ignore_void=yes 7647 +else 7648 + tcl_cv_winnt_ignore_void=no 7649 +fi 7650 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7651 + 7652 +fi 7653 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_winnt_ignore_void" >&5 7654 +$as_echo "$tcl_cv_winnt_ignore_void" >&6; } 7655 + if test "$tcl_cv_winnt_ignore_void" = "yes" ; then 7656 + 7657 +$as_echo "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h 7658 + 7659 + fi 7660 + fi 7661 + 7662 + # See if the compiler supports casting to a union type. 7663 + # This is used to stop gcc from printing a compiler 7664 + # warning when initializing a union member. 7665 + 7666 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cast to union support" >&5 7667 +$as_echo_n "checking for cast to union support... " >&6; } 7668 +if ${tcl_cv_cast_to_union+:} false; then : 7669 + $as_echo_n "(cached) " >&6 7670 +else 7671 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7672 +/* end confdefs.h. */ 7673 + 7674 +int 7675 +main () 7676 +{ 7677 + 7678 + union foo { int i; double d; }; 7679 + union foo f = (union foo) (int) 0; 7680 + 7681 + ; 7682 + return 0; 7683 +} 7684 +_ACEOF 7685 +if ac_fn_c_try_compile "$LINENO"; then : 7686 + tcl_cv_cast_to_union=yes 7687 +else 7688 + tcl_cv_cast_to_union=no 7689 +fi 7690 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7691 + 7692 +fi 7693 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cast_to_union" >&5 7694 +$as_echo "$tcl_cv_cast_to_union" >&6; } 7695 + if test "$tcl_cv_cast_to_union" = "yes"; then 7696 + 7697 +$as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h 7698 + 7699 + fi 7700 + 7701 + 7702 + 7703 + 7704 + 7705 + 7706 + 7707 + 7708 + 7709 + 7710 + 7711 + 7712 + 7713 + # These must be called after we do the basic CFLAGS checks and 7714 + # verify any possible 64-bit or similar switches are necessary 7715 + 7716 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for required early compiler flags" >&5 7717 +$as_echo_n "checking for required early compiler flags... " >&6; } 7718 + tcl_flags="" 7719 + 7720 + if ${tcl_cv_flag__isoc99_source+:} false; then : 7721 + $as_echo_n "(cached) " >&6 7722 +else 7723 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7724 +/* end confdefs.h. */ 7725 +#include <stdlib.h> 7726 +int 7727 +main () 7728 +{ 7729 +char *p = (char *)strtoll; char *q = (char *)strtoull; 7730 + ; 7731 + return 0; 7732 +} 7733 +_ACEOF 7734 +if ac_fn_c_try_compile "$LINENO"; then : 7735 + tcl_cv_flag__isoc99_source=no 7736 +else 7737 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7738 +/* end confdefs.h. */ 7739 +#define _ISOC99_SOURCE 1 7740 +#include <stdlib.h> 7741 +int 7742 +main () 7743 +{ 7744 +char *p = (char *)strtoll; char *q = (char *)strtoull; 7745 + ; 7746 + return 0; 7747 +} 7748 +_ACEOF 7749 +if ac_fn_c_try_compile "$LINENO"; then : 7750 + tcl_cv_flag__isoc99_source=yes 7751 +else 7752 + tcl_cv_flag__isoc99_source=no 7753 +fi 7754 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7755 +fi 7756 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7757 +fi 7758 + 7759 + if test "x${tcl_cv_flag__isoc99_source}" = "xyes" ; then 7760 + 7761 +$as_echo "#define _ISOC99_SOURCE 1" >>confdefs.h 7762 + 7763 + tcl_flags="$tcl_flags _ISOC99_SOURCE" 7764 + fi 7765 + 7766 + 7767 + if ${tcl_cv_flag__largefile64_source+:} false; then : 7768 + $as_echo_n "(cached) " >&6 7769 +else 7770 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7771 +/* end confdefs.h. */ 7772 +#include <sys/stat.h> 7773 +int 7774 +main () 7775 +{ 7776 +struct stat64 buf; int i = stat64("/", &buf); 7777 + ; 7778 + return 0; 7779 +} 7780 +_ACEOF 7781 +if ac_fn_c_try_compile "$LINENO"; then : 7782 + tcl_cv_flag__largefile64_source=no 7783 +else 7784 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7785 +/* end confdefs.h. */ 7786 +#define _LARGEFILE64_SOURCE 1 7787 +#include <sys/stat.h> 7788 +int 7789 +main () 7790 +{ 7791 +struct stat64 buf; int i = stat64("/", &buf); 7792 + ; 7793 + return 0; 7794 +} 7795 +_ACEOF 7796 +if ac_fn_c_try_compile "$LINENO"; then : 7797 + tcl_cv_flag__largefile64_source=yes 7798 +else 7799 + tcl_cv_flag__largefile64_source=no 7800 +fi 7801 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7802 +fi 7803 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7804 +fi 7805 + 7806 + if test "x${tcl_cv_flag__largefile64_source}" = "xyes" ; then 7807 + 7808 +$as_echo "#define _LARGEFILE64_SOURCE 1" >>confdefs.h 7809 + 7810 + tcl_flags="$tcl_flags _LARGEFILE64_SOURCE" 7811 + fi 7812 + 7813 + 7814 + if ${tcl_cv_flag__largefile_source64+:} false; then : 7815 + $as_echo_n "(cached) " >&6 7816 +else 7817 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7818 +/* end confdefs.h. */ 7819 +#include <sys/stat.h> 7820 +int 7821 +main () 7822 +{ 7823 +char *p = (char *)open64; 7824 + ; 7825 + return 0; 7826 +} 7827 +_ACEOF 7828 +if ac_fn_c_try_compile "$LINENO"; then : 7829 + tcl_cv_flag__largefile_source64=no 7830 +else 7831 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7832 +/* end confdefs.h. */ 7833 +#define _LARGEFILE_SOURCE64 1 7834 +#include <sys/stat.h> 7835 +int 7836 +main () 7837 +{ 7838 +char *p = (char *)open64; 7839 + ; 7840 + return 0; 7841 +} 7842 +_ACEOF 7843 +if ac_fn_c_try_compile "$LINENO"; then : 7844 + tcl_cv_flag__largefile_source64=yes 7845 +else 7846 + tcl_cv_flag__largefile_source64=no 7847 +fi 7848 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7849 +fi 7850 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7851 +fi 7852 + 7853 + if test "x${tcl_cv_flag__largefile_source64}" = "xyes" ; then 7854 + 7855 +$as_echo "#define _LARGEFILE_SOURCE64 1" >>confdefs.h 7856 + 7857 + tcl_flags="$tcl_flags _LARGEFILE_SOURCE64" 7858 + fi 7859 + 7860 + if test "x${tcl_flags}" = "x" ; then 7861 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 7862 +$as_echo "none" >&6; } 7863 + else 7864 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_flags}" >&5 7865 +$as_echo "${tcl_flags}" >&6; } 7866 + fi 7867 + 7868 + 7869 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit integer type" >&5 7870 +$as_echo_n "checking for 64-bit integer type... " >&6; } 7871 + if ${tcl_cv_type_64bit+:} false; then : 7872 + $as_echo_n "(cached) " >&6 7873 +else 7874 + 7875 + tcl_cv_type_64bit=none 7876 + # See if the compiler knows natively about __int64 7877 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7878 +/* end confdefs.h. */ 7879 + 7880 +int 7881 +main () 7882 +{ 7883 +__int64 value = (__int64) 0; 7884 + ; 7885 + return 0; 7886 +} 7887 +_ACEOF 7888 +if ac_fn_c_try_compile "$LINENO"; then : 7889 + tcl_type_64bit=__int64 7890 +else 7891 + tcl_type_64bit="long long" 7892 +fi 7893 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7894 + # See if we should use long anyway Note that we substitute in the 7895 + # type that is our current guess for a 64-bit type inside this check 7896 + # program, so it should be modified only carefully... 7897 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7898 +/* end confdefs.h. */ 7899 + 7900 +int 7901 +main () 7902 +{ 7903 +switch (0) { 7904 + case 1: case (sizeof(${tcl_type_64bit})==sizeof(long)): ; 7905 + } 7906 + ; 7907 + return 0; 7908 +} 7909 +_ACEOF 7910 +if ac_fn_c_try_compile "$LINENO"; then : 7911 + tcl_cv_type_64bit=${tcl_type_64bit} 7912 +fi 7913 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7914 +fi 7915 + 7916 + if test "${tcl_cv_type_64bit}" = none ; then 7917 + 7918 +$as_echo "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h 7919 + 7920 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using long" >&5 7921 +$as_echo "using long" >&6; } 7922 + elif test "${tcl_cv_type_64bit}" = "__int64" \ 7923 + -a "${TEA_PLATFORM}" = "windows" ; then 7924 + # TEA specific: We actually want to use the default tcl.h checks in 7925 + # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER* 7926 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Tcl header defaults" >&5 7927 +$as_echo "using Tcl header defaults" >&6; } 7928 + else 7929 + 7930 +cat >>confdefs.h <<_ACEOF 7931 +#define TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit} 7932 +_ACEOF 7933 + 7934 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_cv_type_64bit}" >&5 7935 +$as_echo "${tcl_cv_type_64bit}" >&6; } 7936 + 7937 + # Now check for auxiliary declarations 7938 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct dirent64" >&5 7939 +$as_echo_n "checking for struct dirent64... " >&6; } 7940 +if ${tcl_cv_struct_dirent64+:} false; then : 7941 + $as_echo_n "(cached) " >&6 7942 +else 7943 + 7944 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7945 +/* end confdefs.h. */ 7946 +#include <sys/types.h> 7947 +#include <dirent.h> 7948 +int 7949 +main () 7950 +{ 7951 +struct dirent64 p; 7952 + ; 7953 + return 0; 7954 +} 7955 +_ACEOF 7956 +if ac_fn_c_try_compile "$LINENO"; then : 7957 + tcl_cv_struct_dirent64=yes 7958 +else 7959 + tcl_cv_struct_dirent64=no 7960 +fi 7961 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7962 +fi 7963 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_dirent64" >&5 7964 +$as_echo "$tcl_cv_struct_dirent64" >&6; } 7965 + if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then 7966 + 7967 +$as_echo "#define HAVE_STRUCT_DIRENT64 1" >>confdefs.h 7968 + 7969 + fi 7970 + 7971 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct stat64" >&5 7972 +$as_echo_n "checking for struct stat64... " >&6; } 7973 +if ${tcl_cv_struct_stat64+:} false; then : 7974 + $as_echo_n "(cached) " >&6 7975 +else 7976 + 7977 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7978 +/* end confdefs.h. */ 7979 +#include <sys/stat.h> 7980 +int 7981 +main () 7982 +{ 7983 +struct stat64 p; 7984 + 7985 + ; 7986 + return 0; 7987 +} 7988 +_ACEOF 7989 +if ac_fn_c_try_compile "$LINENO"; then : 7990 + tcl_cv_struct_stat64=yes 7991 +else 7992 + tcl_cv_struct_stat64=no 7993 +fi 7994 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7995 +fi 7996 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_stat64" >&5 7997 +$as_echo "$tcl_cv_struct_stat64" >&6; } 7998 + if test "x${tcl_cv_struct_stat64}" = "xyes" ; then 7999 + 8000 +$as_echo "#define HAVE_STRUCT_STAT64 1" >>confdefs.h 8001 + 8002 + fi 8003 + 8004 + for ac_func in open64 lseek64 8005 +do : 8006 + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 8007 +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" 8008 +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : 8009 + cat >>confdefs.h <<_ACEOF 8010 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 8011 +_ACEOF 8012 + 8013 +fi 8014 +done 8015 + 8016 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for off64_t" >&5 8017 +$as_echo_n "checking for off64_t... " >&6; } 8018 + if ${tcl_cv_type_off64_t+:} false; then : 8019 + $as_echo_n "(cached) " >&6 8020 +else 8021 + 8022 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8023 +/* end confdefs.h. */ 8024 +#include <sys/types.h> 8025 +int 8026 +main () 8027 +{ 8028 +off64_t offset; 8029 + 8030 + ; 8031 + return 0; 8032 +} 8033 +_ACEOF 8034 +if ac_fn_c_try_compile "$LINENO"; then : 8035 + tcl_cv_type_off64_t=yes 8036 +else 8037 + tcl_cv_type_off64_t=no 8038 +fi 8039 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 8040 +fi 8041 + 8042 + if test "x${tcl_cv_type_off64_t}" = "xyes" && \ 8043 + test "x${ac_cv_func_lseek64}" = "xyes" && \ 8044 + test "x${ac_cv_func_open64}" = "xyes" ; then 8045 + 8046 +$as_echo "#define HAVE_TYPE_OFF64_T 1" >>confdefs.h 8047 + 8048 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 8049 +$as_echo "yes" >&6; } 8050 + else 8051 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 8052 +$as_echo "no" >&6; } 8053 + fi 8054 + fi 8055 + 8056 + 8057 + 8058 +#-------------------------------------------------------------------- 8059 +# Set the default compiler switches based on the --enable-symbols option. 8060 +#-------------------------------------------------------------------- 8061 + 8062 + 8063 + 8064 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for build with symbols" >&5 8065 +$as_echo_n "checking for build with symbols... " >&6; } 8066 + # Check whether --enable-symbols was given. 8067 +if test "${enable_symbols+set}" = set; then : 8068 + enableval=$enable_symbols; tcl_ok=$enableval 8069 +else 8070 + tcl_ok=no 8071 +fi 8072 + 8073 + DBGX="" 8074 + if test "$tcl_ok" = "no"; then 8075 + CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG" 8076 + LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" 8077 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 8078 +$as_echo "no" >&6; } 8079 + else 8080 + CFLAGS_DEFAULT="${CFLAGS_DEBUG}" 8081 + LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" 8082 + if test "$tcl_ok" = "yes"; then 8083 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5 8084 +$as_echo "yes (standard debugging)" >&6; } 8085 + fi 8086 + fi 8087 + # TEA specific: 8088 + if test "${TEA_PLATFORM}" != "windows" ; then 8089 + LDFLAGS_DEFAULT="${LDFLAGS}" 8090 + fi 8091 + 8092 + 8093 + 8094 + 8095 + if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then 8096 + 8097 +$as_echo "#define TCL_MEM_DEBUG 1" >>confdefs.h 8098 + 8099 + fi 8100 + 8101 + if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then 8102 + if test "$tcl_ok" = "all"; then 8103 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled symbols mem debugging" >&5 8104 +$as_echo "enabled symbols mem debugging" >&6; } 8105 + else 8106 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5 8107 +$as_echo "enabled $tcl_ok debugging" >&6; } 8108 + fi 8109 + fi 8110 + 8111 + 8112 +#-------------------------------------------------------------------- 8113 +# Everyone should be linking against the Tcl stub library. If you 8114 +# can't for some reason, remove this definition. If you aren't using 8115 +# stubs, you also need to modify the SHLIB_LD_LIBS setting below to 8116 +# link against the non-stubbed Tcl library. Add Tk too if necessary. 8117 +#-------------------------------------------------------------------- 8118 + 8119 + 8120 +$as_echo "#define USE_TCL_STUBS 1" >>confdefs.h 8121 + 8122 +#AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs]) 8123 + 8124 +#-------------------------------------------------------------------- 8125 +# This macro generates a line to use when building a library. It 8126 +# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS, 8127 +# and TEA_LOAD_TCLCONFIG macros above. 8128 +#-------------------------------------------------------------------- 8129 + 8130 + 8131 + if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then 8132 + MAKE_STATIC_LIB="\${STLIB_LD} -out:\$@ \$(PKG_OBJECTS)" 8133 + MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\$@ \$(PKG_OBJECTS)" 8134 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8135 +/* end confdefs.h. */ 8136 + 8137 +#if defined(_MSC_VER) && _MSC_VER >= 1400 8138 +print("manifest needed") 8139 +#endif 8140 + 8141 +_ACEOF 8142 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 8143 + $EGREP "manifest needed" >/dev/null 2>&1; then : 8144 + 8145 + # Could do a CHECK_PROG for mt, but should always be with MSVC8+ 8146 + VC_MANIFEST_EMBED_DLL="if test -f \$@.manifest ; then mt.exe -nologo -manifest \$@.manifest -outputresource:\$@\;2 ; fi" 8147 + VC_MANIFEST_EMBED_EXE="if test -f \$@.manifest ; then mt.exe -nologo -manifest \$@.manifest -outputresource:\$@\;1 ; fi" 8148 + MAKE_SHARED_LIB="${MAKE_SHARED_LIB} ; ${VC_MANIFEST_EMBED_DLL}" 8149 + 8150 + CLEANFILES="$CLEANFILES *.manifest" 8151 + 8152 + 8153 +fi 8154 +rm -f conftest* 8155 + 8156 + MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\$@ \$(PKG_STUB_OBJECTS)" 8157 + else 8158 + MAKE_STATIC_LIB="\${STLIB_LD} \$@ \$(PKG_OBJECTS)" 8159 + MAKE_SHARED_LIB="\${SHLIB_LD} -o \$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8160 + MAKE_STUB_LIB="\${STLIB_LD} \$@ \$(PKG_STUB_OBJECTS)" 8161 + fi 8162 + 8163 + if test "${SHARED_BUILD}" = "1" ; then 8164 + MAKE_LIB="${MAKE_SHARED_LIB} " 8165 + else 8166 + MAKE_LIB="${MAKE_STATIC_LIB} " 8167 + fi 8168 + 8169 + #-------------------------------------------------------------------- 8170 + # Shared libraries and static libraries have different names. 8171 + # Use the double eval to make sure any variables in the suffix is 8172 + # substituted. (@@@ Might not be necessary anymore) 8173 + #-------------------------------------------------------------------- 8174 + 8175 + if test "${TEA_PLATFORM}" = "windows" ; then 8176 + if test "${SHARED_BUILD}" = "1" ; then 8177 + # We force the unresolved linking of symbols that are really in 8178 + # the private libraries of Tcl and Tk. 8179 + if test x"${TK_BIN_DIR}" != x ; then 8180 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TK_BIN_DIR}/${TK_STUB_LIB_FILE}`\"" 8181 + fi 8182 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}`\"" 8183 + if test "$GCC" = "yes"; then 8184 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -static-libgcc" 8185 + fi 8186 + eval eval "PKG_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}" 8187 + else 8188 + eval eval "PKG_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" 8189 + if test "$GCC" = "yes"; then 8190 + PKG_LIB_FILE=lib${PKG_LIB_FILE} 8191 + fi 8192 + fi 8193 + # Some packages build their own stubs libraries 8194 + eval eval "PKG_STUB_LIB_FILE=${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}" 8195 + if test "$GCC" = "yes"; then 8196 + PKG_STUB_LIB_FILE=lib${PKG_STUB_LIB_FILE} 8197 + fi 8198 + # These aren't needed on Windows (either MSVC or gcc) 8199 + RANLIB=: 8200 + RANLIB_STUB=: 8201 + else 8202 + RANLIB_STUB="${RANLIB}" 8203 + if test "${SHARED_BUILD}" = "1" ; then 8204 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TCL_STUB_LIB_SPEC}" 8205 + if test x"${TK_BIN_DIR}" != x ; then 8206 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${TK_STUB_LIB_SPEC}" 8207 + fi 8208 + eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${SHARED_LIB_SUFFIX}" 8209 + RANLIB=: 8210 + else 8211 + eval eval "PKG_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}${UNSHARED_LIB_SUFFIX}" 8212 + fi 8213 + # Some packages build their own stubs libraries 8214 + eval eval "PKG_STUB_LIB_FILE=lib${PACKAGE_LIB_PREFIX}${PACKAGE_NAME}stub${UNSHARED_LIB_SUFFIX}" 8215 + fi 8216 + 8217 + # These are escaped so that only CFLAGS is picked up at configure time. 8218 + # The other values will be substituted at make time. 8219 + CFLAGS="${CFLAGS} \${CFLAGS_DEFAULT} \${CFLAGS_WARNING}" 8220 + if test "${SHARED_BUILD}" = "1" ; then 8221 + CFLAGS="${CFLAGS} \${SHLIB_CFLAGS}" 8222 + fi 8223 + 8224 + 8225 + 8226 + 8227 + 8228 + 8229 + 8230 + 8231 + 8232 + 8233 +#-------------------------------------------------------------------- 8234 +# Determine the name of the tclsh and/or wish executables in the 8235 +# Tcl and Tk build directories or the location they were installed 8236 +# into. These paths are used to support running test cases only, 8237 +# the Makefile should not be making use of these paths to generate 8238 +# a pkgIndex.tcl file or anything else at extension build time. 8239 +#-------------------------------------------------------------------- 8240 + 8241 + 8242 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5 8243 +$as_echo_n "checking for tclsh... " >&6; } 8244 + if test -f "${TCL_BIN_DIR}/Makefile" ; then 8245 + # tclConfig.sh is in Tcl build directory 8246 + if test "${TEA_PLATFORM}" = "windows"; then 8247 + if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" ; then 8248 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 8249 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" ; then 8250 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" 8251 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" ; then 8252 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" 8253 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" ; then 8254 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" 8255 + fi 8256 + else 8257 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh" 8258 + fi 8259 + else 8260 + # tclConfig.sh is in install location 8261 + if test "${TEA_PLATFORM}" = "windows"; then 8262 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 8263 + else 8264 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}" 8265 + fi 8266 + list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \ 8267 + `ls -d ${TCL_BIN_DIR}/.. 2>/dev/null` \ 8268 + `ls -d ${TCL_PREFIX}/bin 2>/dev/null`" 8269 + for i in $list ; do 8270 + if test -f "$i/${TCLSH_PROG}" ; then 8271 + REAL_TCL_BIN_DIR="`cd "$i"; pwd`/" 8272 + break 8273 + fi 8274 + done 8275 + TCLSH_PROG="${REAL_TCL_BIN_DIR}${TCLSH_PROG}" 8276 + fi 8277 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${TCLSH_PROG}" >&5 8278 +$as_echo "${TCLSH_PROG}" >&6; } 8279 + 8280 + 8281 +#TEA_PROG_WISH 8282 + 8283 +#-------------------------------------------------------------------- 8284 +# Finally, substitute all of the various values into the Makefile. 8285 +# You may alternatively have a special pkgIndex.tcl.in or other files 8286 +# which require substituting th AC variables in. Include these here. 8287 +#-------------------------------------------------------------------- 8288 + 8289 +ac_config_files="$ac_config_files Makefile pkgIndex.tcl" 8290 + 8291 +cat >confcache <<\_ACEOF 8292 +# This file is a shell script that caches the results of configure 8293 +# tests run on this system so they can be shared between configure 8294 +# scripts and configure runs, see configure's option --config-cache. 8295 +# It is not useful on other systems. If it contains results you don't 8296 +# want to keep, you may remove or edit it. 8297 +# 8298 +# config.status only pays attention to the cache file if you give it 8299 +# the --recheck option to rerun configure. 8300 +# 8301 +# `ac_cv_env_foo' variables (set or unset) will be overridden when 8302 +# loading this file, other *unset* `ac_cv_foo' will be assigned the 8303 +# following values. 8304 + 8305 +_ACEOF 8306 + 8307 +# The following way of writing the cache mishandles newlines in values, 8308 +# but we know of no workaround that is simple, portable, and efficient. 8309 +# So, we kill variables containing newlines. 8310 +# Ultrix sh set writes to stderr and can't be redirected directly, 8311 +# and sets the high bit in the cache file unless we assign to the vars. 8312 +( 8313 + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do 8314 + eval ac_val=\$$ac_var 8315 + case $ac_val in #( 8316 + *${as_nl}*) 8317 + case $ac_var in #( 8318 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 8319 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; 8320 + esac 8321 + case $ac_var in #( 8322 + _ | IFS | as_nl) ;; #( 8323 + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( 8324 + *) { eval $ac_var=; unset $ac_var;} ;; 8325 + esac ;; 8326 + esac 8327 + done 8328 + 8329 + (set) 2>&1 | 8330 + case $as_nl`(ac_space=' '; set) 2>&1` in #( 8331 + *${as_nl}ac_space=\ *) 8332 + # `set' does not quote correctly, so add quotes: double-quote 8333 + # substitution turns \\\\ into \\, and sed turns \\ into \. 8334 + sed -n \ 8335 + "s/'/'\\\\''/g; 8336 + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" 8337 + ;; #( 8338 + *) 8339 + # `set' quotes correctly as required by POSIX, so do not add quotes. 8340 + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" 8341 + ;; 8342 + esac | 8343 + sort 8344 +) | 8345 + sed ' 8346 + /^ac_cv_env_/b end 8347 + t clear 8348 + :clear 8349 + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ 8350 + t end 8351 + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ 8352 + :end' >>confcache 8353 +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else 8354 + if test -w "$cache_file"; then 8355 + if test "x$cache_file" != "x/dev/null"; then 8356 + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 8357 +$as_echo "$as_me: updating cache $cache_file" >&6;} 8358 + if test ! -f "$cache_file" || test -h "$cache_file"; then 8359 + cat confcache >"$cache_file" 8360 + else 8361 + case $cache_file in #( 8362 + */* | ?:*) 8363 + mv -f confcache "$cache_file"$$ && 8364 + mv -f "$cache_file"$$ "$cache_file" ;; #( 8365 + *) 8366 + mv -f confcache "$cache_file" ;; 8367 + esac 8368 + fi 8369 + fi 8370 + else 8371 + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 8372 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} 8373 + fi 8374 +fi 8375 +rm -f confcache 8376 + 8377 +test "x$prefix" = xNONE && prefix=$ac_default_prefix 8378 +# Let make expand exec_prefix. 8379 +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' 8380 + 8381 +# Transform confdefs.h into DEFS. 8382 +# Protect against shell expansion while executing Makefile rules. 8383 +# Protect against Makefile macro expansion. 8384 +# 8385 +# If the first sed substitution is executed (which looks for macros that 8386 +# take arguments), then branch to the quote section. Otherwise, 8387 +# look for a macro that doesn't take arguments. 8388 +ac_script=' 8389 +:mline 8390 +/\\$/{ 8391 + N 8392 + s,\\\n,, 8393 + b mline 8394 +} 8395 +t clear 8396 +:clear 8397 +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g 8398 +t quote 8399 +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g 8400 +t quote 8401 +b any 8402 +:quote 8403 +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g 8404 +s/\[/\\&/g 8405 +s/\]/\\&/g 8406 +s/\$/$$/g 8407 +H 8408 +:any 8409 +${ 8410 + g 8411 + s/^\n// 8412 + s/\n/ /g 8413 + p 8414 +} 8415 +' 8416 +DEFS=`sed -n "$ac_script" confdefs.h` 8417 + 8418 + 8419 +ac_libobjs= 8420 +ac_ltlibobjs= 8421 +U= 8422 +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue 8423 + # 1. Remove the extension, and $U if already installed. 8424 + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' 8425 + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` 8426 + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR 8427 + # will be set to the directory where LIBOBJS objects are built. 8428 + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" 8429 + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' 8430 +done 8431 +LIBOBJS=$ac_libobjs 8432 + 8433 +LTLIBOBJS=$ac_ltlibobjs 8434 + 8435 + 8436 + 8437 +CFLAGS="${CFLAGS} ${CPPFLAGS}"; CPPFLAGS="" 8438 + 8439 +: "${CONFIG_STATUS=./config.status}" 8440 +ac_write_fail=0 8441 +ac_clean_files_save=$ac_clean_files 8442 +ac_clean_files="$ac_clean_files $CONFIG_STATUS" 8443 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 8444 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} 8445 +as_write_fail=0 8446 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 8447 +#! $SHELL 8448 +# Generated by $as_me. 8449 +# Run this file to recreate the current configuration. 8450 +# Compiler output produced by configure, useful for debugging 8451 +# configure, is in config.log if it exists. 8452 + 8453 +debug=false 8454 +ac_cs_recheck=false 8455 +ac_cs_silent=false 8456 + 8457 +SHELL=\${CONFIG_SHELL-$SHELL} 8458 +export SHELL 8459 +_ASEOF 8460 +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 8461 +## -------------------- ## 8462 +## M4sh Initialization. ## 8463 +## -------------------- ## 8464 + 8465 +# Be more Bourne compatible 8466 +DUALCASE=1; export DUALCASE # for MKS sh 8467 +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 8468 + emulate sh 8469 + NULLCMD=: 8470 + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 8471 + # is contrary to our usage. Disable this feature. 8472 + alias -g '${1+"$@"}'='"$@"' 8473 + setopt NO_GLOB_SUBST 8474 +else 8475 + case `(set -o) 2>/dev/null` in #( 8476 + *posix*) : 8477 + set -o posix ;; #( 8478 + *) : 8479 + ;; 8480 +esac 8481 +fi 8482 + 8483 + 8484 +as_nl=' 8485 +' 8486 +export as_nl 8487 +# Printing a long string crashes Solaris 7 /usr/bin/printf. 8488 +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' 8489 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo 8490 +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo 8491 +# Prefer a ksh shell builtin over an external printf program on Solaris, 8492 +# but without wasting forks for bash or zsh. 8493 +if test -z "$BASH_VERSION$ZSH_VERSION" \ 8494 + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then 8495 + as_echo='print -r --' 8496 + as_echo_n='print -rn --' 8497 +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then 8498 + as_echo='printf %s\n' 8499 + as_echo_n='printf %s' 8500 +else 8501 + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then 8502 + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' 8503 + as_echo_n='/usr/ucb/echo -n' 8504 + else 8505 + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' 8506 + as_echo_n_body='eval 8507 + arg=$1; 8508 + case $arg in #( 8509 + *"$as_nl"*) 8510 + expr "X$arg" : "X\\(.*\\)$as_nl"; 8511 + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; 8512 + esac; 8513 + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" 8514 + ' 8515 + export as_echo_n_body 8516 + as_echo_n='sh -c $as_echo_n_body as_echo' 8517 + fi 8518 + export as_echo_body 8519 + as_echo='sh -c $as_echo_body as_echo' 8520 +fi 8521 + 8522 +# The user is always right. 8523 +if test "${PATH_SEPARATOR+set}" != set; then 8524 + PATH_SEPARATOR=: 8525 + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 8526 + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 8527 + PATH_SEPARATOR=';' 8528 + } 8529 +fi 8530 + 8531 + 8532 +# IFS 8533 +# We need space, tab and new line, in precisely that order. Quoting is 8534 +# there to prevent editors from complaining about space-tab. 8535 +# (If _AS_PATH_WALK were called with IFS unset, it would disable word 8536 +# splitting by setting IFS to empty value.) 8537 +IFS=" "" $as_nl" 8538 + 8539 +# Find who we are. Look in the path if we contain no directory separator. 8540 +as_myself= 8541 +case $0 in #(( 8542 + *[\\/]* ) as_myself=$0 ;; 8543 + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 8544 +for as_dir in $PATH 8545 +do 8546 + IFS=$as_save_IFS 8547 + test -z "$as_dir" && as_dir=. 8548 + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break 8549 + done 8550 +IFS=$as_save_IFS 8551 + 8552 + ;; 8553 +esac 8554 +# We did not find ourselves, most probably we were run as `sh COMMAND' 8555 +# in which case we are not to be found in the path. 8556 +if test "x$as_myself" = x; then 8557 + as_myself=$0 8558 +fi 8559 +if test ! -f "$as_myself"; then 8560 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 8561 + exit 1 8562 +fi 8563 + 8564 +# Unset variables that we do not need and which cause bugs (e.g. in 8565 +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" 8566 +# suppresses any "Segmentation fault" message there. '((' could 8567 +# trigger a bug in pdksh 5.2.14. 8568 +for as_var in BASH_ENV ENV MAIL MAILPATH 8569 +do eval test x\${$as_var+set} = xset \ 8570 + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : 8571 +done 8572 +PS1='$ ' 8573 +PS2='> ' 8574 +PS4='+ ' 8575 + 8576 +# NLS nuisances. 8577 +LC_ALL=C 8578 +export LC_ALL 8579 +LANGUAGE=C 8580 +export LANGUAGE 8581 + 8582 +# CDPATH. 8583 +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 8584 + 8585 + 8586 +# as_fn_error STATUS ERROR [LINENO LOG_FD] 8587 +# ---------------------------------------- 8588 +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are 8589 +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the 8590 +# script with STATUS, using 1 if that was 0. 8591 +as_fn_error () 8592 +{ 8593 + as_status=$1; test $as_status -eq 0 && as_status=1 8594 + if test "$4"; then 8595 + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 8596 + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 8597 + fi 8598 + $as_echo "$as_me: error: $2" >&2 8599 + as_fn_exit $as_status 8600 +} # as_fn_error 8601 + 8602 + 8603 +# as_fn_set_status STATUS 8604 +# ----------------------- 8605 +# Set $? to STATUS, without forking. 8606 +as_fn_set_status () 8607 +{ 8608 + return $1 8609 +} # as_fn_set_status 8610 + 8611 +# as_fn_exit STATUS 8612 +# ----------------- 8613 +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. 8614 +as_fn_exit () 8615 +{ 8616 + set +e 8617 + as_fn_set_status $1 8618 + exit $1 8619 +} # as_fn_exit 8620 + 8621 +# as_fn_unset VAR 8622 +# --------------- 8623 +# Portably unset VAR. 8624 +as_fn_unset () 8625 +{ 8626 + { eval $1=; unset $1;} 8627 +} 8628 +as_unset=as_fn_unset 8629 +# as_fn_append VAR VALUE 8630 +# ---------------------- 8631 +# Append the text in VALUE to the end of the definition contained in VAR. Take 8632 +# advantage of any shell optimizations that allow amortized linear growth over 8633 +# repeated appends, instead of the typical quadratic growth present in naive 8634 +# implementations. 8635 +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : 8636 + eval 'as_fn_append () 8637 + { 8638 + eval $1+=\$2 8639 + }' 8640 +else 8641 + as_fn_append () 8642 + { 8643 + eval $1=\$$1\$2 8644 + } 8645 +fi # as_fn_append 8646 + 8647 +# as_fn_arith ARG... 8648 +# ------------------ 8649 +# Perform arithmetic evaluation on the ARGs, and store the result in the 8650 +# global $as_val. Take advantage of shells that can avoid forks. The arguments 8651 +# must be portable across $(()) and expr. 8652 +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : 8653 + eval 'as_fn_arith () 8654 + { 8655 + as_val=$(( $* )) 8656 + }' 8657 +else 8658 + as_fn_arith () 8659 + { 8660 + as_val=`expr "$@" || test $? -eq 1` 8661 + } 8662 +fi # as_fn_arith 8663 + 8664 + 8665 +if expr a : '\(a\)' >/dev/null 2>&1 && 8666 + test "X`expr 00001 : '.*\(...\)'`" = X001; then 8667 + as_expr=expr 8668 +else 8669 + as_expr=false 8670 +fi 8671 + 8672 +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then 8673 + as_basename=basename 8674 +else 8675 + as_basename=false 8676 +fi 8677 + 8678 +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then 8679 + as_dirname=dirname 8680 +else 8681 + as_dirname=false 8682 +fi 8683 + 8684 +as_me=`$as_basename -- "$0" || 8685 +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ 8686 + X"$0" : 'X\(//\)$' \| \ 8687 + X"$0" : 'X\(/\)' \| . 2>/dev/null || 8688 +$as_echo X/"$0" | 8689 + sed '/^.*\/\([^/][^/]*\)\/*$/{ 8690 + s//\1/ 8691 + q 8692 + } 8693 + /^X\/\(\/\/\)$/{ 8694 + s//\1/ 8695 + q 8696 + } 8697 + /^X\/\(\/\).*/{ 8698 + s//\1/ 8699 + q 8700 + } 8701 + s/.*/./; q'` 8702 + 8703 +# Avoid depending upon Character Ranges. 8704 +as_cr_letters='abcdefghijklmnopqrstuvwxyz' 8705 +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' 8706 +as_cr_Letters=$as_cr_letters$as_cr_LETTERS 8707 +as_cr_digits='0123456789' 8708 +as_cr_alnum=$as_cr_Letters$as_cr_digits 8709 + 8710 +ECHO_C= ECHO_N= ECHO_T= 8711 +case `echo -n x` in #((((( 8712 +-n*) 8713 + case `echo 'xy\c'` in 8714 + *c*) ECHO_T=' ';; # ECHO_T is single tab character. 8715 + xy) ECHO_C='\c';; 8716 + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null 8717 + ECHO_T=' ';; 8718 + esac;; 8719 +*) 8720 + ECHO_N='-n';; 8721 +esac 8722 + 8723 +rm -f conf$$ conf$$.exe conf$$.file 8724 +if test -d conf$$.dir; then 8725 + rm -f conf$$.dir/conf$$.file 8726 +else 8727 + rm -f conf$$.dir 8728 + mkdir conf$$.dir 2>/dev/null 8729 +fi 8730 +if (echo >conf$$.file) 2>/dev/null; then 8731 + if ln -s conf$$.file conf$$ 2>/dev/null; then 8732 + as_ln_s='ln -s' 8733 + # ... but there are two gotchas: 8734 + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. 8735 + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. 8736 + # In both cases, we have to default to `cp -pR'. 8737 + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || 8738 + as_ln_s='cp -pR' 8739 + elif ln conf$$.file conf$$ 2>/dev/null; then 8740 + as_ln_s=ln 8741 + else 8742 + as_ln_s='cp -pR' 8743 + fi 8744 +else 8745 + as_ln_s='cp -pR' 8746 +fi 8747 +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file 8748 +rmdir conf$$.dir 2>/dev/null 8749 + 8750 + 8751 +# as_fn_mkdir_p 8752 +# ------------- 8753 +# Create "$as_dir" as a directory, including parents if necessary. 8754 +as_fn_mkdir_p () 8755 +{ 8756 + 8757 + case $as_dir in #( 8758 + -*) as_dir=./$as_dir;; 8759 + esac 8760 + test -d "$as_dir" || eval $as_mkdir_p || { 8761 + as_dirs= 8762 + while :; do 8763 + case $as_dir in #( 8764 + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( 8765 + *) as_qdir=$as_dir;; 8766 + esac 8767 + as_dirs="'$as_qdir' $as_dirs" 8768 + as_dir=`$as_dirname -- "$as_dir" || 8769 +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 8770 + X"$as_dir" : 'X\(//\)[^/]' \| \ 8771 + X"$as_dir" : 'X\(//\)$' \| \ 8772 + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || 8773 +$as_echo X"$as_dir" | 8774 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 8775 + s//\1/ 8776 + q 8777 + } 8778 + /^X\(\/\/\)[^/].*/{ 8779 + s//\1/ 8780 + q 8781 + } 8782 + /^X\(\/\/\)$/{ 8783 + s//\1/ 8784 + q 8785 + } 8786 + /^X\(\/\).*/{ 8787 + s//\1/ 8788 + q 8789 + } 8790 + s/.*/./; q'` 8791 + test -d "$as_dir" && break 8792 + done 8793 + test -z "$as_dirs" || eval "mkdir $as_dirs" 8794 + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" 8795 + 8796 + 8797 +} # as_fn_mkdir_p 8798 +if mkdir -p . 2>/dev/null; then 8799 + as_mkdir_p='mkdir -p "$as_dir"' 8800 +else 8801 + test -d ./-p && rmdir ./-p 8802 + as_mkdir_p=false 8803 +fi 8804 + 8805 + 8806 +# as_fn_executable_p FILE 8807 +# ----------------------- 8808 +# Test if FILE is an executable regular file. 8809 +as_fn_executable_p () 8810 +{ 8811 + test -f "$1" && test -x "$1" 8812 +} # as_fn_executable_p 8813 +as_test_x='test -x' 8814 +as_executable_p=as_fn_executable_p 8815 + 8816 +# Sed expression to map a string onto a valid CPP name. 8817 +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" 8818 + 8819 +# Sed expression to map a string onto a valid variable name. 8820 +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" 8821 + 8822 + 8823 +exec 6>&1 8824 +## ----------------------------------- ## 8825 +## Main body of $CONFIG_STATUS script. ## 8826 +## ----------------------------------- ## 8827 +_ASEOF 8828 +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 8829 + 8830 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 8831 +# Save the log message, to keep $0 and so on meaningful, and to 8832 +# report actual input values of CONFIG_FILES etc. instead of their 8833 +# values after options handling. 8834 +ac_log=" 8835 +This file was extended by schemadtx $as_me 1.0, which was 8836 +generated by GNU Autoconf 2.69. Invocation command line was 8837 + 8838 + CONFIG_FILES = $CONFIG_FILES 8839 + CONFIG_HEADERS = $CONFIG_HEADERS 8840 + CONFIG_LINKS = $CONFIG_LINKS 8841 + CONFIG_COMMANDS = $CONFIG_COMMANDS 8842 + $ $0 $@ 8843 + 8844 +on `(hostname || uname -n) 2>/dev/null | sed 1q` 8845 +" 8846 + 8847 +_ACEOF 8848 + 8849 +case $ac_config_files in *" 8850 +"*) set x $ac_config_files; shift; ac_config_files=$*;; 8851 +esac 8852 + 8853 + 8854 + 8855 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 8856 +# Files that config.status was made for. 8857 +config_files="$ac_config_files" 8858 + 8859 +_ACEOF 8860 + 8861 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 8862 +ac_cs_usage="\ 8863 +\`$as_me' instantiates files and other configuration actions 8864 +from templates according to the current configuration. Unless the files 8865 +and actions are specified as TAGs, all are instantiated by default. 8866 + 8867 +Usage: $0 [OPTION]... [TAG]... 8868 + 8869 + -h, --help print this help, then exit 8870 + -V, --version print version number and configuration settings, then exit 8871 + --config print configuration, then exit 8872 + -q, --quiet, --silent 8873 + do not print progress messages 8874 + -d, --debug don't remove temporary files 8875 + --recheck update $as_me by reconfiguring in the same conditions 8876 + --file=FILE[:TEMPLATE] 8877 + instantiate the configuration file FILE 8878 + 8879 +Configuration files: 8880 +$config_files 8881 + 8882 +Report bugs to the package provider." 8883 + 8884 +_ACEOF 8885 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 8886 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" 8887 +ac_cs_version="\\ 8888 +schemadtx config.status 1.0 8889 +configured by $0, generated by GNU Autoconf 2.69, 8890 + with options \\"\$ac_cs_config\\" 8891 + 8892 +Copyright (C) 2012 Free Software Foundation, Inc. 8893 +This config.status script is free software; the Free Software Foundation 8894 +gives unlimited permission to copy, distribute and modify it." 8895 + 8896 +ac_pwd='$ac_pwd' 8897 +srcdir='$srcdir' 8898 +test -n "\$AWK" || AWK=awk 8899 +_ACEOF 8900 + 8901 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 8902 +# The default lists apply if the user does not specify any file. 8903 +ac_need_defaults=: 8904 +while test $# != 0 8905 +do 8906 + case $1 in 8907 + --*=?*) 8908 + ac_option=`expr "X$1" : 'X\([^=]*\)='` 8909 + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` 8910 + ac_shift=: 8911 + ;; 8912 + --*=) 8913 + ac_option=`expr "X$1" : 'X\([^=]*\)='` 8914 + ac_optarg= 8915 + ac_shift=: 8916 + ;; 8917 + *) 8918 + ac_option=$1 8919 + ac_optarg=$2 8920 + ac_shift=shift 8921 + ;; 8922 + esac 8923 + 8924 + case $ac_option in 8925 + # Handling of the options. 8926 + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) 8927 + ac_cs_recheck=: ;; 8928 + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) 8929 + $as_echo "$ac_cs_version"; exit ;; 8930 + --config | --confi | --conf | --con | --co | --c ) 8931 + $as_echo "$ac_cs_config"; exit ;; 8932 + --debug | --debu | --deb | --de | --d | -d ) 8933 + debug=: ;; 8934 + --file | --fil | --fi | --f ) 8935 + $ac_shift 8936 + case $ac_optarg in 8937 + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; 8938 + '') as_fn_error $? "missing file argument" ;; 8939 + esac 8940 + as_fn_append CONFIG_FILES " '$ac_optarg'" 8941 + ac_need_defaults=false;; 8942 + --he | --h | --help | --hel | -h ) 8943 + $as_echo "$ac_cs_usage"; exit ;; 8944 + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ 8945 + | -silent | --silent | --silen | --sile | --sil | --si | --s) 8946 + ac_cs_silent=: ;; 8947 + 8948 + # This is an error. 8949 + -*) as_fn_error $? "unrecognized option: \`$1' 8950 +Try \`$0 --help' for more information." ;; 8951 + 8952 + *) as_fn_append ac_config_targets " $1" 8953 + ac_need_defaults=false ;; 8954 + 8955 + esac 8956 + shift 8957 +done 8958 + 8959 +ac_configure_extra_args= 8960 + 8961 +if $ac_cs_silent; then 8962 + exec 6>/dev/null 8963 + ac_configure_extra_args="$ac_configure_extra_args --silent" 8964 +fi 8965 + 8966 +_ACEOF 8967 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 8968 +if \$ac_cs_recheck; then 8969 + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion 8970 + shift 8971 + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 8972 + CONFIG_SHELL='$SHELL' 8973 + export CONFIG_SHELL 8974 + exec "\$@" 8975 +fi 8976 + 8977 +_ACEOF 8978 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 8979 +exec 5>>config.log 8980 +{ 8981 + echo 8982 + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX 8983 +## Running $as_me. ## 8984 +_ASBOX 8985 + $as_echo "$ac_log" 8986 +} >&5 8987 + 8988 +_ACEOF 8989 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 8990 +_ACEOF 8991 + 8992 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 8993 + 8994 +# Handling of arguments. 8995 +for ac_config_target in $ac_config_targets 8996 +do 8997 + case $ac_config_target in 8998 + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; 8999 + "pkgIndex.tcl") CONFIG_FILES="$CONFIG_FILES pkgIndex.tcl" ;; 9000 + 9001 + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; 9002 + esac 9003 +done 9004 + 9005 + 9006 +# If the user did not use the arguments to specify the items to instantiate, 9007 +# then the envvar interface is used. Set only those that are not. 9008 +# We use the long form for the default assignment because of an extremely 9009 +# bizarre bug on SunOS 4.1.3. 9010 +if $ac_need_defaults; then 9011 + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files 9012 +fi 9013 + 9014 +# Have a temporary directory for convenience. Make it in the build tree 9015 +# simply because there is no reason against having it here, and in addition, 9016 +# creating and moving files from /tmp can sometimes cause problems. 9017 +# Hook for its removal unless debugging. 9018 +# Note that there is a small window in which the directory will not be cleaned: 9019 +# after its creation but before its name has been assigned to `$tmp'. 9020 +$debug || 9021 +{ 9022 + tmp= ac_tmp= 9023 + trap 'exit_status=$? 9024 + : "${ac_tmp:=$tmp}" 9025 + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status 9026 +' 0 9027 + trap 'as_fn_exit 1' 1 2 13 15 9028 +} 9029 +# Create a (secure) tmp directory for tmp files. 9030 + 9031 +{ 9032 + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && 9033 + test -d "$tmp" 9034 +} || 9035 +{ 9036 + tmp=./conf$$-$RANDOM 9037 + (umask 077 && mkdir "$tmp") 9038 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 9039 +ac_tmp=$tmp 9040 + 9041 +# Set up the scripts for CONFIG_FILES section. 9042 +# No need to generate them if there are no CONFIG_FILES. 9043 +# This happens for instance with `./config.status config.h'. 9044 +if test -n "$CONFIG_FILES"; then 9045 + 9046 + 9047 +ac_cr=`echo X | tr X '\015'` 9048 +# On cygwin, bash can eat \r inside `` if the user requested igncr. 9049 +# But we know of no other shell where ac_cr would be empty at this 9050 +# point, so we can use a bashism as a fallback. 9051 +if test "x$ac_cr" = x; then 9052 + eval ac_cr=\$\'\\r\' 9053 +fi 9054 +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` 9055 +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then 9056 + ac_cs_awk_cr='\\r' 9057 +else 9058 + ac_cs_awk_cr=$ac_cr 9059 +fi 9060 + 9061 +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && 9062 +_ACEOF 9063 + 9064 + 9065 +{ 9066 + echo "cat >conf$$subs.awk <<_ACEOF" && 9067 + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && 9068 + echo "_ACEOF" 9069 +} >conf$$subs.sh || 9070 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 9071 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` 9072 +ac_delim='%!_!# ' 9073 +for ac_last_try in false false false false false :; do 9074 + . ./conf$$subs.sh || 9075 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 9076 + 9077 + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` 9078 + if test $ac_delim_n = $ac_delim_num; then 9079 + break 9080 + elif $ac_last_try; then 9081 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 9082 + else 9083 + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " 9084 + fi 9085 +done 9086 +rm -f conf$$subs.sh 9087 + 9088 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 9089 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && 9090 +_ACEOF 9091 +sed -n ' 9092 +h 9093 +s/^/S["/; s/!.*/"]=/ 9094 +p 9095 +g 9096 +s/^[^!]*!// 9097 +:repl 9098 +t repl 9099 +s/'"$ac_delim"'$// 9100 +t delim 9101 +:nl 9102 +h 9103 +s/\(.\{148\}\)..*/\1/ 9104 +t more1 9105 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ 9106 +p 9107 +n 9108 +b repl 9109 +:more1 9110 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ 9111 +p 9112 +g 9113 +s/.\{148\}// 9114 +t nl 9115 +:delim 9116 +h 9117 +s/\(.\{148\}\)..*/\1/ 9118 +t more2 9119 +s/["\\]/\\&/g; s/^/"/; s/$/"/ 9120 +p 9121 +b 9122 +:more2 9123 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ 9124 +p 9125 +g 9126 +s/.\{148\}// 9127 +t delim 9128 +' <conf$$subs.awk | sed ' 9129 +/^[^""]/{ 9130 + N 9131 + s/\n// 9132 +} 9133 +' >>$CONFIG_STATUS || ac_write_fail=1 9134 +rm -f conf$$subs.awk 9135 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 9136 +_ACAWK 9137 +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && 9138 + for (key in S) S_is_set[key] = 1 9139 + FS = "" 9140 + 9141 +} 9142 +{ 9143 + line = $ 0 9144 + nfields = split(line, field, "@") 9145 + substed = 0 9146 + len = length(field[1]) 9147 + for (i = 2; i < nfields; i++) { 9148 + key = field[i] 9149 + keylen = length(key) 9150 + if (S_is_set[key]) { 9151 + value = S[key] 9152 + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) 9153 + len += length(value) + length(field[++i]) 9154 + substed = 1 9155 + } else 9156 + len += 1 + keylen 9157 + } 9158 + 9159 + print line 9160 +} 9161 + 9162 +_ACAWK 9163 +_ACEOF 9164 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 9165 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then 9166 + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" 9167 +else 9168 + cat 9169 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ 9170 + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 9171 +_ACEOF 9172 + 9173 +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), 9174 +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and 9175 +# trailing colons and then remove the whole line if VPATH becomes empty 9176 +# (actually we leave an empty line to preserve line numbers). 9177 +if test "x$srcdir" = x.; then 9178 + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ 9179 +h 9180 +s/// 9181 +s/^/:/ 9182 +s/[ ]*$/:/ 9183 +s/:\$(srcdir):/:/g 9184 +s/:\${srcdir}:/:/g 9185 +s/:@srcdir@:/:/g 9186 +s/^:*// 9187 +s/:*$// 9188 +x 9189 +s/\(=[ ]*\).*/\1/ 9190 +G 9191 +s/\n// 9192 +s/^[^=]*=[ ]*$// 9193 +}' 9194 +fi 9195 + 9196 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 9197 +fi # test -n "$CONFIG_FILES" 9198 + 9199 + 9200 +eval set X " :F $CONFIG_FILES " 9201 +shift 9202 +for ac_tag 9203 +do 9204 + case $ac_tag in 9205 + :[FHLC]) ac_mode=$ac_tag; continue;; 9206 + esac 9207 + case $ac_mode$ac_tag in 9208 + :[FHL]*:*);; 9209 + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; 9210 + :[FH]-) ac_tag=-:-;; 9211 + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; 9212 + esac 9213 + ac_save_IFS=$IFS 9214 + IFS=: 9215 + set x $ac_tag 9216 + IFS=$ac_save_IFS 9217 + shift 9218 + ac_file=$1 9219 + shift 9220 + 9221 + case $ac_mode in 9222 + :L) ac_source=$1;; 9223 + :[FH]) 9224 + ac_file_inputs= 9225 + for ac_f 9226 + do 9227 + case $ac_f in 9228 + -) ac_f="$ac_tmp/stdin";; 9229 + *) # Look for the file first in the build tree, then in the source tree 9230 + # (if the path is not absolute). The absolute path cannot be DOS-style, 9231 + # because $ac_f cannot contain `:'. 9232 + test -f "$ac_f" || 9233 + case $ac_f in 9234 + [\\/$]*) false;; 9235 + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; 9236 + esac || 9237 + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; 9238 + esac 9239 + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac 9240 + as_fn_append ac_file_inputs " '$ac_f'" 9241 + done 9242 + 9243 + # Let's still pretend it is `configure' which instantiates (i.e., don't 9244 + # use $as_me), people would be surprised to read: 9245 + # /* config.h. Generated by config.status. */ 9246 + configure_input='Generated from '` 9247 + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' 9248 + `' by configure.' 9249 + if test x"$ac_file" != x-; then 9250 + configure_input="$ac_file. $configure_input" 9251 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 9252 +$as_echo "$as_me: creating $ac_file" >&6;} 9253 + fi 9254 + # Neutralize special characters interpreted by sed in replacement strings. 9255 + case $configure_input in #( 9256 + *\&* | *\|* | *\\* ) 9257 + ac_sed_conf_input=`$as_echo "$configure_input" | 9258 + sed 's/[\\\\&|]/\\\\&/g'`;; #( 9259 + *) ac_sed_conf_input=$configure_input;; 9260 + esac 9261 + 9262 + case $ac_tag in 9263 + *:-:* | *:-) cat >"$ac_tmp/stdin" \ 9264 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; 9265 + esac 9266 + ;; 9267 + esac 9268 + 9269 + ac_dir=`$as_dirname -- "$ac_file" || 9270 +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 9271 + X"$ac_file" : 'X\(//\)[^/]' \| \ 9272 + X"$ac_file" : 'X\(//\)$' \| \ 9273 + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || 9274 +$as_echo X"$ac_file" | 9275 + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 9276 + s//\1/ 9277 + q 9278 + } 9279 + /^X\(\/\/\)[^/].*/{ 9280 + s//\1/ 9281 + q 9282 + } 9283 + /^X\(\/\/\)$/{ 9284 + s//\1/ 9285 + q 9286 + } 9287 + /^X\(\/\).*/{ 9288 + s//\1/ 9289 + q 9290 + } 9291 + s/.*/./; q'` 9292 + as_dir="$ac_dir"; as_fn_mkdir_p 9293 + ac_builddir=. 9294 + 9295 +case "$ac_dir" in 9296 +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; 9297 +*) 9298 + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` 9299 + # A ".." for each directory in $ac_dir_suffix. 9300 + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` 9301 + case $ac_top_builddir_sub in 9302 + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; 9303 + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; 9304 + esac ;; 9305 +esac 9306 +ac_abs_top_builddir=$ac_pwd 9307 +ac_abs_builddir=$ac_pwd$ac_dir_suffix 9308 +# for backward compatibility: 9309 +ac_top_builddir=$ac_top_build_prefix 9310 + 9311 +case $srcdir in 9312 + .) # We are building in place. 9313 + ac_srcdir=. 9314 + ac_top_srcdir=$ac_top_builddir_sub 9315 + ac_abs_top_srcdir=$ac_pwd ;; 9316 + [\\/]* | ?:[\\/]* ) # Absolute name. 9317 + ac_srcdir=$srcdir$ac_dir_suffix; 9318 + ac_top_srcdir=$srcdir 9319 + ac_abs_top_srcdir=$srcdir ;; 9320 + *) # Relative name. 9321 + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix 9322 + ac_top_srcdir=$ac_top_build_prefix$srcdir 9323 + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; 9324 +esac 9325 +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix 9326 + 9327 + 9328 + case $ac_mode in 9329 + :F) 9330 + # 9331 + # CONFIG_FILE 9332 + # 9333 + 9334 +_ACEOF 9335 + 9336 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 9337 +# If the template does not know about datarootdir, expand it. 9338 +# FIXME: This hack should be removed a few years after 2.60. 9339 +ac_datarootdir_hack=; ac_datarootdir_seen= 9340 +ac_sed_dataroot=' 9341 +/datarootdir/ { 9342 + p 9343 + q 9344 +} 9345 +/@datadir@/p 9346 +/@docdir@/p 9347 +/@infodir@/p 9348 +/@localedir@/p 9349 +/@mandir@/p' 9350 +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in 9351 +*datarootdir*) ac_datarootdir_seen=yes;; 9352 +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) 9353 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 9354 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} 9355 +_ACEOF 9356 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 9357 + ac_datarootdir_hack=' 9358 + s&@datadir@&$datadir&g 9359 + s&@docdir@&$docdir&g 9360 + s&@infodir@&$infodir&g 9361 + s&@localedir@&$localedir&g 9362 + s&@mandir@&$mandir&g 9363 + s&\\\${datarootdir}&$datarootdir&g' ;; 9364 +esac 9365 +_ACEOF 9366 + 9367 +# Neutralize VPATH when `$srcdir' = `.'. 9368 +# Shell code in configure.ac might set extrasub. 9369 +# FIXME: do we really want to maintain this feature? 9370 +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 9371 +ac_sed_extra="$ac_vpsub 9372 +$extrasub 9373 +_ACEOF 9374 +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 9375 +:t 9376 +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b 9377 +s|@configure_input@|$ac_sed_conf_input|;t t 9378 +s&@top_builddir@&$ac_top_builddir_sub&;t t 9379 +s&@top_build_prefix@&$ac_top_build_prefix&;t t 9380 +s&@srcdir@&$ac_srcdir&;t t 9381 +s&@abs_srcdir@&$ac_abs_srcdir&;t t 9382 +s&@top_srcdir@&$ac_top_srcdir&;t t 9383 +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t 9384 +s&@builddir@&$ac_builddir&;t t 9385 +s&@abs_builddir@&$ac_abs_builddir&;t t 9386 +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t 9387 +$ac_datarootdir_hack 9388 +" 9389 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ 9390 + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 9391 + 9392 +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && 9393 + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && 9394 + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ 9395 + "$ac_tmp/out"`; test -z "$ac_out"; } && 9396 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' 9397 +which seems to be undefined. Please make sure it is defined" >&5 9398 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' 9399 +which seems to be undefined. Please make sure it is defined" >&2;} 9400 + 9401 + rm -f "$ac_tmp/stdin" 9402 + case $ac_file in 9403 + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; 9404 + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; 9405 + esac \ 9406 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 9407 + ;; 9408 + 9409 + 9410 + 9411 + esac 9412 + 9413 +done # for ac_tag 9414 + 9415 + 9416 +as_fn_exit 0 9417 +_ACEOF 9418 +ac_clean_files=$ac_clean_files_save 9419 + 9420 +test $ac_write_fail = 0 || 9421 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 9422 + 9423 + 9424 +# configure is writing to config.log, and then calls config.status. 9425 +# config.status does its own redirection, appending to config.log. 9426 +# Unfortunately, on DOS this fails, as config.log is still kept open 9427 +# by configure, so config.status won't be able to write to it; its 9428 +# output is simply discarded. So we exec the FD to /dev/null, 9429 +# effectively closing config.log, so it can be properly (re)opened and 9430 +# appended to by config.status. When coming back to configure, we 9431 +# need to make the FD available again. 9432 +if test "$no_create" != yes; then 9433 + ac_cs_success=: 9434 + ac_config_status_args= 9435 + test "$silent" = yes && 9436 + ac_config_status_args="$ac_config_status_args --quiet" 9437 + exec 5>/dev/null 9438 + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false 9439 + exec 5>>config.log 9440 + # Use ||, not &&, to avoid exiting from the if with $? = 1, which 9441 + # would make configure fail if this is the last instruction. 9442 + $ac_cs_success || as_fn_exit 1 9443 +fi 9444 +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then 9445 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 9446 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} 9447 +fi 9448 +
Added extensions/schemadtx/configure.ac.
1 +#!/bin/bash -norc 2 +dnl This file is an input file used by the GNU "autoconf" program to 3 +dnl generate the file "configure", which is run during Tcl installation 4 +dnl to configure the system for the local environment. 5 + 6 +#----------------------------------------------------------------------- 7 +# Sample configure.in for Tcl Extensions. The only places you should 8 +# need to modify this file are marked by the string __CHANGE__ 9 +#----------------------------------------------------------------------- 10 + 11 +#----------------------------------------------------------------------- 12 +# __CHANGE__ 13 +# Set your package name and version numbers here. 14 +# 15 +# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION 16 +# set as provided. These will also be added as -D defs in your Makefile 17 +# so you can encode the package version directly into the source files. 18 +# This will also define a special symbol for Windows (BUILD_sample in 19 +# this case) so that we create the export library with the dll. 20 +#----------------------------------------------------------------------- 21 + 22 +AC_INIT([schemadtx], [1.0]) 23 + 24 +#-------------------------------------------------------------------- 25 +# Call TEA_INIT as the first TEA_ macro to set up initial vars. 26 +# This will define a ${TEA_PLATFORM} variable == "unix" or "windows" 27 +# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE. 28 +#-------------------------------------------------------------------- 29 + 30 +TEA_INIT() 31 + 32 +AC_CONFIG_AUX_DIR(../../tclconfig) 33 + 34 +#-------------------------------------------------------------------- 35 +# Load the tclConfig.sh file 36 +#-------------------------------------------------------------------- 37 + 38 +TEA_PATH_TCLCONFIG 39 +TEA_LOAD_TCLCONFIG 40 + 41 +#-------------------------------------------------------------------- 42 +# Load the tkConfig.sh file if necessary (Tk extension) 43 +#-------------------------------------------------------------------- 44 + 45 +#TEA_PATH_TKCONFIG 46 +#TEA_LOAD_TKCONFIG 47 + 48 +#----------------------------------------------------------------------- 49 +# Handle the --prefix=... option by defaulting to what Tcl gave. 50 +# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER. 51 +#----------------------------------------------------------------------- 52 + 53 +TEA_PREFIX 54 + 55 +#----------------------------------------------------------------------- 56 +# Standard compiler checks. 57 +# This sets up CC by using the CC env var, or looks for gcc otherwise. 58 +# This also calls AC_PROG_CC and a few others to create the basic setup 59 +# necessary to compile executables. 60 +#----------------------------------------------------------------------- 61 + 62 +TEA_SETUP_COMPILER 63 + 64 +#-------------------------------------------------------------------- 65 +# Load the tdomConfig.sh file 66 +#-------------------------------------------------------------------- 67 + 68 +TDOM_PATH_CONFIG 69 +TDOM_LOAD_CONFIG 70 + 71 +#----------------------------------------------------------------------- 72 +# __CHANGE__ 73 +# Specify the C source files to compile in TEA_ADD_SOURCES, 74 +# public headers that need to be installed in TEA_ADD_HEADERS, 75 +# stub library C source files to compile in TEA_ADD_STUB_SOURCES, 76 +# and runtime Tcl library files in TEA_ADD_TCL_SOURCES. 77 +# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS 78 +# and PKG_TCL_SOURCES. 79 +#----------------------------------------------------------------------- 80 + 81 +TEA_ADD_SOURCES([schemadtx.c]) 82 +TEA_ADD_HEADERS([]) 83 +TEA_ADD_INCLUDES([-I${srcdir}/../../generic -I${srcdir}/../../expat]) 84 +TEA_ADD_LIBS([${TDOM_STUB_LIB_SPEC}]) 85 +TEA_ADD_CFLAGS([-DUSE_TDOM_STUBS=1]) 86 +TEA_ADD_STUB_SOURCES([]) 87 +TEA_ADD_TCL_SOURCES([]) 88 + 89 +#-------------------------------------------------------------------- 90 +# __CHANGE__ 91 +# 92 +# You can add more files to clean if your extension creates any extra 93 +# files by extending CLEANFILES. 94 +# Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure 95 +# and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var. 96 +# 97 +# A few miscellaneous platform-specific items: 98 +# TEA_ADD_* any platform specific compiler/build info here. 99 +#-------------------------------------------------------------------- 100 + 101 +#CLEANFILES="$CLEANFILES pkgIndex.tcl" 102 +if test "${TEA_PLATFORM}" = "windows" ; then 103 + # Ensure no empty if clauses 104 + : 105 + #TEA_ADD_SOURCES([win/winFile.c]) 106 + #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"]) 107 +else 108 + # Ensure no empty else clauses 109 + : 110 + #TEA_ADD_SOURCES([unix/unixFile.c]) 111 + #TEA_ADD_LIBS([-lsuperfly]) 112 +fi 113 + 114 +#-------------------------------------------------------------------- 115 +# __CHANGE__ 116 +# Choose which headers you need. Extension authors should try very 117 +# hard to only rely on the Tcl public header files. Internal headers 118 +# contain private data structures and are subject to change without 119 +# notice. 120 +# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG 121 +#-------------------------------------------------------------------- 122 + 123 +TEA_PUBLIC_TCL_HEADERS 124 +#TEA_PRIVATE_TCL_HEADERS 125 + 126 +#TEA_PUBLIC_TK_HEADERS 127 +#TEA_PRIVATE_TK_HEADERS 128 +#TEA_PATH_X 129 + 130 +#-------------------------------------------------------------------- 131 +# Check whether --enable-threads or --disable-threads was given. 132 +# This auto-enables if Tcl was compiled threaded. 133 +#-------------------------------------------------------------------- 134 + 135 +TEA_ENABLE_THREADS 136 + 137 +#-------------------------------------------------------------------- 138 +# The statement below defines a collection of symbols related to 139 +# building as a shared library instead of a static library. 140 +#-------------------------------------------------------------------- 141 + 142 +TEA_ENABLE_SHARED 143 + 144 +#-------------------------------------------------------------------- 145 +# This macro figures out what flags to use with the compiler/linker 146 +# when building shared/static debug/optimized objects. This information 147 +# can be taken from the tclConfig.sh file, but this figures it all out. 148 +#-------------------------------------------------------------------- 149 + 150 +TEA_CONFIG_CFLAGS 151 + 152 +#-------------------------------------------------------------------- 153 +# Set the default compiler switches based on the --enable-symbols option. 154 +#-------------------------------------------------------------------- 155 + 156 +TEA_ENABLE_SYMBOLS 157 + 158 +#-------------------------------------------------------------------- 159 +# Everyone should be linking against the Tcl stub library. If you 160 +# can't for some reason, remove this definition. If you aren't using 161 +# stubs, you also need to modify the SHLIB_LD_LIBS setting below to 162 +# link against the non-stubbed Tcl library. Add Tk too if necessary. 163 +#-------------------------------------------------------------------- 164 + 165 +AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs]) 166 +#AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs]) 167 + 168 +#-------------------------------------------------------------------- 169 +# This macro generates a line to use when building a library. It 170 +# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS, 171 +# and TEA_LOAD_TCLCONFIG macros above. 172 +#-------------------------------------------------------------------- 173 + 174 +TEA_MAKE_LIB 175 + 176 +#-------------------------------------------------------------------- 177 +# Determine the name of the tclsh and/or wish executables in the 178 +# Tcl and Tk build directories or the location they were installed 179 +# into. These paths are used to support running test cases only, 180 +# the Makefile should not be making use of these paths to generate 181 +# a pkgIndex.tcl file or anything else at extension build time. 182 +#-------------------------------------------------------------------- 183 + 184 +TEA_PROG_TCLSH 185 +#TEA_PROG_WISH 186 + 187 +#-------------------------------------------------------------------- 188 +# Finally, substitute all of the various values into the Makefile. 189 +# You may alternatively have a special pkgIndex.tcl.in or other files 190 +# which require substituting th AC variables in. Include these here. 191 +#-------------------------------------------------------------------- 192 + 193 +AC_OUTPUT([Makefile pkgIndex.tcl])
Added extensions/schemadtx/pkgIndex.tcl.in.
1 +# 2 +# Tcl package index file 3 +# 4 +package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \ 5 + "package require tdom 0.9.2-; 6 + load [file join $dir @PKG_LIB_FILE@]"
Added extensions/schemadtx/schemadtx.c.
1 + 2 +#include <tdom.h> 3 +#include <dom.h> 4 +#include <tcldom.h> 5 +#include <schema.h> 6 + 7 +#define SetResult(str) Tcl_ResetResult(interp); \ 8 + Tcl_SetStringObj(Tcl_GetObjResult(interp), (str), -1) 9 + 10 +#define CHECK_TI \ 11 + if (!sdata) { \ 12 + SetResult ("Command called outside of schema context"); \ 13 + return TCL_ERROR; \ 14 + } \ 15 + if (!sdata->isTextConstraint) { \ 16 + SetResult ("Command called in invalid schema context"); \ 17 + return TCL_ERROR; \ 18 + } 19 + 20 +#define ADD_CONSTRAINT(sdata, sc) \ 21 + sc = TMALLOC (SchemaConstraint); \ 22 + memset (sc, 0, sizeof (SchemaConstraint)); \ 23 + if (sdata->cp->nc == sdata->contentSize) { \ 24 + sdata->cp->content = \ 25 + REALLOC (sdata->cp->content, \ 26 + 2 * sdata->contentSize \ 27 + * sizeof (SchemaCP*)); \ 28 + sdata->cp->quants = \ 29 + REALLOC (sdata->cp->quants, \ 30 + 2 * sdata->contentSize \ 31 + * sizeof (SchemaQuant)); \ 32 + sdata->contentSize *= 2; \ 33 + } \ 34 + sdata->cp->content[sdata->cp->nc] = (SchemaCP *) sc; \ 35 + sdata->cp->quants[sdata->cp->nc] = SCHEMA_CQUANT_ONE; \ 36 + sdata->cp->nc++; \ 37 + 38 +extern char *Tdom_InitStubs (Tcl_Interp *interp, char *version, int exact); 39 + 40 +#define GTIN_8 1 41 +#define GTIN_12 2 42 +#define GTIN_13 4 43 +#define GTIN_14 8 44 + 45 + 46 +static int 47 +gtinImpl ( 48 + Tcl_Interp *interp, 49 + void *constraintData, 50 + char *text 51 + ) 52 +{ 53 + int len, sum, i, mult, digit; 54 + long flags = (long) constraintData; 55 + 56 + len = strlen (text); 57 + if (len == 8) { 58 + if (flags && !(flags & GTIN_8)) return 0; 59 + } else if (len == 12) { 60 + if (flags && !(flags & GTIN_12)) return 0; 61 + } else if (len == 13) { 62 + if (flags && !(flags & GTIN_13)) return 0; 63 + } else if (len == 14) { 64 + if (flags && !(flags & GTIN_14)) return 0; 65 + } else { 66 + return 0; 67 + } 68 + 69 + sum = 0; 70 + mult = len % 2; 71 + for (i = len - 1; i >= 0; i--) { 72 + digit = text[i] - '0'; 73 + if (digit < 0 || digit > 9) return 0; 74 + if (i % 2 == mult) digit *= 3; 75 + sum += digit; 76 + } 77 + if (sum % 10 != 0) return 0; 78 + return 1; 79 +} 80 + 81 +/* 82 + *---------------------------------------------------------------------------- 83 + * 84 + * gtinTCObjCmd 85 + * 86 + * This procedure is invoked to process the 87 + * "tdom::schema::text::gtin" command. 88 + * 89 + * Results: 90 + * A standard Tcl result. 91 + * 92 + * Side effects: 93 + * The ususal schema text constraint command machinery. 94 + * 95 + *---------------------------------------------------------------------------- 96 + */ 97 + 98 +int 99 +gtinTCObjCmd (dummy, interp, objc, objv) 100 + ClientData dummy; 101 + Tcl_Interp *interp; 102 + int objc; 103 + Tcl_Obj *const objv[]; 104 +{ 105 + SchemaData *sdata = tdomGetSchemadata(); 106 + SchemaConstraint *sc; 107 + int optionIndex; 108 + long flags = 0; 109 + 110 + CHECK_TI; 111 + 112 + static const char *options[] = { 113 + "-gtin8", "-gtin12", "-gtin13", "-gtin14", NULL 114 + }; 115 + enum option { 116 + m_gtin8, m_gtin12, m_gtin13, m_gtin14 117 + }; 118 + 119 + while (objc > 1) { 120 + if (Tcl_GetIndexFromObj (interp, objv[1], options, "option", 0, 121 + &optionIndex) != TCL_OK) { 122 + return TCL_ERROR; 123 + } 124 + switch ((enum option) optionIndex) { 125 + case m_gtin8: 126 + flags |= GTIN_8; 127 + break; 128 + case m_gtin12: 129 + flags |= GTIN_12; 130 + break; 131 + case m_gtin13: 132 + flags |= GTIN_13; 133 + break; 134 + case m_gtin14: 135 + flags |= GTIN_14; 136 + break; 137 + } 138 + objv++; 139 + objc--; 140 + } 141 + 142 + ADD_CONSTRAINT (sdata, sc) 143 + sc->constraint = gtinImpl; 144 + sc->constraintData = (void *)flags; 145 + return TCL_OK; 146 +} 147 + 148 +/* 149 + *---------------------------------------------------------------------------- 150 + * 151 + * Schemadtx_Init -- 152 + * 153 + * Initialization routine for loadable module 154 + * 155 + * Results: 156 + * None. 157 + * 158 + * Side effects: 159 + * Defines the additional text constraint commands 160 + * 161 + *---------------------------------------------------------------------------- 162 + */ 163 + 164 +int 165 +Schemadtx_Init (interp) 166 + Tcl_Interp *interp; 167 +{ 168 +#ifdef USE_TCL_STUBS 169 + if (Tcl_InitStubs(interp, "8", 0) == NULL) { 170 + return TCL_ERROR; 171 + } 172 +#endif 173 +#ifdef USE_TDOM_STUBS 174 + if (Tdom_InitStubs(interp, "0.9.2", 0) == NULL) { 175 + return TCL_ERROR; 176 + } 177 +#endif 178 + if (Tcl_PkgRequire (interp, "tdom", "0.9.2", 0) == NULL) { 179 + return TCL_ERROR; 180 + }; 181 + Tcl_CreateObjCommand (interp,"tdom::schema::text::gtin", 182 + gtinTCObjCmd, (ClientData) 3, NULL); 183 + Tcl_PkgProvide (interp, "schemadtx", "1.0"); 184 + return TCL_OK; 185 +}
Added extensions/schemadtx/tests/all.tcl.
1 +# all.tcl -- 2 +# 3 +# This file contains a top-level script to run all of the Tcl 4 +# tests. Execute it by invoking "tclsh all.test". 5 +# 6 +# Copyright (c) 1998-1999 by Scriptics Corporation. 7 +# All rights reserved. 8 +# 9 +# RCS: @(#) $Id$ 10 +# 11 + 12 +source [file join [file dir [info script]] loadschemadtx.tcl] 13 + 14 +singleProcess 1 15 +configure {*}$argv -testdir [file dirname [info script]] 16 +runAllTests 17 +# See http://mini.net/tcl/3248 for an explanation. 18 +proc exit args {}
Added extensions/schemadtx/tests/loadschemadtx.tcl.
1 +catch {load ../../../unix/libtdom0.9.2.so} 2 +catch {load ../libschemadtx1.0.so} 3 +catch {load ../../unix/libtdom0.9.2.so} 4 +catch {load libschemadtx1.0.so} 5 +# loadschemadtx.tcl -- 6 +# 7 +# This file is [source]d by all.tcl and all test files, to ensure, that 8 +# the tcltest package and the lastest schemadtx build is present. 9 + 10 +if {[lsearch [namespace children] ::tcltest] == -1} { 11 + package require tcltest 12 + namespace import ::tcltest::* 13 +} 14 + 15 +if {[catch {package present tdom}]} { 16 + package require tdom 0.9.2 17 +} 18 + 19 +if {[catch {package require tnc}]} { 20 + package require schemadtx 21 +} 22 +
Added extensions/schemadtx/tests/schemadtx.test.
1 +# Features covered: extended schema text constraint commands. 2 +# 3 +# This file contains a collection of tests for the collection of 4 +# additional schema text constraint commands of schemadtx, provided as 5 +# an "extension extension" to tdom. 6 +# 7 +# Copyright (c) 2020 Rolf Ade. 8 + 9 + 10 +set testDir [file dir [info script]] 11 +source [file join $testDir loadschemadtx.tcl] 12 + 13 +test schemadtx-1.1 {gtin} { 14 + tdom::schema s 15 + s defelement e { 16 + text { 17 + gtin 18 + } 19 + } 20 + set result "" 21 + foreach xml { 22 + <e/> 23 + <e></e> 24 + <e>1</e> 25 + <e>4012345123456</e> 26 + <e>4012345a23456</e> 27 + } { 28 + lappend result [s validate $xml] 29 + } 30 + s delete 31 + set result 32 +} {0 0 0 1 0} 33 + 34 + 35 +# Local Variables: 36 +# mode: tcl 37 +# End: 38 + 39 +
Changes to extensions/tdomhtml/configure.
607 607 pdfdir 608 608 dvidir 609 609 htmldir 610 610 infodir 611 611 docdir 612 612 oldincludedir 613 613 includedir 614 +runstatedir 614 615 localstatedir 615 616 sharedstatedir 616 617 sysconfdir 617 618 datadir 618 619 datarootdir 619 620 libexecdir 620 621 sbindir ................................................................................ 671 672 sbindir='${exec_prefix}/sbin' 672 673 libexecdir='${exec_prefix}/libexec' 673 674 datarootdir='${prefix}/share' 674 675 datadir='${datarootdir}' 675 676 sysconfdir='${prefix}/etc' 676 677 sharedstatedir='${prefix}/com' 677 678 localstatedir='${prefix}/var' 679 +runstatedir='${localstatedir}/run' 678 680 includedir='${prefix}/include' 679 681 oldincludedir='/usr/include' 680 682 docdir='${datarootdir}/doc/${PACKAGE}' 681 683 infodir='${datarootdir}/info' 682 684 htmldir='${docdir}' 683 685 dvidir='${docdir}' 684 686 pdfdir='${docdir}' ................................................................................ 922 924 ac_prev=psdir ;; 923 925 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) 924 926 psdir=$ac_optarg ;; 925 927 926 928 -q | -quiet | --quiet | --quie | --qui | --qu | --q \ 927 929 | -silent | --silent | --silen | --sile | --sil) 928 930 silent=yes ;; 931 + 932 + -runstatedir | --runstatedir | --runstatedi | --runstated \ 933 + | --runstate | --runstat | --runsta | --runst | --runs \ 934 + | --run | --ru | --r) 935 + ac_prev=runstatedir ;; 936 + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ 937 + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ 938 + | --run=* | --ru=* | --r=*) 939 + runstatedir=$ac_optarg ;; 929 940 930 941 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) 931 942 ac_prev=sbindir ;; 932 943 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ 933 944 | --sbi=* | --sb=*) 934 945 sbindir=$ac_optarg ;; 935 946 ................................................................................ 1060 1071 esac 1061 1072 fi 1062 1073 1063 1074 # Check all directory arguments for consistency. 1064 1075 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ 1065 1076 datadir sysconfdir sharedstatedir localstatedir includedir \ 1066 1077 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ 1067 - libdir localedir mandir 1078 + libdir localedir mandir runstatedir 1068 1079 do 1069 1080 eval ac_val=\$$ac_var 1070 1081 # Remove trailing slashes. 1071 1082 case $ac_val in 1072 1083 */ ) 1073 1084 ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` 1074 1085 eval $ac_var=\$ac_val;; ................................................................................ 1213 1224 Fine tuning of the installation directories: 1214 1225 --bindir=DIR user executables [EPREFIX/bin] 1215 1226 --sbindir=DIR system admin executables [EPREFIX/sbin] 1216 1227 --libexecdir=DIR program executables [EPREFIX/libexec] 1217 1228 --sysconfdir=DIR read-only single-machine data [PREFIX/etc] 1218 1229 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 1219 1230 --localstatedir=DIR modifiable single-machine data [PREFIX/var] 1231 + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] 1220 1232 --libdir=DIR object code libraries [EPREFIX/lib] 1221 1233 --includedir=DIR C header files [PREFIX/include] 1222 1234 --oldincludedir=DIR C header files for non-gcc [/usr/include] 1223 1235 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 1224 1236 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 1225 1237 --infodir=DIR info documentation [DATAROOTDIR/info] 1226 1238 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
Deleted extensions/tdomhtml/mkinstalldirs.
1 -#! /bin/sh 2 -# mkinstalldirs --- make directory hierarchy 3 -# Author: Noah Friedman <friedman@prep.ai.mit.edu> 4 -# Created: 1993-05-16 5 -# Public domain 6 - 7 -# $Id$ 8 - 9 -errstatus=0 10 - 11 -for file 12 -do 13 - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 - shift 15 - 16 - pathcomp= 17 - for d 18 - do 19 - pathcomp="$pathcomp$d" 20 - case "$pathcomp" in 21 - -* ) pathcomp=./$pathcomp ;; 22 - esac 23 - 24 - if test ! -d "$pathcomp"; then 25 - echo "mkdir $pathcomp" 26 - 27 - mkdir "$pathcomp" || lasterr=$? 28 - 29 - if test ! -d "$pathcomp"; then 30 - errstatus=$lasterr 31 - fi 32 - fi 33 - 34 - pathcomp="$pathcomp/" 35 - done 36 -done 37 - 38 -exit $errstatus 39 - 40 -# mkinstalldirs ends here
Changes to extensions/tnc/configure.
615 615 # include <stdint.h> 616 616 #endif 617 617 #ifdef HAVE_UNISTD_H 618 618 # include <unistd.h> 619 619 #endif" 620 620 621 621 ac_subst_vars='LTLIBOBJS 622 -LIBOBJS 623 622 TCLSH_PROG 624 623 VC_MANIFEST_EMBED_EXE 625 624 VC_MANIFEST_EMBED_DLL 626 625 RANLIB_STUB 627 626 MAKE_STUB_LIB 628 627 MAKE_STATIC_LIB 629 628 MAKE_SHARED_LIB 630 629 MAKE_LIB 631 -TCL_DBGX 632 630 LDFLAGS_DEFAULT 633 631 CFLAGS_DEFAULT 634 632 LD_LIBRARY_PATH_VAR 635 633 SHLIB_CFLAGS 636 634 SHLIB_LD_LIBS 637 635 SHLIB_LD 638 636 STLIB_LD 637 +LDFLAGS_OPTIMIZE 638 +LDFLAGS_DEBUG 639 639 CFLAGS_WARNING 640 640 CFLAGS_OPTIMIZE 641 641 CFLAGS_DEBUG 642 +LIBOBJS 642 643 RC 643 -CELIB_DIR 644 644 AR 645 645 STUBS_BUILD 646 646 SHARED_BUILD 647 647 TCL_THREADS 648 648 TCL_INCLUDES 649 649 PKG_OBJECTS 650 650 PKG_SOURCES 651 651 TDOM_SRC_DIR 652 652 TDOM_STUB_LIB_SPEC 653 653 TDOM_VERSION 654 -MATH_LIBS 655 654 EGREP 656 655 GREP 657 656 RANLIB 658 657 SET_MAKE 659 -INSTALL_LIBRARY 660 -INSTALL_SCRIPT 661 -INSTALL_PROGRAM 662 -INSTALL_DATA 663 -INSTALL_DATA_DIR 664 -INSTALL 665 658 CPP 666 659 TCL_SHLIB_LD_LIBS 667 660 TCL_LD_FLAGS 668 661 TCL_EXTRA_CFLAGS 669 662 TCL_DEFS 670 663 TCL_LIBS 671 664 CLEANFILES ................................................................................ 681 674 TCL_LIB_SPEC 682 675 TCL_LIB_FLAG 683 676 TCL_LIB_FILE 684 677 TCL_SRC_DIR 685 678 TCL_BIN_DIR 686 679 TCL_PATCH_LEVEL 687 680 TCL_VERSION 681 +INSTALL_LIBRARY 682 +INSTALL_SCRIPT 683 +INSTALL_PROGRAM 684 +INSTALL_DATA 685 +INSTALL_DATA_DIR 686 +INSTALL 688 687 PKG_CFLAGS 689 688 PKG_LIBS 690 689 PKG_INCLUDES 691 690 PKG_HEADERS 692 691 PKG_TCL_SOURCES 693 692 PKG_STUB_OBJECTS 694 693 PKG_STUB_SOURCES ................................................................................ 711 710 pdfdir 712 711 dvidir 713 712 htmldir 714 713 infodir 715 714 docdir 716 715 oldincludedir 717 716 includedir 717 +runstatedir 718 718 localstatedir 719 719 sharedstatedir 720 720 sysconfdir 721 721 datadir 722 722 datarootdir 723 723 libexecdir 724 724 sbindir ................................................................................ 742 742 with_tclinclude 743 743 enable_threads 744 744 enable_shared 745 745 enable_stubs 746 746 enable_64bit 747 747 enable_64bit_vis 748 748 enable_rpath 749 -enable_wince 750 -with_celib 751 749 enable_symbols 752 750 ' 753 751 ac_precious_vars='build_alias 754 752 host_alias 755 753 target_alias 756 754 CC 757 755 CFLAGS ................................................................................ 793 791 sbindir='${exec_prefix}/sbin' 794 792 libexecdir='${exec_prefix}/libexec' 795 793 datarootdir='${prefix}/share' 796 794 datadir='${datarootdir}' 797 795 sysconfdir='${prefix}/etc' 798 796 sharedstatedir='${prefix}/com' 799 797 localstatedir='${prefix}/var' 798 +runstatedir='${localstatedir}/run' 800 799 includedir='${prefix}/include' 801 800 oldincludedir='/usr/include' 802 801 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' 803 802 infodir='${datarootdir}/info' 804 803 htmldir='${docdir}' 805 804 dvidir='${docdir}' 806 805 pdfdir='${docdir}' ................................................................................ 1044 1043 ac_prev=psdir ;; 1045 1044 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) 1046 1045 psdir=$ac_optarg ;; 1047 1046 1048 1047 -q | -quiet | --quiet | --quie | --qui | --qu | --q \ 1049 1048 | -silent | --silent | --silen | --sile | --sil) 1050 1049 silent=yes ;; 1050 + 1051 + -runstatedir | --runstatedir | --runstatedi | --runstated \ 1052 + | --runstate | --runstat | --runsta | --runst | --runs \ 1053 + | --run | --ru | --r) 1054 + ac_prev=runstatedir ;; 1055 + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ 1056 + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ 1057 + | --run=* | --ru=* | --r=*) 1058 + runstatedir=$ac_optarg ;; 1051 1059 1052 1060 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) 1053 1061 ac_prev=sbindir ;; 1054 1062 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ 1055 1063 | --sbi=* | --sb=*) 1056 1064 sbindir=$ac_optarg ;; 1057 1065 ................................................................................ 1182 1190 esac 1183 1191 fi 1184 1192 1185 1193 # Check all directory arguments for consistency. 1186 1194 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ 1187 1195 datadir sysconfdir sharedstatedir localstatedir includedir \ 1188 1196 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ 1189 - libdir localedir mandir 1197 + libdir localedir mandir runstatedir 1190 1198 do 1191 1199 eval ac_val=\$$ac_var 1192 1200 # Remove trailing slashes. 1193 1201 case $ac_val in 1194 1202 */ ) 1195 1203 ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` 1196 1204 eval $ac_var=\$ac_val;; ................................................................................ 1335 1343 Fine tuning of the installation directories: 1336 1344 --bindir=DIR user executables [EPREFIX/bin] 1337 1345 --sbindir=DIR system admin executables [EPREFIX/sbin] 1338 1346 --libexecdir=DIR program executables [EPREFIX/libexec] 1339 1347 --sysconfdir=DIR read-only single-machine data [PREFIX/etc] 1340 1348 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 1341 1349 --localstatedir=DIR modifiable single-machine data [PREFIX/var] 1350 + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] 1342 1351 --libdir=DIR object code libraries [EPREFIX/lib] 1343 1352 --includedir=DIR C header files [PREFIX/include] 1344 1353 --oldincludedir=DIR C header files for non-gcc [/usr/include] 1345 1354 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 1346 1355 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 1347 1356 --infodir=DIR info documentation [DATAROOTDIR/info] 1348 1357 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] ................................................................................ 1364 1373 esac 1365 1374 cat <<\_ACEOF 1366 1375 1367 1376 Optional Features: 1368 1377 --disable-option-checking ignore unrecognized --enable/--with options 1369 1378 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) 1370 1379 --enable-FEATURE[=ARG] include FEATURE [ARG=yes] 1371 - --enable-threads build with threads 1380 + --enable-threads build with threads (default: on) 1372 1381 --enable-shared build and link with shared libraries (default: on) 1373 1382 --enable-stubs build and link with stub libraries. Always true for 1374 1383 shared builds (default: on) 1375 1384 --enable-64bit enable 64bit support (default: off) 1376 1385 --enable-64bit-vis enable 64bit Sparc VIS support (default: off) 1377 1386 --disable-rpath disable rpath support (default: on) 1378 - --enable-wince enable Win/CE support (where applicable) 1379 1387 --enable-symbols build with debugging symbols (default: off) 1380 1388 1381 1389 Optional Packages: 1382 1390 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 1383 1391 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 1384 1392 --with-tcl directory containing tcl configuration 1385 1393 (tclConfig.sh) 1386 - --with-tdom directory containig tDOM configuration 1394 + --with-tdom directory containing tDOM configuration 1387 1395 (tdomConfig.sh) 1388 1396 --with-tclinclude directory containing the public Tcl header files 1389 - --with-celib=DIR use Windows/CE support library from DIR 1390 1397 1391 1398 Some influential environment variables: 1392 1399 CC C compiler command 1393 1400 CFLAGS C compiler flags 1394 1401 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a 1395 1402 nonstandard directory <lib dir> 1396 1403 LIBS libraries to pass to the linker, e.g. -l<library> ................................................................................ 1668 1675 # left behind by Apple's compiler. We do this before executing the actions. 1669 1676 rm -rf conftest.dSYM conftest_ipa8_conftest.oo 1670 1677 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1671 1678 as_fn_set_status $ac_retval 1672 1679 1673 1680 } # ac_fn_c_try_link 1674 1681 1675 -# ac_fn_c_check_func LINENO FUNC VAR 1676 -# ---------------------------------- 1677 -# Tests whether FUNC exists, setting the cache variable VAR accordingly 1678 -ac_fn_c_check_func () 1679 -{ 1680 - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1681 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1682 -$as_echo_n "checking for $2... " >&6; } 1683 -if eval \${$3+:} false; then : 1684 - $as_echo_n "(cached) " >&6 1685 -else 1686 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1687 -/* end confdefs.h. */ 1688 -/* Define $2 to an innocuous variant, in case <limits.h> declares $2. 1689 - For example, HP-UX 11i <limits.h> declares gettimeofday. */ 1690 -#define $2 innocuous_$2 1691 - 1692 -/* System header to define __stub macros and hopefully few prototypes, 1693 - which can conflict with char $2 (); below. 1694 - Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 1695 - <limits.h> exists even on freestanding compilers. */ 1696 - 1697 -#ifdef __STDC__ 1698 -# include <limits.h> 1699 -#else 1700 -# include <assert.h> 1701 -#endif 1702 - 1703 -#undef $2 1704 - 1705 -/* Override any GCC internal prototype to avoid an error. 1706 - Use char because int might match the return type of a GCC 1707 - builtin and then its argument prototype would still apply. */ 1708 -#ifdef __cplusplus 1709 -extern "C" 1710 -#endif 1711 -char $2 (); 1712 -/* The GNU C library defines this for functions which it implements 1713 - to always fail with ENOSYS. Some functions are actually named 1714 - something starting with __ and the normal name is an alias. */ 1715 -#if defined __stub_$2 || defined __stub___$2 1716 -choke me 1717 -#endif 1718 - 1719 -int 1720 -main () 1721 -{ 1722 -return $2 (); 1723 - ; 1724 - return 0; 1725 -} 1726 -_ACEOF 1727 -if ac_fn_c_try_link "$LINENO"; then : 1728 - eval "$3=yes" 1729 -else 1730 - eval "$3=no" 1731 -fi 1732 -rm -f core conftest.err conftest.$ac_objext \ 1733 - conftest$ac_exeext conftest.$ac_ext 1734 -fi 1735 -eval ac_res=\$$3 1736 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1737 -$as_echo "$ac_res" >&6; } 1738 - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1739 - 1740 -} # ac_fn_c_check_func 1741 - 1742 1682 # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES 1743 1683 # ------------------------------------------------------- 1744 1684 # Tests whether HEADER exists, giving a warning if it cannot be compiled using 1745 1685 # the include files in INCLUDES and setting the cache variable VAR 1746 1686 # accordingly. 1747 1687 ac_fn_c_check_header_mongrel () 1748 1688 { ................................................................................ 1821 1761 eval ac_res=\$$3 1822 1762 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1823 1763 $as_echo "$ac_res" >&6; } 1824 1764 fi 1825 1765 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1826 1766 1827 1767 } # ac_fn_c_check_header_mongrel 1768 + 1769 +# ac_fn_c_check_func LINENO FUNC VAR 1770 +# ---------------------------------- 1771 +# Tests whether FUNC exists, setting the cache variable VAR accordingly 1772 +ac_fn_c_check_func () 1773 +{ 1774 + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack 1775 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 1776 +$as_echo_n "checking for $2... " >&6; } 1777 +if eval \${$3+:} false; then : 1778 + $as_echo_n "(cached) " >&6 1779 +else 1780 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1781 +/* end confdefs.h. */ 1782 +/* Define $2 to an innocuous variant, in case <limits.h> declares $2. 1783 + For example, HP-UX 11i <limits.h> declares gettimeofday. */ 1784 +#define $2 innocuous_$2 1785 + 1786 +/* System header to define __stub macros and hopefully few prototypes, 1787 + which can conflict with char $2 (); below. 1788 + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 1789 + <limits.h> exists even on freestanding compilers. */ 1790 + 1791 +#ifdef __STDC__ 1792 +# include <limits.h> 1793 +#else 1794 +# include <assert.h> 1795 +#endif 1796 + 1797 +#undef $2 1798 + 1799 +/* Override any GCC internal prototype to avoid an error. 1800 + Use char because int might match the return type of a GCC 1801 + builtin and then its argument prototype would still apply. */ 1802 +#ifdef __cplusplus 1803 +extern "C" 1804 +#endif 1805 +char $2 (); 1806 +/* The GNU C library defines this for functions which it implements 1807 + to always fail with ENOSYS. Some functions are actually named 1808 + something starting with __ and the normal name is an alias. */ 1809 +#if defined __stub_$2 || defined __stub___$2 1810 +choke me 1811 +#endif 1812 + 1813 +int 1814 +main () 1815 +{ 1816 +return $2 (); 1817 + ; 1818 + return 0; 1819 +} 1820 +_ACEOF 1821 +if ac_fn_c_try_link "$LINENO"; then : 1822 + eval "$3=yes" 1823 +else 1824 + eval "$3=no" 1825 +fi 1826 +rm -f core conftest.err conftest.$ac_objext \ 1827 + conftest$ac_exeext conftest.$ac_ext 1828 +fi 1829 +eval ac_res=\$$3 1830 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 1831 +$as_echo "$ac_res" >&6; } 1832 + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1833 + 1834 +} # ac_fn_c_check_func 1828 1835 cat >config.log <<_ACEOF 1829 1836 This file contains any messages produced by compilers while 1830 1837 running configure, to aid debugging if configure makes a mistake. 1831 1838 1832 1839 It was created by tnc $as_me 0.3.0, which was 1833 1840 generated by GNU Autoconf 2.69. Invocation command line was 1834 1841 ................................................................................ 2181 2188 #-------------------------------------------------------------------- 2182 2189 # Call TEA_INIT as the first TEA_ macro to set up initial vars. 2183 2190 # This will define a ${TEA_PLATFORM} variable == "unix" or "windows" 2184 2191 # as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE. 2185 2192 #-------------------------------------------------------------------- 2186 2193 2187 2194 2188 - # TEA extensions pass this us the version of TEA they think they 2189 - # are compatible with. 2190 - TEA_VERSION="3.10" 2195 + TEA_VERSION="3.13" 2191 2196 2192 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for correct TEA configuration" >&5 2193 -$as_echo_n "checking for correct TEA configuration... " >&6; } 2197 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking TEA configuration" >&5 2198 +$as_echo_n "checking TEA configuration... " >&6; } 2194 2199 if test x"${PACKAGE_NAME}" = x ; then 2195 2200 as_fn_error $? " 2196 2201 The PACKAGE_NAME variable must be defined by your TEA configure.ac" "$LINENO" 5 2197 2202 fi 2198 - if test x"3.10" = x ; then 2199 - as_fn_error $? " 2200 -TEA version not specified." "$LINENO" 5 2201 - elif test "3.10" != "${TEA_VERSION}" ; then 2202 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: warning: requested TEA version \"3.10\", have \"${TEA_VERSION}\"" >&5 2203 -$as_echo "warning: requested TEA version \"3.10\", have \"${TEA_VERSION}\"" >&6; } 2204 - else 2205 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok (TEA ${TEA_VERSION})" >&5 2203 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok (TEA ${TEA_VERSION})" >&5 2206 2204 $as_echo "ok (TEA ${TEA_VERSION})" >&6; } 2207 - fi 2208 2205 2209 2206 # If the user did not set CFLAGS, set it now to keep macros 2210 2207 # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2". 2211 2208 if test "${CFLAGS+set}" != "set" ; then 2212 2209 CFLAGS="" 2213 2210 fi 2214 2211 2215 2212 case "`uname -s`" in 2216 - *win32*|*WIN32*|*MINGW32_*) 2213 + *win32*|*WIN32*|*MINGW32_*|*MINGW64_*|*MSYS_*) 2217 2214 # Extract the first word of "cygpath", so it can be a program name with args. 2218 2215 set dummy cygpath; ac_word=$2 2219 2216 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 2220 2217 $as_echo_n "checking for $ac_word... " >&6; } 2221 2218 if ${ac_cv_prog_CYGPATH+:} false; then : 2222 2219 $as_echo_n "(cached) " >&6 2223 2220 else ................................................................................ 2293 2290 # This package name must be replaced statically for AC_SUBST to work 2294 2291 2295 2292 # Substitute STUB_LIB_FILE in case package creates a stub library too. 2296 2293 2297 2294 2298 2295 # We AC_SUBST these here to ensure they are subst'ed, 2299 2296 # in case the user doesn't call TEA_ADD_... 2297 + 2298 + 2299 + 2300 + 2301 + 2302 + 2303 + 2304 + 2305 + # Configure the installer. 2306 + 2307 + INSTALL='$(SHELL) $(srcdir)/tclconfig/install-sh -c' 2308 + INSTALL_DATA_DIR='${INSTALL} -d -m 755' 2309 + INSTALL_DATA='${INSTALL} -m 644' 2310 + INSTALL_PROGRAM='${INSTALL} -m 755' 2311 + INSTALL_SCRIPT='${INSTALL} -m 755' 2312 + 2313 + 2314 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 2315 +$as_echo_n "checking system version... " >&6; } 2316 +if ${tcl_cv_sys_version+:} false; then : 2317 + $as_echo_n "(cached) " >&6 2318 +else 2319 + 2320 + # TEA specific: 2321 + if test "${TEA_PLATFORM}" = "windows" ; then 2322 + tcl_cv_sys_version=windows 2323 + else 2324 + tcl_cv_sys_version=`uname -s`-`uname -r` 2325 + if test "$?" -ne 0 ; then 2326 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 2327 +$as_echo "$as_me: WARNING: can't find uname command" >&2;} 2328 + tcl_cv_sys_version=unknown 2329 + else 2330 + if test "`uname -s`" = "AIX" ; then 2331 + tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 2332 + fi 2333 + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then 2334 + tcl_cv_sys_version=NetBSD-Debian 2335 + fi 2336 + fi 2337 + fi 2338 + 2339 +fi 2340 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 2341 +$as_echo "$tcl_cv_sys_version" >&6; } 2342 + system=$tcl_cv_sys_version 2343 + 2344 + case $system in 2345 + HP-UX-*) INSTALL_LIBRARY='${INSTALL} -m 755' ;; 2346 + *) INSTALL_LIBRARY='${INSTALL} -m 644' ;; 2347 + esac 2348 + 2300 2349 2301 2350 2302 2351 2303 2352 2304 2353 2305 2354 2306 2355 ................................................................................ 2409 2458 fi 2410 2459 2411 2460 # on Darwin, check in Framework installation locations 2412 2461 if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then 2413 2462 for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ 2414 2463 `ls -d /Library/Frameworks 2>/dev/null` \ 2415 2464 `ls -d /Network/Library/Frameworks 2>/dev/null` \ 2416 - `ls -d /System/Library/Frameworks 2>/dev/null` \ 2465 + `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2466 + `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Network/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2467 + `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework 2>/dev/null` \ 2417 2468 ; do 2418 2469 if test -f "$i/Tcl.framework/tclConfig.sh" ; then 2419 2470 ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" 2420 2471 break 2421 2472 fi 2422 2473 done 2423 2474 fi ................................................................................ 2436 2487 fi 2437 2488 2438 2489 # check in a few common install locations 2439 2490 if test x"${ac_cv_c_tclconfig}" = x ; then 2440 2491 for i in `ls -d ${libdir} 2>/dev/null` \ 2441 2492 `ls -d ${exec_prefix}/lib 2>/dev/null` \ 2442 2493 `ls -d ${prefix}/lib 2>/dev/null` \ 2443 - `ls -d /usr/contrib/lib 2>/dev/null` \ 2444 2494 `ls -d /usr/local/lib 2>/dev/null` \ 2495 + `ls -d /usr/contrib/lib 2>/dev/null` \ 2445 2496 `ls -d /usr/pkg/lib 2>/dev/null` \ 2446 2497 `ls -d /usr/lib 2>/dev/null` \ 2447 2498 `ls -d /usr/lib64 2>/dev/null` \ 2448 2499 `ls -d /usr/lib/tcl8.6 2>/dev/null` \ 2449 2500 `ls -d /usr/lib/tcl8.5 2>/dev/null` \ 2501 + `ls -d /usr/local/lib/tcl8.6 2>/dev/null` \ 2502 + `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \ 2503 + `ls -d /usr/local/lib/tcl/tcl8.6 2>/dev/null` \ 2504 + `ls -d /usr/local/lib/tcl/tcl8.5 2>/dev/null` \ 2450 2505 ; do 2451 2506 if test -f "$i/tclConfig.sh" ; then 2452 2507 ac_cv_c_tclconfig="`(cd $i; pwd)`" 2453 2508 break 2454 2509 fi 2455 2510 done 2456 2511 fi ................................................................................ 3287 3342 $as_echo "loading" >&6; } 3288 3343 . "${TCL_BIN_DIR}/tclConfig.sh" 3289 3344 else 3290 3345 { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5 3291 3346 $as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; } 3292 3347 fi 3293 3348 3294 - # eval is required to do the TCL_DBGX substitution 3295 - eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" 3296 - eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" 3297 - 3298 3349 # If the TCL_BIN_DIR is the build directory (not the install directory), 3299 3350 # then set the common variable name to the value of the build variables. 3300 3351 # For example, the variable TCL_LIB_SPEC will be set to the value 3301 3352 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC 3302 3353 # instead of TCL_BUILD_LIB_SPEC since it will work with both an 3303 3354 # installed and uninstalled version of Tcl. 3304 3355 if test -f "${TCL_BIN_DIR}/Makefile" ; then ................................................................................ 3324 3375 TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}" 3325 3376 TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}" 3326 3377 fi 3327 3378 ;; 3328 3379 esac 3329 3380 fi 3330 3381 3331 - # eval is required to do the TCL_DBGX substitution 3332 - eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" 3333 - eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" 3334 - eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" 3335 - eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" 3336 - 3337 3382 3338 3383 3339 3384 3340 3385 3341 3386 3342 3387 3343 3388 ................................................................................ 3363 3408 3364 3409 ; 3365 3410 return 0; 3366 3411 } 3367 3412 _ACEOF 3368 3413 if ac_fn_c_try_compile "$LINENO"; then : 3369 3414 3370 - TEA_PLATFORM="unix" 3415 + # first test we've already retrieved platform (cross-compile), fallback to unix otherwise: 3416 + TEA_PLATFORM="${TEA_PLATFORM-unix}" 3371 3417 CYGPATH=echo 3372 3418 3373 3419 else 3374 3420 3375 3421 TEA_PLATFORM="windows" 3376 3422 # Extract the first word of "cygpath", so it can be a program name with args. 3377 3423 set dummy cygpath; ac_word=$2 ................................................................................ 4162 4208 4163 4209 ac_ext=c 4164 4210 ac_cpp='$CPP $CPPFLAGS' 4165 4211 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 4166 4212 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' 4167 4213 ac_compiler_gnu=$ac_cv_c_compiler_gnu 4168 4214 4169 - 4170 - INSTALL='$(SHELL) $(srcdir)/tclconfig/install-sh -c' 4171 - INSTALL_DATA_DIR='${INSTALL} -d -m 755' 4172 - INSTALL_DATA='${INSTALL} -m 644' 4173 - INSTALL_PROGRAM='${INSTALL}' 4174 - INSTALL_SCRIPT='${INSTALL}' 4175 - INSTALL_LIBRARY='${INSTALL_DATA}' 4176 - 4177 - 4178 - 4179 - 4180 - 4181 - 4182 - 4183 4215 4184 4216 #-------------------------------------------------------------------- 4185 4217 # Checks to see if the make program sets the $MAKE variable. 4186 4218 #-------------------------------------------------------------------- 4187 4219 4188 4220 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 4189 4221 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } ................................................................................ 4848 4880 4849 4881 ;; #( 4850 4882 *) 4851 4883 as_fn_error $? "unknown endianness 4852 4884 presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; 4853 4885 esac 4854 4886 4855 - if test "${TEA_PLATFORM}" = "unix" ; then 4856 - 4857 - #-------------------------------------------------------------------- 4858 - # On a few very rare systems, all of the libm.a stuff is 4859 - # already in libc.a. Set compiler flags accordingly. 4860 - # Also, Linux requires the "ieee" library for math to work 4861 - # right (and it must appear before "-lm"). 4862 - #-------------------------------------------------------------------- 4863 - 4864 - ac_fn_c_check_func "$LINENO" "sin" "ac_cv_func_sin" 4865 -if test "x$ac_cv_func_sin" = xyes; then : 4866 - MATH_LIBS="" 4867 -else 4868 - MATH_LIBS="-lm" 4869 -fi 4870 - 4871 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lieee" >&5 4872 -$as_echo_n "checking for main in -lieee... " >&6; } 4873 -if ${ac_cv_lib_ieee_main+:} false; then : 4874 - $as_echo_n "(cached) " >&6 4875 -else 4876 - ac_check_lib_save_LIBS=$LIBS 4877 -LIBS="-lieee $LIBS" 4878 -cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4879 -/* end confdefs.h. */ 4880 - 4881 - 4882 -int 4883 -main () 4884 -{ 4885 -return main (); 4886 - ; 4887 - return 0; 4888 -} 4889 -_ACEOF 4890 -if ac_fn_c_try_link "$LINENO"; then : 4891 - ac_cv_lib_ieee_main=yes 4892 -else 4893 - ac_cv_lib_ieee_main=no 4894 -fi 4895 -rm -f core conftest.err conftest.$ac_objext \ 4896 - conftest$ac_exeext conftest.$ac_ext 4897 -LIBS=$ac_check_lib_save_LIBS 4898 -fi 4899 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ieee_main" >&5 4900 -$as_echo "$ac_cv_lib_ieee_main" >&6; } 4901 -if test "x$ac_cv_lib_ieee_main" = xyes; then : 4902 - MATH_LIBS="-lieee $MATH_LIBS" 4903 -fi 4904 - 4905 - 4906 - #-------------------------------------------------------------------- 4907 - # Interactive UNIX requires -linet instead of -lsocket, plus it 4908 - # needs net/errno.h to define the socket-related error codes. 4909 - #-------------------------------------------------------------------- 4910 - 4911 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -linet" >&5 4912 -$as_echo_n "checking for main in -linet... " >&6; } 4913 -if ${ac_cv_lib_inet_main+:} false; then : 4914 - $as_echo_n "(cached) " >&6 4915 -else 4916 - ac_check_lib_save_LIBS=$LIBS 4917 -LIBS="-linet $LIBS" 4918 -cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4919 -/* end confdefs.h. */ 4920 - 4921 - 4922 -int 4923 -main () 4924 -{ 4925 -return main (); 4926 - ; 4927 - return 0; 4928 -} 4929 -_ACEOF 4930 -if ac_fn_c_try_link "$LINENO"; then : 4931 - ac_cv_lib_inet_main=yes 4932 -else 4933 - ac_cv_lib_inet_main=no 4934 -fi 4935 -rm -f core conftest.err conftest.$ac_objext \ 4936 - conftest$ac_exeext conftest.$ac_ext 4937 -LIBS=$ac_check_lib_save_LIBS 4938 -fi 4939 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_inet_main" >&5 4940 -$as_echo "$ac_cv_lib_inet_main" >&6; } 4941 -if test "x$ac_cv_lib_inet_main" = xyes; then : 4942 - LIBS="$LIBS -linet" 4943 -fi 4944 - 4945 - ac_fn_c_check_header_mongrel "$LINENO" "net/errno.h" "ac_cv_header_net_errno_h" "$ac_includes_default" 4946 -if test "x$ac_cv_header_net_errno_h" = xyes; then : 4947 - 4948 - 4949 -$as_echo "#define HAVE_NET_ERRNO_H 1" >>confdefs.h 4950 - 4951 -fi 4952 - 4953 - 4954 - 4955 - #-------------------------------------------------------------------- 4956 - # Check for the existence of the -lsocket and -lnsl libraries. 4957 - # The order here is important, so that they end up in the right 4958 - # order in the command line generated by make. Here are some 4959 - # special considerations: 4960 - # 1. Use "connect" and "accept" to check for -lsocket, and 4961 - # "gethostbyname" to check for -lnsl. 4962 - # 2. Use each function name only once: can't redo a check because 4963 - # autoconf caches the results of the last check and won't redo it. 4964 - # 3. Use -lnsl and -lsocket only if they supply procedures that 4965 - # aren't already present in the normal libraries. This is because 4966 - # IRIX 5.2 has libraries, but they aren't needed and they're 4967 - # bogus: they goof up name resolution if used. 4968 - # 4. On some SVR4 systems, can't use -lsocket without -lnsl too. 4969 - # To get around this problem, check for both libraries together 4970 - # if -lsocket doesn't work by itself. 4971 - #-------------------------------------------------------------------- 4972 - 4973 - tcl_checkBoth=0 4974 - ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" 4975 -if test "x$ac_cv_func_connect" = xyes; then : 4976 - tcl_checkSocket=0 4977 -else 4978 - tcl_checkSocket=1 4979 -fi 4980 - 4981 - if test "$tcl_checkSocket" = 1; then 4982 - ac_fn_c_check_func "$LINENO" "setsockopt" "ac_cv_func_setsockopt" 4983 -if test "x$ac_cv_func_setsockopt" = xyes; then : 4984 - 4985 -else 4986 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for setsockopt in -lsocket" >&5 4987 -$as_echo_n "checking for setsockopt in -lsocket... " >&6; } 4988 -if ${ac_cv_lib_socket_setsockopt+:} false; then : 4989 - $as_echo_n "(cached) " >&6 4990 -else 4991 - ac_check_lib_save_LIBS=$LIBS 4992 -LIBS="-lsocket $LIBS" 4993 -cat confdefs.h - <<_ACEOF >conftest.$ac_ext 4994 -/* end confdefs.h. */ 4995 - 4996 -/* Override any GCC internal prototype to avoid an error. 4997 - Use char because int might match the return type of a GCC 4998 - builtin and then its argument prototype would still apply. */ 4999 -#ifdef __cplusplus 5000 -extern "C" 5001 -#endif 5002 -char setsockopt (); 5003 -int 5004 -main () 5005 -{ 5006 -return setsockopt (); 5007 - ; 5008 - return 0; 5009 -} 5010 -_ACEOF 5011 -if ac_fn_c_try_link "$LINENO"; then : 5012 - ac_cv_lib_socket_setsockopt=yes 5013 -else 5014 - ac_cv_lib_socket_setsockopt=no 5015 -fi 5016 -rm -f core conftest.err conftest.$ac_objext \ 5017 - conftest$ac_exeext conftest.$ac_ext 5018 -LIBS=$ac_check_lib_save_LIBS 5019 -fi 5020 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_setsockopt" >&5 5021 -$as_echo "$ac_cv_lib_socket_setsockopt" >&6; } 5022 -if test "x$ac_cv_lib_socket_setsockopt" = xyes; then : 5023 - LIBS="$LIBS -lsocket" 5024 -else 5025 - tcl_checkBoth=1 5026 -fi 5027 - 5028 -fi 5029 - 5030 - fi 5031 - if test "$tcl_checkBoth" = 1; then 5032 - tk_oldLibs=$LIBS 5033 - LIBS="$LIBS -lsocket -lnsl" 5034 - ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept" 5035 -if test "x$ac_cv_func_accept" = xyes; then : 5036 - tcl_checkNsl=0 5037 -else 5038 - LIBS=$tk_oldLibs 5039 -fi 5040 - 5041 - fi 5042 - ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" 5043 -if test "x$ac_cv_func_gethostbyname" = xyes; then : 5044 - 5045 -else 5046 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 5047 -$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } 5048 -if ${ac_cv_lib_nsl_gethostbyname+:} false; then : 5049 - $as_echo_n "(cached) " >&6 5050 -else 5051 - ac_check_lib_save_LIBS=$LIBS 5052 -LIBS="-lnsl $LIBS" 5053 -cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5054 -/* end confdefs.h. */ 5055 - 5056 -/* Override any GCC internal prototype to avoid an error. 5057 - Use char because int might match the return type of a GCC 5058 - builtin and then its argument prototype would still apply. */ 5059 -#ifdef __cplusplus 5060 -extern "C" 5061 -#endif 5062 -char gethostbyname (); 5063 -int 5064 -main () 5065 -{ 5066 -return gethostbyname (); 5067 - ; 5068 - return 0; 5069 -} 5070 -_ACEOF 5071 -if ac_fn_c_try_link "$LINENO"; then : 5072 - ac_cv_lib_nsl_gethostbyname=yes 5073 -else 5074 - ac_cv_lib_nsl_gethostbyname=no 5075 -fi 5076 -rm -f core conftest.err conftest.$ac_objext \ 5077 - conftest$ac_exeext conftest.$ac_ext 5078 -LIBS=$ac_check_lib_save_LIBS 5079 -fi 5080 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 5081 -$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } 5082 -if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : 5083 - LIBS="$LIBS -lnsl" 5084 -fi 5085 - 5086 -fi 5087 - 5088 - 5089 - # TEA specific: Don't perform the eval of the libraries here because 5090 - # DL_LIBS won't be set until we call TEA_CONFIG_CFLAGS 5091 - 5092 - TCL_LIBS='${DL_LIBS} ${LIBS} ${MATH_LIBS}' 5093 - 5094 - 5095 - 5096 - 5097 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dirent.h" >&5 5098 -$as_echo_n "checking dirent.h... " >&6; } 5099 -if ${tcl_cv_dirent_h+:} false; then : 5100 - $as_echo_n "(cached) " >&6 5101 -else 5102 - 5103 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5104 -/* end confdefs.h. */ 5105 -#include <sys/types.h> 5106 -#include <dirent.h> 5107 -int 5108 -main () 5109 -{ 5110 - 5111 -#ifndef _POSIX_SOURCE 5112 -# ifdef __Lynx__ 5113 - /* 5114 - * Generate compilation error to make the test fail: Lynx headers 5115 - * are only valid if really in the POSIX environment. 5116 - */ 5117 - 5118 - missing_procedure(); 5119 -# endif 5120 -#endif 5121 -DIR *d; 5122 -struct dirent *entryPtr; 5123 -char *p; 5124 -d = opendir("foobar"); 5125 -entryPtr = readdir(d); 5126 -p = entryPtr->d_name; 5127 -closedir(d); 5128 - 5129 - ; 5130 - return 0; 5131 -} 5132 -_ACEOF 5133 -if ac_fn_c_try_link "$LINENO"; then : 5134 - tcl_cv_dirent_h=yes 5135 -else 5136 - tcl_cv_dirent_h=no 5137 -fi 5138 -rm -f core conftest.err conftest.$ac_objext \ 5139 - conftest$ac_exeext conftest.$ac_ext 5140 -fi 5141 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_dirent_h" >&5 5142 -$as_echo "$tcl_cv_dirent_h" >&6; } 5143 - 5144 - if test $tcl_cv_dirent_h = no; then 5145 - 5146 -$as_echo "#define NO_DIRENT_H 1" >>confdefs.h 5147 - 5148 - fi 5149 - 5150 - # TEA specific: 5151 - ac_fn_c_check_header_mongrel "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default" 5152 -if test "x$ac_cv_header_errno_h" = xyes; then : 5153 - 5154 -else 5155 - 5156 -$as_echo "#define NO_ERRNO_H 1" >>confdefs.h 5157 - 5158 -fi 5159 - 5160 - 5161 - ac_fn_c_check_header_mongrel "$LINENO" "float.h" "ac_cv_header_float_h" "$ac_includes_default" 5162 -if test "x$ac_cv_header_float_h" = xyes; then : 5163 - 5164 -else 5165 - 5166 -$as_echo "#define NO_FLOAT_H 1" >>confdefs.h 5167 - 5168 -fi 5169 - 5170 - 5171 - ac_fn_c_check_header_mongrel "$LINENO" "values.h" "ac_cv_header_values_h" "$ac_includes_default" 5172 -if test "x$ac_cv_header_values_h" = xyes; then : 5173 - 5174 -else 5175 - 5176 -$as_echo "#define NO_VALUES_H 1" >>confdefs.h 5177 - 5178 -fi 5179 - 5180 - 5181 - ac_fn_c_check_header_mongrel "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" 5182 -if test "x$ac_cv_header_limits_h" = xyes; then : 5183 - 5184 -$as_echo "#define HAVE_LIMITS_H 1" >>confdefs.h 5185 - 5186 -else 5187 - 5188 -$as_echo "#define NO_LIMITS_H 1" >>confdefs.h 5189 - 5190 -fi 5191 - 5192 - 5193 - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" 5194 -if test "x$ac_cv_header_stdlib_h" = xyes; then : 5195 - tcl_ok=1 5196 -else 5197 - tcl_ok=0 5198 -fi 5199 - 5200 - 5201 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5202 -/* end confdefs.h. */ 5203 -#include <stdlib.h> 5204 - 5205 -_ACEOF 5206 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 5207 - $EGREP "strtol" >/dev/null 2>&1; then : 5208 - 5209 -else 5210 - tcl_ok=0 5211 -fi 5212 -rm -f conftest* 5213 - 5214 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5215 -/* end confdefs.h. */ 5216 -#include <stdlib.h> 5217 - 5218 -_ACEOF 5219 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 5220 - $EGREP "strtoul" >/dev/null 2>&1; then : 5221 - 5222 -else 5223 - tcl_ok=0 5224 -fi 5225 -rm -f conftest* 5226 - 5227 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5228 -/* end confdefs.h. */ 5229 -#include <stdlib.h> 5230 - 5231 -_ACEOF 5232 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 5233 - $EGREP "strtod" >/dev/null 2>&1; then : 5234 - 5235 -else 5236 - tcl_ok=0 5237 -fi 5238 -rm -f conftest* 5239 - 5240 - if test $tcl_ok = 0; then 5241 - 5242 -$as_echo "#define NO_STDLIB_H 1" >>confdefs.h 5243 - 5244 - fi 5245 - ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" 5246 -if test "x$ac_cv_header_string_h" = xyes; then : 5247 - tcl_ok=1 5248 -else 5249 - tcl_ok=0 5250 -fi 5251 - 5252 - 5253 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5254 -/* end confdefs.h. */ 5255 -#include <string.h> 5256 - 5257 -_ACEOF 5258 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 5259 - $EGREP "strstr" >/dev/null 2>&1; then : 5260 - 5261 -else 5262 - tcl_ok=0 5263 -fi 5264 -rm -f conftest* 5265 - 5266 - cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5267 -/* end confdefs.h. */ 5268 -#include <string.h> 5269 - 5270 -_ACEOF 5271 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | 5272 - $EGREP "strerror" >/dev/null 2>&1; then : 5273 - 5274 -else 5275 - tcl_ok=0 5276 -fi 5277 -rm -f conftest* 5278 - 5279 - 5280 - # See also memmove check below for a place where NO_STRING_H can be 5281 - # set and why. 5282 - 5283 - if test $tcl_ok = 0; then 5284 - 5285 -$as_echo "#define NO_STRING_H 1" >>confdefs.h 5286 - 5287 - fi 5288 - 5289 - ac_fn_c_check_header_mongrel "$LINENO" "sys/wait.h" "ac_cv_header_sys_wait_h" "$ac_includes_default" 5290 -if test "x$ac_cv_header_sys_wait_h" = xyes; then : 5291 - 5292 -else 5293 - 5294 -$as_echo "#define NO_SYS_WAIT_H 1" >>confdefs.h 5295 - 5296 -fi 5297 - 5298 - 5299 - ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" 5300 -if test "x$ac_cv_header_dlfcn_h" = xyes; then : 5301 - 5302 -else 5303 - 5304 -$as_echo "#define NO_DLFCN_H 1" >>confdefs.h 5305 - 5306 -fi 5307 - 5308 - 5309 - 5310 - # OS/390 lacks sys/param.h (and doesn't need it, by chance). 5311 - for ac_header in sys/param.h 5312 -do : 5313 - ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" 5314 -if test "x$ac_cv_header_sys_param_h" = xyes; then : 5315 - cat >>confdefs.h <<_ACEOF 5316 -#define HAVE_SYS_PARAM_H 1 5317 -_ACEOF 5318 - 5319 -fi 5320 - 5321 -done 5322 - 5323 - 5324 - # Let the user call this, because if it triggers, they will 5325 - # need a compat/strtod.c that is correct. Users can also 5326 - # use Tcl_GetDouble(FromObj) instead. 5327 - #TEA_BUGGY_STRTOD 5328 - fi 5329 4887 5330 4888 5331 4889 #-------------------------------------------------------------------- 5332 4890 # Load the tdomConfig.sh file 5333 4891 #-------------------------------------------------------------------- 5334 4892 5335 4893 ................................................................................ 5499 5057 5500 5058 5501 5059 5502 5060 vars="${TDOM_STUB_LIB_SPEC}" 5503 5061 for i in $vars; do 5504 5062 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 5505 5063 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 5506 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 5064 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 5507 5065 fi 5508 5066 PKG_LIBS="$PKG_LIBS $i" 5509 5067 done 5510 5068 5511 5069 5512 5070 5513 5071 PKG_CFLAGS="$PKG_CFLAGS -DUSE_TDOM_STUBS=1" ................................................................................ 5981 5539 Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 5982 5540 that IS thread-enabled. It is recommended to use --enable-threads." >&5 5983 5541 $as_echo "$as_me: WARNING: 5984 5542 Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 5985 5543 that IS thread-enabled. It is recommended to use --enable-threads." >&2;} 5986 5544 fi 5987 5545 ;; 5988 - *) 5989 - if test "${TCL_THREADS}" = "1"; then 5990 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 5991 - --enable-threads requested, but building against a Tcl that is NOT 5992 - thread-enabled. This is an OK configuration that will also run in 5993 - a thread-enabled core." >&5 5994 -$as_echo "$as_me: WARNING: 5995 - --enable-threads requested, but building against a Tcl that is NOT 5996 - thread-enabled. This is an OK configuration that will also run in 5997 - a thread-enabled core." >&2;} 5998 - fi 5999 - ;; 6000 5546 esac 6001 5547 6002 5548 6003 5549 6004 5550 #-------------------------------------------------------------------- 6005 5551 # The statement below defines a collection of symbols related to 6006 5552 # building as a shared library instead of a static library. ................................................................................ 6264 5810 else 6265 5811 doRpath=yes 6266 5812 fi 6267 5813 6268 5814 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doRpath" >&5 6269 5815 $as_echo "$doRpath" >&6; } 6270 5816 6271 - # TEA specific: Cross-compiling options for Windows/CE builds? 6272 - 6273 - if test "${TEA_PLATFORM}" = windows; then : 6274 - 6275 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Windows/CE build is requested" >&5 6276 -$as_echo_n "checking if Windows/CE build is requested... " >&6; } 6277 - # Check whether --enable-wince was given. 6278 -if test "${enable_wince+set}" = set; then : 6279 - enableval=$enable_wince; doWince=$enableval 6280 -else 6281 - doWince=no 6282 -fi 6283 - 6284 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $doWince" >&5 6285 -$as_echo "$doWince" >&6; } 6286 - 6287 -fi 6288 - 6289 5817 # Set the variable "system" to hold the name and version number 6290 5818 # for the system. 6291 5819 6292 5820 6293 5821 { $as_echo "$as_me:${as_lineno-$LINENO}: checking system version" >&5 6294 5822 $as_echo_n "checking system version... " >&6; } 6295 5823 if ${tcl_cv_sys_version+:} false; then : ................................................................................ 6304 5832 if test "$?" -ne 0 ; then 6305 5833 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find uname command" >&5 6306 5834 $as_echo "$as_me: WARNING: can't find uname command" >&2;} 6307 5835 tcl_cv_sys_version=unknown 6308 5836 else 6309 5837 if test "`uname -s`" = "AIX" ; then 6310 5838 tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 5839 + fi 5840 + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then 5841 + tcl_cv_sys_version=NetBSD-Debian 6311 5842 fi 6312 5843 fi 6313 5844 fi 6314 5845 6315 5846 fi 6316 5847 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_sys_version" >&5 6317 5848 $as_echo "$tcl_cv_sys_version" >&6; } ................................................................................ 6448 5979 SHLIB_VERSION="" 6449 5980 else 6450 5981 SHLIB_VERSION=".$SHLIB_VERSION" 6451 5982 fi 6452 5983 case $system in 6453 5984 # TEA specific: 6454 5985 windows) 6455 - # This is a 2-stage check to make sure we have the 64-bit SDK 6456 - # We have to know where the SDK is installed. 6457 - # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs 6458 - # MACHINE is IX86 for LINK, but this is used by the manifest, 6459 - # which requires x86|amd64|ia64. 6460 5986 MACHINE="X86" 6461 5987 if test "$do64bit" != "no" ; then 6462 - if test "x${MSSDK}x" = "xx" ; then 6463 - MSSDK="C:/Progra~1/Microsoft Platform SDK" 6464 - fi 6465 - MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'` 6466 - PATH64="" 6467 5988 case "$do64bit" in 6468 5989 amd64|x64|yes) 6469 5990 MACHINE="AMD64" ; # default to AMD64 64-bit build 6470 - PATH64="${MSSDK}/Bin/Win64/x86/AMD64" 6471 5991 ;; 6472 5992 ia64) 6473 5993 MACHINE="IA64" 6474 - PATH64="${MSSDK}/Bin/Win64" 6475 5994 ;; 6476 5995 esac 6477 - if test "$GCC" != "yes" -a ! -d "${PATH64}" ; then 6478 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&5 6479 -$as_echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&2;} 6480 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ensure latest Platform SDK is installed" >&5 6481 -$as_echo "$as_me: WARNING: Ensure latest Platform SDK is installed" >&2;} 6482 - do64bit="no" 6483 - else 6484 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using 64-bit $MACHINE mode" >&5 6485 -$as_echo " Using 64-bit $MACHINE mode" >&6; } 6486 - do64bit_ok="yes" 6487 - fi 6488 - fi 6489 - 6490 - if test "$doWince" != "no" ; then 6491 - if test "$do64bit" != "no" ; then 6492 - as_fn_error $? "Windows/CE and 64-bit builds incompatible" "$LINENO" 5 6493 - fi 6494 - if test "$GCC" = "yes" ; then 6495 - as_fn_error $? "Windows/CE and GCC builds incompatible" "$LINENO" 5 6496 - fi 6497 - 6498 - # First, look for one uninstalled. 6499 - # the alternative search directory is invoked by --with-celib 6500 - 6501 - if test x"${no_celib}" = x ; then 6502 - # we reset no_celib in case something fails here 6503 - no_celib=true 6504 - 6505 -# Check whether --with-celib was given. 6506 -if test "${with_celib+set}" = set; then : 6507 - withval=$with_celib; with_celibconfig=${withval} 6508 -fi 6509 - 6510 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Windows/CE celib directory" >&5 6511 -$as_echo_n "checking for Windows/CE celib directory... " >&6; } 6512 - if ${ac_cv_c_celibconfig+:} false; then : 6513 - $as_echo_n "(cached) " >&6 6514 -else 6515 - 6516 - # First check to see if --with-celibconfig was specified. 6517 - if test x"${with_celibconfig}" != x ; then 6518 - if test -d "${with_celibconfig}/inc" ; then 6519 - ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)` 6520 - else 6521 - as_fn_error $? "${with_celibconfig} directory doesn't contain inc directory" "$LINENO" 5 6522 - fi 6523 - fi 6524 - 6525 - # then check for a celib library 6526 - if test x"${ac_cv_c_celibconfig}" = x ; then 6527 - for i in \ 6528 - ../celib-palm-3.0 \ 6529 - ../celib \ 6530 - ../../celib-palm-3.0 \ 6531 - ../../celib \ 6532 - `ls -dr ../celib-*3.[0-9]* 2>/dev/null` \ 6533 - ${srcdir}/../celib-palm-3.0 \ 6534 - ${srcdir}/../celib \ 6535 - `ls -dr ${srcdir}/../celib-*3.[0-9]* 2>/dev/null` \ 6536 - ; do 6537 - if test -d "$i/inc" ; then 6538 - ac_cv_c_celibconfig=`(cd $i; pwd)` 6539 - break 6540 - fi 6541 - done 6542 - fi 6543 - 6544 -fi 6545 - 6546 - if test x"${ac_cv_c_celibconfig}" = x ; then 6547 - as_fn_error $? "Cannot find celib support library directory" "$LINENO" 5 6548 - else 6549 - no_celib= 6550 - CELIB_DIR=${ac_cv_c_celibconfig} 6551 - CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` 6552 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $CELIB_DIR" >&5 6553 -$as_echo "found $CELIB_DIR" >&6; } 6554 - fi 6555 - fi 6556 - 6557 - # Set defaults for common evc4/PPC2003 setup 6558 - # Currently Tcl requires 300+, possibly 420+ for sockets 6559 - CEVERSION=420; # could be 211 300 301 400 420 ... 6560 - TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... 6561 - ARCH=ARM; # could be ARM MIPS X86EM ... 6562 - PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" 6563 - if test "$doWince" != "yes"; then 6564 - # If !yes then the user specified something 6565 - # Reset ARCH to allow user to skip specifying it 6566 - ARCH= 6567 - eval `echo $doWince | awk -F, '{ \ 6568 - if (length($1)) { printf "CEVERSION=\"%s\"\n", $1; \ 6569 - if ($1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ 6570 - if (length($2)) { printf "TARGETCPU=\"%s\"\n", toupper($2) }; \ 6571 - if (length($3)) { printf "ARCH=\"%s\"\n", toupper($3) }; \ 6572 - if (length($4)) { printf "PLATFORM=\"%s\"\n", $4 }; \ 6573 - }'` 6574 - if test "x${ARCH}" = "x" ; then 6575 - ARCH=$TARGETCPU; 6576 - fi 6577 - fi 6578 - OSVERSION=WCE$CEVERSION; 6579 - if test "x${WCEROOT}" = "x" ; then 6580 - WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" 6581 - if test ! -d "${WCEROOT}" ; then 6582 - WCEROOT="C:/Program Files/Microsoft eMbedded Tools" 6583 - fi 6584 - fi 6585 - if test "x${SDKROOT}" = "x" ; then 6586 - SDKROOT="C:/Program Files/Windows CE Tools" 6587 - if test ! -d "${SDKROOT}" ; then 6588 - SDKROOT="C:/Windows CE Tools" 6589 - fi 6590 - fi 6591 - WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` 6592 - SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` 6593 - if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \ 6594 - -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then 6595 - as_fn_error $? "could not find PocketPC SDK or target compiler to enable WinCE mode $CEVERSION,$TARGETCPU,$ARCH,$PLATFORM" "$LINENO" 5 6596 - doWince="no" 6597 - else 6598 - # We could PATH_NOSPACE these, but that's not important, 6599 - # as long as we quote them when used. 6600 - CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" 6601 - if test -d "${CEINCLUDE}/${TARGETCPU}" ; then 6602 - CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" 6603 - fi 6604 - CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" 6605 - fi 6606 5996 fi 6607 5997 6608 5998 if test "$GCC" != "yes" ; then 6609 5999 if test "${SHARED_BUILD}" = "0" ; then 6610 6000 runtime=-MT 6611 6001 else 6612 6002 runtime=-MD ................................................................................ 6615 6005 x1[4-9]*) 6616 6006 lflags="${lflags} -nodefaultlib:libucrt.lib" 6617 6007 6618 6008 vars="ucrt.lib" 6619 6009 for i in $vars; do 6620 6010 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 6621 6011 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 6622 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 6012 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 6623 6013 fi 6624 6014 PKG_LIBS="$PKG_LIBS $i" 6625 6015 done 6626 6016 6627 6017 6628 6018 ;; 6629 6019 *) 6630 6020 ;; 6631 6021 esac 6632 6022 6633 6023 if test "$do64bit" != "no" ; then 6634 - # All this magic is necessary for the Win64 SDK RC1 - hobbs 6635 - CC="\"${PATH64}/cl.exe\"" 6636 - CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\"" 6637 - RC="\"${MSSDK}/bin/rc.exe\"" 6638 - lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\"" 6639 - LINKBIN="\"${PATH64}/link.exe\"" 6024 + CC="cl.exe" 6025 + RC="rc.exe" 6026 + lflags="${lflags} -nologo -MACHINE:${MACHINE} " 6027 + LINKBIN="link.exe" 6640 6028 CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d" 6641 6029 CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 6642 6030 # Avoid 'unresolved external symbol __security_cookie' 6643 6031 # errors, c.f. http://support.microsoft.com/?id=894573 6644 6032 6645 6033 vars="bufferoverflowU.lib" 6646 6034 for i in $vars; do 6647 6035 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 6648 6036 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 6649 - i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'` 6037 + i=`echo "$i" | sed -e 's/^\([^-].*\)\.[lL][iI][bB]$/-l\1/'` 6650 6038 fi 6651 6039 PKG_LIBS="$PKG_LIBS $i" 6652 6040 done 6653 6041 6654 6042 6655 - elif test "$doWince" != "no" ; then 6656 - CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" 6657 - if test "${TARGETCPU}" = "X86"; then 6658 - CC="\"${CEBINROOT}/cl.exe\"" 6659 - else 6660 - CC="\"${CEBINROOT}/cl${ARCH}.exe\"" 6661 - fi 6662 - CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" 6663 - RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" 6664 - arch=`echo ${ARCH} | awk '{print tolower($0)}'` 6665 - defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS" 6666 - if test "${SHARED_BUILD}" = "1" ; then 6667 - # Static CE builds require static celib as well 6668 - defs="${defs} _DLL" 6669 - fi 6670 - for i in $defs ; do 6671 - 6672 -cat >>confdefs.h <<_ACEOF 6673 -#define $i 1 6674 -_ACEOF 6675 - 6676 - done 6677 - 6678 -cat >>confdefs.h <<_ACEOF 6679 -#define _WIN32_WCE $CEVERSION 6680 -_ACEOF 6681 - 6682 - 6683 -cat >>confdefs.h <<_ACEOF 6684 -#define UNDER_CE $CEVERSION 6685 -_ACEOF 6686 - 6687 - CFLAGS_DEBUG="-nologo -Zi -Od" 6688 - CFLAGS_OPTIMIZE="-nologo -Ox" 6689 - lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` 6690 - lflags="${lflags} -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" 6691 - LINKBIN="\"${CEBINROOT}/link.exe\"" 6692 - 6693 6043 else 6694 6044 RC="rc" 6695 6045 lflags="${lflags} -nologo" 6696 6046 LINKBIN="link" 6697 6047 CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d" 6698 6048 CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 6699 6049 fi ................................................................................ 6829 6179 6830 6180 fi 6831 6181 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cross" >&5 6832 6182 $as_echo "$ac_cv_cross" >&6; } 6833 6183 if test "$ac_cv_cross" = "yes"; then 6834 6184 case "$do64bit" in 6835 6185 amd64|x64|yes) 6836 - CC="x86_64-w64-mingw32-gcc" 6186 + CC="x86_64-w64-mingw32-${CC}" 6837 6187 LD="x86_64-w64-mingw32-ld" 6838 6188 AR="x86_64-w64-mingw32-ar" 6839 6189 RANLIB="x86_64-w64-mingw32-ranlib" 6840 6190 RC="x86_64-w64-mingw32-windres" 6841 6191 ;; 6842 6192 *) 6843 - CC="i686-w64-mingw32-gcc" 6193 + CC="i686-w64-mingw32-${CC}" 6844 6194 LD="i686-w64-mingw32-ld" 6845 6195 AR="i686-w64-mingw32-ar" 6846 6196 RANLIB="i686-w64-mingw32-ranlib" 6847 6197 RC="i686-w64-mingw32-windres" 6848 6198 ;; 6849 6199 esac 6850 6200 fi ................................................................................ 6858 6208 # For information on what debugtype is most useful, see: 6859 6209 # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp 6860 6210 # and also 6861 6211 # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx 6862 6212 # This essentially turns it all on. 6863 6213 LDFLAGS_DEBUG="-debug -debugtype:cv" 6864 6214 LDFLAGS_OPTIMIZE="-release" 6865 - if test "$doWince" != "no" ; then 6866 - LDFLAGS_CONSOLE="-link ${lflags}" 6867 - LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} 6868 - else 6869 - LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 6870 - LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 6871 - fi 6215 + LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 6216 + LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 6872 6217 fi 6873 6218 6874 6219 SHLIB_SUFFIX=".dll" 6875 6220 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll' 6876 6221 6877 6222 TCL_LIB_VERSIONS_OK=nodots 6878 6223 ;; 6879 6224 AIX-*) 6880 - if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"; then : 6225 + if test "$GCC" != "yes"; then : 6881 6226 6882 6227 # AIX requires the _r compiler when gcc isn't being used 6883 6228 case "${CC}" in 6884 6229 *_r|*_r\ *) 6885 6230 # ok ... 6886 6231 ;; 6887 6232 *) ................................................................................ 6922 6267 6923 6268 if test "`uname -m`" = ia64; then : 6924 6269 6925 6270 # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC 6926 6271 SHLIB_LD="/usr/ccs/bin/ld -G -z text" 6927 6272 if test "$GCC" = yes; then : 6928 6273 6929 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 6274 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 6930 6275 6931 6276 else 6932 6277 6933 - CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}' 6278 + CC_SEARCH_FLAGS='"-R${LIB_RUNTIME_DIR}"' 6934 6279 6935 6280 fi 6936 - LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 6281 + LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 6937 6282 6938 6283 else 6939 6284 6940 6285 if test "$GCC" = yes; then : 6941 6286 6942 6287 SHLIB_LD='${CC} -shared -Wl,-bexpall' 6943 6288 ................................................................................ 6944 6289 else 6945 6290 6946 6291 SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry" 6947 6292 LDFLAGS="$LDFLAGS -brtl" 6948 6293 6949 6294 fi 6950 6295 SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}" 6951 - CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}' 6296 + CC_SEARCH_FLAGS='"-L${LIB_RUNTIME_DIR}"' 6952 6297 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 6953 6298 6954 6299 fi 6955 6300 ;; 6956 6301 BeOS*) 6957 6302 SHLIB_CFLAGS="-fPIC" 6958 6303 SHLIB_LD='${CC} -nostart' ................................................................................ 7000 6345 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_inet_ntoa" >&5 7001 6346 $as_echo "$ac_cv_lib_bind_inet_ntoa" >&6; } 7002 6347 if test "x$ac_cv_lib_bind_inet_ntoa" = xyes; then : 7003 6348 LIBS="$LIBS -lbind -lsocket" 7004 6349 fi 7005 6350 7006 6351 ;; 6352 + BSD/OS-2.1*|BSD/OS-3*) 6353 + SHLIB_CFLAGS="" 6354 + SHLIB_LD="shlicc -r" 6355 + SHLIB_SUFFIX=".so" 6356 + CC_SEARCH_FLAGS="" 6357 + LD_SEARCH_FLAGS="" 6358 + ;; 7007 6359 BSD/OS-4.*) 7008 6360 SHLIB_CFLAGS="-export-dynamic -fPIC" 7009 6361 SHLIB_LD='${CC} -shared' 7010 6362 SHLIB_SUFFIX=".so" 7011 6363 LDFLAGS="$LDFLAGS -export-dynamic" 7012 6364 CC_SEARCH_FLAGS="" 7013 6365 LD_SEARCH_FLAGS="" 7014 6366 ;; 7015 6367 CYGWIN_*) 7016 6368 SHLIB_CFLAGS="" 7017 6369 SHLIB_LD='${CC} -shared' 7018 - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a" 7019 6370 SHLIB_SUFFIX=".dll" 6371 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a" 7020 6372 EXEEXT=".exe" 7021 6373 do64bit_ok=yes 6374 + CC_SEARCH_FLAGS="" 6375 + LD_SEARCH_FLAGS="" 6376 + ;; 6377 + dgux*) 6378 + SHLIB_CFLAGS="-K PIC" 6379 + SHLIB_LD='${CC} -G' 6380 + SHLIB_LD_LIBS="" 6381 + SHLIB_SUFFIX=".so" 7022 6382 CC_SEARCH_FLAGS="" 7023 6383 LD_SEARCH_FLAGS="" 7024 6384 ;; 7025 6385 Haiku*) 7026 6386 LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 7027 6387 SHLIB_CFLAGS="-fPIC" 7028 6388 SHLIB_SUFFIX=".so" 7029 - SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}' 6389 + SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared' 7030 6390 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa in -lnetwork" >&5 7031 6391 $as_echo_n "checking for inet_ntoa in -lnetwork... " >&6; } 7032 6392 if ${ac_cv_lib_network_inet_ntoa+:} false; then : 7033 6393 $as_echo_n "(cached) " >&6 7034 6394 else 7035 6395 ac_check_lib_save_LIBS=$LIBS 7036 6396 LIBS="-lnetwork $LIBS" ................................................................................ 7076 6436 # TEA specific: Needed by Tcl, but not most extensions 7077 6437 #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?]) 7078 6438 #LIBS="$LIBS -lxnet" # Use the XOPEN network library 7079 6439 7080 6440 if test "`uname -m`" = ia64; then : 7081 6441 7082 6442 SHLIB_SUFFIX=".so" 7083 - # Use newer C++ library for C++ extensions 7084 - #if test "$GCC" != "yes" ; then 7085 - # CPPFLAGS="-AA" 7086 - #fi 7087 6443 7088 6444 else 7089 6445 7090 6446 SHLIB_SUFFIX=".sl" 7091 6447 7092 6448 fi 7093 6449 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 ................................................................................ 7130 6486 tcl_ok=yes 7131 6487 else 7132 6488 tcl_ok=no 7133 6489 fi 7134 6490 7135 6491 if test "$tcl_ok" = yes; then : 7136 6492 6493 + SHLIB_CFLAGS="+z" 6494 + SHLIB_LD="ld -b" 7137 6495 LDFLAGS="$LDFLAGS -Wl,-E" 7138 - CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.' 7139 - LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.' 6496 + CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."' 6497 + LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."' 7140 6498 LD_LIBRARY_PATH_VAR="SHLIB_PATH" 7141 6499 7142 6500 fi 7143 6501 if test "$GCC" = yes; then : 7144 6502 7145 6503 SHLIB_LD='${CC} -shared' 7146 6504 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7147 6505 7148 6506 else 7149 6507 7150 6508 CFLAGS="$CFLAGS -z" 7151 - # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc 7152 - #CFLAGS="$CFLAGS +DAportable" 7153 - SHLIB_CFLAGS="+z" 7154 - SHLIB_LD="ld -b" 7155 6509 7156 6510 fi 7157 6511 7158 6512 # Check to enable 64-bit flags for compiler/linker 7159 6513 if test "$do64bit" = "yes"; then : 7160 6514 7161 6515 if test "$GCC" = yes; then : ................................................................................ 7163 6517 case `${CC} -dumpmachine` in 7164 6518 hppa64*) 7165 6519 # 64-bit gcc in use. Fix flags for GNU ld. 7166 6520 do64bit_ok=yes 7167 6521 SHLIB_LD='${CC} -shared' 7168 6522 if test $doRpath = yes; then : 7169 6523 7170 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6524 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7171 6525 fi 7172 6526 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7173 6527 ;; 7174 6528 *) 7175 6529 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 64bit mode not supported with GCC on $system" >&5 7176 6530 $as_echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;} 7177 6531 ;; ................................................................................ 7182 6536 do64bit_ok=yes 7183 6537 CFLAGS="$CFLAGS +DD64" 7184 6538 LDFLAGS_ARCH="+DD64" 7185 6539 7186 6540 fi 7187 6541 7188 6542 fi ;; 6543 + HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*) 6544 + SHLIB_SUFFIX=".sl" 6545 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 6546 +$as_echo_n "checking for shl_load in -ldld... " >&6; } 6547 +if ${ac_cv_lib_dld_shl_load+:} false; then : 6548 + $as_echo_n "(cached) " >&6 6549 +else 6550 + ac_check_lib_save_LIBS=$LIBS 6551 +LIBS="-ldld $LIBS" 6552 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext 6553 +/* end confdefs.h. */ 6554 + 6555 +/* Override any GCC internal prototype to avoid an error. 6556 + Use char because int might match the return type of a GCC 6557 + builtin and then its argument prototype would still apply. */ 6558 +#ifdef __cplusplus 6559 +extern "C" 6560 +#endif 6561 +char shl_load (); 6562 +int 6563 +main () 6564 +{ 6565 +return shl_load (); 6566 + ; 6567 + return 0; 6568 +} 6569 +_ACEOF 6570 +if ac_fn_c_try_link "$LINENO"; then : 6571 + ac_cv_lib_dld_shl_load=yes 6572 +else 6573 + ac_cv_lib_dld_shl_load=no 6574 +fi 6575 +rm -f core conftest.err conftest.$ac_objext \ 6576 + conftest$ac_exeext conftest.$ac_ext 6577 +LIBS=$ac_check_lib_save_LIBS 6578 +fi 6579 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 6580 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } 6581 +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : 6582 + tcl_ok=yes 6583 +else 6584 + tcl_ok=no 6585 +fi 6586 + 6587 + if test "$tcl_ok" = yes; then : 6588 + 6589 + SHLIB_CFLAGS="+z" 6590 + SHLIB_LD="ld -b" 6591 + SHLIB_LD_LIBS="" 6592 + LDFLAGS="$LDFLAGS -Wl,-E" 6593 + CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."' 6594 + LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."' 6595 + LD_LIBRARY_PATH_VAR="SHLIB_PATH" 6596 + 6597 +fi ;; 6598 + IRIX-5.*) 6599 + SHLIB_CFLAGS="" 6600 + SHLIB_LD="ld -shared -rdata_shared" 6601 + SHLIB_SUFFIX=".so" 6602 + case " $LIBOBJS " in 6603 + *" mkstemp.$ac_objext "* ) ;; 6604 + *) LIBOBJS="$LIBOBJS mkstemp.$ac_objext" 6605 + ;; 6606 +esac 6607 + 6608 + if test $doRpath = yes; then : 6609 + 6610 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 6611 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"' 6612 +fi 6613 + ;; 7189 6614 IRIX-6.*) 7190 6615 SHLIB_CFLAGS="" 7191 6616 SHLIB_LD="ld -n32 -shared -rdata_shared" 7192 6617 SHLIB_SUFFIX=".so" 7193 6618 if test $doRpath = yes; then : 7194 6619 7195 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7196 - LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 6620 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 6621 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"' 7197 6622 fi 7198 6623 if test "$GCC" = yes; then : 7199 6624 7200 6625 CFLAGS="$CFLAGS -mabi=n32" 7201 6626 LDFLAGS="$LDFLAGS -mabi=n32" 7202 6627 7203 6628 else ................................................................................ 7217 6642 ;; 7218 6643 IRIX64-6.*) 7219 6644 SHLIB_CFLAGS="" 7220 6645 SHLIB_LD="ld -n32 -shared -rdata_shared" 7221 6646 SHLIB_SUFFIX=".so" 7222 6647 if test $doRpath = yes; then : 7223 6648 7224 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7225 - LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 6649 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 6650 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"' 7226 6651 fi 7227 6652 7228 6653 # Check to enable 64-bit flags for compiler/linker 7229 6654 7230 6655 if test "$do64bit" = yes; then : 7231 6656 7232 6657 if test "$GCC" = yes; then : ................................................................................ 7241 6666 CFLAGS="$CFLAGS -64" 7242 6667 LDFLAGS_ARCH="-64" 7243 6668 7244 6669 fi 7245 6670 7246 6671 fi 7247 6672 ;; 7248 - Linux*|GNU*|NetBSD-Debian) 6673 + Linux*|GNU*|NetBSD-Debian|DragonFly-*|FreeBSD-*) 7249 6674 SHLIB_CFLAGS="-fPIC" 7250 6675 SHLIB_SUFFIX=".so" 7251 6676 7252 6677 # TEA specific: 7253 6678 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" 7254 6679 7255 6680 # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 7256 - SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS_DEFAULT}' 6681 + SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared' 7257 6682 LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 6683 + 6684 + case $system in 6685 + DragonFly-*|FreeBSD-*) 6686 + if test "${TCL_THREADS}" = "1"; then : 6687 + 6688 + # The -pthread needs to go in the LDFLAGS, not LIBS 6689 + LIBS=`echo $LIBS | sed s/-pthread//` 6690 + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 6691 + LDFLAGS="$LDFLAGS $PTHREAD_LIBS" 6692 +fi 6693 + ;; 6694 + esac 6695 + 7258 6696 if test $doRpath = yes; then : 7259 6697 7260 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6698 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7261 6699 fi 7262 6700 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7263 6701 if test "`uname -m`" = "alpha"; then : 7264 6702 CFLAGS="$CFLAGS -mieee" 7265 6703 fi 7266 6704 if test $do64bit = yes; then : 7267 6705 ................................................................................ 7318 6756 SHLIB_CFLAGS="-fPIC" 7319 6757 SHLIB_SUFFIX=".so" 7320 6758 CFLAGS_OPTIMIZE=-02 7321 6759 SHLIB_LD='${CC} -shared' 7322 6760 LD_FLAGS="-Wl,--export-dynamic" 7323 6761 if test $doRpath = yes; then : 7324 6762 7325 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7326 - LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6763 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 6764 + LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7327 6765 fi 7328 6766 ;; 7329 6767 OpenBSD-*) 7330 6768 arch=`arch -s` 7331 6769 case "$arch" in 7332 6770 alpha|sparc64) 7333 6771 SHLIB_CFLAGS="-fPIC" 7334 6772 ;; 7335 6773 *) 7336 6774 SHLIB_CFLAGS="-fpic" 7337 6775 ;; 7338 6776 esac 7339 - SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' 6777 + SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 7340 6778 SHLIB_SUFFIX=".so" 7341 6779 if test $doRpath = yes; then : 7342 6780 7343 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6781 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7344 6782 fi 7345 6783 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7346 6784 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}' 7347 - LDFLAGS="-Wl,-export-dynamic" 6785 + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" 7348 6786 CFLAGS_OPTIMIZE="-O2" 7349 - if test "${TCL_THREADS}" = "1"; then : 7350 - 7351 - # On OpenBSD: Compile with -pthread 7352 - # Don't link with -lpthread 7353 - LIBS=`echo $LIBS | sed s/-lpthread//` 7354 - CFLAGS="$CFLAGS -pthread" 7355 - 7356 -fi 6787 + # On OpenBSD: Compile with -pthread 6788 + # Don't link with -lpthread 6789 + LIBS=`echo $LIBS | sed s/-lpthread//` 6790 + CFLAGS="$CFLAGS -pthread" 7357 6791 # OpenBSD doesn't do version numbers with dots. 7358 6792 UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 7359 6793 TCL_LIB_VERSIONS_OK=nodots 7360 6794 ;; 7361 6795 NetBSD-*) 7362 6796 # NetBSD has ELF and can use 'cc -shared' to build shared libs 7363 6797 SHLIB_CFLAGS="-fPIC" 7364 - SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' 6798 + SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 7365 6799 SHLIB_SUFFIX=".so" 7366 6800 LDFLAGS="$LDFLAGS -export-dynamic" 7367 6801 if test $doRpath = yes; then : 7368 6802 7369 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 6803 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7370 6804 fi 7371 6805 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7372 - if test "${TCL_THREADS}" = "1"; then : 7373 - 7374 - # The -pthread needs to go in the CFLAGS, not LIBS 7375 - LIBS=`echo $LIBS | sed s/-pthread//` 7376 - CFLAGS="$CFLAGS -pthread" 7377 - LDFLAGS="$LDFLAGS -pthread" 7378 - 7379 -fi 7380 - ;; 7381 - FreeBSD-*) 7382 - # This configuration from FreeBSD Ports. 7383 - SHLIB_CFLAGS="-fPIC" 7384 - SHLIB_LD="${CC} -shared" 7385 - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname,\$@" 7386 - SHLIB_SUFFIX=".so" 7387 - LDFLAGS="" 7388 - if test $doRpath = yes; then : 7389 - 7390 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7391 - LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7392 -fi 7393 - if test "${TCL_THREADS}" = "1"; then : 7394 - 7395 - # The -pthread needs to go in the LDFLAGS, not LIBS 7396 - LIBS=`echo $LIBS | sed s/-pthread//` 7397 - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 7398 - LDFLAGS="$LDFLAGS $PTHREAD_LIBS" 7399 -fi 7400 - case $system in 7401 - FreeBSD-3.*) 7402 - # Version numbers are dot-stripped by system policy. 7403 - TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` 7404 - UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 7405 - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' 7406 - TCL_LIB_VERSIONS_OK=nodots 7407 - ;; 7408 - esac 6806 + # The -pthread needs to go in the CFLAGS, not LIBS 6807 + LIBS=`echo $LIBS | sed s/-pthread//` 6808 + CFLAGS="$CFLAGS -pthread" 6809 + LDFLAGS="$LDFLAGS -pthread" 7409 6810 ;; 7410 6811 Darwin-*) 7411 6812 CFLAGS_OPTIMIZE="-Os" 7412 6813 SHLIB_CFLAGS="-fno-common" 7413 6814 # To avoid discrepancies between what headers configure sees during 7414 6815 # preprocessing tests and compiling tests, move any -isysroot and 7415 6816 # -mmacosx-version-min flags from CFLAGS to CPPFLAGS: ................................................................................ 7548 6949 SHLIB_LD="${SHLIB_LD} -Wl,-single_module" 7549 6950 7550 6951 fi 7551 6952 # TEA specific: link shlib with current and compatibility version flags 7552 6953 vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([0-9]\{1,5\}\)\(\(\.[0-9]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d` 7553 6954 SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}" 7554 6955 SHLIB_SUFFIX=".dylib" 7555 - # Don't use -prebind when building for Mac OS X 10.4 or later only: 7556 - if test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int($2)}'`" -lt 4 -a \ 7557 - "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int($2)}'`" -lt 4; then : 7558 - 7559 - LDFLAGS="$LDFLAGS -prebind" 7560 -fi 7561 6956 LDFLAGS="$LDFLAGS -headerpad_max_install_names" 7562 6957 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5 7563 6958 $as_echo_n "checking if ld accepts -search_paths_first flag... " >&6; } 7564 6959 if ${tcl_cv_ld_search_paths_first+:} false; then : 7565 6960 $as_echo_n "(cached) " >&6 7566 6961 else 7567 6962 ................................................................................ 7717 7112 7718 7113 SHLIB_LD='ld -non_shared -expect_unresolved "*"' 7719 7114 7720 7115 fi 7721 7116 SHLIB_SUFFIX=".so" 7722 7117 if test $doRpath = yes; then : 7723 7118 7724 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 7119 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 7725 7120 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}' 7726 7121 fi 7727 7122 if test "$GCC" = yes; then : 7728 7123 CFLAGS="$CFLAGS -mieee" 7729 7124 else 7730 7125 7731 7126 CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee" 7732 7127 fi 7733 7128 # see pthread_intro(3) for pthread support on osf1, k.furukawa 7734 - if test "${TCL_THREADS}" = 1; then : 7129 + CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 7130 + CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 7131 + LIBS=`echo $LIBS | sed s/-lpthreads//` 7132 + if test "$GCC" = yes; then : 7735 7133 7736 - CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 7737 - CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 7738 - LIBS=`echo $LIBS | sed s/-lpthreads//` 7739 - if test "$GCC" = yes; then : 7740 - 7741 - LIBS="$LIBS -lpthread -lmach -lexc" 7134 + LIBS="$LIBS -lpthread -lmach -lexc" 7742 7135 7743 7136 else 7744 7137 7745 - CFLAGS="$CFLAGS -pthread" 7746 - LDFLAGS="$LDFLAGS -pthread" 7747 - 7748 -fi 7138 + CFLAGS="$CFLAGS -pthread" 7139 + LDFLAGS="$LDFLAGS -pthread" 7749 7140 7750 7141 fi 7751 7142 ;; 7752 7143 QNX-6*) 7753 7144 # QNX RTP 7754 7145 # This may work for all QNX, but it was only reported for v6. 7755 7146 SHLIB_CFLAGS="-fPIC" ................................................................................ 7791 7182 7792 7183 7793 7184 SHLIB_CFLAGS="-KPIC" 7794 7185 SHLIB_SUFFIX=".so" 7795 7186 if test "$GCC" = yes; then : 7796 7187 7797 7188 SHLIB_LD='${CC} -shared' 7798 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7189 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 7799 7190 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7800 7191 7801 7192 else 7802 7193 7803 7194 SHLIB_LD="/usr/ccs/bin/ld -G -z text" 7804 - CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 7195 + CC_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 7805 7196 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7806 7197 7807 7198 fi 7808 7199 ;; 7809 7200 SunOS-5*) 7810 7201 # Note: If _REENTRANT isn't defined, then Solaris 7811 7202 # won't define thread-safe library routines. ................................................................................ 7897 7288 7898 7289 fi 7899 7290 7900 7291 SHLIB_SUFFIX=".so" 7901 7292 if test "$GCC" = yes; then : 7902 7293 7903 7294 SHLIB_LD='${CC} -shared' 7904 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7295 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 7905 7296 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 7906 7297 if test "$do64bit_ok" = yes; then : 7907 7298 7908 7299 if test "$arch" = "sparcv9 sparc"; then : 7909 7300 7910 7301 # We need to specify -static-libgcc or we need to 7911 7302 # add the path to the sparv9 libgcc. ................................................................................ 7934 7325 case $system in 7935 7326 SunOS-5.[1-9][0-9]*) 7936 7327 # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 7937 7328 SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';; 7938 7329 *) 7939 7330 SHLIB_LD='/usr/ccs/bin/ld -G -z text';; 7940 7331 esac 7941 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 7942 - LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 7332 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 7333 + LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 7943 7334 7944 7335 fi 7945 7336 ;; 7946 7337 UNIX_SV* | UnixWare-5*) 7947 7338 SHLIB_CFLAGS="-KPIC" 7948 7339 SHLIB_LD='${CC} -G' 7949 7340 SHLIB_LD_LIBS="" ................................................................................ 8008 7399 # standard manufacturer compiler. 8009 7400 8010 7401 if test "$GCC" = yes; then : 8011 7402 8012 7403 case $system in 8013 7404 AIX-*) ;; 8014 7405 BSD/OS*) ;; 8015 - CYGWIN_*|MINGW32_*) ;; 7406 + CYGWIN_*|MINGW32_*|MINGW64_*|MSYS_*) ;; 8016 7407 IRIX*) ;; 8017 - NetBSD-*|FreeBSD-*|OpenBSD-*) ;; 7408 + NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;; 8018 7409 Darwin-*) ;; 8019 7410 SCO_SV-3.2*) ;; 8020 7411 windows) ;; 8021 7412 *) SHLIB_CFLAGS="-fPIC" ;; 8022 7413 esac 8023 7414 fi 8024 7415 ................................................................................ 8213 7604 $as_echo "$tcl_cv_cast_to_union" >&6; } 8214 7605 if test "$tcl_cv_cast_to_union" = "yes"; then 8215 7606 8216 7607 $as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h 8217 7608 8218 7609 fi 8219 7610 7611 + ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" 7612 +if test "x$ac_cv_header_stdbool_h" = xyes; then : 7613 + 7614 +$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h 7615 + 7616 +fi 7617 + 7618 + 7619 + 7620 + 7621 + 8220 7622 8221 7623 8222 7624 8223 7625 8224 7626 8225 7627 8226 7628 ................................................................................ 8406 7808 _ACEOF 8407 7809 if ac_fn_c_try_compile "$LINENO"; then : 8408 7810 tcl_type_64bit=__int64 8409 7811 else 8410 7812 tcl_type_64bit="long long" 8411 7813 fi 8412 7814 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 8413 - # See if we should use long anyway Note that we substitute in the 7815 + # See if we could use long anyway Note that we substitute in the 8414 7816 # type that is our current guess for a 64-bit type inside this check 8415 7817 # program, so it should be modified only carefully... 8416 7818 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8417 7819 /* end confdefs.h. */ 8418 7820 8419 7821 int 8420 7822 main () ................................................................................ 8432 7834 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 8433 7835 fi 8434 7836 8435 7837 if test "${tcl_cv_type_64bit}" = none ; then 8436 7838 8437 7839 $as_echo "#define TCL_WIDE_INT_IS_LONG 1" >>confdefs.h 8438 7840 8439 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: using long" >&5 8440 -$as_echo "using long" >&6; } 7841 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 7842 +$as_echo "yes" >&6; } 8441 7843 elif test "${tcl_cv_type_64bit}" = "__int64" \ 8442 7844 -a "${TEA_PLATFORM}" = "windows" ; then 8443 7845 # TEA specific: We actually want to use the default tcl.h checks in 8444 7846 # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER* 8445 7847 { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Tcl header defaults" >&5 8446 7848 $as_echo "using Tcl header defaults" >&6; } 8447 7849 else ................................................................................ 8481 7883 fi 8482 7884 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_struct_dirent64" >&5 8483 7885 $as_echo "$tcl_cv_struct_dirent64" >&6; } 8484 7886 if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then 8485 7887 8486 7888 $as_echo "#define HAVE_STRUCT_DIRENT64 1" >>confdefs.h 8487 7889 7890 + fi 7891 + 7892 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DIR64" >&5 7893 +$as_echo_n "checking for DIR64... " >&6; } 7894 +if ${tcl_cv_DIR64+:} false; then : 7895 + $as_echo_n "(cached) " >&6 7896 +else 7897 + 7898 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7899 +/* end confdefs.h. */ 7900 +#include <sys/types.h> 7901 +#include <dirent.h> 7902 +int 7903 +main () 7904 +{ 7905 +struct dirent64 *p; DIR64 d = opendir64("."); 7906 + p = readdir64(d); rewinddir64(d); closedir64(d); 7907 + ; 7908 + return 0; 7909 +} 7910 +_ACEOF 7911 +if ac_fn_c_try_compile "$LINENO"; then : 7912 + tcl_cv_DIR64=yes 7913 +else 7914 + tcl_cv_DIR64=no 7915 +fi 7916 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7917 +fi 7918 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_DIR64" >&5 7919 +$as_echo "$tcl_cv_DIR64" >&6; } 7920 + if test "x${tcl_cv_DIR64}" = "xyes" ; then 7921 + 7922 +$as_echo "#define HAVE_DIR64 1" >>confdefs.h 7923 + 8488 7924 fi 8489 7925 8490 7926 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct stat64" >&5 8491 7927 $as_echo_n "checking for struct stat64... " >&6; } 8492 7928 if ${tcl_cv_struct_stat64+:} false; then : 8493 7929 $as_echo_n "(cached) " >&6 8494 7930 else ................................................................................ 8585 8021 # Check whether --enable-symbols was given. 8586 8022 if test "${enable_symbols+set}" = set; then : 8587 8023 enableval=$enable_symbols; tcl_ok=$enableval 8588 8024 else 8589 8025 tcl_ok=no 8590 8026 fi 8591 8027 8592 - DBGX="" 8593 8028 if test "$tcl_ok" = "no"; then 8594 8029 CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG" 8595 8030 LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" 8596 8031 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 8597 8032 $as_echo "no" >&6; } 8598 8033 else 8599 8034 CFLAGS_DEFAULT="${CFLAGS_DEBUG}" 8600 8035 LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" 8601 8036 if test "$tcl_ok" = "yes"; then 8602 8037 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (standard debugging)" >&5 8603 8038 $as_echo "yes (standard debugging)" >&6; } 8604 8039 fi 8605 8040 fi 8606 - # TEA specific: 8607 - if test "${TEA_PLATFORM}" != "windows" ; then 8608 - LDFLAGS_DEFAULT="${LDFLAGS}" 8609 - fi 8610 - 8611 8041 8612 8042 8613 8043 8614 8044 if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then 8615 8045 8616 8046 $as_echo "#define TCL_MEM_DEBUG 1" >>confdefs.h 8617 8047 ................................................................................ 8645 8075 # depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS, 8646 8076 # and TEA_LOAD_TCLCONFIG macros above. 8647 8077 #-------------------------------------------------------------------- 8648 8078 8649 8079 8650 8080 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then 8651 8081 MAKE_STATIC_LIB="\${STLIB_LD} -out:\$@ \$(PKG_OBJECTS)" 8652 - MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\$@ \$(PKG_OBJECTS)" 8082 + MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -out:\$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8653 8083 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 8654 8084 /* end confdefs.h. */ 8655 8085 8656 8086 #if defined(_MSC_VER) && _MSC_VER >= 1400 8657 8087 print("manifest needed") 8658 8088 #endif 8659 8089 ................................................................................ 8671 8101 8672 8102 fi 8673 8103 rm -f conftest* 8674 8104 8675 8105 MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\$@ \$(PKG_STUB_OBJECTS)" 8676 8106 else 8677 8107 MAKE_STATIC_LIB="\${STLIB_LD} \$@ \$(PKG_OBJECTS)" 8678 - MAKE_SHARED_LIB="\${SHLIB_LD} -o \$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8108 + MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -o \$@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 8679 8109 MAKE_STUB_LIB="\${STLIB_LD} \$@ \$(PKG_STUB_OBJECTS)" 8680 8110 fi 8681 8111 8682 8112 if test "${SHARED_BUILD}" = "1" ; then 8683 8113 MAKE_LIB="${MAKE_SHARED_LIB} " 8684 8114 else 8685 8115 MAKE_LIB="${MAKE_STATIC_LIB} " ................................................................................ 8759 8189 8760 8190 8761 8191 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5 8762 8192 $as_echo_n "checking for tclsh... " >&6; } 8763 8193 if test -f "${TCL_BIN_DIR}/Makefile" ; then 8764 8194 # tclConfig.sh is in Tcl build directory 8765 8195 if test "${TEA_PLATFORM}" = "windows"; then 8766 - if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" ; then 8767 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 8768 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" ; then 8769 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" 8770 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" ; then 8771 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" 8772 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" ; then 8773 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" 8196 + if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" ; then 8197 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" 8198 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" ; then 8199 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" 8200 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" ; then 8201 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" 8202 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" ; then 8203 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" 8774 8204 fi 8775 8205 else 8776 8206 TCLSH_PROG="${TCL_BIN_DIR}/tclsh" 8777 8207 fi 8778 8208 else 8779 8209 # tclConfig.sh is in install location 8780 8210 if test "${TEA_PLATFORM}" = "windows"; then 8781 - TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 8211 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" 8782 8212 else 8783 - TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}" 8213 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" 8784 8214 fi 8785 8215 list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \ 8786 8216 `ls -d ${TCL_BIN_DIR}/.. 2>/dev/null` \ 8787 8217 `ls -d ${TCL_PREFIX}/bin 2>/dev/null`" 8788 8218 for i in $list ; do 8789 8219 if test -f "$i/${TCLSH_PROG}" ; then 8790 8220 REAL_TCL_BIN_DIR="`cd "$i"; pwd`/"
Deleted extensions/tnc/mkinstalldirs.
1 -#! /bin/sh 2 -# mkinstalldirs --- make directory hierarchy 3 -# Author: Noah Friedman <friedman@prep.ai.mit.edu> 4 -# Created: 1993-05-16 5 -# Public domain 6 - 7 -# $Id$ 8 - 9 -errstatus=0 10 - 11 -for file 12 -do 13 - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 - shift 15 - 16 - pathcomp= 17 - for d 18 - do 19 - pathcomp="$pathcomp$d" 20 - case "$pathcomp" in 21 - -* ) pathcomp=./$pathcomp ;; 22 - esac 23 - 24 - if test ! -d "$pathcomp"; then 25 - echo "mkdir $pathcomp" 26 - 27 - mkdir "$pathcomp" || lasterr=$? 28 - 29 - if test ! -d "$pathcomp"; then 30 - errstatus=$lasterr 31 - fi 32 - fi 33 - 34 - pathcomp="$pathcomp/" 35 - done 36 -done 37 - 38 -exit $errstatus 39 - 40 -# mkinstalldirs ends here
Changes to extensions/tnc/tests/tnc.test.
160 160 puts stderr "Unexpected systemId '$systemId'" 161 161 return "" 162 162 } 163 163 } 164 164 } 165 165 166 166 test tnc-2.8 {Validate REC-xslt-19991116.xml} { 167 - set ::tDOM::extRefHandlerDebug 1 167 + set ::tdom::extRefHandlerDebug 1 168 168 set parser [expat -externalentitycommand 2.8-resolver \ 169 169 -paramentityparsing always] 170 170 tnc $parser enable 171 171 $parser parsefile [file join [file dir [info script]] \ 172 172 ../../../tests/data/REC-xslt-19991116.xml] 173 173 $parser free 174 174 } {}
Changes to generic/dom.c.
1 1 /*--------------------------------------------------------------------------- 2 2 | Copyright (C) 1999 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +---------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A DOM interface upon the expat XML parser for the C language 9 6 | according to the W3C recommendation REC-DOM-Level-1-19981001 10 7 | 11 8 | 12 9 | The contents of this file are subject to the Mozilla Public License 13 10 | Version 2.0 (the "License"); you may not use this file except in ................................................................................ 45 42 /*--------------------------------------------------------------------------- 46 43 | Includes 47 44 | 48 45 \--------------------------------------------------------------------------*/ 49 46 #include <tcl.h> 50 47 #include <dom.h> 51 48 #include <domxpath.h> 49 +#include <schema.h> 52 50 #include <tclexpat.h> 53 51 54 52 55 53 /* #define DEBUG */ 56 54 /*---------------------------------------------------------------------------- 57 55 | Debug Macros 58 56 | ................................................................................ 147 145 int activeNSsize; 148 146 int activeNSpos; 149 147 domActiveNS *activeNS; 150 148 int baseURIstackSize; 151 149 int baseURIstackPos; 152 150 domActiveBaseURI *baseURIstack; 153 151 int insideDTD; 154 - StructureData *sdata; 152 +#ifndef TDOM_NO_SCHEMA 153 + SchemaData *sdata; 154 +#endif 155 155 int status; 156 156 157 157 } domReadInfo; 158 158 159 159 /*---------------------------------------------------------------------------- 160 160 | Prototypes 161 161 | ................................................................................ 350 350 if (clen > 4) return 0; 351 351 if (UTF8_XMLCHAR((unsigned const char *)p,clen)) 352 352 p += clen; 353 353 else return 0; 354 354 } 355 355 return 1; 356 356 } 357 + 358 +/*--------------------------------------------------------------------------- 359 +| domClearString 360 +| 361 +\--------------------------------------------------------------------------*/ 362 +char * 363 +domClearString ( 364 + char *str, 365 + int *haveToFree 366 + ) 367 +{ 368 + const char *p, *s; 369 + char *p1, *clearedstr; 370 + int clen, i, rewrite = 0; 371 + 372 + p = str; 373 + while (*p) { 374 + clen = UTF8_CHAR_LEN(*p); 375 + if (clen > 4 || !UTF8_XMLCHAR((unsigned const char*)p,clen)) { 376 + rewrite = 1; 377 + break; 378 + } 379 + p += clen; 380 + } 381 + if (!rewrite) { 382 + *haveToFree = 0; 383 + return str; 384 + } 385 + s = p; 386 + p += clen; 387 + while (*p) p++; 388 + clearedstr = MALLOC (sizeof(char) * (p-str)); 389 + p1 = clearedstr; 390 + while (str < s) { 391 + *p1 = *str; 392 + p1++; str++; 393 + } 394 + str += clen; 395 + while (*str) { 396 + clen = UTF8_CHAR_LEN(*str); 397 + if (clen <= 4 && UTF8_XMLCHAR((unsigned const char*)str,clen)) { 398 + for (i = 0; i < clen; i++) { 399 + *p1 = *str; 400 + p1++; str++; 401 + } 402 + } else { 403 + str += clen; 404 + } 405 + } 406 + *p1 = '\0'; 407 + *haveToFree = 1; 408 + return clearedstr; 409 +} 357 410 358 411 /*--------------------------------------------------------------------------- 359 412 | domIsBMPChar 360 413 | 361 414 \--------------------------------------------------------------------------*/ 362 415 int 363 416 domIsBMPChar ( ................................................................................ 1374 1427 should return this as an error, shouldn't we?*/ 1375 1428 } 1376 1429 attrNSfound: 1377 1430 ; 1378 1431 } 1379 1432 } 1380 1433 } 1434 +#ifndef TDOM_NO_SCHEMA 1381 1435 if (info->sdata) { 1382 - if (probeElement (info->interp, info->sdata, node->nodeName, 1436 + if (tDOM_probeElement (info->interp, info->sdata, node->nodeName, 1383 1437 node->namespace ? 1384 - info->document->namespaces[node->namespace-1]->uri : NULL) 1438 + info->document->namespaces[node->namespace-1]->uri 1439 + : NULL) 1385 1440 != TCL_OK) { 1386 1441 XML_StopParser(info->parser, 0); 1442 + } else { 1443 + if (tDOM_probeDomAttributes (info->interp, info->sdata, 1444 + node->firstAttr) 1445 + != TCL_OK) { 1446 + XML_StopParser(info->parser, 0); 1447 + } 1387 1448 } 1388 1449 } 1450 +#endif 1389 1451 info->depth++; 1390 1452 } 1391 1453 1392 1454 /*--------------------------------------------------------------------------- 1393 1455 | endElement 1394 1456 | 1395 1457 \--------------------------------------------------------------------------*/ ................................................................................ 1420 1482 } 1421 1483 1422 1484 if (info->depth) { 1423 1485 if (info->baseURIstack[info->baseURIstackPos].depth == info->depth) { 1424 1486 info->baseURIstackPos--; 1425 1487 } 1426 1488 } 1489 +#ifndef TDOM_NO_SCHEMA 1427 1490 if (info->sdata) { 1428 - if (probeElementEnd (info->interp, info->sdata) != TCL_OK) { 1491 + if (tDOM_probeElementEnd (info->interp, info->sdata) != TCL_OK) { 1429 1492 XML_StopParser(info->parser, 0); 1430 1493 } 1431 1494 } 1495 +#endif 1432 1496 } 1433 1497 1434 1498 /*--------------------------------------------------------------------------- 1435 1499 | characterDataHandler 1436 1500 | 1437 1501 \--------------------------------------------------------------------------*/ 1438 1502 static void ................................................................................ 1489 1553 ) 1490 1554 { 1491 1555 domTextNode *node; 1492 1556 domNode *parentNode; 1493 1557 domLineColumn *lc; 1494 1558 Tcl_HashEntry *h; 1495 1559 char *s; 1496 - int len, hnew; 1560 + int len, hnew, only_whites; 1497 1561 1498 1562 len = Tcl_DStringLength (info->cdata); 1563 +#ifndef TDOM_NO_SCHEMA 1564 + if (!len && !info->cdataSection 1565 + && !(info->sdata 1566 + && info->sdata->stack 1567 + && info->sdata->stack->pattern->flags & CONSTRAINT_TEXT_CHILD)) 1568 + return; 1569 +#else 1499 1570 if (!len && !info->cdataSection) return; 1571 +#endif 1500 1572 s = Tcl_DStringValue (info->cdata); 1501 1573 1502 1574 parentNode = info->currentNode; 1503 1575 if (!parentNode) return; 1504 1576 1505 1577 if ( parentNode->lastChild 1506 1578 && parentNode->lastChild->nodeType == TEXT_NODE ................................................................................ 1508 1580 1509 1581 /* normalize text node, i.e. there are no adjacent text nodes */ 1510 1582 node = (domTextNode*)parentNode->lastChild; 1511 1583 node->nodeValue = REALLOC(node->nodeValue, node->valueLength + len); 1512 1584 memmove(node->nodeValue + node->valueLength, s, len); 1513 1585 node->valueLength += len; 1514 1586 1587 + only_whites = 0; 1515 1588 } else { 1516 1589 1517 1590 if (info->ignoreWhiteSpaces) { 1518 1591 char *pc; 1519 - int i, only_whites; 1592 + int i; 1520 1593 1521 1594 only_whites = 1; 1522 1595 for (i=0, pc = s; i < len; i++, pc++) { 1523 1596 if ( (*pc != ' ') && 1524 1597 (*pc != '\t') && 1525 1598 (*pc != '\n') && 1526 1599 (*pc != '\r') ) { 1527 1600 only_whites = 0; 1528 1601 break; 1529 1602 } 1530 1603 } 1531 1604 if (only_whites) { 1532 - Tcl_DStringSetLength (info->cdata, 0); 1533 - return; 1605 + goto checkTextConstraints; 1534 1606 } 1535 1607 } 1536 1608 1537 1609 if (info->storeLineColumn) { 1538 1610 node = (domTextNode*) domAlloc(sizeof(domTextNode) 1539 1611 + sizeof(domLineColumn)); 1540 1612 } else { ................................................................................ 1574 1646 if (info->storeLineColumn) { 1575 1647 lc = (domLineColumn*) ( ((char*)node) + sizeof(domTextNode) ); 1576 1648 node->nodeFlags |= HAS_LINE_COLUMN; 1577 1649 lc->line = XML_GetCurrentLineNumber(info->parser); 1578 1650 lc->column = XML_GetCurrentColumnNumber(info->parser); 1579 1651 } 1580 1652 } 1653 +checkTextConstraints: 1654 +#ifndef TDOM_NO_SCHEMA 1581 1655 if (info->sdata) { 1582 - if (probeText (info->interp, info->sdata, s) != TCL_OK) { 1656 + if (tDOM_probeText (info->interp, info->sdata, s, &only_whites) 1657 + != TCL_OK) { 1583 1658 XML_StopParser(info->parser, 0); 1584 1659 } 1585 1660 } 1661 +#endif 1586 1662 Tcl_DStringSetLength (info->cdata, 0); 1587 1663 } 1588 1664 1589 1665 1590 1666 /*--------------------------------------------------------------------------- 1591 1667 | commentHandler 1592 1668 | ................................................................................ 2107 2183 int feedbackAfter, 2108 2184 Tcl_Obj *feedbackCmd, 2109 2185 Tcl_Channel channel, 2110 2186 const char *baseurl, 2111 2187 Tcl_Obj *extResolver, 2112 2188 int useForeignDTD, 2113 2189 int paramEntityParsing, 2114 - StructureData *sdata, 2190 +#ifndef TDOM_NO_SCHEMA 2191 + SchemaData *sdata, 2192 +#endif 2115 2193 Tcl_Interp *interp, 2116 2194 int *resultcode 2117 2195 ) 2118 2196 { 2119 2197 int done, tclLen; 2120 2198 enum XML_Status status; 2121 2199 size_t len; ................................................................................ 2154 2232 * info.activeNSsize); 2155 2233 info.baseURIstackPos = 0; 2156 2234 info.baseURIstackSize = INITIAL_BASEURISTACK_SIZE; 2157 2235 info.baseURIstack = (domActiveBaseURI*) 2158 2236 MALLOC (sizeof(domActiveBaseURI) * info.baseURIstackSize); 2159 2237 info.insideDTD = 0; 2160 2238 info.status = 0; 2239 +#ifndef TDOM_NO_SCHEMA 2161 2240 info.sdata = sdata; 2241 +#endif 2162 2242 2163 2243 XML_SetUserData(parser, &info); 2164 2244 XML_SetBase (parser, baseurl); 2165 2245 /* We must use XML_GetBase(), because XML_SetBase copies the baseURI, 2166 2246 and we want to compare the pointers */ 2167 2247 info.baseURIstack[0].baseURI = XML_GetBase (parser); 2168 2248 info.baseURIstack[0].depth = 0; ................................................................................ 2307 2387 /*--------------------------------------------------------------------------- 2308 2388 | domGetLineColumn 2309 2389 | 2310 2390 \--------------------------------------------------------------------------*/ 2311 2391 int 2312 2392 domGetLineColumn ( 2313 2393 domNode *node, 2314 - int *line, 2315 - int *column 2394 + long *line, 2395 + long *column 2316 2396 ) 2317 2397 { 2318 2398 char *v; 2319 2399 domLineColumn *lc; 2320 2400 2321 2401 *line = -1; 2322 2402 *column = -1; ................................................................................ 4565 4645 pinode->targetValue, 4566 4646 pinode->targetLength, 4567 4647 pinode->dataValue, 4568 4648 pinode->dataLength); 4569 4649 } 4570 4650 if (node->nodeType != ELEMENT_NODE) { 4571 4651 domTextNode *t1node, *tnode = (domTextNode*)node; 4572 - if (tnode->info) { 4573 - t1node = domNewTextNode(tnode->ownerDocument, 4574 - tnode->nodeValue, tnode->valueLength, 4575 - tnode->nodeType); 4576 - t1node->info = tnode->info; 4577 - return (domNode*) t1node; 4578 - } else { 4579 - return (domNode*) domNewTextNode(tnode->ownerDocument, 4580 - tnode->nodeValue, tnode->valueLength, 4581 - tnode->nodeType); 4582 - } 4652 + t1node = domNewTextNode(tnode->ownerDocument, tnode->nodeValue, 4653 + tnode->valueLength, tnode->nodeType); 4654 + t1node->info = tnode->info; 4655 + t1node->nodeFlags = tnode->nodeFlags; 4656 + return (domNode*) t1node; 4583 4657 } 4584 4658 4585 4659 n = domNewElementNode(node->ownerDocument, node->nodeName); 4586 4660 n->namespace = node->namespace; 4587 4661 n->info = node->info; 4588 4662 4589 4663 /*------------------------------------------------------------------ 4590 4664 | copy attributes (if any) 4591 4665 \-----------------------------------------------------------------*/ 4592 4666 attr = node->firstAttr; 4593 4667 while (attr != NULL) { 4594 4668 nattr = domSetAttribute (n, attr->nodeName, attr->nodeValue ); 4595 4669 nattr->namespace = attr->namespace; 4596 - if (attr->nodeFlags & IS_NS_NODE) { 4597 - nattr->nodeFlags |= IS_NS_NODE; 4598 - } 4670 + nattr->nodeFlags = attr->nodeFlags; 4599 4671 attr = attr->nextSibling; 4600 4672 } 4601 4673 4602 4674 if (deep) { 4603 4675 child = node->firstChild; 4604 4676 while (child) { 4605 4677 newChild = domCloneNode(child, deep); ................................................................................ 5145 5217 int activeNSsize; 5146 5218 int activeNSpos; 5147 5219 domActiveNS *activeNS; 5148 5220 int baseURIstackSize; 5149 5221 int baseURIstackPos; 5150 5222 domActiveBaseURI *baseURIstack; 5151 5223 int insideDTD; 5152 - StructureData *sdata; 5224 +#ifndef TDOM_NO_SCHEMA 5225 + SchemaData *sdata; 5226 +#endif 5153 5227 /* Now the tdom cmd specific elements */ 5154 5228 int tdomStatus; 5155 5229 Tcl_Obj *extResolver; 5156 5230 5157 5231 } tdomCmdReadInfo; 5158 5232 5159 -EXTERN int tcldom_returnDocumentObj (Tcl_Interp *interp, 5160 - domDocument *document, 5161 - int setVariable, Tcl_Obj *var_name, 5162 - int trace, int forOwnerDocument); 5233 +int tcldom_returnDocumentObj (Tcl_Interp *interp, 5234 + domDocument *document, 5235 + int setVariable, Tcl_Obj *var_name, 5236 + int trace, int forOwnerDocument); 5163 5237 5164 5238 void 5165 5239 tdom_freeProc ( 5166 5240 Tcl_Interp *interp, 5167 5241 void *userData 5168 5242 ) 5169 5243 { ................................................................................ 5357 5431 info->baseURIstackPos = 0; 5358 5432 info->baseURIstackSize = INITIAL_BASEURISTACK_SIZE; 5359 5433 info->baseURIstack = (domActiveBaseURI*) 5360 5434 MALLOC (sizeof(domActiveBaseURI) * info->baseURIstackSize); 5361 5435 info->insideDTD = 0; 5362 5436 info->tdomStatus = 0; 5363 5437 info->extResolver = NULL; 5438 +#ifndef TDOM_NO_SCHEMA 5364 5439 info->sdata = NULL; 5440 +#endif 5365 5441 handlerSet->userData = info; 5366 5442 5367 5443 CHandlerSetInstall (interp, objv[1], handlerSet); 5368 5444 break; 5369 5445 5370 5446 case m_getdoc: 5371 5447 info = CHandlerSetGetUserData (interp, objv[1], "tdom");
Changes to generic/dom.h.
1 1 /*--------------------------------------------------------------------------- 2 2 | Copyright (C) 1999 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +---------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A DOM interface upon the expat XML parser for the C language 9 6 | according to the W3C recommendation REC-DOM-Level-1-19981001 10 7 | 11 8 | 12 9 | The contents of this file are subject to the Mozilla Public License 13 10 | Version 2.0 (the "License"); you may not use this file except in ................................................................................ 38 35 39 36 #include <tcl.h> 40 37 #include <stdlib.h> 41 38 #include <string.h> 42 39 #include <ctype.h> 43 40 #include <expat.h> 44 41 #include <domalloc.h> 45 -#include <structure.h> 46 42 47 43 /* 48 44 * tDOM provides it's own memory allocator which is optimized for 49 45 * low heap usage. It uses the native Tcl allocator underneath, 50 46 * though, but it is not very MT-friendly. Therefore, you might 51 47 * use the (normal) Tcl allocator with USE_NORMAL_ALLOCATOR 52 48 * defined during compile time. Actually, the symbols name is ................................................................................ 71 67 # else 72 68 # define MALLOC malloc 73 69 # define FREE free 74 70 # define REALLOC realloc 75 71 # define tdomstrdup strdup 76 72 # endif /* TCL_MEM_DEBUG */ 77 73 #endif /* USE_NORMAL_ALLOCATOR */ 74 +#define TMALLOC(t) (t*)MALLOC(sizeof(t)) 78 75 79 76 #if defined(TCL_MEM_DEBUG) || defined(NS_AOLSERVER) 80 77 static void* my_malloc(size_t size){return Tcl_Alloc(size);} 81 78 static void my_free(void *ptr){Tcl_Free((char*)ptr);} 82 79 static void* my_realloc(void *ptr,size_t size){return Tcl_Realloc(ptr,size);} 83 80 static XML_Memory_Handling_Suite memsuite = { 84 81 my_malloc, my_realloc, my_free ................................................................................ 560 557 561 558 /*-------------------------------------------------------------------------- 562 559 | domLineColumn 563 560 | 564 561 \-------------------------------------------------------------------------*/ 565 562 typedef struct domLineColumn { 566 563 567 - int line; 568 - int column; 564 + long line; 565 + long column; 569 566 570 567 } domLineColumn; 571 568 572 569 573 570 /*-------------------------------------------------------------------------- 574 571 | domNode 575 572 | ................................................................................ 699 696 700 697 /*-------------------------------------------------------------------------- 701 698 | domAddCallback 702 699 | 703 700 \-------------------------------------------------------------------------*/ 704 701 typedef int (*domAddCallback) (domNode * node, void * clientData); 705 702 typedef void (*domFreeCallback) (domNode * node, void * clientData); 703 + 704 +/*-------------------------------------------------------------------------- 705 +| Forward declaration 706 +| 707 +\-------------------------------------------------------------------------*/ 708 +typedef struct SchemaData_ SchemaData; 706 709 707 710 /*-------------------------------------------------------------------------- 708 711 | Function prototypes 709 712 | 710 713 \-------------------------------------------------------------------------*/ 711 714 const char * domException2String (domException exception); 712 715 ................................................................................ 727 730 int feedbackAfter, 728 731 Tcl_Obj *feedbackCmd, 729 732 Tcl_Channel channel, 730 733 const char *baseurl, 731 734 Tcl_Obj *extResolver, 732 735 int useForeignDTD, 733 736 int paramEntityParsing, 734 - StructureData *sdata, 737 +#ifndef TDOM_NO_SCHEMA 738 + SchemaData *sdata, 739 +#endif 735 740 Tcl_Interp *interp, 736 741 int *status); 737 742 738 743 void domFreeDocument (domDocument *doc, 739 744 domFreeCallback freeCB, 740 745 void * clientData); 741 746 ................................................................................ 803 808 const char *prefix, const char *namespaceURI); 804 809 const char * domLookupPrefixWithMappings (domNode *node, const char *prefix, 805 810 char **prefixMappings); 806 811 domNS * domLookupURI (domNode *node, char *uri); 807 812 domNS * domGetNamespaceByIndex (domDocument *doc, int nsIndex); 808 813 domNS * domNewNamespace (domDocument *doc, const char *prefix, 809 814 const char *namespaceURI); 810 -int domGetLineColumn (domNode *node, int *line, int *column); 815 +int domGetLineColumn (domNode *node, long *line, long *column); 811 816 812 817 int domXPointerChild (domNode * node, int all, int instance, domNodeType type, 813 818 char *element, char *attrName, char *attrValue, 814 819 int attrLen, domAddCallback addCallback, 815 820 void * clientData); 816 821 817 822 int domXPointerDescendant (domNode * node, int all, int instance, ................................................................................ 833 838 834 839 void tcldom_tolower (const char *str, char *str_out, int len); 835 840 int domIsNAME (const char *name); 836 841 int domIsPINAME (const char *name); 837 842 int domIsQNAME (const char *name); 838 843 int domIsNCNAME (const char *name); 839 844 int domIsChar (const char *str); 845 +char * domClearString (char *str, int *haveToFree); 840 846 int domIsBMPChar (const char *str); 841 847 int domIsComment (const char *str); 842 848 int domIsCDATA (const char *str); 843 849 int domIsPIValue (const char *str); 844 850 void domCopyTo (domNode *node, domNode *parent, int copyNS); 845 851 void domCopyNS (domNode *from, domNode *to); 846 852 domAttrNode * domCreateXMLNamespaceNode (domNode *parent);
Changes to generic/domalloc.c.
1 1 /*--------------------------------------------------------------------------- 2 2 | Copyright (C) 1999-2000 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +---------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A special memory allocator, which uses pre-allocated / bit masked 9 6 | based administration of memory blocks with fixed sizes, like 10 7 | DOM nodes. This will hopefully save some memory. 11 8 | 12 9 | 13 10 | The contents of this file are subject to the Mozilla Public License
Changes to generic/domalloc.h.
1 1 /*--------------------------------------------------------------------------- 2 2 | Copyright (C) 1999-2000 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +---------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A special memory allocator, which uses pre-allocated / bit masked 9 6 | based administration of memory block with fixed sizes, like 10 7 | DOM nodes. This will hopefully save some memory. 11 8 | 12 9 | 13 10 | The contents of this file are subject to the Mozilla Public License
Changes to generic/domlock.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (C) 1999 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +----------------------------------------------------------------------------- 4 4 | 5 -| $Id$ 6 -| 7 5 | The contents of this file are subject to the Mozilla Public License 8 6 | Version 2.0 (the "License"); you may not use this file except in 9 7 | compliance with the License. You may obtain a copy of the License at 10 8 | http://www.mozilla.org/MPL/ 11 9 | 12 10 | Software distributed under the License is distributed on an "AS IS" 13 11 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
Changes to generic/domxpath.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 1999-2001 Jochen Loewer (loewerj@hotmail.com) 3 3 |----------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A XPath implementation (lexer/parser/evaluator) for tDOM, 9 6 | the DOM implementation for Tcl. 10 7 | Based on November 16 1999 Recommendation of the W3C 11 8 | (http://www.w3.org/TR/1999/REC-xslt-19991116) 12 9 | 13 10 | ................................................................................ 260 257 rs->nr_nodes = 0; 261 258 } else 262 259 if (rs->type == StringResult) { 263 260 if (rs->string) FREE((char*)rs->string); 264 261 } 265 262 rs->type = EmptyResult; 266 263 } 264 + 265 +void 266 +xpathRSReset ( 267 + xpathResultSet *rs, 268 + domNode *node 269 + ) 270 +{ 271 + if (rs->type == StringResult) FREE(rs->string); 272 + if (node) { 273 + if (!rs->nodes) { 274 + rs->nodes = (domNode**)MALLOC( INITIAL_SIZE*sizeof(domNode*)); 275 + rs->allocated = INITIAL_SIZE; 276 + } 277 + rs->nodes[0] = node; 278 + rs->nr_nodes = 1; 279 + rs->type = xNodeSetResult; 280 + } else { 281 + rs->nr_nodes = 0; 282 + if (rs->nodes) rs->type = xNodeSetResult; 283 + else rs->type = EmptyResult; 284 + } 285 +} 267 286 268 287 void rsPrint ( xpathResultSet *rs ) { 269 288 int i = 0,l; char tmp[80]; 270 289 switch (rs->type) { 271 290 case EmptyResult: 272 291 fprintf(stderr, "empty result \n"); 273 292 break; ................................................................................ 673 692 int *useNamespaceAxis, 674 693 xpathParseVarCB *varParseCB, 675 694 char **errMsg 676 695 ) 677 696 { 678 697 int l, allocated; 679 698 int i, k, start, offset; 680 - char delim, *ps, save, tmpErr[80]; 699 + char delim, *ps, save, tmpErr[80], *tailptr; 681 700 const char *uri; 682 701 XPathTokens tokens; 683 702 int token = EOS; 684 703 685 704 686 705 tokens = (XPathTokens)MALLOC(INITIAL_SIZE * sizeof(XPathToken)); 687 706 if (tokens == NULL) { ................................................................................ 1107 1126 tokens[l].intvalue = strtol(ps, NULL, 10); 1108 1127 if (errno == ERANGE 1109 1128 && ( tokens[l].intvalue == LONG_MAX 1110 1129 || tokens[l].intvalue == LONG_MIN)) { 1111 1130 token = REALNUMBER; 1112 1131 } 1113 1132 } 1114 - tokens[l].realvalue = (double)atof(ps); 1133 + tokens[l].realvalue = strtod(ps, &tailptr); 1115 1134 xpath[i--] = save; 1135 + if (tokens[l].realvalue == 0.0 && tailptr == ps) { 1136 + sprintf (tmpErr, "Number value too large " 1137 + "at position %d", i); 1138 + *errMsg = tdomstrdup (tmpErr); 1139 + return tokens; 1140 + } 1116 1141 } else { 1117 1142 sprintf (tmpErr, "Unexpected character '%c' at " 1118 1143 "position %d", xpath[i], i); 1119 1144 *errMsg = tdomstrdup (tmpErr); 1120 1145 return tokens; 1121 1146 } 1122 1147 break; ................................................................................ 2280 2305 varParseCB, errMsg); 2281 2306 if (*errMsg != NULL) { 2282 2307 if (tokens != NULL) xpathFreeTokens (tokens); 2283 2308 return XPATH_LEX_ERR; 2284 2309 } 2285 2310 DDBG( 2286 2311 for (i=0; tokens[i].token != EOS; i++) { 2287 - fprintf(stderr, "%3d %-12s %5ld %8.3f %5d %s\n", 2312 + fprintf(stderr, "%3d %-12s %5ld %8.3g %5d %s\n", 2288 2313 i, 2289 2314 token2str[tokens[i].token-LPAR], 2290 2315 tokens[i].intvalue, 2291 2316 tokens[i].realvalue, 2292 2317 tokens[i].pos, 2293 2318 tokens[i].strvalue 2294 2319 ); ................................................................................ 2313 2338 newlen = strlen(xpath); 2314 2339 *errMsg = (char*)REALLOC(*errMsg, len+newlen+10); 2315 2340 memmove(*errMsg + len, " for '", 6); 2316 2341 memmove(*errMsg + len+6, xpath, newlen); 2317 2342 memmove(*errMsg + len+6+newlen, "' ", 3); 2318 2343 2319 2344 for (i=0; tokens[i].token != EOS; i++) { 2320 - sprintf(tmp, "%s\n%3s%3d %-12s %5ld %09.3f %5d ", 2345 + sprintf(tmp, "%s\n%3s%3d %-12s %5ld %09.3g %5d ", 2321 2346 (i==0) ? "\n\nParsed symbols:" : "", 2322 2347 (i==l) ? "-->" : " ", 2323 2348 i, 2324 2349 token2str[tokens[i].token-LPAR], 2325 2350 tokens[i].intvalue, 2326 2351 tokens[i].realvalue, 2327 2352 tokens[i].pos ................................................................................ 2714 2739 2715 2740 case RealResult: 2716 2741 if (IS_NAN (rs->realvalue)) return tdomstrdup ("NaN"); 2717 2742 else if (IS_INF (rs->realvalue)) { 2718 2743 if (IS_INF (rs->realvalue) == 1) return tdomstrdup ("Infinity"); 2719 2744 else return tdomstrdup ("-Infinity"); 2720 2745 } 2721 - sprintf(tmp, "%f", rs->realvalue); 2746 + sprintf(tmp, "%g", rs->realvalue); 2722 2747 /* strip trailing 0 and . */ 2723 2748 len = strlen(tmp); 2724 2749 for (; (len > 0) && (tmp[len-1] == '0'); len--) tmp[len-1] = '\0'; 2725 2750 if ((len > 0) && (tmp[len-1] == '.')) tmp[len-1] = '\0'; 2726 2751 return (tdomstrdup(tmp)); 2727 2752 2728 2753 case NaNResult: ................................................................................ 4453 4478 rsSetReal (result, dLeft / dRight); 4454 4479 } 4455 4480 break; 4456 4481 case Mod: 4457 4482 if ((int)dRight == 0) { 4458 4483 rsSetNaN (result); 4459 4484 } else { 4460 - rsSetInt (result, ((int)dLeft) % ((int)dRight)); 4485 + if (dRight < LONG_MIN - 0.1 4486 + || dRight > LONG_MAX + 0.1 4487 + || dLeft < LONG_MIN - 0.1 4488 + || dLeft > LONG_MAX + 0.1) { 4489 + rsSetNaN (result); 4490 + } else { 4491 + rsSetInt (result, ((long)dLeft) % ((long)dRight)); 4492 + } 4461 4493 } 4462 4494 break; 4463 4495 default: break; 4464 4496 } 4465 4497 xpathRSFree (&rightResult); 4466 4498 xpathRSFree (&leftResult); 4467 4499 return XPATH_OK; ................................................................................ 5222 5254 CHECK_RC; 5223 5255 5224 5256 DBG(rsPrint( result );) 5225 5257 return 0; 5226 5258 5227 5259 } /* xpathEval */ 5228 5260 5261 + 5262 +int 5263 +xpathEvalAst ( 5264 + ast t, 5265 + xpathResultSet *nodeList, 5266 + domNode *node, 5267 + xpathCBs * cbs, 5268 + xpathResultSet *rs, 5269 + char **errMsg 5270 + ) 5271 +{ 5272 + int i, rc, first = 1, docOrder = 1; 5273 + xpathResultSet savedContext; 5274 + savedContext = *nodeList; 5275 + 5276 + while (t) { 5277 + DBG (fprintf (stderr, "xpathEvalAst: eval step '%s'\n", 5278 + astType2str[t->type]);) 5279 + if (t->type == Pred) { 5280 + *errMsg = "Pred step not expected now!"; 5281 + return XPATH_EVAL_ERR; 5282 + } 5283 + if (first) { 5284 + rc = xpathEvalStepAndPredicates (t, nodeList, node, 5285 + node, 0, &docOrder, 5286 + cbs, rs, errMsg); 5287 + CHECK_RC; 5288 + first = 0; 5289 + } else { 5290 + DBG( fprintf(stderr, "doing location step nodeList->nr_nodes=%d \n", 5291 + nodeList->nr_nodes); 5292 + ) 5293 + if (rs->type != xNodeSetResult) { 5294 + *nodeList = savedContext; 5295 + return 0; 5296 + } 5297 + 5298 + *nodeList = *rs; 5299 + xpathRSReset (rs, NULL); 5300 + for (i=0; i < nodeList->nr_nodes; i++) { 5301 + rc = xpathEvalStepAndPredicates (t, nodeList, 5302 + nodeList->nodes[i], 5303 + node, i, &docOrder, NULL, 5304 + rs, errMsg); 5305 + if (rc) { 5306 + *nodeList = savedContext; 5307 + return rc; 5308 + } 5309 + } 5310 + } 5311 + DBG( fprintf(stderr, "result after location step: \n"); ) 5312 + DBG( rsPrint( result); ) 5313 + 5314 + t = t->next; 5315 + /* skip the already processed Predicate parts */ 5316 + while (t && t->type == Pred) t = t->next; 5317 + docOrder = 1; 5318 + } 5319 + *nodeList = savedContext; 5320 + return 0; 5321 +} 5322 + 5229 5323 /*---------------------------------------------------------------------------- 5230 5324 | xpathMatches 5231 5325 | 5232 5326 \---------------------------------------------------------------------------*/ 5233 5327 int xpathMatches ( 5234 5328 ast step, 5235 5329 domNode * exprContext,
Changes to generic/domxpath.h.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 1999 Jochen Loewer (loewerj@hotmail.com) 3 3 |----------------------------------------------------------------------------- 4 4 | 5 -| $Id$ 6 -| 7 -| 8 5 | A (partial) XPath implementation (lexer/parser/evaluator) for tDOM, 9 6 | the DOM implementation for Tcl. 10 7 | Based on the August 13 working draft of the W3C 11 8 | (http://www.w3.org/1999/08/WD-xpath-19990813.html) 12 9 | 13 10 | 14 11 | The contents of this file are subject to the Mozilla Public License ................................................................................ 171 168 ast *t, char **errMsg); 172 169 void xpathFreeAst (ast t); 173 170 double xpathGetPrio (ast t); 174 171 int xpathEval (domNode *node, domNode *exprContext, char *xpath, 175 172 char **prefixMappings, xpathCBs *cbs, 176 173 xpathParseVarCB *parseVarCB, Tcl_HashTable *catch, 177 174 char **errMsg, xpathResultSet *rs); 175 +int xpathEvalAst (ast t, xpathResultSet *nodeList, domNode *node, 176 + xpathCBs *cbs, xpathResultSet *rs, char **errMsg); 178 177 int xpathMatches (ast steps, domNode * exprContext, domNode *nodeToMatch, 179 178 xpathCBs *cbs, char **errMsg 180 179 ); 181 180 182 181 int xpathEvalSteps (ast steps, xpathResultSet *nodeList, 183 182 domNode *currentNode, domNode *exprContext, int currentPos, 184 183 int *docOrder, 185 184 xpathCBs *cbs, 186 185 xpathResultSet *result, char **errMsg); 187 186 188 187 #define xpathRSInit(x) (x)->type = EmptyResult; \ 189 188 (x)->intvalue = 0; \ 190 189 (x)->nr_nodes = 0; 191 -void xpathRSFree (xpathResultSet *rs ); 190 +void xpathRSFree (xpathResultSet *rs); 191 +void xpathRSReset (xpathResultSet *rs, domNode *ode); 192 192 193 193 int xpathFuncBoolean (xpathResultSet *rs); 194 194 double xpathFuncNumber (xpathResultSet *rs, int *NaN); 195 195 char * xpathFuncString (xpathResultSet *rs); 196 196 char * xpathFuncStringForNode (domNode *node); 197 197 int xpathRound (double r); 198 198 ................................................................................ 206 206 void rsSetString ( xpathResultSet *rs, const char *s ); 207 207 void rsAddNode ( xpathResultSet *rs, domNode *node ); 208 208 void rsAddNodeFast ( xpathResultSet *rs, domNode *node ); 209 209 void rsCopy ( xpathResultSet *to, xpathResultSet *from ); 210 210 211 211 /* This function is only used for debugging code */ 212 212 void rsPrint ( xpathResultSet *rs ); 213 + 214 +/* This function is used (outside of tcldom.c) only by schema.c. It 215 + * has to have a prototype somewhere. */ 216 +int tcldom_xpathFuncCallBack ( 217 + void *clientData, 218 + char *functionName, 219 + domNode *ctxNode, 220 + int position, 221 + xpathResultSet *nodeList, 222 + domNode *exprContext, 223 + int argc, 224 + xpathResultSets *args, 225 + xpathResultSet *result, 226 + char **errMsg 227 + ); 213 228 214 229 #endif 215 230
Changes to generic/domxslt.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 2000 Jochen Loewer (loewerj@hotmail.com) 3 3 |----------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A XSLT implementation for tDOM, according to the W3C 9 6 | recommendation (16 Nov 1999). 10 7 | See http://www.w3.org/TR/1999/REC-xslt-19991116 for details. 11 8 | 12 9 | 13 10 | The contents of this file are subject to the Mozilla Public License ................................................................................ 541 538 domNode * node, 542 539 char * str, 543 540 char ** errMsg) 544 541 { 545 542 Tcl_DString dStr; 546 543 char buffer[1024]; 547 544 const char *baseURI; 548 - int line, column; 545 + long line, column; 549 546 550 547 Tcl_DStringInit (&dStr); 551 548 baseURI = findBaseURI (node); 552 549 if (baseURI) { 553 550 Tcl_DStringAppend (&dStr, "In entity ", 10); 554 551 Tcl_DStringAppend (&dStr, baseURI, -1); 555 552 } 556 553 if (node->nodeFlags & HAS_LINE_COLUMN) { 557 554 domGetLineColumn (node, &line, &column); 558 - sprintf (buffer, " at line %d, column %d:\n", line, column); 555 + sprintf (buffer, " at line %ld, column %ld:\n", line, column); 559 556 Tcl_DStringAppend (&dStr, buffer, -1); 560 557 Tcl_DStringAppend (&dStr, str, -1); 561 558 } else { 562 559 if (baseURI) Tcl_DStringAppend (&dStr, ": ", 2); 563 560 Tcl_DStringAppend (&dStr, str, -1); 564 561 } 565 562 if (*errMsg) FREE (*errMsg); ................................................................................ 2858 2855 xsltState *xs, 2859 2856 domNode *node, 2860 2857 double precedence, 2861 2858 char **errMsg 2862 2859 ) 2863 2860 { 2864 2861 xsltTemplate *tpl, *t; 2865 - char *prioStr, *str, prefix[MAX_PREFIX_LEN]; 2862 + char *prioStr, *str, prefix[MAX_PREFIX_LEN], *tailptr; 2866 2863 const char *localName; 2867 2864 int rc, hnew; 2868 2865 domNS *ns; 2869 2866 Tcl_HashEntry *h; 2870 2867 Tcl_DString dStr; 2871 2868 xsltSubDoc *sDoc; 2872 2869 ................................................................................ 2966 2963 tpl->prio = 0.5; 2967 2964 tpl->content = node; 2968 2965 tpl->precedence = precedence; 2969 2966 tpl->next = NULL; 2970 2967 2971 2968 prioStr = getAttr(node,"priority", a_prio); 2972 2969 if (prioStr) { 2973 - tpl->prio = (double)atof(prioStr); 2974 - } 2970 + tpl->prio = strtod (prioStr, &tailptr); 2971 + if (tpl->prio == 0.0 && prioStr == tailptr) { 2972 + /* If the template has a name attribute, it is already stored in 2973 + in the namedTemplates hash table and will be freed. */ 2974 + if (!tpl->name) { 2975 + FREE ((char*)tpl); 2976 + } 2977 + return -1; 2978 + } 2979 + } 2975 2980 2976 2981 sDoc = xs->subDocs; 2977 2982 while (sDoc) { 2978 2983 if (sDoc->doc == node->ownerDocument) break; 2979 2984 sDoc = sDoc->next; 2980 2985 } 2981 2986 tpl->sDoc = sDoc; ................................................................................ 5783 5788 extResolver = Tcl_NewStringObj(xsltDoc->extResolver, -1); 5784 5789 Tcl_IncrRefCount (extResolver); 5785 5790 } 5786 5791 /* keep white space, no fiddling with the encoding (is this 5787 5792 a good idea?) */ 5788 5793 doc = domReadDocument (parser, xmlstring, len, 0, 0, storeLineColumn, 5789 5794 0, 0, NULL, chan, extbase, extResolver, 0, 5790 - (int) XML_PARAM_ENTITY_PARSING_ALWAYS, NULL, 5795 + (int) XML_PARAM_ENTITY_PARSING_ALWAYS, 5796 +#ifndef TDOM_NO_SCHEMA 5797 + NULL, 5798 +#endif 5791 5799 interp, &resultcode); 5792 5800 if (xsltDoc->extResolver) { 5793 5801 Tcl_DecrRefCount (extResolver); 5794 5802 } 5795 5803 if (doc == NULL) { 5796 5804 DBG(fprintf (stderr, "parse error, str len %d, xmlstring: -->%s<--\n", 5797 5805 strlen (xmlstring), xmlstring);)
Changes to generic/domxslt.h.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 2000 Jochen Loewer (loewerj@hotmail.com) 3 3 |----------------------------------------------------------------------------- 4 4 | 5 -| $Id$ 6 -| 7 -| 8 -| A (partial) XSLT implementation for tDOM, according to the W3C 5 +| A XSLT implementation for tDOM, according to the W3C 9 6 | recommendation (16 Nov 1999, 10 7 | http://www.w3.org/TR/1999/REC-xslt-19991116). 11 8 | 12 9 | 13 10 | The contents of this file are subject to the Mozilla Public License 14 11 | Version 2.0 (the "License"); you may not use this file except in 15 12 | compliance with the License. You may obtain a copy of the License at
Changes to generic/nodecmd.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (C) 1999 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +----------------------------------------------------------------------------- 4 4 | 5 -| Rcsid: @(#)$Id$ 6 -| 7 5 | The contents of this file are subject to the Mozilla Public License 8 6 | Version 2.0 (the "License"); you may not use this file except in 9 7 | compliance with the License. You may obtain a copy of the License at 10 8 | http://www.mozilla.org/MPL/ 11 9 | 12 10 | Software distributed under the License is distributed on an "AS IS" 13 11 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
Changes to generic/nodecmd.h.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (C) 1999 Jochen C. Loewer (loewerj@hotmail.com) 3 3 +----------------------------------------------------------------------------- 4 4 | 5 -| $Id$ 6 - 7 5 | The contents of this file are subject to the Mozilla Public License 8 6 | Version 2.0 (the "License"); you may not use this file except in 9 7 | compliance with the License. You may obtain a copy of the License at 10 8 | http://www.mozilla.org/MPL/ 11 9 | 12 10 | Software distributed under the License is distributed on an "AS IS" 13 11 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
Added generic/schema.c.
1 +/*---------------------------------------------------------------------------- 2 +| Copyright (c) 2018, 2019 Rolf Ade (rolf@pointsman.de) 3 +|----------------------------------------------------------------------------- 4 +| 5 +| 6 +| The contents of this file are subject to the Mozilla Public License 7 +| Version 2.0 (the "License"); you may not use this file except in 8 +| compliance with the License. You may obtain a copy of the License at 9 +| http://www.mozilla.org/MPL/ 10 +| 11 +| Software distributed under the License is distributed on an "AS IS" 12 +| basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 13 +| License for the specific language governing rights and limitations 14 +| under the License. 15 +| 16 +| Contributor(s): 17 +| 18 +| 19 +| written by Rolf Ade 20 +| 2018-2020 21 +| 22 +\---------------------------------------------------------------------------*/ 23 + 24 +#ifndef TDOM_NO_SCHEMA 25 + 26 +#include <tdom.h> 27 +#include <tcldom.h> 28 +#include <domxpath.h> 29 +#include <schema.h> 30 +#include <stdint.h> 31 +#include <fcntl.h> 32 + 33 +#ifdef _MSC_VER 34 +#include <io.h> 35 +#else 36 +#include <unistd.h> 37 +#endif 38 + 39 +/* #define DEBUG */ 40 +/* #define DDEBUG */ 41 +/*---------------------------------------------------------------------------- 42 +| Debug Macros 43 +| 44 +\---------------------------------------------------------------------------*/ 45 +#ifdef DEBUG 46 +# define DBG(x) x 47 +#else 48 +# define DBG(x) 49 +#endif 50 +#if defined(DEBUG) || defined(DDEBUG) 51 +# define DDBG(x) x 52 +#else 53 +# define DDBG(x) 54 +#endif 55 + 56 + 57 +/*---------------------------------------------------------------------------- 58 +| Choice/attribute handling method threshold 59 +| 60 +\---------------------------------------------------------------------------*/ 61 +#ifndef TDOM_CHOICE_HASH_THRESHOLD 62 +# define TDOM_CHOICE_HASH_THRESHOLD 5 63 +#endif 64 +#ifndef TDOM_ATTRIBUTE_HASH_THRESHOLD 65 +# define TDOM_ATTRIBUTE_HASH_THRESHOLD 5 66 +#endif 67 +#ifndef TDOM_EXPAT_READ_SIZE 68 +# define TDOM_EXPAT_READ_SIZE (1024*8) 69 +#endif 70 + 71 +/*---------------------------------------------------------------------------- 72 +| Initial buffer sizes 73 +| 74 +\---------------------------------------------------------------------------*/ 75 +#ifndef CONTENT_ARRAY_SIZE_INIT 76 +# define CONTENT_ARRAY_SIZE_INIT 20 77 +#endif 78 +#ifndef ANON_PATTERN_ARRAY_SIZE_INIT 79 +# define ANON_PATTERN_ARRAY_SIZE_INIT 256 80 +#endif 81 +#ifndef URI_BUFFER_LEN_INIT 82 +# define URI_BUFFER_LEN_INIT 128 83 +#endif 84 +#ifndef ATTR_ARRAY_INIT 85 +# define ATTR_ARRAY_INIT 4 86 +#endif 87 +#ifndef WHITESPACETC_BUFFER_LEN_INIT 88 +# define WHITESPACETC_BUFFER_LEN_INIT 200 89 +#endif 90 + 91 +/*---------------------------------------------------------------------------- 92 +| Local defines 93 +| 94 +\---------------------------------------------------------------------------*/ 95 +#ifndef O_BINARY 96 +# ifdef _O_BINARY 97 +# define O_BINARY _O_BINARY 98 +# else 99 +# define O_BINARY 0 100 +# endif 101 +#endif 102 +#if !defined(PTR2UINT) 103 +# if defined(HAVE_UINTPTR_T) || defined(uintptr_t) 104 +# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) 105 +# else 106 +# define PTR2UINT(p) ((unsigned int)(p)) 107 +# endif 108 +#endif 109 +#if !defined(UINT2PTR) 110 +# if defined(HAVE_UINTPTR_T) || defined(uintptr_t) 111 +# define UINT2PTR(p) ((void *)(uintptr_t)(p)) 112 +# else 113 +# define UINT2PTR(p) ((void *)(p)) 114 +# endif 115 +#endif 116 +#ifndef TCL_MATCH_NOCASE 117 +# define TCL_MATCH_NOCASE 1 118 +#endif 119 + 120 +/*---------------------------------------------------------------------------- 121 +| Local typedefs 122 +| 123 +\---------------------------------------------------------------------------*/ 124 + 125 +typedef struct 126 +{ 127 + SchemaData *sdata; 128 + Tcl_Interp *interp; 129 + XML_Parser parser; 130 + Tcl_DString *cdata; 131 + int onlyWhiteSpace; 132 + char *uri; 133 + int maxUriLen; 134 +} ValidateMethodData; 135 + 136 +typedef enum { 137 + MATCH_GLOBAL = 1, 138 + MATCH_ELEMENT_START, 139 + MATCH_ELEMENT_END, 140 + MATCH_TEXT, 141 + MATCH_ATTRIBUTE_TEXT, 142 + MATCH_DOM_KEYCONSTRAINT, 143 + MATCH_DOM_XPATH_BOOLEAN 144 +} ValidationAction; 145 + 146 +static char *ValidationAction2str[] = { 147 + "NOT_USED", 148 + "MATCH_GLOBAL", 149 + "MATCH_ELEMENT_START", 150 + "MATCH_ELEMENT_END", 151 + "MATCH_TEXT", 152 + "MATCH_ATTRIBUTE_TEXT", 153 + "MATCH_DOM_KEYCONSTRAINT", 154 + "MATCH_DOM_XPATH_BOOLEAN" 155 +}; 156 + 157 +typedef enum { 158 + DOM_KEYCONSTRAINT, 159 + DOM_XPATH_BOOLEAN, 160 + MISSING_ATTRIBUTE, 161 + MISSING_ELEMENT_MATCH_START, 162 + MISSING_ELEMENT_MATCH_END, 163 + UNEXPECTED_TEXT, 164 + MISSING_TEXT_MATCH_START, 165 + MISSING_TEXT_MATCH_END, 166 + UNEXPECTED_ROOT_ELEMENT, 167 + UNEXPECTED_ELEMENT, 168 + UNKNOWN_ATTRIBUTE, 169 + INVALID_KEYREF_MATCH_START, 170 + INVALID_KEYREF_MATCH_END, 171 + INVALID_KEYREF_MATCH_TEXT, 172 + UNKNOWN_ROOT_ELEMENT, 173 + UNKOWN_GLOBAL_ID, 174 + UNKOWN_ID, 175 + INVALID_ATTRIBUTE_VALUE, 176 + INVALID_VALUE 177 +} ValidationErrorType; 178 + 179 +static char *ValidationErrorType2str[] = { 180 + "DOM_KEYCONSTRAINT", 181 + "DOM_XPATH_BOOLEAN", 182 + "MISSING_ATTRIBUTE", 183 + "MISSING_ELEMENT", 184 + "MISSING_ELEMENT", 185 + "UNEXPECTED_TEXT", 186 + "MISSING_TEXT", 187 + "MISSING_TEXT", 188 + "UNEXPECTED_ROOT_ELEMENT", 189 + "UNEXPECTED_ELEMENT", 190 + "UNKNOWN_ATTRIBUTE", 191 + "INVALID_KEYREF", 192 + "INVALID_KEYREF", 193 + "INVALID_KEYREF", 194 + "UNKNOWN_ROOT_ELEMENT", 195 + "UNKOWN_GLOBAL_ID", 196 + "UNKOWN_ID", 197 + "INVALID_ATTRIBUTE_VALUE", 198 + "INVALID_VALUE" 199 +}; 200 + 201 +/*---------------------------------------------------------------------------- 202 +| Recovering related flage 203 +| 204 +\---------------------------------------------------------------------------*/ 205 + 206 +#define RECOVER_FLAG_REWIND 1 207 +#define RECOVER_FLAG_DONT_REPORT 2 208 +#define RECOVER_FLAG_IGNORE 4 209 +#define RECOVER_FLAG_MATCH_END_CONTINUE 8 210 + 211 +/*---------------------------------------------------------------------------- 212 +| [schemacmd info expected] related flags 213 +| 214 +\---------------------------------------------------------------------------*/ 215 + 216 +#define EXPECTED_IGNORE_MATCHED 1 217 +#define EXPECTED_ONLY_MANDATORY 2 218 +#define EXPECTED_PROBE_MAYSKIP 4 219 + 220 +/*---------------------------------------------------------------------------- 221 +| domKeyConstraint related flage 222 +| 223 +\---------------------------------------------------------------------------*/ 224 + 225 +#define DKC_FLAG_IGNORE_EMPTY_FIELD_SET 1 226 +#define DKC_FLAG_BOOLEAN 2 227 + 228 +/*---------------------------------------------------------------------------- 229 +| Macros 230 +| 231 +\---------------------------------------------------------------------------*/ 232 +#define SetResult(str) Tcl_ResetResult(interp); \ 233 + Tcl_SetStringObj(Tcl_GetObjResult(interp), (str), -1) 234 +#define SetResultV(str) if (!sdata->evalError) { \ 235 + Tcl_ResetResult(interp); \ 236 + Tcl_SetStringObj(Tcl_GetObjResult(interp), (str), -1); \ 237 + } 238 +#define SetResult3(str1,str2,str3) Tcl_ResetResult(interp); \ 239 + Tcl_AppendResult(interp, (str1), (str2), (str3), NULL) 240 +#define SetResult3V(str1,str2,str3) if (!sdata->evalError) { \ 241 + Tcl_ResetResult(interp); \ 242 + Tcl_AppendResult(interp, (str1), (str2), (str3), NULL); \ 243 + } 244 +#define SetIntResult(i) Tcl_ResetResult(interp); \ 245 + Tcl_SetIntObj(Tcl_GetObjResult(interp), (i)) 246 +#define SetLongResult(i) Tcl_ResetResult(interp); \ 247 + Tcl_SetLongObj(Tcl_GetObjResult(interp), (i)) 248 +#define SetBooleanResult(i) Tcl_ResetResult(interp); \ 249 + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (i)) 250 + 251 +#define SPACE(c) IS_XML_WHITESPACE ((c)) 252 + 253 +#define checkNrArgs(l,h,err) if (objc < l || objc > h) { \ 254 + SetResult (err); \ 255 + return TCL_ERROR; \ 256 + } 257 + 258 +#if defined(DEBUG) || defined(DDEBUG) 259 +static char *Schema_CP_Type2str[] = { 260 + "ANY", 261 + "NAME", 262 + "CHOICE", 263 + "INTERLEAVE", 264 + "PATTERN", 265 + "TEXT", 266 + "VIRTUAL", 267 + "KEYSPACE_START", 268 + "KEYSPACE_END" 269 +}; 270 +static char *Schema_Quant_Type2str[] = { 271 + "ONE", 272 + "OPT", 273 + "REP", 274 + "PLUS", 275 + "NM", 276 + "ERROR" 277 +}; 278 +#endif 279 + 280 + 281 +#ifndef TCL_THREADS 282 + static SchemaData *activeSchemaData = 0; 283 +# define GETASI activeSchemaData 284 +# define SETASI(v) activeSchemaData = v 285 +#else 286 + static Tcl_ThreadDataKey activeSchemaData; 287 +# define GETASI *(SchemaData**) Tcl_GetThreadData(&activeSchemaData, \ 288 + sizeof(SchemaData*)) 289 +static void SetActiveSchemaData (SchemaData *v) 290 +{ 291 + SchemaData **schemaInfoPtr = Tcl_GetThreadData(&activeSchemaData, 292 + sizeof (SchemaData*)); 293 + *schemaInfoPtr = v; 294 +} 295 +# define SETASI(v) SetActiveSchemaData (v) 296 +#endif 297 + 298 +#define CHECK_SI \ 299 + if (!sdata) { \ 300 + SetResult ("Command called outside of schema context"); \ 301 + return TCL_ERROR; \ 302 + } \ 303 + if (sdata->isTextConstraint) { \ 304 + SetResult ("Command called in invalid schema context"); \ 305 + return TCL_ERROR; \ 306 + } 307 + 308 +#define CHECK_TI \ 309 + if (!sdata) { \ 310 + SetResult ("Command called outside of schema context"); \ 311 + return TCL_ERROR; \ 312 + } \ 313 + if (!sdata->isTextConstraint) { \ 314 + SetResult ("Command called in invalid schema context"); \ 315 + return TCL_ERROR; \ 316 + } 317 + 318 +#define CHECK_TOPLEVEL \ 319 + if (sdata->defineToplevel) { \ 320 + SetResult("Command not allowed at top level " \ 321 + "in schema define evaluation"); \ 322 + return TCL_ERROR; \ 323 + } 324 + 325 +#define CHECK_RECURSIVE_CALL \ 326 + if (clientData != NULL) { \ 327 + savedsdata = GETASI; \ 328 + if (savedsdata == sdata) { \ 329 + SetResult ("This recursive call is not allowed"); \ 330 + return TCL_ERROR; \ 331 + } \ 332 + } else if (!sdata->defineToplevel) { \ 333 + SetResult ("Command only allowed at lop level"); \ 334 + return TCL_ERROR; \ 335 + } 336 + 337 +#define CHECK_EVAL \ 338 + if (sdata->currentEvals) { \ 339 + SetResult ("This method is not allowed in nested evaluation"); \ 340 + return TCL_ERROR; \ 341 + } 342 + 343 +#define CHECK_REWIND \ 344 + if (sdata->recoverFlags & RECOVER_FLAG_REWIND) { \ 345 + rewindStack (sdata); \ 346 + sdata->recoverFlags &= ~RECOVER_FLAG_REWIND; \ 347 + } \ 348 + 349 +#define REMEMBER_PATTERN(pattern) \ 350 + if (sdata->numPatternList == sdata->patternListSize) { \ 351 + sdata->patternList = (SchemaCP **) REALLOC ( \ 352 + sdata->patternList, \ 353 + sizeof (SchemaCP*) * sdata->patternListSize * 2); \ 354 + sdata->patternListSize *= 2; \ 355 + } \ 356 + sdata->patternList[sdata->numPatternList] = pattern; \ 357 + sdata->numPatternList++; 358 + 359 + 360 +#define ADD_CONSTRAINT(sdata, sc) \ 361 + sc = TMALLOC (SchemaConstraint); \ 362 + memset (sc, 0, sizeof (SchemaConstraint)); \ 363 + if (sdata->cp->nc == sdata->contentSize) { \ 364 + sdata->cp->content = \ 365 + REALLOC (sdata->cp->content, \ 366 + 2 * sdata->contentSize \ 367 + * sizeof (SchemaCP*)); \ 368 + sdata->cp->quants = \ 369 + REALLOC (sdata->cp->quants, \ 370 + 2 * sdata->contentSize \ 371 + * sizeof (SchemaQuant)); \ 372 + sdata->contentSize *= 2; \ 373 + } \ 374 + sdata->cp->content[sdata->cp->nc] = (SchemaCP *) sc; \ 375 + sdata->cp->quants[sdata->cp->nc] = SCHEMA_CQUANT_ONE; \ 376 + sdata->cp->nc++; \ 377 + 378 +#define maxOne(quant) \ 379 + ((quant) == SCHEMA_CQUANT_ONE || (quant) == SCHEMA_CQUANT_OPT) ? 1 : 0 380 + 381 +#define minOne(quant) \ 382 + ((quant) == SCHEMA_CQUANT_ONE || (quant) == SCHEMA_CQUANT_PLUS) ? 1 : 0 383 + 384 +#define mayRepeat(quant) \ 385 + ((quant) == SCHEMA_CQUANT_REP || (quant) == SCHEMA_CQUANT_PLUS) ? 1 : 0 386 + 387 +#define mayMiss(quant) \ 388 + ((quant) == SCHEMA_CQUANT_REP || (quant) == SCHEMA_CQUANT_OPT) ? 1 : 0 389 + 390 +#define hasMatched(quant,hm) \ 391 + (hm) == 0 ? mayMiss(quant) : 1 392 + 393 +#define mustMatch(quant,hm) \ 394 + (hm) == 0 ? minOne(quant) : 0 395 + 396 + 397 +#define getContext(cp, ac, hm) \ 398 + cp = se->pattern; \ 399 + ac = se->activeChild; \ 400 + hm = se->hasMatched; \ 401 + if (hm && maxOne (cp->quants[ac])) { \ 402 + ac += + 1; \ 403 + hm = 0; \ 404 + } \ 405 + 406 + 407 +#define updateStack(sdata,se,ac) \ 408 + if (!(sdata->recoverFlags & RECOVER_FLAG_REWIND)) { \ 409 + se->activeChild = ac; \ 410 + se->hasMatched = 1; \ 411 + } \ 412 + 413 + 414 +#ifndef TCL_THREADS 415 +SchemaData * 416 +tdomGetSchemadata (Tcl_Interp *interp) 417 +{ 418 + return activeSchemaData; 419 +} 420 +#else 421 +SchemaData * 422 +tdomGetSchemadata (void) 423 +{ 424 + return GETASI; 425 +} 426 +#endif 427 + 428 +static SchemaCP* 429 +initSchemaCP ( 430 + Schema_CP_Type type, 431 + void *namespace, 432 + char *name 433 + ) 434 +{ 435 + SchemaCP *pattern; 436 + 437 + pattern = TMALLOC (SchemaCP); 438 + memset (pattern, 0, sizeof(SchemaCP)); 439 + pattern->type = type; 440 + switch (type) { 441 + case SCHEMA_CTYPE_NAME: 442 + pattern->flags |= CONSTRAINT_TEXT_CHILD; 443 + /* Fall thru. */ 444 + case SCHEMA_CTYPE_PATTERN: 445 + pattern->namespace = (char *)namespace; 446 + pattern->name = name; 447 + /* Fall thru. */ 448 + case SCHEMA_CTYPE_CHOICE: 449 + case SCHEMA_CTYPE_INTERLEAVE: 450 + pattern->content = (SchemaCP**) MALLOC ( 451 + sizeof(SchemaCP*) * CONTENT_ARRAY_SIZE_INIT 452 + ); 453 + pattern->quants = (SchemaQuant*) MALLOC ( 454 + sizeof (SchemaQuant) * CONTENT_ARRAY_SIZE_INIT 455 + ); 456 + break; 457 + case SCHEMA_CTYPE_TEXT: 458 + /* content/quant will be allocated, if the cp in fact has 459 + * constraints */ 460 + break; 461 + case SCHEMA_CTYPE_KEYSPACE_END: 462 + case SCHEMA_CTYPE_KEYSPACE: 463 + pattern->name = name; 464 + break; 465 + case SCHEMA_CTYPE_ANY: 466 + pattern->namespace = namespace; 467 + break; 468 + case SCHEMA_CTYPE_VIRTUAL: 469 + /* Do nothing */ 470 + break; 471 + } 472 + return pattern; 473 +} 474 + 475 +DDBG( 476 +static void serializeCP ( 477 + SchemaCP *pattern 478 + ) 479 +{ 480 + fprintf (stderr, "CP %p type: %s\n", 481 + pattern, Schema_CP_Type2str[pattern->type]); 482 + switch (pattern->type) { 483 + case SCHEMA_CTYPE_KEYSPACE_END: 484 + case SCHEMA_CTYPE_KEYSPACE: 485 + fprintf (stderr, "\tName: '%s'\n", pattern->name); 486 + break; 487 + case SCHEMA_CTYPE_NAME: 488 + case SCHEMA_CTYPE_PATTERN: 489 + fprintf (stderr, "\tName: '%s' Namespace: '%s'\n", 490 + pattern->name, pattern->namespace); 491 + if (pattern->flags & FORWARD_PATTERN_DEF) { 492 + fprintf (stderr, "\tAnonymously defined NAME\n"); 493 + } 494 + if (pattern->flags & PLACEHOLDER_PATTERN_DEF) { 495 + fprintf (stderr, "\tAs placeholder defined NAME\n"); 496 + } 497 + if (pattern->flags & LOCAL_DEFINED_ELEMENT) { 498 + fprintf (stderr, "\tLocal defined NAME\n"); 499 + } 500 + if (pattern->flags & ELEMENTTYPE_DEF) { 501 + fprintf (stderr, "\tElementtype '%s'\n", pattern->typeName); 502 + } 503 + /* Fall thru. */ 504 + case SCHEMA_CTYPE_CHOICE: 505 + case SCHEMA_CTYPE_INTERLEAVE: 506 + fprintf (stderr, "\t%d childs\n", pattern->nc); 507 + break; 508 + case SCHEMA_CTYPE_ANY: 509 + if (pattern->namespace) { 510 + fprintf (stderr, "\tNamespace: '%s'\n", 511 + pattern->namespace); 512 + } 513 + break; 514 + case SCHEMA_CTYPE_TEXT: 515 + case SCHEMA_CTYPE_VIRTUAL: 516 + /* Do nothing */ 517 + break; 518 + } 519 +} 520 + 521 +static void serializeQuant ( 522 + SchemaQuant quant 523 + ) 524 +{ 525 + fprintf (stderr, "Quant type: %s\n", 526 + Schema_Quant_Type2str[quant]); 527 +} 528 + 529 +static int getDeep ( 530 + SchemaValidationStack *se 531 + ) 532 +{ 533 + int i = 0; 534 + while (se) { 535 + if (se->pattern->type == SCHEMA_CTYPE_NAME) i++; 536 + se = se->down; 537 + } 538 + return i; 539 +} 540 + 541 +static void serializeStack ( 542 + SchemaData *sdata 543 + ) 544 +{ 545 + SchemaValidationStack *se; 546 + 547 + fprintf (stderr, "++++ Current validation stack:\n"); 548 + se = sdata->stack; 549 + while (se) { 550 + serializeCP (se->pattern); 551 + fprintf (stderr, "\tdeep: %d ac: %d hm: %d\n", 552 + getDeep (se), se->activeChild, se->hasMatched); 553 + se = se->down; 554 + } 555 + fprintf (stderr, "++++ Stack bottom\n"); 556 +} 557 +) 558 + 559 +/* DBG end */ 560 + 561 + 562 +static void freedomKeyConstraints ( 563 + domKeyConstraint *kc 564 + ) 565 +{ 566 + domKeyConstraint *knext; 567 + int i; 568 + 569 + while (kc) { 570 + knext = kc->next; 571 + if (kc->name) FREE (kc->name); 572 + if (kc->emptyFieldSetValue) FREE (kc->emptyFieldSetValue); 573 + xpathFreeAst (kc->selector); 574 + for (i = 0; i < kc->nrFields; i++) { 575 + xpathFreeAst (kc->fields[i]); 576 + } 577 + FREE (kc->fields); 578 + FREE (kc); 579 + kc = knext; 580 + } 581 +} 582 + 583 +static void freeSchemaCP ( 584 + SchemaCP *pattern 585 + ) 586 +{ 587 + int i; 588 + SchemaConstraint *sc; 589 + 590 + switch (pattern->type) { 591 + case SCHEMA_CTYPE_ANY: 592 + /* do nothing */ 593 + break; 594 + case SCHEMA_CTYPE_VIRTUAL: 595 + for (i = 0; i < pattern->nc; i++) { 596 + Tcl_DecrRefCount ((Tcl_Obj *)pattern->content[i]); 597 + } 598 + FREE (pattern->content); 599 + break; 600 + case SCHEMA_CTYPE_TEXT: 601 + for (i = 0; i < pattern->nc; i++) { 602 + sc = (SchemaConstraint *) pattern->content[i]; 603 + if (sc->freeData) { 604 + (sc->freeData) (sc->constraintData); 605 + } 606 + FREE (pattern->content[i]); 607 + } 608 + /* Fall throu */ 609 + default: 610 + FREE (pattern->content); 611 + FREE (pattern->quants); 612 + if (pattern->attrs) { 613 + for (i = 0; i < pattern->numAttr; i++) { 614 + FREE (pattern->attrs[i]); 615 + } 616 + FREE (pattern->attrs); 617 + } 618 + freedomKeyConstraints (pattern->domKeys); 619 + if (pattern->typedata) { 620 + Tcl_DeleteHashTable ((Tcl_HashTable *) pattern->typedata); 621 + FREE (pattern->typedata); 622 + } 623 + break; 624 + } 625 + if (pattern->defScript) { 626 + Tcl_DecrRefCount (pattern->defScript); 627 + } 628 + if (pattern->associated) { 629 + Tcl_DecrRefCount (pattern->associated); 630 + } 631 + FREE (pattern); 632 +} 633 + 634 +static SchemaData* 635 +initSchemaData ( 636 + Tcl_Obj *cmdNameObj) 637 +{ 638 + SchemaData *sdata; 639 + int hnew, len; 640 + char *name; 641 + 642 + sdata = TMALLOC (SchemaData); 643 + memset (sdata, 0, sizeof(SchemaData)); 644 + name = Tcl_GetStringFromObj (cmdNameObj, &len); 645 + sdata->self = Tcl_NewStringObj (name, len); 646 + Tcl_IncrRefCount (sdata->self); 647 + Tcl_InitHashTable (&sdata->element, TCL_STRING_KEYS); 648 + Tcl_InitHashTable (&sdata->elementType, TCL_STRING_KEYS); 649 + Tcl_InitHashTable (&sdata->prefix, TCL_STRING_KEYS); 650 + Tcl_InitHashTable (&sdata->pattern, TCL_STRING_KEYS); 651 + Tcl_InitHashTable (&sdata->attrNames, TCL_STRING_KEYS); 652 + Tcl_InitHashTable (&sdata->namespace, TCL_STRING_KEYS); 653 + Tcl_InitHashTable (&sdata->textDef, TCL_STRING_KEYS); 654 + sdata->emptyNamespace = Tcl_CreateHashEntry ( 655 + &sdata->namespace, "", &hnew); 656 + sdata->patternList = (SchemaCP **) MALLOC ( 657 + sizeof (SchemaCP*) * ANON_PATTERN_ARRAY_SIZE_INIT); 658 + sdata->patternListSize = ANON_PATTERN_ARRAY_SIZE_INIT; 659 + /* evalStub initialization */ 660 + sdata->evalStub = (Tcl_Obj **) MALLOC (sizeof (Tcl_Obj*) * 4); 661 + sdata->evalStub[0] = Tcl_NewStringObj("::namespace", 11); 662 + Tcl_IncrRefCount (sdata->evalStub[0]); 663 + sdata->evalStub[1] = Tcl_NewStringObj("eval", 4); 664 + Tcl_IncrRefCount (sdata->evalStub[1]); 665 + sdata->evalStub[2] = Tcl_NewStringObj("::tdom::schema", 14); 666 + Tcl_IncrRefCount (sdata->evalStub[2]); 667 + /* textStub initialization */ 668 + sdata->textStub = (Tcl_Obj **) MALLOC (sizeof (Tcl_Obj*) * 4); 669 + sdata->textStub[0] = Tcl_NewStringObj("::namespace", 11); 670 + Tcl_IncrRefCount (sdata->textStub[0]); 671 + sdata->textStub[1] = Tcl_NewStringObj("eval", 4); 672 + Tcl_IncrRefCount (sdata->textStub[1]); 673 + sdata->textStub[2] = Tcl_NewStringObj("::tdom::schema::text", 20); 674 + Tcl_IncrRefCount (sdata->textStub[2]); 675 + sdata->cdata = TMALLOC (Tcl_DString); 676 + Tcl_DStringInit (sdata->cdata); 677 + Tcl_InitHashTable (&sdata->ids, TCL_STRING_KEYS); 678 + sdata->unknownIDrefs = 0; 679 + Tcl_InitHashTable (&sdata->idTables, TCL_STRING_KEYS); 680 + Tcl_InitHashTable (&sdata->keySpaces, TCL_STRING_KEYS); 681 + sdata->choiceHashThreshold = TDOM_CHOICE_HASH_THRESHOLD; 682 + sdata->attributeHashThreshold = TDOM_ATTRIBUTE_HASH_THRESHOLD; 683 + return sdata; 684 +} 685 + 686 +static void schemaInstanceDelete ( 687 + ClientData clientData 688 + ) 689 +{ 690 + SchemaData *sdata = (SchemaData *) clientData; 691 + unsigned int i; 692 + SchemaValidationStack *down; 693 + Tcl_HashEntry *h; 694 + Tcl_HashSearch search; 695 + SchemaDocKey *dk; 696 + SchemaKeySpace *ks; 697 + 698 + /* Protect the clientData to be freed inside (even nested) 699 + * Tcl_Eval*() calls to avoid invalid mem access and postpone the 700 + * cleanup until the Tcl_Eval*() calls are finished (done in 701 + * tDOM_schemaInstanceCmd()). */ 702 + if (sdata->currentEvals || sdata->inuse > 0) { 703 + sdata->cleanupAfterUse = 1; 704 + return; 705 + } 706 + Tcl_DecrRefCount (sdata->self); 707 + if (sdata->start) FREE (sdata->start); 708 + if (sdata->prefixns) { 709 + i = 0; 710 + while (sdata->prefixns[i]) { 711 + FREE (sdata->prefixns[i]); 712 + i++; 713 + } 714 + FREE (sdata->prefixns); 715 + } 716 + Tcl_DeleteHashTable (&sdata->namespace); 717 + Tcl_DeleteHashTable (&sdata->element); 718 + Tcl_DeleteHashTable (&sdata->elementType); 719 + Tcl_DeleteHashTable (&sdata->prefix); 720 + Tcl_DeleteHashTable (&sdata->pattern); 721 + Tcl_DeleteHashTable (&sdata->attrNames); 722 + Tcl_DeleteHashTable (&sdata->textDef); 723 + for (i = 0; i < sdata->numPatternList; i++) { 724 + freeSchemaCP (sdata->patternList[i]); 725 + } 726 + FREE (sdata->patternList); 727 + FREE (sdata->quants); 728 + while (sdata->stack) { 729 + down = sdata->stack->down; 730 + if (sdata->stack->interleaveState) 731 + FREE (sdata->stack->interleaveState); 732 + FREE (sdata->stack); 733 + sdata->stack = down; 734 + } 735 + while (sdata->lastMatchse) { 736 + down = sdata->lastMatchse->down; 737 + if (sdata->lastMatchse->interleaveState) 738 + FREE (sdata->lastMatchse->interleaveState); 739 + FREE (sdata->lastMatchse); 740 + sdata->lastMatchse = down; 741 + } 742 + while (sdata->stackPool) { 743 + down = sdata->stackPool->down; 744 + /* interleaveState always got cleand up at puting se back to 745 + * pool */ 746 + FREE (sdata->stackPool); 747 + sdata->stackPool = down; 748 + } 749 + Tcl_DecrRefCount (sdata->evalStub[0]); 750 + Tcl_DecrRefCount (sdata->evalStub[1]); 751 + Tcl_DecrRefCount (sdata->evalStub[2]); 752 + FREE (sdata->evalStub); 753 + Tcl_DecrRefCount (sdata->textStub[0]); 754 + Tcl_DecrRefCount (sdata->textStub[1]); 755 + Tcl_DecrRefCount (sdata->textStub[2]); 756 + FREE (sdata->textStub); 757 + Tcl_DStringFree (sdata->cdata); 758 + FREE (sdata->cdata); 759 + if (sdata->reportCmd) { 760 + Tcl_DecrRefCount (sdata->reportCmd); 761 + } 762 + Tcl_DeleteHashTable (&sdata->ids); 763 + for (h = Tcl_FirstHashEntry (&sdata->idTables, &search); 764 + h != NULL; 765 + h = Tcl_NextHashEntry (&search)) { 766 + dk = Tcl_GetHashValue (h); 767 + Tcl_DeleteHashTable (&dk->ids); 768 + FREE (dk); 769 + } 770 + Tcl_DeleteHashTable (&sdata->idTables); 771 + for (h = Tcl_FirstHashEntry (&sdata->keySpaces, &search); 772 + h != NULL; 773 + h = Tcl_NextHashEntry (&search)) { 774 + ks = Tcl_GetHashValue (h); 775 + if (ks->active) { 776 + Tcl_DeleteHashTable (&ks->ids); 777 + } 778 + FREE (ks); 779 + } 780 + Tcl_DeleteHashTable (&sdata->keySpaces); 781 + if (sdata->wsbufLen) { 782 + FREE (sdata->wsbuf); 783 + } 784 + FREE (sdata); 785 +} 786 + 787 +static void 788 +cleanupLastPattern ( 789 + SchemaData *sdata, 790 + unsigned int from 791 + ) 792 +{ 793 + unsigned int i; 794 + char *name; 795 + Tcl_HashTable *hashTable; 796 + Tcl_HashEntry *h; 797 + 798 + SchemaCP *this, *previous, *current; 799 + 800 + for (i = from; i < sdata->numPatternList; i++) { 801 + this = sdata->patternList[i]; 802 + hashTable = NULL; 803 + name = NULL; 804 + if (this->type == SCHEMA_CTYPE_NAME) { 805 + /* Local defined elements aren't saved under their local 806 + * name bucket in the sdata->element hash table. */ 807 + if (this->flags & LOCAL_DEFINED_ELEMENT) { 808 + freeSchemaCP (sdata->patternList[i]); 809 + continue; 810 + } 811 + if (this->flags & ELEMENTTYPE_DEF) { 812 + hashTable = &sdata->elementType; 813 + name = this->typeName; 814 + } else { 815 + hashTable = &sdata->element; 816 + name = this->name; 817 + } 818 + } 819 + if (this->type == SCHEMA_CTYPE_PATTERN) { 820 + hashTable = &sdata->pattern; 821 + name = this->name; 822 + } 823 + if (name && hashTable) { 824 + if (this->flags & FORWARD_PATTERN_DEF) { 825 + sdata->forwardPatternDefs--; 826 + } 827 + h = Tcl_FindHashEntry (hashTable, name); 828 + previous = NULL; 829 + current = Tcl_GetHashValue (h); 830 + while (current != NULL && current != this) { 831 + previous = current; 832 + current = current->next; 833 + } 834 + if (previous) { 835 + if (current->next) { 836 + previous->next = current->next; 837 + } else { 838 + previous->next = NULL; 839 + } 840 + } else { 841 + if (current && current->next) { 842 + Tcl_SetHashValue (h, current->next); 843 + } else { 844 + Tcl_DeleteHashEntry (h); 845 + } 846 + } 847 + } 848 + freeSchemaCP (sdata->patternList[i]); 849 + } 850 + sdata->numPatternList = from; 851 +} 852 + 853 +static void 854 +addToContent ( 855 + SchemaData *sdata, 856 + SchemaCP *pattern, 857 + SchemaQuant quant, 858 + int n, 859 + int m 860 + ) 861 +{ 862 + SchemaCP *wrapperCP; 863 + SchemaCP *savedCP = NULL; 864 + unsigned int savedContenSize; 865 + 866 + if (sdata->cp->type == SCHEMA_CTYPE_NAME 867 + && sdata->cp->flags & CONSTRAINT_TEXT_CHILD 868 + && (pattern->type != SCHEMA_CTYPE_TEXT 869 + || pattern->nc == 0)) { 870 + sdata->cp->flags &= ~CONSTRAINT_TEXT_CHILD; 871 + } 872 + if (sdata->cp->type == SCHEMA_CTYPE_CHOICE 873 + || sdata->cp->type == SCHEMA_CTYPE_INTERLEAVE) { 874 + if (pattern->type == SCHEMA_CTYPE_CHOICE) { 875 + if (pattern->flags & MIXED_CONTENT) { 876 + sdata->cp->flags |= MIXED_CONTENT; 877 + } 878 + wrapperCP = initSchemaCP (SCHEMA_CTYPE_PATTERN, NULL, NULL); 879 + REMEMBER_PATTERN (wrapperCP); 880 + wrapperCP->content[0] = pattern; 881 + wrapperCP->quants[0] = SCHEMA_CQUANT_ONE; 882 + wrapperCP->nc = 1; 883 + pattern = wrapperCP; 884 + } 885 + if (sdata->cp->type == SCHEMA_CTYPE_CHOICE 886 + && quant != SCHEMA_CQUANT_ONE) { 887 + wrapperCP = initSchemaCP (SCHEMA_CTYPE_PATTERN, NULL, NULL); 888 + REMEMBER_PATTERN (wrapperCP); 889 + if (sdata->cp->nc == sdata->contentSize) { 890 + sdata->cp->content = 891 + REALLOC (sdata->cp->content, 892 + 2 * sdata->contentSize 893 + * sizeof (SchemaCP*)); 894 + sdata->cp->quants = 895 + REALLOC (sdata->cp->quants, 896 + 2 * sdata->contentSize 897 + * sizeof (SchemaQuant)); 898 + sdata->contentSize *= 2; 899 + } 900 + sdata->cp->content[sdata->cp->nc] = wrapperCP; 901 + sdata->cp->quants[sdata->cp->nc] = SCHEMA_CQUANT_ONE; 902 + sdata->cp->nc++; 903 + savedCP = sdata->cp; 904 + savedContenSize = sdata->contentSize; 905 + sdata->cp = wrapperCP; 906 + sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 907 + } 908 + } 909 + if (quant == SCHEMA_CQUANT_NM) { 910 + int i; 911 + int newChilds = (n >= m) ? n : m; 912 + while (sdata->cp->nc + newChilds >= sdata->contentSize) { 913 + sdata->cp->content = 914 + REALLOC (sdata->cp->content, 915 + 2 * sdata->contentSize 916 + * sizeof (SchemaCP*)); 917 + sdata->cp->quants = 918 + REALLOC (sdata->cp->quants, 919 + 2 * sdata->contentSize 920 + * sizeof (SchemaQuant)); 921 + sdata->contentSize *= 2; 922 + } 923 + for (i = 0; i < n; i++) { 924 + sdata->cp->content[sdata->cp->nc+i] = pattern; 925 + sdata->cp->quants[sdata->cp->nc+i] = SCHEMA_CQUANT_ONE; 926 + } 927 + for (i = n; i < m; i++) { 928 + sdata->cp->content[sdata->cp->nc+i] = pattern; 929 + sdata->cp->quants[sdata->cp->nc+i] = SCHEMA_CQUANT_OPT; 930 + } 931 + sdata->cp->nc = sdata->cp->nc + newChilds; 932 + } else { 933 + if (sdata->cp->nc == sdata->contentSize) { 934 + sdata->cp->content = 935 + REALLOC (sdata->cp->content, 936 + 2 * sdata->contentSize 937 + * sizeof (SchemaCP*)); 938 + sdata->cp->quants = 939 + REALLOC (sdata->cp->quants, 940 + 2 * sdata->contentSize 941 + * sizeof (SchemaQuant)); 942 + sdata->contentSize *= 2; 943 + } 944 + sdata->cp->content[sdata->cp->nc] = pattern; 945 + sdata->cp->quants[sdata->cp->nc] = quant; 946 + sdata->cp->nc++; 947 + } 948 + if (savedCP) { 949 + sdata->cp = savedCP; 950 + sdata->contentSize = savedContenSize; 951 + } 952 +} 953 + 954 +static SchemaValidationStack * 955 +getStackElement ( 956 + SchemaData *sdata, 957 + SchemaCP *pattern 958 + ) 959 +{ 960 + SchemaValidationStack *stackElm; 961 + 962 + if (sdata->stackPool) { 963 + stackElm = sdata->stackPool; 964 + sdata->stackPool = stackElm->down; 965 + } else { 966 + stackElm = TMALLOC (SchemaValidationStack); 967 + } 968 + memset (stackElm, 0, sizeof (SchemaValidationStack)); 969 + stackElm->pattern = pattern; 970 + return stackElm; 971 +} 972 + 973 +static void 974 +repoolStackElement ( 975 + SchemaData *sdata, 976 + SchemaValidationStack *se 977 + ) 978 +{ 979 + if (se->interleaveState) { 980 + FREE (se->interleaveState); 981 + se->interleaveState = NULL; 982 + } 983 + se->down = sdata->stackPool; 984 + sdata->stackPool = se; 985 +} 986 + 987 +static void 988 +pushToStack ( 989 + SchemaData *sdata, 990 + SchemaCP *pattern 991 + ) 992 +{ 993 + SchemaValidationStack *se, *nextse; 994 + DBG(fprintf(stderr, "push to Stack:\n");serializeCP(pattern)); 995 + if (pattern->type == SCHEMA_CTYPE_NAME && sdata->lastMatchse) { 996 + se = sdata->lastMatchse; 997 + while (se) { 998 + nextse = se->down; 999 + repoolStackElement (sdata, se); 1000 + se = nextse; 1001 + } 1002 + sdata->lastMatchse = NULL; 1003 + } 1004 + se = getStackElement (sdata, pattern); 1005 + se->down = sdata->stack; 1006 + if (pattern->type == SCHEMA_CTYPE_INTERLEAVE) { 1007 + se->interleaveState = MALLOC (sizeof (int) * pattern->nc); 1008 + memset (se->interleaveState, 0, sizeof (int) * pattern->nc); 1009 + } 1010 + sdata->stack = se; 1011 +} 1012 + 1013 +static void 1014 +popFromStack ( 1015 + SchemaData *sdata, 1016 + SchemaValidationStack **stack 1017 + ) 1018 +{ 1019 + SchemaValidationStack *se; 1020 + DBG(fprintf(stderr, "popFromStack:\n"); serializeCP((*stack)->pattern)); 1021 + se = (*stack)->down; 1022 + repoolStackElement (sdata, *stack); 1023 + *stack = se; 1024 +} 1025 + 1026 +static void 1027 +popStack ( 1028 + SchemaData *sdata 1029 + ) 1030 +{ 1031 + SchemaValidationStack *se, *nextse; 1032 + DBG(fprintf(stderr, "popStack:\n"); serializeCP(sdata->stack->pattern)); 1033 + if (sdata->stack->pattern->type == SCHEMA_CTYPE_NAME) { 1034 + se = sdata->lastMatchse; 1035 + while (se) { 1036 + nextse = se->down; 1037 + repoolStackElement (sdata, se); 1038 + se = nextse; 1039 + } 1040 + sdata->lastMatchse = NULL; 1041 + se = sdata->stack->down; 1042 + repoolStackElement (sdata, sdata->stack); 1043 + sdata->stack = se; 1044 + } else { 1045 + if (sdata->stack->hasMatched) { 1046 + se = sdata->stack->down; 1047 + sdata->stack->down = sdata->lastMatchse; 1048 + sdata->lastMatchse = sdata->stack; 1049 + sdata->stack = se; 1050 + } else { 1051 + se = sdata->stack->down; 1052 + repoolStackElement (sdata, sdata->stack); 1053 + sdata->stack = se; 1054 + } 1055 + } 1056 +} 1057 + 1058 +static void 1059 +finalizeElement ( 1060 + SchemaData *sdata, 1061 + int ac 1062 + ) 1063 +{ 1064 + SchemaValidationStack *se; 1065 + SchemaCP *cp, *cp1; 1066 + int i; 1067 + 1068 + se = sdata->stack; 1069 + cp = se->pattern; 1070 + if (cp->type == SCHEMA_CTYPE_NAME || cp->type == SCHEMA_CTYPE_PATTERN) { 1071 + for (i = ac; i < cp->nc; i++) { 1072 + cp1 = cp->content[ac]; 1073 + if (cp1->type == SCHEMA_CTYPE_KEYSPACE) { 1074 + if (!cp1->keySpace->active) { 1075 + Tcl_InitHashTable (&cp1->keySpace->ids, 1076 + TCL_STRING_KEYS); 1077 + cp1->keySpace->active = 1; 1078 + cp1->keySpace->unknownIDrefs = 0; 1079 + } else { 1080 + cp1->keySpace->active++; 1081 + } 1082 + } else if (cp->content[ac]->type == SCHEMA_CTYPE_KEYSPACE_END) { 1083 + cp1->keySpace->active--; 1084 + if (!cp1->keySpace->active) { 1085 + cp1->keySpace->unknownIDrefs = 0; 1086 + Tcl_DeleteHashTable (&cp1->keySpace->ids); 1087 + } 1088 + } 1089 + } 1090 + } 1091 + popStack (sdata); 1092 + /* cp is still the pattern from stack top before the popStack */ 1093 + if (cp->type != SCHEMA_CTYPE_NAME) { 1094 + finalizeElement (sdata, sdata->stack->activeChild + 1); 1095 + } 1096 +} 1097 + 1098 +static void 1099 +rewindStack ( 1100 + SchemaData *sdata 1101 + ) 1102 +{ 1103 + SchemaValidationStack *se; 1104 + 1105 + while (sdata->lastMatchse) { 1106 + se = sdata->lastMatchse; 1107 + sdata->lastMatchse = se->down; 1108 + se->down = sdata->stack; 1109 + sdata->stack = se; 1110 + } 1111 +} 1112 + 1113 +static int 1114 +recover ( 1115 + Tcl_Interp *interp, 1116 + SchemaData *sdata, 1117 + ValidationErrorType errorType, 1118 + const char *name, 1119 + const char *ns, 1120 + char *text, 1121 + int ac 1122 + ) 1123 +{ 1124 + Tcl_Obj *cmdPtr; 1125 + int rc; 1126 + SchemaValidationStack *se; 1127 + 1128 + if (!sdata->reportCmd || sdata->evalError) return 0; 1129 + if (sdata->recoverFlags & RECOVER_FLAG_DONT_REPORT) return 1; 1130 + /* If non SCHEMA_CTYPE_NAME and the pattern hasn't already matched 1131 + * that's a pattern pushed on stack to look for (probe) if it 1132 + * matches (or allows empty match). Even if the pattern fail it 1133 + * may be optional; recovering is done at the caller level in case 1134 + * the pattern isn't optional. */ 1135 + if (sdata->stack 1136 + && sdata->stack->pattern->type != SCHEMA_CTYPE_NAME 1137 + && sdata->stack->activeChild == 0 1138 + && sdata->stack->hasMatched == 0) return 0; 1139 + cmdPtr = Tcl_DuplicateObj (sdata->reportCmd); 1140 + Tcl_IncrRefCount(cmdPtr); 1141 + Tcl_ListObjAppendElement (interp, cmdPtr, 1142 + sdata->self); 1143 + Tcl_ListObjAppendElement ( 1144 + interp, cmdPtr, 1145 + Tcl_NewStringObj (ValidationErrorType2str[errorType], -1) 1146 + ); 1147 + /* In case of unknown element the name/ns arguments of recover() 1148 + * are NULL, but sdata->vname/sdata->vns are already 1149 + * pre-filled. */ 1150 + if (name) sdata->vname = name; 1151 + if (ns) sdata->vns = ns; 1152 + sdata->vtext = text; 1153 + switch (errorType) { 1154 + case DOM_KEYCONSTRAINT: 1155 + sdata->vaction = MATCH_DOM_KEYCONSTRAINT; 1156 + break; 1157 + case DOM_XPATH_BOOLEAN: 1158 + sdata->vaction = MATCH_DOM_XPATH_BOOLEAN; 1159 + break; 1160 + case MISSING_ATTRIBUTE: 1161 + case UNKNOWN_ATTRIBUTE: 1162 + case MISSING_ELEMENT_MATCH_START: 1163 + case MISSING_TEXT_MATCH_START: 1164 + case INVALID_KEYREF_MATCH_START: 1165 + case UNEXPECTED_ROOT_ELEMENT: 1166 + case UNKNOWN_ROOT_ELEMENT: 1167 + case UNEXPECTED_ELEMENT: 1168 + sdata->vaction = MATCH_ELEMENT_START; 1169 + break; 1170 + case MISSING_TEXT_MATCH_END: 1171 + case INVALID_KEYREF_MATCH_END: 1172 + case MISSING_ELEMENT_MATCH_END: 1173 + if (sdata->stack) { 1174 + se = sdata->stack; 1175 + while (se->pattern->type != SCHEMA_CTYPE_NAME) { 1176 + se = se->down; 1177 + } 1178 + sdata->vname = se->pattern->name; 1179 + sdata->vns = se->pattern->namespace; 1180 + } 1181 + sdata->vaction = MATCH_ELEMENT_END; 1182 + break; 1183 + case UNEXPECTED_TEXT: 1184 + sdata->vaction = MATCH_TEXT; 1185 + break; 1186 + case INVALID_KEYREF_MATCH_TEXT: 1187 + case INVALID_VALUE: 1188 + if (sdata->stack) { 1189 + se = sdata->stack; 1190 + while (se->pattern->type != SCHEMA_CTYPE_NAME) { 1191 + se = se->down; 1192 + } 1193 + sdata->vname = se->pattern->name; 1194 + sdata->vns = se->pattern->namespace; 1195 + } 1196 + sdata->vaction = MATCH_TEXT; 1197 + break; 1198 + case UNKOWN_GLOBAL_ID: 1199 + case UNKOWN_ID: 1200 + sdata->vaction = MATCH_GLOBAL; 1201 + break; 1202 + case INVALID_ATTRIBUTE_VALUE: 1203 + sdata->vaction = MATCH_ATTRIBUTE_TEXT; 1204 + break; 1205 + } 1206 + sdata->currentEvals++; 1207 + rc = Tcl_EvalObjEx (interp, cmdPtr, 1208 + TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 1209 + sdata->currentEvals--; 1210 + sdata->vaction = 0; 1211 + if (name) sdata->vname = name; 1212 + if (ns) sdata->vns = ns; 1213 + sdata->vtext = NULL; 1214 + Tcl_DecrRefCount (cmdPtr); 1215 + if (rc != TCL_OK) { 1216 + sdata->evalError = 1; 1217 + return 0; 1218 + } 1219 + switch (errorType) { 1220 + case MISSING_ELEMENT_MATCH_START: 1221 + if (strcmp (Tcl_GetStringResult (interp), "ignore") == 0) { 1222 + sdata->recoverFlags |= RECOVER_FLAG_IGNORE; 1223 + return 1; 1224 + } else if (strcmp (Tcl_GetStringResult (interp), "vanish") == 0) { 1225 + sdata->recoverFlags |= RECOVER_FLAG_REWIND; 1226 + sdata->skipDeep = 1; 1227 + return 1; 1228 + } else { 1229 + /* Rewind stack to last match and ignore the just opened 1230 + * Element. */ 1231 + finalizeElement (sdata, ac+1); 1232 + sdata->skipDeep = 2; 1233 + } 1234 + break; 1235 + case UNEXPECTED_ELEMENT: 1236 + if (strcmp (Tcl_GetStringResult (interp), "vanish") == 0) { 1237 + sdata->recoverFlags |= RECOVER_FLAG_REWIND; 1238 + sdata->skipDeep = 1; 1239 + return 1; 1240 + } else { 1241 + finalizeElement (sdata, ac+1); 1242 + sdata->skipDeep = 2; 1243 + } 1244 + break; 1245 + case UNEXPECTED_TEXT: 1246 + sdata->recoverFlags |= RECOVER_FLAG_REWIND; 1247 + break; 1248 + case MISSING_ELEMENT_MATCH_END: 1249 + case MISSING_TEXT_MATCH_END: 1250 + if (strcmp (Tcl_GetStringResult (interp), "ignore") == 0) { 1251 + sdata->recoverFlags |= RECOVER_FLAG_MATCH_END_CONTINUE; 1252 + } else { 1253 + sdata->recoverFlags |= RECOVER_FLAG_DONT_REPORT; 1254 + } 1255 + break; 1256 + case DOM_KEYCONSTRAINT: 1257 + case DOM_XPATH_BOOLEAN: 1258 + case MISSING_ATTRIBUTE: 1259 + case MISSING_TEXT_MATCH_START: 1260 + case UNEXPECTED_ROOT_ELEMENT: 1261 + case UNKNOWN_ATTRIBUTE: 1262 + case INVALID_KEYREF_MATCH_START: 1263 + case INVALID_KEYREF_MATCH_END: 1264 + case INVALID_KEYREF_MATCH_TEXT: 1265 + case UNKNOWN_ROOT_ELEMENT: 1266 + case UNKOWN_GLOBAL_ID: 1267 + case UNKOWN_ID: 1268 + case INVALID_ATTRIBUTE_VALUE: 1269 + case INVALID_VALUE: 1270 + break; 1271 + } 1272 + return 1; 1273 +} 1274 + 1275 +/* The cp argument must be type SCHEMA_CTYPE_TEXT */ 1276 +static int 1277 +checkText ( 1278 + Tcl_Interp *interp, 1279 + void *clientData, 1280 + char *text 1281 + ) 1282 +{ 1283 + int i; 1284 + SchemaCP *cp = (SchemaCP *) clientData; 1285 + SchemaConstraint *sc; 1286 + 1287 + /* Look also at oneOfImpl */ 1288 + for (i = 0; i < cp->nc; i++) { 1289 + sc = (SchemaConstraint *) cp->content[i]; 1290 + if (!(sc->constraint) (interp, sc->constraintData, text)) { 1291 + return 0; 1292 + } 1293 + } 1294 + return 1; 1295 +} 1296 + 1297 +/* The argument ac points to the child of the current top-most stack 1298 + * element pattern which is to evaluate. */ 1299 +static int 1300 +evalVirtual ( 1301 + Tcl_Interp *interp, 1302 + SchemaData *sdata, 1303 + int ac 1304 + ) 1305 +{ 1306 + int rc; 1307 + SchemaCP *cp; 1308 + 1309 + cp = sdata->stack->pattern->content[ac]; 1310 + sdata->currentEvals++; 1311 + rc = Tcl_EvalObjv (interp, cp->nc, (Tcl_Obj **) cp->content, 1312 + TCL_EVAL_GLOBAL); 1313 + sdata->currentEvals--; 1314 + if (rc != TCL_OK) { 1315 + sdata->evalError = 1; 1316 + return 0; 1317 + } 1318 + return 1; 1319 +} 1320 + 1321 +/* Check, if the pattern to probe does not call itself (even 1322 + * indirectly) without a match inbetween.*/ 1323 +static int inline 1324 +recursivePattern ( 1325 + SchemaValidationStack *se, 1326 + SchemaCP *pattern 1327 + ) 1328 +{ 1329 + int rc = 0; 1330 + 1331 + while (se && se->pattern->type != SCHEMA_CTYPE_NAME) { 1332 + if (!se->hasMatched && se->pattern == pattern) { 1333 + rc = 1; 1334 + break; 1335 + } 1336 + se = se->down; 1337 + } 1338 + return rc; 1339 +} 1340 + 1341 +static int 1342 +matchElementStart ( 1343 + Tcl_Interp *interp, 1344 + SchemaData *sdata, 1345 + char *name, 1346 + char *namespace 1347 + ) 1348 +{ 1349 + SchemaCP *cp, *candidate, *icp; 1350 + int hm, ac, i, mayskip, thismayskip, rc; 1351 + int isName = 0; 1352 + SchemaValidationStack *se; 1353 + Tcl_HashEntry *h; 1354 + 1355 + if (!sdata->stack) return 0; 1356 + se = sdata->stack; 1357 + getContext (cp, ac, hm); 1358 + 1359 + switch (cp->type) { 1360 + case SCHEMA_CTYPE_NAME: 1361 + isName = 1; 1362 + /* fall through */ 1363 + case SCHEMA_CTYPE_PATTERN: 1364 + while (ac < cp->nc) { 1365 + candidate = cp->content[ac]; 1366 + mayskip = 0; 1367 + switch (candidate->type) { 1368 + case SCHEMA_CTYPE_TEXT: 1369 + if (candidate->nc) { 1370 + if (!checkText (interp, candidate, "")) { 1371 + if (recover (interp, sdata, MISSING_TEXT_MATCH_START, 1372 + name, namespace, NULL, ac)) { 1373 + mayskip = 1; 1374 + break; 1375 + } 1376 + return 0; 1377 + } 1378 + } 1379 + break; 1380 + 1381 + case SCHEMA_CTYPE_ANY: 1382 + if (candidate->namespace && 1383 + candidate->namespace != namespace) { 1384 + break; 1385 + } 1386 + updateStack (sdata, se, ac); 1387 + sdata->skipDeep = 1; 1388 + /* See comment in tDOM_probeElement: sdata->vname and 1389 + * sdata->vns may be pre-filled. We reset it here.*/ 1390 + sdata->vname = NULL; 1391 + sdata->vns = NULL; 1392 + return 1; 1393 + 1394 + case SCHEMA_CTYPE_NAME: 1395 + DBG(fprintf (stderr, "name: %s ns: %s candidate name: %s " 1396 + "candidate ns: %s\n", name, namespace, 1397 + candidate->name, candidate->namespace)); 1398 + if (candidate->name == name 1399 + && candidate->namespace == namespace) { 1400 + pushToStack (sdata, candidate); 1401 + updateStack (sdata, se, ac); 1402 + return 1; 1403 + } 1404 + break; 1405 + 1406 + case SCHEMA_CTYPE_CHOICE: 1407 + if (candidate->typedata) { 1408 + h = Tcl_FindHashEntry ((Tcl_HashTable *)candidate->typedata, 1409 + name); 1410 + if (h) { 1411 + icp = Tcl_GetHashValue (h); 1412 + if (icp->namespace == namespace) { 1413 + pushToStack (sdata, icp); 1414 + updateStack (sdata, se, ac); 1415 + return 1; 1416 + } 1417 + } 1418 + /* TODO: Short-cut in case of no match (looking 1419 + * for emtpy match, recovering). For now fall 1420 + * throu to simple, serial approach. */ 1421 + } 1422 + for (i = 0; i < candidate->nc; i++) { 1423 + icp = candidate->content[i]; 1424 + switch (icp->type) { 1425 + case SCHEMA_CTYPE_TEXT: 1426 + break; 1427 + 1428 + case SCHEMA_CTYPE_ANY: 1429 + if (icp->namespace && icp->namespace != namespace) { 1430 + break; 1431 + } 1432 + updateStack (sdata, se, ac); 1433 + sdata->skipDeep = 1; 1434 + /* See comment in tDOM_probeElement: sdata->vname 1435 + * and sdata->vns may be pre-filled. We reset it 1436 + * here.*/ 1437 + sdata->vname = NULL; 1438 + sdata->vns = NULL; 1439 + return 1; 1440 + 1441 + case SCHEMA_CTYPE_NAME: 1442 + if (icp->name == name 1443 + && icp->namespace == namespace) { 1444 + pushToStack (sdata, icp); 1445 + updateStack (sdata, se, ac); 1446 + return 1; 1447 + } 1448 + break; 1449 + 1450 + case SCHEMA_CTYPE_CHOICE: 1451 + Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE"); 1452 + 1453 + case SCHEMA_CTYPE_PATTERN: 1454 + if (recursivePattern (se, icp)) { 1455 + mayskip = 1; 1456 + continue; 1457 + } 1458 + /* fall throu */ 1459 + case SCHEMA_CTYPE_INTERLEAVE: 1460 + pushToStack (sdata, icp); 1461 + rc = matchElementStart (interp, sdata, name, namespace); 1462 + if (rc == 1) { 1463 + updateStack (sdata, se, ac); 1464 + return 1; 1465 + } 1466 + popStack (sdata); 1467 + if (rc == -1) mayskip = 1; 1468 + break; 1469 + 1470 + case SCHEMA_CTYPE_VIRTUAL: 1471 + Tcl_Panic ("Virtual constrain in MIXED or CHOICE"); 1472 + 1473 + case SCHEMA_CTYPE_KEYSPACE_END: 1474 + case SCHEMA_CTYPE_KEYSPACE: 1475 + Tcl_Panic ("Keyspace constrain in MIXED or CHOICE"); 1476 + 1477 + } 1478 + if (!mayskip && mayMiss (candidate->quants[i])) 1479 + mayskip = 1; 1480 + } 1481 + break; 1482 + 1483 + case SCHEMA_CTYPE_VIRTUAL: 1484 + if (evalVirtual (interp, sdata, ac)) { 1485 + hm = 1; 1486 + break; 1487 + } 1488 + else return 0; 1489 + 1490 + case SCHEMA_CTYPE_PATTERN: 1491 + if (recursivePattern (se, candidate)) { 1492 + mayskip = 1; 1493 + break; 1494 + } 1495 + /* fall throu */ 1496 + case SCHEMA_CTYPE_INTERLEAVE: 1497 + pushToStack (sdata, candidate); 1498 + rc = matchElementStart (interp, sdata, name, namespace); 1499 + if (rc == 1) { 1500 + updateStack (sdata, se, ac); 1501 + return 1; 1502 + } 1503 + popStack (sdata); 1504 + if (rc == -1) mayskip = 1; 1505 + break; 1506 + 1507 + case SCHEMA_CTYPE_KEYSPACE_END: 1508 + candidate->keySpace->active--; 1509 + if (!candidate->keySpace->active) { 1510 + if (candidate->keySpace->unknownIDrefs) { 1511 + if (!recover (interp, sdata, 1512 + INVALID_KEYREF_MATCH_START, name, 1513 + namespace, NULL, ac)) { 1514 + return 0; 1515 + } 1516 + candidate->keySpace->unknownIDrefs = 0; 1517 + } 1518 + Tcl_DeleteHashTable (&candidate->keySpace->ids); 1519 + } 1520 + ac++; 1521 + hm = 0; 1522 + continue; 1523 + 1524 + case SCHEMA_CTYPE_KEYSPACE: 1525 + if (!candidate->keySpace->active) { 1526 + Tcl_InitHashTable (&candidate->keySpace->ids, 1527 + TCL_STRING_KEYS); 1528 + candidate->keySpace->active = 1; 1529 + candidate->keySpace->unknownIDrefs = 0; 1530 + } else { 1531 + candidate->keySpace->active++; 1532 + } 1533 + ac++; 1534 + hm = 0; 1535 + continue; 1536 + } 1537 + if (!mayskip && mustMatch (cp->quants[ac], hm)) { 1538 + if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name, 1539 + namespace, NULL, ac)) { 1540 + if (sdata->recoverFlags & RECOVER_FLAG_IGNORE) { 1541 + /* We pretend the ac content particle had 1542 + * matched. */ 1543 + updateStack (sdata, se, ac); 1544 + } 1545 + return 1; 1546 + } 1547 + return 0; 1548 + } 1549 + ac++; 1550 + hm = 0; 1551 + } 1552 + if (isName) { 1553 + if (recover (interp, sdata, UNEXPECTED_ELEMENT, name, namespace, 1554 + NULL, 0)) { 1555 + return 1; 1556 + } 1557 + return 0; 1558 + } 1559 + return -1; 1560 + 1561 + case SCHEMA_CTYPE_KEYSPACE: 1562 + case SCHEMA_CTYPE_KEYSPACE_END: 1563 + case SCHEMA_CTYPE_VIRTUAL: 1564 + case SCHEMA_CTYPE_CHOICE: 1565 + case SCHEMA_CTYPE_TEXT: 1566 + case SCHEMA_CTYPE_ANY: 1567 + /* Never pushed onto stack */ 1568 + Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 1569 + 1570 + case SCHEMA_CTYPE_INTERLEAVE: 1571 + mayskip = 1; 1572 + for (i = 0; i < cp->nc; i++) { 1573 + thismayskip = 0; 1574 + if (se->interleaveState[i]) { 1575 + if (maxOne (cp->quants[i])) continue; 1576 + } 1577 + icp = cp->content[i]; 1578 + switch (icp->type) { 1579 + case SCHEMA_CTYPE_TEXT: 1580 + if (icp->nc) { 1581 + if (checkText (interp, icp, "")) { 1582 + thismayskip = 1; 1583 + } 1584 + } else { 1585 + thismayskip = 1; 1586 + } 1587 + break; 1588 + 1589 + case SCHEMA_CTYPE_ANY: 1590 + if (icp->namespace && icp->namespace != namespace) { 1591 + break; 1592 + } 1593 + sdata->skipDeep = 1; 1594 + se->hasMatched = 1; 1595 + se->interleaveState[i] = 1; 1596 + /* See comment in tDOM_probeElement: sdata->vname and 1597 + * sdata->vns may be pre-filled. We reset it here.*/ 1598 + sdata->vname = NULL; 1599 + sdata->vns = NULL; 1600 + return 1; 1601 + 1602 + case SCHEMA_CTYPE_NAME: 1603 + if (icp->name == name 1604 + && icp->namespace == namespace) { 1605 + pushToStack (sdata, icp); 1606 + se->hasMatched = 1; 1607 + se->interleaveState[i] = 1; 1608 + return 1; 1609 + } 1610 + break; 1611 + 1612 + case SCHEMA_CTYPE_CHOICE: 1613 + Tcl_Panic ("MIXED or CHOICE child of INTERLEAVE"); 1614 + 1615 + case SCHEMA_CTYPE_PATTERN: 1616 + if (recursivePattern (se, icp)) { 1617 + thismayskip = 1; 1618 + break; 1619 + } 1620 + /* fall throu */ 1621 + case SCHEMA_CTYPE_INTERLEAVE: 1622 + pushToStack (sdata, icp); 1623 + rc = matchElementStart (interp, sdata, name, namespace); 1624 + if (rc == 1) { 1625 + if (!(sdata->recoverFlags & RECOVER_FLAG_REWIND)) { 1626 + se->hasMatched = 1; 1627 + se->interleaveState[i] = 1; 1628 + } 1629 + return 1; 1630 + } 1631 + popStack (sdata); 1632 + if (rc == -1) thismayskip = 1; 1633 + break; 1634 + 1635 + case SCHEMA_CTYPE_VIRTUAL: 1636 + Tcl_Panic ("Virtual constraint child of INTERLEAVE"); 1637 + break; 1638 + 1639 + case SCHEMA_CTYPE_KEYSPACE_END: 1640 + case SCHEMA_CTYPE_KEYSPACE: 1641 + Tcl_Panic ("Keyspace constraint child of INTERLEAVE"); 1642 + break; 1643 + 1644 + } 1645 + if (!thismayskip && minOne (cp->quants[i])) mayskip = 0; 1646 + } 1647 + if (mayskip) break; 1648 + if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name, 1649 + namespace, NULL, cp->nc)) { 1650 + if (sdata->recoverFlags & RECOVER_FLAG_IGNORE) { 1651 + /* We mark the first so far not matched mandatory 1652 + * interleave child cp as matched */ 1653 + for (i = 0; i < cp->nc; i++) { 1654 + if (!se->interleaveState[i]) { 1655 + if (minOne (cp->quants[i])) { 1656 + se->interleaveState[i] = 1; 1657 + break; 1658 + } 1659 + } 1660 + } 1661 + } 1662 + return 1; 1663 + } 1664 + return 0; 1665 + } 1666 + return -1; 1667 +} 1668 + 1669 +static void * 1670 +getNamespacePtr ( 1671 + SchemaData *sdata, 1672 + char *ns 1673 + ) 1674 +{ 1675 + Tcl_HashEntry *h; 1676 + int hnew; 1677 + 1678 + if (!ns) return NULL; 1679 + h = Tcl_FindHashEntry (&sdata->prefix, ns); 1680 + if (h) { 1681 + return Tcl_GetHashValue (h); 1682 + } 1683 + h = Tcl_CreateHashEntry (&sdata->namespace, ns, &hnew); 1684 + if (h != sdata->emptyNamespace) { 1685 + return Tcl_GetHashKey (&sdata->namespace, h); 1686 + } 1687 + return NULL; 1688 +} 1689 + 1690 +int 1691 +tDOM_probeElement ( 1692 + Tcl_Interp *interp, 1693 + SchemaData *sdata, 1694 + const char *name, 1695 + void *namespace 1696 + ) 1697 +{ 1698 + Tcl_HashEntry *h; 1699 + void *namespacePtr, *namePtr; 1700 + SchemaCP *pattern; 1701 + int rc = 1, reportError; 1702 + 1703 + if (sdata->skipDeep) { 1704 + sdata->skipDeep++; 1705 + return TCL_OK; 1706 + } 1707 + if (sdata->validationState == VALIDATION_FINISHED) { 1708 + SetResult ("Validation finished."); 1709 + return TCL_ERROR; 1710 + } 1711 + 1712 + DBG( 1713 + fprintf (stderr, "tDOM_probeElement: look if '%s' in ns '%s' match\n", 1714 + name, (char *)namespace); 1715 + ); 1716 + 1717 + if (namespace) { 1718 + h = Tcl_FindHashEntry (&sdata->namespace, namespace); 1719 + } else { 1720 + h = NULL; 1721 + } 1722 + if (h) { 1723 + namespacePtr = Tcl_GetHashKey (&sdata->namespace, h); 1724 + } else { 1725 + if (namespace) { 1726 + /* This namespace isn't known at all by the schema; this 1727 + * element may only match an any condition. If it does we 1728 + * know only later. So we use namePtr and namespacePtr 1729 + * both NULL that match nothing else in the schema and 1730 + * will be able to look if there is such a possible any 1731 + * match in the schema. */ 1732 + rc = 0; 1733 + /* If there isn't a matching any cp this is a validation 1734 + * error. To have the node name/namespace information 1735 + * available in case of recovering we prefill the sdata 1736 + * struct here.*/ 1737 + sdata->vname = name; 1738 + sdata->vns = namespace; 1739 + } 1740 + namespacePtr = NULL; 1741 + } 1742 + if (!rc) { 1743 + /* Already the provided namespace isn't known to the schema, 1744 + * so the name in that namespace of course also. */ 1745 + namePtr = NULL; 1746 + } else { 1747 + h = Tcl_FindHashEntry (&sdata->element, name); 1748 + if (h) { 1749 + namePtr = Tcl_GetHashKey (&sdata->element, h); 1750 + } else { 1751 + namePtr = NULL; 1752 + /* Prefill in case of validation error. See above. */ 1753 + sdata->vname = name; 1754 + } 1755 + } 1756 + 1757 + if (sdata->validationState == VALIDATION_READY) { 1758 + /* The root of the tree to check. */ 1759 + if (sdata->start) { 1760 + if (strcmp (name, sdata->start) != 0) { 1761 + if (recover (interp, sdata, UNEXPECTED_ROOT_ELEMENT, name, 1762 + namespace, NULL, 0)) { 1763 + sdata->validationState = VALIDATION_FINISHED; 1764 + return TCL_OK; 1765 + } 1766 + SetResult ("Root element doesn't match"); 1767 + return TCL_ERROR; 1768 + } 1769 + if (namespace) { 1770 + if (!sdata->startNamespace|| 1771 + strcmp (namespace, sdata->startNamespace) != 0) { 1772 + if (recover (interp, sdata, UNEXPECTED_ROOT_ELEMENT, name, 1773 + namespace, NULL, 0)) { 1774 + sdata->validationState = VALIDATION_FINISHED; 1775 + return TCL_OK; 1776 + } 1777 + SetResult ("Root element namespace doesn't match"); 1778 + return TCL_ERROR; 1779 + } 1780 + } else { 1781 + if (sdata->startNamespace) { 1782 + if (recover (interp, sdata, UNEXPECTED_ROOT_ELEMENT, name, 1783 + namespace, NULL, 0)) { 1784 + sdata->validationState = VALIDATION_FINISHED; 1785 + return TCL_OK; 1786 + } 1787 + SetResult ("Root element namespace doesn't match"); 1788 + return TCL_ERROR; 1789 + } 1790 + } 1791 + } 1792 + reportError = 0; 1793 + if (h) { 1794 + pattern = (SchemaCP *) Tcl_GetHashValue (h); 1795 + while (pattern) { 1796 + if (pattern->namespace == namespacePtr) { 1797 + if (pattern->flags & PLACEHOLDER_PATTERN_DEF 1798 + || pattern->flags & FORWARD_PATTERN_DEF) { 1799 + reportError = 1; 1800 + } 1801 + break; 1802 + } 1803 + pattern = pattern->next; 1804 + } 1805 + } else { 1806 + pattern = NULL; 1807 + } 1808 + sdata->validationState = VALIDATION_STARTED; 1809 + if (reportError || pattern == NULL) { 1810 + if (recover (interp, sdata, UNKNOWN_ROOT_ELEMENT, name, namespace, 1811 + NULL, 0)) { 1812 + sdata->skipDeep = 1; 1813 + return TCL_OK; 1814 + } 1815 + SetResult ("Unknown element"); 1816 + return TCL_ERROR; 1817 + } 1818 + pushToStack (sdata, pattern); 1819 + return TCL_OK; 1820 + } 1821 + 1822 + /* The normal case: we're inside the tree */ 1823 + /* In case of recovering and if the user wants a required cp to be 1824 + * treated as matched (or in other words: that the validation 1825 + * engine should ignore the mandatory state of the cp) we unwind 1826 + * the call stack to have updated stack elements, to be able to 1827 + * pretend, we have seen the mandatory cp. Now try to match the 1828 + * open element from this stack state. */ 1829 + while (1) { 1830 + rc = matchElementStart (interp, sdata, (char *) namePtr, 1831 + namespacePtr); 1832 + while (rc == -1) { 1833 + popStack (sdata); 1834 + rc = matchElementStart (interp, sdata, (char *) namePtr, 1835 + namespacePtr); 1836 + }; 1837 + if (rc) { 1838 + DBG( 1839 + fprintf (stderr, "tDOM_probeElement: element '%s' match\n", 1840 + name); 1841 + serializeStack (sdata); 1842 + fprintf (stderr, "\n"); 1843 + ); 1844 + if (sdata->recoverFlags & RECOVER_FLAG_IGNORE) { 1845 + sdata->recoverFlags &= ~RECOVER_FLAG_IGNORE; 1846 + continue; 1847 + } 1848 + CHECK_REWIND; 1849 + return TCL_OK; 1850 + } 1851 + break; 1852 + } 1853 + DBG( 1854 + fprintf (stderr, "element '%s' DOESN'T match\n", name); 1855 + serializeStack (sdata); 1856 + fprintf (stderr, "\n"); 1857 + ); 1858 + if (!sdata->evalError) { 1859 + SetResult ("Element \""); 1860 + if (namespacePtr) { 1861 + Tcl_AppendResult (interp, namespacePtr, ":", NULL); 1862 + } 1863 + Tcl_AppendResult (interp, name, "\" doesn't match", NULL); 1864 + } 1865 + return TCL_ERROR; 1866 +} 1867 + 1868 +int probeAttribute ( 1869 + Tcl_Interp *interp, 1870 + SchemaData *sdata, 1871 + const char *name, 1872 + const char *ns, 1873 + char *value, 1874 + int *isrequired 1875 + ) 1876 +{ 1877 + int i; 1878 + SchemaCP *cp; 1879 + Tcl_HashTable *t; 1880 + Tcl_HashEntry *h; 1881 + SchemaAttr *attr; 1882 + 1883 + cp = sdata->stack->pattern; 1884 + *isrequired = 0; 1885 + if (cp->typedata) { 1886 + t = (Tcl_HashTable *) cp->typedata; 1887 + h = Tcl_FindHashEntry (t, name); 1888 + if (!h) return 0; 1889 + attr = (SchemaAttr *) Tcl_GetHashValue (h); 1890 + while (attr && attr->namespace != ns) { 1891 + attr = attr->next; 1892 + } 1893 + if (!attr) return 0; 1894 + if (attr->cp) { 1895 + if (!checkText (interp, attr->cp, value)) { 1896 + if (!recover (interp, sdata, INVALID_ATTRIBUTE_VALUE, name, 1897 + ns, value, 0)) { 1898 + SetResult3V ("Attribute value doesn't match for " 1899 + "attribute '", name , "'"); 1900 + return 0; 1901 + } 1902 + } 1903 + } 1904 + if (attr->required) *isrequired = 1; 1905 + return 1; 1906 + } 1907 + for (i = 0; i < cp->numAttr; i++) { 1908 + if (cp->attrs[i]->namespace == ns 1909 + && cp->attrs[i]->name == name) { 1910 + if (cp->attrs[i]->cp) { 1911 + if (!checkText (interp, cp->attrs[i]->cp, value)) { 1912 + if (!recover (interp, sdata, INVALID_ATTRIBUTE_VALUE, name, 1913 + ns, value, i)) { 1914 + SetResult3V ("Attribute value doesn't match for " 1915 + "attribute '", name , "'"); 1916 + return 0; 1917 + } 1918 + } 1919 + } 1920 + if (cp->attrs[i]->required) *isrequired = 1; 1921 + return 1; 1922 + } 1923 + } 1924 + return 0; 1925 +} 1926 + 1927 +int tDOM_probeAttributes ( 1928 + Tcl_Interp *interp, 1929 + SchemaData *sdata, 1930 + const char **attr 1931 + ) 1932 +{ 1933 + char **atPtr, *ln, *namespace, *ns; 1934 + int i, j, found, nsatt, req, reqAttr = 0; 1935 + SchemaCP *cp; 1936 + Tcl_HashEntry *h; 1937 + 1938 + cp = sdata->stack->pattern; 1939 + for (atPtr = (char **) attr; atPtr[0] && atPtr[1]; atPtr += 2) { 1940 + found = 0; 1941 + ln = atPtr[0]; 1942 + j = 0; 1943 + while (*ln && *ln != '\xFF') { 1944 + j++, ln++; 1945 + } 1946 + if (*ln == '\xFF') { 1947 + namespace = atPtr[0]; 1948 + namespace[j] = '\0'; 1949 + ln++; 1950 + nsatt = 1; 1951 + } else { 1952 + namespace = NULL; 1953 + ln = atPtr[0]; 1954 + nsatt = 0; 1955 + } 1956 + h = Tcl_FindHashEntry (&sdata->attrNames, ln); 1957 + if (!h) goto unknowncleanup; 1958 + ln = Tcl_GetHashKey (&sdata->attrNames, h); 1959 + ns = NULL; 1960 + if (namespace) { 1961 + h = Tcl_FindHashEntry (&sdata->namespace, namespace); 1962 + if (!h) goto unknowncleanup; 1963 + ns = Tcl_GetHashKey (&sdata->namespace, h); 1964 + } 1965 + found = probeAttribute (interp, sdata, ln, ns, atPtr[1], &req); 1966 + reqAttr += req; 1967 + unknowncleanup: 1968 + if (!found) { 1969 + if (!recover (interp, sdata, UNKNOWN_ATTRIBUTE, ln, namespace, 1970 + NULL, 0)) { 1971 + if (!sdata->evalError) { 1972 + if (nsatt) { 1973 + SetResult ("Unknown attribute \""); 1974 + Tcl_AppendResult (interp, namespace, ":", ln, "\"", 1975 + NULL); 1976 + } else { 1977 + SetResult3 ("Unknown attribute \"", ln, "\""); 1978 + } 1979 + } 1980 + if (nsatt) namespace[j] = '\xFF'; 1981 + return TCL_ERROR; 1982 + } 1983 + } 1984 + if (nsatt) namespace[j] = '\xFF'; 1985 + } 1986 + if (reqAttr != cp->numReqAttr) { 1987 + /* Lookup the missing attribute(s) */ 1988 + if (!sdata->evalError) { 1989 + SetResult ("Missing mandatory attribute(s):"); 1990 + } 1991 + for (i = 0; i < cp->numAttr; i++) { 1992 + if (!cp->attrs[i]->required) continue; 1993 + found = 0; 1994 + for (atPtr = (char **) attr; atPtr[0] && atPtr[1]; atPtr += 2) { 1995 + ln = atPtr[0]; 1996 + if (cp->attrs[i]->namespace) { 1997 + j = 0; 1998 + while (*ln && *ln != '\xFF') { 1999 + j++, ln++; 2000 + } 2001 + if (*ln == '\xFF') { 2002 + namespace = atPtr[0]; 2003 + namespace[j] = '\0'; 2004 + ln++; 2005 + nsatt = 1; 2006 + } else { 2007 + continue; 2008 + } 2009 + if (strcmp (cp->attrs[i]->namespace, namespace) != 0) { 2010 + if (nsatt) namespace[j] = '\xFF'; 2011 + continue; 2012 + } 2013 + if (nsatt) namespace[j] = '\xFF'; 2014 + } 2015 + if (strcmp (ln, cp->attrs[i]->name) == 0) { 2016 + found = 1; 2017 + break; 2018 + } 2019 + } 2020 + if (!found) { 2021 + if (!recover (interp, sdata, MISSING_ATTRIBUTE, 2022 + cp->attrs[i]->name, cp->attrs[i]->namespace, 2023 + NULL, i)) { 2024 + if (cp->attrs[i]->namespace) { 2025 + Tcl_AppendResult (interp, " ", cp->attrs[i]->namespace, 2026 + ":", cp->attrs[i]->name, NULL); 2027 + } else { 2028 + Tcl_AppendResult (interp, " ", cp->attrs[i]->name, NULL); 2029 + } 2030 + } 2031 + } 2032 + } 2033 + if (!sdata->reportCmd) { 2034 + return TCL_ERROR; 2035 + } 2036 + } 2037 + return TCL_OK; 2038 +} 2039 + 2040 +int tDOM_probeDomAttributes ( 2041 + Tcl_Interp *interp, 2042 + SchemaData *sdata, 2043 + domAttrNode *attr 2044 + ) 2045 +{ 2046 + domAttrNode *atPtr; 2047 + int i, found, req, reqAttr = 0; 2048 + const char *ns, *ln; 2049 + SchemaCP *cp; 2050 + Tcl_HashEntry *h; 2051 + 2052 + cp = sdata->stack->pattern; 2053 + atPtr = attr; 2054 + while (atPtr) { 2055 + if (atPtr->nodeFlags & IS_NS_NODE) goto nextAttr; 2056 + found = 0; 2057 + if (atPtr->namespace) { 2058 + ns = domNamespaceURI ((domNode *)atPtr); 2059 + /* A namespaced attribute must always have a prefix */ 2060 + ln = atPtr->nodeName; 2061 + while (*ln) { 2062 + if (*ln == ':') { 2063 + ln++; 2064 + break; 2065 + } 2066 + ln++; 2067 + } 2068 + } else { 2069 + ns = NULL; 2070 + ln = atPtr->nodeName; 2071 + } 2072 + h = Tcl_FindHashEntry (&sdata->attrNames, ln); 2073 + if (!h) goto unknown; 2074 + ln = Tcl_GetHashKey (&sdata->attrNames, h); 2075 + if (ns) { 2076 + h = Tcl_FindHashEntry (&sdata->namespace, ns); 2077 + if (!h) goto unknown; 2078 + ns = Tcl_GetHashKey (&sdata->namespace, h); 2079 + } else { 2080 + ns = NULL; 2081 + } 2082 + found = probeAttribute (interp, sdata, ln, ns, atPtr->nodeValue, &req); 2083 + reqAttr += req; 2084 + unknown: 2085 + if (!found) { 2086 + if (!recover (interp, sdata, UNKNOWN_ATTRIBUTE, ln, ns, NULL, 0)) { 2087 + if (!sdata->evalError) { 2088 + if (ns) { 2089 + SetResult ("Unknown attribute \""); 2090 + Tcl_AppendResult (interp, ns, ":", atPtr->nodeName, 2091 + "\"", NULL); 2092 + } else { 2093 + SetResult3 ("Unknown attribute \"", atPtr->nodeName, 2094 + "\""); 2095 + } 2096 + sdata->validationState = VALIDATION_ERROR; 2097 + } 2098 + return TCL_ERROR; 2099 + } 2100 + } 2101 + nextAttr: 2102 + atPtr = atPtr->nextSibling; 2103 + } 2104 + if (reqAttr != cp->numReqAttr) { 2105 + /* Lookup the missing attribute(s) */ 2106 + if (!sdata->evalError) { 2107 + SetResult ("Missing mandatory attribute(s):"); 2108 + } 2109 + for (i = 0; i < cp->numAttr; i++) { 2110 + if (!cp->attrs[i]->required) continue; 2111 + found = 0; 2112 + atPtr = attr; 2113 + while (atPtr) { 2114 + if (cp->attrs[i]->namespace) { 2115 + if (!atPtr->namespace) goto nextAttr2; 2116 + ns = domNamespaceURI ((domNode *)atPtr); 2117 + if (strcmp (ns, cp->attrs[i]->namespace) != 0) { 2118 + goto nextAttr2; 2119 + } 2120 + ln = atPtr->nodeName; 2121 + while (*ln) { 2122 + if (*ln == ':') { 2123 + ln++; 2124 + break; 2125 + } 2126 + ln++; 2127 + } 2128 + } else { 2129 + if (atPtr->namespace) goto nextAttr2; 2130 + ln = atPtr->nodeName; 2131 + } 2132 + if (strcmp (ln, cp->attrs[i]->name) == 0) { 2133 + found = 1; 2134 + break; 2135 + } 2136 + nextAttr2: 2137 + atPtr = atPtr->nextSibling; 2138 + } 2139 + if (!found) { 2140 + if (!recover (interp, sdata, MISSING_ATTRIBUTE, 2141 + cp->attrs[i]->name, cp->attrs[i]->namespace, 2142 + NULL, i)) { 2143 + if (!sdata->evalError) { 2144 + if (cp->attrs[i]->namespace) { 2145 + Tcl_AppendResult (interp, " ", 2146 + cp->attrs[i]->namespace, ":", 2147 + cp->attrs[i]->name, NULL); 2148 + } else { 2149 + Tcl_AppendResult (interp, " ", cp->attrs[i]->name, 2150 + NULL); 2151 + } 2152 + } 2153 + } 2154 + } 2155 + } 2156 + if (!sdata->reportCmd) { 2157 + sdata->validationState = VALIDATION_ERROR; 2158 + return TCL_ERROR; 2159 + } 2160 + } 2161 + return TCL_OK; 2162 +} 2163 +int probeEventAttribute ( 2164 + Tcl_Interp *interp, 2165 + SchemaData *sdata, 2166 + Tcl_Obj *attr, 2167 + int len 2168 + ) 2169 +{ 2170 + int i, found, req, reqAttr = 0; 2171 + char *name, *ns; 2172 + SchemaCP *cp; 2173 + Tcl_HashEntry *h; 2174 + Tcl_Obj *attname, *attns, *attvalue; 2175 + 2176 + cp = sdata->stack->pattern; 2177 + for (i = 0; i < len; i += 2) { 2178 + found = 0; 2179 + ns = NULL; 2180 + name = NULL; 2181 + attns = NULL; 2182 + Tcl_ListObjIndex (interp, attr, i, &attname); 2183 + Tcl_ListObjIndex (interp, attr, i+1, &attvalue); 2184 + if (Tcl_ListObjLength (interp, attname, &len) == TCL_OK) { 2185 + if (len == 2) { 2186 + Tcl_ListObjIndex (interp, attname, 1, &attns); 2187 + Tcl_ListObjIndex (interp, attname, 0, &attname); 2188 + } 2189 + } 2190 + h = Tcl_FindHashEntry (&sdata->attrNames, Tcl_GetString (attname)); 2191 + if (!h) goto unknown; 2192 + name = Tcl_GetHashKey (&sdata->attrNames, h); 2193 + if (attns) { 2194 + h = Tcl_FindHashEntry (&sdata->namespace, Tcl_GetString (attns)); 2195 + if (!h) goto unknown; 2196 + ns = Tcl_GetHashKey (&sdata->namespace, h); 2197 + } 2198 + found = probeAttribute (interp, sdata, name, ns, 2199 + Tcl_GetString (attvalue), &req); 2200 + reqAttr += req; 2201 + unknown: 2202 + if (!found) { 2203 + if (!recover (interp, sdata, UNKNOWN_ATTRIBUTE, 2204 + Tcl_GetString (attname), Tcl_GetString (attns), 2205 + NULL, 0)) { 2206 + if (ns) { 2207 + SetResult ("Unknown attribute \""); 2208 + Tcl_AppendResult (interp, ns, ":", name, "\"", NULL); 2209 + } else { 2210 + SetResult3 ("Unknown attribute \"", name, "\""); 2211 + } 2212 + sdata->validationState = VALIDATION_ERROR; 2213 + return TCL_ERROR; 2214 + } 2215 + } 2216 + } 2217 + if (reqAttr != cp->numReqAttr) { 2218 + SetResult ("Missing mandatory attribute(s)"); 2219 + return TCL_ERROR; 2220 + } 2221 + return TCL_OK; 2222 +} 2223 + 2224 +/* Returns either -1, 0, 1, 2 2225 + 2226 + -1 means a pattern or an interleave ended may end, look further at 2227 + parents next sibling. 2228 + 2229 + 0 means rewind with validation error. 2230 + 2231 + 1 means element content may end here. 2232 + 2233 + 2 means recovering requested further error reporting about missing childs 2234 + in the current element. To be able to to answer a [info expected] on 2235 + the occasion of the next error, we update the stack in this case 2236 + and let tDOM_probeElementEnd restart checkElementEnd again with this 2237 + stack state. 2238 +*/ 2239 +static int checkElementEnd ( 2240 + Tcl_Interp *interp, 2241 + SchemaData *sdata 2242 + ) 2243 +{ 2244 + SchemaValidationStack *se; 2245 + SchemaCP *cp, *ic; 2246 + int hm, ac, i, thismayskip, mayskip = 0, rc; 2247 + int isName = 0; 2248 + 2249 + DBG(fprintf (stderr, "checkElementEnd:\n"); 2250 + serializeStack(sdata);); 2251 + se = sdata->stack; 2252 + getContext (cp, ac, hm); 2253 + 2254 + if (cp->type == SCHEMA_CTYPE_INTERLEAVE) { 2255 + ac = 0; hm = 0; mayskip = 1; 2256 + } 2257 + switch (cp->type) { 2258 + case SCHEMA_CTYPE_NAME: 2259 + isName = 1; 2260 + /* Fall through */ 2261 + case SCHEMA_CTYPE_INTERLEAVE: 2262 + case SCHEMA_CTYPE_PATTERN: 2263 + if (ac < cp->nc && (hasMatched (cp->quants[ac], hm))) { 2264 + DBG(fprintf (stderr, "ac %d has matched, skiping to next ac\n", ac)); 2265 + ac++; hm = 0; 2266 + } 2267 + while (ac < cp->nc) { 2268 + DBG(fprintf (stderr, "ac %d hm %d mayMiss: %d\n", 2269 + ac, hm, mayMiss (cp->quants[ac]))); 2270 + if (se->interleaveState && se->interleaveState[ac]) { 2271 + ac++; continue; 2272 + } 2273 + if (mayMiss (cp->quants[ac])) { 2274 + ac++; continue; 2275 + } 2276 + switch (cp->content[ac]->type) { 2277 + case SCHEMA_CTYPE_KEYSPACE_END: 2278 + /* Don't happen as INTERLEAVE child */ 2279 + cp->content[ac]->keySpace->active--; 2280 + if (!cp->content[ac]->keySpace->active) { 2281 + if (cp->content[ac]->keySpace->unknownIDrefs) { 2282 + if (!recover (interp, sdata, INVALID_KEYREF_MATCH_END, 2283 + NULL, NULL, 2284 + cp->content[ac]->keySpace->name, 0)) { 2285 + return 0; 2286 + } 2287 + cp->content[ac]->keySpace->unknownIDrefs = 0; 2288 + } 2289 + Tcl_DeleteHashTable (&cp->content[ac]->keySpace->ids); 2290 + } 2291 + break; 2292 + 2293 + case SCHEMA_CTYPE_KEYSPACE: 2294 + /* Don't happen as INTERLEAVE child */ 2295 + if (!cp->content[ac]->keySpace->active) { 2296 + Tcl_InitHashTable (&cp->content[ac]->keySpace->ids, 2297 + TCL_STRING_KEYS); 2298 + cp->content[ac]->keySpace->active = 1; 2299 + cp->content[ac]->keySpace->unknownIDrefs = 0; 2300 + } else { 2301 + cp->content[ac]->keySpace->active++; 2302 + } 2303 + break; 2304 + 2305 + case SCHEMA_CTYPE_TEXT: 2306 + if (cp->content[ac]->nc) { 2307 + if (!checkText (interp, cp->content[ac], "")) { 2308 + if (recover (interp, sdata, MISSING_TEXT_MATCH_END, 2309 + NULL, NULL, NULL, ac)) { 2310 + break; 2311 + } 2312 + return 0; 2313 + } 2314 + } 2315 + break; 2316 + 2317 + case SCHEMA_CTYPE_CHOICE: 2318 + /* Don't happen as INTERLEAVE child */ 2319 + thismayskip = 0; 2320 + for (i = 0; i < cp->content[ac]->nc; i++) { 2321 + if (mayMiss (cp->content[ac]->quants[i])) { 2322 + thismayskip = 1; 2323 + break; 2324 + } 2325 + ic = cp->content[ac]->content[i]; 2326 + switch (ic->type) { 2327 + case SCHEMA_CTYPE_TEXT: 2328 + if (ic->nc) { 2329 + if (!checkText (interp, ic, "")) { 2330 + continue; 2331 + } 2332 + } 2333 + thismayskip = 1; 2334 + break; 2335 + 2336 + case SCHEMA_CTYPE_NAME: 2337 + case SCHEMA_CTYPE_ANY: 2338 + continue; 2339 + 2340 + case SCHEMA_CTYPE_PATTERN: 2341 + if (recursivePattern (se, ic)) { 2342 + thismayskip = 1; 2343 + break; 2344 + } 2345 + /* fall throu */ 2346 + case SCHEMA_CTYPE_INTERLEAVE: 2347 + pushToStack (sdata, ic); 2348 + if (checkElementEnd (interp, sdata) == -1) { 2349 + thismayskip = 1; 2350 + } 2351 + popStack (sdata); 2352 + break; 2353 + 2354 + case SCHEMA_CTYPE_KEYSPACE_END: 2355 + case SCHEMA_CTYPE_KEYSPACE: 2356 + case SCHEMA_CTYPE_VIRTUAL: 2357 + case SCHEMA_CTYPE_CHOICE: 2358 + Tcl_Panic ("Invalid CTYPE in MIXED or CHOICE"); 2359 + 2360 + } 2361 + if (thismayskip) break; 2362 + } 2363 + if (thismayskip) break; 2364 + if (!recover (interp, sdata, MISSING_ELEMENT_MATCH_END, NULL, 2365 + NULL, NULL, 0)) { 2366 + return 0; 2367 + } 2368 + if (sdata->recoverFlags & RECOVER_FLAG_MATCH_END_CONTINUE) { 2369 + updateStack (sdata, se, ac); 2370 + return 2; 2371 + } 2372 + break; 2373 + 2374 + case SCHEMA_CTYPE_VIRTUAL: 2375 + if (evalVirtual (interp, sdata, ac)) break; 2376 + else return 0; 2377 + 2378 + case SCHEMA_CTYPE_PATTERN: 2379 + if (recursivePattern (se, cp->content[ac])) { 2380 + break; 2381 + } 2382 + /* fall throu */ 2383 + case SCHEMA_CTYPE_INTERLEAVE: 2384 + pushToStack (sdata, cp->content[ac]); 2385 + rc = checkElementEnd (interp, sdata); 2386 + if (rc == 0) { 2387 + popStack (sdata); 2388 + if (sdata->stack->pattern->type == SCHEMA_CTYPE_NAME 2389 + || sdata->stack->activeChild 2390 + || sdata->stack->hasMatched) { 2391 + if (recover (interp, sdata, MISSING_ELEMENT_MATCH_END, 2392 + NULL, NULL, NULL, 0)) { 2393 + if (sdata->recoverFlags & 2394 + RECOVER_FLAG_MATCH_END_CONTINUE) { 2395 + updateStack (sdata, se, ac); 2396 + return 2; 2397 + } 2398 + break; 2399 + } 2400 + } 2401 + return 0; 2402 + } 2403 + if (rc == 2) { 2404 + updateStack (sdata, se, ac); 2405 + return 2; 2406 + } 2407 + popStack (sdata); 2408 + break; 2409 + 2410 + case SCHEMA_CTYPE_ANY: 2411 + case SCHEMA_CTYPE_NAME: 2412 + if (recover (interp, sdata, MISSING_ELEMENT_MATCH_END, 2413 + NULL, NULL, NULL, 0)) { 2414 + if (sdata->recoverFlags & RECOVER_FLAG_MATCH_END_CONTINUE) { 2415 + updateStack (sdata, se, ac); 2416 + return 2; 2417 + } 2418 + break; 2419 + } 2420 + return 0; 2421 + } 2422 + ac++; 2423 + } 2424 + if (se->interleaveState) { 2425 + if (!mayskip) return 0; 2426 + } 2427 + if (isName) return 1; 2428 + return -1; 2429 + 2430 + case SCHEMA_CTYPE_KEYSPACE_END: 2431 + case SCHEMA_CTYPE_KEYSPACE: 2432 + case SCHEMA_CTYPE_VIRTUAL: 2433 + case SCHEMA_CTYPE_CHOICE: 2434 + case SCHEMA_CTYPE_TEXT: 2435 + case SCHEMA_CTYPE_ANY: 2436 + /* Never pushed onto stack */ 2437 + Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 2438 + 2439 + } 2440 + /* Not reached */ 2441 + return 0; 2442 +} 2443 + 2444 +static int 2445 +checkDocKeys ( 2446 + Tcl_Interp *interp, 2447 + SchemaData *sdata 2448 + ) 2449 +{ 2450 + Tcl_HashEntry *h, *h1; 2451 + Tcl_HashSearch search, search1; 2452 + int haveErrMsg = 0; 2453 + SchemaDocKey *dk; 2454 + 2455 + if (sdata->evalError) return 0; 2456 + if (sdata->unknownIDrefs) { 2457 + if (!recover (interp, sdata, UNKOWN_ID, NULL, NULL, NULL, 0)) { 2458 + haveErrMsg = 1; 2459 + SetResult ("References to unknown IDs:"); 2460 + for (h = Tcl_FirstHashEntry (&sdata->ids, &search); 2461 + h != NULL; 2462 + h = Tcl_NextHashEntry (&search)) { 2463 + if (Tcl_GetHashValue (h) == 0) { 2464 + Tcl_AppendResult (interp, " '", 2465 + Tcl_GetHashKey (&sdata->ids, h), 2466 + "'", NULL); 2467 + } 2468 + } 2469 + } 2470 + } 2471 + if (sdata->idTables.numEntries) { 2472 + for (h = Tcl_FirstHashEntry (&sdata->idTables, &search); 2473 + h != NULL; 2474 + h = Tcl_NextHashEntry (&search)) { 2475 + dk = Tcl_GetHashValue (h); 2476 + if (dk->unknownIDrefs) { 2477 + if (!recover (interp, sdata, UNKOWN_GLOBAL_ID, NULL, NULL, 2478 + NULL, 0)) { 2479 + if (haveErrMsg) { 2480 + Tcl_AppendResult (interp, "\n", NULL); 2481 + } else { 2482 + haveErrMsg = 1; 2483 + } 2484 + Tcl_AppendResult (interp, 2485 + "References to unknown IDs in ID space '", 2486 + Tcl_GetHashKey (&sdata->idTables, h), 2487 + "':", NULL); 2488 + for (h1 = Tcl_FirstHashEntry (&dk->ids, &search1); 2489 + h1 != NULL; 2490 + h1 = Tcl_NextHashEntry (&search1)) { 2491 + if (Tcl_GetHashValue (h1) == 0) { 2492 + Tcl_AppendResult (interp, " '", 2493 + Tcl_GetHashKey (&dk->ids, h1), 2494 + "'", NULL); 2495 + } 2496 + } 2497 + } 2498 + } 2499 + } 2500 + } 2501 + if (haveErrMsg) { 2502 + sdata->validationState = VALIDATION_ERROR; 2503 + return 0; 2504 + } 2505 + return 1; 2506 +} 2507 + 2508 +int 2509 +tDOM_probeElementEnd ( 2510 + Tcl_Interp *interp, 2511 + SchemaData *sdata 2512 + ) 2513 +{ 2514 + int rc; 2515 + 2516 + DBG(if (sdata->stack) { 2517 + fprintf (stderr, "tDOM_probeElementEnd: look if current stack top can " 2518 + " end name: '%s' deep: %d\n", 2519 + sdata->stack->pattern->name, getDeep (sdata->stack)); 2520 + } else {fprintf (stderr, "stack is NULL\n");} 2521 + ); 2522 + 2523 + if (sdata->skipDeep) { 2524 + sdata->skipDeep--; 2525 + return TCL_OK; 2526 + } 2527 + if (sdata->validationState == VALIDATION_FINISHED) { 2528 + SetResult ("Validation finished"); 2529 + return TCL_ERROR; 2530 + } 2531 + if (sdata->validationState == VALIDATION_READY) { 2532 + SetResult ("No validation started"); 2533 + return TCL_ERROR; 2534 + } 2535 + if (sdata->validationState == VALIDATION_ERROR) { 2536 + return TCL_ERROR; 2537 + } 2538 + 2539 + while (1) { 2540 + rc = checkElementEnd (interp, sdata); 2541 + while (rc == -1) { 2542 + popStack (sdata); 2543 + rc = checkElementEnd (interp, sdata); 2544 + } 2545 + sdata->recoverFlags &= ~RECOVER_FLAG_DONT_REPORT; 2546 + if (rc == 2) { 2547 + sdata->recoverFlags &= ~RECOVER_FLAG_MATCH_END_CONTINUE; 2548 + continue; 2549 + } 2550 + if (rc == 1) { 2551 + popStack (sdata); 2552 + if (sdata->stack == NULL) { 2553 + /* End of the first pattern (the tree root) without error. */ 2554 + /* Check for unknown ID references */ 2555 + if (!checkDocKeys (interp, sdata)) { 2556 + return TCL_ERROR; 2557 + } 2558 + /* We have successfully finished validation */ 2559 + sdata->validationState = VALIDATION_FINISHED; 2560 + } 2561 + DBG( 2562 + fprintf(stderr, "tDOM_probeElementEnd: _CAN_ end here.\n"); 2563 + serializeStack (sdata); 2564 + ); 2565 + return TCL_OK; 2566 + } 2567 + break; 2568 + } 2569 + SetResultV ("Missing mandatory content"); 2570 + sdata->validationState = VALIDATION_ERROR; 2571 + DBG( 2572 + fprintf(stderr, "tDOM_probeElementEnd: CAN'T end here.\n"); 2573 + serializeStack (sdata); 2574 + ); 2575 + return TCL_ERROR; 2576 +} 2577 + 2578 +static int 2579 +matchText ( 2580 + Tcl_Interp *interp, 2581 + SchemaData *sdata, 2582 + char *text 2583 + ) 2584 +{ 2585 + SchemaCP *cp, *candidate, *ic; 2586 + SchemaValidationStack *se; 2587 + int ac, hm, isName = 0, i, mayskip; 2588 + 2589 + DBG(fprintf (stderr, "matchText called with text '%s'\n", text)); 2590 + 2591 + se = sdata->stack; 2592 + getContext (cp, ac, hm); 2593 + while (1) { 2594 + switch (cp->type) { 2595 + case SCHEMA_CTYPE_NAME: 2596 + isName = 1; 2597 + /* Fall through */ 2598 + case SCHEMA_CTYPE_PATTERN: 2599 + while (ac < cp->nc) { 2600 + candidate = cp->content[ac]; 2601 + switch (candidate->type) { 2602 + case SCHEMA_CTYPE_TEXT: 2603 + if (checkText (interp, candidate, text)) { 2604 + updateStack (sdata, se, ac); 2605 + return 1; 2606 + } 2607 + if (sdata->evalError) return 0; 2608 + if (recover (interp, sdata, INVALID_VALUE, NULL, NULL, 2609 + text, ac)) { 2610 + updateStack (sdata, se, ac); 2611 + return 1; 2612 + } 2613 + SetResult ("Invalid text content"); 2614 + return 0; 2615 + 2616 + case SCHEMA_CTYPE_CHOICE: 2617 + if (candidate->flags & MIXED_CONTENT) { 2618 + updateStack (sdata, se, ac); 2619 + return 1; 2620 + } 2621 + for (i = 0; i < candidate->nc; i++) { 2622 + ic = candidate->content[i]; 2623 + switch (ic->type) { 2624 + case SCHEMA_CTYPE_TEXT: 2625 + if (checkText (interp, ic, text)) { 2626 + updateStack (sdata, se, ac); 2627 + return 1; 2628 + } 2629 + break; 2630 + 2631 + case SCHEMA_CTYPE_NAME: 2632 + case SCHEMA_CTYPE_ANY: 2633 + break; 2634 + 2635 + case SCHEMA_CTYPE_PATTERN: 2636 + if (recursivePattern (se, ic)) { 2637 + break; 2638 + } 2639 + /* fall throu */ 2640 + case SCHEMA_CTYPE_INTERLEAVE: 2641 + pushToStack (sdata, ic); 2642 + if (matchText (interp, sdata, text)) { 2643 + updateStack (sdata, se, ac); 2644 + return 1; 2645 + } 2646 + popStack (sdata); 2647 + break; 2648 + 2649 + case SCHEMA_CTYPE_VIRTUAL: 2650 + Tcl_Panic ("Virtual constrain in MIXED or" 2651 + " CHOICE"); 2652 + 2653 + case SCHEMA_CTYPE_CHOICE: 2654 + Tcl_Panic ("MIXED or CHOICE child of MIXED or" 2655 + " CHOICE"); 2656 + 2657 + case SCHEMA_CTYPE_KEYSPACE_END: 2658 + case SCHEMA_CTYPE_KEYSPACE: 2659 + Tcl_Panic ("Keyspace constrain in MIXED or" 2660 + " CHOICE"); 2661 + 2662 + } 2663 + } 2664 + if (mustMatch (cp->quants[ac], hm)) { 2665 + if (recover (interp, sdata, UNEXPECTED_TEXT, 2666 + NULL, NULL, text, 0)) { 2667 + return 1; 2668 + } 2669 + SetResultV ("Unexpected text content"); 2670 + return 0; 2671 + } 2672 + break; 2673 + 2674 + case SCHEMA_CTYPE_PATTERN: 2675 + if (recursivePattern (se, candidate)) { 2676 + break; 2677 + } 2678 + /* fall throu */ 2679 + case SCHEMA_CTYPE_INTERLEAVE: 2680 + pushToStack (sdata, candidate); 2681 + if (matchText (interp, sdata, text)) { 2682 + updateStack (sdata, se, ac); 2683 + return 1; 2684 + } 2685 + popStack (sdata); 2686 + if (mustMatch (cp->quants[ac], hm)) { 2687 + if (recover (interp, sdata, UNEXPECTED_TEXT, 2688 + NULL, NULL, text, 0)) { 2689 + return 1; 2690 + } 2691 + SetResultV ("Unexpected text content"); 2692 + return 0; 2693 + } 2694 + break; 2695 + 2696 + case SCHEMA_CTYPE_VIRTUAL: 2697 + if (!evalVirtual (interp, sdata, ac)) return 0; 2698 + break; 2699 + 2700 + case SCHEMA_CTYPE_KEYSPACE: 2701 + if (!cp->content[ac]->keySpace->active) { 2702 + Tcl_InitHashTable (&cp->content[ac]->keySpace->ids, 2703 + TCL_STRING_KEYS); 2704 + cp->content[ac]->keySpace->active = 1; 2705 + cp->content[ac]->keySpace->unknownIDrefs = 0; 2706 + } else { 2707 + cp->content[ac]->keySpace->active++; 2708 + } 2709 + break; 2710 + 2711 + case SCHEMA_CTYPE_KEYSPACE_END: 2712 + cp->content[ac]->keySpace->active--; 2713 + if (!cp->content[ac]->keySpace->active) { 2714 + if (cp->content[ac]->keySpace->unknownIDrefs) { 2715 + if (!recover (interp, sdata, 2716 + INVALID_KEYREF_MATCH_TEXT, NULL, 2717 + NULL, text, ac)) { 2718 + return 0; 2719 + } 2720 + cp->content[ac]->keySpace->unknownIDrefs = 0; 2721 + } 2722 + Tcl_DeleteHashTable (&cp->content[ac]->keySpace->ids); 2723 + } 2724 + break; 2725 + 2726 + case SCHEMA_CTYPE_NAME: 2727 + case SCHEMA_CTYPE_ANY: 2728 + if (mustMatch (cp->quants[ac], hm)) { 2729 + if (recover (interp, sdata, UNEXPECTED_TEXT, 2730 + NULL, NULL, text, ac)) { 2731 + return 1; 2732 + } 2733 + SetResultV ("Unexpected text content"); 2734 + return 0; 2735 + } 2736 + break; 2737 + 2738 + } 2739 + ac++; 2740 + } 2741 + if (isName) { 2742 + if (recover (interp, sdata, UNEXPECTED_TEXT, NULL, 2743 + NULL, text, 0)) { 2744 + return 1; 2745 + } 2746 + SetResultV ("Unexpected text content"); 2747 + return 0; 2748 + } 2749 + popStack (sdata); 2750 + se = sdata->stack; 2751 + getContext (cp, ac, hm); 2752 + ac++; 2753 + continue; 2754 + 2755 + case SCHEMA_CTYPE_KEYSPACE: 2756 + case SCHEMA_CTYPE_KEYSPACE_END: 2757 + case SCHEMA_CTYPE_VIRTUAL: 2758 + case SCHEMA_CTYPE_CHOICE: 2759 + case SCHEMA_CTYPE_TEXT: 2760 + case SCHEMA_CTYPE_ANY: 2761 + /* Never pushed onto stack */ 2762 + Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 2763 + break; 2764 + 2765 + case SCHEMA_CTYPE_INTERLEAVE: 2766 + mayskip = 1; 2767 + for (i = 0; i < cp->nc; i++) { 2768 + if (se->interleaveState[i]) { 2769 + if (maxOne (cp->quants[i])) continue; 2770 + } else { 2771 + if (minOne (cp->quants[i])) mayskip = 0; 2772 + } 2773 + ic = cp->content[i]; 2774 + switch (ic->type) { 2775 + case SCHEMA_CTYPE_TEXT: 2776 + if (checkText (interp, ic, text)) { 2777 + if (!(sdata->recoverFlags & RECOVER_FLAG_REWIND)) { 2778 + se->hasMatched = 1; 2779 + se->interleaveState[i] = 1; 2780 + } 2781 + return 1; 2782 + } 2783 + break; 2784 + 2785 + case SCHEMA_CTYPE_NAME: 2786 + case SCHEMA_CTYPE_ANY: 2787 + break; 2788 + 2789 + case SCHEMA_CTYPE_PATTERN: 2790 + if (recursivePattern (se, ic)) { 2791 + break; 2792 + } 2793 + /* fall throu */ 2794 + case SCHEMA_CTYPE_INTERLEAVE: 2795 + pushToStack (sdata, ic); 2796 + if (matchText (interp, sdata, text)) { 2797 + updateStack (sdata, se, ac); 2798 + return 1; 2799 + } 2800 + popStack (sdata); 2801 + break; 2802 + 2803 + case SCHEMA_CTYPE_CHOICE: 2804 + Tcl_Panic ("MIXED or CHOICE child of INTERLEAVE"); 2805 + 2806 + case SCHEMA_CTYPE_KEYSPACE_END: 2807 + case SCHEMA_CTYPE_KEYSPACE: 2808 + Tcl_Panic ("Keyspace child of INTERLEAVE"); 2809 + 2810 + case SCHEMA_CTYPE_VIRTUAL: 2811 + break; 2812 + 2813 + } 2814 + } 2815 + if (!mayskip) { 2816 + if (recover (interp, sdata, UNEXPECTED_TEXT, NULL, NULL, text, 2817 + ac)) { 2818 + return 1; 2819 + } 2820 + SetResultV ("Unexpected text content"); 2821 + return 0; 2822 + } 2823 + popStack (sdata); 2824 + se = sdata->stack; 2825 + getContext (cp, ac, hm); 2826 + ac++; 2827 + continue; 2828 + } 2829 + /* Not reached, but this is inside a while (1) {} loop ...*/ 2830 + break; 2831 + } 2832 + /* Not reached, but at least makes the compiler happy. */ 2833 + return 0; 2834 +} 2835 + 2836 +int 2837 +tDOM_probeText ( 2838 + Tcl_Interp *interp, 2839 + SchemaData *sdata, 2840 + char *text, 2841 + int *only_whites 2842 + ) 2843 +{ 2844 + int myonly_whites; 2845 + char *pc; 2846 + 2847 + DBG(fprintf (stderr, "tDOM_probeText started, text: '%s'\n", text);) 2848 + if (sdata->skipDeep) { 2849 + return TCL_OK; 2850 + } 2851 + if (sdata->validationState == VALIDATION_FINISHED) { 2852 + SetResult ("Validation finished"); 2853 + return TCL_ERROR; 2854 + } 2855 + if (sdata->validationState == VALIDATION_READY) { 2856 + SetResult ("No validation started"); 2857 + return TCL_ERROR; 2858 + } 2859 + 2860 + if (sdata->stack->pattern->flags & CONSTRAINT_TEXT_CHILD) { 2861 + if (!*text && sdata->stack->pattern->nc == 0) { 2862 + return TCL_OK; 2863 + } 2864 + if (matchText (interp, sdata, text)) { 2865 + CHECK_REWIND; 2866 + return TCL_OK; 2867 + } 2868 + } else { 2869 + if (only_whites) { 2870 + myonly_whites = *only_whites; 2871 + } else { 2872 + myonly_whites = 1; 2873 + pc = text; 2874 + while (SPACE (*pc)) pc++; 2875 + if (*pc) myonly_whites = 0; 2876 + } 2877 + if (myonly_whites) return TCL_OK; 2878 + if (matchText (interp, sdata, text)) { 2879 + CHECK_REWIND; 2880 + return TCL_OK; 2881 + } 2882 + } 2883 + if (!sdata->evalError) { 2884 + SetResult ("Text content doesn't match"); 2885 + } 2886 + return TCL_ERROR; 2887 +} 2888 + 2889 +static void 2890 +startElement( 2891 + void *userData, 2892 + const char *name, 2893 + const char **atts 2894 +) 2895 +{ 2896 + ValidateMethodData *vdata = (ValidateMethodData *) userData; 2897 + SchemaData *sdata; 2898 + char *namespace; 2899 + const char *s; 2900 + int i = 0; 2901 + 2902 + DBG(fprintf (stderr, "startElement: '%s'\n", name);) 2903 + sdata = vdata->sdata; 2904 + if (!sdata->skipDeep && sdata->stack && Tcl_DStringLength (vdata->cdata)) { 2905 + if (tDOM_probeText (vdata->interp, sdata, 2906 + Tcl_DStringValue (vdata->cdata), NULL) != TCL_OK) { 2907 + sdata->validationState = VALIDATION_ERROR; 2908 + XML_StopParser (vdata->parser, 0); 2909 + Tcl_DStringSetLength (vdata->cdata, 0); 2910 + vdata->onlyWhiteSpace = 1; 2911 + return; 2912 + } 2913 + Tcl_DStringSetLength (vdata->cdata, 0); 2914 + vdata->onlyWhiteSpace = 1; 2915 + } 2916 + s = name; 2917 + while (*s && *s != '\xFF') { 2918 + i++; s++; 2919 + } 2920 + namespace = NULL; 2921 + if (*s == '\xFF') { 2922 + s++; 2923 + if (i) { 2924 + if (i >= vdata->maxUriLen - 1) { 2925 + vdata->uri = (char *) REALLOC (vdata->uri, vdata->maxUriLen * 2); 2926 + vdata->maxUriLen *= 2; 2927 + } 2928 + memcpy (vdata->uri, name, i); 2929 + vdata->uri[i] = '\0'; 2930 + namespace = vdata->uri; 2931 + } 2932 + } else { 2933 + s = name; 2934 + } 2935 + 2936 + if (tDOM_probeElement (vdata->interp, sdata, s, namespace) 2937 + != TCL_OK) { 2938 + sdata->validationState = VALIDATION_ERROR; 2939 + XML_StopParser (vdata->parser, 0); 2940 + return; 2941 + } 2942 + if (sdata->skipDeep == 0 2943 + && (atts[0] || (sdata->stack && sdata->stack->pattern->attrs))) { 2944 + if (tDOM_probeAttributes (vdata->interp, sdata, atts) 2945 + != TCL_OK) { 2946 + sdata->validationState = VALIDATION_ERROR; 2947 + XML_StopParser (vdata->parser, 0); 2948 + } 2949 + } 2950 +} 2951 + 2952 +static void 2953 +endElement ( 2954 + void *userData, 2955 + const char *name 2956 +) 2957 +{ 2958 + ValidateMethodData *vdata = (ValidateMethodData *) userData; 2959 + SchemaData *sdata; 2960 + 2961 + DBG(fprintf (stderr, "endElement: '%s'\n", name);) 2962 + sdata = vdata->sdata; 2963 + if (sdata->validationState == VALIDATION_ERROR) { 2964 + return; 2965 + } 2966 + if (!sdata->skipDeep && sdata->stack && Tcl_DStringLength (vdata->cdata)) { 2967 + if (tDOM_probeText (vdata->interp, sdata, 2968 + Tcl_DStringValue (vdata->cdata), NULL) != TCL_OK) { 2969 + sdata->validationState = VALIDATION_ERROR; 2970 + XML_StopParser (vdata->parser, 0); 2971 + Tcl_DStringSetLength (vdata->cdata, 0); 2972 + vdata->onlyWhiteSpace = 1; 2973 + return; 2974 + } 2975 + } 2976 + if (Tcl_DStringLength (vdata->cdata)) { 2977 + Tcl_DStringSetLength (vdata->cdata, 0); 2978 + vdata->onlyWhiteSpace = 1; 2979 + } 2980 + if (tDOM_probeElementEnd (vdata->interp, sdata) 2981 + != TCL_OK) { 2982 + sdata->validationState = VALIDATION_ERROR; 2983 + XML_StopParser (vdata->parser, 0); 2984 + } 2985 +} 2986 + 2987 +static void 2988 +characterDataHandler ( 2989 + void *userData, 2990 + const char *s, 2991 + int len 2992 +) 2993 +{ 2994 + ValidateMethodData *vdata = (ValidateMethodData *) userData; 2995 + const char *pc; 2996 + 2997 + if (vdata->onlyWhiteSpace) { 2998 + int i = 0; 2999 + pc = s; 3000 + while (i < len) { 3001 + if ( (*pc == ' ') || 3002 + (*pc == '\n') || 3003 + (*pc == '\r') || 3004 + (*pc == '\t') ) { 3005 + pc++; 3006 + i++; 3007 + continue; 3008 + } 3009 + vdata->onlyWhiteSpace = 0; 3010 + break; 3011 + } 3012 + } 3013 + Tcl_DStringAppend (vdata->cdata, s, len); 3014 +} 3015 + 3016 +static int 3017 +validateString ( 3018 + Tcl_Interp *interp, 3019 + SchemaData *sdata, 3020 + char *xmlstr, 3021 + int len 3022 + ) 3023 +{ 3024 + XML_Parser parser; 3025 + char sep = '\xFF'; 3026 + ValidateMethodData vdata; 3027 + Tcl_DString cdata; 3028 + Tcl_Obj *resultObj; 3029 + char sl[50], sc[50]; 3030 + int result; 3031 + 3032 + parser = XML_ParserCreate_MM (NULL, MEM_SUITE, &sep); 3033 + vdata.interp = interp; 3034 + vdata.sdata = sdata; 3035 + vdata.parser = parser; 3036 + sdata->parser = parser; 3037 + Tcl_DStringInit (&cdata); 3038 + vdata.cdata = &cdata; 3039 + vdata.onlyWhiteSpace = 1; 3040 + vdata.uri = (char *) MALLOC (URI_BUFFER_LEN_INIT); 3041 + vdata.maxUriLen = URI_BUFFER_LEN_INIT; 3042 + XML_SetUserData (parser, &vdata); 3043 + XML_SetElementHandler (parser, startElement, endElement); 3044 + XML_SetCharacterDataHandler (parser, characterDataHandler); 3045 + 3046 + if (XML_Parse (parser, xmlstr, len, 1) != XML_STATUS_OK 3047 + || sdata->validationState == VALIDATION_ERROR) { 3048 + resultObj = Tcl_NewObj (); 3049 + sprintf(sl, "%ld", XML_GetCurrentLineNumber(parser)); 3050 + sprintf(sc, "%ld", XML_GetCurrentColumnNumber(parser)); 3051 + if (sdata->validationState == VALIDATION_ERROR) { 3052 + Tcl_AppendStringsToObj (resultObj, "error \"", 3053 + Tcl_GetStringResult (interp), 3054 + "\" at line ", sl, " character ", sc, NULL); 3055 + } else { 3056 + Tcl_AppendStringsToObj (resultObj, "error \"", 3057 + XML_ErrorString(XML_GetErrorCode(parser)), 3058 + "\" at line ", sl, " character ", sc, NULL); 3059 + } 3060 + Tcl_SetObjResult (interp, resultObj); 3061 + result = TCL_ERROR; 3062 + } else { 3063 + result = TCL_OK; 3064 + } 3065 + sdata->parser = NULL; 3066 + XML_ParserFree (parser); 3067 + Tcl_DStringFree (&cdata); 3068 + FREE (vdata.uri); 3069 + return result; 3070 +} 3071 + 3072 +static int 3073 +validateFile ( 3074 + Tcl_Interp *interp, 3075 + SchemaData *sdata, 3076 + Tcl_Obj *filenameObj 3077 + ) 3078 +{ 3079 + XML_Parser parser; 3080 + char sep = '\xFF'; 3081 + ValidateMethodData vdata; 3082 + Tcl_DString cdata; 3083 + Tcl_Obj *resultObj; 3084 + char sl[50], sc[50]; 3085 + char *filename; 3086 + int result, fd; 3087 + Tcl_DString translatedFilename; 3088 + 3089 + parser = XML_ParserCreate_MM (NULL, MEM_SUITE, &sep); 3090 + vdata.interp = interp; 3091 + vdata.sdata = sdata; 3092 + vdata.parser = parser; 3093 + sdata->parser = parser; 3094 + Tcl_DStringInit (&cdata); 3095 + vdata.cdata = &cdata; 3096 + vdata.onlyWhiteSpace = 1; 3097 + vdata.uri = (char *) MALLOC (URI_BUFFER_LEN_INIT); 3098 + vdata.maxUriLen = URI_BUFFER_LEN_INIT; 3099 + XML_SetUserData (parser, &vdata); 3100 + XML_SetElementHandler (parser, startElement, endElement); 3101 + XML_SetCharacterDataHandler (parser, characterDataHandler); 3102 + 3103 + filename = Tcl_TranslateFileName (interp, Tcl_GetString (filenameObj), 3104 + &translatedFilename); 3105 + if (filename == NULL) { 3106 + result = TCL_ERROR; 3107 + goto cleanup; 3108 + } 3109 + fd = open(filename, O_BINARY|O_RDONLY); 3110 + if (fd < 0) { 3111 + Tcl_ResetResult (interp); 3112 + Tcl_AppendResult (interp, "error opening file \"", 3113 + filename, "\"", (char *) NULL); 3114 + result = TCL_ERROR; 3115 + goto cleanup; 3116 + } 3117 + for (;;) { 3118 + int nread; 3119 + char *fbuf = XML_GetBuffer (parser, TDOM_EXPAT_READ_SIZE); 3120 + if (!fbuf) { 3121 + close (fd); 3122 + Tcl_ResetResult (interp); 3123 + Tcl_SetResult (interp, "Out of memory\n", NULL); 3124 + result = TCL_ERROR; 3125 + goto cleanup; 3126 + } 3127 + nread = read(fd, fbuf, TDOM_EXPAT_READ_SIZE); 3128 + if (nread < 0) { 3129 + close (fd); 3130 + Tcl_ResetResult (interp); 3131 + Tcl_AppendResult (interp, "error reading from file \"", 3132 + filename, "\"", (char *) NULL); 3133 + result = TCL_ERROR; 3134 + goto cleanup; 3135 + } 3136 + result = XML_ParseBuffer (parser, nread, nread == 0); 3137 + if (result != XML_STATUS_OK || !nread 3138 + || sdata->validationState == VALIDATION_ERROR) { 3139 + close (fd); 3140 + break; 3141 + } 3142 + } 3143 + if (result != XML_STATUS_OK 3144 + || sdata->validationState == VALIDATION_ERROR) { 3145 + resultObj = Tcl_NewObj (); 3146 + sprintf(sl, "%ld", XML_GetCurrentLineNumber(parser)); 3147 + sprintf(sc, "%ld", XML_GetCurrentColumnNumber(parser)); 3148 + if (sdata->validationState == VALIDATION_ERROR) { 3149 + Tcl_AppendStringsToObj (resultObj, "error \"", 3150 + Tcl_GetStringResult (interp), 3151 + "\" at line ", sl, " character ", sc, NULL); 3152 + } else { 3153 + Tcl_AppendStringsToObj (resultObj, "error \"", 3154 + XML_ErrorString(XML_GetErrorCode(parser)), 3155 + "\" at line ", sl, " character ", sc, NULL); 3156 + } 3157 + Tcl_SetObjResult (interp, resultObj); 3158 + result = TCL_ERROR; 3159 + } else { 3160 + Tcl_DStringFree (&translatedFilename); 3161 + result = TCL_OK; 3162 + } 3163 +cleanup: 3164 + Tcl_DStringFree (&translatedFilename); 3165 + sdata->parser = NULL; 3166 + XML_ParserFree (parser); 3167 + Tcl_DStringFree (&cdata); 3168 + FREE (vdata.uri); 3169 + return result; 3170 +} 3171 + 3172 +static int 3173 +validateChannel ( 3174 + Tcl_Interp *interp, 3175 + SchemaData *sdata, 3176 + Tcl_Channel channel 3177 + ) 3178 +{ 3179 + XML_Parser parser; 3180 + char sep = '\xFF'; 3181 + ValidateMethodData vdata; 3182 + Tcl_DString cdata; 3183 + Tcl_Obj *resultObj, *bufObj; 3184 + char sl[50], sc[50], *str; 3185 + int result = TCL_OK, len, done, tclLen, rc; 3186 + 3187 + parser = XML_ParserCreate_MM (NULL, MEM_SUITE, &sep); 3188 + vdata.interp = interp; 3189 + vdata.sdata = sdata; 3190 + vdata.parser = parser; 3191 + sdata->parser = parser; 3192 + Tcl_DStringInit (&cdata); 3193 + vdata.cdata = &cdata; 3194 + vdata.onlyWhiteSpace = 1; 3195 + vdata.uri = (char *) MALLOC (URI_BUFFER_LEN_INIT); 3196 + vdata.maxUriLen = URI_BUFFER_LEN_INIT; 3197 + XML_SetUserData (parser, &vdata); 3198 + XML_SetElementHandler (parser, startElement, endElement); 3199 + XML_SetCharacterDataHandler (parser, characterDataHandler); 3200 + 3201 + bufObj = Tcl_NewObj(); 3202 + Tcl_SetObjLength (bufObj, 6144); 3203 + do { 3204 + len = Tcl_ReadChars (channel, bufObj, 1024, 0); 3205 + done = (len < 1024); 3206 + str = Tcl_GetStringFromObj(bufObj, &tclLen); 3207 + rc = XML_Parse (parser, str, tclLen, done); 3208 + if (rc != XML_STATUS_OK 3209 + || sdata->validationState == VALIDATION_ERROR) { 3210 + resultObj = Tcl_NewObj (); 3211 + sprintf(sl, "%ld", XML_GetCurrentLineNumber(parser)); 3212 + sprintf(sc, "%ld", XML_GetCurrentColumnNumber(parser)); 3213 + if (sdata->validationState == VALIDATION_ERROR) { 3214 + Tcl_AppendStringsToObj (resultObj, "error \"", 3215 + Tcl_GetStringResult (interp), 3216 + "\" at line ", sl, " character ", sc, 3217 + NULL); 3218 + } else { 3219 + Tcl_AppendStringsToObj (resultObj, "error \"", 3220 + XML_ErrorString(XML_GetErrorCode(parser)), 3221 + "\" at line ", sl, " character ", sc, 3222 + NULL); 3223 + } 3224 + Tcl_SetObjResult (interp, resultObj); 3225 + result = TCL_ERROR; 3226 + break; 3227 + } 3228 + } while (!done); 3229 + Tcl_DecrRefCount (bufObj); 3230 + sdata->parser = NULL; 3231 + XML_ParserFree (parser); 3232 + Tcl_DStringFree (&cdata); 3233 + FREE (vdata.uri); 3234 + return result; 3235 +} 3236 + 3237 +static void 3238 +schemaxpathRSFree ( 3239 + xpathResultSet *rs 3240 + ) 3241 +{ 3242 + if (rs->type == StringResult) FREE (rs->string); 3243 + FREE (rs->nodes); 3244 +} 3245 + 3246 +static int 3247 +checkdomKeyConstraints ( 3248 + Tcl_Interp *interp, 3249 + SchemaData *sdata, 3250 + domNode *node 3251 + ) 3252 +{ 3253 + xpathResultSet nodeList, rs, frs; 3254 + domKeyConstraint *kc; 3255 + domNode *n; 3256 + domAttrNode *attr; 3257 + int rc, i, j, hnew, len, skip, first; 3258 + char *errMsg = NULL, *keystr, *efsv; 3259 + Tcl_HashTable htable; 3260 + Tcl_DString dStr; 3261 + xpathCBs cbs; 3262 + 3263 + kc = sdata->stack->pattern->domKeys; 3264 + memset (&nodeList, 0, sizeof (xpathResultSet)); 3265 + nodeList.type = EmptyResult; 3266 + memset (&rs, 0, sizeof (xpathResultSet)); 3267 + rs.type = EmptyResult; 3268 + memset (&frs, 0, sizeof (xpathResultSet)); 3269 + frs.type = EmptyResult; 3270 + Tcl_DStringInit (&dStr); 3271 + xpathRSReset (&nodeList, node); 3272 + cbs.funcCB = tcldom_xpathFuncCallBack; 3273 + cbs.funcClientData = interp; 3274 + cbs.varCB = NULL; 3275 + cbs.varClientData = NULL; 3276 + while (kc) { 3277 + xpathRSReset (&rs, NULL); 3278 + rc = xpathEvalAst (kc->selector, &nodeList, node, &cbs, &rs, &errMsg); 3279 + if (rc) { 3280 + SetResult (errMsg); 3281 + goto booleanErrorCleanup; 3282 + } 3283 + if (kc->flags & DKC_FLAG_BOOLEAN) { 3284 + i = xpathFuncBoolean (&rs); 3285 + if (!i) { 3286 + if (!recover (interp, sdata, DOM_XPATH_BOOLEAN, kc->name, 3287 + NULL, NULL, 0)) { 3288 + SetResultV ("INVALID_DOM_XPATH_BOOLEAN"); 3289 + goto booleanErrorCleanup; 3290 + } 3291 + } 3292 + kc = kc->next; 3293 + continue; 3294 + } 3295 + if (rs.type == EmptyResult) goto nextConstraint; 3296 + if (rs.type != xNodeSetResult) { 3297 + SetResult ("INVALID_DOM_KEYCONSTRAINT"); 3298 + goto errorCleanup; 3299 + } 3300 + Tcl_InitHashTable (&htable, TCL_STRING_KEYS); 3301 + for (i = 0; i < rs.nr_nodes; i++) { 3302 + n = rs.nodes[i]; 3303 + if (n->nodeType != ELEMENT_NODE) { 3304 + SetResult ("INVALID_DOM_KEYCONSTRAINT"); 3305 + goto errorCleanup; 3306 + } 3307 + xpathRSReset (&nodeList, n); 3308 + if (kc->nrFields == 1) { 3309 + xpathRSReset (&frs, NULL); 3310 + rc = xpathEvalAst (kc->fields[0], &nodeList, n, &cbs, &frs, 3311 + &errMsg); 3312 + if (rc) { 3313 + SetResult (errMsg); 3314 + goto errorCleanup; 3315 + } 3316 + if (frs.type != xNodeSetResult && frs.type != EmptyResult) { 3317 + SetResult ("INVALID_DOM_KEYCONSTRAINT"); 3318 + goto errorCleanup; 3319 + } 3320 + if (frs.type == EmptyResult || frs.nr_nodes == 0) { 3321 + if (kc->flags & DKC_FLAG_IGNORE_EMPTY_FIELD_SET) { 3322 + continue; 3323 + } 3324 + efsv = ""; 3325 + if (kc->emptyFieldSetValue) { 3326 + efsv = kc->emptyFieldSetValue; 3327 + } 3328 + Tcl_CreateHashEntry (&htable, efsv, &hnew); 3329 + if (!hnew) { 3330 + if (recover (interp, sdata, DOM_KEYCONSTRAINT, 3331 + kc->name, NULL, efsv, 0)) { 3332 + break; 3333 + } 3334 + SetResultV ("DOM_KEYCONSTRAINT"); 3335 + goto errorCleanup; 3336 + } 3337 + continue; 3338 + } 3339 + if (frs.nr_nodes != 1) { 3340 + if (recover (interp, sdata, DOM_KEYCONSTRAINT, kc->name, 3341 + NULL, NULL, 0)) { 3342 + break; 3343 + } 3344 + SetResultV ("DOM_KEYCONSTRAINT"); 3345 + goto errorCleanup; 3346 + } 3347 + if (frs.nodes[0]->nodeType != ELEMENT_NODE 3348 + && frs.nodes[0]->nodeType != ATTRIBUTE_NODE) { 3349 + SetResult ("INVALID_DOM_KEYCONSTRAINT"); 3350 + goto errorCleanup; 3351 + } 3352 + if (frs.nodes[0]->nodeType == ATTRIBUTE_NODE) { 3353 + attr = (domAttrNode *) frs.nodes[0]; 3354 + Tcl_CreateHashEntry (&htable, attr->nodeValue, &hnew); 3355 + if (!hnew) { 3356 + if (recover (interp, sdata, DOM_KEYCONSTRAINT, 3357 + kc->name, NULL, attr->nodeValue, 0)) { 3358 + break; 3359 + } 3360 + SetResultV ("DOM_KEYCONSTRAINT"); 3361 + goto errorCleanup; 3362 + } 3363 + } else { 3364 + keystr = xpathGetStringValue (frs.nodes[0], &len); 3365 + Tcl_CreateHashEntry (&htable, keystr, &hnew); 3366 + if (!hnew) { 3367 + if (recover (interp, sdata, DOM_KEYCONSTRAINT, 3368 + kc->name, NULL, keystr, 0)) { 3369 + FREE(keystr); 3370 + break; 3371 + } 3372 + FREE(keystr); 3373 + SetResultV ("DOM_KEYCONSTRAINT"); 3374 + goto errorCleanup; 3375 + } 3376 + FREE(keystr); 3377 + } 3378 + } else { 3379 + Tcl_DStringSetLength (&dStr, 0); 3380 + skip = 0; 3381 + first = 1; 3382 + for (j = 0; j < kc->nrFields; j++) { 3383 + xpathRSReset (&frs, NULL); 3384 + rc = xpathEvalAst (kc->fields[j], &nodeList, n, &cbs, 3385 + &frs, &errMsg); 3386 + if (rc) { 3387 + SetResult (errMsg); 3388 + goto errorCleanup; 3389 + } 3390 + if (frs.type != xNodeSetResult 3391 + && frs.type != EmptyResult) { 3392 + SetResult ("INVALID_DOM_KEYCONSTRAINT"); 3393 + goto errorCleanup; 3394 + } 3395 + if (frs.type == EmptyResult || frs.nr_nodes == 0) { 3396 + if (kc->flags & DKC_FLAG_IGNORE_EMPTY_FIELD_SET) { 3397 + continue; 3398 + } 3399 + if (kc->emptyFieldSetValue) { 3400 + if (first) first = 0; 3401 + else Tcl_DStringAppend (&dStr, ":", 1); 3402 + Tcl_DStringAppend (&dStr, kc->emptyFieldSetValue, 3403 + kc->efsv_len); 3404 + } else { 3405 + if (first) first = 0; 3406 + else Tcl_DStringAppend (&dStr, ":", 1); 3407 + } 3408 + continue; 3409 + } 3410 + if (frs.nr_nodes != 1) { 3411 + if (recover (interp, sdata, DOM_KEYCONSTRAINT, 3412 + kc->name, NULL, NULL, 0)) { 3413 + skip = 1; 3414 + break; 3415 + } 3416 + SetResultV ("DOM_KEYCONSTRAINT"); 3417 + goto errorCleanup; 3418 + } 3419 + if (frs.nodes[0]->nodeType != ELEMENT_NODE 3420 + && frs.nodes[0]->nodeType != ATTRIBUTE_NODE) { 3421 + SetResult ("INVALID_DOM_KEYCONSTRAINT"); 3422 + goto errorCleanup; 3423 + } 3424 + if (first) first = 0; 3425 + else Tcl_DStringAppend (&dStr, ":", 1); 3426 + if (frs.nodes[0]->nodeType == ATTRIBUTE_NODE) { 3427 + attr = (domAttrNode *) frs.nodes[0]; 3428 + Tcl_DStringAppend (&dStr, attr->nodeValue, 3429 + attr->valueLength); 3430 + } else { 3431 + keystr = xpathGetStringValue (frs.nodes[0], &len); 3432 + Tcl_DStringAppend (&dStr, keystr, len); 3433 + FREE (keystr); 3434 + } 3435 + } 3436 + if (skip) break; 3437 + Tcl_CreateHashEntry (&htable, Tcl_DStringValue (&dStr), &hnew); 3438 + if (!hnew) { 3439 + if (recover (interp, sdata, DOM_KEYCONSTRAINT, 3440 + kc->name, NULL, Tcl_DStringValue (&dStr), 3441 + 0)) { 3442 + break; 3443 + } 3444 + SetResultV ("DOM_KEYCONSTRAINT"); 3445 + goto errorCleanup; 3446 + } 3447 + } 3448 + } 3449 + Tcl_DeleteHashTable (&htable); 3450 + nextConstraint: 3451 + kc = kc->next; 3452 + } 3453 + schemaxpathRSFree (&frs); 3454 + schemaxpathRSFree (&rs); 3455 + schemaxpathRSFree (&nodeList); 3456 + return TCL_OK; 3457 + 3458 +errorCleanup: 3459 + Tcl_DeleteHashTable (&htable); 3460 +booleanErrorCleanup: 3461 + schemaxpathRSFree (&frs); 3462 + schemaxpathRSFree (&rs); 3463 + schemaxpathRSFree (&nodeList); 3464 + return TCL_ERROR; 3465 +} 3466 + 3467 +static int 3468 +validateDOM ( 3469 + Tcl_Interp *interp, 3470 + SchemaData *sdata, 3471 + domNode *node 3472 + ) 3473 +{ 3474 + char *ln; 3475 + domNode *savednode, *savedinsideNode; 3476 + 3477 + if (node->namespace) { 3478 + if (node->ownerDocument->namespaces[node->namespace-1]->prefix[0] == '\0') { 3479 + ln = node->nodeName; 3480 + } else { 3481 + ln = node->nodeName; 3482 + while (*ln && (*ln != ':')) { 3483 + ln++; 3484 + } 3485 + if (*ln == ':') { 3486 + ln++; 3487 + } else { 3488 + /* Ups? */ 3489 + ln = node->nodeName; 3490 + } 3491 + } 3492 + } else { 3493 + ln = node->nodeName; 3494 + } 3495 + savednode = sdata->node; 3496 + sdata->node = node; 3497 + if (tDOM_probeElement (interp, sdata, ln, 3498 + node->namespace ? 3499 + node->ownerDocument->namespaces[node->namespace-1]->uri 3500 + : NULL) 3501 + != TCL_OK) { 3502 + return TCL_ERROR; 3503 + } 3504 + /* In case of UNKNOWN_ROOT_ELEMENT and reportCmd is set 3505 + * sdata->stack is NULL. */ 3506 + if (!sdata->stack) return TCL_OK; 3507 + if (sdata->skipDeep == 0) { 3508 + if (node->firstAttr) { 3509 + if (tDOM_probeDomAttributes (interp, sdata, node->firstAttr) 3510 + != TCL_OK) { 3511 + return TCL_ERROR; 3512 + } 3513 + } else { 3514 + if (sdata->stack->pattern->numReqAttr) { 3515 + /* tDOM_probeDomAttributes fills interp result with a 3516 + * msg which required attributes are missing in case 3517 + * of no reportCmd. In case of reportCmd 3518 + * tDOM_probeDomAttributes() returns only error in the 3519 + * case of error in called scripts. */ 3520 + if (tDOM_probeDomAttributes (interp, sdata, NULL) != TCL_OK) { 3521 + return TCL_ERROR; 3522 + } 3523 + } 3524 + } 3525 + } 3526 + 3527 + if (sdata->stack->pattern->domKeys) { 3528 + if (checkdomKeyConstraints (interp, sdata, node) != TCL_OK) 3529 + return TCL_ERROR; 3530 + } 3531 + 3532 + savedinsideNode = sdata->insideNode; 3533 + sdata->insideNode = node; 3534 + node = node->firstChild; 3535 + while (node) { 3536 + switch (node->nodeType) { 3537 + case ELEMENT_NODE: 3538 + if (Tcl_DStringLength (sdata->cdata)) { 3539 + if (tDOM_probeText (interp, sdata, 3540 + Tcl_DStringValue (sdata->cdata), NULL) != TCL_OK) 3541 + return TCL_ERROR; 3542 + Tcl_DStringSetLength (sdata->cdata, 0); 3543 + } 3544 + if (validateDOM (interp, sdata, node) != TCL_OK) return TCL_ERROR; 3545 + break; 3546 + 3547 + case TEXT_NODE: 3548 + case CDATA_SECTION_NODE: 3549 + if (node == node->parentNode->firstChild 3550 + && node == node->parentNode->lastChild) { 3551 + Tcl_DStringAppend (sdata->cdata, 3552 + ((domTextNode *) node)->nodeValue, 3553 + ((domTextNode *) node)->valueLength); 3554 + if (tDOM_probeText (interp, sdata, 3555 + Tcl_DStringValue (sdata->cdata), NULL) != TCL_OK) { 3556 + Tcl_DStringSetLength (sdata->cdata, 0); 3557 + return TCL_ERROR; 3558 + } 3559 + Tcl_DStringSetLength (sdata->cdata, 0); 3560 + break; 3561 + } 3562 + Tcl_DStringAppend (sdata->cdata, 3563 + ((domTextNode *) node)->nodeValue, 3564 + ((domTextNode *) node)->valueLength); 3565 + break; 3566 + 3567 + case COMMENT_NODE: 3568 + case PROCESSING_INSTRUCTION_NODE: 3569 + /* They are just ignored by validation. */ 3570 + break; 3571 + 3572 + default: 3573 + SetResult ("Unexpected node type in validateDOM!"); 3574 + return TCL_ERROR; 3575 + } 3576 + node = node->nextSibling; 3577 + } 3578 + if (Tcl_DStringLength (sdata->cdata)) { 3579 + if (tDOM_probeText (interp, sdata, Tcl_DStringValue (sdata->cdata), 3580 + NULL) != TCL_OK) return TCL_ERROR; 3581 + Tcl_DStringSetLength (sdata->cdata, 0); 3582 + } 3583 + if (tDOM_probeElementEnd (interp, sdata) != TCL_OK) return TCL_ERROR; 3584 + sdata->node = savednode; 3585 + sdata->insideNode = savedinsideNode; 3586 + return TCL_OK; 3587 +} 3588 + 3589 +static void 3590 +schemaReset ( 3591 + SchemaData *sdata 3592 + ) 3593 +{ 3594 + Tcl_HashEntry *h; 3595 + Tcl_HashSearch search; 3596 + SchemaDocKey *dk; 3597 + SchemaKeySpace *ks; 3598 + 3599 + while (sdata->stack) popStack (sdata); 3600 + while (sdata->lastMatchse) popFromStack (sdata, &sdata->lastMatchse); 3601 + sdata->recoverFlags = 0; 3602 + sdata->validationState = VALIDATION_READY; 3603 + sdata->skipDeep = 0; 3604 + sdata->evalError = 0; 3605 + sdata->vaction = 0; 3606 + sdata->vname = NULL; 3607 + sdata->vns = NULL; 3608 + sdata->vtext = NULL; 3609 + Tcl_DStringSetLength (sdata->cdata, 0); 3610 + if (sdata->ids.numEntries) { 3611 + Tcl_DeleteHashTable (&sdata->ids); 3612 + Tcl_InitHashTable (&sdata->ids, TCL_STRING_KEYS); 3613 + sdata->unknownIDrefs = 0; 3614 + } 3615 + if (sdata->idTables.numEntries) { 3616 + for (h = Tcl_FirstHashEntry (&sdata->idTables, &search); 3617 + h != NULL; 3618 + h = Tcl_NextHashEntry (&search)) { 3619 + dk = Tcl_GetHashValue (h); 3620 + if ((&dk->ids)->numEntries) { 3621 + Tcl_DeleteHashTable (&dk->ids); 3622 + Tcl_InitHashTable (&dk->ids, TCL_STRING_KEYS); 3623 + dk->unknownIDrefs = 0; 3624 + } 3625 + } 3626 + } 3627 + if (sdata->keySpaces.numEntries) { 3628 + for (h = Tcl_FirstHashEntry (&sdata->keySpaces, &search); 3629 + h != NULL; 3630 + h = Tcl_NextHashEntry (&search)) { 3631 + ks = Tcl_GetHashValue (h); 3632 + if (ks->active && ks->ids.numEntries) { 3633 + Tcl_DeleteHashTable (&ks->ids); 3634 + Tcl_InitHashTable (&ks->ids, TCL_STRING_KEYS); 3635 + } 3636 + ks->unknownIDrefs = 0; 3637 + ks->active = 0; 3638 + } 3639 + } 3640 + sdata->parser = NULL; 3641 + sdata->node = NULL; 3642 + sdata->insideNode = NULL; 3643 +} 3644 + 3645 +void 3646 +tDOM_schemaReset ( 3647 + SchemaData *sdata, 3648 + int lookforCleanup 3649 + ) 3650 +{ 3651 + if (lookforCleanup) { 3652 + if (sdata->cleanupAfterUse && sdata->inuse == 0 3653 + && sdata->currentEvals == 0) { 3654 + schemaInstanceDelete (sdata); 3655 + return; 3656 + } 3657 + } 3658 + schemaReset (sdata); 3659 +} 3660 + 3661 +static int 3662 +evalConstraints ( 3663 + Tcl_Interp *interp, 3664 + SchemaData *sdata, 3665 + SchemaCP *cp, 3666 + Tcl_Obj *script 3667 + ) 3668 +{ 3669 + int result, savedIsTextConstraint; 3670 + SchemaCP *savedCP; 3671 + unsigned int savedContenSize; 3672 + 3673 + /* Save some state of sdata .. */ 3674 + savedCP = sdata->cp; 3675 + savedContenSize = sdata->contentSize; 3676 + savedIsTextConstraint = sdata->isTextConstraint; 3677 + /* ... and prepare sdata for definition evaluation. */ 3678 + sdata->cp = cp; 3679 + sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 3680 + sdata->isTextConstraint = 1; 3681 + sdata->textStub[3] = script; 3682 + sdata->currentEvals++; 3683 + result = Tcl_EvalObjv (interp, 4, sdata->textStub, TCL_EVAL_GLOBAL); 3684 + sdata->currentEvals--; 3685 + /* ... and restore the previously saved sdata states */ 3686 + sdata->isTextConstraint = savedIsTextConstraint; 3687 + sdata->cp = savedCP; 3688 + sdata->contentSize = savedContenSize; 3689 + return result; 3690 +} 3691 + 3692 +/* cp must be of type SCHEMA_CTYPE_NAME for useful results */ 3693 +static Tcl_Obj* 3694 +serializeElementName ( 3695 + Tcl_Interp *interp, 3696 + SchemaCP *cp 3697 + ) 3698 +{ 3699 + Tcl_Obj *rObj; 3700 + 3701 + rObj = Tcl_NewObj(); 3702 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj (cp->name, -1)); 3703 + if (cp->namespace) { 3704 + Tcl_ListObjAppendElement (interp, rObj, 3705 + Tcl_NewStringObj (cp->namespace, -1)); 3706 + } 3707 + return rObj; 3708 +} 3709 + 3710 +static Tcl_Obj* 3711 +serializeElementTypeName ( 3712 + Tcl_Interp *interp, 3713 + SchemaCP *cp 3714 + ) 3715 +{ 3716 + Tcl_Obj *rObj; 3717 + 3718 + rObj = Tcl_NewObj(); 3719 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj (cp->typeName, -1)); 3720 + if (cp->namespace) { 3721 + Tcl_ListObjAppendElement (interp, rObj, 3722 + Tcl_NewStringObj (cp->namespace, -1)); 3723 + } 3724 + return rObj; 3725 +} 3726 + 3727 +/* cp must be of type SCHEMA_CTYPE_ANY for useful results */ 3728 +static Tcl_Obj* 3729 +serializeAnyCP ( 3730 + Tcl_Interp *interp, 3731 + SchemaCP *cp 3732 + ) 3733 +{ 3734 + Tcl_Obj *rObj; 3735 + 3736 + rObj = Tcl_NewObj(); 3737 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj ("<any>", 5)); 3738 + if (cp->namespace) { 3739 + Tcl_ListObjAppendElement (interp, rObj, 3740 + Tcl_NewStringObj (cp->namespace, -1)); 3741 + } else { 3742 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewObj()); 3743 + } 3744 + return rObj; 3745 +} 3746 + 3747 +/* The cp argument may be NULL. If it isn't NULL cp must be of type 3748 + * SCHEMA_CTYPE_TEXT for useful results */ 3749 +static Tcl_Obj* 3750 +serializeTextCP ( 3751 + Tcl_Interp *interp, 3752 + SchemaCP *cp 3753 + ) 3754 +{ 3755 + Tcl_Obj *rObj; 3756 + 3757 + rObj = Tcl_NewObj(); 3758 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj ("#text", 5)); 3759 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewObj()); 3760 + return rObj; 3761 +} 3762 + 3763 +static Tcl_Obj* 3764 +serializeElementEnd ( 3765 + Tcl_Interp *interp 3766 + ) 3767 +{ 3768 + Tcl_Obj *rObj; 3769 + 3770 + rObj = Tcl_NewObj(); 3771 + Tcl_ListObjAppendElement (interp, rObj, 3772 + Tcl_NewStringObj ("<elementend>", 12)); 3773 + Tcl_ListObjAppendElement (interp, rObj, Tcl_NewObj()); 3774 + return rObj; 3775 +} 3776 + 3777 +static void 3778 +definedElements ( 3779 + Tcl_HashTable *htable, 3780 + Tcl_Interp *interp 3781 + ) 3782 +{ 3783 + Tcl_Obj *rObj, *elmObj; 3784 + Tcl_HashEntry *h; 3785 + Tcl_HashSearch search; 3786 + SchemaCP *cp; 3787 + 3788 + rObj = Tcl_GetObjResult (interp); 3789 + for (h = Tcl_FirstHashEntry (htable, &search); 3790 + h != NULL; 3791 + h = Tcl_NextHashEntry (&search)) { 3792 + cp = (SchemaCP *) Tcl_GetHashValue (h); 3793 + while (cp) { 3794 + if (cp->flags & FORWARD_PATTERN_DEF 3795 + || cp->flags & PLACEHOLDER_PATTERN_DEF) { 3796 + cp = cp->next; 3797 + continue; 3798 + } 3799 + elmObj = serializeElementName (interp, cp); 3800 + Tcl_ListObjAppendElement (interp, rObj, elmObj); 3801 + cp = cp->next; 3802 + } 3803 + } 3804 +} 3805 + 3806 +static void 3807 +definedElementtypes ( 3808 + SchemaData *sdata, 3809 + Tcl_Interp *interp 3810 + ) 3811 +{ 3812 + Tcl_Obj *rObj, *elmObj; 3813 + Tcl_HashEntry *h; 3814 + Tcl_HashSearch search; 3815 + SchemaCP *cp; 3816 + 3817 + rObj = Tcl_GetObjResult (interp); 3818 + for (h = Tcl_FirstHashEntry (&sdata->elementType, &search); 3819 + h != NULL; 3820 + h = Tcl_NextHashEntry (&search)) { 3821 + cp = (SchemaCP *) Tcl_GetHashValue (h); 3822 + while (cp) { 3823 + if (cp->flags & FORWARD_PATTERN_DEF 3824 + || cp->flags & PLACEHOLDER_PATTERN_DEF) { 3825 + cp = cp->next; 3826 + continue; 3827 + } 3828 + if (cp->flags & FORWARD_PATTERN_DEF 3829 + || cp->flags & PLACEHOLDER_PATTERN_DEF) continue; 3830 + elmObj = serializeElementTypeName (interp, cp); 3831 + Tcl_ListObjAppendElement (interp, rObj, elmObj); 3832 + cp = cp->next; 3833 + } 3834 + } 3835 +} 3836 + 3837 +static int 3838 +getNextExpectedWorker ( 3839 + SchemaData *sdata, 3840 + SchemaValidationStack *se, 3841 + Tcl_Interp *interp, 3842 + Tcl_HashTable *seenCPs, 3843 + Tcl_Obj *rObj, 3844 + int expectedFlags 3845 + ) 3846 +{ 3847 + int ac, hm, i, hnew, mustMatch, mayskip, rc = 1; 3848 + int probeMayskip = 0; 3849 + SchemaCP *cp, *ic, *jc; 3850 + SchemaValidationStack *se1; 3851 + 3852 + if (expectedFlags & EXPECTED_PROBE_MAYSKIP) { 3853 + probeMayskip = 1; 3854 + } 3855 + getContext (cp, ac, hm); 3856 + if ((expectedFlags & EXPECTED_IGNORE_MATCHED 3857 + || expectedFlags & EXPECTED_ONLY_MANDATORY) 3858 + && hm) { 3859 + ac++; 3860 + hm = 0; 3861 + } else { 3862 + if (hm && maxOne(cp->quants[ac])) { 3863 + ac++; 3864 + hm = 0; 3865 + } 3866 + } 3867 + switch (cp->type) { 3868 + case SCHEMA_CTYPE_INTERLEAVE: 3869 + ac = 0; 3870 + mustMatch = 0; 3871 + /* Fall through */ 3872 + case SCHEMA_CTYPE_NAME: 3873 + case SCHEMA_CTYPE_PATTERN: 3874 + while (ac < cp->nc) { 3875 + if (se->interleaveState 3876 + && se->interleaveState[ac] 3877 + && maxOne (cp->quants[ac])) { 3878 + ac++; 3879 + hm = 0; 3880 + continue; 3881 + } 3882 + if (expectedFlags & EXPECTED_ONLY_MANDATORY 3883 + && !(mustMatch (cp->quants[ac], hm))) { 3884 + ac++; 3885 + hm = 0; 3886 + continue; 3887 + } 3888 + ic = cp->content[ac]; 3889 + mayskip = 0; 3890 + switch (ic->type) { 3891 + case SCHEMA_CTYPE_NAME: 3892 + if (probeMayskip) break; 3893 + Tcl_ListObjAppendElement (interp, rObj, 3894 + serializeElementName (interp, ic)); 3895 + break; 3896 + case SCHEMA_CTYPE_PATTERN: 3897 + if (recursivePattern (se, ic)) { 3898 + break; 3899 + } 3900 + /* Fall through */ 3901 + case SCHEMA_CTYPE_INTERLEAVE: 3902 + if (expectedFlags & EXPECTED_ONLY_MANDATORY 3903 + && !se->hasMatched) { 3904 + expectedFlags |= EXPECTED_PROBE_MAYSKIP; 3905 + se1 = getStackElement (sdata, ic); 3906 + mayskip = getNextExpectedWorker (sdata, se1, interp, 3907 + seenCPs, rObj, 3908 + expectedFlags); 3909 + repoolStackElement (sdata, se1); 3910 + if (!probeMayskip) { 3911 + expectedFlags &= ~EXPECTED_PROBE_MAYSKIP; 3912 + } 3913 + if (mayskip) break; 3914 + } 3915 + if (probeMayskip) break; 3916 + Tcl_CreateHashEntry (seenCPs, ic, &hnew); 3917 + if (hnew) { 3918 + se1 = getStackElement (sdata, ic); 3919 + mayskip = getNextExpectedWorker (sdata, se1, interp, 3920 + seenCPs, rObj, 3921 + expectedFlags); 3922 + repoolStackElement (sdata, se1); 3923 + } 3924 + break; 3925 + 3926 + case SCHEMA_CTYPE_ANY: 3927 + if (probeMayskip) break; 3928 + if (!(expectedFlags & EXPECTED_ONLY_MANDATORY) 3929 + || minOne (cp->quants[ac])) { 3930 + Tcl_ListObjAppendElement (interp, rObj, 3931 + serializeAnyCP (interp, ic)); 3932 + } 3933 + break; 3934 + 3935 + case SCHEMA_CTYPE_TEXT: 3936 + if (ic->nc == 0 || checkText (interp, ic, "")) { 3937 + mayskip = 1; 3938 + } 3939 + if (probeMayskip) break; 3940 + if (!(expectedFlags & EXPECTED_ONLY_MANDATORY) 3941 + || mayskip == 0) { 3942 + Tcl_ListObjAppendElement (interp, rObj, 3943 + serializeTextCP (interp, ic)); 3944 + } 3945 + break; 3946 + 3947 + case SCHEMA_CTYPE_CHOICE: 3948 + if (probeMayskip) { 3949 + for (i = 0; i < ic->nc; i++) { 3950 + if (mayMiss (ic->quants[i])) { 3951 + mayskip = 1; 3952 + break; 3953 + } 3954 + jc = ic->content[i]; 3955 + switch (jc->type) { 3956 + case SCHEMA_CTYPE_PATTERN: 3957 + if (recursivePattern (se, ic)) { 3958 + mayskip = 1; 3959 + break; 3960 + } 3961 + /* fall throu */ 3962 + case SCHEMA_CTYPE_INTERLEAVE: 3963 + se1 = getStackElement (sdata, ic); 3964 + mayskip = getNextExpectedWorker ( 3965 + sdata, se1, interp, seenCPs, rObj, 3966 + expectedFlags 3967 + ); 3968 + repoolStackElement (sdata, se1); 3969 + break; 3970 + case SCHEMA_CTYPE_TEXT: 3971 + if (ic->nc == 0 || checkText (interp, ic, "")) { 3972 + mayskip = 1; 3973 + } 3974 + break; 3975 + default: 3976 + break; 3977 + } 3978 + if (mayskip) break; 3979 + } 3980 + break; 3981 + } 3982 + if (ic->flags & MIXED_CONTENT) { 3983 + if (!(expectedFlags & EXPECTED_ONLY_MANDATORY)) { 3984 + Tcl_ListObjAppendElement ( 3985 + interp, rObj, serializeTextCP (interp, NULL)); 3986 + } 3987 + } 3988 + for (i = 0; i < ic->nc; i++) { 3989 + jc = ic->content[i]; 3990 + switch (jc->type) { 3991 + case SCHEMA_CTYPE_NAME: 3992 + if (!(expectedFlags & EXPECTED_ONLY_MANDATORY) 3993 + || minOne (cp->quants[i])) { 3994 + Tcl_ListObjAppendElement ( 3995 + interp, rObj, serializeElementName (interp, jc) 3996 + ); 3997 + } 3998 + break; 3999 + case SCHEMA_CTYPE_PATTERN: 4000 + if (recursivePattern (se, jc)) { 4001 + break; 4002 + } 4003 + /* Fall through */ 4004 + case SCHEMA_CTYPE_INTERLEAVE: 4005 + Tcl_CreateHashEntry (seenCPs, jc, &hnew); 4006 + if (hnew) { 4007 + se1 = getStackElement (sdata, jc); 4008 + mayskip = getNextExpectedWorker ( 4009 + sdata, se1, interp, seenCPs, rObj, 4010 + expectedFlags 4011 + ); 4012 + repoolStackElement (sdata, se1); 4013 + } 4014 + break; 4015 + case SCHEMA_CTYPE_ANY: 4016 + if (!(expectedFlags & EXPECTED_ONLY_MANDATORY) 4017 + || minOne (cp->quants[i])) { 4018 + Tcl_ListObjAppendElement ( 4019 + interp, rObj, serializeAnyCP (interp, jc) 4020 + ); 4021 + } 4022 + break; 4023 + case SCHEMA_CTYPE_TEXT: 4024 + if (!(expectedFlags & EXPECTED_ONLY_MANDATORY) 4025 + || minOne (cp->quants[i])) { 4026 + Tcl_ListObjAppendElement ( 4027 + interp, rObj, serializeTextCP (interp, jc) 4028 + ); 4029 + } 4030 + break; 4031 + case SCHEMA_CTYPE_CHOICE: 4032 + Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE"); 4033 + 4034 + case SCHEMA_CTYPE_VIRTUAL: 4035 + case SCHEMA_CTYPE_KEYSPACE: 4036 + case SCHEMA_CTYPE_KEYSPACE_END: 4037 + break; 4038 + } 4039 + } 4040 + break; 4041 + 4042 + case SCHEMA_CTYPE_VIRTUAL: 4043 + case SCHEMA_CTYPE_KEYSPACE: 4044 + case SCHEMA_CTYPE_KEYSPACE_END: 4045 + mayskip = 1; 4046 + break; 4047 + } 4048 + if (cp->type == SCHEMA_CTYPE_INTERLEAVE) { 4049 + if (!mustMatch && minOne(cp->quants[ac])) mustMatch = 1; 4050 + } else { 4051 + if (!mayskip && !hm && minOne (cp->quants[ac])) break; 4052 + } 4053 + ac++; 4054 + hm = 0; 4055 + } 4056 + if (cp->type == SCHEMA_CTYPE_NAME) { 4057 + if (ac == cp->nc) { 4058 + /* The curently open element can end here, no 4059 + * mandatory elements missing. 4060 + * The element end is always mandatory.*/ 4061 + Tcl_ListObjAppendElement ( 4062 + interp, rObj, serializeElementEnd (interp) 4063 + ); 4064 + } 4065 + rc = 0; 4066 + } else if (cp->type == SCHEMA_CTYPE_INTERLEAVE) { 4067 + if (mustMatch) rc = 0; 4068 + } else { 4069 + /* SCHEMA_CTYPE_PATTERN */ 4070 + if (ac < cp->nc) rc = 0; 4071 + } 4072 + break; 4073 + 4074 + case SCHEMA_CTYPE_ANY: 4075 + case SCHEMA_CTYPE_CHOICE: 4076 + case SCHEMA_CTYPE_TEXT: 4077 + case SCHEMA_CTYPE_VIRTUAL: 4078 + case SCHEMA_CTYPE_KEYSPACE: 4079 + case SCHEMA_CTYPE_KEYSPACE_END: 4080 + Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 4081 + } 4082 + return rc; 4083 +} 4084 + 4085 +static Tcl_Obj * 4086 +unifyMatchList ( 4087 + Tcl_Interp *interp, 4088 + Tcl_HashTable *htable, 4089 + Tcl_Obj *list 4090 + ) 4091 +{ 4092 + int len, i, hnew; 4093 + Tcl_HashEntry *h; 4094 + Tcl_Obj *rObj, *thisObj; 4095 + Tcl_HashSearch search; 4096 + 4097 + rObj = Tcl_NewObj(); 4098 + Tcl_ListObjLength (interp, list, &len); 4099 + if (len == 0) return rObj; 4100 + if (len == 1) { 4101 + Tcl_ListObjIndex (interp, list, 0, &thisObj); 4102 + Tcl_ListObjAppendElement (interp, rObj, thisObj); 4103 + return rObj; 4104 + } 4105 + Tcl_InitHashTable (htable, TCL_STRING_KEYS); 4106 + for (i = 0; i < len; i++) { 4107 + Tcl_ListObjIndex (interp, list, i, &thisObj); 4108 + h = Tcl_CreateHashEntry (htable, Tcl_GetString (thisObj), &hnew); 4109 + if (hnew) { 4110 + Tcl_SetHashValue (h, thisObj); 4111 + } 4112 + } 4113 + for (h = Tcl_FirstHashEntry (htable, &search); 4114 + h != NULL; 4115 + h = Tcl_NextHashEntry (&search)) { 4116 + Tcl_ListObjAppendElement (interp, rObj, Tcl_GetHashValue (h)); 4117 + } 4118 + Tcl_DeleteHashTable (htable); 4119 + return rObj; 4120 +} 4121 + 4122 +static void 4123 +getNextExpected ( 4124 + SchemaData *sdata, 4125 + Tcl_Interp *interp, 4126 + int expectedFlags 4127 + ) 4128 +{ 4129 + int remainingLastMatch, count, rc; 4130 + Tcl_Obj *rObj; 4131 + Tcl_HashTable localHash; 4132 + SchemaValidationStack *se; 4133 + 4134 + rObj = Tcl_NewObj(); 4135 + Tcl_InitHashTable (&localHash, TCL_ONE_WORD_KEYS); 4136 + remainingLastMatch = 0; 4137 + if (sdata->lastMatchse) { 4138 + se = sdata->lastMatchse; 4139 + while (se->down) { 4140 + remainingLastMatch++; 4141 + se = se->down; 4142 + } 4143 + while (se && getNextExpectedWorker (sdata, se, interp, &localHash, rObj, 4144 + expectedFlags)) { 4145 + if (remainingLastMatch) { 4146 + count = 1; 4147 + se = sdata->lastMatchse; 4148 + while (count < remainingLastMatch) { 4149 + se = se->down; 4150 + count++; 4151 + } 4152 + remainingLastMatch--; 4153 + } else break; 4154 + } 4155 + } 4156 + 4157 + se = sdata->stack; 4158 + while (se) { 4159 + if (!se->hasMatched && se->pattern->type != SCHEMA_CTYPE_NAME) { 4160 + se = se->down; 4161 + continue; 4162 + } 4163 + rc = getNextExpectedWorker (sdata, se, interp, &localHash, rObj, 4164 + expectedFlags); 4165 + if (se->pattern->type == SCHEMA_CTYPE_NAME) break; 4166 + se = se->down; 4167 + if (!rc) break; 4168 + } 4169 + Tcl_DeleteHashTable (&localHash); 4170 + Tcl_SetObjResult (interp, unifyMatchList (interp, &localHash, rObj)); 4171 + Tcl_DecrRefCount (rObj); 4172 +} 4173 + 4174 +static int 4175 +schemaInstanceInfoCmd ( 4176 + SchemaData *sdata, 4177 + Tcl_Interp *interp, 4178 + int objc, 4179 + Tcl_Obj *const objv[] 4180 + ) 4181 +{ 4182 + int methodIndex, expectedFlags; 4183 + long line, column; 4184 + Tcl_HashEntry *h; 4185 + SchemaCP *cp; 4186 + SchemaValidationStack *se; 4187 + void *ns; 4188 + Tcl_Obj *rObj; 4189 + 4190 + static const char *schemaInstanceInfoMethods[] = { 4191 + "validationstate", "vstate", "definedElements", "stack", "toplevel", 4192 + "expected", "definition", "validationaction", "vaction", "line", 4193 + "column", "domNode", "nrForwardDefinitions", "typedefinition", 4194 + "definedElementtypes", "patterndefinition", "definedPatterns", NULL 4195 + }; 4196 + enum schemaInstanceInfoMethod { 4197 + m_validationstate, m_vstate, m_definedElements, m_stack, m_toplevel, 4198 + m_expected, m_definition, m_validationaction, m_vaction, m_line, 4199 + m_column, m_domNode, m_nrForwardDefinitions, m_typedefinition, 4200 + m_definedElementtypes, m_patterndefinition, m_definedPatterns 4201 + }; 4202 + 4203 + static const char *schemaInstanceInfoStackMethods[] = { 4204 + "top", "inside", "associated", NULL 4205 + }; 4206 + enum schemaInstanceInfoStackMethod { 4207 + m_top, m_inside, m_associated 4208 + }; 4209 + 4210 + static const char *schemaInstanceInfoVactionMethods[] = { 4211 + "name", "namespace", "text", NULL 4212 + }; 4213 + enum schemaInstanceInfoVactionMethod { 4214 + m_name, m_namespace, m_text 4215 + }; 4216 + 4217 + static const char *schemaInstanceInfoExpectedOptions[] = { 4218 + "-ignorematched", "-onlymandatory", NULL 4219 + }; 4220 + enum schemaInstanceInfoExpectedOption 4221 + { 4222 + o_ignorematched, o_onlymandatory 4223 + }; 4224 + 4225 + if (objc < 2) { 4226 + Tcl_WrongNumArgs (interp, 1, objv, "subcommand ?arguments?"); 4227 + return TCL_ERROR; 4228 + } 4229 + 4230 + if (Tcl_GetIndexFromObj (interp, objv[1], schemaInstanceInfoMethods, 4231 + "method", 0, &methodIndex) 4232 + != TCL_OK) { 4233 + return TCL_ERROR; 4234 + } 4235 + 4236 + Tcl_ResetResult (interp); 4237 + switch ((enum schemaInstanceInfoMethod) methodIndex) { 4238 + case m_validationstate: 4239 + case m_vstate: 4240 + switch (sdata->validationState) { 4241 + case VALIDATION_READY: 4242 + SetResult ("READY"); 4243 + break; 4244 + case VALIDATION_STARTED: 4245 + SetResult ("VALIDATING"); 4246 + break; 4247 + case VALIDATION_FINISHED: 4248 + SetResult ("FINISHED"); 4249 + break; 4250 + default: 4251 + SetResult ("Internal error: Invalid validation state"); 4252 + return TCL_ERROR; 4253 + } 4254 + break; 4255 + 4256 + case m_definedElements: 4257 + if (objc != 2) { 4258 + Tcl_WrongNumArgs (interp, 1, objv, "definedElements"); 4259 + return TCL_ERROR; 4260 + } 4261 + definedElements (&sdata->element, interp); 4262 + break; 4263 + 4264 + case m_definedPatterns: 4265 + if (objc != 2) { 4266 + Tcl_WrongNumArgs (interp, 1, objv, "definedPatterns"); 4267 + return TCL_ERROR; 4268 + } 4269 + definedElements (&sdata->pattern, interp); 4270 + break; 4271 + 4272 + case m_definedElementtypes: 4273 + if (objc != 2) { 4274 + Tcl_WrongNumArgs (interp, 1, objv, "definedElementtypes"); 4275 + return TCL_ERROR; 4276 + } 4277 + definedElementtypes (sdata, interp); 4278 + break; 4279 + 4280 + case m_stack: 4281 + if (objc != 3) { 4282 + Tcl_WrongNumArgs (interp, 2, objv, "top|inside"); 4283 + return TCL_ERROR; 4284 + } 4285 + if (Tcl_GetIndexFromObj (interp, objv[2], 4286 + schemaInstanceInfoStackMethods, 4287 + "method", 0, &methodIndex) 4288 + != TCL_OK) { 4289 + return TCL_ERROR; 4290 + } 4291 + if (!sdata->stack) { 4292 + return TCL_OK; 4293 + } 4294 + se = sdata->stack; 4295 + switch ((enum schemaInstanceInfoStackMethod) methodIndex) { 4296 + case m_inside: 4297 + rObj = Tcl_NewObj(); 4298 + while (se) { 4299 + if (se->pattern->type == SCHEMA_CTYPE_NAME) { 4300 + Tcl_ListObjAppendElement (interp, rObj, 4301 + serializeElementName (interp, se->pattern)); 4302 + } 4303 + se = se->down; 4304 + } 4305 + Tcl_SetObjResult (interp, rObj); 4306 + return TCL_OK; 4307 + 4308 + case m_top: 4309 + while (se->pattern->type != SCHEMA_CTYPE_NAME) { 4310 + se = se->down; 4311 + } 4312 + rObj = serializeElementName (interp, se->pattern); 4313 + Tcl_SetObjResult (interp, rObj); 4314 + return TCL_OK; 4315 + 4316 + case m_associated: 4317 + if (!se->pattern->associated) { 4318 + return TCL_OK; 4319 + } 4320 + Tcl_SetObjResult (interp, se->pattern->associated); 4321 + return TCL_OK; 4322 + } 4323 + 4324 + case m_toplevel: 4325 + if (objc != 2) { 4326 + Tcl_WrongNumArgs (interp, 2, objv, ""); 4327 + return TCL_ERROR; 4328 + } 4329 + if (!sdata->currentEvals) { 4330 + SetResult ("not called while schema evaluation"); 4331 + return TCL_ERROR; 4332 + } 4333 + if (!sdata->defineToplevel && sdata->currentEvals > 1) { 4334 + SetBooleanResult (0); 4335 + } else { 4336 + SetBooleanResult (1); 4337 + } 4338 + return TCL_OK; 4339 + 4340 + case m_expected: 4341 + if (objc < 2 && objc > 4) { 4342 + Tcl_WrongNumArgs (interp, 2, objv, "?-ignorematched? ?-onlymandatory?"); 4343 + return TCL_ERROR; 4344 + } 4345 + if (sdata->validationState == VALIDATION_ERROR 4346 + || sdata->validationState == VALIDATION_FINISHED) { 4347 + return TCL_OK; 4348 + } 4349 + expectedFlags = 0; 4350 + while (objc > 2) { 4351 + if (Tcl_GetIndexFromObj (interp, objv[2], 4352 + schemaInstanceInfoExpectedOptions, 4353 + "option", 0, &methodIndex) 4354 + != TCL_OK) { 4355 + return TCL_ERROR; 4356 + } 4357 + switch ((enum schemaInstanceInfoExpectedOption) methodIndex) { 4358 + case o_ignorematched: 4359 + expectedFlags |= EXPECTED_IGNORE_MATCHED; 4360 + break; 4361 + case o_onlymandatory: 4362 + expectedFlags |= EXPECTED_ONLY_MANDATORY; 4363 + break; 4364 + } 4365 + objv++; 4366 + objc--; 4367 + } 4368 + if (!sdata->stack) { 4369 + if (sdata->start) { 4370 + Tcl_AppendElement (interp, sdata->start); 4371 + if (sdata->startNamespace) { 4372 + Tcl_AppendElement (interp, sdata->startNamespace); 4373 + } 4374 + } else { 4375 + definedElements (&sdata->element, interp); 4376 + } 4377 + } else { 4378 + getNextExpected (sdata, interp, expectedFlags); 4379 + } 4380 + break; 4381 + 4382 + case m_definition: 4383 + if (objc < 3 && objc > 4) { 4384 + Tcl_WrongNumArgs (interp, 1, objv, "name ?namespace?"); 4385 + return TCL_ERROR; 4386 + } 4387 + h = Tcl_FindHashEntry (&sdata->element, Tcl_GetString (objv[2])); 4388 + if (!h) { 4389 + SetResult ("Unknown element definition"); 4390 + return TCL_ERROR; 4391 + } 4392 + cp = Tcl_GetHashValue (h); 4393 + ns = NULL; 4394 + if (objc == 4) { 4395 + ns = getNamespacePtr (sdata, Tcl_GetString (objv[3])); 4396 + } 4397 + while (cp && cp->namespace != ns) { 4398 + cp = cp->next; 4399 + } 4400 + if (!cp 4401 + || cp->flags & LOCAL_DEFINED_ELEMENT 4402 + || cp->flags & PLACEHOLDER_PATTERN_DEF) { 4403 + SetResult ("Unknown element definition"); 4404 + return TCL_ERROR; 4405 + } 4406 + Tcl_AppendElement (interp, "defelement"); 4407 + Tcl_AppendElement (interp, cp->name); 4408 + if (cp->namespace) { 4409 + Tcl_AppendElement (interp, cp->namespace); 4410 + } 4411 + if (cp->defScript) { 4412 + Tcl_AppendElement (interp, Tcl_GetString (cp->defScript)); 4413 + } 4414 + break; 4415 + 4416 + case m_patterndefinition: 4417 + if (objc < 3 && objc > 4) { 4418 + Tcl_WrongNumArgs (interp, 1, objv, "name ?namespace?"); 4419 + return TCL_ERROR; 4420 + } 4421 + h = Tcl_FindHashEntry (&sdata->pattern, Tcl_GetString (objv[2])); 4422 + if (!h) { 4423 + SetResult ("Unknown pattern definition"); 4424 + return TCL_ERROR; 4425 + } 4426 + cp = Tcl_GetHashValue (h); 4427 + ns = NULL; 4428 + if (objc == 4) { 4429 + ns = getNamespacePtr (sdata, Tcl_GetString (objv[3])); 4430 + } 4431 + while (cp && cp->namespace != ns) { 4432 + cp = cp->next; 4433 + } 4434 + if (!cp 4435 + || cp->flags & LOCAL_DEFINED_ELEMENT 4436 + || cp->flags & PLACEHOLDER_PATTERN_DEF) { 4437 + SetResult ("Unknown pattern definition"); 4438 + return TCL_ERROR; 4439 + } 4440 + Tcl_AppendElement (interp, "defpattern"); 4441 + Tcl_AppendElement (interp, cp->name); 4442 + if (cp->namespace) { 4443 + Tcl_AppendElement (interp, cp->namespace); 4444 + } 4445 + if (cp->defScript) { 4446 + Tcl_AppendElement (interp, Tcl_GetString (cp->defScript)); 4447 + } 4448 + break; 4449 + 4450 + case m_typedefinition: 4451 + if (objc < 3 && objc > 4) { 4452 + Tcl_WrongNumArgs (interp, 1, objv, "name ?namespace?"); 4453 + return TCL_ERROR; 4454 + } 4455 + h = Tcl_FindHashEntry (&sdata->elementType, Tcl_GetString (objv[2])); 4456 + if (!h) { 4457 + SetResult ("Unknown elementtype definition"); 4458 + return TCL_ERROR; 4459 + } 4460 + cp = Tcl_GetHashValue (h); 4461 + ns = NULL; 4462 + if (objc == 4) { 4463 + ns = getNamespacePtr (sdata, Tcl_GetString (objv[3])); 4464 + } 4465 + while (cp && cp->namespace != ns) { 4466 + cp = cp->next; 4467 + } 4468 + if (!cp 4469 + || cp->flags & LOCAL_DEFINED_ELEMENT 4470 + || cp->flags & PLACEHOLDER_PATTERN_DEF) { 4471 + SetResult ("Unknown elementtype definition"); 4472 + return TCL_ERROR; 4473 + } 4474 + Tcl_AppendElement (interp, "defelementtype"); 4475 + Tcl_AppendElement (interp, cp->typeName); 4476 + Tcl_AppendElement (interp, cp->name); 4477 + if (cp->namespace) { 4478 + Tcl_AppendElement (interp, cp->namespace); 4479 + } 4480 + if (cp->defScript) { 4481 + Tcl_AppendElement (interp, Tcl_GetString (cp->defScript)); 4482 + } 4483 + break; 4484 + 4485 + case m_vaction: 4486 + case m_validationaction: 4487 + if (sdata->validationState != VALIDATION_STARTED 4488 + || sdata->currentEvals == 0) { 4489 + SetResult ("NONE"); 4490 + break; 4491 + } 4492 + if (objc == 2) { 4493 + SetResult (ValidationAction2str[sdata->vaction]); 4494 + break; 4495 + } 4496 + if (objc != 3) { 4497 + Tcl_WrongNumArgs (interp, 2, objv, "?name|namespace|text?"); 4498 + return TCL_ERROR; 4499 + } 4500 + if (Tcl_GetIndexFromObj (interp, objv[2], 4501 + schemaInstanceInfoVactionMethods, 4502 + "method", 0, &methodIndex) 4503 + != TCL_OK) { 4504 + return TCL_ERROR; 4505 + } 4506 + switch ((enum schemaInstanceInfoVactionMethod) methodIndex) { 4507 + case m_name: 4508 + SetResult (sdata->vname); 4509 + break; 4510 + case m_namespace: 4511 + SetResult (sdata->vns); 4512 + break; 4513 + case m_text: 4514 + SetResult (sdata->vtext); 4515 + break; 4516 + } 4517 + break; 4518 + 4519 + case m_line: 4520 + if (!sdata->parser && !sdata->node) break; 4521 + if (sdata->parser) { 4522 + SetLongResult (XML_GetCurrentLineNumber (sdata->parser)); 4523 + break; 4524 + } 4525 + if (domGetLineColumn(sdata->node, &line, &column) < 0) break; 4526 + SetLongResult (line); 4527 + break; 4528 + 4529 + case m_column: 4530 + if (!sdata->parser && !sdata->node) break; 4531 + if (sdata->parser) { 4532 + SetLongResult (XML_GetCurrentColumnNumber (sdata->parser)); 4533 + break; 4534 + } 4535 + if (domGetLineColumn(sdata->node, &line, &column) < 0) break; 4536 + SetLongResult (column); 4537 + break; 4538 + 4539 + case m_domNode: 4540 + if (!sdata->node) break; 4541 + /* We distinguish between calls from reportCmd and others 4542 + * (from scripts called with the tcl cmd). */ 4543 + if (sdata->vaction) { 4544 + /* This is the case: called from reportCmd. */ 4545 + return tcldom_setInterpAndReturnVar (interp, sdata->node, 0, NULL); 4546 + } else { 4547 + /* This is the case: called from a with tcl called script. */ 4548 + return tcldom_setInterpAndReturnVar (interp, sdata->insideNode, 0, NULL); 4549 + } 4550 + break; 4551 + 4552 + case m_nrForwardDefinitions: 4553 + if (objc != 2) { 4554 + Tcl_WrongNumArgs(interp, 2, objv, ""); 4555 + return TCL_ERROR; 4556 + } 4557 + SetIntResult(sdata->forwardPatternDefs); 4558 + break; 4559 + 4560 + } 4561 + return TCL_OK; 4562 +} 4563 + 4564 +static void 4565 +attributeLookupPreparation ( 4566 + SchemaData *sdata, 4567 + SchemaCP *cp 4568 + ) 4569 +{ 4570 + Tcl_HashTable *t; 4571 + int i, hnew; 4572 + Tcl_HashEntry *h; 4573 + SchemaAttr *attr; 4574 + 4575 + if (cp->numAttr <= sdata->attributeHashThreshold) return; 4576 + t = TMALLOC (Tcl_HashTable); 4577 + Tcl_InitHashTable (t, TCL_STRING_KEYS); 4578 + for (i = 0; i < cp->numAttr; i++) { 4579 + h = Tcl_CreateHashEntry (t, cp->attrs[i]->name, &hnew); 4580 + if (hnew) { 4581 + Tcl_SetHashValue (h, cp->attrs[i]); 4582 + } else { 4583 + attr = (SchemaAttr *) Tcl_GetHashValue (h); 4584 + cp->attrs[i]->next = attr->next; 4585 + attr->next = cp->attrs[i]; 4586 + } 4587 + } 4588 + cp->typedata = (void *)t; 4589 +} 4590 + 4591 +/* This implements the script interface to the created schema commands. 4592 + 4593 + Since validation may call out to tcl scripts those scripts may 4594 + delete the schema command (which just validates input by calling 4595 + out to a tcl script). This is handled by tcl evaluation level 4596 + counting and postponing the schema data deletion until back on top. 4597 + 4598 + After any code by this function that may have called out to a tcl 4599 + script it is important not to return locally but to signal the 4600 + return value with the result variable and ensure to reach the code 4601 + at the end of tDOM_schemaInstanceCmd. 4602 + */ 4603 +int 4604 +tDOM_schemaInstanceCmd ( 4605 + ClientData clientData, 4606 + Tcl_Interp *interp, 4607 + int objc, 4608 + Tcl_Obj *const objv[] 4609 + ) 4610 +{ 4611 + int methodIndex, keywordIndex, hnew, hnew1, patternIndex; 4612 + int result = TCL_OK, forwardDef = 0, i = 0, j, mode; 4613 + int savedDefineToplevel, type, len, n; 4614 + unsigned int savedNumPatternList; 4615 + SchemaData *savedsdata = NULL, *sdata = (SchemaData *) clientData; 4616 + Tcl_HashTable *hashTable; 4617 + Tcl_HashEntry *h, *h1; 4618 + SchemaCP *pattern, *thiscp, *current = NULL; 4619 + void *namespacePtr, *savedNamespacePtr; 4620 + char *xmlstr, *errMsg; 4621 + domDocument *doc; 4622 + domNode *node; 4623 + Tcl_Obj *attData; 4624 + Tcl_Channel chan = NULL; 4625 + 4626 + static const char *schemaInstanceMethods[] = { 4627 + "defelement", "defpattern", "start", "event", "delete", 4628 + "reset", "define", "validate", "domvalidate", "deftexttype", 4629 + "info", "reportcmd", "prefixns", "validatefile", 4630 + "validatechannel", "defelementtype", "set", 4631 + NULL 4632 + }; 4633 + enum schemaInstanceMethod { 4634 + m_defelement, m_defpattern, m_start, m_event, m_delete, 4635 + m_reset, m_define, m_validate, m_domvalidate, m_deftexttype, 4636 + m_info, m_reportcmd, m_prefixns, m_validatefile, 4637 + m_validatechannel, m_defelementtype, m_set 4638 + }; 4639 + 4640 + static const char *eventKeywords[] = { 4641 + "start", "end", "text", NULL 4642 + }; 4643 + enum eventKeyword 4644 + { 4645 + k_elementstart, k_elementend, k_text 4646 + }; 4647 + 4648 + static const char *setKeywords[] = { 4649 + "choiceHashThreshold", "attributeHashThreshold", NULL 4650 + }; 4651 + enum setKeyword 4652 + { 4653 + s_choiceHashThreshold, s_attributeHashThreshold 4654 + }; 4655 + 4656 + if (sdata == NULL) { 4657 + /* Inline defined defelement, defelementtype, defpattern, 4658 + * deftexttype, start or prefixns */ 4659 + sdata = GETASI; 4660 + CHECK_SI; 4661 + if (!sdata->defineToplevel && sdata->currentEvals > 1) { 4662 + SetResult ("Command not allowed in nested schema define script"); 4663 + return TCL_ERROR; 4664 + } 4665 + i = 1; 4666 + } 4667 + if (objc + i < 2) { 4668 + Tcl_WrongNumArgs (interp, 1, objv, "subcommand ?arguments?"); 4669 + return TCL_ERROR; 4670 + } 4671 + 4672 + 4673 + if (Tcl_GetIndexFromObj (interp, objv[1-i], schemaInstanceMethods, 4674 + "method", 0, &methodIndex) 4675 + != TCL_OK) { 4676 + return TCL_ERROR; 4677 + } 4678 + 4679 + Tcl_ResetResult (interp); 4680 + switch ((enum schemaInstanceMethod) methodIndex) { 4681 + case m_defelement: 4682 + case m_defpattern: 4683 + CHECK_RECURSIVE_CALL 4684 + if (objc != 4-i && objc != 5-i) { 4685 + Tcl_WrongNumArgs (interp, 1-i, objv, "<name>" 4686 + " ?<namespace>? pattern"); 4687 + return TCL_ERROR; 4688 + } 4689 + if ((enum schemaInstanceMethod) methodIndex == m_defelement) { 4690 + hashTable = &sdata->element; 4691 + type = SCHEMA_CTYPE_NAME; 4692 + } else { 4693 + hashTable = &sdata->pattern; 4694 + type = SCHEMA_CTYPE_PATTERN; 4695 + } 4696 + savedNumPatternList = sdata->numPatternList; 4697 + namespacePtr = NULL; 4698 + patternIndex = 3-i; 4699 + if (objc == 5-i) { 4700 + patternIndex = 4-i; 4701 + namespacePtr = getNamespacePtr (sdata, Tcl_GetString (objv[3-i])); 4702 + } 4703 + h = Tcl_CreateHashEntry (hashTable, Tcl_GetString (objv[2-i]), &hnew); 4704 + pattern = NULL; 4705 + if (!hnew) { 4706 + pattern = (SchemaCP *) Tcl_GetHashValue (h); 4707 + while (pattern) { 4708 + if (pattern->namespace == namespacePtr) { 4709 + if (pattern->flags & FORWARD_PATTERN_DEF 4710 + || pattern->flags & PLACEHOLDER_PATTERN_DEF) { 4711 + forwardDef = 1; 4712 + break; 4713 + } 4714 + if ((enum schemaInstanceMethod) methodIndex 4715 + == m_defelement) { 4716 + SetResult ("Element already defined " 4717 + "in this namespace"); 4718 + } else { 4719 + SetResult ("Pattern already defined " 4720 + "in this namespace"); 4721 + } 4722 + return TCL_ERROR; 4723 + } 4724 + pattern = pattern->next; 4725 + } 4726 + } 4727 + if (pattern == NULL) { 4728 + pattern = initSchemaCP (type, namespacePtr, 4729 + Tcl_GetHashKey (hashTable, h)); 4730 + if (!hnew) { 4731 + current = (SchemaCP *) Tcl_GetHashValue (h); 4732 + pattern->next = current; 4733 + } 4734 + REMEMBER_PATTERN (pattern); 4735 + Tcl_SetHashValue (h, pattern); 4736 + } 4737 + 4738 + SETASI(sdata); 4739 + savedDefineToplevel = sdata->defineToplevel; 4740 + savedNamespacePtr = sdata->currentNamespace; 4741 + sdata->defineToplevel = 0; 4742 + sdata->currentNamespace = namespacePtr; 4743 + sdata->cp = pattern; 4744 + sdata->numAttr = 0; 4745 + sdata->numReqAttr = 0; 4746 + sdata->currentAttrs = NULL; 4747 + sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 4748 + sdata->evalStub[3] = objv[patternIndex]; 4749 + sdata->currentEvals++; 4750 + result = Tcl_EvalObjv (interp, 4, sdata->evalStub, TCL_EVAL_GLOBAL); 4751 + sdata->currentEvals--; 4752 + sdata->currentNamespace = NULL; 4753 + pattern->attrs = sdata->currentAttrs; 4754 + pattern->numAttr = sdata->numAttr; 4755 + pattern->numReqAttr = sdata->numReqAttr; 4756 + if (result == TCL_OK) { 4757 + if (pattern->numAttr) { 4758 + attributeLookupPreparation (sdata, pattern); 4759 + } 4760 + if (forwardDef) { 4761 + if (pattern->flags & FORWARD_PATTERN_DEF) { 4762 + sdata->forwardPatternDefs--; 4763 + pattern->flags &= ~FORWARD_PATTERN_DEF; 4764 + } 4765 + pattern->flags &= ~PLACEHOLDER_PATTERN_DEF; 4766 + } 4767 + pattern->defScript = objv[patternIndex]; 4768 + Tcl_IncrRefCount (pattern->defScript); 4769 + } else { 4770 + if (forwardDef) { 4771 + pattern->nc = 0; 4772 + } 4773 + cleanupLastPattern (sdata, savedNumPatternList); 4774 + } 4775 + sdata->defineToplevel = savedDefineToplevel; 4776 + sdata->currentNamespace = savedNamespacePtr; 4777 + if (!savedDefineToplevel) { 4778 + SETASI(savedsdata); 4779 + } 4780 + break; 4781 + 4782 + case m_define: 4783 + CHECK_EVAL 4784 + if (objc != 3) { 4785 + Tcl_WrongNumArgs (interp, 2, objv, "<definition commands>"); 4786 + return TCL_ERROR; 4787 + } 4788 + if (clientData) { 4789 + savedsdata = GETASI; 4790 + if (savedsdata == sdata) { 4791 + SetResult ("Recursive call of schema command is not allowed"); 4792 + return TCL_ERROR; 4793 + } 4794 + } 4795 + SETASI(sdata); 4796 + savedNumPatternList = sdata->numPatternList; 4797 + sdata->currentNamespace = 0; 4798 + sdata->cp = NULL; 4799 + sdata->contentSize = 0; 4800 + sdata->defineToplevel = 1; 4801 + sdata->evalStub[3] = objv[2]; 4802 + sdata->currentEvals++; 4803 + result = Tcl_EvalObjv (interp, 4, sdata->evalStub, TCL_EVAL_GLOBAL); 4804 + sdata->currentEvals--; 4805 + if (result != TCL_OK) { 4806 + cleanupLastPattern (sdata, savedNumPatternList); 4807 + } 4808 + sdata->defineToplevel = 0; 4809 + SETASI(savedsdata); 4810 + break; 4811 + 4812 + case m_deftexttype: 4813 + CHECK_RECURSIVE_CALL 4814 + if (objc != 4-i) { 4815 + Tcl_WrongNumArgs (interp, 2-i, objv, "<name>" 4816 + " <constraints script>"); 4817 + return TCL_ERROR; 4818 + } 4819 + h = Tcl_CreateHashEntry (&sdata->textDef, Tcl_GetString (objv[2-i]), 4820 + &hnew); 4821 + if (!hnew) { 4822 + SetResult ("There is already a text type definition with this " 4823 + "name"); 4824 + return TCL_ERROR; 4825 + } 4826 + pattern = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 4827 + pattern->type = SCHEMA_CTYPE_TEXT; 4828 + REMEMBER_PATTERN (pattern) 4829 + SETASI(sdata); 4830 + savedDefineToplevel = sdata->defineToplevel; 4831 + result = evalConstraints (interp, sdata, pattern, objv[3-i]); 4832 + sdata->defineToplevel = savedDefineToplevel; 4833 + if (!savedDefineToplevel) { 4834 + SETASI(savedsdata); 4835 + } 4836 + if (result == TCL_OK) { 4837 + Tcl_SetHashValue (h, pattern); 4838 + } else { 4839 + Tcl_DeleteHashEntry (h); 4840 + } 4841 + break; 4842 + 4843 + case m_start: 4844 + CHECK_RECURSIVE_CALL 4845 + if (objc < 3-i || objc > 4-i) { 4846 + Tcl_WrongNumArgs (interp, 2-i, objv, "<documentElement>" 4847 + " ?<namespace>?"); 4848 + return TCL_ERROR; 4849 + } 4850 + if (sdata->start) { 4851 + FREE (sdata->start); 4852 + } 4853 + if (objc == 3-i && strcmp (Tcl_GetString (objv[2-i]), "") == 0) { 4854 + sdata->startNamespace = NULL; 4855 + sdata->start = NULL; 4856 + break; 4857 + } 4858 + sdata->start = tdomstrdup (Tcl_GetString (objv[2-i])); 4859 + if (objc == 4-i) { 4860 + sdata->startNamespace = 4861 + getNamespacePtr (sdata, Tcl_GetString (objv[3-i])); 4862 + } 4863 + break; 4864 + 4865 + case m_event: 4866 + CHECK_EVAL 4867 + if (objc < 3) { 4868 + Tcl_WrongNumArgs (interp, 2, objv, "<eventType>" 4869 + " ?<type specific data>?"); 4870 + return TCL_ERROR; 4871 + } 4872 + if (Tcl_GetIndexFromObj (interp, objv[2], eventKeywords, 4873 + "keyword", 0, &keywordIndex) 4874 + != TCL_OK) { 4875 + return TCL_ERROR; 4876 + } 4877 + switch ((enum eventKeyword) keywordIndex) { 4878 + case k_elementstart: 4879 + if (objc < 4 && objc > 6) { 4880 + Tcl_WrongNumArgs (interp, 3, objv, "<elementname>" 4881 + "?<attInfo>? ?<namespace>?"); 4882 + return TCL_ERROR; 4883 + } 4884 + namespacePtr = NULL; 4885 + len = 0; 4886 + attData = NULL; 4887 + if (objc == 6) { 4888 + namespacePtr = getNamespacePtr (sdata, 4889 + Tcl_GetString (objv[5])); 4890 + } 4891 + if (objc >= 5) { 4892 + if (Tcl_ListObjLength (interp, objv[4], &len) != TCL_OK) { 4893 + if (objc == 6) { 4894 + SetResult ("Invalid attribute information"); 4895 + return TCL_ERROR; 4896 + } else { 4897 + namespacePtr = 4898 + getNamespacePtr (sdata, Tcl_GetString (objv[4])); 4899 + len = 0; 4900 + } 4901 + } else { 4902 + if (len == 1) { 4903 + namespacePtr = 4904 + getNamespacePtr (sdata, Tcl_GetString (objv[4])); 4905 + len = 0; 4906 + } else if (len % 2 != 0) { 4907 + SetResult ("Invalid attribute information"); 4908 + return TCL_ERROR; 4909 + } else { 4910 + attData = objv[4]; 4911 + } 4912 + } 4913 + } 4914 + result = tDOM_probeElement (interp, sdata, Tcl_GetString (objv[3]), 4915 + namespacePtr); 4916 + /* In case of UNKNOWN_ROOT_ELEMENT and reportCmd is set 4917 + * sdata->stack is NULL. */ 4918 + if (!sdata->stack) break; 4919 + if (sdata->skipDeep == 0 && result == TCL_OK) { 4920 + result = probeEventAttribute (interp, sdata, attData, len); 4921 + } 4922 + break; 4923 + 4924 + case k_elementend: 4925 + if (objc != 3) { 4926 + Tcl_WrongNumArgs (interp, 3, objv, "No arguments expected."); 4927 + return TCL_ERROR; 4928 + } 4929 + result = tDOM_probeElementEnd (interp, sdata); 4930 + break; 4931 + 4932 + case k_text: 4933 + if (objc != 4) { 4934 + Tcl_WrongNumArgs (interp, 3, objv, "<text>"); 4935 + return TCL_ERROR; 4936 + } 4937 + result = tDOM_probeText (interp, sdata, Tcl_GetString (objv[3]), NULL); 4938 + break; 4939 + } 4940 + break; 4941 + 4942 + case m_delete: 4943 + if (objc != 2) { 4944 + Tcl_WrongNumArgs(interp, 2, objv, ""); 4945 + return TCL_ERROR; 4946 + } 4947 + Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); 4948 + /* We return immediately here to avoid clashes with postponed 4949 + sdata cleanup at the end of the function. */ 4950 + return TCL_OK; 4951 + 4952 + case m_reset: 4953 + CHECK_EVAL 4954 + schemaReset (sdata); 4955 + break; 4956 + 4957 + case m_validate: 4958 + CHECK_EVAL 4959 + if (objc < 3 || objc > 4) { 4960 + Tcl_WrongNumArgs (interp, 2, objv, "<xml> ?resultVarName?"); 4961 + return TCL_ERROR; 4962 + } 4963 + if (sdata->validationState != VALIDATION_READY) { 4964 + SetResult ("The schema command is busy"); 4965 + return TCL_ERROR; 4966 + } 4967 + xmlstr = Tcl_GetStringFromObj (objv[2], &len); 4968 + if (validateString (interp, sdata, xmlstr, len) == TCL_OK) { 4969 + SetBooleanResult (1); 4970 + if (objc == 4) { 4971 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), "", 0); 4972 + } 4973 + } else { 4974 + if (objc == 4) { 4975 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), 4976 + Tcl_GetStringResult (interp), 0); 4977 + } 4978 + if (sdata->evalError) { 4979 + result = TCL_ERROR; 4980 + } else { 4981 + SetBooleanResult (0); 4982 + } 4983 + } 4984 + schemaReset (sdata); 4985 + break; 4986 + 4987 + case m_validatefile: 4988 + CHECK_EVAL 4989 + if (objc < 3 || objc > 4) { 4990 + Tcl_WrongNumArgs (interp, 2, objv, "<filename> ?resultVarName?"); 4991 + return TCL_ERROR; 4992 + } 4993 + if (sdata->validationState != VALIDATION_READY) { 4994 + SetResult ("The schema command is busy"); 4995 + return TCL_ERROR; 4996 + } 4997 + if (validateFile (interp, sdata, objv[2]) == TCL_OK) { 4998 + SetBooleanResult (1); 4999 + if (objc == 4) { 5000 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), "", 0); 5001 + } 5002 + } else { 5003 + if (objc == 4) { 5004 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), 5005 + Tcl_GetStringResult (interp), 0); 5006 + } 5007 + if (sdata->evalError) { 5008 + result = TCL_ERROR; 5009 + } else { 5010 + SetBooleanResult (0); 5011 + } 5012 + } 5013 + schemaReset (sdata); 5014 + break; 5015 + 5016 + case m_validatechannel: 5017 + CHECK_EVAL 5018 + if (objc < 3 || objc > 4) { 5019 + Tcl_WrongNumArgs (interp, 2, objv, "<channel> ?resultVarName?"); 5020 + return TCL_ERROR; 5021 + } 5022 + if (sdata->validationState != VALIDATION_READY) { 5023 + SetResult ("The schema command is busy"); 5024 + return TCL_ERROR; 5025 + } 5026 + chan = Tcl_GetChannel(interp, Tcl_GetString (objv[2]), &mode); 5027 + if (chan == NULL) { 5028 + SetResult ("The channel argument isn't a tcl channel"); 5029 + return TCL_ERROR; 5030 + } 5031 + if (validateChannel (interp, sdata, chan) == TCL_OK) { 5032 + SetBooleanResult (1); 5033 + if (objc == 4) { 5034 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), "", 0); 5035 + } 5036 + } else { 5037 + if (objc == 4) { 5038 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), 5039 + Tcl_GetStringResult (interp), 0); 5040 + } 5041 + if (sdata->evalError) { 5042 + result = TCL_ERROR; 5043 + } else { 5044 + SetBooleanResult (0); 5045 + } 5046 + } 5047 + schemaReset (sdata); 5048 + break; 5049 + 5050 + case m_domvalidate: 5051 + CHECK_EVAL 5052 + if (objc < 3 || objc > 4) { 5053 + Tcl_WrongNumArgs (interp, 2, objv, "<xml> ?resultVarName?"); 5054 + return TCL_ERROR; 5055 + } 5056 + doc = tcldom_getDocumentFromName (interp, Tcl_GetString (objv[2]), 5057 + &errMsg); 5058 + if (doc) { 5059 + node = doc->documentElement; 5060 + } else { 5061 + node = tcldom_getNodeFromObj (interp, objv[2]); 5062 + if (!node) { 5063 + SetResult ("The second argument must be either a " 5064 + "document or a element node"); 5065 + return TCL_ERROR; 5066 + } 5067 + } 5068 + if (validateDOM (interp, sdata, node) == TCL_OK) { 5069 + SetBooleanResult (1); 5070 + if (objc == 4) { 5071 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), "", 0); 5072 + } 5073 + } else { 5074 + if (objc == 4) { 5075 + Tcl_SetVar (interp, Tcl_GetString (objv[3]), 5076 + Tcl_GetStringResult (interp), 0); 5077 + } 5078 + SetBooleanResult (0); 5079 + } 5080 + schemaReset (sdata); 5081 + break; 5082 + 5083 + case m_info: 5084 + objv++; 5085 + objc--; 5086 + result = schemaInstanceInfoCmd (sdata, interp, objc, objv); 5087 + break; 5088 + 5089 + case m_reportcmd: 5090 + if (objc == 2) { 5091 + if (sdata->reportCmd) { 5092 + Tcl_SetObjResult (interp, sdata->reportCmd); 5093 + } else { 5094 + Tcl_SetObjResult (interp, Tcl_NewObj()); 5095 + } 5096 + break; 5097 + } 5098 + if (objc != 3) { 5099 + Tcl_WrongNumArgs (interp, 2, objv, "<tcl-cmd>"); 5100 + return TCL_ERROR; 5101 + } 5102 + if (sdata->reportCmd) { 5103 + Tcl_DecrRefCount (sdata->reportCmd); 5104 + } 5105 + if (strlen (Tcl_GetString (objv[2])) == 0) { 5106 + sdata->reportCmd = NULL; 5107 + } else { 5108 + sdata->reportCmd = objv[2]; 5109 + Tcl_IncrRefCount (sdata->reportCmd); 5110 + } 5111 + break; 5112 + 5113 + case m_prefixns: 5114 + CHECK_RECURSIVE_CALL 5115 + if (objc != 2-i && objc != 3-i) { 5116 + Tcl_WrongNumArgs (interp, 2-i, objv, "?prefixUriList?"); 5117 + return TCL_ERROR; 5118 + } 5119 + if (!i) {objc--; objv++;} 5120 + result = tcldom_prefixNSlist (&sdata->prefixns, interp, objc, objv, 5121 + "prefixns"); 5122 + if (sdata->prefix.numEntries) { 5123 + Tcl_DeleteHashTable (&sdata->prefix); 5124 + Tcl_InitHashTable (&sdata->prefix, TCL_STRING_KEYS); 5125 + } 5126 + if (result == TCL_OK && sdata->prefixns) { 5127 + j = 0; 5128 + while (sdata->prefixns[j]) { 5129 + h1 = Tcl_CreateHashEntry (&sdata->prefix, 5130 + sdata->prefixns[j], &hnew); 5131 + /* This means: First prefix mapping wins */ 5132 + if (hnew) { 5133 + h = Tcl_CreateHashEntry (&sdata->namespace, 5134 + sdata->prefixns[j+1], &hnew); 5135 + Tcl_SetHashValue (h1, Tcl_GetHashKey (&sdata->namespace, 5136 + h)); 5137 + } 5138 + j += 2; 5139 + } 5140 + } 5141 + break; 5142 + 5143 + case m_defelementtype: 5144 + CHECK_RECURSIVE_CALL 5145 + if (objc != 5-i && objc != 6-i) { 5146 + Tcl_WrongNumArgs (interp, 1-i, objv, "<type_name> <name>" 5147 + " ?<namespace>? pattern"); 5148 + return TCL_ERROR; 5149 + } 5150 + savedNumPatternList = sdata->numPatternList; 5151 + namespacePtr = NULL; 5152 + patternIndex = 4-i; 5153 + if (objc == 6-i) { 5154 + patternIndex = 5-i; 5155 + namespacePtr = getNamespacePtr (sdata, Tcl_GetString (objv[4-i])); 5156 + } 5157 + h = Tcl_CreateHashEntry (&sdata->elementType , Tcl_GetString (objv[2-i]), 5158 + &hnew); 5159 + pattern = NULL; 5160 + if (!hnew) { 5161 + pattern = (SchemaCP *) Tcl_GetHashValue (h); 5162 + while (pattern) { 5163 + if (pattern->namespace == namespacePtr) { 5164 + if (pattern->flags & FORWARD_PATTERN_DEF) { 5165 + forwardDef = 1; 5166 + break; 5167 + } 5168 + SetResult ("Element type already defined in this " 5169 + "namespace"); 5170 + return TCL_ERROR; 5171 + } 5172 + pattern = pattern->next; 5173 + } 5174 + } 5175 + h1 = Tcl_CreateHashEntry (&sdata->element , Tcl_GetString (objv[3-i]), 5176 + &hnew1); 5177 + if (hnew1) { 5178 + thiscp = initSchemaCP (SCHEMA_CTYPE_NAME, namespacePtr, 5179 + Tcl_GetString (objv[3-i])); 5180 + REMEMBER_PATTERN (thiscp); 5181 + thiscp->flags |= PLACEHOLDER_PATTERN_DEF; 5182 + Tcl_SetHashValue (h1, thiscp); 5183 + } 5184 + if (pattern == NULL) { 5185 + pattern = initSchemaCP (SCHEMA_CTYPE_NAME, namespacePtr, 5186 + Tcl_GetHashKey (&sdata->element, h1)); 5187 + pattern->flags |= ELEMENTTYPE_DEF; 5188 + pattern->typeName = Tcl_GetHashKey (&sdata->elementType, h); 5189 + if (!hnew) { 5190 + current = (SchemaCP *) Tcl_GetHashValue (h); 5191 + pattern->next = current; 5192 + } 5193 + REMEMBER_PATTERN (pattern); 5194 + Tcl_SetHashValue (h, pattern); 5195 + } 5196 + 5197 + SETASI(sdata); 5198 + savedDefineToplevel = sdata->defineToplevel; 5199 + savedNamespacePtr = sdata->currentNamespace; 5200 + sdata->defineToplevel = 0; 5201 + sdata->currentNamespace = namespacePtr; 5202 + sdata->cp = pattern; 5203 + sdata->numAttr = 0; 5204 + sdata->numReqAttr = 0; 5205 + sdata->currentAttrs = NULL; 5206 + sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 5207 + sdata->evalStub[3] = objv[patternIndex]; 5208 + sdata->currentEvals++; 5209 + result = Tcl_EvalObjv (interp, 4, sdata->evalStub, TCL_EVAL_GLOBAL); 5210 + sdata->currentEvals--; 5211 + sdata->currentNamespace = NULL; 5212 + pattern->attrs = sdata->currentAttrs; 5213 + pattern->numAttr = sdata->numAttr; 5214 + pattern->numReqAttr = sdata->numReqAttr; 5215 + if (result == TCL_OK) { 5216 + if (pattern->numAttr) { 5217 + attributeLookupPreparation (sdata, pattern); 5218 + } 5219 + if (forwardDef) { 5220 + sdata->forwardPatternDefs--; 5221 + pattern->name = Tcl_GetHashKey (&sdata->element, h1); 5222 + pattern->flags &= ~FORWARD_PATTERN_DEF; 5223 + } 5224 + pattern->defScript = objv[patternIndex]; 5225 + Tcl_IncrRefCount (pattern->defScript); 5226 + } else { 5227 + if (forwardDef) { 5228 + pattern->nc = 0; 5229 + } 5230 + cleanupLastPattern (sdata, savedNumPatternList); 5231 + } 5232 + sdata->defineToplevel = savedDefineToplevel; 5233 + sdata->currentNamespace = savedNamespacePtr; 5234 + if (!savedDefineToplevel) { 5235 + SETASI(savedsdata); 5236 + } 5237 + break; 5238 + 5239 + case m_set: 5240 + if (objc < 3 || objc > 4) { 5241 + Tcl_WrongNumArgs (interp, 2, objv, "setting ?value?"); 5242 + return TCL_ERROR; 5243 + } 5244 + if (Tcl_GetIndexFromObj (interp, objv[2], setKeywords, 5245 + "setting", 0, &keywordIndex) 5246 + != TCL_OK) { 5247 + return TCL_ERROR; 5248 + } 5249 + switch ((enum setKeyword) keywordIndex) { 5250 + case s_choiceHashThreshold: 5251 + if (objc == 4) { 5252 + if (Tcl_GetIntFromObj (interp, objv[3], &n) != TCL_OK) { 5253 + SetResult ("Invalid threshold value"); 5254 + return TCL_ERROR; 5255 + } 5256 + if (n < 0) { 5257 + SetResult ("Invalid threshold value"); 5258 + return TCL_ERROR; 5259 + } 5260 + sdata->choiceHashThreshold = n; 5261 + } 5262 + SetIntResult (sdata->choiceHashThreshold); 5263 + case s_attributeHashThreshold: 5264 + if (objc == 4) { 5265 + if (Tcl_GetIntFromObj (interp, objv[3], &n) != TCL_OK) { 5266 + SetResult ("Invalid threshold value"); 5267 + return TCL_ERROR; 5268 + } 5269 + if (n < 0) { 5270 + SetResult ("Invalid threshold value"); 5271 + return TCL_ERROR; 5272 + } 5273 + sdata->attributeHashThreshold = n; 5274 + } 5275 + SetIntResult (sdata->attributeHashThreshold); 5276 + } 5277 + break; 5278 + 5279 + default: 5280 + Tcl_SetResult (interp, "unknown method", NULL); 5281 + result = TCL_ERROR; 5282 + break; 5283 + 5284 + } 5285 + if (sdata->cleanupAfterUse && sdata->currentEvals == 0 5286 + && !(sdata->inuse > 0)) { 5287 + schemaInstanceDelete (sdata); 5288 + } 5289 + return result; 5290 +} 5291 + 5292 + 5293 +/* 5294 + *---------------------------------------------------------------------------- 5295 + * 5296 + * tDOM_SchemaObjCmd -- 5297 + * 5298 + * This procedure is invoked to process the "schema" command. 5299 + * See the user documentation for what it does. 5300 + * 5301 + * Results: 5302 + * A standard Tcl result. 5303 + * 5304 + * Side effects: 5305 + * 5306 + * 5307 + *---------------------------------------------------------------------------- 5308 + */ 5309 + 5310 +int 5311 +tDOM_SchemaObjCmd ( 5312 + ClientData clientData, 5313 + Tcl_Interp *interp, 5314 + int objc, 5315 + Tcl_Obj *const objv[] 5316 + ) 5317 +{ 5318 + int methodIndex, ind, result = TCL_OK; 5319 + SchemaData *sdata; 5320 + 5321 + static const char *schemaMethods[] = { 5322 + "create", NULL 5323 + }; 5324 + enum schemaMethod { 5325 + m_create 5326 + }; 5327 + 5328 + if (objc < 2 || objc > 3) { 5329 + Tcl_WrongNumArgs (interp, 1, objv, "subcommand ?argument?"); 5330 + return TCL_ERROR; 5331 + } 5332 + 5333 + if (objc == 2) { 5334 + methodIndex = m_create; 5335 + ind = 1; 5336 + } else { 5337 + if (Tcl_GetIndexFromObj (interp, objv[1], schemaMethods, 5338 + "method", 0, &methodIndex) 5339 + != TCL_OK) { 5340 + return TCL_ERROR; 5341 + } 5342 + ind = 2; 5343 + } 5344 + 5345 + Tcl_ResetResult (interp); 5346 + switch ((enum schemaMethod) methodIndex) { 5347 + case m_create: 5348 + sdata = initSchemaData (objv[ind]); 5349 + Tcl_CreateObjCommand (interp, Tcl_GetString(objv[ind]), 5350 + tDOM_schemaInstanceCmd, 5351 + (ClientData) sdata, 5352 + schemaInstanceDelete); 5353 + Tcl_SetObjResult (interp, objv[ind]); 5354 + break; 5355 + 5356 + default: 5357 + Tcl_SetResult (interp, "unknown method", NULL); 5358 + result = TCL_ERROR; 5359 + break; 5360 + 5361 + } 5362 + return result; 5363 +} 5364 + 5365 +static SchemaQuant 5366 +getQuant ( 5367 + Tcl_Interp *interp, 5368 + SchemaData *sdata, 5369 + Tcl_Obj *quantObj, 5370 + int *n, 5371 + int *m 5372 + ) 5373 +{ 5374 + char *quantStr; 5375 + int len; 5376 + Tcl_Obj *thisObj; 5377 + 5378 + *n = 0; 5379 + *m = 0; 5380 + if (!quantObj) { 5381 + return SCHEMA_CQUANT_ONE; 5382 + } 5383 + quantStr = Tcl_GetStringFromObj (quantObj, &len); 5384 + if (len == 1) { 5385 + switch (quantStr[0]) { 5386 + case '!': 5387 + return SCHEMA_CQUANT_ONE; 5388 + case '*': 5389 + return SCHEMA_CQUANT_REP; 5390 + case '?': 5391 + return SCHEMA_CQUANT_OPT; 5392 + case '+': 5393 + return SCHEMA_CQUANT_PLUS; 5394 + } 5395 + } 5396 + if (Tcl_ListObjLength (interp, quantObj, &len) != TCL_OK) { 5397 + SetResult ("Invalid quant specifier"); 5398 + return SCHEMA_CQUANT_ERROR; 5399 + } 5400 + if (len != 1 && len != 2) { 5401 + SetResult ("Invalid quant specifier"); 5402 + return SCHEMA_CQUANT_ERROR; 5403 + } 5404 + if (len == 1) { 5405 + if (Tcl_GetIntFromObj (interp, quantObj, n) != TCL_OK) { 5406 + SetResult ("Invalid quant specifier"); 5407 + return SCHEMA_CQUANT_ERROR; 5408 + } 5409 + if (*n < 1) { 5410 + SetResult ("Invalid quant specifier"); 5411 + return SCHEMA_CQUANT_ERROR; 5412 + } 5413 + if (*n == 1) { 5414 + return SCHEMA_CQUANT_ONE; 5415 + *n = 0; 5416 + } 5417 + return SCHEMA_CQUANT_NM; 5418 + } 5419 + /* The "list-ness" of the quantObj is already checked by the 5420 + * Tcl_ListObjLength() call above, no need to check result. */ 5421 + Tcl_ListObjIndex (interp, quantObj, 0, &thisObj); 5422 + if (Tcl_GetIntFromObj (interp, thisObj, n) != TCL_OK) { 5423 + SetResult ("Invalid quant specifier"); 5424 + return SCHEMA_CQUANT_ERROR; 5425 + } 5426 + if (*n < 0) { 5427 + SetResult ("Invalid quant specifier"); 5428 + return SCHEMA_CQUANT_ERROR; 5429 + } 5430 + Tcl_ListObjIndex (interp, quantObj, 1, &thisObj); 5431 + if (Tcl_GetIntFromObj (interp, thisObj, m) != TCL_OK) { 5432 + SetResult ("Invalid quant specifier"); 5433 + return SCHEMA_CQUANT_ERROR; 5434 + } 5435 + if (*n > *m) { 5436 + SetResult ("Invalid quant specifier"); 5437 + return SCHEMA_CQUANT_ERROR; 5438 + } 5439 + if (*n == 0 && *m == 1) { 5440 + return SCHEMA_CQUANT_OPT; 5441 + } 5442 + if (*n == 1 && *m == 1) { 5443 + return SCHEMA_CQUANT_ONE; 5444 + } 5445 + return SCHEMA_CQUANT_NM; 5446 +} 5447 + 5448 +/* Implements the schema definition command "any" */ 5449 +static int 5450 +AnyPatternObjCmd ( 5451 + ClientData clientData, 5452 + Tcl_Interp *interp, 5453 + int objc, 5454 + Tcl_Obj *const objv[] 5455 + ) 5456 +{ 5457 + SchemaData *sdata = GETASI; 5458 + SchemaCP *pattern; 5459 + SchemaQuant quant; 5460 + char *ns = NULL; 5461 + int n, m; 5462 + 5463 + CHECK_SI 5464 + CHECK_TOPLEVEL 5465 + checkNrArgs (1,3,"?namespace? ?quant?"); 5466 + if (objc == 1) { 5467 + quant = SCHEMA_CQUANT_ONE; 5468 + n = 0; m = 0; 5469 + } else if (objc == 2) { 5470 + quant = getQuant (interp, sdata, objv[1], &n, &m); 5471 + if (quant == SCHEMA_CQUANT_ERROR) { 5472 + ns = getNamespacePtr (sdata, Tcl_GetString (objv[1])); 5473 + quant = SCHEMA_CQUANT_ONE; 5474 + } 5475 + } else { 5476 + ns = getNamespacePtr (sdata, Tcl_GetString (objv[1])); 5477 + quant = getQuant (interp, sdata, objv[2], &n, &m); 5478 + if (quant == SCHEMA_CQUANT_ERROR) { 5479 + return TCL_ERROR; 5480 + } 5481 + } 5482 + pattern = initSchemaCP (SCHEMA_CTYPE_ANY, ns, NULL); 5483 + REMEMBER_PATTERN (pattern) 5484 + addToContent(sdata, pattern, quant, n, m); 5485 + return TCL_OK; 5486 +} 5487 + 5488 +static int 5489 +evalDefinition ( 5490 + Tcl_Interp *interp, 5491 + SchemaData *sdata, 5492 + Tcl_Obj *definition, 5493 + SchemaCP *pattern, 5494 + SchemaQuant quant, 5495 + int n, 5496 + int m 5497 + ) 5498 +{ 5499 + SchemaCP *savedCP; 5500 + SchemaAttr **savedCurrentAttrs; 5501 + unsigned int savedContenSize; 5502 + unsigned int savedAttrSize, savedNumAttr, savedNumReqAttr; 5503 + int result, i, onlyName, hnew; 5504 + Tcl_HashEntry *h; 5505 + Tcl_HashTable *t; 5506 + 5507 + /* Save some state of sdata .. */ 5508 + savedCP = sdata->cp; 5509 + savedContenSize = sdata->contentSize; 5510 + savedNumAttr = sdata->numAttr; 5511 + savedNumReqAttr = sdata->numReqAttr; 5512 + savedAttrSize = sdata->attrSize; 5513 + savedCurrentAttrs = sdata->currentAttrs; 5514 + /* ... and prepare sdata for definition evaluation. */ 5515 + sdata->cp = pattern; 5516 + sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 5517 + sdata->numAttr = 0; 5518 + sdata->numReqAttr = 0; 5519 + sdata->currentAttrs = NULL; 5520 + sdata->attrSize = 0; 5521 + 5522 + sdata->currentEvals++; 5523 + result = Tcl_EvalObjEx (interp, definition, TCL_EVAL_DIRECT); 5524 + sdata->currentEvals--; 5525 + 5526 + pattern->attrs = sdata->currentAttrs; 5527 + pattern->numAttr = sdata->numAttr; 5528 + pattern->numReqAttr = sdata->numReqAttr; 5529 + /* ... and restore the previously saved sdata states */ 5530 + sdata->cp = savedCP; 5531 + sdata->contentSize = savedContenSize; 5532 + sdata->numAttr = savedNumAttr; 5533 + sdata->numReqAttr = savedNumReqAttr; 5534 + sdata->currentAttrs = savedCurrentAttrs; 5535 + sdata->attrSize = savedAttrSize; 5536 + 5537 + if (result != TCL_OK) { 5538 + freeSchemaCP (pattern); 5539 + return result; 5540 + } 5541 + 5542 + REMEMBER_PATTERN (pattern); 5543 + if (pattern->numAttr) { 5544 + attributeLookupPreparation (sdata, pattern); 5545 + } 5546 + if (pattern->type == SCHEMA_CTYPE_CHOICE) { 5547 + onlyName = 1; 5548 + for (i = 0; i < pattern->nc; i++) { 5549 + if (pattern->content[i]->type != SCHEMA_CTYPE_NAME 5550 + && pattern->content[i]->type != SCHEMA_CTYPE_TEXT) { 5551 + onlyName = 0; 5552 + break; 5553 + } 5554 + } 5555 + if (onlyName && pattern->nc > sdata->choiceHashThreshold) { 5556 + t = TMALLOC (Tcl_HashTable); 5557 + Tcl_InitHashTable (t, TCL_ONE_WORD_KEYS); 5558 + hnew = 1; 5559 + for (i = 0; i < pattern->nc; i++) { 5560 + if (pattern->content[i]->type != SCHEMA_CTYPE_NAME) { 5561 + continue; 5562 + } 5563 + h = Tcl_CreateHashEntry (t, pattern->content[i]->name, &hnew); 5564 + if (!hnew) { 5565 + break; 5566 + } 5567 + Tcl_SetHashValue (h, pattern->content[i]); 5568 + } 5569 + if (hnew) { 5570 + pattern->typedata = (void *)t; 5571 + } else { 5572 + /* No simple lookup possible because of more than one 5573 + * element with the same local name belong to the 5574 + * choices. Rewind. */ 5575 + Tcl_DeleteHashTable (t); 5576 + FREE (t); 5577 + } 5578 + } 5579 + } 5580 + addToContent (sdata, pattern, quant, n, m); 5581 + return TCL_OK; 5582 +} 5583 + 5584 +/* Implements the schema definition commands "element", "elementtype" 5585 + * and "ref" */ 5586 +static int 5587 +NamedPatternObjCmd ( 5588 + ClientData clientData, 5589 + Tcl_Interp *interp, 5590 + int objc, 5591 + Tcl_Obj *const objv[] 5592 + ) 5593 +{ 5594 + SchemaData *sdata = GETASI; 5595 + Schema_CP_Type patternType = (Schema_CP_Type) clientData; 5596 + Tcl_HashTable *hashTable; 5597 + Tcl_HashEntry *h; 5598 + SchemaCP *pattern = NULL, *current; 5599 + SchemaQuant quant; 5600 + int hnew, n, m; 5601 + 5602 + CHECK_SI 5603 + CHECK_TOPLEVEL 5604 + if (clientData == 0) { 5605 + checkNrArgs (2,4,"Expected: elementName ?quant? ?pattern?"); 5606 + patternType = SCHEMA_CTYPE_NAME; 5607 + hashTable = &sdata->element; 5608 + } else if (clientData == (ClientData) 1) { 5609 + checkNrArgs (2,3,"Expected: elementtypeName ?quant?"); 5610 + patternType = SCHEMA_CTYPE_NAME; 5611 + hashTable = &sdata->elementType; 5612 + } else { 5613 + checkNrArgs (2,3,"Expected: patternName ?quant?"); 5614 + patternType = SCHEMA_CTYPE_PATTERN; 5615 + hashTable = &sdata->pattern; 5616 + } 5617 + 5618 + quant = getQuant (interp, sdata, objc == 2 ? NULL : objv[2], &n, &m); 5619 + if (quant == SCHEMA_CQUANT_ERROR) { 5620 + return TCL_ERROR; 5621 + } 5622 + h = Tcl_CreateHashEntry (hashTable, Tcl_GetString(objv[1]), &hnew); 5623 + if (objc < 4) { 5624 + /* Reference to an element, elementtype or pattern */ 5625 + if (!hnew) { 5626 + pattern = (SchemaCP *) Tcl_GetHashValue (h); 5627 + while (pattern) { 5628 + if (pattern->namespace == sdata->currentNamespace) { 5629 + break; 5630 + } 5631 + pattern = pattern->next; 5632 + } 5633 + } 5634 + if (!pattern) { 5635 + pattern = initSchemaCP ( 5636 + patternType, 5637 + sdata->currentNamespace, 5638 + Tcl_GetHashKey (hashTable, h) 5639 + ); 5640 + if (clientData == (ClientData) 1) { 5641 + pattern->typeName = pattern->name; 5642 + pattern->name = NULL; 5643 + pattern->flags |= ELEMENTTYPE_DEF; 5644 + } 5645 + pattern->flags |= FORWARD_PATTERN_DEF; 5646 + sdata->forwardPatternDefs++; 5647 + if (!hnew) { 5648 + current = (SchemaCP *) Tcl_GetHashValue (h); 5649 + pattern->next = current; 5650 + } 5651 + REMEMBER_PATTERN (pattern); 5652 + Tcl_SetHashValue (h, pattern); 5653 + } 5654 + addToContent (sdata, pattern, quant, n, m); 5655 + } else { 5656 + /* Local definition of this element */ 5657 + if (hnew) { 5658 + pattern = initSchemaCP( 5659 + SCHEMA_CTYPE_NAME, 5660 + sdata->currentNamespace, 5661 + Tcl_GetHashKey (hashTable, h) 5662 + ); 5663 + pattern->flags |= PLACEHOLDER_PATTERN_DEF; 5664 + REMEMBER_PATTERN (pattern); 5665 + Tcl_SetHashValue (h, pattern); 5666 + } 5667 + pattern = initSchemaCP ( 5668 + SCHEMA_CTYPE_NAME, 5669 + sdata->currentNamespace, 5670 + Tcl_GetHashKey (hashTable, h) 5671 + ); 5672 + pattern->flags |= LOCAL_DEFINED_ELEMENT; 5673 + return evalDefinition (interp, sdata, objv[3], pattern, quant, n, m); 5674 + } 5675 + return TCL_OK; 5676 +} 5677 + 5678 +/* Implements the schema definition commands "choice", "group", 5679 + * "interleave" and "mixed" */ 5680 +static int 5681 +AnonPatternObjCmd ( 5682 + ClientData clientData, 5683 + Tcl_Interp *interp, 5684 + int objc, 5685 + Tcl_Obj *const objv[] 5686 + ) 5687 +{ 5688 + SchemaData *sdata = GETASI; 5689 + Schema_CP_Type patternType; 5690 + SchemaQuant quant; 5691 + SchemaCP *pattern; 5692 + int n, m; 5693 + 5694 + CHECK_SI 5695 + CHECK_TOPLEVEL 5696 + checkNrArgs (2,3,"Expected: ?quant? definition"); 5697 + 5698 + quant = getQuant (interp, sdata, objc == 2 ? NULL : objv[1], &n, &m); 5699 + if (quant == SCHEMA_CQUANT_ERROR) { 5700 + return TCL_ERROR; 5701 + } 5702 + if (clientData == 0) { 5703 + patternType = SCHEMA_CTYPE_CHOICE; 5704 + } else if (clientData == (ClientData) 1) { 5705 + patternType = SCHEMA_CTYPE_CHOICE; 5706 + /* Default quant for mixed is * */ 5707 + if (objc == 2) { 5708 + quant = SCHEMA_CQUANT_REP; 5709 + } 5710 + } else if (clientData == (ClientData) 2) { 5711 + patternType = SCHEMA_CTYPE_INTERLEAVE; 5712 + } else { 5713 + patternType = SCHEMA_CTYPE_PATTERN; 5714 + } 5715 + 5716 + pattern = initSchemaCP (patternType, NULL, NULL); 5717 + if (clientData == (ClientData) 1) { 5718 + pattern->flags |= MIXED_CONTENT; 5719 + } 5720 + return evalDefinition (interp, sdata, objc == 2 ? objv[1] : objv[2], 5721 + pattern, quant, n, m); 5722 +} 5723 + 5724 +static int maybeAddAttr ( 5725 + Tcl_Interp *interp, 5726 + SchemaData *sdata, 5727 + Tcl_Obj *nameObj, 5728 + Tcl_Obj *namespaceObj, 5729 + Tcl_Obj *scriptObj, 5730 + int required, 5731 + SchemaCP *type 5732 + ) 5733 +{ 5734 + Tcl_HashEntry *h; 5735 + int hnew, i, result = TCL_OK; 5736 + char *name, *namespace = NULL; 5737 + SchemaAttr *attr; 5738 + SchemaCP *cp; 5739 + 5740 + if (namespaceObj) { 5741 + namespace = getNamespacePtr (sdata, 5742 + Tcl_GetString (namespaceObj)); 5743 + } 5744 + h = Tcl_CreateHashEntry (&sdata->attrNames, 5745 + Tcl_GetString (nameObj), &hnew); 5746 + name = Tcl_GetHashKey (&sdata->attrNames, h); 5747 + if (!hnew) { 5748 + /* Check, if there is already an attribute with this name 5749 + and namespace */ 5750 + for (i = 0; i < sdata->numAttr; i++) { 5751 + if (sdata->currentAttrs[i]->name == name 5752 + && sdata->currentAttrs[i]->namespace == namespace) { 5753 + /* Ignore the later attribute declaration */ 5754 + return TCL_OK; 5755 + } 5756 + } 5757 + } 5758 + attr = TMALLOC (SchemaAttr); 5759 + attr->namespace = namespace; 5760 + attr->name = name; 5761 + attr->next = NULL; 5762 + attr->required = required; 5763 + if (scriptObj) { 5764 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 5765 + cp->type = SCHEMA_CTYPE_TEXT; 5766 + REMEMBER_PATTERN (cp) 5767 + sdata->isAttributeConstaint = 1; 5768 + result = evalConstraints (interp, sdata, cp, scriptObj); 5769 + sdata->isAttributeConstaint = 0; 5770 + attr->cp = cp; 5771 + } else if (type) { 5772 + attr->cp = type; 5773 + } else { 5774 + attr->cp = NULL; 5775 + } 5776 + if (!sdata->currentAttrs) { 5777 + sdata->currentAttrs = MALLOC (sizeof(SchemaAttr*) 5778 + * ATTR_ARRAY_INIT); 5779 + sdata->attrSize = ATTR_ARRAY_INIT; 5780 + } else if (sdata->numAttr == sdata->attrSize) { 5781 + sdata->currentAttrs = 5782 + REALLOC (sdata->currentAttrs, 2 * sdata->attrSize 5783 + * sizeof (SchemaAttr)); 5784 + sdata->attrSize *= 2; 5785 + } 5786 + sdata->currentAttrs[sdata->numAttr] = attr; 5787 + sdata->numAttr++; 5788 + if (required) { 5789 + sdata->numReqAttr++; 5790 + } 5791 + return result; 5792 +} 5793 + 5794 +static int 5795 +AttributePatternObjCmd ( 5796 + ClientData clientData, 5797 + Tcl_Interp *interp, 5798 + int objc, 5799 + Tcl_Obj *const objv[] 5800 + ) 5801 +{ 5802 + SchemaData *sdata = GETASI; 5803 + char *str; 5804 + int len, required = 1; 5805 + Tcl_Obj *nsObj, *nameObj; 5806 + Tcl_HashEntry *h; 5807 + SchemaCP *type; 5808 + 5809 + CHECK_SI 5810 + CHECK_TOPLEVEL 5811 + 5812 + if (sdata->cp->type != SCHEMA_CTYPE_NAME) { 5813 + SetResult ("The commands attribute and nsattribute are only allowed toplevel in element definition scripts"); 5814 + return TCL_ERROR; 5815 + } 5816 + if (clientData) { 5817 + checkNrArgs (3,6,"Expected:" 5818 + " name namespace" 5819 + " | name namespace attquant" 5820 + " | name namespace ?attquant? <constraint script>" 5821 + " | name namespace ?attquant? \"type\" typename"); 5822 + nsObj = objv[2]; 5823 + } else { 5824 + checkNrArgs (2,5,"Expected:" 5825 + " name" 5826 + " | name attquant" 5827 + " | name ?attquant? <constraint script>" 5828 + " | name ?attquant? \"type\" typename"); 5829 + nsObj = NULL; 5830 + } 5831 + nameObj = objv[1]; 5832 + if (clientData) { 5833 + objv++; 5834 + objc--; 5835 + } 5836 + if (objc == 2) { 5837 + return maybeAddAttr (interp, sdata, nameObj, nsObj, NULL, 1, NULL); 5838 + } 5839 + str = Tcl_GetStringFromObj (objv[2], &len); 5840 + if (len == 1) { 5841 + if (str[0] == '?') { 5842 + required = 0; 5843 + } else if (str[0] != '!') { 5844 + SetResult ("Invalid attribute quant"); 5845 + return TCL_ERROR; 5846 + } 5847 + if (objc == 3) { 5848 + return maybeAddAttr (interp, sdata, nameObj, nsObj, NULL, 5849 + required, NULL); 5850 + } 5851 + objv++; 5852 + objc--; 5853 + str = Tcl_GetStringFromObj (objv[2], &len); 5854 + } 5855 + if (objc == 4) { 5856 + if (len != 4 5857 + || strcmp("type", str) != 0) { 5858 + if (clientData) { 5859 + SetResult ("Expected:" 5860 + " name namespace" 5861 + " | name namespace attquant" 5862 + " | name namespace ?attquant? <constraint script>" 5863 + " | name namespace ?attquant? \"type\" typename"); 5864 + } else { 5865 + SetResult ("Expected:" 5866 + " name" 5867 + " | name attquant" 5868 + " | name ?attquant? <constraint script>" 5869 + " | name ?attquant? \"type\" typename"); 5870 + } 5871 + return TCL_ERROR; 5872 + } 5873 + h = Tcl_FindHashEntry (&sdata->textDef, Tcl_GetString (objv[3])); 5874 + if (!h) { 5875 + SetResult3 ("Unknown text type \"", Tcl_GetString (objv[3]), "\""); 5876 + return TCL_ERROR; 5877 + } 5878 + type = (SchemaCP *) Tcl_GetHashValue (h); 5879 + return maybeAddAttr (interp, sdata, nameObj, nsObj, NULL, 5880 + required, type); 5881 + } else { 5882 + return maybeAddAttr (interp, sdata, nameObj, nsObj, objv[2], 5883 + required, NULL); 5884 + } 5885 +} 5886 + 5887 +static int 5888 +NamespacePatternObjCmd ( 5889 + ClientData clientData, 5890 + Tcl_Interp *interp, 5891 + int objc, 5892 + Tcl_Obj *const objv[] 5893 + ) 5894 +{ 5895 + SchemaData *sdata = GETASI; 5896 + char *currentNamespace; 5897 + int result; 5898 + 5899 + CHECK_SI 5900 + CHECK_TOPLEVEL 5901 + checkNrArgs (3,3,"Expected: namespace pattern"); 5902 + 5903 + currentNamespace = sdata->currentNamespace; 5904 + sdata->currentNamespace = 5905 + getNamespacePtr (sdata, Tcl_GetString(objv[1])); 5906 + sdata->currentEvals++; 5907 + result = Tcl_EvalObjEx (interp, objv[2], TCL_EVAL_DIRECT); 5908 + sdata->currentEvals--; 5909 + sdata->currentNamespace = currentNamespace; 5910 + return result; 5911 +} 5912 + 5913 +static int 5914 +TextPatternObjCmd ( 5915 + ClientData clientData, 5916 + Tcl_Interp *interp, 5917 + int objc, 5918 + Tcl_Obj *const objv[] 5919 + ) 5920 +{ 5921 + SchemaData *sdata = GETASI; 5922 + SchemaQuant quant = SCHEMA_CQUANT_OPT; 5923 + SchemaCP *pattern; 5924 + Tcl_HashEntry *h; 5925 + int result = TCL_OK; 5926 + 5927 + CHECK_SI 5928 + CHECK_TOPLEVEL 5929 + checkNrArgs (1,3,"?<definition script>? | type <name>"); 5930 + if (objc == 1) { 5931 + pattern = initSchemaCP (SCHEMA_CTYPE_TEXT, NULL, NULL); 5932 + } else if (objc == 2) { 5933 + quant = SCHEMA_CQUANT_ONE; 5934 + pattern = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 5935 + pattern->type = SCHEMA_CTYPE_TEXT; 5936 + } else { 5937 + if (strcmp("type", Tcl_GetString (objv[1])) != 0) { 5938 + SetResult ("Expected: ?<definition script>? | type <name>"); 5939 + return TCL_ERROR; 5940 + } 5941 + h = Tcl_FindHashEntry (&sdata->textDef, Tcl_GetString (objv[2])); 5942 + if (!h) { 5943 + SetResult3 ("Unknown text type \"", Tcl_GetString (objv[2]), "\""); 5944 + return TCL_ERROR; 5945 + } 5946 + quant = SCHEMA_CQUANT_ONE; 5947 + pattern = (SchemaCP *) Tcl_GetHashValue (h); 5948 + } 5949 + if (objc == 2) { 5950 + result = evalConstraints (interp, sdata, pattern, objv[1]); 5951 + } 5952 + if (result == TCL_OK) { 5953 + if (objc < 3) { 5954 + REMEMBER_PATTERN (pattern) 5955 + } 5956 + addToContent (sdata, pattern, quant, 0, 0); 5957 + } else { 5958 + freeSchemaCP (pattern); 5959 + } 5960 + return result; 5961 +} 5962 + 5963 +static int 5964 +VirtualPatternObjCmd ( 5965 + ClientData clientData, 5966 + Tcl_Interp *interp, 5967 + int objc, 5968 + Tcl_Obj *const objv[] 5969 + ) 5970 +{ 5971 + SchemaData *sdata = GETASI; 5972 + SchemaCP *pattern; 5973 + int i; 5974 + 5975 + CHECK_SI 5976 + CHECK_TOPLEVEL 5977 + if (objc < 2) { 5978 + SetResult ("Expected: <tclcmd> ?arg? ?arg? ..."); 5979 + return TCL_ERROR; 5980 + } 5981 + 5982 + if (sdata->cp->type != SCHEMA_CTYPE_NAME 5983 + && sdata->cp->type != SCHEMA_CTYPE_PATTERN) { 5984 + SetResult ("The \"tcl\" schema definition command is only " 5985 + "allowed in sequential context (defelement, " 5986 + "element, group or defpattern)"); 5987 + return TCL_ERROR; 5988 + } 5989 + 5990 + pattern = initSchemaCP (SCHEMA_CTYPE_VIRTUAL, NULL, NULL); 5991 + REMEMBER_PATTERN (pattern) 5992 + pattern->content = MALLOC (sizeof (Tcl_Obj*) * (objc-1)); 5993 + for (i = 0; i < objc-1; i++) { 5994 + pattern->content[i] = (SchemaCP *) objv[i+1]; 5995 + Tcl_IncrRefCount (objv[i+1]); 5996 + } 5997 + pattern->nc = objc-1; 5998 + addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0); 5999 + return TCL_OK; 6000 +} 6001 + 6002 +static int 6003 +SelfObjCmd ( 6004 + ClientData clientData, 6005 + Tcl_Interp *interp, 6006 + int objc, 6007 + Tcl_Obj *const objv[] 6008 + ) 6009 +{ 6010 + SchemaData *sdata = GETASI; 6011 + 6012 + CHECK_SI 6013 + CHECK_TOPLEVEL 6014 + if (objc != 1) { 6015 + SetResult ("No argument expected"); 6016 + return TCL_ERROR; 6017 + } 6018 + Tcl_SetObjResult (interp, Tcl_DuplicateObj (sdata->self)); 6019 + return TCL_OK; 6020 +} 6021 + 6022 +static int 6023 +domuniquePatternObjCmd ( 6024 + ClientData clientData, 6025 + Tcl_Interp *interp, 6026 + int objc, 6027 + Tcl_Obj *const objv[] 6028 + ) 6029 +{ 6030 + SchemaData *sdata = GETASI; 6031 + ast t; 6032 + char *errMsg = NULL; 6033 + domKeyConstraint *kc, *kc1; 6034 + int i, nrFields, flags = 0; 6035 + Tcl_Obj *elm; 6036 + 6037 + CHECK_SI 6038 + CHECK_TOPLEVEL 6039 + checkNrArgs (3, 6, "Expected: <selector> <fieldlist> ?<name>? ?\"IGNORE_EMPTY_FIELD_SET\"|(?\"EMPTY_FIELD_SET_VALUE\" <emptyFieldSetValue?)"); 6040 + if (sdata->cp->type != SCHEMA_CTYPE_NAME) { 6041 + SetResult ("The domunique schema definition command is only " 6042 + "allowed as direct child of an element."); 6043 + } 6044 + if (Tcl_ListObjLength (interp, objv[2], &nrFields) != TCL_OK) { 6045 + SetResult ("The <fieldlist> argument must be a valid tcl list"); 6046 + return TCL_ERROR; 6047 + } 6048 + if (nrFields == 0) { 6049 + SetResult ("Non empty fieldlist argument expected."); 6050 + return TCL_ERROR; 6051 + } 6052 + if (objc == 5) { 6053 + if (strcmp (Tcl_GetString (objv[4]), "IGNORE_EMPTY_FIELD_SET") != 0) { 6054 + SetResult3 ("Unknown flag '", Tcl_GetString (objv[4]), "'"); 6055 + return TCL_ERROR; 6056 + } 6057 + flags |= DKC_FLAG_IGNORE_EMPTY_FIELD_SET; 6058 + } 6059 + if (objc == 6) { 6060 + if (strcmp (Tcl_GetString (objv[4]), "EMPTY_FIELD_SET_VALUE") != 0) { 6061 + SetResult3 ("Unknown flag '", Tcl_GetString (objv[4]), "'"); 6062 + return TCL_ERROR; 6063 + } 6064 + } 6065 + 6066 + if (xpathParse (Tcl_GetString (objv[1]), NULL, XPATH_EXPR, 6067 + sdata->prefixns, NULL, &t, &errMsg) < 0) { 6068 + SetResult3 ("Error in selector xpath: '", errMsg, ""); 6069 + FREE (errMsg); 6070 + return TCL_ERROR; 6071 + } 6072 + 6073 + kc = TMALLOC (domKeyConstraint); 6074 + memset (kc, 0, sizeof (domKeyConstraint)); 6075 + kc->fields = MALLOC (sizeof (ast) * nrFields); 6076 + memset (kc->fields, 0, sizeof (ast) * nrFields); 6077 + kc->nrFields = nrFields; 6078 + kc->selector = t; 6079 + kc->flags = flags; 6080 + for (i = 0; i < nrFields; i++) { 6081 + Tcl_ListObjIndex (interp, objv[2], i, &elm); 6082 + if (xpathParse (Tcl_GetString (elm), NULL, XPATH_EXPR, 6083 + sdata->prefixns, NULL, &t, &errMsg) < 0) { 6084 + SetResult3 ("Error in field xpath: '", errMsg, ""); 6085 + FREE (errMsg); 6086 + xpathFreeAst (t); 6087 + freedomKeyConstraints (kc); 6088 + return TCL_ERROR; 6089 + } 6090 + kc->fields[i] = t; 6091 + } 6092 + if (objc >= 4) { 6093 + kc->name = tdomstrdup (Tcl_GetString (objv[3])); 6094 + } 6095 + if (objc == 6) { 6096 + kc->emptyFieldSetValue = tdomstrdup (Tcl_GetString (objv[5])); 6097 + kc->efsv_len = strlen (kc->emptyFieldSetValue); 6098 + } 6099 + /* Apppend to end so that the constraints are checked in 6100 + * definition order */ 6101 + if (sdata->cp->domKeys) { 6102 + kc1 = sdata->cp->domKeys; 6103 + while (1) { 6104 + if (kc1->next) kc1 = kc1->next; 6105 + else break; 6106 + } 6107 + kc1->next = kc; 6108 + } else { 6109 + sdata->cp->domKeys = kc; 6110 + } 6111 + return TCL_OK; 6112 +} 6113 + 6114 +static int 6115 +domxpathbooleanPatternObjCmd ( 6116 + ClientData clientData, 6117 + Tcl_Interp *interp, 6118 + int objc, 6119 + Tcl_Obj *const objv[] 6120 + ) 6121 +{ 6122 + SchemaData *sdata = GETASI; 6123 + ast t; 6124 + char *errMsg = NULL; 6125 + domKeyConstraint *kc, *kc1; 6126 + 6127 + CHECK_SI 6128 + CHECK_TOPLEVEL 6129 + checkNrArgs (2, 3, "Expected: <selector> ?<name>?"); 6130 + if (sdata->cp->type != SCHEMA_CTYPE_NAME) { 6131 + SetResult ("The domxpathboolean schema definition command is only " 6132 + "allowed as direct child of an element."); 6133 + } 6134 + if (xpathParse (Tcl_GetString (objv[1]), NULL, XPATH_EXPR, 6135 + sdata->prefixns, NULL, &t, &errMsg) < 0) { 6136 + SetResult3 ("Error in selector xpath: '", errMsg, ""); 6137 + FREE (errMsg); 6138 + return TCL_ERROR; 6139 + } 6140 + 6141 + kc = TMALLOC (domKeyConstraint); 6142 + memset (kc, 0, sizeof (domKeyConstraint)); 6143 + kc->selector = t; 6144 + kc->flags |= DKC_FLAG_BOOLEAN; 6145 + if (objc == 3) { 6146 + kc->name = tdomstrdup (Tcl_GetString (objv[2])); 6147 + } 6148 + /* Apppend to end so that the constraints are checked in 6149 + * definition order */ 6150 + if (sdata->cp->domKeys) { 6151 + kc1 = sdata->cp->domKeys; 6152 + while (1) { 6153 + if (kc1->next) kc1 = kc1->next; 6154 + else break; 6155 + } 6156 + kc1->next = kc; 6157 + } else { 6158 + sdata->cp->domKeys = kc; 6159 + } 6160 + return TCL_OK; 6161 +} 6162 + 6163 +static int 6164 +keyspacePatternObjCmd ( 6165 + ClientData clientData, 6166 + Tcl_Interp *interp, 6167 + int objc, 6168 + Tcl_Obj *const objv[] 6169 + ) 6170 +{ 6171 + SchemaData *sdata = GETASI; 6172 + SchemaCP *pattern; 6173 + int nrKeyspaces, i, hnew; 6174 + Tcl_Obj *ksObj; 6175 + SchemaKeySpace *ks; 6176 + Tcl_HashEntry *h; 6177 + 6178 + CHECK_SI 6179 + CHECK_TOPLEVEL 6180 + checkNrArgs (3, 3, "Expected: <keyspace-name list> pattern"); 6181 + if (sdata->cp->type != SCHEMA_CTYPE_NAME 6182 + && sdata->cp->type != SCHEMA_CTYPE_PATTERN) { 6183 + SetResult ("The keyspace schema definition command is only " 6184 + "allowed in sequential context (defelement, " 6185 + "element or defpattern)"); 6186 + return TCL_ERROR; 6187 + } 6188 + if (Tcl_ListObjLength (interp, objv[1], &nrKeyspaces) != TCL_OK) { 6189 + SetResult ("The <keyspace-name list> argument must be a valid tcl " 6190 + "list"); 6191 + return TCL_ERROR; 6192 + } 6193 + for (i = 0; i < nrKeyspaces; i++) { 6194 + Tcl_ListObjIndex (interp, objv[1], i, &ksObj); 6195 + h = Tcl_CreateHashEntry (&sdata->keySpaces, 6196 + Tcl_GetString (ksObj), &hnew); 6197 + if (hnew) { 6198 + ks = TMALLOC (SchemaKeySpace); 6199 + ks->name = Tcl_GetHashKey (&sdata->keySpaces, h); 6200 + ks->active = 0; 6201 + ks->unknownIDrefs = 0; 6202 + Tcl_SetHashValue (h, ks); 6203 + } else { 6204 + ks = Tcl_GetHashValue (h); 6205 + } 6206 + pattern = initSchemaCP (SCHEMA_CTYPE_KEYSPACE, 6207 + Tcl_GetString (ksObj), NULL); 6208 + pattern->keySpace = ks; 6209 + REMEMBER_PATTERN (pattern); 6210 + addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0); 6211 + } 6212 + sdata->currentEvals++; 6213 + if (Tcl_EvalObjEx (interp, objv[2], TCL_EVAL_DIRECT) != TCL_OK) { 6214 + return TCL_ERROR; 6215 + } 6216 + sdata->currentEvals--; 6217 + for (i = 0; i < nrKeyspaces; i++) { 6218 + Tcl_ListObjIndex (interp, objv[1], i, &ksObj); 6219 + h = Tcl_FindHashEntry (&sdata->keySpaces, Tcl_GetString(ksObj)); 6220 + pattern = initSchemaCP (SCHEMA_CTYPE_KEYSPACE_END, 6221 + Tcl_GetString (ksObj), NULL); 6222 + REMEMBER_PATTERN (pattern); 6223 + pattern->keySpace = Tcl_GetHashValue (h); 6224 + addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0); 6225 + } 6226 + return TCL_OK; 6227 +} 6228 + 6229 +static int 6230 +associatePatternObjCmd ( 6231 + ClientData clientData, 6232 + Tcl_Interp *interp, 6233 + int objc, 6234 + Tcl_Obj *const objv[] 6235 + ) 6236 +{ 6237 + SchemaData *sdata = GETASI; 6238 + 6239 + CHECK_SI 6240 + CHECK_TOPLEVEL 6241 + checkNrArgs (2, 2, "Expected: data"); 6242 + switch (sdata->cp->type) { 6243 + case SCHEMA_CTYPE_NAME: 6244 + case SCHEMA_CTYPE_PATTERN: 6245 + case SCHEMA_CTYPE_INTERLEAVE: 6246 + break; 6247 + default: 6248 + SetResult ("The associate schema definition command is only " 6249 + "allowed inside of global or local element, pattern or " 6250 + "interleval context"); 6251 + return TCL_ERROR; 6252 + } 6253 + if (sdata->cp->associated) { 6254 + Tcl_DecrRefCount (sdata->cp->associated); 6255 + } 6256 + sdata->cp->associated = objv[1]; 6257 + Tcl_IncrRefCount (sdata->cp->associated); 6258 + return TCL_OK; 6259 +} 6260 + 6261 +static int 6262 +integerImplXsd ( 6263 + Tcl_Interp *interp, 6264 + void *constraintData, 6265 + char *text 6266 + ) 6267 +{ 6268 + char *c = text; 6269 + if (*c == 0) return 0; 6270 + switch ((intptr_t)constraintData) { 6271 + case 0: 6272 + /* integer */ 6273 + if (*c == '-' || *c == '+') c++; 6274 + break; 6275 + case 1: 6276 + /* negativeInteger */ 6277 + if (*c != '-') return 0; 6278 + c++; 6279 + while (*c == '0') c++; 6280 + break; 6281 + case 2: 6282 + /* nonNegativeInteger */ 6283 + if (*c == '+') c++; 6284 + else if (*c == '-') { 6285 + c++; 6286 + if (*c == '0') { 6287 + c++; 6288 + while (*c == '0') c++; 6289 + if (*c == 0) return 1; 6290 + } 6291 + return 0; 6292 + } 6293 + break; 6294 + case 3: 6295 + /* nonPositiveInteger */ 6296 + if (*c == '-') c++; 6297 + else { 6298 + if (*c == '+') c++; 6299 + if (*c == 0) return 0; 6300 + while (*c == '0') c++; 6301 + if (*c == 0) return 1; 6302 + return 0; 6303 + } 6304 + break; 6305 + case 4: 6306 + /* positiveInteger */ 6307 + if (*c == '+') c++; 6308 + while (*c == '0') c++; 6309 + break; 6310 + } 6311 + if (*c == 0) return 0; 6312 + while (isdigit(*c)) { 6313 + c++; 6314 + } 6315 + if (*c != 0) return 0; 6316 + return 1; 6317 +} 6318 + 6319 +static int 6320 +integerImplTcl ( 6321 + Tcl_Interp *interp, 6322 + void *constraintData, 6323 + char *text 6324 + ) 6325 +{ 6326 + int n; 6327 + 6328 + if (Tcl_GetInt (interp, text, &n) != TCL_OK) { 6329 + return 0; 6330 + } 6331 + switch ((intptr_t)constraintData) { 6332 + case 0: 6333 + /* integer */ 6334 + break; 6335 + case 1: 6336 + /* negativeInteger */ 6337 + if (n >= 0) return 0; 6338 + break; 6339 + case 2: 6340 + /* nonNegativeInteger */ 6341 + if (n < 0) return 0; 6342 + break; 6343 + case 3: 6344 + /* nonPositiveInteger */ 6345 + if (n > 0) return 0; 6346 + break; 6347 + case 4: 6348 + /* positiveInteger */ 6349 + if (n <= 0) return 0; 6350 + break; 6351 + } 6352 + 6353 + return 1; 6354 +} 6355 + 6356 +static int 6357 +integerTCObjCmd ( 6358 + ClientData clientData, 6359 + Tcl_Interp *interp, 6360 + int objc, 6361 + Tcl_Obj *const objv[] 6362 + ) 6363 +{ 6364 + SchemaData *sdata = GETASI; 6365 + SchemaConstraint *sc; 6366 + int type; 6367 + 6368 + static const char *types[] = { 6369 + "xsd", "tcl", NULL 6370 + }; 6371 + enum typeSyms { 6372 + t_xsd, t_tcl 6373 + }; 6374 + 6375 + CHECK_TI 6376 + checkNrArgs (1,2,"?xsd|tcl?"); 6377 + if (objc == 1) { 6378 + type = t_xsd; 6379 + } else { 6380 + if (Tcl_GetIndexFromObj (interp, objv[1], types, "type", 0, &type) 6381 + != TCL_OK) { 6382 + return TCL_ERROR; 6383 + } 6384 + } 6385 + ADD_CONSTRAINT (sdata, sc) 6386 + switch ((enum typeSyms) type) { 6387 + case t_xsd: 6388 + sc->constraint = integerImplXsd; 6389 + break; 6390 + case t_tcl: 6391 + sc->constraint = integerImplTcl; 6392 + break; 6393 + } 6394 + sc->constraintData = clientData; 6395 + return TCL_OK; 6396 +} 6397 + 6398 +typedef struct 6399 +{ 6400 + int nrArg; 6401 + Tcl_Obj **evalStub; 6402 + SchemaData *sdata; 6403 +} tclTCData; 6404 + 6405 +static void 6406 +tclImplFree ( 6407 + void *constraintData 6408 + ) 6409 +{ 6410 + tclTCData *tcdata = constraintData; 6411 + int i; 6412 + 6413 + for (i = 0; i < tcdata->nrArg-1; i++) { 6414 + Tcl_DecrRefCount (tcdata->evalStub[i]); 6415 + } 6416 + FREE (tcdata->evalStub); 6417 + FREE (tcdata); 6418 +} 6419 + 6420 +static int 6421 +tclImpl ( 6422 + Tcl_Interp *interp, 6423 + void *constraintData, 6424 + char *text 6425 + ) 6426 +{ 6427 + tclTCData *tcdata = constraintData; 6428 + int result, bool; 6429 + 6430 + tcdata->evalStub[tcdata->nrArg-1] = Tcl_NewStringObj(text, -1); 6431 + Tcl_IncrRefCount (tcdata->evalStub[tcdata->nrArg-1]); 6432 + tcdata->sdata->currentEvals++; 6433 + result = Tcl_EvalObjv (interp, tcdata->nrArg, tcdata->evalStub, 6434 + TCL_EVAL_GLOBAL); 6435 + tcdata->sdata->currentEvals--; 6436 + Tcl_DecrRefCount (tcdata->evalStub[tcdata->nrArg-1]); 6437 + if (result != TCL_OK) { 6438 + tcdata->sdata->evalError = 1; 6439 + return 0; 6440 + } 6441 + result = Tcl_GetBooleanFromObj (interp, Tcl_GetObjResult (interp), &bool); 6442 + if (result != TCL_OK) { 6443 + return 0; 6444 + } 6445 + if (bool) { 6446 + return 1; 6447 + } 6448 + return 0; 6449 +} 6450 + 6451 +static int 6452 +tclTCObjCmd ( 6453 + ClientData clientData, 6454 + Tcl_Interp *interp, 6455 + int objc, 6456 + Tcl_Obj *const objv[] 6457 + ) 6458 +{ 6459 + SchemaData *sdata = GETASI; 6460 + SchemaConstraint *sc; 6461 + tclTCData *tcdata; 6462 + int i; 6463 + 6464 + CHECK_TI 6465 + if (objc < 2) { 6466 + SetResult ("Expected: tclcmd ?arg arg ...?"); 6467 + return TCL_ERROR; 6468 + } 6469 + ADD_CONSTRAINT (sdata, sc) 6470 + sc->constraint = tclImpl; 6471 + sc->freeData = tclImplFree; 6472 + tcdata = TMALLOC (tclTCData); 6473 + tcdata->nrArg = objc; 6474 + tcdata->evalStub = MALLOC (sizeof (Tcl_Obj*) * objc); 6475 + for (i = 1; i < objc; i++) { 6476 + tcdata->evalStub[i-1] = objv[i]; 6477 + Tcl_IncrRefCount (tcdata->evalStub[i-1]); 6478 + } 6479 + tcdata->sdata = sdata; 6480 + sc->constraintData = tcdata; 6481 + return TCL_OK; 6482 +} 6483 + 6484 +static void 6485 +fixedImplFree ( 6486 + void *constraintData 6487 + ) 6488 +{ 6489 + FREE (constraintData); 6490 +} 6491 + 6492 +static int 6493 +fixedImpl ( 6494 + Tcl_Interp *interp, 6495 + void *constraintData, 6496 + char *text 6497 + ) 6498 +{ 6499 + if (strcmp (text, (char *) constraintData) == 0) { 6500 + return 1; 6501 + } 6502 + return 0; 6503 +} 6504 + 6505 +static int 6506 +fixedTCObjCmd ( 6507 + ClientData clientData, 6508 + Tcl_Interp *interp, 6509 + int objc, 6510 + Tcl_Obj *const objv[] 6511 + ) 6512 +{ 6513 + SchemaData *sdata = GETASI; 6514 + SchemaConstraint *sc; 6515 + 6516 + CHECK_TI 6517 + checkNrArgs (2,2,"Expected: <fixed value>"); 6518 + ADD_CONSTRAINT (sdata, sc) 6519 + sc->constraint = fixedImpl; 6520 + sc->freeData = fixedImplFree; 6521 + sc->constraintData = tdomstrdup (Tcl_GetString (objv[1])); 6522 + return TCL_OK; 6523 +} 6524 + 6525 +static void 6526 +enumerationImplFree ( 6527 + void *constraintData 6528 + ) 6529 +{ 6530 + Tcl_HashTable *values = (Tcl_HashTable *) constraintData; 6531 + 6532 + Tcl_DeleteHashTable (values); 6533 + FREE (values); 6534 +} 6535 + 6536 +static int 6537 +enumerationImpl ( 6538 + Tcl_Interp *interp, 6539 + void *constraintData, 6540 + char *text 6541 + ) 6542 +{ 6543 + Tcl_HashTable *values = (Tcl_HashTable *) constraintData; 6544 + 6545 + if (Tcl_FindHashEntry(values, text)) return 1; 6546 + return 0; 6547 +} 6548 + 6549 +static int 6550 +enumerationTCObjCmd ( 6551 + ClientData clientData, 6552 + Tcl_Interp *interp, 6553 + int objc, 6554 + Tcl_Obj *const objv[] 6555 + ) 6556 +{ 6557 + SchemaData *sdata = GETASI; 6558 + SchemaConstraint *sc; 6559 + Tcl_HashTable *values; 6560 + int len, i, hnew; 6561 + Tcl_Obj *value; 6562 + 6563 + CHECK_TI 6564 + checkNrArgs (2,2,"Expected: <value list>"); 6565 + if (Tcl_ListObjLength (interp, objv[1], &len) != TCL_OK) { 6566 + SetResult ("The argument must be a valid tcl list"); 6567 + return TCL_ERROR; 6568 + } 6569 + ADD_CONSTRAINT (sdata, sc) 6570 + sc->constraint = enumerationImpl; 6571 + sc->freeData = enumerationImplFree; 6572 + values = TMALLOC (Tcl_HashTable); 6573 + Tcl_InitHashTable (values, TCL_STRING_KEYS); 6574 + for (i = 0; i < len; i++) { 6575 + Tcl_ListObjIndex (interp, objv[1], i, &value); 6576 + Tcl_CreateHashEntry (values, Tcl_GetString (value), &hnew); 6577 + } 6578 + sc->constraintData = values; 6579 + return TCL_OK; 6580 +} 6581 + 6582 +static void 6583 +matchImplFree ( 6584 + void *constraintData 6585 + ) 6586 +{ 6587 + Tcl_DecrRefCount ((Tcl_Obj *) constraintData); 6588 +} 6589 + 6590 +static int 6591 +matchImpl ( 6592 + Tcl_Interp *interp, 6593 + void *constraintData, 6594 + char *text 6595 + ) 6596 +{ 6597 + if (Tcl_StringCaseMatch (text, Tcl_GetString ((Tcl_Obj *) constraintData), 0)) 6598 + return 1; 6599 + return 0; 6600 +} 6601 + 6602 +static int 6603 +matchNocaseImpl ( 6604 + Tcl_Interp *interp, 6605 + void *constraintData, 6606 + char *text 6607 + ) 6608 +{ 6609 + if (Tcl_StringCaseMatch (text, Tcl_GetString ((Tcl_Obj *) constraintData), 6610 + TCL_MATCH_NOCASE)) 6611 + return 1; 6612 + return 0; 6613 +} 6614 + 6615 +static int 6616 +matchTCObjCmd ( 6617 + ClientData clientData, 6618 + Tcl_Interp *interp, 6619 + int objc, 6620 + Tcl_Obj *const objv[] 6621 + ) 6622 +{ 6623 + SchemaData *sdata = GETASI; 6624 + SchemaConstraint *sc; 6625 + 6626 + CHECK_TI 6627 + checkNrArgs (2,3,"Expected: ?-nocase? <match pattern>"); 6628 + if (objc == 3) { 6629 + if (strcmp ("-nocase", Tcl_GetString (objv[1])) != 0) { 6630 + SetResult ("Expected: ?-nocase? <match pattern>"); 6631 + return TCL_ERROR; 6632 + } 6633 + objv++; 6634 + } 6635 + ADD_CONSTRAINT (sdata, sc) 6636 + if (objc == 2) { 6637 + sc->constraint = matchImpl; 6638 + } else { 6639 + sc->constraint = matchNocaseImpl; 6640 + } 6641 + sc->freeData = matchImplFree; 6642 + Tcl_IncrRefCount (objv[1]); 6643 + sc->constraintData = objv[1]; 6644 + return TCL_OK; 6645 +} 6646 + 6647 +static void 6648 +regexpImplFree ( 6649 + void *constraintData 6650 + ) 6651 +{ 6652 + Tcl_DecrRefCount ((Tcl_Obj *) constraintData); 6653 +} 6654 + 6655 +static int 6656 +regexpImpl ( 6657 + Tcl_Interp *interp, 6658 + void *constraintData, 6659 + char *text 6660 + ) 6661 +{ 6662 + Tcl_Obj *textObj; 6663 + int rc; 6664 + 6665 + 6666 + textObj = Tcl_NewStringObj(text, -1); 6667 + rc = Tcl_RegExpMatchObj (interp, textObj, (Tcl_Obj *) constraintData); 6668 + Tcl_DecrRefCount (textObj); 6669 + /* rc may be 1, 0, -1 */ 6670 + if (rc == 1) { 6671 + return 1; 6672 + } 6673 + return 0; 6674 +} 6675 + 6676 +static int 6677 +regexpTCObjCmd ( 6678 + ClientData clientData, 6679 + Tcl_Interp *interp, 6680 + int objc, 6681 + Tcl_Obj *const objv[] 6682 + ) 6683 +{ 6684 + SchemaData *sdata = GETASI; 6685 + SchemaConstraint *sc; 6686 + 6687 + CHECK_TI 6688 + checkNrArgs (2,2,"Expected: <regexp>"); 6689 + /* Compile it as syntax test (plus caches the complied regexp in 6690 + * the internal value) */ 6691 + if (!Tcl_GetRegExpFromObj (interp, objv[1], 0)) { 6692 + return TCL_ERROR; 6693 + } 6694 + ADD_CONSTRAINT (sdata, sc) 6695 + sc->constraint = regexpImpl; 6696 + sc->freeData = regexpImplFree; 6697 + Tcl_IncrRefCount (objv[1]); 6698 + sc->constraintData = objv[1]; 6699 + return TCL_OK; 6700 +} 6701 + 6702 +static int 6703 +nmtokenImpl ( 6704 + Tcl_Interp *interp, 6705 + void *constraintData, 6706 + char *text 6707 + ) 6708 +{ 6709 + char *p; 6710 + int clen, tokenSeen = 0; 6711 + 6712 + p = text; 6713 + /* Skip leading space */ 6714 + while (*p && *p == ' ') { 6715 + p++; 6716 + } 6717 + while (*p && *p != ' ') { 6718 + clen = UTF8_CHAR_LEN (*p); 6719 + if (!clen) { 6720 + SetResult ("Invalid UTF-8 character"); 6721 + return 0; 6722 + } 6723 + if (!UTF8_GET_NAMING_NMTOKEN (p, clen)) { 6724 + SetResult ("Attribute value isn't a NMTOKEN"); 6725 + return 0; 6726 + } 6727 + tokenSeen = 1; 6728 + p += clen; 6729 + } 6730 + /* Skip following space */ 6731 + while (*p && *p == ' ') { 6732 + p++; 6733 + } 6734 + if (*p) { 6735 + SetResult ("Attribute value isn't a NMTOKEN"); 6736 + return 0; 6737 + } 6738 + if (!*p && !tokenSeen) { 6739 + SetResult ("Missing NMTOKEN value"); 6740 + return 0; 6741 + } 6742 + return 1; 6743 +} 6744 + 6745 +static int 6746 +nmtokenTCObjCmd ( 6747 + ClientData clientData, 6748 + Tcl_Interp *interp, 6749 + int objc, 6750 + Tcl_Obj *const objv[] 6751 + ) 6752 +{ 6753 + SchemaData *sdata = GETASI; 6754 + SchemaConstraint *sc; 6755 + 6756 + CHECK_TI 6757 + checkNrArgs (1,1,"No arguments expected"); 6758 + ADD_CONSTRAINT (sdata, sc) 6759 + sc->constraint = nmtokenImpl; 6760 + return TCL_OK; 6761 +} 6762 + 6763 +static int 6764 +nmtokensImpl ( 6765 + Tcl_Interp *interp, 6766 + void *constraintData, 6767 + char *text 6768 + ) 6769 +{ 6770 + char *p; 6771 + int clen, tokenSeen = 0; 6772 + 6773 + p = text; 6774 + /* Skip leading space */ 6775 + while (*p && *p == ' ') { 6776 + p++; 6777 + } 6778 + while (*p) { 6779 + if (*p == ' ') { 6780 + p++; continue; 6781 + } 6782 + clen = UTF8_CHAR_LEN (*p); 6783 + if (!clen) { 6784 + SetResult ("Invalid UTF-8 character"); 6785 + return 0; 6786 + } 6787 + if (!UTF8_GET_NAMING_NMTOKEN (p, clen)) { 6788 + SetResult ("Invalid charcter: attribute value isn't a NMTOKENS"); 6789 + return 0; 6790 + } 6791 + tokenSeen = 1; 6792 + p += clen; 6793 + } 6794 + /* Any following space is already skipped above */ 6795 + if (!tokenSeen) { 6796 + SetResult ("Missing NMTOKENS value"); 6797 + return 0; 6798 + } 6799 + return 1; 6800 +} 6801 + 6802 +static int 6803 +nmtokensTCObjCmd ( 6804 + ClientData clientData, 6805 + Tcl_Interp *interp, 6806 + int objc, 6807 + Tcl_Obj *const objv[] 6808 + ) 6809 +{ 6810 + SchemaData *sdata = GETASI; 6811 + SchemaConstraint *sc; 6812 + 6813 + CHECK_TI 6814 + checkNrArgs (1,1,"No arguments expected"); 6815 + ADD_CONSTRAINT (sdata, sc) 6816 + sc->constraint = nmtokensImpl; 6817 + return TCL_OK; 6818 +} 6819 + 6820 +static int 6821 +numberImplXsd ( 6822 + Tcl_Interp *interp, 6823 + void *constraintData, 6824 + char *text 6825 + ) 6826 +{ 6827 + char *c = text; 6828 + if (!*c) return 0; 6829 + if (*c == '-' || *c == '+') c++; 6830 + while (isdigit(*c)) { 6831 + c++; 6832 + } 6833 + if (*c == '.') c++; 6834 + while (isdigit(*c)) { 6835 + c++; 6836 + } 6837 + if (*c) return 0; 6838 + return 1; 6839 +} 6840 + 6841 +static int 6842 +numberImplTcl ( 6843 + Tcl_Interp *interp, 6844 + void *constraintData, 6845 + char *text 6846 + ) 6847 +{ 6848 + double d; 6849 + 6850 + if (Tcl_GetDouble (interp, text, &d) != TCL_OK) { 6851 + return 0; 6852 + } 6853 + return 1; 6854 +} 6855 + 6856 +static int 6857 +numberTCObjCmd ( 6858 + ClientData clientData, 6859 + Tcl_Interp *interp, 6860 + int objc, 6861 + Tcl_Obj *const objv[] 6862 + ) 6863 +{ 6864 + SchemaData *sdata = GETASI; 6865 + SchemaConstraint *sc; 6866 + int type; 6867 + 6868 + static const char *types[] = { 6869 + "xsd", "tcl", NULL 6870 + }; 6871 + enum typeSyms { 6872 + t_xsd, t_tcl 6873 + }; 6874 + 6875 + CHECK_TI 6876 + checkNrArgs (1,2,"?xsd|tcl?"); 6877 + if (objc == 1) { 6878 + type = t_xsd; 6879 + } else { 6880 + if (Tcl_GetIndexFromObj (interp, objv[1], types, "type", 0, &type) 6881 + != TCL_OK) { 6882 + return TCL_ERROR; 6883 + } 6884 + } 6885 + ADD_CONSTRAINT (sdata, sc) 6886 + switch ((enum typeSyms) type) { 6887 + case t_xsd: 6888 + sc->constraint = numberImplXsd; 6889 + break; 6890 + case t_tcl: 6891 + sc->constraint = numberImplTcl; 6892 + break; 6893 + } 6894 + return TCL_OK; 6895 +} 6896 + 6897 +static int 6898 +booleanImplXsd ( 6899 + Tcl_Interp *interp, 6900 + void *constraintData, 6901 + char *text 6902 + ) 6903 +{ 6904 + char *c = text; 6905 + switch (*c) { 6906 + case '0': 6907 + case '1': 6908 + c++; 6909 + if (*c == 0) return 1; 6910 + break; 6911 + case 't': 6912 + if (strcmp (text, "true") == 0) return 1; 6913 + break; 6914 + case 'f': 6915 + if (strcmp (text, "false") == 0) return 1; 6916 + break; 6917 + } 6918 + return 0; 6919 +} 6920 + 6921 +static int 6922 +booleanImplTcl ( 6923 + Tcl_Interp *interp, 6924 + void *constraintData, 6925 + char *text 6926 + ) 6927 +{ 6928 + int b; 6929 + 6930 + if (Tcl_GetBoolean (interp, text, &b) != TCL_OK) { 6931 + return 0; 6932 + } 6933 + return 1; 6934 +} 6935 + 6936 +static int 6937 +booleanTCObjCmd ( 6938 + ClientData clientData, 6939 + Tcl_Interp *interp, 6940 + int objc, 6941 + Tcl_Obj *const objv[] 6942 + ) 6943 +{ 6944 + SchemaData *sdata = GETASI; 6945 + SchemaConstraint *sc; 6946 + int type; 6947 + 6948 + static const char *types[] = { 6949 + "xsd", "tcl", NULL 6950 + }; 6951 + enum typeSyms { 6952 + t_xsd, t_tcl 6953 + }; 6954 + 6955 + CHECK_TI 6956 + checkNrArgs (1,2,"?xsd|tcl?"); 6957 + if (objc == 1) { 6958 + type = t_xsd; 6959 + } else { 6960 + if (Tcl_GetIndexFromObj (interp, objv[1], types, "type", 0, &type) 6961 + != TCL_OK) { 6962 + return TCL_ERROR; 6963 + } 6964 + } 6965 + ADD_CONSTRAINT (sdata, sc) 6966 + switch ((enum typeSyms) type) { 6967 + case t_xsd: 6968 + sc->constraint = booleanImplXsd; 6969 + break; 6970 + case t_tcl: 6971 + sc->constraint = booleanImplTcl; 6972 + break; 6973 + } 6974 + return TCL_OK; 6975 +} 6976 + 6977 +static int 6978 +isodateImpl ( 6979 + Tcl_Interp *interp, 6980 + void *constraintData, 6981 + char *text 6982 + ) 6983 +{ 6984 + int i, y, m, d, h, min, s, zh, zm, seenNonzero = 0; 6985 + 6986 + if (constraintData < (void *)2) { 6987 + if (*text == '-') { 6988 + /* A bce date */ 6989 + text++; 6990 + } 6991 + i = 1; 6992 + /* Parse year */ 6993 + while (*text >= '0' && *text <= '9') { 6994 + if (*text > '0' && !seenNonzero) seenNonzero = i; 6995 + text++; 6996 + i++; 6997 + } 6998 + /* Premature end */ 6999 + if (i < 5) return 0; 7000 + if (i > 5) { 7001 + /* The year has more than 4 digits. Only allowed if in fact 7002 + * needed (no extra leading zeros). */ 7003 + if (seenNonzero > 1) return 0; 7004 + } 7005 + if (*text != '-') return 0; 7006 + /* We only need to know the modulo of the year for 4, 100 and 400, 7007 + * for this the 4 last letters are enough */ 7008 + y = atoi(text-4); 7009 + /* There isn't a year 0. it's either 0001 or -0001 */ 7010 + if (!seenNonzero) return 0; 7011 + text++; 7012 + /* Parse month */ 7013 + for (i = 0; i < 2; i++) { 7014 + if (*text < '0' || *text > '9') return 0; 7015 + text++; 7016 + } 7017 + if (*text != '-') return 0; 7018 + m = atoi(text-2); 7019 + if (m < 1 || m > 12) return 0; 7020 + text++; 7021 + /* Parse day */ 7022 + for (i = 0; i < 2; i++) { 7023 + if (*text < '0' || *text > '9') return 0; 7024 + text++; 7025 + } 7026 + d = atoi(text-2); 7027 + if (d < 1) return 0; 7028 + switch (m) { 7029 + case 1: 7030 + case 3: 7031 + case 5: 7032 + case 7: 7033 + case 8: 7034 + case 10: 7035 + case 12: 7036 + if (d > 31) return 0; 7037 + break; 7038 + case 4: 7039 + case 6: 7040 + case 9: 7041 + case 11: 7042 + if (d > 30) return 0; 7043 + break; 7044 + case 2: 7045 + if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) { 7046 + if (d > 29) return 0; 7047 + } else { 7048 + if (d > 28) return 0; 7049 + } 7050 + break; 7051 + } 7052 + } 7053 + /* Date part end */ 7054 + if (constraintData) { 7055 + if (constraintData == (void *)1) { 7056 + /* Time part starts */ 7057 + if (*text != 'T') return 0; 7058 + text++; 7059 + } 7060 + /* Parse hour part */ 7061 + if (*text < '0' || *text > '9') return 0; 7062 + h = (*text - 48) * 10; 7063 + text++; 7064 + if (*text < '0' || *text > '9') return 0; 7065 + h += (*text - 48); 7066 + if (h > 24) return 0; 7067 + text++; 7068 + if (*text != ':') return 0; 7069 + text++; 7070 + /* Parse minute part */ 7071 + if (*text < '0' || *text > '9') return 0; 7072 + min = (*text - 48) * 10; 7073 + text++; 7074 + if (*text < '0' || *text > '9') return 0; 7075 + min += (*text - 48); 7076 + if (min > 59) return 0; 7077 + text++; 7078 + if (*text != ':') return 0; 7079 + text++; 7080 + /* Parse seconds part */ 7081 + if (*text < '0' || *text > '9') return 0; 7082 + s = (*text - 48) * 10; 7083 + text++; 7084 + if (*text < '0' || *text > '9') return 0; 7085 + s += (*text - 48); 7086 + if (s > 59) return 0; 7087 + text++; 7088 + /* Check for optional fraction seconds part */ 7089 + if (*text == '.') { 7090 + if (h == 24) return 0; 7091 + text++; 7092 + /* Dangling decimal point is not allowed */ 7093 + if (*text < '0' || *text > '9') return 0; 7094 + text++; 7095 + while (*text >= '0' && *text <= '9') text++; 7096 + } 7097 + if (h == 24 && (min > 0 || s > 0)) return 0; 7098 + } 7099 + if (*text == '\0') return 1; 7100 + /* Parse optional time zone part */ 7101 + switch (*text) { 7102 + case 'Z': 7103 + text++; 7104 + if (*text != '\0') return 0; 7105 + break; 7106 + case '+': 7107 + case '-': 7108 + text++; 7109 + for (i = 0; i < 2; i++) { 7110 + if (*text < '0' || *text > '9') return 0; 7111 + text++; 7112 + } 7113 + if (*text != ':') return 0; 7114 + zh = atoi(text-2); 7115 + if (zh > 14) return 0; 7116 + text++; 7117 + for (i = 0; i < 2; i++) { 7118 + if (*text < '0' || *text > '9') return 0; 7119 + text++; 7120 + } 7121 + if (*text != '\0') return 0; 7122 + zm = atoi(text-2); 7123 + if (zh < 14) { 7124 + if (zm > 59) return 0; 7125 + } else { 7126 + if (zm != 0) return 0; 7127 + } 7128 + break; 7129 + default: 7130 + return 0; 7131 + } 7132 + return 1; 7133 +} 7134 + 7135 +static int 7136 +dateTCObjCmd ( 7137 + ClientData clientData, 7138 + Tcl_Interp *interp, 7139 + int objc, 7140 + Tcl_Obj *const objv[] 7141 + ) 7142 +{ 7143 + SchemaData *sdata = GETASI; 7144 + SchemaConstraint *sc; 7145 + 7146 + CHECK_TI 7147 + checkNrArgs (1,1,"No arguments expected"); 7148 + ADD_CONSTRAINT (sdata, sc) 7149 + sc->constraint = isodateImpl; 7150 + sc->constraintData = (void *) 0; 7151 + return TCL_OK; 7152 +} 7153 + 7154 +static int 7155 +dateTimeTCObjCmd ( 7156 + ClientData clientData, 7157 + Tcl_Interp *interp, 7158 + int objc, 7159 + Tcl_Obj *const objv[] 7160 + ) 7161 +{ 7162 + SchemaData *sdata = GETASI; 7163 + SchemaConstraint *sc; 7164 + 7165 + CHECK_TI 7166 + checkNrArgs (1,1,"No arguments expected"); 7167 + ADD_CONSTRAINT (sdata, sc) 7168 + sc->constraint = isodateImpl; 7169 + sc->constraintData = (void *) 1; 7170 + return TCL_OK; 7171 +} 7172 + 7173 +static int 7174 +timeTCObjCmd ( 7175 + ClientData clientData, 7176 + Tcl_Interp *interp, 7177 + int objc, 7178 + Tcl_Obj *const objv[] 7179 + ) 7180 +{ 7181 + SchemaData *sdata = GETASI; 7182 + SchemaConstraint *sc; 7183 + 7184 + CHECK_TI 7185 + checkNrArgs (1,1,"No arguments expected"); 7186 + ADD_CONSTRAINT (sdata, sc) 7187 + sc->constraint = isodateImpl; 7188 + sc->constraintData = (void *) 2; 7189 + return TCL_OK; 7190 +} 7191 + 7192 +static int 7193 +maxLengthImpl ( 7194 + Tcl_Interp *interp, 7195 + void *constraintData, 7196 + char *text 7197 + ) 7198 +{ 7199 + unsigned int maxlen = PTR2UINT(constraintData); 7200 + int len = 0, clen; 7201 + 7202 + while (*text != '\0') { 7203 + clen = UTF8_CHAR_LEN (*text); 7204 + if (!clen) { 7205 + SetResult ("Invalid UTF-8 character"); 7206 + return 0; 7207 + } 7208 + len++; 7209 + if (len > maxlen) return 0; 7210 + text += clen; 7211 + } 7212 + return 1; 7213 +} 7214 + 7215 +static int 7216 +maxLengthTCObjCmd ( 7217 + ClientData clientData, 7218 + Tcl_Interp *interp, 7219 + int objc, 7220 + Tcl_Obj *const objv[] 7221 + ) 7222 +{ 7223 + SchemaData *sdata = GETASI; 7224 + SchemaConstraint *sc; 7225 + int len; 7226 + 7227 + CHECK_TI 7228 + checkNrArgs (2,2,"Expected: <maximal length as integer>"); 7229 + if (Tcl_GetIntFromObj (interp, objv[1], &len) != TCL_OK) { 7230 + SetResult ("Expected: <maximal length as integer>"); 7231 + return TCL_ERROR; 7232 + } 7233 + if (len < 1) { 7234 + SetResult ("The maximum length must be at least 1"); 7235 + } 7236 + ADD_CONSTRAINT (sdata, sc) 7237 + sc->constraint = maxLengthImpl; 7238 + sc->constraintData = UINT2PTR(len); 7239 + return TCL_OK; 7240 +} 7241 + 7242 +static int 7243 +minLengthImpl ( 7244 + Tcl_Interp *interp, 7245 + void *constraintData, 7246 + char *text 7247 + ) 7248 +{ 7249 + unsigned int minlen = PTR2UINT(constraintData); 7250 + int len = 0, clen; 7251 + while (*text != '\0') { 7252 + clen = UTF8_CHAR_LEN (*text); 7253 + if (!clen) { 7254 + SetResult ("Invalid UTF-8 character"); 7255 + return 0; 7256 + } 7257 + len++; 7258 + if (len >= minlen) return 1; 7259 + text += clen; 7260 + } 7261 + return 0; 7262 +} 7263 + 7264 +static int 7265 +minLengthTCObjCmd ( 7266 + ClientData clientData, 7267 + Tcl_Interp *interp, 7268 + int objc, 7269 + Tcl_Obj *const objv[] 7270 + ) 7271 +{ 7272 + SchemaData *sdata = GETASI; 7273 + SchemaConstraint *sc; 7274 + int len; 7275 + 7276 + CHECK_TI 7277 + checkNrArgs (2,2,"Expected: <minimum length as integer>"); 7278 + if (Tcl_GetIntFromObj (interp, objv[1], &len) != TCL_OK) { 7279 + SetResult ("Expected: <minimum length as integer>"); 7280 + return TCL_ERROR; 7281 + } 7282 + if (len < 1) { 7283 + SetResult ("The minimum length must be at least 1"); 7284 + } 7285 + ADD_CONSTRAINT (sdata, sc) 7286 + sc->constraint = minLengthImpl; 7287 + sc->constraintData = UINT2PTR(len); 7288 + return TCL_OK; 7289 +} 7290 + 7291 +static int 7292 +oneOfImpl ( 7293 + Tcl_Interp *interp, 7294 + void *constraintData, 7295 + char *text 7296 + ) 7297 +{ 7298 + SchemaCP *cp = (SchemaCP *) constraintData; 7299 + SchemaConstraint *sc; 7300 + int i; 7301 + 7302 + /* Look also at checkText */ 7303 + for (i = 0; i < cp->nc; i++) { 7304 + sc = (SchemaConstraint *) cp->content[i]; 7305 + if ((sc->constraint) (interp, sc->constraintData, text)) { 7306 + return 1; 7307 + } 7308 + } 7309 + return 0; 7310 +} 7311 + 7312 +static int 7313 +oneOfTCObjCmd ( 7314 + ClientData clientData, 7315 + Tcl_Interp *interp, 7316 + int objc, 7317 + Tcl_Obj *const objv[] 7318 + ) 7319 +{ 7320 + SchemaData *sdata = GETASI; 7321 + SchemaCP *cp; 7322 + SchemaConstraint *sc; 7323 + int rc; 7324 + 7325 + CHECK_TI 7326 + checkNrArgs (2,2,"Expected: <text constraint script>"); 7327 + 7328 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 7329 + cp->type = SCHEMA_CTYPE_TEXT; 7330 + REMEMBER_PATTERN (cp) 7331 + rc = evalConstraints (interp, sdata, cp, objv[1]); 7332 + if (rc == TCL_OK) { 7333 + ADD_CONSTRAINT (sdata, sc) 7334 + sc->constraint = oneOfImpl; 7335 + sc->constraintData = (void *)cp; 7336 + return TCL_OK; 7337 + } 7338 + return TCL_ERROR; 7339 +} 7340 + 7341 +static int 7342 +allOfTCObjCmd ( 7343 + ClientData clientData, 7344 + Tcl_Interp *interp, 7345 + int objc, 7346 + Tcl_Obj *const objv[] 7347 + ) 7348 +{ 7349 + SchemaData *sdata = GETASI; 7350 + SchemaCP *cp; 7351 + SchemaConstraint *sc; 7352 + int rc; 7353 + 7354 + CHECK_TI 7355 + checkNrArgs (2,2,"Expected: <text constraint script>"); 7356 + 7357 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 7358 + cp->type = SCHEMA_CTYPE_TEXT; 7359 + REMEMBER_PATTERN (cp) 7360 + rc = evalConstraints (interp, sdata, cp, objv[1]); 7361 + if (rc == TCL_OK) { 7362 + ADD_CONSTRAINT (sdata, sc) 7363 + sc->constraint = checkText; 7364 + sc->constraintData = (void *)cp; 7365 + return TCL_OK; 7366 + } 7367 + return TCL_ERROR; 7368 +} 7369 + 7370 +static int 7371 +stripImpl ( 7372 + Tcl_Interp *interp, 7373 + void *constraintData, 7374 + char *text 7375 + ) 7376 +{ 7377 + SchemaCP *cp = (SchemaCP *) constraintData; 7378 + int rc, restore = 0; 7379 + char *end, saved; 7380 + 7381 + while(SPACE((unsigned char)*text)) text++; 7382 + if(*text != 0) { 7383 + /* Not white space only */ 7384 + /* Trim trailing space */ 7385 + end = text + strlen(text) - 1; 7386 + while(end > text && SPACE((unsigned char)*end)) end--; 7387 + saved = end[1]; 7388 + restore = 1; 7389 + end[1] = '\0'; 7390 + } 7391 + rc = checkText (interp, cp, text); 7392 + if (restore) end[1] = saved; 7393 + return rc; 7394 +} 7395 + 7396 +static int 7397 +stripTCObjCmd ( 7398 + ClientData clientData, 7399 + Tcl_Interp *interp, 7400 + int objc, 7401 + Tcl_Obj *const objv[] 7402 + ) 7403 +{ 7404 + SchemaData *sdata = GETASI; 7405 + SchemaCP *cp; 7406 + SchemaConstraint *sc; 7407 + int rc; 7408 + 7409 + CHECK_TI 7410 + checkNrArgs (2,2,"Expected: <text constraint script>"); 7411 + 7412 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 7413 + cp->type = SCHEMA_CTYPE_TEXT; 7414 + REMEMBER_PATTERN (cp) 7415 + rc = evalConstraints (interp, sdata, cp, objv[1]); 7416 + if (rc == TCL_OK) { 7417 + ADD_CONSTRAINT (sdata, sc) 7418 + sc->constraint = stripImpl; 7419 + sc->constraintData = (void *)cp; 7420 + return TCL_OK; 7421 + } 7422 + return TCL_ERROR; 7423 +} 7424 + 7425 +static int 7426 +splitWhitespaceImpl ( 7427 + Tcl_Interp *interp, 7428 + void *constraintData, 7429 + char *text 7430 + ) 7431 +{ 7432 + SchemaCP *cp = (SchemaCP *) constraintData; 7433 + int rc = 0; 7434 + char *p, *end, saved = 0; 7435 + 7436 + p = text; 7437 + while (*p != 0) { 7438 + while(SPACE (*p)) p++; 7439 + if (*p == 0) break; 7440 + end = p; end++; 7441 + while (*end != 0 && !SPACE(*end)) end++; 7442 + saved = *end; 7443 + *end = 0; 7444 + rc = checkText (interp, cp, p); 7445 + *end = saved; 7446 + p = end; 7447 + if (!rc) break; 7448 + } 7449 + return rc; 7450 +} 7451 + 7452 +typedef struct 7453 +{ 7454 + int nrArg; 7455 + Tcl_Obj **evalStub; 7456 + SchemaData *sdata; 7457 + SchemaCP *cp; 7458 +} splitTclTCData; 7459 + 7460 + 7461 +static int 7462 +splitTclImpl ( 7463 + Tcl_Interp *interp, 7464 + void *constraintData, 7465 + char *text 7466 + ) 7467 +{ 7468 + splitTclTCData *tcdata = (splitTclTCData *) constraintData; 7469 + int rc, listlen, i; 7470 + Tcl_Obj *list, *listelm; 7471 + 7472 + tcdata->evalStub[tcdata->nrArg-1] = Tcl_NewStringObj(text, -1); 7473 + Tcl_IncrRefCount (tcdata->evalStub[tcdata->nrArg-1]); 7474 + tcdata->sdata->currentEvals++; 7475 + rc = Tcl_EvalObjv (interp, tcdata->nrArg, tcdata->evalStub, 7476 + TCL_EVAL_GLOBAL); 7477 + tcdata->sdata->currentEvals--; 7478 + Tcl_DecrRefCount (tcdata->evalStub[tcdata->nrArg-1]); 7479 + if (rc != TCL_OK) { 7480 + tcdata->sdata->evalError = 1; 7481 + return 0; 7482 + } 7483 + list = Tcl_GetObjResult (interp); 7484 + Tcl_IncrRefCount (list); 7485 + Tcl_ResetResult (interp); 7486 + if (Tcl_ListObjLength (interp, list, &listlen) != TCL_OK) { 7487 + Tcl_DecrRefCount (list); 7488 + tcdata->sdata->evalError = 1; 7489 + return 0; 7490 + } 7491 + rc = 0; 7492 + for (i = 0; i < listlen; i++) { 7493 + Tcl_ListObjIndex (interp, list, i, &listelm); 7494 + rc = checkText (interp, tcdata->cp, Tcl_GetString (listelm)); 7495 + if (!rc) break; 7496 + } 7497 + Tcl_DecrRefCount (list); 7498 + return rc; 7499 +} 7500 + 7501 +static void 7502 +splitTclImplFree ( 7503 + void *constraintData 7504 + ) 7505 +{ 7506 + splitTclTCData *tcdata = constraintData; 7507 + int i; 7508 + 7509 + for (i = 0; i < tcdata->nrArg-1; i++) { 7510 + Tcl_DecrRefCount (tcdata->evalStub[i]); 7511 + } 7512 + FREE (tcdata->evalStub); 7513 + FREE (tcdata); 7514 +} 7515 + 7516 +static int 7517 +splitTCObjCmd ( 7518 + ClientData clientData, 7519 + Tcl_Interp *interp, 7520 + int objc, 7521 + Tcl_Obj *const objv[] 7522 + ) 7523 +{ 7524 + SchemaData *sdata = GETASI; 7525 + SchemaCP *cp; 7526 + SchemaConstraint *sc; 7527 + int methodIndex, rc, i; 7528 + splitTclTCData *tcdata; 7529 + 7530 + static const char *methods[] = { 7531 + "whitespace", "tcl", NULL 7532 + }; 7533 + enum method { 7534 + m_whitespace, m_tcl 7535 + }; 7536 + 7537 + CHECK_TI 7538 + if (objc < 2) { 7539 + SetResult("Expected: ?type ?args?? <text constraint script>"); 7540 + return TCL_ERROR; 7541 + } 7542 + 7543 + if (objc == 2) { 7544 + methodIndex = m_whitespace; 7545 + } else { 7546 + if (Tcl_GetIndexFromObj (interp, objv[1], methods, "type", 0, 7547 + &methodIndex) != TCL_OK) { 7548 + return TCL_ERROR; 7549 + } 7550 + } 7551 + switch ((enum method) methodIndex) { 7552 + case m_whitespace: 7553 + if (objc > 2) { 7554 + SetResult ("Type whitespace expects no argument."); 7555 + return TCL_ERROR; 7556 + } 7557 + break; 7558 + case m_tcl: 7559 + if (objc < 3) { 7560 + SetResult ("Expected: tclcmd ?arg ...?."); 7561 + return TCL_ERROR; 7562 + } 7563 + } 7564 + 7565 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 7566 + cp->type = SCHEMA_CTYPE_TEXT; 7567 + REMEMBER_PATTERN (cp) 7568 + rc = evalConstraints (interp, sdata, cp, objv[objc-1]); 7569 + if (rc != TCL_OK) { 7570 + return TCL_ERROR; 7571 + } 7572 + ADD_CONSTRAINT (sdata, sc) 7573 + switch ((enum method) methodIndex) { 7574 + case m_whitespace: 7575 + sc->constraint = splitWhitespaceImpl; 7576 + sc->constraintData = cp; 7577 + break; 7578 + case m_tcl: 7579 + sc->constraint = splitTclImpl; 7580 + sc->freeData = splitTclImplFree; 7581 + tcdata = TMALLOC (splitTclTCData); 7582 + tcdata->nrArg = objc - 2; 7583 + tcdata->evalStub = MALLOC (sizeof (Tcl_Obj*) * (objc-2)); 7584 + for (i = 2; i < objc -1; i++) { 7585 + tcdata->evalStub[i-2] = objv[i]; 7586 + Tcl_IncrRefCount (tcdata->evalStub[i-2]); 7587 + } 7588 + tcdata->sdata = sdata; 7589 + tcdata->cp = cp; 7590 + sc->constraintData = tcdata; 7591 + } 7592 + return TCL_OK; 7593 +} 7594 + 7595 +static int 7596 +idImpl ( 7597 + Tcl_Interp *interp, 7598 + void *constraintData, 7599 + char *text 7600 + ) 7601 +{ 7602 + SchemaData *sdata = (SchemaData *) constraintData; 7603 + int hnew; 7604 + Tcl_HashEntry *h; 7605 + 7606 + h = Tcl_CreateHashEntry (&sdata->ids, text, &hnew); 7607 + if (hnew) { 7608 + Tcl_SetHashValue (h, 1); 7609 + return 1; 7610 + } 7611 + if (Tcl_GetHashValue (h) == 0) { 7612 + Tcl_SetHashValue (h, 1); 7613 + sdata->unknownIDrefs--; 7614 + return 1; 7615 + } else { 7616 + /* Duplicate ID value */ 7617 + return 0; 7618 + } 7619 +} 7620 + 7621 +static int 7622 +docidImpl ( 7623 + Tcl_Interp *interp, 7624 + void *constraintData, 7625 + char *text 7626 + ) 7627 +{ 7628 + SchemaDocKey *dk = (SchemaDocKey *) constraintData; 7629 + int hnew; 7630 + Tcl_HashEntry *h; 7631 + 7632 + h = Tcl_CreateHashEntry (&dk->ids, text, &hnew); 7633 + if (hnew) { 7634 + Tcl_SetHashValue (h, 1); 7635 + return 1; 7636 + } 7637 + if (Tcl_GetHashValue (h) == 0) { 7638 + Tcl_SetHashValue (h, 1); 7639 + dk->unknownIDrefs--; 7640 + return 1; 7641 + } 7642 + /* Duplicate ID value */ 7643 + return 0; 7644 +} 7645 + 7646 +static int 7647 +idTCObjCmd ( 7648 + ClientData clientData, 7649 + Tcl_Interp *interp, 7650 + int objc, 7651 + Tcl_Obj *const objv[] 7652 + ) 7653 +{ 7654 + SchemaData *sdata = GETASI; 7655 + SchemaConstraint *sc; 7656 + Tcl_HashEntry *h; 7657 + int hnew; 7658 + SchemaDocKey *dk; 7659 + 7660 + CHECK_TI 7661 + checkNrArgs (1,2,"?key_space?"); 7662 + ADD_CONSTRAINT (sdata, sc) 7663 + if (objc == 1) { 7664 + sc->constraint = idImpl; 7665 + sc->constraintData = (void *)sdata; 7666 + } else { 7667 + h = Tcl_CreateHashEntry (&sdata->idTables, Tcl_GetString (objv[1]), 7668 + &hnew); 7669 + if (hnew) { 7670 + dk = TMALLOC (SchemaDocKey); 7671 + Tcl_InitHashTable (&dk->ids, TCL_STRING_KEYS); 7672 + dk->unknownIDrefs = 0; 7673 + Tcl_SetHashValue (h, dk); 7674 + } else { 7675 + dk = Tcl_GetHashValue (h); 7676 + } 7677 + sc->constraint = docidImpl; 7678 + sc->constraintData = (void *)dk; 7679 + } 7680 + return TCL_OK; 7681 +} 7682 + 7683 +static int 7684 +idrefImpl ( 7685 + Tcl_Interp *interp, 7686 + void *constraintData, 7687 + char *text 7688 + ) 7689 +{ 7690 + SchemaData *sdata = (SchemaData *) constraintData; 7691 + int hnew; 7692 + Tcl_HashEntry *h; 7693 + 7694 + h = Tcl_CreateHashEntry (&sdata->ids, text, &hnew); 7695 + if (hnew) { 7696 + Tcl_SetHashValue (h, 0); 7697 + sdata->unknownIDrefs++; 7698 + } 7699 + return 1; 7700 +} 7701 + 7702 +static int 7703 +docidrefImpl ( 7704 + Tcl_Interp *interp, 7705 + void *constraintData, 7706 + char *text 7707 + ) 7708 +{ 7709 + SchemaDocKey *dk = (SchemaDocKey *) constraintData; 7710 + int hnew; 7711 + Tcl_HashEntry *h; 7712 + 7713 + h = Tcl_CreateHashEntry (&dk->ids, text, &hnew); 7714 + if (hnew) { 7715 + Tcl_SetHashValue (h, 0); 7716 + dk->unknownIDrefs++; 7717 + } 7718 + return 1; 7719 +} 7720 + 7721 +static int 7722 +idrefTCObjCmd ( 7723 + ClientData clientData, 7724 + Tcl_Interp *interp, 7725 + int objc, 7726 + Tcl_Obj *const objv[] 7727 + ) 7728 +{ 7729 + SchemaData *sdata = GETASI; 7730 + SchemaConstraint *sc; 7731 + Tcl_HashEntry *h; 7732 + int hnew; 7733 + SchemaDocKey *dk; 7734 + 7735 + CHECK_TI 7736 + checkNrArgs (1,2,"?key_space?"); 7737 + ADD_CONSTRAINT (sdata, sc) 7738 + if (objc == 1) { 7739 + sc->constraint = idrefImpl; 7740 + sc->constraintData = (void *)sdata; 7741 + } else { 7742 + h = Tcl_CreateHashEntry (&sdata->idTables, Tcl_GetString (objv[1]), 7743 + &hnew); 7744 + if (hnew) { 7745 + dk = TMALLOC (SchemaDocKey); 7746 + Tcl_InitHashTable (&dk->ids, TCL_STRING_KEYS); 7747 + dk->unknownIDrefs = 0; 7748 + Tcl_SetHashValue (h, dk); 7749 + } else { 7750 + dk = Tcl_GetHashValue (h); 7751 + } 7752 + sc->constraint = docidrefImpl; 7753 + sc->constraintData = (void *)dk; 7754 + } 7755 + return TCL_OK; 7756 +} 7757 + 7758 +static int 7759 +keyImpl ( 7760 + Tcl_Interp *interp, 7761 + void *constraintData, 7762 + char *text 7763 + ) 7764 +{ 7765 + SchemaKeySpace *ks = (SchemaKeySpace *) constraintData; 7766 + int hnew; 7767 + Tcl_HashEntry *h; 7768 + 7769 + if (!ks->active) return 1; 7770 + h = Tcl_CreateHashEntry (&ks->ids, text, &hnew); 7771 + if (hnew) { 7772 + Tcl_SetHashValue (h, 1); 7773 + return 1; 7774 + } 7775 + if (Tcl_GetHashValue (h) == 0) { 7776 + Tcl_SetHashValue (h, 1); 7777 + ks->unknownIDrefs--; 7778 + return 1; 7779 + } else { 7780 + /* Duplicate ID value */ 7781 + return 0; 7782 + } 7783 +} 7784 + 7785 +static int 7786 +keyTCObjCmd ( 7787 + ClientData clientData, 7788 + Tcl_Interp *interp, 7789 + int objc, 7790 + Tcl_Obj *const objv[] 7791 + ) 7792 +{ 7793 + SchemaData *sdata = GETASI; 7794 + SchemaConstraint *sc; 7795 + Tcl_HashEntry *h; 7796 + int hnew; 7797 + SchemaKeySpace *ks; 7798 + 7799 + CHECK_TI 7800 + checkNrArgs (2,2,"key_space"); 7801 + ADD_CONSTRAINT (sdata, sc) 7802 + h = Tcl_CreateHashEntry (&sdata->keySpaces, Tcl_GetString (objv[1]), &hnew); 7803 + if (hnew) { 7804 + ks = TMALLOC (SchemaKeySpace); 7805 + ks->active = 0; 7806 + ks->unknownIDrefs = 0; 7807 + Tcl_SetHashValue (h, ks); 7808 + } else { 7809 + ks = Tcl_GetHashValue (h); 7810 + } 7811 + sc->constraint = keyImpl; 7812 + sc->constraintData = (void *) ks; 7813 + return TCL_OK; 7814 +} 7815 + 7816 +static int 7817 +keyrefImpl ( 7818 + Tcl_Interp *interp, 7819 + void *constraintData, 7820 + char *text 7821 + ) 7822 +{ 7823 + SchemaKeySpace *ks = (SchemaKeySpace *) constraintData; 7824 + int hnew; 7825 + Tcl_HashEntry *h; 7826 + 7827 + if (!ks->active) return 1; 7828 + h = Tcl_CreateHashEntry (&ks->ids, text, &hnew); 7829 + if (hnew) { 7830 + Tcl_SetHashValue (h, 0); 7831 + ks->unknownIDrefs++; 7832 + } 7833 + return 1; 7834 +} 7835 + 7836 +static int 7837 +keyrefTCObjCmd ( 7838 + ClientData clientData, 7839 + Tcl_Interp *interp, 7840 + int objc, 7841 + Tcl_Obj *const objv[] 7842 + ) 7843 +{ 7844 + SchemaData *sdata = GETASI; 7845 + SchemaConstraint *sc; 7846 + Tcl_HashEntry *h; 7847 + int hnew; 7848 + SchemaKeySpace *ks; 7849 + 7850 + CHECK_TI 7851 + checkNrArgs (2,2,"key_space"); 7852 + ADD_CONSTRAINT (sdata, sc) 7853 + h = Tcl_CreateHashEntry (&sdata->keySpaces, Tcl_GetString (objv[1]), 7854 + &hnew); 7855 + if (hnew) { 7856 + ks = TMALLOC (SchemaKeySpace); 7857 + Tcl_InitHashTable (&ks->ids, TCL_STRING_KEYS); 7858 + ks->unknownIDrefs = 0; 7859 + Tcl_SetHashValue (h, ks); 7860 + } else { 7861 + ks = Tcl_GetHashValue (h); 7862 + } 7863 + sc->constraint = keyrefImpl; 7864 + sc->constraintData = (void *)ks; 7865 + return TCL_OK; 7866 +} 7867 + 7868 +static int 7869 +base64Impl ( 7870 + Tcl_Interp *interp, 7871 + void *constraintData, 7872 + char *text 7873 + ) 7874 +{ 7875 + int chars = 0, equals = 0; 7876 + 7877 + while (*text != '\0') { 7878 + if (SPACE(*text)) { 7879 + text++; 7880 + continue; 7881 + } 7882 + if ( (*text >= 'A' && *text <= 'Z') 7883 + || (*text >= 'a' && *text <= 'z') 7884 + || (*text >= '0' && *text <= '9') 7885 + || (*text = '+') 7886 + || (*text = '/')) { 7887 + chars++; 7888 + text++; 7889 + continue; 7890 + } 7891 + if (equals < 2 && *text == '=') { 7892 + equals++; 7893 + text++; 7894 + continue; 7895 + } 7896 + break; 7897 + } 7898 + if (*text) { 7899 + return 0; 7900 + } 7901 + if ((chars + equals) % 4 != 0) { 7902 + return 0; 7903 + } 7904 + return 1; 7905 +} 7906 + 7907 +static int 7908 +base64TCObjCmd ( 7909 + ClientData clientData, 7910 + Tcl_Interp *interp, 7911 + int objc, 7912 + Tcl_Obj *const objv[] 7913 + ) 7914 +{ 7915 + SchemaData *sdata = GETASI; 7916 + SchemaConstraint *sc; 7917 + 7918 + CHECK_TI 7919 + checkNrArgs (1,1,"No arguments expected"); 7920 + ADD_CONSTRAINT (sdata, sc) 7921 + sc->constraint = base64Impl; 7922 + return TCL_OK; 7923 +} 7924 + 7925 +static int 7926 +nameImpl ( 7927 + Tcl_Interp *interp, 7928 + void *constraintData, 7929 + char *text 7930 + ) 7931 +{ 7932 + return domIsNAME (text); 7933 +} 7934 + 7935 +static int 7936 +nameTCObjCmd ( 7937 + ClientData clientData, 7938 + Tcl_Interp *interp, 7939 + int objc, 7940 + Tcl_Obj *const objv[] 7941 + ) 7942 +{ 7943 + SchemaData *sdata = GETASI; 7944 + SchemaConstraint *sc; 7945 + 7946 + CHECK_TI 7947 + checkNrArgs (1,1,"No arguments expected"); 7948 + ADD_CONSTRAINT (sdata, sc) 7949 + sc->constraint = nameImpl; 7950 + return TCL_OK; 7951 +} 7952 + 7953 +static int 7954 +ncnameImpl ( 7955 + Tcl_Interp *interp, 7956 + void *constraintData, 7957 + char *text 7958 + ) 7959 +{ 7960 + return domIsNCNAME (text); 7961 +} 7962 + 7963 +static int 7964 +ncnameTCObjCmd ( 7965 + ClientData clientData, 7966 + Tcl_Interp *interp, 7967 + int objc, 7968 + Tcl_Obj *const objv[] 7969 + ) 7970 +{ 7971 + SchemaData *sdata = GETASI; 7972 + SchemaConstraint *sc; 7973 + 7974 + CHECK_TI 7975 + checkNrArgs (1,1,"No arguments expected"); 7976 + ADD_CONSTRAINT (sdata, sc) 7977 + sc->constraint = ncnameImpl; 7978 + return TCL_OK; 7979 +} 7980 + 7981 +static int 7982 +qnameImpl ( 7983 + Tcl_Interp *interp, 7984 + void *constraintData, 7985 + char *text 7986 + ) 7987 +{ 7988 + return domIsQNAME (text); 7989 +} 7990 + 7991 +static int 7992 +qnameTCObjCmd ( 7993 + ClientData clientData, 7994 + Tcl_Interp *interp, 7995 + int objc, 7996 + Tcl_Obj *const objv[] 7997 + ) 7998 +{ 7999 + SchemaData *sdata = GETASI; 8000 + SchemaConstraint *sc; 8001 + 8002 + CHECK_TI 8003 + checkNrArgs (1,1,"No arguments expected"); 8004 + ADD_CONSTRAINT (sdata, sc) 8005 + sc->constraint = qnameImpl; 8006 + return TCL_OK; 8007 +} 8008 + 8009 +static int 8010 +hexBinaryImpl ( 8011 + Tcl_Interp *interp, 8012 + void *constraintData, 8013 + char *text 8014 + ) 8015 +{ 8016 + int count = 0; 8017 + 8018 + if (*text == 0) return 0; 8019 + while (*text) { 8020 + if ((*text >= '0' && *text <= '9') 8021 + || (*text >= 'A' && *text <= 'F') 8022 + || (*text >= 'a' && *text <= 'f')) { 8023 + text++; 8024 + count++; 8025 + } else return 0; 8026 + } 8027 + if (count % 2 == 0) return 1; 8028 + return 0; 8029 +} 8030 + 8031 +static int 8032 +hexBinaryTCObjCmd ( 8033 + ClientData clientData, 8034 + Tcl_Interp *interp, 8035 + int objc, 8036 + Tcl_Obj *const objv[] 8037 + ) 8038 +{ 8039 + SchemaData *sdata = GETASI; 8040 + SchemaConstraint *sc; 8041 + 8042 + CHECK_TI 8043 + checkNrArgs (1,1,"No arguments expected"); 8044 + ADD_CONSTRAINT (sdata, sc) 8045 + sc->constraint = hexBinaryImpl; 8046 + return TCL_OK; 8047 +} 8048 + 8049 +static int 8050 +unsignedIntTypesImpl ( 8051 + Tcl_Interp *interp, 8052 + void *constraintData, 8053 + char *text 8054 + ) 8055 +{ 8056 + char *c; 8057 + int count = 0; 8058 + int nrDigits[] = {3, 5, 10, 20}; 8059 + char *max[] = { 8060 + "255", 8061 + "65535", 8062 + "4294967295", 8063 + "18446744073709551615" 8064 + }; 8065 + 8066 + if (*text == '+') text++; 8067 + if (*text == 0) return 0; 8068 + if (*text == '0') { 8069 + text++; 8070 + while (*text == '0') text++; 8071 + if (*text == 0) return 1; 8072 + } 8073 + c = text; 8074 + while (*text) { 8075 + if (*text >= '0' && *text <= '9') { 8076 + text++; 8077 + count++; 8078 + } else return 0; 8079 + } 8080 + if (count < nrDigits[(intptr_t) constraintData]) return 1; 8081 + if (count == nrDigits[(intptr_t) constraintData]) { 8082 + if (strcmp (max[(intptr_t) constraintData], c) >= 0) { 8083 + return 1; 8084 + } 8085 + } 8086 + return 0; 8087 +} 8088 + 8089 +static int 8090 +unsignedIntTypesTCObjCmd ( 8091 + ClientData clientData, 8092 + Tcl_Interp *interp, 8093 + int objc, 8094 + Tcl_Obj *const objv[] 8095 + ) 8096 +{ 8097 + SchemaData *sdata = GETASI; 8098 + SchemaConstraint *sc; 8099 + 8100 + CHECK_TI 8101 + checkNrArgs (1,1,"No arguments expected"); 8102 + ADD_CONSTRAINT (sdata, sc) 8103 + sc->constraint = unsignedIntTypesImpl; 8104 + sc->constraintData = clientData; 8105 + return TCL_OK; 8106 +} 8107 + 8108 +static void 8109 +setvarImplFree ( 8110 + void *constraintData 8111 + ) 8112 +{ 8113 + FREE (constraintData); 8114 +} 8115 + 8116 +static int 8117 +setvarImpl ( 8118 + Tcl_Interp *interp, 8119 + void *constraintData, 8120 + char *text 8121 + ) 8122 +{ 8123 + char *varName = (char *)constraintData; 8124 + 8125 + if (!Tcl_SetVar (interp, varName, text, TCL_LEAVE_ERR_MSG)) { 8126 + return 0; 8127 + } 8128 + return 1; 8129 +} 8130 + 8131 +static int 8132 +setvarTCObjCmd ( 8133 + ClientData clientData, 8134 + Tcl_Interp *interp, 8135 + int objc, 8136 + Tcl_Obj *const objv[] 8137 + ) 8138 +{ 8139 + SchemaData *sdata = GETASI; 8140 + SchemaConstraint *sc; 8141 + 8142 + CHECK_TI 8143 + checkNrArgs (2,2,"<tcl variable name>"); 8144 + ADD_CONSTRAINT (sdata, sc) 8145 + sc->constraint = setvarImpl; 8146 + sc->freeData = setvarImplFree; 8147 + sc->constraintData = tdomstrdup (Tcl_GetString (objv[1])); 8148 + return TCL_OK; 8149 +} 8150 + 8151 +typedef struct 8152 +{ 8153 + SchemaCP *cp; 8154 + SchemaData *sdata; 8155 +} WhitespaceTCData; 8156 + 8157 +static void 8158 +whitespaceImplFree ( 8159 + void *constraintData 8160 + ) 8161 +{ 8162 + WhitespaceTCData *wsdata = (WhitespaceTCData *) constraintData; 8163 + 8164 + FREE (wsdata); 8165 +} 8166 + 8167 +static int 8168 +whitespaceImplReplace ( 8169 + Tcl_Interp *interp, 8170 + void *constraintData, 8171 + char *text 8172 + ) 8173 +{ 8174 + WhitespaceTCData *wsdata = (WhitespaceTCData *) constraintData; 8175 + char *p, *c, *alloced; 8176 + SchemaData *sdata; 8177 + 8178 + sdata = wsdata->sdata; 8179 + p = text; 8180 + c = sdata->wsbuf; 8181 + alloced = sdata->wsbuf + sdata->wsbufLen; 8182 + while (*p) { 8183 + if (*p == '\t' || *p == '\n' || *p == '\r') { 8184 + *c = ' '; 8185 + } else { 8186 + *c = *p; 8187 + } 8188 + c++; 8189 + if (c == alloced) { 8190 + sdata->wsbuf = REALLOC (sdata->wsbuf, 2 * sdata->wsbufLen); 8191 + c = sdata->wsbuf + sdata->wsbufLen; 8192 + sdata->wsbufLen *= 2; 8193 + alloced = sdata->wsbuf + sdata->wsbufLen; 8194 + } 8195 + p++; 8196 + } 8197 + *c = '\0'; 8198 + return checkText (interp, wsdata->cp, sdata->wsbuf); 8199 +} 8200 + 8201 +static int 8202 +whitespaceImplCollapse ( 8203 + Tcl_Interp *interp, 8204 + void *constraintData, 8205 + char *text 8206 + ) 8207 +{ 8208 + WhitespaceTCData *wsdata = (WhitespaceTCData *) constraintData; 8209 + char *p, *c, *alloced; 8210 + SchemaData *sdata; 8211 + 8212 + sdata = wsdata->sdata; 8213 + p = text; 8214 + c = sdata->wsbuf; 8215 + alloced = sdata->wsbuf + sdata->wsbufLen; 8216 + while (SPACE(*p)) p++; 8217 + while (*p) { 8218 + if (SPACE (*p)) { 8219 + *c = ' '; 8220 + c++; 8221 + if (c == alloced) { 8222 + sdata->wsbuf = REALLOC (sdata->wsbuf, 2 * sdata->wsbufLen); 8223 + c = sdata->wsbuf + sdata->wsbufLen; 8224 + sdata->wsbufLen *= 2; 8225 + alloced = sdata->wsbuf + sdata->wsbufLen; 8226 + } 8227 + p++; 8228 + while (SPACE (*p)) p++; 8229 + if (!*p) c--; 8230 + } else { 8231 + *c = *p; 8232 + c++; 8233 + if (c == alloced) { 8234 + sdata->wsbuf = REALLOC (sdata->wsbuf, 2 * sdata->wsbufLen); 8235 + c = sdata->wsbuf + sdata->wsbufLen; 8236 + sdata->wsbufLen *= 2; 8237 + alloced = sdata->wsbuf + sdata->wsbufLen; 8238 + } 8239 + p++; 8240 + } 8241 + } 8242 + *c = '\0'; 8243 + return checkText (interp, wsdata->cp, wsdata->sdata->wsbuf); 8244 +} 8245 + 8246 +static int 8247 +whitespaceTCObjCmd ( 8248 + ClientData clientData, 8249 + Tcl_Interp *interp, 8250 + int objc, 8251 + Tcl_Obj *const objv[] 8252 + ) 8253 +{ 8254 + SchemaData *sdata = GETASI; 8255 + SchemaCP *cp; 8256 + SchemaConstraint *sc; 8257 + int type; 8258 + WhitespaceTCData *wsdata; 8259 + 8260 + static const char *types[] = { 8261 + "preserve", "replace", "collapse", NULL 8262 + }; 8263 + enum typeSyms { 8264 + t_preserve, t_replace, t_collapse 8265 + }; 8266 + 8267 + CHECK_TI 8268 + checkNrArgs (3,3,"(\"preserve\"|\"replace\"|\"collapse\") " 8269 + "<text constraint script>"); 8270 + if (Tcl_GetIndexFromObj (interp, objv[1], types, "type", 0, &type) 8271 + != TCL_OK) { 8272 + return TCL_ERROR; 8273 + } 8274 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 8275 + cp->type = SCHEMA_CTYPE_TEXT; 8276 + REMEMBER_PATTERN (cp) 8277 + if (evalConstraints (interp, sdata, cp, objv[2]) != TCL_OK) { 8278 + return TCL_ERROR; 8279 + } 8280 + if (type == t_preserve) { 8281 + ADD_CONSTRAINT (sdata, sc) 8282 + sc->constraint = checkText; 8283 + sc->constraintData = (void *)cp; 8284 + return TCL_OK; 8285 + } 8286 + ADD_CONSTRAINT (sdata, sc) 8287 + sc->freeData = whitespaceImplFree; 8288 + if (sdata->wsbufLen == 0) { 8289 + sdata->wsbuf = (char *) MALLOC (WHITESPACETC_BUFFER_LEN_INIT); 8290 + sdata->wsbufLen = WHITESPACETC_BUFFER_LEN_INIT; 8291 + } 8292 + wsdata = TMALLOC (WhitespaceTCData); 8293 + wsdata->sdata = sdata; 8294 + wsdata->cp = cp; 8295 + sc->constraintData = (void *)wsdata; 8296 + if (type == t_replace) { 8297 + sc->constraint = whitespaceImplReplace; 8298 + } else { 8299 + sc->constraint = whitespaceImplCollapse; 8300 + } 8301 + return TCL_OK; 8302 +} 8303 + 8304 +static int 8305 +notImpl ( 8306 + Tcl_Interp *interp, 8307 + void *constraintData, 8308 + char *text 8309 + ) 8310 +{ 8311 + SchemaCP *cp = (SchemaCP *) constraintData; 8312 + SchemaConstraint *sc; 8313 + int i; 8314 + 8315 + /* Look also at checkText and oneOfImpl */ 8316 + for (i = 0; i < cp->nc; i++) { 8317 + sc = (SchemaConstraint *) cp->content[i]; 8318 + if ((sc->constraint) (interp, sc->constraintData, text)) { 8319 + return 0; 8320 + } 8321 + } 8322 + return 1; 8323 +} 8324 + 8325 +static int 8326 +notTCObjCmd ( 8327 + ClientData clientData, 8328 + Tcl_Interp *interp, 8329 + int objc, 8330 + Tcl_Obj *const objv[] 8331 + ) 8332 +{ 8333 + SchemaData *sdata = GETASI; 8334 + SchemaCP *cp; 8335 + SchemaConstraint *sc; 8336 + int rc; 8337 + 8338 + CHECK_TI 8339 + checkNrArgs (2,2,"Expected: <text constraint script>"); 8340 + 8341 + cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); 8342 + cp->type = SCHEMA_CTYPE_TEXT; 8343 + REMEMBER_PATTERN (cp) 8344 + rc = evalConstraints (interp, sdata, cp, objv[1]); 8345 + if (rc == TCL_OK) { 8346 + ADD_CONSTRAINT (sdata, sc) 8347 + sc->constraint = notImpl; 8348 + sc->constraintData = (void *)cp; 8349 + return TCL_OK; 8350 + } 8351 + return TCL_ERROR; 8352 +} 8353 + 8354 +static int 8355 +durationImpl ( 8356 + Tcl_Interp *interp, 8357 + void *constraintData, 8358 + char *text 8359 + ) 8360 +{ 8361 + /* PnYnMnDTnHnMnS */ 8362 + int p, n, seen = 0, seenT = 0; 8363 + char des[9] = " YMDTHMS"; 8364 + 8365 + if (*text == '-') { 8366 + /* Negative duration is allowed */ 8367 + text++; 8368 + } 8369 + if (*text != 'P') return 0; 8370 + text++; 8371 + p = 0; 8372 + while (*text) { 8373 + n = 0; 8374 + while (*text >= '0' && *text <= '9') { 8375 + n++; 8376 + text++; 8377 + } 8378 + if (!*text) return 0; 8379 + if (*text == '.') { 8380 + if (p < 4 || !n) return 0; 8381 + text++; 8382 + if (!*text) return 0; 8383 + /* Ensure at least one digit after . */ 8384 + if (*text < '0' || *text > '9') return 0; 8385 + text++; 8386 + while (*text >= '0' && *text <= '9') text++; 8387 + if (*text != 'S') return 0; 8388 + text++; 8389 + if (*text) return 0; 8390 + return 1; 8391 + } 8392 + for (; p < 8; p++) { 8393 + if (*text == des[p]) break; 8394 + } 8395 + if (p == 4) { 8396 + if (n) return 0; 8397 + seenT = 1; 8398 + text++; 8399 + if (!*text) return 0; 8400 + continue; 8401 + } else { 8402 + if (!n) return 0; 8403 + seen = 1; 8404 + } 8405 + if (p > 4 && !seenT) return 0; 8406 + if (p == 8 || !seen) return 0; 8407 + text++; 8408 + } 8409 + if (!p) return 0; 8410 + return 1; 8411 +} 8412 + 8413 +static int 8414 +durationTCObjCmd ( 8415 + ClientData clientData, 8416 + Tcl_Interp *interp, 8417 + int objc, 8418 + Tcl_Obj *const objv[] 8419 + ) 8420 +{ 8421 + SchemaData *sdata = GETASI; 8422 + SchemaConstraint *sc; 8423 + 8424 + CHECK_TI 8425 + checkNrArgs (1,1,"No arguments expected"); 8426 + ADD_CONSTRAINT (sdata, sc) 8427 + sc->constraint = durationImpl; 8428 + return TCL_OK; 8429 +} 8430 + 8431 +static int 8432 +lengthImpl ( 8433 + Tcl_Interp *interp, 8434 + void *constraintData, 8435 + char *text 8436 + ) 8437 +{ 8438 + unsigned int length = PTR2UINT(constraintData); 8439 + int len = 0, clen; 8440 + while (*text != '\0') { 8441 + clen = UTF8_CHAR_LEN (*text); 8442 + if (!clen) { 8443 + SetResult ("Invalid UTF-8 character"); 8444 + return 0; 8445 + } 8446 + len++; 8447 + if (len > length) return 0; 8448 + text += clen; 8449 + } 8450 + if (len == length) return 1; 8451 + return 0; 8452 +} 8453 + 8454 +static int 8455 +lengthTCObjCmd ( 8456 + ClientData clientData, 8457 + Tcl_Interp *interp, 8458 + int objc, 8459 + Tcl_Obj *const objv[] 8460 + ) 8461 +{ 8462 + SchemaData *sdata = GETASI; 8463 + SchemaConstraint *sc; 8464 + int len; 8465 + 8466 + CHECK_TI 8467 + checkNrArgs (2,2,"Expected: <length as integer>"); 8468 + if (Tcl_GetIntFromObj (interp, objv[1], &len) != TCL_OK) { 8469 + SetResult ("Expected: <length as integer>"); 8470 + return TCL_ERROR; 8471 + } 8472 + if (len < 0) { 8473 + SetResult ("The length must be at least 0"); 8474 + } 8475 + ADD_CONSTRAINT (sdata, sc) 8476 + sc->constraint = lengthImpl; 8477 + sc->constraintData = UINT2PTR(len); 8478 + return TCL_OK; 8479 +} 8480 + 8481 +static int 8482 +dateObjCmd ( 8483 + ClientData clientData, 8484 + Tcl_Interp *interp, 8485 + int objc, 8486 + Tcl_Obj *const objv[] 8487 + ) 8488 +{ 8489 + checkNrArgs (2,2,"<text>"); 8490 + Tcl_SetObjResult (interp, 8491 + Tcl_NewBooleanObj ( 8492 + isodateImpl (interp, NULL, 8493 + Tcl_GetString (objv[1])))); 8494 + return TCL_OK; 8495 +} 8496 + 8497 +static int 8498 +dateTimeObjCmd ( 8499 + ClientData clientData, 8500 + Tcl_Interp *interp, 8501 + int objc, 8502 + Tcl_Obj *const objv[] 8503 + ) 8504 +{ 8505 + checkNrArgs (2,2,"<text>"); 8506 + Tcl_SetObjResult (interp, 8507 + Tcl_NewBooleanObj ( 8508 + isodateImpl (interp, (void *) 1, 8509 + Tcl_GetString (objv[1])))); 8510 + return TCL_OK; 8511 +} 8512 + 8513 +static int 8514 +timeObjCmd ( 8515 + ClientData clientData, 8516 + Tcl_Interp *interp, 8517 + int objc, 8518 + Tcl_Obj *const objv[] 8519 + ) 8520 +{ 8521 + checkNrArgs (2,2,"<text>"); 8522 + Tcl_SetObjResult (interp, 8523 + Tcl_NewBooleanObj ( 8524 + isodateImpl (interp, (void *) 2, 8525 + Tcl_GetString (objv[1])))); 8526 + return TCL_OK; 8527 +} 8528 + 8529 +static int 8530 +durationObjCmd ( 8531 + ClientData clientData, 8532 + Tcl_Interp *interp, 8533 + int objc, 8534 + Tcl_Obj *const objv[] 8535 + ) 8536 +{ 8537 + checkNrArgs (2,2,"<text>"); 8538 + Tcl_SetObjResult (interp, 8539 + Tcl_NewBooleanObj ( 8540 + durationImpl (interp, NULL, 8541 + Tcl_GetString (objv[1])))); 8542 + return TCL_OK; 8543 +} 8544 + 8545 +void 8546 +tDOM_SchemaInit ( 8547 + Tcl_Interp *interp 8548 + ) 8549 +{ 8550 + Tcl_CreateObjCommand (interp, "tdom::schema", tDOM_SchemaObjCmd, 8551 + NULL, NULL); 8552 + 8553 + /* Inline definition commands. */ 8554 + Tcl_CreateObjCommand (interp, "tdom::schema::defelement", 8555 + tDOM_schemaInstanceCmd, NULL, NULL); 8556 + Tcl_CreateObjCommand (interp, "tdom::schema::defelementtype", 8557 + tDOM_schemaInstanceCmd, NULL, NULL); 8558 + Tcl_CreateObjCommand (interp, "tdom::schema::defpattern", 8559 + tDOM_schemaInstanceCmd, NULL, NULL); 8560 + Tcl_CreateObjCommand (interp, "tdom::schema::deftexttype", 8561 + tDOM_schemaInstanceCmd, NULL, NULL); 8562 + Tcl_CreateObjCommand (interp, "tdom::schema::start", 8563 + tDOM_schemaInstanceCmd, NULL, NULL); 8564 + Tcl_CreateObjCommand (interp, "tdom::schema::prefixns", 8565 + tDOM_schemaInstanceCmd, NULL, NULL); 8566 + 8567 + /* The "any" definition command. */ 8568 + Tcl_CreateObjCommand (interp, "tdom::schema::any", 8569 + AnyPatternObjCmd, NULL, NULL); 8570 + 8571 + /* The named pattern commands "element", "elementtype" and 8572 + * "ref". */ 8573 + Tcl_CreateObjCommand (interp, "tdom::schema::element", 8574 + NamedPatternObjCmd, (ClientData) 0, NULL); 8575 + Tcl_CreateObjCommand (interp, "tdom::schema::elementtype", 8576 + NamedPatternObjCmd, (ClientData) 1, NULL); 8577 + Tcl_CreateObjCommand (interp, "tdom::schema::ref", 8578 + NamedPatternObjCmd, (ClientData) 2, NULL); 8579 + 8580 + /* The anonymous pattern commands "choise", "mixed", "interleave" 8581 + * and "group". */ 8582 + Tcl_CreateObjCommand (interp, "tdom::schema::choice", 8583 + AnonPatternObjCmd, (ClientData) 0, NULL); 8584 + Tcl_CreateObjCommand (interp, "tdom::schema::mixed", 8585 + AnonPatternObjCmd, (ClientData) 1, NULL); 8586 + Tcl_CreateObjCommand (interp, "tdom::schema::interleave", 8587 + AnonPatternObjCmd, (ClientData) 2, NULL); 8588 + Tcl_CreateObjCommand (interp, "tdom::schema::group", 8589 + AnonPatternObjCmd, (ClientData) 3, NULL); 8590 + 8591 + /* The "attribute", "nsattribute", "namespace" and "text" 8592 + * definition commands. */ 8593 + Tcl_CreateObjCommand (interp, "tdom::schema::attribute", 8594 + AttributePatternObjCmd, NULL, NULL); 8595 + Tcl_CreateObjCommand (interp, "tdom::schema::nsattribute", 8596 + AttributePatternObjCmd, (ClientData) 1, NULL); 8597 + Tcl_CreateObjCommand (interp, "tdom::schema::namespace", 8598 + NamespacePatternObjCmd, NULL, NULL); 8599 + Tcl_CreateObjCommand (interp, "tdom::schema::text", 8600 + TextPatternObjCmd, NULL, NULL); 8601 + 8602 + /* The 'virtual' "tcl" and the "self" definition command */ 8603 + Tcl_CreateObjCommand (interp, "tdom::schema::tcl", 8604 + VirtualPatternObjCmd, NULL, NULL); 8605 + Tcl_CreateObjCommand (interp, "tdom::schema::self", 8606 + SelfObjCmd, NULL, NULL); 8607 + 8608 + /* XPath contraints for DOM validation */ 8609 + Tcl_CreateObjCommand (interp,"tdom::schema::domunique", 8610 + domuniquePatternObjCmd, NULL, NULL); 8611 + Tcl_CreateObjCommand (interp,"tdom::schema::domxpathboolean", 8612 + domxpathbooleanPatternObjCmd, NULL, NULL); 8613 + 8614 + /* Local key constraints */ 8615 + Tcl_CreateObjCommand (interp, "tdom::schema::keyspace", 8616 + keyspacePatternObjCmd, NULL, NULL); 8617 + 8618 + /* The associate command */ 8619 + Tcl_CreateObjCommand (interp,"tdom::schema::associate", 8620 + associatePatternObjCmd, NULL, NULL); 8621 + 8622 + /* The text constraint commands */ 8623 + Tcl_CreateObjCommand (interp,"tdom::schema::text::integer", 8624 + integerTCObjCmd, (ClientData) 0, NULL); 8625 + Tcl_CreateObjCommand (interp,"tdom::schema::text::negativeInteger", 8626 + integerTCObjCmd, (ClientData) 1, NULL); 8627 + Tcl_CreateObjCommand (interp,"tdom::schema::text::nonNegativeInteger", 8628 + integerTCObjCmd, (ClientData) 2, NULL); 8629 + Tcl_CreateObjCommand (interp,"tdom::schema::text::nonPositiveInteger", 8630 + integerTCObjCmd, (ClientData) 3, NULL); 8631 + Tcl_CreateObjCommand (interp,"tdom::schema::text::positiveInteger", 8632 + integerTCObjCmd, (ClientData) 4, NULL); 8633 + Tcl_CreateObjCommand (interp, "tdom::schema::text::tcl", 8634 + tclTCObjCmd, NULL, NULL); 8635 + Tcl_CreateObjCommand (interp, "tdom::schema::text::fixed", 8636 + fixedTCObjCmd, NULL, NULL); 8637 + Tcl_CreateObjCommand (interp, "tdom::schema::text::enumeration", 8638 + enumerationTCObjCmd, NULL, NULL); 8639 + Tcl_CreateObjCommand (interp, "tdom::schema::text::match", 8640 + matchTCObjCmd, NULL, NULL); 8641 + Tcl_CreateObjCommand (interp, "tdom::schema::text::regexp", 8642 + regexpTCObjCmd, NULL, NULL); 8643 + Tcl_CreateObjCommand (interp, "tdom::schema::text::nmtoken", 8644 + nmtokenTCObjCmd, NULL, NULL); 8645 + Tcl_CreateObjCommand (interp, "tdom::schema::text::nmtokens", 8646 + nmtokensTCObjCmd, NULL, NULL); 8647 + Tcl_CreateObjCommand (interp,"tdom::schema::text::number", 8648 + numberTCObjCmd, NULL, NULL); 8649 + Tcl_CreateObjCommand (interp,"tdom::schema::text::boolean", 8650 + booleanTCObjCmd, NULL, NULL); 8651 + Tcl_CreateObjCommand (interp,"tdom::schema::text::date", 8652 + dateTCObjCmd, NULL, NULL); 8653 + Tcl_CreateObjCommand (interp,"tdom::schema::text::dateTime", 8654 + dateTimeTCObjCmd, NULL, NULL); 8655 + Tcl_CreateObjCommand (interp,"tdom::schema::text::time", 8656 + timeTCObjCmd, NULL, NULL); 8657 + Tcl_CreateObjCommand (interp,"tdom::schema::text::duration", 8658 + durationTCObjCmd, NULL, NULL); 8659 + Tcl_CreateObjCommand (interp,"tdom::schema::text::maxLength", 8660 + maxLengthTCObjCmd, NULL, NULL); 8661 + Tcl_CreateObjCommand (interp,"tdom::schema::text::minLength", 8662 + minLengthTCObjCmd, NULL, NULL); 8663 + Tcl_CreateObjCommand (interp,"tdom::schema::text::oneOf", 8664 + oneOfTCObjCmd, NULL, NULL); 8665 + Tcl_CreateObjCommand (interp,"tdom::schema::text::allOf", 8666 + allOfTCObjCmd, NULL, NULL); 8667 + Tcl_CreateObjCommand (interp,"tdom::schema::text::strip", 8668 + stripTCObjCmd, NULL, NULL); 8669 + Tcl_CreateObjCommand (interp,"tdom::schema::text::split", 8670 + splitTCObjCmd, NULL, NULL); 8671 + Tcl_CreateObjCommand (interp,"tdom::schema::text::id", 8672 + idTCObjCmd, NULL, NULL); 8673 + Tcl_CreateObjCommand (interp,"tdom::schema::text::idref", 8674 + idrefTCObjCmd, NULL, NULL); 8675 + Tcl_CreateObjCommand (interp,"tdom::schema::text::base64", 8676 + base64TCObjCmd, NULL, NULL); 8677 + Tcl_CreateObjCommand (interp,"tdom::schema::text::key", 8678 + keyTCObjCmd, NULL, NULL); 8679 + Tcl_CreateObjCommand (interp,"tdom::schema::text::keyref", 8680 + keyrefTCObjCmd, NULL, NULL); 8681 + Tcl_CreateObjCommand (interp,"tdom::schema::text::name", 8682 + nameTCObjCmd, NULL, NULL); 8683 + Tcl_CreateObjCommand (interp,"tdom::schema::text::ncname", 8684 + ncnameTCObjCmd, NULL, NULL); 8685 + Tcl_CreateObjCommand (interp,"tdom::schema::text::qname", 8686 + qnameTCObjCmd, NULL, NULL); 8687 + Tcl_CreateObjCommand (interp,"tdom::schema::text::hexBinary", 8688 + hexBinaryTCObjCmd, NULL, NULL); 8689 + Tcl_CreateObjCommand (interp,"tdom::schema::text::unsignedByte", 8690 + unsignedIntTypesTCObjCmd, (ClientData) 0, NULL); 8691 + Tcl_CreateObjCommand (interp,"tdom::schema::text::unsignedShort", 8692 + unsignedIntTypesTCObjCmd, (ClientData) 1, NULL); 8693 + Tcl_CreateObjCommand (interp,"tdom::schema::text::unsignedInt", 8694 + unsignedIntTypesTCObjCmd, (ClientData) 2, NULL); 8695 + Tcl_CreateObjCommand (interp,"tdom::schema::text::unsignedLong", 8696 + unsignedIntTypesTCObjCmd, (ClientData) 3, NULL); 8697 + Tcl_CreateObjCommand (interp,"tdom::schema::text::setvar", 8698 + setvarTCObjCmd, (ClientData) 3, NULL); 8699 + Tcl_CreateObjCommand (interp,"tdom::schema::text::whitespace", 8700 + whitespaceTCObjCmd, (ClientData) 3, NULL); 8701 + Tcl_CreateObjCommand (interp,"tdom::schema::text::not", 8702 + notTCObjCmd, (ClientData) 3, NULL); 8703 + Tcl_CreateObjCommand (interp,"tdom::schema::text::length", 8704 + lengthTCObjCmd, (ClientData) 3, NULL); 8705 + 8706 + /* Exposed text type commands */ 8707 + Tcl_CreateObjCommand (interp,"tdom::type::date", 8708 + dateObjCmd, NULL, NULL); 8709 + Tcl_CreateObjCommand (interp,"tdom::type::dateTime", 8710 + dateTimeObjCmd, NULL, NULL); 8711 + Tcl_CreateObjCommand (interp,"tdom::type::time", 8712 + timeObjCmd, NULL, NULL); 8713 + Tcl_CreateObjCommand (interp,"tdom::type::duration", 8714 + durationObjCmd, NULL, NULL); 8715 + 8716 +} 8717 + 8718 + 8719 +#endif /* #ifndef TDOM_NO_SCHEMA */
Added generic/schema.h.
1 +/*---------------------------------------------------------------------------- 2 +| Copyright (c) 2018 Rolf Ade (rolf@pointsman.de) 3 +|----------------------------------------------------------------------------- 4 +| 5 +| 6 +| The contents of this file are subject to the Mozilla Public License 7 +| Version 2.0 (the "License"); you may not use this file except in 8 +| compliance with the License. You may obtain a copy of the License at 9 +| http://www.mozilla.org/MPL/ 10 +| 11 +| Software distributed under the License is distributed on an "AS IS" 12 +| basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 13 +| License for the specific language governing rights and limitations 14 +| under the License. 15 +| 16 +| Contributor(s): 17 +| 18 +| 19 +| written by Rolf Ade 20 +| 2018-2020 21 +| 22 +\---------------------------------------------------------------------------*/ 23 + 24 +#ifndef __SCHEMA_H__ 25 +#define __SCHEMA_H__ 26 + 27 +#include <tcldom.h> 28 +#include <domxpath.h> 29 + 30 +typedef enum { 31 + SCHEMA_CTYPE_ANY, 32 + SCHEMA_CTYPE_NAME, 33 + SCHEMA_CTYPE_CHOICE, 34 + SCHEMA_CTYPE_INTERLEAVE, 35 + SCHEMA_CTYPE_PATTERN, 36 + SCHEMA_CTYPE_TEXT, 37 + SCHEMA_CTYPE_VIRTUAL, 38 + SCHEMA_CTYPE_KEYSPACE, 39 + SCHEMA_CTYPE_KEYSPACE_END, 40 +} Schema_CP_Type; 41 + 42 +typedef enum { 43 + SCHEMA_CQUANT_ONE, 44 + SCHEMA_CQUANT_OPT, 45 + SCHEMA_CQUANT_REP, 46 + SCHEMA_CQUANT_PLUS, 47 + SCHEMA_CQUANT_NM, 48 + SCHEMA_CQUANT_ERROR, 49 +} SchemaQuant; 50 + 51 +typedef int (*SchemaConstraintFunc) (Tcl_Interp *interp, 52 + void *constraintData, char *text); 53 +typedef void (*SchemaConstraintFreeFunc) (void *constraintData); 54 + 55 +typedef struct 56 +{ 57 + void *constraintData; 58 + SchemaConstraintFunc constraint; 59 + SchemaConstraintFreeFunc freeData; 60 +} SchemaConstraint; 61 + 62 +typedef struct SchemaAttr 63 +{ 64 + char *namespace; 65 + char *name; 66 + int required; 67 + struct SchemaAttr *next; 68 + struct SchemaCP *cp; 69 +} SchemaAttr; 70 + 71 +typedef unsigned int SchemaFlags; 72 + 73 +/* The SchemaFlags flags */ 74 +#define FORWARD_PATTERN_DEF 1 75 +#define PLACEHOLDER_PATTERN_DEF 2 76 +#define AMBIGUOUS_PATTERN 4 77 +#define LOCAL_DEFINED_ELEMENT 8 78 +#define CONSTRAINT_TEXT_CHILD 16 79 +#define MIXED_CONTENT 32 80 +#define ELEMENTTYPE_DEF 64 81 + 82 +typedef struct domKeyConstraint { 83 + char *name; 84 + ast selector; 85 + ast *fields; 86 + int nrFields; 87 + int flags; 88 + char *emptyFieldSetValue; 89 + int efsv_len; 90 + struct domKeyConstraint *next; 91 +} domKeyConstraint; 92 + 93 +typedef struct 94 +{ 95 + char *name; 96 + int active; 97 + Tcl_HashTable ids; 98 + int unknownIDrefs; 99 +} SchemaKeySpace; 100 + 101 +typedef struct SchemaCP 102 +{ 103 + Schema_CP_Type type; 104 + char *namespace; 105 + char *name; 106 + char *typeName; 107 + struct SchemaCP *next; 108 + SchemaFlags flags; 109 + struct SchemaCP **content; 110 + SchemaQuant *quants; 111 + unsigned int nc; 112 + void *typedata; 113 + SchemaAttr **attrs; 114 + unsigned int numAttr; 115 + unsigned int numReqAttr; 116 + domKeyConstraint *domKeys; 117 + SchemaKeySpace *keySpace; 118 + Tcl_Obj *defScript; 119 + Tcl_Obj *associated; 120 +} SchemaCP; 121 + 122 +typedef struct SchemaValidationStack 123 +{ 124 + SchemaCP *pattern; 125 + struct SchemaValidationStack *next; 126 + struct SchemaValidationStack *down; 127 + int activeChild; 128 + int hasMatched; 129 + int *interleaveState; 130 +} SchemaValidationStack; 131 + 132 +typedef enum { 133 + VALIDATION_READY, 134 + VALIDATION_STARTED, 135 + VALIDATION_ERROR, 136 + VALIDATION_FINISHED 137 +} ValidationState; 138 + 139 +typedef struct 140 +{ 141 + Tcl_HashTable ids; 142 + int unknownIDrefs; 143 +} SchemaDocKey; 144 + 145 +typedef struct SchemaData_ 146 +{ 147 + Tcl_Obj *self; 148 + char *start; 149 + char *startNamespace; 150 + Tcl_HashTable element; 151 + Tcl_HashTable elementType; 152 + Tcl_HashTable namespace; 153 + Tcl_HashEntry *emptyNamespace; 154 + char **prefixns; 155 + Tcl_HashTable prefix; 156 + Tcl_HashTable pattern; 157 + Tcl_HashTable attrNames; 158 + Tcl_HashTable textDef; 159 + SchemaCP **patternList; 160 + unsigned int numPatternList; 161 + unsigned int patternListSize; 162 + unsigned int forwardPatternDefs; 163 + SchemaQuant *quants; 164 + int inuse; 165 + int currentEvals; 166 + int cleanupAfterUse; 167 + int evalError; 168 + Tcl_Obj *reportCmd; 169 + SchemaValidationStack *lastMatchse; 170 + int recoverFlags; 171 + Tcl_Obj **evalStub; 172 + Tcl_Obj **textStub; 173 + char *currentNamespace; 174 + int defineToplevel; 175 + int isTextConstraint; 176 + int isAttributeConstaint; 177 + SchemaCP *cp; 178 + unsigned int contentSize; 179 + SchemaAttr **currentAttrs; 180 + unsigned int numAttr; 181 + unsigned int numReqAttr; 182 + unsigned int attrSize; 183 + SchemaValidationStack *stack; 184 + SchemaValidationStack *stackPool; 185 + ValidationState validationState; 186 + int vaction; 187 + const char *vname; 188 + const char *vns; 189 + const char *vtext; 190 + unsigned int skipDeep; 191 + Tcl_DString *cdata; 192 + Tcl_HashTable ids; 193 + int unknownIDrefs; 194 + Tcl_HashTable idTables; 195 + Tcl_HashTable keySpaces; 196 + XML_Parser parser; 197 + domNode *node; 198 + domNode *insideNode; 199 + int choiceHashThreshold; 200 + int attributeHashThreshold; 201 + char *wsbuf; 202 + int wsbufLen; 203 +} SchemaData; 204 + 205 +int 206 +tDOM_schemaInstanceCmd ( 207 + ClientData clientData, 208 + Tcl_Interp *interp, 209 + int objc, 210 + Tcl_Obj *const objv[] 211 + ); 212 + 213 +void tDOM_SchemaInit ( 214 + Tcl_Interp *interp 215 + ); 216 + 217 +int 218 +tDOM_probeElement ( 219 + Tcl_Interp *interp, 220 + SchemaData *sdata, 221 + const char *name, 222 + void *namespace 223 + ); 224 + 225 +int 226 +tDOM_probeAttributes ( 227 + Tcl_Interp *interp, 228 + SchemaData *sdata, 229 + const char **attr 230 + ); 231 + 232 +typedef struct domDocument domDocument; 233 +typedef struct domNode domNode; 234 +typedef struct domAttrNode domAttrNode; 235 +typedef struct domTextNode domTextNode; 236 + 237 +int tDOM_probeDomAttributes ( 238 + Tcl_Interp *interp, 239 + SchemaData *sdata, 240 + domAttrNode *attr 241 + ); 242 + 243 +int 244 +tDOM_probeElementEnd ( 245 + Tcl_Interp * interp, 246 + SchemaData *sdata 247 + ); 248 + 249 +int 250 +tDOM_probeText ( 251 + Tcl_Interp *interp, 252 + SchemaData *sdata, 253 + char *text, 254 + int *only_whites 255 + ); 256 + 257 +void 258 +tDOM_schemaReset ( 259 + SchemaData *sdata, 260 + int lookforCleanup 261 + ); 262 + 263 +#endif
Deleted generic/structure.c.
1 -/*---------------------------------------------------------------------------- 2 -| Copyright (c) 2018 Rolf Ade (rolf@pointsman.de) 3 -|----------------------------------------------------------------------------- 4 -| 5 -| 6 -| The contents of this file are subject to the Mozilla Public License 7 -| Version 2.0 (the "License"); you may not use this file except in 8 -| compliance with the License. You may obtain a copy of the License at 9 -| http://www.mozilla.org/MPL/ 10 -| 11 -| Software distributed under the License is distributed on an "AS IS" 12 -| basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 13 -| License for the specific language governing rights and limitations 14 -| under the License. 15 -| 16 -| Contributor(s): 17 -| 18 -| 19 -| written by Rolf Ade 20 -| November 2018 21 -| 22 -\---------------------------------------------------------------------------*/ 23 - 24 -#ifndef TDOM_NO_STRUCTURE 25 - 26 -#include <tdom.h> 27 -#include <structure.h> 28 - 29 -/* #define DEBUG */ 30 -/*---------------------------------------------------------------------------- 31 -| Debug Macros 32 -| 33 -\---------------------------------------------------------------------------*/ 34 -#ifdef DEBUG 35 -# define DBG(x) x 36 -#else 37 -# define DBG(x) 38 -#endif 39 - 40 -/*---------------------------------------------------------------------------- 41 -| Initial buffer sizes 42 -| 43 -\---------------------------------------------------------------------------*/ 44 -#ifndef CONTENT_ARRAY_SIZE_INIT 45 -# define CONTENT_ARRAY_SIZE_INIT 20 46 -#endif 47 -#ifndef ANON_PATTERN_ARRAY_SIZE_INIT 48 -# define ANON_PATTERN_ARRAY_SIZE_INIT 256 49 -#endif 50 -#ifndef QUANTS_ARRAY_SIZE_INIT 51 -# define QUANTS_ARRAY_SIZE_INIT 8 52 -#endif 53 -#ifndef STACK_SIZE_INIT 54 -# define STACK_SIZE_INIT 16 55 -#endif 56 -#ifndef STACK_LIST_SIZE_INIT 57 -# define STACK_LIST_SIZE_INIT 64 58 -#endif 59 -#ifndef URI_BUFFER_LEN_INIT 60 -# define URI_BUFFER_LEN_INIT 128 61 -#endif 62 - 63 -/*---------------------------------------------------------------------------- 64 -| Local typedefs 65 -| 66 -\---------------------------------------------------------------------------*/ 67 - 68 -typedef struct 69 -{ 70 - StructureData *sdata; 71 - Tcl_Interp *interp; 72 - XML_Parser parser; 73 - Tcl_DString *cdata; 74 - char *uri; 75 - int maxUriLen; 76 -} ValidateMethodData; 77 - 78 -/*---------------------------------------------------------------------------- 79 -| Macros 80 -| 81 -\---------------------------------------------------------------------------*/ 82 -#define TMALLOC(t) (t*)MALLOC(sizeof(t)) 83 - 84 -#define SetResult(str) Tcl_ResetResult(interp); \ 85 - Tcl_SetStringObj(Tcl_GetObjResult(interp), (str), -1) 86 -#define SetResult3(str1,str2,str3) Tcl_ResetResult(interp); \ 87 - Tcl_AppendResult(interp, (str1), (str2), (str3), NULL) 88 -#define SetIntResult(i) Tcl_ResetResult(interp); \ 89 - Tcl_SetIntObj(Tcl_GetObjResult(interp), (i)) 90 -#define SetBooleanResult(i) Tcl_ResetResult(interp); \ 91 - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (i)) 92 - 93 -#define checkNrArgs(l,h,err) if (objc < l || objc > h) { \ 94 - SetResult (err); \ 95 - return TCL_ERROR; \ 96 - } 97 - 98 -#ifdef DEBUG 99 -static char *Structure_CP_Type2str[] = { 100 - "EMPTY", 101 - "ANY", 102 - "MIXED", 103 - "NAME", 104 - "CHOICE", 105 - "INTERLEAVE", 106 - "PATTERN", 107 - "GROUP", 108 - "TEXT" 109 -}; 110 -static char *Structure_Quant_Type2str[] = { 111 - "ONE", 112 - "OPT", 113 - "REP", 114 - "PLUS", 115 - "N", 116 - "NM" 117 -}; 118 -#endif 119 - 120 - 121 -/* The StructureFlags flags */ 122 -#define FORWARD_PATTERN_DEF 1 123 -#define PLACEHOLDER_PATTERN_DEF 2 124 -#define AMBIGUOUS_PATTERN 4 125 -#define LOCAL_DEFINED_ELEMENT 8 126 - 127 -/* Pointer to heap-allocated shared quants. */ 128 -static StructureQuant QuantOne; 129 -static StructureQuant *quantOne = &QuantOne; 130 - 131 -static StructureQuant QuantOpt; 132 -static StructureQuant *quantOpt = &QuantOpt; 133 - 134 -static StructureQuant QuantRep; 135 -static StructureQuant *quantRep = &QuantRep; 136 - 137 -static StructureQuant QuantPlus; 138 -static StructureQuant *quantPlus = &QuantPlus; 139 - 140 -#ifndef TCL_THREADS 141 - static StructureData *activeStructureData = 0; 142 -# define GETASI activeStructureData 143 -# define SETASI(v) activeStructureData = v 144 -#else 145 - static Tcl_ThreadDataKey activeStructureData; 146 -# define GETASI *(StructureData**) Tcl_GetThreadData(&activeStructureData, \ 147 - sizeof(StructureData*)) 148 -static void SetActiveStructureData (StructureData *v) 149 -{ 150 - StructureData **structureInfoPtr = Tcl_GetThreadData(&activeStructureData, 151 - sizeof (StructureData*)); 152 - *structureInfoPtr = v; 153 -} 154 -# define SETASI(v) SetActiveStructureData (v) 155 -#endif 156 - 157 - 158 -#define CHECK_SI \ 159 - if (!sdata) { \ 160 - SetResult ("Command called outside of grammar context."); \ 161 - return TCL_ERROR; \ 162 - } 163 - 164 -#define CHECK_TOPLEVEL \ 165 - if (sdata->defineToplevel) { \ 166 - SetResult("Command not allowed at top level " \ 167 - "in grammar define evaluation"); \ 168 - return TCL_ERROR; \ 169 - } 170 - 171 -#define CHECK_SI_CONTEXT \ 172 - if (sdata->isAttribute) { \ 173 - SetResult ("Command called in invalid grammar context."); \ 174 - return TCL_ERROR; \ 175 - } 176 - 177 -#define ADD_TO_CONTENT(pattern,quant) \ 178 - checkForAmbiguousness (pattern); \ 179 - if (sdata->numChildren == sdata->contentSize) { \ 180 - sdata->currentContent = \ 181 - REALLOC (sdata->currentContent, \ 182 - 2 * sdata->contentSize \ 183 - * sizeof (StructureCP*)); \ 184 - sdata->currentQuants = \ 185 - REALLOC (sdata->currentQuants, \ 186 - 2 * sdata->contentSize \ 187 - * sizeof (StructureQuant*)); \ 188 - sdata->contentSize *= 2; \ 189 - } \ 190 - sdata->currentContent[sdata->numChildren] = (pattern); \ 191 - sdata->currentQuants[sdata->numChildren] = quant; \ 192 - sdata->numChildren++; \ 193 - 194 -#define REMEMBER_PATTERN(pattern) \ 195 - if (sdata->numPatternList == sdata->patternListSize) { \ 196 - sdata->patternList = (StructureCP **) MALLOC ( \ 197 - sizeof (StructureCP*) * sdata->patternListSize * 2); \ 198 - sdata->patternListSize *= 2; \ 199 - } \ 200 - sdata->patternList[sdata->numPatternList] = pattern; \ 201 - sdata->numPatternList++; 202 - 203 -static StructureCP* 204 -initStructureCP ( 205 - Structure_CP_Type type, 206 - void *namespace, 207 - char *name 208 - ) 209 -{ 210 - StructureCP *pattern; 211 - 212 - pattern = TMALLOC (StructureCP); 213 - memset (pattern, 0, sizeof(StructureCP)); 214 - pattern->type = type; 215 - switch (type) { 216 - case STRUCTURE_CTYPE_NAME: 217 - case STRUCTURE_CTYPE_PATTERN: 218 - pattern->namespace = (char *)namespace; 219 - pattern->name = name; 220 - /* Fall thru. */ 221 - case STRUCTURE_CTYPE_GROUP: 222 - case STRUCTURE_CTYPE_MIXED: 223 - case STRUCTURE_CTYPE_CHOICE: 224 - case STRUCTURE_CTYPE_INTERLEAVE: 225 - pattern->content = (StructureCP**) MALLOC ( 226 - sizeof(StructureCP*) * CONTENT_ARRAY_SIZE_INIT 227 - ); 228 - pattern->quants = (StructureQuant**) MALLOC ( 229 - sizeof (StructureQuant*) * CONTENT_ARRAY_SIZE_INIT 230 - ); 231 - break; 232 - case STRUCTURE_CTYPE_EMPTY: 233 - case STRUCTURE_CTYPE_ANY: 234 - case STRUCTURE_CTYPE_TEXT: 235 - /* Do nothing */ 236 - break; 237 - } 238 - return pattern; 239 -} 240 - 241 -DBG( 242 -static void serializeCP ( 243 - StructureCP *pattern 244 - ) 245 -{ 246 - fprintf (stderr, "CP type: %s\n", 247 - Structure_CP_Type2str[pattern->type]); 248 - switch (pattern->type) { 249 - case STRUCTURE_CTYPE_NAME: 250 - case STRUCTURE_CTYPE_PATTERN: 251 - case STRUCTURE_CTYPE_GROUP: 252 - fprintf (stderr, "\tName: '%s' Namespace: '%s'\n", 253 - pattern->name,pattern->namespace); 254 - if (pattern->flags & FORWARD_PATTERN_DEF) { 255 - fprintf (stderr, "\tAnonymously defined NAME\n"); 256 - } 257 - if (pattern->flags & PLACEHOLDER_PATTERN_DEF) { 258 - fprintf (stderr, "\tAs placeholder defined NAME\n"); 259 - } 260 - if (pattern->flags & LOCAL_DEFINED_ELEMENT) { 261 - fprintf (stderr, "\tAs placeholder defined NAME\n"); 262 - } 263 - /* Fall thru. */ 264 - case STRUCTURE_CTYPE_MIXED: 265 - case STRUCTURE_CTYPE_CHOICE: 266 - case STRUCTURE_CTYPE_INTERLEAVE: 267 - fprintf (stderr, "\t%d childs\n", pattern->numChildren); 268 - break; 269 - case STRUCTURE_CTYPE_EMPTY: 270 - case STRUCTURE_CTYPE_ANY: 271 - case STRUCTURE_CTYPE_TEXT: 272 - /* Do nothing */ 273 - break; 274 - } 275 -} 276 - 277 -static void serializeQuant ( 278 - StructureQuant *quant 279 - ) 280 -{ 281 - fprintf (stderr, "Quant type: %s n: %d m: %d\n", 282 - Structure_Quant_Type2str[quant->type], quant->minOccur, quant->maxOccur); 283 -} 284 - 285 -static void serializeStack ( 286 - StructureData *sdata 287 - ) 288 -{ 289 - int i = sdata->stackPtr-1; 290 - 291 - fprintf (stderr, "++++ Current validation stack (size %d):\n", i+1); 292 - while (i >= 0) { 293 - serializeCP (sdata->stack[i]->pattern); 294 - fprintf (stderr, "deep: %d matched: %d ac: %d nm: %d\n", 295 - sdata->stack[i]->deep, sdata->stack[i]->acNrMatched, 296 - sdata->stack[i]->activeChild, sdata->stack[i]->nrMatched); 297 - i--; 298 - } 299 - fprintf (stderr, "++++ Stack bottom\n"); 300 -} 301 -) 302 - 303 -/* DBG end */ 304 - 305 -static void freeStructureCP ( 306 - StructureCP *pattern 307 - ) 308 -{ 309 - switch (pattern->type) { 310 - case STRUCTURE_CTYPE_EMPTY: 311 - case STRUCTURE_CTYPE_ANY: 312 - /* do nothing */ 313 - break; 314 - default: 315 - FREE (pattern->content); 316 - FREE (pattern->quants); 317 - break; 318 - } 319 - FREE (pattern); 320 -} 321 - 322 -static StructureData* 323 -initStructureData () 324 -{ 325 - StructureData *sdata; 326 - int hnew; 327 - 328 - sdata = TMALLOC (StructureData); 329 - memset (sdata, 0, sizeof(StructureData)); 330 - Tcl_InitHashTable (&sdata->element, TCL_STRING_KEYS); 331 - Tcl_InitHashTable (&sdata->pattern, TCL_STRING_KEYS); 332 - Tcl_InitHashTable (&sdata->namespace, TCL_STRING_KEYS); 333 - sdata->emptyNamespace = Tcl_CreateHashEntry ( 334 - &sdata->namespace, "", &hnew); 335 - sdata->patternList = (StructureCP **) MALLOC ( 336 - sizeof (StructureCP*) * ANON_PATTERN_ARRAY_SIZE_INIT); 337 - sdata->patternListSize = ANON_PATTERN_ARRAY_SIZE_INIT; 338 - sdata->quants = (StructureQuant **) MALLOC ( 339 - sizeof (StructureQuant*) * QUANTS_ARRAY_SIZE_INIT); 340 - sdata->quantsSize = QUANTS_ARRAY_SIZE_INIT; 341 - sdata->stack = (StructureValidationStack **) MALLOC ( 342 - sizeof (StructureValidationStack *) * STACK_SIZE_INIT); 343 - sdata->stackSize = STACK_SIZE_INIT; 344 - sdata->stackList = (StructureValidationStack **) MALLOC ( 345 - sizeof (StructureValidationStack *) * STACK_LIST_SIZE_INIT); 346 - sdata->stackListSize = STACK_LIST_SIZE_INIT; 347 - sdata->evalStub = (Tcl_Obj **) (MALLOC (sizeof (Tcl_Obj*) * 4)); 348 - sdata->evalStub[0] = Tcl_NewStringObj("::namespace", 11); 349 - Tcl_IncrRefCount (sdata->evalStub[0]); 350 - sdata->evalStub[1] = Tcl_NewStringObj("eval", 4); 351 - Tcl_IncrRefCount (sdata->evalStub[1]); 352 - sdata->evalStub[2] = Tcl_NewStringObj("::tdom::structure", 17); 353 - Tcl_IncrRefCount (sdata->evalStub[2]); 354 - return sdata; 355 -} 356 - 357 -static void structureInstanceDelete ( 358 - ClientData clientData 359 - ) 360 -{ 361 - StructureData *sdata = (StructureData *) clientData; 362 - unsigned int i; 363 - 364 - if (sdata->start) FREE (sdata->start); 365 - if (sdata->startNamespace) FREE (sdata->startNamespace); 366 - Tcl_DeleteHashTable (&sdata->namespace); 367 - Tcl_DeleteHashTable (&sdata->element); 368 - Tcl_DeleteHashTable (&sdata->pattern); 369 - for (i = 0; i < sdata->numPatternList; i++) { 370 - freeStructureCP (sdata->patternList[i]); 371 - } 372 - FREE (sdata->patternList); 373 - for (i = 0; i < sdata->numQuants; i++) { 374 - FREE (sdata->quants[i]); 375 - } 376 - FREE (sdata->quants); 377 - FREE (sdata->stack); 378 - for (i = 0; i < sdata->numStackAllocated; i++) { 379 - FREE (sdata->stackList[i]); 380 - } 381 - FREE (sdata->stackList); 382 - Tcl_DecrRefCount (sdata->evalStub[0]); 383 - Tcl_DecrRefCount (sdata->evalStub[1]); 384 - Tcl_DecrRefCount (sdata->evalStub[2]); 385 - FREE (sdata->evalStub); 386 - FREE (sdata); 387 -} 388 - 389 -static void 390 -cleanupLastPattern ( 391 - StructureData *sdata, 392 - unsigned int from 393 - ) 394 -{ 395 - unsigned int i; 396 - Tcl_HashTable *hashTable; 397 - Tcl_HashEntry *entryPtr; 398 - StructureCP *this, *previous, *current; 399 - 400 - for (i = from; i < sdata->numPatternList; i++) { 401 - this = sdata->patternList[i]; 402 - hashTable = NULL; 403 - if (this->type == STRUCTURE_CTYPE_NAME) { 404 - hashTable = &sdata->element; 405 - } 406 - if (this->type == STRUCTURE_CTYPE_PATTERN) { 407 - hashTable = &sdata->pattern; 408 - } 409 - if (hashTable) { 410 - if (this->flags & FORWARD_PATTERN_DEF) { 411 - sdata->forwardPatternDefs--; 412 - } 413 - entryPtr = Tcl_FindHashEntry (hashTable, this->name); 414 - previous = NULL; 415 - current = Tcl_GetHashValue (entryPtr); 416 - while (current != NULL && current != this) { 417 - previous = current; 418 - current = current->next; 419 - } 420 - if (previous) { 421 - if (current->next) { 422 - previous->next = current->next; 423 - } else { 424 - previous->next = NULL; 425 - } 426 - } else { 427 - if (current) { 428 - Tcl_SetHashValue (entryPtr, current->next); 429 - } else { 430 - Tcl_DeleteHashEntry (entryPtr); 431 - } 432 - } 433 - } 434 - freeStructureCP (sdata->patternList[i]); 435 - } 436 - sdata->numPatternList = from; 437 -} 438 - 439 -static void 440 -checkForAmbiguousness ( 441 - StructureCP *pattern 442 - ) 443 -{ 444 - /* As long as we don't know otherwise we assume any pattern to be 445 - * ambiguous. */ 446 - pattern->flags |= AMBIGUOUS_PATTERN; 447 -} 448 - 449 -static void 450 -pushToStack ( 451 - StructureData *sdata, 452 - StructureCP *pattern, 453 - int deep 454 - ) 455 -{ 456 - StructureValidationStack *stackElm; 457 - 458 - if (sdata->numStackList < sdata->numStackAllocated) { 459 - stackElm = sdata->stackList[sdata->numStackList]; 460 - } else { 461 - if (sdata->stackPtr == sdata->stackSize) { 462 - sdata->stack = REALLOC ( 463 - sdata->stack, 464 - sizeof (StructureValidationStack *) * 2 * sdata->stackSize); 465 - sdata->stackSize *= 2; 466 - } 467 - if (sdata->stackListSize == sdata->numStackList) { 468 - sdata->stackList = REALLOC ( 469 - sdata->stackList, 470 - sizeof (StructureValidationStack *) * 2 * sdata->stackListSize); 471 - sdata->stackListSize *= 2; 472 - } 473 - stackElm = TMALLOC (StructureValidationStack); 474 - sdata->numStackAllocated++; 475 - sdata->stackList[sdata->numStackList] = stackElm; 476 - } 477 - sdata->numStackList++; 478 - memset (stackElm, 0, sizeof (StructureValidationStack)); 479 - stackElm->pattern = pattern; 480 - stackElm->deep = deep; 481 - sdata->stack[sdata->stackPtr] = stackElm; 482 - sdata->stackPtr++; 483 -} 484 - 485 -#define maxOne(quant) \ 486 - ((quant) == quantOne || (quant) == quantOpt) ? 1 : 0 487 - 488 -#define minOne(quant) \ 489 - ((quant) == quantOne || (quant) == quantPlus) || (quant->type == STRUCTURE_CQUANT_NM && (quant)->minOccur > 0) ? 1 : 0 490 - 491 -#define mayMiss(quant) \ 492 - ((quant) == quantOpt || (quant) == quantRep) || (quant->type == STRUCTURE_CQUANT_NM && (quant)->minOccur == 0) ? 1 : 0 493 - 494 -#define mayRepeat(quant) \ 495 - ((quant) == quantRep || (quant) == quantPlus) ? 1 : 0 496 - 497 -#define mustMatch(quant,nr) \ 498 - (nr) == 0 ? minOne(quant) \ 499 - : (quant->type == STRUCTURE_CQUANT_NM && quant->minOccur < (nr)) ? 1 : 0 500 - 501 -#define hasMatched(quant,nr) \ 502 - (nr) == 0 ? 0 : ((nr) == 1 && (quant == quantOne || quant == quantOpt) ? 1 : quant->maxOccur == (nr)) 503 - 504 -#define getContext(parent, ac, nm) \ 505 - parent = sdata->stack[sdata->stackPtr-1]->pattern; \ 506 - ac = sdata->stack[sdata->stackPtr-1]->activeChild; \ 507 - nm = sdata->stack[sdata->stackPtr-1]->nrMatched; 508 - 509 -#define updateStack(sdata,stackPtr,newac,newnm) \ 510 - sdata->stack[stackPtr-1]->activeChild = newac; \ 511 - sdata->stack[stackPtr-1]->nrMatched = newnm; 512 - 513 -#define popStack(sdata) sdata->stackPtr-- 514 - 515 -#define waterMark(sdata) sdata->stack[sdata->stackPtr-1]->stacklistWatermark = sdata->numStackList - 1 516 -#define restoreWaterMark(sdata) sdata->numStackList = sdata->stack[sdata->stackPtr-1]->stacklistWatermark 517 - 518 -static int 519 -matchNamePattern ( 520 - StructureData *sdata, 521 - StructureCP *pattern, 522 - int currentDeep 523 - ) 524 -{ 525 - StructureCP *parent, *candidate; 526 - int nm, ac, startac, savedStackPtr, rc, i; 527 - int isName = 0, loopOver = 0; 528 - 529 - /* The caller must ensure pattern->type = STRUCTURE_CTYPE_NAME */ 530 - 531 - getContext (parent, ac, nm); 532 - 533 - if (hasMatched (parent->quants[ac], nm)) {ac++; nm = 0;} 534 - 535 - DBG( 536 - fprintf (stderr, "matchNamePattern: ac: %d nm: %d stack:\n", ac, nm); 537 - serializeStack (sdata); 538 - ) 539 - 540 - switch (parent->type) { 541 - case STRUCTURE_CTYPE_NAME: 542 - isName = 1; 543 - /* fall through */ 544 - case STRUCTURE_CTYPE_GROUP: 545 - case STRUCTURE_CTYPE_PATTERN: 546 - startac = ac; 547 - loopOverContent: 548 - while (ac < parent->numChildren) { 549 - candidate = parent->content[ac]; 550 - switch (candidate->type) { 551 - case STRUCTURE_CTYPE_EMPTY: 552 - /* The empty pattern never match an element, successfully */ 553 - ac++; 554 - nm = 0; 555 - break; 556 - 557 - case STRUCTURE_CTYPE_ANY: 558 - updateStack (sdata, sdata->stackPtr, ac, nm+1); 559 - return 1; 560 - 561 - case STRUCTURE_CTYPE_NAME: 562 - if (candidate == pattern 563 - || strcmp (candidate->name, pattern->name) == 0) { 564 - updateStack (sdata, sdata->stackPtr, ac, nm+1); 565 - if (loopOver) { 566 - sdata->stack[sdata->stackPtr-2]->nrMatched++; 567 - } 568 - /* We need to push the element only onto the stack 569 - * if it has non-empty content. But how many real 570 - * life XML vocabularies does have EMPTY 571 - * elements? Should we check for this? */ 572 - pushToStack (sdata, candidate, currentDeep + 1); 573 - waterMark (sdata); 574 - return 1; 575 - } 576 - if (mustMatch (parent->quants[ac], nm)) return 0; 577 - ac++; 578 - nm = 0; 579 - break; 580 - 581 - case STRUCTURE_CTYPE_TEXT: 582 - if (mustMatch (parent->quants[ac], nm)) return 0; 583 - ac++; 584 - nm = 0; 585 - break; 586 - 587 - case STRUCTURE_CTYPE_GROUP: 588 - case STRUCTURE_CTYPE_PATTERN: 589 - case STRUCTURE_CTYPE_MIXED: 590 - case STRUCTURE_CTYPE_INTERLEAVE: 591 - case STRUCTURE_CTYPE_CHOICE: 592 - savedStackPtr = sdata->stackPtr; 593 - pushToStack (sdata, candidate, currentDeep); 594 - rc = matchNamePattern (sdata, pattern, currentDeep); 595 - if (rc == 1) { 596 - updateStack (sdata, savedStackPtr, ac, nm+1); 597 - return 1; 598 - } 599 - popStack (sdata); 600 - if (rc == 0) return 0; 601 - if (mustMatch (parent->quants[ac], nm)) return 0; 602 - ac++; 603 - nm = 0; 604 - break; 605 - } 606 - } 607 - if (isName) { 608 - /* No match, but any remaining possible childs tested */ 609 - return 0; 610 - } else { 611 - /* No match, but also no explicit error. */ 612 - /* We finished a non atomic pattern (GROUP or PATTERN) and 613 - * increment the nrMatched of that inside its parent. */ 614 - 615 - /* Check, if we have to restart the parent pattern (look 616 - for match right from the start) because of quant. */ 617 - if (startac) { 618 - /* It only make sense to look for a match from the 619 - * start if the start active child wasn't already 0*/ 620 - StructureQuant *parentQuant; 621 - parentQuant = sdata->stack[sdata->stackPtr-2]-> 622 - pattern->quants[sdata->stack[sdata->stackPtr-2]->activeChild]; 623 - if (mayRepeat (parentQuant)) { 624 - ac = 0; 625 - nm = 0; 626 - startac = 0; 627 - loopOver = 1; 628 - DBG(fprintf (stderr, "... loopOverContent\n")); 629 - goto loopOverContent; 630 - } else { 631 - if (!maxOne (parentQuant)) { 632 - if (sdata->stack[sdata->stackPtr-2]->nrMatched 633 - < parentQuant->maxOccur) { 634 - ac = 0; 635 - nm = 0; 636 - startac = 0; 637 - loopOver = 1; 638 - DBG(fprintf (stderr, "... loopOverContent\n")); 639 - goto loopOverContent; 640 - } 641 - } 642 - 643 - } 644 - } 645 - return -1; 646 - } 647 - 648 - case STRUCTURE_CTYPE_TEXT: 649 - if (mustMatch (parent->quants[ac], nm)) return 0; 650 - break; 651 - 652 - case STRUCTURE_CTYPE_ANY: 653 - case STRUCTURE_CTYPE_EMPTY: 654 - /* Never pushed onto stack */ 655 - Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 656 - 657 - case STRUCTURE_CTYPE_INTERLEAVE: 658 - fprintf (stderr, "matchNamePattern: STRUCTURE_CTYPE_INTERLEAVE to be implemented\n"); 659 - return 0; 660 - 661 - case STRUCTURE_CTYPE_MIXED: 662 - case STRUCTURE_CTYPE_CHOICE: 663 - for (i = 0; i < parent->numChildren; i++) { 664 - candidate = parent->content[i]; 665 - 666 - switch (candidate->type) { 667 - case STRUCTURE_CTYPE_EMPTY: 668 - /* The empty pattern never match an element */ 669 - break; 670 - 671 - case STRUCTURE_CTYPE_ANY: 672 - return 1; 673 - 674 - case STRUCTURE_CTYPE_TEXT: 675 - /* An elememt never match text. */ 676 - break; 677 - 678 - case STRUCTURE_CTYPE_NAME: 679 - if (candidate == pattern 680 - || strcmp (candidate->name, pattern->name) == 0) { 681 - updateStack (sdata, sdata->stackPtr, 0, nm+1); 682 - pushToStack (sdata, candidate, currentDeep + 1); 683 - return 1; 684 - } 685 - break; 686 - 687 - case STRUCTURE_CTYPE_GROUP: 688 - case STRUCTURE_CTYPE_PATTERN: 689 - case STRUCTURE_CTYPE_MIXED: 690 - case STRUCTURE_CTYPE_INTERLEAVE: 691 - case STRUCTURE_CTYPE_CHOICE: 692 - savedStackPtr = sdata->stackPtr; 693 - pushToStack (sdata, candidate, currentDeep); 694 - rc = matchNamePattern (sdata, pattern, currentDeep); 695 - if (rc == 1) { 696 - /* Matched */ 697 - updateStack (sdata, savedStackPtr, 0, nm+1); 698 - return 1; 699 - } 700 - popStack (sdata); 701 - break; 702 - } 703 - 704 - } 705 - /* No match, but the pattern may be optional or has already 706 - * matched often enough. Check this on caller level. */ 707 - return -1; 708 - } 709 - return 0; 710 -} 711 - 712 -int 713 -probeElement ( 714 - Tcl_Interp *interp, 715 - StructureData *sdata, 716 - const char *name, 717 - void *namespace 718 - ) 719 -{ 720 - Tcl_HashEntry *entryPtr; 721 - void *namespacePtr; 722 - StructureCP *pattern; 723 - int savedStackPtr, activeStack, currentDeep, rc; 724 - 725 - if (sdata->validationState == VALIDATION_FINISHED) { 726 - SetResult ("Validation finished."); 727 - return TCL_ERROR; 728 - } 729 - 730 - if (namespace) { 731 - entryPtr = Tcl_FindHashEntry (&sdata->namespace, (char *)namespace); 732 - if (!entryPtr) { 733 - SetResult ("No elements defined in this namespace"); 734 - return TCL_ERROR; 735 - } 736 - if (entryPtr == sdata->emptyNamespace) { 737 - namespacePtr = NULL; 738 - } else { 739 - namespacePtr = Tcl_GetHashKey (&sdata->namespace, entryPtr); 740 - } 741 - } else { 742 - namespacePtr = NULL; 743 - } 744 - 745 - entryPtr = Tcl_FindHashEntry (&sdata->element, name); 746 - if (!entryPtr) { 747 - SetResult3 ("\"", name, "\" isn't a defined element name in grammar."); 748 - return TCL_ERROR; 749 - } 750 - pattern = (StructureCP *) Tcl_GetHashValue (entryPtr); 751 - while (pattern) { 752 - if (pattern->namespace == namespacePtr) { 753 - break; 754 - } 755 - pattern = pattern->next; 756 - } 757 - if (!pattern) { 758 - SetResult ("No such element definition."); 759 - return TCL_ERROR; 760 - } 761 - 762 - if (sdata->validationState == VALIDATION_READY) { 763 - /* The root of the tree to check. */ 764 - if (sdata->start) { 765 - if (strcmp (name, sdata->start) != 0) { 766 - SetResult ("Root element doesn't match."); 767 - return TCL_ERROR; 768 - } 769 - if (namespace) { 770 - if (!sdata->startNamespace || 771 - strcmp (namespace, sdata->startNamespace) != 0) { 772 - SetResult ("Root element namespace doesn't match"); 773 - return TCL_ERROR; 774 - } 775 - } else { 776 - if (sdata->startNamespace) { 777 - SetResult ("Root element namespace doesn't match"); 778 - return TCL_ERROR; 779 - } 780 - } 781 - } 782 - pushToStack (sdata, pattern, 0); 783 - sdata->validationState = VALIDATION_STARTED; 784 - return TCL_OK; 785 - } 786 - 787 - /* The normal case: we're inside the tree */ 788 - savedStackPtr = sdata->stackPtr; 789 - activeStack = savedStackPtr; 790 - currentDeep = sdata->stack[activeStack-1]->deep; 791 - 792 - DBG( 793 - fprintf (stderr, "probeElement: look if '%s' match\n", pattern->name); 794 - ); 795 - 796 - while ((rc = matchNamePattern (sdata, pattern, currentDeep)) == -1) { 797 - activeStack--; 798 - if (activeStack < 0 || sdata->stack[activeStack]->deep < currentDeep) { 799 - break; 800 - } 801 - sdata->stackPtr = activeStack + 1; 802 - } 803 - if (rc == 1) { 804 - DBG( 805 - fprintf (stderr, "probeElement: element '%s' match\n", name); 806 - serializeStack (sdata); 807 - fprintf (stderr, "\n"); 808 - ); 809 - return TCL_OK; 810 - } 811 - sdata->stackPtr = savedStackPtr; 812 - DBG( 813 - fprintf (stderr, "element '%s' DOESN'T match\n", name); 814 - serializeStack (sdata); 815 - fprintf (stderr, "\n"); 816 - ); 817 - SetResult3 ("Element \"", name, "\" doesn't match"); 818 - return TCL_ERROR; 819 -} 820 - 821 -static int checkElementEnd ( 822 - StructureData *sdata 823 - ) 824 -{ 825 - StructureCP *parent; 826 - int nm, ac; 827 - int isName = 0; 828 - 829 - getContext (parent, ac, nm); 830 - 831 - switch (parent->type) { 832 - case STRUCTURE_CTYPE_NAME: 833 - if (sdata->stackPtr == 1) return 1; 834 - isName = 1; 835 - /* fall through */ 836 - case STRUCTURE_CTYPE_GROUP: 837 - case STRUCTURE_CTYPE_PATTERN: 838 - while (ac < parent->numChildren) { 839 - if (mustMatch (parent->quants[ac], nm)) { 840 - return 0; 841 - } 842 - ac ++; 843 - nm = 0; 844 - } 845 - if (isName) return 1; 846 - else return -1; 847 - 848 - case STRUCTURE_CTYPE_TEXT: 849 - case STRUCTURE_CTYPE_ANY: 850 - case STRUCTURE_CTYPE_EMPTY: 851 - /* Never pushed onto stack */ 852 - Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 853 - return 0; 854 - 855 - case STRUCTURE_CTYPE_INTERLEAVE: 856 - fprintf (stderr, "checkElementEnd: STRUCTURE_CTYPE_INTERLEAVE to be implemented\n"); 857 - return 0; 858 - 859 - case STRUCTURE_CTYPE_MIXED: 860 - case STRUCTURE_CTYPE_CHOICE: 861 - return -1; 862 - } 863 - return 0; 864 -} 865 - 866 -int 867 -probeElementEnd ( 868 - Tcl_Interp *interp, 869 - StructureData *sdata 870 - ) 871 -{ 872 - int activeStack, savedStackPtr, rc, currentDeep; 873 - 874 - if (sdata->validationState == VALIDATION_FINISHED) { 875 - SetResult ("Validation finished."); 876 - return TCL_ERROR; 877 - } 878 - if (sdata->validationState == VALIDATION_READY) { 879 - SetResult ("No validation started"); 880 - return TCL_ERROR; 881 - } 882 - 883 - savedStackPtr = sdata->stackPtr; 884 - activeStack = savedStackPtr; 885 - currentDeep = sdata->stack[activeStack-1]->deep; 886 - 887 - DBG( 888 - fprintf (stderr, "probeElementEnd: look if current stack top can end " 889 - " name: '%s' currentDeep: %d\n", 890 - sdata->stack[sdata->stackPtr-1]->pattern->name, currentDeep); 891 - serializeStack (sdata); 892 - ); 893 - 894 - while ((rc = checkElementEnd (sdata)) == -1) { 895 - activeStack--; 896 - if (activeStack < 1 || sdata->stack[activeStack]->deep < currentDeep) { 897 - break; 898 - } 899 - popStack(sdata); 900 - } 901 - 902 - if (rc != 1) { 903 - sdata->stackPtr = savedStackPtr; 904 - SetResult ("Missing mandatory element\n"); 905 - DBG( 906 - fprintf(stderr, "probeElementEnd: CAN'T end here.\n"); 907 - serializeStack (sdata); 908 - ); 909 - return TCL_ERROR; 910 - } 911 - 912 - restoreWaterMark(sdata); 913 - popStack(sdata); 914 - DBG( 915 - fprintf(stderr, "probeElementEnd: ended here.\n"); 916 - serializeStack (sdata); 917 - ); 918 - if (sdata->stackPtr == 0) { 919 - /* End of the first pattern (the tree root) without error. 920 - We have successfully ended validation */ 921 - sdata->validationState = VALIDATION_FINISHED; 922 - } 923 - 924 - return TCL_OK; 925 -} 926 - 927 -static int 928 -checkText ( 929 - Tcl_Interp *interp, 930 - StructureCP *cp, 931 - char *text 932 - ) 933 -{ 934 - 935 - return TCL_OK; 936 -} 937 - 938 -int 939 -probeText ( 940 - Tcl_Interp *interp, 941 - StructureData *sdata, 942 - char *text 943 - ) 944 -{ 945 - StructureCP *parent; 946 - int ac, nm, only_whites; 947 - char *pc; 948 - 949 - DBG(fprintf (stderr, "probeText started, text: '%s'\n", text);) 950 - if (sdata->validationState == VALIDATION_FINISHED) { 951 - SetResult ("Validation finished."); 952 - return TCL_ERROR; 953 - } 954 - if (sdata->validationState == VALIDATION_READY) { 955 - SetResult ("No validation started"); 956 - return TCL_ERROR; 957 - } 958 - 959 - getContext (parent, ac, nm); 960 - 961 - while (ac < parent->numChildren) { 962 - if (parent->content[ac]->type == STRUCTURE_CTYPE_TEXT 963 - || mustMatch (parent->quants[ac], nm)) break; 964 - ac++; 965 - nm = 0; 966 - } 967 - if (ac < parent->numChildren) { 968 - if (parent->content[ac]->type == STRUCTURE_CTYPE_TEXT) { 969 - return checkText (interp, parent->content[ac], text); 970 - } 971 - } 972 - /* If we are here then there isn't a matching TEXT cp. Check, if 973 - * this is white space only between tags. */ 974 - only_whites = 1; 975 - pc = text; 976 - while (*pc) { 977 - if ( (*pc == ' ') || 978 - (*pc == '\n') || 979 - (*pc == '\r') || 980 - (*pc == '\t') ) { 981 - pc++; 982 - continue; 983 - } 984 - only_whites = 0; 985 - break; 986 - } 987 - if (only_whites) return TCL_OK; 988 - return TCL_ERROR; 989 -} 990 - 991 -static void 992 -startElement( 993 - void *userData, 994 - const char *name, 995 - const char **atts 996 -) 997 -{ 998 - ValidateMethodData *vdata = (ValidateMethodData *) userData; 999 - char *namespace; 1000 - const char *s; 1001 - int i = 0; 1002 - 1003 - DBG(fprintf (stderr, "startElement: '%s'\n", name);) 1004 - if (Tcl_DStringLength (vdata->cdata)) { 1005 - if (probeText (vdata->interp, vdata->sdata, 1006 - Tcl_DStringValue (vdata->cdata)) != TCL_OK) { 1007 - XML_StopParser (vdata->parser, 0); 1008 - } 1009 - } 1010 - s = name; 1011 - while (*s && *s != '\xFF') { 1012 - i++; s++; 1013 - } 1014 - namespace = NULL; 1015 - if (*s == '\xFF') { 1016 - s++; 1017 - if (i) { 1018 - if (i >= vdata->maxUriLen - 1) { 1019 - vdata->uri = (char *) REALLOC (vdata->uri, vdata->maxUriLen * 2); 1020 - vdata->maxUriLen *= 2; 1021 - } 1022 - memcpy (vdata->uri, name, i); 1023 - vdata->uri[i] = '\0'; 1024 - namespace = vdata->uri; 1025 - } 1026 - } else { 1027 - s = name; 1028 - } 1029 - 1030 - if (probeElement (vdata->interp, vdata->sdata, s, namespace) 1031 - != TCL_OK) { 1032 - XML_StopParser (vdata->parser, 0); 1033 - } 1034 -} 1035 - 1036 -static void 1037 -endElement ( 1038 - void *userData, 1039 - const char *name 1040 -) 1041 -{ 1042 - ValidateMethodData *vdata = (ValidateMethodData *) userData; 1043 - 1044 - DBG(fprintf (stderr, "endElement: '%s'\n", name);) 1045 - if (Tcl_DStringLength (vdata->cdata)) { 1046 - if (probeText (vdata->interp, vdata->sdata, 1047 - Tcl_DStringValue (vdata->cdata)) != TCL_OK) { 1048 - XML_StopParser (vdata->parser, 0); 1049 - } 1050 - } 1051 - if (probeElementEnd (vdata->interp, vdata->sdata) 1052 - != TCL_OK) { 1053 - XML_StopParser (vdata->parser, 0); 1054 - } 1055 -} 1056 - 1057 -static void 1058 -characterDataHandler ( 1059 - void *userData, 1060 - const char *s, 1061 - int len 1062 -) 1063 -{ 1064 - ValidateMethodData *vdata = (ValidateMethodData *) userData; 1065 - 1066 - Tcl_DStringAppend (vdata->cdata, s, len); 1067 -} 1068 - 1069 -static int 1070 -validateString ( 1071 - Tcl_Interp *interp, 1072 - StructureData *sdata, 1073 - char *xmlstr, 1074 - int len 1075 - ) 1076 -{ 1077 - XML_Parser parser; 1078 - char sep = '\xFF'; 1079 - ValidateMethodData vdata; 1080 - Tcl_DString cdata; 1081 - Tcl_Obj *resultObj; 1082 - char sl[50], sc[50]; 1083 - int result; 1084 - 1085 - parser = XML_ParserCreate_MM (NULL, MEM_SUITE, &sep); 1086 - vdata.interp = interp; 1087 - vdata.sdata = sdata; 1088 - vdata.parser = parser; 1089 - Tcl_DStringInit (&cdata); 1090 - vdata.cdata = &cdata; 1091 - vdata.uri = (char *) MALLOC (URI_BUFFER_LEN_INIT); 1092 - vdata.maxUriLen = URI_BUFFER_LEN_INIT; 1093 - XML_SetUserData (parser, &vdata); 1094 - XML_SetElementHandler (parser, startElement, endElement); 1095 - XML_SetCharacterDataHandler (parser, characterDataHandler); 1096 - 1097 - if (XML_Parse (parser, xmlstr, len, 1) != XML_STATUS_OK) { 1098 - resultObj = Tcl_NewObj (); 1099 - sprintf(sl, "%ld", XML_GetCurrentLineNumber(parser)); 1100 - sprintf(sc, "%ld", XML_GetCurrentColumnNumber(parser)); 1101 - Tcl_AppendStringsToObj (resultObj, "error \"", 1102 - Tcl_GetStringResult (interp),"\" at line ", 1103 - sl, " character ", sc, NULL); 1104 - Tcl_SetObjResult (interp, resultObj); 1105 - result = TCL_ERROR; 1106 - } else { 1107 - result = TCL_OK; 1108 - } 1109 - XML_ParserFree (parser); 1110 - Tcl_DStringFree (&cdata); 1111 - FREE (vdata.uri); 1112 - return result; 1113 -} 1114 - 1115 -int 1116 -structureInstanceCmd ( 1117 - ClientData clientData, 1118 - Tcl_Interp *interp, 1119 - int objc, 1120 - Tcl_Obj *const objv[] 1121 - ) 1122 -{ 1123 - int methodIndex, keywordIndex, hnew, patternIndex; 1124 - int result = TCL_OK, forwardDef = 0, i = 0; 1125 - int savedDefineToplevel, type, len; 1126 - unsigned int savedNumPatternList; 1127 - StructureData *sdata = (StructureData *) clientData; 1128 - Tcl_HashTable *hashTable; 1129 - Tcl_HashEntry *entryPtr; 1130 - StructureCP *pattern, *current = NULL; 1131 - void *namespacePtr, *savedNamespacePtr; 1132 - char *xmlstr; 1133 - 1134 - static const char *structureInstanceMethods[] = { 1135 - "defelement", "defpattern", "start", "event", "delete", 1136 - "nrForwardDefinitions", "state", "reset", "define", 1137 - "validate", NULL 1138 - }; 1139 - enum structureInstanceMethod { 1140 - m_defelement, m_defpattern, m_start, m_event, m_delete, 1141 - m_nrForwardDefinitions, m_state, m_reset, m_define, 1142 - m_validate 1143 - }; 1144 - 1145 - static const char *eventKeywords[] = { 1146 - "start", "end", "text", NULL 1147 - }; 1148 - 1149 - enum eventKeyword 1150 - { 1151 - k_elementstart, k_elementend, k_text 1152 - }; 1153 - 1154 - if (objc < 2) { 1155 - Tcl_WrongNumArgs (interp, 1, objv, "subcommand ?arguments?"); 1156 - return TCL_ERROR; 1157 - } 1158 - 1159 - if (sdata == NULL) { 1160 - /* Inline defined defelement, defpattern or start */ 1161 - sdata = GETASI; 1162 - CHECK_SI; 1163 - i = 1; 1164 - } 1165 - 1166 - if (Tcl_GetIndexFromObj (interp, objv[1-i], structureInstanceMethods, 1167 - "method", 0, &methodIndex) 1168 - != TCL_OK) { 1169 - return TCL_ERROR; 1170 - } 1171 - 1172 - Tcl_ResetResult (interp); 1173 - switch ((enum structureInstanceMethod) methodIndex) { 1174 - case m_defelement: 1175 - case m_defpattern: 1176 - if (objc != 4-i && objc != 5-i) { 1177 - Tcl_WrongNumArgs (interp, 1-i, objv, "<name>" 1178 - " ?<namespace>? pattern"); 1179 - return TCL_ERROR; 1180 - } 1181 - if ((enum structureInstanceMethod) methodIndex == m_defelement) { 1182 - hashTable = &sdata->element; 1183 - type = STRUCTURE_CTYPE_NAME; 1184 - } else { 1185 - hashTable = &sdata->pattern; 1186 - type = STRUCTURE_CTYPE_PATTERN; 1187 - } 1188 - savedNumPatternList = sdata->numPatternList; 1189 - namespacePtr = NULL; 1190 - patternIndex = 3-i; 1191 - if (objc == 5-i) { 1192 - patternIndex = 4-i; 1193 - entryPtr = Tcl_CreateHashEntry (&sdata->namespace, 1194 - Tcl_GetString (objv[3-i]), &hnew); 1195 - if (entryPtr != sdata->emptyNamespace) { 1196 - namespacePtr = Tcl_GetHashKey (&sdata->namespace, 1197 - entryPtr); 1198 - } 1199 - } 1200 - entryPtr = Tcl_CreateHashEntry (hashTable, 1201 - Tcl_GetString (objv[2-i]), &hnew); 1202 - pattern = NULL; 1203 - if (!hnew) { 1204 - pattern = (StructureCP *) Tcl_GetHashValue (entryPtr); 1205 - while (pattern) { 1206 - if (pattern->namespace == namespacePtr) { 1207 - if (pattern->flags & FORWARD_PATTERN_DEF 1208 - || pattern->flags & PLACEHOLDER_PATTERN_DEF) { 1209 - forwardDef = 1; 1210 - break; 1211 - } 1212 - if ((enum structureInstanceMethod) methodIndex 1213 - == m_defelement) { 1214 - SetResult ("Element already defined " 1215 - "in this namespace."); 1216 - } else { 1217 - SetResult ("Pattern already defined " 1218 - "in this namespace."); 1219 - } 1220 - return TCL_ERROR; 1221 - } 1222 - pattern = pattern->next; 1223 - } 1224 - } 1225 - if (pattern == NULL) { 1226 - pattern = initStructureCP (type, namespacePtr, 1227 - Tcl_GetHashKey (hashTable, entryPtr)); 1228 - if (!hnew) { 1229 - current = (StructureCP *) Tcl_GetHashValue (entryPtr); 1230 - pattern->next = current; 1231 - } 1232 - REMEMBER_PATTERN (pattern); 1233 - Tcl_SetHashValue (entryPtr, pattern); 1234 - } 1235 - 1236 - if (!sdata->defineToplevel) { 1237 - SETASI(sdata); 1238 - } 1239 - savedDefineToplevel = sdata->defineToplevel; 1240 - savedNamespacePtr = sdata->currentNamespace; 1241 - sdata->defineToplevel = 0; 1242 - sdata->currentNamespace = namespacePtr; 1243 - sdata->currentContent = pattern->content; 1244 - sdata->currentQuants = pattern->quants; 1245 - sdata->numChildren = 0; 1246 - sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 1247 - sdata->evalStub[3] = objv[patternIndex]; 1248 - result = Tcl_EvalObjv (interp, 4, sdata->evalStub, 1249 - TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL); 1250 - sdata->currentNamespace = NULL; 1251 - pattern->content = sdata->currentContent; 1252 - pattern->quants = sdata->currentQuants; 1253 - pattern->numChildren = sdata->numChildren; 1254 - if (result == TCL_OK) { 1255 - if (forwardDef) { 1256 - if (pattern->flags & FORWARD_PATTERN_DEF) { 1257 - sdata->forwardPatternDefs--; 1258 - pattern->flags &= ~FORWARD_PATTERN_DEF; 1259 - } 1260 - pattern->flags &= ~PLACEHOLDER_PATTERN_DEF; 1261 - } 1262 - } else { 1263 - cleanupLastPattern (sdata, savedNumPatternList); 1264 - } 1265 - sdata->defineToplevel = savedDefineToplevel; 1266 - sdata->currentNamespace = savedNamespacePtr; 1267 - if (!savedDefineToplevel) { 1268 - SETASI(0); 1269 - } 1270 - break; 1271 - 1272 - case m_define: 1273 - if (objc != 3) { 1274 - Tcl_WrongNumArgs (interp, 2, objv, "<definition commands>"); 1275 - return TCL_ERROR; 1276 - } 1277 - SETASI(sdata); 1278 - savedNumPatternList = sdata->numPatternList; 1279 - sdata->currentNamespace = 0; 1280 - sdata->currentContent = NULL; 1281 - sdata->currentQuants = NULL; 1282 - sdata->numChildren = 0; 1283 - sdata->contentSize = 0; 1284 - sdata->defineToplevel = 1; 1285 - sdata->evalStub[3] = objv[2]; 1286 - result = Tcl_EvalObjv (interp, 4, sdata->evalStub, 1287 - TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL); 1288 - if (result != TCL_OK) { 1289 - cleanupLastPattern (sdata, savedNumPatternList); 1290 - } 1291 - sdata->defineToplevel = 0; 1292 - SETASI(0); 1293 - break; 1294 - 1295 - case m_start: 1296 - if (objc < 3-i || objc > 3-i) { 1297 - Tcl_WrongNumArgs (interp, 2-i, objv, "<documentElement>" 1298 - " ?<namespace>?"); 1299 - return TCL_ERROR; 1300 - } 1301 - if (sdata->start) { 1302 - FREE (sdata->start); 1303 - } 1304 - if (objc == 3-i && strcmp (Tcl_GetString (objv[2-i]), "") == 0) { 1305 - if (sdata->startNamespace) { 1306 - FREE (sdata->startNamespace); 1307 - } 1308 - sdata->start = NULL; 1309 - break; 1310 - } 1311 - sdata->start = tdomstrdup (Tcl_GetString (objv[2-i])); 1312 - if (objc == 4-i) { 1313 - if (sdata->startNamespace) { 1314 - FREE (sdata->startNamespace); 1315 - } 1316 - sdata->startNamespace = 1317 - tdomstrdup (Tcl_GetString (objv[3-i])); 1318 - } 1319 - break; 1320 - 1321 - case m_event: 1322 - if (objc < 3) { 1323 - Tcl_WrongNumArgs (interp, 2, objv, "<eventType>" 1324 - " ?<type specific data>?"); 1325 - return TCL_ERROR; 1326 - } 1327 - if (Tcl_GetIndexFromObj (interp, objv[2], eventKeywords, 1328 - "keyword", 0, &keywordIndex) 1329 - != TCL_OK) { 1330 - return TCL_ERROR; 1331 - } 1332 - switch ((enum eventKeyword) keywordIndex) { 1333 - case k_elementstart: 1334 - if (objc < 4 && objc > 6) { 1335 - Tcl_WrongNumArgs (interp, 3, objv, "<elementname>" 1336 - "?<attInfo>? ?<namespace>?"); 1337 - return TCL_ERROR; 1338 - } 1339 - if (objc == 6) { 1340 - entryPtr = Tcl_FindHashEntry (&sdata->namespace, 1341 - Tcl_GetString (objv[5])); 1342 - if (entryPtr && entryPtr != sdata->emptyNamespace) { 1343 - namespacePtr = Tcl_GetHashKey (&sdata->namespace, 1344 - entryPtr); 1345 - } else { 1346 - namespacePtr = NULL; 1347 - } 1348 - } else { 1349 - namespacePtr = NULL; 1350 - } 1351 - result = probeElement (interp, sdata, Tcl_GetString (objv[3]), 1352 - namespacePtr); 1353 - break; 1354 - case k_elementend: 1355 - if (objc != 3) { 1356 - Tcl_WrongNumArgs (interp, 3, objv, "No arguments expected."); 1357 - return TCL_ERROR; 1358 - } 1359 - result = probeElementEnd (interp, sdata); 1360 - break; 1361 - 1362 - case k_text: 1363 - if (objc != 4) { 1364 - Tcl_WrongNumArgs (interp, 3, objv, "<text>"); 1365 - return TCL_ERROR; 1366 - } 1367 - result = probeText (interp, sdata, Tcl_GetString (objv[3])); 1368 - break; 1369 - } 1370 - break; 1371 - 1372 - case m_delete: 1373 - if (objc != 2) { 1374 - Tcl_WrongNumArgs(interp, 2, objv, ""); 1375 - return TCL_ERROR; 1376 - } 1377 - Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); 1378 - break; 1379 - 1380 - case m_nrForwardDefinitions: 1381 - if (objc != 2) { 1382 - Tcl_WrongNumArgs(interp, 2, objv, ""); 1383 - return TCL_ERROR; 1384 - } 1385 - SetIntResult(sdata->forwardPatternDefs); 1386 - break; 1387 - 1388 - case m_state: 1389 - switch (sdata->validationState) { 1390 - case VALIDATION_READY: 1391 - SetResult ("READY"); 1392 - break; 1393 - case VALIDATION_STARTED: 1394 - SetResult ("VALIDATING"); 1395 - break; 1396 - case VALIDATION_FINISHED: 1397 - SetResult ("FINISHED"); 1398 - break; 1399 - default: 1400 - SetResult ("Internal error: Invalid validation state."); 1401 - return TCL_ERROR; 1402 - } 1403 - break; 1404 - 1405 - case m_reset: 1406 - sdata->stackPtr = 0; 1407 - sdata->validationState = VALIDATION_READY; 1408 - break; 1409 - 1410 - case m_validate: 1411 - if (objc < 3 || objc > 4) { 1412 - Tcl_WrongNumArgs (interp, 2, objv, "<xml> ?resultVarName?"); 1413 - return TCL_ERROR; 1414 - } 1415 - xmlstr = Tcl_GetStringFromObj (objv[2], &len); 1416 - if (validateString (interp, sdata, xmlstr, len) == TCL_OK) { 1417 - SetBooleanResult (1); 1418 - } else { 1419 - if (objc == 4) { 1420 - Tcl_SetVar (interp, Tcl_GetString (objv[3]), 1421 - Tcl_GetStringResult (interp), 0); 1422 - } 1423 - SetBooleanResult (0); 1424 - } 1425 - break; 1426 - 1427 - default: 1428 - Tcl_SetResult (interp, "unknown method", NULL); 1429 - result = TCL_ERROR; 1430 - break; 1431 - 1432 - } 1433 - return result; 1434 -} 1435 - 1436 - 1437 -/* 1438 - *---------------------------------------------------------------------------- 1439 - * 1440 - * tDOM_StructureObjCmd -- 1441 - * 1442 - * This procedure is invoked to process the "structure" command. 1443 - * See the user documentation for what it does. 1444 - * 1445 - * Results: 1446 - * A standard Tcl result. 1447 - * 1448 - * Side effects: 1449 - * 1450 - * 1451 - *---------------------------------------------------------------------------- 1452 - */ 1453 - 1454 -int 1455 -tDOM_StructureObjCmd ( 1456 - ClientData clientData, 1457 - Tcl_Interp *interp, 1458 - int objc, 1459 - Tcl_Obj *const objv[] 1460 - ) 1461 -{ 1462 - int methodIndex, result = TCL_OK; 1463 - StructureData *sdata; 1464 - 1465 - static const char *structureMethods[] = { 1466 - "create", NULL 1467 - }; 1468 - enum structureMethod { 1469 - m_create 1470 - }; 1471 - 1472 - if (objc < 2 || objc > 3) { 1473 - Tcl_WrongNumArgs (interp, 1, objv, "subcommand ?argument?"); 1474 - return TCL_ERROR; 1475 - } 1476 - 1477 - if (objc == 2) { 1478 - methodIndex = m_create; 1479 - } else { 1480 - if (Tcl_GetIndexFromObj (interp, objv[1], structureMethods, 1481 - "method", 0, &methodIndex) 1482 - != TCL_OK) { 1483 - return TCL_ERROR; 1484 - } 1485 - } 1486 - 1487 - Tcl_ResetResult (interp); 1488 - switch ((enum structureMethod) methodIndex) { 1489 - case m_create: 1490 - sdata = initStructureData (); 1491 - Tcl_CreateObjCommand (interp, Tcl_GetString(objv[2]), 1492 - structureInstanceCmd, 1493 - (ClientData) sdata, 1494 - structureInstanceDelete); 1495 - Tcl_SetObjResult (interp, objv[2]); 1496 - break; 1497 - 1498 - default: 1499 - Tcl_SetResult (interp, "unknown method", NULL); 1500 - result = TCL_ERROR; 1501 - break; 1502 - 1503 - } 1504 - return result; 1505 -} 1506 - 1507 - 1508 -static StructureQuant * 1509 -initStructureQuant ( 1510 - StructureData * sdata, 1511 - Structure_Content_Quant quantType, 1512 - int n, 1513 - int m 1514 - ) 1515 -{ 1516 - StructureQuant * quant; 1517 - 1518 - quant = TMALLOC (StructureQuant); 1519 - quant->type = quantType; 1520 - quant->minOccur = n; 1521 - quant->maxOccur = m; 1522 - if (sdata->numQuants == sdata->quantsSize) { 1523 - sdata->quants = REALLOC ( 1524 - sdata->quants, 1525 - sizeof (StructureQuant*) * 2 * sdata->quantsSize 1526 - ); 1527 - sdata->quantsSize *= 2; 1528 - } 1529 - sdata->quants[sdata->numQuants] = quant; 1530 - sdata->numQuants++; 1531 - return quant; 1532 -} 1533 - 1534 - 1535 -static StructureQuant * 1536 -getQuant ( 1537 - Tcl_Interp *interp, 1538 - StructureData *sdata, 1539 - Tcl_Obj *quantObj 1540 - ) 1541 -{ 1542 - char *quantStr; 1543 - int len, n, m; 1544 - Tcl_Obj *thisObj; 1545 - 1546 - if (!quantObj) { 1547 - return quantOne; 1548 - } 1549 - quantStr = Tcl_GetStringFromObj (quantObj, &len); 1550 - if (len == 1) { 1551 - switch (quantStr[0]) { 1552 - case '!': 1553 - return quantOne; 1554 - case '*': 1555 - return quantRep; 1556 - case '?': 1557 - return quantOpt; 1558 - case '+': 1559 - return quantPlus; 1560 - } 1561 - } 1562 - if (Tcl_ListObjLength (interp, quantObj, &len) != TCL_OK) { 1563 - SetResult ("Invalid quant specifier."); 1564 - return NULL; 1565 - } 1566 - if (len != 1 && len != 2) { 1567 - SetResult ("Invalid quant specifier."); 1568 - return NULL; 1569 - } 1570 - if (len == 1) { 1571 - if (Tcl_GetIntFromObj (interp, quantObj, &n) != TCL_OK) { 1572 - SetResult ("Invalid quant specifier."); 1573 - return NULL; 1574 - } 1575 - if (n < 1) { 1576 - SetResult ("Invalid quant specifier."); 1577 - return NULL; 1578 - } 1579 - if (n == 1) { 1580 - return quantOne; 1581 - } 1582 - return initStructureQuant (sdata, STRUCTURE_CQUANT_NM, n, n); 1583 - } 1584 - /* The "list-ness" of the quantObj is already checked by the 1585 - * Tcl_ListObjLength() call above, no need to check result. */ 1586 - Tcl_ListObjIndex (interp, quantObj, 0, &thisObj); 1587 - if (Tcl_GetIntFromObj (interp, thisObj, &n) != TCL_OK) { 1588 - SetResult ("Invalid quant specifier."); 1589 - return NULL; 1590 - } 1591 - if (n < 0) { 1592 - SetResult ("Invalid quant specifier."); 1593 - return NULL; 1594 - } 1595 - Tcl_ListObjIndex (interp, quantObj, 1, &thisObj); 1596 - if (Tcl_GetIntFromObj (interp, thisObj, &m) != TCL_OK) { 1597 - SetResult ("Invalid quant specifier."); 1598 - return NULL; 1599 - } 1600 - if (n >= m) { 1601 - SetResult ("Invalid quant specifier."); 1602 - return NULL; 1603 - } 1604 - if (n == 0 && m == 1) { 1605 - return quantOpt; 1606 - } 1607 - return initStructureQuant (sdata, STRUCTURE_CQUANT_NM, n, m); 1608 -} 1609 - 1610 -/* Implements the grammar definition commands "empty" and "any" */ 1611 -static int 1612 -EmptyAnyPatternObjCmd ( 1613 - ClientData clientData, 1614 - Tcl_Interp *interp, 1615 - int objc, 1616 - Tcl_Obj *const objv[] 1617 - ) 1618 -{ 1619 - StructureData *sdata = GETASI; 1620 - StructureCP *pattern; 1621 - 1622 - CHECK_SI 1623 - CHECK_TOPLEVEL 1624 - checkNrArgs (1,1,"No arguments expected."); 1625 - pattern = initStructureCP ((Structure_CP_Type) clientData, 1626 - NULL, NULL); 1627 - REMEMBER_PATTERN (pattern) 1628 - ADD_TO_CONTENT (pattern, quantRep) 1629 - return TCL_OK; 1630 -} 1631 - 1632 -static int 1633 -evalDefinition ( 1634 - Tcl_Interp *interp, 1635 - StructureData *sdata, 1636 - Tcl_Obj *definition, 1637 - StructureCP *pattern, 1638 - StructureQuant *quant 1639 - ) 1640 -{ 1641 - StructureCP **savedCurrentContent; 1642 - StructureQuant **savedCurrentQuant; 1643 - unsigned int savedNumChildren, savedContenSize; 1644 - int result; 1645 - 1646 - /* Save some state of sdata .. */ 1647 - savedCurrentContent = sdata->currentContent; 1648 - savedCurrentQuant = sdata->currentQuants; 1649 - savedNumChildren = sdata->numChildren; 1650 - savedContenSize = sdata->contentSize; 1651 - /* ... and prepare sdata for definition evaluation. */ 1652 - sdata->currentContent = pattern->content; 1653 - sdata->currentQuants = pattern->quants; 1654 - sdata->numChildren = 0; 1655 - sdata->contentSize = CONTENT_ARRAY_SIZE_INIT; 1656 - 1657 - result = Tcl_EvalObjEx (interp, definition, TCL_EVAL_DIRECT); 1658 - 1659 - /* Save the definition evaluation results to the pattern ... */ 1660 - pattern->content = sdata->currentContent; 1661 - pattern->quants = sdata->currentQuants; 1662 - pattern->numChildren = sdata->numChildren; 1663 - /* ... and restore the previously saved sdata states */ 1664 - sdata->currentContent = savedCurrentContent; 1665 - sdata->currentQuants = savedCurrentQuant; 1666 - sdata->numChildren = savedNumChildren; 1667 - sdata->contentSize = savedContenSize; 1668 - 1669 - if (result == TCL_OK) { 1670 - REMEMBER_PATTERN (pattern); 1671 - ADD_TO_CONTENT (pattern, quant); 1672 - } else { 1673 - freeStructureCP (pattern); 1674 - } 1675 - return result; 1676 -} 1677 - 1678 -/* Implements the grammar definition commands "element" and "ref" */ 1679 -static int 1680 -NamedPatternObjCmd ( 1681 - ClientData clientData, 1682 - Tcl_Interp *interp, 1683 - int objc, 1684 - Tcl_Obj *const objv[] 1685 - ) 1686 -{ 1687 - StructureData *sdata = GETASI; 1688 - Structure_CP_Type patternType = (Structure_CP_Type) clientData; 1689 - Tcl_HashTable *hashTable; 1690 - Tcl_HashEntry *entryPtr; 1691 - StructureCP *pattern = NULL, *current; 1692 - StructureQuant *quant; 1693 - int hnew; 1694 - 1695 - CHECK_SI 1696 - CHECK_TOPLEVEL 1697 - if (patternType == STRUCTURE_CTYPE_NAME) { 1698 - checkNrArgs (2,4,"Expected: elementName ?quant? ?pattern?"); 1699 - hashTable = &sdata->element; 1700 - } else { 1701 - checkNrArgs (2,3,"Expected: patternName ?quant?"); 1702 - hashTable = &sdata->pattern; 1703 - } 1704 - 1705 - quant = getQuant (interp, sdata, objc == 2 ? NULL : objv[2]); 1706 - if (!quant) { 1707 - return TCL_ERROR; 1708 - } 1709 - entryPtr = Tcl_CreateHashEntry (hashTable, 1710 - Tcl_GetString(objv[1]), &hnew); 1711 - if (objc < 4) { 1712 - /* Reference to an element or pattern */ 1713 - if (!hnew) { 1714 - pattern = (StructureCP *) Tcl_GetHashValue (entryPtr); 1715 - while (pattern) { 1716 - if (pattern->namespace == sdata->currentNamespace) { 1717 - break; 1718 - } 1719 - pattern = pattern->next; 1720 - } 1721 - } 1722 - if (!pattern) { 1723 - pattern = initStructureCP ( 1724 - patternType, 1725 - sdata->currentNamespace, 1726 - Tcl_GetHashKey (hashTable, entryPtr) 1727 - ); 1728 - pattern->flags |= FORWARD_PATTERN_DEF; 1729 - sdata->forwardPatternDefs++; 1730 - if (!hnew) { 1731 - current = (StructureCP *) Tcl_GetHashValue (entryPtr); 1732 - pattern->next = current; 1733 - } 1734 - REMEMBER_PATTERN (pattern); 1735 - Tcl_SetHashValue (entryPtr, pattern); 1736 - } 1737 - ADD_TO_CONTENT (pattern, quant); 1738 - } else { 1739 - /* Local definition of this element */ 1740 - if (hnew) { 1741 - pattern = initStructureCP ( 1742 - STRUCTURE_CTYPE_NAME, 1743 - sdata->currentNamespace, 1744 - Tcl_GetHashKey (hashTable, entryPtr) 1745 - ); 1746 - pattern->flags |= PLACEHOLDER_PATTERN_DEF; 1747 - REMEMBER_PATTERN (pattern); 1748 - Tcl_SetHashValue (entryPtr, pattern); 1749 - } 1750 - pattern = initStructureCP ( 1751 - STRUCTURE_CTYPE_NAME, 1752 - sdata->currentNamespace, 1753 - Tcl_GetHashKey (hashTable, entryPtr) 1754 - ); 1755 - pattern->flags |= LOCAL_DEFINED_ELEMENT; 1756 - return evalDefinition (interp, sdata, objv[3], pattern, quant); 1757 - } 1758 - return TCL_OK; 1759 -} 1760 - 1761 -/* Implements the grammar definition commands "choice", "group", 1762 - * "interleave" and "mixed" */ 1763 -static int 1764 -AnonPatternObjCmd ( 1765 - ClientData clientData, 1766 - Tcl_Interp *interp, 1767 - int objc, 1768 - Tcl_Obj *const objv[] 1769 - ) 1770 -{ 1771 - StructureData *sdata = GETASI; 1772 - Structure_CP_Type patternType = (Structure_CP_Type) clientData; 1773 - StructureQuant *quant; 1774 - StructureCP *pattern; 1775 - 1776 - CHECK_SI 1777 - CHECK_TOPLEVEL 1778 - checkNrArgs (2,3,"Expected: ?quant? definition"); 1779 - quant = getQuant (interp, sdata, objc == 2 ? NULL : objv[1]); 1780 - if (!quant) { 1781 - return TCL_ERROR; 1782 - } 1783 - 1784 - pattern = initStructureCP (patternType, NULL, NULL); 1785 - 1786 - return evalDefinition (interp, sdata, objc == 2 ? objv[1] : objv[2], 1787 - pattern, quant); 1788 -} 1789 - 1790 -static int 1791 -AttributePatternObjCmd ( 1792 - ClientData clientData, 1793 - Tcl_Interp *interp, 1794 - int objc, 1795 - Tcl_Obj *const objv[] 1796 - ) 1797 -{ 1798 - 1799 - return TCL_OK; 1800 -} 1801 - 1802 -static int 1803 -NamespacePatternObjCmd ( 1804 - ClientData clientData, 1805 - Tcl_Interp *interp, 1806 - int objc, 1807 - Tcl_Obj *const objv[] 1808 - ) 1809 -{ 1810 - StructureData *sdata = GETASI; 1811 - char *currentNamespace; 1812 - Tcl_HashEntry *entryPtr; 1813 - int hnew, result; 1814 - 1815 - CHECK_SI 1816 - CHECK_TOPLEVEL 1817 - checkNrArgs (3,3,"Expected: namespace pattern"); 1818 - 1819 - currentNamespace = sdata->currentNamespace; 1820 - entryPtr = Tcl_CreateHashEntry (&sdata->namespace, 1821 - objv[1], &hnew); 1822 - if (entryPtr == sdata->emptyNamespace) { 1823 - sdata->currentNamespace = NULL; 1824 - } else { 1825 - sdata->currentNamespace = (char *) 1826 - Tcl_GetHashKey (&sdata->namespace, entryPtr); 1827 - } 1828 - result = Tcl_EvalObjEx (interp, objv[2], TCL_EVAL_DIRECT); 1829 - sdata->currentNamespace = currentNamespace; 1830 - return result; 1831 -} 1832 - 1833 -static int 1834 -TextPatternObjCmd ( 1835 - ClientData clientData, 1836 - Tcl_Interp *interp, 1837 - int objc, 1838 - Tcl_Obj *const objv[] 1839 - ) 1840 -{ 1841 - StructureData *sdata = GETASI; 1842 - StructureCP *pattern; 1843 - 1844 - CHECK_SI 1845 - CHECK_TOPLEVEL 1846 - checkNrArgs (1,1,"No arguments expected."); 1847 - pattern = initStructureCP ((Structure_CP_Type) clientData, 1848 - NULL, NULL); 1849 - REMEMBER_PATTERN (pattern) 1850 - ADD_TO_CONTENT (pattern, quantOne) 1851 - return TCL_OK; 1852 -} 1853 - 1854 -void 1855 -tDOM_StructureInit ( 1856 - Tcl_Interp *interp 1857 - ) 1858 -{ 1859 - memset (quantOne, 0, sizeof (StructureQuant)); 1860 - quantOne->type = STRUCTURE_CQUANT_ONE; 1861 - memset (quantOpt, 0, sizeof (StructureQuant)); 1862 - quantOpt->type = STRUCTURE_CQUANT_OPT; 1863 - memset (quantRep, 0, sizeof (StructureQuant)); 1864 - quantRep->type = STRUCTURE_CQUANT_REP; 1865 - memset (quantPlus, 0, sizeof (StructureQuant)); 1866 - quantPlus->type = STRUCTURE_CQUANT_PLUS; 1867 - 1868 - /* Inline definition commands. */ 1869 - Tcl_CreateObjCommand (interp, "tdom::structure::defelement", 1870 - structureInstanceCmd, NULL, NULL); 1871 - Tcl_CreateObjCommand (interp, "tdom::structure::defpattern", 1872 - structureInstanceCmd, NULL, NULL); 1873 - Tcl_CreateObjCommand (interp, "tdom::structure::start", 1874 - structureInstanceCmd, NULL, NULL); 1875 - 1876 - /* The "empty" and "any" definition commands. */ 1877 - Tcl_CreateObjCommand (interp, "tdom::structure::empty", 1878 - EmptyAnyPatternObjCmd, 1879 - (ClientData) STRUCTURE_CTYPE_EMPTY, NULL); 1880 - Tcl_CreateObjCommand (interp, "tdom::structure::any", 1881 - EmptyAnyPatternObjCmd, 1882 - (ClientData) STRUCTURE_CTYPE_ANY, NULL); 1883 - 1884 - /* The named pattern commands "element" and "ref". */ 1885 - Tcl_CreateObjCommand (interp, "tdom::structure::element", 1886 - NamedPatternObjCmd, 1887 - (ClientData) STRUCTURE_CTYPE_NAME, NULL); 1888 - Tcl_CreateObjCommand (interp, "tdom::structure::ref", 1889 - NamedPatternObjCmd, 1890 - (ClientData) STRUCTURE_CTYPE_PATTERN, NULL); 1891 - /* The anonymous pattern commands "choise", "mixed", "interleave" 1892 - * and "group". */ 1893 - Tcl_CreateObjCommand (interp, "tdom::structure::choice", 1894 - AnonPatternObjCmd, 1895 - (ClientData) STRUCTURE_CTYPE_CHOICE, NULL); 1896 - Tcl_CreateObjCommand (interp, "tdom::structure::mixed", 1897 - AnonPatternObjCmd, 1898 - (ClientData) STRUCTURE_CTYPE_MIXED, NULL); 1899 - Tcl_CreateObjCommand (interp, "tdom::structure::interleave", 1900 - AnonPatternObjCmd, 1901 - (ClientData) STRUCTURE_CTYPE_INTERLEAVE, NULL); 1902 - Tcl_CreateObjCommand (interp, "tdom::structure::group", 1903 - AnonPatternObjCmd, 1904 - (ClientData) STRUCTURE_CTYPE_GROUP, NULL); 1905 - 1906 - /* The "attribute", "namespace" and "text" definition commands. */ 1907 - Tcl_CreateObjCommand (interp, "tdom::structure::attribute", 1908 - AttributePatternObjCmd, NULL, NULL); 1909 - Tcl_CreateObjCommand (interp, "tdom::structure::namespace", 1910 - NamespacePatternObjCmd, NULL, NULL); 1911 - Tcl_CreateObjCommand (interp, "tdom::structure::text", 1912 - TextPatternObjCmd, NULL, NULL); 1913 -} 1914 - 1915 -# else /* #ifndef TDOM_NO_STRUCTURE */ 1916 -int 1917 -structureInstanceCmd ( 1918 - ClientData clientData, 1919 - Tcl_Interp *interp, 1920 - int objc, 1921 - Tcl_Obj *const objv[] 1922 - ) 1923 -{ 1924 - return TCL_OK; 1925 -} 1926 - 1927 -int 1928 -probeElement ( 1929 - Tcl_Interp *interp, 1930 - StructureData *sdata, 1931 - char *name, 1932 - void *namespace 1933 - ) 1934 -{ 1935 - return TCL_OK; 1936 -} 1937 - 1938 -int 1939 -probeElementEnd ( 1940 - Tcl_Interp * interp, 1941 - StructureData *sdata 1942 - ) 1943 -{ 1944 - return TCL_OK; 1945 -} 1946 - 1947 -int 1948 -probeText ( 1949 - Tcl_Interp *interp, 1950 - StructureData *sdata, 1951 - char *text 1952 - ) 1953 -{ 1954 - return TCL_OK; 1955 -} 1956 - 1957 -#endif /* #ifndef TDOM_NO_STRUCTURE */
Deleted generic/structure.h.
1 -/*---------------------------------------------------------------------------- 2 -| Copyright (c) 2018 Rolf Ade (rolf@pointsman.de) 3 -|----------------------------------------------------------------------------- 4 -| 5 -| 6 -| The contents of this file are subject to the Mozilla Public License 7 -| Version 2.0 (the "License"); you may not use this file except in 8 -| compliance with the License. You may obtain a copy of the License at 9 -| http://www.mozilla.org/MPL/ 10 -| 11 -| Software distributed under the License is distributed on an "AS IS" 12 -| basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 13 -| License for the specific language governing rights and limitations 14 -| under the License. 15 -| 16 -| Contributor(s): 17 -| 18 -| 19 -| written by Rolf Ade 20 -| November 2018 21 -| 22 -\---------------------------------------------------------------------------*/ 23 - 24 -#ifndef __STRUCTURE_H__ 25 -#define __STRUCTURE_H__ 26 - 27 -typedef enum { 28 - STRUCTURE_CTYPE_EMPTY, 29 - STRUCTURE_CTYPE_ANY, 30 - STRUCTURE_CTYPE_MIXED, 31 - STRUCTURE_CTYPE_NAME, 32 - STRUCTURE_CTYPE_CHOICE, 33 - STRUCTURE_CTYPE_INTERLEAVE, 34 - STRUCTURE_CTYPE_PATTERN, 35 - STRUCTURE_CTYPE_GROUP, 36 - STRUCTURE_CTYPE_TEXT 37 -} Structure_CP_Type; 38 - 39 -typedef enum { 40 - STRUCTURE_CQUANT_ONE, 41 - STRUCTURE_CQUANT_OPT, 42 - STRUCTURE_CQUANT_REP, 43 - STRUCTURE_CQUANT_PLUS, 44 - STRUCTURE_CQUANT_NM 45 -} Structure_Content_Quant; 46 - 47 -typedef unsigned int QuantFlags; 48 - 49 -typedef struct 50 -{ 51 - Structure_Content_Quant type; 52 - int minOccur; 53 - int maxOccur; 54 -} StructureQuant; 55 - 56 -typedef unsigned int StructureFlags; 57 - 58 -typedef struct StructureCP 59 -{ 60 - Structure_CP_Type type; 61 - char *namespace; 62 - char *name; 63 - struct StructureCP *next; 64 - StructureFlags flags; 65 - struct StructureCP **content; 66 - StructureQuant **quants; 67 - unsigned int numChildren; 68 -} StructureCP; 69 - 70 -typedef struct StructureValidationStack 71 -{ 72 - StructureCP *pattern; 73 - struct StructureValidationStack *next; 74 - struct StructureValidationStack *down; 75 - int activeChild; 76 - int deep; 77 - int nrMatched; 78 - unsigned int stacklistWatermark; 79 -} StructureValidationStack; 80 - 81 -typedef enum { 82 - VALIDATION_READY, 83 - VALIDATION_STARTED, 84 - VALIDATION_FINISHED 85 -} ValidationState; 86 - 87 -typedef struct 88 -{ 89 - char *start; 90 - char *startNamespace; 91 - Tcl_HashTable element; 92 - Tcl_HashTable namespace; 93 - Tcl_HashEntry *emptyNamespace; 94 - Tcl_HashTable pattern; 95 - StructureCP **patternList; 96 - unsigned int numPatternList; 97 - unsigned int patternListSize; 98 - unsigned int forwardPatternDefs; 99 - StructureQuant **quants; 100 - unsigned int numQuants; 101 - unsigned int quantsSize; 102 - Tcl_Obj **evalStub; 103 - char *currentNamespace; 104 - char *currentAttributeNamespace; 105 - int defineToplevel; 106 - int isAttribute; 107 - StructureCP **currentContent; 108 - StructureQuant **currentQuants; 109 - unsigned int numChildren; 110 - unsigned int contentSize; 111 - StructureValidationStack **stack; 112 - int stackSize; 113 - int stackPtr; 114 - ValidationState validationState; 115 - StructureValidationStack **stackList; 116 - unsigned int numStackList; 117 - unsigned int stackListSize; 118 - unsigned int numStackAllocated; 119 -} StructureData; 120 - 121 -int 122 -structureInstanceCmd ( 123 - ClientData clientData, 124 - Tcl_Interp *interp, 125 - int objc, 126 - Tcl_Obj *const objv[] 127 - ); 128 - 129 -int tDOM_StructureObjCmd ( 130 - ClientData clientData, 131 - Tcl_Interp *interp, 132 - int objc, 133 - Tcl_Obj *CONST objv[] 134 - ); 135 - 136 -void tDOM_StructureInit ( 137 - Tcl_Interp *interp 138 - ); 139 - 140 -int 141 -probeElement ( 142 - Tcl_Interp *interp, 143 - StructureData *sdata, 144 - const char *name, 145 - void *namespace 146 - ); 147 - 148 -int 149 -probeElementEnd ( 150 - Tcl_Interp * interp, 151 - StructureData *sdata 152 - ); 153 - 154 -int 155 -probeText ( 156 - Tcl_Interp *interp, 157 - StructureData *sdata, 158 - char *text 159 - ); 160 - 161 - 162 -#endif
Changes to generic/tcldom.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 1999 Jochen Loewer (loewerj@hotmail.com) 3 3 +----------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A DOM implementation for Tcl using James Clark's expat XML parser 9 6 | 10 7 | 11 8 | The contents of this file are subject to the Mozilla Public License 12 9 | Version 2.0 (the "License"); you may not use this file except in 13 10 | compliance with the License. You may obtain a copy of the License at ................................................................................ 47 44 #include <domxslt.h> 48 45 #include <xmlsimple.h> 49 46 #include <domjson.h> 50 47 #include <domhtml.h> 51 48 #include <domhtml5.h> 52 49 #include <nodecmd.h> 53 50 #include <tcldom.h> 54 -#include <structure.h> 51 +#include <schema.h> 55 52 #include <versionhash.h> 56 53 57 54 /* #define DEBUG */ 58 55 /*---------------------------------------------------------------------------- 59 56 | Debug Macros 60 57 | 61 58 \---------------------------------------------------------------------------*/ ................................................................................ 161 158 #define SERIALIZE_DOCTYPE_DECLARATION 2 162 159 #define SERIALIZE_FOR_ATTR 4 163 160 #define SERIALIZE_ESCAPE_NON_ASCII 8 164 161 #define SERIALIZE_HTML_ENTITIES 16 165 162 #define SERIALIZE_ESCAPE_ALL_QUOT 32 166 163 #define SERIALIZE_NO_GT_ESCAPE 64 167 164 #define SERIALIZE_NO_EMPTY_ELEMENT_TAG 128 165 +#define SERIALIZE_INDENT_WITH_TAB 256 166 +#define SERIALIZE_INDENT_ATTR_WITH_TAB 512 168 167 169 168 /*---------------------------------------------------------------------------- 170 169 | Module Globals 171 170 | 172 171 \---------------------------------------------------------------------------*/ 173 172 #ifndef TCL_THREADS 174 173 static int storeLineColumn = 0; ................................................................................ 219 218 ) 220 219 " createNodeCmd ?-returnNodeCmd? ?-tagName name? ?-jsonType jsonType? ?-namespace URI? (element|comment|text|cdata|pi)Node cmdName \n" 221 220 " setStoreLineColumn ?boolean? \n" 222 221 " setNameCheck ?boolean? \n" 223 222 " setTextCheck ?boolean? \n" 224 223 " setObjectCommands ?(automatic|token|command)? \n" 225 224 " isCharData string \n" 225 + " clearString string \n" 226 + " isBMPCharData string \n" 226 227 " isComment string \n" 227 228 " isCDATA string \n" 228 229 " isPIValue string \n" 229 230 " isName string \n" 230 231 " isQName string \n" 231 232 " isNCName string \n" 232 233 " isPIName string \n" ................................................................................ 240 241 " getElementsByTagNameNS uri localname \n" 241 242 " createElement tagName ?objVar? \n" 242 243 " createElementNS uri tagName ?objVar? \n" 243 244 " createCDATASection data ?objVar? \n" 244 245 " createTextNode text ?objVar? \n" 245 246 " createComment text ?objVar? \n" 246 247 " createProcessingInstruction target data ?objVar? \n" 247 - " asXML ?-indent <none,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n" 248 + " asXML ?-indent <none,tabs,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n" 248 249 " asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n" 249 250 " asText \n" 250 251 " asJSON ?-indent <none,0..8>? \n" 251 252 " getDefaultOutputMethod \n" 252 253 " publicId ?publicId? \n" 253 254 " systemId ?systemId? \n" 254 255 " internalSubset ?internalSubset? \n" ................................................................................ 337 338 " baseURI ?URI? \n" 338 339 " localName \n" 339 340 " delete \n" 340 341 " getLine \n" 341 342 " getColumn \n" 342 343 " @<attrName> ?defaultValue? \n" 343 344 " asList \n" 344 - " asXML ?-indent <none,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n" 345 + " asXML ?-indent <none,tabs,0..8>? ?-channel <channel>? ?-escapeNonASCII? ?-escapeAllQuot? ?-doctypeDeclaration <boolean>?\n" 345 346 " asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n" 346 347 " asText \n" 347 348 " asJSON ?-indent <none,0..8>? \n" 348 349 " appendFromList nestedList \n" 349 350 " appendFromScript script \n" 350 351 " insertBeforeFromScript script ref \n" 351 352 " appendXML xmlString \n" ................................................................................ 396 397 SetTdomNodeFromAny 397 398 }; 398 399 399 400 /*---------------------------------------------------------------------------- 400 401 | Prototypes for procedures defined later in this file: 401 402 | 402 403 \---------------------------------------------------------------------------*/ 403 -#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION <= 3) 404 -/* 405 - * Before Tcl 8.4, Tcl_VarTraceProc and Tcl_CmdDeleteProc were not 406 - * CONST84'ified. When compiling with -DTCL_NO_DEPRECATED, CONST84 is 407 - * gone, therefore we can't use the function type definitions of 408 - * Tcl_VarTraceProc and Tcl_CmdDeleteProc for these old version. 409 - * 410 - */ 411 -static char * tcldom_docTrace( 412 - ClientData clientData, Tcl_Interp *interp, 413 - const char *part1, const char *part2, int flags); 414 -static void tcldom_docCmdDeleteProc(ClientData clientData); 415 -#else 416 404 static Tcl_VarTraceProc tcldom_docTrace; 417 405 static Tcl_CmdDeleteProc tcldom_docCmdDeleteProc; 418 -#endif 419 406 420 407 static void tcldom_treeAsJSON(Tcl_Obj *jstring, domNode *node, 421 408 Tcl_Channel channel, int indent, 422 - int level, 423 - int inside); 409 + int outputFlags, int level, int inside); 424 410 425 411 #ifdef TCL_THREADS 426 412 427 413 static int tcldom_EvalLocked(Tcl_Interp* interp, Tcl_Obj** objv, 428 414 domDocument* doc, int flag); 429 415 430 416 static int tcldom_RegisterDocShared(domDocument* doc); ................................................................................ 674 660 } 675 661 } 676 662 677 663 /*---------------------------------------------------------------------------- 678 664 | tcldom_setInterpAndReturnVar 679 665 | 680 666 \---------------------------------------------------------------------------*/ 681 -static 682 667 int tcldom_setInterpAndReturnVar ( 683 668 Tcl_Interp *interp, 684 669 domNode *node, 685 670 int setVariable, 686 671 Tcl_Obj *var_name 687 672 ) 688 673 { ................................................................................ 1237 1222 0, 1238 1223 NULL, 1239 1224 NULL, 1240 1225 NULL, 1241 1226 extResolver, 1242 1227 0, 1243 1228 (int) XML_PARAM_ENTITY_PARSING_ALWAYS, 1229 +#ifndef TDOM_NO_SCHEMA 1244 1230 NULL, 1231 +#endif 1245 1232 interp, 1246 1233 &resultcode); 1247 1234 if (extResolver) { 1248 1235 Tcl_DecrRefCount(extResolver); 1249 1236 } 1250 1237 if (doc == NULL) { 1251 1238 char s[50]; ................................................................................ 1390 1377 } 1391 1378 1392 1379 1393 1380 /*---------------------------------------------------------------------------- 1394 1381 | tcldom_xpathFuncCallBack 1395 1382 | 1396 1383 \---------------------------------------------------------------------------*/ 1397 -static 1398 1384 int tcldom_xpathFuncCallBack ( 1399 1385 void *clientData, 1400 1386 char *functionName, 1401 1387 domNode *ctxNode, 1402 1388 int position, 1403 1389 xpathResultSet *nodeList, 1404 1390 domNode *exprContext, ................................................................................ 2513 2499 } 2514 2500 if (clen == 4 || outputFlags & SERIALIZE_ESCAPE_NON_ASCII) { 2515 2501 if (clen == 4) { 2516 2502 unicode = ((pc[0] & 0x07) << 18) 2517 2503 + ((pc[1] & 0x3F) << 12) 2518 2504 + ((pc[2] & 0x3F) << 6) 2519 2505 + (pc[3] & 0x3F); 2506 + } else if (clen == 3) { 2507 + unicode = ((pc[0] & 0x0F) << 12) 2508 + + ((pc[1] & 0x3F) << 6) 2509 + + (pc[2] & 0x3F); 2520 2510 } else { 2521 - unicode = 0; 2522 - Tcl_UtfToUniChar(pc, (Tcl_UniChar*)&unicode); 2511 + unicode = ((pc[0] & 0x1F) << 6) 2512 + + (pc[1] & 0x3F); 2523 2513 } 2524 2514 AP('&') AP('#') 2525 2515 sprintf(charRef, "%d", unicode); 2526 2516 for (i = 0; i < (int)strlen(charRef); i++) { 2527 2517 AP(charRef[i]); 2528 2518 } 2529 2519 AP(';') ................................................................................ 2581 2571 void tcldom_treeAsHTML ( 2582 2572 Tcl_Obj *htmlString, 2583 2573 domNode *node, 2584 2574 Tcl_Channel chan, 2585 2575 int escapeNonASCII, 2586 2576 int htmlEntities, 2587 2577 int doctypeDeclaration, 2588 - int noEscaping 2578 + int noEscaping, 2579 + int onlyContents, 2580 + int breakLines 2589 2581 ) 2590 2582 { 2591 2583 int empty, scriptTag, outputFlags = 0; 2592 2584 domNode *child; 2593 2585 domAttrNode *attrs; 2594 2586 domDocument *doc; 2595 2587 char tag[80], attrName[80]; ................................................................................ 2623 2615 writeChars(htmlString, chan, "]", 1); 2624 2616 } 2625 2617 writeChars(htmlString, chan, ">\n", 2); 2626 2618 } 2627 2619 child = doc->rootNode->firstChild; 2628 2620 while (child) { 2629 2621 tcldom_treeAsHTML(htmlString, child, chan, escapeNonASCII, 2630 - htmlEntities, doctypeDeclaration, 0); 2622 + htmlEntities, doctypeDeclaration, 0, 0, 2623 + breakLines); 2631 2624 child = child->nextSibling; 2632 2625 } 2633 2626 return; 2634 2627 } 2635 2628 2636 2629 if (node->nodeType == PROCESSING_INSTRUCTION_NODE) { 2637 2630 domProcessingInstructionNode *dpn; ................................................................................ 2677 2670 ((domTextNode*)node)->valueLength); 2678 2671 writeChars(htmlString, chan, "-->", 3); 2679 2672 return; 2680 2673 2681 2674 } 2682 2675 2683 2676 tcldom_tolower(node->nodeName, tag, 80); 2684 - writeChars(htmlString, chan, "<", 1); 2685 - writeChars(htmlString, chan, tag, -1); 2686 - 2687 - 2688 2677 /*----------------------------------------------------------- 2689 2678 | check for HTML tags, that must be handled special: 2690 2679 | empty tags and script tags (todo: HTML tags with 2691 2680 | URI attributes, to do escaping of Non-ASCII chars 2692 2681 | in the URI). 2693 2682 \----------------------------------------------------------*/ 2694 2683 empty = 0; ................................................................................ 2707 2696 case 'l': if (!strcmp(tag,"link")) {empty = 1;} break; 2708 2697 case 'm': if (!strcmp(tag,"meta")) {empty = 1;} break; 2709 2698 case 'p': if (!strcmp(tag,"param")) {empty = 1;} break; 2710 2699 case 's': if (!strcmp(tag,"script") || 2711 2700 !strcmp(tag,"style")) {scriptTag = 1;} break; 2712 2701 } 2713 2702 2703 + if (!onlyContents) { 2704 + writeChars(htmlString, chan, "<", 1); 2705 + writeChars(htmlString, chan, tag, -1); 2714 2706 2715 - attrs = node->firstAttr; 2716 - while (attrs) { 2717 - tcldom_tolower(attrs->nodeName, attrName, 80); 2718 - writeChars(htmlString, chan, " ", 1); 2719 - writeChars (htmlString, chan, attrName, -1); 2720 - writeChars(htmlString, chan, "=\"", 2); 2721 - tcldom_AppendEscaped(htmlString, chan, attrs->nodeValue, -1, 2722 - outputFlags | SERIALIZE_FOR_ATTR); 2723 - writeChars(htmlString, chan, "\"", 1); 2724 - attrs = attrs->nextSibling; 2707 + attrs = node->firstAttr; 2708 + while (attrs) { 2709 + tcldom_tolower(attrs->nodeName, attrName, 80); 2710 + writeChars(htmlString, chan, " ", 1); 2711 + writeChars (htmlString, chan, attrName, -1); 2712 + writeChars(htmlString, chan, "=\"", 2); 2713 + tcldom_AppendEscaped(htmlString, chan, attrs->nodeValue, -1, 2714 + outputFlags | SERIALIZE_FOR_ATTR); 2715 + writeChars(htmlString, chan, "\"", 1); 2716 + attrs = attrs->nextSibling; 2717 + } 2718 + if (breakLines) { 2719 + writeChars(htmlString, chan, "\n>", 2); 2720 + } else { 2721 + writeChars(htmlString, chan, ">", 1); 2722 + } 2725 2723 } 2726 - writeChars(htmlString, chan, ">", 1); 2727 - 2728 - 2724 + 2729 2725 if (empty) { 2730 2726 /* strange ! should not happen ! */ 2731 2727 child = node->firstChild; 2732 2728 while (child != NULL) { 2733 2729 tcldom_treeAsHTML(htmlString, child, chan, escapeNonASCII, 2734 - htmlEntities, doctypeDeclaration, scriptTag); 2730 + htmlEntities, doctypeDeclaration, scriptTag, 0, 2731 + breakLines); 2735 2732 child = child->nextSibling; 2736 2733 } 2737 2734 return; 2738 2735 } 2739 2736 2740 2737 if (node->nodeType == ELEMENT_NODE) { 2741 2738 child = node->firstChild; 2742 2739 if ((child != NULL) && (child != node->lastChild) 2743 2740 && (child->nodeType != TEXT_NODE)) { 2744 2741 writeChars(htmlString, chan, "\n", 1); 2745 2742 } 2746 2743 while (child != NULL) { 2747 2744 tcldom_treeAsHTML(htmlString, child, chan, escapeNonASCII, 2748 - htmlEntities, doctypeDeclaration, scriptTag); 2745 + htmlEntities, doctypeDeclaration, scriptTag, 0, 2746 + breakLines); 2749 2747 child = child->nextSibling; 2750 2748 } 2751 2749 if ((node->firstChild != NULL) && (node->firstChild != node->lastChild) 2752 2750 && (node->lastChild->nodeType != TEXT_NODE)) { 2753 2751 writeChars(htmlString, chan, "\n", 1); 2754 2752 } 2755 2753 } 2756 - writeChars(htmlString, chan, "</", 2); 2757 - writeChars(htmlString, chan, tag, -1); 2758 - writeChars(htmlString, chan, ">", 1); 2754 + if (!onlyContents) { 2755 + writeChars(htmlString, chan, "</", 2); 2756 + writeChars(htmlString, chan, tag, -1); 2757 + writeChars(htmlString, chan, ">", 1); 2758 + } 2759 2759 } 2760 2760 2761 2761 2762 2762 /*---------------------------------------------------------------------------- 2763 2763 | tcldom_treeAsXML 2764 2764 | 2765 2765 \---------------------------------------------------------------------------*/ ................................................................................ 2885 2885 writeChars(xmlString, chan, ((domTextNode*)node)->nodeValue, 2886 2886 ((domTextNode*)node)->valueLength); 2887 2887 writeChars(xmlString, chan, "]]>", 3); 2888 2888 return; 2889 2889 } 2890 2890 2891 2891 if ((indent != -1) && doIndent) { 2892 - for(i=0; i<level; i++) { 2893 - writeChars(xmlString, chan, " ", indent); 2892 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 2893 + for(i=0; i<level; i++) { 2894 + writeChars(xmlString, chan, "\t", 1); 2895 + } 2896 + } else { 2897 + for(i=0; i<level; i++) { 2898 + writeChars(xmlString, chan, " ", indent); 2899 + } 2894 2900 } 2895 2901 } 2896 2902 2897 2903 if (node->nodeType == COMMENT_NODE) { 2898 2904 writeChars(xmlString, chan, "<!--", 4); 2899 2905 writeChars(xmlString, chan, ((domTextNode*)node)->nodeValue, 2900 2906 ((domTextNode*)node)->valueLength); ................................................................................ 2921 2927 writeChars(xmlString, chan, node->nodeName, -1); 2922 2928 2923 2929 attrs = node->firstAttr; 2924 2930 while (attrs) { 2925 2931 if (indentAttrs > -1) { 2926 2932 writeChars(xmlString, chan, "\n", 1); 2927 2933 if ((indent != -1) && doIndent) { 2928 - for(i=0; i<level; i++) { 2929 - writeChars(xmlString, chan, " ", indent); 2934 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 2935 + for(i=0; i<level; i++) { 2936 + writeChars(xmlString, chan, "\t", 1); 2937 + } 2938 + } else { 2939 + for(i=0; i<level; i++) { 2940 + writeChars(xmlString, chan, " ", indent); 2941 + } 2930 2942 } 2931 - if (indentAttrs) { 2943 + if (outputFlags & SERIALIZE_INDENT_ATTR_WITH_TAB) { 2944 + writeChars(xmlString, chan, "\t", 1); 2945 + } else { 2932 2946 writeChars(xmlString, chan, " ", indentAttrs); 2933 2947 } 2934 2948 } 2935 2949 } else { 2936 2950 writeChars(xmlString, chan, " ", 1); 2937 2951 } 2938 2952 writeChars(xmlString, chan, attrs->nodeName, -1); ................................................................................ 3016 3030 writeChars(xmlString, chan, ">", 1); 3017 3031 } else { 3018 3032 writeChars(xmlString, chan, "/>", 2); 3019 3033 } 3020 3034 } 3021 3035 } else { 3022 3036 if ((indent != -1) && hasElements) { 3023 - for(i=0; i<level; i++) { 3024 - writeChars(xmlString, chan, " ", indent); 3037 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 3038 + for(i=0; i<level; i++) { 3039 + writeChars(xmlString, chan, "\t", 1); 3040 + } 3041 + } else { 3042 + for(i=0; i<level; i++) { 3043 + writeChars(xmlString, chan, " ", indent); 3044 + } 3025 3045 } 3026 3046 } 3027 3047 writeChars (xmlString, chan, "</", 2); 3028 3048 writeChars(xmlString, chan, node->nodeName, -1); 3029 3049 if (indent != -1) { 3030 3050 writeChars(xmlString, chan, ">\n", 2); 3031 3051 } else { ................................................................................ 3111 3131 3112 3132 static 3113 3133 void tcldom_childsAsJSON ( 3114 3134 Tcl_Obj *jstring, 3115 3135 domNode *node, /* Must be an ELEMENT_NODE */ 3116 3136 Tcl_Channel channel, 3117 3137 int indent, 3138 + int outputFlags, 3118 3139 int level, 3119 3140 int inside 3120 3141 ) 3121 3142 { 3122 3143 domNode *child, *nextChild; 3123 3144 int i, effectivParentType = 0; 3124 3145 int first = 1; ................................................................................ 3184 3205 } 3185 3206 if (nextChild) { 3186 3207 effectivParentType = JSON_ARRAY; 3187 3208 } else { 3188 3209 /* Exactly one 'relevant' child node, a text node; 3189 3210 * serialize it as simple token value. */ 3190 3211 tcldom_treeAsJSON (jstring, child, channel, indent, 3191 - level, JSON_ARRAY); 3212 + outputFlags, level, JSON_ARRAY); 3192 3213 return; 3193 3214 } 3194 3215 } 3195 3216 } 3196 3217 3197 3218 switch (effectivParentType) { 3198 3219 case JSON_ARRAY: ................................................................................ 3202 3223 first = 0; 3203 3224 level++; 3204 3225 } else { 3205 3226 writeChars(jstring, channel, ",", 1); 3206 3227 } 3207 3228 if (indent > -1) { 3208 3229 writeChars(jstring, channel, "\n", 1); 3209 - if (first) level++; 3210 - for (i = 0; i < level; i++) { 3211 - writeChars(jstring, channel, " ", indent); 3230 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 3231 + for (i = 0; i < level; i++) { 3232 + writeChars(jstring, channel, "\t", 1); 3233 + } 3234 + } else { 3235 + for (i = 0; i < level; i++) { 3236 + writeChars(jstring, channel, " ", indent); 3237 + } 3212 3238 } 3213 3239 } 3214 3240 tcldom_treeAsJSON (jstring, child, channel, indent, 3215 - level, JSON_ARRAY); 3241 + outputFlags, level, JSON_ARRAY); 3216 3242 child = child->nextSibling; 3217 3243 while (child 3218 3244 && child->nodeType != TEXT_NODE 3219 3245 && child->nodeType != ELEMENT_NODE) { 3220 3246 child = child->nextSibling; 3221 3247 } 3222 3248 } 3223 3249 if (indent > -1 && first == 0) { 3224 3250 writeChars(jstring, channel, "\n", 1); 3225 3251 level--; 3226 - for (i = 0; i < level; i++) { 3227 - writeChars(jstring, channel, " ", indent); 3252 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 3253 + for (i = 0; i < level; i++) { 3254 + writeChars(jstring, channel, "\t", 1); 3255 + } 3256 + } else { 3257 + for (i = 0; i < level; i++) { 3258 + writeChars(jstring, channel, " ", indent); 3259 + } 3228 3260 } 3229 3261 } 3230 3262 writeChars(jstring, channel, "]",1); 3231 3263 break; 3232 3264 case JSON_OBJECT: 3233 3265 writeChars(jstring, channel, "{",1); 3234 3266 while (child) { ................................................................................ 3236 3268 first = 0; 3237 3269 level++; 3238 3270 } else { 3239 3271 writeChars(jstring, channel, ",", 1); 3240 3272 } 3241 3273 if (indent > -1) { 3242 3274 writeChars(jstring, channel, "\n", 1); 3243 - if (first) level++; 3244 - for (i = 0; i < level; i++) { 3245 - writeChars(jstring, channel, " ", indent); 3275 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 3276 + for (i = 0; i < level; i++) { 3277 + writeChars(jstring, channel, "\t", 1); 3278 + } 3279 + } else { 3280 + for (i = 0; i < level; i++) { 3281 + writeChars(jstring, channel, " ", indent); 3282 + } 3246 3283 } 3247 3284 } 3248 3285 tcldom_treeAsJSON (jstring, child, channel, indent, 3249 - level, JSON_OBJECT); 3286 + outputFlags, level, JSON_OBJECT); 3250 3287 child = child->nextSibling; 3251 3288 /* Inside of a JSON_OBJECT, only element childs make 3252 3289 * semantically sense. */ 3253 3290 while (child && child->nodeType != ELEMENT_NODE) { 3254 3291 child = child->nextSibling; 3255 3292 } 3256 3293 } 3257 3294 if (indent > -1 && first == 0) { 3258 3295 writeChars(jstring, channel, "\n", 1); 3259 3296 level--; 3260 - for (i = 0; i < level; i++) { 3261 - writeChars(jstring, channel, " ", indent); 3297 + if (outputFlags & SERIALIZE_INDENT_WITH_TAB) { 3298 + for (i = 0; i < level; i++) { 3299 + writeChars(jstring, channel, "\t", 1); 3300 + } 3301 + } else { 3302 + for (i = 0; i < level; i++) { 3303 + writeChars(jstring, channel, " ", indent); 3304 + } 3262 3305 } 3263 3306 } 3264 3307 writeChars(jstring, channel, "}",1); 3265 3308 break; 3266 3309 default: 3267 3310 break; 3268 3311 } ................................................................................ 3275 3318 \---------------------------------------------------------------------------*/ 3276 3319 static 3277 3320 void tcldom_treeAsJSON ( 3278 3321 Tcl_Obj *jstring, 3279 3322 domNode *node, /* Must not be NULL */ 3280 3323 Tcl_Channel channel, 3281 3324 int indent, 3325 + int outputFlags, 3282 3326 int level, 3283 3327 int inside 3284 3328 ) 3285 3329 { 3286 3330 domTextNode *textNode; 3287 3331 int i, seenDP, seenE; 3288 3332 unsigned char c; ................................................................................ 3375 3419 switch (inside) { 3376 3420 case JSON_OBJECT: 3377 3421 /* Write the member name and recurse to the childs for the 3378 3422 * value. */ 3379 3423 tcldom_AppendEscapedJSON (jstring, channel, 3380 3424 node->nodeName, -1); 3381 3425 writeChars (jstring, channel, ":", 1); 3426 + if (indent > -1 || outputFlags & SERIALIZE_INDENT_WITH_TAB) { 3427 + writeChars (jstring, channel, " ", 1); 3428 + } 3382 3429 tcldom_childsAsJSON (jstring, node, channel, indent, 3383 - level, inside); 3430 + outputFlags, level, inside); 3384 3431 break; 3385 3432 case JSON_ARRAY: 3386 3433 /* Since we're already inside of an array, the element can 3387 3434 only be interpreted as a container for a nested JSON 3388 3435 object or array. */ 3389 3436 tcldom_childsAsJSON (jstring, node, channel, indent, 3390 - level, inside); 3437 + outputFlags, level, inside); 3391 3438 break; 3392 3439 case JSON_START: 3393 3440 tcldom_childsAsJSON (jstring, node, channel, indent, 3394 - level, inside); 3441 + outputFlags, level, inside); 3395 3442 break; 3396 3443 } 3397 3444 return; 3398 3445 default: 3399 3446 /* Any other node types (COMMENT_NODE, CDATA_SECTION_NODE, 3400 3447 PROCESSING_INSTRUCTION_NODE) are ignored. */ 3401 3448 return; ................................................................................ 3477 3524 goto cleanup; 3478 3525 } 3479 3526 switch ((enum asXMLOption) optionIndex) { 3480 3527 3481 3528 case m_indent: 3482 3529 if (objc < 4) { 3483 3530 SetResult("-indent must have an argument " 3484 - "(0..8 or 'no'/'none')"); 3531 + "(0..8 or 'no'/'none'/'tabs')"); 3485 3532 goto cleanup; 3486 3533 } 3487 3534 if (strcmp("none", Tcl_GetString(objv[3]))==0) { 3488 3535 indent = -1; 3489 3536 } 3490 3537 else if (strcmp("no", Tcl_GetString(objv[3]))==0) { 3491 3538 indent = -1; 3539 + } 3540 + else if (strcmp("tabs", Tcl_GetString(objv[3]))==0) { 3541 + outputFlags |= SERIALIZE_INDENT_WITH_TAB; 3492 3542 } 3493 3543 else if (Tcl_GetIntFromObj(interp, objv[3], &indent) != TCL_OK) { 3494 - SetResult( "indent must be an integer (0..8) or 'no'/'none'"); 3544 + SetResult( "indent must be an integer (0..8) or " 3545 + "'no'/'none'/'tabs'"); 3495 3546 goto cleanup; 3496 3547 } 3497 3548 objc -= 2; 3498 3549 objv += 2; 3499 3550 break; 3500 3551 3501 3552 case m_indentAttrs: 3502 3553 if (objc < 4) { 3503 3554 SetResult("-indentAttrs must have an argument " 3504 - "(0..8 or 'no'/'none')"); 3555 + "(0..8 or 'no'/'none'/'tabs')"); 3505 3556 goto cleanup; 3506 3557 } 3507 3558 if (strcmp("none", Tcl_GetString(objv[3]))==0) { 3508 3559 indentAttrs = -1; 3509 3560 } 3510 3561 else if (strcmp("no", Tcl_GetString(objv[3]))==0) { 3511 3562 indentAttrs = -1; 3563 + } 3564 + else if (strcmp("tabs", Tcl_GetString(objv[3]))==0) { 3565 + outputFlags |= SERIALIZE_INDENT_ATTR_WITH_TAB; 3512 3566 } 3513 3567 else if (Tcl_GetIntFromObj(interp, objv[3], &indentAttrs) != TCL_OK) { 3514 - SetResult( "indentAttrs must be an integer (0..8) or 'no'/'none'"); 3568 + SetResult( "indentAttrs must be an integer (0..8) or " 3569 + "'no'/'none'/'tabs'"); 3515 3570 goto cleanup; 3516 3571 } 3517 3572 if (indentAttrs > 8) indentAttrs = 8; 3518 3573 if (indentAttrs < 0) indentAttrs = 0; 3519 3574 objc -= 2; 3520 3575 objv += 2; 3521 3576 break; ................................................................................ 3665 3720 Tcl_Interp *interp, 3666 3721 int objc, 3667 3722 Tcl_Obj *const objv[] 3668 3723 ) 3669 3724 { 3670 3725 char *channelId; 3671 3726 int optionIndex, mode, escapeNonASCII = 0, htmlEntities = 0; 3672 - int doctypeDeclaration = 0; 3727 + int doctypeDeclaration = 0, onlyContents = 0, breakLines = 0; 3673 3728 Tcl_Obj *resultPtr; 3674 3729 Tcl_Channel chan = (Tcl_Channel) NULL; 3675 3730 3676 3731 static const char *asHTMLOptions[] = { 3677 3732 "-channel", "-escapeNonASCII", "-htmlEntities", "-doctypeDeclaration", 3678 - NULL 3733 + "-onlyContents", "-breakLines", NULL 3679 3734 }; 3680 3735 enum asHTMLOption { 3681 - m_channel, m_escapeNonASCII, m_htmlEntities, m_doctypeDeclaration 3736 + m_channel, m_escapeNonASCII, m_htmlEntities, m_doctypeDeclaration, 3737 + m_onlyContents, m_breakLines 3682 3738 }; 3683 3739 3684 - if (objc > 8) { 3740 + if (objc > 10) { 3685 3741 Tcl_WrongNumArgs(interp, 2, objv, 3686 3742 "?-channel <channelId>? ?-escapeNonASCII? " 3687 - "?-htmlEntities? ?-doctypeDeclaration <boolean>?"); 3743 + "?-htmlEntities? ?-doctypeDeclaration <boolean>? " 3744 + "?-onlyContents? ?-breakLines?"); 3688 3745 return TCL_ERROR; 3689 3746 } 3690 3747 while (objc > 2) { 3691 3748 if (Tcl_GetIndexFromObj(interp, objv[2], asHTMLOptions, "option", 3692 3749 0, &optionIndex) != TCL_OK) { 3693 3750 return TCL_ERROR; 3694 3751 } ................................................................................ 3740 3797 if (Tcl_GetBooleanFromObj(interp, objv[3], &doctypeDeclaration) 3741 3798 != TCL_OK) { 3742 3799 return TCL_ERROR; 3743 3800 } 3744 3801 objc -= 2; 3745 3802 objv += 2; 3746 3803 break; 3804 + 3805 + case m_onlyContents: 3806 + onlyContents = 1; 3807 + objc--; 3808 + objv++; 3809 + break; 3810 + 3811 + case m_breakLines: 3812 + breakLines = 1; 3813 + objc--; 3814 + objv++; 3815 + break; 3747 3816 } 3748 3817 } 3749 3818 resultPtr = Tcl_NewStringObj("", 0); 3750 3819 tcldom_treeAsHTML(resultPtr, node, chan, escapeNonASCII, htmlEntities, 3751 - doctypeDeclaration, 0); 3820 + doctypeDeclaration, 0, onlyContents, breakLines); 3752 3821 Tcl_AppendResult(interp, Tcl_GetString(resultPtr), NULL); 3753 3822 Tcl_DecrRefCount(resultPtr); 3754 3823 return TCL_OK; 3755 3824 } 3756 3825 3757 3826 /*---------------------------------------------------------------------------- 3758 3827 | serializeAsJSON ................................................................................ 3762 3831 domNode *node, 3763 3832 Tcl_Interp *interp, 3764 3833 int objc, 3765 3834 Tcl_Obj *const objv[] 3766 3835 ) 3767 3836 { 3768 3837 char *channelId; 3769 - int optionIndex, mode, indent = -1; 3838 + int optionIndex, mode, outputFlags = 0, indent = -1; 3770 3839 Tcl_Obj *resultPtr; 3771 3840 Tcl_Channel chan = (Tcl_Channel) NULL; 3772 3841 3773 3842 static const char *asJSONOptions[] = { 3774 3843 "-channel", "-indent", 3775 3844 NULL 3776 3845 }; ................................................................................ 3823 3892 return TCL_ERROR; 3824 3893 } 3825 3894 if (strcmp("none", Tcl_GetString(objv[3]))==0) { 3826 3895 indent = -1; 3827 3896 } 3828 3897 else if (strcmp("no", Tcl_GetString(objv[3]))==0) { 3829 3898 indent = -1; 3899 + } 3900 + else if (strcmp("tabs", Tcl_GetString(objv[3]))==0) { 3901 + /* User wants indentation */ 3902 + indent = 0; 3903 + outputFlags |= SERIALIZE_INDENT_WITH_TAB; 3830 3904 } 3831 3905 else if (Tcl_GetIntFromObj(interp, objv[3], &indent) != TCL_OK) { 3832 3906 SetResult( "indent must be an integer (0..8) or 'no'/'none'"); 3833 3907 return TCL_ERROR; 3834 3908 } else if (indent < 0 || indent > 8) { 3835 3909 SetResult( "indent must be an integer (0..8) or 'no'/'none'"); 3836 3910 return TCL_ERROR; ................................................................................ 3838 3912 3839 3913 objc -= 2; 3840 3914 objv += 2; 3841 3915 break; 3842 3916 } 3843 3917 } 3844 3918 resultPtr = Tcl_NewStringObj("", 0); 3845 - tcldom_treeAsJSON(resultPtr, node, chan, indent, 0, JSON_START); 3919 + tcldom_treeAsJSON(resultPtr, node, chan, indent, outputFlags, 0, 3920 + JSON_START); 3846 3921 Tcl_AppendResult(interp, Tcl_GetString(resultPtr), NULL); 3847 3922 Tcl_DecrRefCount(resultPtr); 3848 3923 return TCL_OK; 3849 3924 } 3850 3925 3851 3926 /*---------------------------------------------------------------------------- 3852 3927 | cdataSectionElements ................................................................................ 3938 4013 return TCL_OK; 3939 4014 } 3940 4015 3941 4016 /*---------------------------------------------------------------------------- 3942 4017 | selectNodesNamespaces 3943 4018 | 3944 4019 \---------------------------------------------------------------------------*/ 3945 -static int selectNodesNamespaces ( 3946 - domDocument *doc, 4020 +int tcldom_prefixNSlist ( 4021 + char ***prefixnsPtr, 3947 4022 Tcl_Interp *interp, 3948 4023 int objc, 3949 - Tcl_Obj *const objv[] 4024 + Tcl_Obj *const objv[], 4025 + const char *methodName 3950 4026 ) 3951 4027 { 4028 + char **prefixns = *prefixnsPtr; 3952 4029 int len, i, result; 3953 4030 Tcl_Obj *objPtr, *listPtr; 3954 4031 3955 - CheckArgs (2,3,2, "?prefixUriList?"); 3956 - if (objc == 3) { 3957 - result = Tcl_ListObjLength (interp, objv[2], &len); 3958 - if (result != TCL_OK || (len % 2) != 0) { 3959 - SetResult ("The optional argument to the selectNodesNamespaces" 3960 - " method must be a 'prefix namespace' pairs list"); 3961 - return TCL_ERROR; 3962 - } 3963 - i = 0; 3964 - if (doc->prefixNSMappings) { 3965 - while (doc->prefixNSMappings[i]) { 3966 - FREE (doc->prefixNSMappings[i]); 3967 - i++; 3968 - } 3969 - } 3970 - if (i < len + 1) { 3971 - if (doc->prefixNSMappings) FREE (doc->prefixNSMappings); 3972 - doc->prefixNSMappings = MALLOC (sizeof (char*)*(len+1)); 3973 - } 3974 - for (i = 0; i < len; i++) { 3975 - Tcl_ListObjIndex (interp, objv[2], i, &objPtr); 3976 - doc->prefixNSMappings[i] = tdomstrdup (Tcl_GetString (objPtr)); 3977 - } 3978 - doc->prefixNSMappings[len] = NULL; 3979 - Tcl_SetObjResult (interp, objv[2]); 3980 - } else { 4032 + i = 0; 4033 + if (objc == 1) { 4034 + if (!prefixns) return TCL_OK; 3981 4035 listPtr = Tcl_NewListObj (0, NULL); 3982 4036 i = 0; 3983 - if (doc->prefixNSMappings) { 3984 - while (doc->prefixNSMappings[i]) { 3985 - objPtr = Tcl_NewStringObj (doc->prefixNSMappings[i], -1); 3986 - Tcl_ListObjAppendElement (interp, listPtr, objPtr); 3987 - i++; 3988 - } 4037 + while (prefixns[i]) { 4038 + Tcl_ListObjAppendElement ( 4039 + interp, listPtr, Tcl_NewStringObj (prefixns[i], -1) 4040 + ); 4041 + i++; 3989 4042 } 3990 4043 Tcl_SetObjResult (interp, listPtr); 4044 + return TCL_OK; 3991 4045 } 4046 + result = Tcl_ListObjLength (interp, objv[1], &len); 4047 + if (result != TCL_OK || (len % 2) != 0) { 4048 + SetResult3 ("The optional argument to ", methodName, 4049 + " must be a 'prefix namespace' pairs list"); 4050 + return TCL_ERROR; 4051 + } 4052 + if (prefixns) { 4053 + while (prefixns[i]) { 4054 + FREE (prefixns[i]); 4055 + i++; 4056 + } 4057 + } 4058 + if (len == 0) { 4059 + FREE (prefixns); 4060 + *prefixnsPtr = NULL; 4061 + return TCL_OK; 4062 + } 4063 + if (i < len + 1) { 4064 + if (prefixns) FREE (prefixns); 4065 + prefixns = MALLOC (sizeof (char*) * (len+1)); 4066 + *prefixnsPtr = prefixns; 4067 + } 4068 + for (i = 0; i < len; i++) { 4069 + Tcl_ListObjIndex (interp, objv[1], i, &objPtr); 4070 + prefixns[i] = tdomstrdup (Tcl_GetString (objPtr)); 4071 + } 4072 + prefixns[len] = NULL; 4073 + Tcl_SetObjResult (interp, objv[1]); 3992 4074 return TCL_OK; 3993 4075 } 3994 4076 3995 4077 /*---------------------------------------------------------------------------- 3996 4078 | renameNodes 3997 4079 | 3998 4080 \---------------------------------------------------------------------------*/ ................................................................................ 4363 4445 domNode *node, *child, *refChild, *oldChild, *refNode; 4364 4446 domNS *ns; 4365 4447 domAttrNode *attrs; 4366 4448 domException exception; 4367 4449 char tmp[200], prefix[MAX_PREFIX_LEN], *method, *nodeName, 4368 4450 *str, *attr_name, *attr_val, *filter; 4369 4451 const char *localName, *uri, *nsStr; 4370 - int result, length, methodIndex, i, line, column; 4452 + int result, length, methodIndex, i; 4453 + long line, column; 4371 4454 int nsIndex, bool, hnew, legacy, jsonType, fromToken = 0; 4372 4455 Tcl_Obj *namePtr, *resultPtr; 4373 4456 Tcl_Obj *mobjv[MAX_REWRITE_ARGS]; 4374 4457 Tcl_CmdInfo cmdInfo; 4375 4458 Tcl_HashEntry *h; 4376 4459 4377 4460 static const char *nodeMethods[] = { ................................................................................ 4737 4820 Tcl_AppendResult(interp, "Attribute \"", attr_name, 4738 4821 "\" not found!", NULL); 4739 4822 return TCL_ERROR; 4740 4823 } 4741 4824 break; 4742 4825 4743 4826 case m_getAttributeNS: 4744 - CheckArgs(4,4,2,"uri localName"); 4827 + CheckArgs(4,5,2,"uri localName"); 4745 4828 if (node->nodeType != ELEMENT_NODE) { 4746 4829 SetResult("NOT_AN_ELEMENT : there are no attributes"); 4747 4830 return TCL_ERROR; 4748 4831 } 4749 4832 uri = Tcl_GetString(objv[2]); 4750 4833 localName = Tcl_GetString(objv[3]); 4751 4834 attrs = domGetAttributeNodeNS(node, uri, localName); 4752 4835 if (attrs) { 4753 4836 SetResult(attrs->nodeValue); 4754 4837 return TCL_OK; 4755 4838 } 4756 - sprintf(tmp,"attribute with localName %80.80s not found!",localName); 4839 + if (objc == 5) { 4840 + SetResult(Tcl_GetString(objv[4])); 4841 + return TCL_OK; 4842 + } 4843 + sprintf(tmp,"attribute with localName %80.80s not found!", 4844 + localName); 4757 4845 SetResult(tmp); 4758 4846 return TCL_ERROR; 4759 4847 4760 4848 case m_setAttribute: 4761 4849 if (node->nodeType != ELEMENT_NODE) { 4762 4850 SetResult("NOT_AN_ELEMENT : there are no attributes"); 4763 4851 return TCL_ERROR; ................................................................................ 5917 6005 SetResult("DOCUMENT_NODE"); 5918 6006 return TCL_OK; 5919 6007 5920 6008 case m_cdataSectionElements: 5921 6009 return cdataSectionElements (doc, interp, objc, objv); 5922 6010 5923 6011 case m_selectNodesNamespaces: 5924 - return selectNodesNamespaces (doc, interp, objc, objv); 5925 - 6012 + CheckArgs (2,3,2, "?prefixUriList?"); 6013 + return tcldom_prefixNSlist (&(doc->prefixNSMappings), interp, 6014 + --objc, ++objv, 6015 + "selectNodesNamespaces"); 6016 + 5926 6017 case m_renameNode: 5927 6018 return renameNodes (doc, interp, objc, objv); 5928 6019 5929 6020 case m_deleteXPathCache: 5930 6021 return deleteXPathCache (doc, interp, objc, objv); 5931 6022 5932 6023 case m_appendChild: ................................................................................ 6160 6251 int keepCDATA = 0; 6161 6252 int status = 0; 6162 6253 domDocument *doc; 6163 6254 Tcl_Obj *newObjName = NULL; 6164 6255 XML_Parser parser; 6165 6256 Tcl_Channel chan = (Tcl_Channel) NULL; 6166 6257 Tcl_CmdInfo cmdInfo; 6167 - StructureData *sdata = NULL; 6258 +#ifndef TDOM_NO_SCHEMA 6259 + SchemaData *sdata = NULL; 6260 +#endif 6168 6261 static const char *parseOptions[] = { 6169 6262 "-keepEmpties", "-simple", "-html", 6170 6263 "-feedbackAfter", "-channel", "-baseurl", 6171 6264 "-externalentitycommand", "-useForeignDTD", "-paramentityparsing", 6172 6265 "-feedbackcmd", "-json", "-jsonroot", 6173 6266 #ifdef TDOM_HAVE_GUMBO 6174 6267 "-html5", 6175 6268 #endif 6176 -#ifndef TDOM_NO_STRUCTURE 6269 +#ifndef TDOM_NO_SCHEMA 6177 6270 "-validateCmd", 6178 6271 #endif 6179 6272 "-jsonmaxnesting", "-ignorexmlns", "--", 6180 6273 "-keepCDATA", NULL 6181 6274 }; 6182 6275 enum parseOption { 6183 6276 o_keepEmpties, o_simple, o_html, 6184 6277 o_feedbackAfter, o_channel, o_baseurl, 6185 6278 o_externalentitycommand, o_useForeignDTD, o_paramentityparsing, 6186 6279 o_feedbackcmd, o_json, o_jsonroot, 6187 6280 #ifdef TDOM_HAVE_GUMBO 6188 6281 o_htmlfive, 6189 6282 #endif 6190 -#ifndef TDOM_NO_STRUCTURE 6283 +#ifndef TDOM_NO_SCHEMA 6191 6284 o_validateCmd, 6192 6285 #endif 6193 6286 o_jsonmaxnesting, o_ignorexmlns, o_LAST, 6194 6287 o_keepCDATA 6195 6288 }; 6196 6289 6197 6290 static const char *paramEntityParsingValues[] = { ................................................................................ 6237 6330 jsonRoot = Tcl_GetString(objv[1]); 6238 6331 } else { 6239 6332 SetResult("The \"dom parse\" option \"-jsonroot\" " 6240 6333 "expects the document element name of the " 6241 6334 "DOM tree to create as argument."); 6242 6335 return TCL_ERROR; 6243 6336 } 6244 - if (!domIsNAME(jsonRoot)) { 6245 - SetResult("-jsonroot value: not a valid element name"); 6246 - return TCL_ERROR; 6247 - } 6248 6337 objv++; objc--; continue; 6249 6338 6250 6339 case o_simple: 6251 6340 takeSimpleParser = 1; 6252 6341 objv++; objc--; continue; 6253 6342 6254 6343 case o_html: ................................................................................ 6418 6507 case o_LAST: 6419 6508 objv++; objc--; break; 6420 6509 6421 6510 case o_keepCDATA: 6422 6511 keepCDATA = 1; 6423 6512 objv++; objc--; continue; 6424 6513 6425 -#ifndef TDOM_NO_STRUCTURE 6514 +#ifndef TDOM_NO_SCHEMA 6426 6515 case o_validateCmd: 6427 6516 objv++; objc--; 6428 6517 if (objc < 2) { 6429 6518 SetResult("The \"dom parse\" option \"-validateCmd\" " 6430 6519 "requires a tDOM validation command as argument."); 6431 6520 return TCL_ERROR; 6432 6521 } ................................................................................ 6433 6522 if (!Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), 6434 6523 &cmdInfo)) { 6435 6524 SetResult3("The \"-validateCmd\" argument \"", 6436 6525 Tcl_GetString(objv[1]), 6437 6526 "\" is not a tDOM validation command."); 6438 6527 return TCL_ERROR; 6439 6528 } 6440 - if (cmdInfo.objProc != structureInstanceCmd) { 6529 + if (cmdInfo.objProc != tDOM_schemaInstanceCmd) { 6441 6530 SetResult3("The \"-validateCmd\" argument \"", 6442 6531 Tcl_GetString(objv[1]), 6443 6532 "\" is not a tDOM validation command."); 6444 6533 return TCL_ERROR; 6445 6534 } 6446 - sdata = (StructureData *) cmdInfo.objClientData; 6535 + sdata = (SchemaData *) cmdInfo.objClientData; 6447 6536 objv++; objc--; continue; 6448 6537 #endif 6449 6538 } 6450 6539 if ((enum parseOption) optionIndex == o_LAST) break; 6451 6540 } 6452 6541 6453 6542 if (feedbackAfter && !feedbackCmd) { ................................................................................ 6476 6565 xml_string = NULL; 6477 6566 xml_string_len = 0; 6478 6567 if (takeSimpleParser || takeHTMLParser || takeJSONParser 6479 6568 #ifdef TDOM_HAVE_GUMBO 6480 6569 || takeGUMBOParser 6481 6570 #endif 6482 6571 ) { 6483 - Tcl_AppendResult(interp, "simple, JSON or HTML parser(s) " 6572 + Tcl_AppendResult(interp, "simple, JSON and HTML parser " 6484 6573 " don't support channel reading", NULL); 6485 6574 return TCL_ERROR; 6486 6575 } 6487 6576 if (objc == 2) { 6488 6577 newObjName = objv[1]; 6489 6578 setVariable = 1; 6490 6579 } ................................................................................ 6585 6674 } 6586 6675 6587 6676 #ifdef TDOM_NO_EXPAT 6588 6677 Tcl_AppendResult(interp, "tDOM was compiled without Expat!", NULL); 6589 6678 return TCL_ERROR; 6590 6679 #else 6591 6680 parser = XML_ParserCreate_MM(NULL, MEM_SUITE, NULL); 6681 +#ifndef TDOM_NO_SCHEMA 6682 + if (sdata) { 6683 + sdata->inuse++; 6684 + sdata->parser = parser; 6685 + if (sdata->validationState != VALIDATION_READY) { 6686 + SetResult ("The configured schema command is busy"); 6687 + return TCL_ERROR; 6688 + } 6689 + } 6690 +#endif 6592 6691 Tcl_ResetResult(interp); 6593 - 6594 6692 doc = domReadDocument(parser, xml_string, 6595 6693 xml_string_len, 6596 6694 ignoreWhiteSpaces, 6597 6695 keepCDATA, 6598 6696 TSD(storeLineColumn), 6599 6697 ignorexmlns, 6600 6698 feedbackAfter, 6601 6699 feedbackCmd, 6602 6700 chan, 6603 6701 baseURI, 6604 6702 extResolver, 6605 6703 useForeignDTD, 6606 6704 paramEntityParsing, 6705 +#ifndef TDOM_NO_SCHEMA 6607 6706 sdata, 6707 +#endif 6608 6708 interp, 6609 6709 &status); 6710 +#ifndef TDOM_NO_SCHEMA 6711 + if (sdata) { 6712 + sdata->inuse--; 6713 + tDOM_schemaReset (sdata, 1); 6714 + } 6715 +#endif 6610 6716 if (doc == NULL) { 6611 6717 char s[50]; 6612 6718 long byteIndex, i; 6613 6719 6614 6720 switch (status) { 6615 6721 case TCL_BREAK: 6616 6722 /* Abort of parsing by the application */ ................................................................................ 6692 6798 int featureIndex, result; 6693 6799 6694 6800 static const char *features[] = { 6695 6801 "expatversion", "expatmajorversion", "expatminorversion", 6696 6802 "expatmicroversion", "dtd", "ns", 6697 6803 "unknown", "tdomalloc", "lessns", 6698 6804 "html5", "jsonmaxnesting", "versionhash", 6699 - "pullparser", "TCL_UTF_MAX", NULL 6805 + "pullparser", "TCL_UTF_MAX", "schema", 6806 + NULL 6700 6807 }; 6701 6808 enum feature { 6702 6809 o_expatversion, o_expatmajorversion, o_expatminorversion, 6703 6810 o_expatmicroversion, o_dtd, o_ns, 6704 6811 o_unknown, o_tdomalloc, o_lessns, 6705 6812 o_html5, o_jsonmaxnesting, o_versionhash, 6706 - o_pullparser, o_TCL_UTF_MAX, 6813 + o_pullparser, o_TCL_UTF_MAX, o_schema 6707 6814 }; 6708 6815 6709 6816 if (Tcl_GetIndexFromObj(interp, objv[1], features, "feature", 0, 6710 6817 &featureIndex) != TCL_OK) { 6711 6818 return TCL_ERROR; 6712 6819 } 6713 6820 ................................................................................ 6783 6890 #ifndef TDOM_NO_PULL 6784 6891 result = 1; 6785 6892 #else 6786 6893 result = 0; 6787 6894 #endif 6788 6895 SetBooleanResult(result); 6789 6896 break; 6897 + case o_schema: 6898 +#ifndef TDOM_NO_SCHEMA 6899 + result = 1; 6900 +#else 6901 + result = 0; 6902 +#endif 6903 + SetBooleanResult(result); 6904 + break; 6790 6905 case o_TCL_UTF_MAX: 6791 6906 SetIntResult(TCL_UTF_MAX); 6792 6907 break; 6793 6908 } 6794 6909 return TCL_OK; 6795 6910 } 6796 6911 ................................................................................ 6803 6918 Tcl_Interp * interp, 6804 6919 int objc, 6805 6920 Tcl_Obj * const objv[] 6806 6921 ) 6807 6922 { 6808 6923 GetTcldomTSD() 6809 6924 6810 - char * method, tmp[300]; 6925 + char * method, tmp[300], *clearedStr; 6811 6926 int methodIndex, result, i, bool; 6812 6927 Tcl_CmdInfo cmdInfo; 6813 - Tcl_Obj * mobjv[MAX_REWRITE_ARGS]; 6928 + Tcl_Obj * mobjv[MAX_REWRITE_ARGS], *newObj; 6814 6929 6815 6930 static const char *domMethods[] = { 6816 6931 "createDocument", "createDocumentNS", "createNodeCmd", 6817 6932 "parse", "setStoreLineColumn", 6818 6933 "isCharData", "isName", "isPIName", 6819 6934 "isQName", "isComment", "isCDATA", 6820 6935 "isPIValue", "isNCName", "createDocumentNode", 6821 6936 "setNameCheck", "setTextCheck", "setObjectCommands", 6822 - "featureinfo", "isBMPCharData", 6937 + "featureinfo", "isBMPCharData", "clearString", 6823 6938 #ifdef TCL_THREADS 6824 6939 "attachDocument", "detachDocument", 6825 6940 #endif 6826 6941 NULL 6827 6942 }; 6828 6943 enum domMethod { 6829 6944 m_createDocument, m_createDocumentNS, m_createNodeCmd, 6830 6945 m_parse, m_setStoreLineColumn, 6831 6946 m_isCharData, m_isName, m_isPIName, 6832 6947 m_isQName, m_isComment, m_isCDATA, 6833 6948 m_isPIValue, m_isNCName, m_createDocumentNode, 6834 6949 m_setNameCheck, m_setTextCheck, m_setObjectCommands, 6835 - m_featureinfo, m_isBMPCharData 6950 + m_featureinfo, m_isBMPCharData, m_clearString 6836 6951 #ifdef TCL_THREADS 6837 6952 ,m_attachDocument, m_detachDocument 6838 6953 #endif 6839 6954 }; 6840 6955 6841 6956 static const char *nodeModeValues[] = { 6842 6957 "automatic", "command", "token", NULL ................................................................................ 7058 7173 CheckArgs(3,3,2,"feature") 7059 7174 return tcldom_featureinfo(clientData, interp, --objc, objv+1); 7060 7175 7061 7176 case m_isBMPCharData: 7062 7177 CheckArgs(3,3,2,"string"); 7063 7178 SetBooleanResult(domIsBMPChar(Tcl_GetString(objv[2]))); 7064 7179 return TCL_OK; 7180 + 7181 + case m_clearString: 7182 + CheckArgs(3,3,2,"string"); 7183 + clearedStr = domClearString (Tcl_GetString (objv[2]), &bool); 7184 + if (bool) { 7185 + newObj = Tcl_NewStringObj (clearedStr, -1); 7186 + FREE (clearedStr); 7187 + Tcl_SetObjResult (interp, newObj); 7188 + } else { 7189 + Tcl_SetObjResult (interp, objv[2]); 7190 + } 7191 + return TCL_OK; 7065 7192 7066 7193 } 7067 7194 SetResult( dom_usage); 7068 7195 return TCL_ERROR; 7069 7196 } 7070 7197 7071 7198 #ifdef TCL_THREADS
Changes to generic/tcldom.h.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 1999 Jochen Loewer (loewerj@hotmail.com) 3 3 +----------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A DOM implementation for Tcl using James Clark's expat XML parser 9 6 | 10 7 | 11 8 | The contents of this file are subject to the Mozilla Public License 12 9 | Version 2.0 (the "License"); you may not use this file except in 13 10 | compliance with the License. You may obtain a copy of the License at ................................................................................ 48 45 int tcldom_PIValueCheck(Tcl_Interp *interp, char *text); 49 46 int tcldom_PINameCheck(Tcl_Interp *interp, char *name); 50 47 int tcldom_nameCheck(Tcl_Interp *interp, char *name, char *nameType, 51 48 int isFQName); 52 49 void tcldom_createNodeObj(Tcl_Interp * interp, domNode *node, 53 50 char *objCmdName); 54 51 52 +domNode * tcldom_getNodeFromObj(Tcl_Interp *interp, Tcl_Obj *nodeObj); 53 +int tcldom_prefixNSlist (char ***prefixnsPtr, Tcl_Interp *interp, int objc, 54 + Tcl_Obj *const objv[], const char *methodName); 55 +int tcldom_setInterpAndReturnVar (Tcl_Interp *interp, domNode *node, 56 + int setVariable, Tcl_Obj *var_name); 55 57 56 58 void tcldom_initialize(void); 57 59 58 60 Tcl_ObjCmdProc tcldom_DomObjCmd; 59 61 Tcl_ObjCmdProc tcldom_DocObjCmd; 60 62 Tcl_ObjCmdProc tcldom_NodeObjCmd; 61 -Tcl_ObjCmdProc TclExpatObjCmd; 62 63 Tcl_ObjCmdProc tcldom_unknownCmd; 63 64 Tcl_ObjCmdProc TclTdomObjCmd; 64 65 65 66 #if defined(_MSC_VER) || defined(__MINGW32__) 66 67 # undef TCL_STORAGE_CLASS 67 68 # define TCL_STORAGE_CLASS DLLEXPORT 68 69 #endif 69 70 70 71 #define STR_TDOM_VERSION(v) (VERSION) 71 72 72 -EXTERN int Tdom_Init (Tcl_Interp *interp); 73 -EXTERN int Tdom_SafeInit (Tcl_Interp *interp); 73 +int Tdom_Init (Tcl_Interp *interp); 74 +int Tdom_SafeInit (Tcl_Interp *interp); 74 75 75 76 #endif 76 77 77 78
Changes to generic/tclexpat.c.
35 35 | 36 36 \---------------------------------------------------------------------------*/ 37 37 #include <tcl.h> 38 38 #include <string.h> 39 39 #include <dom.h> 40 40 #include <tclexpat.h> 41 41 #include <fcntl.h> 42 -#include <structure.h> 42 +#include <schema.h> 43 43 44 44 #ifdef _MSC_VER 45 45 #include <io.h> 46 46 #else 47 47 #include <unistd.h> 48 48 #endif 49 49 ................................................................................ 96 96 \---------------------------------------------------------------------------*/ 97 97 98 98 typedef enum { 99 99 EXPAT_INPUT_STRING, 100 100 EXPAT_INPUT_CHANNEL, 101 101 EXPAT_INPUT_FILENAME 102 102 } TclExpat_InputType; 103 - 104 - 105 103 106 104 /*---------------------------------------------------------------------------- 107 105 | local globals 108 106 | 109 107 \---------------------------------------------------------------------------*/ 110 108 111 109 static int uniqueCounter = 0; /* Counter to generate unique command names ................................................................................ 343 341 TclExpatObjCmd( 344 342 ClientData dummy, 345 343 Tcl_Interp *interp, 346 344 int objc, 347 345 Tcl_Obj *const objv[] 348 346 ) { 349 347 TclGenExpatInfo *genexpat; 350 - int ns_mode = 0; 351 - char *nsoption; 352 - 353 348 354 349 /* 355 350 * Create the data structures for this parser. 356 351 */ 357 352 358 353 if (!(genexpat = (TclGenExpatInfo *) MALLOC(sizeof(TclGenExpatInfo)))) { 359 354 FREE( (char*) genexpat); ................................................................................ 377 372 objc--; 378 373 } else { 379 374 genexpat->name = FindUniqueCmdName(interp); 380 375 } 381 376 } 382 377 383 378 genexpat->paramentityparsing = XML_PARAM_ENTITY_PARSING_NEVER; 384 - 385 - if (objc > 1) { 386 - nsoption = Tcl_GetString(objv[1]); 387 - if (strcmp(nsoption,"-namespace")==0) { 388 - ns_mode = 1; 389 - objv++; 390 - objc--; 391 - } 392 - } 393 - genexpat->ns_mode = ns_mode; 394 379 genexpat->nsSeparator = ':'; 395 380 381 + if (objc > 0) { 382 + /* 383 + * Handle configuration options 384 + */ 385 + if (TclExpatConfigure(interp, genexpat, objc - 1, objv + 1) != TCL_OK) { 386 + TclExpatDeleteCmd (genexpat); 387 + return TCL_ERROR; 388 + } 389 + } 396 390 if (TclExpatInitializeParser(interp, genexpat, 0) != TCL_OK) { 397 - FREE( (char*) genexpat); 398 - return TCL_ERROR; 391 + TclExpatDeleteCmd (genexpat); 392 + return TCL_ERROR; 399 393 } 400 394 401 395 /* 402 396 * Register a Tcl command for this parser instance. 403 397 */ 404 398 405 399 Tcl_CreateObjCommand(interp, Tcl_GetString(genexpat->name), 406 400 TclExpatInstanceCmd, (ClientData) genexpat, 407 401 TclExpatDeleteCmd); 408 - /* 409 - * Handle configuration options 410 - */ 411 - 412 - if (objc > 1) { 413 - if (TclExpatConfigure(interp, genexpat, objc - 1, objv + 1) != TCL_OK) { 414 - return TCL_ERROR; 415 - } 416 - } 417 - 418 402 Tcl_SetObjResult(interp, genexpat->name); 419 403 420 404 return TCL_OK; 421 405 } 422 406 423 407 424 408 /* ................................................................................ 530 514 eContentSave = eContent; 531 515 eContent = eContent->next; 532 516 FREE((char *) eContentSave); 533 517 } 534 518 expat->eContents = NULL; 535 519 expat->finished = 0; 536 520 expat->parsingState = 0; 521 +#ifndef TDOM_NO_SCHEMA 522 + if (expat->sdata) { 523 + tDOM_schemaReset (expat->sdata, 1); 524 + } 525 +#endif 537 526 538 527 if (resetOptions) { 539 528 expat->final = 1; 540 529 expat->needWSCheck = 0; 541 530 expat->noexpand = 0; 542 531 expat->useForeignDTD = 0; 543 532 expat->paramentityparsing = XML_PARAM_ENTITY_PARSING_NEVER; ................................................................................ 548 537 } 549 538 550 539 if (expat->baseURI) { 551 540 XML_SetBase (expat->parser, Tcl_GetString (expat->baseURI)); 552 541 Tcl_DecrRefCount (expat->baseURI); 553 542 expat->baseURI = NULL; 554 543 } 544 + XML_SetParamEntityParsing(expat->parser, 545 + expat->paramentityparsing); 546 + XML_UseForeignDTD (expat->parser, (unsigned char)expat->useForeignDTD); 555 547 556 548 /* 557 549 * Set handlers for the parser to routines in this module. 558 550 */ 559 551 560 552 XML_SetElementHandler(expat->parser, 561 553 TclGenExpatElementStartHandler, ................................................................................ 646 638 * 647 639 * Set as defaultHandler prior to XML_Currentmarkup() call. 648 640 * 649 641 * Results: 650 642 * None. 651 643 * 652 644 * Side effects: 653 - * Stores the markup context in expapt->currentmarkup. 645 + * Stores the markup context in expat->currentmarkup. 654 646 * 655 647 *---------------------------------------------------------------------------- 656 648 */ 657 649 static void 658 650 CurrentmarkupCommand ( 659 651 void *userData, 660 652 const char *s, ................................................................................ 705 697 Tcl_Interp *interp, 706 698 int objc, 707 699 Tcl_Obj *const objv[] 708 700 ) { 709 701 TclGenExpatInfo *expat = (TclGenExpatInfo *) clientData; 710 702 char *data; 711 703 int len = 0, optionIndex, result = TCL_OK; 712 - 704 +#ifndef TDOM_NO_SCHEMA 705 + int resetsdata = 0; 706 +#endif 707 + 713 708 static const char *options[] = { 714 709 "configure", "cget", "currentmarkup", "free", "get", 715 710 "parse", "parsechannel", "parsefile", "reset", "delete", 716 711 NULL 717 712 }; 718 713 enum options { 719 714 EXPAT_CONFIGURE, EXPAT_CGET, EXPAT_CURRENTMARKUP, EXPAT_FREE, EXPAT_GET, ................................................................................ 787 782 CheckArgs (2,2,1,""); 788 783 789 784 if (expat->parsingState > 1) { 790 785 Tcl_SetResult (interp, "parser delete not allowed from within " 791 786 "callback", TCL_STATIC); 792 787 result = TCL_ERROR; 793 788 } else { 789 +#ifndef TDOM_NO_SCHEMA 790 + if (expat->sdata) { 791 + expat->sdata->inuse--; 792 + tDOM_schemaReset (expat->sdata, 1); 793 + } 794 +#endif 794 795 Tcl_DeleteCommand(interp, Tcl_GetString(expat->name)); 795 796 result = TCL_OK; 796 797 } 797 798 break; 798 799 799 800 case EXPAT_GET: 800 801 ................................................................................ 808 809 CheckArgs (3,3,2,"<XML-String>"); 809 810 if (expat->parsingState > 1) { 810 811 Tcl_SetResult (interp, "Parser already in use.", TCL_STATIC); 811 812 result = TCL_ERROR; 812 813 break; 813 814 } 814 815 data = Tcl_GetStringFromObj(objv[2], &len); 816 +#ifndef TDOM_NO_SCHEMA 817 + if (expat->sdata) { 818 + if (expat->parsingState == 0) { 819 + if (expat->sdata->validationState != VALIDATION_READY) { 820 + Tcl_SetResult (interp, "The configured schema command " 821 + "is busy", TCL_STATIC); 822 + result = TCL_ERROR; 823 + break; 824 + } 825 + } 826 + expat->sdata->parser = expat->parser; 827 + } 828 +#endif 815 829 result = TclExpatParse(interp, expat, data, len, EXPAT_INPUT_STRING); 816 830 if (expat->final || result != TCL_OK) { 831 +#ifndef TDOM_NO_SCHEMA 832 + resetsdata = 1; 833 +#endif 817 834 expat->final = 1; 818 835 expat->finished = 1; 819 836 } 820 837 break; 821 838 822 839 case EXPAT_PARSECHANNEL: 823 840 824 841 CheckArgs (3,3,2,"<Tcl-Channel>"); 825 842 if (expat->parsingState > 1) { 826 843 Tcl_SetResult (interp, "Parser already in use.", TCL_STATIC); 827 844 result = TCL_ERROR; 828 845 break; 829 846 } 847 +#ifndef TDOM_NO_SCHEMA 848 + if (expat->sdata) { 849 + if (expat->parsingState == 0) { 850 + if (expat->sdata->validationState != VALIDATION_READY) { 851 + Tcl_SetResult (interp, "The configured schema command " 852 + "is busy", TCL_STATIC); 853 + result = TCL_ERROR; 854 + break; 855 + } 856 + } 857 + expat->sdata->parser = expat->parser; 858 + } 859 +#endif 830 860 data = Tcl_GetString(objv[2]); 831 861 result = TclExpatParse(interp, expat, data, len, EXPAT_INPUT_CHANNEL); 832 862 if (expat->final || result != TCL_OK) { 863 +#ifndef TDOM_NO_SCHEMA 864 + resetsdata = 1; 865 +#endif 833 866 expat->final = 1; 834 867 expat->finished = 1; 835 868 } 836 869 break; 837 870 838 871 case EXPAT_PARSEFILE: 839 872 840 873 CheckArgs (3,3,2, "<filename>"); 841 874 if (expat->parsingState > 1) { 842 875 Tcl_SetResult (interp, "Parser already in use.", TCL_STATIC); 843 876 result = TCL_ERROR; 844 877 break; 845 878 } 879 +#ifndef TDOM_NO_SCHEMA 880 + if (expat->sdata) { 881 + if (expat->parsingState == 0) { 882 + if (expat->sdata->validationState != VALIDATION_READY) { 883 + Tcl_SetResult (interp, "The configured schema command " 884 + "is busy", TCL_STATIC); 885 + result = TCL_ERROR; 886 + break; 887 + } 888 + } 889 + expat->sdata->parser = expat->parser; 890 + } 891 +#endif 846 892 data = Tcl_GetString(objv[2]); 847 893 result = TclExpatParse (interp, expat, data, len, 848 894 EXPAT_INPUT_FILENAME); 849 895 if (expat->final || result != TCL_OK) { 896 +#ifndef TDOM_NO_SCHEMA 897 + resetsdata = 1; 898 +#endif 850 899 expat->final = 1; 851 900 expat->finished = 1; 852 901 } 853 902 break; 854 903 855 904 case EXPAT_RESET: 856 905 ................................................................................ 863 912 } else { 864 913 result = TclExpatInitializeParser (interp, expat, 1); 865 914 } 866 915 break; 867 916 868 917 } 869 918 919 +#ifndef TDOM_NO_SCHEMA 920 + if (resetsdata && expat->sdata) { 921 + tDOM_schemaReset (expat->sdata, 1); 922 + } 923 +#endif 870 924 return result; 871 925 } 872 926 873 927 874 928 /* 875 929 *---------------------------------------------------------------------------- 876 930 * ................................................................................ 1105 1159 "-notationdeclcommand", 1106 1160 "-externalentitycommand", 1107 1161 "-unknownencodingcommand", 1108 1162 "-startnamespacedeclcommand", 1109 1163 "-endnamespacedeclcommand", 1110 1164 "-ignorewhitecdata", 1111 1165 "-useForeignDTD", 1166 + "-namespace", 1167 + "-namespaceseparator", 1112 1168 1113 1169 "-commentcommand", 1114 1170 "-notstandalonecommand", 1115 1171 "-startcdatasectioncommand", 1116 1172 "-endcdatasectioncommand", 1117 1173 "-elementdeclcommand", 1118 1174 "-attlistdeclcommand", ................................................................................ 1120 1176 "-enddoctypedeclcommand", 1121 1177 "-xmldeclcommand", 1122 1178 "-paramentityparsing", 1123 1179 "-entitydeclcommand", 1124 1180 "-ignorewhitespace", 1125 1181 "-handlerset", 1126 1182 "-noexpand", 1127 -#ifndef TDOM_NO_STRUCTURE 1183 +#ifndef TDOM_NO_SCHEMA 1128 1184 "-validateCmd", 1129 1185 #endif 1130 1186 (char *) NULL 1131 1187 }; 1132 1188 enum switches { 1133 1189 EXPAT_FINAL, EXPAT_BASE, 1134 1190 EXPAT_ELEMENTSTARTCMD, EXPAT_ELEMENTENDCMD, ................................................................................ 1136 1192 EXPAT_DEFAULTCMD, 1137 1193 EXPAT_NOTATIONCMD, 1138 1194 EXPAT_EXTERNALENTITYCMD, EXPAT_UNKNOWNENCODINGCMD, 1139 1195 EXPAT_STARTNAMESPACEDECLCMD, 1140 1196 EXPAT_ENDNAMESPACEDECLCMD, 1141 1197 EXPAT_IGNOREWHITECDATA, 1142 1198 EXPAT_USEFOREIGNDTD, 1199 + EXPAT_NAMESPACE, 1200 + EXPAT_NAMESPACESEPARATOR, 1143 1201 1144 1202 EXPAT_COMMENTCMD, EXPAT_NOTSTANDALONECMD, 1145 1203 EXPAT_STARTCDATASECTIONCMD, EXPAT_ENDCDATASECTIONCMD, 1146 1204 EXPAT_ELEMENTDECLCMD, EXPAT_ATTLISTDECLCMD, 1147 1205 EXPAT_STARTDOCTYPEDECLCMD, EXPAT_ENDDOCTYPEDECLCMD, 1148 1206 EXPAT_XMLDECLCMD, 1149 1207 EXPAT_PARAMENTITYPARSING, 1150 1208 EXPAT_ENTITYDECLCOMMAND, 1151 1209 EXPAT_NOWHITESPACE, 1152 1210 EXPAT_HANDLERSET, 1153 1211 EXPAT_NOEXPAND 1154 -#ifndef TDOM_NO_STRUCTURE 1212 +#ifndef TDOM_NO_SCHEMA 1155 1213 ,EXPAT_VALIDATECMD 1156 1214 #endif 1157 1215 }; 1158 1216 static const char *paramEntityParsingValues[] = { 1159 1217 "always", 1160 1218 "never", 1161 1219 "notstandalone", ................................................................................ 1165 1223 EXPAT_PARAMENTITYPARSINGALWAYS, 1166 1224 EXPAT_PARAMENTITYPARSINGNEVER, 1167 1225 EXPAT_PARAMENTITYPARSINGNOTSTANDALONE 1168 1226 }; 1169 1227 int optionIndex, value, bool; 1170 1228 Tcl_Obj *const *objPtr = objv; 1171 1229 Tcl_CmdInfo cmdInfo; 1172 - int rc; 1230 + int rc, len; 1173 1231 char *handlerSetName = NULL; 1174 1232 TclHandlerSet *tmpTclHandlerSet, *activeTclHandlerSet = NULL; 1233 + Tcl_UniChar uniChar; 1234 +#ifndef TDOM_NO_SCHEMA 1235 + char *schemacmd; 1236 +#endif 1175 1237 1176 1238 if (expat->firstTclHandlerSet 1177 1239 && (strcmp ("default", expat->firstTclHandlerSet->name)==0)) { 1178 1240 activeTclHandlerSet = expat->firstTclHandlerSet; 1179 1241 } 1180 - while (objc > 1) { 1242 + while (objc > 0) { 1181 1243 if (Tcl_GetIndexFromObj(interp, objPtr[0], switches, 1182 1244 "switch", 0, &optionIndex) != TCL_OK) { 1183 1245 return TCL_ERROR; 1246 + } 1247 + if (objc == 1) { 1248 + if (optionIndex != EXPAT_NAMESPACE) { 1249 + Tcl_WrongNumArgs (interp, 1, objPtr, "<value>"); 1250 + return TCL_ERROR; 1251 + } 1184 1252 } 1185 1253 switch ((enum switches) optionIndex) { 1254 + case EXPAT_NAMESPACE: /* -namespace */ 1255 + 1256 + /* This option is a creation time / set once one */ 1257 + if (!expat->parser) { 1258 + expat->ns_mode = 1; 1259 + } 1260 + objPtr++; 1261 + objc--; 1262 + continue; 1263 + 1264 + case EXPAT_NAMESPACESEPARATOR: /* -namespaceseparator */ 1265 + 1266 + len = Tcl_GetCharLength (objPtr[1]); 1267 + if (len > 1) { 1268 + Tcl_SetResult (interp, "invalid -namespaceseparator argument", 1269 + NULL); 1270 + return TCL_ERROR; 1271 + } 1272 + if (len == 0) { 1273 + if (!expat->parser) { 1274 + expat->nsSeparator = 0; 1275 + } 1276 + break; 1277 + } 1278 + Tcl_UtfToUniChar (Tcl_GetString (objPtr[1]), &uniChar); 1279 + if (uniChar > 255) { 1280 + Tcl_SetResult (interp, "invalid -namespaceseparator argument", 1281 + NULL); 1282 + return TCL_ERROR; 1283 + } 1284 + /* This option is a creation time / set once one */ 1285 + if (!expat->parser) { 1286 + expat->nsSeparator = uniChar; 1287 + } 1288 + break; 1289 + 1186 1290 case EXPAT_FINAL: /* -final */ 1187 1291 1188 1292 if (Tcl_GetBooleanFromObj(interp, objPtr[1], &bool) != TCL_OK) { 1189 1293 return TCL_ERROR; 1190 1294 } 1191 1295 1192 1296 expat->final = bool; 1193 1297 break; 1194 1298 1195 - case EXPAT_BASE: /* -base */ 1299 + case EXPAT_BASE: /* -baseurl */ 1196 1300 1197 - if (expat->finished) { 1198 - if (expat->baseURI) { 1199 - Tcl_DecrRefCount (expat->baseURI); 1200 - } 1301 + if (expat->baseURI) { 1302 + Tcl_DecrRefCount (expat->baseURI); 1303 + expat->baseURI = NULL; 1304 + } 1305 + if (!expat->parser || expat->finished) { 1201 1306 expat->baseURI = objPtr[1]; 1202 1307 Tcl_IncrRefCount (expat->baseURI); 1203 - } else { 1204 - if (XML_SetBase(expat->parser, Tcl_GetString(objPtr[1])) 1205 - == 0) { 1206 - Tcl_SetResult(interp, "unable to set base URL", NULL); 1207 - return TCL_ERROR; 1308 + } else { 1309 + if (expat->parser) { 1310 + if (XML_SetBase(expat->parser, Tcl_GetString(objPtr[1])) 1311 + == 0) { 1312 + Tcl_SetResult(interp, "unable to set base URL", NULL); 1313 + return TCL_ERROR; 1314 + } 1208 1315 } 1209 - } 1316 + } 1210 1317 break; 1211 1318 1212 1319 case EXPAT_ELEMENTSTARTCMD: /* -elementstartcommand */ 1213 1320 1214 1321 CheckDefaultTclHandlerSet; 1215 1322 if (activeTclHandlerSet->elementstartcommand != NULL) { 1216 1323 Tcl_DecrRefCount(activeTclHandlerSet->elementstartcommand); ................................................................................ 1366 1473 break; 1367 1474 1368 1475 case EXPAT_USEFOREIGNDTD: /* -useForeignDTD */ 1369 1476 1370 1477 if (Tcl_GetBooleanFromObj (interp, objPtr[1], &bool) != TCL_OK) { 1371 1478 return TCL_ERROR; 1372 1479 } 1373 - /* Cannot be changed after parsing as started (which is kind of 1374 - understandable). We silently ignore return code. */ 1375 - XML_UseForeignDTD (expat->parser, (unsigned char)bool); 1480 + if (expat->parser) { 1481 + /* Cannot be changed after parsing as started (which is 1482 + kind of understandable). */ 1483 + if (XML_UseForeignDTD (expat->parser, (unsigned char)bool) 1484 + != XML_ERROR_NONE) { 1485 + expat->useForeignDTD = bool; 1486 + } 1487 + } else { 1488 + expat->useForeignDTD = bool; 1489 + } 1376 1490 break; 1377 1491 1378 1492 case EXPAT_COMMENTCMD: /* -commentcommand */ 1379 1493 /* ericm@scriptics.com */ 1380 1494 CheckDefaultTclHandlerSet; 1381 1495 if (activeTclHandlerSet->commentCommand != NULL) { 1382 1496 Tcl_DecrRefCount(activeTclHandlerSet->commentCommand); ................................................................................ 1490 1604 1491 1605 activeTclHandlerSet->entityDeclCommand = objPtr[1]; 1492 1606 Tcl_IncrRefCount (activeTclHandlerSet->entityDeclCommand); 1493 1607 1494 1608 break; 1495 1609 1496 1610 case EXPAT_PARAMENTITYPARSING: /* -paramentityparsing */ 1497 - /* ericm@scriptics */ 1498 1611 if (Tcl_GetIndexFromObj(interp, objPtr[1], paramEntityParsingValues, 1499 1612 "value", 0, &value) != TCL_OK) { 1500 1613 return TCL_ERROR; 1501 1614 } 1502 - switch ((enum paramEntityParsingValues) value) { 1503 - case EXPAT_PARAMENTITYPARSINGALWAYS: 1504 - XML_SetParamEntityParsing(expat->parser, 1505 - XML_PARAM_ENTITY_PARSING_ALWAYS); 1506 - expat->paramentityparsing = XML_PARAM_ENTITY_PARSING_ALWAYS; 1507 - break; 1508 - case EXPAT_PARAMENTITYPARSINGNEVER: 1509 - XML_SetParamEntityParsing(expat->parser, 1510 - XML_PARAM_ENTITY_PARSING_NEVER); 1511 - expat->paramentityparsing = XML_PARAM_ENTITY_PARSING_NEVER; 1512 - break; 1513 - case EXPAT_PARAMENTITYPARSINGNOTSTANDALONE: 1514 - XML_SetParamEntityParsing(expat->parser, 1515 - XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE); 1516 - expat->paramentityparsing = 1517 - XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE; 1518 - break; 1615 + switch ((enum paramEntityParsingValues) value) { 1616 + case EXPAT_PARAMENTITYPARSINGALWAYS: 1617 + expat->paramentityparsing = XML_PARAM_ENTITY_PARSING_ALWAYS; 1618 + break; 1619 + case EXPAT_PARAMENTITYPARSINGNEVER: 1620 + expat->paramentityparsing = XML_PARAM_ENTITY_PARSING_NEVER; 1621 + break; 1622 + case EXPAT_PARAMENTITYPARSINGNOTSTANDALONE: 1623 + expat->paramentityparsing = 1624 + XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE; 1625 + break; 1519 1626 } 1627 + if (expat->parser) { 1628 + XML_SetParamEntityParsing (expat->parser, 1629 + expat->paramentityparsing); 1630 + } 1520 1631 break; 1521 1632 1522 1633 case EXPAT_HANDLERSET: 1523 1634 if ((handlerSetName = Tcl_GetString(objPtr[1])) == NULL) { 1524 1635 return TCL_ERROR; 1525 1636 } 1526 1637 activeTclHandlerSet = expat->firstTclHandlerSet; ................................................................................ 1542 1653 } 1543 1654 tmpTclHandlerSet->nextHandlerSet = activeTclHandlerSet; 1544 1655 } 1545 1656 } 1546 1657 break; 1547 1658 1548 1659 case EXPAT_NOEXPAND: 1549 - if (Tcl_GetBooleanFromObj (interp, objv[1], &bool) != TCL_OK) { 1660 + if (Tcl_GetBooleanFromObj (interp, objPtr[1], &bool) != TCL_OK) { 1550 1661 return TCL_ERROR; 1551 1662 } 1552 1663 if (bool) { 1553 1664 XML_SetDefaultHandler( expat->parser, 1554 1665 TclGenExpatDefaultHandler); 1555 1666 } else { 1556 1667 XML_SetDefaultHandlerExpand( expat->parser, 1557 1668 TclGenExpatDefaultHandler); 1558 1669 } 1559 1670 expat->noexpand = bool; 1560 1671 break; 1561 1672 1562 -#ifndef TDOM_NO_STRUCTURE 1673 +#ifndef TDOM_NO_SCHEMA 1563 1674 case EXPAT_VALIDATECMD: 1564 - if (!Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo)) { 1565 - SetResult3("The \"-validateCmd\" argument \"", 1566 - Tcl_GetString(objv[1]), 1567 - "\" is not a tDOM validation command."); 1568 - return TCL_ERROR; 1675 + schemacmd = Tcl_GetString (objv[1]); 1676 + if (schemacmd[0] == '\0') { 1677 + if (expat->sdata) { 1678 + expat->sdata->inuse--; 1679 + tDOM_schemaReset (expat->sdata, 1); 1680 + expat->sdata = NULL; 1681 + } 1682 + } else { 1683 + if (expat->sdata) { 1684 + expat->sdata->inuse--; 1685 + tDOM_schemaReset (expat->sdata, 1); 1686 + expat->sdata = NULL; 1687 + } 1688 + if (!Tcl_GetCommandInfo(interp, schemacmd, &cmdInfo)) { 1689 + SetResult3("The \"-validateCmd\" argument \"", 1690 + Tcl_GetString(objv[1]), 1691 + "\" is not a tDOM validation command."); 1692 + return TCL_ERROR; 1693 + } 1694 + if (cmdInfo.objProc != tDOM_schemaInstanceCmd) { 1695 + SetResult3("The \"-validateCmd\" argument \"", 1696 + Tcl_GetString(objv[1]), 1697 + "\" is not a tDOM validation command."); 1698 + return TCL_ERROR; 1699 + } 1700 + expat->sdata = (SchemaData *) cmdInfo.objClientData; 1701 + expat->sdata->inuse++; 1569 1702 } 1570 - if (cmdInfo.objProc != structureInstanceCmd) { 1571 - SetResult3("The \"-validateCmd\" argument \"", 1572 - Tcl_GetString(objv[1]), 1573 - "\" is not a tDOM validation command."); 1574 - return TCL_ERROR; 1575 - } 1576 - expat->sdata = (StructureData *) cmdInfo.objClientData; 1577 1703 #endif 1578 1704 } 1579 1705 1580 1706 objPtr += 2; 1581 1707 objc -= 2; 1582 1708 1583 1709 } ................................................................................ 1634 1760 "-xmldeclcommand", 1635 1761 "-paramentityparsing", 1636 1762 "-entitydeclcommand", 1637 1763 "-ignorewhitespace", 1638 1764 "-handlerset", 1639 1765 "-noexpand", 1640 1766 "-namespace", 1767 + "-namespaceseparator", 1641 1768 (char *) NULL 1642 1769 }; 1643 1770 enum switches { 1644 1771 EXPAT_FINAL, EXPAT_BASE, 1645 1772 EXPAT_ELEMENTSTARTCMD, EXPAT_ELEMENTENDCMD, 1646 1773 EXPAT_DATACMD, EXPAT_PICMD, 1647 1774 EXPAT_DEFAULTCMD, ................................................................................ 1658 1785 EXPAT_STARTDOCTYPEDECLCMD, EXPAT_ENDDOCTYPEDECLCMD, 1659 1786 EXPAT_XMLDECLCMD, 1660 1787 EXPAT_PARAMENTITYPARSING, 1661 1788 EXPAT_ENTITYDECLCOMMAND, 1662 1789 EXPAT_NOWHITESPACE, 1663 1790 EXPAT_HANDLERSET, 1664 1791 EXPAT_NOEXPAND, 1665 - EXPAT_NAMESPACE 1792 + EXPAT_NAMESPACE, 1793 + EXPAT_NAMESPACESEPARATOR 1666 1794 }; 1667 - int optionIndex; 1795 + int optionIndex, len; 1668 1796 TclHandlerSet *activeTclHandlerSet = NULL; 1669 1797 char *handlerSetName = NULL; 1670 1798 Tcl_Obj* objPtr; 1799 + char utfBuf[TCL_UTF_MAX]; 1800 + Tcl_DString dStr; 1801 + Tcl_UniChar uniChar; 1671 1802 1672 1803 if (Tcl_GetIndexFromObj(interp, objv[0], switches, 1673 1804 "switch", 0, &optionIndex) != TCL_OK) { 1674 1805 return TCL_ERROR; 1675 1806 } 1676 1807 activeTclHandlerSet = expat->firstTclHandlerSet; 1677 1808 ................................................................................ 1717 1848 switch ((enum switches) optionIndex) { 1718 1849 1719 1850 case EXPAT_FINAL: /* -final */ 1720 1851 1721 1852 Tcl_SetResult(interp, expat->final ? "1" : "0", NULL); 1722 1853 return TCL_OK; 1723 1854 1724 - case EXPAT_BASE: /* -base */ 1855 + case EXPAT_BASE: /* -baseurl */ 1725 1856 1726 - if (expat->finished) { 1857 + if (!expat->parser || expat->finished) { 1727 1858 Tcl_SetResult (interp, expat->baseURI != NULL 1728 1859 ? Tcl_GetString (expat->baseURI) : "", NULL); 1729 1860 } else { 1730 1861 Tcl_SetResult(interp, XML_GetBase(expat->parser) != NULL 1731 1862 ? (char*) XML_GetBase(expat->parser) : "", NULL); 1732 1863 } 1733 1864 return TCL_OK; ................................................................................ 1759 1890 SetIntResult (interp, expat->noexpand); 1760 1891 return TCL_OK; 1761 1892 1762 1893 case EXPAT_NAMESPACE: /* -namespace */ 1763 1894 1764 1895 SetIntResult (interp, expat->ns_mode); 1765 1896 return TCL_OK; 1897 + 1898 + case EXPAT_NAMESPACESEPARATOR: /* -namespaceseparator */ 1899 + 1900 + if (expat->nsSeparator) { 1901 + uniChar = expat->nsSeparator; 1902 + len = Tcl_UniCharToUtf (uniChar, utfBuf); 1903 + Tcl_DStringInit (&dStr); 1904 + Tcl_DStringAppend (&dStr, utfBuf, len); 1905 + Tcl_DStringResult (interp, &dStr); 1906 + Tcl_DStringFree (&dStr); 1907 + } 1908 + return TCL_OK; 1766 1909 1767 1910 case EXPAT_NOWHITESPACE: 1768 1911 case EXPAT_IGNOREWHITECDATA: /* -ignorewhitecdata */ 1769 1912 1770 1913 if (activeTclHandlerSet == NULL) { 1771 1914 /* Without any handler script, we return a default boolean 1772 1915 value */ ................................................................................ 2246 2389 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->elementstartcommand); 2247 2390 Tcl_IncrRefCount(cmdPtr); 2248 2391 Tcl_Preserve((ClientData) expat->interp); 2249 2392 2250 2393 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 2251 2394 Tcl_NewStringObj((char *)name, -1)); 2252 2395 Tcl_ListObjAppendElement(expat->interp, cmdPtr, atList); 2253 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2254 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2255 -#else 2256 2396 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2257 - TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 2258 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2397 + TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT ); 2259 2398 2260 2399 Tcl_DecrRefCount(cmdPtr); 2261 2400 Tcl_Release((ClientData) expat->interp); 2262 2401 2263 2402 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2264 2403 } 2265 2404 } ................................................................................ 2275 2414 if (activeCHandlerSet->elementstartcommand) { 2276 2415 activeCHandlerSet->elementstartcommand (activeCHandlerSet->userData, 2277 2416 name, atts); 2278 2417 } 2279 2418 activeCHandlerSet = activeCHandlerSet->nextHandlerSet; 2280 2419 } 2281 2420 2421 +#ifndef TDOM_NO_SCHEMA 2282 2422 if (expat->sdata) { 2283 - if (probeElement (expat->interp, expat->sdata, name, NULL) != TCL_OK) { 2423 + if (tDOM_probeElement (expat->interp, expat->sdata, name, NULL) 2424 + != TCL_OK) { 2284 2425 TclExpatHandlerResult (expat, NULL, TCL_ERROR); 2285 2426 } 2427 + if (atts[0] || (expat->sdata->stack 2428 + && expat->sdata->stack->pattern->attrs)) { 2429 + if (tDOM_probeAttributes (expat->interp, expat->sdata, atts) 2430 + != TCL_OK) { 2431 + expat->sdata->validationState = VALIDATION_ERROR; 2432 + TclExpatHandlerResult (expat, NULL, TCL_ERROR); 2433 + } 2434 + } 2286 2435 } 2436 +#endif 2287 2437 return; 2288 2438 } 2289 2439 2290 2440 2291 2441 /* 2292 2442 *---------------------------------------------------------------------------- 2293 2443 * ................................................................................ 2371 2521 2372 2522 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->elementendcommand); 2373 2523 Tcl_IncrRefCount(cmdPtr); 2374 2524 Tcl_Preserve((ClientData) expat->interp); 2375 2525 2376 2526 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 2377 2527 Tcl_NewStringObj((char *)name, -1)); 2378 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2379 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2380 -#else 2381 2528 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2382 2529 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT ); 2383 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2384 2530 2385 2531 Tcl_DecrRefCount(cmdPtr); 2386 2532 Tcl_Release((ClientData) expat->interp); 2387 2533 2388 2534 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2389 2535 } 2390 2536 } ................................................................................ 2400 2546 if (activeCHandlerSet->elementendcommand ) { 2401 2547 activeCHandlerSet->elementendcommand (activeCHandlerSet->userData, 2402 2548 name); 2403 2549 } 2404 2550 activeCHandlerSet = activeCHandlerSet->nextHandlerSet; 2405 2551 } 2406 2552 2553 +#ifndef TDOM_NO_SCHEMA 2407 2554 if (expat->sdata) { 2408 - if (probeElementEnd (expat->interp, expat->sdata) != TCL_OK) { 2555 + if (tDOM_probeElementEnd (expat->interp, expat->sdata) != TCL_OK) { 2409 2556 TclExpatHandlerResult (expat, NULL, TCL_ERROR); 2410 2557 } 2411 2558 } 2559 +#endif 2412 2560 return; 2413 2561 } 2414 2562 2415 2563 2416 2564 /* 2417 2565 *---------------------------------------------------------------------------- 2418 2566 * ................................................................................ 2471 2619 Tcl_IncrRefCount(cmdPtr); 2472 2620 Tcl_Preserve((ClientData) expat->interp); 2473 2621 2474 2622 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 2475 2623 Tcl_NewStringObj((char *)prefix, -1)); 2476 2624 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 2477 2625 Tcl_NewStringObj((char *)uri, -1)); 2478 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2479 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2480 -#else 2481 2626 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2482 2627 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 2483 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2484 2628 2485 2629 Tcl_DecrRefCount(cmdPtr); 2486 2630 Tcl_Release((ClientData) expat->interp); 2487 2631 2488 2632 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2489 2633 nextTcl: 2490 2634 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 2555 2699 */ 2556 2700 2557 2701 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->endnsdeclcommand); 2558 2702 Tcl_IncrRefCount(cmdPtr); 2559 2703 Tcl_Preserve((ClientData) expat->interp); 2560 2704 2561 2705 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)prefix, -1)); 2562 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2563 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2564 -#else 2565 2706 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2566 2707 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 2567 -#endif /* if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2568 2708 2569 2709 Tcl_DecrRefCount(cmdPtr); 2570 2710 Tcl_Release((ClientData) expat->interp); 2571 2711 2572 2712 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2573 2713 nextTcl: 2574 2714 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 2732 2872 */ 2733 2873 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->datacommand); 2734 2874 Tcl_IncrRefCount(cmdPtr); 2735 2875 Tcl_Preserve((ClientData) expat->interp); 2736 2876 2737 2877 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 2738 2878 Tcl_NewStringObj((char *)s, len)); 2739 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2740 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2741 -#else 2742 2879 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2743 2880 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 2744 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2745 2881 2746 2882 Tcl_DecrRefCount(cmdPtr); 2747 2883 Tcl_Release((ClientData) expat->interp); 2748 2884 2749 2885 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2750 2886 } 2751 2887 nextTcl: ................................................................................ 2762 2898 activeCHandlerSet->datacommand (activeCHandlerSet->userData, 2763 2899 s, len); 2764 2900 } 2765 2901 } 2766 2902 activeCHandlerSet = activeCHandlerSet->nextHandlerSet; 2767 2903 } 2768 2904 2905 +#ifndef TDOM_NO_SCHEMA 2769 2906 if (expat->sdata) { 2770 - if (probeText (expat->interp, expat->sdata, s) != TCL_OK) { 2907 + if (tDOM_probeText (expat->interp, expat->sdata, s, 2908 + expat->needWSCheck ? &onlyWhiteSpace : NULL) != TCL_OK) { 2771 2909 TclExpatHandlerResult (expat, NULL, TCL_ERROR); 2772 2910 } 2773 2911 } 2912 +#endif 2774 2913 Tcl_DecrRefCount (expat->cdata); 2775 2914 expat->cdata = NULL; 2776 2915 return; 2777 2916 } 2778 2917 2779 2918 2780 2919 /* ................................................................................ 2833 2972 2834 2973 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->picommand); 2835 2974 Tcl_IncrRefCount(cmdPtr); 2836 2975 Tcl_Preserve((ClientData) expat->interp); 2837 2976 2838 2977 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)target, strlen(target))); 2839 2978 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)data, strlen(data))); 2840 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2841 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2842 -#else 2843 2979 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2844 2980 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 2845 -#endif /* if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2846 2981 2847 2982 Tcl_DecrRefCount(cmdPtr); 2848 2983 Tcl_Release((ClientData) expat->interp); 2849 2984 2850 2985 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2851 2986 nextTcl: 2852 2987 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 2918 3053 */ 2919 3054 2920 3055 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->defaultcommand); 2921 3056 Tcl_IncrRefCount(cmdPtr); 2922 3057 Tcl_Preserve((ClientData) expat->interp); 2923 3058 2924 3059 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)s, len)); 2925 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 2926 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 2927 -#else 2928 3060 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 2929 3061 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 2930 -#endif /* if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 2931 3062 2932 3063 Tcl_DecrRefCount(cmdPtr); 2933 3064 Tcl_Release((ClientData) expat->interp); 2934 3065 2935 3066 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 2936 3067 nextTcl: 2937 3068 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3038 3169 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)publicId, strlen(publicId))); 3039 3170 } 3040 3171 if (notationName == NULL) { 3041 3172 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewListObj(0, NULL)); 3042 3173 } else { 3043 3174 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)notationName, strlen(notationName))); 3044 3175 } 3045 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3046 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3047 -#else 3048 3176 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3049 3177 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3050 -#endif /* if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3051 3178 3052 3179 Tcl_DecrRefCount(cmdPtr); 3053 3180 Tcl_Release((ClientData) expat->interp); 3054 3181 3055 3182 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 3056 3183 nextTcl: 3057 3184 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3137 3264 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)systemId, strlen(systemId))); 3138 3265 } 3139 3266 if (publicId == NULL) { 3140 3267 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewListObj(0, NULL)); 3141 3268 } else { 3142 3269 Tcl_ListObjAppendElement(expat->interp, cmdPtr, Tcl_NewStringObj((char *)publicId, strlen(publicId))); 3143 3270 } 3144 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3145 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3146 -#else 3147 3271 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3148 3272 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3149 -#endif /* if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3150 3273 3151 3274 Tcl_DecrRefCount(cmdPtr); 3152 3275 Tcl_Release((ClientData) expat->interp); 3153 3276 3154 3277 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 3155 3278 nextTcl: 3156 3279 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3300 3423 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 3301 3424 Tcl_NewStringObj((char *)publicId, strlen(publicId))); 3302 3425 } else { 3303 3426 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 3304 3427 Tcl_NewStringObj("", 0)); 3305 3428 } 3306 3429 3307 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3308 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3309 -#else 3310 3430 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3311 3431 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3312 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3313 3432 3314 3433 Tcl_DecrRefCount(cmdPtr); 3315 3434 Tcl_Release((ClientData) expat->interp); 3316 3435 3317 3436 switch (result) { 3318 3437 case TCL_OK: 3319 3438 break; ................................................................................ 3590 3709 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->commentCommand); 3591 3710 Tcl_IncrRefCount(cmdPtr); 3592 3711 Tcl_Preserve((ClientData) expat->interp); 3593 3712 3594 3713 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 3595 3714 Tcl_NewStringObj((char *)data, strlen(data))); 3596 3715 3597 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3598 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3599 -#else 3600 3716 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3601 3717 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3602 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3603 3718 3604 3719 Tcl_DecrRefCount(cmdPtr); 3605 3720 Tcl_Release((ClientData) expat->interp); 3606 3721 3607 3722 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 3608 3723 nextTcl: 3609 3724 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3669 3784 goto nextTcl; 3670 3785 } 3671 3786 3672 3787 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->notStandaloneCommand); 3673 3788 Tcl_IncrRefCount(cmdPtr); 3674 3789 Tcl_Preserve((ClientData) expat->interp); 3675 3790 3676 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3677 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3678 -#else 3679 3791 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3680 3792 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3681 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3682 3793 3683 3794 Tcl_DecrRefCount(cmdPtr); 3684 3795 Tcl_Release((ClientData) expat->interp); 3685 3796 3686 3797 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 3687 3798 nextTcl: 3688 3799 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3749 3860 goto nextTcl; 3750 3861 } 3751 3862 3752 3863 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->startCdataSectionCommand); 3753 3864 Tcl_IncrRefCount(cmdPtr); 3754 3865 Tcl_Preserve((ClientData) expat->interp); 3755 3866 3756 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3757 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3758 -#else 3759 3867 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3760 3868 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3761 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3762 3869 3763 3870 Tcl_DecrRefCount(cmdPtr); 3764 3871 Tcl_Release((ClientData) expat->interp); 3765 3872 3766 3873 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 3767 3874 nextTcl: 3768 3875 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3826 3933 goto nextTcl; 3827 3934 } 3828 3935 3829 3936 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->endCdataSectionCommand); 3830 3937 Tcl_IncrRefCount(cmdPtr); 3831 3938 Tcl_Preserve((ClientData) expat->interp); 3832 3939 3833 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3834 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3835 -#else 3836 3940 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3837 3941 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3838 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 3839 3942 3840 3943 Tcl_DecrRefCount(cmdPtr); 3841 3944 Tcl_Release((ClientData) expat->interp); 3842 3945 3843 3946 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 3844 3947 nextTcl: 3845 3948 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 3987 4090 3988 4091 3989 4092 content = Tcl_NewListObj (0, NULL); 3990 4093 generateModel (expat->interp, content, model); 3991 4094 3992 4095 Tcl_ListObjAppendElement(expat->interp, cmdPtr, content); 3993 4096 3994 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 3995 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 3996 -#else 3997 4097 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 3998 4098 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 3999 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 4000 4099 4001 4100 Tcl_DecrRefCount(cmdPtr); 4002 4101 4003 4102 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 4004 4103 nextTcl: 4005 4104 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; 4006 4105 } ................................................................................ 4088 4187 else { 4089 4188 Tcl_ListObjAppendElement (expat->interp, cmdPtr, 4090 4189 Tcl_NewStringObj ((char*)dflt, strlen (dflt))); 4091 4190 } 4092 4191 Tcl_ListObjAppendElement (expat->interp, cmdPtr, 4093 4192 Tcl_NewIntObj (isrequired)); 4094 4193 4095 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 4096 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 4097 -#else 4098 4194 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 4099 4195 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 4100 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 4101 4196 4102 4197 Tcl_DecrRefCount(cmdPtr); 4103 4198 Tcl_Release((ClientData) expat->interp); 4104 4199 4105 4200 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 4106 4201 nextTcl: 4107 4202 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 4191 4286 } else { 4192 4287 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 4193 4288 Tcl_NewStringObj("NULL", 4)); 4194 4289 } 4195 4290 Tcl_ListObjAppendElement(expat->interp, cmdPtr, 4196 4291 Tcl_NewIntObj(has_internal_subset)); 4197 4292 4198 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 4199 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 4200 -#else 4201 4293 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 4202 4294 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 4203 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 4204 4295 4205 4296 Tcl_DecrRefCount(cmdPtr); 4206 4297 Tcl_Release((ClientData) expat->interp); 4207 4298 4208 4299 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 4209 4300 nextTcl: 4210 4301 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 4272 4363 goto nextTcl; 4273 4364 } 4274 4365 4275 4366 cmdPtr = Tcl_DuplicateObj(activeTclHandlerSet->endDoctypeDeclCommand); 4276 4367 Tcl_IncrRefCount(cmdPtr); 4277 4368 Tcl_Preserve((ClientData) expat->interp); 4278 4369 4279 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 4280 - result = Tcl_GlobalEvalObj(expat->interp, cmdPtr); 4281 -#else 4282 4370 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 4283 4371 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 4284 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 4285 4372 4286 4373 Tcl_DecrRefCount(cmdPtr); 4287 4374 Tcl_Release((ClientData) expat->interp); 4288 4375 4289 4376 TclExpatHandlerResult(expat, activeTclHandlerSet, result); 4290 4377 nextTcl: 4291 4378 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet; ................................................................................ 4374 4461 Tcl_NewStringObj ("", 0)); 4375 4462 } 4376 4463 else { 4377 4464 Tcl_ListObjAppendElement (expat->interp, cmdPtr, 4378 4465 Tcl_NewBooleanObj (standalone)); 4379 4466 } 4380 4467 4381 -#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) 4382 - result = Tcl_GlobalEvalObj (expat->interp, cmdPtr); 4383 -#else 4384 4468 result = Tcl_EvalObjEx(expat->interp, cmdPtr, 4385 4469 TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); 4386 -#endif /* TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 */ 4387 4470 4388 4471 Tcl_DecrRefCount(cmdPtr); 4389 4472 Tcl_Release((ClientData) expat->interp); 4390 4473 4391 4474 TclExpatHandlerResult (expat, activeTclHandlerSet, result); 4392 4475 nextTcl: 4393 4476 activeTclHandlerSet = activeTclHandlerSet->nextHandlerSet;
Changes to generic/tclexpat.h.
132 132 2 == parsing an input chunk */ 133 133 XML_Char nsSeparator; 134 134 int paramentityparsing; 135 135 int noexpand; 136 136 int useForeignDTD; 137 137 const char *currentmarkup; /* Used to transfer data for method */ 138 138 int currentmarkuplen; /* currentmarkup */ 139 - StructureData *sdata; /* Validation / Structure data */ 139 +#ifndef TDOM_NO_SCHEMA 140 + SchemaData *sdata; /* Validation / Schema data */ 141 +#endif 140 142 141 143 TclHandlerSet *firstTclHandlerSet; 142 144 CHandlerSet *firstCHandlerSet; 143 145 } TclGenExpatInfo; 144 146 145 147 /*-------------------------------------------------------------------------- 146 148 | Function prototypes ................................................................................ 148 150 \-------------------------------------------------------------------------*/ 149 151 150 152 #if defined(_MSC_VER) || defined(BUILD_tdom) || defined(__MINGW32__) 151 153 # undef TCL_STORAGE_CLASS 152 154 # define TCL_STORAGE_CLASS DLLEXPORT 153 155 #endif 154 156 155 -EXTERN Tcl_ObjCmdProc TclExpatObjCmd; 157 +Tcl_ObjCmdProc TclExpatObjCmd; 156 158 157 -EXTERN int CheckExpatParserObj (Tcl_Interp *interp, 158 - Tcl_Obj *const nameObj); 159 -EXTERN int CHandlerSetInstall (Tcl_Interp *interp, 160 - Tcl_Obj *const expatObj, 161 - CHandlerSet *handlerSet); 162 -EXTERN int CHandlerSetRemove (Tcl_Interp *interp, 163 - Tcl_Obj *const expatObj, 164 - char *handlerSetName); 165 -EXTERN CHandlerSet * CHandlerSetCreate (char *name); 166 -EXTERN CHandlerSet * CHandlerSetGet (Tcl_Interp *interp, 167 - Tcl_Obj *const expatObj, 168 - char *handlerSetName); 169 -EXTERN void * CHandlerSetGetUserData (Tcl_Interp *interp, 170 - Tcl_Obj *const expatObj, 171 - char *handlerSetName); 159 +int CheckExpatParserObj (Tcl_Interp *interp, 160 + Tcl_Obj *const nameObj); 161 +int CHandlerSetInstall (Tcl_Interp *interp, 162 + Tcl_Obj *const expatObj, 163 + CHandlerSet *handlerSet); 164 +int CHandlerSetRemove (Tcl_Interp *interp, 165 + Tcl_Obj *const expatObj, 166 + char *handlerSetName); 167 +CHandlerSet * CHandlerSetCreate (char *name); 168 +CHandlerSet * CHandlerSetGet (Tcl_Interp *interp, 169 + Tcl_Obj *const expatObj, 170 + char *handlerSetName); 171 +void * CHandlerSetGetUserData (Tcl_Interp *interp, 172 + Tcl_Obj *const expatObj, 173 + char *handlerSetName); 172 174 173 -EXTERN TclGenExpatInfo * GetExpatInfo (Tcl_Interp *interp, 175 +TclGenExpatInfo * GetExpatInfo (Tcl_Interp *interp, 174 176 Tcl_Obj *const expatObj);
Changes to generic/tclpull.c.
830 830 return TCL_ERROR; 831 831 case PULLPARSERSTATE_END_TAG: 832 832 case PULLPARSERSTATE_START_TAG: 833 833 case PULLPARSERSTATE_END_DOCUMENT: 834 834 case PULLPARSERSTATE_PARSE_ERROR: 835 835 if ((enum method) methodIndex == m_line) { 836 836 Tcl_SetObjResult(interp, 837 - Tcl_NewIntObj (XML_GetCurrentLineNumber(pullInfo->parser))); 837 + Tcl_NewLongObj (XML_GetCurrentLineNumber(pullInfo->parser))); 838 838 } else { 839 839 Tcl_SetObjResult(interp, 840 - Tcl_NewIntObj (XML_GetCurrentColumnNumber(pullInfo->parser))); 840 + Tcl_NewLongObj (XML_GetCurrentColumnNumber(pullInfo->parser))); 841 841 } 842 842 break; 843 843 case PULLPARSERSTATE_START_DOCUMENT: 844 844 Tcl_SetObjResult(interp, Tcl_NewIntObj (0)); 845 845 break; 846 846 } 847 847 break;
Changes to generic/tdom.decls.
13 13 int TclExpatObjCmd (ClientData dummy, Tcl_Interp *interp, 14 14 int objc, Tcl_Obj *const objv[]) 15 15 } 16 16 declare 1 generic { 17 17 int CheckExpatParserObj (Tcl_Interp *interp, Tcl_Obj *const nameObj) 18 18 } 19 19 declare 2 generic { 20 - int CHandlerSetInstall (Tcl_Interp *interp, Tcl_Obj *const expatObj, 20 + int CHandlerSetInstall (Tcl_Interp *interp, Tcl_Obj *const expatObj, 21 21 CHandlerSet *handlerSet) 22 22 } 23 23 declare 3 generic { 24 - int CHandlerSetRemove (Tcl_Interp *interp, Tcl_Obj *const expatObj, 24 + int CHandlerSetRemove (Tcl_Interp *interp, Tcl_Obj *const expatObj, 25 25 char *handlerSetName) 26 26 } 27 27 declare 4 generic { 28 - CHandlerSet * CHandlerSetCreate (char *name) 28 + CHandlerSet * CHandlerSetCreate (char *name) 29 29 } 30 30 declare 5 generic { 31 - CHandlerSet * CHandlerSetGet (Tcl_Interp *interp, Tcl_Obj *const expatObj, 31 + CHandlerSet * CHandlerSetGet (Tcl_Interp *interp, Tcl_Obj *const expatObj, 32 32 char *handlerSetName) 33 33 } 34 34 declare 6 generic { 35 - void * CHandlerSetGetUserData (Tcl_Interp *interp, 35 + void * CHandlerSetGetUserData (Tcl_Interp *interp, 36 36 Tcl_Obj *const expatObj, 37 37 char *handlerSetName) 38 38 } 39 39 declare 7 generic { 40 - TclGenExpatInfo * GetExpatInfo (Tcl_Interp *interp, 40 + TclGenExpatInfo * GetExpatInfo (Tcl_Interp *interp, 41 41 Tcl_Obj *const expatObj) 42 42 } 43 43 declare 8 generic { 44 - XML_Size XML_GetCurrentLineNumber(XML_Parser parser) 44 + XML_Size XML_GetCurrentLineNumber(XML_Parser parser) 45 45 } 46 46 declare 9 generic { 47 - XML_Size XML_GetCurrentColumnNumber(XML_Parser parser) 47 + XML_Size XML_GetCurrentColumnNumber(XML_Parser parser) 48 48 } 49 49 declare 10 generic { 50 - XML_Index XML_GetCurrentByteIndex(XML_Parser parser) 50 + XML_Index XML_GetCurrentByteIndex(XML_Parser parser) 51 51 } 52 52 declare 11 generic { 53 - int XML_GetCurrentByteCount(XML_Parser parser) 53 + int XML_GetCurrentByteCount(XML_Parser parser) 54 54 } 55 55 declare 12 generic { 56 - enum XML_Status XML_SetBase(XML_Parser parser, const XML_Char *base) 56 + enum XML_Status XML_SetBase(XML_Parser parser, const XML_Char *base) 57 57 } 58 58 declare 13 generic { 59 - const XML_Char * XML_GetBase(XML_Parser parser) 59 + const XML_Char * XML_GetBase(XML_Parser parser) 60 60 } 61 61 declare 14 generic { 62 - int XML_GetSpecifiedAttributeCount(XML_Parser parser) 62 + int XML_GetSpecifiedAttributeCount(XML_Parser parser) 63 63 } 64 64 declare 15 generic { 65 - int XML_GetIdAttributeIndex(XML_Parser parser) 65 + int XML_GetIdAttributeIndex(XML_Parser parser) 66 66 } 67 67 declare 16 generic { 68 - domNode * tcldom_getNodeFromName(Tcl_Interp *interp, char *nodeName, 68 + domNode * tcldom_getNodeFromName(Tcl_Interp *interp, char *nodeName, 69 69 char **errMsg) 70 70 } 71 71 declare 17 generic { 72 - domDocument * tcldom_getDocumentFromName (Tcl_Interp *interp, 72 + domDocument * tcldom_getDocumentFromName (Tcl_Interp *interp, 73 73 char *docName, char **errMsg) 74 74 } 75 +declare 18 generic { 76 + SchemaData * tdomGetSchemadata (void) 77 +} 75 78
Changes to generic/tdom.h.
129 129 #ifdef BUILD_tdom 130 130 # undef TCL_STORAGE_CLASS 131 131 # define TCL_STORAGE_CLASS DLLEXPORT 132 132 #endif 133 133 134 134 #include "dom.h" 135 135 #include "tdomDecls.h" 136 - 137 - 138 -
Changes to generic/tdomDecls.h.
17 17 EXTERN int TclExpatObjCmd(ClientData dummy, Tcl_Interp *interp, 18 18 int objc, Tcl_Obj *const objv[]); 19 19 /* 1 */ 20 20 EXTERN int CheckExpatParserObj(Tcl_Interp *interp, 21 21 Tcl_Obj *const nameObj); 22 22 /* 2 */ 23 23 EXTERN int CHandlerSetInstall(Tcl_Interp *interp, 24 - Tcl_Obj *const expatObj, 24 + Tcl_Obj *const expatObj, 25 25 CHandlerSet *handlerSet); 26 26 /* 3 */ 27 27 EXTERN int CHandlerSetRemove(Tcl_Interp *interp, 28 - Tcl_Obj *const expatObj, 28 + Tcl_Obj *const expatObj, 29 29 char *handlerSetName); 30 30 /* 4 */ 31 31 EXTERN CHandlerSet * CHandlerSetCreate(char *name); 32 32 /* 5 */ 33 33 EXTERN CHandlerSet * CHandlerSetGet(Tcl_Interp *interp, 34 - Tcl_Obj *const expatObj, 34 + Tcl_Obj *const expatObj, 35 35 char *handlerSetName); 36 36 /* 6 */ 37 37 EXTERN void * CHandlerSetGetUserData(Tcl_Interp *interp, 38 38 Tcl_Obj *const expatObj, 39 39 char *handlerSetName); 40 40 /* 7 */ 41 41 EXTERN TclGenExpatInfo * GetExpatInfo(Tcl_Interp *interp, ................................................................................ 58 58 EXTERN int XML_GetIdAttributeIndex(XML_Parser parser); 59 59 /* 16 */ 60 60 EXTERN domNode * tcldom_getNodeFromName(Tcl_Interp *interp, 61 61 char *nodeName, char **errMsg); 62 62 /* 17 */ 63 63 EXTERN domDocument * tcldom_getDocumentFromName(Tcl_Interp *interp, 64 64 char *docName, char **errMsg); 65 +/* 18 */ 66 +EXTERN SchemaData * tdomGetSchemadata(void); 65 67 66 68 typedef struct TdomStubs { 67 69 int magic; 68 70 void *hooks; 69 71 70 72 int (*tclExpatObjCmd) (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 0 */ 71 73 int (*checkExpatParserObj) (Tcl_Interp *interp, Tcl_Obj *const nameObj); /* 1 */ ................................................................................ 81 83 int (*xML_GetCurrentByteCount) (XML_Parser parser); /* 11 */ 82 84 enum XML_Status (*xML_SetBase) (XML_Parser parser, const XML_Char *base); /* 12 */ 83 85 const XML_Char * (*xML_GetBase) (XML_Parser parser); /* 13 */ 84 86 int (*xML_GetSpecifiedAttributeCount) (XML_Parser parser); /* 14 */ 85 87 int (*xML_GetIdAttributeIndex) (XML_Parser parser); /* 15 */ 86 88 domNode * (*tcldom_getNodeFromName) (Tcl_Interp *interp, char *nodeName, char **errMsg); /* 16 */ 87 89 domDocument * (*tcldom_getDocumentFromName) (Tcl_Interp *interp, char *docName, char **errMsg); /* 17 */ 90 + SchemaData * (*tdomGetSchemadata) (void); /* 18 */ 88 91 } TdomStubs; 89 92 90 93 extern const TdomStubs *tdomStubsPtr; 91 94 92 95 #ifdef __cplusplus 93 96 } 94 97 #endif ................................................................................ 131 134 (tdomStubsPtr->xML_GetSpecifiedAttributeCount) /* 14 */ 132 135 #define XML_GetIdAttributeIndex \ 133 136 (tdomStubsPtr->xML_GetIdAttributeIndex) /* 15 */ 134 137 #define tcldom_getNodeFromName \ 135 138 (tdomStubsPtr->tcldom_getNodeFromName) /* 16 */ 136 139 #define tcldom_getDocumentFromName \ 137 140 (tdomStubsPtr->tcldom_getDocumentFromName) /* 17 */ 141 +#define tdomGetSchemadata \ 142 + (tdomStubsPtr->tdomGetSchemadata) /* 18 */ 138 143 139 144 #endif /* defined(USE_TDOM_STUBS) */ 140 145 141 146 /* !END!: Do not edit above this line. */
Changes to generic/tdomStubInit.c.
26 26 XML_GetCurrentByteCount, /* 11 */ 27 27 XML_SetBase, /* 12 */ 28 28 XML_GetBase, /* 13 */ 29 29 XML_GetSpecifiedAttributeCount, /* 14 */ 30 30 XML_GetIdAttributeIndex, /* 15 */ 31 31 tcldom_getNodeFromName, /* 16 */ 32 32 tcldom_getDocumentFromName, /* 17 */ 33 + tdomGetSchemadata, /* 18 */ 33 34 }; 34 35 35 36 /* !END!: Do not edit above this line. */ 36 37 37 38 #endif /* USE_TCL_STUBS */ 38 39
Changes to generic/tdomStubLib.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 2007 Rolf Ade (rolf@pointsman.de) 3 3 +----------------------------------------------------------------------------- 4 4 | 5 -| $Id$ 6 -| 7 5 | Implements entry point, which has to be called by C coded extensions 8 6 | to tDOM. Following http://wiki.tcl.tk/3358. 9 7 | 10 8 | The contents of this file are subject to the Mozilla Public License 11 9 | Version 2.0 (the "License"); you may not use this file except in 12 10 | compliance with the License. You may obtain a copy of the License at 13 11 | http://www.mozilla.org/MPL/
Changes to generic/tdominit.c.
1 1 /*---------------------------------------------------------------------------- 2 2 | Copyright (c) 1999 Jochen Loewer (loewerj@hotmail.com) 3 3 +----------------------------------------------------------------------------- 4 -| 5 -| $Id$ 6 -| 7 4 | 8 5 | A DOM implementation for Tcl using James Clark's expat XML parser 9 6 | 10 7 | 11 8 | The contents of this file are subject to the Mozilla Public License 12 9 | Version 2.0 (the "License"); you may not use this file except in 13 10 | compliance with the License. You may obtain a copy of the License at ................................................................................ 39 36 | 40 37 \---------------------------------------------------------------------------*/ 41 38 #include <tcl.h> 42 39 #include <dom.h> 43 40 #include <tdom.h> 44 41 #include <tcldom.h> 45 42 #include <tclpull.h> 46 -#include <structure.h> 43 +#include <schema.h> 47 44 48 45 extern TdomStubs tdomStubs; 49 46 50 47 /* 51 48 *---------------------------------------------------------------------------- 52 49 * 53 50 * Tdom_Init -- ................................................................................ 59 56 * 60 57 * Side effects: 61 58 * Defines "expat"/"dom" commands in the interpreter. 62 59 * 63 60 *---------------------------------------------------------------------------- 64 61 */ 65 62 66 -int 63 +EXTERN int 67 64 Tdom_Init ( 68 65 Tcl_Interp *interp /* Interpreter to initialize. */ 69 66 ) { 70 67 71 68 #ifdef USE_TCL_STUBS 72 - Tcl_InitStubs(interp, "8.4", 0); 69 + if (Tcl_InitStubs(interp, "8.4", 0) == NULL) { 70 + return TCL_ERROR; 71 + } 73 72 #endif 74 73 75 74 domModuleInitialize(); 76 75 77 76 #ifdef TCL_THREADS 78 77 tcldom_initialize(); 79 78 #endif /* TCL_THREADS */ ................................................................................ 93 92 Tcl_CreateObjCommand(interp, "xml::parser", TclExpatObjCmd, NULL, NULL ); 94 93 #endif 95 94 96 95 #ifndef TDOM_NO_PULL 97 96 Tcl_CreateObjCommand(interp, "tdom::pullparser", tDOM_PullParserCmd, NULL, NULL ); 98 97 #endif 99 98 100 -#ifndef TDOM_NO_STRUCTURE 101 - Tcl_CreateObjCommand (interp, "tdom::structure", tDOM_StructureObjCmd, 102 - NULL, NULL); 103 - tDOM_StructureInit (interp); 99 +#ifndef TDOM_NO_SCHEMA 100 + tDOM_SchemaInit (interp); 104 101 #endif 105 102 106 103 #ifdef USE_TCL_STUBS 107 104 Tcl_PkgProvideEx(interp, PACKAGE_NAME, PACKAGE_VERSION, 108 105 (ClientData) &tdomStubs); 109 106 #else 110 107 Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION); 111 108 #endif 112 109 113 110 return TCL_OK; 114 111 } 115 112 116 -int 113 +EXTERN int 117 114 Tdom_SafeInit ( 118 115 Tcl_Interp *interp 119 116 ) { 120 117 return Tdom_Init (interp); 121 118 } 122 119 123 120 /*
Deleted generic/win32.h.
1 - 2 -/* This is stuff to make the code compile with VC++ 6.0 3 - I know nearly nothing about other versions. */ 4 - 5 -#include <float.h> 6 -#define isnan _isnan 7 -#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 : ((_fpclass(d) == _FPCLASS_NINF) ? -1 :0)) 8 - 9 - 10 -/* #ifndef isnan */ 11 -/* int isnan(double number) { return (!(number == number)); } */ 12 -/* #endif */ 13 - 14 -
Changes to lib/tdom.tcl.
637 637 # cp1251 koi8-u macDingbats iso8859-7 cp1252 iso8859-8 cp1253 638 638 # iso8859-9 cp1254 cp1255 cp850 cp1256 cp932 identity cp1257 cp852 639 639 # macJapan cp1258 shiftjis utf-8 cp855 cp936 symbol cp775 unicode 640 640 # cp857 641 641 # 642 642 # Just add more mappings (and mail them to the tDOM mailing list, please). 643 643 644 -proc tdom::IANAEncoding2TclEncoding {IANAName} { 644 +proc ::tdom::IANAEncoding2TclEncoding {IANAName} { 645 645 646 646 # First the most widespread encodings with there 647 647 # preferred MIME name, to speed lookup in this 648 648 # usual cases. Later the official names and the 649 649 # aliases. 650 650 # 651 651 # For "official names for character sets that may be ................................................................................ 735 735 } 736 736 } 737 737 738 738 #---------------------------------------------------------------------------- 739 739 # xmlOpenFileWorker 740 740 # 741 741 #---------------------------------------------------------------------------- 742 -proc tdom::xmlOpenFileWorker {filename {encodingString {}} {forSimple 0} {forRead 0}} { 742 +proc ::tdom::xmlOpenFileWorker {filename {encodingString {}} {forSimple 0} {forRead 0}} { 743 743 744 744 # This partly (mis-)use the encoding of a channel handed to [dom 745 745 # parse -channel ..] as a marker: if the channel encoding is utf-8 746 746 # then behind the scene Tcl_Read() is used, otherwise 747 747 # Tcl_ReadChars(). This is used for the encodings understood (and 748 748 # checked) by the used expat implementation: utf-8 and utf-16 (in 749 749 # either byte order). ................................................................................ 871 871 return $fd 872 872 } 873 873 874 874 #---------------------------------------------------------------------------- 875 875 # xmlOpenFile 876 876 # 877 877 #---------------------------------------------------------------------------- 878 -proc tdom::xmlOpenFile {filename {encodingString {}}} { 878 +proc ::tdom::xmlOpenFile {filename {encodingString {}}} { 879 879 880 880 if {$encodingString != {}} { 881 881 upvar $encodingString encString 882 882 } 883 883 884 884 set fd [xmlOpenFileWorker $filename encString] 885 885 return $fd 886 886 } 887 887 888 888 #---------------------------------------------------------------------------- 889 889 # xmlReadFile 890 890 # 891 891 #---------------------------------------------------------------------------- 892 -proc tdom::xmlReadFile {filename {encodingString {}}} { 892 +proc ::tdom::xmlReadFile {filename {encodingString {}}} { 893 893 894 894 if {$encodingString != {}} { 895 895 upvar $encodingString encString 896 896 } 897 897 898 898 set fd [xmlOpenFileWorker $filename encString 0 1] 899 899 set data [read $fd [file size $filename]] ................................................................................ 901 901 return $data 902 902 } 903 903 904 904 #---------------------------------------------------------------------------- 905 905 # xmlReadFileForSimple 906 906 # 907 907 #---------------------------------------------------------------------------- 908 -proc tdom::xmlReadFileForSimple {filename {encodingString {}}} { 908 +proc ::tdom::xmlReadFileForSimple {filename {encodingString {}}} { 909 909 910 910 if {$encodingString != {}} { 911 911 upvar $encodingString encString 912 912 } 913 913 914 914 set fd [xmlOpenFileWorker $filename encString 1] 915 915 set data [read $fd [file size $filename]] ................................................................................ 922 922 # 923 923 # A very simple external entity resolver, included for convenience. 924 924 # Depends on the tcllib package uri and resolves only file URLs. 925 925 # 926 926 #---------------------------------------------------------------------------- 927 927 928 928 if {![catch {package require uri}]} { 929 - proc tdom::extRefHandler {base systemId publicId} { 929 + proc ::tdom::extRefHandler {base systemId publicId} { 930 930 variable extRefHandlerDebug 931 931 variable useForeignDTD 932 932 933 933 if {$extRefHandlerDebug} { 934 - puts stderr "tdom::extRefHandler called with:" 934 + puts stderr "::tdom::extRefHandler called with:" 935 935 puts stderr "\tbase: '$base'" 936 936 puts stderr "\tsystemId: '$systemId'" 937 937 puts stderr "\tpublicId: '$publicId'" 938 938 } 939 939 if {$systemId == ""} { 940 940 if {$useForeignDTD != ""} { 941 941 set systemId $useForeignDTD ................................................................................ 967 967 #---------------------------------------------------------------------------- 968 968 # baseURL 969 969 # 970 970 # A simple convenience proc which returns an absolute URL for a given 971 971 # filename. 972 972 # 973 973 #---------------------------------------------------------------------------- 974 -proc tdom::baseURL {path} { 974 +proc ::tdom::baseURL {path} { 975 975 # FIXME - path components need to be URL-encoded 976 976 977 977 # Note [file join] will return path as is if it is already absolute. 978 978 # Also on Windows, it will change \ -> /. This is necessary because 979 979 # file URIs must always use /, never \. 980 980 set path [file join [pwd] $path] 981 981 ................................................................................ 996 996 variable extRefHandlerDebug 0 997 997 variable useForeignDTD "" 998 998 999 999 namespace export xmlOpenFile xmlReadFile xmlReadFileForSimple \ 1000 1000 extRefHandler baseURL 1001 1001 } 1002 1002 1003 -foreach cmd { 1003 +foreach ::tdom::cmd { 1004 1004 xmlOpenFile 1005 1005 xmlReadFile 1006 1006 xmlReadFileForSimple 1007 1007 extRefHandler 1008 1008 baseURL 1009 1009 } { 1010 - interp alias {} tDOM::$cmd {} tdom::$cmd 1010 + interp alias {} tDOM::$::tdom::cmd {} tdom::$::tdom::cmd 1011 1011 } 1012 1012 1013 1013 # EOF
Changes to tclconfig/tcl.m4.
100 100 fi 101 101 102 102 # on Darwin, check in Framework installation locations 103 103 if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then 104 104 for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ 105 105 `ls -d /Library/Frameworks 2>/dev/null` \ 106 106 `ls -d /Network/Library/Frameworks 2>/dev/null` \ 107 - `ls -d /System/Library/Frameworks 2>/dev/null` \ 108 107 `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks/Tcl.framework 2>/dev/null` \ 109 108 `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Network/Library/Frameworks/Tcl.framework 2>/dev/null` \ 110 109 `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework 2>/dev/null` \ 111 110 ; do 112 111 if test -f "$i/Tcl.framework/tclConfig.sh" ; then 113 112 ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`" 114 113 break ................................................................................ 263 262 fi 264 263 265 264 # on Darwin, check in Framework installation locations 266 265 if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then 267 266 for i in `ls -d ~/Library/Frameworks 2>/dev/null` \ 268 267 `ls -d /Library/Frameworks 2>/dev/null` \ 269 268 `ls -d /Network/Library/Frameworks 2>/dev/null` \ 270 - `ls -d /System/Library/Frameworks 2>/dev/null` \ 271 - `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks/Tcl.framework 2>/dev/null` \ 272 - `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Network/Library/Frameworks/Tcl.framework 2>/dev/null` \ 273 - `ls -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework 2>/dev/null` \ 274 269 ; do 275 270 if test -f "$i/Tk.framework/tkConfig.sh" ; then 276 271 ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`" 277 272 break 278 273 fi 279 274 done 280 275 fi ................................................................................ 283 278 if test x"${ac_cv_c_tkconfig}" = x ; then 284 279 for i in `ls -d ${libdir} 2>/dev/null` \ 285 280 `ls -d ${exec_prefix}/lib 2>/dev/null` \ 286 281 `ls -d ${prefix}/lib 2>/dev/null` \ 287 282 `ls -d /usr/local/lib 2>/dev/null` \ 288 283 `ls -d /usr/contrib/lib 2>/dev/null` \ 289 284 `ls -d /usr/pkg/lib 2>/dev/null` \ 285 + `ls -d /usr/lib/tk8.6 2>/dev/null` \ 286 + `ls -d /usr/lib/tk8.5 2>/dev/null` \ 290 287 `ls -d /usr/lib 2>/dev/null` \ 291 288 `ls -d /usr/lib64 2>/dev/null` \ 292 - `ls -d /usr/lib/tk8.6 2>/dev/null` \ 293 - `ls -d /usr/lib/tk8.5 2>/dev/null` \ 294 289 `ls -d /usr/local/lib/tk8.6 2>/dev/null` \ 295 290 `ls -d /usr/local/lib/tk8.5 2>/dev/null` \ 296 291 `ls -d /usr/local/lib/tcl/tk8.6 2>/dev/null` \ 297 292 `ls -d /usr/local/lib/tcl/tk8.5 2>/dev/null` \ 298 293 ; do 299 294 if test -f "$i/tkConfig.sh" ; then 300 295 ac_cv_c_tkconfig="`(cd $i; pwd)`" ................................................................................ 373 368 if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then 374 369 AC_MSG_RESULT([loading]) 375 370 . "${TCL_BIN_DIR}/tclConfig.sh" 376 371 else 377 372 AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh]) 378 373 fi 379 374 380 - # eval is required to do the TCL_DBGX substitution 381 - eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\"" 382 - eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\"" 383 - 384 375 # If the TCL_BIN_DIR is the build directory (not the install directory), 385 376 # then set the common variable name to the value of the build variables. 386 377 # For example, the variable TCL_LIB_SPEC will be set to the value 387 378 # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC 388 379 # instead of TCL_BUILD_LIB_SPEC since it will work with both an 389 380 # installed and uninstalled version of Tcl. 390 381 if test -f "${TCL_BIN_DIR}/Makefile" ; then ................................................................................ 410 401 TCL_STUB_LIB_SPEC="-L`echo "${TCL_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TCL_STUB_LIB_FLAG}" 411 402 TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}" 412 403 fi 413 404 ;; 414 405 esac 415 406 fi 416 407 417 - # eval is required to do the TCL_DBGX substitution 418 - eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" 419 - eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" 420 - eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" 421 - eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" 422 - 423 408 AC_SUBST(TCL_VERSION) 424 409 AC_SUBST(TCL_PATCH_LEVEL) 425 410 AC_SUBST(TCL_BIN_DIR) 426 411 AC_SUBST(TCL_SRC_DIR) 427 412 428 413 AC_SUBST(TCL_LIB_FILE) 429 414 AC_SUBST(TCL_LIB_FLAG) ................................................................................ 436 421 AC_MSG_CHECKING([platform]) 437 422 hold_cc=$CC; CC="$TCL_CC" 438 423 AC_TRY_COMPILE(,[ 439 424 #ifdef _WIN32 440 425 #error win32 441 426 #endif 442 427 ], [ 443 - TEA_PLATFORM="unix" 428 + # first test we've already retrieved platform (cross-compile), fallback to unix otherwise: 429 + TEA_PLATFORM="${TEA_PLATFORM-unix}" 444 430 CYGPATH=echo 445 431 ], [ 446 432 TEA_PLATFORM="windows" 447 433 AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo) ] 448 434 ) 449 435 CC=$hold_cc 450 436 AC_MSG_RESULT($TEA_PLATFORM) ................................................................................ 490 476 if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then 491 477 AC_MSG_RESULT([loading]) 492 478 . "${TK_BIN_DIR}/tkConfig.sh" 493 479 else 494 480 AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh]) 495 481 fi 496 482 497 - # eval is required to do the TK_DBGX substitution 498 - eval "TK_LIB_FILE=\"${TK_LIB_FILE}\"" 499 - eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\"" 500 - 501 483 # If the TK_BIN_DIR is the build directory (not the install directory), 502 484 # then set the common variable name to the value of the build variables. 503 485 # For example, the variable TK_LIB_SPEC will be set to the value 504 486 # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC 505 487 # instead of TK_BUILD_LIB_SPEC since it will work with both an 506 488 # installed and uninstalled version of Tcl. 507 489 if test -f "${TK_BIN_DIR}/Makefile" ; then ................................................................................ 527 509 TK_STUB_LIB_SPEC="-L` echo "${TK_BIN_DIR}" | sed -e 's/ /\\\\ /g'` ${TK_STUB_LIB_FLAG}" 528 510 TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}" 529 511 fi 530 512 ;; 531 513 esac 532 514 fi 533 515 534 - # eval is required to do the TK_DBGX substitution 535 - eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\"" 536 - eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\"" 537 - eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\"" 538 - eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\"" 539 - 540 516 # TEA specific: Ensure windowingsystem is defined 541 517 if test "${TEA_PLATFORM}" = "unix" ; then 542 518 case ${TK_DEFS} in 543 519 *MAC_OSX_TK*) 544 520 AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?]) 545 521 TEA_WINDOWINGSYSTEM="aqua" 546 522 ;; ................................................................................ 589 565 #------------------------------------------------------------------------ 590 566 591 567 AC_DEFUN([TEA_PROG_TCLSH], [ 592 568 AC_MSG_CHECKING([for tclsh]) 593 569 if test -f "${TCL_BIN_DIR}/Makefile" ; then 594 570 # tclConfig.sh is in Tcl build directory 595 571 if test "${TEA_PLATFORM}" = "windows"; then 596 - if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" ; then 597 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 598 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" ; then 599 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}s${EXEEXT}" 600 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" ; then 601 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}t${EXEEXT}" 602 - elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" ; then 603 - TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}st${EXEEXT}" 572 + if test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" ; then 573 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" 574 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" ; then 575 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}s${EXEEXT}" 576 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" ; then 577 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}t${EXEEXT}" 578 + elif test -f "${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" ; then 579 + TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}st${EXEEXT}" 604 580 fi 605 581 else 606 582 TCLSH_PROG="${TCL_BIN_DIR}/tclsh" 607 583 fi 608 584 else 609 585 # tclConfig.sh is in install location 610 586 if test "${TEA_PLATFORM}" = "windows"; then 611 - TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}" 587 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}" 612 588 else 613 - TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}" 589 + TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" 614 590 fi 615 591 list="`ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null` \ 616 592 `ls -d ${TCL_BIN_DIR}/.. 2>/dev/null` \ 617 593 `ls -d ${TCL_PREFIX}/bin 2>/dev/null`" 618 594 for i in $list ; do 619 595 if test -f "$i/${TCLSH_PROG}" ; then 620 596 REAL_TCL_BIN_DIR="`cd "$i"; pwd`/" ................................................................................ 647 623 #------------------------------------------------------------------------ 648 624 649 625 AC_DEFUN([TEA_PROG_WISH], [ 650 626 AC_MSG_CHECKING([for wish]) 651 627 if test -f "${TK_BIN_DIR}/Makefile" ; then 652 628 # tkConfig.sh is in Tk build directory 653 629 if test "${TEA_PLATFORM}" = "windows"; then 654 - if test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" ; then 655 - WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" 656 - elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}s${EXEEXT}" ; then 657 - WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}$s{EXEEXT}" 658 - elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}t${EXEEXT}" ; then 659 - WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}t${EXEEXT}" 660 - elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}st${EXEEXT}" ; then 661 - WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}st${EXEEXT}" 630 + if test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${EXEEXT}" ; then 631 + WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${EXEEXT}" 632 + elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}s${EXEEXT}" ; then 633 + WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}$s{EXEEXT}" 634 + elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}t${EXEEXT}" ; then 635 + WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}t${EXEEXT}" 636 + elif test -f "${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}st${EXEEXT}" ; then 637 + WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}st${EXEEXT}" 662 638 fi 663 639 else 664 640 WISH_PROG="${TK_BIN_DIR}/wish" 665 641 fi 666 642 else 667 643 # tkConfig.sh is in install location 668 644 if test "${TEA_PLATFORM}" = "windows"; then 669 - WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}" 645 + WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${EXEEXT}" 670 646 else 671 - WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}" 647 + WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}" 672 648 fi 673 649 list="`ls -d ${TK_BIN_DIR}/../bin 2>/dev/null` \ 674 650 `ls -d ${TK_BIN_DIR}/.. 2>/dev/null` \ 675 651 `ls -d ${TK_PREFIX}/bin 2>/dev/null`" 676 652 for i in $list ; do 677 653 if test -f "$i/${WISH_PROG}" ; then 678 654 REAL_TK_BIN_DIR="`cd "$i"; pwd`/" ................................................................................ 879 855 *THREADS=1*) 880 856 if test "${TCL_THREADS}" = "0"; then 881 857 AC_MSG_WARN([ 882 858 Building ${PACKAGE_NAME} without threads enabled, but building against Tcl 883 859 that IS thread-enabled. It is recommended to use --enable-threads.]) 884 860 fi 885 861 ;; 886 - *) 887 - if test "${TCL_THREADS}" = "1"; then 888 - AC_MSG_WARN([ 889 - --enable-threads requested, but building against a Tcl that is NOT 890 - thread-enabled. This is an OK configuration that will also run in 891 - a thread-enabled core.]) 892 - fi 893 - ;; 894 862 esac 895 863 AC_SUBST(TCL_THREADS) 896 864 ]) 897 865 898 866 #------------------------------------------------------------------------ 899 867 # TEA_ENABLE_SYMBOLS -- 900 868 # ................................................................................ 916 884 # --enable-symbols 917 885 # 918 886 # Defines the following vars: 919 887 # CFLAGS_DEFAULT Sets to $(CFLAGS_DEBUG) if true 920 888 # Sets to "$(CFLAGS_OPTIMIZE) -DNDEBUG" if false 921 889 # LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true 922 890 # Sets to $(LDFLAGS_OPTIMIZE) if false 923 -# DBGX Formerly used as debug library extension; 924 -# always blank now. 925 891 #------------------------------------------------------------------------ 926 892 927 893 AC_DEFUN([TEA_ENABLE_SYMBOLS], [ 928 894 dnl TEA specific: Make sure we are initialized 929 895 AC_REQUIRE([TEA_CONFIG_CFLAGS]) 930 896 AC_MSG_CHECKING([for build with symbols]) 931 897 AC_ARG_ENABLE(symbols, 932 898 AC_HELP_STRING([--enable-symbols], 933 899 [build with debugging symbols (default: off)]), 934 900 [tcl_ok=$enableval], [tcl_ok=no]) 935 - DBGX="" 936 901 if test "$tcl_ok" = "no"; then 937 902 CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE} -DNDEBUG" 938 903 LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" 939 904 AC_MSG_RESULT([no]) 940 905 else 941 906 CFLAGS_DEFAULT="${CFLAGS_DEBUG}" 942 907 LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" 943 908 if test "$tcl_ok" = "yes"; then 944 909 AC_MSG_RESULT([yes (standard debugging)]) 945 910 fi 946 911 fi 947 - # TEA specific: 948 - if test "${TEA_PLATFORM}" != "windows" ; then 949 - LDFLAGS_DEFAULT="${LDFLAGS}" 950 - fi 951 912 AC_SUBST(CFLAGS_DEFAULT) 952 913 AC_SUBST(LDFLAGS_DEFAULT) 953 - AC_SUBST(TCL_DBGX) 954 914 955 915 if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then 956 916 AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?]) 957 917 fi 958 918 959 919 if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then 960 920 if test "$tcl_ok" = "all"; then ................................................................................ 1017 977 # Arguments: 1018 978 # none 1019 979 # 1020 980 # Results: 1021 981 # Defines the following var: 1022 982 # 1023 983 # system - System/platform/version identification code. 984 +# 1024 985 #-------------------------------------------------------------------- 1025 986 1026 987 AC_DEFUN([TEA_CONFIG_SYSTEM], [ 1027 988 AC_CACHE_CHECK([system version], tcl_cv_sys_version, [ 1028 989 # TEA specific: 1029 990 if test "${TEA_PLATFORM}" = "windows" ; then 1030 991 tcl_cv_sys_version=windows ................................................................................ 1032 993 tcl_cv_sys_version=`uname -s`-`uname -r` 1033 994 if test "$?" -ne 0 ; then 1034 995 AC_MSG_WARN([can't find uname command]) 1035 996 tcl_cv_sys_version=unknown 1036 997 else 1037 998 if test "`uname -s`" = "AIX" ; then 1038 999 tcl_cv_sys_version=AIX-`uname -v`.`uname -r` 1000 + fi 1001 + if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then 1002 + tcl_cv_sys_version=NetBSD-Debian 1039 1003 fi 1040 1004 fi 1041 1005 fi 1042 1006 ]) 1043 1007 system=$tcl_cv_sys_version 1044 1008 ]) 1045 1009 ................................................................................ 1152 1116 AC_MSG_CHECKING([if rpath support is requested]) 1153 1117 AC_ARG_ENABLE(rpath, 1154 1118 AC_HELP_STRING([--disable-rpath], 1155 1119 [disable rpath support (default: on)]), 1156 1120 [doRpath=$enableval], [doRpath=yes]) 1157 1121 AC_MSG_RESULT([$doRpath]) 1158 1122 1159 - # TEA specific: Cross-compiling options for Windows/CE builds? 1160 - 1161 - AS_IF([test "${TEA_PLATFORM}" = windows], [ 1162 - AC_MSG_CHECKING([if Windows/CE build is requested]) 1163 - AC_ARG_ENABLE(wince, 1164 - AC_HELP_STRING([--enable-wince], 1165 - [enable Win/CE support (where applicable)]), 1166 - [doWince=$enableval], [doWince=no]) 1167 - AC_MSG_RESULT([$doWince]) 1168 - ]) 1169 - 1170 1123 # Set the variable "system" to hold the name and version number 1171 1124 # for the system. 1172 1125 1173 1126 TEA_CONFIG_SYSTEM 1174 1127 1175 1128 # Require ranlib early so we can override it in special cases below. 1176 1129 ................................................................................ 1203 1156 AC_CHECK_TOOL(AR, ar) 1204 1157 STLIB_LD='${AR} cr' 1205 1158 LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" 1206 1159 AS_IF([test "x$SHLIB_VERSION" = x],[SHLIB_VERSION=""],[SHLIB_VERSION=".$SHLIB_VERSION"]) 1207 1160 case $system in 1208 1161 # TEA specific: 1209 1162 windows) 1210 - # This is a 2-stage check to make sure we have the 64-bit SDK 1211 - # We have to know where the SDK is installed. 1212 - # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs 1213 - # MACHINE is IX86 for LINK, but this is used by the manifest, 1214 - # which requires x86|amd64|ia64. 1215 1163 MACHINE="X86" 1216 1164 if test "$do64bit" != "no" ; then 1217 - if test "x${MSSDK}x" = "xx" ; then 1218 - MSSDK="C:/Progra~1/Microsoft Platform SDK" 1219 - fi 1220 - MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'` 1221 - PATH64="" 1222 1165 case "$do64bit" in 1223 1166 amd64|x64|yes) 1224 1167 MACHINE="AMD64" ; # default to AMD64 64-bit build 1225 - PATH64="${MSSDK}/Bin/Win64/x86/AMD64" 1226 1168 ;; 1227 1169 ia64) 1228 1170 MACHINE="IA64" 1229 - PATH64="${MSSDK}/Bin/Win64" 1230 1171 ;; 1231 1172 esac 1232 - if test "$GCC" != "yes" -a ! -d "${PATH64}" ; then 1233 - AC_MSG_WARN([Could not find 64-bit $MACHINE SDK to enable 64bit mode]) 1234 - AC_MSG_WARN([Ensure latest Platform SDK is installed]) 1235 - do64bit="no" 1236 - else 1237 - AC_MSG_RESULT([ Using 64-bit $MACHINE mode]) 1238 - do64bit_ok="yes" 1239 - fi 1240 - fi 1241 - 1242 - if test "$doWince" != "no" ; then 1243 - if test "$do64bit" != "no" ; then 1244 - AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible]) 1245 - fi 1246 - if test "$GCC" = "yes" ; then 1247 - AC_MSG_ERROR([Windows/CE and GCC builds incompatible]) 1248 - fi 1249 - TEA_PATH_CELIB 1250 - # Set defaults for common evc4/PPC2003 setup 1251 - # Currently Tcl requires 300+, possibly 420+ for sockets 1252 - CEVERSION=420; # could be 211 300 301 400 420 ... 1253 - TARGETCPU=ARMV4; # could be ARMV4 ARM MIPS SH3 X86 ... 1254 - ARCH=ARM; # could be ARM MIPS X86EM ... 1255 - PLATFORM="Pocket PC 2003"; # or "Pocket PC 2002" 1256 - if test "$doWince" != "yes"; then 1257 - # If !yes then the user specified something 1258 - # Reset ARCH to allow user to skip specifying it 1259 - ARCH= 1260 - eval `echo $doWince | awk -F, '{ \ 1261 - if (length([$]1)) { printf "CEVERSION=\"%s\"\n", [$]1; \ 1262 - if ([$]1 < 400) { printf "PLATFORM=\"Pocket PC 2002\"\n" } }; \ 1263 - if (length([$]2)) { printf "TARGETCPU=\"%s\"\n", toupper([$]2) }; \ 1264 - if (length([$]3)) { printf "ARCH=\"%s\"\n", toupper([$]3) }; \ 1265 - if (length([$]4)) { printf "PLATFORM=\"%s\"\n", [$]4 }; \ 1266 - }'` 1267 - if test "x${ARCH}" = "x" ; then 1268 - ARCH=$TARGETCPU; 1269 - fi 1270 - fi 1271 - OSVERSION=WCE$CEVERSION; 1272 - if test "x${WCEROOT}" = "x" ; then 1273 - WCEROOT="C:/Program Files/Microsoft eMbedded C++ 4.0" 1274 - if test ! -d "${WCEROOT}" ; then 1275 - WCEROOT="C:/Program Files/Microsoft eMbedded Tools" 1276 - fi 1277 - fi 1278 - if test "x${SDKROOT}" = "x" ; then 1279 - SDKROOT="C:/Program Files/Windows CE Tools" 1280 - if test ! -d "${SDKROOT}" ; then 1281 - SDKROOT="C:/Windows CE Tools" 1282 - fi 1283 - fi 1284 - WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'` 1285 - SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'` 1286 - if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \ 1287 - -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then 1288 - AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]]) 1289 - doWince="no" 1290 - else 1291 - # We could PATH_NOSPACE these, but that's not important, 1292 - # as long as we quote them when used. 1293 - CEINCLUDE="${SDKROOT}/${OSVERSION}/${PLATFORM}/include" 1294 - if test -d "${CEINCLUDE}/${TARGETCPU}" ; then 1295 - CEINCLUDE="${CEINCLUDE}/${TARGETCPU}" 1296 - fi 1297 - CELIBPATH="${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" 1298 - fi 1299 1173 fi 1300 1174 1301 1175 if test "$GCC" != "yes" ; then 1302 1176 if test "${SHARED_BUILD}" = "0" ; then 1303 1177 runtime=-MT 1304 1178 else 1305 1179 runtime=-MD ................................................................................ 1310 1184 TEA_ADD_LIBS([ucrt.lib]) 1311 1185 ;; 1312 1186 *) 1313 1187 ;; 1314 1188 esac 1315 1189 1316 1190 if test "$do64bit" != "no" ; then 1317 - # All this magic is necessary for the Win64 SDK RC1 - hobbs 1318 - CC="\"${PATH64}/cl.exe\"" 1319 - CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\"" 1320 - RC="\"${MSSDK}/bin/rc.exe\"" 1321 - lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\"" 1322 - LINKBIN="\"${PATH64}/link.exe\"" 1191 + CC="cl.exe" 1192 + RC="rc.exe" 1193 + lflags="${lflags} -nologo -MACHINE:${MACHINE} " 1194 + LINKBIN="link.exe" 1323 1195 CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d" 1324 1196 CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 1325 1197 # Avoid 'unresolved external symbol __security_cookie' 1326 1198 # errors, c.f. http://support.microsoft.com/?id=894573 1327 1199 TEA_ADD_LIBS([bufferoverflowU.lib]) 1328 - elif test "$doWince" != "no" ; then 1329 - CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin" 1330 - if test "${TARGETCPU}" = "X86"; then 1331 - CC="\"${CEBINROOT}/cl.exe\"" 1332 - else 1333 - CC="\"${CEBINROOT}/cl${ARCH}.exe\"" 1334 - fi 1335 - CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\"" 1336 - RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\"" 1337 - arch=`echo ${ARCH} | awk '{print tolower([$]0)}'` 1338 - defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS" 1339 - if test "${SHARED_BUILD}" = "1" ; then 1340 - # Static CE builds require static celib as well 1341 - defs="${defs} _DLL" 1342 - fi 1343 - for i in $defs ; do 1344 - AC_DEFINE_UNQUOTED($i, 1, [WinCE def ]$i) 1345 - done 1346 - AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION, [_WIN32_WCE version]) 1347 - AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION, [UNDER_CE version]) 1348 - CFLAGS_DEBUG="-nologo -Zi -Od" 1349 - CFLAGS_OPTIMIZE="-nologo -Ox" 1350 - lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'` 1351 - lflags="${lflags} -MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo" 1352 - LINKBIN="\"${CEBINROOT}/link.exe\"" 1353 - AC_SUBST(CELIB_DIR) 1354 1200 else 1355 1201 RC="rc" 1356 1202 lflags="${lflags} -nologo" 1357 1203 LINKBIN="link" 1358 1204 CFLAGS_DEBUG="-nologo -Z7 -Od -W3 -WX ${runtime}d" 1359 1205 CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}" 1360 1206 fi ................................................................................ 1379 1225 ], [], 1380 1226 ac_cv_cross=yes, 1381 1227 ac_cv_cross=no) 1382 1228 ) 1383 1229 if test "$ac_cv_cross" = "yes"; then 1384 1230 case "$do64bit" in 1385 1231 amd64|x64|yes) 1386 - CC="x86_64-w64-mingw32-gcc" 1232 + CC="x86_64-w64-mingw32-${CC}" 1387 1233 LD="x86_64-w64-mingw32-ld" 1388 1234 AR="x86_64-w64-mingw32-ar" 1389 1235 RANLIB="x86_64-w64-mingw32-ranlib" 1390 1236 RC="x86_64-w64-mingw32-windres" 1391 1237 ;; 1392 1238 *) 1393 - CC="i686-w64-mingw32-gcc" 1239 + CC="i686-w64-mingw32-${CC}" 1394 1240 LD="i686-w64-mingw32-ld" 1395 1241 AR="i686-w64-mingw32-ar" 1396 1242 RANLIB="i686-w64-mingw32-ranlib" 1397 1243 RC="i686-w64-mingw32-windres" 1398 1244 ;; 1399 1245 esac 1400 1246 fi ................................................................................ 1408 1254 # For information on what debugtype is most useful, see: 1409 1255 # http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp 1410 1256 # and also 1411 1257 # http://msdn2.microsoft.com/en-us/library/y0zzbyt4%28VS.80%29.aspx 1412 1258 # This essentially turns it all on. 1413 1259 LDFLAGS_DEBUG="-debug -debugtype:cv" 1414 1260 LDFLAGS_OPTIMIZE="-release" 1415 - if test "$doWince" != "no" ; then 1416 - LDFLAGS_CONSOLE="-link ${lflags}" 1417 - LDFLAGS_WINDOW=${LDFLAGS_CONSOLE} 1418 - else 1419 - LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 1420 - LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 1421 - fi 1261 + LDFLAGS_CONSOLE="-link -subsystem:console ${lflags}" 1262 + LDFLAGS_WINDOW="-link -subsystem:windows ${lflags}" 1422 1263 fi 1423 1264 1424 1265 SHLIB_SUFFIX=".dll" 1425 1266 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.dll' 1426 1267 1427 1268 TCL_LIB_VERSIONS_OK=nodots 1428 1269 ;; 1429 1270 AIX-*) 1430 - AS_IF([test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"], [ 1271 + AS_IF([test "$GCC" != "yes"], [ 1431 1272 # AIX requires the _r compiler when gcc isn't being used 1432 1273 case "${CC}" in 1433 1274 *_r|*_r\ *) 1434 1275 # ok ... 1435 1276 ;; 1436 1277 *) 1437 1278 # Make sure only first arg gets _r ................................................................................ 1460 1301 ]) 1461 1302 ]) 1462 1303 1463 1304 AS_IF([test "`uname -m`" = ia64], [ 1464 1305 # AIX-5 uses ELF style dynamic libraries on IA-64, but not PPC 1465 1306 SHLIB_LD="/usr/ccs/bin/ld -G -z text" 1466 1307 AS_IF([test "$GCC" = yes], [ 1467 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 1308 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 1468 1309 ], [ 1469 - CC_SEARCH_FLAGS='-R${LIB_RUNTIME_DIR}' 1310 + CC_SEARCH_FLAGS='"-R${LIB_RUNTIME_DIR}"' 1470 1311 ]) 1471 - LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 1312 + LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 1472 1313 ], [ 1473 1314 AS_IF([test "$GCC" = yes], [ 1474 1315 SHLIB_LD='${CC} -shared -Wl,-bexpall' 1475 1316 ], [ 1476 1317 SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry" 1477 1318 LDFLAGS="$LDFLAGS -brtl" 1478 1319 ]) 1479 1320 SHLIB_LD="${SHLIB_LD} ${SHLIB_LD_FLAGS}" 1480 - CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}' 1321 + CC_SEARCH_FLAGS='"-L${LIB_RUNTIME_DIR}"' 1481 1322 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1482 1323 ]) 1483 1324 ;; 1484 1325 BeOS*) 1485 1326 SHLIB_CFLAGS="-fPIC" 1486 1327 SHLIB_LD='${CC} -nostart' 1487 1328 SHLIB_SUFFIX=".so" ................................................................................ 1489 1330 #----------------------------------------------------------- 1490 1331 # Check for inet_ntoa in -lbind, for BeOS (which also needs 1491 1332 # -lsocket, even if the network functions are in -lnet which 1492 1333 # is always linked to, for compatibility. 1493 1334 #----------------------------------------------------------- 1494 1335 AC_CHECK_LIB(bind, inet_ntoa, [LIBS="$LIBS -lbind -lsocket"]) 1495 1336 ;; 1337 + BSD/OS-2.1*|BSD/OS-3*) 1338 + SHLIB_CFLAGS="" 1339 + SHLIB_LD="shlicc -r" 1340 + SHLIB_SUFFIX=".so" 1341 + CC_SEARCH_FLAGS="" 1342 + LD_SEARCH_FLAGS="" 1343 + ;; 1496 1344 BSD/OS-4.*) 1497 1345 SHLIB_CFLAGS="-export-dynamic -fPIC" 1498 1346 SHLIB_LD='${CC} -shared' 1499 1347 SHLIB_SUFFIX=".so" 1500 1348 LDFLAGS="$LDFLAGS -export-dynamic" 1501 1349 CC_SEARCH_FLAGS="" 1502 1350 LD_SEARCH_FLAGS="" 1503 1351 ;; 1504 1352 CYGWIN_*) 1505 1353 SHLIB_CFLAGS="" 1506 1354 SHLIB_LD='${CC} -shared' 1507 - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a" 1508 1355 SHLIB_SUFFIX=".dll" 1356 + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a" 1509 1357 EXEEXT=".exe" 1510 1358 do64bit_ok=yes 1359 + CC_SEARCH_FLAGS="" 1360 + LD_SEARCH_FLAGS="" 1361 + ;; 1362 + dgux*) 1363 + SHLIB_CFLAGS="-K PIC" 1364 + SHLIB_LD='${CC} -G' 1365 + SHLIB_LD_LIBS="" 1366 + SHLIB_SUFFIX=".so" 1511 1367 CC_SEARCH_FLAGS="" 1512 1368 LD_SEARCH_FLAGS="" 1513 1369 ;; 1514 1370 Haiku*) 1515 1371 LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 1516 1372 SHLIB_CFLAGS="-fPIC" 1517 1373 SHLIB_SUFFIX=".so" ................................................................................ 1523 1379 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?]) 1524 1380 # TEA specific: Needed by Tcl, but not most extensions 1525 1381 #AC_DEFINE(_XOPEN_SOURCE, 1, [Do we want to use the XOPEN network library?]) 1526 1382 #LIBS="$LIBS -lxnet" # Use the XOPEN network library 1527 1383 1528 1384 AS_IF([test "`uname -m`" = ia64], [ 1529 1385 SHLIB_SUFFIX=".so" 1530 - # Use newer C++ library for C++ extensions 1531 - #if test "$GCC" != "yes" ; then 1532 - # CPPFLAGS="-AA" 1533 - #fi 1534 1386 ], [ 1535 1387 SHLIB_SUFFIX=".sl" 1536 1388 ]) 1537 1389 AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no) 1538 1390 AS_IF([test "$tcl_ok" = yes], [ 1391 + SHLIB_CFLAGS="+z" 1392 + SHLIB_LD="ld -b" 1539 1393 LDFLAGS="$LDFLAGS -Wl,-E" 1540 - CC_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.' 1541 - LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.' 1394 + CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."' 1395 + LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."' 1542 1396 LD_LIBRARY_PATH_VAR="SHLIB_PATH" 1543 1397 ]) 1544 1398 AS_IF([test "$GCC" = yes], [ 1545 1399 SHLIB_LD='${CC} -shared' 1546 1400 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1547 1401 ], [ 1548 1402 CFLAGS="$CFLAGS -z" 1549 - # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc 1550 - #CFLAGS="$CFLAGS +DAportable" 1551 - SHLIB_CFLAGS="+z" 1552 - SHLIB_LD="ld -b" 1553 1403 ]) 1554 1404 1555 1405 # Check to enable 64-bit flags for compiler/linker 1556 1406 AS_IF([test "$do64bit" = "yes"], [ 1557 1407 AS_IF([test "$GCC" = yes], [ 1558 1408 case `${CC} -dumpmachine` in 1559 1409 hppa64*) 1560 1410 # 64-bit gcc in use. Fix flags for GNU ld. 1561 1411 do64bit_ok=yes 1562 1412 SHLIB_LD='${CC} -shared' 1563 1413 AS_IF([test $doRpath = yes], [ 1564 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) 1414 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"']) 1565 1415 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1566 1416 ;; 1567 1417 *) 1568 1418 AC_MSG_WARN([64bit mode not supported with GCC on $system]) 1569 1419 ;; 1570 1420 esac 1571 1421 ], [ 1572 1422 do64bit_ok=yes 1573 1423 CFLAGS="$CFLAGS +DD64" 1574 1424 LDFLAGS_ARCH="+DD64" 1575 1425 ]) 1576 1426 ]) ;; 1427 + HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*) 1428 + SHLIB_SUFFIX=".sl" 1429 + AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no) 1430 + AS_IF([test "$tcl_ok" = yes], [ 1431 + SHLIB_CFLAGS="+z" 1432 + SHLIB_LD="ld -b" 1433 + SHLIB_LD_LIBS="" 1434 + LDFLAGS="$LDFLAGS -Wl,-E" 1435 + CC_SEARCH_FLAGS='"-Wl,+s,+b,${LIB_RUNTIME_DIR}:."' 1436 + LD_SEARCH_FLAGS='+s +b "${LIB_RUNTIME_DIR}:."' 1437 + LD_LIBRARY_PATH_VAR="SHLIB_PATH" 1438 + ]) ;; 1439 + IRIX-5.*) 1440 + SHLIB_CFLAGS="" 1441 + SHLIB_LD="ld -shared -rdata_shared" 1442 + SHLIB_SUFFIX=".so" 1443 + AC_LIBOBJ(mkstemp) 1444 + AS_IF([test $doRpath = yes], [ 1445 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 1446 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"']) 1447 + ;; 1577 1448 IRIX-6.*) 1578 1449 SHLIB_CFLAGS="" 1579 1450 SHLIB_LD="ld -n32 -shared -rdata_shared" 1580 1451 SHLIB_SUFFIX=".so" 1581 1452 AS_IF([test $doRpath = yes], [ 1582 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 1583 - LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}']) 1453 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 1454 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"']) 1584 1455 AS_IF([test "$GCC" = yes], [ 1585 1456 CFLAGS="$CFLAGS -mabi=n32" 1586 1457 LDFLAGS="$LDFLAGS -mabi=n32" 1587 1458 ], [ 1588 1459 case $system in 1589 1460 IRIX-6.3) 1590 1461 # Use to build 6.2 compatible binaries on 6.3. ................................................................................ 1598 1469 ]) 1599 1470 ;; 1600 1471 IRIX64-6.*) 1601 1472 SHLIB_CFLAGS="" 1602 1473 SHLIB_LD="ld -n32 -shared -rdata_shared" 1603 1474 SHLIB_SUFFIX=".so" 1604 1475 AS_IF([test $doRpath = yes], [ 1605 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 1606 - LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}']) 1476 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 1477 + LD_SEARCH_FLAGS='-rpath "${LIB_RUNTIME_DIR}"']) 1607 1478 1608 1479 # Check to enable 64-bit flags for compiler/linker 1609 1480 1610 1481 AS_IF([test "$do64bit" = yes], [ 1611 1482 AS_IF([test "$GCC" = yes], [ 1612 1483 AC_MSG_WARN([64bit mode not supported by gcc]) 1613 1484 ], [ ................................................................................ 1614 1485 do64bit_ok=yes 1615 1486 SHLIB_LD="ld -64 -shared -rdata_shared" 1616 1487 CFLAGS="$CFLAGS -64" 1617 1488 LDFLAGS_ARCH="-64" 1618 1489 ]) 1619 1490 ]) 1620 1491 ;; 1621 - Linux*|GNU*|NetBSD-Debian) 1492 + Linux*|GNU*|NetBSD-Debian|DragonFly-*|FreeBSD-*) 1622 1493 SHLIB_CFLAGS="-fPIC" 1623 1494 SHLIB_SUFFIX=".so" 1624 1495 1625 1496 # TEA specific: 1626 1497 CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" 1627 1498 1628 1499 # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 1629 1500 SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared' 1630 1501 LDFLAGS="$LDFLAGS -Wl,--export-dynamic" 1502 + 1503 + case $system in 1504 + DragonFly-*|FreeBSD-*) 1505 + AS_IF([test "${TCL_THREADS}" = "1"], [ 1506 + # The -pthread needs to go in the LDFLAGS, not LIBS 1507 + LIBS=`echo $LIBS | sed s/-pthread//` 1508 + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 1509 + LDFLAGS="$LDFLAGS $PTHREAD_LIBS"]) 1510 + ;; 1511 + esac 1512 + 1631 1513 AS_IF([test $doRpath = yes], [ 1632 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) 1514 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"']) 1633 1515 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1634 1516 AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"]) 1635 1517 AS_IF([test $do64bit = yes], [ 1636 1518 AC_CACHE_CHECK([if compiler accepts -m64 flag], tcl_cv_cc_m64, [ 1637 1519 hold_cflags=$CFLAGS 1638 1520 CFLAGS="$CFLAGS -m64" 1639 1521 AC_TRY_LINK(,, tcl_cv_cc_m64=yes, tcl_cv_cc_m64=no) ................................................................................ 1655 1537 Lynx*) 1656 1538 SHLIB_CFLAGS="-fPIC" 1657 1539 SHLIB_SUFFIX=".so" 1658 1540 CFLAGS_OPTIMIZE=-02 1659 1541 SHLIB_LD='${CC} -shared' 1660 1542 LD_FLAGS="-Wl,--export-dynamic" 1661 1543 AS_IF([test $doRpath = yes], [ 1662 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 1663 - LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) 1544 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 1545 + LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"']) 1664 1546 ;; 1665 1547 OpenBSD-*) 1666 1548 arch=`arch -s` 1667 1549 case "$arch" in 1668 1550 alpha|sparc64) 1669 1551 SHLIB_CFLAGS="-fPIC" 1670 1552 ;; ................................................................................ 1671 1553 *) 1672 1554 SHLIB_CFLAGS="-fpic" 1673 1555 ;; 1674 1556 esac 1675 1557 SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 1676 1558 SHLIB_SUFFIX=".so" 1677 1559 AS_IF([test $doRpath = yes], [ 1678 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) 1560 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"']) 1679 1561 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1680 1562 SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}' 1681 - LDFLAGS="-Wl,-export-dynamic" 1563 + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" 1682 1564 CFLAGS_OPTIMIZE="-O2" 1683 - AS_IF([test "${TCL_THREADS}" = "1"], [ 1684 - # On OpenBSD: Compile with -pthread 1685 - # Don't link with -lpthread 1686 - LIBS=`echo $LIBS | sed s/-lpthread//` 1687 - CFLAGS="$CFLAGS -pthread" 1688 - ]) 1565 + # On OpenBSD: Compile with -pthread 1566 + # Don't link with -lpthread 1567 + LIBS=`echo $LIBS | sed s/-lpthread//` 1568 + CFLAGS="$CFLAGS -pthread" 1689 1569 # OpenBSD doesn't do version numbers with dots. 1690 1570 UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 1691 1571 TCL_LIB_VERSIONS_OK=nodots 1692 1572 ;; 1693 1573 NetBSD-*) 1694 1574 # NetBSD has ELF and can use 'cc -shared' to build shared libs 1695 1575 SHLIB_CFLAGS="-fPIC" 1696 1576 SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared' 1697 1577 SHLIB_SUFFIX=".so" 1698 1578 LDFLAGS="$LDFLAGS -export-dynamic" 1699 1579 AS_IF([test $doRpath = yes], [ 1700 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) 1580 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"']) 1701 1581 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1702 - AS_IF([test "${TCL_THREADS}" = "1"], [ 1703 - # The -pthread needs to go in the CFLAGS, not LIBS 1704 - LIBS=`echo $LIBS | sed s/-pthread//` 1705 - CFLAGS="$CFLAGS -pthread" 1706 - LDFLAGS="$LDFLAGS -pthread" 1707 - ]) 1708 - ;; 1709 - FreeBSD-*) 1710 - # This configuration from FreeBSD Ports. 1711 - SHLIB_CFLAGS="-fPIC" 1712 - SHLIB_LD="${CC} -shared" 1713 - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,-soname,\$[@]" 1714 - SHLIB_SUFFIX=".so" 1715 - LDFLAGS="" 1716 - AS_IF([test $doRpath = yes], [ 1717 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 1718 - LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) 1719 - AS_IF([test "${TCL_THREADS}" = "1"], [ 1720 - # The -pthread needs to go in the LDFLAGS, not LIBS 1721 - LIBS=`echo $LIBS | sed s/-pthread//` 1722 - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 1723 - LDFLAGS="$LDFLAGS $PTHREAD_LIBS"]) 1724 - case $system in 1725 - FreeBSD-3.*) 1726 - # Version numbers are dot-stripped by system policy. 1727 - TCL_TRIM_DOTS=`echo ${PACKAGE_VERSION} | tr -d .` 1728 - UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' 1729 - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}\$\{DBGX\}.so.1' 1730 - TCL_LIB_VERSIONS_OK=nodots 1731 - ;; 1732 - esac 1582 + # The -pthread needs to go in the CFLAGS, not LIBS 1583 + LIBS=`echo $LIBS | sed s/-pthread//` 1584 + CFLAGS="$CFLAGS -pthread" 1585 + LDFLAGS="$LDFLAGS -pthread" 1733 1586 ;; 1734 1587 Darwin-*) 1735 1588 CFLAGS_OPTIMIZE="-Os" 1736 1589 SHLIB_CFLAGS="-fno-common" 1737 1590 # To avoid discrepancies between what headers configure sees during 1738 1591 # preprocessing tests and compiling tests, move any -isysroot and 1739 1592 # -mmacosx-version-min flags from CFLAGS to CPPFLAGS: ................................................................................ 1788 1641 AS_IF([test $tcl_cv_ld_single_module = yes], [ 1789 1642 SHLIB_LD="${SHLIB_LD} -Wl,-single_module" 1790 1643 ]) 1791 1644 # TEA specific: link shlib with current and compatibility version flags 1792 1645 vers=`echo ${PACKAGE_VERSION} | sed -e 's/^\([[0-9]]\{1,5\}\)\(\(\.[[0-9]]\{1,3\}\)\{0,2\}\).*$/\1\2/p' -e d` 1793 1646 SHLIB_LD="${SHLIB_LD} -current_version ${vers:-0} -compatibility_version ${vers:-0}" 1794 1647 SHLIB_SUFFIX=".dylib" 1795 - # Don't use -prebind when building for Mac OS X 10.4 or later only: 1796 - AS_IF([test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \ 1797 - "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4], [ 1798 - LDFLAGS="$LDFLAGS -prebind"]) 1799 1648 LDFLAGS="$LDFLAGS -headerpad_max_install_names" 1800 1649 AC_CACHE_CHECK([if ld accepts -search_paths_first flag], 1801 1650 tcl_cv_ld_search_paths_first, [ 1802 1651 hold_ldflags=$LDFLAGS 1803 1652 LDFLAGS="$LDFLAGS -Wl,-search_paths_first" 1804 1653 AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, 1805 1654 tcl_cv_ld_search_paths_first=no) ................................................................................ 1864 1713 AS_IF([test "$SHARED_BUILD" = 1], [ 1865 1714 SHLIB_LD='ld -shared -expect_unresolved "*"' 1866 1715 ], [ 1867 1716 SHLIB_LD='ld -non_shared -expect_unresolved "*"' 1868 1717 ]) 1869 1718 SHLIB_SUFFIX=".so" 1870 1719 AS_IF([test $doRpath = yes], [ 1871 - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' 1720 + CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"' 1872 1721 LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}']) 1873 1722 AS_IF([test "$GCC" = yes], [CFLAGS="$CFLAGS -mieee"], [ 1874 1723 CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"]) 1875 1724 # see pthread_intro(3) for pthread support on osf1, k.furukawa 1876 - AS_IF([test "${TCL_THREADS}" = 1], [ 1877 - CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 1878 - CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 1879 - LIBS=`echo $LIBS | sed s/-lpthreads//` 1880 - AS_IF([test "$GCC" = yes], [ 1881 - LIBS="$LIBS -lpthread -lmach -lexc" 1882 - ], [ 1883 - CFLAGS="$CFLAGS -pthread" 1884 - LDFLAGS="$LDFLAGS -pthread" 1885 - ]) 1725 + CFLAGS="$CFLAGS -DHAVE_PTHREAD_ATTR_SETSTACKSIZE" 1726 + CFLAGS="$CFLAGS -DTCL_THREAD_STACK_MIN=PTHREAD_STACK_MIN*64" 1727 + LIBS=`echo $LIBS | sed s/-lpthreads//` 1728 + AS_IF([test "$GCC" = yes], [ 1729 + LIBS="$LIBS -lpthread -lmach -lexc" 1730 + ], [ 1731 + CFLAGS="$CFLAGS -pthread" 1732 + LDFLAGS="$LDFLAGS -pthread" 1886 1733 ]) 1887 1734 ;; 1888 1735 QNX-6*) 1889 1736 # QNX RTP 1890 1737 # This may work for all QNX, but it was only reported for v6. 1891 1738 SHLIB_CFLAGS="-fPIC" 1892 1739 SHLIB_LD="ld -Bshareable -x" ................................................................................ 1919 1766 AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, 1920 1767 [Do we really want to follow the standard? Yes we do!]) 1921 1768 1922 1769 SHLIB_CFLAGS="-KPIC" 1923 1770 SHLIB_SUFFIX=".so" 1924 1771 AS_IF([test "$GCC" = yes], [ 1925 1772 SHLIB_LD='${CC} -shared' 1926 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 1773 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 1927 1774 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1928 1775 ], [ 1929 1776 SHLIB_LD="/usr/ccs/bin/ld -G -z text" 1930 - CC_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 1777 + CC_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 1931 1778 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1932 1779 ]) 1933 1780 ;; 1934 1781 SunOS-5*) 1935 1782 # Note: If _REENTRANT isn't defined, then Solaris 1936 1783 # won't define thread-safe library routines. 1937 1784 ................................................................................ 1989 1836 ]) 1990 1837 ], [AC_MSG_WARN([64bit mode not supported for $arch])])]) 1991 1838 ]) 1992 1839 1993 1840 SHLIB_SUFFIX=".so" 1994 1841 AS_IF([test "$GCC" = yes], [ 1995 1842 SHLIB_LD='${CC} -shared' 1996 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 1843 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 1997 1844 LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} 1998 1845 AS_IF([test "$do64bit_ok" = yes], [ 1999 1846 AS_IF([test "$arch" = "sparcv9 sparc"], [ 2000 1847 # We need to specify -static-libgcc or we need to 2001 1848 # add the path to the sparv9 libgcc. 2002 1849 # JH: static-libgcc is necessary for core Tcl, but may 2003 1850 # not be necessary for extensions. ................................................................................ 2016 1863 case $system in 2017 1864 SunOS-5.[[1-9]][[0-9]]*) 2018 1865 # TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS 2019 1866 SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';; 2020 1867 *) 2021 1868 SHLIB_LD='/usr/ccs/bin/ld -G -z text';; 2022 1869 esac 2023 - CC_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}' 2024 - LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}' 1870 + CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"' 1871 + LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"' 2025 1872 ]) 2026 1873 ;; 2027 1874 UNIX_SV* | UnixWare-5*) 2028 1875 SHLIB_CFLAGS="-KPIC" 2029 1876 SHLIB_LD='${CC} -G' 2030 1877 SHLIB_LD_LIBS="" 2031 1878 SHLIB_SUFFIX=".so" ................................................................................ 2062 1909 # libraries to the right flags for gcc, instead of those for the 2063 1910 # standard manufacturer compiler. 2064 1911 2065 1912 AS_IF([test "$GCC" = yes], [ 2066 1913 case $system in 2067 1914 AIX-*) ;; 2068 1915 BSD/OS*) ;; 2069 - CYGWIN_*|MINGW32_*|MINGW64_*) ;; 1916 + CYGWIN_*|MINGW32_*|MINGW64_*|MSYS_*) ;; 2070 1917 IRIX*) ;; 2071 - NetBSD-*|FreeBSD-*|OpenBSD-*) ;; 1918 + NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;; 2072 1919 Darwin-*) ;; 2073 1920 SCO_SV-3.2*) ;; 2074 1921 windows) ;; 2075 1922 *) SHLIB_CFLAGS="-fPIC" ;; 2076 1923 esac]) 2077 1924 2078 1925 AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [ ................................................................................ 2178 2025 tcl_cv_cast_to_union=no) 2179 2026 ) 2180 2027 if test "$tcl_cv_cast_to_union" = "yes"; then 2181 2028 AC_DEFINE(HAVE_CAST_TO_UNION, 1, 2182 2029 [Defined when compiler supports casting to union type.]) 2183 2030 fi 2184 2031 2032 + AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],) 2033 + 2185 2034 AC_SUBST(CFLAGS_DEBUG) 2186 2035 AC_SUBST(CFLAGS_OPTIMIZE) 2187 2036 AC_SUBST(CFLAGS_WARNING) 2037 + AC_SUBST(LDFLAGS_DEBUG) 2038 + AC_SUBST(LDFLAGS_OPTIMIZE) 2188 2039 2189 2040 AC_SUBST(STLIB_LD) 2190 2041 AC_SUBST(SHLIB_LD) 2191 2042 2192 2043 AC_SUBST(SHLIB_LD_LIBS) 2193 2044 AC_SUBST(SHLIB_CFLAGS) 2194 2045 ................................................................................ 2464 2315 # Results: 2465 2316 # 2466 2317 # Defines some of the following vars: 2467 2318 # USE_DELTA_FOR_TZ 2468 2319 # HAVE_TM_GMTOFF 2469 2320 # HAVE_TM_TZADJ 2470 2321 # HAVE_TIMEZONE_VAR 2322 +# 2471 2323 #-------------------------------------------------------------------- 2472 2324 2473 2325 AC_DEFUN([TEA_TIME_HANDLER], [ 2474 2326 AC_CHECK_HEADERS(sys/time.h) 2475 2327 AC_HEADER_TIME 2476 2328 AC_STRUCT_TIMEZONE 2477 2329 2478 - AC_CHECK_FUNCS(gmtime_r localtime_r) 2330 + AC_CHECK_FUNCS(gmtime_r localtime_r mktime) 2479 2331 2480 2332 AC_CACHE_CHECK([tm_tzadj in struct tm], tcl_cv_member_tm_tzadj, [ 2481 2333 AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;], 2482 2334 tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no)]) 2483 2335 if test $tcl_cv_member_tm_tzadj = yes ; then 2484 2336 AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?]) 2485 2337 fi ................................................................................ 2539 2391 #-------------------------------------------------------------------- 2540 2392 2541 2393 AC_DEFUN([TEA_BUGGY_STRTOD], [ 2542 2394 AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0) 2543 2395 if test "$tcl_strtod" = 1; then 2544 2396 AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[ 2545 2397 AC_TRY_RUN([ 2398 + #include <stdlib.h> 2546 2399 extern double strtod(); 2547 2400 int main() { 2548 2401 char *infString="Inf", *nanString="NaN", *spaceString=" "; 2549 2402 char *term; 2550 2403 double value; 2551 2404 value = strtod(infString, &term); 2552 2405 if ((term != infString) && (term[-1] == 0)) { ................................................................................ 2566 2419 if test "$tcl_cv_strtod_buggy" = buggy; then 2567 2420 AC_LIBOBJ([fixstrtod]) 2568 2421 USE_COMPAT=1 2569 2422 AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?]) 2570 2423 fi 2571 2424 fi 2572 2425 ]) 2426 + 2427 +#-------------------------------------------------------------------- 2428 +# TEA_TCL_LINK_LIBS 2429 +# 2430 +# Search for the libraries needed to link the Tcl shell. 2431 +# Things like the math library (-lm), socket stuff (-lsocket vs. 2432 +# -lnsl), zlib (-lz) and libtommath (-ltommath) are dealt with here. 2433 +# 2434 +# Arguments: 2435 +# None. 2436 +# 2437 +# Results: 2438 +# 2439 +# Might append to the following vars: 2440 +# LIBS 2441 +# MATH_LIBS 2442 +# 2443 +# Might define the following vars: 2444 +# HAVE_NET_ERRNO_H 2445 +# 2446 +#-------------------------------------------------------------------- 2447 + 2448 +AC_DEFUN([TEA_TCL_LINK_LIBS], [ 2449 + #-------------------------------------------------------------------- 2450 + # On a few very rare systems, all of the libm.a stuff is 2451 + # already in libc.a. Set compiler flags accordingly. 2452 + #-------------------------------------------------------------------- 2453 + 2454 + AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm") 2455 + 2456 + #-------------------------------------------------------------------- 2457 + # Interactive UNIX requires -linet instead of -lsocket, plus it 2458 + # needs net/errno.h to define the socket-related error codes. 2459 + #-------------------------------------------------------------------- 2460 + 2461 + AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"]) 2462 + AC_CHECK_HEADER(net/errno.h, [ 2463 + AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have <net/errno.h>?])]) 2464 + 2465 + #-------------------------------------------------------------------- 2466 + # Check for the existence of the -lsocket and -lnsl libraries. 2467 + # The order here is important, so that they end up in the right 2468 + # order in the command line generated by make. Here are some 2469 + # special considerations: 2470 + # 1. Use "connect" and "accept" to check for -lsocket, and 2471 + # "gethostbyname" to check for -lnsl. 2472 + # 2. Use each function name only once: can't redo a check because 2473 + # autoconf caches the results of the last check and won't redo it. 2474 + # 3. Use -lnsl and -lsocket only if they supply procedures that 2475 + # aren't already present in the normal libraries. This is because 2476 + # IRIX 5.2 has libraries, but they aren't needed and they're 2477 + # bogus: they goof up name resolution if used. 2478 + # 4. On some SVR4 systems, can't use -lsocket without -lnsl too. 2479 + # To get around this problem, check for both libraries together 2480 + # if -lsocket doesn't work by itself. 2481 + #-------------------------------------------------------------------- 2482 + 2483 + tcl_checkBoth=0 2484 + AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1) 2485 + if test "$tcl_checkSocket" = 1; then 2486 + AC_CHECK_FUNC(setsockopt, , [AC_CHECK_LIB(socket, setsockopt, 2487 + LIBS="$LIBS -lsocket", tcl_checkBoth=1)]) 2488 + fi 2489 + if test "$tcl_checkBoth" = 1; then 2490 + tk_oldLibs=$LIBS 2491 + LIBS="$LIBS -lsocket -lnsl" 2492 + AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs]) 2493 + fi 2494 + AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname, 2495 + [LIBS="$LIBS -lnsl"])]) 2496 + AC_CHECK_FUNC(mp_log_u32, , [AC_CHECK_LIB(tommath, mp_log_u32, 2497 + [LIBS="$LIBS -ltommath"])]) 2498 + AC_CHECK_FUNC(deflateSetHeader, , [AC_CHECK_LIB(z, deflateSetHeader, 2499 + [LIBS="$LIBS -lz"])]) 2500 +]) 2573 2501 2574 2502 #-------------------------------------------------------------------- 2575 2503 # TEA_TCL_EARLY_FLAGS 2576 2504 # 2577 2505 # Check for what flags are needed to be passed so the correct OS 2578 2506 # features are available. 2579 2507 # ................................................................................ 2582 2510 # 2583 2511 # Results: 2584 2512 # 2585 2513 # Might define the following vars: 2586 2514 # _ISOC99_SOURCE 2587 2515 # _LARGEFILE64_SOURCE 2588 2516 # _LARGEFILE_SOURCE64 2517 +# 2589 2518 #-------------------------------------------------------------------- 2590 2519 2591 2520 AC_DEFUN([TEA_TCL_EARLY_FLAG],[ 2592 2521 AC_CACHE_VAL([tcl_cv_flag_]translit($1,[A-Z],[a-z]), 2593 2522 AC_TRY_COMPILE([$2], $3, [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no, 2594 2523 AC_TRY_COMPILE([[#define ]$1[ 1 2595 2524 ]$2], $3, ................................................................................ 2626 2555 # None 2627 2556 # 2628 2557 # Results: 2629 2558 # 2630 2559 # Might define the following vars: 2631 2560 # TCL_WIDE_INT_IS_LONG 2632 2561 # TCL_WIDE_INT_TYPE 2633 -# HAVE_STRUCT_DIRENT64 2562 +# HAVE_STRUCT_DIRENT64, HAVE_DIR64 2634 2563 # HAVE_STRUCT_STAT64 2635 2564 # HAVE_TYPE_OFF64_T 2565 +# 2636 2566 #-------------------------------------------------------------------- 2637 2567 2638 2568 AC_DEFUN([TEA_TCL_64BIT_FLAGS], [ 2639 2569 AC_MSG_CHECKING([for 64-bit integer type]) 2640 2570 AC_CACHE_VAL(tcl_cv_type_64bit,[ 2641 2571 tcl_cv_type_64bit=none 2642 2572 # See if the compiler knows natively about __int64 2643 2573 AC_TRY_COMPILE(,[__int64 value = (__int64) 0;], 2644 2574 tcl_type_64bit=__int64, tcl_type_64bit="long long") 2645 - # See if we should use long anyway Note that we substitute in the 2575 + # See if we could use long anyway Note that we substitute in the 2646 2576 # type that is our current guess for a 64-bit type inside this check 2647 2577 # program, so it should be modified only carefully... 2648 2578 AC_TRY_COMPILE(,[switch (0) { 2649 2579 case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ; 2650 2580 }],tcl_cv_type_64bit=${tcl_type_64bit})]) 2651 2581 if test "${tcl_cv_type_64bit}" = none ; then 2652 - AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Are wide integers to be implemented with C 'long's?]) 2653 - AC_MSG_RESULT([using long]) 2582 + AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Do 'long' and 'long long' have the same size (64-bit)?]) 2583 + AC_MSG_RESULT([yes]) 2654 2584 elif test "${tcl_cv_type_64bit}" = "__int64" \ 2655 2585 -a "${TEA_PLATFORM}" = "windows" ; then 2656 2586 # TEA specific: We actually want to use the default tcl.h checks in 2657 2587 # this case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER* 2658 2588 AC_MSG_RESULT([using Tcl header defaults]) 2659 2589 else 2660 2590 AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit}, ................................................................................ 2665 2595 AC_CACHE_CHECK([for struct dirent64], tcl_cv_struct_dirent64,[ 2666 2596 AC_TRY_COMPILE([#include <sys/types.h> 2667 2597 #include <dirent.h>],[struct dirent64 p;], 2668 2598 tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)]) 2669 2599 if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then 2670 2600 AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?]) 2671 2601 fi 2602 + 2603 + AC_CACHE_CHECK([for DIR64], tcl_cv_DIR64,[ 2604 + AC_TRY_COMPILE([#include <sys/types.h> 2605 +#include <dirent.h>],[struct dirent64 *p; DIR64 d = opendir64("."); 2606 + p = readdir64(d); rewinddir64(d); closedir64(d);], 2607 + tcl_cv_DIR64=yes,tcl_cv_DIR64=no)]) 2608 + if test "x${tcl_cv_DIR64}" = "xyes" ; then 2609 + AC_DEFINE(HAVE_DIR64, 1, [Is 'DIR64' in <sys/types.h>?]) 2610 + fi 2672 2611 2673 2612 AC_CACHE_CHECK([for struct stat64], tcl_cv_struct_stat64,[ 2674 2613 AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 p; 2675 2614 ], 2676 2615 tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)]) 2677 2616 if test "x${tcl_cv_struct_stat64}" = "xyes" ; then 2678 2617 AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?]) ................................................................................ 2744 2683 # If the user did not set CFLAGS, set it now to keep macros 2745 2684 # like AC_PROG_CC and AC_TRY_COMPILE from adding "-g -O2". 2746 2685 if test "${CFLAGS+set}" != "set" ; then 2747 2686 CFLAGS="" 2748 2687 fi 2749 2688 2750 2689 case "`uname -s`" in 2751 - *win32*|*WIN32*|*MINGW32_*|*MINGW64_*) 2690 + *win32*|*WIN32*|*MINGW32_*|*MINGW64_*|*MSYS_*) 2752 2691 AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo) 2753 2692 EXEEXT=".exe" 2754 2693 TEA_PLATFORM="windows" 2755 2694 ;; 2756 2695 *CYGWIN_*) 2757 2696 EXEEXT=".exe" 2758 2697 # CYGPATH and TEA_PLATFORM are determined later in LOAD_TCLCONFIG ................................................................................ 2992 2931 # PKG_LIBS 2993 2932 #------------------------------------------------------------------------ 2994 2933 AC_DEFUN([TEA_ADD_LIBS], [ 2995 2934 vars="$@" 2996 2935 for i in $vars; do 2997 2936 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then 2998 2937 # Convert foo.lib to -lfoo for GCC. No-op if not *.lib 2999 - i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.lib[$]/-l\1/i'` 2938 + i=`echo "$i" | sed -e 's/^\([[^-]].*\)\.[[lL]][[iI]][[bB]][$]/-l\1/'` 3000 2939 fi 3001 2940 PKG_LIBS="$PKG_LIBS $i" 3002 2941 done 3003 2942 AC_SUBST(PKG_LIBS) 3004 2943 ]) 3005 2944 3006 2945 #------------------------------------------------------------------------ ................................................................................ 3179 3118 # VC_MANIFEST_EMBED_DLL Makefile rule for embedded VC manifest in DLL 3180 3119 # VC_MANIFEST_EMBED_EXE Makefile rule for embedded VC manifest in EXE 3181 3120 #------------------------------------------------------------------------ 3182 3121 3183 3122 AC_DEFUN([TEA_MAKE_LIB], [ 3184 3123 if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes"; then 3185 3124 MAKE_STATIC_LIB="\${STLIB_LD} -out:\[$]@ \$(PKG_OBJECTS)" 3186 - MAKE_SHARED_LIB="\${SHLIB_LD} \${SHLIB_LD_LIBS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS)" 3125 + MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -out:\[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 3187 3126 AC_EGREP_CPP([manifest needed], [ 3188 3127 #if defined(_MSC_VER) && _MSC_VER >= 1400 3189 3128 print("manifest needed") 3190 3129 #endif 3191 3130 ], [ 3192 3131 # Could do a CHECK_PROG for mt, but should always be with MSVC8+ 3193 3132 VC_MANIFEST_EMBED_DLL="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest -outputresource:\[$]@\;2 ; fi" ................................................................................ 3194 3133 VC_MANIFEST_EMBED_EXE="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest -outputresource:\[$]@\;1 ; fi" 3195 3134 MAKE_SHARED_LIB="${MAKE_SHARED_LIB} ; ${VC_MANIFEST_EMBED_DLL}" 3196 3135 TEA_ADD_CLEANFILES([*.manifest]) 3197 3136 ]) 3198 3137 MAKE_STUB_LIB="\${STLIB_LD} -nodefaultlib -out:\[$]@ \$(PKG_STUB_OBJECTS)" 3199 3138 else 3200 3139 MAKE_STATIC_LIB="\${STLIB_LD} \[$]@ \$(PKG_OBJECTS)" 3201 - MAKE_SHARED_LIB="\${SHLIB_LD} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 3140 + MAKE_SHARED_LIB="\${SHLIB_LD} \${LDFLAGS} \${LDFLAGS_DEFAULT} -o \[$]@ \$(PKG_OBJECTS) \${SHLIB_LD_LIBS}" 3202 3141 MAKE_STUB_LIB="\${STLIB_LD} \[$]@ \$(PKG_STUB_OBJECTS)" 3203 3142 fi 3204 3143 3205 3144 if test "${SHARED_BUILD}" = "1" ; then 3206 3145 MAKE_LIB="${MAKE_SHARED_LIB} " 3207 3146 else 3208 3147 MAKE_LIB="${MAKE_STATIC_LIB} " ................................................................................ 3936 3875 #-------------------------------------------------------------------- 3937 3876 # These are for $1Config.sh 3938 3877 #-------------------------------------------------------------------- 3939 3878 3940 3879 # pkglibdir must be a fully qualified path and (not ${exec_prefix}/lib) 3941 3880 eval pkglibdir="[$]{libdir}/$1${PACKAGE_VERSION}" 3942 3881 if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then 3943 - eval $1_LIB_FLAG="-l$1${PACKAGE_VERSION}${DBGX}" 3944 - eval $1_STUB_LIB_FLAG="-l$1stub${PACKAGE_VERSION}${DBGX}" 3882 + eval $1_LIB_FLAG="-l$1${PACKAGE_VERSION}" 3883 + eval $1_STUB_LIB_FLAG="-l$1stub${PACKAGE_VERSION}" 3945 3884 else 3946 - eval $1_LIB_FLAG="-l$1`echo ${PACKAGE_VERSION} | tr -d .`${DBGX}" 3947 - eval $1_STUB_LIB_FLAG="-l$1stub`echo ${PACKAGE_VERSION} | tr -d .`${DBGX}" 3885 + eval $1_LIB_FLAG="-l$1`echo ${PACKAGE_VERSION} | tr -d .`" 3886 + eval $1_STUB_LIB_FLAG="-l$1stub`echo ${PACKAGE_VERSION} | tr -d .`" 3948 3887 fi 3949 3888 $1_BUILD_LIB_SPEC="-L`$CYGPATH $(pwd)` ${$1_LIB_FLAG}" 3950 3889 $1_LIB_SPEC="-L`$CYGPATH ${pkglibdir}` ${$1_LIB_FLAG}" 3951 3890 $1_BUILD_STUB_LIB_SPEC="-L`$CYGPATH $(pwd)` [$]{$1_STUB_LIB_FLAG}" 3952 3891 $1_STUB_LIB_SPEC="-L`$CYGPATH ${pkglibdir}` [$]{$1_STUB_LIB_FLAG}" 3953 3892 $1_BUILD_STUB_LIB_PATH="`$CYGPATH $(pwd)`/[$]{PKG_STUB_LIB_FILE}" 3954 3893 $1_STUB_LIB_PATH="`$CYGPATH ${pkglibdir}`/[$]{PKG_STUB_LIB_FILE}" ................................................................................ 3962 3901 3963 3902 AC_SUBST(MAJOR_VERSION) 3964 3903 AC_SUBST(MINOR_VERSION) 3965 3904 AC_SUBST(PATCHLEVEL) 3966 3905 ]) 3967 3906 3968 3907 3969 -#------------------------------------------------------------------------ 3970 -# TEA_PATH_CELIB -- 3971 -# 3972 -# Locate Keuchel's celib emulation layer for targeting Win/CE 3973 -# 3974 -# Arguments: 3975 -# none 3976 -# 3977 -# Results: 3978 -# 3979 -# Adds the following arguments to configure: 3980 -# --with-celib=... 3981 -# 3982 -# Defines the following vars: 3983 -# CELIB_DIR Full path to the directory containing 3984 -# the include and platform lib files 3985 -#------------------------------------------------------------------------ 3986 - 3987 -AC_DEFUN([TEA_PATH_CELIB], [ 3988 - # First, look for one uninstalled. 3989 - # the alternative search directory is invoked by --with-celib 3990 - 3991 - if test x"${no_celib}" = x ; then 3992 - # we reset no_celib in case something fails here 3993 - no_celib=true 3994 - AC_ARG_WITH(celib,[ --with-celib=DIR use Windows/CE support library from DIR], with_celibconfig=${withval}) 3995 - AC_MSG_CHECKING([for Windows/CE celib directory]) 3996 - AC_CACHE_VAL(ac_cv_c_celibconfig,[ 3997 - # First check to see if --with-celibconfig was specified. 3998 - if test x"${with_celibconfig}" != x ; then 3999 - if test -d "${with_celibconfig}/inc" ; then 4000 - ac_cv_c_celibconfig=`(cd ${with_celibconfig}; pwd)` 4001 - else 4002 - AC_MSG_ERROR([${with_celibconfig} directory doesn't contain inc directory]) 4003 - fi 4004 - fi 4005 - 4006 - # then check for a celib library 4007 - if test x"${ac_cv_c_celibconfig}" = x ; then 4008 - for i in \ 4009 - ../celib-palm-3.0 \ 4010 - ../celib \ 4011 - ../../celib-palm-3.0 \ 4012 - ../../celib \ 4013 - `ls -dr ../celib-*3.[[0-9]]* 2>/dev/null` \ 4014 - ${srcdir}/../celib-palm-3.0 \ 4015 - ${srcdir}/../celib \ 4016 - `ls -dr ${srcdir}/../celib-*3.[[0-9]]* 2>/dev/null` \ 4017 - ; do 4018 - if test -d "$i/inc" ; then 4019 - ac_cv_c_celibconfig=`(cd $i; pwd)` 4020 - break 4021 - fi 4022 - done 4023 - fi 4024 - ]) 4025 - if test x"${ac_cv_c_celibconfig}" = x ; then 4026 - AC_MSG_ERROR([Cannot find celib support library directory]) 4027 - else 4028 - no_celib= 4029 - CELIB_DIR=${ac_cv_c_celibconfig} 4030 - CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'` 4031 - AC_MSG_RESULT([found $CELIB_DIR]) 4032 - fi 4033 - fi 4034 -]) 4035 - 4036 3908 #------------------------------------------------------------------------ 4037 3909 # TEA_INSTALLER -- 4038 3910 # 4039 3911 # Configure the installer. 4040 3912 # 4041 3913 # Arguments: 4042 3914 # none
Changes to tdom.m4.
200 200 if test "$tcl_ok" = "yes" ; then 201 201 AC_MSG_RESULT([yes]) 202 202 AC_DEFINE(TDOM_LESS_NS) 203 203 else 204 204 AC_MSG_RESULT([no]) 205 205 fi 206 206 ]) 207 + 208 +#------------------------------------------------------------------------ 209 +# TDOM_ENABLE_SCHEMA -- 210 +# 211 +# Building with validation features. 212 +# 213 +# Arguments: 214 +# None 215 +# 216 +# Results: 217 +# 218 +# Adds the following arguments to configure: 219 +# --enable-validation=yes|no 220 +# 221 +# Defines the following vars: 222 +# 223 +# Sets the following vars: 224 +# 225 +#------------------------------------------------------------------------ 226 + 227 +AC_DEFUN(TDOM_ENABLE_SCHEMA, [ 228 + AC_MSG_CHECKING([whether to enable valiation features]) 229 + AC_ARG_ENABLE(schema, 230 + AC_HELP_STRING([--enable-schema], 231 + [build with valiation features (default: on)]), 232 + [tcl_ok=$enableval], [tcl_ok=yes]) 233 + 234 + if test "${enable_schema+set}" = set; then 235 + enableval="$enable_schema" 236 + tcl_ok=$enableval 237 + else 238 + tcl_ok=yes 239 + fi 240 + 241 + if test "$tcl_ok" = "no" ; then 242 + AC_MSG_RESULT([no]) 243 + AC_DEFINE(TDOM_NO_SCHEMA) 244 + else 245 + AC_MSG_RESULT([yes]) 246 + fi 247 +]) 207 248 208 249 #------------------------------------------------------------------------ 209 250 # TDOM_ENABLE_HTML5 -- 210 251 # 211 252 # Building with gumbo support for HTML5 parsing (dom parse -html5) 212 253 # 213 254 # Arguments: ................................................................................ 221 262 # Defines the following vars: 222 263 # 223 264 # Sets the following vars: 224 265 # 225 266 #------------------------------------------------------------------------ 226 267 227 268 AC_DEFUN(TDOM_ENABLE_HTML5, [ 269 + AC_PATH_TOOL([PKG_CONFIG],[pkg-config]) 228 270 AC_MSG_CHECKING([whether to enable support for HTML5 parsing (using gumbo)]) 229 271 AC_ARG_ENABLE(html5, 230 272 AC_HELP_STRING([--enable-html5], 231 273 [build with HTML5 parsing support (default: off)]), 232 274 [tcl_ok=$enableval], [tcl_ok=no]) 233 275 234 276 if test "${enable_html5+set}" = set; then ................................................................................ 237 279 else 238 280 tcl_ok=no 239 281 fi 240 282 HTML5_LIBS="" 241 283 HTML5_INCLUDES="" 242 284 if test "$tcl_ok" = "yes" ; then 243 285 # Check if pkg-config is available 244 - PKGCONFIG=no 245 - pkg-config --version > /dev/null 2>&1 && PKGCONFIG=yes 246 - if test "$PKGCONFIG" = no; then 286 + if test "x$PKG_CONFIG" = x; then 247 287 tcl_ok=no 248 288 AC_MSG_ERROR([cannot find pkg-config needed for --enable-html5.]) 249 289 fi 250 290 fi 251 291 if test "$tcl_ok" = "yes" ; then 252 - HAVEGUMBO=`pkg-config --exists gumbo && echo "1"` 292 + HAVEGUMBO=`$PKG_CONFIG --exists gumbo && echo "1"` 253 293 if test "$HAVEGUMBO" = "1" ; then 254 294 AC_MSG_RESULT([yes]) 255 295 AC_DEFINE(TDOM_HAVE_GUMBO) 256 296 if test "${TEA_PLATFORM}" = "windows" ; then 257 - HTML5_LIBS="-Wl,-Bstatic `pkg-config --static --libs gumbo` -Wl,-Bdynamic" 297 + HTML5_LIBS="-Wl,-Bstatic `$PKG_CONFIG --static --libs gumbo` -Wl,-Bdynamic" 258 298 else 259 - HTML5_LIBS="`pkg-config --libs gumbo`" 299 + HTML5_LIBS="`$PKG_CONFIG --libs gumbo`" 260 300 fi 261 - HTML5_INCLUDES="`pkg-config --cflags gumbo`" 301 + HTML5_INCLUDES="`$PKG_CONFIG --cflags gumbo`" 262 302 else 263 303 AC_MSG_ERROR([The required lib gumbo not found]) 264 304 fi 265 305 else 266 306 AC_MSG_RESULT([no]) 267 307 fi 268 308 ]) ................................................................................ 365 405 fi 366 406 esac 367 407 ]) 368 408 if test x"${ac_cv_c_expat}" = x ; then 369 409 AC_MSG_RESULT([Using bundled expat distribution]) 370 410 TEA_ADD_SOURCES([expat/xmlrole.c \ 371 411 expat/xmltok.c \ 372 - expat/xmlparse.c \ 373 - expat/loadlibrary.c]) 412 + expat/xmlparse.c]) 374 413 TEA_ADD_INCLUDES([-I${srcdir}/expat]) 375 414 AC_DEFINE([XML_POOR_ENTROPY], 1, 376 415 [Define to use poor entropy in lack of better source.]) 377 416 else 378 417 AC_MSG_RESULT([Using shared expat found in ${ac_cv_c_expat}]) 379 418 TEA_ADD_INCLUDES(-I${ac_cv_c_expat}/include) 380 419 TEA_ADD_LIBS([-lexpat])
Changes to tests/data/REC-xslt-19991116.xml.
1 1 <?xml version="1.0" encoding="iso-8859-1"?> 2 2 <!-- $Id$ --> 3 3 <!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.0//EN" 4 - "/XML/1998/06/xmlspec-v20.dtd" [ 4 + "xmlspec-v20.dtd" [ 5 5 <!ENTITY XML "http://www.w3.org/TR/REC-xml"> 6 6 <!ENTITY XMLNames "http://www.w3.org/TR/REC-xml-names"> 7 7 <!ENTITY XSLT.ns "http://www.w3.org/1999/XSL/Transform"> 8 8 <!ENTITY XSLTA.ns "http://www.w3.org/1999/XSL/TransformAlias"> 9 9 <!ENTITY XSLFO.ns "http://www.w3.org/1999/XSL/Format"> 10 10 <!ENTITY XHTML.ns "http://www.w3.org/TR/xhtml1/strict"> 11 11 <!ENTITY year "1999"> ................................................................................ 6352 6352 <item><p>a way to group together consecutive nodes having duplicate 6353 6353 subelements or attributes;</p></item> 6354 6354 6355 6355 <item><p>features to make handling of the HTML <code>style</code> 6356 6356 attribute more convenient.</p></item> 6357 6357 6358 6358 </ulist> 6359 + 6360 +<item><p>features to make handling of the HTML <code>style</code> 6361 +attribute more convenient.</p></item> 6359 6362 6360 6363 </inform-div1> 6361 6364 6362 6365 </back> 6363 6366 </spec>
Changes to tests/dom.test.
176 176 dom createDocument test doc 177 177 set result [catch {set doc foo} errMsg] 178 178 lappend result $errMsg 179 179 $doc delete 180 180 unset doc 181 181 set result 182 182 } {1 {can't set "doc": var is read-only}} 183 + 184 +test dom-1.25 {Doc var} { 185 + dom parse <test/> doc 186 + dom parse <test/> doc 187 + unset doc 188 +} {} 189 + 190 +test dom-1.26 {Doc var} { 191 + dom parse <test/> doc 192 + set result [catch {$doc documentElement doc}] 193 + unset doc 194 + set result 195 +} {1} 183 196 184 197 test dom-2.1 {Don't quash white space at start or end of non white space content} { 185 198 set doc [dom parse {<root> 186 199 some content 187 200 </root>}] 188 201 set root [$doc documentElement] 189 202 $root text ................................................................................ 1044 1057 } {0} 1045 1058 1046 1059 test dom-3.41 {isPIValue} { 1047 1060 dom isPIValue "some invalid processing instruction data?>" 1048 1061 } {0} 1049 1062 1050 1063 1064 +test dom-3.43 {clearString} { 1065 + set result [list] 1066 + foreach str { 1067 + \u0001 1068 + a\u0002 1069 + \u0003b 1070 + a\u0004b 1071 + a\u0004\u0005b 1072 + a\u0004c\u0005b 1073 + a\u0004d\u0005\u0006b 1074 + a\u0004d\u0005\uD800\uD801\uD802_foo_bar 1075 + \uD800\uD801\uD802_foo_bar_baz\uD802_didum\uDFFF 1076 + \uD800\uD801\uD802_foo_bar_baz\uD802_didum\uE000 1077 + \u0004\u0005\uDABC 1078 + abc 1079 + } { 1080 + lappend result [dom clearString $str] 1081 + } 1082 + set result 1083 +} [list {} a b ab ab acb adb ad_foo_bar _foo_bar_baz_didum _foo_bar_baz_didum\uE000 {} abc] 1084 + 1051 1085 test dom-4.1 {-useForeignDTD 0} { 1052 1086 set doc [dom parse -useForeignDTD 0 {<root/>}] 1053 1087 $doc delete 1054 1088 } {} 1055 1089 1056 1090 test dom-4.2 {-useForeignDTD 1 with document with internal subset} {need_uri} { 1057 1091 set baseURI [tdom::baseURL [file join [pwd] [file dir [info script]] dom.test]]
Changes to tests/domDoc.test.
314 314 set doc [dom createDocument doc] 315 315 set root [$doc documentElement] 316 316 $root setAttribute attr "foo\"bar" 317 317 set result [$doc asXML -indent none] 318 318 $doc delete 319 319 set result 320 320 } {<doc attr="foo"bar"/>} 321 + 322 +test domDoc-1.32 {asXML -indent tabs} { 323 + set doc [dom parse {<doc><a><b/></a></doc>}] 324 + set result [$doc asXML -indent tabs] 325 + $doc delete 326 + set result 327 +} "<doc>\n\t<a>\n\t\t<b/>\n\t</a>\n</doc>\n" 328 + 329 +test domDoc-1.33 {asXML -indent tabs} { 330 + set doc [dom parse {<doc><a><b/></a><c><d><f/></d></c><g/></doc>}] 331 + set result [$doc asXML -indent tabs] 332 + $doc delete 333 + set result 334 +} "<doc>\n\t<a>\n\t\t<b/>\n\t</a>\n\t<c>\n\t\t<d>\n\t\t\t<f/>\n\t\t</d>\n\t</c>\n\t<g/>\n</doc>\n" 335 + 336 +test domDoc-1.34 {asXML -indent tabs -noEmptyElementTag} { 337 + set doc [dom parse {<doc><a><b/></a><c><d><f/></d></c><g/></doc>}] 338 + set result [$doc asXML -indent tabs -noEmptyElementTag] 339 + $doc delete 340 + set result 341 +} "<doc>\n\t<a>\n\t\t<b></b>\n\t</a>\n\t<c>\n\t\t<d>\n\t\t\t<f></f>\n\t\t</d>\n\t</c>\n\t<g></g>\n</doc>\n" 342 + 343 +test domDoc-1.35 {asXML -indent tabs -indentAttrs tabs} { 344 + set doc [dom parse {<doc><a a1="a1" a2="a2"><b/></a><c><d a1="a1" a2="a2"><f/></d></c><g/></doc>}] 345 + set result [$doc asXML -indent tabs -indentAttrs tabs] 346 + $doc delete 347 + set result 348 +} "<doc>\n\t<a\n\t\ta1=\"a1\"\n\t\ta2=\"a2\">\n\t\t<b/>\n\t</a>\n\t<c>\n\t\t<d\n\t\t\ta1=\"a1\"\n\t\t\ta2=\"a2\">\n\t\t\t<f/>\n\t\t</d>\n\t</c>\n\t<g/>\n</doc>\n" 349 + 350 +test domDoc-1.36 {asXML -indent tabs -indentAttrs <num>} { 351 + set doc [dom parse {<doc><a a1="a1" a2="a2"><b/></a><c><d a1="a1" a2="a2"><f/></d></c><g/></doc>}] 352 + set result [$doc asXML -indent tabs -indentAttrs 2] 353 + $doc delete 354 + set result 355 +} "<doc>\n\t<a\n\t a1=\"a1\"\n\t a2=\"a2\">\n\t\t<b/>\n\t</a>\n\t<c>\n\t\t<d\n\t\t a1=\"a1\"\n\t\t a2=\"a2\">\n\t\t\t<f/>\n\t\t</d>\n\t</c>\n\t<g/>\n</doc>\n" 356 + 357 +test domDoc-1.37 {asHTML -onlyContents} { 358 + set doc [dom parse {<html><body><p>boo</p></body></html>}] 359 + set result [[$doc documentElement] asHTML -onlyContents] 360 + $doc delete 361 + set result 362 +} {<body><p>boo</p></body>} 363 + 364 +test domDoc-1.38 {asHTML -breakLines} { 365 + set doc [dom parse {<html><body><p>boo</p></body></html>}] 366 + set result [$doc asHTML -breakLines] 367 + $doc delete 368 + set result 369 +} {<html 370 +><body 371 +><p 372 +>boo</p></body></html>} 321 373 322 374 set doc [dom parse <root/>] 323 375 324 376 test domDoc-2.1 {publicId - no publicId there} { 325 377 $doc publicId 326 378 } {} 327 379 ................................................................................ 1391 1443 1392 1444 test domDoc-25.4 {selectNodesNamespaces} { 1393 1445 set doc [dom createDocument foo] 1394 1446 set result [catch {$doc selectNodesNamespaces wrong} errMsg] 1395 1447 lappend result $errMsg 1396 1448 $doc delete 1397 1449 set result 1398 -} {1 {The optional argument to the selectNodesNamespaces method must be a 'prefix namespace' pairs list}} 1450 +} {1 {The optional argument to selectNodesNamespaces must be a 'prefix namespace' pairs list}} 1399 1451 1400 1452 test domDoc-25.5 {selectNodesNamespaces} { 1401 1453 set doc [dom parse {<root xmlns="rootdefaultNS"> 1402 1454 <elem1 xmlns="elem1NS"><elem11/></elem1> 1403 1455 <elem2 xmlns="elem2NS"/> 1404 1456 </root>}] 1405 1457 $doc selectNodesNamespaces {default1 rootdefaultNS}
Changes to tests/domNode.test.
1224 1224 unset result 1225 1225 lappend result [[$removedNode nextSibling] nodeName] 1226 1226 lappend result [$removedNode previousSibling] 1227 1227 $doc delete 1228 1228 set result 1229 1229 } {y {}} 1230 1230 1231 +test domNode-12.11 {cloneNode -deep w/ disableOutputEscaping} { 1232 + dom parse "<doc><td/></doc>" doc 1233 + $doc createTextNode "a b" textnode 1234 + $textnode disableOutputEscaping 1 1235 + $doc documentElement root 1236 + $root firstChild td 1237 + $td appendChild $textnode 1238 + $root appendChild [$td cloneNode -deep] 1239 + set result [$doc asXML -indent none] 1240 + $doc delete 1241 + set result 1242 +} {<doc><td>a b</td><td>a b</td></doc>} 1243 + 1231 1244 namespace eval nodeCmds { 1232 1245 dom createNodeCmd elementNode e1 1233 1246 dom createNodeCmd elementNode e2 1234 1247 dom createNodeCmd commentNode c 1235 1248 dom createNodeCmd textNode t 1236 1249 dom createNodeCmd cdataNode cdata 1237 1250 dom createNodeCmd piNode pi ................................................................................ 2382 2395 p:attr1="p:attr1Value" 2383 2396 xmlns:p="ns1"/>}] 2384 2397 set root [$doc documentElement] 2385 2398 set result [$root getAttributeNS "ns1" attr1] 2386 2399 $doc delete 2387 2400 set result 2388 2401 } {p:attr1Value} 2402 + 2403 +test domNode-28.2 {getAttributeNS - default value} { 2404 + set doc [dom parse { 2405 +<root attr1="attr1Value" 2406 + attr2="attr2Value" 2407 + p:attr1="p:attr1Value" 2408 + xmlns:p="ns1"/>}] 2409 + set root [$doc documentElement] 2410 + set result [$root getAttributeNS "not" attr1 "default"] 2411 + $doc delete 2412 + set result 2413 +} {default} 2414 + 2415 +test domNode-28.3 {getAttributeNS - default value} { 2416 + set doc [dom parse { 2417 +<root attr1="attr1Value" 2418 + attr2="attr2Value" 2419 + p:attr1="p:attr1Value" 2420 + xmlns:p="ns1"/>}] 2421 + set root [$doc documentElement] 2422 + set result [$root getAttributeNS "not" notexisting "some default"] 2423 + $doc delete 2424 + set result 2425 +} {some default} 2426 + 2427 +test domNode-28.4 {getAttributeNS - default value} { 2428 + set doc [dom parse { 2429 +<root attr1="attr1Value" 2430 + attr2="attr2Value" 2431 + p:attr1="p:attr1Value" 2432 + xmlns:p="ns1"/>}] 2433 + set root [$doc documentElement] 2434 + set result [$root getAttributeNS "ns1" notexisting "some other default"] 2435 + $doc delete 2436 + set result 2437 +} {some other default} 2389 2438 2390 2439 proc domAppendChild {parent name} { 2391 2440 $parent ownerDocument doc 2392 2441 $doc createElement $name node 2393 2442 $parent appendChild $node 2394 2443 } 2395 2444
Changes to tests/domjson.test.
386 386 387 387 test json-6.5 {asJSON - serialization of control characters} { 388 388 set doc [dom parse -json "\"a\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\u0008\\u0009\\u000A\\u000B\\u000C\\u000D\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F\\u0020b\""] 389 389 set result [$doc asJSON] 390 390 $doc delete 391 391 set result 392 392 } {"a\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f b"} 393 + 394 +test json-6.6 {asJSON -indent} { 395 + set doc [dom parse -json {{"a":{"aa":[1,2,3,4,"abc"]},"b":"bvalue"}}] 396 + set result [$doc asJSON -indent 2] 397 + $doc delete 398 + set result 399 +} {{ 400 + "a": { 401 + "aa": [ 402 + 1, 403 + 2, 404 + 3, 405 + 4, 406 + "abc" 407 + ] 408 + }, 409 + "b": "bvalue" 410 +}} 411 + 412 +test json-6.7 {asJSON -indent} { 413 + set doc [dom parse -json {{"a":{"aa":[1,2,3,4,"abc"]},"b":"bvalue"}}] 414 + set result [$doc asJSON -indent tabs] 415 + $doc delete 416 + set result 417 +} {{ 418 + "a": { 419 + "aa": [ 420 + 1, 421 + 2, 422 + 3, 423 + 4, 424 + "abc" 425 + ] 426 + }, 427 + "b": "bvalue" 428 +}} 393 429 394 430 test json-7.1 {jsonType} { 395 431 set doc [dom parse {<j>foo</j>}] 396 432 set root [$doc documentElement] 397 433 set result [list] 398 434 lappend result [$root asJSON] 399 435 lappend result [$root jsonType]
Changes to tests/entity.test.
124 124 <!DOCTYPE root [ 125 125 <!ATTLIST root fixed CDATA #FIXED "toThis"> 126 126 ]> 127 127 <root/>} 128 128 $parser free 129 129 set ::extrefhandlerCalled 130 130 } {1} 131 + 132 +test entity-3.4 {cget -useForeignDTD} { 133 + set parser [expat entity-4.4 -useForeignDTD 1] 134 + $parser cget -useForeignDTD 135 +} 1 131 136 132 137 proc extrefhandler-4 {args} { 133 138 global notexistendpath 134 139 # Search for a not existing file path 135 140 set base /ae124 136 141 set filename 0 137 142 set path [file join $base $filename]
Changes to tests/loadtdom.tcl.
10 10 # We still support 8.4 to some degree 11 11 package require Tcl 8.4 12 12 } else { 13 13 package require Tcl 8.4- 14 14 } 15 15 package require tcltest 2.2 16 16 namespace import ::tcltest::* 17 +catch {tcltest::loadTestedCommands} 18 + 17 19 if {[catch {package require -exact tdom 0.9.2}]} { 18 20 if {[catch {load [file join [file dir [info script]] ../unix/libtdom0.9.2.so]}]} { 19 21 error "Unable to load the appropriate tDOM version!" 20 22 } 21 23 } 22 24 if {[info commands ::tdom::xmlReadFile] == ""} { 23 25 # tcldomsh without the script library. Source the lib. 24 26 source [file join [file dir [info script]] ../lib tdom.tcl] 25 27 }
Changes to tests/namespace.test.
101 101 $parser parse {<?xml version="1.0"?> 102 102 <x:Test xmlns="http://www.zveno.com/Schemas" 103 103 xmlns:x='urn:schema'><Test/></x:Test> 104 104 } 105 105 list $::result [eval keysort $::nsdecls] 106 106 } {{{} http://www.zveno.com/Schemas x urn:schema urn:schema:Test http://www.zveno.com/Schemas:Test} {}} 107 107 108 +test ns-1.5 {Place of -namespace option in arg list} { 109 + set ::result {} 110 + set ::nsdecls {} 111 + 112 + catch {rename xml::ns-1.5 {}} 113 + set parser [xml::parser ns-1.4 \ 114 + -startnamespacedeclcommand NSDeclStart \ 115 + -namespace \ 116 + -elementstartcommand EStart] 117 + $parser parse {<?xml version="1.0"?> 118 +<x:Test xmlns="http://tdom.org/Schemas" 119 +xmlns:x='urn:schema'><Test/></x:Test> 120 +} 121 + list $::result [eval keysort $::nsdecls] 122 +} {{{} http://tdom.org/Schemas x urn:schema urn:schema:Test http://tdom.org/Schemas:Test} {}} 123 + 108 124 test ns-2.0 {Multiple namespace declarations, same prefix} { 109 125 set ::result {} 110 126 set ::nsdecls {} 111 127 112 128 catch {rename xml::ns-2.0 {}} 113 129 set parser [xml::parser ns-2.0 \ 114 130 -namespace \ ................................................................................ 122 138 <x:Test xmlns:x='urn:schema'> 123 139 <x:z/> 124 140 </x:Test> 125 141 </Test> 126 142 } 127 143 list $::result [eval keysort $::nsdecls] 128 144 } {{Test x http://www.zveno.com/Schemas http://www.zveno.com/Schemas:Test http://www.zveno.com/Schemas:y x urn:schema urn:schema:Test urn:schema:z} {}} 145 + 146 +test ns-3.1 {-namespaceseparator} { 147 + set result "" 148 + 149 + catch {rename xml::ns-3.1 {}} 150 + set parser [xml::parser ns-3.1 \ 151 + -namespace \ 152 + -namespaceseparator = \ 153 + -elementstartcommand EStart] 154 + $parser parse {<?xml version="1.0"?> 155 +<Test> 156 + <x:Test xmlns:x="http://tdom.org/Schemas"> 157 + <x:y/> 158 + </x:Test> 159 + <x:Test xmlns:x='urn:schema'> 160 + <x:z/> 161 + </x:Test> 162 +</Test> 163 +} 164 + set result 165 +} {Test http://tdom.org/Schemas=Test http://tdom.org/Schemas=y urn:schema=Test urn:schema=z} 166 + 167 +test ns-3.2 {-namespaceseparator} { 168 + set result "" 169 + 170 + catch {rename xml::ns-3.2 {}} 171 + set parser [xml::parser ns-3.2 \ 172 + -namespace \ 173 + -namespaceseparator "" \ 174 + -elementstartcommand EStart] 175 + $parser parse {<?xml version="1.0"?> 176 +<Test> 177 + <x:Test xmlns:x="http://tdom.org/Schemas"> 178 + <x:y/> 179 + </x:Test> 180 + <x:Test xmlns:x='urn:schema'> 181 + <x:z/> 182 + </x:Test> 183 +</Test> 184 +} 185 + set result 186 +} "Test http://tdom.org/SchemasTest http://tdom.org/Schemasy urn:schemaTest urn:schemaz" 187 + 188 +test ns-3.3 {-namespaceseparator} { 189 + set result "" 190 + 191 + catch {rename xml::ns-3.3 {}} 192 + set parser [xml::parser ns-3.3 \ 193 + -namespace \ 194 + -namespaceseparator \x00 \ 195 + -elementstartcommand EStart] 196 + $parser parse {<?xml version="1.0"?> 197 +<Test> 198 + <x:Test xmlns:x="http://tdom.org/Schemas"> 199 + <x:y/> 200 + </x:Test> 201 + <x:Test xmlns:x='urn:schema'> 202 + <x:z/> 203 + </x:Test> 204 +</Test> 205 +} 206 + set result 207 +} "Test http://tdom.org/SchemasTest http://tdom.org/Schemasy urn:schemaTest urn:schemaz" 208 + 209 +test ns-3.4 {-namespaceseparator} { 210 + catch {rename xml::ns-3.4 {}} 211 + set parser [xml::parser ns-3.4 \ 212 + -namespaceseparator =] 213 + $parser cget -namespaceseparator 214 +} = 129 215 130 216 foreach parser [info commands ns-*] { 131 217 $parser free 132 218 } 133 219 134 220 # cleanup 135 221 ::tcltest::cleanupTests 136 222 return
Changes to tests/parser.test.
204 204 set result 205 205 } {0} 206 206 207 207 test parser-1.17 {parser delete} { 208 208 expat parser-1.17 209 209 parser-1.17 delete 210 210 } {} 211 + 212 +proc cdh-1.18 {data} { 213 + if {[string trim $data] ne ""} { 214 + append ::result "cdh:$data" 215 + } 216 +} 217 +proc dh-1.18 {data} { 218 + if {[string trim $data] ne ""} { 219 + append ::result "dh:$data" 220 + } 221 +} 222 + 223 +test parser-1.18 {parser option -noexpand} { 224 + catch {rename parser-1.18 {}} 225 + set parser [expat parser-1.18] 226 + $parser configure \ 227 + -noexpand 1 \ 228 + -defaultcommand dh-1.18 \ 229 + -characterdatacommand cdh-1.18 230 + set result "" 231 + $parser parse {<!DOCTYPE xml [ 232 + <!ELEMENT xml (#PCDATA) > 233 + <!ENTITY xxx "this was the xxx entity"> 234 + ]> 235 + <xml>foo&xxx;bar</xml>} 236 + set result 237 +} {cdh:foodh:&xxx;cdh:bar} 238 + 239 +test parser-1.19 {parser option -noexpand} { 240 + catch {rename parser-1.19 {}} 241 + set parser [expat parser-1.19] 242 + $parser configure \ 243 + -noexpand 0 \ 244 + -defaultcommand dh-1.18 \ 245 + -characterdatacommand cdh-1.18 246 + set result "" 247 + $parser parse {<!DOCTYPE xml [ 248 + <!ELEMENT xml (#PCDATA) > 249 + <!ENTITY xxx "this was the xxx entity"> 250 + ]> 251 + <xml>foo&xxx;bar</xml>} 252 + set result 253 +} {cdh:foothis was the xxx entitybar} 254 + 255 +test parser-1.20 {parser option -noexpand} { 256 + catch {rename parser-1.20 {}} 257 + set parser [expat parser-1.20] 258 + $parser configure \ 259 + -noexpand 1 \ 260 + -characterdatacommand cdh-1.18 261 + set result "" 262 + $parser parse {<!DOCTYPE xml [ 263 + <!ELEMENT xml (#PCDATA) > 264 + <!ENTITY xxx "this was the xxx entity"> 265 + ]> 266 + <xml>foo&xxx;bar</xml>} 267 + set result 268 +} {cdh:foocdh:bar} 269 + 270 +test parser-1.21 {parser option -noexpand} { 271 + catch {rename parser-1.21 {}} 272 + set parser [expat parser-1.21] 273 + $parser configure \ 274 + -noexpand 1 \ 275 + -defaultcommand dh-1.18 276 + set result "" 277 + $parser parse {<!DOCTYPE xml [ 278 + <!ELEMENT xml (#PCDATA) > 279 + <!ENTITY xxx "this was the xxx entity"> 280 + ]> 281 + <xml>foo&xxx;bar</xml>} 282 + set result 283 +} {dh:&xxx;} 284 + 285 +test parser-1.22 {parser option -noexpand} { 286 + catch {rename parser-1.22 {}} 287 + set parser [expat parser-1.18] 288 + $parser configure \ 289 + -noexpand 1 \ 290 + -defaultcommand dh-1.18 291 + set result "" 292 + $parser parse {<!DOCTYPE xml [ 293 + <!ELEMENT xml (#PCDATA) > 294 + <!ENTITY xxx "this was the xxx entity"> 295 + ]> 296 + <xml>foo&xxx;bar</xml>} 297 + set result 298 +} {dh:&xxx;} 299 + 300 +test parser-1.23 {Unknown option flag} { 301 + catch {rename xml::parser-1.23 {}} 302 + catch { 303 + set parser [xml::parser parser-1.23 \ 304 + -elementstartcommand EStart \ 305 + -boo] 306 + } 307 +} 1 308 + 309 +test parser-1.24 {Missing option argument} { 310 + catch {rename xml::parser-1.24 {}} 311 + catch { 312 + set parser [xml::parser parser-1.23 \ 313 + -elementstartcommand] 314 + 315 + } 316 +} 1 211 317 212 318 # Test break return code from callback 213 319 214 320 test parser-2.1 {break in callback} { 215 321 catch {unset ::started} 216 322 217 323 catch {rename parser-2.1 {}} ................................................................................ 622 728 global result 623 729 append result [$parser currentmarkup] 624 730 } 625 731 626 732 test parser-12.1 {currentmarkup method} { 627 733 catch {unset result} 628 734 set result "" 629 - set p [expat parser-12.1 -noexpand] 735 + set p [expat parser-12.1] 630 736 $p configure \ 631 737 -elementstartcommand [list elementstart-12.1 $p] \ 632 738 -elementendcommand [list elementend-12.1 $p] 633 739 $p parse {<root rootatt="rootatt">text<a 634 740 a_att1="a_att1" 635 741 a_att2 = "a_att2"/><b>more text</b></root>} 636 742 $p free
Added tests/schema.test.
more than 10,000 changes
Deleted tests/structure.test.
1 -# Features covered: Structure validation 2 -# 3 -# Tested functionalities: 4 -# structure-1.*: Basics, interface 5 -# structure-2.*: Grammar definition ref 6 -# structure-3.*: Grammar definition choice 7 -# structure-4.*: Script level validation with event 8 -# structure-5.*: dom parse -validateCmd 9 -# structure-6.*: expat parser -validateCmd 10 -# structure-7.*: Validation checks. 11 -# structure-8.*: tdom::structure validate method 12 -# 13 -# Copyright (c) 2018 Rolf Ade. 14 - 15 -source [file join [file dir [info script]] loadtdom.tcl] 16 - 17 -test structure-1.1 {create} { 18 - tdom::structure create grammar 19 - grammar start doc 20 - grammar delete 21 -} {} 22 - 23 -test structure-1.2 {grammar cmd outside context} { 24 - catch {tdom::structure::element} 25 -} {1} 26 - 27 -test structure-1.3 {grammar cmd} { 28 - tdom::structure create grammar 29 - grammar defpattern somePattern { 30 - element foo ! 31 - } 32 - grammar delete 33 -} {} 34 - 35 -test structure-1.4 {grammar cmd} { 36 - tdom::structure create grammar 37 - grammar defpattern somePattern { 38 - for {set i 0} {$i < 100} {incr i} { 39 - element foo$i ! 40 - } 41 - } 42 - grammar delete 43 -} {} 44 - 45 -test structure-1.5 {grammar cmd} { 46 - tdom::structure create grammar 47 - grammar defelement doc { 48 - element elm1 49 - element elm2 * 50 - } 51 - grammar defelement elm1 empty 52 - grammar defelement elm2 empty 53 - grammar delete 54 -} {} 55 - 56 -test structure-1.6 {quants} { 57 - tdom::structure create grammar 58 - grammar defelement doc { 59 - element elm1 60 - element elm2 * 61 - element elm3 ! 62 - element elm4 + 63 - element elm5 ? 64 - element elm6 1 65 - element elm7 5 66 - element elm8 12 67 - element elm9 {0 3} 68 - element elm9 {1 12} 69 - element elm10 "8 " 70 - } 71 - grammar delete 72 -} {} 73 - 74 -test structure-1.7 {quants} { 75 - tdom::structure create grammar 76 - grammar defelement doc { 77 - for {set i 0} {$i < 100} {incr i} { 78 - element elm$i [list $i [expr {$i + 1}]] 79 - } 80 - } 81 - grammar delete 82 -} {} 83 - 84 -test structure-1.8 {Same element name in different Namespaces} { 85 - tdom::structure create grammar 86 - grammar defelement doc { 87 - element elm1 88 - element elm2 89 - } 90 - grammar defelement doc ns1 { 91 - # Forward defined element inherits child namespace 92 - element elm1 93 - element elm2 94 - } 95 - grammar defelement doc ns2 { 96 - # Forward defined element inherits child namespace 97 - element elm1 98 - element elm2 99 - } 100 - grammar defelement elm1 ns2 empty 101 - grammar defelement elm2 ns2 any 102 - set result [catch { 103 - grammar defelement elm1 ns1 { 104 - choice { 105 - element fooElem 106 - element barElem + 107 - } 108 - error 109 - } 110 - }] 111 - grammar defelement elm1 ns1 any 112 - grammar defelement elm2 ns1 empty 113 - grammar delete 114 - set result 115 -} 1 116 - 117 -test structure-1.9 {Same element name in different Namespaces} { 118 - tdom::structure create grammar 119 - set result [catch { 120 - grammar defelement doc { 121 - element elm1 122 - element elm2 123 - } 124 - grammar defelement doc ns1 { 125 - # Forward defined element inherits child namespace 126 - element elm1 127 - element elm2 128 - } 129 - grammar defelement doc ns2 { 130 - # Forward defined element inherits child namespace 131 - element elm1 132 - element elm2 133 - } 134 - grammar defelement elm1 ns2 empty 135 - grammar defelement elm2 ns2 any 136 - grammar defelement elm1 ns1 { 137 - choice { 138 - element fooElem 139 - element barElem + 140 - } 141 - error 142 - } 143 - }] 144 - grammar delete 145 - set result 146 -} 1 147 - 148 -test structure-1.10 {Local element definition} { 149 - tdom::structure create grammar 150 - grammar defelement doc { 151 - element elm1 152 - element elm1 1 { 153 - element a 154 - element b 155 - } 156 - } 157 - grammar defelement c text 158 - grammar defelement d text 159 - grammar defelement elm1 { 160 - element c 161 - element d 162 - } 163 - grammar delete 164 -} {} 165 - 166 -test structure-1.11 {define} { 167 - tdom::structure create grammar 168 - set result [catch {grammar define { 169 - element elm1 170 - }} errMsg] 171 - grammar delete 172 - lappend result $errMsg 173 -} {1 {Command not allowed at top level in grammar define evaluation}} 174 - 175 -test structure-1.12 {define} { 176 - tdom::structure create grammar 177 - set result [catch {grammar define { 178 - defelement elm1 { 179 - element a 180 - element b 181 - } 182 - element elm1 183 - }} errMsg] 184 - grammar delete 185 - lappend result $errMsg 186 -} {1 {Command not allowed at top level in grammar define evaluation}} 187 - 188 -test structure-2.1 {grammar definition: ref} { 189 - tdom::structure create grammar 190 - grammar defpattern thisPattern { 191 - element a 192 - element b 193 - } 194 - grammar defpattern thatPattern { 195 - element c 196 - element d 197 - } 198 - grammar defelement doc { 199 - ref thisPattern 200 - ref thatPattern ? 201 - } 202 - grammar delete 203 -} {} 204 - 205 -test structure-2.2 {grammar definition: ref} { 206 - tdom::structure create grammar 207 - set result [grammar nrForwardDefinitions] 208 - grammar defelement doc { 209 - ref thisPattern 210 - ref thatPattern ? 211 - } 212 - lappend result [grammar nrForwardDefinitions] 213 - grammar delete 214 - set result 215 -} {0 2} 216 - 217 -test structure-3.1 {grammar definition: choice} { 218 - tdom::structure create grammar 219 - grammar defelement doc { 220 - element elm 221 - choice { 222 - element fooElem 223 - element barElem + 224 - } 225 - choice ? { 226 - element one {2 3} 227 - element two 228 - } 229 - element three 230 - } 231 - grammar delete 232 -} {} 233 - 234 -test structure-3.2 {grammar definition: choice} { 235 - tdom::structure create grammar 236 - grammar defpattern thisPattern { 237 - element elm 238 - choice { 239 - element fooElem 240 - element barElem + 241 - } 242 - choice ? { 243 - element one {2 3} 244 - element two 245 - } 246 - element three 247 - } 248 - grammar delete 249 -} {} 250 - 251 -proc pullValidate {g xml} { 252 - tdom::pullparser pp 253 - pp input $xml 254 - while {[pp next] ne "END_DOCUMENT"} { 255 - switch [pp state] { 256 - "START_TAG" { 257 - $g event start [pp tag] 258 - } 259 - "END_TAG" { 260 - $g event end 261 - } 262 - "TEXT" { 263 - $g event text [pp text] 264 - } 265 - } 266 - } 267 -} 268 - 269 -test structure-4.1 {validation} { 270 - tdom::structure create grammar 271 - grammar defelement doc { 272 - element e1 273 - element e2 * 274 - } 275 - foreach e {e1 e2} { 276 - grammar defelement $e {} 277 - } 278 - pullValidate grammar { 279 - <doc><e1/></doc> 280 - } 281 - if {[grammar state] ne "FINISHED"} { 282 - error "Wrong state." 283 - } 284 - grammar reset 285 - pullValidate grammar { 286 - <doc><e1/><e2/></doc> 287 - } 288 - if {[grammar state] ne "FINISHED"} { 289 - error "Wrong state." 290 - } 291 - grammar reset 292 - pullValidate grammar { 293 - <doc><e1/><e2/><e2/><e2/></doc> 294 - } 295 - if {[grammar state] ne "FINISHED"} { 296 - error "Wrong state." 297 - } 298 - grammar delete 299 -} {} 300 - 301 -test structure-5.1 {dom parse -validateCmd} { 302 - set result [catch { 303 - [dom parse -validateCmd tdom::structure <doc/>] 304 - }] 305 -} 1 306 - 307 -test structure-5.2 {dom parse -validateCmd} { 308 - tdom::structure create grammar 309 - grammar defelement doc { 310 - element e1 311 - element e2 * 312 - } 313 - foreach e {e1 e2} { 314 - grammar defelement $e {} 315 - } 316 - dom parse -validateCmd grammar { 317 - <doc><e1/></doc> 318 - } doc 319 - if {[grammar state] ne "FINISHED"} { 320 - error "Wrong state." 321 - } 322 - $doc delete 323 - grammar reset 324 - dom parse -validateCmd grammar { 325 - <doc><e1/><e2/></doc> 326 - } doc 327 - if {[grammar state] ne "FINISHED"} { 328 - error "Wrong state." 329 - } 330 - $doc delete 331 - grammar reset 332 - dom parse -validateCmd grammar { 333 - <doc><e1/><e2/><e2/><e2/></doc> 334 - } doc 335 - if {[grammar state] ne "FINISHED"} { 336 - error "Wrong state." 337 - } 338 - $doc delete 339 - grammar delete 340 -} {} 341 - 342 -proc structure-5.3 {base systemId publicId} { 343 - return [list "string" "" "<foo/>"] 344 -} 345 - 346 -test structure-5.3 {dom parse -validateCmd} { 347 - tdom::structure create grammar 348 - grammar defelement doc { 349 - element e1 350 - element e2 * 351 - } 352 - foreach e {e1 e2} { 353 - grammar defelement $e {} 354 - } 355 - set result [catch {dom parse -validateCmd grammar \ 356 - -externalentitycommand structure-5.3 { 357 - <!DOCTYPE doc [ 358 - <!ENTITY e1 PUBLIC "e1" "e1.xml"> 359 - ]> 360 - <doc>&e1;</doc>} doc} errMsg] 361 - grammar delete 362 - set result 363 -} 1 364 - 365 -test structure-5.4 {define} { 366 - tdom::structure create grammar 367 - grammar define { 368 - defelement elm1 { 369 - element a 370 - element b 371 - } 372 - defelement a { 373 - element c 374 - } 375 - defelement b {} 376 - defelement c {empty} 377 - } 378 - set doc [dom parse -validateCmd grammar { 379 - <elm1><a><c/></a><b/></elm1> 380 - }] 381 - $doc delete 382 - grammar delete 383 -} {} 384 - 385 - 386 -test structure-6.1 {expat parser with -validateCmd} { 387 - tdom::structure create grammar 388 - grammar defelement doc { 389 - element e1 390 - element e2 * 391 - } 392 - foreach e {e1 e2} { 393 - grammar defelement $e {} 394 - } 395 - ::xml::parser p -validateCmd grammar 396 - set result [catch {p parse {<doc><e2/></doc>}} errMsg] 397 - p delete 398 - grammar delete 399 - set result 400 -} 1 401 - 402 -test structure-7.1 {group} { 403 - tdom::structure create grammar 404 - grammar defelement doc { 405 - element e1 406 - group ! { 407 - element e1 408 - element e2 409 - } 410 - group ! { 411 - element e1 412 - element e2 413 - } 414 - element e2 * 415 - } 416 - foreach e {e1 e2} { 417 - grammar defelement $e {} 418 - } 419 - dom parse -validateCmd grammar { 420 - <doc><e1/><e1/><e2/><e1/><e2/><e2/><e2/><e2/></doc> 421 - } doc 422 - $doc delete 423 - if {[grammar state] ne "FINISHED"} { 424 - error "Wrong state." 425 - } 426 - grammar delete 427 -} {} 428 - 429 -test structure-7.1.1 {group} { 430 - tdom::structure create grammar 431 - grammar define { 432 - defelement doc { 433 - element e1 434 - group ! { 435 - element e1 436 - element e2 437 - } 438 - group ! { 439 - element e1 440 - element e2 441 - } 442 - element e2 * 443 - } 444 - foreach e {e1 e2} { 445 - defelement $e {} 446 - } 447 - } 448 - dom parse -validateCmd grammar { 449 - <doc><e1/><e1/><e2/><e1/><e2/><e2/><e2/><e2/></doc> 450 - } doc 451 - $doc delete 452 - if {[grammar state] ne "FINISHED"} { 453 - error "Wrong state." 454 - } 455 - grammar delete 456 -} {} 457 - 458 -test structure-7.2 {group} { 459 - tdom::structure create grammar 460 - grammar defelement doc { 461 - element e1 462 - group 2 { 463 - element e1 464 - element e2 465 - } 466 - element e2 * 467 - } 468 - foreach e {e1 e2} { 469 - grammar defelement $e {} 470 - } 471 - dom parse -validateCmd grammar { 472 - <doc><e1/><e1/><e2/><e1/><e2/><e2/><e2/><e2/></doc> 473 - } doc 474 - $doc delete 475 - if {[grammar state] ne "FINISHED"} { 476 - error "Wrong state." 477 - } 478 - grammar delete 479 -} {} 480 - 481 -test structure-7.2.1 {group} { 482 - tdom::structure create grammar 483 - grammar define { 484 - defelement doc { 485 - element e1 486 - group 2 { 487 - element e1 488 - element e2 489 - } 490 - element e2 * 491 - } 492 - foreach e {e1 e2} { 493 - grammar defelement $e {} 494 - } 495 - } 496 - dom parse -validateCmd grammar { 497 - <doc><e1/><e1/><e2/><e1/><e2/><e2/><e2/><e2/></doc> 498 - } doc 499 - $doc delete 500 - if {[grammar state] ne "FINISHED"} { 501 - error "Wrong state." 502 - } 503 - grammar delete 504 -} {} 505 - 506 -test structure-7.3 {group with inline defined element} { 507 - tdom::structure create grammar 508 - grammar define { 509 - defelement doc { 510 - element e1 511 - group 2 { 512 - element e1 1 { 513 - element e2 514 - } 515 - element e2 516 - } 517 - element e2 * 518 - } 519 - foreach e {e1 e2} { 520 - grammar defelement $e {} 521 - } 522 - } 523 - dom parse -validateCmd grammar { 524 - <doc><e1/><e1><e2/></e1><e2/><e1><e2/></e1><e2/><e2/><e2/><e2/></doc> 525 - } doc 526 - $doc delete 527 - if {[grammar state] ne "FINISHED"} { 528 - error "Wrong state." 529 - } 530 - grammar delete 531 -} {} 532 - 533 -test structure-7.4 {group with inline defined element} { 534 - tdom::structure create grammar 535 - grammar define { 536 - defelement doc { 537 - group { 538 - element e1 539 - element e1 1 { 540 - element e2 541 - } 542 - element e2 543 - } 544 - } 545 - foreach e {e1 e2} { 546 - grammar defelement $e {} 547 - } 548 - } 549 - dom parse -validateCmd grammar { 550 - <doc><e1/><e1><e2/></e1><e2/></doc> 551 - } doc 552 - $doc delete 553 - if {[grammar state] ne "FINISHED"} { 554 - error "Wrong state." 555 - } 556 - grammar delete 557 -} {} 558 - 559 -test structure-7.5 {group with inline defined element} { 560 - tdom::structure create grammar 561 - grammar define { 562 - defelement doc { 563 - group { 564 - element e1 565 - element e1 1 { 566 - element e2 567 - } 568 - element e2 569 - } 570 - } 571 - foreach e {e1 e2} { 572 - grammar defelement $e {} 573 - } 574 - } 575 - ::xml::parser p -validateCmd grammar 576 - p parse { 577 - <doc><e1/><e1><e2/></e1><e2/></doc> 578 - } 579 - p delete 580 - if {[grammar state] ne "FINISHED"} { 581 - error "Wrong state." 582 - } 583 - grammar delete 584 -} {} 585 - 586 -test structure-7.6 {nested groups via refs} { 587 - tdom::structure create grammar 588 - grammar define { 589 - defpattern a foouri { 590 - group { 591 - element e1 592 - element e1 1 { 593 - element e2 594 - } 595 - element e2 596 - } 597 - element e3 ? 598 - } 599 - defpattern b foouri { 600 - element b1 * 601 - group 2 { 602 - element b2 603 - ref a 604 - } 605 - } 606 - foreach e {e1 e2 e3 b1 b2} { 607 - defelement $e foouri {} 608 - } 609 - defelement doc foouri { 610 - group { 611 - ref a 612 - ref b 2 613 - } 614 - } 615 - } 616 - set doc [dom parse -validateCmd grammar { 617 - <doc xmlns="foouri"> 618 - <!-- ref a start --> 619 - <e1/> 620 - <e1> 621 - <e2/> 622 - </e1> 623 - <e2/> 624 - <e3/> 625 - <!-- ref a end --> 626 - <!-- ref b start --> 627 - <b1/> 628 - <b1/> 629 - <b2/> 630 - <!-- inside ref b: ref a start --> 631 - <e1/> 632 - <e1> 633 - <e2/> 634 - </e1> 635 - <e2/> 636 - <!-- inside ref b: ref a end --> 637 - <!-- ref b end --> 638 - <!-- ref b start --> 639 - <b2/> 640 - <!-- inside ref b: ref a start --> 641 - <e1/> 642 - <e1> 643 - <e2/> 644 - </e1> 645 - <e2/> 646 - <e3/> 647 - <!-- inside ref a: ref b end --> 648 - <!-- ref b end --> 649 - </doc> 650 - }] 651 - $doc delete 652 - if {[grammar state] ne "FINISHED"} { 653 - error "Wrong state." 654 - } 655 - grammar delete 656 -} {} 657 - 658 -test structure-7.7 {nested groups via refs} { 659 - tdom::structure create grammar 660 - grammar define { 661 - defpattern a { 662 - group { 663 - element e1 664 - element e1 1 { 665 - element e2 666 - } 667 - element e2 668 - } 669 - element e3 ? 670 - } 671 - defpattern b { 672 - element b1 * 673 - group 2 { 674 - element b2 675 - ref a 676 - } 677 - } 678 - foreach e {e1 e2 e3 b1 b2} { 679 - defelement $e {} 680 - } 681 - defelement doc { 682 - group { 683 - ref b 684 - } 685 - } 686 - } 687 - set doc [dom parse -validateCmd grammar { 688 - <doc> 689 - <!-- ref b start --> 690 - <b2/> 691 - <!-- inside ref b: ref a start --> 692 - <e1/> 693 - <e1> 694 - <e2/> 695 - </e1> 696 - <e2/> 697 - <e3/> 698 - <!-- inside ref b: ref a end --> 699 - <!-- inside ref b: ref a start --> 700 - <b2/> 701 - <e1/> 702 - <e1> 703 - <e2/> 704 - </e1> 705 - <e2/> 706 - <e3/> 707 - <!-- inside ref b: ref a end --> 708 - <!-- ref b end --> 709 - </doc> 710 - }] 711 - $doc delete 712 - if {[grammar state] ne "FINISHED"} { 713 - error "Wrong state." 714 - } 715 - grammar delete 716 -} {} 717 - 718 -test structure-7.8 {nested groups via refs} { 719 - tdom::structure create grammar 720 - grammar define { 721 - defpattern a foouri { 722 - group { 723 - element e1 724 - element e1 1 { 725 - element e2 726 - } 727 - element e2 728 - } 729 - element e3 ? 730 - } 731 - foreach e {e1 e2 e3 b1 b2} { 732 - defelement $e foouri {} 733 - } 734 - defelement doc foouri { 735 - group { 736 - ref a 737 - } 738 - } 739 - } 740 - set doc [dom parse -validateCmd grammar { 741 - <doc xmlns="foouri"> 742 - <!-- ref a start --> 743 - <e1/> 744 - <e1> 745 - <e2/> 746 - </e1> 747 - <e2/> 748 - <e3/> 749 - <!-- ref a end --> 750 - </doc> 751 - }] 752 - $doc delete 753 - if {[grammar state] ne "FINISHED"} { 754 - error "Wrong state." 755 - } 756 - grammar delete 757 -} {} 758 - 759 -test structure-7.9 {loop over seq} { 760 - tdom::structure create grammar 761 - grammar define { 762 - defelement doc { 763 - group ? { 764 - element a 765 - element b 766 - } 767 - element c 768 - } 769 - foreach e {a b c} { 770 - defelement $e {} 771 - } 772 - } 773 - set result [grammar validate <doc><a/><b/><a/><b/><c/></doc>] 774 - grammar delete 775 - set result 776 -} 1 777 - 778 -test structure-7.10 {loop over seq} {knownBug} { 779 - tdom::structure create grammar 780 - grammar define { 781 - defelement doc { 782 - group 2 { 783 - element a 784 - element b 785 - } 786 - element c 787 - foreach e {a b c} { 788 - defelement $e {} 789 - } 790 - } 791 - } 792 - set result [grammar validate <doc><a/><b/><c/></doc>] 793 - grammar delete 794 - set result 795 -} 1 796 - 797 -test structure-8.1 {validate method} { 798 - tdom::structure create grammar 799 - grammar defelement doc { 800 - element e1 801 - element e2 * 802 - } 803 - foreach e {e1 e2} { 804 - grammar defelement $e {} 805 - } 806 - set result [grammar validate <doc><e1/></doc>] 807 - if {[grammar state] ne "FINISHED"} { 808 - error "Wrong state." 809 - } 810 - grammar reset 811 - lappend result [grammar validate <doc><e1/><e1/></doc> errMsg] 812 - grammar delete 813 - set result 814 -} {1 0} 815 - 816 -test structure-8.2 {validate method} { 817 - tdom::structure create grammar 818 - grammar defelement doc foouri { 819 - element e1 820 - element e2 * 821 - } 822 - foreach e {e1 e2} { 823 - grammar defelement $e foouri {} 824 - } 825 - set result [grammar validate {<doc xmlns="foouri"><e1/></doc>}] 826 - if {[grammar state] ne "FINISHED"} { 827 - error "Wrong state." 828 - } 829 - grammar reset 830 - lappend result [grammar validate {<doc xmlns="foouri"><e1/><e1/></doc>} errMsg] 831 - grammar delete 832 - set result 833 -} {1 0} 834 - 835 -test structure-9.1 {choice} { 836 - tdom::structure create grammar 837 - grammar define { 838 - defelement doc foouri { 839 - choice * { 840 - element e1 841 - element e2 * 842 - } 843 - } 844 - foreach e {e1 e2} { 845 - defelement $e foouri {} 846 - } 847 - } 848 - grammar validate {<doc xmlns="foouri"/>} 849 - grammar reset 850 - grammar validate {<doc xmlns="foouri"><e1/></doc>} 851 - grammar reset 852 - grammar validate {<doc xmlns="foouri"><e1/><e1/></doc>} 853 - grammar reset 854 - grammar validate {<doc xmlns="foouri"><e1/><e2/><e1/></doc>} 855 - grammar delete 856 -} {} 857 -
Changes to tests/xpath.bench.
77 77 } 78 78 } -body { 79 79 $root selectNodes {e1[myfunc() = '']} 80 80 } -post { 81 81 $doc delete 82 82 } 83 83 84 +} 85 + 86 +foreach nrOf {1 10 50 100} { 87 + 88 + bench -desc "string(<nodeset with $nrOf nodes>)" -pre { 89 + dom createDocument root doc 90 + $doc documentElement root 91 + $root appendFromScript { 92 + for {set x 0} {$x < $nrOf} {incr x} { 93 + e1 94 + } 95 + } 96 + $root selectNodes -cache 1 string(e1) 97 + } -body { 98 + $root selectNodes -cache 1 string(e1) 99 + } -post { 100 + $doc delete 101 + } 102 + 103 +} 104 + 105 +foreach nrOf {1 10 50 100} { 106 + 107 + bench -desc "count(<nodeset with $nrOf nodes>)" -pre { 108 + dom createDocument root doc 109 + $doc documentElement root 110 + $root appendFromScript { 111 + for {set x 0} {$x < $nrOf} {incr x} { 112 + e1 113 + } 114 + } 115 + $root selectNodes -cache 1 count(e1) 116 + } -body { 117 + $root selectNodes -cache 1 count(e1) 118 + } -post { 119 + $doc delete 120 + } 121 + 84 122 } 85 123 86 124 dom createNodeCmd elementNode e2 87 125 88 126 dom createDocument root doc 89 127 $doc documentElement root 90 128 $root appendFromScript {
Changes to tests/xpath.test.
544 544 545 545 test xpath-5.1 {erroneous XPath expr: missing right brace in predicate} { 546 546 set result [catch {$root selectNodes {*[1}} errMsg] 547 547 list $result $errMsg 548 548 } {1 {Predicate: Expected "RBRACKET" for '*[1' 549 549 550 550 Parsed symbols: 551 - 0 WCARDNAME 0 00000.000 0 * 552 - 1 LBRACKET 0 00000.000 1 553 - 2 INTNUMBER 1 00001.000 2 }} 551 + 0 WCARDNAME 0 000000000 0 * 552 + 1 LBRACKET 0 000000000 1 553 + 2 INTNUMBER 1 000000001 2 }} 554 554 555 555 test xpath-5.2 {erroneous XPath expr: missing right brace in predicate} { 556 556 set result [catch {$root selectNodes {*[1][@attr}} errMsg] 557 557 list $result $errMsg 558 558 } {1 {Predicate: Expected "RBRACKET" for '*[1][@attr' 559 559 560 560 Parsed symbols: 561 - 0 WCARDNAME 0 00000.000 0 * 562 - 1 LBRACKET 0 00000.000 1 563 - 2 INTNUMBER 1 00001.000 2 564 - 3 RBRACKET 0 00000.000 3 565 - 4 LBRACKET 0 00000.000 4 566 - 5 ATTRIBUTE 0 00000.000 9 attr}} 561 + 0 WCARDNAME 0 000000000 0 * 562 + 1 LBRACKET 0 000000000 1 563 + 2 INTNUMBER 1 000000001 2 564 + 3 RBRACKET 0 000000000 3 565 + 4 LBRACKET 0 000000000 4 566 + 5 ATTRIBUTE 0 000000000 9 attr}} 567 567 568 568 test xpath-5.3 {erroneous XPath expr: missing left brace in predicate} { 569 569 catch {$root selectNodes {*1]}} 570 570 } {1} 571 571 572 572 test xpath-5.4 {erroneous XPath expr} { 573 573 catch {$root selectNodes {myNS: bar}} errMsg ................................................................................ 1070 1070 set result [catch {$doc selectNodes {a[b %nodeName='another value']}} errMsg] 1071 1071 lappend result $errMsg 1072 1072 $doc delete 1073 1073 set result 1074 1074 } {1 {Predicate: Expected "RBRACKET" for 'a[b %nodeName='another value']' 1075 1075 1076 1076 Parsed symbols: 1077 - 0 WCARDNAME 0 00000.000 0 a 1078 - 1 LBRACKET 0 00000.000 1 1079 - 2 WCARDNAME 0 00000.000 2 b 1080 ---> 3 WCARDNAME 1 00000.000 12 with spaces 1081 - 4 EQUAL 0 00000.000 13 1082 - 5 LITERAL 0 00000.000 28 another value 1083 - 6 RBRACKET 0 00000.000 29 }} 1077 + 0 WCARDNAME 0 000000000 0 a 1078 + 1 LBRACKET 0 000000000 1 1079 + 2 WCARDNAME 0 000000000 2 b 1080 +--> 3 WCARDNAME 1 000000000 12 with spaces 1081 + 4 EQUAL 0 000000000 13 1082 + 5 LITERAL 0 000000000 28 another value 1083 + 6 RBRACKET 0 000000000 29 }} 1084 1084 1085 1085 test xpath-5.47 {Element name injected with tcl variable} { 1086 1086 set doc [dom parse -json {{"a":{"":"the value"},"a":{"":"another value"}}}] 1087 1087 set nodeName "" 1088 1088 set node [$doc selectNodes {a[%nodeName='another value']}] 1089 1089 set result [list] 1090 1090 lappend result [$node nodeName] ................................................................................ 1175 1175 set nodeName1 "a/b" 1176 1176 set result [list] 1177 1177 lappend result [$doc selectNodes string(%nodeName0/%nodeName1)] 1178 1178 lappend result [$doc selectNodes string(a/a/b)] 1179 1179 $doc delete 1180 1180 set result 1181 1181 } {a/b b} 1182 + 1183 +test xpath-5.57 {afl-fuzz found seg fault in reporting error in invalid expr} { 1184 + set doc [dom createDocument doc] 1185 + catch {$doc selectNodes /[string repeat 1 2500]} 1186 + catch {$doc selectNodes /[string repeat 1 250]} 1187 + $doc delete 1188 +} {} 1189 + 1190 +test xpath-5.58 {afl-fuzz found seg fault in reporting error in invalid expr} { 1191 + set doc [dom createDocument doc] 1192 + catch {$doc selectNodes concat([string repeat 1 250],1,1)} 1193 + $doc delete 1194 +} {} 1195 + 1196 +test xpath-5.59 {afl-fuzz found floating point exception in mod calulation} { 1197 + set doc [dom createDocument doc] 1198 + set result [list] 1199 + lappend result [$doc selectNodes "1111111111 mod -1"] 1200 + lappend result [$doc selectNodes "111111111111111111111111111111111111111 mod -1"] 1201 + $doc delete 1202 + set result 1203 +} {0 NaN} 1204 + 1205 +test xpath-5.60 {afl-fuzz found floating point exception in mod calulation} { 1206 + set doc [dom createDocument doc] 1207 + set result [list] 1208 + for {set i 1} {$i < 20} {incr i} { 1209 + for {set j 1} {$j < 20} {incr j} { 1210 + set this [$doc selectNodes "$i mod $j"] 1211 + if {$this != ($i % $j)} { 1212 + lappend result [list $i $j $this [expr "$i % $j"]] 1213 + } 1214 + } 1215 + } 1216 + $doc delete 1217 + set result 1218 +} {} 1182 1219 1183 1220 set doc [dom parse { 1184 1221 <root> 1185 1222 <asub>asub2</asub> 1186 1223 <asub>asub3</asub> 1187 1224 <asub>asub4</asub> 1188 1225 <bsub>bsub1</bsub> ................................................................................ 1197 1234 set result "" 1198 1235 foreach node [$root selectNodes {bsub|asub}] { 1199 1236 append result "[$node text] " 1200 1237 } 1201 1238 set result 1202 1239 } {asub1 asub2 asub3 asub4 bsub1 bsub2 } 1203 1240 1204 -$doc delete 1241 +catch {$doc delete} 1205 1242 1206 1243 1207 1244 set doc [dom parse { 1208 1245 <!-- comment 1 --> 1209 1246 <!-- comment 2 --> 1210 1247 <?api pi data?> 1211 1248 <!-- still not the document element -->
Changes to tests/xslt.test.
1149 1149 catch {$xmldoc xslt $xsltdoc resultDoc} errMsg 1150 1150 $xmldoc delete 1151 1151 $xsltdoc delete 1152 1152 set errMsg 1153 1153 } {The 'current' function is not allowed in Pattern. for '*[current() != 'notthis']' 1154 1154 1155 1155 Parsed symbols: 1156 - 0 WCARDNAME 0 00000.000 0 * 1157 - 1 LBRACKET 0 00000.000 1 1158 - 2 FUNCTION 0 00000.000 8 current 1159 - 3 LPAR 0 00000.000 9 1160 - 4 RPAR 0 00000.000 10 1161 - 5 NOTEQ 0 00000.000 13 1162 - 6 LITERAL 0 00000.000 23 notthis 1163 - 7 RBRACKET 0 00000.000 24 } 1156 + 0 WCARDNAME 0 000000000 0 * 1157 + 1 LBRACKET 0 000000000 1 1158 + 2 FUNCTION 0 000000000 8 current 1159 + 3 LPAR 0 000000000 9 1160 + 4 RPAR 0 000000000 10 1161 + 5 NOTEQ 0 000000000 13 1162 + 6 LITERAL 0 000000000 23 notthis 1163 + 7 RBRACKET 0 000000000 24 } 1164 1164 1165 1165 set xslt-8.2.xml {<?xml version="1.0"?> 1166 1166 <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> 1167 1167 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> 1168 1168 </DocumentProperties> 1169 1169 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> 1170 1170 </OfficeDocumentSettings>
Changes to win/makefile.vc.
39 39 $(TMP_DIR)\domlock.obj \ 40 40 $(TMP_DIR)\domjson.obj \ 41 41 $(TMP_DIR)\tclexpat.obj \ 42 42 $(TMP_DIR)\tcldom.obj \ 43 43 $(TMP_DIR)\tclpull.obj \ 44 44 $(TMP_DIR)\tdomStubInit.obj\ 45 45 $(TMP_DIR)\tdomStubLib.obj \ 46 - $(TMP_DIR)\tdominit.obj \ 47 - $(TMP_DIR)\loadlibrary.obj 46 + $(TMP_DIR)\tdominit.obj 48 47 49 48 PRJ_STUBOBJS = $(TMP_DIR)\tdomStubLib.obj 50 49 51 50 PRJ_DEFINES = \ 52 51 -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE \ 53 52 -DHAVE_MEMMOVE -DXML_DTD=1 -DXML_NS=1 -DTDOM_NO_UNKNOWN_CMD=1 \ 54 53 -DXMLIMPORT=__declspec(dllexport)
Deleted win/mkd.bat.
1 -@echo off 2 -rem RCS: @(#) $Id$ 3 - 4 -if exist %1\nul goto end 5 - 6 -md %1 7 -if errorlevel 1 goto end 8 - 9 -echo Created directory %1 10 - 11 -:end 12 - 13 -
Changes to xe/README.
1 1 2 -XE needs saves the upper input window in the file ~/.xe-input, if 3 -it is called without arguments. Otherwise the first argument 4 -gives the file name for the saved input windos. 2 +XE saves the upper input window in the file ~/.xe-input, if it is 3 +called without arguments. Otherwise the first argument gives the file 4 +name for the saved input windos. 5 5 6 -To start playing with XE copy you could do either: 6 +To start playing with xe you could do either: 7 7 8 8 1) cp xe-input ~/.xe-input 9 9 xe 10 10 11 11 2) xe xe-input 12 12 13 - 14 -Latter should be more appropriate for Wn32 users. 15 -
Changes to xe/xe.
1 -#!/opt/tcl/bin/wish 1 +#!/usr/bin/env wish 2 2 #---------------------------------------------------------------------------- 3 3 # Copyright (c) 1999 - 2000 Jochen C. Loewer (loewerj@hotmail.com) 4 4 #---------------------------------------------------------------------------- 5 5 # 6 6 # A XML/DOM/XPath evaluator/viewer... featuring the Tk text widget. 7 7 # 8 8 # ................................................................................ 19 19 # The Original Code is tDOM. 20 20 # 21 21 # The Initial Developer of the Original Code is Jochen Loewer 22 22 # Portions created by Jochen Loewer are Copyright (C) 1998, 1999 23 23 # Jochen Loewer. All Rights Reserved. 24 24 # 25 25 # Contributor(s): 26 -# 27 -# 28 -# 29 -# $Log$ 30 -# Revision 1.1 2002/02/22 01:05:35 rolf 31 -# Initial revision 32 -# 33 -# 34 -# 35 26 # 36 27 # written by Jochen Loewer 37 28 # December, 1999 38 29 # 39 30 # 40 31 # 41 32 # Contains emacsbinds.tcl: