diff --git a/src/core/misc.c b/src/core/misc.c index 27741220..e1f199b2 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -757,6 +757,22 @@ char *escape_string(const char *str) return ret; } +/* Escape all '\' chars with '\' */ +char *escape_string_backslashes(const char *str) +{ + char *ret, *p; + + p = ret = g_malloc(strlen(str)*2+1); + while (*str != '\0') { + if (*str == '\\') + *p++ = '\\'; + *p++ = *str++; + } + *p = '\0'; + + return ret; +} + int nearest_power(int num) { int n = 1; diff --git a/src/core/misc.h b/src/core/misc.h index a46a1432..1545f7a2 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -93,6 +93,9 @@ char *ascii_strdown(char *str); /* Escape all '"', "'" and '\' chars with '\' */ char *escape_string(const char *str); +/* Escape all '\' chars with '\' */ +char *escape_string_backslashes(const char *str); + /* convert all low-ascii (<32) to ^ combinations */ char *show_lowascii(const char *str); diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 29a052b3..a6513d58 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -268,7 +268,7 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i /* escape if the word doesn't begin with '/' and expand_escapes are turned on */ data = strchr(cmdchars, *line) == NULL && expand_escapes ? - escape_string(complist->data) : g_strdup(complist->data); + escape_string_backslashes(complist->data) : g_strdup(complist->data); /* word completed */ *pos = startpos + strlen(data);