fix typo
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index 8e7f0ce..803e912 100644 (file)
--- a/file.c
+++ b/file.c
  * This file contains the code for parsing uci config files
  */
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/file.h>
 #include <stdbool.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -373,7 +375,6 @@ static void uci_fixup_section(struct uci_context *ctx, struct uci_section *s)
 static void uci_parse_config(struct uci_context *ctx, char **str)
 {
        struct uci_parse_context *pctx = ctx->pctx;
-       struct uci_section *s;
        char *name = NULL;
        char *type = NULL;
 
@@ -524,7 +525,7 @@ static void uci_export_package(struct uci_package *p, FILE *stream, bool header)
        uci_foreach_element(&p->sections, s) {
                struct uci_section *sec = uci_to_section(s);
                fprintf(stream, "\nconfig '%s'", uci_escape(ctx, sec->type));
-               if (!sec->anonymous)
+               if (!sec->anonymous || (ctx->flags & UCI_FLAG_EXPORT_NAME))
                        fprintf(stream, " '%s'", uci_escape(ctx, sec->e.name));
                fprintf(stream, "\n");
                uci_foreach_element(&sec->options, o) {