Browse Source

ctype: return true in isupper/islower if there is a simple case mapping present

master
Reece H. Dunn 8 years ago
parent
commit
bd71fed013
6 changed files with 29 additions and 8 deletions
  1. 1
    0
      CHANGELOG.md
  2. 4
    2
      src/ctype.c
  3. 1
    1
      tests/printcdata.c
  4. 1
    1
      tests/printucddata.c
  5. 1
    1
      tests/printucddata_cpp.cpp
  6. 21
    3
      tools/printdata.py

+ 1
- 0
CHANGELOG.md View File

## 9.0.0.1 - (In Progress) ## 9.0.0.1 - (In Progress)


* Add `iswblank` and `iswxdigit` compatibility. * Add `iswblank` and `iswxdigit` compatibility.
* Improve ctype compatibility.


## 9.0.0 - 2016-12-28 ## 9.0.0 - 2016-12-28



+ 4
- 2
src/ctype.c View File



int ucd_islower(codepoint_t c) int ucd_islower(codepoint_t c)
{ {
return ucd_lookup_category(c) == UCD_CATEGORY_Ll;
return ucd_lookup_category(c) == UCD_CATEGORY_Ll
|| ucd_toupper(c) != c;
} }


int ucd_isprint(codepoint_t c) int ucd_isprint(codepoint_t c)


int ucd_isupper(codepoint_t c) int ucd_isupper(codepoint_t c)
{ {
return ucd_lookup_category(c) == UCD_CATEGORY_Lu;
return ucd_lookup_category(c) == UCD_CATEGORY_Lu
|| ucd_tolower(c) != c;
} }


int ucd_isxdigit(codepoint_t c) int ucd_isxdigit(codepoint_t c)

+ 1
- 1
tests/printcdata.c View File

else else
{ {
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n");
} }
return 0; return 0;
} }

+ 1
- 1
tests/printucddata.c View File

else else
{ {
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) for (codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n");
} }
return 0; return 0;
} }

+ 1
- 1
tests/printucddata_cpp.cpp View File

else else
{ {
for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c) for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c)
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n");
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n");
} }
return 0; return 0;
} }

+ 21
- 3
tools/printdata.py View File

ucd_rootdir = sys.argv[1] ucd_rootdir = sys.argv[1]
csur_rootdir = 'data/csur' csur_rootdir = 'data/csur'


null = ucd.CodePoint('0000')

unicode_chars = {} unicode_chars = {}
for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'): for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'):
for codepoint in data['CodePoint']: for codepoint in data['CodePoint']:
def isspace(data): def isspace(data):
return data.get('White_Space', 0) return data.get('White_Space', 0)


null = ucd.CodePoint('0000')
def isupper(data):
if data.get('LowerCase', null) != null:
return 1
elif data.get('GeneralCategory', 'Cn') == 'Lu':
return 1
else:
return 0

def islower(data):
if data.get('UpperCase', null) != null:
return 1
elif data.get('GeneralCategory', 'Cn') == 'Ll':
return 1
else:
return 0

if __name__ == '__main__': if __name__ == '__main__':
for codepoint in ucd.CodeRange('000000..10FFFF'): for codepoint in ucd.CodeRange('000000..10FFFF'):
try: try:
if title == null: title = codepoint if title == null: title = codepoint
if upper == null: upper = codepoint if upper == null: upper = codepoint
if lower == null: lower = codepoint if lower == null: lower = codepoint
print('%s %s %s %s %s %s %s %s' % (
print('%s %s %s %s %s %s %s %s %s %s' % (
codepoint, script, codepoint, script,
data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
upper, lower, title, upper, lower, title,
isspace(data)))
isspace(data),
isupper(data), islower(data)))

Loading…
Cancel
Save