From bc16887a7932123b594f2d4647629039804399a5 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 8 Apr 2017 19:11:45 +0100 Subject: [PATCH] Use ucd_properties to implement ucd_isspace. --- src/ctype.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/ctype.c b/src/ctype.c index 4632b55e..373d15e3 100644 --- a/src/ctype.c +++ b/src/ctype.c @@ -437,34 +437,8 @@ int ucd_ispunct(codepoint_t c) int ucd_isspace(codepoint_t c) { - switch (ucd_lookup_category(c)) - { - case UCD_CATEGORY_Zl: - case UCD_CATEGORY_Zp: - return 1; - case UCD_CATEGORY_Zs: - switch (c) // Exclude characters with the DispositionType - { - case 0x00A0: // U+00A0 : NO-BREAK SPACE - case 0x2007: // U+2007 : FIGURE SPACE - case 0x202F: // U+202F : NARROW NO-BREAK SPACE - return 0; - } - return 1; - case UCD_CATEGORY_Cc: - switch (c) // Include control characters marked as White_Space - { - 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; - } - default: - return 0; - } + ucd_property props = ucd_properties(c, ucd_lookup_category(c)); + return (props & (UCD_PROPERTY_WHITE_SPACE | UCD_PROPERTY_NO_BREAK)) == UCD_PROPERTY_WHITE_SPACE; } int ucd_isupper(codepoint_t c)