--- cfg_syn.c 2002/07/10 14:46:28 1.12
+++ cfg_syn.c 2002/07/18 15:34:55 1.13
@@ -270,7 +270,8 @@
cfg_rc_t rc;
char *token;
- rc = cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TYPE, &type);
+ if ((rc = cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TYPE, &type)) != CFG_OK)
+ return;
if (type == CFG_NODE_TYPE_SEQ) {
export_format(ctx, "{\n");
export_indent(ctx, 1);
@@ -313,6 +314,7 @@
cfg_buf_t *buf;
cfg_rc_t rc;
export_t ctx;
+ cfg_node_t *root;
if (node == NULL || output == NULL)
return CFG_ERR_ARG;
@@ -323,12 +325,20 @@
ctx.buf = buf;
ctx.indent = 0;
- /* first SEQ node is special, so expand it manually instead
- of just calling once export_node(&ctx, node); */
- cfg_node_get(cfg, node, CFG_NODE_ATTR_CHILD1, &node);
- while (node != NULL) {
+ if ((rc = cfg_node_root(cfg, &root)) != CFG_OK)
+ return rc;
+ if (node == root) {
+ /* if we dump the whole configuration, treat the first SEQ node special
+ because of the implicit braces around it. So expand it manually instead
+ of just calling once export_node(&ctx, node); */
+ cfg_node_get(cfg, node, CFG_NODE_ATTR_CHILD1, &node);
+ while (node != NULL) {
+ export_node(&ctx, node);
+ cfg_node_get(cfg, node, CFG_NODE_ATTR_RBROTH, &node);
+ }
+ }
+ else {
export_node(&ctx, node);
- cfg_node_get(cfg, node, CFG_NODE_ATTR_RBROTH, &node);
}
cfg_buf_content(buf, output, NULL, NULL);
|