Changeset 6608 for trunk/src/shlwapi/string_odin.cpp
- Timestamp:
- Aug 30, 2001, 9:19:59 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shlwapi/string_odin.cpp
r6375 r6608 1 /* $Id: string_odin.cpp,v 1. 3 2001-07-20 15:37:53 sandervlExp $ */1 /* $Id: string_odin.cpp,v 1.4 2001-08-30 19:19:59 phaller Exp $ */ 2 2 3 3 /* … … 271 271 272 272 273 274 273 /***************************************************************************** 274 * Name : StrSpnA 275 * Purpose : find the first occurence of a character in string1 276 * that is not contained in the set of characters specified by 277 * string2. 278 * Parameters: 279 * Variables : 280 * Result : 281 * Remark : COMCTL32undoc.StrSpnW, CRTDLL.strspn 282 * Status : UNTESTED 283 * 284 * Author : 285 *****************************************************************************/ 286 287 ODINFUNCTION2(INT, StrSpnA, 288 LPCSTR, lpString1, 289 LPCSTR, lpString2) 290 { 291 // 2001-08-30 PH 292 // copied from implementation in COMCTL32 293 if ( (lpString1 == NULL) || 294 (lpString2 == NULL) ) 295 return 0; 296 297 LPSTR lpLoop = (LPSTR)lpString1; 298 299 for (; (*lpLoop != 0); lpLoop++ ) 300 if ( StrChrA( lpString2, *lpLoop ) ) 301 return (INT) (lpLoop - lpString1); 302 303 return (INT) (lpLoop - lpString1); 304 } 305 306 307 /***************************************************************************** 308 * Name : StrSpnW 309 * Purpose : find the first occurence of a character in string1 310 * that is not contained in the set of characters specified by 311 * string2. 312 * Parameters: 313 * Variables : 314 * Result : 315 * Remark : COMCTL32undoc.StrSpnW, CRTDLL.strspn 316 * Status : UNTESTED 317 * 318 * Author : 319 *****************************************************************************/ 320 321 ODINFUNCTION2(INT, StrSpnW, 322 LPCWSTR, lpString1, 323 LPCWSTR, lpString2) 324 { 325 // 2001-08-30 PH 326 // copied from implementation in COMCTL32 327 if ( (lpString1 == NULL) || 328 (lpString2 == NULL) ) 329 return 0; 330 331 LPWSTR lpLoop = (LPWSTR)lpString1; 332 333 for (; (*lpLoop != 0); lpLoop++ ) 334 if ( StrChrW( lpString2, *lpLoop ) ) 335 return (INT) (lpLoop - lpString1); 336 337 return (INT) (lpLoop - lpString1); 338 } 339 340 341 /***************************************************************************** 342 * Name : StrPBrkA 343 * Purpose : find the first occurence in string1 of any character from string2 344 * Parameters: 345 * Variables : 346 * Result : 347 * Remark : 348 * Status : UNTESTED 349 * 350 * Author : 351 *****************************************************************************/ 352 353 ODINFUNCTION2(LPSTR, StrPBrkA, 354 LPCSTR, lpString1, 355 LPCSTR, lpString2) 356 { 357 register LPSTR s1; 358 359 while (*lpString1) 360 { 361 for (s1 = (LPSTR)lpString2; 362 *s1 && *s1 != *lpString1; 363 s1++) 364 /* empty */ 365 ; 366 367 if (*s1) 368 return (LPSTR)lpString1; 369 370 lpString1++; 371 } 372 373 return (LPSTR)NULL; 374 } 375 376 377 /***************************************************************************** 378 * Name : StrPBrkW 379 * Purpose : find the first occurence in string1 of any character from string2 380 * Parameters: 381 * Variables : 382 * Result : 383 * Remark : 384 * Status : UNTESTED 385 * 386 * Author : 387 *****************************************************************************/ 388 389 ODINFUNCTION2(LPWSTR, StrPBrkW, 390 LPCWSTR, lpString1, 391 LPCWSTR, lpString2) 392 { 393 register LPWSTR s1; 394 395 while (*lpString1) 396 { 397 for (s1 = (LPWSTR)lpString2; 398 *s1 && *s1 != *lpString1; 399 s1++) 400 /* empty */ 401 ; 402 403 if (*s1) 404 return (LPWSTR)lpString1; 405 406 lpString1++; 407 } 408 409 return (LPWSTR)NULL; 410 } 411 412 413 /************************************************************************* 414 * StrRStrIA [SHLWAPI] 415 */ 416 LPSTR WINAPI StrRStrIA(LPCSTR lpFirst, LPCSTR lpSrch) 417 { 418 INT iLen = lstrlenA(lpFirst) - lstrlenA(lpSrch); 419 420 // lpSrch cannot fit into lpFirst 421 if (iLen < 0) 422 return (LPSTR)NULL; 423 424 LPSTR lpThis = (LPSTR)lpFirst + iLen; 425 426 while (lpThis >= lpFirst) 427 { 428 LPCSTR p1 = lpThis, p2 = lpSrch; 429 while (*p1 && *p2 && toupper(*p1) == toupper(*p2)) { p1++; p2++; } 430 if (!*p2) return (LPSTR)lpThis; 431 lpThis--; 432 } 433 434 return NULL; 435 } 436 437 438 /************************************************************************* 439 * StrRStrIW [SHLWAPI] 440 */ 441 LPWSTR WINAPI StrRStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch) 442 { 443 INT iLen = lstrlenW(lpFirst) - lstrlenW(lpSrch); 444 445 // lpSrch cannot fit into lpFirst 446 if (iLen < 0) 447 return (LPWSTR)NULL; 448 449 LPWSTR lpThis = (LPWSTR)lpFirst + iLen; 450 451 while (lpThis >= lpFirst) 452 { 453 LPCWSTR p1 = lpThis, p2 = lpSrch; 454 while (*p1 && *p2 && toupperW(*p1) == toupperW(*p2)) { p1++; p2++; } 455 if (!*p2) return (LPWSTR)lpThis; 456 lpThis--; 457 } 458 459 return NULL; 460 }
Note:
See TracChangeset
for help on using the changeset viewer.