Unit Test
[platform/upstream/libxml2.git] / debugXML.c
index c8efe6a..a1b550a 100644 (file)
@@ -44,10 +44,10 @@ struct _xmlDebugCtxt {
     int depth;                  /* current depth */
     xmlDocPtr doc;              /* current document */
     xmlNodePtr node;           /* current node */
-    xmlDictPtr dict;           /* the doc dictionnary */
+    xmlDictPtr dict;           /* the doc dictionary */
     int check;                  /* do just checkings */
     int errors;                 /* number of errors found */
-    int nodict;                        /* if the document has no dictionnary */
+    int nodict;                        /* if the document has no dictionary */
     int options;               /* options */
 };
 
@@ -164,7 +164,7 @@ xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg)
                    NULL, NULL, NULL, 0, 0,
                    "%s", msg);
 }
-static void
+static void LIBXML_ATTR_FORMAT(3,0)
 xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
 {
     ctxt->errors++;
@@ -174,7 +174,7 @@ xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
                    NULL, NULL, NULL, 0, 0,
                    msg, extra);
 }
-static void
+static void LIBXML_ATTR_FORMAT(3,0)
 xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra)
 {
     ctxt->errors++;
@@ -243,7 +243,7 @@ xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
  * @ctxt: the debug context
  * @name: the name
  *
- * Do debugging on the name, for example the dictionnary status and
+ * Do debugging on the name, for example the dictionary status and
  * conformance to the Name production.
  */
 static void
@@ -254,16 +254,18 @@ xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name)
            xmlDebugErr(ctxt, XML_CHECK_NO_NAME, "Name is NULL");
            return;
        }
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
         if (xmlValidateName(name, 0)) {
            xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME,
                         "Name is not an NCName '%s'", (const char *) name);
        }
+#endif
        if ((ctxt->dict != NULL) &&
            (!xmlDictOwns(ctxt->dict, name)) &&
             ((ctxt->doc == NULL) ||
              ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) {
            xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
-                        "Name is not from the document dictionnary '%s'",
+                        "Name is not from the document dictionary '%s'",
                         (const char *) name);
        }
     }
@@ -290,7 +292,7 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
             /* desactivated right now as it raises too many errors */
            if (doc->type == XML_DOCUMENT_NODE)
                xmlDebugErr(ctxt, XML_CHECK_NO_DICT,
-                           "Document has no dictionnary\n");
+                           "Document has no dictionary\n");
 #endif
            ctxt->nodict = 1;
        }
@@ -2946,7 +2948,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
         } else if (!strcmp(command, "save")) {
             xmlShellSave(ctxt, arg, NULL, NULL);
         } else if (!strcmp(command, "write")) {
-           if ((arg == NULL) || (arg[0] == 0))
+           if (arg[0] == 0)
                xmlGenericError(xmlGenericErrorContext,
                         "Write command requires a filename argument\n");
            else
@@ -3241,7 +3243,12 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
                 ctxt->node = (xmlNodePtr) ctxt->doc;
             } else {
 #ifdef LIBXML_XPATH_ENABLED
+                int l;
+
                 ctxt->pctxt->node = ctxt->node;
+               l = strlen(arg);
+               if ((l >= 2) && (arg[l - 1] == '/'))
+                   arg[l - 1] = 0;
                 list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
 #else
                 list = NULL;