aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-11-02 01:34:58 -0600
committerRob Landley <rob@landley.net>2015-11-02 01:34:58 -0600
commit45e0acc110465175afc678ee103f2f5c4e6b270f (patch)
treea680d360b130751b62b791e3e820cc833d0d748f
parent11d6079ed3cb067dc66a795a1c7565c13afd5a00 (diff)
downloadtoybox-45e0acc110465175afc678ee103f2f5c4e6b270f.tar.gz
If chomp() needs to test it found \n, should also test it's at end of string.
-rw-r--r--lib/lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/lib.c b/lib/lib.c
index aa7b1c30..b3703052 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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;
}