Changeset 1712


Ignore:
Timestamp:
Dec 6, 2004, 7:46:13 AM (21 years ago)
Author:
bird
Message:

Bugfixing locale.

Location:
trunk/src/emx/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.88 to 1.89
    r1711 r1712  
    13521352    "___wctype" @1367
    13531353    "____wctype" @1368
    1354     "main" @1369
    1355     "_main" @1370
  • trunk/src/emx/src/lib/locale/locale_ctype.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1711 r1712  
    249249const __LIBC_LOCALEWCTYPE    __libc_GLocaleWCtype =
    250250{
    251     .awcUpper =
    252     {
    253 
     251    .awcLower =
     252    {
    254253        0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
    255254        0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
     
    287286    .awcUpper =
    288287    {
    289 
    290288        0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
    291289        0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
     
    466464
    467465
    468 #if 1 /* code for regenerating that table - link staticly! */
     466#if 0 /* code for regenerating that table - link staticly! */
    469467
    470468#include <InnoTekLIBC/locale.h>
     
    608606
    609607    /* Lower */
    610     printf("    .awcUpper =\n"
    611            "    {\n");
     608    printf("    .awcLower =\n"
     609           "    {");
    612610    for (i = 0; i < sizeof(__libc_GLocaleWCtype.awcLower) / sizeof(__libc_GLocaleWCtype.awcLower[0]); i++)
    613611    {
     
    623621    /* Upper */
    624622    printf("    .awcUpper =\n"
    625            "    {\n");
     623           "    {");
    626624    for (i = 0; i < sizeof(__libc_GLocaleWCtype.awcUpper) / sizeof(__libc_GLocaleWCtype.awcUpper[0]); i++)
    627625    {
     
    637635    /* Type */
    638636    printf("    .aufType =\n"
    639            "    {\n");
     637           "    {");
    640638    for (i = 0; i < sizeof(__libc_GLocaleWCtype.aufType) / sizeof(__libc_GLocaleWCtype.aufType[0]); i++)
    641639    {
  • trunk/src/emx/src/lib/locale/mb_libuni.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1711 r1712  
    9999    __wchar_t wc;
    100100    unsigned char uch = *(const unsigned char *)s;
     101#ifndef NO_CONVERSION_TABLES
    101102    if (    !pState->chState
    102103        &&  (wc = __libc_GLocaleCtype.aucUnicode[uch]) != 0xffff)
     
    104105        if (pwc != NULL)
    105106            *pwc = wc;
    106         return !wc;
    107     }
     107        return wc != 0;
     108    }
     109#endif /* !NO_CONVERSION_TABLES */
    108110
    109111    /*
     
    111113     * and restore the state before we try convert anything.
    112114     */
    113     if (!pwc)
    114         pwc = &wc;                      /* The api crashes elsewise. */
     115    wchar_t *pwcIn = &wc;
     116    if (n >= 0x7fffffff)
     117        n = 0x7ffffffe;                 /* UTF-8 decoder/encoder don't like -1, so let's play safe. */
    115118    size_t  cbInLeft = n;
    116119    size_t  cwcOutLeft = 1;
     
    133136        if (!rc)
    134137        {
    135             rc = UniUconvToUcs(__libc_GLocaleCtype.uobj, (void **)(void *)&s, &cbInLeft, (UniChar **)&pwc, &cwcOutLeft, &cIgnore);
    136             if (!rc)
    137             {
     138            rc = UniUconvToUcs(__libc_GLocaleCtype.uobj, (void **)(void *)&s, &cbInLeft, (UniChar **)&pwcIn, &cwcOutLeft, &cIgnore);
     139            if (    !rc
     140                ||  (rc == UCONV_E2BIG && !cwcOutLeft))
     141            {
     142                if (pwc)
     143                    *pwc = wc;
     144                rc = 0;
    138145                if (!UniQueryUconvObject(__libc_GLocaleCtype.uobj, &attr, sizeof(attr), NULL, NULL, NULL))
    139146                    pState->chState = attr.state;
     
    145152
    146153    if (!rc)
    147         return n - cbInLeft;
     154        return n - cbInLeft - !wc;
    148155    /* failure */
    149156    libuni_errno(rc);
     
    170177     */
    171178    char    ch;
     179#ifndef NO_CONVERSION_TABLES
    172180    if (!pState->chState)
    173181    {
     
    204212        /* not found */
    205213    }
     214#endif /* !NO_CONVERSION_TABLES */
    206215
    207216    /*
     
    279288{
    280289    const char *pch = *src;
    281     size_t      cwc = 0;
     290    size_t      cbIn = nms;
    282291    if (dst == NULL)
    283292    {
     
    291300                    return (size_t)-1;    /* Invalid sequence - mbrtowc() sets errno. */
    292301                else /* if (cb == 0 || cb == (size_t)-2) */
    293                     return cwc;
     302                    return cbIn - nms;
    294303            }
    295304
     
    297306            pch += cb;
    298307            nms -= cb;
    299             cwc++;
    300308        }
    301309        /* (won't ever get here.) */
     
    311319                {
    312320                    *src = NULL;
    313                     return cwc;
     321                    return cbIn - nms;
    314322                }
    315323                else if (cb == (size_t)-2)
    316324                {
    317325                    *src = pch + nms;
    318                     return cwc;
     326                    return cbIn - nms;
    319327                }
    320328                else /*if (cb == (size_t)-1) */
     
    328336            pch += cb;
    329337            nms -= cb;
    330             cwc++;
    331338            dst++;
    332339        }
    333340
    334341        *src = pch;
    335         return cwc;
     342        return cbIn - nms;
    336343    }
    337344}
  • trunk/src/emx/src/lib/locale/setlocale.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1711 r1712  
    206206static const char *getDefaultLocale(const char *pszCategory, char *pszBuffer, int *pfDefault);
    207207static int getCodepage(const char *pszCodepage, const char *pszLocale, LocaleObject lobj, UniChar *pucsCodepage, unsigned cucCodepage);
    208 static int query_mbcs(UconvObject uobj, char *mbcs, unsigned char *au2MBCSPrefixs, int *pmb_cur_max);
     208static int query_mbcs(UconvObject uobj, char *mbcs, unsigned char *au2MBCSPrefixs);
    209209
    210210static int localeCollateDo(__LIBC_PLOCALECOLLATE pCollate, UconvObject uobj, LocaleObject lobj);
     
    336336
    337337
    338 static int query_mbcs(UconvObject uobj, char *mbcs, unsigned char *au2MBCSPrefixs, int *pmb_cur_max)
     338static int query_mbcs(UconvObject uobj, char *mbcs, unsigned char *au2MBCSPrefixs)
    339339{
    340340    unsigned            i;
     
    353353     * Create the return values.
    354354     */
    355     if (pmb_cur_max)
    356         *pmb_cur_max = uconv_attr.mb_max_len;
    357     *mbcs = (uconv_attr.mb_max_len > 1);
     355    *mbcs = uconv_attr.mb_max_len > 1 ? uconv_attr.mb_max_len : 0;
    358356
    359357    bzero(au2MBCSPrefixs, 256/4);
     
    384382     * Query multi-byte related stuff.
    385383     */
    386     rc = query_mbcs(uobj, &pCollate->mbcs, &pCollate->au2MBCSPrefixs[0], NULL);
     384    rc = query_mbcs(uobj, &pCollate->mbcs, &pCollate->au2MBCSPrefixs[0]);
    387385    if (rc)
    388386        return rc;
     
    508506     * Query multi-byte related stuff.
    509507     */
    510     rc = query_mbcs(uobj, &pCtype->mbcs, &pCtype->au2MBCSPrefixs[0], NULL);
     508    rc = query_mbcs(uobj, &pCtype->mbcs, &pCtype->au2MBCSPrefixs[0]);
    511509    if (rc)
    512510        return rc;
     
    14461444        localeCtypeFree(&__libc_GLocaleCtype);
    14471445        memcpy(&__libc_GLocaleCtype, &pTemp->Ctype, sizeof(__libc_GLocaleCtype));
     1446        MB_CUR_MAX = pTemp->Ctype.mbcs ? pTemp->Ctype.mbcs : 1;
    14481447        pTemp->afProcessed[LC_CTYPE + 1] = 0;
    14491448        gLocale.apszNames[LC_CTYPE + 1] = pTemp->Global.apszNames[LC_CTYPE + 1];
Note: See TracChangeset for help on using the changeset viewer.