version 1.1.1.1, 2014/07/30 08:16:45
|
version 1.1.1.2, 2021/03/17 01:01:01
|
Line 1
|
Line 1
|
/* nls.c -- skeletal internationalization code. */ |
/* nls.c -- skeletal internationalization code. */ |
|
|
/* Copyright (C) 1996-2009 Free Software Foundation, Inc. | /* Copyright (C) 1996-2017 Free Software Foundation, Inc. |
|
|
This file is part of the GNU Readline Library (Readline), a library |
This file is part of the GNU Readline Library (Readline), a library |
for reading lines of text with interactive input and history editing. |
for reading lines of text with interactive input and history editing. |
Line 74 static char *legal_lang_values[] =
|
Line 74 static char *legal_lang_values[] =
|
"iso88599", |
"iso88599", |
"iso885910", |
"iso885910", |
"koi8r", |
"koi8r", |
|
"utf8", |
0 |
0 |
}; |
}; |
|
|
Line 85 static char *find_codeset PARAMS((char *, size_t *));
|
Line 86 static char *find_codeset PARAMS((char *, size_t *));
|
static char *_rl_get_locale_var PARAMS((const char *)); |
static char *_rl_get_locale_var PARAMS((const char *)); |
|
|
static char * |
static char * |
_rl_get_locale_var (v) | _rl_get_locale_var (const char *v) |
const char *v; | |
{ |
{ |
char *lspec; |
char *lspec; |
|
|
Line 100 _rl_get_locale_var (v)
|
Line 100 _rl_get_locale_var (v)
|
} |
} |
|
|
static int |
static int |
utf8locale (lspec) | utf8locale (char *lspec) |
char *lspec; | |
{ |
{ |
char *cp; |
char *cp; |
size_t len; |
size_t len; |
Line 118 utf8locale (lspec)
|
Line 117 utf8locale (lspec)
|
#endif |
#endif |
} |
} |
|
|
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value | /* Query the right environment variables and call setlocale() to initialize |
to decide the defaults for 8-bit character input and output. Returns | the C library locale settings. */ |
1 if we set eight-bit mode. */ | char * |
int | _rl_init_locale (void) |
_rl_init_eightbit () | |
{ |
{ |
/* If we have setlocale(3), just check the current LC_CTYPE category | char *ret, *lspec; |
value, and go into eight-bit mode if it's not C or POSIX. */ | |
#if defined (HAVE_SETLOCALE) | |
char *lspec, *t; | |
|
|
/* Set the LC_CTYPE locale category from environment variables. */ |
/* Set the LC_CTYPE locale category from environment variables. */ |
lspec = _rl_get_locale_var ("LC_CTYPE"); |
lspec = _rl_get_locale_var ("LC_CTYPE"); |
Line 140 _rl_init_eightbit ()
|
Line 135 _rl_init_eightbit ()
|
lspec = setlocale (LC_CTYPE, (char *)NULL); |
lspec = setlocale (LC_CTYPE, (char *)NULL); |
if (lspec == 0) |
if (lspec == 0) |
lspec = ""; |
lspec = ""; |
t = setlocale (LC_CTYPE, lspec); | ret = setlocale (LC_CTYPE, lspec); /* ok, since it does not change locale */ |
|
|
if (t && *t) | _rl_utf8locale = (ret && *ret) ? utf8locale (ret) : 0; |
_rl_utf8locale = utf8locale (t); | |
|
|
|
return ret; |
|
} |
|
|
|
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value |
|
to decide the defaults for 8-bit character input and output. Returns |
|
1 if we set eight-bit mode. */ |
|
int |
|
_rl_init_eightbit (void) |
|
{ |
|
/* If we have setlocale(3), just check the current LC_CTYPE category |
|
value, and go into eight-bit mode if it's not C or POSIX. */ |
|
#if defined (HAVE_SETLOCALE) |
|
char *lspec, *t; |
|
|
|
t = _rl_init_locale (); /* returns static pointer */ |
|
|
if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0)) |
if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0)) |
{ |
{ |
_rl_meta_flag = 1; |
_rl_meta_flag = 1; |
Line 174 _rl_init_eightbit ()
|
Line 184 _rl_init_eightbit ()
|
_rl_output_meta_chars = 1; |
_rl_output_meta_chars = 1; |
break; |
break; |
} |
} |
|
|
|
_rl_utf8locale = *t ? STREQ (t, "utf8") : 0; |
|
|
xfree (t); |
xfree (t); |
return (legal_lang_values[i] ? 1 : 0); |
return (legal_lang_values[i] ? 1 : 0); |
|
|
#endif /* !HAVE_SETLOCALE */ |
#endif /* !HAVE_SETLOCALE */ |
} |
} |
|
|
#if !defined (HAVE_SETLOCALE) |
#if !defined (HAVE_SETLOCALE) |
static char * |
static char * |
normalize_codeset (codeset) | normalize_codeset (char *codeset) |
char *codeset; | |
{ |
{ |
size_t namelen, i; |
size_t namelen, i; |
int len, all_digits; |
int len, all_digits; |
Line 230 normalize_codeset (codeset)
|
Line 241 normalize_codeset (codeset)
|
|
|
/* Isolate codeset portion of locale specification. */ |
/* Isolate codeset portion of locale specification. */ |
static char * |
static char * |
find_codeset (name, lenp) | find_codeset (char *name, size_t *lenp) |
char *name; | |
size_t *lenp; | |
{ |
{ |
char *cp, *language, *result; |
char *cp, *language, *result; |
|
|