From: Frederic Marchal Date: Tue, 9 Jun 2015 18:23:28 +0000 (+0200) Subject: Fails if no file names can be found when file globbing is on X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69a910adbd744bff9f2d4f248530306937cc5af7;p=thirdparty%2Fsarg.git Fails if no file names can be found when file globbing is on 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. --- diff --git a/filelist.c b/filelist.c index e851a00..c90e23d 100644 --- a/filelist.c +++ b/filelist.c @@ -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 /*