MSYS2-packages/msys2-runtime-3.3/0012-dcrt0.cc-globify-Don-t-quote-literal-strings-differe.patch
Christoph Reiter 743bae3086 Add msys2-runtime-3.3
Provides and conflicts with msys2-runtime, so can be used to replace it if wanted.

Keep this as a separate package to test for regressions in cygwin
and to have (in theory) a runtime that supports 32bit in the repo.

There is no guarantee for how long we are going to keep this.
2022-12-09 17:58:25 +01:00

58 lines
2.1 KiB
Diff

From 8cbda4bfc8f6ac7075a294498d62f803f6a141b5 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 d652b32..f75ba5f 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)