Ignore empty lines
This commit is contained in:
@@ -147,6 +147,19 @@ int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Trim leading and trailing whitespace
|
||||
char *start = line;
|
||||
while (isspace((unsigned char)*start)) start++;
|
||||
char *end = start + strlen(start) - 1;
|
||||
while (end > start && isspace((unsigned char)*end)) end--;
|
||||
*(end + 1) = '\0';
|
||||
|
||||
if (strlen(start) == 0) {
|
||||
fprintf(stderr, "Input is empty.\n");
|
||||
free(line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LogMessage msg = parse_log_line(line);
|
||||
append_log_to_file(filename, &msg);
|
||||
free(line);
|
||||
|
||||
Reference in New Issue
Block a user