rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 0d180a2b0601275b773dc60e948831fae18bd020
parent afebc52a8291acb8e32762027277f24ccf0ba375
Author: Bert Münnich <ber.t@posteo.de>
Date:   Sun, 10 Feb 2019 19:02:20 +0100

Remove useless unquote function

It is only needed for completing an open quoted string with an escaped quote:

    'it''s alive

Unfortunately, readline will always treat the last quote character as the start
of the string so that unquote only gets called on "s alive".

Diffstat:
Medit-readline.c | 26+++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/edit-readline.c b/edit-readline.c @@ -44,22 +44,6 @@ static char *quote(char *text, int type, char *qp) { return r; } -/* "unquote" is called with "text", the text of the word to be dequoted, and - * "quote_char", which is the quoting character that delimits the filename. - */ -char *unquote(char *text, int quote_char) { - char *p, *r; - - p = r = ealloc(strlen(text) + 1); - while (*text) { - *p++ = *text++; - if (quote_char && *(text - 1) == '\'' && *text == '\'') - ++text; - } - *p = '\0'; - return r; -} - /* Join two strings with a "/" between them, into a malloc string */ static char *dir_join(char *a, char *b) { char *p; @@ -119,10 +103,10 @@ void split_last_slash(const char *text, char **pre, char **post) { *pre = ealloc(l + 1); strncpy(*pre, text, l); (*pre)[l] = '\0'; - *post = strdup(last_slash + 1); + *post = last_slash + 1; } else { *pre = NULL; - *post = strdup(text); + *post = (char *)text; } } @@ -133,9 +117,7 @@ static char *compl_extcmd(const char *text, int state) { static size_t len; if (!state) { - char *utext = unquote((char *)text, *text); - split_last_slash(utext, &subdirs, &prefix); - efree(utext); + split_last_slash(text, &subdirs, &prefix); d = NULL; if (subdirs && isabsolute(subdirs)) path = &nil; @@ -163,7 +145,6 @@ static char *compl_extcmd(const char *text, int state) { } } efree(subdirs); - efree(prefix); return NULL; } @@ -261,7 +242,6 @@ void *edit_begin(int fd) { rl_basic_word_break_characters = " \t\n`@$><=;|&{("; rl_catch_signals = 0; rl_completer_quote_characters = "'"; - rl_filename_dequoting_function = unquote; rl_filename_quote_characters = quote_chars; rl_filename_quoting_function = quote; rl_readline_name = "rc";