OLD | NEW |
1 /* | 1 /* |
2 * debugXML.c : This is a set of routines used for debugging the tree | 2 * debugXML.c : This is a set of routines used for debugging the tree |
3 * produced by the XML parser. | 3 * produced by the XML parser. |
4 * | 4 * |
5 * See Copyright for the status of this software. | 5 * See Copyright for the status of this software. |
6 * | 6 * |
7 * Daniel Veillard <daniel@veillard.com> | 7 * Daniel Veillard <daniel@veillard.com> |
8 */ | 8 */ |
9 | 9 |
10 #define IN_LIBXML | 10 #define IN_LIBXML |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return(-3); | 134 return(-3); |
135 } | 135 } |
136 | 136 |
137 static void | 137 static void |
138 xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt) | 138 xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt) |
139 { | 139 { |
140 if (ctxt->check) | 140 if (ctxt->check) |
141 return; | 141 return; |
142 if ((ctxt->output != NULL) && (ctxt->depth > 0)) { | 142 if ((ctxt->output != NULL) && (ctxt->depth > 0)) { |
143 if (ctxt->depth < 50) | 143 if (ctxt->depth < 50) |
144 fprintf(ctxt->output, &ctxt->shift[100 - 2 * ctxt->depth]); | 144 fprintf(ctxt->output, "%s", &ctxt->shift[100 - 2 * ctxt->depth]); |
145 else | 145 else |
146 fprintf(ctxt->output, ctxt->shift); | 146 fprintf(ctxt->output, "%s", ctxt->shift); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 /** | 150 /** |
151 * xmlDebugErr: | 151 * xmlDebugErr: |
152 * @ctxt: a debug context | 152 * @ctxt: a debug context |
153 * @error: the error code | 153 * @error: the error code |
154 * | 154 * |
155 * Handle a debug error. | 155 * Handle a debug error. |
156 */ | 156 */ |
157 static void | 157 static void |
158 xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg) | 158 xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg) |
159 { | 159 { |
160 ctxt->errors++; | 160 ctxt->errors++; |
161 __xmlRaiseError(NULL, NULL, NULL, | 161 __xmlRaiseError(NULL, NULL, NULL, |
162 NULL, ctxt->node, XML_FROM_CHECK, | 162 NULL, ctxt->node, XML_FROM_CHECK, |
163 error, XML_ERR_ERROR, NULL, 0, | 163 error, XML_ERR_ERROR, NULL, 0, |
164 NULL, NULL, NULL, 0, 0, | 164 NULL, NULL, NULL, 0, 0, |
165 » » msg); | 165 » » "%s", msg); |
166 } | 166 } |
167 static void | 167 static void |
168 xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra) | 168 xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra) |
169 { | 169 { |
170 ctxt->errors++; | 170 ctxt->errors++; |
171 __xmlRaiseError(NULL, NULL, NULL, | 171 __xmlRaiseError(NULL, NULL, NULL, |
172 NULL, ctxt->node, XML_FROM_CHECK, | 172 NULL, ctxt->node, XML_FROM_CHECK, |
173 error, XML_ERR_ERROR, NULL, 0, | 173 error, XML_ERR_ERROR, NULL, 0, |
174 NULL, NULL, NULL, 0, 0, | 174 NULL, NULL, NULL, 0, 0, |
175 msg, extra); | 175 msg, extra); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (ctxt->check) { | 252 if (ctxt->check) { |
253 if (name == NULL) { | 253 if (name == NULL) { |
254 xmlDebugErr(ctxt, XML_CHECK_NO_NAME, "Name is NULL"); | 254 xmlDebugErr(ctxt, XML_CHECK_NO_NAME, "Name is NULL"); |
255 return; | 255 return; |
256 } | 256 } |
257 if (xmlValidateName(name, 0)) { | 257 if (xmlValidateName(name, 0)) { |
258 xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME, | 258 xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME, |
259 "Name is not an NCName '%s'", (const char *) name); | 259 "Name is not an NCName '%s'", (const char *) name); |
260 } | 260 } |
261 if ((ctxt->dict != NULL) && | 261 if ((ctxt->dict != NULL) && |
262 » (!xmlDictOwns(ctxt->dict, name))) { | 262 » (!xmlDictOwns(ctxt->dict, name)) && |
| 263 ((ctxt->doc == NULL) || |
| 264 ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0
))) { |
263 xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT, | 265 xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT, |
264 "Name is not from the document dictionnary '%s'", | 266 "Name is not from the document dictionnary '%s'", |
265 (const char *) name); | 267 (const char *) name); |
266 } | 268 } |
267 } | 269 } |
268 } | 270 } |
269 | 271 |
270 static void | 272 static void |
271 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) { | 273 xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) { |
272 xmlDocPtr doc; | 274 xmlDocPtr doc; |
(...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2794 * Implements the XML shell | 2796 * Implements the XML shell |
2795 * This allow to load, validate, view, modify and save a document | 2797 * This allow to load, validate, view, modify and save a document |
2796 * using a environment similar to a UNIX commandline. | 2798 * using a environment similar to a UNIX commandline. |
2797 */ | 2799 */ |
2798 void | 2800 void |
2799 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input, | 2801 xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input, |
2800 FILE * output) | 2802 FILE * output) |
2801 { | 2803 { |
2802 char prompt[500] = "/ > "; | 2804 char prompt[500] = "/ > "; |
2803 char *cmdline = NULL, *cur; | 2805 char *cmdline = NULL, *cur; |
2804 int nbargs; | |
2805 char command[100]; | 2806 char command[100]; |
2806 char arg[400]; | 2807 char arg[400]; |
2807 int i; | 2808 int i; |
2808 xmlShellCtxtPtr ctxt; | 2809 xmlShellCtxtPtr ctxt; |
2809 xmlXPathObjectPtr list; | 2810 xmlXPathObjectPtr list; |
2810 | 2811 |
2811 if (doc == NULL) | 2812 if (doc == NULL) |
2812 return; | 2813 return; |
2813 if (filename == NULL) | 2814 if (filename == NULL) |
2814 return; | 2815 return; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2846 * Get a new command line | 2847 * Get a new command line |
2847 */ | 2848 */ |
2848 cmdline = ctxt->input(prompt); | 2849 cmdline = ctxt->input(prompt); |
2849 if (cmdline == NULL) | 2850 if (cmdline == NULL) |
2850 break; | 2851 break; |
2851 | 2852 |
2852 /* | 2853 /* |
2853 * Parse the command itself | 2854 * Parse the command itself |
2854 */ | 2855 */ |
2855 cur = cmdline; | 2856 cur = cmdline; |
2856 nbargs = 0; | |
2857 while ((*cur == ' ') || (*cur == '\t')) | 2857 while ((*cur == ' ') || (*cur == '\t')) |
2858 cur++; | 2858 cur++; |
2859 i = 0; | 2859 i = 0; |
2860 while ((*cur != ' ') && (*cur != '\t') && | 2860 while ((*cur != ' ') && (*cur != '\t') && |
2861 (*cur != '\n') && (*cur != '\r')) { | 2861 (*cur != '\n') && (*cur != '\r')) { |
2862 if (*cur == 0) | 2862 if (*cur == 0) |
2863 break; | 2863 break; |
2864 command[i++] = *cur++; | 2864 command[i++] = *cur++; |
2865 } | 2865 } |
2866 command[i] = 0; | 2866 command[i] = 0; |
2867 if (i == 0) | 2867 if (i == 0) |
2868 continue; | 2868 continue; |
2869 nbargs++; | |
2870 | 2869 |
2871 /* | 2870 /* |
2872 * Parse the argument | 2871 * Parse the argument |
2873 */ | 2872 */ |
2874 while ((*cur == ' ') || (*cur == '\t')) | 2873 while ((*cur == ' ') || (*cur == '\t')) |
2875 cur++; | 2874 cur++; |
2876 i = 0; | 2875 i = 0; |
2877 while ((*cur != '\n') && (*cur != '\r') && (*cur != 0)) { | 2876 while ((*cur != '\n') && (*cur != '\r') && (*cur != 0)) { |
2878 if (*cur == 0) | 2877 if (*cur == 0) |
2879 break; | 2878 break; |
2880 arg[i++] = *cur++; | 2879 arg[i++] = *cur++; |
2881 } | 2880 } |
2882 arg[i] = 0; | 2881 arg[i] = 0; |
2883 if (i != 0) | |
2884 nbargs++; | |
2885 | 2882 |
2886 /* | 2883 /* |
2887 * start interpreting the command | 2884 * start interpreting the command |
2888 */ | 2885 */ |
2889 if (!strcmp(command, "exit")) | 2886 if (!strcmp(command, "exit")) |
2890 break; | 2887 break; |
2891 if (!strcmp(command, "quit")) | 2888 if (!strcmp(command, "quit")) |
2892 break; | 2889 break; |
2893 if (!strcmp(command, "bye")) | 2890 if (!strcmp(command, "bye")) |
2894 break; | 2891 break; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 xmlFree(ctxt->filename); | 3254 xmlFree(ctxt->filename); |
3258 xmlFree(ctxt); | 3255 xmlFree(ctxt); |
3259 if (cmdline != NULL) | 3256 if (cmdline != NULL) |
3260 free(cmdline); /* not xmlFree here ! */ | 3257 free(cmdline); /* not xmlFree here ! */ |
3261 } | 3258 } |
3262 | 3259 |
3263 #endif /* LIBXML_XPATH_ENABLED */ | 3260 #endif /* LIBXML_XPATH_ENABLED */ |
3264 #define bottom_debugXML | 3261 #define bottom_debugXML |
3265 #include "elfgcchack.h" | 3262 #include "elfgcchack.h" |
3266 #endif /* LIBXML_DEBUG_ENABLED */ | 3263 #endif /* LIBXML_DEBUG_ENABLED */ |
OLD | NEW |