1.0.39.11: fix readdir for :inode64 builds
[sbcl.git] / src / runtime / darwin-langinfo.c
1 /*
2  * This is a minimal nl_langinfo replacement that only handles CODESET.
3  * By default, it returns UTF-8.  It checks if LC_CTYPE or LANG are set, and
4  * uses LATIN-1 if it finds one set to C, or UTF-8 if it finds one set to
5  * anything else.
6  */
7
8 /*
9  * This software is part of the SBCL system. See the README file for
10  * more information.
11  *
12  * This software is derived from the CMU CL system, which was
13  * written at Carnegie Mellon University and released into the
14  * public domain. The software is in the public domain and is
15  * provided with absolutely no warranty. See the COPYING and CREDITS
16  * files for more information.
17  */
18
19 #include <stdlib.h>
20 #include <string.h>
21 #include "darwin-langinfo.h"
22
23 char *nl_langinfo(nl_item item)
24 {
25   char *nada = "", *utf8 = "UTF-8", *latin1 = "LATIN-1";
26
27   if (item != CODESET) {
28     return nada;
29   } else {
30     char *ctype = getenv ("LC_CTYPE");
31
32     if ((ctype != NULL) && (!strcmp(ctype, "C"))) {
33       return latin1;
34     } else if (ctype != NULL) {
35       return utf8;
36     } else {
37       char *lang = getenv ("LANG");
38
39       if ((lang != NULL) && (!strcmp(lang, "C"))) {
40         return latin1;
41       } else {
42         return utf8;
43       }
44     }
45   }
46 }