diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/confnode.c | 1 | ||||
-rw-r--r-- | src/config/conftree.c | 2 | ||||
-rw-r--r-- | src/config/lexparse.c | 1 | ||||
-rw-r--r-- | src/config/tipidee-config-internal.h | 2 | ||||
-rw-r--r-- | src/config/tipidee-config-preprocess.c | 37 |
5 files changed, 30 insertions, 13 deletions
diff --git a/src/config/confnode.c b/src/config/confnode.c index 758e79d..2d5aeea 100644 --- a/src/config/confnode.c +++ b/src/config/confnode.c @@ -8,7 +8,6 @@ #include "tipidee-config-internal.h" -#define dienomem() strerr_diefu1sys(111, "stralloc_catb") #define diestorage() strerr_diefu2x(100, "add node to configuration tree", ": too much data") #define diefilepos() strerr_diefu2x(100, "add node to configuration tree", ": file too large") diff --git a/src/config/conftree.c b/src/config/conftree.c index fc0b5bc..4eac28e 100644 --- a/src/config/conftree.c +++ b/src/config/conftree.c @@ -11,8 +11,6 @@ #include "tipidee-config-internal.h" -#define dienomem() strerr_diefu1sys(111, "stralloc_catb") - static void *confnode_dtok (uint32_t d, void *data) { return g.storage.s + GENSETDYN_P(confnode, (gensetdyn *)data, d)->key ; diff --git a/src/config/lexparse.c b/src/config/lexparse.c index da9d7f5..99693a5 100644 --- a/src/config/lexparse.c +++ b/src/config/lexparse.c @@ -15,7 +15,6 @@ #include <tipidee/config.h> #include "tipidee-config-internal.h" -#define dienomem() strerr_diefu1sys(111, "stralloc_catb") #define dietoobig() strerr_diefu1sys(100, "read configuration") typedef struct mdt_s mdt, *mdt_ref ; diff --git a/src/config/tipidee-config-internal.h b/src/config/tipidee-config-internal.h index 154c6ff..7ffee8a 100644 --- a/src/config/tipidee-config-internal.h +++ b/src/config/tipidee-config-internal.h @@ -10,6 +10,8 @@ #include <skalibs/stralloc.h> #include <skalibs/cdbmake.h> +#define dienomem() strerr_diefu1sys(111, "stralloc_catb") + typedef struct confnode_s confnode, *confnode_ref ; struct confnode_s { diff --git a/src/config/tipidee-config-preprocess.c b/src/config/tipidee-config-preprocess.c index 03b54f1..a5a47c2 100644 --- a/src/config/tipidee-config-preprocess.c +++ b/src/config/tipidee-config-preprocess.c @@ -149,23 +149,22 @@ static void includefromhere (char const *file) uint32_t d ; uint32_t line = 1 ; char buf[4096] ; - char linefmt[UINT32_FMT] = "1" ; unsigned char state = 0 ; if (!stralloc_catb(&namesa, "\004", 1) || sarealpath(&namesa, file) < 0 || !stralloc_0(&namesa)) dienomem() ; if (avltree_search(&namemap, namesa.s + namesabase + 1, &d)) { if (namesa.s[d] & 0x04) - strerr_dief3x(3, "file ", namesa.s + namesabase + 1, " is included in a cycle") ; + strerr_dief3x(2, "file ", namesa.s + namesabase + 1, " is included in a cycle") ; if (!(namesa.s[d] & 0x02)) - strerr_dief3x(3, "file ", namesa.s + namesabase + 1, " is included twice but does not declare !included: unique or !included: multiple") ; + strerr_dief3x(2, "file ", namesa.s + namesabase + 1, " is included twice but does not declare !included: unique or !included: multiple") ; namesa.len = namesabase ; if (namesa.s[d] & 0x01) return ; } else { if (namesabase > UINT32_MAX) - strerr_dief3x(3, "in ", namesa.s + d + 1, ": too many, too long filenames") ; + strerr_dief3x(100, "in ", namesa.s + d + 1, ": too many, too long filenames") ; d = namesabase ; if (!avltree_insert(&namemap, d)) dienomem() ; } @@ -197,7 +196,11 @@ static void includefromhere (char const *file) if (!stralloc_0(&sa)) dienomem() ; cmd = idcmd(sa.s + sastart) ; if (cmd == -1) - strerr_dief6x(2, "in ", namesa.s + d + 1, " line ", linefmt, ": unrecognized directive: ", sa.s + sastart) ; + { + char linefmt[UINT32_FMT] ; + linefmt[uint32_fmt(linefmt, line)] = 0 ; + strerr_dief6x(1, "in ", namesa.s + d + 1, " line ", linefmt, ": unrecognized directive: ", sa.s + sastart) ; + } sa.len = sastart ; } if (what & 0x0080) @@ -207,17 +210,28 @@ static void includefromhere (char const *file) { case 2 : if (namesa.s[d] & 2) - strerr_dief5x(3, "in ", namesa.s + d + 1, " line ", linefmt, ": extra !included: directive") ; + { + char linefmt[UINT32_FMT] ; + linefmt[uint32_fmt(linefmt, line)] = 0 ; + strerr_dief5x(1, "in ", namesa.s + d + 1, " line ", linefmt, ": extra !included: directive") ; + } if (!strcmp(sa.s + sastart, "unique")) namesa.s[d] |= 3 ; else if (!strcmp(sa.s + sastart, "multiple")) namesa.s[d] |= 2 ; - else strerr_dief6x(3, "in ", namesa.s + d + 1, " line ", linefmt, ": invalid !included: argument: ", sa.s + sastart) ; + else + { + char linefmt[UINT32_FMT] ; + linefmt[uint32_fmt(linefmt, line)] = 0 ; + strerr_dief6x(1, "in ", namesa.s + d + 1, " line ", linefmt, ": invalid !included: argument: ", sa.s + sastart) ; + } break ; case 1 : case 0 : { int fdhere = open2(".", O_RDONLY | O_DIRECTORY) ; + char linefmt[UINT32_FMT] ; if (fdhere == -1) strerr_dief3sys(111, "in ", namesa.s + d + 1, ": unable to open base directory: ") ; + linefmt[uint32_fmt(linefmt, line)] = 0 ; if (cmd & 1) { if (chdir(sa.s + sastart) == -1) @@ -239,9 +253,14 @@ static void includefromhere (char const *file) } sa.len = sastart ; } - if (c == '\n' && state <= 8) linefmt[uint32_fmt(linefmt, ++line)] = 0 ; + if (c == '\n' && state <= 8) line++ ; + } + if (state > 8) + { + char linefmt[UINT32_FMT] ; + linefmt[uint32_fmt(linefmt, line)] = 0 ; + strerr_dief5x(1, "in ", namesa.s + d + 1, " line ", linefmt, ": syntax error: invalid ! line") ; } - if (state > 8) strerr_dief5x(2, "in ", namesa.s + d + 1, " line ", linefmt, ": syntax error: invalid ! line") ; fd_close(fd) ; sa.len = sabase ; namesa.s[d] &= ~0x04 ; |