From dd542d578ab9fcac53b46c89287a2cfb61f017d5 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 10 Sep 2026 12:04:59 -0400 Subject: [PATCH 1/2] change options argument type to unsigned int --- bench/bench.c | 2 +- test/fuzzer.c | 2 +- utf8proc.c | 16 ++++++++-------- utf8proc.h | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bench/bench.c b/bench/bench.c index b0cc92a..c3e04f5 100644 --- a/bench/bench.c +++ b/bench/bench.c @@ -8,7 +8,7 @@ int main(int argc, char **argv) { int i, j; - int options = 0; + unsigned int options = 0; for (i = 1; i < argc; ++i) { if (!strcmp(argv[i], "-nfkc")) { diff --git a/test/fuzzer.c b/test/fuzzer.c index 1c216ef..8aa55b2 100644 --- a/test/fuzzer.c +++ b/test/fuzzer.c @@ -12,7 +12,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) const uint8_t* ptr = data; utf8proc_int32_t c = 0, c_prev = 0, state = 0; - utf8proc_option_t options; + unsigned int options; utf8proc_ssize_t ret, bytes = 0; utf8proc_uint8_t *str = NULL; size_t len = strlen((const char*)data); diff --git a/utf8proc.c b/utf8proc.c index 8afb11a..1caf5c4 100644 --- a/utf8proc.c +++ b/utf8proc.c @@ -377,7 +377,7 @@ static utf8proc_int32_t seqindex_decode_index(const utf8proc_uint32_t seqindex) return seqindex_decode_entry(&entry); } -static utf8proc_ssize_t seqindex_write_char_decomposed(utf8proc_uint16_t seqindex, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, utf8proc_option_t options, int *last_boundclass) { +static utf8proc_ssize_t seqindex_write_char_decomposed(utf8proc_uint16_t seqindex, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, unsigned int options, int *last_boundclass) { utf8proc_ssize_t written = 0; const utf8proc_uint16_t *entry = &utf8proc_sequences[seqindex & 0x3FFF]; int len = seqindex >> 14; @@ -449,7 +449,7 @@ UTF8PROC_DLLEXPORT const char *utf8proc_category_string(utf8proc_int32_t c) { return utf8proc_decompose_char((replacement_uc), dst, bufsize, \ (utf8proc_option_t)(options & ~(unsigned int)UTF8PROC_LUMP), last_boundclass) -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, utf8proc_option_t options, int *last_boundclass) { +UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, unsigned int options, int *last_boundclass) { const utf8proc_property_t *property; utf8proc_propval_t category; utf8proc_int32_t hangul_sindex; @@ -539,14 +539,14 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc, UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose( const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, - utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options + utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, unsigned int options ) { return utf8proc_decompose_custom(str, strlen, buffer, bufsize, options, NULL, NULL); } UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom( const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, - utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options, + utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, unsigned int options, utf8proc_custom_func custom_func, void *custom_data ) { /* strlen will be ignored, if UTF8PROC_NULLTERM is set in options */ @@ -621,7 +621,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom( return wpos; } -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *buffer, utf8proc_ssize_t length, utf8proc_option_t options) { +UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *buffer, utf8proc_ssize_t length, unsigned int options) { /* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored */ if (options & (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS | UTF8PROC_STRIPCC)) { utf8proc_ssize_t rpos; @@ -742,7 +742,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *b return length; } -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, utf8proc_ssize_t length, utf8proc_option_t options) { +UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, utf8proc_ssize_t length, unsigned int options) { /* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored ASSERT: 'buffer' has one spare byte of free space at the end! */ length = utf8proc_normalize_utf32(buffer, length, options); @@ -767,13 +767,13 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, } UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options + const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, unsigned int options ) { return utf8proc_map_custom(str, strlen, dstptr, options, NULL, NULL); } UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map_custom( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options, + const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, unsigned int options, utf8proc_custom_func custom_func, void *custom_data ) { utf8proc_int32_t *buffer; diff --git a/utf8proc.h b/utf8proc.h index 83bb5f6..d8065e3 100644 --- a/utf8proc.h +++ b/utf8proc.h @@ -549,7 +549,7 @@ UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int */ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char( utf8proc_int32_t codepoint, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, - utf8proc_option_t options, int *last_boundclass + unsigned int options, int *last_boundclass ); /** @@ -571,7 +571,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char( */ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose( const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, - utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options + utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, unsigned int options ); /** @@ -582,7 +582,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose( */ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom( const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, - utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options, + utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, unsigned int options, utf8proc_custom_func custom_func, void *custom_data ); @@ -609,7 +609,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom( * @warning The entries of the array pointed to by `str` have to be in the * range `0x0000` to `0x10FFFF`. Otherwise, the program might crash! */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *buffer, utf8proc_ssize_t length, utf8proc_option_t options); +UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *buffer, utf8proc_ssize_t length, unsigned int options); /** * Reencodes the sequence of `length` codepoints pointed to by `buffer` @@ -639,7 +639,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *b * entries of the array pointed to by `str` have to be in the * range `0x0000` to `0x10FFFF`. Otherwise, the program might crash! */ -UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, utf8proc_ssize_t length, utf8proc_option_t options); +UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, utf8proc_ssize_t length, unsigned int options); /** * Given a pair of consecutive codepoints, return whether a grapheme break is @@ -758,7 +758,7 @@ UTF8PROC_DLLEXPORT const char *utf8proc_category_string(utf8proc_int32_t codepoi * those two functions directly. */ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options + const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, unsigned int options ); /** @@ -768,7 +768,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map( * The `custom_func` argument is ignored if it is `NULL`. */ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map_custom( - const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options, + const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, unsigned int options, utf8proc_custom_func custom_func, void *custom_data ); From e10f9a3a3b8d25397b9b304fc7b5dadef80cb0be Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 10 Sep 2026 12:19:36 -0400 Subject: [PATCH 2/2] Update utf8proc.h: clarify docstring --- utf8proc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utf8proc.h b/utf8proc.h index d8065e3..0a26171 100644 --- a/utf8proc.h +++ b/utf8proc.h @@ -143,7 +143,9 @@ extern "C" { #endif /** - * Option flags used by several functions in the library. + * Option flags used by several functions in the library. For + * `unsigned int options` arguments, you can pass a bitwise-or of these + * enumerated constants. */ typedef enum { /** The given UTF-8 input is NULL terminated. */