Changeset 147
- Timestamp:
- Mar 16, 2002, 8:53:47 AM (23 years ago)
- Location:
- trunk
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CodingConventions.txt
r118 r147 139 139 140 140 xdoc can create a full change log if these things are set 141 properly. Try "createdoc.cmd" in the WarpIN and XWorkplace 142 main source directories, respectively. 141 properly. Try "createdoc.cmd" or "createchangelog.cmd" in 142 the WarpIN and XWorkplace main source directories, 143 respectively. 143 144 144 145 Also, this way I can do a simple search over all files -
trunk/include/encodings/alltables.h
r37 r147 27 27 // #include "encodings\cp949.h" 28 28 // #include "encodings\cp950.h" 29 #include "encodings\cp1004.h" // added V0.9.18 (2002-03-08) [umoeller] 29 30 #include "encodings\cp1250.h" 30 31 #include "encodings\cp1251.h" -
trunk/include/encodings/base.h
r97 r147 16 16 /* 17 17 *@@ XWPENCODINGMAP: 18 * entry in a n 8-bit toUnicode conversion table.18 * entry in a codepage-to-Unicode conversion table. 19 19 */ 20 20 21 21 typedef struct _XWPENCODINGMAP 22 22 { 23 unsigned short us From;23 unsigned short usCP; 24 24 unsigned short usUni; 25 25 } XWPENCODINGMAP, *PXWPENCODINGMAP; 26 26 27 27 /* 28 *@@ XWPENCODINGID:28 *@@ ENCID: 29 29 * enum identifying each encoding set which is 30 30 * generally supported. Each ID corresponds to … … 32 32 */ 33 33 34 typedef enum _ XWPENCODINGID34 typedef enum _ENCID 35 35 { 36 UNSUPPORTED, 36 37 enc_cp437, 37 38 enc_cp737, … … 54 55 enc_cp949, 55 56 enc_cp950, 57 enc_cp1004, // added V0.9.18 (2002-03-08) [umoeller] 56 58 enc_cp1250, 57 59 enc_cp1251, … … 76 78 enc_iso8859_14, 77 79 enc_iso8859_15 78 } XWPENCODINGID; 80 } ENCID; 81 82 /* 83 *@@ CONVERSION: 84 * 85 *@@added V0.9.18 (2002-03-08) [umoeller] 86 */ 87 88 typedef struct _CONVERSION 89 { 90 ENCID EncodingID; 91 92 // to get Unicode for character 123 in the specific 93 // encoding, do pTable->ausEntriesUniFromCP[123]. 94 // If you get 0xFFFF, the encoding is undefined. 95 unsigned short usHighestCP; 96 unsigned short *ausEntriesUniFromCP; // usHighestCP + 1 entries 97 98 // to get codepage for unicode character 123, 99 // do pTable->ausEntriesCPFromUni[123]. 100 // If you get 0xFFFF, the encoding is undefined. 101 unsigned short usHighestUni; 102 unsigned short *ausEntriesCPFromUni; // usHighestUni + 1 entries 103 104 } CONVERSION, *PCONVERSION; 105 106 typedef enum _ENCBYTECOUNT 107 { 108 SINGLE, 109 DOUBLE, 110 EBCDIC, 111 MULTI_UNICODE, 112 UNKNOWN 113 } ENCBYTECOUNT; 114 115 ENCID encFindIdForCodepage(unsigned short usCodepage, 116 const char **ppcszDescription, 117 ENCBYTECOUNT *pByteCount); 118 119 PCONVERSION encCreateCodec(ENCID id); 120 121 void encFreeCodec(PCONVERSION *ppTable); 122 123 unsigned long encChar2Uni(PCONVERSION pTable, 124 unsigned short c); 125 126 unsigned short encUni2Char(PCONVERSION pTable, 127 unsigned long ulUni); 79 128 80 129 unsigned long encDecodeUTF8(const char **ppch); -
trunk/include/encodings/cp1250.h
r37 r147 3 3 *@@sourcefile cp1250.h: 4 4 * encoding translation for CP1250 to Unicode. 5 * 6 * Note: From my checking, 1250 is exactly the 7 * same as 1004, except for character point 0xAF. 5 8 * 6 9 *@@added V0.9.9 (2001-02-10) [umoeller] -
trunk/include/encodings/cp1252.h
r37 r147 3 3 *@@sourcefile cp1252.h: 4 4 * encoding translation for CP1252 to Unicode. 5 * 6 * Note: From my checking, 1252 is exactly the 7 * same as 1004, except for codepoint 0xAF. 5 8 * 6 9 *@@added V0.9.9 (2001-02-10) [umoeller] -
trunk/include/helpers/cnrh.h
r113 r147 86 86 { 87 87 ULONG ulFieldOffset; 88 P SZpszColumnTitle;88 PCSZ pszColumnTitle; 89 89 ULONG ulDataType; 90 90 ULONG ulOrientation; … … 450 450 * This can only be used after BEGIN_CNRINFO(). 451 451 * 452 * Container sort funcs must have this prototype: 453 + 454 + SHORT EXPENTRY fnCompare(PRECORDCORE p1, PRECORDCORE p2, PVOID pStorage) 455 * 452 456 *@@added V0.9.0 453 457 */ -
trunk/include/helpers/configsys.h
r117 r147 66 66 // -- CFGRPL_REMOVEPART mode (5) 67 67 68 P SZpszUniqueSearchString2;68 PCSZ pszUniqueSearchString2; 69 69 // for UNIQUE(statement2): 70 70 // the "statement2" to search for … … 76 76 // 2: add before pszSearchString 77 77 // 3: add after pszSearchString 78 P SZpszVerticalSearchString;78 PCSZ pszVerticalSearchString; 79 79 // for iVertical == 2 or 3 80 80 81 P SZpszNewLine;81 PCSZ pszNewLine; 82 82 // this is a copy of stuff before the "|" char 83 83 // in pszConfigSys given to the constructor -
trunk/include/helpers/linklist.h
r141 r147 95 95 #define LINKLISTMAGIC 0xf124 // could be anything 96 96 97 typedef signed short _SystemFNSORTLIST(void*, void*, void*);97 typedef signed short XWPENTRY FNSORTLIST(void*, void*, void*); 98 98 // changed V0.9.0 (99-10-22) [umoeller] 99 99 typedef FNSORTLIST *PFNSORTLIST; -
trunk/include/helpers/nls.h
r115 r147 99 99 APIRET XWPENTRY nlsUpper(PSZ psz, ULONG ulLength); 100 100 101 /* 102 *@@ STRINGENTITY: 103 * 104 *@@added V0.9.16 (2001-09-29) [umoeller] 105 */ 106 107 typedef struct _STRINGENTITY 108 { 109 PCSZ pcszEntity; 110 PCSZ *ppcszString; 111 } STRINGENTITY, *PSTRINGENTITY; 112 113 typedef const struct _STRINGENTITY *PCSTRINGENTITY; 114 115 VOID nlsInitStrings(HAB hab, 116 HMODULE hmod, 117 PCSTRINGENTITY paEntities, 118 ULONG cEntities); 119 120 PCSZ nlsGetString(ULONG ulStringID); 121 101 122 #endif 102 123 -
trunk/include/helpers/stringh.h
r143 r147 145 145 ULONG XWPENTRY strhGetBlock(const char *pszSearchIn, 146 146 PULONG pulSearchOffset, 147 PSZpszTag,147 const char *pszTag, 148 148 PSZ *ppszBlock, 149 149 PSZ *ppszAttribs, -
trunk/include/helpers/tmsgfile.h
r113 r147 54 54 PCSZ pcszMessageName, 55 55 PXSTRING pstr, 56 P SZ *pTable,56 PCSZ *pTable, 57 57 ULONG cTableEntries); 58 58 -
trunk/include/helpers/winh.h
r135 r147 652 652 653 653 BOOL XWPENTRY winhAdjustControls(HWND hwndDlg, 654 MPARAM *pmpFlags,654 const MPARAM *pmpFlags, 655 655 ULONG ulCount, 656 656 PSWP pswpNew, -
trunk/src/helpers/cctl_checkcnr.c
r146 r147 566 566 567 567 if (lstCountItems(G_pllCnrOwners) == 0) 568 {569 568 lstFree(&G_pllCnrOwners); 570 } 569 571 570 DosReleaseMutexSem(G_hmtxCnrOwnersList); 572 571 } … … 627 626 case WM_CONTROL: 628 627 { 629 USHORT usItemID = SHORT1FROMMP(mp1), 630 usNotifyCode = SHORT2FROMMP(mp1); 631 632 if (usItemID == pcbco->usCnrID) 628 if (SHORT1FROMMP(mp1) == pcbco->usCnrID) 633 629 { 634 switch ( usNotifyCode)630 switch (SHORT2FROMMP(mp1)) 635 631 { 636 632 case CN_ENTER: … … 645 641 } 646 642 break; 643 644 default: 645 mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2); 647 646 } 648 647 } 649 650 mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2);648 else 649 mrc = pfnwpOrig(hwndOwner, msg, mp1, mp2); 651 650 } 652 651 break; -
trunk/src/helpers/cnrh.c
r129 r147 334 334 cnrhSetFieldInfo(&pFieldInfo2, 335 335 pxfi->ulFieldOffset, 336 pxfi->pszColumnTitle,336 (PSZ)pxfi->pszColumnTitle, 337 337 pxfi->ulDataType, 338 338 pxfi->ulOrientation, -
trunk/src/helpers/encodings.c
r97 r147 3 3 *@@sourcefile encodings.c: 4 4 * character encoding translations. 5 * 6 * See encCreateCodec for an introduction. 5 7 * 6 8 *@@header "encodings\base.h" … … 31 33 #include "setup.h" // code generation and debugging options 32 34 33 #include "encodings\base.h" // includes all other encodings 35 #include "helpers\standards.h" 36 37 #include "encodings\base.h" 38 #include "encodings\alltables.h" 39 // #include "encodings\collate.h" 34 40 35 41 #pragma hdrstop 36 42 37 typedef struct _ENCODINGTABLE 38 { 39 XWPENCODINGID EncodingID; 40 41 unsigned short cEntries; 42 unsigned short ausEntries[1]; // variable size 43 } ENCODINGTABLE, *PENCODINGTABLE; 44 45 46 /* 47 *@@ encRegisterEncoding: 48 * registers a new proprietary encoding with the engine. 49 * 50 * Before you can translate encodings with this engine, 51 * you have to register them. This makes sure that the 52 * big encoding tables will only be linked to the executable 53 * code if they are explicitly referenced. As a result, you 54 * have to #include "encodings\base.h" and pass a pointer to 55 * one of the global tables in the header files to this 56 * function. 57 * 58 * This returns an encoding handle that can then be used 59 * with the other encoding functions. 60 * 61 * Example: 62 * 63 + #include "encodings\base.h" 64 + #include "encodings\alltables.h" // or a specific table only 65 + 66 + int rc = encRegisterEncoding(&G_iso8859_1, 67 + sizeof(G_iso8859_1) / sizeof(G_iso8859_1[0]), 68 + enc_iso8859_1); // ID to register with 69 */ 70 71 long encRegisterEncoding(PXWPENCODINGMAP pEncodingMap, 72 unsigned long cArrayEntries, // count of array items 73 XWPENCODINGID EncodingID) // enum from encodings\base.h 74 { 75 long lrc = 0; 76 77 unsigned short usHighest = 0; 43 #define ENCODINGENTRY(id) enc_ ## id, G_ ## id, ARRAYITEMCOUNT(G_ ## id) 44 45 /* 46 *@@ G_aEncodings: 47 * list of all encodings supported by this engine 48 * (i.e. we have a corresponding codepage in 49 * include\encodings\*.h) together with some 50 * additional information for each encoding, 51 * such as the corresponding OS/2 codepage 52 * number and a descriptive string. 53 * 54 *@@added V [umoeller] 55 */ 56 57 struct 58 { 59 ENCID id; // engine ID (enum) 60 PXWPENCODINGMAP pMap; // ptr to map from include\encodings\*.h 61 unsigned long cEntries; // entries in map (array item count) 62 unsigned short usCodepageOS2; // corresponding OS/2 codepage or 0 if none 63 ENCBYTECOUNT bc; 64 const char *pcszDescription; // description 65 } G_aEncodings[] = 66 { 67 ENCODINGENTRY(cp437), 437, SINGLE, "DOS Latin US", 68 ENCODINGENTRY(cp737), 737, SINGLE, "DOS Greek", 69 ENCODINGENTRY(cp775), 775, SINGLE, "DOS BaltRim", 70 ENCODINGENTRY(cp850), 850, SINGLE, "DOS Latin 1", 71 ENCODINGENTRY(cp852), 852, SINGLE, "DOS Latin 2", // default in Hungary, 72 // Romania, Poland 73 ENCODINGENTRY(cp855), 855, SINGLE, "DOS Cyrillic", 74 ENCODINGENTRY(cp857), 857, SINGLE, "DOS Latin 5 (Turkish)", 75 ENCODINGENTRY(cp860), 860, SINGLE, "DOS Portuguese", 76 ENCODINGENTRY(cp861), 861, SINGLE, "DOS Icelandic", 77 ENCODINGENTRY(cp862), 862, SINGLE, "DOS Hebrew", 78 ENCODINGENTRY(cp863), 863, SINGLE, "DOS Canadian French", 79 ENCODINGENTRY(cp864), 864, SINGLE, "DOS Arabic", // default in Egypt 80 ENCODINGENTRY(cp865), 865, SINGLE, "DOS Nordic", 81 ENCODINGENTRY(cp866), 866, SINGLE, "DOS Cyrillic Russian", // default in Russia 82 ENCODINGENTRY(cp869), 869, SINGLE, "DOS Greek2", 83 ENCODINGENTRY(cp874), 874, SINGLE, "DOS Thai (TIS-620)", // default in Thailand 84 // ENCODINGENTRY(cp932), 932 or 943?, DOUBLE, "Japanese Windows", 85 // ENCODINGENTRY(cp936), 936 or 946?, DOUBLE, "Chinese", 86 // ENCODINGENTRY(cp949), 951 or 949?, DOUBLE, "Korean", 87 // ENCODINGENTRY(cp950), 947 or 950?, DOUBLE, "Taiwan Big-5", // default in China? 88 ENCODINGENTRY(cp1004), 1004, SINGLE, "Windows Extended", 89 ENCODINGENTRY(cp1250), 1250, SINGLE, "Windows Latin 2", 90 ENCODINGENTRY(cp1251), 1251, SINGLE, "Windows Cyrillic", 91 ENCODINGENTRY(cp1252), 1252, SINGLE, "Windows Latin 1", 92 ENCODINGENTRY(cp1253), 1253, SINGLE, "Windows Greek", 93 ENCODINGENTRY(cp1254), 1254, SINGLE, "Windows Turkish", 94 ENCODINGENTRY(cp1255), 1255, SINGLE, "Windows Hebrew", 95 ENCODINGENTRY(cp1256), 1256, SINGLE, "Windows Arabic", 96 ENCODINGENTRY(cp1257), 1257, SINGLE, "Windows Latin-4", 97 ENCODINGENTRY(cp1258), 1258, UNKNOWN, "unknown", 98 ENCODINGENTRY(iso8859_1), 819, SINGLE, "ISO/IEC 8859-1:1998 (Latin-1)", 99 ENCODINGENTRY(iso8859_2), 912, SINGLE, "ISO 8859-2:1999 (Latin-2)", 100 ENCODINGENTRY(iso8859_3), 913, SINGLE, "ISO/IEC 8859-3:1999 (Latin-3)", 101 ENCODINGENTRY(iso8859_4), 914, SINGLE, "ISO/IEC 8859-4:1998 (Latin-4)", 102 ENCODINGENTRY(iso8859_5), 915, SINGLE, "ISO 8859-5:1999 (Cyrillic)", 103 ENCODINGENTRY(iso8859_6), 1089, SINGLE, "ISO 8859-6:1999 (Arabic)", 104 ENCODINGENTRY(iso8859_7), 813, SINGLE, "ISO 8859-7:1987 (Greek)", // default in Greece 105 ENCODINGENTRY(iso8859_8), 916, SINGLE, "ISO/IEC 8859-8:1999 (Hebrew)", 106 ENCODINGENTRY(iso8859_9), 920, SINGLE, "ISO/IEC 8859-9:1999 (Latin-5)", 107 ENCODINGENTRY(iso8859_10), 0, SINGLE, "ISO/IEC 8859-10:1998", 108 ENCODINGENTRY(iso8859_13), 0, SINGLE, "ISO/IEC 8859-13:1998", 109 ENCODINGENTRY(iso8859_14), 0, SINGLE, "ISO/IEC 8859-14:1998", 110 ENCODINGENTRY(iso8859_15), 923, SINGLE, "ISO/IEC 8859-15:1999", 111 112 UNSUPPORTED, NULL, 0, 1200, MULTI_UNICODE, "Unicode UCS-2", 113 UNSUPPORTED, NULL, 0, 1208, MULTI_UNICODE, "Unicode UTF-8" 114 }; 115 116 /* 117 *@@ FindEntry: 118 * 119 *@@added V0.9.18 (2002-03-08) [umoeller] 120 */ 121 122 static int FindEntry(ENCID id, 123 PXWPENCODINGMAP *ppMap, 124 unsigned long *pcEntries) 125 { 78 126 unsigned long ul; 79 80 // step 1:81 // run through the table and calculate the highest82 // character entry used83 127 for (ul = 0; 84 ul < cArrayEntries;128 ul < ARRAYITEMCOUNT(G_aEncodings); 85 129 ul++) 86 130 { 87 unsigned short usFrom = pEncodingMap[ul].usFrom; 88 if (usFrom > usHighest) 89 usHighest = usFrom; 131 if (G_aEncodings[ul].id == id) 132 { 133 *ppMap = G_aEncodings[ul].pMap; 134 *pcEntries = G_aEncodings[ul].cEntries; 135 return (1); 136 } 90 137 } 91 138 92 // step 2: allocate encoding table 93 if (usHighest) 139 return (0); 140 } 141 142 /* 143 *@@ encFindIdForCodepage: 144 * returns the ENCID for the given OS/2 145 * codepage, or UNSUPPORTED if there's none. 146 * 147 *@@added V0.9.18 (2002-03-08) [umoeller] 148 */ 149 150 ENCID encFindIdForCodepage(unsigned short usCodepage, 151 const char **ppcszDescription, // out: codepage description; ptr can be NULL 152 ENCBYTECOUNT *pByteCount) 153 { 154 unsigned long ul; 155 for (ul = 0; 156 ul < ARRAYITEMCOUNT(G_aEncodings); 157 ul++) 94 158 { 95 // allocate memory as needed 96 unsigned long cb = sizeof(ENCODINGTABLE) 97 + ( (usHighest - 1) 98 * sizeof(unsigned short) 99 ); 100 101 PENCODINGTABLE pTableNew = (PENCODINGTABLE)malloc(cb); 102 if (pTableNew) 103 { 104 memset(pTableNew, -1, cb); 105 pTableNew->cEntries = usHighest; // array size 106 107 // step 3: fill encoding table 108 // this only has the Unicode target USHORTs; 109 // the source is simply the offset. So to 110 // get Unicode for character 123 in the specific encoding, 111 // do pTableNew->ausEntries[123]. 112 // If you get 0xFFFF, the encoding is undefined. 113 114 for (ul = 0; 115 ul < cArrayEntries; 116 ul++) 159 if (G_aEncodings[ul].usCodepageOS2 == usCodepage) 160 161 { 162 if (ppcszDescription) 163 *ppcszDescription = G_aEncodings[ul].pcszDescription; 164 if (pByteCount) 165 *pByteCount = G_aEncodings[ul].bc; 166 return G_aEncodings[ul].id; 167 } 168 } 169 170 return (UNSUPPORTED); 171 } 172 173 /* 174 *@@ encCreateCodec: 175 * creates a codec that can be used for conversion between 176 * Unicode and codepaged characters (and vice versa). 177 * 178 * A codec essentially consists of two tables which can 179 * be used for quick index-based lookups in both directions. 180 * This function goes thru the tables provided in 181 * include\encodings\*.h and builds the codec tables 182 * from them. 183 * 184 * This function takes an encoding ID as input. Each 185 * codepage table in include\encodings\*.h has one 186 * of those IDs assigned. Use encFindIdForCodepage 187 * to find the ID for a given OS/2 codepage. 188 * 189 * Use codecs carefully and only when they are really 190 * needed for a specific conversion. Building a codec 191 * is expensive, so you should create a codec once 192 * and reuse it for future conversions. In addition, 193 * create codecs only for the codepages that are 194 * actually used. Each codec will take up 195 * n * sizeof(USHORT) bytes, where n is the highest 196 * Unicode character used in the codepage. 197 * 198 * Remarks: 199 * 200 * -- All codepages share the first 128 characters 201 * (0-0x7F) with ASCII. 202 * 203 * -- Since the first 128 characters (0-0x7F) in 204 * Unicode are equivalent to ASCII also, codecs 205 * are not needed if you process ASCII strings 206 * only. 207 * 208 * -- Since the next 128 characters (0x80-0xFF) in 209 * Unicode are equivalent to ISO/IEC 8859-1 210 * (Latin-1), codecs aren't needed for those 211 * strings either. 212 * 213 * Note that codepoints 0x80-0x9F are undefined 214 * in Latin-1 but used as control sequences in 215 * Unicode. 216 * 217 * -- As far as I know, codepage 1252, which is 218 * used per default under Windows, is equivalent 219 * to Latin 1 except that it also defines 220 * codepoints 0x80-0x9F to certain DTP characters. 221 * 222 * -- From my testing, codepage 1004 (which is 223 * described as "Windows-compatible" in most OS/2 224 * docs) is the same as codepage 1252, except for 225 * character 0xAF. 226 * 227 * Unfortunately, OS/2 uses codepage 850 on most 228 * systems (and Windows uses OS/2 codepage 1252), 229 * so for conversion between those, codecs are needed. 230 */ 231 232 PCONVERSION encCreateCodec(ENCID id) 233 { 234 PXWPENCODINGMAP pEncodingMap; 235 unsigned long cArrayEntries; 236 237 if (FindEntry(id, 238 &pEncodingMap, 239 &cArrayEntries)) 240 { 241 unsigned short usHighestCP = 0, 242 usHighestUni = 0; 243 unsigned long ul; 244 245 // step 1: 246 // run through the table and calculate the highest 247 // character entry used 248 for (ul = 0; 249 ul < cArrayEntries; 250 ul++) 251 { 252 if (pEncodingMap[ul].usCP > usHighestCP) 253 usHighestCP = pEncodingMap[ul].usCP; 254 if (pEncodingMap[ul].usUni > usHighestUni) 255 usHighestUni = pEncodingMap[ul].usUni; 256 } 257 258 // step 2: allocate encoding table 259 if (usHighestCP && usHighestUni) 260 { 261 PCONVERSION pTableNew; 262 if (pTableNew = NEW(CONVERSION)) 117 263 { 118 PXWPENCODINGMAP pEntry = &pEncodingMap[ul]; 119 pTableNew->ausEntries[pEntry->usFrom] = pEntry->usUni; 264 unsigned long cbEntriesUniFromCP 265 = (usHighestCP + 1) * sizeof(unsigned short); 266 unsigned long cbEntriesCPFromUni 267 = (usHighestUni + 1) * sizeof(unsigned short); 268 269 ZERO(pTableNew); 270 271 pTableNew->usHighestCP = usHighestCP; 272 pTableNew->usHighestUni = usHighestUni; 273 274 if ( (pTableNew->ausEntriesUniFromCP 275 = (unsigned short*)malloc(cbEntriesUniFromCP)) 276 && (pTableNew->ausEntriesCPFromUni 277 = (unsigned short*)malloc(cbEntriesCPFromUni)) 278 ) 279 { 280 // step 3: fill encoding tables 281 282 memset(pTableNew->ausEntriesUniFromCP, 283 0xFF, 284 cbEntriesUniFromCP); 285 memset(pTableNew->ausEntriesCPFromUni, 286 0xFF, 287 cbEntriesCPFromUni); 288 289 for (ul = 0; 290 ul < cArrayEntries; 291 ul++) 292 { 293 PXWPENCODINGMAP pEntry = &pEncodingMap[ul]; 294 295 pTableNew->ausEntriesUniFromCP[pEntry->usCP] = pEntry->usUni; 296 297 pTableNew->ausEntriesCPFromUni[pEntry->usUni] = pEntry->usCP; 298 } 299 300 return (pTableNew); 301 } 302 303 free(pTableNew); 120 304 } 121 122 lrc = (long)pTableNew;123 305 } 124 306 } 125 307 126 return (lrc); 308 return (NULL); 309 } 310 311 /* 312 *@@ encFreeCodec: 313 * frees a codec created with encFreeConversion 314 * and sets the given pointer to NULL. 315 * 316 *@@added V0.9.18 (2002-03-08) [umoeller] 317 */ 318 319 void encFreeCodec(PCONVERSION *ppTable) // in: ptr to codec ptr returned by encCreateCodec 320 { 321 PCONVERSION pTable; 322 if (pTable = *ppTable) 323 { 324 if (pTable->ausEntriesUniFromCP) 325 free(pTable->ausEntriesUniFromCP); 326 if (pTable->ausEntriesCPFromUni) 327 free(pTable->ausEntriesCPFromUni); 328 free(pTable); 329 *ppTable = NULL; 330 } 331 } 332 333 /* 334 *@@ encChar2Uni: 335 * converts a codepage-specific character 336 * to Unicode, using the given conversion 337 * table from encCreateCodec(). 338 * 339 * Returns 0xFFFF on errors, which is unlikely 340 * with Unicode though. 341 * 342 *@@added V0.9.18 (2002-03-08) [umoeller] 343 */ 344 345 unsigned long encChar2Uni(PCONVERSION pTable, 346 unsigned short c) 347 { 348 if ( (pTable) 349 && (c <= pTable->usHighestCP) 350 ) 351 return (pTable->ausEntriesUniFromCP[c]); 352 353 return (0xFFFF); 354 } 355 356 /* 357 *@@ encUni2Char: 358 * converts a Unicode character to the 359 * codepage specified by the given 360 * conversion table from encCreateCodec(). 361 * 362 * Returns 0xFFFF if the Unicode character 363 * has no codepage equivalent. 364 * 365 *@@added V0.9.18 (2002-03-08) [umoeller] 366 */ 367 368 unsigned short encUni2Char(PCONVERSION pTable, 369 unsigned long ulUni) 370 { 371 if ( (pTable) 372 && (ulUni <= pTable->usHighestUni) 373 ) 374 return (pTable->ausEntriesCPFromUni[ulUni]); 375 376 return (0xFFFF); 127 377 } 128 378 … … 246 496 } 247 497 498 #if 0 499 500 /* 501 *@@ encCodepageToUTF8: 502 * 503 *@@added V0.9.18 (2002-03-08) [umoeller] 504 */ 505 506 void encCodepageToUTF8(const char **ppch) 507 { 508 509 } 510 511 putwchar(c) 512 { 513 if (c < 0x80) { 514 putchar (c); 515 } 516 else if (c < 0x800) { 517 putchar (0xC0 | c>>6); 518 putchar (0x80 | c & 0x3F); 519 } 520 else if (c < 0x10000) { 521 putchar (0xE0 | c>>12); 522 putchar (0x80 | c>>6 & 0x3F); 523 putchar (0x80 | c & 0x3F); 524 } 525 else if (c < 0x200000) { 526 putchar (0xF0 | c>>18); 527 putchar (0x80 | c>>12 & 0x3F); 528 putchar (0x80 | c>>6 & 0x3F); 529 putchar (0x80 | c & 0x3F); 530 } 531 } 532 533 #endif 534 -
trunk/src/helpers/linklist.c
r141 r147 961 961 * sort function pfnSort, which works similar to those of the 962 962 * container sorts, i.e. it must be declared as a 963 + SHORTfnSort(void* pItem1, void* pItem2, void* pStorage)963 + signed short XWPENTRY fnSort(void* pItem1, void* pItem2, void* pStorage) 964 964 * 965 965 * These sort functions need to return the following: -
trunk/src/helpers/nls.c
r142 r147 40 40 41 41 #define INCL_DOSNLS 42 #define INCL_DOSSEMAPHORES 43 #define INCL_DOSEXCEPTIONS 44 #define INCL_DOSPROCESS 42 45 #define INCL_DOSERRORS 43 46 #define INCL_WINSHELLDATA … … 48 51 #include <string.h> 49 52 #include <math.h> 53 #include <setjmp.h> 50 54 51 55 #include "setup.h" // code generation and debugging options 52 56 57 #include "helpers\except.h" 58 #include "helpers\nls.h" 53 59 #include "helpers\prfh.h" 54 #include "helpers\nls.h" 60 #include "helpers\standards.h" 61 #include "helpers\stringh.h" 62 #include "helpers\tree.h" 63 #include "helpers\xstring.h" 55 64 56 65 #pragma hdrstop … … 495 504 return (ERROR_INVALID_PARAMETER); 496 505 } 506 507 /* ****************************************************************** 508 * 509 * NLS strings 510 * 511 ********************************************************************/ 512 513 static HAB G_hab = NULLHANDLE; 514 static HMODULE G_hmod = NULLHANDLE; 515 static PCSTRINGENTITY G_paEntities = NULL; 516 static ULONG G_cEntities = 0; 517 518 /* 519 *@@ ReplaceEntities: 520 * 521 *@@added V0.9.16 (2001-09-29) [umoeller] 522 */ 523 524 static ULONG ReplaceEntities(PXSTRING pstr) 525 { 526 ULONG ul, 527 rc = 0; 528 529 for (ul = 0; 530 ul < G_cEntities; 531 ul++) 532 { 533 ULONG ulOfs = 0; 534 PCSTRINGENTITY pThis = &G_paEntities[ul]; 535 while (xstrFindReplaceC(pstr, 536 &ulOfs, 537 pThis->pcszEntity, 538 *(pThis->ppcszString))) 539 rc++; 540 } 541 542 return (rc); 543 } 544 545 /* 546 *@@ LoadString: 547 * 548 *@@added V0.9.18 (2002-03-08) [umoeller] 549 */ 550 551 static void LoadString(ULONG ulID, 552 PSZ *ppsz, 553 PULONG pulLength) // out: length of new string (ptr can be NULL) 554 { 555 CHAR szBuf[500]; 556 XSTRING str; 557 558 if (*ppsz) 559 free(*ppsz); 560 561 if (!WinLoadString(G_hab, 562 G_hmod, 563 ulID, 564 sizeof(szBuf), 565 szBuf)) 566 // loading failed: 567 sprintf(szBuf, 568 "LoadString error: string resource %d not found in module 0x%lX", 569 ulID, 570 G_hmod); 571 572 xstrInitCopy(&str, szBuf, 0); 573 ReplaceEntities(&str); 574 *ppsz = str.psz; 575 if (pulLength) 576 *pulLength = str.ulLength; 577 // do not free string 578 } 579 580 static HMTX G_hmtxStringsCache = NULLHANDLE; 581 static TREE *G_StringsCache; 582 static LONG G_cStringsInCache = 0; 583 584 /* 585 *@@ LockStrings: 586 * 587 *@@added V0.9.9 (2001-04-04) [umoeller] 588 */ 589 590 static BOOL LockStrings(VOID) 591 { 592 BOOL brc = FALSE; 593 594 if (G_hmtxStringsCache == NULLHANDLE) 595 { 596 brc = !DosCreateMutexSem(NULL, 597 &G_hmtxStringsCache, 598 0, 599 TRUE); 600 treeInit(&G_StringsCache, 601 &G_cStringsInCache); 602 } 603 else 604 brc = !DosRequestMutexSem(G_hmtxStringsCache, SEM_INDEFINITE_WAIT); 605 606 return (brc); 607 } 608 609 /* 610 *@@ UnlockStrings: 611 * 612 *@@added V0.9.9 (2001-04-04) [umoeller] 613 */ 614 615 static VOID UnlockStrings(VOID) 616 { 617 DosReleaseMutexSem(G_hmtxStringsCache); 618 } 619 620 /* 621 *@@ STRINGTREENODE: 622 * internal string node structure for cmnGetString. 623 * 624 *@@added V0.9.9 (2001-04-04) [umoeller] 625 *@@changed V0.9.16 (2002-01-26) [umoeller]: no longer using malloc() for string 626 */ 627 628 typedef struct _STRINGTREENODE 629 { 630 TREE Tree; // tree node (src\helpers\tree.c) 631 CHAR szLoaded[1]; // string that was loaded; 632 // the struct is dynamic in size now 633 // V0.9.16 (2002-01-26) [umoeller] 634 } STRINGTREENODE, *PSTRINGTREENODE; 635 636 /* 637 *@@ nlsInitStrings: 638 * initializes the NLS strings cache. Call this 639 * before calling nlsGetString for the first time. 640 * 641 *@@added V0.9.18 (2002-03-08) [umoeller] 642 */ 643 644 VOID nlsInitStrings(HAB hab, // in: anchor block 645 HMODULE hmod, // in: module handle to load strings from 646 PCSTRINGENTITY paEntities, // in: entities array or NULL 647 ULONG cEntities) // in: array item count of paEntities or 0 648 { 649 G_hab = hab; 650 G_hmod = hmod; 651 G_paEntities = paEntities; 652 G_cEntities = cEntities; 653 } 654 655 /* 656 *@@ nlsGetString: 657 * returns a resource NLS string. 658 * 659 * Before calling this for the first time, initialize 660 * the engine with nlsInitStrings. 661 * 662 * After that, this function implements a fast string 663 * cache for various NLS strings. Compared to the 664 * standard method, this has the following advantages: 665 * 666 * -- Memory is only consumed for strings that are actually 667 * used. The NLSSTRINGS array had become terribly big, 668 * and lots of strings were loaded that were never used. 669 * 670 * -- Program startup should be a bit faster because we don't 671 * have to load a thousand strings at startup. 672 * 673 * -- The memory buffer holding the string is probably close 674 * to the rest of the heap data that the caller allocated, 675 * so this might lead to less memory page fragmentation. 676 * 677 * -- To add a new NLS string, before this mechanism existed, 678 * three files had to be changed (and kept in sync): common.h 679 * to add a field to the NLSSTRINGS structure, dlgids.h to 680 * add the string ID, and xfldrXXX.rc to add the resource. 681 * With the new mechanism, there's no need to change common.h 682 * any more, so the danger of forgetting something is a bit 683 * reduced. Anyway, fewer recompiles are needed (maybe), 684 * and sending in patches to the code is a bit easier. 685 * 686 * On input, specify a string resouce ID that exists 687 * in the hmod that was given to nlsInitStrings. 688 * 689 * The way this works is that the function maintains a 690 * fast cache of string IDs and only loads the string 691 * resources on demand from the given NLS DLL. If a 692 * string ID is queried for the first time, the string 693 * is loaded. Otherwise the cached copy is returned. 694 * 695 * There is a slight overhead to this function compared to 696 * simply getting a static string from an array, because 697 * the cache needs to be searched for the string ID. However, 698 * this uses a binary tree (balanced according to string IDs) 699 * internally, so this is quite fast still. 700 * 701 * This never releases the strings again. 702 * 703 * This never returns NULL. Even if loading the string failed, 704 * a string is returned; in that case, it's a meaningful error 705 * message specifying the ID that failed. 706 * 707 *@@added V0.9.9 (2001-04-04) [umoeller] 708 *@@changed V0.9.16 (2001-10-19) [umoeller]: fixed bad string count which was never set 709 *@@changed V0.9.16 (2002-01-26) [umoeller]: optimized heap locality 710 */ 711 712 PCSZ nlsGetString(ULONG ulStringID) 713 { 714 BOOL fLocked = FALSE; 715 PSZ pszReturn = "Error"; 716 717 TRY_LOUD(excpt1) 718 { 719 if (fLocked = LockStrings()) 720 { 721 PSTRINGTREENODE pNode; 722 723 if (pNode = (PSTRINGTREENODE)treeFind(G_StringsCache, 724 ulStringID, 725 treeCompareKeys)) 726 // already loaded: 727 pszReturn = pNode->szLoaded; 728 else 729 { 730 // not loaded: load now 731 PSZ psz = NULL; 732 ULONG ulLength = 0; 733 734 LoadString(ulStringID, 735 &psz, 736 &ulLength); 737 738 if ( (!psz) 739 || (!(pNode = (PSTRINGTREENODE)malloc( sizeof(STRINGTREENODE) 740 // has one byte for null 741 // terminator already 742 + ulLength))) 743 ) 744 pszReturn = "malloc() failed."; 745 else 746 { 747 pNode->Tree.ulKey = ulStringID; 748 memcpy(pNode->szLoaded, 749 psz, 750 ulLength + 1); 751 treeInsert(&G_StringsCache, 752 &G_cStringsInCache, // fixed V0.9.16 (2001-10-19) [umoeller] 753 (TREE*)pNode, 754 treeCompareKeys); 755 pszReturn = pNode->szLoaded; 756 } 757 758 if (psz) 759 free(psz); 760 } 761 } 762 else 763 // we must always return a string, never NULL 764 pszReturn = "Cannot get strings lock."; 765 } 766 CATCH(excpt1) {} END_CATCH(); 767 768 if (fLocked) 769 UnlockStrings(); 770 771 return (pszReturn); 772 } 773 -
trunk/src/helpers/stringh.c
r144 r147 1413 1413 ULONG strhGetBlock(const char *pszSearchIn, // in: buffer to search 1414 1414 PULONG pulSearchOffset, // in/out: offset where to start search (0 for beginning) 1415 PSZpszTag,1415 const char *pszTag, 1416 1416 PSZ *ppszBlock, // out: block enclosed by the tags 1417 1417 PSZ *ppszAttribs, // out: attributes of the opening tag … … 1429 1429 while ((pszBeginTag = strchr(pszBeginTag, '<'))) 1430 1430 { 1431 if (memicmp(pszBeginTag+1, pszTag, strlen(pszTag)) == 0)1431 if (memicmp(pszBeginTag+1, (void*)pszTag, strlen(pszTag)) == 0) 1432 1432 // yes: stop 1433 1433 break; … … 1480 1480 // tag, we need to have several closing tags before 1481 1481 // we're done 1482 if (memicmp(pszClosingTag+1, pszTag, cbTag) == 0)1482 if (memicmp(pszClosingTag+1, (void*)pszTag, cbTag) == 0) 1483 1483 ulNestingLevel++; 1484 1484 else … … 1486 1486 // is this ours? 1487 1487 if ( (*(pszClosingTag+1) == '/') 1488 && (memicmp(pszClosingTag+2, pszTag, cbTag) == 0)1488 && (memicmp(pszClosingTag+2, (void*)pszTag, cbTag) == 0) 1489 1489 ) 1490 1490 { -
trunk/src/helpers/tmsgfile.c
r129 r147 406 406 PCSZ pcszMessageName, // in: msg name to look for (case-sensitive!) 407 407 PXSTRING pstr, // out: message string, if found (XSTRING must be initialized) 408 P SZ *pTable,// in: replacement table or NULL408 PCSZ *pTable, // in: replacement table or NULL 409 409 ULONG cTableEntries) // in: count of items in pTable or null 410 410 { -
trunk/src/helpers/winh.c
r146 r147 2355 2355 2356 2356 BOOL winhAdjustControls(HWND hwndDlg, // in: dialog (req.) 2357 MPARAM *pmpFlags,// in: init flags or NULL for cleanup2357 const MPARAM *pmpFlags, // in: init flags or NULL for cleanup 2358 2358 ULONG ulCount, // in: item count (req.) 2359 2359 PSWP pswpNew, // in: pswpNew from WM_WINDOWPOSCHANGED or NULL for cleanup … … 2369 2369 { 2370 2370 PSWP pswpThis; 2371 MPARAM *pmpThis;2371 const MPARAM *pmpThis; 2372 2372 LONG ldcx, ldcy; 2373 2373 ULONG cWindows = 0; -
trunk/src/helpers/xml.c
r142 r147 2131 2131 XSTRING strElementName; 2132 2132 xstrInitSet(&strElementName, (PSZ)pcszElementName); 2133 pThis = (PCMATTRIBUTEDECLBASE)treeFind(2133 if (!(pThis = (PCMATTRIBUTEDECLBASE)treeFind( 2134 2134 pDocType->AttribDeclBasesTree, 2135 2135 (ULONG)&strElementName, 2136 CompareXStrings); 2137 2138 if (!pThis) 2136 CompareXStrings))) 2139 2137 { 2140 2138 // still not found: 2141 2139 // we need a new node then 2142 pDom->arcDOM = xmlCreateNodeBase(ATTRIBUTE_DECLARATION_BASE,2140 if (!(pDom->arcDOM = xmlCreateNodeBase(ATTRIBUTE_DECLARATION_BASE, 2143 2141 sizeof(CMATTRIBUTEDECLBASE), 2144 2142 strElementName.psz, 2145 2143 strElementName.ulLength, 2146 (PNODEBASE*)&pThis); 2147 if (!pDom->arcDOM) 2144 (PNODEBASE*)&pThis))) 2148 2145 { 2149 2146 // initialize the subtree -
trunk/src/helpers/xmlparse.c
r142 r147 829 829 */ 830 830 831 XML_Parser XML_ParserCreateNS(const XML_Char * encodingName, XML_Char nsSep) 831 XML_Parser XML_ParserCreateNS(const XML_Char * encodingName, 832 XML_Char nsSep) 832 833 { 833 834 XML_Char tmp[2]; … … 1006 1007 */ 1007 1008 1008 int XML_SetEncoding(XML_Parser parser, const XML_Char * encodingName) 1009 int XML_SetEncoding(XML_Parser parser, 1010 const XML_Char * encodingName) 1009 1011 { 1010 1012 if (!encodingName) … … 1140 1142 } 1141 1143 1142 static void destroyBindings(BINDING * bindings, XML_Parser parser) 1144 static void destroyBindings(BINDING * bindings, 1145 XML_Parser parser) 1143 1146 { 1144 1147 for (;;) … … 1238 1241 */ 1239 1242 1240 void XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) 1243 void XML_SetReturnNSTriplet(XML_Parser parser, 1244 int do_nst) 1241 1245 { 1242 1246 ns_triplets = do_nst; … … 1257 1261 */ 1258 1262 1259 void XML_SetUserData(XML_Parser parser, void *p) 1263 void XML_SetUserData(XML_Parser parser, 1264 void *p) 1260 1265 { 1261 1266 if (handlerArg == userData) … … 1272 1277 */ 1273 1278 1274 int XML_SetBase(XML_Parser parser, const XML_Char * p) 1279 int XML_SetBase(XML_Parser parser, 1280 const XML_Char * p) 1275 1281 { 1276 1282 if (p) … … 2077 2083 */ 2078 2084 2079 int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) 2085 int XML_Parse(XML_Parser parser, 2086 const char *s, 2087 int len, 2088 int isFinal) 2080 2089 { 2081 2090 if (len == 0) … … 2155 2164 */ 2156 2165 2157 int XML_ParseBuffer(XML_Parser parser, int len, int isFinal) 2166 int XML_ParseBuffer(XML_Parser parser, 2167 int len, 2168 int isFinal) 2158 2169 { 2159 2170 const char *start = bufferPtr; … … 2207 2218 */ 2208 2219 2209 void *XML_GetBuffer(XML_Parser parser, int len) 2220 void *XML_GetBuffer(XML_Parser parser, 2221 int len) 2210 2222 { 2211 2223 if (len > bufferLim - bufferEnd) … … 2357 2369 */ 2358 2370 2359 const char *XML_GetInputContext(XML_Parser parser, int *offset, int *size) 2371 const char *XML_GetInputContext(XML_Parser parser, 2372 int *offset, 2373 int *size) 2360 2374 { 2361 2375 #ifdef XML_CONTEXT_BYTES … … 3095 3109 * otherwise just check the attributes for well-formedness. */ 3096 3110 3097 static XMLERROR storeAtts(XML_Parser parser, const ENCODING * enc, 3098 const char *attStr, TAG_NAME * tagNamePtr, 3111 static XMLERROR storeAtts(XML_Parser parser, 3112 const ENCODING * enc, 3113 const char *attStr, 3114 TAG_NAME * tagNamePtr, 3099 3115 BINDING ** bindingsPtr) 3100 3116 { … … 5424 5440 } 5425 5441 5426 static int setContext(XML_Parser parser, const XML_Char * context) 5442 static int setContext(XML_Parser parser, 5443 const XML_Char * context) 5427 5444 { 5428 5445 const XML_Char *s = context; … … 5512 5529 } 5513 5530 5514 static int dtdInit(DTD * p, XML_Parser parser) 5531 static int dtdInit(DTD * p, 5532 XML_Parser parser) 5515 5533 { 5516 5534 XML_Memory_Handling_Suite *ms = &((Parser *) parser)->m_mem; … … 5796 5814 } 5797 5815 5798 static NAMED *lookup(HASH_TABLE * table, KEY name, size_t createSize) 5816 static NAMED *lookup(HASH_TABLE * table, 5817 KEY name, 5818 size_t createSize) 5799 5819 { 5800 5820 size_t i; -
trunk/src/helpers/xmltok.c
r98 r147 85 85 #define UTF8_INVALID4(p) ((*p) == 0xF4 && ((p)[1] & 0x30) != 0) 86 86 87 static 88 int EXPATENTRY isNever(const ENCODING * enc, const char *p) 87 static int EXPATENTRY isNever(const ENCODING * enc, const char *p) 89 88 { 90 89 return 0; 91 90 } 92 91 93 static 94 int EXPATENTRY utf8_isName2(const ENCODING * enc, const char *p) 92 static int EXPATENTRY utf8_isName2(const ENCODING * enc, const char *p) 95 93 { 96 94 return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); 97 95 } 98 96 99 static 100 int EXPATENTRY utf8_isName3(const ENCODING * enc, const char *p) 97 static int EXPATENTRY utf8_isName3(const ENCODING * enc, const char *p) 101 98 { 102 99 return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); … … 105 102 #define utf8_isName4 isNever 106 103 107 static 108 int EXPATENTRY utf8_isNmstrt2(const ENCODING * enc, const char *p) 104 static int EXPATENTRY utf8_isNmstrt2(const ENCODING * enc, const char *p) 109 105 { 110 106 return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); 111 107 } 112 108 113 static 114 int EXPATENTRY utf8_isNmstrt3(const ENCODING * enc, const char *p) 109 static int EXPATENTRY utf8_isNmstrt3(const ENCODING * enc, const char *p) 115 110 { 116 111 return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); … … 121 116 #define utf8_isInvalid2 isNever 122 117 123 static 124 int EXPATENTRY utf8_isInvalid3(const ENCODING * enc, const char *p) 118 static int EXPATENTRY utf8_isInvalid3(const ENCODING * enc, const char *p) 125 119 { 126 120 return UTF8_INVALID3((const unsigned char *)p); 127 121 } 128 122 129 static 130 int EXPATENTRY utf8_isInvalid4(const ENCODING * enc, const char *p) 123 static int EXPATENTRY utf8_isInvalid4(const ENCODING * enc, const char *p) 131 124 { 132 125 return UTF8_INVALID4((const unsigned char *)p); … … 276 269 277 270 static void EXPATENTRY utf8_toUtf8(const ENCODING * enc, 278 const char **fromP,279 const char *fromLim,280 char **toP,281 const char *toLim)271 const char **fromP, 272 const char *fromLim, 273 char **toP, 274 const char *toLim) 282 275 { 283 276 char *to; … … 302 295 303 296 static void EXPATENTRY utf8_toUtf16(const ENCODING * enc, 304 const char **fromP,305 const char *fromLim,306 unsigned short **toP,307 const unsigned short *toLim)297 const char **fromP, 298 const char *fromLim, 299 unsigned short **toP, 300 const unsigned short *toLim) 308 301 { 309 302 unsigned short *to = *toP; … … 397 390 398 391 static void EXPATENTRY latin1_toUtf8(const ENCODING * enc, 399 const char **fromP,400 const char *fromLim,401 char **toP,402 const char *toLim)392 const char **fromP, 393 const char *fromLim, 394 char **toP, 395 const char *toLim) 403 396 { 404 397 for (;;) … … 427 420 428 421 static void EXPATENTRY latin1_toUtf16(const ENCODING * enc, 429 const char **fromP,430 const char *fromLim,431 unsigned short **toP,432 const unsigned short *toLim)422 const char **fromP, 423 const char *fromLim, 424 unsigned short **toP, 425 const unsigned short *toLim) 433 426 { 434 427 while (*fromP != fromLim && *toP != toLim) … … 463 456 464 457 static void EXPATENTRY ascii_toUtf8(const ENCODING * enc, 465 const char **fromP,466 const char *fromLim,467 char **toP,468 const char *toLim)458 const char **fromP, 459 const char *fromLim, 460 char **toP, 461 const char *toLim) 469 462 { 470 463 while (*fromP != fromLim && *toP != toLim) … … 918 911 } 919 912 920 static void EXPATENTRY initUpdatePosition(const ENCODING * enc, const char *ptr, 921 const char *end, POSITION * pos) 913 static void EXPATENTRY initUpdatePosition(const ENCODING * enc, 914 const char *ptr, 915 const char *end, 916 POSITION * pos) 922 917 { 923 918 normal_updatePosition(&utf8_encoding.enc, ptr, end, pos); 924 919 } 925 920 926 static int EXPATENTRY toAscii(const ENCODING * enc, const char *ptr, const char *end) 921 static int EXPATENTRY toAscii(const ENCODING * enc, 922 const char *ptr, 923 const char *end) 927 924 { 928 925 char buf[1]; … … 952 949 * or there's an S followed by name=val. */ 953 950 static int EXPATENTRY parsePseudoAttribute(const ENCODING * enc, 954 const char *ptr,955 const char *end,956 const char **namePtr,957 const char **nameEndPtr,958 const char **valPtr,959 const char **nextTokPtr)951 const char *ptr, 952 const char *end, 953 const char **namePtr, 954 const char **nameEndPtr, 955 const char **valPtr, 956 const char **nextTokPtr) 960 957 { 961 958 int c; … … 1312 1309 1313 1310 static void EXPATENTRY unknown_toUtf8(const ENCODING * enc, 1314 const char **fromP,1315 const char *fromLim,1316 char **toP,1317 const char *toLim)1311 const char **fromP, 1312 const char *fromLim, 1313 char **toP, 1314 const char *toLim) 1318 1315 { 1319 1316 char buf[XML_UTF8_ENCODE_MAX]; … … 1355 1352 1356 1353 static void EXPATENTRY unknown_toUtf16(const ENCODING * enc, 1357 const char **fromP,1358 const char *fromLim,1359 unsigned short **toP,1360 const unsigned short *toLim)1354 const char **fromP, 1355 const char *fromLim, 1356 unsigned short **toP, 1357 const unsigned short *toLim) 1361 1358 { 1362 1359 while (*fromP != fromLim && *toP != toLim) … … 1559 1556 1560 1557 static int EXPATENTRY initScan(const ENCODING ** encodingTable, 1561 const INIT_ENCODING * enc,1562 int state,1563 const char *ptr,1564 const char *end,1565 const char **nextTokPtr)1558 const INIT_ENCODING * enc, 1559 int state, 1560 const char *ptr, 1561 const char *end, 1562 const char **nextTokPtr) 1566 1563 { 1567 1564 const ENCODING **encPtr; -
trunk/src/helpers/xmltok_impl.c
r98 r147 156 156 /* ptr points to character following "<!" */ 157 157 158 static int EXPATENTRY PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end, 159 const char **nextTokPtr) 158 static int EXPATENTRY PREFIX(scanDecl)(const ENCODING *enc, 159 const char *ptr, 160 const char *end, 161 const char **nextTokPtr) 160 162 { 161 163 if (ptr == end) … … 202 204 } 203 205 204 static int EXPATENTRY PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr) 206 static int EXPATENTRY PREFIX(checkPiTarget)(const ENCODING *enc, 207 const char *ptr, 208 const char *end, 209 int *tokPtr) 205 210 { 206 211 int upper = 0; … … 245 250 /* ptr points to character following "<?" */ 246 251 247 static int EXPATENTRY PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end, 248 const char **nextTokPtr) 252 static int EXPATENTRY PREFIX(scanPi)(const ENCODING *enc, 253 const char *ptr, 254 const char *end, 255 const char **nextTokPtr) 249 256 { 250 257 int tok; … … 307 314 308 315 309 static int EXPATENTRY PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end, 310 const char **nextTokPtr) 316 static int EXPATENTRY PREFIX(scanCdataSection)(const ENCODING *enc, 317 const char *ptr, 318 const char *end, 319 const char **nextTokPtr) 311 320 { 312 321 static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB }; … … 325 334 } 326 335 327 static int EXPATENTRY PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end, 328 const char **nextTokPtr) 336 static int EXPATENTRY PREFIX(cdataSectionTok)(const ENCODING *enc, 337 const char *ptr, 338 const char *end, 339 const char **nextTokPtr) 329 340 { 330 341 if (ptr == end) … … 402 413 /* ptr points to character following "</" */ 403 414 404 static int EXPATENTRY PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end, 405 const char **nextTokPtr) 415 static int EXPATENTRY PREFIX(scanEndTag)(const ENCODING *enc, 416 const char *ptr, 417 const char *end, 418 const char **nextTokPtr) 406 419 { 407 420 if (ptr == end) … … 449 462 /* ptr points to character following "&#X" */ 450 463 451 static int EXPATENTRY PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end, 452 const char **nextTokPtr) 464 static int EXPATENTRY PREFIX(scanHexCharRef)(const ENCODING *enc, 465 const char *ptr, 466 const char *end, 467 const char **nextTokPtr) 453 468 { 454 469 if (ptr != end) { … … 480 495 /* ptr points to character following "&#" */ 481 496 482 static int EXPATENTRY PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end, 483 const char **nextTokPtr) 497 static int EXPATENTRY PREFIX(scanCharRef)(const ENCODING *enc, 498 const char *ptr, 499 const char *end, 500 const char **nextTokPtr) 484 501 { 485 502 if (ptr != end) { … … 511 528 /* ptr points to character following "&" */ 512 529 513 static int EXPATENTRY PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end, 514 const char **nextTokPtr) 530 static int EXPATENTRY PREFIX(scanRef)(const ENCODING *enc, 531 const char *ptr, 532 const char *end, 533 const char **nextTokPtr) 515 534 { 516 535 if (ptr == end) … … 540 559 /* ptr points to character following first character of attribute name */ 541 560 542 static int EXPATENTRY PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, 543 const char **nextTokPtr) 561 static int EXPATENTRY PREFIX(scanAtts)(const ENCODING *enc, 562 const char *ptr, 563 const char *end, 564 const char **nextTokPtr) 544 565 { 545 566 #ifdef XML_NS … … 699 720 /* ptr points to character following "<" */ 700 721 701 static int EXPATENTRY PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, 702 const char **nextTokPtr) 722 static int EXPATENTRY PREFIX(scanLt)(const ENCODING *enc, 723 const char *ptr, 724 const char *end, 725 const char **nextTokPtr) 703 726 { 704 727 #ifdef XML_NS … … 797 820 } 798 821 799 static int EXPATENTRY PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, 800 const char **nextTokPtr) 822 static int EXPATENTRY PREFIX(contentTok)(const ENCODING *enc, 823 const char *ptr, 824 const char *end, 825 const char **nextTokPtr) 801 826 { 802 827 if (ptr == end) … … 895 920 /* ptr points to character following "%" */ 896 921 897 static int EXPATENTRY PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, 898 const char **nextTokPtr) 922 static int EXPATENTRY PREFIX(scanPercent)(const ENCODING *enc, 923 const char *ptr, 924 const char *end, 925 const char **nextTokPtr) 899 926 { 900 927 if (ptr == end) … … 923 950 } 924 951 925 static int EXPATENTRY PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, 926 const char **nextTokPtr) 952 static int EXPATENTRY PREFIX(scanPoundName)(const ENCODING *enc, 953 const char *ptr, 954 const char *end, 955 const char **nextTokPtr) 927 956 { 928 957 if (ptr == end) … … 949 978 } 950 979 951 static int EXPATENTRY PREFIX(scanLit)(int open, const ENCODING *enc, 952 const char *ptr, const char *end, 953 const char **nextTokPtr) 980 static int EXPATENTRY PREFIX(scanLit)(int open, 981 const ENCODING *enc, 982 const char *ptr, 983 const char *end, 984 const char **nextTokPtr) 954 985 { 955 986 while (ptr != end) { … … 980 1011 } 981 1012 982 static int EXPATENTRY PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, 983 const char **nextTokPtr) 1013 static int EXPATENTRY PREFIX(prologTok)(const ENCODING *enc, 1014 const char *ptr, 1015 const char *end, 1016 const char **nextTokPtr) 984 1017 { 985 1018 int tok; … … 1207 1240 } 1208 1241 1209 static int EXPATENTRY PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, 1210 const char **nextTokPtr) 1242 static int EXPATENTRY PREFIX(attributeValueTok)(const ENCODING *enc, 1243 const char *ptr, 1244 const char *end, 1245 const char **nextTokPtr) 1211 1246 { 1212 1247 const char *start; … … 1264 1299 } 1265 1300 1266 static int EXPATENTRY PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, 1267 const char **nextTokPtr) 1301 static int EXPATENTRY PREFIX(entityValueTok)(const ENCODING *enc, 1302 const char *ptr, 1303 const char *end, 1304 const char **nextTokPtr) 1268 1305 { 1269 1306 const char *start; … … 1320 1357 #ifdef XML_DTD 1321 1358 1322 static int EXPATENTRY PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, 1323 const char **nextTokPtr) 1359 static int EXPATENTRY PREFIX(ignoreSectionTok)(const ENCODING *enc, 1360 const char *ptr, 1361 const char *end, 1362 const char **nextTokPtr) 1324 1363 { 1325 1364 int level = 0; … … 1372 1411 #endif /* XML_DTD */ 1373 1412 1374 static int EXPATENTRY PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, 1375 const char **badPtr) 1413 static int EXPATENTRY PREFIX(isPublicId)(const ENCODING *enc, 1414 const char *ptr, 1415 const char *end, 1416 const char **badPtr) 1376 1417 { 1377 1418 ptr += MINBPC(enc); … … 1430 1471 are stored in atts. */ 1431 1472 1432 static int EXPATENTRY PREFIX(getAtts)(const ENCODING *enc, const char *ptr, 1433 int attsMax, ATTRIBUTE *atts) 1473 static int EXPATENTRY PREFIX(getAtts)(const ENCODING *enc, 1474 const char *ptr, 1475 int attsMax, 1476 ATTRIBUTE *atts) 1434 1477 { 1435 1478 enum { other, inName, inValue } state = inName; … … 1522 1565 } 1523 1566 1524 static int EXPATENTRY PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) 1567 static int EXPATENTRY PREFIX(charRefNumber)(const ENCODING *enc, 1568 const char *ptr) 1525 1569 { 1526 1570 int result = 0; … … 1561 1605 } 1562 1606 1563 static int EXPATENTRY PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end) 1607 static int EXPATENTRY PREFIX(predefinedEntityName)(const ENCODING *enc, 1608 const char *ptr, 1609 const char *end) 1564 1610 { 1565 1611 switch ((end - ptr)/MINBPC(enc)) { … … 1613 1659 } 1614 1660 1615 static int EXPATENTRY PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) 1661 static int EXPATENTRY PREFIX(sameName)(const ENCODING *enc, 1662 const char *ptr1, 1663 const char *ptr2) 1616 1664 { 1617 1665 for (;;) { … … 1676 1724 } 1677 1725 1678 static int EXPATENTRY PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, 1679 const char *end1, const char *ptr2) 1726 static int EXPATENTRY PREFIX(nameMatchesAscii)(const ENCODING *enc, 1727 const char *ptr1, 1728 const char *end1, 1729 const char *ptr2) 1680 1730 { 1681 1731 for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { … … 1688 1738 } 1689 1739 1690 static int EXPATENTRY PREFIX(nameLength)(const ENCODING *enc, const char *ptr) 1740 static int EXPATENTRY PREFIX(nameLength)(const ENCODING *enc, 1741 const char *ptr) 1691 1742 { 1692 1743 const char *start = ptr; … … 1714 1765 } 1715 1766 1716 static const char* EXPATENTRY PREFIX(skipS)(const ENCODING *enc, const char *ptr) 1767 static const char* EXPATENTRY PREFIX(skipS)(const ENCODING *enc, 1768 const char *ptr) 1717 1769 { 1718 1770 for (;;) { … … 1730 1782 1731 1783 static void EXPATENTRY PREFIX(updatePosition)(const ENCODING *enc, 1732 const char *ptr,1733 const char *end,1734 POSITION *pos)1784 const char *ptr, 1785 const char *end, 1786 POSITION *pos) 1735 1787 { 1736 1788 while (ptr != end) { -
trunk/src/helpers/xmltok_ns.c
r98 r147 27 27 }; 28 28 29 static int EXPATENTRY NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, 30 const char **nextTokPtr) 29 static int EXPATENTRY NS(initScanProlog)(const ENCODING *enc, 30 const char *ptr, 31 const char *end, 32 const char **nextTokPtr) 31 33 { 32 34 return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr); 33 35 } 34 36 35 static int EXPATENTRY NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, 36 const char **nextTokPtr) 37 static int EXPATENTRY NS(initScanContent)(const ENCODING *enc, 38 const char *ptr, 39 const char *end, 40 const char **nextTokPtr) 37 41 { 38 42 return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr); 39 43 } 40 44 41 int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name) 45 int NS(XmlInitEncoding)(INIT_ENCODING *p, 46 const ENCODING **encPtr, 47 const char *name) 42 48 { 43 49 int i = getEncodingIndex(name); … … 54 60 55 61 static 56 const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) 62 const ENCODING *NS(findEncoding)(const ENCODING *enc, 63 const char *ptr, 64 const char *end) 57 65 { 58 66 #define ENCODING_MAX 128 … … 73 81 74 82 int NS(XmlParseXmlDecl)(int isGeneralTextEntity, 75 const ENCODING *enc,76 const char *ptr,77 const char *end,78 const char **badPtr,79 const char **versionPtr,80 const char **versionEndPtr,81 const char **encodingName,82 const ENCODING **encoding,83 int *standalone)83 const ENCODING *enc, 84 const char *ptr, 85 const char *end, 86 const char **badPtr, 87 const char **versionPtr, 88 const char **versionEndPtr, 89 const char **encodingName, 90 const ENCODING **encoding, 91 int *standalone) 84 92 { 85 93 return doParseXmlDecl(NS(findEncoding), -
trunk/src/helpers/xstring.c
r144 r147 1064 1064 do // while p 1065 1065 { 1066 p = (PSZ)strhmemfind(p, // in: haystack 1067 pxstr->ulLength - (p - pxstr->psz), 1068 // remaining length of haystack 1069 pstrFind->psz, 1070 ulFoundLen, 1071 pShiftTable, 1072 pfRepeatFind); 1073 if (p) 1066 if (p = (PSZ)strhmemfind(p, // in: haystack 1067 pxstr->ulLength - (p - pxstr->psz), 1068 // remaining length of haystack 1069 pstrFind->psz, 1070 ulFoundLen, 1071 pShiftTable, 1072 pfRepeatFind)) 1074 1073 { 1075 1074 // string found: … … 1187 1186 // yes: 1188 1187 ULONG ulOfs = *pulOfs; 1189 PCSZ pFound 1190 = (PCSZ)strhmemfind(pxstr->psz + ulOfs, // in: haystack 1191 pxstr->ulLength - ulOfs, 1192 pstrSearch->psz, 1193 cSearchLen, 1194 pShiftTable, 1195 pfRepeatFind); 1196 if (pFound) 1188 PCSZ pFound; 1189 if (pFound = (PCSZ)strhmemfind(pxstr->psz + ulOfs, // in: haystack 1190 pxstr->ulLength - ulOfs, 1191 pstrSearch->psz, 1192 cSearchLen, 1193 pShiftTable, 1194 pfRepeatFind)) 1197 1195 { 1198 1196 ULONG ulFirstReplOfs = pFound - pxstr->psz;
Note:
See TracChangeset
for help on using the changeset viewer.