1
1

* util.c (name_quote): Don't quote ':', '~' and '@'. Quote '#'

and '~' only if it's the first character.
Этот коммит содержится в:
Pavel Roskin 2003-01-28 22:52:04 +00:00
родитель 5cecc135e1
Коммит 2edd447426
2 изменённых файлов: 46 добавлений и 38 удалений

Просмотреть файл

@ -1,5 +1,8 @@
2003-01-28 Pavel Roskin <proski@gnu.org> 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 * info.c (info_show_info): Cast nlink_t to int to avoid a
warning if nlink_t is short. warning if nlink_t is short.
* screen.c (string_file_nlinks): Likewise. * screen.c (string_file_nlinks): Likewise.

Просмотреть файл

@ -143,53 +143,58 @@ trim (char *s, char *d, int len)
return d; 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 * char *
name_quote (const char *s, int quote_percent) name_quote (const char *s, int quote_percent)
{ {
char *ret, *d; char *ret, *d;
d = ret = g_malloc (strlen (s)*2 + 2 + 1); d = ret = g_malloc (strlen (s) * 2 + 2 + 1);
if (*s == '-') { if (*s == '-') {
*d++ = '.'; *d++ = '.';
*d++ = '/'; *d++ = '/';
} }
for (; *s; s++, d++) { for (; *s; s++, d++) {
switch (*s) switch (*s) {
{ case '%':
case '%': if (quote_percent)
if (quote_percent) *d++ = '%';
*d++ = '%'; break;
break; case '\'':
case '\'': case '\\':
case '\\': case '\r':
case '\r': case '\n':
case '\n': case '\t':
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 '`':
case '>': case '!':
case '`': case '$':
case '~': case '&':
case '!': case '*':
case '@': case '(':
case '#': case ')':
case '$': *d++ = '\\';
case '^': break;
case '&': case '~':
case '*': case '#':
case '(': if (d == ret)
case ')':
*d++ = '\\'; *d++ = '\\';
break;
} }
*d = *s; *d = *s;
} }