Support libc's without GLOB_TILDE

GLOB_TILDE is a GNU extension and may not be present on all systems.

Note (jcapik): The original patch from Michael Forney didn't
apply cleanly due to my recent addition of the GLOB_BRACE flag
in the list of flags. I had to edit the patch to make it apply,
but that produces an inconsistent state. It's gonna be fixed
in the next commit.
This commit is contained in:
Michael Forney 2013-10-01 05:34:36 +00:00 committed by Jaromir Capik
parent 007c438148
commit fb6d4e6cb4

View File

@ -502,7 +502,15 @@ static int Preload(const char *restrict const filename)
int globerr;
int j;
#ifdef GLOB_TILDE
globerr = glob(filename, GLOB_NOCHECK | GLOB_TILDE | GLOB_BRACE, NULL, &globbuf);
#else
if (filename[0] == '~')
xwarnx(_("GLOB_TILDE is not supported on your platform, "
"the tilde in \"%s\" won't be expanded."), filename);
globerr = glob(filename, GLOB_NOCHECK, NULL, &globbuf);
#endif
if (globerr != 0 && globerr != GLOB_NOMATCH)
xerr(EXIT_FAILURE, _("glob failed"));