From ceda811b12c3330a6000162c5c5bbbdac3c54910 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sun, 12 Feb 2017 08:16:23 +0000 Subject: [PATCH] printdata: add the properties to the primary data map --- tests/printcdata.c | 8 ++------ tests/printucddata.c | 8 ++------ tests/printucddata_cpp.cpp | 8 ++------ tools/printdata.py | 7 +++---- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/tests/printcdata.c b/tests/printcdata.c index 24d57c92..21f668b9 100644 --- a/tests/printcdata.c +++ b/tests/printcdata.c @@ -178,10 +178,6 @@ void uprintf(FILE *out, codepoint_t c, const char *format) case 'U': // uppercase uprintf_codepoint(out, towupper(c), *++format); break; - case 'W': // whitespace - if (iswspace(c)) - fputs("White_Space", out); - break; } ++format; break; @@ -218,7 +214,7 @@ void print_file(FILE *in, const char *format) { codepoint_t c = 0; while (fget_utf8c(in, &c)) - uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%W\n"); + uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%is\n"); } int main(int argc, char **argv) @@ -252,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 %W\n"); + uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n"); } return 0; } diff --git a/tests/printucddata.c b/tests/printucddata.c index e397f12e..47086c52 100644 --- a/tests/printucddata.c +++ b/tests/printucddata.c @@ -175,10 +175,6 @@ void uprintf(FILE *out, codepoint_t c, const char *format) case 'U': // uppercase uprintf_codepoint(out, ucd_toupper(c), *++format); break; - case 'W': // whitespace - if (ucd_isspace(c)) - fputs("White_Space", out); - break; } ++format; break; @@ -215,7 +211,7 @@ void print_file(FILE *in, const char *format) { codepoint_t c = 0; while (fget_utf8c(in, &c)) - uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%W\n"); + uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%is\n"); } int main(int argc, char **argv) @@ -247,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 %W\n"); + uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n"); } return 0; } diff --git a/tests/printucddata_cpp.cpp b/tests/printucddata_cpp.cpp index 2318b09a..8bc8fc71 100644 --- a/tests/printucddata_cpp.cpp +++ b/tests/printucddata_cpp.cpp @@ -175,10 +175,6 @@ void uprintf(FILE *out, ucd::codepoint_t c, const char *format) case 'U': // uppercase uprintf_codepoint(out, ucd::toupper(c), *++format); break; - case 'W': // whitespace - if (ucd::isspace(c)) - fputs("White_Space", out); - break; } ++format; break; @@ -215,7 +211,7 @@ void print_file(FILE *in, const char *format) { ucd::codepoint_t c = 0; while (fget_utf8c(in, c)) - uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%W\n"); + uprintf(stdout, c, format ? format : "%pc\t%pH\t%s\t%c\t%Uc\t%Lc\t%Tc\t%is\n"); } int main(int argc, char **argv) @@ -247,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 %W\n"); + uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is\n"); } return 0; } diff --git a/tools/printdata.py b/tools/printdata.py index 8df3e011..e6de9313 100755 --- a/tools/printdata.py +++ b/tools/printdata.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# Copyright (C) 2012 Reece H. Dunn +# Copyright (C) 2012-2017 Reece H. Dunn # # This file is part of ucd-tools. # @@ -28,11 +28,10 @@ unicode_chars = {} for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'): for codepoint in data['CodePoint']: unicode_chars[codepoint] = data - unicode_chars[codepoint]['Properties'] = [] for data in ucd.parse_ucd_data(ucd_rootdir, 'PropList'): if data['Property'] in ['White_Space']: for codepoint in data['Range']: - unicode_chars[codepoint]['Properties'].append(data['Property']) + unicode_chars[codepoint][data['Property']] = 1 for data in ucd.parse_ucd_data(ucd_rootdir, 'Scripts'): for codepoint in data['Range']: unicode_chars[codepoint]['Script'] = data['Script'] @@ -60,4 +59,4 @@ if __name__ == '__main__': codepoint, script, data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), upper, lower, title, - ' '.join(data.get('Properties', [])))) + data.get('White_Space', 0)))