summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@gmail.com>2016-01-30 22:57:55 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-09-09 19:58:36 +0200
commit4e647ad27476f09f02e3ba989eb231c242ae6022 (patch)
tree2094b32b2ed93addcd4b93a088c0da49868d92c1
parentf403a29fdb1402f45790bb67a42a6d846f33984e (diff)
termio: don't use strlen() when it can be avoideddevs/jayji/fixes
-rw-r--r--src/bin/termio.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 9ec1444..96ef5c1 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -3637,30 +3637,32 @@ _rep_mouse_down(Termio *sd, Evas_Event_Mouse_Down *ev, int cx, int cy)
3637 buf[i++] = 0x80 + (v & 0x3f); 3637 buf[i++] = 0x80 + (v & 0x3f);
3638 } 3638 }
3639 buf[i] = 0; 3639 buf[i] = 0;
3640 termpty_write(sd->pty, buf, strlen(buf)); 3640 termpty_write(sd->pty, buf, i);
3641 ret = EINA_TRUE; 3641 ret = EINA_TRUE;
3642 } 3642 }
3643 break; 3643 break;
3644 case MOUSE_EXT_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M 3644 case MOUSE_EXT_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M
3645 { 3645 {
3646 int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0; 3646 int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
3647 int len;
3647 3648
3648 if (btn > 2) btn = 0; 3649 if (btn > 2) btn = 0;
3649 snprintf(buf, sizeof(buf), "%c[<%i;%i;%iM", 0x1b, 3650 len = snprintf(buf, sizeof(buf), "%c[<%i;%i;%iM", 0x1b,
3650 (btn | meta), cx + 1, cy + 1); 3651 (btn | meta), cx + 1, cy + 1);
3651 termpty_write(sd->pty, buf, strlen(buf)); 3652 termpty_write(sd->pty, buf, len);
3652 ret = EINA_TRUE; 3653 ret = EINA_TRUE;
3653 } 3654 }
3654 break; 3655 break;
3655 case MOUSE_EXT_URXVT: // ESC.[.NUM.;.NUM.;.NUM.M 3656 case MOUSE_EXT_URXVT: // ESC.[.NUM.;.NUM.;.NUM.M
3656 { 3657 {
3657 int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0; 3658 int meta = evas_key_modifier_is_set(ev->modifiers, "Alt") ? 8 : 0;
3659 int len;
3658 3660
3659 if (btn > 2) btn = 0; 3661 if (btn > 2) btn = 0;
3660 snprintf(buf, sizeof(buf), "%c[%i;%i;%iM", 0x1b, 3662 len = snprintf(buf, sizeof(buf), "%c[%i;%i;%iM", 0x1b,
3661 (btn | meta) + ' ', 3663 (btn | meta) + ' ',
3662 cx + 1, cy + 1); 3664 cx + 1, cy + 1);
3663 termpty_write(sd->pty, buf, strlen(buf)); 3665 termpty_write(sd->pty, buf, len);
3664 ret = EINA_TRUE; 3666 ret = EINA_TRUE;
3665 } 3667 }
3666 break; 3668 break;
@@ -5547,10 +5549,11 @@ _smart_pty_command(void *data)
5547 if (ty->cur_cmd[1] == 's') 5549 if (ty->cur_cmd[1] == 's')
5548 { 5550 {
5549 char buf[256]; 5551 char buf[256];
5552 int len;
5550 5553
5551 snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n", 5554 len = snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n",
5552 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh); 5555 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh);
5553 termpty_write(ty, buf, strlen(buf)); 5556 termpty_write(ty, buf, len);
5554 return; 5557 return;
5555 } 5558 }
5556 else if (ty->cur_cmd[1] == 'j') 5559 else if (ty->cur_cmd[1] == 'j')
@@ -5790,10 +5793,11 @@ _smart_pty_command(void *data)
5790 if (ty->cur_cmd[1] == 's') 5793 if (ty->cur_cmd[1] == 's')
5791 { 5794 {
5792 char buf[256]; 5795 char buf[256];
5796 int len;
5793 5797
5794 snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n", 5798 len = snprintf(buf, sizeof(buf), "%i;%i;%i;%i\n",
5795 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh); 5799 sd->grid.w, sd->grid.h, sd->font.chw, sd->font.chh);
5796 termpty_write(ty, buf, strlen(buf)); 5800 termpty_write(ty, buf, len);
5797 return; 5801 return;
5798 } 5802 }
5799 else if (ty->cur_cmd[1] == 'j') 5803 else if (ty->cur_cmd[1] == 'j')
@@ -5867,7 +5871,7 @@ _smart_cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
5867 { 5871 {
5868 char *p, *p2, *p3, *tb; 5872 char *p, *p2, *p3, *tb;
5869 5873
5870 tb = malloc(strlen(ev->data) + 1); 5874 tb = malloc(ev->len + 1);
5871 if (tb) 5875 if (tb)
5872 { 5876 {
5873 for (p = ev->data; p;) 5877 for (p = ev->data; p;)