rc: fix and improve script scanning START and STOP
Currently we stop searching at the first occurence of START or STOP entry. This is wrong since we totally miss the other data (START or STOP) in the occurence of the other. Fix and improve script scanning by: - Increase the line max length to 255 char to read it in one go. - Scan only the first 10 lines. - Don't stop at the first occurence and try to search also for the other data. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
parent
c0df2a7af7
commit
4de3f02e31
1 changed files with 5 additions and 2 deletions
7
rc.c
7
rc.c
|
@ -187,17 +187,20 @@ static void rc_list_readdir(struct rc_list_context *c)
|
||||||
if (fp) {
|
if (fp) {
|
||||||
struct stat s;
|
struct stat s;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char line[32];
|
char line[255];
|
||||||
bool beginning;
|
bool beginning;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
beginning = true;
|
beginning = true;
|
||||||
while (c->entry.start < 0 && c->entry.stop < 0 && fgets(line, sizeof(line), fp)) {
|
while ((c->entry.start < 0 || c->entry.stop < 0) &&
|
||||||
|
count <= 10 && fgets(line, sizeof(line), fp)) {
|
||||||
if (beginning) {
|
if (beginning) {
|
||||||
if (!strncmp(line, "START=", 6)) {
|
if (!strncmp(line, "START=", 6)) {
|
||||||
c->entry.start = strtoul(line + 6, NULL, 0);
|
c->entry.start = strtoul(line + 6, NULL, 0);
|
||||||
} else if (!strncmp(line, "STOP=", 5)) {
|
} else if (!strncmp(line, "STOP=", 5)) {
|
||||||
c->entry.stop = strtoul(line + 5, NULL, 0);
|
c->entry.stop = strtoul(line + 5, NULL, 0);
|
||||||
}
|
}
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginning = !!strchr(line, '\n');
|
beginning = !!strchr(line, '\n');
|
||||||
|
|
Loading…
Reference in a new issue