mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Original patch as attached on the bugreport
This commit is contained in:
parent
d731741110
commit
b0e39cc68d
45
src/util.c
45
src/util.c
@ -1527,48 +1527,3 @@ Q_ (const char *s)
|
||||
return (sep != NULL) ? sep + 1 : result;
|
||||
}
|
||||
|
||||
/* Unescape paths or other strings for e.g the internal cd */
|
||||
char *
|
||||
unescape_string(const char *in) {
|
||||
GString *str;
|
||||
const char * src;
|
||||
char *result;
|
||||
|
||||
str = g_string_new("");
|
||||
|
||||
for (src = in; *src != '\0'; src++) {
|
||||
if (src[0] == '\\' && strchr(" !#$%&'()*;<>?[]`{|}~", src[1])) {
|
||||
g_string_append_c(str, src[1]);
|
||||
src++;
|
||||
} else {
|
||||
g_string_append_c(str, src[0]);
|
||||
}
|
||||
}
|
||||
|
||||
result = str->str;
|
||||
g_string_free(str, FALSE);
|
||||
return result;
|
||||
}
|
||||
/* To be compatible with the general posix command lines we have to escape *
|
||||
* strings for the command line */
|
||||
char *
|
||||
escape_string ( const char * in ) {
|
||||
GString *str;
|
||||
const char * src;
|
||||
char *result;
|
||||
|
||||
str = g_string_new("");
|
||||
|
||||
for (src = in;src[0] != '\0';src++) {
|
||||
if ( (src[-1] != '\\') && strchr(" !#$%&'()*;<>?[]`{|}~",src[0])) {
|
||||
g_string_append_c(str,'\\');
|
||||
g_string_append_c(str,src[0]);
|
||||
} else {
|
||||
g_string_append_c(str,src[0]);
|
||||
}
|
||||
}
|
||||
|
||||
result = str->str;
|
||||
g_string_free(str, FALSE);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user