Skip to content

Commit

Permalink
Change name of internal function
Browse files Browse the repository at this point in the history
This is in preparation for working on it; the new name, mem_collxfrm_ is
in compliance with the C Standard; the old was not.
  • Loading branch information
khwilliamson committed May 5, 2021
1 parent e8b7e10 commit 6110c8c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion embed.fnc
Expand Up @@ -1350,7 +1350,7 @@ p |int |magic_freecollxfrm|NN SV* sv|NN MAGIC* mg
pbD |char* |mem_collxfrm |NN const char* input_string|STRLEN len|NN STRLEN* xlen
: Defined in locale.c, used only in sv.c
# if defined(PERL_IN_LOCALE_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_MATHOMS_C)
p |char* |_mem_collxfrm |NN const char* input_string \
Ep |char* |mem_collxfrm_ |NN const char* input_string \
|STRLEN len \
|NN STRLEN* xlen \
|bool utf8
Expand Down
10 changes: 5 additions & 5 deletions embed.h
Expand Up @@ -1043,6 +1043,11 @@
# if defined(PERL_IN_GV_C) || defined(PERL_IN_UNIVERSAL_C)
#define gv_stashsvpvn_cached(a,b,c,d) Perl_gv_stashsvpvn_cached(aTHX_ a,b,c,d)
# endif
# if defined(PERL_IN_LOCALE_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_MATHOMS_C)
# if defined(USE_LOCALE_COLLATE)
#define mem_collxfrm_(a,b,c,d) Perl_mem_collxfrm_(aTHX_ a,b,c,d)
# endif
# endif
# if defined(PERL_IN_REGCOMP_C)
#define add_above_Latin1_folds(a,b,c) S_add_above_Latin1_folds(aTHX_ a,b,c)
#define add_data S_add_data
Expand Down Expand Up @@ -1753,11 +1758,6 @@
# endif
# endif
# endif
# if defined(PERL_IN_LOCALE_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_MATHOMS_C)
# if defined(USE_LOCALE_COLLATE)
#define _mem_collxfrm(a,b,c,d) Perl__mem_collxfrm(aTHX_ a,b,c,d)
# endif
# endif
# if defined(PERL_IN_MALLOC_C)
#define adjust_size_and_find_bucket S_adjust_size_and_find_bucket
# endif
Expand Down
38 changes: 19 additions & 19 deletions locale.c
Expand Up @@ -2214,7 +2214,7 @@ S_new_collate(pTHX_ const char *newcoll)
char * x_shorter; /* We also transform a substring of 'longer' */
Size_t x_len_shorter;

/* _mem_collxfrm() is used get the transformation (though here we
/* mem_collxfrm_() is used get the transformation (though here we
* are interested only in its length). It is used because it has
* the intelligence to handle all cases, but to work, it needs some
* values of 'm' and 'b' to get it started. For the purposes of
Expand All @@ -2226,7 +2226,7 @@ S_new_collate(pTHX_ const char *newcoll)
PL_collxfrm_mult = 5 * sizeof(UV);

/* Find out how long the transformation really is */
x_longer = _mem_collxfrm(longer,
x_longer = mem_collxfrm_(longer,
sizeof(longer) - 1,
&x_len_longer,

Expand All @@ -2245,7 +2245,7 @@ S_new_collate(pTHX_ const char *newcoll)
* sufficient to calculate 'm' and 'b'. The substring is all of
* 'longer' except the first character. This minimizes the chances
* of being swayed by outliers */
x_shorter = _mem_collxfrm(longer + 1,
x_shorter = mem_collxfrm_(longer + 1,
sizeof(longer) - 2,
&x_len_shorter,
PL_in_utf8_COLLATE_locale);
Expand Down Expand Up @@ -5081,15 +5081,15 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
#ifdef USE_LOCALE_COLLATE

char *
Perl__mem_collxfrm(pTHX_ const char *input_string,
Perl_mem_collxfrm_(pTHX_ const char *input_string,
STRLEN len, /* Length of 'input_string' */
STRLEN *xlen, /* Set to length of returned string
(not including the collation index
prefix) */
bool utf8 /* Is the input in UTF-8? */
)
{
/* _mem_collxfrm() is like strxfrm() but with two important differences.
/* mem_collxfrm_() is like strxfrm() but with two important differences.
* First, it handles embedded NULs. Second, it allocates a bit more memory
* than needed for the transformed data itself. The real transformed data
* begins at offset COLLXFRM_HDR_LEN. *xlen is set to the length of that,
Expand All @@ -5114,15 +5114,15 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
locale_t constructed_locale = (locale_t) 0;
# endif

PERL_ARGS_ASSERT__MEM_COLLXFRM;
PERL_ARGS_ASSERT_MEM_COLLXFRM_;

/* Must be NUL-terminated */
assert(*(input_string + len) == '\0');

/* If this locale has defective collation, skip */
if (PL_collxfrm_base == 0 && PL_collxfrm_mult == 0) {
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: locale's collation is defective\n"));
"mem_collxfrm_: locale's collation is defective\n"));
goto bad;
}

Expand Down Expand Up @@ -5194,7 +5194,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
cur_source[0] = (char) j;

/* Then transform it */
x = _mem_collxfrm(cur_source, trial_len, &x_len,
x = mem_collxfrm_(cur_source, trial_len, &x_len,
0 /* The string is not in UTF-8 */);

/* Ignore any character that didn't successfully transform.
Expand Down Expand Up @@ -5229,18 +5229,18 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
* work in the locale, repeat the loop, looking for any
* character that works */
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: No control worked. Trying non-controls\n"));
"mem_collxfrm_: No control worked. Trying non-controls\n"));
} /* End of loop to try first the controls, then any char */

if (! cur_min_x) {
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: Couldn't find any character to replace"
"mem_collxfrm_: Couldn't find any character to replace"
" embedded NULs in locale %s with", PL_collation_name));
goto bad;
}

DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: Replacing embedded NULs in locale %s with "
"mem_collxfrm_: Replacing embedded NULs in locale %s with "
"0x%02X\n", PL_collation_name, PL_strxfrm_NUL_replacement));

Safefree(cur_min_x);
Expand Down Expand Up @@ -5353,7 +5353,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
cur_source[0] = (char) j;

/* Then transform it */
x = _mem_collxfrm(cur_source, 1, &x_len, FALSE);
x = mem_collxfrm_(cur_source, 1, &x_len, FALSE);

/* If something went wrong (which it shouldn't), just
* ignore this code point */
Expand All @@ -5378,14 +5378,14 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,

if (! cur_max_x) {
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: Couldn't find any character to"
"mem_collxfrm_: Couldn't find any character to"
" replace above-Latin1 chars in locale %s with",
PL_collation_name));
goto bad;
}

DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: highest 1-byte collating character"
"mem_collxfrm_: highest 1-byte collating character"
" in locale %s is 0x%02X\n",
PL_collation_name,
PL_strxfrm_max_cp));
Expand Down Expand Up @@ -5445,7 +5445,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
Newx(xbuf, xAlloc, char);
if (UNLIKELY(! xbuf)) {
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: Couldn't malloc %zu bytes\n", xAlloc));
"mem_collxfrm_: Couldn't malloc %zu bytes\n", xAlloc));
goto bad;
}

Expand Down Expand Up @@ -5571,7 +5571,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,

if (UNLIKELY(*xlen >= PERL_INT_MAX)) {
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: Needed %zu bytes, max permissible is %u\n",
"mem_collxfrm_: Needed %zu bytes, max permissible is %u\n",
*xlen, PERL_INT_MAX));
goto bad;
}
Expand All @@ -5598,7 +5598,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
PL_strxfrm_is_behaved = FALSE;

DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm required more space than previously"
"mem_collxfrm_ required more space than previously"
" calculated for locale %s, trying again with new"
" guess=%zu+%zu\n",
PL_collation_name, COLLXFRM_HDR_LEN,
Expand All @@ -5608,7 +5608,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
Renew(xbuf, xAlloc, char);
if (UNLIKELY(! xbuf)) {
DEBUG_L(PerlIO_printf(Perl_debug_log,
"_mem_collxfrm: Couldn't realloc %zu bytes\n", xAlloc));
"mem_collxfrm_: Couldn't realloc %zu bytes\n", xAlloc));
goto bad;
}

Expand Down Expand Up @@ -5658,7 +5658,7 @@ S_print_collxfrm_input_and_return(pTHX_

PERL_ARGS_ASSERT_PRINT_COLLXFRM_INPUT_AND_RETURN;

PerlIO_printf(Perl_debug_log, "_mem_collxfrm[%" UVuf "]: returning ",
PerlIO_printf(Perl_debug_log, "mem_collxfrm_[%" UVuf "]: returning ",
(UV)PL_collation_ix);
if (xlen) {
PerlIO_printf(Perl_debug_log, "%zu", *xlen);
Expand Down
2 changes: 1 addition & 1 deletion mathoms.c
Expand Up @@ -1089,7 +1089,7 @@ Perl_mem_collxfrm(pTHX_ const char *input_string, STRLEN len, STRLEN *xlen)

PERL_ARGS_ASSERT_MEM_COLLXFRM;

return _mem_collxfrm(input_string, len, xlen, FALSE);
return mem_collxfrm_(input_string, len, xlen, FALSE);
}

#endif
Expand Down
4 changes: 2 additions & 2 deletions proto.h
Expand Up @@ -5239,8 +5239,8 @@ STATIC char* S_win32_setlocale(pTHX_ int category, const char* locale);
#endif
#if defined(PERL_IN_LOCALE_C) || defined(PERL_IN_SV_C) || defined(PERL_IN_MATHOMS_C)
# if defined(USE_LOCALE_COLLATE)
PERL_CALLCONV char* Perl__mem_collxfrm(pTHX_ const char* input_string, STRLEN len, STRLEN* xlen, bool utf8);
#define PERL_ARGS_ASSERT__MEM_COLLXFRM \
PERL_CALLCONV char* Perl_mem_collxfrm_(pTHX_ const char* input_string, STRLEN len, STRLEN* xlen, bool utf8);
#define PERL_ARGS_ASSERT_MEM_COLLXFRM_ \
assert(input_string); assert(xlen)
# endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion sv.c
Expand Up @@ -8261,7 +8261,7 @@ Perl_sv_collxfrm_flags(pTHX_ SV *const sv, STRLEN *const nxp, const I32 flags)
Safefree(mg->mg_ptr);

s = SvPV_flags_const(sv, len, flags);
if ((xf = _mem_collxfrm(s, len, &xlen, cBOOL(SvUTF8(sv))))) {
if ((xf = mem_collxfrm_(s, len, &xlen, cBOOL(SvUTF8(sv))))) {
if (! mg) {
mg = sv_magicext(sv, 0, PERL_MAGIC_collxfrm, &PL_vtbl_collxfrm,
0, 0);
Expand Down

0 comments on commit 6110c8c

Please sign in to comment.