From 45e0acc110465175afc678ee103f2f5c4e6b270f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 2 Nov 2015 01:34:58 -0600 Subject: If chomp() needs to test it found \n, should also test it's at end of string. --- lib/lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3