Changeset 444 for branches/branch-1-0/src
- Timestamp:
- Feb 20, 2019, 8:00:49 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1-0/src/helpers/nls.c
r437 r444 243 243 * replacement for strchr with DBCS support. 244 244 * 245 * This finds single-byte characters in strings 246 * that may contain DBCS characters. Both DBCS 247 * leading and trailing bytes are ignored, even 248 * if one of them matches the search character. 249 * 245 250 * If the system is not running with DBCS, 246 251 * this calls plain strchr automatically. 247 252 * 248 *@@added V0.9.19 (2002-06-13) [umoeller]249 *@@changed V0.9.20 (2002-07-22) [umoeller]: optimized250 *@@changed V0.9.20 (2002-07-22) [lafaix]: optimized251 253 */ 252 254 … … 254 256 { 255 257 PCSZ p2; 256 ULONG ulDBCSType = TYPE_SBCS; 257 258 259 // if not DBCS, do standard strchr() 258 260 if (!nlsDBCS()) 259 // not DBCS:260 261 return strchr(p, c); 261 262 // we're on DBCS:263 262 264 263 // we can't find c if it is a DBCS lead byte … … 266 265 return NULL; 267 266 268 for (p2 = p; 269 *p2; 270 ++p2) 271 { 272 // Set current DBCS scan state based of _previous_ DBCS scan state 273 switch (ulDBCSType) 274 { 275 case TYPE_DBCS_1ST : 276 ulDBCSType = TYPE_DBCS_2ND; 277 break; 278 case TYPE_SBCS: 279 if (G_afLeadByte[*p2]) 280 ulDBCSType = TYPE_DBCS_1ST; 281 break; 282 } 283 284 if (ulDBCSType != TYPE_DBCS_1ST) { 267 for (p2 = p; *p2; p2++) 268 { 269 // skip over DBCS leading bytes and their trailing bytes 270 if (G_afLeadByte[*p2]) { 271 272 // exit if the trailing byte is zero (shouldn't be) 273 if (!*(++p2)) 274 return NULL; 275 276 continue; 277 } 278 279 // test the SBCS char at p2 285 280 if (*p2 == c) 286 return (PSZ)p2; 287 ulDBCSType = TYPE_SBCS; // Ensure next char checked for DBCS lead 288 } 289 290 } // for 281 return (PSZ)p2; 282 } 291 283 292 284 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.