Skip to content

Commit

Permalink
Handle CRLF
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed May 24, 2024
1 parent e49b259 commit 26ee984
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ ssize_t getline_chomp(char **lineptr, size_t *n, FILE *stream) {
ssize_t len = getline(lineptr, n, stream);
if (len > 0) {
char *line = *lineptr;
// Chomp CR(\r), LF(\n), CR+LF
if (line[len - 1] == '\n')
line[--len] = '\0';
if (line[len - 1] == '\r')
line[--len] = '\0';
}
return len;
}
Expand Down

0 comments on commit 26ee984

Please sign in to comment.