Fix the ispunct ctype implementation.

This commit is contained in:
Reece H. Dunn
2018-05-03 21:29:17 +01:00
parent d6c1b5d597
commit df247b7cab
3 changed files with 7 additions and 18 deletions
+4
View File
@@ -1,5 +1,9 @@
# Change Log
## (In Development)
* Make the ispunct ctype compatibility implementation conformant.
## 10.0.0 - 2017-06-25
* Add `iswblank` and `iswxdigit` compatibility.
+2 -14
View File
@@ -1,6 +1,6 @@
/* ctype-style APIs.
*
* Copyright (C) 2012-2017 Reece H. Dunn
* Copyright (C) 2012-2018 Reece H. Dunn
*
* This file is part of ucd-tools.
*
@@ -151,19 +151,7 @@ int ucd_isprint(codepoint_t c)
int ucd_ispunct(codepoint_t c)
{
switch (ucd_lookup_category(c))
{
case UCD_CATEGORY_Pc:
case UCD_CATEGORY_Pd:
case UCD_CATEGORY_Pe:
case UCD_CATEGORY_Pf:
case UCD_CATEGORY_Pi:
case UCD_CATEGORY_Po:
case UCD_CATEGORY_Ps:
return 1;
default:
return 0;
}
return ucd_isgraph(c) && !ucd_isalnum(c);
}
int ucd_isspace(codepoint_t c)
+1 -4
View File
@@ -78,10 +78,7 @@ def isblank(data): # word separator
return 0
def ispunct(data):
if data.get('GeneralCategory', 'Cn')[0] in 'P':
return 1
else:
return 0
return 1 if isgraph(data) and not isalnum(data) else 0
def isprint(data):
if data.get('GeneralCategory', 'Cn')[0] in 'LMNPSZ': # not in 'CI'