diff options
author | Rob Landley <rob@landley.net> | 2015-11-02 01:34:58 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-11-02 01:34:58 -0600 |
commit | 45e0acc110465175afc678ee103f2f5c4e6b270f (patch) | |
tree | a680d360b130751b62b791e3e820cc833d0d748f /lib | |
parent | 11d6079ed3cb067dc66a795a1c7565c13afd5a00 (diff) | |
download | toybox-45e0acc110465175afc678ee103f2f5c4e6b270f.tar.gz |
If chomp() needs to test it found \n, should also test it's at end of string.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -342,11 +342,12 @@ char *strlower(char *s) 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; } |