Skip to content

Commit

Permalink
perl_langinfo.h: Resume some assumptions
Browse files Browse the repository at this point in the history
To save some typing, I assumed that if a system had these glibc-only
locale categories, that it would have all elements that comprise them.
For example with LC_PAPER, the elements are the height and width of a
piece of paper.  It doesn't make any sense to have LC_PAPER without any
dimensions available.

But Android has LC_PAPER without paper dimensions; the same with all the
other elements in the glibc category extensions.  See GH #22627.

I believe that means that these categories are useless on this platform.

But this commit now checks each element for existence individually;
removing the assumption that if the category exists, the element must
too.
  • Loading branch information
khwilliamson committed Oct 9, 2024
1 parent 82c4939 commit fe289ff
Showing 1 changed file with 147 additions and 47 deletions.
194 changes: 147 additions & 47 deletions perl_langinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,70 +253,170 @@ typedef int nl_item; /* Substitute 'int' for emulated nl_langinfo() */
* conflict with some other value, in which case after much gnashing of teeth
* you will find this comment, and end up having to adjust the numbers. But
* glibc values are not (so far) negative */
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_ADDRESS)
# define _NL_ADDRESS_POSTAL_FMT -58
# define _NL_ADDRESS_COUNTRY_NAME -59
# define _NL_ADDRESS_COUNTRY_POST -60
# define _NL_ADDRESS_COUNTRY_AB2 -61
# define _NL_ADDRESS_COUNTRY_AB3 -62
# define _NL_ADDRESS_COUNTRY_CAR -63
# define _NL_ADDRESS_COUNTRY_NUM -64
# define _NL_ADDRESS_COUNTRY_ISBN -65
# define _NL_ADDRESS_LANG_NAME -66
# define _NL_ADDRESS_LANG_AB -67
# define _NL_ADDRESS_LANG_TERM -68
# define _NL_ADDRESS_LANG_LIB -69

#ifndef _NL_ADDRESS_POSTAL_FMT
# define _NL_ADDRESS_POSTAL_FMT -58
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_NAME
# define _NL_ADDRESS_COUNTRY_NAME -59
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_POST
# define _NL_ADDRESS_COUNTRY_POST -60
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_AB2
# define _NL_ADDRESS_COUNTRY_AB2 -61
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_AB3
# define _NL_ADDRESS_COUNTRY_AB3 -62
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_CAR
# define _NL_ADDRESS_COUNTRY_CAR -63
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_NUM
# define _NL_ADDRESS_COUNTRY_NUM -64
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_COUNTRY_ISBN
# define _NL_ADDRESS_COUNTRY_ISBN -65
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_LANG_NAME
# define _NL_ADDRESS_LANG_NAME -66
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_LANG_AB
# define _NL_ADDRESS_LANG_AB -67
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_LANG_TERM
# define _NL_ADDRESS_LANG_TERM -68
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_ADDRESS_LANG_LIB
# define _NL_ADDRESS_LANG_LIB -69
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_IDENTIFICATION)
# define _NL_IDENTIFICATION_TITLE -70
# define _NL_IDENTIFICATION_SOURCE -71
# define _NL_IDENTIFICATION_ADDRESS -72
# define _NL_IDENTIFICATION_CONTACT -73
# define _NL_IDENTIFICATION_EMAIL -74
# define _NL_IDENTIFICATION_TEL -75
# define _NL_IDENTIFICATION_FAX -76
# define _NL_IDENTIFICATION_LANGUAGE -77
# define _NL_IDENTIFICATION_TERRITORY -78
# define _NL_IDENTIFICATION_AUDIENCE -79
# define _NL_IDENTIFICATION_APPLICATION -80
# define _NL_IDENTIFICATION_ABBREVIATION -81
# define _NL_IDENTIFICATION_REVISION -82
# define _NL_IDENTIFICATION_DATE -83
# define _NL_IDENTIFICATION_CATEGORY -84

#ifndef _NL_IDENTIFICATION_TITLE
# define _NL_IDENTIFICATION_TITLE -70
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_SOURCE
# define _NL_IDENTIFICATION_SOURCE -71
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_ADDRESS
# define _NL_IDENTIFICATION_ADDRESS -72
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_CONTACT
# define _NL_IDENTIFICATION_CONTACT -73
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_EMAIL
# define _NL_IDENTIFICATION_EMAIL -74
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_TEL
# define _NL_IDENTIFICATION_TEL -75
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_FAX
# define _NL_IDENTIFICATION_FAX -76
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_LANGUAGE
# define _NL_IDENTIFICATION_LANGUAGE -77
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_TERRITORY
# define _NL_IDENTIFICATION_TERRITORY -78
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_AUDIENCE
# define _NL_IDENTIFICATION_AUDIENCE -79
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_APPLICATION
# define _NL_IDENTIFICATION_APPLICATION -80
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_ABBREVIATION
# define _NL_IDENTIFICATION_ABBREVIATION -81
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_REVISION
# define _NL_IDENTIFICATION_REVISION -82
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_DATE
# define _NL_IDENTIFICATION_DATE -83
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_IDENTIFICATION_CATEGORY
# define _NL_IDENTIFICATION_CATEGORY -84
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_MEASUREMENT)
# define _NL_MEASUREMENT_MEASUREMENT -85

#ifndef _NL_MEASUREMENT_MEASUREMENT
# define _NL_MEASUREMENT_MEASUREMENT -85
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_NAME)
# define _NL_NAME_NAME_FMT -86
# define _NL_NAME_NAME_GEN -87
# define _NL_NAME_NAME_MR -88
# define _NL_NAME_NAME_MRS -89
# define _NL_NAME_NAME_MISS -90
# define _NL_NAME_NAME_MS -91

#ifndef _NL_NAME_NAME_FMT
# define _NL_NAME_NAME_FMT -86
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_NAME_NAME_GEN
# define _NL_NAME_NAME_GEN -87
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_NAME_NAME_MR
# define _NL_NAME_NAME_MR -88
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_NAME_NAME_MRS
# define _NL_NAME_NAME_MRS -89
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_NAME_NAME_MISS
# define _NL_NAME_NAME_MISS -90
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_NAME_NAME_MS
# define _NL_NAME_NAME_MS -91
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_PAPER)
# define _NL_PAPER_HEIGHT -92
# define _NL_PAPER_WIDTH -93

#ifndef _NL_PAPER_HEIGHT
# define _NL_PAPER_HEIGHT -92
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_PAPER_WIDTH
# define _NL_PAPER_WIDTH -93
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_TELEPHONE)
# define _NL_TELEPHONE_TEL_INT_FMT -94
# define _NL_TELEPHONE_TEL_DOM_FMT -95
# define _NL_TELEPHONE_INT_SELECT -96
# define _NL_TELEPHONE_INT_PREFIX -97

#ifndef _NL_TELEPHONE_TEL_INT_FMT
# define _NL_TELEPHONE_TEL_INT_FMT -94
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_TELEPHONE_TEL_DOM_FMT
# define _NL_TELEPHONE_TEL_DOM_FMT -95
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_TELEPHONE_INT_SELECT
# define _NL_TELEPHONE_INT_SELECT -96
# define HAS_MISSING_LANGINFO_ITEM_
#endif
#ifndef _NL_TELEPHONE_INT_PREFIX
# define _NL_TELEPHONE_INT_PREFIX -97
#endif

/* All these categories have to be emulated if not available on the platform */
#if ! LC_CTYPE_AVAIL_ \
Expand Down

0 comments on commit fe289ff

Please sign in to comment.