From 265ec34504a94be951392fbafdb653fb6db13ce8 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 15 Aug 2021 20:22:44 -0600 Subject: utf8.c: White-space, comment only --- utf8.c | 82 ++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'utf8.c') diff --git a/utf8.c b/utf8.c index b372267506..dd1dd49b0f 100644 --- a/utf8.c +++ b/utf8.c @@ -3192,59 +3192,61 @@ S_to_case_cp_list(pTHX_ const UV original, PERL_ARGS_ASSERT_TO_CASE_CP_LIST; - /* 'index' is guaranteed to be non-negative, as this is an inversion - * map that covers all possible inputs. See [perl #133365] */ - index = _invlist_search(invlist, original); - base = invmap[index]; + /* 'index' is guaranteed to be non-negative, as this is an inversion map + * that covers all possible inputs. See [perl #133365] */ + index = _invlist_search(invlist, original); + base = invmap[index]; if (LIKELY(base == 0)) { /* 0 => original was unchanged by casing */ /* At this bottom level routine is where we warn about illegal code * points */ if (isUNICODE_POSSIBLY_PROBLEMATIC(original)) { - if (UNLIKELY(UNICODE_IS_SURROGATE(original))) { - if (ckWARN_d(WARN_SURROGATE)) { - const char* desc = (PL_op) ? OP_DESC(PL_op) : normal; - Perl_warner(aTHX_ packWARN(WARN_SURROGATE), - "Operation \"%s\" returns its argument for" - " UTF-16 surrogate U+%04" UVXf, desc, original); - } - } - else if (UNLIKELY(UNICODE_IS_SUPER(original))) { - if (UNLIKELY(original > MAX_LEGAL_CP)) { - Perl_croak(aTHX_ "%s", form_cp_too_large_msg(16, NULL, 0, original)); - } - if (ckWARN_d(WARN_NON_UNICODE)) { - const char* desc = (PL_op) ? OP_DESC(PL_op) : normal; - Perl_warner(aTHX_ packWARN(WARN_NON_UNICODE), - "Operation \"%s\" returns its argument for" - " non-Unicode code point 0x%04" UVXf, desc, original); - } + if (UNLIKELY(UNICODE_IS_SURROGATE(original))) { + if (ckWARN_d(WARN_SURROGATE)) { + const char* desc = (PL_op) ? OP_DESC(PL_op) : normal; + Perl_warner(aTHX_ packWARN(WARN_SURROGATE), + "Operation \"%s\" returns its argument for" + " UTF-16 surrogate U+%04" UVXf, desc, original); } - /* Note that non-characters are perfectly legal, so no warning should - * be given. */ - } - - *remaining_count = 0; - return original; + else if (UNLIKELY(UNICODE_IS_SUPER(original))) { + if (UNLIKELY(original > MAX_LEGAL_CP)) { + Perl_croak(aTHX_ "%s", form_cp_too_large_msg(16, NULL, 0, original)); + } + if (ckWARN_d(WARN_NON_UNICODE)) { + const char* desc = (PL_op) ? OP_DESC(PL_op) : normal; + Perl_warner(aTHX_ packWARN(WARN_NON_UNICODE), + "Operation \"%s\" returns its argument for" + " non-Unicode code point 0x%04" UVXf, desc, original); + } } - if (LIKELY(base > 0)) { - *remaining_count = 0; - return base + original - invlist_array(invlist)[index]; + /* Note that non-characters are perfectly legal, so no warning + * should be given. */ } + *remaining_count = 0; + return original; + } - /* Here 'base' is negative. That means the mapping is 1-to-many, and - * requires an auxiliary table look up. abs(base) gives the index into - * a list of such tables which points to the proper aux table. And a - * parallel list gives the length of each corresponding aux table. */ - base = -base; - *remaining_list = aux_tables[base] + 1; - *remaining_count = (Size_t) (aux_table_lengths[base] - 1); + if (LIKELY(base > 0)) { /* means original mapped to a single code point, + different from itself */ + *remaining_count = 0; + return base + original - invlist_array(invlist)[index]; + } - return (UV) aux_tables[base][0]; + /* Here 'base' is negative. That means the mapping is 1-to-many, and + * requires an auxiliary table look up. abs(base) gives the index into a + * list of such tables which points to the proper aux table. And a + * parallel list gives the length of each corresponding aux table. Skip + * the first entry in the *remaining returns, as it is returned by the + * function. */ + base = -base; + *remaining_list = aux_tables[base] + 1; + *remaining_count = (Size_t) (aux_table_lengths[base] - 1); + + return (UV) aux_tables[base][0]; } STATIC UV @@ -3296,7 +3298,7 @@ S__to_utf8_case(pTHX_ const UV original, const U8 *p, for (i = 0; i < remaining_count; i++) { d = uvchr_to_utf8(d, remaining_list[i]); - } + } *d = '\0'; *lenp = d - ustrp; -- cgit v1.2.1