From 8a299e4b4ebdecec2de938cc7bb2047be2570af5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 10 Jul 2022 17:26:42 -0500 Subject: [PATCH] Cleanup: Converted type is actually uint32_t rather than f_utf_char_t. The f_utf_char_t is supposed to be an uint32_t so this is not a problem. The intent and design of this, however, is that f_utf_char_t is a special case representing the character as a string rather than as a digit. The f_utf_char_t is stored as a 4-byte integer to store each byte representing a character. The uint32_t is simply a straight up 4-byte integer. This is the numeric value of the code point rather than the representation as a string. This is an important semantic difference. --- level_0/f_utf/c/utf/convert.c | 4 ++-- level_0/f_utf/c/utf/convert.h | 2 +- level_3/fake/c/private-make-operate_process.c | 2 +- level_3/utf8/c/private-print.c | 4 ++-- level_3/utf8/c/private-print.h | 4 ++-- level_3/utf8/c/private-utf8_bytesequence.c | 2 +- level_3/utf8/c/private-utf8_codepoint.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/level_0/f_utf/c/utf/convert.c b/level_0/f_utf/c/utf/convert.c index 6dff6c8..5940e7d 100644 --- a/level_0/f_utf/c/utf/convert.c +++ b/level_0/f_utf/c/utf/convert.c @@ -304,7 +304,7 @@ extern "C" { #endif // _di_f_utf_unicode_to_ #ifndef _di_f_utf_unicode_string_to_f_ - f_status_t f_utf_unicode_string_to(const f_string_t string, const f_array_length_t length, f_utf_char_t *unicode) { + f_status_t f_utf_unicode_string_to(const f_string_t string, const f_array_length_t length, uint32_t *unicode) { #ifndef _di_level_0_parameter_checking_ if (!unicode) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -337,7 +337,7 @@ extern "C" { return F_status_set_error(F_valid_not); } - f_utf_char_t value = 0; + uint32_t value = 0; for (; i < length; ++i) { diff --git a/level_0/f_utf/c/utf/convert.h b/level_0/f_utf/c/utf/convert.h index db92062..ce51052 100644 --- a/level_0/f_utf/c/utf/convert.h +++ b/level_0/f_utf/c/utf/convert.h @@ -222,7 +222,7 @@ extern "C" { * F_valid_not (with error bit) if string is not a valid Unicode string. */ #ifndef _di_f_utf_unicode_string_to_ - extern f_status_t f_utf_unicode_string_to(const f_string_t string, const f_array_length_t length, f_utf_char_t *unicode); + extern f_status_t f_utf_unicode_string_to(const f_string_t string, const f_array_length_t length, uint32_t *unicode); #endif // _di_f_utf_unicode_string_to_ #ifdef __cplusplus diff --git a/level_3/fake/c/private-make-operate_process.c b/level_3/fake/c/private-make-operate_process.c index 13029ea..91cf46a 100644 --- a/level_3/fake/c/private-make-operate_process.c +++ b/level_3/fake/c/private-make-operate_process.c @@ -549,7 +549,7 @@ extern "C" { } // for if (buffer.used > 2) { - f_utf_char_t codepoint = 0; + uint32_t codepoint = 0; status = f_utf_unicode_string_to(buffer.string, buffer.used, &codepoint); diff --git a/level_3/utf8/c/private-print.c b/level_3/utf8/c/private-print.c index c816a07..395116d 100644 --- a/level_3/utf8/c/private-print.c +++ b/level_3/utf8/c/private-print.c @@ -43,7 +43,7 @@ extern "C" { #endif // _di_utf8_print_character_invalid_ #ifndef _di_utf8_print_codepoint_ - void utf8_print_codepoint(utf8_data_t * const data, const f_utf_char_t codepoint) { + void utf8_print_codepoint(utf8_data_t * const data, const uint32_t codepoint) { if (codepoint < 0x10000) { fl_print_format("%rU+%04_U%r", data->file.stream, data->prepend, codepoint, data->append); @@ -138,7 +138,7 @@ extern "C" { #endif // _di_utf8_print_error_decode_ #ifndef _di_utf8_print_error_encode_ - void utf8_print_error_encode(utf8_data_t * const data, const f_status_t status, const f_utf_char_t codepoint) { + void utf8_print_error_encode(utf8_data_t * const data, const f_status_t status, const uint32_t codepoint) { if (data->main->error.verbosity == f_console_verbosity_quiet_e) return; diff --git a/level_3/utf8/c/private-print.h b/level_3/utf8/c/private-print.h index 34c5a9c..cb0247b 100644 --- a/level_3/utf8/c/private-print.h +++ b/level_3/utf8/c/private-print.h @@ -50,7 +50,7 @@ extern "C" { * This is the code that represents a single character. */ #ifndef _di_utf8_print_codepoint_ - extern void utf8_print_codepoint(utf8_data_t * const data, const f_utf_char_t codepoint) F_attribute_visibility_internal_d; + extern void utf8_print_codepoint(utf8_data_t * const data, const uint32_t codepoint) F_attribute_visibility_internal_d; #endif // _di_utf8_print_codepoint_ /** @@ -98,7 +98,7 @@ extern "C" { * The codepoint that is invalid. */ #ifndef _di_utf8_print_error_encode_ - extern void utf8_print_error_encode(utf8_data_t * const data, const f_status_t status, const f_utf_char_t codepoint) F_attribute_visibility_internal_d; + extern void utf8_print_error_encode(utf8_data_t * const data, const f_status_t status, const uint32_t codepoint) F_attribute_visibility_internal_d; #endif // _di_utf8_print_error_encode_ /** diff --git a/level_3/utf8/c/private-utf8_bytesequence.c b/level_3/utf8/c/private-utf8_bytesequence.c index 0266d14..45c133d 100644 --- a/level_3/utf8/c/private-utf8_bytesequence.c +++ b/level_3/utf8/c/private-utf8_bytesequence.c @@ -15,7 +15,7 @@ extern "C" { f_status_t status = F_none; bool valid_not = F_false; - f_utf_char_t codepoint = 0; + uint32_t codepoint = 0; if (sequence.used) { status = f_utf_unicode_to(sequence.string, sequence.used, &codepoint); diff --git a/level_3/utf8/c/private-utf8_codepoint.c b/level_3/utf8/c/private-utf8_codepoint.c index 48adae3..f46d031 100644 --- a/level_3/utf8/c/private-utf8_codepoint.c +++ b/level_3/utf8/c/private-utf8_codepoint.c @@ -27,7 +27,7 @@ extern "C" { } if (*mode == utf8_codepoint_mode_end_e) { - f_utf_char_t codepoint = 0; + uint32_t codepoint = 0; status = f_utf_unicode_string_to(data->text.string, data->text.used, &codepoint); -- 1.8.3.1