Here's one final diff I have for jot for now:

Use strchr(3) and strspn(3) instead of handrolled functions.

Part of dsl@NetBSD's r1.20.

Index: jot.c
===================================================================
RCS file: /cvs/src/usr.bin/jot/jot.c,v
retrieving revision 1.33
diff -u -p -r1.33 jot.c
--- jot.c       12 Aug 2016 21:31:11 -0000      1.33
+++ jot.c       12 Aug 2016 21:35:07 -0000
@@ -348,18 +348,9 @@ usage(void)
 static int
 getprec(char *s)
 {
-       char    *p;
-       char    *q;
-
-       for (p = s; *p != '\0'; p++)
-               if (*p == '.')
-                       break;
-       if (*p == '\0')
+       if ((s = strchr(s, '.')) == NULL)
                return (0);
-       for (q = ++p; *p != '\0'; p++)
-               if (!isdigit((unsigned char)*p))
-                       break;
-       return (p - q);
+       return (strspn(s + 1, "0123456789"));
 }
 
 static void

Reply via email to