Changeset 5737 for trunk/src


Ignore:
Timestamp:
May 18, 2001, 10:15:02 PM (24 years ago)
Author:
sandervl
Message:

Fixed FS corruption in LCMapStringA/W + ole2nls resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/ole2nls.cpp

    r5457 r5737  
    1 /* $Id: ole2nls.cpp,v 1.10 2001-04-03 17:47:11 sandervl Exp $ */
    2 
    31/*
    42 *      National Language Support library
     
    75 *      Copyright 1998  David Lee Lambert
    86 *      Copyright 2000  Julio César Gázquez
    9  *      Copyright 2000 Patrick Haller
    10  *
    11  *
    12  * Project Odin Software License can be found in LICENSE.TXT
    13  *
    147 */
    158
    16 
    17 /*****************************************************************************
    18  * Includes                                                                  *
    19  *****************************************************************************/
    20 
     9#ifdef __WIN32OS2__
    2110#include <odin.h>
    2211#include <odinwrap.h>
    23 #include <os2sel.h>
    24 #include <os2win.h>
    25 #include <misc.h>
     12
     13#include <string.h>
     14#include <stdio.h>
     15#include <heapstring.h>
     16#include <ctype.h>
     17#include <wcstr.h>
     18#endif
    2619
    2720#include <string.h>
     
    3023#include <stdlib.h>
    3124#include <locale.h>
    32 #include <heapstring.h>
    33 #include <ctype.h>
    34 #include <wcstr.h>
    3525
    3626#include "windef.h"
     27#include "winbase.h"
    3728#include "wingdi.h"
    3829#include "winuser.h"
     
    4536#include "winerror.h"
    4637#include "debugtools.h"
    47 #include "main.h"
    48 
     38
     39#ifdef __WIN32OS2__
    4940#include <wctype.h>
    5041
     
    5243#include "dbglocal.h"
    5344
    54 /*****************************************************************************
    55  * Defines                                                                   *
    56  *****************************************************************************/
    57 
    5845ODINDEBUGCHANNEL(KERNEL32-OLE2NLS)
    59 
    60                 /* this define enables certain less important debug messages */
    61 //#define DEBUG_LOCAL 1
    62 
    63  
     46#endif
     47
     48DEFAULT_DEBUG_CHANNEL(string);
     49
    6450/* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA
    6551 * MUST contain all #defines from winnls.h
     
    179165static char *GetLocaleSubkeyName( DWORD lctype );
    180166
     167#ifndef __WIN32OS2__
     168/***********************************************************************
     169 *              GetUserDefaultLCID (KERNEL32.@)
     170 *              GetUserDefaultLCID (OLE2NLS.1)
     171 */
     172LCID WINAPI GetUserDefaultLCID(void)
     173{
     174        return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT );
     175}
     176
     177/***********************************************************************
     178 *              GetSystemDefaultLCID (KERNEL32.@)
     179 *              GetSystemDefaultLCID (OLE2NLS.2)
     180 */
     181LCID WINAPI GetSystemDefaultLCID(void)
     182{
     183        return GetUserDefaultLCID();
     184}
     185#endif //__WIN32OS2__
    181186
    182187#define NLS_MAX_LANGUAGES 20
     
    199204    char buf_en_language[128];
    200205
    201     dprintf2(("%04X\n", (UINT)LangID));
     206    TRACE("%04X\n", (UINT)LangID);
    202207    if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
    203208        return TRUE; /* continue search */
     
    348353    return l_data.found_lang_id[0];
    349354}
    350 
     355#ifndef __WIN32OS2__
    351356/***********************************************************************
    352  *         GetUserDefaultLangID       [KERNEL32.426]
     357 *              GetUserDefaultLangID (KERNEL32.@)
     358 *              GetUserDefaultLangID (OLE2NLS.3)
    353359 */
    354 #if 0
    355 // PH Note: this is better implemented in lang.cpp
    356360LANGID WINAPI GetUserDefaultLangID(void)
    357361{
     
    398402        return userLCID;
    399403}
    400 #endif
    401 
    402 /*****************************************************************************
    403  * Name      : LCID WIN32API ConvertDefaultLocale
    404  * Purpose   : The ConvertDefaultLocale function converts a special default
    405  *             locale value to an actual locale identifier.
    406  * Parameters: LCID Locale   special default locale value to be converted
    407  *             Value                   Description
    408  *             LOCALE_SYSTEM_DEFAULT   The system's default locale.
    409  *             LOCALE_USER_DEFAULT     The current user's default locale.
    410  *             zero                The language-neutral default locale.
    411  *                                     This is equivalent to the locale identifier
    412  *                                     created by calling the MAKELCID macro
    413  *                                     with a language identifier consisting
    414  *                                     of the LANG_NEUTRAL and SUBLANG_NEUTRAL
    415  *                                     values.
    416  *             Any sublanguage neutral default locale
    417  *                                     A locale identifier constructed by
    418  *                                     calling MAKELCID with a language
    419  *                                     identifier consisting of a primary
    420  *                                     language value, such as LANG_ENGLISH,
    421  *                                     and the SUBLANG_NEUTRAL value.
    422  *
    423  * Variables :
    424  * Result    : If the function succeeds, the return value is the appropriate
    425  *             actual locale identifier.
    426  *             If the function fails, the return value is the Locale parameter.
    427  *             The function fails when Locale is not one of the special
    428  *             default locale values listed above.
    429  * Remark    : A call to ConvertDefaultLocale(LOCALE_SYSTEM_DEFAULT)
    430  *              is equivalent to a call to GetSystemDefaultLCID.
    431  *             A call to ConvertDefaultLocale(LOCALE_USER_DEFAULT)
    432  *              is equivalent to a call to GetUserDefaultLCID.
    433  *
    434  * ConvertDefaultLocale [KERNEL32.147]
    435  *
    436  * Status    : UNTESTED STUB
    437  *
    438  * Author    : Markus Montkowski [Thu, 1998/05/19 11:46]
    439  *****************************************************************************/
    440 
     404
     405/***********************************************************************
     406 *              GetSystemDefaultLangID (KERNEL32.@)
     407 *              GetSystemDefaultLangID (OLE2NLS.4)
     408 */
     409LANGID WINAPI GetSystemDefaultLangID(void)
     410{
     411        return GetUserDefaultLangID();
     412}
     413#endif //__WIN32OS2__
     414/******************************************************************************
     415 *              ConvertDefaultLocale (KERNEL32.@)
     416 */
    441417LCID WINAPI ConvertDefaultLocale (LCID lcid)
    442418{       switch (lcid)
     
    471447    if(!hmem) return 0;
    472448   
     449#ifdef __WIN32OS2__
    473450    p = (WCHAR*)LockResource(hmem);
     451#else
     452    p = LockResource(hmem);
     453#endif
    474454    string_num = res_id & 0x000f;
    475455    for(i = 0; i < string_num; i++)
     
    489469
    490470    FreeResource(hmem);
    491     TRACE("\"%s\" loaded!\n", debugstr_w(buffer));
     471    TRACE("%s loaded!\n", debugstr_w(buffer));
    492472    return (i + 1);
    493473}
    494 
     474#ifndef __WIN32OS2__
     475/******************************************************************************
     476 *              GetLocaleInfoA (KERNEL32.@)
     477 *
     478 * NOTES
     479 *  LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT
     480 *
     481 *  MS online documentation states that the string returned is NULL terminated
     482 *  except for LOCALE_FONTSIGNATURE  which "will return a non-NULL
     483 *  terminated string".
     484 */
     485INT WINAPI GetLocaleInfoA(LCID lcid,LCTYPE LCType,LPSTR buf,INT len)
     486{
     487    LPCSTR  retString = NULL;
     488    int found = 0, i;
     489    char    *pacKey;
     490    char    acBuffer[128];
     491    DWORD   dwBufferSize=128;
     492    BOOL NoUserOverride;
     493
     494  TRACE("(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len);
     495
     496  if (len && (! buf) ) {
     497    SetLastError(ERROR_INSUFFICIENT_BUFFER);
     498                return 0;
     499        }
     500
     501        if (lcid == LOCALE_NEUTRAL || lcid == LANG_SYSTEM_DEFAULT)
     502        {
     503            lcid = GetSystemDefaultLCID();
     504        }
     505        else if (lcid == LANG_USER_DEFAULT) /*0x800*/
     506        {
     507            lcid = GetUserDefaultLCID();
     508        }
     509
     510    /* LOCALE_NOUSEROVERRIDE means: do not get user redefined settings
     511       from the registry. Instead, use system default values. */
     512    NoUserOverride = (LCType & LOCALE_NOUSEROVERRIDE) != 0;
     513
     514        LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
     515
     516    /* First, check if it's in the registry. */
     517    /* All user customized values are stored in the registry by SetLocaleInfo */
     518    if ( !NoUserOverride && (pacKey = GetLocaleSubkeyName(LCType)) )
     519    {
     520        char    acRealKey[128];
     521        HKEY    hKey;
     522
     523        sprintf( acRealKey, "Control Panel\\International\\%s", pacKey );
     524
     525        if ( RegOpenKeyExA( HKEY_CURRENT_USER, acRealKey,
     526                            0, KEY_READ, &hKey) == ERROR_SUCCESS )
     527        {
     528            if ( RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)acBuffer,
     529                                   &dwBufferSize ) == ERROR_SUCCESS )
     530            {
     531                retString = acBuffer;
     532                found = 1;
     533            }
     534            RegCloseKey(hKey);
     535        }
     536    }
     537
     538    /* If not in the registry, get it from the NLS entries. */
     539    if(!found) {
     540        WCHAR wcBuffer[128];
     541        int res_size;
     542
     543        /* check if language is registered in the kernel32 resources */
     544        if((res_size = NLS_LoadStringExW(GetModuleHandleA("KERNEL32"), LANGIDFROMLCID(lcid),
     545                LCType, wcBuffer, sizeof(wcBuffer)/sizeof(wcBuffer[0])))) {
     546            WideCharToMultiByte(CP_ACP, 0, wcBuffer, res_size, acBuffer, dwBufferSize, NULL, NULL);
     547            retString = acBuffer;
     548            found = 1;
     549        }
     550    }
     551
     552    /* if not found report a most descriptive error */
     553    if(!found) {
     554        retString=0;
     555        /* If we are through all of this, retLen should not be zero anymore.
     556           If it is, the value is not supported */
     557        i=0;
     558        while (locale_name2id[i].name!=NULL) {
     559            if (LCType == locale_name2id[i].id) {
     560                retString = locale_name2id[i].name;
     561                break;
     562            }
     563            i++;
     564        }
     565        if(!retString)
     566            FIXME("Unkown LC type %lX\n", LCType);
     567        else
     568            FIXME("'%s' is not defined for your language (%04X).\n"
     569                "Please define it in dlls/kernel/nls/YourLanguage.nls\n"
     570                "and submit patch for inclusion into the next Wine release.\n",
     571                        retString, LOWORD(lcid));
     572        SetLastError(ERROR_INVALID_PARAMETER);
     573        return 0;                       
     574    }
     575
     576    /* a FONTSIGNATURE is not a string, just 6 DWORDs  */
     577    if (LCType == LOCALE_FONTSIGNATURE) {
     578        if (len) {
     579            len = (len < sizeof(FONTSIGNATURE)) ? len : sizeof(FONTSIGNATURE);
     580            memcpy(buf, retString, len);
     581            return len;
     582        }
     583        return sizeof(FONTSIGNATURE);
     584    }
     585    /* if len=0 return only the length, don't touch the buffer*/
     586    if (len) {
     587        lstrcpynA(buf,retString,len);
     588        return strlen(buf) + 1;
     589    }
     590    return strlen(retString)+1;
     591}
     592
     593/******************************************************************************
     594 *              GetLocaleInfoW (KERNEL32.@)
     595 *
     596 * NOTES
     597 *  MS documentation states that len "specifies the size, in bytes (ANSI version)
     598 *  or characters (Unicode version), of" wbuf. Thus the number returned is
     599 *  the same between GetLocaleInfoW and GetLocaleInfoA.
     600 */
     601INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len)
     602{       WORD wlen;
     603        LPSTR abuf;
     604       
     605        if (len && (! wbuf) )
     606        { SetLastError(ERROR_INSUFFICIENT_BUFFER);
     607          return 0;
     608        }
     609
     610        abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len);
     611        wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
     612
     613        if (wlen && len)        /* if len=0 return only the length*/
     614            MultiByteToWideChar( CP_ACP, 0, abuf, -1, wbuf, len );
     615
     616        HeapFree(GetProcessHeap(),0,abuf);
     617        return wlen;
     618}
     619#endif //__WIN32OS2__
    495620
    496621/******************************************************************************
     
    626751 *              SetLocaleInfoA  [KERNEL32.656]
    627752 */
    628 BOOL16 WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
     753BOOL WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)
    629754{
    630755    HKEY    hKey;
     
    639764        {
    640765            if ( RegSetValueExA( hKey, NULL, 0, REG_SZ,
     766#ifdef __WIN32OS2__
    641767                                 (LPBYTE)data, strlen(data)+1 ) != ERROR_SUCCESS )
     768#else
     769                                 data, strlen(data)+1 ) != ERROR_SUCCESS )
     770#endif
    642771            {
    643772                ERR("SetLocaleInfoA: %s did not work\n", pacKey );
     
    653782}
    654783
    655 
     784#ifdef __WIN32OS2__
    656785/*****************************************************************************
    657786 * Name      : BOOL SetLocaleInfoW
     
    691820  return (FALSE);
    692821}
    693 
     822#endif
    694823
    695824/******************************************************************************
     
    13511480 *           VerLanguageNameA              [KERNEL32.709][VERSION.9]
    13521481 */
    1353 ODINFUNCTION3(DWORD,VerLanguageNameA,DWORD,  wLang,
    1354                                      LPSTR,  szLang,
    1355                                      DWORD,  nSize)
     1482DWORD WINAPI VerLanguageNameA( UINT wLang, LPSTR szLang, UINT nSize )
    13561483{
    13571484    if(!szLang)
     
    13641491 *           VerLanguageNameW              [KERNEL32.710][VERSION.10]
    13651492 */
    1366 ODINFUNCTION3(DWORD,VerLanguageNameW,DWORD,  wLang,
    1367                                      LPWSTR, szLang,
    1368                                      DWORD,  nSize)
     1493DWORD WINAPI VerLanguageNameW( UINT wLang, LPWSTR szLang, UINT nSize )
    13691494{
    13701495    if(!szLang)
     
    17981923     for which it returns true are ignored when mapping a
    17991924     string with NORM_IGNORESYMBOLS */
    1800   //return ( (c!=0) && !O32_IsCharAlphaNumericA(c) );
     1925#ifdef __WIN32OS2__
    18011926  return ( (c!=0) && !iswalpha((wint_t)c) );
     1927#else
     1928  return ( (c!=0) && !IsCharAlphaNumericA(c) );
     1929#endif
    18021930}
    18031931
     
    18051933 *              identity        [Internal]
    18061934 */
     1935#ifdef __WIN32OS2__
    18071936static int _Optlink identity(int c)
     1937#else
     1938static int identity(int c)
     1939#endif
    18081940{
    18091941  return c;
     
    18361968 *    so there is nothing to be done for this flag.
    18371969 */
    1838 
    1839 typedef int (* _Optlink PFNCONVERSION)(int);
    1840 
    1841 
     1970#ifdef __WIN32OS2__
     1971ODINFUNCTION6(INT, LCMapStringA,
     1972        LCID, lcid,      /* [in] locale identifier created with MAKELCID;
     1973                                LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
     1974                                predefined values. */
     1975        DWORD, mapflags, /* [in] flags */
     1976        LPCSTR, srcstr,  /* [in] source buffer */
     1977        INT, srclen,     /* [in] source length */
     1978        LPSTR, dststr,   /* [out] destination buffer */
     1979        INT, dstlen)     /* [in] destination buffer length */
     1980#else
    18421981INT WINAPI LCMapStringA(
    1843         LCID lcid /* locale identifier created with MAKELCID;
    1844                      LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
    1845                      predefined values. */,
    1846         DWORD mapflags /* flags */,
    1847         LPCSTR srcstr  /* source buffer */,
    1848         INT srclen   /* source length */,
    1849         LPSTR dststr   /* destination buffer */,
    1850         INT dstlen   /* destination buffer length */)
     1982        LCID lcid,      /* [in] locale identifier created with MAKELCID;
     1983                                LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are
     1984                                predefined values. */
     1985        DWORD mapflags, /* [in] flags */
     1986        LPCSTR srcstr,  /* [in] source buffer */
     1987        INT srclen,     /* [in] source length */
     1988        LPSTR dststr,   /* [out] destination buffer */
     1989        INT dstlen)     /* [in] destination buffer length */
     1990#endif
    18511991{
    18521992  int i;
    18531993
    1854   dprintf2(("LCMapStringA: (0x%04lx,0x%08lx,%s,%d,%p,%d)",
    1855         lcid,mapflags,srcstr,srclen,dststr,dstlen));
     1994  TRACE("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n",
     1995        lcid,mapflags,srcstr,srclen,dststr,dstlen);
    18561996
    18571997  if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) )
     
    18722012                                        NORM_IGNOREWIDTH    | \
    18732013                                        NORM_IGNOREKANATYPE)
    1874   /* FIXME: as long as we don't support Kanakana nor Hirigana
     2014  /* FIXME: as long as we don't support Katakana nor Hiragana
    18752015   * characters, we can support NORM_IGNOREKANATYPE
    18762016   */
     
    18922032  {
    18932033    int i,j;
    1894     // int (*f)(int) = identity;
    1895     PFNCONVERSION f = identity;
     2034#ifdef __WIN32OS2__
     2035    int (* _Optlink f)(int) = identity;
     2036#else
     2037    int (* f)(int) = identity;
     2038#endif
    18962039    int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE;
    18972040    int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS;
     
    20302173        if (!flag_stringsort && OLE2NLS_isPunctuation(source_char))
    20312174        {
    2032           UINT16 encrypted_location = (1<<15) + 7 + 4*count;
     2175          WORD encrypted_location = (1<<15) + 7 + 4*count;
    20332176          *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8);
    20342177          *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255);
     
    20862229 * See LCMapStringA for documentation
    20872230 */
     2231#ifdef __WIN32OS2__
     2232ODINFUNCTION6(INT, LCMapStringW,
     2233        LCID, lcid,DWORD, mapflags,LPCWSTR, srcstr,INT, srclen,LPWSTR, dststr,
     2234        INT, dstlen)
     2235#else
    20882236INT WINAPI LCMapStringW(
    20892237        LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr,
    20902238        INT dstlen)
     2239#endif
    20912240{
    20922241  int i;
     
    23552504  else
    23562505  {
    2357     //int (*f)(int)=identity;
    2358     PFNCONVERSION f = identity;
     2506#ifdef __WIN32OS2__
     2507    int (* _Optlink f)(int) = identity;
     2508#else
     2509    int (*f)(int)=identity;
     2510#endif
    23592511
    23602512    if (dstlen==0)
     
    24212573 */
    24222574UINT WINAPI CompareStringA(
    2423     DWORD lcid,     /* locale ID */
    2424     DWORD fdwStyle, /* comparison-style options */
    2425     LPCSTR s1,      /* first string */
    2426     DWORD l1,       /* length of first string */
    2427     LPCSTR s2,      /* second string */
    2428     DWORD l2)       /* length of second string */
     2575    DWORD lcid,     /* [in] locale ID */
     2576    DWORD fdwStyle, /* [in] comparison-style options */
     2577    LPCSTR s1,      /* [in] first string */
     2578    DWORD l1,       /* [in] length of first string */
     2579    LPCSTR s2,      /* [in] second string */
     2580    DWORD l2)       /* [in] length of second string */
    24292581{
    24302582  int mapstring_flags;
     
    24322584  int result;
    24332585  LPSTR sk1,sk2;
    2434   dprintf2(("%s and %s\n",
    2435         debugstr_a (s1), debugstr_a (s2)));
     2586  TRACE("%s and %s\n",
     2587        debugstr_a (s1), debugstr_a (s2));
    24362588
    24372589  if ( (s1==NULL) || (s2==NULL) )
     
    25012653        ret = (fdwStyle & NORM_IGNORECASE) ? strncmpiW(s1,s2,len) : strncmpW(s1,s2,len);
    25022654        /* not equal, return 1 or 3 */
    2503         if(ret!=0) return ret+2;
     2655        if(ret!=0) {
     2656                /* need to translate result */
     2657                return ((int)ret < 0) ? 1 : 3;
     2658        }
    25042659        /* same len, return 2 */
    25052660        if(l1==l2) return 2;
     
    25632718
    25642719   /* report, for debugging */
    2565    TRACE("(0x%lx,0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
     2720   TRACE("(0x%lx,0x%lx, 0x%lx, time(y=%d m=%d wd=%d d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n",
    25662721         locale, flags, tflags,
    2567          xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
     2722         xtime->wYear,xtime->wMonth,xtime->wDayOfWeek,xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond,
    25682723         _format, _format, date, datelen);
    25692724 
     
    26202775      } else if (  (count && (format[inpos] != type))
    26212776                   || count == 4
    2622                    || (count == 2 && strchr("ghHmst", type)) )
    2623        {
    2624             if         (type == 'd') {
    2625                if        (count == 4) {
     2777                   || (count == 2 && strchr("ghHmst", type)) ) {
     2778            if (type == 'h' && (tflags & TIME_FORCE24HOURFORMAT)) type= 'H';
     2779            if (type == 'd') {
     2780               if (count == 4) {
    26262781                  GetLocaleInfoA(locale,
    26272782                                   LOCALE_SDAYNAME1
    2628                                    + xtime->wDayOfWeek - 1,
     2783                                   + (xtime->wDayOfWeek+6)%7,
    26292784                                   buf, sizeof(buf));
    26302785               } else if (count == 3) {
    26312786                           GetLocaleInfoA(locale,
    26322787                                            LOCALE_SABBREVDAYNAME1
    2633                                             + xtime->wDayOfWeek - 1,
     2788                                            + (xtime->wDayOfWeek+6)%7,
    26342789                                            buf, sizeof(buf));
    26352790                      } else {
     
    26782833               sprintf(buf, dgfmt[count], xtime->wSecond);
    26792834            } else if (type == 't') {
    2680                if        (count == 1) {
     2835               if ((tflags & TIME_NOTIMEMARKER))
     2836                  buf[0]='\0';
     2837               else if (count == 1) {
    26812838                  sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P');
    2682                } else if (count == 2) {
    2683                   /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
    2684                   GetLocaleInfoA(locale,
    2685                                    (xtime->wHour<12)
    2686                                    ? LOCALE_S1159 : LOCALE_S2359,
    2687                                    buf, sizeof(buf));
    2688                }
     2839               } else if (count == 2) {
     2840                 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */
     2841                  GetLocaleInfoA(locale,
     2842                           (xtime->wHour<12)
     2843                           ? LOCALE_S1159 : LOCALE_S2359,
     2844                           buf, sizeof(buf));
     2845               }
    26892846            };
    26902847
     
    27482905   date[outpos] = '\0';
    27492906   
    2750    TRACE("OLE_GetFormatA returns string '%s', len %d\n",
    2751                date, outpos);
     2907   TRACE("returns string '%s', len %d\n", date, outpos);
    27522908   return outpos;
    27532909}
     
    27642920   int     count, type=0, inquote;
    27652921   int     Overflow; /* loop check */
     2922   char    tmp[16];
    27662923   WCHAR   buf[40];
    27672924   int     buflen=0;
     
    28272984                        (count==2 && type =='s') ||
    28282985                        (count==2 && type =='t') )  ) {
    2829          if        (type == 'd') {
    2830             if        (count == 3) {
     2986          switch(type)
     2987          {
     2988          case 'd':
     2989            if        (count == 4) {
    28312990               GetLocaleInfoW(locale,
    2832                              LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,
     2991                             LOCALE_SDAYNAME1 + (xtime->wDayOfWeek +6)%7,
    28332992                             buf, sizeof(buf)/sizeof(WCHAR) );
    28342993            } else if (count == 3) {
    28352994               GetLocaleInfoW(locale,
    28362995                                LOCALE_SABBREVDAYNAME1 +
    2837                                 xtime->wDayOfWeek -1,
     2996                                (xtime->wDayOfWeek +6)%7,
    28382997                                buf, sizeof(buf)/sizeof(WCHAR) );
    28392998            } else {
    2840                wsnprintfW(buf, 5, argarr[count], xtime->wDay );
    2841             };
    2842          } else if (type == 'M') {
     2999                sprintf( tmp, "%.*d", count, xtime->wDay );
     3000                MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3001            }
     3002            break;
     3003
     3004          case 'M':
    28433005            if        (count == 4) {
    28443006               GetLocaleInfoW(locale,  LOCALE_SMONTHNAME1 +
     
    28503012                                sizeof(buf)/sizeof(WCHAR) );
    28513013            } else {
    2852                wsnprintfW(buf, 5, argarr[count], xtime->wMonth);
     3014                sprintf( tmp, "%.*d", count, xtime->wMonth );
     3015                MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
    28533016            }
    2854          } else if (type == 'y') {
     3017            break;
     3018          case 'y':
    28553019            if        (count == 4) {
    2856                wsnprintfW(buf, 6, argarr[1] /* "%d" */,
    2857                          xtime->wYear);
     3020                sprintf( tmp, "%d", xtime->wYear );
    28583021            } else if (count == 3) {
    2859                lstrcpynAtoW(buf, "yyy", 5);
     3022                strcpy( tmp, "yyy" );
    28603023            } else {
    2861                wsnprintfW(buf, 6, argarr[count],
    2862                             xtime->wYear % 100);
     3024                sprintf( tmp, "%.*d", count, xtime->wYear % 100 );
    28633025            }
    2864          } else if (type == 'g') {
     3026            MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3027            break;
     3028
     3029          case 'g':
    28653030            if        (count == 2) {
    28663031               FIXME("LOCALE_ICALENDARTYPE unimplemented\n");
    2867                lstrcpynAtoW(buf, "AD", 5);
     3032               strcpy( tmp, "AD" );
    28683033            } else {
    28693034               /* Win API sez we copy it verbatim */
    2870                lstrcpynAtoW(buf, "g", 5);
     3035                strcpy( tmp, "g" );
    28713036            }
    2872          } else if (type == 'h') {
    2873             /* hours 1:00-12:00 --- is this right? */
    2874             wsnprintfW(buf, 5, argarr[count],
    2875                          (xtime->wHour-1)%12 +1);
    2876          } else if (type == 'H') {
    2877             wsnprintfW(buf, 5, argarr[count],
    2878                          xtime->wHour);
    2879          } else if (type == 'm' ) {
    2880             wsnprintfW(buf, 5, argarr[count],
    2881                          xtime->wMinute);
    2882          } else if (type == 's' ) {
    2883             wsnprintfW(buf, 5, argarr[count],
    2884                          xtime->wSecond);
    2885          } else if (type == 't') {
     3037            MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3038            break;
     3039
     3040          case 'h':
     3041              /* hours 1:00-12:00 --- is this right? */
     3042              sprintf( tmp, "%.*d", count, (xtime->wHour-1)%12 +1);
     3043              MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3044              break;
     3045
     3046          case 'H':
     3047              sprintf( tmp, "%.*d", count, xtime->wHour );
     3048              MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3049              break;
     3050
     3051          case 'm':
     3052              sprintf( tmp, "%.*d", count, xtime->wMinute );
     3053              MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3054              break;
     3055
     3056          case 's':
     3057              sprintf( tmp, "%.*d", count, xtime->wSecond );
     3058              MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) );
     3059              break;
     3060
     3061          case 't':
    28863062            GetLocaleInfoW(locale, (xtime->wHour < 12) ?
    28873063                             LOCALE_S1159 : LOCALE_S2359,
     
    28903066               buf[1] = 0;
    28913067            }
    2892 }
     3068            break;
     3069          }
    28933070
    28943071         /* no matter what happened,  we need to check this next
     
    29813158 */
    29823159INT WINAPI GetDateFormatA(LCID locale,DWORD flags,
    2983                           CONST SYSTEMTIME * xtime,
    2984                           LPCSTR format, LPSTR date,INT datelen)
     3160                              LPSYSTEMTIME xtime,
     3161                              LPCSTR format, LPSTR date,INT datelen)
    29853162{
    29863163   
     
    29913168  LCID thislocale;
    29923169  INT ret;
     3170  FILETIME ft;
     3171  BOOL res;
    29933172
    29943173  TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",
     
    30093188  if (xtime == NULL) {
    30103189     GetSystemTime(&t);
    3011      thistime = &t;
    30123190  } else {
    3013      thistime = (SYSTEMTIME *)xtime;
     3191      /* Silently correct wDayOfWeek by tranforming to FileTime and back again*/
     3192      res=SystemTimeToFileTime(xtime,&ft);
     3193      /* Check year(?)/month and date for range and set ERROR_INVALID_PARAMETER  on error*/
     3194      /*FIXME: SystemTimeToFileTime doesn't yet do that ckeck*/
     3195      if(!res)
     3196        {
     3197          SetLastError(ERROR_INVALID_PARAMETER);
     3198          return 0;
     3199        }
     3200      FileTimeToSystemTime(&ft,&t);
     3201     
    30143202  };
     3203  thistime = &t;
    30153204
    30163205  if (format == NULL) {
     
    30443233 */
    30453234INT WINAPI GetDateFormatW(LCID locale,DWORD flags,
    3046                           CONST SYSTEMTIME *xtime,
    3047                           LPCWSTR format,
    3048                           LPWSTR date, INT datelen)
     3235                              LPSYSTEMTIME xtime,
     3236                              LPCWSTR format,
     3237                              LPWSTR date, INT datelen)
    30493238{
    30503239   unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0};
     
    37803969
    37813970/**************************************************************************
    3782  *              GetNumberFormatW        (KERNEL32.xxx)
     3971 *              GetNumberFormatW        (KERNEL32.@)
    37833972 */
    37843973INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags,
     
    40834272 */
    40844273INT WINAPI
    4085 GetTimeFormatA(LCID locale,        /* in  */
    4086                  DWORD flags,        /* in  */
    4087                  CONST SYSTEMTIME *xtime, /* in  */
    4088                  LPCSTR format,      /* in  */
    4089                  LPSTR timestr,      /* out */
    4090                  INT timelen       /* in  */)
     4274GetTimeFormatA(LCID locale,        /* [in]  */
     4275               DWORD flags,        /* [in]  */
     4276               LPSYSTEMTIME xtime, /* [in]  */
     4277               LPCSTR format,      /* [in]  */
     4278               LPSTR timestr,      /* [out] */
     4279               INT timelen         /* [in]  */)
    40914280{ char format_buf[40];
    40924281  LPCSTR thisformat;
     
    41004289
    41014290  thislocale = OLE2NLS_CheckLocale ( locale );
    4102 
    4103   if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
    4104   { FIXME("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
    4105   }
    4106  
    4107   flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
    41084291
    41094292  if (format == NULL)
     
    41234306  }
    41244307  else
    4125   { thistime = (SYSTEMTIME *)xtime;
     4308  { thistime = xtime;
     4309  /* Check that hour,min and sec is in range */
    41264310  }
    41274311  ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat,
     
    41364320 */
    41374321INT WINAPI
    4138 GetTimeFormatW(LCID locale,        /* in  */
    4139                  DWORD flags,        /* in  */
    4140                  CONST SYSTEMTIME *xtime, /* in  */
    4141                  LPCWSTR format,     /* in  */
    4142                  LPWSTR timestr,     /* out */
    4143                  INT timelen       /* in  */)
     4322GetTimeFormatW(LCID locale,        /* [in]  */
     4323               DWORD flags,        /* [in]  */
     4324               LPSYSTEMTIME xtime, /* [in]  */
     4325               LPCWSTR format,     /* [in]  */
     4326               LPWSTR timestr,     /* [out] */
     4327               INT timelen         /* [in]  */)
    41444328{       WCHAR format_buf[40];
    41454329        LPCWSTR thisformat;
     
    41544338
    41554339        thislocale = OLE2NLS_CheckLocale ( locale );
    4156 
    4157         if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
    4158         { FIXME("TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n");
    4159         }
    4160  
    4161         flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/
    41624340
    41634341        if (format == NULL)
     
    41734351 
    41744352        if (xtime == NULL) /* NULL means use the current local time*/
    4175         { GetSystemTime(&t);
     4353        { GetLocalTime(&t);
    41764354          thistime = &t;
    41774355        }
    41784356        else
    4179         { thistime = (SYSTEMTIME *)xtime;;
     4357        { thistime = xtime;
    41804358        }
    41814359
     
    41854363}
    41864364
    4187 
    4188 /*****************************************************************************
    4189  * Name      : BOOL WIN32API EnumCalendarInfoA
    4190  * Purpose   : The EnumCalendarInfoA function enumerates calendar information
    4191  *             for a specified locale. The CalType parameter specifies the type
    4192  *             of calendar information to enumerate. The function returns the
    4193  *             specified calendar information for all applicable calendars for
    4194  *             the locale, or for a single requested calendar, depending on the
    4195  *             value of the Calendar parameter.
    4196  *             The EnumCalendarInfo function enumerates the calendar information
    4197  *             by calling an application-defined callback function. It passes
    4198  *             the callback function a pointer to a string buffer containing
    4199  *             the requested calendar information. This continues until either
    4200  *             the last applicable calendar is found or the callback function
    4201  *             returns FALSE.
    4202  * Parameters: CALINFO_ENUMPROCA lpCalInfoEnumProc  pointer to enumeration
    4203  *                                                  callback function
    4204  *             LCID Locale      locale whose calendar information is of interest
    4205  *             CALID Calendar   calendar whose information is of interest
    4206  *             CALTYPE CalType  type of calendar information of interest
    4207  * Variables :
    4208  * Result    : If the function succeeds, the return value is nonzero.
    4209  *             If the function fails, the return value is zero
    4210  *
    4211  * Remark    :  EnumCalendarInfoA       [KERNEL32.196]
    4212  *
    4213  * Status    : UNTESTED STUB
    4214  *
    4215  * Author    : Markus Montkowski [Tha, 1998/05/21 17:46]
    4216  *****************************************************************************/
    4217 
    4218 BOOL WINAPI EnumCalendarInfoA(CALINFO_ENUMPROCA calinfoproc,
    4219                               LCID locale,
    4220                               CALID calendar,
    4221                               CALTYPE caltype)
    4222 {
    4223   FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",
    4224         calinfoproc,
    4225         locale,
    4226         calendar,
    4227         caltype);
    4228   return FALSE;
    4229 }
    4230 
    4231 
     4365/******************************************************************************
     4366 *              EnumCalendarInfoA       [KERNEL32.196]
     4367 */
     4368BOOL WINAPI EnumCalendarInfoA(
     4369        CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype
     4370) {
     4371        FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype);
     4372        return FALSE;
     4373}
     4374
     4375#ifdef __WIN32OS2__
    42324376/*****************************************************************************
    42334377 * Name      : BOOL WIN32API EnumCalendarInfoW
     
    42734417  return (FALSE);
    42744418}
     4419#endif
Note: See TracChangeset for help on using the changeset viewer.