Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 1/2] termquery: extract function for URL-encoding and writing to TTY



To be reused in the next patch.

(FWIW, I don't understand how the existing call to "url_encode()"
doesn't leak memory.)
---
 Src/Zle/termquery.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/Src/Zle/termquery.c b/Src/Zle/termquery.c
index c8f5385d9..731589722 100644
--- a/Src/Zle/termquery.c
+++ b/Src/Zle/termquery.c
@@ -765,20 +765,24 @@ mark_output(int start)
 		(start ? sizeof(START) : sizeof(END)) - 1);
 }
 
+static void
+write_urlencoded(const char *path_components)
+{
+    size_t enc_len;
+    const char *enc = url_encode(path_components, &enc_len);
+    write_loop(SHTTY, enc, enc_len);
+}
+
 /**/
 void
 notify_pwd(void)
 {
-    char *url;
-    size_t ulen;
-
     if (!extension_enabled("integration", "pwd", 11, 1))
 	return;
 
-    url = url_encode(pwd, &ulen);
     /* only "localhost" seems to be much use here as the host */
     write_loop(SHTTY, "\033]7;file://localhost", 20);
-    write_loop(SHTTY, url, ulen);
+    write_urlencoded(pwd);
     write_loop(SHTTY, "\033\\", 2);
 }
 
-- 
2.51.0.167.g6ad8021821.dirty





Messages sorted by: Reverse Date, Date, Thread, Author