* $Id$
*
* Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2014, MinGW.org Project
+ * Copyright (C) 2014, 2017, MinGW.org Project
*
* ---------------------------------------------------------------------------
*
* ---------------------------------------------------------------------------
*
*/
+#define _ISOC99_SOURCE
+
#include <glob.h>
#include <string.h>
#include <ctype.h>
/* Capture any non-default globbing options, which the user may have
* specified via a custom setting for _CRT_glob.
*/
- int gl_opts = GLOB_NOCHECK;
- if( _CRT_glob & __CRT_GLOB_CASE_SENSITIVE__ )
- gl_opts |= GLOB_CASEMATCH;
+ int gl_opts = GLOB_NOCHECK | (_CRT_glob & (GLOB_CASEMATCH | GLOB_BRACE));
/* We explicitly DO NOT use the GLOB_DOOFFS capability; ensure that
* the associated field, in the glob_t structure, is initialized to
* need special handling.
*/
case '\\':
- /* We don't (yet) know if this is a literal backslash,
- * (directory separator), or an escape for a following
- * quote character; just note its presence, until we
- * have looked far enough ahead to decide.
- */
- ++bslash;
+ if( quoted == '\'' )
+ /* Backslashes within single quotes are always literal.
+ */
+ *argptr++ = '\\';
+
+ else
+ /* We don't (yet) know if this is a literal backslash,
+ * (directory separator), or an escape for a following
+ * quote character; just note its presence, until we
+ * have looked far enough ahead to decide.
+ */
+ ++bslash;
break;
case '[':
* literally, after flushing out any pending backslashes.
*/
argptr = backslash( bslash, argptr );
- if( (quoted == 0) && isspace( c ) )
+ if( (quoted == 0) && isblank( c ) )
{
- /* The one exception is any white space character,
+ /* The one exception is any blank or tab character,
* when it is not contained within quotes; this acts
* as an argument separator, (or is simply discarded
* if there is no argument already collected)...