Mercurial > yaffs-ecoscentric
changeset 224:88c51f5947b9
Change name matching algorithm
| author | charles |
|---|---|
| date | Wed, 20 Aug 2008 00:14:22 +0100 |
| parents | 93417be1750a |
| children | 16f50fb54fc0 |
| files | direct/yaffsfs.c |
| diffstat | 1 files changed, 27 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -169,6 +169,7 @@ static yaffs_Device *yaffsfs_FindDevice( yaffs_Device *retval = NULL; int thisMatchLength; int longestMatch = -1; + int matching; // Check all configs, choose the one that: // 1) Actually matches a prefix (ie /a amd /abc will not match @@ -178,45 +179,45 @@ static yaffs_Device *yaffsfs_FindDevice( leftOver = path; p = cfg->prefix; thisMatchLength = 0; + matching = 1; - // Strip off any leading /'s - - while(yaffsfs_IsPathDivider(*p)) - p++; - - while(yaffsfs_IsPathDivider(*leftOver)) - leftOver++; - - while(*p && *leftOver && - yaffsfs_Match(*p,*leftOver)) - { - p++; - leftOver++; - thisMatchLength++; - - // Skip over any multiple /'s to treat them as one or - // skip over a trailling / in the prefix, but not the matching string - while(yaffsfs_IsPathDivider(*p) && - (yaffsfs_IsPathDivider(*(p+1)) || !(*(p+1)))) + while(matching && *p && *leftOver){ + // Skip over any /s + while(yaffsfs_IsPathDivider(*p)) p++; - // Only skip over multiple /'s - while(yaffsfs_IsPathDivider(*leftOver) && - yaffsfs_IsPathDivider(*(leftOver+1))) - leftOver++; + // Skip over any /s + while(yaffsfs_IsPathDivider(*leftOver)) + leftOver++; + + // Now match the text part + while(matching && + *p && !yaffsfs_IsPathDivider(*p) && + *leftOver && !yaffsfs_IsPathDivider(*leftOver)){ + if(yaffsfs_Match(*p,*leftOver)){ + p++; + leftOver++; + thisMatchLength++; + } else { + matching = 0; + } + } } + // Skip over any /s in leftOver + while(yaffsfs_IsPathDivider(*leftOver)) + leftOver++; + - if((!*p ) && - (!*leftOver || yaffsfs_IsPathDivider(*leftOver)) && // no more in this path name part - (thisMatchLength > longestMatch)) + if( matching && (thisMatchLength > longestMatch)) { // Matched prefix *restOfPath = (YCHAR *)leftOver; retval = cfg->dev; longestMatch = thisMatchLength; } + cfg++; } return retval;
