discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=f723b88d50639567a352cc806ccc25ca3c32b830

commit f723b88d50639567a352cc806ccc25ca3c32b830
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Mon Feb 29 09:52:54 2016 -0500

    use strbuf instead of strcat in edgebinding string synthesis
    
    CID 1039800
---
 .../conf_bindings/e_int_config_edgebindings.c      | 59 +++++++++++-----------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/modules/conf_bindings/e_int_config_edgebindings.c 
b/src/modules/conf_bindings/e_int_config_edgebindings.c
index 3796b5b..1a08c9a 100644
--- a/src/modules/conf_bindings/e_int_config_edgebindings.c
+++ b/src/modules/conf_bindings/e_int_config_edgebindings.c
@@ -1361,65 +1361,64 @@ _find_edge_binding_action(const char *action, const 
char *params, int *g, int *a
 static char *
 _edge_binding_text_get(E_Zone_Edge edge, float delay, int mod, int drag_only)
 {
-   char b[256] = "";
-
-   if (mod & E_BINDING_MODIFIER_CTRL)
-     strcat(b, _("CTRL"));
+   Eina_Strbuf *b;
+   char *ret;
 
+   b = eina_strbuf_new();
    if (mod & E_BINDING_MODIFIER_ALT)
      {
-        if (b[0]) strcat(b, " + ");
-        strcat(b, _("ALT"));
+        if (eina_strbuf_length_get(b)) eina_strbuf_append(b, " + ");
+        eina_strbuf_append(b, _("ALT"));
      }
 
    if (mod & E_BINDING_MODIFIER_SHIFT)
      {
-        if (b[0]) strcat(b, " + ");
-        strcat(b, _("SHIFT"));
+        if (eina_strbuf_length_get(b)) eina_strbuf_append(b, " + ");
+        eina_strbuf_append(b, _("SHIFT"));
      }
 
    if (mod & E_BINDING_MODIFIER_WIN)
      {
-        if (b[0]) strcat(b, " + ");
-        strcat(b, _("WIN"));
+        if (eina_strbuf_length_get(b)) eina_strbuf_append(b, " + ");
+        eina_strbuf_append(b, _("WIN"));
      }
 
    if (edge)
      {
-        if (b[0]) strcat(b, " + ");
+        if (eina_strbuf_length_get(b)) eina_strbuf_append(b, " + ");
 
         switch (edge)
           {
            case E_ZONE_EDGE_LEFT:
-             strcat(b, _("Left Edge"));
+             eina_strbuf_append(b, _("Left Edge"));
              break;
 
            case E_ZONE_EDGE_TOP:
-             strcat(b, _("Top Edge"));
+             eina_strbuf_append(b, _("Top Edge"));
              break;
 
            case E_ZONE_EDGE_RIGHT:
-             strcat(b, _("Right Edge"));
+             eina_strbuf_append(b, _("Right Edge"));
              break;
 
            case E_ZONE_EDGE_BOTTOM:
-             strcat(b, _("Bottom Edge"));
+             eina_strbuf_append(b, _("Bottom Edge"));
              break;
 
            case E_ZONE_EDGE_TOP_LEFT:
-             strcat(b, _("Top Left Edge"));
+             eina_strbuf_append(b, _("Top Left Edge"));
              break;
 
            case E_ZONE_EDGE_TOP_RIGHT:
-             strcat(b, _("Top Right Edge"));
+             eina_strbuf_append(b, _("Top Right Edge"));
              break;
 
            case E_ZONE_EDGE_BOTTOM_RIGHT:
-             strcat(b, _("Bottom Right Edge"));
+             eina_strbuf_append(b, _("Bottom Right Edge"));
              break;
 
            case E_ZONE_EDGE_BOTTOM_LEFT:
-             strcat(b, _("Bottom Left Edge"));
+             eina_strbuf_append(b, _("Bottom Left Edge"));
              break;
 
            default:
@@ -1429,25 +1428,25 @@ _edge_binding_text_get(E_Zone_Edge edge, float delay, 
int mod, int drag_only)
 
    if (delay)
      {
-        char buf[20];
-
-        if (b[0]) strcat(b, " ");
+        if (eina_strbuf_length_get(b)) eina_strbuf_append(b, " ");
         if (delay == -1.0)
-          snprintf(buf, 20, _("(left clickable)"));
+          eina_strbuf_append(b, _("(left clickable)"));
         else if (delay < -1.0)
-          snprintf(buf, 20, _("(clickable)"));
+          eina_strbuf_append(b, _("(clickable)"));
         else
-          snprintf(buf, 20, "%.2fs", delay);
-        strcat(b, buf);
+          eina_strbuf_append_printf(b, "%.2fs", delay);
      }
 
    if (drag_only)
      {
-        if (b[0]) strcat(b, " ");
-        strcat(b, _("(drag only)"));
+        if (eina_strbuf_length_get(b)) eina_strbuf_append(b, " ");
+        eina_strbuf_append(b, _("(drag only)"));
      }
 
-   if (!b[0]) return strdup(TEXT_NONE_ACTION_EDGE);
-   return strdup(b);
+   ret = eina_strbuf_string_steal(b);
+   eina_strbuf_free(b);
+   if (ret[0]) return ret;
+   free(ret);
+   return strdup(TEXT_NONE_ACTION_EDGE);
 }
 

-- 


Reply via email to