From 808b2b380f86beee0973ad00a558424e6d7af3e0 Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 12 Aug 2016 23:29:59 +0000 Subject: [PATCH] Simplify getprec() by using strchr(3) and strspn(3). Part of NetBSD's jot r1.20 by dsl. ok jca --- usr.bin/jot/jot.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 2235bfce97a..805f2f84b18 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jot.c,v 1.33 2016/08/12 21:31:11 tb Exp $ */ +/* $OpenBSD: jot.c,v 1.34 2016/08/12 23:29:59 tb Exp $ */ /* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */ /*- @@ -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 -- 2.20.1