From 78daa0d760fbcc767dd099d68ae02d23b3df4991 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 2 Apr 2022 08:16:39 -0500 Subject: [PATCH] Regression: Accidentally reversed the big vs little endian bits. I had a fear that I might of done this with the commit dda60cc8d9cad69b55e7d79b4c052677b03b4413. Turns out I was right. All that back and forth getting confused before I realized that I should not use the BIG_ENDIAN macro did result in me getting confused on what bit goes where. --- level_0/f_utf/c/utf/common.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/level_0/f_utf/c/utf/common.h b/level_0/f_utf/c/utf/common.h index eae155b..9019a0d 100644 --- a/level_0/f_utf/c/utf/common.h +++ b/level_0/f_utf/c/utf/common.h @@ -182,26 +182,6 @@ extern "C" { #define macro_f_utf_char_t_initialize(code) code #ifdef _is_F_endian_big - #define F_utf_char_mask_byte_1_d 0xff000000u // 1111 1111, 0000 0000, 0000 0000, 0000 0000 - #define F_utf_char_mask_byte_2_d 0xffff0000u // 1111 1111, 1111 1111, 0000 0000, 0000 0000 - #define F_utf_char_mask_byte_3_d 0xffffff00u // 1111 1111, 1111 1111, 1111 1111, 0000 0000 - #define F_utf_char_mask_byte_4_d 0xffffffffu // 1111 1111, 1111 1111, 1111 1111, 1111 1111 - - #define F_utf_char_mask_char_1_d 0xff000000u // 1111 1111, 0000 0000, 0000 0000, 0000 0000 - #define F_utf_char_mask_char_2_d 0x00ff0000u // 0000 0000, 1111 1111, 0000 0000, 0000 0000 - #define F_utf_char_mask_char_3_d 0x0000ff00u // 0000 0000, 0000 0000, 1111 1111, 0000 0000 - #define F_utf_char_mask_char_4_d 0x000000ffu // 0000 0000, 0000 0000, 0000 0000, 1111 1111 - - #define macro_f_utf_char_t_to_char_1(character) (((character) & F_utf_char_mask_char_1_d) >> 24u) // Grab first byte. - #define macro_f_utf_char_t_to_char_2(character) (((character) & F_utf_char_mask_char_2_d) >> 16u) // Grab second byte. - #define macro_f_utf_char_t_to_char_3(character) (((character) & F_utf_char_mask_char_3_d) >> 8u) // Grab third byte. - #define macro_f_utf_char_t_to_char_4(character) ((character) & F_utf_char_mask_char_4_d) // Grab fourth byte. - - #define macro_f_utf_char_t_from_char_1(character) (((character) << 24u) & F_utf_char_mask_char_1_d) // Shift to first byte. - #define macro_f_utf_char_t_from_char_2(character) (((character) << 16u) & F_utf_char_mask_char_2_d) // Shift to second byte. - #define macro_f_utf_char_t_from_char_3(character) (((character) << 8u) & F_utf_char_mask_char_3_d) // Shift to third byte. - #define macro_f_utf_char_t_from_char_4(character) ((character) & F_utf_char_mask_char_4_d) // Shift to fourth byte. - #else #define F_utf_char_mask_byte_1_d 0x000000ffu // 0000 0000, 0000 0000, 0000 0000, 1111 1111 #define F_utf_char_mask_byte_2_d 0x0000ffffu // 0000 0000, 0000 0000, 1111 1111, 1111 1111 #define F_utf_char_mask_byte_3_d 0x00ffffffu // 0000 0000, 1111 1111, 1111 1111, 1111 1111 @@ -221,6 +201,26 @@ extern "C" { #define macro_f_utf_char_t_from_char_2(character) (((character) << 8u) & F_utf_char_mask_char_2_d) // Shift to second byte. #define macro_f_utf_char_t_from_char_3(character) (((character) << 16u) & F_utf_char_mask_char_3_d) // Shift to third byte. #define macro_f_utf_char_t_from_char_4(character) (((character) << 24u) & F_utf_char_mask_char_4_d) // Shift to fourth byte. + #else + #define F_utf_char_mask_byte_1_d 0xff000000u // 1111 1111, 0000 0000, 0000 0000, 0000 0000 + #define F_utf_char_mask_byte_2_d 0xffff0000u // 1111 1111, 1111 1111, 0000 0000, 0000 0000 + #define F_utf_char_mask_byte_3_d 0xffffff00u // 1111 1111, 1111 1111, 1111 1111, 0000 0000 + #define F_utf_char_mask_byte_4_d 0xffffffffu // 1111 1111, 1111 1111, 1111 1111, 1111 1111 + + #define F_utf_char_mask_char_1_d 0xff000000u // 1111 1111, 0000 0000, 0000 0000, 0000 0000 + #define F_utf_char_mask_char_2_d 0x00ff0000u // 0000 0000, 1111 1111, 0000 0000, 0000 0000 + #define F_utf_char_mask_char_3_d 0x0000ff00u // 0000 0000, 0000 0000, 1111 1111, 0000 0000 + #define F_utf_char_mask_char_4_d 0x000000ffu // 0000 0000, 0000 0000, 0000 0000, 1111 1111 + + #define macro_f_utf_char_t_to_char_1(character) (((character) & F_utf_char_mask_char_1_d) >> 24u) // Grab first byte. + #define macro_f_utf_char_t_to_char_2(character) (((character) & F_utf_char_mask_char_2_d) >> 16u) // Grab second byte. + #define macro_f_utf_char_t_to_char_3(character) (((character) & F_utf_char_mask_char_3_d) >> 8u) // Grab third byte. + #define macro_f_utf_char_t_to_char_4(character) ((character) & F_utf_char_mask_char_4_d) // Grab fourth byte. + + #define macro_f_utf_char_t_from_char_1(character) (((character) << 24u) & F_utf_char_mask_char_1_d) // Shift to first byte. + #define macro_f_utf_char_t_from_char_2(character) (((character) << 16u) & F_utf_char_mask_char_2_d) // Shift to second byte. + #define macro_f_utf_char_t_from_char_3(character) (((character) << 8u) & F_utf_char_mask_char_3_d) // Shift to third byte. + #define macro_f_utf_char_t_from_char_4(character) ((character) & F_utf_char_mask_char_4_d) // Shift to fourth byte. #endif // _is_F_endian_big #define macro_f_utf_char_t_width(character) (macro_f_utf_byte_width(macro_f_utf_char_t_to_char_1(character))) @@ -234,11 +234,11 @@ extern "C" { */ #ifndef _di_f_utf_char_t_codes_ #ifdef _is_F_endian_big - #define F_utf_char_t_eol_d 0x0a000000u // 0000 1010, 0000 0000, 0000 0000, 0000 0000 + #define F_utf_char_t_eol_d 0x0000000au // 0000 0000, 0000 0000, 0000 0000, 0000 1010 #define F_utf_char_t_eos_d 0x00000000u // 0000 0000, 0000 0000, 0000 0000, 0000 0000 #define F_utf_char_t_placeholder_d 0x00000000u // 0000 0000, 0000 0000, 0000 0000, 0000 0000 #else - #define F_utf_char_t_eol_d 0x0000000au // 0000 0000, 0000 0000, 0000 0000, 0000 1010 + #define F_utf_char_t_eol_d 0x0a000000u // 0000 1010, 0000 0000, 0000 0000, 0000 0000 #define F_utf_char_t_eos_d 0x00000000u // 0000 0000, 0000 0000, 0000 0000, 0000 0000 #define F_utf_char_t_placeholder_d 0x00000000u // 0000 0000, 0000 0000, 0000 0000, 0000 0000 #endif // _is_F_endian_big -- 1.8.3.1