author | ecalot
<ecalot> 2005-06-14 14:08:33 UTC |
committer | ecalot
<ecalot> 2005-06-14 14:08:33 UTC |
parent | 05b7daabc1e23650c72cb5468472470300b434ab |
PR/doc/changelog.txt | +4 | -6 |
PR/src/include/memory.h | +3 | -2 |
PR/src/lib/layers/idlist.c | +0 | -64 |
PR/src/lib/layers/memory.c | +10 | -0 |
diff --git a/PR/doc/changelog.txt b/PR/doc/changelog.txt index d1f8900..e09057a 100644 --- a/PR/doc/changelog.txt +++ b/PR/doc/changelog.txt @@ -155,16 +155,14 @@ Versions: + Rewritten DAT indexing layer to support pop2 - Rewritten resource handling using dynamic structures - Support of partial list folder selection wildcards (e.g. - vdungeon.dat@vdungeon/chopper/*.bmp) + vdungeon.dat@vdungeon/chopper/*.bmp) '*' and '?' using '&' as escape * PR v1.2 (future plans) - x Finish python interface - x Fix the language support x Add parsing feature @:pahs + x Add pop2 flag to xml file x Add pop2 importing x Add pop2 to resources.xml - x Replace wildcard matching function for a smaller one adding & as - space and fix the space bug - x delete equalsignorecase + x Finish python interface + x Fix the language support 2) ToDo List & Future Plans: diff --git a/PR/src/include/memory.h b/PR/src/include/memory.h index 9d5ba41..26c5947 100644 --- a/PR/src/include/memory.h +++ b/PR/src/include/memory.h @@ -19,7 +19,7 @@ */ /* -memory.h: Princed Resources : Memory handling headers +memory.h: Princed Resources : Memory handling & comparission headers \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf Copyright 2003 Princed Development Team Created: 20 Dec 2003 @@ -40,7 +40,7 @@ memory.h: Princed Resources : Memory handling headers char* strallocandcopy(const char* text); #define freeAllocation(m) if ((m)!=NULL) free(m) -/* equalsIgnoreCase is coded unless we are in the BSD standars that is taken from string.h */ +/* equalsIgnoreCase is built in unless we are in the BSD standars that is taken from string.h */ #ifdef __USE_BSD #include <string.h> #define IGNORE_EQUALS @@ -51,6 +51,7 @@ int equalsIgnoreCase2(const char s1[],const char s2[]); #endif void str5uppercpy (char* dst,const char* src); +int matchesIn(const char *s, const char *p); #endif diff --git a/PR/src/lib/layers/idlist.c b/PR/src/lib/layers/idlist.c index bfef546..bc2cd4c 100644 --- a/PR/src/lib/layers/idlist.c +++ b/PR/src/lib/layers/idlist.c @@ -130,70 +130,6 @@ void parseGivenPath(char* path) { } } -/* TODO rewrite into memory.c */ -/* Code taken from PR 0.1 */ -int getMaskToken(const char texto[],char token[],int* i,int k) { - int j=0; - /* Copy text string until a space is found or the end of line is reached. - * In case the text diesn't fit inside the token it is truncated, but i is increased until the end of the token */ - char entreComillas=0; /* flag indicating if we are inside the quotation marks */ - while ((((entreComillas^=(texto[(*i)]=='"')) || (texto[*i]!=' ')) && ((j<k)?(token[j++]=texto[(*i)++]):(texto[(*i)++])))); - token[j]='\0'; - return (texto[((*i)++)-1]); -} - -int matches1(const char* text,const char* mask,int ptext, int pmask) { - /* - * Verify if the text matches in the mask. - * In case a wildcar * is found it recurses to itself - * Optimization: - * i) multiple contiguous wildcars are taken as single to avoid - * executing the recursivity of order O(n\xb2) more extra times. - * ii) a wildcard at the end of the mask is taken as the end of the - * comparission. No recursivity is needed to know that is true. - * - * " are ignored - * ? is interpreted as any character (including * and ? itself) - * - * Returns true in case it matches and false in case it doesn't - */ - - while (text[ptext]||mask[pmask]) { - if (mask[pmask]=='"') { - pmask++; - } else if (mask[pmask]=='?') { - pmask++; - if (!text[ptext]) return 0; - ptext++; - } else if (mask[pmask]=='*') { - int aux; - while (mask[pmask++]=='*'); /* optimization i */ - pmask--; - if (!mask[pmask]) return 1; /* optimization ii */ - while ((text[ptext]) && !(aux=matches1(text,mask,ptext++,pmask))); - return aux; - } else { - if (text[ptext]!=mask[pmask]) return 0; - ptext++; - pmask++; - } - } - return (text[ptext]==mask[pmask]); -} - -int matchesIn(const char* text,const char* mask) { - int i=0; - char token[PARSING_MAX_TOKEN_SIZE]; - char valor=0; - - /* - * matches in main function: partitionates the text using spaces and matches - * each token against the text - */ - while (getMaskToken(mask,token,&i,PARSING_MAX_TOKEN_SIZE) && !(valor=(valor || matches1(text,token,0,0)))); - return valor?1:matches1(text,token,0,0); -} - int isInThePartialList(const char* vFile, tResourceId id) { /* Cases: diff --git a/PR/src/lib/layers/memory.c b/PR/src/lib/layers/memory.c index 04d39b6..55ec04c 100644 --- a/PR/src/lib/layers/memory.c +++ b/PR/src/lib/layers/memory.c @@ -54,6 +54,16 @@ void str5uppercpy (char* dst,const char* src) { *dst=0; } +int matchesIn(const char *s, const char *p) { + switch(*p) { + case 0: return !(*s); + case '*': return matchesIn(s,p+1) || ((*s) && matchesIn(s+1,p)); + case '?': return (*s) && matchesIn(s+1,p+1); + case '&': p++; + default: return ((*p)==(*s)) && matchesIn(s+1,p+1); + } +} + #ifndef IGNORE_EQUALS int equalsIgnoreCase2(const char s1[],const char s2[]) { int i=0;