@@ -55,31 +55,125 @@ ZEND_EXTERN_MODULE_GLOBALS( intl )
55
55
#define EXTLANG_KEYNAME_LEN 10
56
56
#define PRIVATE_KEYNAME_LEN 11
57
57
58
- /* Based on IANA registry at the time of writing this code
59
- *
60
- */
58
+ /* Based on the IANA language subtag registry (File-Date: 2021-08-06)
59
+ * https://www.iana.org/assignments/language-subtag-registry
60
+ *
61
+ * This list includes all grandfathered tags, as well as redundant
62
+ * tags that have a Preferred-Value.
63
+ */
61
64
static const char * const LOC_GRANDFATHERED [] = {
62
- "art-lojban" , "i-klingon" , "i-lux" , "i-navajo" , "no-bok" , "no-nyn" ,
63
- "cel-gaulish" , "en-GB-oed" , "i-ami" ,
64
- "i-bnn" , "i-default" , "i-enochian" ,
65
- "i-mingo" , "i-pwn" , "i-tao" ,
66
- "i-tay" , "i-tsu" , "sgn-BE-fr" ,
67
- "sgn-BE-nl" , "sgn-CH-de" , "zh-cmn" ,
68
- "zh-cmn-Hans" , "zh-cmn-Hant" , "zh-gan" ,
69
- "zh-guoyu" , "zh-hakka" , "zh-min" ,
70
- "zh-min-nan" , "zh-wuu" , "zh-xiang" ,
71
- "zh-yue" , NULL
65
+ "art-lojban" ,
66
+ "cel-gaulish" ,
67
+ "en-GB-oed" ,
68
+ "i-ami" ,
69
+ "i-bnn" ,
70
+ "i-default" ,
71
+ "i-enochian" ,
72
+ "i-hak" ,
73
+ "i-klingon" ,
74
+ "i-lux" ,
75
+ "i-mingo" ,
76
+ "i-navajo" ,
77
+ "i-pwn" ,
78
+ "i-tao" ,
79
+ "i-tay" ,
80
+ "i-tsu" ,
81
+ "no-bok" ,
82
+ "no-nyn" ,
83
+ "sgn-BE-FR" ,
84
+ "sgn-BE-NL" ,
85
+ "sgn-BR" ,
86
+ "sgn-CH-DE" ,
87
+ "sgn-CO" ,
88
+ "sgn-DE" ,
89
+ "sgn-DK" ,
90
+ "sgn-ES" ,
91
+ "sgn-FR" ,
92
+ "sgn-GB" ,
93
+ "sgn-GR" ,
94
+ "sgn-IE" ,
95
+ "sgn-IT" ,
96
+ "sgn-JP" ,
97
+ "sgn-MX" ,
98
+ "sgn-NI" ,
99
+ "sgn-NL" ,
100
+ "sgn-NO" ,
101
+ "sgn-PT" ,
102
+ "sgn-SE" ,
103
+ "sgn-US" ,
104
+ "sgn-ZA" ,
105
+ "zh-cmn" ,
106
+ "zh-cmn-Hans" ,
107
+ "zh-cmn-Hant" ,
108
+ "zh-gan" ,
109
+ "zh-guoyu" ,
110
+ "zh-hakka" ,
111
+ "zh-min" ,
112
+ "zh-min-nan" ,
113
+ "zh-wuu" ,
114
+ "zh-xiang" ,
115
+ NULL
72
116
};
73
117
74
- /* Based on IANA registry at the time of writing this code
75
- * This array lists the preferred values for the grandfathered tags if applicable
76
- * This is in sync with the array LOC_GRANDFATHERED
77
- * e.g. the offsets of the grandfathered tags match the offset of the preferred value
78
- */
79
- static const int LOC_PREFERRED_GRANDFATHERED_LEN = 6 ;
80
- static const char * const LOC_PREFERRED_GRANDFATHERED [] = {
81
- "jbo" , "tlh" , "lb" ,
82
- "nv" , "nb" , "nn" ,
118
+ /* Based on the IANA language subtag registry (File-Date: 2021-08-06)
119
+ *
120
+ * This array lists the preferred values for the grandfathered and redundant
121
+ * tags listed in LOC_GRANDFATHERED. This is in sync with the array
122
+ * LOC_GRANDFATHERED, i.e., the offsets of the grandfathered tags match the
123
+ * offsets of the preferred value. If a value in LOC_PREFERRED_GRANDFATHERED is
124
+ * NULL, then the matching offset in LOC_GRANDFATHERED has no preferred value.
125
+ */
126
+ static const char * const LOC_PREFERRED_GRANDFATHERED [] = {
127
+ "jbo" ,
128
+ NULL ,
129
+ "en-GB-oxendict" ,
130
+ "ami" ,
131
+ "bnn" ,
132
+ NULL ,
133
+ NULL ,
134
+ "hak" ,
135
+ "tlh" ,
136
+ "lb" ,
137
+ NULL ,
138
+ "nv" ,
139
+ "pwn" ,
140
+ "tao" ,
141
+ "tay" ,
142
+ "tsu" ,
143
+ "nb" ,
144
+ "nn" ,
145
+ "sfb" ,
146
+ "vgt" ,
147
+ "bzs" ,
148
+ "sgg" ,
149
+ "csn" ,
150
+ "gsg" ,
151
+ "dsl" ,
152
+ "ssp" ,
153
+ "fsl" ,
154
+ "bfi" ,
155
+ "gss" ,
156
+ "isg" ,
157
+ "ise" ,
158
+ "jsl" ,
159
+ "mfs" ,
160
+ "ncs" ,
161
+ "dse" ,
162
+ "nsl" ,
163
+ "psr" ,
164
+ "swl" ,
165
+ "ase" ,
166
+ "sfs" ,
167
+ "cmn" ,
168
+ "cmn-Hans" ,
169
+ "cmn-Hant" ,
170
+ "gan" ,
171
+ "cmn" ,
172
+ "hak" ,
173
+ NULL ,
174
+ "nan" ,
175
+ "wuu" ,
176
+ "hsn" ,
83
177
NULL
84
178
};
85
179
@@ -105,7 +199,7 @@ static int16_t findOffset(const char* const* list, const char* key)
105
199
{
106
200
const char * const * anchor = list ;
107
201
while (* list != NULL ) {
108
- if (strcmp (key , * list ) == 0 ) {
202
+ if (strcasecmp (key , * list ) == 0 ) {
109
203
return (int16_t )(list - anchor );
110
204
}
111
205
list ++ ;
@@ -125,7 +219,7 @@ static char* getPreferredTag(const char* gf_tag)
125
219
if (grOffset < 0 ) {
126
220
return NULL ;
127
221
}
128
- if ( grOffset < LOC_PREFERRED_GRANDFATHERED_LEN ){
222
+ if ( LOC_PREFERRED_GRANDFATHERED [ grOffset ] != NULL ){
129
223
/* return preferred tag */
130
224
result = estrdup ( LOC_PREFERRED_GRANDFATHERED [grOffset ] );
131
225
} else {
@@ -503,7 +597,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
503
597
if ( strcmp (tag_name , LOC_LANG_TAG )== 0 ){
504
598
mod_loc_name = getPreferredTag ( loc_name );
505
599
} else {
506
- /* Since Grandfathered, no value, do nothing, retutn NULL */
600
+ /* Since Grandfathered, no value, do nothing, return NULL */
507
601
RETURN_FALSE ;
508
602
}
509
603
}
0 commit comments