From 9dc325629d710fc0946cb6e238628229ab004fe0 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 22 Nov 1998 15:36:14 +0000 Subject: [PATCH] Turn mega double switch into static table (reduces compile time). --- ole/nls/frs.nls | 2 +- ole/nls/sky.nls | 2 +- ole/ole2nls.c | 479 +++++++++++++++++++++++++++++--------------------------- 3 files changed, 247 insertions(+), 236 deletions(-) diff --git a/ole/nls/frs.nls b/ole/nls/frs.nls index c8776edf65e..f2417d68490 100644 --- a/ole/nls/frs.nls +++ b/ole/nls/frs.nls @@ -16,7 +16,7 @@ LOCVAL(LOCALE_SNATIVECTRYNAME,"Suisse") LOCVAL(LOCALE_IDEFAULTLANGUAGE,"040c") LOCVAL(LOCALE_IDEFAULTCOUNTRY,"33") LOCVAL(LOCALE_IDEFAULTCODEPAGE,"850") -LOCVAL(LOCALE_IDEFAULTANSICODEPAGE,1252) +LOCVAL(LOCALE_IDEFAULTANSICODEPAGE,"1252") /* LOCVAL(LOCALE_SLIST,"") */ /* LOCVAL(LOCALE_IMEASURE,"") */ /* LOCVAL(LOCALE_SDECIMAL,"") */ diff --git a/ole/nls/sky.nls b/ole/nls/sky.nls index 0519b1bc5b0..02c7369344a 100644 --- a/ole/nls/sky.nls +++ b/ole/nls/sky.nls @@ -18,7 +18,7 @@ LOCVAL(LOCALE_IDEFAULTLANGUAGE,"041b") LOCVAL(LOCALE_IDEFAULTCOUNTRY, "42") LOCVAL(LOCALE_IDEFAULTCODEPAGE,"895") LOCVAL(LOCALE_IDEFAULTANSICODEPAGE,"1250") -LOCVAL(LOCALE_IDEFAULTMACCODEPAGE,""); +LOCVAL(LOCALE_IDEFAULTMACCODEPAGE,"") LOCVAL(LOCALE_SLIST, ";") LOCVAL(LOCALE_IMEASURE, "0") LOCVAL(LOCALE_SDECIMAL, ",") diff --git a/ole/ole2nls.c b/ole/ole2nls.c index 9b149e4e9c4..1a5f8dd7d23 100644 --- a/ole/ole2nls.c +++ b/ole/ole2nls.c @@ -18,6 +18,221 @@ #include "debug.h" #include "main.h" +struct NLS_langlocale { + const int lang; + struct NLS_localevar { + const int type; + const char *val; + } locvars[150]; +}; + +#define LANG_BEGIN(l,s) { MAKELANGID(l,s), { + +#define LOCVAL(type,value) {type,value}, + +#define LANG_END }}, + +static const struct NLS_langlocale langlocales[] = { +/* add languages in numerical order of main language (last two digits) + * it is much easier to find the missing holes that way */ + +LANG_BEGIN (LANG_CATALAN, SUBLANG_DEFAULT) /*0x0403*/ +#include "nls/cat.nls" +LANG_END + +LANG_BEGIN (LANG_CZECH, SUBLANG_DEFAULT) /*0x0405*/ +#include "nls/cze.nls" +LANG_END + +LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x0406*/ +#include "nls/dan.nls" +LANG_END + +LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN) /*0x0407*/ +#include "nls/deu.nls" +LANG_END +LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_SWISS) /*0x0807*/ +#include "nls/des.nls" +LANG_END +LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN) /*0x0C07*/ +#include "nls/dea.nls" +LANG_END +LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG) /*0x1007*/ +#include "nls/del.nls" +LANG_END +LANG_BEGIN (LANG_GERMAN, SUBLANG_GERMAN_LIECHTENSTEIN) /*0x1407*/ +#include "nls/dec.nls" +LANG_END + +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_US) /*0x0409*/ +#include "nls/enu.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_UK) /*0x0809*/ +#include "nls/eng.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_AUS) /*0x0C09*/ +#include "nls/ena.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CAN) /*0x1009*/ +#include "nls/enc.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_NZ) /*0x1409*/ +#include "nls/enz.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_EIRE) /*0x1809*/ +#include "nls/irl.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_SAFRICA) /*0x1C09*/ +#include "nls/ens.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_JAMAICA) /*0x2009*/ +#include "nls/enj.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_CARRIBEAN) /*0x2409*/ +#include "nls/enb.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_BELIZE) /*0x2809*/ +#include "nls/enl.nls" +LANG_END +LANG_BEGIN (LANG_ENGLISH, SUBLANG_ENGLISH_TRINIDAD) /*0x2C09*/ +#include "nls/ent.nls" +LANG_END + +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH) /*0x040a*/ +#include "nls/esp.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MEXICAN) /*0x080a*/ +#include "nls/esm.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_MODERN) /*0x0C0a*/ +#include "nls/esn.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_GUATEMALA) /*0x100a*/ +#include "nls/esg.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COSTARICA) /*0x140a*/ +#include "nls/esc.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PANAMA) /*0x180a*/ +#include "nls/esa.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_DOMINICAN) /*0x1C0A*/ +#include "nls/esd.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_VENEZUELA) /*0x200a*/ +#include "nls/esv.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_COLOMBIA) /*0x240a*/ +#include "nls/eso.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PERU) /*0x280a*/ +#include "nls/esr.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ARGENTINA) /*0x2c0a*/ +#include "nls/ess.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_ECUADOR) /*0x300a*/ +#include "nls/esf.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_CHILE) /*0x340a*/ +#include "nls/esl.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_URUGUAY) /*0x380a*/ +#include "nls/esy.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PARAGUAY) /*0x3c0a*/ +#include "nls/esz.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_BOLIVIA) /*0x400a*/ +#include "nls/esb.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_EL_SALVADOR) /*0x440a*/ +#include "nls/ese.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_HONDURAS) /*0x480a*/ +#include "nls/esh.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_NICARAGUA) /*0x4c0a*/ +#include "nls/esi.nls" +LANG_END +LANG_BEGIN (LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO) /*0x500a*/ +#include "nls/esu.nls" +LANG_END + +LANG_BEGIN (LANG_FINNISH, SUBLANG_DEFAULT) /*0x040B*/ +#include "nls/fin.nls" +LANG_END + +LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH) /*0x040C*/ +#include "nls/fra.nls" +LANG_END +LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_BELGIAN) /*0x080C*/ +#include "nls/frb.nls" +LANG_END +LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_CANADIAN) /*0x0C0C*/ +#include "nls/frc.nls" +LANG_END +LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_SWISS) /*0x100C*/ +#include "nls/frs.nls" +LANG_END +LANG_BEGIN (LANG_FRENCH, SUBLANG_FRENCH_LUXEMBOURG) /*0x140C*/ +#include "nls/frl.nls" +LANG_END + +LANG_BEGIN (LANG_HUNGARIAN, SUBLANG_DEFAULT) /*0x040e*/ +#include "nls/hun.nls" +LANG_END + +LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN) /*0x0410*/ +#include "nls/ita.nls" +LANG_END +LANG_BEGIN (LANG_ITALIAN, SUBLANG_ITALIAN_SWISS) /*0x0810*/ +#include "nls/its.nls" +LANG_END + +LANG_BEGIN (LANG_KOREAN, SUBLANG_KOREAN) /*0x0412*/ +#include "nls/kor.nls" +LANG_END + +LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL) /*0x0414*/ +#include "nls/nor.nls" +LANG_END +LANG_BEGIN (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK) /*0x0814*/ +#include "nls/non.nls" +LANG_END + +LANG_BEGIN (LANG_POLISH, SUBLANG_DEFAULT) /*0x0415*/ +#include "nls/plk.nls" +LANG_END + +LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE_BRAZILIAN) /*0x0416*/ +#include "nls/ptb.nls" +LANG_END +LANG_BEGIN (LANG_PORTUGUESE ,SUBLANG_PORTUGUESE) /*0x0816*/ +#include "nls/ptg.nls" +LANG_END + +LANG_BEGIN (LANG_SLOVAK, SUBLANG_DEFAULT) /*0x041b*/ +#include "nls/sky.nls" +LANG_END + +LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH) /*0x041d*/ +#include "nls/sve.nls" +LANG_END +LANG_BEGIN (LANG_SWEDISH, SUBLANG_SWEDISH_FINLAND) /*0x081d*/ +#include "nls/svf.nls" +LANG_END + +LANG_BEGIN (LANG_THAI, SUBLANG_DEFAULT) /*0x41e*/ +#include "nls/tha.nls" +LANG_END + +LANG_BEGIN (LANG_ESPERANTO, SUBLANG_DEFAULT) /*0x048f*/ +#include "nls/esperanto.nls" +LANG_END + }; + + /* Locale name to id map. used by EnumSystemLocales, GetLocalInfoA * MUST contain all #defines from winnls.h * last entry has NULL name, 0 id. @@ -423,25 +638,23 @@ INT16 WINAPI GetLocaleInfo16(LCID lcid,LCTYPE LCType,LPSTR buf,INT16 len) */ INT32 WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,INT32 len) { - char *retString; + LPCSTR retString; int found,i; int lang=0; - TRACE(ole,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n", - lcid,LCType,buf,len); + TRACE(ole,"(lcid=0x%lx,lctype=0x%lx,%p,%x)\n",lcid,LCType,buf,len); - if (len && (! buf) ) - { SetLastError(ERROR_INSUFFICIENT_BUFFER); + if (len && (! buf) ) { + SetLastError(ERROR_INSUFFICIENT_BUFFER); return 0; } - if (lcid == LOCALE_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) ) - { lcid = GetSystemDefaultLCID(); + if (lcid == LOCALE_SYSTEM_DEFAULT || (LCType & LOCALE_NOUSEROVERRIDE) ) { + lcid = GetSystemDefaultLCID(); + } else + if (lcid == LOCALE_USER_DEFAULT) { + lcid = GetUserDefaultLCID(); } - else if (lcid == LOCALE_USER_DEFAULT) - { lcid = GetUserDefaultLCID(); - } - LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP); /* As an option, we could obtain the value from win.ini. @@ -459,246 +672,44 @@ INT32 WINAPI GetLocaleInfo32A(LCID lcid,LCTYPE LCType,LPSTR buf,INT32 len) i++; } if (!retString) { - WARN(ole,"Unkown LC type %lX\n",LCType); + FIXME(ole,"Unkown LC type %lX\n",LCType); return 0; } -#define LOCVAL(type,value) case type:retString=value;found=1;break; -#define LANG_BEGIN(l,s) case MAKELANGID(l,s): switch (LCType) { -#define LANG_END default: found=0; break; } break; - /* Now, the language specific definitions. They don't have to be - complete */ - - found=0; i=0; lang=lcid; - - if ((lang & 0x3ff) == 0x000) /*LANG_NEUTRAL ==> US English*/ - { + if ((lang & 0x3ff) == 0x000) /*LANG_NEUTRAL ==> US English*/ { lang = 0x0409; WARN(ole,"no language set, assume LANG_ENGLISH_US \n"); } - do - { switch(lang) - { + found=0;lang=lcid; + for (i=0;i<3;i++) { + int j; -/* add languages in numerical order of main language (last two digits) - * it is much easier to find the missing holes that way */ - -LANG_BEGIN (LANG_CATALAN, SUBLANG_DEFAULT) /*0x0403*/ -#include "nls/cat.nls" -LANG_END - -LANG_BEGIN (LANG_CZECH, SUBLANG_DEFAULT) /*0x0405*/ -#include "nls/cze.nls" -LANG_END - -LANG_BEGIN (LANG_DANISH, SUBLANG_DEFAULT) /*0x0406*/ -#include "nls/dan.nls" -LANG_END + for (j=0;j