Skip to content

Commit

Permalink
perf: quicker check/removal of escaped newlines for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Jul 30, 2020
1 parent 0ac6f6b commit 7983d12
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/common/fgetline.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: fgetline.c,v 2.10 2020/07/29 18:19:31 greg Exp $";
static const char RCSid[] = "$Id: fgetline.c,v 2.11 2020/07/30 17:25:01 greg Exp $";
#endif
/*
* fgetline.c - read line with escaped newlines.
Expand Down Expand Up @@ -35,9 +35,10 @@ fgetline( /* read in line with escapes, elide final newline */
return(NULL);
*cp = '\0';
#if defined(_WIN32) || defined(_WIN64)
/* remove escaped newlines */
for (cp = s; (cp = strchr(cp, '\\')) != NULL && cp[1] == '\n'; )
memmove(cp, cp+2, strlen(cp+2)+1);
for (cp = s; *cp; cp++) /* remove escaped newlines */
if (cp[0] == '\\' && cp[1] == '\n') {
*cp++ = ' '; *cp = ' ';
}
#endif
return(s);
}

0 comments on commit 7983d12

Please # to comment.