From 03f9e7b713fb7bbd3ba45316207643674fc12e07 Mon Sep 17 00:00:00 2001 From: Boudewijn Dekker Date: Sat, 27 Mar 1999 22:29:57 +0000 Subject: [PATCH] fixed some bugs to make nls functions compile svn path=/trunk/; revision=346 --- reactos/include/kernel32/cptable.h | 127 ++++++++++++++++++++++++++++ reactos/include/kernel32/lctable.h | 36 ++++++++ reactos/include/kernel32/nls.h | 26 ++++++ reactos/lib/kernel32/makefile | 21 ++++- reactos/lib/kernel32/nls/codepage.c | 9 +- reactos/lib/kernel32/nls/locale.c | 45 +++++----- reactos/lib/kernel32/nls/mbtowc.c | 13 +-- reactos/lib/kernel32/nls/wctomb.c | 11 ++- 8 files changed, 256 insertions(+), 32 deletions(-) create mode 100644 reactos/include/kernel32/cptable.h create mode 100644 reactos/include/kernel32/lctable.h create mode 100644 reactos/include/kernel32/nls.h diff --git a/reactos/include/kernel32/cptable.h b/reactos/include/kernel32/cptable.h new file mode 100644 index 00000000000..cbc2d3e7c65 --- /dev/null +++ b/reactos/include/kernel32/cptable.h @@ -0,0 +1,127 @@ +/* + * nls/cptable.h + */ + +#ifndef __NLS_CPTABLE_H +#define __NLS_CPTABLE_H + +#undef WIN32_LEAN_AND_MEAN +#include +#include + + +#define CODEPAGE_ANSI 1 +#define CODEPAGE_OEM 2 +#define CODEPAGE_MAC 3 +#define CODEPAGE_EBCDIC 4 +#define CODEPAGE_DBCS 0x10 + + + +typedef struct __CURRENCYFMTA +{ + UINT NumDigits; + UINT LeadingZero; + UINT Grouping; + LPSTR lpDecimalSep; + LPSTR lpThousandSep; + UINT NegativeOrder; + UINT PositiveOrder; + LPSTR lpCurrencySymbol; +} CURRENCYFMTA, *PCURRENCYFMTA, *LPCURRENCYFMTA; + +typedef struct __CURRENCYFMTW +{ + UINT NumDigits; + UINT LeadingZero; + UINT Grouping; + LPWSTR lpDecimalSep; + LPWSTR lpThousandSep; + UINT NegativeOrder; + UINT PositiveOrder; + LPWSTR lpCurrencySymbol; +} CURRENCYFMTW, *PCURRENCYFMTW, *LPCURRENCYFMTW; + +typedef struct __NUMBERFMTA +{ + UINT NumDigits; + UINT LeadingZero; + UINT Grouping; + LPSTR lpDecimalSep; + LPSTR lpThousandSep; + UINT NegativeOrder; +} NUMBERFMTA, *PNUMBERFMTA, *LPNUMBERFMTA; + +typedef struct __NUMBERFMTW +{ + UINT NumDigits; + UINT LeadingZero; + UINT Grouping; + LPWSTR lpDecimalSep; + LPWSTR lpThousandSep; + UINT NegativeOrder; +} NUMBERFMTW, *PNUMBERFMTW, *LPNUMBERFMTW; + +typedef struct __CODEPAGE +{ + struct __CODEPAGE *Next; + INT Id; + DWORD Flags; + WCHAR **ToUnicode; + WCHAR **ToUnicodeGlyph; + CHAR ***FromUnicode; + LPCPINFO Info; +} CODEPAGE, *PCODEPAGE; + +extern PCODEPAGE __CPFirst; + +extern CODEPAGE __CP37; +extern CODEPAGE __CP437; +extern CODEPAGE __CP500; +extern CODEPAGE __CP737; +extern CODEPAGE __CP775; +extern CODEPAGE __CP850; +extern CODEPAGE __CP852; +extern CODEPAGE __CP855; +extern CODEPAGE __CP857; +extern CODEPAGE __CP860; +extern CODEPAGE __CP861; +extern CODEPAGE __CP863; +extern CODEPAGE __CP865; +extern CODEPAGE __CP866; +extern CODEPAGE __CP869; +extern CODEPAGE __CP875; +extern CODEPAGE __CP1026; +extern CODEPAGE __CP1250; +extern CODEPAGE __CP1251; +extern CODEPAGE __CP1252; +extern CODEPAGE __CP1253; +extern CODEPAGE __CP1254; +extern CODEPAGE __CP1255; +extern CODEPAGE __CP1256; +extern CODEPAGE __CP1257; +extern CODEPAGE __CP1258; +extern CODEPAGE __CP10000; +extern CODEPAGE __CP10006; +extern CODEPAGE __CP10007; +extern CODEPAGE __CP10029; +extern CODEPAGE __CP10079; +extern CODEPAGE __CP10081; + +extern CPINFO __CPGenInfo; + +extern WCHAR __ASCII_00[32]; +extern WCHAR __ASCII_20[32]; +extern WCHAR __ASCII_40[32]; +extern WCHAR __ASCII_60[32]; + +extern CHAR __ASCII_0000[32]; +extern CHAR __ASCII_0020[32]; +extern CHAR __ASCII_0040[32]; +extern CHAR __ASCII_0060[32]; + +extern WCHAR __NULL_00[32]; +extern CHAR __NULL_0000[32]; +extern CHAR *__NULL_00XX[32]; + +#endif \ No newline at end of file diff --git a/reactos/include/kernel32/lctable.h b/reactos/include/kernel32/lctable.h new file mode 100644 index 00000000000..17ceff8548d --- /dev/null +++ b/reactos/include/kernel32/lctable.h @@ -0,0 +1,36 @@ +/* + * nls/lctable.h + */ + + + +#ifndef __NLS_LCTABLE_H +#define __NLS_LCTABLE_H + + +struct __CODEPAGE; + +#ifdef WIN32_LEAN_AND_MEAN + typedef DWORD LCID; +#endif + +#define LOCALE_ARRAY 200 +typedef struct __LOCALE +{ + LCID Id; + LPSTR AbbrName; + LPWSTR *Info0; + LPWSTR *Info1; + LPWSTR *ShortDateFormat; + LPWSTR *LongDateFormat; + LPWSTR *TimeFormat; + struct __CODEPAGE *AnsiCodePage; + struct __CODEPAGE *OemCodePage; +} LOCALE, *PLOCALE, *LPLOCALE; + +extern LOCALE __Locale[LOCALE_ARRAY]; +extern PLOCALE __UserLocale; + +extern BOOL __LocaleInit(VOID); + +#endif \ No newline at end of file diff --git a/reactos/include/kernel32/nls.h b/reactos/include/kernel32/nls.h new file mode 100644 index 00000000000..2d6766a7585 --- /dev/null +++ b/reactos/include/kernel32/nls.h @@ -0,0 +1,26 @@ +/* + * win32/nls.h + * + * National Language Support definitions + * + * Copyright (C) 1996 Free Software Foundation, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include +#include + diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index 5b08af48046..e623e257b02 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -22,7 +22,26 @@ FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \ MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o -NLS_OBJECTS = # nls/mbtowc.o nls/wctomb.o +NLS_OBJECTS = nls/codepage.o nls/cpmisc.o nls/cptable.o\ + nls/cp37.o nls/cp437.o nls/cp500.o nls/cp737.o nls/cp775.o nls/cp850.o nls/cp852.o nls/cp855.o nls/cp857.o\ + nls/cp860.o nls/cp861.o nls/cp863.o nls/cp865.o nls/cp866.o nls/cp869.o nls/cp875.o nls/cp1026.o\ + nls/cp1250.o nls/cp1251.o nls/cp1252.o nls/cp1253.o nls/cp1254.o nls/cp1255.o nls/cp1256.o nls/cp1257.o\ + nls/cp10000.o nls/cp10006.o nls/cp10007.o nls/cp10029.o nls/cp10079.o nls/cp10081.o\ + nls/lctable.o\ + nls/lcAFK.o nls/lcBEL.o nls/lcBGR.o nls/lcCAT.o nls/lcCSY.o nls/lcDAN.o\ + nls/lcDEA.o nls/lcDEC.o nls/lcDEL.o nls/lcDES.o nls/lcDEU.o\ + nls/lcELL.o\ + nls/lcENA.o nls/lcENB.o nls/lcENC.o nls/lcENG.o nls/lcENI.o nls/lcENJ.o nls/lcENL.o nls/lcENS.o nls/lcENT.o\ + nls/lcENU.o nls/lcENZ.o\ + nls/lcESA.o nls/lcESB.o nls/lcESC.o nls/lcESD.o nls/lcESE.o nls/lcESF.o nls/lcESG.o nls/lcESH.o nls/lcESI.o\ + nls/lcESL.o nls/lcESM.o nls/lcESN.o nls/lcESO.o nls/lcESP.o nls/lcESR.o nls/lcESS.o nls/lcESU.o nls/lcESV.o\ + nls/lcESY.o nls/lcESZ.o\ + nls/lcETI.o nls/lcEUQ.o nls/lcFIN.o nls/lcFOS.o\ + nls/lcFRA.o nls/lcFRB.o nls/lcFRC.o nls/lcFRL.o nls/lcFRS.o\ + nls/lcHRV.o nls/lcHUN.o nls/lcIND.o nls/lcISL.o nls/lcITA.o nls/lcITS.o nls/lcLTH.o nls/lcLVI.o nls/lcNLB.o\ + nls/lcNLD.o nls/lcNON.o nls/lcNOR.o nls/lcPLK.o nls/lcPTB.o nls/lcPTG.o nls/lcROM.o nls/lcRUS.o nls/lcSKY.o\ + nls/lcSLV.o nls/lcSQI.o nls/lcSRB.o nls/lcSRL.o nls/lcSVE.o nls/lcSVF.o nls/lcTRK.o nls/lcUKR.o\ + nls/locale.o nls/mbtowc.o nls/wctomb.o THREAD_OBJECTS = thread/thread.o diff --git a/reactos/lib/kernel32/nls/codepage.c b/reactos/lib/kernel32/nls/codepage.c index 9ee4aef3430..fb32d8bd6f3 100644 --- a/reactos/lib/kernel32/nls/codepage.c +++ b/reactos/lib/kernel32/nls/codepage.c @@ -27,19 +27,24 @@ #include +extern PLOCALE __TebLocale; + +#define GetTebLocale() __TebLocale + + UINT STDCALL GetACP(void) { //aprintf("GetACP()\n"); /* XXX: read from registry, take this as default */ - return GetThreadLocale()->AnsiCodePage->Id; + return GetTebLocale()->AnsiCodePage->Id; } UINT STDCALL GetOEMCP(void) { //aprintf("GetOEMCP()\n"); /* XXX: read from registry, take this as default */ - return GetThreadLocale()->OemCodePage->Id; + return GetTebLocale()->OemCodePage->Id; } WINBOOL STDCALL IsValidCodePage(UINT codepage) diff --git a/reactos/lib/kernel32/nls/locale.c b/reactos/lib/kernel32/nls/locale.c index b4627457d68..22c92d97649 100644 --- a/reactos/lib/kernel32/nls/locale.c +++ b/reactos/lib/kernel32/nls/locale.c @@ -86,7 +86,7 @@ int OLE_GetFormatA(LCID locale, PLOCALE __UserLocale; PLOCALE __TebLocale; -PLOCALE __Locale; +LOCALE __Locale[LOCALE_ARRAY]; WINBOOL __LocaleInit(void) { @@ -1300,6 +1300,7 @@ int STDCALL GetDateFormatA(LCID locale,DWORD flags, return ret; } + int STDCALL GetTimeFormatW( @@ -1333,14 +1334,17 @@ GetTimeFormatW( * tt time marker (AM, PM) * */ -INT STDCALL -GetTimeFormatA(LCID locale, /* in */ - DWORD flags, /* in */ - LPSYSTEMTIME xtime, /* in */ - LPCSTR format, /* in */ - LPSTR timestr, /* out */ - INT timelen /* in */) -{ char format_buf[40]; +int +STDCALL +GetTimeFormatA( + LCID Locale, + DWORD dwFlags, + CONST SYSTEMTIME *lpTime, + LPCSTR lpFormat, + LPSTR lpTimeStr, + int cchTime) +{ + char format_buf[40]; LPCSTR thisformat; SYSTEMTIME t; LPSYSTEMTIME thistime; @@ -1348,34 +1352,35 @@ GetTimeFormatA(LCID locale, /* in */ DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */ INT ret; - thislocale = OLE2NLS_CheckLocale ( locale ); + thislocale = OLE2NLS_CheckLocale ( Locale ); - if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT )) - { FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n"); + if ( dwFlags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT )) + { + //FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n"); } - flags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/ + dwFlags &= (TIME_NOSECONDS | TIME_NOMINUTESORSECONDS); /* mask for OLE_GetFormatA*/ - if (format == NULL) - { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/ + if (lpFormat == NULL) + { if (dwFlags & LOCALE_NOUSEROVERRIDE) /*use system default*/ { thislocale = GetSystemDefaultLCID(); } GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf)); thisformat = format_buf; } else - { thisformat = format; + { thisformat = lpFormat; } - if (xtime == NULL) /* NULL means use the current local time*/ + if (lpTime == NULL) /* NULL means use the current local time*/ { GetSystemTime(&t); thistime = &t; } else - { thistime = xtime; + { thistime = lpTime; } - ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, - timestr, timelen); + ret = OLE_GetFormatA(thislocale, thisflags, dwFlags, thistime, thisformat, + lpTimeStr, cchTime); return ret; } diff --git a/reactos/lib/kernel32/nls/mbtowc.c b/reactos/lib/kernel32/nls/mbtowc.c index c826d2e950b..378c2ec7c9a 100644 --- a/reactos/lib/kernel32/nls/mbtowc.c +++ b/reactos/lib/kernel32/nls/mbtowc.c @@ -19,24 +19,27 @@ #include #include +extern PLOCALE __TebLocale; + +#define GetTebLocale() __TebLocale INT MultiByteToWideChar(UINT cpid, DWORD flags, LPCSTR src, int srclen, LPWSTR dest, int destlen) { - PCODEPAGE pcodepage; + PCODEPAGE pcodepage =__CPFirst; INT copylen; INT retlen; WCHAR **atou; CHAR c; - aprintf("MultiByteToWideChar( %u, 0x%lX, %s, %d, 0x%lX, %d )\n", - cpid, flags, src, srclen, (ULONG) dest, destlen); + //aprintf("MultiByteToWideChar( %u, 0x%lX, %s, %d, 0x%lX, %d )\n", + // cpid, flags, src, srclen, (ULONG) dest, destlen); /* get codepage */ switch(cpid) { - case CP_ACP: pcodepage=GetThreadLocale()->OemCodePage; break; - case CP_OEMCP: pcodepage=GetThreadLocale()->AnsiCodePage; break; + case CP_ACP: pcodepage= GetTebLocale()->OemCodePage; break; + case CP_OEMCP: pcodepage= GetTebLocale()->AnsiCodePage; break; case CP_MACCP: pcodepage=&__CP10000; break; default: pcodepage=__CPFirst; diff --git a/reactos/lib/kernel32/nls/wctomb.c b/reactos/lib/kernel32/nls/wctomb.c index 88693b94e8d..1842fd55008 100644 --- a/reactos/lib/kernel32/nls/wctomb.c +++ b/reactos/lib/kernel32/nls/wctomb.c @@ -20,12 +20,15 @@ #include #include +extern PLOCALE __TebLocale; + +#define GetTebLocale() __TebLocale INT WideCharToMultiByte(UINT cpid, DWORD flags, LPCWSTR src, int srclen, LPSTR dest, int destlen, LPCSTR pdefchar, LPBOOL pdefused ) { - PCODEPAGE pcodepage; + PCODEPAGE pcodepage = __CPFirst; BOOL defused=FALSE; INT copylen; INT retlen; @@ -34,13 +37,13 @@ INT WideCharToMultiByte(UINT cpid, DWORD flags, LPCWSTR src, int srclen, CHAR d; WCHAR c; - aprintf("WideCharToMultiByte()\n"); + // aprintf("WideCharToMultiByte()\n"); /* get codepage */ switch(cpid) { - case CP_ACP: pcodepage=GetThreadLocale()->OemCodePage; break; - case CP_OEMCP: pcodepage=GetThreadLocale()->AnsiCodePage; break; + case CP_ACP: pcodepage=GetTebLocale()->OemCodePage; break; + case CP_OEMCP: pcodepage=GetTebLocale()->AnsiCodePage; break; case CP_MACCP: pcodepage=&__CP10000; break; default: pcodepage=__CPFirst;