|
From: <set...@us...> - 2006-04-21 02:07:09
|
Revision: 1317 Author: sethdill Date: 2006-04-20 19:06:59 -0700 (Thu, 20 Apr 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1317&view=rev Log Message: ----------- Moved the charsets table to system.charsets. Initialization routine moved to strings.c, called from linksystemtablestructure in tablesturcture.c. Other changes involved setting up the global hdlhashtable for the charset table. Modified Paths: -------------- Frontier/trunk/Common/headers/stringdefs.h Frontier/trunk/Common/headers/strings.h Frontier/trunk/Common/headers/tablestructure.h Frontier/trunk/Common/source/langstartup.c Frontier/trunk/Common/source/strings.c Frontier/trunk/Common/source/stringverbs.c Frontier/trunk/Common/source/tablestructure.c Modified: Frontier/trunk/Common/headers/stringdefs.h =================================================================== --- Frontier/trunk/Common/headers/stringdefs.h 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/headers/stringdefs.h 2006-04-21 02:06:59 UTC (rev 1317) @@ -78,6 +78,7 @@ #define STR_this BIGSTRING ("\x04" "this") #define STR_temp "\x04" "temp" #define STR_environment "\x0b" "environment" + #define STR_charsets "\x08" "charsets" #define STR_Stack_overflow BIGSTRING ("\x0f" "Stack overflow!") Modified: Frontier/trunk/Common/headers/strings.h =================================================================== --- Frontier/trunk/Common/headers/strings.h 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/headers/strings.h 2006-04-21 02:06:59 UTC (rev 1317) @@ -266,7 +266,9 @@ extern boolean utf8tomacroman (Handle, Handle); /* 2006-02-25 creedon */ -extern boolean converttextencoding (Handle, Handle, long, long); +extern boolean converttextencoding (Handle, Handle, long, long); /* 2006-04-14 smd */ +extern boolean initcharsetstable (void); /* 2006-04-20 smd */ + #endif Modified: Frontier/trunk/Common/headers/tablestructure.h =================================================================== --- Frontier/trunk/Common/headers/tablestructure.h 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/headers/tablestructure.h 2006-04-21 02:06:59 UTC (rev 1317) @@ -180,7 +180,9 @@ extern hdlhashtable environmenttable; +extern hdlhashtable charsetstable; + extern byte nameinternaltable []; extern byte namemenubar []; @@ -227,7 +229,9 @@ extern byte nameenvironmenttable []; +extern byte namecharsetstable []; + /*prototypes*/ extern boolean linksystemtablestructure (hdlhashtable); /*tablestructure.c*/ Modified: Frontier/trunk/Common/source/langstartup.c =================================================================== --- Frontier/trunk/Common/source/langstartup.c 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/source/langstartup.c 2006-04-21 02:06:59 UTC (rev 1317) @@ -476,6 +476,11 @@ if (!initenvironment (environmenttable)) goto error; + // and now the charsets table + + if (!tablenewsystemtable (htable, namecharsetstable, &charsetstable)) + goto error; + pophashtable (); return (true); @@ -588,144 +593,6 @@ #define addstring(x,y) if (!langaddstringconst ((ptrstring) x, y)) return (false) -static boolean langinit_charset_consttable (void) { - - hdlhashtable hcharsetconsttable; - - if (!tablenewsystemtable (langtable, (ptrstring) "\x08" "charsets", &hcharsetconsttable)) - return (false); - - pushhashtable (hcharsetconsttable); - -#if MACVERSION - #if 1 - OSStatus err; - ItemCount ct, actual_ct, i; - - err = TECCountAvailableTextEncodings( &ct ); - if ( err != noErr ) { - pophashtable(); - - return (true); // don't kill the whole startup - } - - TextEncoding enc; - TextEncoding availEncodings[ ct ]; - bigstring ianaName; - - err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct ); - if ( err != noErr ) { - pophashtable(); - - return (true); // we don't want to kill the whole startup here - } - - for ( i = 0; i < actual_ct; i++ ) { - enc = availEncodings[ i ]; - // enc = i; - - err = TECGetTextEncodingInternetName( enc, ianaName ); - if ( err != noErr ) - continue; - - nullterminate( ianaName ); - - if ( ! hashsymbolexists( ianaName ) ) - langassignlongvalue( hcharsetconsttable, ianaName, enc ); - } - #endif - #if 0 - addlong( "ASCII", kCFStringEncodingASCII ); - addlong( "MacRoman", kCFStringEncodingMacRoman ); - addlong( "MACINTOSH", kCFStringEncodingMacRoman ); - - addlong( "iso-8859-1", kCFStringEncodingISOLatin1 ); - addlong( "iso-latin-1", kCFStringEncodingISOLatin1 ); - addlong( "iso-8859-2", kCFStringEncodingISOLatin2 ); - addlong( "iso-8859-3", kCFStringEncodingISOLatin3 ); - addlong( "iso-8859-4", kCFStringEncodingISOLatin4 ); - addlong( "iso-8859-5", kCFStringEncodingISOLatin5 ); - addlong( "iso-8859-6", kCFStringEncodingISOLatin6 ); - addlong( "iso-8859-7", kCFStringEncodingISOLatin7 ); - addlong( "iso-8859-8", kCFStringEncodingISOLatin8 ); - addlong( "iso-8859-9", kCFStringEncodingISOLatin9 ); - - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - addlong( "iso-8859-10", kCFStringEncodingISOLatin10 ); - #endif - - addlong( "windows-1250", kCFStringEncodingWindowsLatin2 ); - addlong( "windows-latin-2", kCFStringEncodingWindowsLatin2 ); /* code page 1250, Central Europe */ - - addlong( "windows-1251", kCFStringEncodingWindowsCyrillic ); /* code page 1251, Slavic Cyrillic */ - - addlong( "windows-1252", kCFStringEncodingWindowsLatin1 ); - addlong( "windows-latin-1", kCFStringEncodingWindowsLatin1 ); /* ANSI 1252 */ - - addlong( "windows-1253", kCFStringEncodingWindowsLatin5 ); /* code page 1253 */ - addlong( "windows-1254", kCFStringEncodingWindowsLatin5 ); /* code page 1254, Turkish */ - addlong( "windows-1255", kCFStringEncodingWindowsHebrew ); /* code page 1255 */ - addlong( "windows-1256", kCFStringEncodingWindowsArabic ); /* code page 1256 */ - addlong( "windows-1257", kCFStringEncodingWindowsBalticRim ); /* code page 1257 */ - addlong( "windows-1258", kCFStringEncodingWindowsVietnamese ); /* code page 1258 */ - addlong( "windows-1361", kCFStringEncodingWindowsKoreanJohab ); /* code page 1361, for Windows NT */ - - addlong( "UTF-7", kCFStringEncodingNonLossyASCII ); - addlong( "UTF-8", kCFStringEncodingUTF8 ); - addlong( "UTF-16", kCFStringEncodingUnicode ); - - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - addlong( "UTF-16le", kCFStringEncodingUTF16LE ); - addlong( "UTF-16be", kCFStringEncodingUTF16BE ); - #endif - #endif -#endif - -#if WIN95VERSION - addlong( "ASCII", 20127 ); - addlong( "MacRoman", 10000 ); - addlong( "MACINTOSH", 10000 ); - - addlong( "iso-8859-1", 28591 ); - addlong( "iso-latin-1", 28591 ); - addlong( "iso-8859-2", 28592 ); - addlong( "iso-8859-3", 28593 ); - addlong( "iso-8859-4", 28594 ); - addlong( "iso-8859-5", 28595 ); - addlong( "iso-8859-6", 28596 ); - addlong( "iso-8859-7", 28597 ); - addlong( "iso-8859-8", 28598 ); - addlong( "iso-8859-9", 28599 ); - addlong( "iso-8859-10", 28592 ); - - addlong( "windows-1250", 1250 ); - addlong( "windows-latin-2", 1250 ); /* code page 1250, Central Europe */ - - addlong( "windows-1251", 1251 ); /* code page 1251, Slavic Cyrillic */ - - addlong( "windows-1252", 1252 ); - addlong( "windows-latin-1", 1252 ); - - addlong( "windows-1253", 1253 ); /* code page 1253 */ - addlong( "windows-1254", 1254 ); /* code page 1254, Turkish */ - addlong( "windows-1255", 1255 ); /* code page 1255 */ - addlong( "windows-1256", 1256 ); /* code page 1256 */ - addlong( "windows-1257", 1257 ); /* code page 1257 */ - addlong( "windows-1258", 1258 ); /* code page 1258 */ - addlong( "windows-1361", 1361 ); /* code page 1361, for Windows NT */ - - addlong( "UTF-7", 65000 ); - addlong( "UTF-8", 65001 ); - addlong( "UTF-16", 0 ); - addlong( "UTF-16le", 1200 ); - addlong( "UTF-16be", 1201 ); -#endif - - pophashtable(); - - return (true); - } /* langinit_charset_consttable */ - static boolean langinitconsttable (void) { /* @@ -824,7 +691,7 @@ static boolean langinitbuiltintable (void) { - if (!tablenewsystemtable (langtable, (ptrstring) BIGSTRING ("\x08" "builtins"), &hbuiltinfunctions)) + if (!tablenewsystemtable (langtable, (ptrstring) "\x08" "builtins", &hbuiltinfunctions)) return (false); pushhashtable (hbuiltinfunctions); /*converted to function ops by the parser*/ @@ -879,7 +746,7 @@ 3/6/92 dmb: added "with" token */ - if (!tablenewsystemtable (langtable, (ptrstring) BIGSTRING ("\x08" "keywords"), &hkeywordtable)) + if (!tablenewsystemtable (langtable, (ptrstring) "\x08" "keywords", &hkeywordtable)) return (false); pushhashtable (hkeywordtable); /*converted to tokens by the scanner*/ @@ -955,9 +822,6 @@ if (!langinitconsttable ()) return (false); - if (!langinit_charset_consttable ()) - return (false); - if (!langinitbuiltintable ()) return (false); Modified: Frontier/trunk/Common/source/strings.c =================================================================== --- Frontier/trunk/Common/source/strings.c 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/source/strings.c 2006-04-21 02:06:59 UTC (rev 1317) @@ -35,6 +35,7 @@ #include "ops.h" #include "resources.h" #include "shell.rsrc.h" +#include "tablestructure.h" #include "timedate.h" #include "langinternal.h" /* 2006-02-26 creedon */ #include "byteorder.h" /* 2006-04-08 aradke: endianness conversion macros */ @@ -2481,7 +2482,100 @@ #endif } /*converttextencoding*/ +boolean initcharsetstable (void) { +#if MACVERSION + OSStatus err; + ItemCount ct, actual_ct, i; + tyvaluerecord v; + + v.valuetype = longvaluetype; + + err = TECCountAvailableTextEncodings( &ct ); + if ( err != noErr ) { + pophashtable(); + + return (true); // don't kill the whole startup + } + + TextEncoding enc; + TextEncoding availEncodings[ ct ]; + bigstring ianaName; + + err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct ); + if ( err != noErr ) { + pophashtable(); + + return (true); // we don't want to kill the whole startup here + } + + for ( i = 0; i < actual_ct; i++ ) { + enc = availEncodings[ i ]; + // enc = i; + + err = TECGetTextEncodingInternetName( enc, ianaName ); + if ( err != noErr ) + continue; + + nullterminate( ianaName ); + + v.data.longvalue = (signed long) enc; + + hashtableassign( charsetstable, ianaName, v ); + } +#endif + +#if WIN95VERSION + pushhashtable (charsetstable); /* global, table is created in langstartup.c : inittablestructure() */ + + addlong( "ASCII", 20127 ); + addlong( "US-ASCII" 20127 ); /* alias for ASCII */ + + addlong( "MACINTOSH", 10000 ); + addlong( "MacRoman", 10000 ); /* alias for MACINTOSH */ + + addlong( "iso-8859-1", 28591 ); + addlong( "iso-latin-1", 28591 ); /* alias for iso-8859-1 */ + addlong( "iso-8859-2", 28592 ); + addlong( "iso-8859-3", 28593 ); + addlong( "iso-8859-4", 28594 ); + addlong( "iso-8859-5", 28595 ); + addlong( "iso-8859-6", 28596 ); + addlong( "iso-8859-7", 28597 ); + addlong( "iso-8859-8", 28598 ); + addlong( "iso-8859-9", 28599 ); + addlong( "iso-8859-10", 28592 ); + + addlong( "windows-1250", 1250 ); + addlong( "windows-latin-2", 1250 ); /* code page 1250, Central Europe */ + + addlong( "windows-1251", 1251 ); /* code page 1251, Slavic Cyrillic */ + + addlong( "windows-1252", 1252 ); + addlong( "windows-latin-1", 1252 ); + + addlong( "windows-1253", 1253 ); /* code page 1253 */ + addlong( "windows-1254", 1254 ); /* code page 1254, Turkish */ + addlong( "windows-1255", 1255 ); /* code page 1255 */ + addlong( "windows-1256", 1256 ); /* code page 1256 */ + addlong( "windows-1257", 1257 ); /* code page 1257 */ + addlong( "windows-1258", 1258 ); /* code page 1258 */ + addlong( "windows-1361", 1361 ); /* code page 1361, for Windows NT */ + + addlong( "UTF-7", 65000 ); + addlong( "UTF-8", 65001 ); + addlong( "UTF-16", 0 ); /* not a real code page. 0 for special case handling in Frontier */ + addlong( "UTF-16le", 1200 ); + addlong( "UTF-16be", 1201 ); + + pophashtable(); +#endif + + return (true); + } /* initcharsetstable */ + + + boolean utf16toansi (Handle h, Handle hresult) { /* Modified: Frontier/trunk/Common/source/stringverbs.c =================================================================== --- Frontier/trunk/Common/source/stringverbs.c 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/source/stringverbs.c 2006-04-21 02:06:59 UTC (rev 1317) @@ -2358,8 +2358,12 @@ initialize the builtins directly. 2.1b5 dmb: verb initialization is now resource-based + + 2006-04-20 smd: added call to initialize the character sets */ + initcharsetstable(); + return (loadfunctionprocessor (idstringverbs, &stringfunctionvalue)); } /*stringinitverbs*/ Modified: Frontier/trunk/Common/source/tablestructure.c =================================================================== --- Frontier/trunk/Common/source/tablestructure.c 2006-04-20 20:06:19 UTC (rev 1316) +++ Frontier/trunk/Common/source/tablestructure.c 2006-04-21 02:06:59 UTC (rev 1317) @@ -100,8 +100,10 @@ byte nameenvironmenttable [] = STR_environment; +byte namecharsetstable [] = STR_charsets; + Handle rootvariable = nil; hdlhashtable roottable = nil; @@ -146,8 +148,10 @@ hdlhashtable environmenttable = nil; +hdlhashtable charsetstable = nil; + boolean getsystemtablescript (short idscript, bigstring bsscript) { return (getstringlist (idsystemtablescripts, idscript, bsscript)); @@ -259,6 +263,10 @@ if (!linksystemtable (hsystem, nameenvironmenttable, environmenttable)) return (false); + // link in the charsets table, not part of saved structure + if (!linksystemtable (hsystem, namecharsetstable, charsetstable)) + return (false); + // create the temp table, not part of saved structure if (checktable (hsystem, nametemptable, true, &htemp)) langexternaldontsave (hsystem, nametemptable); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |