Removed redundant parsing

This commit is contained in:
Devine Lu Linvega 2024-04-06 07:57:23 -07:00
parent df1a4ed32b
commit 767c7e93d5
1 changed files with 3 additions and 21 deletions

View File

@ -179,34 +179,16 @@ parse_rulefrag(char *line)
return res;
}
static int
parse_line(char *line)
{
char c;
if(line[0] == 0) return 1;
if(line[0] == '<' && line[1] == '>')
return !!addrule(line);
while((c = *line++))
*prog_++ = c;
return 1;
}
static int
parse(char *path)
{
FILE *f;
char c, line[0x400], *line_ = line;
int res;
if(!(f = fopen(path, "r")))
return !printf("Invalid file: %s\n", path);
while(f && fread(&c, 1, 1, f)) {
if(c == 0xa)
*line_++ = 0x00, parse_line(line), line_ = line;
else if(line_ - line < 0x400)
*line_++ = c;
}
*line_++ = 0x00, parse_line(line), line_ = line;
res = fread(&prog, 1, 0x1000, f);
fclose(f);
return 1;
return res;
}
int