summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/settings.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/settings.c b/src/settings.c
index 115a71c..5731577 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -201,9 +201,8 @@ void BarSettingsRead (BarSettings_t *settings) {
for (size_t j = 0; j < sizeof (configfiles) / sizeof (*configfiles); j++) {
static const char *formatMsgPrefix = "format_msg_";
FILE *configfd;
- /* getline allocates these on the first run */
- char *line = NULL;
- size_t lineLen = 0, lineNum = 0;
+ char line[512];
+ size_t lineNum = 0;
char * const path = BarGetXdgConfigDir (configfiles[j]);
assert (path != NULL);
@@ -214,11 +213,16 @@ void BarSettingsRead (BarSettings_t *settings) {
while (1) {
++lineNum;
- ssize_t ret = getline (&line, &lineLen, configfd);
- if (ret == -1) {
+ char * const ret = fgets (line, sizeof (line), configfd);
+ if (ret == NULL) {
/* EOF or error */
break;
}
+ if (strchr (line, '\n') == NULL && !feof (configfd)) {
+ BarUiMsg (settings, MSG_INFO, "Line %s:%zu too long, "
+ "ignoring\n", path, lineNum);
+ continue;
+ }
/* parse lines that match "^\s*(.*?)\s?=\s?(.*)$". Windows and Unix
* line terminators are supported. */
char *key = line;
@@ -410,7 +414,6 @@ void BarSettingsRead (BarSettings_t *settings) {
fclose (configfd);
free (path);
- free (line);
}
/* check environment variable if proxy is not set explicitly */