Commit 21f436f3 authored by Michael R Sweet's avatar Michael R Sweet

Fix loading of text values with MXML_NO_CALLBACK or MXML_TEXT_CALLBACK (Bug #502)

Update unit test program to validate fix and cleanup output so that we can get
proper error messages.
parent 17f3dfcc
......@@ -4,9 +4,8 @@ Mini-XML 2.8 is now available for download from:
Mini-XML 2.8 fixes some minor platform and XML issues. Changes include:
- Now call docsetutil using xcrun on OS X (Bug #458)
- mxmldoc did not escape special HTML characters inside @code foo@
comments.
- Fixed a memory leak in mxmlElementDeleteAttr (Bug #452)
- Added MXML_MAJOR/MINOR_VERSION definitions to mxml.h (Bug $461)
- Fixed a bug reading UTF-16 characters from a file (Bug #454)
- Now call docsetutil using xcrun on OS X (Bug #458)
- mxmldoc did not escape special HTML characters inside @code foo@ comments.
- Fixed a memory leak in mxmlElementDeleteAttr (Bug #452)
- Added MXML_MAJOR/MINOR_VERSION definitions to mxml.h (Bug $461)
- Fixed a bug reading UTF-16 characters from a file (Bug #454)
CHANGES - 2014-01-04
CHANGES - 2014-10-19
--------------------
CHANGES IN Mini-XML 2.9
- mxmlLoad* did not correctly load value nodes with MXML_NO_CALLBACK
or MXML_TEXT_CALLBACK (Bug #502)
CHANGES IN Mini-XML 2.8
- Now call docsetutil using xcrun on OS X (Bug #458)
......
......@@ -352,8 +352,8 @@ testmxml: libmxml.a testmxml.o
echo Linking $@...
$(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS)
@echo Testing library...
./testmxml test.xml >temp1.xml 2>temp1s.xml
./testmxml temp1.xml >temp2.xml 2>temp2s.xml
./testmxml test.xml temp1s.xml >temp1.xml
./testmxml temp1.xml temp2s.xml >temp2.xml
@if cmp temp1.xml temp2.xml; then \
echo Stdio file test passed!; \
$(RM) temp2.xml temp2s.xml; \
......
This diff is collapsed.
......@@ -21,7 +21,7 @@ dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h)
dnl Version number...
VERSION=2.8
VERSION=2.9
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
......
......@@ -3,7 +3,7 @@
<head>
<title>Documentation </title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="creator" content="Mini-XML v2.8">
<meta name="creator" content="Mini-XML v2.9">
<style type="text/css"><!--
body, p, h1, h2, h3, h4 {
font-family: "lucida grande", geneva, helvetica, arial, sans-serif;
......
......@@ -1798,6 +1798,8 @@ mxml_load_data(
if (cb)
type = (*cb)(parent);
else
type = MXML_TEXT;
}
}
}
......@@ -1884,6 +1886,8 @@ mxml_load_data(
if (cb)
type = (*cb)(parent);
else
type = MXML_TEXT;
}
}
}
......
......@@ -3,6 +3,11 @@
*
* Test program for Mini-XML, a small XML-like file parsing library.
*
* Usage:
*
* ./testmxml input.xml [string-output.xml] >stdio-output.xml
* ./testmxml "<?xml ..." [string-output.xml] >stdio-output.xml
*
* Copyright 2003-2014 by Michael R Sweet.
*
* These coded instructions, statements, and computer programs are the
......@@ -74,9 +79,9 @@ main(int argc, /* I - Number of command-line args */
* Check arguments...
*/
if (argc != 2)
if (argc != 2 && argc != 3)
{
fputs("Usage: testmxml filename.xml\n", stderr);
fputs("Usage: testmxml filename.xml [string-output.xml]\n", stderr);
return (1);
}
......@@ -445,6 +450,68 @@ main(int argc, /* I - Number of command-line args */
mxmlDelete(tree);
/*
* Open the file/string using the default (MXML_NO_CALLBACK) callback...
*/
if (argv[1][0] == '<')
tree = mxmlLoadString(NULL, argv[1], MXML_NO_CALLBACK);
else if ((fp = fopen(argv[1], "rb")) == NULL)
{
perror(argv[1]);
return (1);
}
else
{
/*
* Read the file...
*/
tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
fclose(fp);
}
if (!tree)
{
fputs("Unable to read XML file with default callback!\n", stderr);
return (1);
}
if (!strcmp(argv[1], "test.xml"))
{
const char *text; /* Text value */
/*
* Verify that mxmlFindElement() and indirectly mxmlWalkNext() work
* properly...
*/
if ((node = mxmlFindPath(tree, "group/option/keyword")) == NULL)
{
fputs("Unable to find group/option/keyword element in XML tree!\n", stderr);
mxmlDelete(tree);
return (1);
}
if (node->type != MXML_TEXT)
{
fputs("No child node of group/option/keyword!\n", stderr);
mxmlSaveFile(tree, stderr, MXML_NO_CALLBACK);
mxmlDelete(tree);
return (1);
}
if ((text = mxmlGetText(node, NULL)) == NULL || strcmp(text, "InputSlot"))
{
fprintf(stderr, "Child node of group/option/value has value \"%s\" instead of \"InputSlot\"!\n", text ? text : "(null)");
mxmlDelete(tree);
return (1);
}
}
mxmlDelete(tree);
/*
* Open the file...
*/
......@@ -507,7 +574,14 @@ main(int argc, /* I - Number of command-line args */
*/
if (mxmlSaveString(tree, buffer, sizeof(buffer), whitespace_cb) > 0)
fputs(buffer, stderr);
{
if (argc == 3)
{
fp = fopen(argv[2], "w");
fputs(buffer, fp);
fclose(fp);
}
}
/*
* Delete the tree...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment