fixed some bugs to make nls functions compile

svn path=/trunk/; revision=346
This commit is contained in:
Boudewijn Dekker 1999-03-27 22:29:57 +00:00
parent fbcc7fb423
commit 03f9e7b713
8 changed files with 256 additions and 32 deletions

View file

@ -0,0 +1,127 @@
/*
* nls/cptable.h
*/
#ifndef __NLS_CPTABLE_H
#define __NLS_CPTABLE_H
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <kernel32/lctable.h>
#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

View file

@ -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

View file

@ -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 <kernel32/lctable.h>
#include <kernel32/cptable.h>

View file

@ -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 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 THREAD_OBJECTS = thread/thread.o

View file

@ -27,19 +27,24 @@
#include <string.h> #include <string.h>
extern PLOCALE __TebLocale;
#define GetTebLocale() __TebLocale
UINT STDCALL GetACP(void) UINT STDCALL GetACP(void)
{ {
//aprintf("GetACP()\n"); //aprintf("GetACP()\n");
/* XXX: read from registry, take this as default */ /* XXX: read from registry, take this as default */
return GetThreadLocale()->AnsiCodePage->Id; return GetTebLocale()->AnsiCodePage->Id;
} }
UINT STDCALL GetOEMCP(void) UINT STDCALL GetOEMCP(void)
{ {
//aprintf("GetOEMCP()\n"); //aprintf("GetOEMCP()\n");
/* XXX: read from registry, take this as default */ /* XXX: read from registry, take this as default */
return GetThreadLocale()->OemCodePage->Id; return GetTebLocale()->OemCodePage->Id;
} }
WINBOOL STDCALL IsValidCodePage(UINT codepage) WINBOOL STDCALL IsValidCodePage(UINT codepage)

View file

@ -86,7 +86,7 @@ int OLE_GetFormatA(LCID locale,
PLOCALE __UserLocale; PLOCALE __UserLocale;
PLOCALE __TebLocale; PLOCALE __TebLocale;
PLOCALE __Locale; LOCALE __Locale[LOCALE_ARRAY];
WINBOOL __LocaleInit(void) WINBOOL __LocaleInit(void)
{ {
@ -1300,6 +1300,7 @@ int STDCALL GetDateFormatA(LCID locale,DWORD flags,
return ret; return ret;
} }
int int
STDCALL STDCALL
GetTimeFormatW( GetTimeFormatW(
@ -1333,14 +1334,17 @@ GetTimeFormatW(
* tt time marker (AM, PM) * tt time marker (AM, PM)
* *
*/ */
INT STDCALL int
GetTimeFormatA(LCID locale, /* in */ STDCALL
DWORD flags, /* in */ GetTimeFormatA(
LPSYSTEMTIME xtime, /* in */ LCID Locale,
LPCSTR format, /* in */ DWORD dwFlags,
LPSTR timestr, /* out */ CONST SYSTEMTIME *lpTime,
INT timelen /* in */) LPCSTR lpFormat,
{ char format_buf[40]; LPSTR lpTimeStr,
int cchTime)
{
char format_buf[40];
LPCSTR thisformat; LPCSTR thisformat;
SYSTEMTIME t; SYSTEMTIME t;
LPSYSTEMTIME thistime; LPSYSTEMTIME thistime;
@ -1348,34 +1352,35 @@ GetTimeFormatA(LCID locale, /* in */
DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */ DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */
INT ret; INT ret;
thislocale = OLE2NLS_CheckLocale ( locale ); thislocale = OLE2NLS_CheckLocale ( Locale );
if ( flags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT )) if ( dwFlags & (TIME_NOTIMEMARKER | TIME_FORCE24HOURFORMAT ))
{ FIXME(ole,"TIME_NOTIMEMARKER or TIME_FORCE24HOURFORMAT not implemented\n"); {
//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 (lpFormat == NULL)
{ if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/ { if (dwFlags & LOCALE_NOUSEROVERRIDE) /*use system default*/
{ thislocale = GetSystemDefaultLCID(); { thislocale = GetSystemDefaultLCID();
} }
GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf)); GetLocaleInfoA(thislocale, thisflags, format_buf, sizeof(format_buf));
thisformat = format_buf; thisformat = format_buf;
} }
else 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); { GetSystemTime(&t);
thistime = &t; thistime = &t;
} }
else else
{ thistime = xtime; { thistime = lpTime;
} }
ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, ret = OLE_GetFormatA(thislocale, thisflags, dwFlags, thistime, thisformat,
timestr, timelen); lpTimeStr, cchTime);
return ret; return ret;
} }

View file

@ -19,24 +19,27 @@
#include <wchar.h> #include <wchar.h>
#include <string.h> #include <string.h>
extern PLOCALE __TebLocale;
#define GetTebLocale() __TebLocale
INT MultiByteToWideChar(UINT cpid, DWORD flags, LPCSTR src, int srclen, INT MultiByteToWideChar(UINT cpid, DWORD flags, LPCSTR src, int srclen,
LPWSTR dest, int destlen) LPWSTR dest, int destlen)
{ {
PCODEPAGE pcodepage; PCODEPAGE pcodepage =__CPFirst;
INT copylen; INT copylen;
INT retlen; INT retlen;
WCHAR **atou; WCHAR **atou;
CHAR c; CHAR c;
aprintf("MultiByteToWideChar( %u, 0x%lX, %s, %d, 0x%lX, %d )\n", //aprintf("MultiByteToWideChar( %u, 0x%lX, %s, %d, 0x%lX, %d )\n",
cpid, flags, src, srclen, (ULONG) dest, destlen); // cpid, flags, src, srclen, (ULONG) dest, destlen);
/* get codepage */ /* get codepage */
switch(cpid) switch(cpid)
{ {
case CP_ACP: pcodepage=GetThreadLocale()->OemCodePage; break; case CP_ACP: pcodepage= GetTebLocale()->OemCodePage; break;
case CP_OEMCP: pcodepage=GetThreadLocale()->AnsiCodePage; break; case CP_OEMCP: pcodepage= GetTebLocale()->AnsiCodePage; break;
case CP_MACCP: pcodepage=&__CP10000; break; case CP_MACCP: pcodepage=&__CP10000; break;
default: default:
pcodepage=__CPFirst; pcodepage=__CPFirst;

View file

@ -20,12 +20,15 @@
#include <kernel32/thread.h> #include <kernel32/thread.h>
#include <wchar.h> #include <wchar.h>
extern PLOCALE __TebLocale;
#define GetTebLocale() __TebLocale
INT WideCharToMultiByte(UINT cpid, DWORD flags, LPCWSTR src, int srclen, INT WideCharToMultiByte(UINT cpid, DWORD flags, LPCWSTR src, int srclen,
LPSTR dest, int destlen, LPCSTR pdefchar, LPSTR dest, int destlen, LPCSTR pdefchar,
LPBOOL pdefused ) LPBOOL pdefused )
{ {
PCODEPAGE pcodepage; PCODEPAGE pcodepage = __CPFirst;
BOOL defused=FALSE; BOOL defused=FALSE;
INT copylen; INT copylen;
INT retlen; INT retlen;
@ -34,13 +37,13 @@ INT WideCharToMultiByte(UINT cpid, DWORD flags, LPCWSTR src, int srclen,
CHAR d; CHAR d;
WCHAR c; WCHAR c;
aprintf("WideCharToMultiByte()\n"); // aprintf("WideCharToMultiByte()\n");
/* get codepage */ /* get codepage */
switch(cpid) switch(cpid)
{ {
case CP_ACP: pcodepage=GetThreadLocale()->OemCodePage; break; case CP_ACP: pcodepage=GetTebLocale()->OemCodePage; break;
case CP_OEMCP: pcodepage=GetThreadLocale()->AnsiCodePage; break; case CP_OEMCP: pcodepage=GetTebLocale()->AnsiCodePage; break;
case CP_MACCP: pcodepage=&__CP10000; break; case CP_MACCP: pcodepage=&__CP10000; break;
default: default:
pcodepage=__CPFirst; pcodepage=__CPFirst;