diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2016-08-12 23:30:00 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2016-08-12 23:30:00 +0000 |
commit | 77a874d074b24385e7af775bf3d4ce845dfecc32 (patch) | |
tree | f47cfb9152d0481391bc499509ce594750236e0f /usr.bin/jot/jot.c | |
parent | 9d103a073572ea392b5b172ca33598be34542b16 (diff) |
Simplify getprec() by using strchr(3) and strspn(3).
Part of NetBSD's jot r1.20 by dsl.
ok jca
Diffstat (limited to 'usr.bin/jot/jot.c')
-rw-r--r-- | usr.bin/jot/jot.c | 15 |
1 files 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 |