billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=fd43c274c19fc69a015ca7e51d92ed6fa4e5a3e2

commit fd43c274c19fc69a015ca7e51d92ed6fa4e5a3e2
Author: Boris Faure <bill...@gmail.com>
Date:   Wed Jan 22 22:12:01 2014 +0100

    fix pasting for real… Closes T706
---
 src/bin/termio.c | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index 44b697c..ddc1050 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1831,36 +1831,37 @@ _getsel_cb(void *data, Evas_Object *obj EINA_UNUSED, 
Elm_Selection_Data *ev)
 
    if (ev->format == ELM_SEL_FORMAT_TEXT)
      {
-        if (ev->len > 0)
+        char *tmp;
+
+        if (ev->len <= 0) return EINA_TRUE;
+
+        tmp = malloc(ev->len);
+        if (tmp)
           {
-             char *tmp;
+             char *s = ev->data;
+             size_t i;
 
              // apparently we have to convert \n into \r in terminal land.
-             tmp = malloc(ev->len + 1);
-             if (tmp)
+             for (i = 0; i < ev->len && s[i]; i++)
+               {
+                  tmp[i] = s[i];
+                  if (tmp[i] == '\n') tmp[i] = '\r';
+               }
+             if (i)
                {
-                  char *s = ev->data;
-                  size_t i;
-
-                  tmp[ev->len] = '\0';
-                  for (i = 0; i < ev->len; i++)
-                    {
-                       tmp[i] = s[i];
-                       if (tmp[i] == '\n') tmp[i] = '\r';
-                    }
-
-                  if (sd->pty->state.bracketed_paste)
-                      termpty_write(sd->pty, "\x1b[200~",
-                                    sizeof("\x1b[200~") - 1);
 
-                  termpty_write(sd->pty, tmp, ev->len);
+                if (sd->pty->state.bracketed_paste)
+                  termpty_write(sd->pty, "\x1b[200~",
+                                sizeof("\x1b[200~") - 1);
 
-                  if (sd->pty->state.bracketed_paste)
-                      termpty_write(sd->pty, "\x1b[201~",
-                                    sizeof("\x1b[201~") - 1);
+                termpty_write(sd->pty, tmp, i);
 
-                  free(tmp);
+                if (sd->pty->state.bracketed_paste)
+                  termpty_write(sd->pty, "\x1b[201~",
+                                sizeof("\x1b[201~") - 1);
                }
+
+             free(tmp);
           }
      }
    else

-- 


Reply via email to