1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

fixed XML Base computation which was broken added a base function to the

* tree.c: fixed XML Base computation which was broken
* debugXML.c: added a base function to the shell
* Makefile.am result/scripts/* test/scripts/*: added scripts
  based regression tests, and adding 2 XML Base tests
Daniel
This commit is contained in:
Daniel Veillard
2001-07-09 16:01:19 +00:00
parent 19e96c3059
commit b8c9be9718
10 changed files with 140 additions and 11 deletions

View File

@ -1091,6 +1091,34 @@ xmlShellList(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED , char *arg ATTRIBUTE_UNUSED,
return(0);
}
/**
* xmlShellBase:
* @ctxt: the shell context
* @arg: unused
* @node: a node
* @node2: unused
*
* Implements the XML shell function "base"
* dumps the current XML base of the node
*
* Returns 0
*/
static int
xmlShellBase(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED, xmlNodePtr node,
xmlNodePtr node2 ATTRIBUTE_UNUSED) {
xmlChar *base;
base = xmlNodeGetBase(node->doc, node);
if (base == NULL) {
printf(" No base found !!!\n");
} else {
printf("%s\n", base);
xmlFree(base);
}
return(0);
}
/**
* xmlShellDir:
* @ctxt: the shell context
@ -1654,6 +1682,8 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
printf("%s\n", dir);
} else if (!strcmp(command, "du")) {
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
} else if (!strcmp(command, "base")) {
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
} else if ((!strcmp(command, "ls")) ||
(!strcmp(command, "dir"))) {
int dir = (!strcmp(command, "dir"));
@ -1724,7 +1754,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
break;
}
#ifdef LIBXML_XPATH_ENABLED
xmlXPathFreeNodeSetList(list);
xmlXPathFreeObject(list);
#endif
} else {
xmlGenericError(xmlGenericErrorContext,
@ -1790,7 +1820,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
break;
}
#ifdef LIBXML_XPATH_ENABLED
xmlXPathFreeNodeSetList(list);
xmlXPathFreeObject(list);
#endif
} else {
xmlGenericError(xmlGenericErrorContext,
@ -1860,7 +1890,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
break;
}
#ifdef LIBXML_XPATH_ENABLED
xmlXPathFreeNodeSetList(list);
xmlXPathFreeObject(list);
#endif
} else {
xmlGenericError(xmlGenericErrorContext,
@ -1880,6 +1910,8 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
if (ctxt->loaded) {
xmlFreeDoc(ctxt->doc);
}
if (ctxt->filename != NULL)
xmlFree(ctxt->filename);
xmlFree(ctxt);
if (cmdline != NULL)
free(cmdline); /* not xmlFree here ! */