A patch from Vladimir to simplify chomp()
authorEric Andersen <andersen@codepoet.org>
Mon, 7 May 2001 23:02:39 +0000 (23:02 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 7 May 2001 23:02:39 +0000 (23:02 -0000)
libbb/chomp.c

index d2f6d5e6ffd95068b94ff480f2658371546a605b..e62cb4005663f5a0393d2af0792eab4ace409115 100644 (file)
 
 void chomp(char *s)
 {
-       size_t len = strlen(s);
-
-       if (len == 0)
-               return;
-
-       if (s[len-1] == '\n')
-               s[len-1] = '\0';
+       char *lc = (char *)last_char_is(s, '\n');
+       
+       if(lc)
+               *lc = 0;
 }