Wrapping was not disabled when mxmlSetWrapMargin(0) was called, and

"<?xml ... ?>" was always followed by a newline (STR #76)
pull/193/head
Michael R Sweet 17 years ago
parent d7fcf13ff8
commit a38251bc9b
  1. 3
      CHANGES
  2. 24
      mxml-file.c
  3. 6
      mxml.xml
  4. 5
      mxmldoc.c
  5. 5
      testmxml.c

@ -3,6 +3,9 @@ CHANGES - 2008-03-20
CHANGES IN Mini-XML 2.5.1
- Wrapping was not disabled when mxmlSetWrapMargin(0) was
called, and "<?xml ... ?>" was always followed by a newline
(STR #76)
- The mxml.pc.in file was broken (STR #79)
- The mxmldoc program now handles "typedef enum name {} name"
correctly (STR #72)

@ -606,22 +606,19 @@ mxmlSetErrorCallback(mxml_error_cb_t cb)/* I - Error callback function */
/*
* 'mxmlSetWrapMargin()' - Set the the wrap margin when saving XML data.
*
* Wrapping is disabled when "column" is <= 0.
* Wrapping is disabled when "column" is 0.
*
* @since Mini-XML 2.3@
*/
void
mxmlSetWrapMargin(int column) /* I - Column for wrapping */
mxmlSetWrapMargin(int column) /* I - Column for wrapping, 0 to disable wrapping */
{
_mxml_global_t *global = _mxml_global();
/* Global data */
if (column <= 0)
global->wrap = 2147483647;
else
global->wrap = column;
global->wrap = column;
}
@ -2804,13 +2801,6 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
for (ptr = node->value.element.name; *ptr; ptr ++)
if ((*putc_cb)(*ptr, p) < 0)
return (-1);
/*
* Prefer a newline for whitespace after ?xml...
*/
if (!strncmp(node->value.element.name, "?xml", 4))
col = global->wrap;
}
else if (mxml_write_name(node->value.element.name, p, putc_cb) < 0)
return (-1);
@ -2826,7 +2816,7 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
if (attr->value)
width += strlen(attr->value) + 3;
if ((col + width) > global->wrap)
if (global->wrap > 0 && (col + width) > global->wrap)
{
if ((*putc_cb)('\n', p) < 0)
return (-1);
@ -2931,7 +2921,7 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
case MXML_INTEGER :
if (node->prev)
{
if (col > global->wrap)
if (global->wrap > 0 && col > global->wrap)
{
if ((*putc_cb)('\n', p) < 0)
return (-1);
@ -2961,7 +2951,7 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
case MXML_REAL :
if (node->prev)
{
if (col > global->wrap)
if (global->wrap > 0 && col > global->wrap)
{
if ((*putc_cb)('\n', p) < 0)
return (-1);
@ -2984,7 +2974,7 @@ mxml_write_node(mxml_node_t *node, /* I - Node to write */
case MXML_TEXT :
if (node->value.text.whitespace && col > 0)
{
if (col > global->wrap)
if (global->wrap > 0 && col > global->wrap)
{
if ((*putc_cb)('\n', p) < 0)
return (-1);

@ -1,7 +1,5 @@
<?xml version="1.0"?><mxmldoc
xmlns="http://www.easysw.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.minixml.org/mxmldoc.xsd">
<?xml version="1.0"?>
<mxmldoc xmlns="http://www.easysw.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.minixml.org/mxmldoc.xsd">
<function name="mxmlAdd">
<description>Add a node to a tree.

@ -456,6 +456,8 @@ main(int argc, /* I - Number of command-line args */
* Write over the existing XML file...
*/
mxmlSetWrapMargin(0);
if (mxmlSaveFile(doc, fp, ws_cb))
{
fprintf(stderr,
@ -4701,7 +4703,8 @@ ws_cb(mxml_node_t *node, /* I - Element node */
strcmp(name, "struct") &&
strcmp(name, "typedef") &&
strcmp(name, "union") &&
strcmp(name, "variable"))
strcmp(name, "variable") &&
strncmp(name, "?xml", 4))
return (NULL);
else
return ("\n");

@ -710,7 +710,10 @@ whitespace_cb(mxml_node_t *node, /* I - Element node */
}
else if (!strncmp(name, "?xml", 4))
{
return (NULL);
if (where == MXML_WS_AFTER_OPEN)
return ("\n");
else
return (NULL);
}
else if (where == MXML_WS_BEFORE_OPEN ||
((!strcmp(name, "choice") || !strcmp(name, "option")) &&

Loading…
Cancel
Save