This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Silence compiler warning when no LC_CTYPE
authorKarl Williamson <khw@cpan.org>
Mon, 5 Sep 2022 00:52:23 +0000 (18:52 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 10 Sep 2022 15:27:17 +0000 (09:27 -0600)
On Configurations without LC_CTYPE, various unused warnings were
being generated.

embed.fnc
embed.h
locale.c
proto.h

index 4a4f9b0..392f2b0 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -3320,14 +3320,16 @@ ST      |const char *|save_to_buffer|NULLOK const char * string \
                                    |NULLOK const char **buf    \
                                    |NULLOK Size_t *buf_size
 ST     |unsigned int|get_category_index|const int category|NULLOK const char * locale
-ST     |bool       |is_codeset_name_UTF8|NN const char * name
 S      |utf8ness_t|get_locale_string_utf8ness_i                                \
                                |NULLOK const char * locale             \
                                |const unsigned cat_index               \
                                |NULLOK const char * string             \
                                |const locale_utf8ness_t known_utf8
 S      |void   |new_collate    |NN const char* newcoll
+#    ifdef USE_LOCALE_CTYPE
 S      |void   |new_ctype      |NN const char* newctype
+ST     |bool   |is_codeset_name_UTF8|NN const char * name
+#    endif
 #    ifdef USE_LOCALE_NUMERIC
 S      |void   |new_numeric    |NN const char* newnum
 #    endif
diff --git a/embed.h b/embed.h
index daad5c2..4ad23c9 100644 (file)
--- a/embed.h
+++ b/embed.h
 #    if defined(USE_LOCALE)
 #define get_category_index     S_get_category_index
 #define get_locale_string_utf8ness_i(a,b,c,d)  S_get_locale_string_utf8ness_i(aTHX_ a,b,c,d)
-#define is_codeset_name_UTF8   S_is_codeset_name_UTF8
 #define is_locale_utf8(a)      S_is_locale_utf8(aTHX_ a)
 #define mortalized_pv_copy(a)  S_mortalized_pv_copy(aTHX_ a)
 #define new_LC_ALL(a)          S_new_LC_ALL(aTHX_ a)
 #define new_collate(a)         S_new_collate(aTHX_ a)
-#define new_ctype(a)           S_new_ctype(aTHX_ a)
 #define save_to_buffer         S_save_to_buffer
 #define setlocale_failure_panic_i(a,b,c,d,e)   S_setlocale_failure_panic_i(aTHX_ a,b,c,d,e)
 #define stdize_locale(a,b,c,d,e)       S_stdize_locale(aTHX_ a,b,c,d,e)
+#      if defined(USE_LOCALE_CTYPE)
+#define is_codeset_name_UTF8   S_is_codeset_name_UTF8
+#define new_ctype(a)           S_new_ctype(aTHX_ a)
+#      endif
 #      if defined(USE_LOCALE_NUMERIC)
 #define new_numeric(a)         S_new_numeric(aTHX_ a)
 #      endif
index ada1476..4bdbff7 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -1814,20 +1814,12 @@ Perl_set_numeric_underlying(pTHX)
 
 }
 
-/*
- * Set up for a new ctype locale.
- */
+#  ifdef USE_LOCALE_CTYPE
+
 STATIC void
 S_new_ctype(pTHX_ const char *newctype)
 {
 
-#  ifndef USE_LOCALE_CTYPE
-
-    PERL_UNUSED_ARG(newctype);
-    PERL_UNUSED_CONTEXT;
-
-#  else
-
     /* Called after each libc setlocale() call affecting LC_CTYPE, to tell
      * core Perl this and that 'newctype' is the name of the new locale.
      *
@@ -2222,11 +2214,10 @@ S_new_ctype(pTHX_ const char *newctype)
             }
         }
     }
+}
 
 #  endif /* USE_LOCALE_CTYPE */
 
-}
-
 void
 Perl__warn_problematic_locale()
 {
@@ -5251,7 +5242,10 @@ Perl_mem_collxfrm_(pTHX_ const char *input_string,
     STRLEN xAlloc;          /* xalloc is a reserved word in VC */
     STRLEN length_in_chars;
     bool first_time = TRUE; /* Cleared after first loop iteration */
-    const char * orig_CTYPE_locale = NULL;
+
+#  ifdef USE_LOCALE_CTYPE
+        const char * orig_CTYPE_locale = NULL;
+#  endif
 
 #  if defined(USE_POSIX_2008_LOCALE) && defined HAS_STRXFRM_L
     locale_t constructed_locale = (locale_t) 0;
@@ -5947,6 +5941,8 @@ S_restore_toggled_locale_i(pTHX_ const unsigned int cat_index,
 
 }
 
+#ifdef USE_LOCALE_CTYPE
+
 STATIC bool
 S_is_codeset_name_UTF8(const char * name)
 {
@@ -5972,6 +5968,8 @@ S_is_codeset_name_UTF8(const char * name)
             && (len == 4 || name[3] == '-'));
 }
 
+#endif
+
 STATIC bool
 S_is_locale_utf8(pTHX_ const char * locale)
 {
diff --git a/proto.h b/proto.h
index 40199a2..05aee81 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -5670,9 +5670,6 @@ STATIC unsigned int       S_get_category_index(const int category, const char * locale
 #define PERL_ARGS_ASSERT_GET_CATEGORY_INDEX
 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);
 #define PERL_ARGS_ASSERT_GET_LOCALE_STRING_UTF8NESS_I
-STATIC bool    S_is_codeset_name_UTF8(const char * name);
-#define PERL_ARGS_ASSERT_IS_CODESET_NAME_UTF8  \
-       assert(name)
 STATIC bool    S_is_locale_utf8(pTHX_ const char * locale);
 #define PERL_ARGS_ASSERT_IS_LOCALE_UTF8        \
        assert(locale)
@@ -5687,9 +5684,6 @@ STATIC void       S_new_LC_ALL(pTHX_ const char* unused);
 STATIC void    S_new_collate(pTHX_ const char* newcoll);
 #define PERL_ARGS_ASSERT_NEW_COLLATE   \
        assert(newcoll)
-STATIC void    S_new_ctype(pTHX_ const char* newctype);
-#define PERL_ARGS_ASSERT_NEW_CTYPE     \
-       assert(newctype)
 STATIC void    S_restore_toggled_locale_i(pTHX_ const unsigned cat_index, const char * original_locale, const line_t caller_line);
 #define PERL_ARGS_ASSERT_RESTORE_TOGGLED_LOCALE_I
 STATIC const char *    S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size);
@@ -5704,6 +5698,14 @@ STATIC const char*       S_stdize_locale(pTHX_ const int category, const char* input_l
 STATIC const char *    S_toggle_locale_i(pTHX_ const unsigned switch_cat_index, const char * new_locale, const line_t caller_line);
 #define PERL_ARGS_ASSERT_TOGGLE_LOCALE_I       \
        assert(new_locale)
+#    if defined(USE_LOCALE_CTYPE)
+STATIC bool    S_is_codeset_name_UTF8(const char * name);
+#define PERL_ARGS_ASSERT_IS_CODESET_NAME_UTF8  \
+       assert(name)
+STATIC void    S_new_ctype(pTHX_ const char* newctype);
+#define PERL_ARGS_ASSERT_NEW_CTYPE     \
+       assert(newctype)
+#    endif
 #    if defined(USE_LOCALE_NUMERIC)
 STATIC void    S_new_numeric(pTHX_ const char* newnum);
 #define PERL_ARGS_ASSERT_NEW_NUMERIC   \