MSYS2-packages/msys2-runtime-3.4/0012-dcrt0.cc-globify-Don-t-quote-literal-strings-differe.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

58 lines
2.1 KiB
Diff

From e9b519af4a971d8d804b05906ef8ab1831bb1f05 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Mon, 24 Aug 2015 00:48:06 +0100
Subject: [PATCH 12/N] dcrt0.cc (globify): Don't quote literal strings
differently when dos_spec
Reverts 25ba8f306f3099caf8397859019e936b90510e8d. I can't figure out what
the intention was. I'm sure I'll find out soon enough when everything breaks.
This change means that input of:
'"C:/test.exe SOME_VAR=\"literal quotes\""'
becomes:
'C:/test.exe SOME_VAR="literal quotes"'
instead of:
'C:/test.exe SOME_VAR=\literal quotes\'
.. which is at least consistent with the result for:
'"no_drive_or_colon SOME_VAR=\"literal quotes\""'
The old result of course resulted in the quoted string being split into
two arguments at the space which is clearly not intended.
I *guess* backslashes in dos paths may have been the issue here?
If so I don't care since we should not use them, ever, esp. not at
the expense of sensible forward-slash-containing input.
---
winsup/cygwin/dcrt0.cc | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 2e6d00a..3c977d0 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -236,10 +236,20 @@ globify (char *word, char **&argv, int &argc, int &argvlen)
char quote = *s;
while (*++s && *s != quote)
{
+ /* This used to be:
if (dos_spec || *s != '\\')
- /* nothing */;
+ // nothing
else if (s[1] == quote || s[1] == '\\')
s++;
+ With commit message:
+ dcrt0.cc (globify): Don't use \ quoting when apparently quoting a DOS path
+ spec, even within a quoted string.
+ But that breaks the "literal quotes" part of '"C:/test.exe SOME_VAR=\"literal quotes\""'
+ giving: 'C:/test.exe SOME_VAR=\literal quotes\' (with \'s between each character)
+ instead of 'C:/test.exe SOME_VAR="literal quotes"' (with \'s between each character)
+ */
+ if (*s == '\\' && (s[1] == quote || s[1] == '\\'))
+ s++;
*p++ = '\\';
size_t cnt = isascii (*s) ? 1 : mbtowc (NULL, s, MB_CUR_MAX);
if (cnt <= 1 || cnt == (size_t)-1)