chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
conf-parser: get rid of redundant NEWLINES definition
[elogind.git]
/
conf-parser.c
diff --git
a/conf-parser.c
b/conf-parser.c
index 4075465b2496719bfec6275eddc22d4c68f55e99..712b4e489c3fc9e7c35988d3b79978ead1bd458d 100644
(file)
--- a/
conf-parser.c
+++ b/
conf-parser.c
@@
-32,7
+32,6
@@
#include "log.h"
#define COMMENTS "#;\n"
#include "log.h"
#define COMMENTS "#;\n"
-#define NEWLINES "\n\r"
#define LINE_MAX 4096
/* Run the user supplied parser for an assignment */
#define LINE_MAX 4096
/* Run the user supplied parser for an assignment */
@@
-135,6
+134,7
@@
int config_parse(const char *filename, FILE *f, const char* const * sections, co
unsigned line = 0;
char *section = NULL;
int r;
unsigned line = 0;
char *section = NULL;
int r;
+ bool ours = false;
assert(filename);
assert(t);
assert(filename);
assert(t);
@@
-145,6
+145,8
@@
int config_parse(const char *filename, FILE *f, const char* const * sections, co
log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
goto finish;
}
log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
goto finish;
}
+
+ ours = true;
}
while (!feof(f)) {
}
while (!feof(f)) {
@@
-168,7
+170,7
@@
int config_parse(const char *filename, FILE *f, const char* const * sections, co
finish:
free(section);
finish:
free(section);
- if (f)
+ if (f
&& ours
)
fclose(f);
return r;
fclose(f);
return r;
@@
-365,8
+367,12
@@
int config_parse_strv(
if (!(n = new(char*, k+1)))
return -ENOMEM;
if (!(n = new(char*, k+1)))
return -ENOMEM;
- for (k = 0; (*sv)[k]; k++)
- n[k] = (*sv)[k];
+ if (*sv)
+ for (k = 0; (*sv)[k]; k++)
+ n[k] = (*sv)[k];
+ else
+ k = 0;
+
FOREACH_WORD_QUOTED(w, l, rvalue, state)
if (!(n[k++] = strndup(w, l)))
goto fail;
FOREACH_WORD_QUOTED(w, l, rvalue, state)
if (!(n[k++] = strndup(w, l)))
goto fail;