From e50fcca9a79d8e25b33ad3611df6bf4627faafbf Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 13 Sep 2023 20:24:22 -0400 Subject: [ruby/yarp] make some encoding tables `const` https://github.com/ruby/yarp/commit/777c376deb --- yarp/enc/yp_encoding.h | 2 +- yarp/enc/yp_unicode.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/yarp/enc/yp_encoding.h b/yarp/enc/yp_encoding.h index 9e8e7e01f6..d8563bd54a 100644 --- a/yarp/enc/yp_encoding.h +++ b/yarp/enc/yp_encoding.h @@ -60,7 +60,7 @@ size_t yp_encoding_utf_8_alnum_char(const uint8_t *b, ptrdiff_t n); // This lookup table is referenced in both the UTF-8 encoding file and the // parser directly in order to speed up the default encoding processing. -extern uint8_t yp_encoding_unicode_table[256]; +extern const uint8_t yp_encoding_unicode_table[256]; // These are the encodings that are supported by the parser. They are defined in // their own files in the src/enc directory. diff --git a/yarp/enc/yp_unicode.c b/yarp/enc/yp_unicode.c index bb4e041309..196955d483 100644 --- a/yarp/enc/yp_unicode.c +++ b/yarp/enc/yp_unicode.c @@ -10,7 +10,7 @@ typedef uint32_t yp_unicode_codepoint_t; // this table is different from other encodings where we used a lookup table // because the indices of those tables are the byte representations, not the // codepoints themselves. -uint8_t yp_encoding_unicode_table[256] = { +const uint8_t yp_encoding_unicode_table[256] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x @@ -31,7 +31,7 @@ uint8_t yp_encoding_unicode_table[256] = { }; #define UNICODE_ALPHA_CODEPOINTS_LENGTH 1450 -static yp_unicode_codepoint_t unicode_alpha_codepoints[UNICODE_ALPHA_CODEPOINTS_LENGTH] = { +static const yp_unicode_codepoint_t unicode_alpha_codepoints[UNICODE_ALPHA_CODEPOINTS_LENGTH] = { 0x100, 0x2C1, 0x2C6, 0x2D1, 0x2E0, 0x2E4, @@ -760,7 +760,7 @@ static yp_unicode_codepoint_t unicode_alpha_codepoints[UNICODE_ALPHA_CODEPOINTS_ }; #define UNICODE_ALNUM_CODEPOINTS_LENGTH 1528 -static yp_unicode_codepoint_t unicode_alnum_codepoints[UNICODE_ALNUM_CODEPOINTS_LENGTH] = { +static const yp_unicode_codepoint_t unicode_alnum_codepoints[UNICODE_ALNUM_CODEPOINTS_LENGTH] = { 0x100, 0x2C1, 0x2C6, 0x2D1, 0x2E0, 0x2E4, @@ -1528,7 +1528,7 @@ static yp_unicode_codepoint_t unicode_alnum_codepoints[UNICODE_ALNUM_CODEPOINTS_ }; #define UNICODE_ISUPPER_CODEPOINTS_LENGTH 1296 -static yp_unicode_codepoint_t unicode_isupper_codepoints[UNICODE_ISUPPER_CODEPOINTS_LENGTH] = { +static const yp_unicode_codepoint_t unicode_isupper_codepoints[UNICODE_ISUPPER_CODEPOINTS_LENGTH] = { 0x100, 0x100, 0x102, 0x102, 0x104, 0x104, @@ -2180,7 +2180,7 @@ static yp_unicode_codepoint_t unicode_isupper_codepoints[UNICODE_ISUPPER_CODEPOI }; static bool -yp_unicode_codepoint_match(yp_unicode_codepoint_t codepoint, yp_unicode_codepoint_t *codepoints, size_t size) { +yp_unicode_codepoint_match(yp_unicode_codepoint_t codepoint, const yp_unicode_codepoint_t *codepoints, size_t size) { size_t start = 0; size_t end = size; -- cgit v1.2.3