From 30f03f5d76dfb3922b64cad6cfb2b6ab22c82f54 Mon Sep 17 00:00:00 2001 From: black Date: Fri, 15 Feb 2008 19:31:27 +0000 Subject: [PATCH] Fix a parameter switch typo in the linux code. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8101 d7cf8633-e32d-0410-b094-e92efae38249 --- filematch.c | 2 +- fs.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/filematch.c b/filematch.c index 9092f551..622f774b 100644 --- a/filematch.c +++ b/filematch.c @@ -162,7 +162,7 @@ void listdirectory(stringlist_t *list, const char *basepath, const char *path) char fullpath[MAX_OSPATH]; DIR *dir; struct dirent *ent; - dpsnprintf(fullpath, "%s%s", sizeof(fullpath), basepath, *path ? path : "./"); + dpsnprintf(fullpath, sizeof(fullpath), "%s%s", basepath, *path ? path : "./"); dir = opendir(fullpath); if (!dir) return; diff --git a/fs.c b/fs.c index ad806685..60c89d26 100644 --- a/fs.c +++ b/fs.c @@ -2596,7 +2596,6 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) else { stringlist_t matchedSet, foundSet; - int resultindex = 0; const char *start = pattern; stringlistinit(&matchedSet); @@ -2630,20 +2629,21 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) if( !nextseparator ) { nextseparator = start + strlen( start ); } - + + // prevseparator points past the '/' right before the wildcard and nextseparator at the one following it (or at the end of the string) // copy everything up except nextseperator strlcpy(subpattern, pattern, min(sizeof(subpattern), nextseparator - pattern + 1)); - // find the last / + // find the last '/' before the wildcard prevseparator = strrchr( subpattern, '/' ) + 1; if (!prevseparator) { prevseparator = subpattern; } - // copy everything including the last '/' - strlcpy(subpath, start, min(sizeof(subpath), (prevseparator - subpattern) - (start - pattern) + 1)); - - // prevseparator points to the one right before the wildcard and nextseparator to the one following it (or past the end of the string (at \0)) - // start to prevseparator can be opened now and added to the other resultset + // copy everything from start to the previous including the '/' (before the wildcard) + // everything up to start is already included in the path of matchedSet's entries + strlcpy(subpath, start, min(sizeof(subpath), (size_t) ((prevseparator - subpattern) - (start - pattern) + 1))); + + // for each entry in matchedSet try to open the subdirectories specified in subpath for( dirlistindex = 0 ; dirlistindex < matchedSet.numstrings ; dirlistindex++ ) { strlcpy( temp, matchedSet.strings[ dirlistindex ], sizeof(temp) ); strlcat( temp, subpath, sizeof(temp) ); -- 2.39.2