Remove readline.c
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
This commit is contained in:
parent
51838df916
commit
70ce4f9dc6
33
main.c
33
main.c
@ -23,7 +23,6 @@
|
|||||||
#include "cairo.h"
|
#include "cairo.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "loop.h"
|
#include "loop.h"
|
||||||
#include "readline.h"
|
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "wlr-input-inhibitor-unstable-v1-client-protocol.h"
|
#include "wlr-input-inhibitor-unstable-v1-client-protocol.h"
|
||||||
@ -808,36 +807,32 @@ static int load_config(char *path, struct swaylock_state *state,
|
|||||||
wlr_log(WLR_ERROR, "Failed to read config. Running without it.");
|
wlr_log(WLR_ERROR, "Failed to read config. Running without it.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char *line;
|
char *line = NULL;
|
||||||
|
size_t line_size = 0;
|
||||||
|
ssize_t nread;
|
||||||
int line_number = 0;
|
int line_number = 0;
|
||||||
while (!feof(config)) {
|
int result = 0;
|
||||||
line = read_line(config);
|
while ((nread = getline(&line, &line_size, config)) != -1) {
|
||||||
if (!line) {
|
line_number++;
|
||||||
continue;
|
|
||||||
|
if (line[nread - 1] == '\n') {
|
||||||
|
line[--nread] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
line_number++;
|
if (!*line || line[0] == '#') {
|
||||||
if (line[0] == '#') {
|
|
||||||
free(line);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strlen(line) == 0) {
|
|
||||||
free(line);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line);
|
wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line);
|
||||||
char flag[strlen(line) + 3];
|
char flag[nread + 3];
|
||||||
sprintf(flag, "--%s", line);
|
sprintf(flag, "--%s", line);
|
||||||
char *argv[] = {"swaylock", flag};
|
char *argv[] = {"swaylock", flag};
|
||||||
int result = parse_options(2, argv, state, line_mode, NULL);
|
result = parse_options(2, argv, state, line_mode, NULL);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
free(line);
|
break;
|
||||||
fclose(config);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
free(line);
|
|
||||||
}
|
}
|
||||||
|
free(line);
|
||||||
fclose(config);
|
fclose(config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user