HuntnGather – Diff between revs 33 and 37
?pathlinks?
Rev 33 | Rev 37 | |||
---|---|---|---|---|
Line 43... | Line 43... | |||
43 | return p > q ? p : q; |
43 | return p > q ? p : q; |
|
44 | } |
44 | } |
|
Line 45... | Line 45... | |||
45 | |
45 | |
|
46 | /* |
46 | /* |
|
- | 47 | * |
||
- | 48 | * Returns largest of strings. |
||
- | 49 | */ |
||
- | 50 | #if defined ___AmigaOS___ |
||
- | 51 | LONG StringLenMin(char *a, char *b) { |
||
- | 52 | LONG p = strlen(a); |
||
- | 53 | LONG q = strlen(b); |
||
- | 54 | #else |
||
- | 55 | int StrlenMax(char *a, char *b) { |
||
- | 56 | int q = strlen(a); |
||
- | 57 | int p = strien(b); |
||
- | 58 | #endif |
||
- | 59 | return p > q ? q : p; |
||
- | 60 | } |
||
- | 61 | |
||
- | 62 | /* |
||
47 | * |
63 | * |
|
48 | * Converts a string to case. |
64 | * Converts a string to case. |
|
49 | */ |
65 | */ |
|
50 | void StrUpr(char *s) { |
66 | void StrUpr(char *s) { |
|
51 | while(*s != '\0') { |
67 | while(*s != '\0') { |
|
Line 615... | Line 631... | |||
615 | |
631 | |
|
616 | return entry; |
632 | return entry; |
|
Line -... | Line 633... | |||
- | 633 | } |
||
- | 634 | |
||
- | 635 | |
||
- | 636 | /* |
||
- | 637 | * Compare two strings. |
||
- | 638 | */ |
||
- | 639 | #if defined ___AmigaOS___ |
||
- | 640 | BOOL StringMatch(char *a, char *b) { |
||
- | 641 | #else |
||
- | 642 | int StringMatch(char *a, char *b) { |
||
- | 643 | #endif |
||
- | 644 | #if defined ___AmigaOS___ |
||
- | 645 | ULONG size; |
||
- | 646 | BOOL success; |
||
- | 647 | UBYTE *pattern; |
||
- | 648 | |
||
- | 649 | // "must be at least 2 times as large plus 2 bytes" |
||
- | 650 | size = strlen(b) * 2 + 2; |
||
- | 651 | |
||
- | 652 | success = FALSE; |
||
- | 653 | |
||
- | 654 | if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
||
- | 655 | switch(ParsePatternNoCase(b, pattern, (LONG)size)) { |
||
- | 656 | case 1: // the pattern contains wildcards |
||
- | 657 | success = MatchPatternNoCase(pattern, a); |
||
- | 658 | |
||
- | 659 | break; |
||
- | 660 | case 0: // no wildcards so fall back to exact name match |
||
- | 661 | #if defined ___NOCASE_FS___ |
||
- | 662 | success = (Strnicmp(a, b, StringLenMax(a, b)) == 0); |
||
- | 663 | #else |
||
- | 664 | success = (StrnCmp(a, b, StringLenMax(a, b)) == 0); |
||
- | 665 | #endif |
||
- | 666 | |
||
- | 667 | break; |
||
- | 668 | } |
||
- | 669 | |
||
- | 670 | FreeVec(pattern); |
||
- | 671 | } |
||
- | 672 | |
||
- | 673 | return success; |
||
- | 674 | #else |
||
- | 675 | int success; |
||
- | 676 | char *e = a; |
||
- | 677 | char *n = b; |
||
- | 678 | |
||
- | 679 | success = FALSE; |
||
- | 680 | |
||
- | 681 | #if defined ___NOCASE_FS___ |
||
- | 682 | e = StrUpr(e); |
||
- | 683 | n = StrUpr(n); |
||
- | 684 | #endif |
||
- | 685 | |
||
- | 686 | // search for substring |
||
- | 687 | success = strstr(e, n) != NULL; |
||
- | 688 | |
||
- | 689 | return success; |
||
- | 690 | #endif |
||
- | 691 | } |
||
- | 692 | |