summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2014-02-15 13:09:17 -0700
committerKarl Williamson <public@khwilliamson.com>2014-02-15 15:50:35 -0700
commit0e92a118111cc7fdf7a2bf58c8e45ef7b2b85ef4 (patch)
tree45c89e1cb01f9a33e52b88ac6f1d410d9b08dc92 /locale.c
parentb385bb4ddcb252e69a1044d702646741e2e489fb (diff)
downloadperl-0e92a118111cc7fdf7a2bf58c8e45ef7b2b85ef4.tar.gz
locale.c: Add, move some comments, and a declaration
This adds some more comments at the beginning of a function concerning its API, and moves them to before any declarations. It also moves the declaration for 'done' to the block of other declarations, and adds a PERL_UNUSED_VAR call if the code that uses it is #ifdef'd out. Previously it was too easy to not notice the declaration separate from the others, and to insert code between the two, which would not compile under C89, but only on Ultrix machines.
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/locale.c b/locale.c
index 18f5ee9613..73fe055bca 100644
--- a/locale.c
+++ b/locale.c
@@ -416,13 +416,20 @@ Perl_my_setlocale(pTHX_ int category, const char* locale)
int
Perl_init_i18nl10n(pTHX_ int printwarn)
{
- int ok = 1;
- /* returns
+ /* printwarn is
+ *
+ * 0 if not to output warning when setup locale is bad
+ * 1 if to output warning based on value of PERL_BADLANG
+ * >1 if to output regardless of PERL_BADLANG
+ *
+ * returns
* 1 = set ok or not applicable,
- * 0 = fallback to C locale,
- * -1 = fallback to C locale failed
+ * 0 = fallback to a locale of lower priority
+ * -1 = fallback to all locales failed, not even to the C locale
*/
+ int ok = 1;
+
#if defined(USE_LOCALE)
dVAR;
@@ -445,16 +452,18 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
char * const lc_all = PerlEnv_getenv("LC_ALL");
char * const lang = PerlEnv_getenv("LANG");
bool setlocale_failure = FALSE;
+ bool done = FALSE;
+
-#ifdef LOCALE_ENVIRON_REQUIRED
+#ifndef LOCALE_ENVIRON_REQUIRED
+ PERL_UNUSED_VAR(done);
+#else
/*
* Ultrix setlocale(..., "") fails if there are no environment
* variables from which to get a locale name.
*/
- bool done = FALSE;
-
# ifdef LC_ALL
if (lang) {
if (my_setlocale(LC_ALL, setlocale_init))