Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/libbb/unicode.c


Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/libbb/unicode.c

    r2725 r3232  
    2424/* Unicode support using libc locale support. */
    2525
    26 void FAST_FUNC init_unicode(void)
     26void FAST_FUNC reinit_unicode(const char *LANG)
    2727{
    2828    static const char unicode_0x394[] = { 0xce, 0x94, 0 };
    2929    size_t width;
    3030
    31     if (unicode_status != UNICODE_UNKNOWN)
    32         return;
     31//TODO: avoid repeated calls by caching last string?
     32    setlocale(LC_ALL, (LANG && LANG[0]) ? LANG : "C");
     33
    3334    /* In unicode, this is a one character string */
    3435// can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused
     
    3738}
    3839
     40void FAST_FUNC init_unicode(void)
     41{
     42    if (unicode_status == UNICODE_UNKNOWN)
     43        reinit_unicode(getenv("LANG"));
     44}
     45
    3946#else
    4047
     
    4249
    4350# if ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
    44 void FAST_FUNC init_unicode(void)
    45 {
    46     char *lang;
    47 
    48     if (unicode_status != UNICODE_UNKNOWN)
    49         return;
    50 
     51void FAST_FUNC reinit_unicode(const char *LANG)
     52{
    5153    unicode_status = UNICODE_OFF;
    52     lang = getenv("LANG");
    53     if (!lang || !(strstr(lang, ".utf") || strstr(lang, ".UTF")))
     54    if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF")))
    5455        return;
    5556    unicode_status = UNICODE_ON;
     57}
     58
     59void FAST_FUNC init_unicode(void)
     60{
     61    if (unicode_status == UNICODE_UNKNOWN)
     62        reinit_unicode(getenv("LANG"));
    5663}
    5764# endif
     
    11081115    return unicode_conv_to_printable2(stats, src, INT_MAX, 0);
    11091116}
     1117char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width)
     1118{
     1119    return unicode_conv_to_printable2(/*stats:*/ NULL, src, width, UNI_FLAG_PAD);
     1120}
     1121
     1122#ifdef UNUSED
    11101123char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth)
    11111124{
    11121125    return unicode_conv_to_printable2(stats, src, maxwidth, 0);
    11131126}
    1114 char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width)
    1115 {
    1116     return unicode_conv_to_printable2(stats, src, width, UNI_FLAG_PAD);
    1117 }
    1118 
    1119 #ifdef UNUSED
     1127
    11201128unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src)
    11211129{
Note: See TracChangeset for help on using the changeset viewer.