From bc6a5c23ccb16f47c9d444a894025bd1123e51b4 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 22 Dec 2012 01:19:03 +0000 Subject: [PATCH] Remove the Zc class as it is not part of the UCD; special case Cc-based whitespace instead. --- src/categories.cpp | 2 +- src/ctype.cpp | 22 ++++++++++++++-------- src/include/ucd/ucd.h | 1 - tools/categories.py | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/categories.cpp b/src/categories.cpp index 0be4a315..230a5058 100644 --- a/src/categories.cpp +++ b/src/categories.cpp @@ -3285,7 +3285,7 @@ ucd::category_group ucd::lookup_category_group(codepoint_t c) { switch (lookup_category(c)) { - case Cc: case Cf: case Ci: case Cn: case Co: case Cs: case Zc: + case Cc: case Cf: case Ci: case Cn: case Co: case Cs: return C; case Ll: case Lm: case Lo: case Lt: case Lu: return L; diff --git a/src/ctype.cpp b/src/ctype.cpp index 4488378e..6237ba73 100644 --- a/src/ctype.cpp +++ b/src/ctype.cpp @@ -46,12 +46,7 @@ int ucd::isalpha(codepoint_t c) int ucd::iscntrl(codepoint_t c) { - switch (lookup_category(c)) - { - case Cc: case Zc: - return 1; - } - return 0; + return lookup_category(c) == Cc; } int ucd::isdigit(codepoint_t c) @@ -69,7 +64,7 @@ int ucd::isgraph(codepoint_t c) switch (lookup_category(c)) { case Cc: case Cf: case Ci: case Cn: case Co: case Cs: - case Zc: case Zl: case Zp: case Zs: + case Zl: case Zp: case Zs: return 0; } return 1; @@ -104,8 +99,19 @@ int ucd::isspace(codepoint_t c) { switch (lookup_category(c)) { - case Zc: case Zl: case Zp: case Zs: + case Zl: case Zp: case Zs: return 1; + case Cc: + switch (c) // Some control characters are also whitespace characters: + { + case 0x09: // U+0009 : CHARACTER TABULATION + case 0x0A: // U+000A : LINE FEED + case 0x0B: // U+000B : LINE TABULATION + case 0x0C: // U+000C : FORM FEED + case 0x0D: // U+000D : CARRIAGE RETURN + case 0x85: // U+0085 : NEXT LINE + return 1; + } } return 0; } diff --git a/src/include/ucd/ucd.h b/src/include/ucd/ucd.h index 6a3c1f54..cb95d2ca 100644 --- a/src/include/ucd/ucd.h +++ b/src/include/ucd/ucd.h @@ -84,7 +84,6 @@ namespace ucd Sm, /**< @brief Math Symbol */ So, /**< @brief Other Symbol */ - Zc, /**< @brief Whitespace character in the Cc category */ Zl, /**< @brief Line Separator */ Zp, /**< @brief Paragraph Separator */ Zs, /**< @brief Space Separator */ diff --git a/tools/categories.py b/tools/categories.py index 94ed932c..895ce747 100755 --- a/tools/categories.py +++ b/tools/categories.py @@ -159,7 +159,7 @@ ucd::category_group ucd::lookup_category_group(codepoint_t c) { switch (lookup_category(c)) { - case Cc: case Cf: case Ci: case Cn: case Co: case Cs: case Zc: + case Cc: case Cf: case Ci: case Cn: case Co: case Cs: return C; case Ll: case Lm: case Lo: case Lt: case Lu: return L;