]> diplodocus.org Git - nmh/commitdiff
Replace strchr() condition with TrimSuffixC().
authorRalph Corderoy <ralph@inputplus.co.uk>
Tue, 18 Oct 2016 23:50:28 +0000 (00:50 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 19 Oct 2016 09:12:01 +0000 (10:12 +0100)
sbr/read_line.c

index 35d71a7..51fa87d 100644 (file)
@@ -1,16 +1,15 @@
 #include <h/mh.h>
+#include <h/utils.h>
 
 const char *
 read_line(void)
 {
-    char *cp;
     static char line[BUFSIZ];
 
     fflush(stdout);
     if (fgets(line, sizeof(line), stdin) == NULL)
             return NULL;
-    if ((cp = strchr(line, '\n')))
-       *cp = 0;
-    return line;
-}
+    TrimSuffixC(line, '\n');
 
+    return line; /* May not be a complete line. */
+}