]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/psdate.c
Make pw_scan(3) more compatible with getpwent(3) et. al. when processing
[pw-darwin.git] / pw / psdate.c
index 537861bd9770c35cbeaaf7f7b9bb2ed4915a0e15..8c833b5c69c72f8096888a5a300083d8bc9801f5 100644 (file)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 1996
  *     David L. Nugent.  All rights reserved.
  *
@@ -29,40 +31,20 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif /* not lint */
 
-#include <stdio.h>
+#include <ctype.h>
+#include <err.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <xlocale.h>
-#include <err.h>
 
 #include "psdate.h"
 
 
-static int
-a2i(char const ** str)
-{
-       int             i = 0;
-       char const     *s = *str;
-
-       if (isdigit((unsigned char)*s)) {
-               i = atoi(s);
-               while (isdigit((unsigned char)*s))
-                       ++s;
-               *str = s;
-       }
-       return i;
-}
-
-static int
+int
 numerics(char const * str)
 {
-       int             rc = isdigit((unsigned char)*str);
 
-       if (rc)
-               while (isdigit((unsigned char)*str) || *str == 'x')
-                       ++str;
-       return rc && !*str;
+       return (str[strspn(str, "0123456789x")] == '\0');
 }
 
 static int