Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: third_party/libxml/src/xmllint.c

Issue 1193533007: Upgrade to libxml 2.9.2 and libxslt 1.1.28 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no iconv Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libxml/src/xmlcatalog.c ('k') | third_party/libxml/src/xmlmemory.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * xmllint.c : a small tester program for XML input. 2 * xmllint.c : a small tester program for XML input.
3 * 3 *
4 * See Copyright for the status of this software. 4 * See Copyright for the status of this software.
5 * 5 *
6 * daniel@veillard.com 6 * daniel@veillard.com
7 */ 7 */
8 8
9 #include "libxml.h" 9 #include "libxml.h"
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 static int shell = 0; 123 static int shell = 0;
124 static int debugent = 0; 124 static int debugent = 0;
125 #endif 125 #endif
126 static int debug = 0; 126 static int debug = 0;
127 static int maxmem = 0; 127 static int maxmem = 0;
128 #ifdef LIBXML_TREE_ENABLED 128 #ifdef LIBXML_TREE_ENABLED
129 static int copy = 0; 129 static int copy = 0;
130 #endif /* LIBXML_TREE_ENABLED */ 130 #endif /* LIBXML_TREE_ENABLED */
131 static int recovery = 0; 131 static int recovery = 0;
132 static int noent = 0; 132 static int noent = 0;
133 static int noenc = 0;
133 static int noblanks = 0; 134 static int noblanks = 0;
134 static int noout = 0; 135 static int noout = 0;
135 static int nowrap = 0; 136 static int nowrap = 0;
136 #ifdef LIBXML_OUTPUT_ENABLED 137 #ifdef LIBXML_OUTPUT_ENABLED
137 static int format = 0; 138 static int format = 0;
138 static const char *output = NULL; 139 static const char *output = NULL;
139 static int compress = 0; 140 static int compress = 0;
140 static int oldout = 0; 141 static int oldout = 0;
141 #endif /* LIBXML_OUTPUT_ENABLED */ 142 #endif /* LIBXML_OUTPUT_ENABLED */
142 #ifdef LIBXML_VALID_ENABLED 143 #ifdef LIBXML_VALID_ENABLED
(...skipping 12 matching lines...) Expand all
155 static char * schematron = NULL; 156 static char * schematron = NULL;
156 static xmlSchematronPtr wxschematron = NULL; 157 static xmlSchematronPtr wxschematron = NULL;
157 #endif 158 #endif
158 static int repeat = 0; 159 static int repeat = 0;
159 static int insert = 0; 160 static int insert = 0;
160 #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) 161 #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
161 static int html = 0; 162 static int html = 0;
162 static int xmlout = 0; 163 static int xmlout = 0;
163 #endif 164 #endif
164 static int htmlout = 0; 165 static int htmlout = 0;
166 #if defined(LIBXML_HTML_ENABLED)
167 static int nodefdtd = 0;
168 #endif
165 #ifdef LIBXML_PUSH_ENABLED 169 #ifdef LIBXML_PUSH_ENABLED
166 static int push = 0; 170 static int push = 0;
171 static int pushsize = 4096;
167 #endif /* LIBXML_PUSH_ENABLED */ 172 #endif /* LIBXML_PUSH_ENABLED */
168 #ifdef HAVE_SYS_MMAN_H 173 #ifdef HAVE_MMAP
169 static int memory = 0; 174 static int memory = 0;
170 #endif 175 #endif
171 static int testIO = 0; 176 static int testIO = 0;
172 static char *encoding = NULL; 177 static char *encoding = NULL;
173 #ifdef LIBXML_XINCLUDE_ENABLED 178 #ifdef LIBXML_XINCLUDE_ENABLED
174 static int xinclude = 0; 179 static int xinclude = 0;
175 #endif 180 #endif
176 static int dtdattrs = 0; 181 static int dtdattrs = 0;
177 static int loaddtd = 0; 182 static int loaddtd = 0;
178 static xmllintReturnCode progresult = XMLLINT_RETURN_OK; 183 static xmllintReturnCode progresult = XMLLINT_RETURN_OK;
(...skipping 19 matching lines...) Expand all
198 static int sax1 = 0; 203 static int sax1 = 0;
199 #endif /* LIBXML_SAX1_ENABLED */ 204 #endif /* LIBXML_SAX1_ENABLED */
200 #ifdef LIBXML_PATTERN_ENABLED 205 #ifdef LIBXML_PATTERN_ENABLED
201 static const char *pattern = NULL; 206 static const char *pattern = NULL;
202 static xmlPatternPtr patternc = NULL; 207 static xmlPatternPtr patternc = NULL;
203 static xmlStreamCtxtPtr patstream = NULL; 208 static xmlStreamCtxtPtr patstream = NULL;
204 #endif 209 #endif
205 #ifdef LIBXML_XPATH_ENABLED 210 #ifdef LIBXML_XPATH_ENABLED
206 static const char *xpathquery = NULL; 211 static const char *xpathquery = NULL;
207 #endif 212 #endif
208 static int options = XML_PARSE_COMPACT; 213 static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
209 static int sax = 0; 214 static int sax = 0;
210 static int oldxml10 = 0; 215 static int oldxml10 = 0;
211 216
212 /************************************************************************ 217 /************************************************************************
213 * * 218 * *
214 * Entity loading control and customization. * 219 * Entity loading control and customization. *
215 * * 220 * *
216 ************************************************************************/ 221 ************************************************************************/
217 #define MAX_PATHS 64 222 #define MAX_PATHS 64
218 #ifdef _WIN32 223 #ifdef _WIN32
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 * Do nothing 514 * Do nothing
510 */ 515 */
511 } 516 }
512 static void XMLCDECL 517 static void XMLCDECL
513 endTimer(char *format, ...) 518 endTimer(char *format, ...)
514 { 519 {
515 /* 520 /*
516 * We cannot do anything because we don't have a timing function 521 * We cannot do anything because we don't have a timing function
517 */ 522 */
518 #ifdef HAVE_STDARG_H 523 #ifdef HAVE_STDARG_H
524 va_list ap;
519 va_start(ap, format); 525 va_start(ap, format);
520 vfprintf(stderr, format, ap); 526 vfprintf(stderr, format, ap);
521 va_end(ap); 527 va_end(ap);
522 fprintf(stderr, " was not timed\n", msec); 528 fprintf(stderr, " was not timed\n");
523 #else 529 #else
524 /* We don't have gettimeofday, time or stdarg.h, what crazy world is 530 /* We don't have gettimeofday, time or stdarg.h, what crazy world is
525 * this ?! 531 * this ?!
526 */ 532 */
527 #endif 533 #endif
528 } 534 }
529 #endif 535 #endif
530 /************************************************************************ 536 /************************************************************************
531 * * 537 * *
532 * HTML ouput * 538 * HTML ouput *
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 #ifdef LIBXML_SCHEMAS_ENABLED 1663 #ifdef LIBXML_SCHEMAS_ENABLED
1658 if (wxschemas != NULL) { 1664 if (wxschemas != NULL) {
1659 int ret; 1665 int ret;
1660 xmlSchemaValidCtxtPtr vctxt; 1666 xmlSchemaValidCtxtPtr vctxt;
1661 1667
1662 vctxt = xmlSchemaNewValidCtxt(wxschemas); 1668 vctxt = xmlSchemaNewValidCtxt(wxschemas);
1663 xmlSchemaSetValidErrors(vctxt, 1669 xmlSchemaSetValidErrors(vctxt,
1664 (xmlSchemaValidityErrorFunc) fprintf, 1670 (xmlSchemaValidityErrorFunc) fprintf,
1665 (xmlSchemaValidityWarningFunc) fprintf, 1671 (xmlSchemaValidityWarningFunc) fprintf,
1666 stderr); 1672 stderr);
1673 xmlSchemaValidateSetFilename(vctxt, filename);
1667 1674
1668 ret = xmlSchemaValidateStream(vctxt, buf, 0, handler, 1675 ret = xmlSchemaValidateStream(vctxt, buf, 0, handler,
1669 (void *)user_data); 1676 (void *)user_data);
1670 if (repeat == 0) { 1677 if (repeat == 0) {
1671 if (ret == 0) { 1678 if (ret == 0) {
1672 fprintf(stderr, "%s validates\n", filename); 1679 fprintf(stderr, "%s validates\n", filename);
1673 } else if (ret > 0) { 1680 } else if (ret > 0) {
1674 fprintf(stderr, "%s fails to validate\n", filename); 1681 fprintf(stderr, "%s fails to validate\n", filename);
1675 progresult = XMLLINT_ERR_VALID; 1682 progresult = XMLLINT_ERR_VALID;
1676 } else { 1683 } else {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 } 1818 }
1812 if (path != NULL) 1819 if (path != NULL)
1813 xmlFree(path); 1820 xmlFree(path);
1814 } 1821 }
1815 #endif 1822 #endif
1816 } 1823 }
1817 1824
1818 static void streamFile(char *filename) { 1825 static void streamFile(char *filename) {
1819 xmlTextReaderPtr reader; 1826 xmlTextReaderPtr reader;
1820 int ret; 1827 int ret;
1821 #ifdef HAVE_SYS_MMAN_H 1828 #ifdef HAVE_MMAP
1822 int fd = -1; 1829 int fd = -1;
1823 struct stat info; 1830 struct stat info;
1824 const char *base = NULL; 1831 const char *base = NULL;
1825 xmlParserInputBufferPtr input = NULL; 1832 xmlParserInputBufferPtr input = NULL;
1826 1833
1827 if (memory) { 1834 if (memory) {
1828 if (stat(filename, &info) < 0) 1835 if (stat(filename, &info) < 0)
1829 return; 1836 return;
1830 if ((fd = open(filename, O_RDONLY)) < 0) 1837 if ((fd = open(filename, O_RDONLY)) < 0)
1831 return; 1838 return;
1832 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; 1839 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
1833 » if (base == (void *) MAP_FAILED) 1840 » if (base == (void *) MAP_FAILED) {
1841 » close(fd);
1842 » fprintf(stderr, "mmap failure for file %s\n", filename);
1843 » progresult = XMLLINT_ERR_RDFILE;
1834 return; 1844 return;
1845 }
1835 1846
1836 reader = xmlReaderForMemory(base, info.st_size, filename, 1847 reader = xmlReaderForMemory(base, info.st_size, filename,
1837 NULL, options); 1848 NULL, options);
1838 } else 1849 } else
1839 #endif 1850 #endif
1840 reader = xmlReaderForFile(filename, NULL, options); 1851 reader = xmlReaderForFile(filename, NULL, options);
1841 #ifdef LIBXML_PATTERN_ENABLED 1852 #ifdef LIBXML_PATTERN_ENABLED
1842 if (pattern != NULL) { 1853 if (pattern != NULL) {
1843 patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL); 1854 patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
1844 if (patternc == NULL) { 1855 if (patternc == NULL) {
(...skipping 16 matching lines...) Expand all
1861 } 1872 }
1862 #endif 1873 #endif
1863 1874
1864 1875
1865 if (reader != NULL) { 1876 if (reader != NULL) {
1866 #ifdef LIBXML_VALID_ENABLED 1877 #ifdef LIBXML_VALID_ENABLED
1867 if (valid) 1878 if (valid)
1868 xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); 1879 xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1);
1869 else 1880 else
1870 #endif /* LIBXML_VALID_ENABLED */ 1881 #endif /* LIBXML_VALID_ENABLED */
1871 » xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); 1882 » if (loaddtd)
1883 » » xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1);
1872 #ifdef LIBXML_SCHEMAS_ENABLED 1884 #ifdef LIBXML_SCHEMAS_ENABLED
1873 if (relaxng != NULL) { 1885 if (relaxng != NULL) {
1874 if ((timing) && (!repeat)) { 1886 if ((timing) && (!repeat)) {
1875 startTimer(); 1887 startTimer();
1876 } 1888 }
1877 ret = xmlTextReaderRelaxNGValidate(reader, relaxng); 1889 ret = xmlTextReaderRelaxNGValidate(reader, relaxng);
1878 if (ret < 0) { 1890 if (ret < 0) {
1879 xmlGenericError(xmlGenericErrorContext, 1891 xmlGenericError(xmlGenericErrorContext,
1880 "Relax-NG schema %s failed to compile\n", relaxng); 1892 "Relax-NG schema %s failed to compile\n", relaxng);
1881 progresult = XMLLINT_ERR_SCHEMACOMP; 1893 progresult = XMLLINT_ERR_SCHEMACOMP;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 } else { 1974 } else {
1963 fprintf(stderr, "Unable to open %s\n", filename); 1975 fprintf(stderr, "Unable to open %s\n", filename);
1964 progresult = XMLLINT_ERR_UNCLASS; 1976 progresult = XMLLINT_ERR_UNCLASS;
1965 } 1977 }
1966 #ifdef LIBXML_PATTERN_ENABLED 1978 #ifdef LIBXML_PATTERN_ENABLED
1967 if (patstream != NULL) { 1979 if (patstream != NULL) {
1968 xmlFreeStreamCtxt(patstream); 1980 xmlFreeStreamCtxt(patstream);
1969 patstream = NULL; 1981 patstream = NULL;
1970 } 1982 }
1971 #endif 1983 #endif
1972 #ifdef HAVE_SYS_MMAN_H 1984 #ifdef HAVE_MMAP
1973 if (memory) { 1985 if (memory) {
1974 xmlFreeParserInputBuffer(input); 1986 xmlFreeParserInputBuffer(input);
1975 munmap((char *) base, info.st_size); 1987 munmap((char *) base, info.st_size);
1976 close(fd); 1988 close(fd);
1977 } 1989 }
1978 #endif 1990 #endif
1979 } 1991 }
1980 1992
1981 static void walkDoc(xmlDocPtr doc) { 1993 static void walkDoc(xmlDocPtr doc) {
1982 xmlTextReaderPtr reader; 1994 xmlTextReaderPtr reader;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 ************************************************************************/ 2074 ************************************************************************/
2063 2075
2064 static void doXPathDump(xmlXPathObjectPtr cur) { 2076 static void doXPathDump(xmlXPathObjectPtr cur) {
2065 switch(cur->type) { 2077 switch(cur->type) {
2066 case XPATH_NODESET: { 2078 case XPATH_NODESET: {
2067 int i; 2079 int i;
2068 xmlNodePtr node; 2080 xmlNodePtr node;
2069 #ifdef LIBXML_OUTPUT_ENABLED 2081 #ifdef LIBXML_OUTPUT_ENABLED
2070 xmlSaveCtxtPtr ctxt; 2082 xmlSaveCtxtPtr ctxt;
2071 2083
2072 if (cur->nodesetval->nodeNr <= 0) { 2084 if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) {
2073 fprintf(stderr, "XPath set is empty\n"); 2085 fprintf(stderr, "XPath set is empty\n");
2074 progresult = XMLLINT_ERR_XPATH; 2086 progresult = XMLLINT_ERR_XPATH;
2075 break; 2087 break;
2076 } 2088 }
2077 ctxt = xmlSaveToFd(1, NULL, 0); 2089 ctxt = xmlSaveToFd(1, NULL, 0);
2078 if (ctxt == NULL) { 2090 if (ctxt == NULL) {
2079 fprintf(stderr, "Out of memory for XPath\n"); 2091 fprintf(stderr, "Out of memory for XPath\n");
2080 progresult = XMLLINT_ERR_MEM; 2092 progresult = XMLLINT_ERR_MEM;
2081 return; 2093 return;
2082 } 2094 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 static void doXPathQuery(xmlDocPtr doc, const char *query) { 2139 static void doXPathQuery(xmlDocPtr doc, const char *query) {
2128 xmlXPathContextPtr ctxt; 2140 xmlXPathContextPtr ctxt;
2129 xmlXPathObjectPtr res; 2141 xmlXPathObjectPtr res;
2130 2142
2131 ctxt = xmlXPathNewContext(doc); 2143 ctxt = xmlXPathNewContext(doc);
2132 if (ctxt == NULL) { 2144 if (ctxt == NULL) {
2133 fprintf(stderr, "Out of memory for XPath\n"); 2145 fprintf(stderr, "Out of memory for XPath\n");
2134 progresult = XMLLINT_ERR_MEM; 2146 progresult = XMLLINT_ERR_MEM;
2135 return; 2147 return;
2136 } 2148 }
2137 ctxt->node = xmlDocGetRootElement(doc); 2149 ctxt->node = (xmlNodePtr) doc;
2138 res = xmlXPathEval(BAD_CAST query, ctxt); 2150 res = xmlXPathEval(BAD_CAST query, ctxt);
2139 xmlXPathFreeContext(ctxt); 2151 xmlXPathFreeContext(ctxt);
2140 2152
2141 if (res == NULL) { 2153 if (res == NULL) {
2142 fprintf(stderr, "XPath evaluation failure\n"); 2154 fprintf(stderr, "XPath evaluation failure\n");
2143 progresult = XMLLINT_ERR_XPATH; 2155 progresult = XMLLINT_ERR_XPATH;
2144 return; 2156 return;
2145 } 2157 }
2146 doXPathDump(res); 2158 doXPathDump(res);
2147 xmlXPathFreeObject(res); 2159 xmlXPathFreeObject(res);
(...skipping 27 matching lines...) Expand all
2175 } 2187 }
2176 } 2188 }
2177 #endif /* LIBXML_TREE_ENABLED */ 2189 #endif /* LIBXML_TREE_ENABLED */
2178 #ifdef LIBXML_HTML_ENABLED 2190 #ifdef LIBXML_HTML_ENABLED
2179 #ifdef LIBXML_PUSH_ENABLED 2191 #ifdef LIBXML_PUSH_ENABLED
2180 else if ((html) && (push)) { 2192 else if ((html) && (push)) {
2181 FILE *f; 2193 FILE *f;
2182 2194
2183 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) 2195 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
2184 f = fopen(filename, "rb"); 2196 f = fopen(filename, "rb");
2197 #elif defined(__OS400__)
2198 f = fopen(filename, "rb");
2185 #else 2199 #else
2186 f = fopen(filename, "r"); 2200 f = fopen(filename, "r");
2187 #endif 2201 #endif
2188 if (f != NULL) { 2202 if (f != NULL) {
2189 int res, size = 3; 2203 int res;
2190 char chars[4096]; 2204 char chars[4096];
2191 htmlParserCtxtPtr ctxt; 2205 htmlParserCtxtPtr ctxt;
2192 2206
2193 /* if (repeat) */
2194 size = 4096;
2195 res = fread(chars, 1, 4, f); 2207 res = fread(chars, 1, 4, f);
2196 if (res > 0) { 2208 if (res > 0) {
2197 ctxt = htmlCreatePushParserCtxt(NULL, NULL, 2209 ctxt = htmlCreatePushParserCtxt(NULL, NULL,
2198 chars, res, filename, XML_CHAR_ENCODING_NONE); 2210 chars, res, filename, XML_CHAR_ENCODING_NONE);
2199 while ((res = fread(chars, 1, size, f)) > 0) { 2211 xmlCtxtUseOptions(ctxt, options);
2212 while ((res = fread(chars, 1, pushsize, f)) > 0) {
2200 htmlParseChunk(ctxt, chars, res, 0); 2213 htmlParseChunk(ctxt, chars, res, 0);
2201 } 2214 }
2202 htmlParseChunk(ctxt, chars, 0, 1); 2215 htmlParseChunk(ctxt, chars, 0, 1);
2203 doc = ctxt->myDoc; 2216 doc = ctxt->myDoc;
2204 htmlFreeParserCtxt(ctxt); 2217 htmlFreeParserCtxt(ctxt);
2205 } 2218 }
2206 fclose(f); 2219 fclose(f);
2207 } 2220 }
2208 } 2221 }
2209 #endif /* LIBXML_PUSH_ENABLED */ 2222 #endif /* LIBXML_PUSH_ENABLED */
2210 #ifdef HAVE_SYS_MMAN_H 2223 #ifdef HAVE_MMAP
2211 else if ((html) && (memory)) { 2224 else if ((html) && (memory)) {
2212 int fd; 2225 int fd;
2213 struct stat info; 2226 struct stat info;
2214 const char *base; 2227 const char *base;
2215 if (stat(filename, &info) < 0) 2228 if (stat(filename, &info) < 0)
2216 return; 2229 return;
2217 if ((fd = open(filename, O_RDONLY)) < 0) 2230 if ((fd = open(filename, O_RDONLY)) < 0)
2218 return; 2231 return;
2219 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; 2232 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
2220 » if (base == (void *) MAP_FAILED) 2233 » if (base == (void *) MAP_FAILED) {
2234 » close(fd);
2235 » fprintf(stderr, "mmap failure for file %s\n", filename);
2236 » progresult = XMLLINT_ERR_RDFILE;
2221 return; 2237 return;
2238 }
2222 2239
2223 doc = htmlReadMemory((char *) base, info.st_size, filename, 2240 doc = htmlReadMemory((char *) base, info.st_size, filename,
2224 NULL, options); 2241 NULL, options);
2225 2242
2226 munmap((char *) base, info.st_size); 2243 munmap((char *) base, info.st_size);
2227 close(fd); 2244 close(fd);
2228 } 2245 }
2229 #endif 2246 #endif
2230 else if (html) { 2247 else if (html) {
2231 doc = htmlReadFile(filename, NULL, options); 2248 doc = htmlReadFile(filename, NULL, options);
2232 } 2249 }
2233 #endif /* LIBXML_HTML_ENABLED */ 2250 #endif /* LIBXML_HTML_ENABLED */
2234 else { 2251 else {
2235 #ifdef LIBXML_PUSH_ENABLED 2252 #ifdef LIBXML_PUSH_ENABLED
2236 /* 2253 /*
2237 * build an XML tree from a string; 2254 * build an XML tree from a string;
2238 */ 2255 */
2239 if (push) { 2256 if (push) {
2240 FILE *f; 2257 FILE *f;
2241 2258
2242 /* '-' Usually means stdin -<sven@zen.org> */ 2259 /* '-' Usually means stdin -<sven@zen.org> */
2243 if ((filename[0] == '-') && (filename[1] == 0)) { 2260 if ((filename[0] == '-') && (filename[1] == 0)) {
2244 f = stdin; 2261 f = stdin;
2245 } else { 2262 } else {
2246 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) 2263 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
2247 f = fopen(filename, "rb"); 2264 f = fopen(filename, "rb");
2265 #elif defined(__OS400__)
2266 f = fopen(filename, "rb");
2248 #else 2267 #else
2249 f = fopen(filename, "r"); 2268 f = fopen(filename, "r");
2250 #endif 2269 #endif
2251 } 2270 }
2252 if (f != NULL) { 2271 if (f != NULL) {
2253 int ret; 2272 int ret;
2254 int res, size = 1024; 2273 int res, size = 1024;
2255 char chars[1024]; 2274 char chars[1024];
2256 xmlParserCtxtPtr ctxt; 2275 xmlParserCtxtPtr ctxt;
2257 2276
(...skipping 21 matching lines...) Expand all
2279 } else 2298 } else
2280 #endif /* LIBXML_PUSH_ENABLED */ 2299 #endif /* LIBXML_PUSH_ENABLED */
2281 if (testIO) { 2300 if (testIO) {
2282 if ((filename[0] == '-') && (filename[1] == 0)) { 2301 if ((filename[0] == '-') && (filename[1] == 0)) {
2283 doc = xmlReadFd(0, NULL, NULL, options); 2302 doc = xmlReadFd(0, NULL, NULL, options);
2284 } else { 2303 } else {
2285 FILE *f; 2304 FILE *f;
2286 2305
2287 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) 2306 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
2288 f = fopen(filename, "rb"); 2307 f = fopen(filename, "rb");
2308 #elif defined(__OS400__)
2309 f = fopen(filename, "rb");
2289 #else 2310 #else
2290 f = fopen(filename, "r"); 2311 f = fopen(filename, "r");
2291 #endif 2312 #endif
2292 if (f != NULL) { 2313 if (f != NULL) {
2293 if (rectxt == NULL) 2314 if (rectxt == NULL)
2294 doc = xmlReadIO((xmlInputReadCallback) myRead, 2315 doc = xmlReadIO((xmlInputReadCallback) myRead,
2295 (xmlInputCloseCallback) myClose, f, 2316 (xmlInputCloseCallback) myClose, f,
2296 filename, NULL, options); 2317 filename, NULL, options);
2297 else 2318 else
2298 doc = xmlCtxtReadIO(rectxt, 2319 doc = xmlCtxtReadIO(rectxt,
(...skipping 16 matching lines...) Expand all
2315 ctxt->sax->error = xmlHTMLError; 2336 ctxt->sax->error = xmlHTMLError;
2316 ctxt->sax->warning = xmlHTMLWarning; 2337 ctxt->sax->warning = xmlHTMLWarning;
2317 ctxt->vctxt.error = xmlHTMLValidityError; 2338 ctxt->vctxt.error = xmlHTMLValidityError;
2318 ctxt->vctxt.warning = xmlHTMLValidityWarning; 2339 ctxt->vctxt.warning = xmlHTMLValidityWarning;
2319 2340
2320 doc = xmlCtxtReadFile(ctxt, filename, NULL, options); 2341 doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
2321 2342
2322 if (rectxt == NULL) 2343 if (rectxt == NULL)
2323 xmlFreeParserCtxt(ctxt); 2344 xmlFreeParserCtxt(ctxt);
2324 } 2345 }
2325 #ifdef HAVE_SYS_MMAN_H 2346 #ifdef HAVE_MMAP
2326 } else if (memory) { 2347 } else if (memory) {
2327 int fd; 2348 int fd;
2328 struct stat info; 2349 struct stat info;
2329 const char *base; 2350 const char *base;
2330 if (stat(filename, &info) < 0) 2351 if (stat(filename, &info) < 0)
2331 return; 2352 return;
2332 if ((fd = open(filename, O_RDONLY)) < 0) 2353 if ((fd = open(filename, O_RDONLY)) < 0)
2333 return; 2354 return;
2334 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ; 2355 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
2335 » if (base == (void *) MAP_FAILED) 2356 » if (base == (void *) MAP_FAILED) {
2357 » close(fd);
2358 » fprintf(stderr, "mmap failure for file %s\n", filename);
2359 » » progresult = XMLLINT_ERR_RDFILE;
2336 return; 2360 return;
2361 }
2337 2362
2338 if (rectxt == NULL) 2363 if (rectxt == NULL)
2339 doc = xmlReadMemory((char *) base, info.st_size, 2364 doc = xmlReadMemory((char *) base, info.st_size,
2340 filename, NULL, options); 2365 filename, NULL, options);
2341 else 2366 else
2342 doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size, 2367 doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
2343 filename, NULL, options); 2368 filename, NULL, options);
2344 2369
2345 munmap((char *) base, info.st_size); 2370 munmap((char *) base, info.st_size);
2346 close(fd); 2371 close(fd);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 #endif 2525 #endif
2501 if ((timing) && (!repeat)) { 2526 if ((timing) && (!repeat)) {
2502 startTimer(); 2527 startTimer();
2503 } 2528 }
2504 #ifdef LIBXML_HTML_ENABLED 2529 #ifdef LIBXML_HTML_ENABLED
2505 if ((html) && (!xmlout)) { 2530 if ((html) && (!xmlout)) {
2506 if (compress) { 2531 if (compress) {
2507 htmlSaveFile(output ? output : "-", doc); 2532 htmlSaveFile(output ? output : "-", doc);
2508 } 2533 }
2509 else if (encoding != NULL) { 2534 else if (encoding != NULL) {
2510 » » if ( format ) { 2535 » » if (format == 1) {
2511 htmlSaveFileFormat(output ? output : "-", doc, encoding, 1); 2536 htmlSaveFileFormat(output ? output : "-", doc, encoding, 1);
2512 } 2537 }
2513 else { 2538 else {
2514 htmlSaveFileFormat(output ? output : "-", doc, encoding, 0); 2539 htmlSaveFileFormat(output ? output : "-", doc, encoding, 0);
2515 } 2540 }
2516 } 2541 }
2517 » » else if (format) { 2542 » » else if (format == 1) {
2518 htmlSaveFileFormat(output ? output : "-", doc, NULL, 1); 2543 htmlSaveFileFormat(output ? output : "-", doc, NULL, 1);
2519 } 2544 }
2520 else { 2545 else {
2521 FILE *out; 2546 FILE *out;
2522 if (output == NULL) 2547 if (output == NULL)
2523 out = stdout; 2548 out = stdout;
2524 else { 2549 else {
2525 out = fopen(output,"wb"); 2550 out = fopen(output,"wb");
2526 } 2551 }
2527 if (out != NULL) { 2552 if (out != NULL) {
(...skipping 12 matching lines...) Expand all
2540 } 2565 }
2541 } else 2566 } else
2542 #endif 2567 #endif
2543 #ifdef LIBXML_C14N_ENABLED 2568 #ifdef LIBXML_C14N_ENABLED
2544 if (canonical) { 2569 if (canonical) {
2545 xmlChar *result = NULL; 2570 xmlChar *result = NULL;
2546 int size; 2571 int size;
2547 2572
2548 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &r esult); 2573 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &r esult);
2549 if (size >= 0) { 2574 if (size >= 0) {
2550 » » write(1, result, size); 2575 » » if (write(1, result, size) == -1) {
2576 » » fprintf(stderr, "Can't write data\n");
2577 » » }
2551 xmlFree(result); 2578 xmlFree(result);
2552 } else { 2579 } else {
2553 fprintf(stderr, "Failed to canonicalize\n"); 2580 fprintf(stderr, "Failed to canonicalize\n");
2554 progresult = XMLLINT_ERR_OUT; 2581 progresult = XMLLINT_ERR_OUT;
2555 } 2582 }
2556 » } else if (canonical) { 2583 » } else if (canonical_11) {
2557 xmlChar *result = NULL; 2584 xmlChar *result = NULL;
2558 int size; 2585 int size;
2559 2586
2560 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &r esult); 2587 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &r esult);
2561 if (size >= 0) { 2588 if (size >= 0) {
2562 » » write(1, result, size); 2589 » » if (write(1, result, size) == -1) {
2590 » » fprintf(stderr, "Can't write data\n");
2591 » » }
2563 xmlFree(result); 2592 xmlFree(result);
2564 } else { 2593 } else {
2565 fprintf(stderr, "Failed to canonicalize\n"); 2594 fprintf(stderr, "Failed to canonicalize\n");
2566 progresult = XMLLINT_ERR_OUT; 2595 progresult = XMLLINT_ERR_OUT;
2567 } 2596 }
2568 } else 2597 } else
2569 if (exc_canonical) { 2598 if (exc_canonical) {
2570 xmlChar *result = NULL; 2599 xmlChar *result = NULL;
2571 int size; 2600 int size;
2572 2601
2573 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, N ULL, 1, &result); 2602 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, N ULL, 1, &result);
2574 if (size >= 0) { 2603 if (size >= 0) {
2575 » » write(1, result, size); 2604 » » if (write(1, result, size) == -1) {
2605 » » fprintf(stderr, "Can't write data\n");
2606 » » }
2576 xmlFree(result); 2607 xmlFree(result);
2577 } else { 2608 } else {
2578 fprintf(stderr, "Failed to canonicalize\n"); 2609 fprintf(stderr, "Failed to canonicalize\n");
2579 progresult = XMLLINT_ERR_OUT; 2610 progresult = XMLLINT_ERR_OUT;
2580 } 2611 }
2581 } else 2612 } else
2582 #endif 2613 #endif
2583 #ifdef HAVE_SYS_MMAN_H 2614 #ifdef HAVE_MMAP
2584 if (memory) { 2615 if (memory) {
2585 xmlChar *result; 2616 xmlChar *result;
2586 int len; 2617 int len;
2587 2618
2588 if (encoding != NULL) { 2619 if (encoding != NULL) {
2589 » » if ( format ) { 2620 » » if (format == 1) {
2590 xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1); 2621 xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1);
2591 } else { 2622 } else {
2592 xmlDocDumpMemoryEnc(doc, &result, &len, encoding); 2623 xmlDocDumpMemoryEnc(doc, &result, &len, encoding);
2593 } 2624 }
2594 } else { 2625 } else {
2595 » » if (format) 2626 » » if (format == 1)
2596 xmlDocDumpFormatMemory(doc, &result, &len, 1); 2627 xmlDocDumpFormatMemory(doc, &result, &len, 1);
2597 else 2628 else
2598 xmlDocDumpMemory(doc, &result, &len); 2629 xmlDocDumpMemory(doc, &result, &len);
2599 } 2630 }
2600 if (result == NULL) { 2631 if (result == NULL) {
2601 fprintf(stderr, "Failed to save\n"); 2632 fprintf(stderr, "Failed to save\n");
2602 progresult = XMLLINT_ERR_OUT; 2633 progresult = XMLLINT_ERR_OUT;
2603 } else { 2634 } else {
2604 » » write(1, result, len); 2635 » » if (write(1, result, len) == -1) {
2636 » » fprintf(stderr, "Can't write data\n");
2637 » » }
2605 xmlFree(result); 2638 xmlFree(result);
2606 } 2639 }
2607 2640
2608 } else 2641 } else
2609 #endif /* HAVE_SYS_MMAN_H */ 2642 #endif /* HAVE_MMAP */
2610 if (compress) { 2643 if (compress) {
2611 xmlSaveFile(output ? output : "-", doc); 2644 xmlSaveFile(output ? output : "-", doc);
2612 } else if (oldout) { 2645 } else if (oldout) {
2613 if (encoding != NULL) { 2646 if (encoding != NULL) {
2614 » » if ( format ) { 2647 » » if (format == 1) {
2615 ret = xmlSaveFormatFileEnc(output ? output : "-", doc, 2648 ret = xmlSaveFormatFileEnc(output ? output : "-", doc,
2616 encoding, 1); 2649 encoding, 1);
2617 } 2650 }
2618 else { 2651 else {
2619 ret = xmlSaveFileEnc(output ? output : "-", doc, 2652 ret = xmlSaveFileEnc(output ? output : "-", doc,
2620 encoding); 2653 encoding);
2621 } 2654 }
2622 if (ret < 0) { 2655 if (ret < 0) {
2623 fprintf(stderr, "failed save to %s\n", 2656 fprintf(stderr, "failed save to %s\n",
2624 output ? output : "-"); 2657 output ? output : "-");
2625 progresult = XMLLINT_ERR_OUT; 2658 progresult = XMLLINT_ERR_OUT;
2626 } 2659 }
2627 » » } else if (format) { 2660 » » } else if (format == 1) {
2628 ret = xmlSaveFormatFile(output ? output : "-", doc, 1); 2661 ret = xmlSaveFormatFile(output ? output : "-", doc, 1);
2629 if (ret < 0) { 2662 if (ret < 0) {
2630 fprintf(stderr, "failed save to %s\n", 2663 fprintf(stderr, "failed save to %s\n",
2631 output ? output : "-"); 2664 output ? output : "-");
2632 progresult = XMLLINT_ERR_OUT; 2665 progresult = XMLLINT_ERR_OUT;
2633 } 2666 }
2634 } else { 2667 } else {
2635 FILE *out; 2668 FILE *out;
2636 if (output == NULL) 2669 if (output == NULL)
2637 out = stdout; 2670 out = stdout;
2638 else { 2671 else {
2639 out = fopen(output,"wb"); 2672 out = fopen(output,"wb");
2640 } 2673 }
2641 if (out != NULL) { 2674 if (out != NULL) {
2642 if (xmlDocDump(out, doc) < 0) 2675 if (xmlDocDump(out, doc) < 0)
2643 progresult = XMLLINT_ERR_OUT; 2676 progresult = XMLLINT_ERR_OUT;
2644 2677
2645 if (output != NULL) 2678 if (output != NULL)
2646 fclose(out); 2679 fclose(out);
2647 } else { 2680 } else {
2648 fprintf(stderr, "failed to open %s\n", output); 2681 fprintf(stderr, "failed to open %s\n", output);
2649 progresult = XMLLINT_ERR_OUT; 2682 progresult = XMLLINT_ERR_OUT;
2650 } 2683 }
2651 } 2684 }
2652 } else { 2685 } else {
2653 xmlSaveCtxtPtr ctxt; 2686 xmlSaveCtxtPtr ctxt;
2654 int saveOpts = 0; 2687 int saveOpts = 0;
2655 2688
2656 if (format) 2689 if (format == 1)
2657 saveOpts |= XML_SAVE_FORMAT; 2690 saveOpts |= XML_SAVE_FORMAT;
2691 else if (format == 2)
2692 saveOpts |= XML_SAVE_WSNONSIG;
2658 2693
2659 #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED) 2694 #if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
2660 if (xmlout) 2695 if (xmlout)
2661 saveOpts |= XML_SAVE_AS_XML; 2696 saveOpts |= XML_SAVE_AS_XML;
2662 #endif 2697 #endif
2663 2698
2664 if (output == NULL) 2699 if (output == NULL)
2665 ctxt = xmlSaveToFd(1, encoding, saveOpts); 2700 ctxt = xmlSaveToFd(1, encoding, saveOpts);
2666 else 2701 else
2667 ctxt = xmlSaveToFilename(output, encoding, saveOpts); 2702 ctxt = xmlSaveToFilename(output, encoding, saveOpts);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); 2972 if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps ");
2938 if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata "); 2973 if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata ");
2939 if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr "); 2974 if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr ");
2940 if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas "); 2975 if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas ");
2941 if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron "); 2976 if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron ");
2942 if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules "); 2977 if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules ");
2943 if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug "); 2978 if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug ");
2944 if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug "); 2979 if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
2945 if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug "); 2980 if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
2946 if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib "); 2981 if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib ");
2982 if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma ");
2947 fprintf(stderr, "\n"); 2983 fprintf(stderr, "\n");
2948 } 2984 }
2949 2985
2950 static void usage(const char *name) { 2986 static void usage(const char *name) {
2951 printf("Usage : %s [options] XMLfiles ...\n", name); 2987 printf("Usage : %s [options] XMLfiles ...\n", name);
2952 #ifdef LIBXML_OUTPUT_ENABLED 2988 #ifdef LIBXML_OUTPUT_ENABLED
2953 printf("\tParse the XML files and output the result of the parsing\n"); 2989 printf("\tParse the XML files and output the result of the parsing\n");
2954 #else 2990 #else
2955 printf("\tParse the XML files\n"); 2991 printf("\tParse the XML files\n");
2956 #endif /* LIBXML_OUTPUT_ENABLED */ 2992 #endif /* LIBXML_OUTPUT_ENABLED */
2957 printf("\t--version : display the version of the XML library used\n"); 2993 printf("\t--version : display the version of the XML library used\n");
2958 #ifdef LIBXML_DEBUG_ENABLED 2994 #ifdef LIBXML_DEBUG_ENABLED
2959 printf("\t--debug : dump a debug tree of the in-memory document\n"); 2995 printf("\t--debug : dump a debug tree of the in-memory document\n");
2960 printf("\t--shell : run a navigating shell\n"); 2996 printf("\t--shell : run a navigating shell\n");
2961 printf("\t--debugent : debug the entities defined in the document\n"); 2997 printf("\t--debugent : debug the entities defined in the document\n");
2962 #else 2998 #else
2963 #ifdef LIBXML_READER_ENABLED 2999 #ifdef LIBXML_READER_ENABLED
2964 printf("\t--debug : dump the nodes content when using --stream\n"); 3000 printf("\t--debug : dump the nodes content when using --stream\n");
2965 #endif /* LIBXML_READER_ENABLED */ 3001 #endif /* LIBXML_READER_ENABLED */
2966 #endif 3002 #endif
2967 #ifdef LIBXML_TREE_ENABLED 3003 #ifdef LIBXML_TREE_ENABLED
2968 printf("\t--copy : used to test the internal copy implementation\n"); 3004 printf("\t--copy : used to test the internal copy implementation\n");
2969 #endif /* LIBXML_TREE_ENABLED */ 3005 #endif /* LIBXML_TREE_ENABLED */
2970 printf("\t--recover : output what was parsable on broken XML documents\n"); 3006 printf("\t--recover : output what was parsable on broken XML documents\n");
2971 printf("\t--huge : remove any internal arbitrary parser limits\n"); 3007 printf("\t--huge : remove any internal arbitrary parser limits\n");
2972 printf("\t--noent : substitute entity references by their value\n"); 3008 printf("\t--noent : substitute entity references by their value\n");
3009 printf("\t--noenc : ignore any encoding specified inside the document\n");
2973 printf("\t--noout : don't output the result tree\n"); 3010 printf("\t--noout : don't output the result tree\n");
2974 printf("\t--path 'paths': provide a set of paths for resources\n"); 3011 printf("\t--path 'paths': provide a set of paths for resources\n");
2975 printf("\t--load-trace : print trace of all external entites loaded\n"); 3012 printf("\t--load-trace : print trace of all external entities loaded\n");
2976 printf("\t--nonet : refuse to fetch DTDs or entities over network\n"); 3013 printf("\t--nonet : refuse to fetch DTDs or entities over network\n");
2977 printf("\t--nocompact : do not generate compact text nodes\n"); 3014 printf("\t--nocompact : do not generate compact text nodes\n");
2978 printf("\t--htmlout : output results as HTML\n"); 3015 printf("\t--htmlout : output results as HTML\n");
2979 printf("\t--nowrap : do not put HTML doc wrapper\n"); 3016 printf("\t--nowrap : do not put HTML doc wrapper\n");
2980 #ifdef LIBXML_VALID_ENABLED 3017 #ifdef LIBXML_VALID_ENABLED
2981 printf("\t--valid : validate the document in addition to std well-formed che ck\n"); 3018 printf("\t--valid : validate the document in addition to std well-formed che ck\n");
2982 printf("\t--postvalid : do a posteriori validation, i.e after parsing\n"); 3019 printf("\t--postvalid : do a posteriori validation, i.e after parsing\n");
2983 printf("\t--dtdvalid URL : do a posteriori validation against a given DTD\n" ); 3020 printf("\t--dtdvalid URL : do a posteriori validation against a given DTD\n" );
2984 printf("\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier \n"); 3021 printf("\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier \n");
2985 #endif /* LIBXML_VALID_ENABLED */ 3022 #endif /* LIBXML_VALID_ENABLED */
2986 printf("\t--timing : print some timings\n"); 3023 printf("\t--timing : print some timings\n");
2987 printf("\t--output file or -o file: save to a given file\n"); 3024 printf("\t--output file or -o file: save to a given file\n");
2988 printf("\t--repeat : repeat 100 times, for timing or profiling\n"); 3025 printf("\t--repeat : repeat 100 times, for timing or profiling\n");
2989 printf("\t--insert : ad-hoc test for valid insertions\n"); 3026 printf("\t--insert : ad-hoc test for valid insertions\n");
2990 #ifdef LIBXML_OUTPUT_ENABLED 3027 #ifdef LIBXML_OUTPUT_ENABLED
2991 #ifdef HAVE_ZLIB_H 3028 #ifdef HAVE_ZLIB_H
2992 printf("\t--compress : turn on gzip compression of output\n"); 3029 printf("\t--compress : turn on gzip compression of output\n");
2993 #endif 3030 #endif
2994 #endif /* LIBXML_OUTPUT_ENABLED */ 3031 #endif /* LIBXML_OUTPUT_ENABLED */
2995 #ifdef LIBXML_HTML_ENABLED 3032 #ifdef LIBXML_HTML_ENABLED
2996 printf("\t--html : use the HTML parser\n"); 3033 printf("\t--html : use the HTML parser\n");
2997 printf("\t--xmlout : force to use the XML serializer when using --html\n"); 3034 printf("\t--xmlout : force to use the XML serializer when using --html\n");
3035 printf("\t--nodefdtd : do not default HTML doctype\n");
2998 #endif 3036 #endif
2999 #ifdef LIBXML_PUSH_ENABLED 3037 #ifdef LIBXML_PUSH_ENABLED
3000 printf("\t--push : use the push mode of the parser\n"); 3038 printf("\t--push : use the push mode of the parser\n");
3039 printf("\t--pushsmall : use the push mode of the parser using tiny increment s\n");
3001 #endif /* LIBXML_PUSH_ENABLED */ 3040 #endif /* LIBXML_PUSH_ENABLED */
3002 #ifdef HAVE_SYS_MMAN_H 3041 #ifdef HAVE_MMAP
3003 printf("\t--memory : parse from memory\n"); 3042 printf("\t--memory : parse from memory\n");
3004 #endif 3043 #endif
3005 printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n"); 3044 printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
3006 printf("\t--nowarning : do not emit warnings from parser/validator\n"); 3045 printf("\t--nowarning : do not emit warnings from parser/validator\n");
3007 printf("\t--noblanks : drop (ignorable?) blanks spaces\n"); 3046 printf("\t--noblanks : drop (ignorable?) blanks spaces\n");
3008 printf("\t--nocdata : replace cdata section with text nodes\n"); 3047 printf("\t--nocdata : replace cdata section with text nodes\n");
3009 #ifdef LIBXML_OUTPUT_ENABLED 3048 #ifdef LIBXML_OUTPUT_ENABLED
3010 printf("\t--format : reformat/reindent the input\n"); 3049 printf("\t--format : reformat/reindent the input\n");
3011 printf("\t--encode encoding : output in the given encoding\n"); 3050 printf("\t--encode encoding : output in the given encoding\n");
3012 printf("\t--dropdtd : remove the DOCTYPE of the input docs\n"); 3051 printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
3052 printf("\t--pretty STYLE : pretty-print in a particular style\n");
3053 printf("\t 0 Do not pretty print\n");
3054 printf("\t 1 Format the XML content, as --format\n");
3055 printf("\t 2 Add whitespace inside tags, preserving content\ n");
3013 #endif /* LIBXML_OUTPUT_ENABLED */ 3056 #endif /* LIBXML_OUTPUT_ENABLED */
3014 printf("\t--c14n : save in W3C canonical format v1.0 (with comments)\n"); 3057 printf("\t--c14n : save in W3C canonical format v1.0 (with comments)\n");
3015 printf("\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n"); 3058 printf("\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n");
3016 printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments )\n"); 3059 printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments )\n");
3017 #ifdef LIBXML_C14N_ENABLED 3060 #ifdef LIBXML_C14N_ENABLED
3018 #endif /* LIBXML_C14N_ENABLED */ 3061 #endif /* LIBXML_C14N_ENABLED */
3019 printf("\t--nsclean : remove redundant namespace declarations\n"); 3062 printf("\t--nsclean : remove redundant namespace declarations\n");
3020 printf("\t--testIO : test user I/O support\n"); 3063 printf("\t--testIO : test user I/O support\n");
3021 #ifdef LIBXML_CATALOG_ENABLED 3064 #ifdef LIBXML_CATALOG_ENABLED
3022 printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n"); 3065 printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n");
(...skipping 23 matching lines...) Expand all
3046 #endif 3089 #endif
3047 #ifdef LIBXML_SCHEMATRON_ENABLED 3090 #ifdef LIBXML_SCHEMATRON_ENABLED
3048 printf("\t--schematron schema : do validation against a schematron\n"); 3091 printf("\t--schematron schema : do validation against a schematron\n");
3049 #endif 3092 #endif
3050 #ifdef LIBXML_SAX1_ENABLED 3093 #ifdef LIBXML_SAX1_ENABLED
3051 printf("\t--sax1: use the old SAX1 interfaces for processing\n"); 3094 printf("\t--sax1: use the old SAX1 interfaces for processing\n");
3052 #endif 3095 #endif
3053 printf("\t--sax: do not build a tree but work just at the SAX level\n"); 3096 printf("\t--sax: do not build a tree but work just at the SAX level\n");
3054 printf("\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n"); 3097 printf("\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n");
3055 #ifdef LIBXML_XPATH_ENABLED 3098 #ifdef LIBXML_XPATH_ENABLED
3056 printf("\t--xpath expr: evaluate the XPath expression, inply --noout\n"); 3099 printf("\t--xpath expr: evaluate the XPath expression, imply --noout\n");
3057 #endif 3100 #endif
3058 3101
3059 printf("\nLibxml project home page: http://xmlsoft.org/\n"); 3102 printf("\nLibxml project home page: http://xmlsoft.org/\n");
3060 printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\ n"); 3103 printf("To report bugs or get some help check: http://xmlsoft.org/bugs.html\ n");
3061 } 3104 }
3062 3105
3063 static void registerNode(xmlNodePtr node) 3106 static void registerNode(xmlNodePtr node)
3064 { 3107 {
3065 node->_private = malloc(sizeof(long)); 3108 node->_private = malloc(sizeof(long));
3109 if (node->_private == NULL) {
3110 fprintf(stderr, "Out of memory in xmllint:registerNode()\n");
3111 exit(XMLLINT_ERR_MEM);
3112 }
3066 *(long*)node->_private = (long) 0x81726354; 3113 *(long*)node->_private = (long) 0x81726354;
3067 nbregister++; 3114 nbregister++;
3068 } 3115 }
3069 3116
3070 static void deregisterNode(xmlNodePtr node) 3117 static void deregisterNode(xmlNodePtr node)
3071 { 3118 {
3072 assert(node->_private != NULL); 3119 assert(node->_private != NULL);
3073 assert(*(long*)node->_private == (long) 0x81726354); 3120 assert(*(long*)node->_private == (long) 0x81726354);
3074 free(node->_private); 3121 free(node->_private);
3075 nbregister--; 3122 nbregister--;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 (!strcmp(argv[i], "--recover"))) { 3159 (!strcmp(argv[i], "--recover"))) {
3113 recovery++; 3160 recovery++;
3114 options |= XML_PARSE_RECOVER; 3161 options |= XML_PARSE_RECOVER;
3115 } else if ((!strcmp(argv[i], "-huge")) || 3162 } else if ((!strcmp(argv[i], "-huge")) ||
3116 (!strcmp(argv[i], "--huge"))) { 3163 (!strcmp(argv[i], "--huge"))) {
3117 options |= XML_PARSE_HUGE; 3164 options |= XML_PARSE_HUGE;
3118 } else if ((!strcmp(argv[i], "-noent")) || 3165 } else if ((!strcmp(argv[i], "-noent")) ||
3119 (!strcmp(argv[i], "--noent"))) { 3166 (!strcmp(argv[i], "--noent"))) {
3120 noent++; 3167 noent++;
3121 options |= XML_PARSE_NOENT; 3168 options |= XML_PARSE_NOENT;
3169 } else if ((!strcmp(argv[i], "-noenc")) ||
3170 (!strcmp(argv[i], "--noenc"))) {
3171 noenc++;
3172 options |= XML_PARSE_IGNORE_ENC;
3122 } else if ((!strcmp(argv[i], "-nsclean")) || 3173 } else if ((!strcmp(argv[i], "-nsclean")) ||
3123 (!strcmp(argv[i], "--nsclean"))) { 3174 (!strcmp(argv[i], "--nsclean"))) {
3124 options |= XML_PARSE_NSCLEAN; 3175 options |= XML_PARSE_NSCLEAN;
3125 } else if ((!strcmp(argv[i], "-nocdata")) || 3176 } else if ((!strcmp(argv[i], "-nocdata")) ||
3126 (!strcmp(argv[i], "--nocdata"))) { 3177 (!strcmp(argv[i], "--nocdata"))) {
3127 options |= XML_PARSE_NOCDATA; 3178 options |= XML_PARSE_NOCDATA;
3128 } else if ((!strcmp(argv[i], "-nodict")) || 3179 } else if ((!strcmp(argv[i], "-nodict")) ||
3129 (!strcmp(argv[i], "--nodict"))) { 3180 (!strcmp(argv[i], "--nodict"))) {
3130 options |= XML_PARSE_NODICT; 3181 options |= XML_PARSE_NODICT;
3131 } else if ((!strcmp(argv[i], "-version")) || 3182 } else if ((!strcmp(argv[i], "-version")) ||
(...skipping 18 matching lines...) Expand all
3150 (!strcmp(argv[i], "--nowrap"))) 3201 (!strcmp(argv[i], "--nowrap")))
3151 nowrap++; 3202 nowrap++;
3152 #ifdef LIBXML_HTML_ENABLED 3203 #ifdef LIBXML_HTML_ENABLED
3153 else if ((!strcmp(argv[i], "-html")) || 3204 else if ((!strcmp(argv[i], "-html")) ||
3154 (!strcmp(argv[i], "--html"))) { 3205 (!strcmp(argv[i], "--html"))) {
3155 html++; 3206 html++;
3156 } 3207 }
3157 else if ((!strcmp(argv[i], "-xmlout")) || 3208 else if ((!strcmp(argv[i], "-xmlout")) ||
3158 (!strcmp(argv[i], "--xmlout"))) { 3209 (!strcmp(argv[i], "--xmlout"))) {
3159 xmlout++; 3210 xmlout++;
3211 } else if ((!strcmp(argv[i], "-nodefdtd")) ||
3212 (!strcmp(argv[i], "--nodefdtd"))) {
3213 nodefdtd++;
3214 options |= HTML_PARSE_NODEFDTD;
3160 } 3215 }
3161 #endif /* LIBXML_HTML_ENABLED */ 3216 #endif /* LIBXML_HTML_ENABLED */
3162 else if ((!strcmp(argv[i], "-loaddtd")) || 3217 else if ((!strcmp(argv[i], "-loaddtd")) ||
3163 (!strcmp(argv[i], "--loaddtd"))) { 3218 (!strcmp(argv[i], "--loaddtd"))) {
3164 loaddtd++; 3219 loaddtd++;
3165 options |= XML_PARSE_DTDLOAD; 3220 options |= XML_PARSE_DTDLOAD;
3166 } else if ((!strcmp(argv[i], "-dtdattr")) || 3221 } else if ((!strcmp(argv[i], "-dtdattr")) ||
3167 (!strcmp(argv[i], "--dtdattr"))) { 3222 (!strcmp(argv[i], "--dtdattr"))) {
3168 loaddtd++; 3223 loaddtd++;
3169 dtdattrs++; 3224 dtdattrs++;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3209 (!strcmp(argv[i], "--repeat"))) { 3264 (!strcmp(argv[i], "--repeat"))) {
3210 if (repeat) 3265 if (repeat)
3211 repeat *= 10; 3266 repeat *= 10;
3212 else 3267 else
3213 repeat = 100; 3268 repeat = 100;
3214 } 3269 }
3215 #ifdef LIBXML_PUSH_ENABLED 3270 #ifdef LIBXML_PUSH_ENABLED
3216 else if ((!strcmp(argv[i], "-push")) || 3271 else if ((!strcmp(argv[i], "-push")) ||
3217 (!strcmp(argv[i], "--push"))) 3272 (!strcmp(argv[i], "--push")))
3218 push++; 3273 push++;
3274 else if ((!strcmp(argv[i], "-pushsmall")) ||
3275 (!strcmp(argv[i], "--pushsmall"))) {
3276 push++;
3277 pushsize = 10;
3278 }
3219 #endif /* LIBXML_PUSH_ENABLED */ 3279 #endif /* LIBXML_PUSH_ENABLED */
3220 #ifdef HAVE_SYS_MMAN_H 3280 #ifdef HAVE_MMAP
3221 else if ((!strcmp(argv[i], "-memory")) || 3281 else if ((!strcmp(argv[i], "-memory")) ||
3222 (!strcmp(argv[i], "--memory"))) 3282 (!strcmp(argv[i], "--memory")))
3223 memory++; 3283 memory++;
3224 #endif 3284 #endif
3225 else if ((!strcmp(argv[i], "-testIO")) || 3285 else if ((!strcmp(argv[i], "-testIO")) ||
3226 (!strcmp(argv[i], "--testIO"))) 3286 (!strcmp(argv[i], "--testIO")))
3227 testIO++; 3287 testIO++;
3228 #ifdef LIBXML_XINCLUDE_ENABLED 3288 #ifdef LIBXML_XINCLUDE_ENABLED
3229 else if ((!strcmp(argv[i], "-xinclude")) || 3289 else if ((!strcmp(argv[i], "-xinclude")) ||
3230 (!strcmp(argv[i], "--xinclude"))) { 3290 (!strcmp(argv[i], "--xinclude"))) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 (!strcmp(argv[i], "--encode"))) { 3362 (!strcmp(argv[i], "--encode"))) {
3303 i++; 3363 i++;
3304 encoding = argv[i]; 3364 encoding = argv[i];
3305 /* 3365 /*
3306 * OK it's for testing purposes 3366 * OK it's for testing purposes
3307 */ 3367 */
3308 xmlAddEncodingAlias("UTF-8", "DVEnc"); 3368 xmlAddEncodingAlias("UTF-8", "DVEnc");
3309 } 3369 }
3310 else if ((!strcmp(argv[i], "-noblanks")) || 3370 else if ((!strcmp(argv[i], "-noblanks")) ||
3311 (!strcmp(argv[i], "--noblanks"))) { 3371 (!strcmp(argv[i], "--noblanks"))) {
3312 » noblanks++; 3372 » noblanks++;
3313 » xmlKeepBlanksDefault(0); 3373 » xmlKeepBlanksDefault(0);
3374 » options |= XML_PARSE_NOBLANKS;
3314 } 3375 }
3315 else if ((!strcmp(argv[i], "-maxmem")) || 3376 else if ((!strcmp(argv[i], "-maxmem")) ||
3316 (!strcmp(argv[i], "--maxmem"))) { 3377 (!strcmp(argv[i], "--maxmem"))) {
3317 i++; 3378 i++;
3318 if (sscanf(argv[i], "%d", &maxmem) == 1) { 3379 if (sscanf(argv[i], "%d", &maxmem) == 1) {
3319 xmlMemSetup(myFreeFunc, myMallocFunc, myReallocFunc, 3380 xmlMemSetup(myFreeFunc, myMallocFunc, myReallocFunc,
3320 myStrdupFunc); 3381 myStrdupFunc);
3321 } else { 3382 } else {
3322 maxmem = 0; 3383 maxmem = 0;
3323 } 3384 }
3324 } 3385 }
3325 else if ((!strcmp(argv[i], "-format")) || 3386 else if ((!strcmp(argv[i], "-format")) ||
3326 (!strcmp(argv[i], "--format"))) { 3387 (!strcmp(argv[i], "--format"))) {
3327 noblanks++; 3388 noblanks++;
3328 #ifdef LIBXML_OUTPUT_ENABLED 3389 #ifdef LIBXML_OUTPUT_ENABLED
3329 » format++; 3390 » format = 1;
3330 #endif /* LIBXML_OUTPUT_ENABLED */ 3391 #endif /* LIBXML_OUTPUT_ENABLED */
3331 xmlKeepBlanksDefault(0); 3392 xmlKeepBlanksDefault(0);
3332 } 3393 }
3394 else if ((!strcmp(argv[i], "-pretty")) ||
3395 (!strcmp(argv[i], "--pretty"))) {
3396 i++;
3397 #ifdef LIBXML_OUTPUT_ENABLED
3398 if (argv[i] != NULL) {
3399 format = atoi(argv[i]);
3400 if (format == 1) {
3401 noblanks++;
3402 xmlKeepBlanksDefault(0);
3403 }
3404 }
3405 #endif /* LIBXML_OUTPUT_ENABLED */
3406 }
3333 #ifdef LIBXML_READER_ENABLED 3407 #ifdef LIBXML_READER_ENABLED
3334 else if ((!strcmp(argv[i], "-stream")) || 3408 else if ((!strcmp(argv[i], "-stream")) ||
3335 (!strcmp(argv[i], "--stream"))) { 3409 (!strcmp(argv[i], "--stream"))) {
3336 stream++; 3410 stream++;
3337 } 3411 }
3338 else if ((!strcmp(argv[i], "-walker")) || 3412 else if ((!strcmp(argv[i], "-walker")) ||
3339 (!strcmp(argv[i], "--walker"))) { 3413 (!strcmp(argv[i], "--walker"))) {
3340 walker++; 3414 walker++;
3341 noout++; 3415 noout++;
3342 } 3416 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 if ((!strcmp(argv[i], "-relaxng")) || 3683 if ((!strcmp(argv[i], "-relaxng")) ||
3610 (!strcmp(argv[i], "--relaxng"))) { 3684 (!strcmp(argv[i], "--relaxng"))) {
3611 i++; 3685 i++;
3612 continue; 3686 continue;
3613 } 3687 }
3614 if ((!strcmp(argv[i], "-maxmem")) || 3688 if ((!strcmp(argv[i], "-maxmem")) ||
3615 (!strcmp(argv[i], "--maxmem"))) { 3689 (!strcmp(argv[i], "--maxmem"))) {
3616 i++; 3690 i++;
3617 continue; 3691 continue;
3618 } 3692 }
3693 if ((!strcmp(argv[i], "-pretty")) ||
3694 (!strcmp(argv[i], "--pretty"))) {
3695 i++;
3696 continue;
3697 }
3619 if ((!strcmp(argv[i], "-schema")) || 3698 if ((!strcmp(argv[i], "-schema")) ||
3620 (!strcmp(argv[i], "--schema"))) { 3699 (!strcmp(argv[i], "--schema"))) {
3621 i++; 3700 i++;
3622 continue; 3701 continue;
3623 } 3702 }
3624 if ((!strcmp(argv[i], "-schematron")) || 3703 if ((!strcmp(argv[i], "-schematron")) ||
3625 (!strcmp(argv[i], "--schematron"))) { 3704 (!strcmp(argv[i], "--schematron"))) {
3626 i++; 3705 i++;
3627 continue; 3706 continue;
3628 } 3707 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3713 #ifdef LIBXML_PATTERN_ENABLED 3792 #ifdef LIBXML_PATTERN_ENABLED
3714 if (patternc != NULL) 3793 if (patternc != NULL)
3715 xmlFreePattern(patternc); 3794 xmlFreePattern(patternc);
3716 #endif 3795 #endif
3717 xmlCleanupParser(); 3796 xmlCleanupParser();
3718 xmlMemoryDump(); 3797 xmlMemoryDump();
3719 3798
3720 return(progresult); 3799 return(progresult);
3721 } 3800 }
3722 3801
OLDNEW
« no previous file with comments | « third_party/libxml/src/xmlcatalog.c ('k') | third_party/libxml/src/xmlmemory.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698