mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* util.c (name_quote): Don't quote ':', '~' and '@'. Quote '#'
and '~' only if it's the first character.
This commit is contained in:
parent
5cecc135e1
commit
2edd447426
@ -1,5 +1,8 @@
|
||||
2003-01-28 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* util.c (name_quote): Don't quote ':', '~' and '@'. Quote '#'
|
||||
and '~' only if it's the first character.
|
||||
|
||||
* info.c (info_show_info): Cast nlink_t to int to avoid a
|
||||
warning if nlink_t is short.
|
||||
* screen.c (string_file_nlinks): Likewise.
|
||||
|
81
src/util.c
81
src/util.c
@ -143,53 +143,58 @@ trim (char *s, char *d, int len)
|
||||
return d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Quote the filename for the purpose of inserting it into the command
|
||||
* line. If quote_percent is 1, replace "%" with "%%" - the percent is
|
||||
* processed by the mc command line.
|
||||
*/
|
||||
char *
|
||||
name_quote (const char *s, int quote_percent)
|
||||
{
|
||||
char *ret, *d;
|
||||
|
||||
d = ret = g_malloc (strlen (s)*2 + 2 + 1);
|
||||
|
||||
d = ret = g_malloc (strlen (s) * 2 + 2 + 1);
|
||||
if (*s == '-') {
|
||||
*d++ = '.';
|
||||
*d++ = '/';
|
||||
*d++ = '.';
|
||||
*d++ = '/';
|
||||
}
|
||||
|
||||
for (; *s; s++, d++) {
|
||||
switch (*s)
|
||||
{
|
||||
case '%':
|
||||
if (quote_percent)
|
||||
*d++ = '%';
|
||||
break;
|
||||
case '\'':
|
||||
case '\\':
|
||||
case '\r':
|
||||
case '\n':
|
||||
case '\t':
|
||||
case '"':
|
||||
case ':':
|
||||
case ';':
|
||||
case ' ':
|
||||
case '?':
|
||||
case '|':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '<':
|
||||
case '>':
|
||||
case '`':
|
||||
case '~':
|
||||
case '!':
|
||||
case '@':
|
||||
case '#':
|
||||
case '$':
|
||||
case '^':
|
||||
case '&':
|
||||
case '*':
|
||||
case '(':
|
||||
case ')':
|
||||
switch (*s) {
|
||||
case '%':
|
||||
if (quote_percent)
|
||||
*d++ = '%';
|
||||
break;
|
||||
case '\'':
|
||||
case '\\':
|
||||
case '\r':
|
||||
case '\n':
|
||||
case '\t':
|
||||
case '"':
|
||||
case ';':
|
||||
case ' ':
|
||||
case '?':
|
||||
case '|':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '<':
|
||||
case '>':
|
||||
case '`':
|
||||
case '!':
|
||||
case '$':
|
||||
case '&':
|
||||
case '*':
|
||||
case '(':
|
||||
case ')':
|
||||
*d++ = '\\';
|
||||
break;
|
||||
case '~':
|
||||
case '#':
|
||||
if (d == ret)
|
||||
*d++ = '\\';
|
||||
break;
|
||||
}
|
||||
*d = *s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user