- Timestamp:
- May 18, 2001, 10:15:02 PM (24 years ago)
- 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 3 1 /* 4 2 * National Language Support library … … 7 5 * Copyright 1998 David Lee Lambert 8 6 * Copyright 2000 Julio César Gázquez 9 * Copyright 2000 Patrick Haller10 *11 *12 * Project Odin Software License can be found in LICENSE.TXT13 *14 7 */ 15 8 16 17 /***************************************************************************** 18 * Includes * 19 *****************************************************************************/ 20 9 #ifdef __WIN32OS2__ 21 10 #include <odin.h> 22 11 #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 26 19 27 20 #include <string.h> … … 30 23 #include <stdlib.h> 31 24 #include <locale.h> 32 #include <heapstring.h>33 #include <ctype.h>34 #include <wcstr.h>35 25 36 26 #include "windef.h" 27 #include "winbase.h" 37 28 #include "wingdi.h" 38 29 #include "winuser.h" … … 45 36 #include "winerror.h" 46 37 #include "debugtools.h" 47 #include "main.h" 48 38 39 #ifdef __WIN32OS2__ 49 40 #include <wctype.h> 50 41 … … 52 43 #include "dbglocal.h" 53 44 54 /*****************************************************************************55 * Defines *56 *****************************************************************************/57 58 45 ODINDEBUGCHANNEL(KERNEL32-OLE2NLS) 59 60 /* this define enables certain less important debug messages */ 61 //#define DEBUG_LOCAL 1 62 63 46 #endif 47 48 DEFAULT_DEBUG_CHANNEL(string); 49 64 50 /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA 65 51 * MUST contain all #defines from winnls.h … … 179 165 static char *GetLocaleSubkeyName( DWORD lctype ); 180 166 167 #ifndef __WIN32OS2__ 168 /*********************************************************************** 169 * GetUserDefaultLCID (KERNEL32.@) 170 * GetUserDefaultLCID (OLE2NLS.1) 171 */ 172 LCID WINAPI GetUserDefaultLCID(void) 173 { 174 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT ); 175 } 176 177 /*********************************************************************** 178 * GetSystemDefaultLCID (KERNEL32.@) 179 * GetSystemDefaultLCID (OLE2NLS.2) 180 */ 181 LCID WINAPI GetSystemDefaultLCID(void) 182 { 183 return GetUserDefaultLCID(); 184 } 185 #endif //__WIN32OS2__ 181 186 182 187 #define NLS_MAX_LANGUAGES 20 … … 199 204 char buf_en_language[128]; 200 205 201 dprintf2(("%04X\n", (UINT)LangID));206 TRACE("%04X\n", (UINT)LangID); 202 207 if(PRIMARYLANGID(LangID) == LANG_NEUTRAL) 203 208 return TRUE; /* continue search */ … … 348 353 return l_data.found_lang_id[0]; 349 354 } 350 355 #ifndef __WIN32OS2__ 351 356 /*********************************************************************** 352 * GetUserDefaultLangID [KERNEL32.426] 357 * GetUserDefaultLangID (KERNEL32.@) 358 * GetUserDefaultLangID (OLE2NLS.3) 353 359 */ 354 #if 0355 // PH Note: this is better implemented in lang.cpp356 360 LANGID WINAPI GetUserDefaultLangID(void) 357 361 { … … 398 402 return userLCID; 399 403 } 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 */ 409 LANGID WINAPI GetSystemDefaultLangID(void) 410 { 411 return GetUserDefaultLangID(); 412 } 413 #endif //__WIN32OS2__ 414 /****************************************************************************** 415 * ConvertDefaultLocale (KERNEL32.@) 416 */ 441 417 LCID WINAPI ConvertDefaultLocale (LCID lcid) 442 418 { switch (lcid) … … 471 447 if(!hmem) return 0; 472 448 449 #ifdef __WIN32OS2__ 473 450 p = (WCHAR*)LockResource(hmem); 451 #else 452 p = LockResource(hmem); 453 #endif 474 454 string_num = res_id & 0x000f; 475 455 for(i = 0; i < string_num; i++) … … 489 469 490 470 FreeResource(hmem); 491 TRACE(" \"%s\"loaded!\n", debugstr_w(buffer));471 TRACE("%s loaded!\n", debugstr_w(buffer)); 492 472 return (i + 1); 493 473 } 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 */ 485 INT 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 */ 601 INT 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__ 495 620 496 621 /****************************************************************************** … … 626 751 * SetLocaleInfoA [KERNEL32.656] 627 752 */ 628 BOOL 16WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data)753 BOOL WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data) 629 754 { 630 755 HKEY hKey; … … 639 764 { 640 765 if ( RegSetValueExA( hKey, NULL, 0, REG_SZ, 766 #ifdef __WIN32OS2__ 641 767 (LPBYTE)data, strlen(data)+1 ) != ERROR_SUCCESS ) 768 #else 769 data, strlen(data)+1 ) != ERROR_SUCCESS ) 770 #endif 642 771 { 643 772 ERR("SetLocaleInfoA: %s did not work\n", pacKey ); … … 653 782 } 654 783 655 784 #ifdef __WIN32OS2__ 656 785 /***************************************************************************** 657 786 * Name : BOOL SetLocaleInfoW … … 691 820 return (FALSE); 692 821 } 693 822 #endif 694 823 695 824 /****************************************************************************** … … 1351 1480 * VerLanguageNameA [KERNEL32.709][VERSION.9] 1352 1481 */ 1353 ODINFUNCTION3(DWORD,VerLanguageNameA,DWORD, wLang, 1354 LPSTR, szLang, 1355 DWORD, nSize) 1482 DWORD WINAPI VerLanguageNameA( UINT wLang, LPSTR szLang, UINT nSize ) 1356 1483 { 1357 1484 if(!szLang) … … 1364 1491 * VerLanguageNameW [KERNEL32.710][VERSION.10] 1365 1492 */ 1366 ODINFUNCTION3(DWORD,VerLanguageNameW,DWORD, wLang, 1367 LPWSTR, szLang, 1368 DWORD, nSize) 1493 DWORD WINAPI VerLanguageNameW( UINT wLang, LPWSTR szLang, UINT nSize ) 1369 1494 { 1370 1495 if(!szLang) … … 1798 1923 for which it returns true are ignored when mapping a 1799 1924 string with NORM_IGNORESYMBOLS */ 1800 //return ( (c!=0) && !O32_IsCharAlphaNumericA(c) ); 1925 #ifdef __WIN32OS2__ 1801 1926 return ( (c!=0) && !iswalpha((wint_t)c) ); 1927 #else 1928 return ( (c!=0) && !IsCharAlphaNumericA(c) ); 1929 #endif 1802 1930 } 1803 1931 … … 1805 1933 * identity [Internal] 1806 1934 */ 1935 #ifdef __WIN32OS2__ 1807 1936 static int _Optlink identity(int c) 1937 #else 1938 static int identity(int c) 1939 #endif 1808 1940 { 1809 1941 return c; … … 1836 1968 * so there is nothing to be done for this flag. 1837 1969 */ 1838 1839 typedef int (* _Optlink PFNCONVERSION)(int); 1840 1841 1970 #ifdef __WIN32OS2__ 1971 ODINFUNCTION6(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 1842 1981 INT 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 1851 1991 { 1852 1992 int i; 1853 1993 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); 1856 1996 1857 1997 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) ) … … 1872 2012 NORM_IGNOREWIDTH | \ 1873 2013 NORM_IGNOREKANATYPE) 1874 /* FIXME: as long as we don't support Ka nakana nor Hirigana2014 /* FIXME: as long as we don't support Katakana nor Hiragana 1875 2015 * characters, we can support NORM_IGNOREKANATYPE 1876 2016 */ … … 1892 2032 { 1893 2033 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 1896 2039 int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE; 1897 2040 int flag_ignoresymbols = mapflags & NORM_IGNORESYMBOLS; … … 2030 2173 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char)) 2031 2174 { 2032 UINT16encrypted_location = (1<<15) + 7 + 4*count;2175 WORD encrypted_location = (1<<15) + 7 + 4*count; 2033 2176 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8); 2034 2177 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255); … … 2086 2229 * See LCMapStringA for documentation 2087 2230 */ 2231 #ifdef __WIN32OS2__ 2232 ODINFUNCTION6(INT, LCMapStringW, 2233 LCID, lcid,DWORD, mapflags,LPCWSTR, srcstr,INT, srclen,LPWSTR, dststr, 2234 INT, dstlen) 2235 #else 2088 2236 INT WINAPI LCMapStringW( 2089 2237 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr, 2090 2238 INT dstlen) 2239 #endif 2091 2240 { 2092 2241 int i; … … 2355 2504 else 2356 2505 { 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 2359 2511 2360 2512 if (dstlen==0) … … 2421 2573 */ 2422 2574 UINT 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 */ 2429 2581 { 2430 2582 int mapstring_flags; … … 2432 2584 int result; 2433 2585 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)); 2436 2588 2437 2589 if ( (s1==NULL) || (s2==NULL) ) … … 2501 2653 ret = (fdwStyle & NORM_IGNORECASE) ? strncmpiW(s1,s2,len) : strncmpW(s1,s2,len); 2502 2654 /* 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 } 2504 2659 /* same len, return 2 */ 2505 2660 if(l1==l2) return 2; … … 2563 2718 2564 2719 /* 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", 2566 2721 locale, flags, tflags, 2567 xtime->w Day, xtime->wHour, xtime->wMinute, xtime->wSecond,2722 xtime->wYear,xtime->wMonth,xtime->wDayOfWeek,xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond, 2568 2723 _format, _format, date, datelen); 2569 2724 … … 2620 2775 } else if ( (count && (format[inpos] != type)) 2621 2776 || count == 4 2622 || (count == 2 && strchr("ghHmst", type)) ) 2623 { 2624 if 2625 if 2777 || (count == 2 && strchr("ghHmst", type)) ) { 2778 if (type == 'h' && (tflags & TIME_FORCE24HOURFORMAT)) type= 'H'; 2779 if (type == 'd') { 2780 if (count == 4) { 2626 2781 GetLocaleInfoA(locale, 2627 2782 LOCALE_SDAYNAME1 2628 + xtime->wDayOfWeek - 1,2783 + (xtime->wDayOfWeek+6)%7, 2629 2784 buf, sizeof(buf)); 2630 2785 } else if (count == 3) { 2631 2786 GetLocaleInfoA(locale, 2632 2787 LOCALE_SABBREVDAYNAME1 2633 + xtime->wDayOfWeek - 1,2788 + (xtime->wDayOfWeek+6)%7, 2634 2789 buf, sizeof(buf)); 2635 2790 } else { … … 2678 2833 sprintf(buf, dgfmt[count], xtime->wSecond); 2679 2834 } else if (type == 't') { 2680 if (count == 1) { 2835 if ((tflags & TIME_NOTIMEMARKER)) 2836 buf[0]='\0'; 2837 else if (count == 1) { 2681 2838 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P'); 2682 2683 2684 2685 2686 2687 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 } 2689 2846 }; 2690 2847 … … 2748 2905 date[outpos] = '\0'; 2749 2906 2750 TRACE("OLE_GetFormatA returns string '%s', len %d\n", 2751 date, outpos); 2907 TRACE("returns string '%s', len %d\n", date, outpos); 2752 2908 return outpos; 2753 2909 } … … 2764 2920 int count, type=0, inquote; 2765 2921 int Overflow; /* loop check */ 2922 char tmp[16]; 2766 2923 WCHAR buf[40]; 2767 2924 int buflen=0; … … 2827 2984 (count==2 && type =='s') || 2828 2985 (count==2 && type =='t') ) ) { 2829 if (type == 'd') { 2830 if (count == 3) { 2986 switch(type) 2987 { 2988 case 'd': 2989 if (count == 4) { 2831 2990 GetLocaleInfoW(locale, 2832 LOCALE_SDAYNAME1 + xtime->wDayOfWeek -1,2991 LOCALE_SDAYNAME1 + (xtime->wDayOfWeek +6)%7, 2833 2992 buf, sizeof(buf)/sizeof(WCHAR) ); 2834 2993 } else if (count == 3) { 2835 2994 GetLocaleInfoW(locale, 2836 2995 LOCALE_SABBREVDAYNAME1 + 2837 xtime->wDayOfWeek -1,2996 (xtime->wDayOfWeek +6)%7, 2838 2997 buf, sizeof(buf)/sizeof(WCHAR) ); 2839 2998 } 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': 2843 3005 if (count == 4) { 2844 3006 GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 + … … 2850 3012 sizeof(buf)/sizeof(WCHAR) ); 2851 3013 } 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) ); 2853 3016 } 2854 } else if (type == 'y') { 3017 break; 3018 case 'y': 2855 3019 if (count == 4) { 2856 wsnprintfW(buf, 6, argarr[1] /* "%d" */, 2857 xtime->wYear); 3020 sprintf( tmp, "%d", xtime->wYear ); 2858 3021 } else if (count == 3) { 2859 lstrcpynAtoW(buf, "yyy", 5);3022 strcpy( tmp, "yyy" ); 2860 3023 } else { 2861 wsnprintfW(buf, 6, argarr[count], 2862 xtime->wYear % 100); 3024 sprintf( tmp, "%.*d", count, xtime->wYear % 100 ); 2863 3025 } 2864 } else if (type == 'g') { 3026 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) ); 3027 break; 3028 3029 case 'g': 2865 3030 if (count == 2) { 2866 3031 FIXME("LOCALE_ICALENDARTYPE unimplemented\n"); 2867 lstrcpynAtoW(buf, "AD", 5);3032 strcpy( tmp, "AD" ); 2868 3033 } else { 2869 3034 /* Win API sez we copy it verbatim */ 2870 lstrcpynAtoW(buf, "g", 5);3035 strcpy( tmp, "g" ); 2871 3036 } 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': 2886 3062 GetLocaleInfoW(locale, (xtime->wHour < 12) ? 2887 3063 LOCALE_S1159 : LOCALE_S2359, … … 2890 3066 buf[1] = 0; 2891 3067 } 2892 } 3068 break; 3069 } 2893 3070 2894 3071 /* no matter what happened, we need to check this next … … 2981 3158 */ 2982 3159 INT WINAPI GetDateFormatA(LCID locale,DWORD flags, 2983 CONST SYSTEMTIME *xtime,2984 3160 LPSYSTEMTIME xtime, 3161 LPCSTR format, LPSTR date,INT datelen) 2985 3162 { 2986 3163 … … 2991 3168 LCID thislocale; 2992 3169 INT ret; 3170 FILETIME ft; 3171 BOOL res; 2993 3172 2994 3173 TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n", … … 3009 3188 if (xtime == NULL) { 3010 3189 GetSystemTime(&t); 3011 thistime = &t;3012 3190 } 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 3014 3202 }; 3203 thistime = &t; 3015 3204 3016 3205 if (format == NULL) { … … 3044 3233 */ 3045 3234 INT WINAPI GetDateFormatW(LCID locale,DWORD flags, 3046 CONST SYSTEMTIME *xtime,3047 3048 3235 LPSYSTEMTIME xtime, 3236 LPCWSTR format, 3237 LPWSTR date, INT datelen) 3049 3238 { 3050 3239 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0}; … … 3780 3969 3781 3970 /************************************************************************** 3782 * GetNumberFormatW (KERNEL32. xxx)3971 * GetNumberFormatW (KERNEL32.@) 3783 3972 */ 3784 3973 INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags, … … 4083 4272 */ 4084 4273 INT 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*/)4274 GetTimeFormatA(LCID locale, /* [in] */ 4275 DWORD flags, /* [in] */ 4276 LPSYSTEMTIME xtime, /* [in] */ 4277 LPCSTR format, /* [in] */ 4278 LPSTR timestr, /* [out] */ 4279 INT timelen /* [in] */) 4091 4280 { char format_buf[40]; 4092 4281 LPCSTR thisformat; … … 4100 4289 4101 4290 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*/4108 4291 4109 4292 if (format == NULL) … … 4123 4306 } 4124 4307 else 4125 { thistime = (SYSTEMTIME *)xtime; 4308 { thistime = xtime; 4309 /* Check that hour,min and sec is in range */ 4126 4310 } 4127 4311 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, … … 4136 4320 */ 4137 4321 INT 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*/)4322 GetTimeFormatW(LCID locale, /* [in] */ 4323 DWORD flags, /* [in] */ 4324 LPSYSTEMTIME xtime, /* [in] */ 4325 LPCWSTR format, /* [in] */ 4326 LPWSTR timestr, /* [out] */ 4327 INT timelen /* [in] */) 4144 4328 { WCHAR format_buf[40]; 4145 4329 LPCWSTR thisformat; … … 4154 4338 4155 4339 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*/4162 4340 4163 4341 if (format == NULL) … … 4173 4351 4174 4352 if (xtime == NULL) /* NULL means use the current local time*/ 4175 { Get SystemTime(&t);4353 { GetLocalTime(&t); 4176 4354 thistime = &t; 4177 4355 } 4178 4356 else 4179 { thistime = (SYSTEMTIME *)xtime;;4357 { thistime = xtime; 4180 4358 } 4181 4359 … … 4185 4363 } 4186 4364 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 */ 4368 BOOL 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__ 4232 4376 /***************************************************************************** 4233 4377 * Name : BOOL WIN32API EnumCalendarInfoW … … 4273 4417 return (FALSE); 4274 4418 } 4419 #endif
Note:
See TracChangeset
for help on using the changeset viewer.