commit | 45e0acc110465175afc678ee103f2f5c4e6b270f | [log] [tgz] |
---|---|---|
author | Rob Landley <rob@landley.net> | Mon Nov 02 01:34:58 2015 -0600 |
committer | Rob Landley <rob@landley.net> | Mon Nov 02 01:34:58 2015 -0600 |
tree | a680d360b130751b62b791e3e820cc833d0d748f | |
parent | 11d6079ed3cb067dc66a795a1c7565c13afd5a00 [diff] |
If chomp() needs to test it found \n, should also test it's at end of string.
diff --git a/lib/lib.c b/lib/lib.c index aa7b1c3..b370305 100644 --- a/lib/lib.c +++ b/lib/lib.c
@@ -342,11 +342,12 @@ return try; } +// Remove trailing \n char *chomp(char *s) { char *p = strrchr(s, '\n'); - if (p) *p = 0; + if (p && !p[1]) *p = 0; return s; }