Skip to content

Commit fe289ff

Browse files
committed
perl_langinfo.h: Resume some assumptions
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 Perl#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.
1 parent 82c4939 commit fe289ff

File tree

1 file changed

+147
-47
lines changed

1 file changed

+147
-47
lines changed

perl_langinfo.h

+147-47
Original file line numberDiff line numberDiff line change
@@ -253,70 +253,170 @@ typedef int nl_item; /* Substitute 'int' for emulated nl_langinfo() */
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
255255
* glibc values are not (so far) negative */
256-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_ADDRESS)
257-
# define _NL_ADDRESS_POSTAL_FMT -58
258-
# define _NL_ADDRESS_COUNTRY_NAME -59
259-
# define _NL_ADDRESS_COUNTRY_POST -60
260-
# define _NL_ADDRESS_COUNTRY_AB2 -61
261-
# define _NL_ADDRESS_COUNTRY_AB3 -62
262-
# define _NL_ADDRESS_COUNTRY_CAR -63
263-
# define _NL_ADDRESS_COUNTRY_NUM -64
264-
# define _NL_ADDRESS_COUNTRY_ISBN -65
265-
# define _NL_ADDRESS_LANG_NAME -66
266-
# define _NL_ADDRESS_LANG_AB -67
267-
# define _NL_ADDRESS_LANG_TERM -68
268-
# define _NL_ADDRESS_LANG_LIB -69
269-
256+
#ifndef _NL_ADDRESS_POSTAL_FMT
257+
# define _NL_ADDRESS_POSTAL_FMT -58
258+
# define HAS_MISSING_LANGINFO_ITEM_
259+
#endif
260+
#ifndef _NL_ADDRESS_COUNTRY_NAME
261+
# define _NL_ADDRESS_COUNTRY_NAME -59
262+
# define HAS_MISSING_LANGINFO_ITEM_
263+
#endif
264+
#ifndef _NL_ADDRESS_COUNTRY_POST
265+
# define _NL_ADDRESS_COUNTRY_POST -60
266+
# define HAS_MISSING_LANGINFO_ITEM_
267+
#endif
268+
#ifndef _NL_ADDRESS_COUNTRY_AB2
269+
# define _NL_ADDRESS_COUNTRY_AB2 -61
270+
# define HAS_MISSING_LANGINFO_ITEM_
271+
#endif
272+
#ifndef _NL_ADDRESS_COUNTRY_AB3
273+
# define _NL_ADDRESS_COUNTRY_AB3 -62
274+
# define HAS_MISSING_LANGINFO_ITEM_
275+
#endif
276+
#ifndef _NL_ADDRESS_COUNTRY_CAR
277+
# define _NL_ADDRESS_COUNTRY_CAR -63
278+
# define HAS_MISSING_LANGINFO_ITEM_
279+
#endif
280+
#ifndef _NL_ADDRESS_COUNTRY_NUM
281+
# define _NL_ADDRESS_COUNTRY_NUM -64
282+
# define HAS_MISSING_LANGINFO_ITEM_
283+
#endif
284+
#ifndef _NL_ADDRESS_COUNTRY_ISBN
285+
# define _NL_ADDRESS_COUNTRY_ISBN -65
286+
# define HAS_MISSING_LANGINFO_ITEM_
287+
#endif
288+
#ifndef _NL_ADDRESS_LANG_NAME
289+
# define _NL_ADDRESS_LANG_NAME -66
290+
# define HAS_MISSING_LANGINFO_ITEM_
291+
#endif
292+
#ifndef _NL_ADDRESS_LANG_AB
293+
# define _NL_ADDRESS_LANG_AB -67
294+
# define HAS_MISSING_LANGINFO_ITEM_
295+
#endif
296+
#ifndef _NL_ADDRESS_LANG_TERM
297+
# define _NL_ADDRESS_LANG_TERM -68
298+
# define HAS_MISSING_LANGINFO_ITEM_
299+
#endif
300+
#ifndef _NL_ADDRESS_LANG_LIB
301+
# define _NL_ADDRESS_LANG_LIB -69
270302
# define HAS_MISSING_LANGINFO_ITEM_
271303
#endif
272-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_IDENTIFICATION)
273-
# define _NL_IDENTIFICATION_TITLE -70
274-
# define _NL_IDENTIFICATION_SOURCE -71
275-
# define _NL_IDENTIFICATION_ADDRESS -72
276-
# define _NL_IDENTIFICATION_CONTACT -73
277-
# define _NL_IDENTIFICATION_EMAIL -74
278-
# define _NL_IDENTIFICATION_TEL -75
279-
# define _NL_IDENTIFICATION_FAX -76
280-
# define _NL_IDENTIFICATION_LANGUAGE -77
281-
# define _NL_IDENTIFICATION_TERRITORY -78
282-
# define _NL_IDENTIFICATION_AUDIENCE -79
283-
# define _NL_IDENTIFICATION_APPLICATION -80
284-
# define _NL_IDENTIFICATION_ABBREVIATION -81
285-
# define _NL_IDENTIFICATION_REVISION -82
286-
# define _NL_IDENTIFICATION_DATE -83
287-
# define _NL_IDENTIFICATION_CATEGORY -84
288304

305+
#ifndef _NL_IDENTIFICATION_TITLE
306+
# define _NL_IDENTIFICATION_TITLE -70
307+
# define HAS_MISSING_LANGINFO_ITEM_
308+
#endif
309+
#ifndef _NL_IDENTIFICATION_SOURCE
310+
# define _NL_IDENTIFICATION_SOURCE -71
311+
# define HAS_MISSING_LANGINFO_ITEM_
312+
#endif
313+
#ifndef _NL_IDENTIFICATION_ADDRESS
314+
# define _NL_IDENTIFICATION_ADDRESS -72
315+
# define HAS_MISSING_LANGINFO_ITEM_
316+
#endif
317+
#ifndef _NL_IDENTIFICATION_CONTACT
318+
# define _NL_IDENTIFICATION_CONTACT -73
319+
# define HAS_MISSING_LANGINFO_ITEM_
320+
#endif
321+
#ifndef _NL_IDENTIFICATION_EMAIL
322+
# define _NL_IDENTIFICATION_EMAIL -74
323+
# define HAS_MISSING_LANGINFO_ITEM_
324+
#endif
325+
#ifndef _NL_IDENTIFICATION_TEL
326+
# define _NL_IDENTIFICATION_TEL -75
327+
# define HAS_MISSING_LANGINFO_ITEM_
328+
#endif
329+
#ifndef _NL_IDENTIFICATION_FAX
330+
# define _NL_IDENTIFICATION_FAX -76
331+
# define HAS_MISSING_LANGINFO_ITEM_
332+
#endif
333+
#ifndef _NL_IDENTIFICATION_LANGUAGE
334+
# define _NL_IDENTIFICATION_LANGUAGE -77
335+
# define HAS_MISSING_LANGINFO_ITEM_
336+
#endif
337+
#ifndef _NL_IDENTIFICATION_TERRITORY
338+
# define _NL_IDENTIFICATION_TERRITORY -78
339+
# define HAS_MISSING_LANGINFO_ITEM_
340+
#endif
341+
#ifndef _NL_IDENTIFICATION_AUDIENCE
342+
# define _NL_IDENTIFICATION_AUDIENCE -79
343+
# define HAS_MISSING_LANGINFO_ITEM_
344+
#endif
345+
#ifndef _NL_IDENTIFICATION_APPLICATION
346+
# define _NL_IDENTIFICATION_APPLICATION -80
347+
# define HAS_MISSING_LANGINFO_ITEM_
348+
#endif
349+
#ifndef _NL_IDENTIFICATION_ABBREVIATION
350+
# define _NL_IDENTIFICATION_ABBREVIATION -81
351+
# define HAS_MISSING_LANGINFO_ITEM_
352+
#endif
353+
#ifndef _NL_IDENTIFICATION_REVISION
354+
# define _NL_IDENTIFICATION_REVISION -82
355+
# define HAS_MISSING_LANGINFO_ITEM_
356+
#endif
357+
#ifndef _NL_IDENTIFICATION_DATE
358+
# define _NL_IDENTIFICATION_DATE -83
359+
# define HAS_MISSING_LANGINFO_ITEM_
360+
#endif
361+
#ifndef _NL_IDENTIFICATION_CATEGORY
362+
# define _NL_IDENTIFICATION_CATEGORY -84
289363
# define HAS_MISSING_LANGINFO_ITEM_
290364
#endif
291-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_MEASUREMENT)
292-
# define _NL_MEASUREMENT_MEASUREMENT -85
293365

366+
#ifndef _NL_MEASUREMENT_MEASUREMENT
367+
# define _NL_MEASUREMENT_MEASUREMENT -85
294368
# define HAS_MISSING_LANGINFO_ITEM_
295369
#endif
296-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_NAME)
297-
# define _NL_NAME_NAME_FMT -86
298-
# define _NL_NAME_NAME_GEN -87
299-
# define _NL_NAME_NAME_MR -88
300-
# define _NL_NAME_NAME_MRS -89
301-
# define _NL_NAME_NAME_MISS -90
302-
# define _NL_NAME_NAME_MS -91
303370

371+
#ifndef _NL_NAME_NAME_FMT
372+
# define _NL_NAME_NAME_FMT -86
373+
# define HAS_MISSING_LANGINFO_ITEM_
374+
#endif
375+
#ifndef _NL_NAME_NAME_GEN
376+
# define _NL_NAME_NAME_GEN -87
377+
# define HAS_MISSING_LANGINFO_ITEM_
378+
#endif
379+
#ifndef _NL_NAME_NAME_MR
380+
# define _NL_NAME_NAME_MR -88
381+
# define HAS_MISSING_LANGINFO_ITEM_
382+
#endif
383+
#ifndef _NL_NAME_NAME_MRS
384+
# define _NL_NAME_NAME_MRS -89
385+
# define HAS_MISSING_LANGINFO_ITEM_
386+
#endif
387+
#ifndef _NL_NAME_NAME_MISS
388+
# define _NL_NAME_NAME_MISS -90
389+
# define HAS_MISSING_LANGINFO_ITEM_
390+
#endif
391+
#ifndef _NL_NAME_NAME_MS
392+
# define _NL_NAME_NAME_MS -91
304393
# define HAS_MISSING_LANGINFO_ITEM_
305394
#endif
306-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_PAPER)
307-
# define _NL_PAPER_HEIGHT -92
308-
# define _NL_PAPER_WIDTH -93
309395

396+
#ifndef _NL_PAPER_HEIGHT
397+
# define _NL_PAPER_HEIGHT -92
398+
# define HAS_MISSING_LANGINFO_ITEM_
399+
#endif
400+
#ifndef _NL_PAPER_WIDTH
401+
# define _NL_PAPER_WIDTH -93
310402
# define HAS_MISSING_LANGINFO_ITEM_
311403
#endif
312-
#if ! defined(HAS_NL_LANGINFO) || ! defined(LC_TELEPHONE)
313-
# define _NL_TELEPHONE_TEL_INT_FMT -94
314-
# define _NL_TELEPHONE_TEL_DOM_FMT -95
315-
# define _NL_TELEPHONE_INT_SELECT -96
316-
# define _NL_TELEPHONE_INT_PREFIX -97
317404

405+
#ifndef _NL_TELEPHONE_TEL_INT_FMT
406+
# define _NL_TELEPHONE_TEL_INT_FMT -94
407+
# define HAS_MISSING_LANGINFO_ITEM_
408+
#endif
409+
#ifndef _NL_TELEPHONE_TEL_DOM_FMT
410+
# define _NL_TELEPHONE_TEL_DOM_FMT -95
411+
# define HAS_MISSING_LANGINFO_ITEM_
412+
#endif
413+
#ifndef _NL_TELEPHONE_INT_SELECT
414+
# define _NL_TELEPHONE_INT_SELECT -96
318415
# define HAS_MISSING_LANGINFO_ITEM_
319416
#endif
417+
#ifndef _NL_TELEPHONE_INT_PREFIX
418+
# define _NL_TELEPHONE_INT_PREFIX -97
419+
#endif
320420

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

0 commit comments

Comments
 (0)