glibc ctype

本文探讨了glibc库中的ctype.h头文件,重点介绍了__isctype函数及其相关实现,如toupper和tolower函数的工作原理。通过查阅资料,揭示了ctype函数如何利用特征表进行字符类型判断,并解释了为何使用short int类型来处理可能的EOF情况。
摘要由CSDN通过智能技术生成

最近看了一下glibc,版本1.09.1。记录一下过程。


ctype.h


//实际上调用的都是__isctype

#define    isalnum(c)    __isctype((c), _ISalnum)
#define    isalpha(c)    __isctype((c), _ISalpha)
#define    iscntrl(c)    __isctype((c), _IScntrl)
#define    isdigit(c)    __isctype((c), _ISdigit)
#define    islower(c)    __isctype((c), _ISlower)
#define    isgraph(c)    __isctype((c), _ISgraph)
#define    isprint(c)    __isctype((c), _ISprint)
#define    ispunct(c)    __isctype((c), _ISpunct)
#define    isspace(c)    __isctype((c), _ISspace)
#define    isupper(c)    __isctype((c), _ISupper)
#define    isxdigit(c)   __isctype((c), _ISxdigit)


__isctype原型

#define    __isctype(c, type)    (__ctype_b[(int) (c)] & (unsigned short int) type)


_ISalnum,_ISalpha

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值