Skip to content

Commit

Permalink
locale.c: Properly identify reason for placeholder in arrays
Browse files Browse the repository at this point in the history
This is needed to handle the case where a locale category passed in (via
Perl_setlocale) is unknown to perl, hence is considered illegal.

The previous comments were misleading.
  • Loading branch information
khwilliamson committed May 6, 2023
1 parent cc0ba70 commit b1f3d4a
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions locale.c
Expand Up @@ -309,9 +309,9 @@ STATIC const int categories[] = {
FAKE_LC_ALL,
# endif

/* Placeholder as a precaution if code fails to check the return of
* get_category_index(), which returns this element to indicate an error */
-1
/* Placeholder for an unknown category. get_category_index() maps all
* categories we don't know about to the index of this element */
PERL_INT_MIN
};

/* The top-most real element is LC_ALL */
Expand Down Expand Up @@ -366,10 +366,9 @@ STATIC const char * const category_names[] = {
"If you see this, it is a bug in"
" perl; please report it via perlbug",
# endif

/* Placeholder as a precaution if code fails to check the return of
* get_category_index(), which returns this element to indicate an error */
NULL
"Locale category unknown to Perl; if" \
" you see this, it is a bug in perl;" \
" please report it via perlbug"
};

/* A few categories require additional setup when they are changed. This table
Expand Down Expand Up @@ -420,9 +419,8 @@ STATIC void (*update_functions[]) (pTHX_ const char *, bool force) = {
/* No harm done to have this even without an LC_ALL */
S_new_LC_ALL,

/* Placeholder as a precaution if code fails to check the return of
* get_category_index(), which returns this element to indicate an error */
NULL
NULL /* Placeholder for all unknown
categories */
};

# ifdef USE_POSIX_2008_LOCALE
Expand Down Expand Up @@ -474,9 +472,7 @@ STATIC const int category_masks[] = {
# endif
LC_ALL_MASK,

/* Placeholder as a precaution if code fails to check the return of
* get_category_index(), which returns this element to indicate an error */
0
0 /* Placeholder for all unknown categories */
};

# endif
Expand Down

0 comments on commit b1f3d4a

Please sign in to comment.