contain new-line separated variable
assignments. Empty lines and lines
starting with ; or # will be ignored,
- which may be used for commenting. The
- parser strips leading and
- trailing whitespace from the values
+ which may be used for commenting. A line
+ ending with a backslash will be concatenated
+ with the following one, allowing multiline variable
+ definitions. The parser strips leading
+ and trailing whitespace from the values
of assignments, unless you use
double quotes (").</para>
char ***rl) {
FILE *f;
+ char *b;
+ char *c = NULL;
char **m = NULL;
int r;
return -errno;
while (!feof(f)) {
- char l[LINE_MAX], *p, *u;
+ char l[LINE_MAX], *p, *u, *cs;
char **t;
if (!fgets(l, sizeof(l), f)) {
- if (feof(f))
+ if(!feof(f)) {
+ r = -errno;
+ goto finish;
+ }
+ else if (!c)
break;
- r = -errno;
- goto finish;
}
- p = strstrip(l);
+ cs = endswith(l, "\\\n");
+ if (cs) {
+
+ *cs = '\0';
+ b = strappend(c, l);
+ if (!b) {
+ r = log_oom();
+ goto finish;
+ }
+ free(c);
+ c = b;
+ *l = '\0';
+ continue;
+ }
+
+ if (c) {
+ b = strappend(c, l);
+ if (!b) {
+ r = log_oom();
+ goto finish;
+ }
+ free(c);
+ c = b;
+ }
+
+ p = strstrip(c ? c : l);
if (!*p)
continue;
r = log_oom();
goto finish;
}
+ free(c);
+ c = NULL;
t = strv_append(m, u);
free(u);
if (f)
fclose(f);
+ free(c);
+
strv_free(m);
return r;