/trunk/HuntnGather/Hunt/Hunt.c/Hunt.c |
@@ -6,9 +6,12 @@ |
#include <stdlib.h> |
#include <string.h> |
#include <dirent.h> |
#include <ctype.h> |
#if !defined ___AmigaOS___ |
#include <signal.h> |
#include <ctype.h> |
#endif |
|
|
#include <sys/types.h> |
#include <sys/stat.h> |
|
@@ -57,32 +60,50 @@ |
} |
|
/* |
* |
* Returns largest of strings. |
*/ |
#if defined ___AmigaOS___ |
LONG StringLenMax(char *a, char *b) { |
LONG p = strlen(a); |
LONG q = strlen(b); |
#else |
int StrlenMax(char *a, char *b) { |
int q = strlen(a); |
int p = strien(b); |
#endif |
return p > q ? p : q; |
} |
|
/* |
* Compare two strings. |
*/ |
#if defined ___AmigaOS___ |
BOOL compare(char *a, char *b) { |
#else |
int compare(char *a, char *b) { |
#endif |
#if defined ___AmigaOS___ |
ULONG size; |
int success; |
BOOL success; |
UBYTE *pattern; |
char *e = a; |
char *n = b; |
|
// "must be at least 2 times as large plus 2 bytes" |
size = strlen(n) * 2 + 2; |
size = strlen(b) * 2 + 2; |
|
success = FALSE; |
|
if(pattern = AllocVec(size, MEMF_ANY|MEMF_CLEAR)) { |
switch(ParsePatternNoCase(n, pattern, (LONG)size)) { |
switch(ParsePatternNoCase(b, pattern, (LONG)size)) { |
case 1: // the pattern contains wildcards |
success = MatchPatternNoCase(pattern, e); |
success = MatchPatternNoCase(pattern, a); |
|
break; |
case 0: // no wildcards so fall back to exact name match |
#if defined ___NOCASE_FS___ |
success = Strnicmp(e, n, (LONG)strlen(n)) == 0; |
success = (Strnicmp(a, b, StringLenMax(a, b)) == 0); |
#else |
success = StrnCmp(e, n, (LONG)strlen(n)) == 0; |
success = (StrnCmp(a, b, StringLenMax(a, b)) == 0); |
#endif |
|
break; |