Ignore empty lines

This commit is contained in:
2025-06-04 16:19:19 +12:00
parent eeb8f18f6a
commit f32b21236a

View File

@@ -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);