mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
replace homegrown is_digit with correct calls to isdigit()
This commit is contained in:
parent
66e58127e8
commit
d6d41fe686
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: localtime.c,v 1.39 2015/02/09 08:25:11 tedu Exp $ */
|
||||
/* $OpenBSD: localtime.c,v 1.40 2015/02/09 13:03:59 tedu Exp $ */
|
||||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 1996-06-05 by Arthur David Olson.
|
||||
@ -9,7 +9,7 @@
|
||||
** POSIX-style TZ environment variable handling from Guy Harris.
|
||||
*/
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
#include <ctype.h>
|
||||
|
||||
#include "private.h"
|
||||
#include "tzfile.h"
|
||||
@ -624,7 +624,7 @@ register const char * strp;
|
||||
{
|
||||
register char c;
|
||||
|
||||
while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
|
||||
while ((c = *strp) != '\0' && !isdigit((unsigned char)c) && c != ',' && c != '-' &&
|
||||
c != '+')
|
||||
++strp;
|
||||
return strp;
|
||||
@ -666,7 +666,7 @@ const int max;
|
||||
register char c;
|
||||
register int num;
|
||||
|
||||
if (strp == NULL || !is_digit(c = *strp))
|
||||
if (strp == NULL || !isdigit((unsigned char)(c = *strp)))
|
||||
return NULL;
|
||||
num = 0;
|
||||
do {
|
||||
@ -674,7 +674,7 @@ const int max;
|
||||
if (num > max)
|
||||
return NULL; /* illegal value */
|
||||
c = *++strp;
|
||||
} while (is_digit(c));
|
||||
} while (isdigit((unsigned char)c));
|
||||
if (num < min)
|
||||
return NULL; /* illegal value */
|
||||
*nump = num;
|
||||
@ -787,7 +787,7 @@ register struct rule * const rulep;
|
||||
if (*strp++ != '.')
|
||||
return NULL;
|
||||
strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
|
||||
} else if (is_digit(*strp)) {
|
||||
} else if (isdigit((unsigned char)*strp)) {
|
||||
/*
|
||||
** Day of year.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: private.h,v 1.28 2015/02/09 11:29:19 tedu Exp $ */
|
||||
/* $OpenBSD: private.h,v 1.29 2015/02/09 13:03:59 tedu Exp $ */
|
||||
#ifndef PRIVATE_H
|
||||
|
||||
#define PRIVATE_H
|
||||
@ -113,9 +113,6 @@
|
||||
#define R_OK 4
|
||||
#endif /* !defined R_OK */
|
||||
|
||||
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
|
||||
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#ifndef INT_FAST64_MAX
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* $OpenBSD: scheck.c,v 1.1 2015/02/09 12:37:47 tedu Exp $ */
|
||||
/* $OpenBSD: scheck.c,v 1.2 2015/02/09 13:03:59 tedu Exp $ */
|
||||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 2006-07-17 by Arthur David Olson.
|
||||
*/
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
#include <ctype.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
@ -13,11 +13,11 @@ scheck(string, format)
|
||||
const char * const string;
|
||||
const char * const format;
|
||||
{
|
||||
register char * fbuf;
|
||||
register const char * fp;
|
||||
register char * tp;
|
||||
register int c;
|
||||
register const char * result;
|
||||
char * fbuf;
|
||||
const char * fp;
|
||||
char * tp;
|
||||
int c;
|
||||
const char * result;
|
||||
char dummy;
|
||||
|
||||
result = "";
|
||||
@ -38,7 +38,7 @@ const char * const format;
|
||||
*tp++ = '*';
|
||||
if (*fp == '*')
|
||||
++fp;
|
||||
while (is_digit(*fp))
|
||||
while (isdigit((unsigned char)*fp))
|
||||
*tp++ = *fp++;
|
||||
if (*fp == 'l' || *fp == 'h')
|
||||
*tp++ = *fp++;
|
||||
|
Loading…
Reference in New Issue
Block a user