This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
shm.t: Skip under miniperl
[perl5.git] / locale.c
CommitLineData
98994639
HS
1/* locale.c
2 *
1129b882
NC
3 * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
4 * 2002, 2003, 2005, 2006, 2007, 2008 by Larry Wall and others
98994639
HS
5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 *
9 */
10
11/*
4ac71550 12 * A Elbereth Gilthoniel,
cdad3b53 13 * silivren penna míriel
4ac71550 14 * o menel aglar elenath!
cdad3b53 15 * Na-chaered palan-díriel
4ac71550
TC
16 * o galadhremmin ennorath,
17 * Fanuilos, le linnathon
18 * nef aear, si nef aearon!
19 *
20 * [p.238 of _The Lord of the Rings_, II/i: "Many Meetings"]
98994639
HS
21 */
22
166f8a29
DM
23/* utility functions for handling locale-specific stuff like what
24 * character represents the decimal point.
25 */
26
98994639
HS
27#include "EXTERN.h"
28#define PERL_IN_LOCALE_C
29#include "perl.h"
30
31#ifdef I_LOCALE
32# include <locale.h>
33#endif
34
b310b053
JH
35#ifdef I_LANGINFO
36# include <langinfo.h>
37#endif
38
a4af207c
JH
39#include "reentr.h"
40
27da23d5 41#if defined(USE_LOCALE_NUMERIC) || defined(USE_LOCALE_COLLATE)
98994639
HS
42/*
43 * Standardize the locale name from a string returned by 'setlocale'.
44 *
45 * The standard return value of setlocale() is either
46 * (1) "xx_YY" if the first argument of setlocale() is not LC_ALL
47 * (2) "xa_YY xb_YY ..." if the first argument of setlocale() is LC_ALL
48 * (the space-separated values represent the various sublocales,
486ec47a 49 * in some unspecified order)
98994639
HS
50 *
51 * In some platforms it has a form like "LC_SOMETHING=Lang_Country.866\n",
52 * which is harmful for further use of the string in setlocale().
53 *
54 */
55STATIC char *
56S_stdize_locale(pTHX_ char *locs)
57{
7452cf6a 58 const char * const s = strchr(locs, '=');
98994639
HS
59 bool okay = TRUE;
60
7918f24d
NC
61 PERL_ARGS_ASSERT_STDIZE_LOCALE;
62
8772537c
AL
63 if (s) {
64 const char * const t = strchr(s, '.');
98994639 65 okay = FALSE;
8772537c
AL
66 if (t) {
67 const char * const u = strchr(t, '\n');
68 if (u && (u[1] == 0)) {
69 const STRLEN len = u - s;
70 Move(s + 1, locs, len, char);
71 locs[len] = 0;
72 okay = TRUE;
98994639
HS
73 }
74 }
75 }
76
77 if (!okay)
78 Perl_croak(aTHX_ "Can't fix broken locale name \"%s\"", locs);
79
80 return locs;
81}
27da23d5 82#endif
98994639
HS
83
84void
85Perl_set_numeric_radix(pTHX)
86{
87#ifdef USE_LOCALE_NUMERIC
97aff369 88 dVAR;
98994639 89# ifdef HAS_LOCALECONV
7452cf6a 90 const struct lconv* const lc = localeconv();
98994639 91
98994639
HS
92 if (lc && lc->decimal_point) {
93 if (lc->decimal_point[0] == '.' && lc->decimal_point[1] == 0) {
94 SvREFCNT_dec(PL_numeric_radix_sv);
a0714e2c 95 PL_numeric_radix_sv = NULL;
98994639
HS
96 }
97 else {
98 if (PL_numeric_radix_sv)
99 sv_setpv(PL_numeric_radix_sv, lc->decimal_point);
100 else
101 PL_numeric_radix_sv = newSVpv(lc->decimal_point, 0);
102 }
103 }
104 else
a0714e2c 105 PL_numeric_radix_sv = NULL;
98994639
HS
106# endif /* HAS_LOCALECONV */
107#endif /* USE_LOCALE_NUMERIC */
108}
109
110/*
111 * Set up for a new numeric locale.
112 */
113void
8772537c 114Perl_new_numeric(pTHX_ const char *newnum)
98994639
HS
115{
116#ifdef USE_LOCALE_NUMERIC
97aff369 117 dVAR;
98994639
HS
118
119 if (! newnum) {
43c5f42d
NC
120 Safefree(PL_numeric_name);
121 PL_numeric_name = NULL;
98994639
HS
122 PL_numeric_standard = TRUE;
123 PL_numeric_local = TRUE;
124 return;
125 }
126
127 if (! PL_numeric_name || strNE(PL_numeric_name, newnum)) {
128 Safefree(PL_numeric_name);
129 PL_numeric_name = stdize_locale(savepv(newnum));
770526c1
NC
130 PL_numeric_standard = ((*newnum == 'C' && newnum[1] == '\0')
131 || strEQ(newnum, "POSIX"));
98994639
HS
132 PL_numeric_local = TRUE;
133 set_numeric_radix();
134 }
135
136#endif /* USE_LOCALE_NUMERIC */
137}
138
139void
140Perl_set_numeric_standard(pTHX)
141{
142#ifdef USE_LOCALE_NUMERIC
97aff369 143 dVAR;
98994639
HS
144
145 if (! PL_numeric_standard) {
146 setlocale(LC_NUMERIC, "C");
147 PL_numeric_standard = TRUE;
148 PL_numeric_local = FALSE;
149 set_numeric_radix();
150 }
151
152#endif /* USE_LOCALE_NUMERIC */
153}
154
155void
156Perl_set_numeric_local(pTHX)
157{
158#ifdef USE_LOCALE_NUMERIC
97aff369 159 dVAR;
98994639
HS
160
161 if (! PL_numeric_local) {
162 setlocale(LC_NUMERIC, PL_numeric_name);
163 PL_numeric_standard = FALSE;
164 PL_numeric_local = TRUE;
165 set_numeric_radix();
166 }
167
168#endif /* USE_LOCALE_NUMERIC */
169}
170
171/*
172 * Set up for a new ctype locale.
173 */
174void
8772537c 175Perl_new_ctype(pTHX_ const char *newctype)
98994639
HS
176{
177#ifdef USE_LOCALE_CTYPE
27da23d5 178 dVAR;
98994639
HS
179 int i;
180
7918f24d
NC
181 PERL_ARGS_ASSERT_NEW_CTYPE;
182
98994639
HS
183 for (i = 0; i < 256; i++) {
184 if (isUPPER_LC(i))
185 PL_fold_locale[i] = toLOWER_LC(i);
186 else if (isLOWER_LC(i))
187 PL_fold_locale[i] = toUPPER_LC(i);
188 else
189 PL_fold_locale[i] = i;
190 }
191
192#endif /* USE_LOCALE_CTYPE */
7918f24d 193 PERL_ARGS_ASSERT_NEW_CTYPE;
8772537c 194 PERL_UNUSED_ARG(newctype);
96a5add6 195 PERL_UNUSED_CONTEXT;
98994639
HS
196}
197
198/*
199 * Set up for a new collation locale.
200 */
201void
8772537c 202Perl_new_collate(pTHX_ const char *newcoll)
98994639
HS
203{
204#ifdef USE_LOCALE_COLLATE
97aff369 205 dVAR;
98994639
HS
206
207 if (! newcoll) {
208 if (PL_collation_name) {
209 ++PL_collation_ix;
210 Safefree(PL_collation_name);
211 PL_collation_name = NULL;
212 }
213 PL_collation_standard = TRUE;
214 PL_collxfrm_base = 0;
215 PL_collxfrm_mult = 2;
216 return;
217 }
218
219 if (! PL_collation_name || strNE(PL_collation_name, newcoll)) {
220 ++PL_collation_ix;
221 Safefree(PL_collation_name);
222 PL_collation_name = stdize_locale(savepv(newcoll));
770526c1
NC
223 PL_collation_standard = ((*newcoll == 'C' && newcoll[1] == '\0')
224 || strEQ(newcoll, "POSIX"));
98994639
HS
225
226 {
227 /* 2: at most so many chars ('a', 'b'). */
228 /* 50: surely no system expands a char more. */
229#define XFRMBUFSIZE (2 * 50)
230 char xbuf[XFRMBUFSIZE];
8772537c
AL
231 const Size_t fa = strxfrm(xbuf, "a", XFRMBUFSIZE);
232 const Size_t fb = strxfrm(xbuf, "ab", XFRMBUFSIZE);
233 const SSize_t mult = fb - fa;
e0601d3c 234 if (mult < 1 && !(fa == 0 && fb == 0))
ad49ad39
NC
235 Perl_croak(aTHX_ "panic: strxfrm() gets absurd - a => %"UVuf", ab => %"UVuf,
236 (UV) fa, (UV) fb);
eb160463 237 PL_collxfrm_base = (fa > (Size_t)mult) ? (fa - mult) : 0;
98994639
HS
238 PL_collxfrm_mult = mult;
239 }
240 }
241
242#endif /* USE_LOCALE_COLLATE */
243}
244
245/*
246 * Initialize locale awareness.
247 */
248int
249Perl_init_i18nl10n(pTHX_ int printwarn)
250{
251 int ok = 1;
252 /* returns
253 * 1 = set ok or not applicable,
254 * 0 = fallback to C locale,
255 * -1 = fallback to C locale failed
256 */
257
258#if defined(USE_LOCALE)
97aff369 259 dVAR;
98994639
HS
260
261#ifdef USE_LOCALE_CTYPE
262 char *curctype = NULL;
263#endif /* USE_LOCALE_CTYPE */
264#ifdef USE_LOCALE_COLLATE
265 char *curcoll = NULL;
266#endif /* USE_LOCALE_COLLATE */
267#ifdef USE_LOCALE_NUMERIC
268 char *curnum = NULL;
269#endif /* USE_LOCALE_NUMERIC */
270#ifdef __GLIBC__
7452cf6a 271 char * const language = PerlEnv_getenv("LANGUAGE");
98994639 272#endif
7452cf6a
AL
273 char * const lc_all = PerlEnv_getenv("LC_ALL");
274 char * const lang = PerlEnv_getenv("LANG");
98994639
HS
275 bool setlocale_failure = FALSE;
276
277#ifdef LOCALE_ENVIRON_REQUIRED
278
279 /*
280 * Ultrix setlocale(..., "") fails if there are no environment
281 * variables from which to get a locale name.
282 */
283
284 bool done = FALSE;
285
286#ifdef LC_ALL
287 if (lang) {
288 if (setlocale(LC_ALL, ""))
289 done = TRUE;
290 else
291 setlocale_failure = TRUE;
292 }
293 if (!setlocale_failure) {
294#ifdef USE_LOCALE_CTYPE
56279a21 295 Safefree(curctype);
98994639
HS
296 if (! (curctype =
297 setlocale(LC_CTYPE,
298 (!done && (lang || PerlEnv_getenv("LC_CTYPE")))
bd61b366 299 ? "" : NULL)))
98994639
HS
300 setlocale_failure = TRUE;
301 else
302 curctype = savepv(curctype);
303#endif /* USE_LOCALE_CTYPE */
304#ifdef USE_LOCALE_COLLATE
56279a21 305 Safefree(curcoll);
98994639
HS
306 if (! (curcoll =
307 setlocale(LC_COLLATE,
308 (!done && (lang || PerlEnv_getenv("LC_COLLATE")))
bd61b366 309 ? "" : NULL)))
98994639
HS
310 setlocale_failure = TRUE;
311 else
312 curcoll = savepv(curcoll);
313#endif /* USE_LOCALE_COLLATE */
314#ifdef USE_LOCALE_NUMERIC
56279a21 315 Safefree(curnum);
98994639
HS
316 if (! (curnum =
317 setlocale(LC_NUMERIC,
318 (!done && (lang || PerlEnv_getenv("LC_NUMERIC")))
bd61b366 319 ? "" : NULL)))
98994639
HS
320 setlocale_failure = TRUE;
321 else
322 curnum = savepv(curnum);
323#endif /* USE_LOCALE_NUMERIC */
324 }
325
326#endif /* LC_ALL */
327
328#endif /* !LOCALE_ENVIRON_REQUIRED */
329
330#ifdef LC_ALL
331 if (! setlocale(LC_ALL, ""))
332 setlocale_failure = TRUE;
333#endif /* LC_ALL */
334
335 if (!setlocale_failure) {
336#ifdef USE_LOCALE_CTYPE
6cb43dbf 337 Safefree(curctype);
98994639
HS
338 if (! (curctype = setlocale(LC_CTYPE, "")))
339 setlocale_failure = TRUE;
340 else
341 curctype = savepv(curctype);
342#endif /* USE_LOCALE_CTYPE */
343#ifdef USE_LOCALE_COLLATE
6cb43dbf 344 Safefree(curcoll);
98994639
HS
345 if (! (curcoll = setlocale(LC_COLLATE, "")))
346 setlocale_failure = TRUE;
347 else
348 curcoll = savepv(curcoll);
349#endif /* USE_LOCALE_COLLATE */
350#ifdef USE_LOCALE_NUMERIC
6cb43dbf 351 Safefree(curnum);
98994639
HS
352 if (! (curnum = setlocale(LC_NUMERIC, "")))
353 setlocale_failure = TRUE;
354 else
355 curnum = savepv(curnum);
356#endif /* USE_LOCALE_NUMERIC */
357 }
358
359 if (setlocale_failure) {
360 char *p;
0bd48802 361 const bool locwarn = (printwarn > 1 ||
98994639
HS
362 (printwarn &&
363 (!(p = PerlEnv_getenv("PERL_BADLANG")) || atoi(p))));
364
365 if (locwarn) {
366#ifdef LC_ALL
367
368 PerlIO_printf(Perl_error_log,
369 "perl: warning: Setting locale failed.\n");
370
371#else /* !LC_ALL */
372
373 PerlIO_printf(Perl_error_log,
374 "perl: warning: Setting locale failed for the categories:\n\t");
375#ifdef USE_LOCALE_CTYPE
376 if (! curctype)
377 PerlIO_printf(Perl_error_log, "LC_CTYPE ");
378#endif /* USE_LOCALE_CTYPE */
379#ifdef USE_LOCALE_COLLATE
380 if (! curcoll)
381 PerlIO_printf(Perl_error_log, "LC_COLLATE ");
382#endif /* USE_LOCALE_COLLATE */
383#ifdef USE_LOCALE_NUMERIC
384 if (! curnum)
385 PerlIO_printf(Perl_error_log, "LC_NUMERIC ");
386#endif /* USE_LOCALE_NUMERIC */
387 PerlIO_printf(Perl_error_log, "\n");
388
389#endif /* LC_ALL */
390
391 PerlIO_printf(Perl_error_log,
392 "perl: warning: Please check that your locale settings:\n");
393
394#ifdef __GLIBC__
395 PerlIO_printf(Perl_error_log,
396 "\tLANGUAGE = %c%s%c,\n",
397 language ? '"' : '(',
398 language ? language : "unset",
399 language ? '"' : ')');
400#endif
401
402 PerlIO_printf(Perl_error_log,
403 "\tLC_ALL = %c%s%c,\n",
404 lc_all ? '"' : '(',
405 lc_all ? lc_all : "unset",
406 lc_all ? '"' : ')');
407
408#if defined(USE_ENVIRON_ARRAY)
409 {
410 char **e;
411 for (e = environ; *e; e++) {
412 if (strnEQ(*e, "LC_", 3)
413 && strnNE(*e, "LC_ALL=", 7)
414 && (p = strchr(*e, '=')))
415 PerlIO_printf(Perl_error_log, "\t%.*s = \"%s\",\n",
416 (int)(p - *e), *e, p + 1);
417 }
418 }
419#else
420 PerlIO_printf(Perl_error_log,
421 "\t(possibly more locale environment variables)\n");
422#endif
423
424 PerlIO_printf(Perl_error_log,
425 "\tLANG = %c%s%c\n",
426 lang ? '"' : '(',
427 lang ? lang : "unset",
428 lang ? '"' : ')');
429
430 PerlIO_printf(Perl_error_log,
431 " are supported and installed on your system.\n");
432 }
433
434#ifdef LC_ALL
435
436 if (setlocale(LC_ALL, "C")) {
437 if (locwarn)
438 PerlIO_printf(Perl_error_log,
439 "perl: warning: Falling back to the standard locale (\"C\").\n");
440 ok = 0;
441 }
442 else {
443 if (locwarn)
444 PerlIO_printf(Perl_error_log,
445 "perl: warning: Failed to fall back to the standard locale (\"C\").\n");
446 ok = -1;
447 }
448
449#else /* ! LC_ALL */
450
451 if (0
452#ifdef USE_LOCALE_CTYPE
453 || !(curctype || setlocale(LC_CTYPE, "C"))
454#endif /* USE_LOCALE_CTYPE */
455#ifdef USE_LOCALE_COLLATE
456 || !(curcoll || setlocale(LC_COLLATE, "C"))
457#endif /* USE_LOCALE_COLLATE */
458#ifdef USE_LOCALE_NUMERIC
459 || !(curnum || setlocale(LC_NUMERIC, "C"))
460#endif /* USE_LOCALE_NUMERIC */
461 )
462 {
463 if (locwarn)
464 PerlIO_printf(Perl_error_log,
465 "perl: warning: Cannot fall back to the standard locale (\"C\").\n");
466 ok = -1;
467 }
468
469#endif /* ! LC_ALL */
470
471#ifdef USE_LOCALE_CTYPE
56279a21 472 Safefree(curctype);
bd61b366 473 curctype = savepv(setlocale(LC_CTYPE, NULL));
98994639
HS
474#endif /* USE_LOCALE_CTYPE */
475#ifdef USE_LOCALE_COLLATE
56279a21 476 Safefree(curcoll);
bd61b366 477 curcoll = savepv(setlocale(LC_COLLATE, NULL));
98994639
HS
478#endif /* USE_LOCALE_COLLATE */
479#ifdef USE_LOCALE_NUMERIC
56279a21 480 Safefree(curnum);
bd61b366 481 curnum = savepv(setlocale(LC_NUMERIC, NULL));
98994639
HS
482#endif /* USE_LOCALE_NUMERIC */
483 }
484 else {
485
486#ifdef USE_LOCALE_CTYPE
487 new_ctype(curctype);
488#endif /* USE_LOCALE_CTYPE */
489
490#ifdef USE_LOCALE_COLLATE
491 new_collate(curcoll);
492#endif /* USE_LOCALE_COLLATE */
493
494#ifdef USE_LOCALE_NUMERIC
495 new_numeric(curnum);
496#endif /* USE_LOCALE_NUMERIC */
b310b053 497
98994639
HS
498 }
499
500#endif /* USE_LOCALE */
501
ec71e770 502#ifdef USE_PERLIO
b310b053 503 {
fde18df1 504 /* Set PL_utf8locale to TRUE if using PerlIO _and_
ec71e770 505 any of the following are true:
085a54d9 506 - nl_langinfo(CODESET) contains /^utf-?8/i
61de9fb5 507 - $ENV{LC_ALL} contains /^utf-?8/i
085a54d9 508 - $ENV{LC_CTYPE} contains /^utf-?8/i
61de9fb5
JH
509 - $ENV{LANG} contains /^utf-?8/i
510 The LC_ALL, LC_CTYPE, LANG obey the usual override
511 hierarchy of locale environment variables. (LANGUAGE
512 affects only LC_MESSAGES only under glibc.) (If present,
513 it overrides LC_MESSAGES for GNU gettext, and it also
514 can have more than one locale, separated by spaces,
515 in case you need to know.)
8aa8f774 516 If PL_utf8locale and PL_unicode (set by -C or by $ENV{PERL_UNICODE})
a05d7ebb 517 are true, perl.c:S_parse_body() will turn on the PerlIO :utf8 layer
fde18df1 518 on STDIN, STDOUT, STDERR, _and_ the default open discipline.
085a54d9 519 */
fde18df1 520 bool utf8locale = FALSE;
b310b053
JH
521 char *codeset = NULL;
522#if defined(HAS_NL_LANGINFO) && defined(CODESET)
523 codeset = nl_langinfo(CODESET);
524#endif
61de9fb5 525 if (codeset)
e6226b18
KW
526 utf8locale = (foldEQ(codeset, STR_WITH_LEN("UTF-8"))
527 || foldEQ(codeset, STR_WITH_LEN("UTF8") ));
077a72a9 528#if defined(USE_LOCALE)
61de9fb5
JH
529 else { /* nl_langinfo(CODESET) is supposed to correctly
530 * interpret the locale environment variables,
531 * but just in case it fails, let's do this manually. */
532 if (lang)
e6226b18
KW
533 utf8locale = (foldEQ(lang, STR_WITH_LEN("UTF-8"))
534 || foldEQ(lang, STR_WITH_LEN("UTF8") ));
b310b053 535#ifdef USE_LOCALE_CTYPE
61de9fb5 536 if (curctype)
e6226b18
KW
537 utf8locale = (foldEQ(curctype, STR_WITH_LEN("UTF-8"))
538 || foldEQ(curctype, STR_WITH_LEN("UTF8") ));
b310b053 539#endif
61de9fb5 540 if (lc_all)
e6226b18
KW
541 utf8locale = (foldEQ(lc_all, STR_WITH_LEN("UTF-8"))
542 || foldEQ(lc_all, STR_WITH_LEN("UTF8") ));
61de9fb5 543 }
fde18df1
JH
544#endif /* USE_LOCALE */
545 if (utf8locale)
546 PL_utf8locale = TRUE;
547 }
a05d7ebb 548 /* Set PL_unicode to $ENV{PERL_UNICODE} if using PerlIO.
fde18df1
JH
549 This is an alternative to using the -C command line switch
550 (the -C if present will override this). */
551 {
dd374669 552 const char *p = PerlEnv_getenv("PERL_UNICODE");
a05d7ebb 553 PL_unicode = p ? parse_unicode_opts(&p) : 0;
5a22a2bb
NC
554 if (PL_unicode & PERL_UNICODE_UTF8CACHEASSERT_FLAG)
555 PL_utf8cache = -1;
b310b053 556 }
ec71e770 557#endif
b310b053 558
98994639 559#ifdef USE_LOCALE_CTYPE
43c5f42d 560 Safefree(curctype);
98994639
HS
561#endif /* USE_LOCALE_CTYPE */
562#ifdef USE_LOCALE_COLLATE
43c5f42d 563 Safefree(curcoll);
98994639
HS
564#endif /* USE_LOCALE_COLLATE */
565#ifdef USE_LOCALE_NUMERIC
43c5f42d 566 Safefree(curnum);
98994639
HS
567#endif /* USE_LOCALE_NUMERIC */
568 return ok;
569}
570
98994639
HS
571#ifdef USE_LOCALE_COLLATE
572
573/*
574 * mem_collxfrm() is a bit like strxfrm() but with two important
575 * differences. First, it handles embedded NULs. Second, it allocates
576 * a bit more memory than needed for the transformed data itself.
577 * The real transformed data begins at offset sizeof(collationix).
578 * Please see sv_collxfrm() to see how this is used.
579 */
166f8a29 580
98994639
HS
581char *
582Perl_mem_collxfrm(pTHX_ const char *s, STRLEN len, STRLEN *xlen)
583{
97aff369 584 dVAR;
98994639
HS
585 char *xbuf;
586 STRLEN xAlloc, xin, xout; /* xalloc is a reserved word in VC */
587
7918f24d
NC
588 PERL_ARGS_ASSERT_MEM_COLLXFRM;
589
98994639
HS
590 /* the first sizeof(collationix) bytes are used by sv_collxfrm(). */
591 /* the +1 is for the terminating NUL. */
592
593 xAlloc = sizeof(PL_collation_ix) + PL_collxfrm_base + (PL_collxfrm_mult * len) + 1;
a02a5408 594 Newx(xbuf, xAlloc, char);
98994639
HS
595 if (! xbuf)
596 goto bad;
597
598 *(U32*)xbuf = PL_collation_ix;
599 xout = sizeof(PL_collation_ix);
600 for (xin = 0; xin < len; ) {
224e8ef5 601 Size_t xused;
98994639
HS
602
603 for (;;) {
604 xused = strxfrm(xbuf + xout, s + xin, xAlloc - xout);
224e8ef5 605 if (xused >= PERL_INT_MAX)
98994639 606 goto bad;
eb160463 607 if ((STRLEN)xused < xAlloc - xout)
98994639
HS
608 break;
609 xAlloc = (2 * xAlloc) + 1;
610 Renew(xbuf, xAlloc, char);
611 if (! xbuf)
612 goto bad;
613 }
614
615 xin += strlen(s + xin) + 1;
616 xout += xused;
617
618 /* Embedded NULs are understood but silently skipped
619 * because they make no sense in locale collation. */
620 }
621
622 xbuf[xout] = '\0';
623 *xlen = xout - sizeof(PL_collation_ix);
624 return xbuf;
625
626 bad:
627 Safefree(xbuf);
628 *xlen = 0;
629 return NULL;
630}
631
632#endif /* USE_LOCALE_COLLATE */
633
66610fdd
RGS
634/*
635 * Local variables:
636 * c-indentation-style: bsd
637 * c-basic-offset: 4
638 * indent-tabs-mode: t
639 * End:
640 *
37442d52
RGS
641 * ex: set ts=8 sts=4 sw=4 noet:
642 */