Changeset 304 for branches


Ignore:
Timestamp:
Oct 29, 2005, 4:05:59 PM (20 years ago)
Author:
pr
Message:

Bug 614 fixes for NLS on MCP systems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1-0/src/helpers/nls.c

    r222 r304  
    4949#include <string.h>
    5050#include <math.h>
     51#include <unidef.h>
     52#include <uconv.h>
    5153
    5254// XWP's setup.h replaces strchr and the like, and
     
    5557#include "setup.h"                      // code generation and debugging options
    5658
     59#include "helpers\dosh.h"
    5760#include "helpers\nls.h"
    5861#include "helpers\prfh.h"
     
    6063
    6164#pragma hdrstop
     65
     66#pragma library("LIBULS")
     67#pragma library("LIBCONV")
    6268
    6369/*
     
    367373 *@@added V0.9.0 [umoeller]
    368374 *@@changed V0.9.7 (2000-12-02) [umoeller]: added cDecimal
     375 *@@changed V1.0.4 (2005-10-15) [bvl]: Added support for Locale object settings on MCP systems @@fixes 614
     376 *@@changed V1.0.4 (2005-10-29) [pr]: Rewritten to prevent memory leaks and errors
    369377 */
    370378
     
    397405                                               "sThousand",
    398406                                               ',');
     407        if (doshIsWarp4()==2)
     408        {
     409            UconvObject         uconv_object;
     410
     411            if (UniCreateUconvObject((UniChar *)L"",
     412                                     &uconv_object) == ULS_SUCCESS)
     413            {
     414                LocaleObject locale_object;
     415
     416                if (UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
     417                                          (UniChar *)L"",
     418                                          &locale_object) == ULS_SUCCESS)
     419                {
     420                    int i;
     421                    struct LOCALE_ITEMLIST
     422                    {
     423                        LocaleItem      lclItem;
     424                        PVOID           vTarget;
     425                        int             iType;
     426                    } itemList[] = {
     427                        { LOCI_iDate, &pcs->ulDateFormat, 1 },
     428                        { LOCI_iTime, &pcs->ulTimeFormat, 1 },
     429                        { LOCI_sDate, &pcs->cDateSep, 2 },
     430                        { LOCI_sTime, &pcs->cTimeSep, 2 },
     431                        { LOCI_sDecimal, &pcs->cDecimal, 2 },
     432                        { LOCI_sThousand, &pcs->cThousands, 2 }
     433                                   };
     434
     435                    for (i = 0;
     436                         i < sizeof(itemList) / sizeof(itemList[0]);
     437                         i++)
     438                    {
     439                        UniChar *pItem;
     440
     441                        if (UniQueryLocaleItem(locale_object,
     442                                               itemList[i].lclItem,
     443                                               &pItem) == ULS_SUCCESS)
     444                        {
     445                            int iLen = UniStrlen(pItem) + 1;
     446                            PSZ pszResult = malloc(iLen);
     447
     448                            if (UniStrFromUcs(uconv_object,
     449                                              pszResult,
     450                                              pItem,
     451                                              iLen) == ULS_SUCCESS)
     452                            {
     453                                switch(itemList[i].iType)
     454                                {
     455                                    case 1:
     456                                        *((ULONG *) itemList[i].vTarget) = atol(pszResult);
     457                                        break;
     458
     459                                    case 2:
     460                                        *((CHAR *) itemList[i].vTarget) = pszResult[0];
     461                                        break;
     462                                }
     463                            }
     464
     465                            free(pszResult);
     466                            UniFreeMem(pItem);
     467                        }
     468                    }
     469
     470                    UniFreeLocaleObject(locale_object);
     471                }
     472
     473                UniFreeUconvObject(uconv_object);
     474            }
     475        }
    399476    }
    400477}
Note: See TracChangeset for help on using the changeset viewer.