]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix a parameter switch typo in the linux code.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 15 Feb 2008 19:31:27 +0000 (19:31 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 15 Feb 2008 19:31:27 +0000 (19:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8101 d7cf8633-e32d-0410-b094-e92efae38249

filematch.c
fs.c

index 9092f55181332625e093091a80b949cf97a14013..622f774bc204fdcf680a6c066c485e77781f389f 100644 (file)
@@ -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 ad8066859b4a02eb8691ef699eac3a5c00ee60c8..60c89d2609cbe53c7dd201b5daf9d6e40aec355d 100644 (file)
--- 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) );