]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fails if no file names can be found when file globbing is on
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 9 Jun 2015 18:23:28 +0000 (20:23 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 9 Jun 2015 18:23:28 +0000 (20:23 +0200)
If file globbing is enabled and no files can be found to match the pattern,
sarg must fail as it does when file globbing is disabled (that was how
sarg worked before file globbing was programmed).

It is meant as a safety in case there is a problem with the generated log
files.

filelist.c

index e851a00cfafc4d22c001490120f935a7d881a1dc..c90e23dfe17579a3ff7a251515ef11d70b69b960 100644 (file)
@@ -439,20 +439,11 @@ const char *FileListIter_Next(struct _FileListIterator *FIter)
                globfree(&FIter->Glob);
                FIter->NextGlob=0;
        }
-       /*
-        * Try every pattern until the list is exhausted or a real error
-        * occurs or a file is matched.
-        */
-       while ((Path=FileListIter_NextWithMask(FIter))!=NULL)
+       Path=FileListIter_NextWithMask(FIter);
+       if (Path!=NULL)
        {
                int ErrCode=glob(Path,GLOB_ERR | GLOB_NOSORT,NULL,&FIter->Glob);
-               if (ErrCode==0)//success
-               {
-                       Path=FIter->Glob.gl_pathv[0];
-                       FIter->NextGlob=1;
-                       break;
-               }
-               if (ErrCode!=GLOB_NOMATCH)
+               if (ErrCode!=0)
                {
                        switch (ErrCode)
                        {
@@ -462,9 +453,14 @@ const char *FileListIter_Next(struct _FileListIterator *FIter)
                        case GLOB_ABORTED:
                                debuga(__FILE__,__LINE__,_("Read error while listing the files matching \"%s\"\n"),Path);
                                break;
+                       case GLOB_NOMATCH:
+                               debuga(__FILE__,__LINE__,_("No files matching \"%s\"\n"),Path);
+                               break;
                        }
                        exit(EXIT_FAILURE);
                }
+               Path=FIter->Glob.gl_pathv[0];
+               FIter->NextGlob=1;
        }
 #else
        /*