Add isalpha_l and friends.

This commit is contained in:
joerg 2013-04-16 11:29:12 +00:00
parent f6c75cc7da
commit 4e2459a9e6
2 changed files with 48 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype.h,v 1.31 2010/06/01 13:52:08 tnozaki Exp $ */
/* $NetBSD: ctype.h,v 1.32 2013/04/16 11:29:12 joerg Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -57,6 +57,28 @@ int isxdigit(int);
int tolower(int);
int toupper(int);
#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
# ifndef __LOCALE_T_DECLARED
typedef struct _locale *locale_t;
# define __LOCALE_T_DECLARED
# endif
int isalnum_l(int, locale_t);
int isalpha_l(int, locale_t);
int isblank_l(int, locale_t);
int iscntrl_l(int, locale_t);
int isdigit_l(int, locale_t);
int isgraph_l(int, locale_t);
int islower_l(int, locale_t);
int isprint_l(int, locale_t);
int ispunct_l(int, locale_t);
int isspace_l(int, locale_t);
int isupper_l(int, locale_t);
int isxdigit_l(int, locale_t);
int tolower_l(int, locale_t);
int toupper_l(int, locale_t);
#endif
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
int isascii(int);
int toascii(int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: isctype.c,v 1.22 2013/04/13 10:21:20 joerg Exp $ */
/* $NetBSD: isctype.c,v 1.23 2013/04/16 11:29:13 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: isctype.c,v 1.22 2013/04/13 10:21:20 joerg Exp $");
__RCSID("$NetBSD: isctype.c,v 1.23 2013/04/16 11:29:13 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -53,6 +53,13 @@ int \
is##name(int c) \
{ \
return (int)(_CTYPE_TAB(ctype_tab, c) & (bit)); \
} \
int \
is##name ## _l(int c, locale_t loc) \
{ \
if (loc == NULL) \
loc = _C_locale; \
return (int)(((loc->cache->ctype_tab + 1)[c]) & (bit)); \
}
_ISCTYPE_FUNC(alnum, (_CTYPE_A|_CTYPE_D))
@ -74,12 +81,28 @@ toupper(int c)
return (int)_CTYPE_TAB(toupper_tab, c);
}
int
toupper_l(int c, locale_t loc)
{
if (loc == NULL)
loc = _C_locale;
return (int)(((loc->cache->toupper_tab + 1)[c]));
}
int
tolower(int c)
{
return (int)_CTYPE_TAB(tolower_tab, c);
}
int
tolower_l(int c, locale_t loc)
{
if (loc == NULL)
loc = _C_locale;
return (int)(((loc->cache->tolower_tab + 1)[c]));
}
int
_toupper(int c)
{