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

@@ -3,6 +3,7 @@
## 9.0.0.1 - (In Progress)

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

## 9.0.0 - 2016-12-28


+ 4
- 2
src/ctype.c View File

@@ -97,7 +97,8 @@ int ucd_isgraph(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)
@@ -159,7 +160,8 @@ int ucd_isspace(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)

+ 1
- 1
tests/printcdata.c View File

@@ -248,7 +248,7 @@ int main(int argc, char **argv)
else
{
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;
}

+ 1
- 1
tests/printucddata.c View File

@@ -243,7 +243,7 @@ int main(int argc, char **argv)
else
{
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;
}

+ 1
- 1
tests/printucddata_cpp.cpp View File

@@ -243,7 +243,7 @@ int main(int argc, char **argv)
else
{
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;
}

+ 21
- 3
tools/printdata.py View File

@@ -24,6 +24,8 @@ import ucd
ucd_rootdir = sys.argv[1]
csur_rootdir = 'data/csur'

null = ucd.CodePoint('0000')

unicode_chars = {}
for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'):
for codepoint in data['CodePoint']:
@@ -44,7 +46,22 @@ if '--with-csur' in sys.argv:
def isspace(data):
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__':
for codepoint in ucd.CodeRange('000000..10FFFF'):
try:
@@ -58,8 +75,9 @@ if __name__ == '__main__':
if title == null: title = codepoint
if upper == null: upper = 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,
data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'),
upper, lower, title,
isspace(data)))
isspace(data),
isupper(data), islower(data)))

Loading…
Cancel
Save