The following commit has been merged in the master branch: commit 97bdf084f8d655ae03879fa0a6492b00930f17f6 Author: Sergei Trofimovich <sly...@inbox.ru> Date: Sat Feb 7 16:15:41 2009 +0200
shell_unescape: fix recently added breakage of decoding escapy strings This pach fixes two issues (both appear only in escapy strings): * tail cut of escapy string when '\\' is met * head cut of escapy string when '\\' is met :] Signed-off-by: Sergei Trofimovich <sly...@inbox.ru> diff --git a/src/util.c b/src/util.c index cee81e8..e47b6dc 100644 --- a/src/util.c +++ b/src/util.c @@ -1611,7 +1611,7 @@ shell_unescape(const char* text) result = g_strdup(text); return result; } - str = g_string_new(""); + str = g_string_new_len(text, readptr - text); /* if we're here, we're standing on the first '\' */ char c; @@ -1622,6 +1622,9 @@ shell_unescape(const char* text) readptr++; switch ((c = *readptr)) { + case '\0': /* end of string! malformed escape string */ + goto out; + case 'n': g_string_append_c(str,'\n'); break; case 'r': g_string_append_c(str,'\r'); break; case 't': g_string_append_c(str,'\t'); break; @@ -1646,8 +1649,6 @@ shell_unescape(const char* text) case '`': case '"': case ';': - case '\0': /* end of string! malformed escape string */ - goto out; default: g_string_append_c(str,c); break; } @@ -1659,7 +1660,6 @@ shell_unescape(const char* text) readptr++; } out: - g_string_append_c(str,'\0'); result = str->str; g_string_free(str,FALSE); -- Midnight Commander Development _______________________________________________ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel