Changeset 2058


Ignore:
Timestamp:
Jun 23, 2005, 7:58:05 AM (20 years ago)
Author:
bird
Message:

Fixed some more incorrectness of the 'C' locale, it only defines the first 128 chars.

Location:
trunk/src/emx
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/ChangeLog.LIBC

    • Property cvs2svn:cvs-rev changed from 1.59 to 1.60
    r2057 r2058  
    11/* $Id$ */
     2
     32005-06-23: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     4    - libc:
     5        o Fixed some more incorrectness of the 'C' locale, it only
     6          defines the first 128 chars.
    27
    382005-06-19: knut st. osmundsen <bird-gccos2-spam@anduin.net>
  • trunk/src/emx/include/InnoTekLIBC/locale.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r2057 r2058  
    9090    /** MBCS prefixes. Two bits per character. */
    9191    unsigned char           au2MBCSPrefixs[256/4];
    92     /** Unicode translation. (0xffff means not translation.) */
     92    /** Unicode translation. (0xffff means no translation.) */
    9393    unsigned short          aucUnicode[256];
    9494    /** Unicode -> SBCS conversion: 0..128. */
     
    136136    /** Bit flags for every character (for iswXXX() function series). */
    137137    unsigned        aufType[256];
     138    /** Mask used to check if an index is within the above arrays.
     139     * This is required because 'C' doesn't do more than 0-127. So,
     140     * the mask is either ~0xff or ~0x7f. */
     141    unsigned        uMask;
    138142} __LIBC_LOCALEWCTYPE;
    139143/** Pointer to the Ctype unicode struct. */
     
    217221extern const __LIBC_LOCALECTYPE     __libc_GLocaleCtypeDefault;
    218222/** Cached Unicode (__wchar_t) case conversion tables and flags. */
    219 extern const __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype;
     223extern __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype;
    220224/** Locale information structure. */
    221225extern __LIBC_LOCALELCONV           __libc_gLocaleLconv;
  • trunk/src/emx/include/_ctype.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r2057 r2058  
    7171    /** Bit flags for every character (for iswXXX() function series). */
    7272    unsigned        aufType[256];
     73    /** Mask used to check if an index is within the above arrays.
     74     * This is required because 'C' doesn't do more than 0-127. So,
     75     * the mask is either ~0xff or ~0x7f. */
     76    unsigned        uMask;
    7377} __libc_GLocaleWCtype;
    7478__END_DECLS
     
    160164 */
    161165__BEGIN_DECLS
    162 static inline unsigned __ctype(__ct_rune_t __ch, unsigned __f)
    163 {
    164     return !((__ch) & ~0xffU)
    165         ? __libc_GLocaleCtype.aufType[(__ch)/* & 0xff*/] & (__f)
     166static __inline__ unsigned __ctype(__ct_rune_t __ch, unsigned __f)
     167{
     168    return !(__ch & ~0xffU)
     169        ? __libc_GLocaleCtype.aufType[__ch] & __f
    166170        : 0;
    167171}
    168172
    169 static inline int __istype(__ct_rune_t __ch, unsigned __f)
    170 {
    171     return !!__ctype((__ch), (__f));
    172 }
    173 
    174 static inline int __isctype(__ct_rune_t __ch, unsigned __f)
    175 {
    176     return !((__ch) & ~0xffU)
    177         ? !!(__libc_GLocaleCtypeDefault.aufType[(__ch)/* & 0xff*/] & (__f))
     173static __inline__ int __istype(__ct_rune_t __ch, unsigned __f)
     174{
     175    return !!__ctype(__ch, __f);
     176}
     177
     178static __inline__ int __isctype(__ct_rune_t __ch, unsigned __f)
     179{
     180    return !(__ch & ~0xffU)
     181        ? !!(__libc_GLocaleCtypeDefault.aufType[__ch] & __f)
    178182        : 0;
    179183}
    180184
    181 static inline __ct_rune_t __toupper(__ct_rune_t __ch)
    182 {
    183     return !((__ch) & ~0xffU)
    184         ? __libc_GLocaleCtype.auchUpper[(__ch)/* & 0xff*/]
     185static __inline__ __ct_rune_t __toupper(__ct_rune_t __ch)
     186{
     187    return !(__ch & ~0xffU)
     188        ? __libc_GLocaleCtype.auchUpper[__ch]
    185189        : (__ch);
    186190}
    187191
    188 static inline __ct_rune_t __tolower(__ct_rune_t __ch)
    189 {
    190     return !((__ch) & ~0xffU)
    191         ? __libc_GLocaleCtype.auchLower[(__ch)/* & 0xff*/]
    192         : (__ch);
    193 }
    194 
    195 
    196 static inline unsigned __wctype(__wint_t __wc, unsigned __f)
    197 {
    198     return !((__wc) & ~0xffU)
    199         ? __libc_GLocaleWCtype.aufType[(__wc)] & (__f)
    200         : ___wctype(__wc) & (__f);
    201 }
    202 
    203 static inline int __iswtype(__wint_t __wc, unsigned __f)
    204 {
    205     return !!__wctype((__wc), (__f));
    206 }
    207 
    208 static inline __wint_t __towupper(__wint_t __wc)
    209 {
    210     return !((__wc) & ~0xffU)
    211         ? __libc_GLocaleWCtype.awcUpper[(__wc)]
     192static __inline__ __ct_rune_t __tolower(__ct_rune_t __ch)
     193{
     194    return !(__ch & ~0xffU)
     195        ? __libc_GLocaleCtype.auchLower[__ch]
     196        : __ch;
     197}
     198
     199
     200static __inline__ unsigned __wctype(__wint_t __wc, unsigned __f)
     201{
     202    return !(__wc & __libc_GLocaleWCtype.uMask)
     203        ? __libc_GLocaleWCtype.aufType[__wc] & __f
     204        : ___wctype(__wc) & __f;
     205}
     206
     207static __inline__ int __iswtype(__wint_t __wc, unsigned __f)
     208{
     209    return !!__wctype(__wc, __f);
     210}
     211
     212static __inline__ __wint_t __towupper(__wint_t __wc)
     213{
     214    return !(__wc & __libc_GLocaleWCtype.uMask)
     215        ? __libc_GLocaleWCtype.awcUpper[__wc]
    212216        : ___towupper(__wc);
    213217}
    214218
    215 static inline __wint_t __towlower(__wint_t __wc)
    216 {
    217     return !((__wc) & ~0xffU)
    218         ? __libc_GLocaleWCtype.awcLower[(__wc)]
     219static __inline__ __wint_t __towlower(__wint_t __wc)
     220{
     221    return !(__wc & __libc_GLocaleWCtype.uMask)
     222        ? __libc_GLocaleWCtype.awcLower[__wc]
    219223        : ___towlower(__wc);
    220224}
    221225
    222 
    223 static inline int __wcwidth(__wint_t __wc)
    224 {
    225     if ((__wc) != 0)
     226static __inline__ int __wcwidth(__wint_t __wc)
     227{
     228    if (__wc != 0)
    226229    {
    227         unsigned __f = __wctype((__wc), __CT_SCRW_MASK | __CT_PRINT);
    228         return ((__f) & __CT_SCRW_MASK)
    229             ? ((__f) & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
    230             : ((__f) & __CT_PRINT) ? 1 : -1;
     230        unsigned __f = __wctype(__wc, __CT_SCRW_MASK | __CT_PRINT);
     231        return (__f & __CT_SCRW_MASK)
     232            ? (__f & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
     233            : (__f & __CT_PRINT) ? 1 : -1;
    231234    }
    232235    else
     
    250253unsigned    __wctype(__wint_t, unsigned);
    251254int         __iswtype(__wint_t, unsigned);
    252 __wint_t     __towupper(__wint_t);
    253 __wint_t     __towlower(__wint_t);
     255__wint_t    __towupper(__wint_t);
     256__wint_t    __towlower(__wint_t);
    254257int         __wcwidth(__wint_t);
    255258__END_DECLS
  • trunk/src/emx/include/math.h

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r2057 r2058  
    9797    : (sizeof (x) == sizeof (double)) ? __isfinite(x)   \
    9898    : __isfinitel(x))
     99#ifdef IN_INNOTEK_LIBC
     100#undef isinf
     101#define isinf(x)                                        \
     102    ((sizeof (x) == sizeof (float)) ? __isinff(x)       \
     103    : (sizeof (x) == sizeof (double)) ? _STD(isinf)(x)  \
     104    : __isinfl(x))
     105#undef isnan
     106#define isnan(x)                                        \
     107    ((sizeof (x) == sizeof (float)) ? isnanf(x)         \
     108    : (sizeof (x) == sizeof (double)) ? _STD(isnan)(x)  \
     109    : __isnanl(x))
     110#else
    99111#define isinf(x)                                        \
    100112    ((sizeof (x) == sizeof (float)) ? __isinff(x)       \
     
    105117    : (sizeof (x) == sizeof (double)) ? isnan(x)        \
    106118    : __isnanl(x))
     119#endif
    107120#define isnormal(x)                                     \
    108121    ((sizeof (x) == sizeof (float)) ? __isnormalf(x)    \
     
    234247double  hypot(double, double);
    235248int     ilogb(double) __pure2;
     249#ifdef IN_INNOTEK_LIBC
     250int     _STD(isinf)(double) __pure2;
     251int     _STD(isnan)(double) __pure2;
     252#else
    236253int     (isinf)(double) __pure2;
    237254int     (isnan)(double) __pure2;
     255#endif
    238256double  lgamma(double);
    239257long long llrint(double);
  • trunk/src/emx/src/lib/bsd/locale/utf8.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r2057 r2058  
    7171        return (0);
    7272}
    73 #endif /* !__INNOTEK_LIBC__ */
     73#else
     74void __libc_localeFuncsUTF8(__LIBC_PLOCALECTYPEFUNCS pFuncs)
     75{
     76    pFuncs->pfnmbsinit = _UTF8_mbsinit;
     77    pFuncs->pfnmbrtowc = _UTF8_mbrtowc;
     78    pFuncs->pfnmbsnrtowcs = _UTF8_mbsnrtowcs;
     79    pFuncs->pfnwcrtomb = _UTF8_wcrtomb;
     80    pFuncs->pfnwcsnrtombs = _UTF8_wcsnrtombs;
     81}
     82#endif /* __INNOTEK_LIBC__ */
    7483
    7584int
  • trunk/src/emx/src/lib/locale/locale_ctype.c

    • Property cvs2svn:cvs-rev changed from 1.13 to 1.14
    r2057 r2058  
    247247
    248248/** Cached Unicode (__wchar_t) case conversion tables and flags. */
    249 const __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype =
     249__LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype =
    250250{
    251251    .awcLower =
     
    355355        0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200, 0x000f0200,
    356356    },
     357    .uMask = ~0x7fU,
    357358};
    358359
    359360
    360 
    361361unsigned __wctype(__wint_t __wc, unsigned __f)
    362362{
    363     return !((__wc) & ~0xffU)
    364         ? __libc_GLocaleWCtype.aufType[(__wc)] & (__f)
    365         : ___wctype(__wc) & (__f);
     363    return !(__wc & __libc_GLocaleWCtype.uMask)
     364        ? __libc_GLocaleWCtype.aufType[__wc] & __f
     365        : ___wctype(__wc) & __f;
    366366}
    367367
    368368int __iswtype(__wint_t __wc, unsigned __f)
    369369{
    370     return !!__wctype((__wc), (__f));
     370    return !!__wctype(__wc, __f);
    371371}
    372372
    373373__wint_t __towupper(__wint_t __wc)
    374374{
    375     return !((__wc) & ~0xffU)
    376         ? __libc_GLocaleWCtype.awcUpper[(__wc)]
     375    return !(__wc & __libc_GLocaleWCtype.uMask)
     376        ? __libc_GLocaleWCtype.awcUpper[__wc]
    377377        : ___towupper(__wc);
    378378}
     
    380380__wint_t __towlower(__wint_t __wc)
    381381{
    382     return !((__wc) & ~0xffU)
    383         ? __libc_GLocaleWCtype.awcLower[(__wc)]
     382    return !(__wc & __libc_GLocaleWCtype.uMask)
     383        ? __libc_GLocaleWCtype.awcLower[__wc]
    384384        : ___towlower(__wc);
    385385}
    386386
    387 
    388387int __wcwidth(__wint_t __wc)
    389388{
    390     if ((__wc) != 0)
    391     {
    392         unsigned __f = __wctype((__wc), __CT_SCRW_MASK | __CT_PRINT);
    393         return ((__f) & __CT_SCRW_MASK)
    394             ? ((__f) & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
    395             : ((__f) & __CT_PRINT) ? 1 : -1;
    396     }
    397     else
    398         return 0;
     389    if (__wc != 0)
     390    {
     391        unsigned __f = __wctype(__wc, __CT_SCRW_MASK | __CT_PRINT);
     392        return (__f & __CT_SCRW_MASK)
     393            ? (__f & __CT_SCRW_MASK) >> __CT_SCRW_SHIFT
     394            : (__f & __CT_PRINT) ? 1 : -1;
     395    }
     396    return 0;
    399397}
    400398
     
    404402 * ASSUMES that none of the locals differs from the unicode spec
    405403 */
    406 unsigned ___wctype(__wchar_t uc)
     404unsigned ___wctype(__wchar_t wc)
    407405{
    408406    unsigned    ufType = 0;
    409     UNICTYPE   *pUniType = UniQueryCharType(uc);
    410     if (pUniType)
    411     {
    412         /* ASSUMES CT_* << 8 == __* ! */
    413         ufType = ((unsigned)pUniType->itype << 8)
    414                & (__CT_UPPER  | __CT_LOWER  | __CT_DIGIT | __CT_SPACE |
    415                   __CT_PUNCT  | __CT_CNTRL  | __CT_BLANK | __CT_XDIGIT |
    416                   __CT_ALPHA  | __CT_ALNUM  | __CT_GRAPH | __CT_PRINT |
    417                   __CT_NUMBER | __CT_SYMBOL | __CT_ASCII);
    418         if (pUniType->extend & C3_IDEOGRAPH)
    419             ufType |= __CT_IDEOGRAM;
    420         if (ufType & (__CT_XDIGIT | __CT_DIGIT))
     407    if (    __libc_GLocaleWCtype.uMask != ~0x7f
     408        ||  wc <= 127)
     409    {
     410        UNICTYPE   *pUniType = UniQueryCharType(wc);
     411        if (pUniType)
    421412        {
    422             if (     (unsigned)uc - 0x30U <= (0x39 - 0x30))
    423                 ufType |= (unsigned)uc - 0x30;
    424             else if ((unsigned)uc - 0x41U <= (0x46 - 0x41))
    425                 ufType |= (unsigned)uc - 0x41 + 0xa;
    426             else
     413            /* ASSUMES CT_* << 8 == __* ! */
     414            ufType = ((unsigned)pUniType->itype << 8)
     415                   & (__CT_UPPER  | __CT_LOWER  | __CT_DIGIT | __CT_SPACE |
     416                      __CT_PUNCT  | __CT_CNTRL  | __CT_BLANK | __CT_XDIGIT |
     417                      __CT_ALPHA  | __CT_ALNUM  | __CT_GRAPH | __CT_PRINT |
     418                      __CT_NUMBER | __CT_SYMBOL | __CT_ASCII);
     419            if (pUniType->extend & C3_IDEOGRAPH)
     420                ufType |= __CT_IDEOGRAM;
     421            if (ufType & (__CT_XDIGIT | __CT_DIGIT))
    427422            {
    428                 unsigned uVal = UniQueryNumericValue(uc);
    429                 if (!(uVal & ~0xffU))
    430                     ufType |= uVal;
     423                if (     (unsigned)wc - 0x30U <= (0x39 - 0x30))
     424                    ufType |= (unsigned)wc - 0x30;
     425                else if ((unsigned)wc - 0x41U <= (0x46 - 0x41))
     426                    ufType |= (unsigned)wc - 0x41 + 0xa;
     427                else
     428                {
     429                    unsigned uVal = UniQueryNumericValue(wc);
     430                    if (!(uVal & ~0xffU))
     431                        ufType |= uVal;
     432                }
    431433            }
     434            ufType |= (pUniType->bidi & 0xf << 24);
     435
     436            /** @todo screen width. */
    432437        }
    433         ufType |= (pUniType->bidi & 0xf << 24);
    434 
    435         /** @todo screen width. */
    436438    }
    437439    return ufType;
     
    444446__wchar_t ___towlower(__wchar_t wc)
    445447{
     448    if (    __libc_GLocaleWCtype.uMask == ~0x7f
     449        &&  wc > 127)
     450        return wc;
    446451    FS_VAR_SAVE_LOAD();
    447452    UniChar ucRet = UniTolower(wc);
     
    456461__wchar_t ___towupper(__wchar_t wc)
    457462{
     463    if (    __libc_GLocaleWCtype.uMask == ~0x7f
     464        &&  wc > 127)
     465        return wc;
    458466    FS_VAR_SAVE_LOAD();
    459467    UniChar ucRet = UniToupper(wc);
     
    646654    }
    647655    printf("\n"
    648            "    },\n");
     656           "    },\n"
     657           "    .uMask = ~0x7f,\n");
    649658
    650659    /* done */
  • trunk/src/emx/src/lib/locale/mb_libuni.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r2057 r2058  
    9393        return ((size_t)-2);
    9494
    95 
    9695    /*
    9796     * Try the conversion table first.
    9897     */
    99     __wchar_t wc;
     98    __wchar_t wc = -1;
    10099    unsigned char uch = *(const unsigned char *)s;
    101 #ifndef NO_CONVERSION_TABLES
    102100    if (    !pState->chState
    103         &&  (wc = __libc_GLocaleCtype.aucUnicode[uch]) != 0xffff)
     101        &&  (   (wc = __libc_GLocaleCtype.aucUnicode[uch]) != 0xffff
     102             || !IS_MBCS_PREFIX(&__libc_GLocaleCtype, uch)))
     103
    104104    {
    105105        if (pwc != NULL)
     
    107107        return wc != 0;
    108108    }
    109 #endif /* !NO_CONVERSION_TABLES */
     109    if (!__libc_GLocaleCtype.uobj) /* no possible conversion */
     110    {
     111        errno = EILSEQ;
     112        return ((size_t)-1);
     113    }
    110114
    111115    /*
     
    120124    size_t  cIgnore = 0;
    121125    uconv_attribute_t attr;
     126    LOCALE_LOCK();
     127    if (!__libc_GLocaleCtype.uobj)
     128    {
     129        LOCALE_UNLOCK();
     130        errno = EILSEQ;
     131        return ((size_t)-1);
     132    }
    122133    FS_VAR_SAVE_LOAD();
    123     LOCALE_LOCK();
    124     int rc = 0;
    125     if (!__libc_GLocaleCtype.uobj)
    126         rc = __libc_localeCreateObjects("C", NULL, NULL, &__libc_GLocaleCtype.lobj, &__libc_GLocaleCtype.uobj);
    127     if (!rc)
    128         rc = UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL);
     134    int rc = UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL);
    129135    if (!rc)
    130136    {
     
    140146                ||  (rc == UCONV_E2BIG && !cwcOutLeft))
    141147            {
     148                if (wc == 0xfffd)
     149                    wc = -1; /* this seems to make sense sometimes... */
    142150                if (pwc)
    143151                    *pwc = wc;
     
    177185     */
    178186    char    ch;
    179 #ifndef NO_CONVERSION_TABLES
    180187    if (!pState->chState)
    181188    {
     
    212219        /* not found */
    213220    }
    214 #endif /* !NO_CONVERSION_TABLES */
     221    if (!__libc_GLocaleCtype.uobj) /* no possible conversion */
     222    {
     223        errno = EILSEQ;
     224        return ((size_t)-1);
     225    }
    215226
    216227    /*
     
    224235    UniChar    *pucIn = &wc;
    225236    uconv_attribute_t attr;
    226     FS_VAR_SAVE_LOAD();
    227     LOCALE_LOCK();
    228237    size_t      cchMbCurMax = MB_CUR_MAX;
    229238    size_t      cchOutLeft = cchMbCurMax;
    230     int rc = 0;
     239    LOCALE_LOCK();
    231240    if (!__libc_GLocaleCtype.uobj)
    232         rc = __libc_localeCreateObjects("C", NULL, NULL, &__libc_GLocaleCtype.lobj, &__libc_GLocaleCtype.uobj);
    233     if (!rc)
    234         rc = UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL);
     241    {
     242        LOCALE_UNLOCK();
     243        errno = EILSEQ;
     244        return ((size_t)-1);
     245    }
     246    FS_VAR_SAVE_LOAD();
     247    int rc = UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL);
    235248    if (!rc)
    236249    {
     
    453466}
    454467
    455 /* later */
    456 void __libc_localeFuncsUTF8(__LIBC_PLOCALECTYPEFUNCS pFuncs)
    457 {
    458     __libc_localeFuncsDefault(pFuncs);
    459 }
    460 
  • trunk/src/emx/src/lib/locale/setlocale.c

    • Property cvs2svn:cvs-rev changed from 1.19 to 1.20
    r2057 r2058  
    12991299        case LC_CTYPE:
    13001300            rc = localeCtypeDo(&pTemp->Ctype, uobj, lobj, pszLocale, &szCodepageActual[0]);
    1301             fFree = rc != 0;
     1301            fFree = rc != 0 || IS_C_LOCALE(pszLocale) || IS_POSIX_LOCALE(pszLocale);
    13021302            break;
    13031303
     
    15381538        memcpy(&__libc_GLocaleCtype, &pTemp->Ctype, sizeof(__libc_GLocaleCtype));
    15391539        MB_CUR_MAX = pTemp->Ctype.mbcs ? pTemp->Ctype.mbcs : 1;
     1540        if (    IS_C_LOCALE(pTemp->Global.apszNames[LC_CTYPE + 1])
     1541            ||  IS_POSIX_LOCALE(pTemp->Global.apszNames[LC_CTYPE + 1]))
     1542            __libc_GLocaleWCtype.uMask = ~0x7fU;
     1543        else
     1544            __libc_GLocaleWCtype.uMask = ~0xffU;
    15401545        pTemp->afProcessed[LC_CTYPE + 1] = 0;
    15411546        gLocale.apszNames[LC_CTYPE + 1] = pTemp->Global.apszNames[LC_CTYPE + 1];
Note: See TracChangeset for help on using the changeset viewer.