Skip to content

Commit 5957de4

Browse files
committed
perl_langinfo.h: Fix to work on Android
See GH #22627. Glibc has a few locale categories that aren't used elsewhere, AFAIK. Android has a crippled implementation of them, in that it has none of the items that comprise the categories. In a typical langinfo.h, these are enum fields, so their existence can't be checked with an #ifdef, but in Android, everything is a #define, so much be checked with #ifdef. To get around this without writing a Configure probe, this commit just creates #defines when they are missing the category (which catches the non-Androids) or when using Android.
1 parent d7ad458 commit 5957de4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

perl_langinfo.h

+10-7
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ typedef int nl_item; /* Substitute 'int' for emulated nl_langinfo() */
252252
* langinfo.h. There is a slight possibility that one of these numbers could
253253
* conflict with some other value, in which case after much gnashing of teeth
254254
* you will find this comment, and end up having to adjust the numbers. But
255-
* glibc values are not (so far) negative */
256-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_ADDRESS)
255+
* glibc values are not (so far) negative.
256+
*
257+
* Android is special in that it doesn't define any of these, but has the
258+
* corresponding category */
259+
#if defined(__ANDROID__) || ! defined(HAS_NL_LANGINFO) || ! defined(LC_ADDRESS)
257260
# define _NL_ADDRESS_POSTAL_FMT -58
258261
# define _NL_ADDRESS_COUNTRY_NAME -59
259262
# define _NL_ADDRESS_COUNTRY_POST -60
@@ -269,7 +272,7 @@ typedef int nl_item; /* Substitute 'int' for emulated nl_langinfo() */
269272

270273
# define HAS_MISSING_LANGINFO_ITEM_
271274
#endif
272-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_IDENTIFICATION)
275+
#if defined(__ANDROID__) || ! defined(HAS_NL_LANGINFO) || ! defined(LC_IDENTIFICATION)
273276
# define _NL_IDENTIFICATION_TITLE -70
274277
# define _NL_IDENTIFICATION_SOURCE -71
275278
# define _NL_IDENTIFICATION_ADDRESS -72
@@ -288,11 +291,11 @@ typedef int nl_item; /* Substitute 'int' for emulated nl_langinfo() */
288291

289292
# define HAS_MISSING_LANGINFO_ITEM_
290293
#endif
291-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_MEASUREMENT)
294+
#if defined(__ANDROID__) || ! defined(HAS_NL_LANGINFO) || ! defined(LC_MEASUREMENT)
292295
# define _NL_MEASUREMENT_MEASUREMENT -85
293296
# define HAS_MISSING_LANGINFO_ITEM_
294297
#endif
295-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_NAME)
298+
#if defined(__ANDROID__) || ! defined(HAS_NL_LANGINFO) || ! defined(LC_NAME)
296299
# define _NL_NAME_NAME_FMT -86
297300
# define _NL_NAME_NAME_GEN -87
298301
# define _NL_NAME_NAME_MR -88
@@ -302,13 +305,13 @@ typedef int nl_item; /* Substitute 'int' for emulated nl_langinfo() */
302305

303306
# define HAS_MISSING_LANGINFO_ITEM_
304307
#endif
305-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_PAPER)
308+
#if defined(__ANDROID__) || ! defined(HAS_NL_LANGINFO) || ! defined(LC_PAPER)
306309
# define _NL_PAPER_HEIGHT -92
307310
# define _NL_PAPER_WIDTH -93
308311

309312
# define HAS_MISSING_LANGINFO_ITEM_
310313
#endif
311-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_TELEPHONE)
314+
#if defined(__ANDROID__) || ! defined(HAS_NL_LANGINFO) || ! defined(LC_TELEPHONE)
312315
# define _NL_TELEPHONE_TEL_INT_FMT -94
313316
# define _NL_TELEPHONE_TEL_DOM_FMT -95
314317
# define _NL_TELEPHONE_INT_SELECT -96

0 commit comments

Comments
 (0)