Changeset 190 for trunk/src/helpers/nls.c
- Timestamp:
- Jul 22, 2002, 10:08:02 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/nls.c
r185 r190 198 198 * 199 199 *@@added V0.9.19 (2002-06-13) [umoeller] 200 *@@changed V0.9.20 (2002-07-22) [umoeller]: optimized 201 *@@changed V0.9.20 (2002-07-22) [lafaix]: optimized 200 202 */ 201 203 … … 203 205 { 204 206 PCSZ p2; 205 ULONG ulDBCS ;207 ULONG ulDBCSType = TYPE_SBCS; 206 208 207 209 if (!nlsDBCS()) … … 209 211 return strchr(p, c); 210 212 213 // we're on DBCS: 214 215 // we can't find c if it is a leading byte 216 if (G_afLeadByte[c] != TYPE_SBCS) 217 return NULL; 218 219 for (p2 = p; 220 *p2; 221 ++p2) 222 { 223 // check _previous_ DBCS type and refresh 224 // DBCS type accordingly 225 switch (ulDBCSType) 226 { 227 case TYPE_SBCS: 228 case TYPE_DBCS_2ND: 229 ulDBCSType = G_afLeadByte[*p2]; 230 // we can safely do the test here (and skip rechecking 231 // the type) because c can't possibly be a leading byte 232 // V0.9.20 (2002-07-22) [lafaix] 233 if (*p2 == c) 234 return (PSZ)p2; 235 break; 236 237 case TYPE_DBCS_1ST : 238 ulDBCSType = TYPE_DBCS_2ND; 239 break; 240 } 241 } 242 243 /* old code V0.9.20 (2002-07-22) [umoeller] 211 244 // we're on DBCS: 212 245 for (p2 = p; … … 228 261 } 229 262 } 263 */ 230 264 231 265 return NULL; … … 240 274 * 241 275 *@@added V0.9.19 (2002-06-13) [umoeller] 276 *@@changed V0.9.20 (2002-07-22) [lafaix]: optimized 242 277 */ 243 278 244 279 PSZ nlsrchr(PCSZ p, char c) 245 280 { 246 PCSZ p2 ;247 ULONG ulDBCS,248 ulLength;281 PCSZ p2, 282 pLast = NULL; 283 ULONG ulDBCSType = TYPE_SBCS; 249 284 250 285 if (!nlsDBCS()) … … 253 288 254 289 // we're on DBCS: 290 291 // we can't find c if it is a leading byte 292 if (G_afLeadByte[c] != TYPE_SBCS) 293 return NULL; 294 295 for (p2 = p; 296 *p2; 297 ++p2) 298 { 299 // check _previous_ DBCS type and refresh 300 // DBCS type accordingly 301 switch (ulDBCSType) 302 { 303 case TYPE_SBCS: 304 case TYPE_DBCS_2ND: 305 ulDBCSType = G_afLeadByte[*p2]; 306 if (*p2 == c) 307 pLast = p2; 308 break; 309 310 case TYPE_DBCS_1ST : 311 ulDBCSType = TYPE_DBCS_2ND; 312 break; 313 } 314 } 315 316 return (PSZ)pLast; 317 318 // old code V0.9.20 (2002-07-22) [lafaix] 319 /* 255 320 ulLength = strlen(p); 256 321 for (p2 = p + ulLength - 1; … … 274 339 275 340 return NULL; 341 */ 276 342 } 277 343
Note:
See TracChangeset
for help on using the changeset viewer.