mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-15 11:56:11 +08:00
Improve windres's handling of pathnames containing special characters on Windows platforms.
PR 4356 * windres.c (quot): Use double quotes to protect strings on Windows platforms.
This commit is contained in:

committed by
Nick Clifton

parent
53e556e5b4
commit
cc3edc5274
@ -1,3 +1,9 @@
|
||||
2021-01-28 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
PR 4356
|
||||
* windres.c (quot): Use double quotes to protect strings on
|
||||
Windows platforms.
|
||||
|
||||
2021-01-28 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
PR 27252
|
||||
|
@ -703,19 +703,44 @@ quot (const char *string)
|
||||
const char *src;
|
||||
char *dest;
|
||||
|
||||
if ((buflen < slen * 2 + 2) || ! buf)
|
||||
if ((buflen < slen * 2 + 3) || ! buf)
|
||||
{
|
||||
buflen = slen * 2 + 2;
|
||||
buflen = slen * 2 + 3;
|
||||
free (buf);
|
||||
buf = (char *) xmalloc (buflen);
|
||||
}
|
||||
|
||||
for (src=string, dest=buf; *src; src++, dest++)
|
||||
#if defined (_WIN32) && !defined (__CYGWIN__)
|
||||
/* For Windows shells, quote "like this". */
|
||||
{
|
||||
bfd_boolean quoted = FALSE;
|
||||
|
||||
dest = buf;
|
||||
if (strchr (string, ' '))
|
||||
{
|
||||
quoted = TRUE;
|
||||
*dest++ = '"';
|
||||
}
|
||||
|
||||
for (src = string; *src; src++, dest++)
|
||||
{
|
||||
/* Escape-protect embedded double quotes. */
|
||||
if (quoted && *src == '"')
|
||||
*dest++ = '\\';
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
*dest++ = '"';
|
||||
}
|
||||
#else
|
||||
for (src = string, dest = buf; *src; src++, dest++)
|
||||
{
|
||||
if (*src == '(' || *src == ')' || *src == ' ')
|
||||
*dest++ = '\\';
|
||||
*dest = *src;
|
||||
}
|
||||
#endif
|
||||
*dest = 0;
|
||||
return buf;
|
||||
}
|
||||
|
Reference in New Issue
Block a user