Skip to content

Commit 3bc9d32

Browse files
committed
locale.c: Reorder parameters to static function
Move the least important parameters (that can be NULL to indicate unused) to the end of the parameter list, thereby moving the required ones to the beginning. This makes it clear what is important.
1 parent ef4a769 commit 3bc9d32

File tree

3 files changed

+39
-33
lines changed

3 files changed

+39
-33
lines changed

embed.fnc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,11 +3336,11 @@ ST |const char *|save_to_buffer|NULLOK const char * string \
33363336
|NULLOK const char **buf \
33373337
|NULLOK Size_t *buf_size
33383338
ST |unsigned int|get_category_index|const int category|NULLOK const char * locale
3339-
S |utf8ness_t|get_locale_string_utf8ness_i \
3340-
|NULLOK const char * locale \
3341-
|const unsigned cat_index \
3339+
S |utf8ness_t|get_locale_string_utf8ness_i \
33423340
|NULLOK const char * string \
3343-
|const locale_utf8ness_t known_utf8
3341+
|const locale_utf8ness_t known_utf8 \
3342+
|NULLOK const char * locale \
3343+
|const unsigned cat_index
33443344
# ifdef USE_LOCALE_CTYPE
33453345
S |void |new_ctype |NN const char* newctype
33463346
ST |bool |is_codeset_name_UTF8|NN const char * name

locale.c

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,10 +2950,10 @@ S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size)
29502950
}
29512951

29522952
STATIC utf8ness_t
2953-
S_get_locale_string_utf8ness_i(pTHX_ const char * locale,
2954-
const unsigned cat_index,
2955-
const char * string,
2956-
const locale_utf8ness_t known_utf8)
2953+
S_get_locale_string_utf8ness_i(pTHX_ const char * string,
2954+
const locale_utf8ness_t known_utf8,
2955+
const char * locale,
2956+
const unsigned cat_index)
29572957
{
29582958
PERL_ARGS_ASSERT_GET_LOCALE_STRING_UTF8NESS_I;
29592959
assert(cat_index <= NOMINAL_LC_ALL_INDEX);
@@ -3056,7 +3056,7 @@ Perl_get_win32_message_utf8ness(pTHX_ const char * string)
30563056
* locale and category completely.
30573057
*
30583058
* This is because Windows doesn't have LC_MESSAGES */
3059-
return get_locale_string_utf8ness_i(NULL, 0, string, LOCALE_IS_UTF8);
3059+
return get_locale_string_utf8ness_i(string, LOCALE_IS_UTF8, NULL, 0);
30603060
}
30613061

30623062
# endif
@@ -3534,10 +3534,10 @@ S_populate_localeconv(pTHX_ const struct lconv *lcbuf,
35343534
const char *value = *((const char **)(ptr + strings->offset));
35353535
if (value) {
35363536
bool is_utf8 = /* Only make UTF-8 if required to */
3537-
(UTF8NESS_YES == (get_locale_string_utf8ness_i(locale,
3538-
cat_index,
3539-
value,
3540-
locale_is_utf8)));
3537+
(UTF8NESS_YES == (get_locale_string_utf8ness_i(value,
3538+
locale_is_utf8,
3539+
locale,
3540+
cat_index)));
35413541
(void) hv_store(retval,
35423542
strings->name,
35433543
strlen(strings->name),
@@ -3990,8 +3990,9 @@ S_my_langinfo_i(pTHX_
39903990
retval = save_to_buffer(nl_langinfo_l(item, cur), retbufp, retbuf_sizep);
39913991

39923992
if (utf8ness) {
3993-
*utf8ness = get_locale_string_utf8ness_i(locale, cat_index, retval,
3994-
LOCALE_UTF8NESS_UNKNOWN);
3993+
*utf8ness = get_locale_string_utf8ness_i(retval,
3994+
LOCALE_UTF8NESS_UNKNOWN,
3995+
locale, cat_index);
39953996
}
39963997

39973998
freelocale(cur);
@@ -4017,8 +4018,9 @@ S_my_langinfo_i(pTHX_
40174018
gwLOCALE_UNLOCK;
40184019

40194020
if (utf8ness) {
4020-
*utf8ness = get_locale_string_utf8ness_i(locale, cat_index,
4021-
retval, LOCALE_UTF8NESS_UNKNOWN);
4021+
*utf8ness = get_locale_string_utf8ness_i(retval,
4022+
LOCALE_UTF8NESS_UNKNOWN,
4023+
locale, cat_index);
40224024
}
40234025

40244026
restore_toggled_locale_i(cat_index, orig_switched_locale);
@@ -4111,9 +4113,9 @@ S_my_langinfo_i(pTHX_
41114113
Safefree(floatbuf);
41124114

41134115
if (utf8ness) {
4114-
is_utf8 = get_locale_string_utf8ness_i(locale, cat_index,
4115-
retval,
4116-
LOCALE_UTF8NESS_UNKNOWN);
4116+
is_utf8 = get_locale_string_utf8ness_i(retval,
4117+
LOCALE_UTF8NESS_UNKNOWN,
4118+
locale, cat_index);
41174119
}
41184120

41194121
break;
@@ -4149,8 +4151,9 @@ S_my_langinfo_i(pTHX_
41494151
retval = save_to_buffer(SvPV_nolen(string), retbufp, retbuf_sizep);
41504152

41514153
if (utf8ness) {
4152-
is_utf8 = get_locale_string_utf8ness_i(locale, cat_index, retval,
4153-
LOCALE_UTF8NESS_UNKNOWN);
4154+
is_utf8 = get_locale_string_utf8ness_i(retval,
4155+
LOCALE_UTF8NESS_UNKNOWN,
4156+
locale, cat_index);
41544157
}
41554158

41564159
SvREFCNT_dec_NN(string);
@@ -4565,8 +4568,9 @@ Perl_my_strftime8(pTHX_ const char *fmt, int sec, int min, int hour, int mday,
45654568
if (utf8ness) {
45664569

45674570
#ifdef USE_LOCALE_TIME
4568-
*utf8ness = get_locale_string_utf8ness_i(NULL, LC_TIME_INDEX_,
4569-
retval, LOCALE_UTF8NESS_UNKNOWN);
4571+
*utf8ness = get_locale_string_utf8ness_i(retval,
4572+
LOCALE_UTF8NESS_UNKNOWN,
4573+
NULL, LC_TIME_INDEX_);
45704574
#else
45714575
*utf8ness = UTF8NESS_IMMATERIAL;
45724576
#endif
@@ -6406,8 +6410,8 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness)
64066410
: use_curlocale_scratch();
64076411

64086412
const char *errstr = savepv(strerror_l(errnum, which_obj));
6409-
*utf8ness = get_locale_string_utf8ness_i(NULL, WHICH_LC_INDEX, errstr,
6410-
LOCALE_UTF8NESS_UNKNOWN);
6413+
*utf8ness = get_locale_string_utf8ness_i(errstr, LOCALE_UTF8NESS_UNKNOWN,
6414+
NULL, WHICH_LC_INDEX);
64116415
DEBUG_STRERROR_RETURN(errstr, utf8ness);
64126416

64136417
SAVEFREEPV(errstr);
@@ -6436,8 +6440,9 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness)
64366440

64376441
cur = newlocale(LC_CTYPE_MASK, querylocale_c(LC_MESSAGES), cur);
64386442
errstr = savepv(strerror_l(errnum, cur));
6439-
*utf8ness = get_locale_string_utf8ness_i(NULL, LC_MESSAGES_INDEX_,
6440-
errstr, LOCALE_UTF8NESS_UNKNOWN);
6443+
*utf8ness = get_locale_string_utf8ness_i(errstr,
6444+
LOCALE_UTF8NESS_UNKNOWN,
6445+
NULL, LC_MESSAGES_INDEX_);
64416446
freelocale(cur);
64426447
}
64436448

@@ -6487,8 +6492,9 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness)
64876492
const char *errstr;
64886493
if (IN_LC(categories[WHICH_LC_INDEX])) {
64896494
errstr = savepv(Strerror(errnum));
6490-
*utf8ness = get_locale_string_utf8ness_i(NULL, WHICH_LC_INDEX, errstr,
6491-
LOCALE_UTF8NESS_UNKNOWN);
6495+
*utf8ness = get_locale_string_utf8ness_i(errstr,
6496+
LOCALE_UTF8NESS_UNKNOWN,
6497+
NULL, WHICH_LC_INDEX);
64926498
}
64936499
else {
64946500

@@ -6542,8 +6548,8 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness)
65426548

65436549
SETLOCALE_UNLOCK;
65446550

6545-
*utf8ness = get_locale_string_utf8ness_i(NULL, LC_MESSAGES_INDEX_, errstr,
6546-
LOCALE_UTF8NESS_UNKNOWN);
6551+
*utf8ness = get_locale_string_utf8ness_i(errstr, LOCALE_UTF8NESS_UNKNOWN,
6552+
NULL, LC_MESSAGES_INDEX_);
65476553
DEBUG_STRERROR_RETURN(errstr, utf8ness);
65486554

65496555
SAVEFREEPV(errstr);

proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5739,7 +5739,7 @@ PERL_CALLCONV SV* Perl_hfree_next_entry(pTHX_ HV *hv, STRLEN *indexp)
57395739
# if defined(USE_LOCALE)
57405740
STATIC unsigned int S_get_category_index(const int category, const char * locale);
57415741
#define PERL_ARGS_ASSERT_GET_CATEGORY_INDEX
5742-
STATIC utf8ness_t S_get_locale_string_utf8ness_i(pTHX_ const char * locale, const unsigned cat_index, const char * string, const locale_utf8ness_t known_utf8);
5742+
STATIC utf8ness_t S_get_locale_string_utf8ness_i(pTHX_ const char * string, const locale_utf8ness_t known_utf8, const char * locale, const unsigned cat_index);
57435743
#define PERL_ARGS_ASSERT_GET_LOCALE_STRING_UTF8NESS_I
57445744
STATIC bool S_is_locale_utf8(pTHX_ const char * locale);
57455745
#define PERL_ARGS_ASSERT_IS_LOCALE_UTF8 \

0 commit comments

Comments
 (0)