Ignore:
Timestamp:
Jan 19, 2006, 3:44:53 AM (20 years ago)
Author:
bird
Message:

Fixes #30: Fixed two locale bugs. First, setlocale called a locale
dependent function for getting ctype flags. Second, all the
is<>() macros / functions was busted for non-ascii chars (-1..-128).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/include/InnoTekLIBC/locale.h

    r2163 r2511  
    316316/** @} */
    317317
     318#include <ctype.h>
     319
     320/**
     321 * Convert the type info we get from the unicode lib to libc talk.
     322 * ASSUMES that none of the locals differs from the unicode spec
     323 *
     324 * @returns libc ctype flags.
     325 * @param   pUniType    The unicode type info to translate.
     326 * @param   wc          The unicode code point.
     327 */
     328static inline unsigned ___wctype_uni(const UNICTYPE *pUniType, wchar_t wc)
     329{
     330    unsigned    ufType = 0;
     331    /* ASSUMES CT_* << 8 == __* ! */
     332    ufType = ((unsigned)pUniType->itype << 8)
     333           & (__CT_UPPER  | __CT_LOWER  | __CT_DIGIT | __CT_SPACE |
     334              __CT_PUNCT  | __CT_CNTRL  | __CT_BLANK | __CT_XDIGIT |
     335              __CT_ALPHA  | __CT_ALNUM  | __CT_GRAPH | __CT_PRINT |
     336              __CT_NUMBER | __CT_SYMBOL | __CT_ASCII);
     337    if (pUniType->extend & C3_IDEOGRAPH)
     338        ufType |= __CT_IDEOGRAM;
     339    if (ufType & (__CT_XDIGIT | __CT_DIGIT))
     340    {
     341        if (     (unsigned)wc - 0x30U <= (0x39 - 0x30))
     342            ufType |= (unsigned)wc - 0x30;
     343        else if ((unsigned)wc - 0x41U <= (0x46 - 0x41))
     344            ufType |= (unsigned)wc - 0x41 + 0xa;
     345        else
     346        {
     347            unsigned uVal = UniQueryNumericValue(wc);
     348            if (!(uVal & ~0xffU))
     349                ufType |= uVal;
     350        }
     351    }
     352    ufType |= (pUniType->bidi & 0xf << 24);
     353
     354    /** @todo screen width. */
     355    return ufType;
     356}
     357
    318358__END_DECLS
    319359
Note: See TracChangeset for help on using the changeset viewer.