MSYS2-packages/msys2-runtime-3.4/0011-dcrt0.cc-Untangle-allow_glob-from-winshell.patch
Christoph Reiter 14e5524bed Add msys2-runtime-3.4
This will be the msys2-runtime variant that still works on Win7.
2024-03-15 17:55:50 +01:00

78 lines
2.9 KiB
Diff

From 8dd6203320a8c33624c7d2e3f0d1d63c6dae3e45 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Fri, 21 Aug 2015 12:52:09 +0100
Subject: [PATCH 11/N] dcrt0.cc: Untangle allow_glob from winshell
Otherwise if globbing is allowed and we get called from a
Windows program, build_argv thinks we've been called from
a Cygwin program.
---
winsup/cygwin/dcrt0.cc | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index b40697a..2e6d00a 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -154,12 +154,12 @@ isquote (char c)
/* Step over a run of characters delimited by quotes */
static /*__inline*/ char *
-quoted (char *cmd, int winshell)
+quoted (char *cmd, int winshell, int glob)
{
char *p;
char quote = *cmd;
- if (!winshell)
+ if (!winshell || !glob)
{
char *p;
strcpy (cmd, cmd + 1);
@@ -169,8 +169,8 @@ quoted (char *cmd, int winshell)
}
const char *s = quote == '\'' ? "'" : "\\\"";
- /* This must have been run from a Windows shell, so preserve
- quotes for globify to play with later. */
+ /* This must have been run from a Windows shell and globbing is enabled,
+ so preserve quotes for globify to play with later. */
while (*cmd && *++cmd)
if ((p = strpbrk (cmd, s)) == NULL)
{
@@ -291,7 +291,7 @@ globify (char *word, char **&argv, int &argc, int &argvlen)
/* Build argv, argc from string passed from Windows. */
static void
-build_argv (char *cmd, char **&argv, int &argc, int winshell)
+build_argv (char *cmd, char **&argv, int &argc, int winshell, int glob)
{
int argvlen = 0;
int nesting = 0; // monitor "nesting" from insert_file
@@ -325,7 +325,7 @@ build_argv (char *cmd, char **&argv, int &argc, int winshell)
a Cygwin process, or if the word starts with a '@'.
In this case, the insert_file function needs an unquoted
DOS filename and globbing isn't performed anyway. */
- cmd = quoted (cmd, winshell && argc > 0 && *word != '@');
+ cmd = quoted (cmd, winshell && argc > 0 && *word != '@', glob);
}
if (issep (*cmd)) // End of argument if space
break;
@@ -351,7 +351,7 @@ build_argv (char *cmd, char **&argv, int &argc, int winshell)
}
/* Add word to argv file after (optional) wildcard expansion. */
- if (!winshell || !argc || !globify (word, argv, argc, argvlen))
+ if (!glob || !argc || !globify (word, argv, argc, argvlen))
{
debug_printf ("argv[%d] = '%s'", argc, word);
argv[argc++] = word;
@@ -903,6 +903,7 @@ dll_crt0_1 (void *)
/* Scan the command line and build argv. Expand wildcards if not
called from another cygwin process. */
build_argv (line, __argv, __argc,
+ NOTSTATE (myself, PID_CYGPARENT),
NOTSTATE (myself, PID_CYGPARENT) && allow_glob);
/* Convert argv[0] to posix rules if it's currently blatantly