int parse_env_file(
const char *fname,
- const char *seperator, ...) {
+ const char *separator, ...) {
int r = 0;
char *contents, *p;
assert(fname);
- assert(seperator);
+ assert(separator);
if ((r = read_full_file(fname, &contents)) < 0)
return r;
for (;;) {
const char *key = NULL;
- p += strspn(p, seperator);
+ p += strspn(p, separator);
p += strspn(p, WHITESPACE);
if (!*p)
va_list ap;
char **value;
- va_start(ap, seperator);
+ va_start(ap, separator);
while ((key = va_arg(ap, char *))) {
size_t n;
char *v;
continue;
p += n + 1;
- n = strcspn(p, seperator);
+ n = strcspn(p, separator);
if (n >= 2 &&
strchr(QUOTES, p[0]) &&
goto fail;
}
+ if (v[0] == '\0') {
+ /* return empty value strings as NULL */
+ free(v);
+ v = NULL;
+ }
+
free(*value);
*value = v;
}
if (!key)
- p += strcspn(p, seperator);
+ p += strcspn(p, separator);
}
fail: