billiob pushed a commit to branch master.

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

commit 0b488535971aaa43596529920d8b37c99d554be1
Author: Boris Faure <[email protected]>
Date:   Fri Apr 17 23:09:07 2020 +0200

    reduce scope of variables
---
 src/bin/about.c              |   3 +-
 src/bin/col.c                |   4 +-
 src/bin/ipc.c                |   5 +-
 src/bin/keyin.c              |  10 ++-
 src/bin/md5/md5.c            |   3 +-
 src/bin/media.c              |  14 +--
 src/bin/miniview.c           |  10 ++-
 src/bin/options_background.c |  67 +++++++-------
 src/bin/options_font.c       |   2 +-
 src/bin/options_theme.c      |   3 +-
 src/bin/sb.c                 |   3 +-
 src/bin/termio.c             | 208 +++++++++++++++++++++----------------------
 src/bin/termiointernals.c    |  14 ++-
 src/bin/termpty.c            |  23 ++---
 src/bin/termptyops.c         |  14 ++-
 src/bin/tycat.c              |   4 +-
 src/bin/tyfuzz.c             |  10 +--
 src/bin/tyls.c               |  67 +++++++-------
 18 files changed, 246 insertions(+), 218 deletions(-)

diff --git a/src/bin/about.c b/src/bin/about.c
index 80c0e48..ce68634 100644
--- a/src/bin/about.c
+++ b/src/bin/about.c
@@ -58,7 +58,6 @@ about_show(Evas_Object *win, Evas_Object *base, Evas_Object 
*term,
    Evas_Object *o;
    About_Ctx *ctx;
    Config *config = termio_config_get(term);
-   char buf[PATH_MAX];
    const char *txt;
 
    ctx = malloc(sizeof(*ctx));
@@ -74,6 +73,8 @@ about_show(Evas_Object *win, Evas_Object *base, Evas_Object 
*term,
    if (elm_layout_file_set(o, config_theme_path_get(config),
                            "terminology/about") == 0)
      {
+        char buf[PATH_MAX];
+
         snprintf(buf, sizeof(buf), "%s/themes/default.edj",
                  elm_app_data_dir_get());
         elm_layout_file_set(o, buf, "terminology/about");
diff --git a/src/bin/col.c b/src/bin/col.c
index ae6a518..40f3b80 100644
--- a/src/bin/col.c
+++ b/src/bin/col.c
@@ -385,14 +385,14 @@ colors_term_init(Evas_Object *textgrid,
                  const Evas_Object *bg,
                  const Config *config)
 {
-   int c, n;
+   int c;
    char buf[32];
    int r, g , b, a;
    const Color *color;
 
    for (c = 0; c < (4 * 12); c++)
      {
-        n = c + (24 * (c / 24));
+        int n = c + (24 * (c / 24));
         if (config->colors_use)
           {
              r = config->colors[c].r;
diff --git a/src/bin/ipc.c b/src/bin/ipc.c
index 0b9bcdd..e45d934 100644
--- a/src/bin/ipc.c
+++ b/src/bin/ipc.c
@@ -48,8 +48,7 @@ _ipc_hash_get(void)
    const char *disp, *session, *xdg_session, *xdg_id, *xdg_seat, *xdg_vt;
    char *s;
    unsigned int i;
-   unsigned char c1, c2;
-   
+
    /* dumb stoopid hash - i'm feeling lazy */
    disp = getenv("DISPLAY");
    if (!disp) disp = "-unknown-";
@@ -70,6 +69,8 @@ _ipc_hash_get(void)
    memset(hash+12, 'x', 32);
    for (i = 0, s = buf; *s; s++)
      {
+        unsigned char c1, c2;
+
         c1 = (((unsigned char)*s) >> 4) & 0xf;
         c2 = ((unsigned char)*s) & 0x0f;
         hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c1) % 26) + 'a';
diff --git a/src/bin/keyin.c b/src/bin/keyin.c
index 60dd646..065ff3c 100644
--- a/src/bin/keyin.c
+++ b/src/bin/keyin.c
@@ -382,11 +382,9 @@ cb_term_right(Evas_Object *termio_obj)
 static Eina_Bool
 cb_term_new(Evas_Object *termio_obj)
 {
-   RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
+   char path[PATH_MAX], cwd[PATH_MAX];
 
-   char path[PATH_MAX], cwd[PATH_MAX], *cmd;
-   const char *template = "%s -d %s";
-   int length;
+   RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
 
 #if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 16)
    eina_file_path_join(path, sizeof(path), elm_app_bin_dir_get(),
@@ -397,6 +395,10 @@ cb_term_new(Evas_Object *termio_obj)
 #endif
    if (termio_cwd_get(termio_obj, cwd, sizeof(cwd)))
      {
+        const char *template = "%s -d %s";
+        int length;
+        char *cmd;
+
         length = (strlen(path) + strlen(cwd) + strlen(template) - 3);
         cmd = malloc(sizeof(char) * length);
         snprintf(cmd, length, template, path, cwd);
diff --git a/src/bin/md5/md5.c b/src/bin/md5/md5.c
index d437166..4ab77e6 100644
--- a/src/bin/md5/md5.c
+++ b/src/bin/md5/md5.c
@@ -32,9 +32,8 @@ void byteReverse(unsigned char *buf, unsigned longs);
  */
 void byteReverse(unsigned char *buf, unsigned longs)
 {
-    uint32_t t;
     do {
-       t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+         uint32_t t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
            ((unsigned) buf[1] << 8 | buf[0]);
        *(uint32_t *) buf = t;
        buf += 4;
diff --git a/src/bin/media.c b/src/bin/media.c
index 75936a1..3004077 100644
--- a/src/bin/media.c
+++ b/src/bin/media.c
@@ -54,14 +54,17 @@ static Evas_Smart_Class _parent_sc = 
EVAS_SMART_CLASS_INIT_NULL;
 static const char *
 _is_fmt(const char *f, const char **extn)
 {
-   int i, len, l;
+   int i;
+   size_t len;
 
    len = strlen(f);
    for (i = 0; extn[i]; i++)
      {
-        l = strlen(extn[i]);
-        if (len < l) continue;
-        if (!strcasecmp(extn[i], f + len - l)) return extn[i];
+        size_t l = strlen(extn[i]);
+        if (len < l)
+          continue;
+        if (!strcasecmp(extn[i], f + len - l))
+          return extn[i];
      }
    return NULL;
 }
@@ -472,7 +475,6 @@ _type_scale_init(Evas_Object *obj)
 static void
 _type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, 
Evas_Coord h)
 {
-   Evas_Object *o;
    Media *sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0))
@@ -526,6 +528,8 @@ _type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord 
y, Evas_Coord w, Eva
         if (lh < 256) lh = 256;
         if ((lw != sd->sw) || (lh != sd->sh))
           {
+             Evas_Object *o;
+
              o = sd->o_tmp = 
evas_object_image_filled_add(evas_object_evas_get(obj));
              evas_object_smart_member_add(o, obj);
              evas_object_clip_set(o, sd->clip);
diff --git a/src/bin/miniview.c b/src/bin/miniview.c
index 8eb7d55..6d5f4f7 100644
--- a/src/bin/miniview.c
+++ b/src/bin/miniview.c
@@ -213,7 +213,6 @@ void
 miniview_position_offset(const Evas_Object *obj, int by, Eina_Bool sanitize)
 {
    Miniview *mv = evas_object_smart_data_get(obj);
-   int remain = 0;
 
    termio_scroll_get(mv->termio);
    EINA_SAFETY_ON_NULL_RETURN(mv);
@@ -222,6 +221,8 @@ miniview_position_offset(const Evas_Object *obj, int by, 
Eina_Bool sanitize)
 
    if (!mv->fits_to_img)
      {
+        int remain;
+
         mv->screen.pos_val += (double) by / (mv->img_h - mv->rows);
         edje_object_part_drag_value_set(mv->base, "miniview_screen",
                                         0.0, mv->screen.pos_val);
@@ -517,7 +518,6 @@ _deferred_renderer(void *data)
    int history_len, pos;
    ssize_t wret;
    unsigned int *pixels, y;
-   Termcell *cells;
    Termpty *ty;
    unsigned int colors[512];
    double bottom_bound;
@@ -555,8 +555,10 @@ _deferred_renderer(void *data)
 
    for (y = 0; y < mv->img_h; y++)
      {
-        cells = termpty_cellrow_get(ty, mv->img_hist + y, &wret);
-        if (!cells) break;
+        Termcell *cells = termpty_cellrow_get(ty, mv->img_hist + y, &wret);
+
+        if (!cells)
+          break;
         _draw_line(ty, &pixels[y * mv->cols], cells, wret, colors);
      }
    evas_object_image_data_set(mv->img, pixels);
diff --git a/src/bin/options_background.c b/src/bin/options_background.c
index 43241d2..539c743 100644
--- a/src/bin/options_background.c
+++ b/src/bin/options_background.c
@@ -173,43 +173,44 @@ _grid_content_get(void *data, Evas_Object *obj, const 
char *part)
    Background_Ctx *ctx = evas_object_data_get(obj, "ctx");
    assert(ctx);
    Background_Item *item = data;
-   Evas_Object *o, *oe;
    Config *config = ctx->config;
-   char path[PATH_MAX];
 
-   if (!strcmp(part, "elm.swallow.icon"))
+   if (strcmp(part, "elm.swallow.icon"))
+     return NULL;
+
+   if (item->path)
      {
-        if (item->path)
+        int i;
+        Media_Type type;
+        for (i = 0; extn_edj[i]; i++)
           {
-             int i;
-             Media_Type type;
-             for (i = 0; extn_edj[i]; i++)
-               {
-                  if (eina_str_has_extension(item->path, extn_edj[i]))
-                    return media_add(obj, item->path, config,
-                                     MEDIA_BG, MEDIA_TYPE_EDJE);
-               }
-             type = media_src_type_get(item->path);
-             return media_add(obj, item->path, config, MEDIA_THUMB, type);
+             if (eina_str_has_extension(item->path, extn_edj[i]))
+               return media_add(obj, item->path, config,
+                                MEDIA_BG, MEDIA_TYPE_EDJE);
           }
-        else
+        type = media_src_type_get(item->path);
+        return media_add(obj, item->path, config, MEDIA_THUMB, type);
+     }
+   else
+     {
+        Evas_Object *o, *oe;
+        char path[PATH_MAX];
+
+        if (!config->theme)
+          return NULL;
+        snprintf(path, PATH_MAX, "%s/themes/%s", elm_app_data_dir_get(),
+                 config->theme);
+        o = elm_layout_add(obj);
+        oe = elm_layout_edje_get(o);
+        if (!edje_object_file_set(oe, path, "terminology/background"))
           {
-             if (!config->theme)
-               return NULL;
-             snprintf(path, PATH_MAX, "%s/themes/%s", elm_app_data_dir_get(),
-                                                      config->theme);
-             o = elm_layout_add(obj);
-             oe = elm_layout_edje_get(o);
-             if (!edje_object_file_set(oe, path, "terminology/background"))
-               {
-                  evas_object_del(o);
-                  return NULL;
-               }
-             evas_object_show(o);
-             return o;
-         }
+             evas_object_del(o);
+             return NULL;
+          }
+        evas_object_show(o);
+        return o;
      }
-   return NULL;
+   return NULL; /* unreached */
 }
 
 static void
@@ -389,7 +390,6 @@ _cb_entry_changed(void *data,
 static void
 _cb_hoversel_select(Background_Ctx *ctx, const Eina_Stringshare *path)
 {
-   Evas_Object *o;
    if (path)
      {
         elm_flip_go_to(ctx->flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT);
@@ -397,7 +397,7 @@ _cb_hoversel_select(Background_Ctx *ctx, const 
Eina_Stringshare *path)
      }
    else
      {
-        o = elm_object_part_content_get(ctx->flip, "back");
+        Evas_Object *o = elm_object_part_content_get(ctx->flip, "back");
         elm_fileselector_path_set(o, elm_object_text_get(ctx->entry));
         elm_flip_go_to(ctx->flip, EINA_FALSE, ELM_FLIP_PAGE_RIGHT);
      }
@@ -553,7 +553,7 @@ options_background(Evas_Object *opbox, Evas_Object *term)
 {
    Evas_Object *o, *bx, *bx_front;
    Config *config = termio_config_get(term);
-   char path[PATH_MAX], *config_background_dir;
+   char path[PATH_MAX];
    Background_Ctx *ctx;
 
    ctx = calloc(1, sizeof(*ctx));
@@ -706,6 +706,7 @@ options_background(Evas_Object *opbox, Evas_Object *term)
 
    if (config->background)
      {
+        char *config_background_dir;
         config_background_dir = ecore_file_dir_get(config->background);
         elm_object_text_set(ctx->entry, config_background_dir);
         free(config_background_dir);
diff --git a/src/bin/options_font.c b/src/bin/options_font.c
index 3945f6e..696c3ef 100644
--- a/src/bin/options_font.c
+++ b/src/bin/options_font.c
@@ -236,7 +236,6 @@ _cb_op_font_preview_delayed_eval(void *data)
      goto done;
    if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
      {
-        char buf[4096];
         int r, g, b, a;
         Evas *evas = evas_object_evas_get(obj);
         Evas_Object *textgrid = termio_textgrid_get(f->ctx->term);
@@ -250,6 +249,7 @@ _cb_op_font_preview_delayed_eval(void *data)
         evas_object_scale_set(o, elm_config_scale_get());
         if (f->bitmap)
           {
+             char buf[4096];
              snprintf(buf, sizeof(buf), "%s/fonts/%s",
                       elm_app_data_dir_get(), f->full_name);
              evas_object_text_font_set(o, buf, config->font.size);
diff --git a/src/bin/options_theme.c b/src/bin/options_theme.c
index 38fb019..32ced92 100644
--- a/src/bin/options_theme.c
+++ b/src/bin/options_theme.c
@@ -51,11 +51,12 @@ _cb_op_theme_content_get(void *data, Evas_Object *obj, 
const char *part)
 
    if (!strcmp(part, "elm.swallow.icon"))
      {
-        Evas_Object *o;
         Config *config = t->ctx->config;
 
         if (config)
           {
+             Evas_Object *o;
+
              o = options_theme_preview_add(obj, config,
                                            theme_path_get(t->name),
                                            128 * elm_config_scale_get(),
diff --git a/src/bin/sb.c b/src/bin/sb.c
index 38a2e99..7aa7922 100644
--- a/src/bin/sb.c
+++ b/src/bin/sb.c
@@ -80,7 +80,6 @@ ty_sb_spaces_rtrim(struct ty_sb *sb)
 char *
 ty_sb_steal_buf(struct ty_sb *sb)
 {
-   size_t i;
    char *buf;
 
    if (!sb->len)
@@ -88,6 +87,8 @@ ty_sb_steal_buf(struct ty_sb *sb)
 
    if (sb->gap != 0)
      {
+        size_t i;
+
         sb->buf -= sb->gap;
         for (i = 0; i <= sb->len; i++)
           {
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 216c9d1..b773412 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -401,7 +401,6 @@ termio_config_update(Evas_Object *obj)
 {
    Termio *sd = evas_object_smart_data_get(obj);
    Evas_Coord w, h, ow = 0, oh = 0;
-   char buf[4096];
 
    EINA_SAFETY_ON_NULL_RETURN(sd);
 
@@ -410,6 +409,8 @@ termio_config_update(Evas_Object *obj)
 
    if (sd->config->font.bitmap)
      {
+        char buf[4096];
+
         snprintf(buf, sizeof(buf), "%s/fonts/%s",
                  elm_app_data_dir_get(), sd->config->font.name);
         sd->font.name = eina_stringshare_add(buf);
@@ -931,7 +932,6 @@ _cb_ctxp_link_content_copy(void *data,
 {
    Evas_Object *term = data;
    Termio *sd = evas_object_smart_data_get(term);
-   const char *raw_link;
    EINA_SAFETY_ON_NULL_RETURN(sd);
 
    if (sd->link.id)
@@ -945,6 +945,8 @@ _cb_ctxp_link_content_copy(void *data,
    else
      {
         struct ty_sb sb = {.buf = NULL, .len = 0, .alloc = 0};
+        const char *raw_link;
+
         termio_selection_get(sd,
                              sd->link.x1, sd->link.y1,
                              sd->link.x2, sd->link.y2,
@@ -1479,7 +1481,6 @@ _hyperlink_mouseover(Termio *sd,
                      uint16_t link_id)
 {
    Evas_Coord ox, oy, ow, oh;
-   Evas_Object *o;
    int x, y;
    Term_Link *hl;
 
@@ -1506,8 +1507,9 @@ _hyperlink_mouseover(Termio *sd,
    termpty_backscroll_adjust(sd->pty, &sd->scroll);
    for (y = 0; y < sd->grid.h; y++)
      {
-        ssize_t w = 0;
         Termcell *cells;
+        Evas_Object *o;
+        ssize_t w = 0;
         int start_x = -1;
         Eina_Bool add_tooltip = EINA_FALSE;
 
@@ -1607,11 +1609,13 @@ _smart_media_clicked(void *data, Evas_Object *obj, void 
*_info EINA_UNUSED)
                          cmd = config->helper.local.general;
                        if (cmd)
                          {
-                            char buf[PATH_MAX], *escaped;
+                            char *escaped;
 
                             escaped = ecore_file_escape_name(file);
                             if (escaped)
                               {
+                                 char buf[PATH_MAX];
+
                                  snprintf(buf, sizeof(buf), "%s %s", cmd, 
escaped);
                                  ecore_exe_run(buf, NULL);
                                  free(escaped);
@@ -1896,7 +1900,6 @@ static void
 _block_edje_cmds(Termpty *ty, Termblock *blk, Eina_List *cmds, Eina_Bool 
created)
 {
    Eina_List *l;
-   char *s;
 
 #define ISCMD(cmd) !strcmp(s, cmd)
 #define GETS(var) l = l->next; if (!l) return; var = l->data
@@ -1905,7 +1908,7 @@ _block_edje_cmds(Termpty *ty, Termblock *blk, Eina_List 
*cmds, Eina_Bool created
    l = cmds;
    while (l)
      {
-        s = l->data;
+        char *s = l->data;
 
         /////////////////////////////////////////////////////////////////////
         if (ISCMD("text")) // set text part
@@ -3522,6 +3525,7 @@ _smart_pty_command(void *data)
              char *pp;
              int ww = 0, hh = 0, repch;
              Eina_List *strs = NULL;
+             char *link = NULL;
 
              // exact size in CHAR CELLS - WW (decimal) width CELLS,
              // HH (decimal) in CELLS.
@@ -3536,115 +3540,113 @@ _smart_pty_command(void *data)
              //  CMD is the command, P1, P2, P3 etc. are parameters (P2 and
              //  on are optional depending on CMD)
              repch = ty->cur_cmd[2];
-             if (repch)
-               {
-                  char *link = NULL;
+             if (!repch)
+               return;
 
-                  for (p0 = p = &(ty->cur_cmd[3]); *p; p++)
+             for (p0 = p = &(ty->cur_cmd[3]); *p; p++)
+               {
+                  if (*p == ';')
                     {
-                       if (*p == ';')
-                         {
-                            ww = strtol(p0, NULL, 10);
-                            p++;
-                            break;
-                         }
+                       ww = strtol(p0, NULL, 10);
+                       p++;
+                       break;
                     }
-                  for (p0 = p; *p; p++)
+               }
+             for (p0 = p; *p; p++)
+               {
+                  if (*p == ';')
                     {
-                       if (*p == ';')
-                         {
-                            hh = strtol(p0, NULL, 10);
-                            p++;
-                            break;
-                         }
+                       hh = strtol(p0, NULL, 10);
+                       p++;
+                       break;
                     }
-                  if (ty->cur_cmd[1] == 'j')
+               }
+             if (ty->cur_cmd[1] == 'j')
+               {
+                  // parse from p until end of string - one newline
+                  // per list item in strs
+                  p0 = p1 = p;
+                  for (;;)
                     {
-                       // parse from p until end of string - one newline
-                       // per list item in strs
-                       p0 = p1 = p;
-                       for (;;)
+                       // end of str param
+                       if ((*p1 == '\n') || (*p1 == '\r') || (!*p1))
                          {
-                            // end of str param
-                            if ((*p1 == '\n') || (*p1 == '\r') || (!*p1))
+                            // if string is non-empty...
+                            if ((p1 - p0) >= 1)
                               {
-                                 // if string is non-empty...
-                                 if ((p1 - p0) >= 1)
+                                 // allocate, fill and add to list
+                                 pp = malloc(p1 - p0 + 1);
+                                 if (pp)
                                    {
-                                      // allocate, fill and add to list
-                                      pp = malloc(p1 - p0 + 1);
-                                      if (pp)
-                                        {
-                                           strncpy(pp, p0, p1 - p0);
-                                           pp[p1 - p0] = 0;
-                                           strs = eina_list_append(strs, pp);
-                                        }
+                                      strncpy(pp, p0, p1 - p0);
+                                      pp[p1 - p0] = 0;
+                                      strs = eina_list_append(strs, pp);
                                    }
-                                 // end of string buffer
-                                 if (!*p1) break;
-                                 p1++; // skip \n or \r
-                                 p0 = p1;
                               }
-                            else
-                              p1++;
+                            // end of string buffer
+                            if (!*p1) break;
+                            p1++; // skip \n or \r
+                            p0 = p1;
                          }
+                       else
+                         p1++;
                     }
-                  else
+               }
+             else
+               {
+                  path = p;
+                  p = strchr(path, '\n');
+                  if (p)
                     {
-                       path = p;
-                       p = strchr(path, '\n');
-                       if (p)
-                         {
-                            link = strdup(path);
-                            path = p + 1;
-                            if (isspace(path[0])) path++;
-                            pp = strchr(link, '\n');
-                            if (pp) *pp = 0;
-                            pp = strchr(link, '\r');
-                            if (pp) *pp = 0;
-                         }
+                       link = strdup(path);
+                       path = p + 1;
+                       if (isspace(path[0])) path++;
+                       pp = strchr(link, '\n');
+                       if (pp) *pp = 0;
+                       pp = strchr(link, '\r');
+                       if (pp) *pp = 0;
                     }
-                  if ((ww < 512) && (hh < 512))
-                    {
-                       Termblock *blk = NULL;
+               }
+             if ((ww < 512) && (hh < 512))
+               {
+                  Termblock *blk = NULL;
 
-                       if (strs)
-                         {
-                            const char *file, *group;
-                            Eina_List *l;
-
-                            file = eina_list_nth(strs, 0);
-                            group = eina_list_nth(strs, 1);
-                            l = eina_list_nth_list(strs, 2);
-                            blk = termpty_block_new(ty, ww, hh, file, group);
-                            for (;l; l = l->next)
-                              {
-                                 pp = l->data;
-                                 if (pp)
-                                   blk->cmds = eina_list_append(blk->cmds, pp);
-                                 l->data = NULL;
-                              }
-                         }
-                       else
-                         blk = termpty_block_new(ty, ww, hh, path, link);
-                       if (blk)
+                  if (strs)
+                    {
+                       const char *file, *group;
+                       Eina_List *l;
+
+                       file = eina_list_nth(strs, 0);
+                       group = eina_list_nth(strs, 1);
+                       l = eina_list_nth_list(strs, 2);
+                       blk = termpty_block_new(ty, ww, hh, file, group);
+                       for (;l; l = l->next)
                          {
-                            if (ty->cur_cmd[1] == 's')
-                              blk->scale_stretch = EINA_TRUE;
-                            else if (ty->cur_cmd[1] == 'c')
-                              blk->scale_center = EINA_TRUE;
-                            else if (ty->cur_cmd[1] == 'f')
-                              blk->scale_fill = EINA_TRUE;
-                            else if (ty->cur_cmd[1] == 't')
-                              blk->thumb = EINA_TRUE;
-                            else if (ty->cur_cmd[1] == 'j')
-                              blk->edje = EINA_TRUE;
-                            termpty_block_insert(ty, repch, blk);
+                            pp = l->data;
+                            if (pp)
+                              blk->cmds = eina_list_append(blk->cmds, pp);
+                            l->data = NULL;
                          }
                     }
-                  free(link);
-                  EINA_LIST_FREE(strs, pp) free(pp);
+                  else
+                    blk = termpty_block_new(ty, ww, hh, path, link);
+                  if (blk)
+                    {
+                       if (ty->cur_cmd[1] == 's')
+                         blk->scale_stretch = EINA_TRUE;
+                       else if (ty->cur_cmd[1] == 'c')
+                         blk->scale_center = EINA_TRUE;
+                       else if (ty->cur_cmd[1] == 'f')
+                         blk->scale_fill = EINA_TRUE;
+                       else if (ty->cur_cmd[1] == 't')
+                         blk->thumb = EINA_TRUE;
+                       else if (ty->cur_cmd[1] == 'j')
+                         blk->edje = EINA_TRUE;
+                       termpty_block_insert(ty, repch, blk);
+                    }
                }
+             free(link);
+             EINA_LIST_FREE(strs, pp) free(pp);
              return;
           }
         else if (ty->cur_cmd[1] == 'C')
@@ -3718,27 +3720,25 @@ _smart_pty_command(void *data)
           }
         else if (ty->cur_cmd[1] == 'd') // data packet
           {
-             int pksum = atoi(&(ty->cur_cmd[2]));
-             int sum;
              char *p = strchr(ty->cur_cmd, ' ');
              Eina_Bool valid = EINA_TRUE;
 
              if (p)
                {
                   Eina_Binbuf *bb = eina_binbuf_new();
-                  unsigned char v;
 
                   if (bb)
                     {
                        unsigned char localbuf[128];
                        unsigned char localbufpos = 0;
+                       int pksum = atoi(&(ty->cur_cmd[2]));
+                       int sum;
 
                        eina_binbuf_expand(bb, 32 * 1024);
-                       sum = 0;
                        for (sum = 0, p++; *p; p++)
                          {
                             // high nibble
-                            v = (unsigned char)(*p);
+                            unsigned char v = (unsigned char)(*p);
                             sum += v;
                             v = ((v - '@') & 0xf) << 4;
                             // low nibble
@@ -3852,13 +3852,13 @@ _smart_cb_drop(void *data,
      {
         if (strchr(ev->data, '\n'))
           {
-             char *p, *p2, *p3, *tb;
-
-             tb = malloc(strlen(ev->data) + 1);
+             char *tb = malloc(strlen(ev->data) + 1);
              if (tb)
                {
+                  char *p;
                   for (p = ev->data; p;)
                     {
+                       char *p2, *p3;
                        p2 = strchr(p, '\n');
                        p3 = strchr(p, '\r');
                        if (p2 && p3)
diff --git a/src/bin/termiointernals.c b/src/bin/termiointernals.c
index d12f978..af6bc5f 100644
--- a/src/bin/termiointernals.c
+++ b/src/bin/termiointernals.c
@@ -2735,17 +2735,23 @@ termio_internal_render(Termio *sd,
    preedit_str = term_preedit_str_get(sd->term);
    if (preedit_str && preedit_str[0])
      {
-        Eina_Unicode *uni, g;
-        int len = 0, i, jump, xx, backx;
-        Eina_Bool dbl;
-        Evas_Textgrid_Cell *tc;
+        Eina_Unicode *uni;
+        int len = 0;
         x = sd->cursor.x, y = sd->cursor.y;
 
         uni = eina_unicode_utf8_to_unicode(preedit_str, &len);
         if (uni)
           {
+             int i;
              for (i = 0; i < len; i++)
                {
+                  int backx;
+                  int xx;
+                  int jump;
+                  Eina_Bool dbl;
+                  Evas_Textgrid_Cell *tc;
+                  Eina_Unicode g;
+
                   jump = 1;
                   g = uni[i];
                   dbl = _termpty_is_dblwidth_get(sd->pty, g);
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index fdb5869..d881d31 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -227,15 +227,15 @@ _pty_size(Termpty *ty)
 static Eina_Bool
 _handle_read(Termpty *ty, Eina_Bool false_on_empty)
 {
-   char buf[4097];
-   Eina_Unicode codepoint[4097];
-   int len, i, j, reads;
-   unsigned int k;
+   int len, reads;
 
    // read up to 64 * 4096 bytes
    for (reads = 0; reads < 64; reads++)
      {
+        Eina_Unicode codepoint[4097];
+        char buf[4097];
         char *rbuf = buf;
+        int i, j;
         len = sizeof(buf) - 1;
 
         for (i = 0; i < (int)sizeof(ty->oldbuf) && ty->oldbuf[i] & 0x80; i++)
@@ -293,6 +293,8 @@ _handle_read(Termpty *ty, Eina_Bool false_on_empty)
                   if ((0xdc80 <= g) && (g <= 0xdcff) &&
                       (len - prev_i) <= (int)sizeof(ty->oldbuf))
                     {
+                       unsigned int k;
+
                        for (k = 0;
                             (k < (unsigned int)sizeof(ty->oldbuf)) &&
                             (k < (unsigned int)(len - prev_i));
@@ -474,7 +476,7 @@ termpty_resize_tabs(Termpty *ty, int old_w, int new_w)
 {
     unsigned int *new_tabs;
     int i;
-    size_t nb_elems, n;
+    size_t nb_elems;
 
     if ((new_w == old_w) && ty->tabs) return;
 
@@ -484,7 +486,7 @@ termpty_resize_tabs(Termpty *ty, int old_w, int new_w)
 
     if (ty->tabs)
       {
-         n = old_w;
+         size_t n = old_w;
          if (nb_elems < n) n = nb_elems;
          if (n > 0) memcpy(new_tabs, ty->tabs, n * sizeof(unsigned int));
          free(ty->tabs);
@@ -707,12 +709,9 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const 
char *cd,
      }
    if (!ty->pid)
      {
-        char buf[256];
-        int ret;
-
         if (cd)
           {
-             ret = chdir(cd);
+             int ret = chdir(cd);
              if (ret != 0)
                {
                   ERR(_("Could not change current directory to '%s': %s"),
@@ -772,6 +771,8 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const 
char *cd,
         putenv("XTERM_256_COLORS=1");
         if (window_id)
           {
+             char buf[256];
+
              snprintf(buf, sizeof(buf), "WINDOWID=%lu", window_id);
              putenv(buf);
           }
@@ -931,7 +932,7 @@ _termpty_line_is_empty(const Termcell *cells, ssize_t 
nb_cells)
 ssize_t
 termpty_line_length(const Termcell *cells, ssize_t nb_cells)
 {
-   ssize_t len = nb_cells;
+   ssize_t len;
 
    if (!cells)
      return 0;
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index a01630d..5bcbe7b 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -38,8 +38,8 @@ termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
 void
 termpty_text_scroll(Termpty *ty, Eina_Bool clear)
 {
-   Termcell *cells = NULL, *cells2;
-   int y, start_y = 0, end_y = ty->h - 1;
+   Termcell *cells = NULL;
+   int start_y = 0, end_y = ty->h - 1;
 
    start_y = ty->termstate.top_margin;
    if (ty->termstate.bottom_margin != 0)
@@ -69,6 +69,7 @@ termpty_text_scroll(Termpty *ty, Eina_Bool clear)
      {
         int x = ty->termstate.left_margin;
         int w = ty->w - x;
+        int y;
 
         if (ty->termstate.right_margin)
           w = ty->termstate.right_margin - x;
@@ -76,6 +77,8 @@ termpty_text_scroll(Termpty *ty, Eina_Bool clear)
         cells = &(TERMPTY_SCREEN(ty, x, end_y));
         for (y = start_y; y < end_y; y++)
           {
+             Termcell *cells2;
+
              cells = &(TERMPTY_SCREEN(ty, x, (y + 1)));
              cells2 = &(TERMPTY_SCREEN(ty, x, y));
              TERMPTY_CELL_COPY(ty, cells, cells2, w);
@@ -88,8 +91,8 @@ termpty_text_scroll(Termpty *ty, Eina_Bool clear)
 void
 termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
 {
-   Termcell *cells, *cells2 = NULL;
-   int y, start_y = 0, end_y = ty->h - 1;
+   Termcell *cells;
+   int start_y = 0, end_y = ty->h - 1;
 
    if (ty->termstate.bottom_margin != 0)
      {
@@ -116,6 +119,7 @@ termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
      {
         int x = ty->termstate.left_margin;
         int w = ty->w - x;
+        int y;
 
         if (ty->termstate.right_margin)
           w = ty->termstate.right_margin - x;
@@ -123,6 +127,8 @@ termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
         cells = &(TERMPTY_SCREEN(ty, x, end_y));
         for (y = end_y; y > start_y; y--)
           {
+             Termcell *cells2;
+
              cells = &(TERMPTY_SCREEN(ty, x, (y - 1)));
              cells2 = &(TERMPTY_SCREEN(ty, x, y));
              TERMPTY_CELL_COPY(ty, cells, cells2, w);
diff --git a/src/bin/tycat.c b/src/bin/tycat.c
index d9a10ef..2def982 100644
--- a/src/bin/tycat.c
+++ b/src/bin/tycat.c
@@ -69,12 +69,12 @@ scaleterm(int w, int h, int *iw, int *ih)
 static const char *
 is_fmt(const char *f, const char **extn)
 {
-   int i, len, l;
+   int i, len;
 
    len = strlen(f);
    for (i = 0; extn[i]; i++)
      {
-        l = strlen(extn[i]);
+        int l = strlen(extn[i]);
         if (len < l) continue;
         if (!strcasecmp(extn[i], f + len - l)) return extn[i];
      }
diff --git a/src/bin/tyfuzz.c b/src/bin/tyfuzz.c
index a6e18a2..21cd895 100644
--- a/src/bin/tyfuzz.c
+++ b/src/bin/tyfuzz.c
@@ -287,10 +287,6 @@ _termpty_init(Termpty *ty, Config *config)
 int
 main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
 {
-   char buf[4097];
-   Eina_Unicode codepoint[4097];
-   int len, i, j, k;
-
    eina_init();
 
 #ifdef TYTEST
@@ -319,8 +315,11 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
 
    do
      {
+        char buf[4097];
+        Eina_Unicode codepoint[4097];
+        int i, j;
         char *rbuf = buf;
-        len = sizeof(buf) - 1;
+        int len = sizeof(buf) - 1;
 
         for (i = 0; i < (int)sizeof(_ty.oldbuf) && _ty.oldbuf[i] & 0x80; i++)
           {
@@ -354,6 +353,7 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
                   if ((0xdc80 <= g) && (g <= 0xdcff) &&
                       (len - prev_i) <= (int)sizeof(_ty.oldbuf))
                     {
+                       int k;
                        for (k = 0;
                             (k < (int)sizeof(_ty.oldbuf)) &&
                             (k < (len - prev_i));
diff --git a/src/bin/tyls.c b/src/bin/tyls.c
index 8c0c190..2b7639c 100644
--- a/src/bin/tyls.c
+++ b/src/bin/tyls.c
@@ -98,7 +98,7 @@ colorprint(int mode, int fgbg, int r, int g, int b)
    else if (mode == CORE) // 8 bg and 8 fg colors
      {
         int v = 0;
-        
+
         if (r & BRIGHT) printf("%c[01m", 0x1b);
         else printf("%c[0m", 0x1b);
         if (fgbg == FG) v = 30 + (r & 0x7);
@@ -108,7 +108,7 @@ colorprint(int mode, int fgbg, int r, int g, int b)
    else if (mode == CUBE) // 6x6x6 cube
      {
         int v = 0, c = 0;
-        
+
         if (fgbg == FG) v = 38;
         else v = 48;
         c = 16 + ((r * 6 * 6) + (g * 6) + b);
@@ -244,7 +244,7 @@ const Cmatch fmatch[] =
    { 5, 5, 5,  9, 9, 9, "*.SRF", NULL},
    { 5, 5, 5,  9, 9, 9, "*.x3f", NULL},
    { 5, 5, 5,  9, 9, 9, "*.X3F", NULL},
-   
+
    { 5, 5, 2,  9, 9, 9, "*.pdf", NULL},
    { 5, 5, 2,  9, 9, 9, "*.PDF", NULL},
    { 5, 5, 2,  9, 9, 9, "*.pdf", NULL},
@@ -302,7 +302,7 @@ const Cmatch fmatch[] =
    { 3, 4, 5,  9, 9, 9, "*.3p2", NULL},
    { 3, 4, 5,  9, 9, 9, "*.264", NULL},
    { 3, 4, 5,  9, 9, 9, "*.3gp", NULL},
-   
+
    { 2, 3, 5,  9, 9, 9, "*.mp3", "audio-x-mpeg.svg"},
    { 2, 3, 5,  9, 9, 9, "*.MP3", "audio-x-mpeg.svg"},
    { 2, 3, 5,  9, 9, 9, "*.aac", "audio-x-generic.svg"},
@@ -313,7 +313,7 @@ const Cmatch fmatch[] =
    { 2, 3, 5,  9, 9, 9, "*.WAV", "audio-x-wav.svg"},
    { 2, 3, 5,  9, 9, 9, "*.m3u", "audio-x-mp3-playlist"},
    { 2, 3, 5,  9, 9, 9, "*.M3U", "audio-x-mp3-playlist"},
-   
+
    { 3, 5, 2,  9, 9, 9, "*.patch", "text-x-generic"},
    { 3, 5, 2,  9, 9, 9, "*.PATCH", "text-x-generic"},
    { 3, 5, 2,  9, 9, 9, "*.diff", "text-x-generic"},
@@ -347,7 +347,7 @@ const Cmatch fmatch[] =
    { 0, 5, 2,  9, 9, 9, "*.ISO", "application-x-cd-image"},
    { 0, 5, 2,  9, 9, 9, "*.img", "text-x-generic"},
    { 0, 5, 2,  9, 9, 9, "*.IMG", "text-x-generic"},
-   
+
    { 3, 5, 1,  9, 9, 9, "*.ttf", "font-x-generic"},
    { 3, 5, 1,  9, 9, 9, "*.TTF", "font-x-generic"},
    { 3, 5, 1,  9, 9, 9, "*.bdf", "font-x-generic"},
@@ -356,7 +356,7 @@ const Cmatch fmatch[] =
    { 3, 5, 1,  9, 9, 9, "*.PCF", "font-x-generic"},
 
    { 1, 1, 1,  9, 9, 9, "*~", "text-x-generic"},
-   
+
    { 1, 2, 2,  9, 9, 9, "stamp-h1", "text-x-generic"},
 
    { 5, 3, 1,  9, 9, 9, "Makefile", "text-x-generic"},
@@ -364,9 +364,9 @@ const Cmatch fmatch[] =
    { 3, 1, 0,  9, 9, 9, "*.am", "text-x-generic"},
 
    { 4, 2, 5,  9, 9, 9, "*.spec", "text-x-generic"},
-   
+
    { 4, 1, 5,  9, 9, 9, "*.m4", "application-x-m4"},
-   
+
    { 5, 2, 0,  9, 9, 9, "*.sh", "text-x-generic"},
    { 5, 2, 0,  9, 9, 9, "*.SH", "text-x-generic"},
    { 5, 2, 0,  9, 9, 9, "*.bin", "text-x-generic"},
@@ -379,7 +379,7 @@ const Cmatch fmatch[] =
    { 5, 2, 0,  9, 9, 9, "configure.ac", "text-x-generic"},
 
    { 2, 2, 3,  9, 9, 9, "*.in", "text-x-generic"},
-   
+
    { 0, 5, 5,  9, 9, 9, "*.c", "text-x-c"},
    { 0, 5, 5,  9, 9, 9, "*.C", "text-x-c"},
    { 1, 4, 5,  9, 9, 9, "*.x", "text-x-c"},
@@ -392,7 +392,7 @@ const Cmatch fmatch[] =
 
    { 5, 3, 0,  9, 9, 9, "*.edj", "text-x-generic"},
    { 5, 3, 0,  9, 9, 9, "*.EDJ", "text-x-generic"},
-   
+
    { 5, 0, 5,  9, 9, 9, "*.cc", "text-x-c++"},
    { 5, 0, 5,  9, 9, 9, "*.CC", "text-x-c++"},
    { 3, 1, 5,  9, 9, 9, "*.hh", "text-x-c++hdr"},
@@ -403,7 +403,7 @@ const Cmatch fmatch[] =
 
    { 2, 0, 5,  9, 9, 9, "*.desktop", "application-x-desktop"},
    { 2, 0, 5,  9, 9, 9, "*.directory", "application-x-desktop"},
-   
+
    { 0, 1, 3,  9, 9, 9, "*.o", "text-x-generic"},
    { 0, 1, 3,  9, 9, 9, "*.O", "text-x-generic"},
    { 0, 1, 3,  9, 9, 9, "*.lo", "text-x-generic"},
@@ -435,7 +435,7 @@ const Cmatch fmatch[] =
    { 3, 1, 5,  9, 9, 9, "*.HTM", "text-x-html"},
    { 3, 1, 5,  9, 9, 9, "*.css", "text-x-css"},
    { 3, 1, 5,  9, 9, 9, "*.CSS", "text-x-css"},
-   
+
    { 0, 0, 0,  0, 0, 0, NULL, NULL}
 };
 
@@ -460,7 +460,7 @@ const Cmatch xmatch[] =
    { 4, 0, 4,  9, 9, 9, "*.EXE", "application-x-executable"},
 
    { 5, 0, 5,  9, 9, 9, "*", "application-x-executable"},
-   
+
    { 0, 0, 0,  0, 0, 0, NULL, NULL}
 };
 
@@ -468,7 +468,7 @@ static const char *
 filematch(const char *name, const Cmatch *m)
 {
    int i;
-   
+
    for (i = 0; m[i].match; i++)
      {
         if (!fnmatch(m[i].match, name, 0))
@@ -483,7 +483,7 @@ fileicon(const char *path)
    Eina_Bool isdir = EINA_FALSE;
    Eina_Bool isexec = EINA_FALSE;
    const char *name;
-   
+
    name = ecore_file_file_get(path);
    if (name)
      {
@@ -502,7 +502,7 @@ static Eina_Bool
 printmatch(const char *name, const Cmatch *m)
 {
    int i;
-   
+
    for (i = 0; m[i].match; i++)
      {
         if (!fnmatch(m[i].match, name, 0))
@@ -522,11 +522,11 @@ fileprint(char *path, char *name, Eina_Bool type)
    Eina_Bool isdir = EINA_FALSE;
    Eina_Bool islink = EINA_FALSE;
    Eina_Bool isexec = EINA_FALSE;
-   
+
    if (name || type)
      {
         char *ts;
-             
+
         if (ecore_file_is_dir(path)) isdir = EINA_TRUE;
         ts = ecore_file_readlink(path);
         if (ts)
@@ -590,8 +590,8 @@ list_dir(const char *dir, Tyls_Options *options)
 {
    Eina_List *files, *l;
    char *s, **names;
-   int maxlen = 0, cols, c, rows, i, j, num, cw, stuff;
-   
+   int maxlen = 0, i, num, stuff;
+
    files = ecore_file_ls(dir);
    if (!files) return;
    names = calloc(eina_list_count(files) * 2, sizeof(char *));
@@ -600,7 +600,7 @@ list_dir(const char *dir, Tyls_Options *options)
    EINA_LIST_FOREACH(files, l, s)
      {
         int len = eina_unicode_utf8_get_len(s);
-        
+
         if (s[0] == '.' && options->hidden == EINA_FALSE) continue;
         if (len > maxlen) maxlen = len;
         names[i] = s;
@@ -618,7 +618,9 @@ list_dir(const char *dir, Tyls_Options *options)
    maxlen += stuff;
    if (maxlen > 0)
      {
-        cols = tw / maxlen;
+        int rows;
+        int cols = tw / maxlen;
+
         if (cols < 1) cols = 1;
         if (cols == 1)
           {
@@ -632,14 +634,15 @@ list_dir(const char *dir, Tyls_Options *options)
           {
              char buf[4096];
              const char *icon;
-             
+             int c, j, cw;
+
              if (options->mode == SMALL)
                {
                   for (c = 0; c < cols; c++)
                     {
                        char sz[6], szch = ' ';
                        long long size;
-                       
+
                        s = names[(c * rows) + i];
                        if (!s) continue;
                        snprintf(buf, sizeof(buf), "%s/%s", dir, s);
@@ -694,7 +697,7 @@ list_dir(const char *dir, Tyls_Options *options)
                        char sz[6], szch = ' ';
                        long long size;
                        int len;
-                       
+
                        s = names[(c * rows) + i];
                        if (!s) continue;
                        snprintf(buf, sizeof(buf), "%s/%s", dir, s);
@@ -738,9 +741,6 @@ print_usage(const char *argv0)
 int
 main(int argc, char **argv)
 {
-   char buf[64];
-   char *path;
-   Eina_List *dirs = NULL;
    Tyls_Options options = {SMALL, EINA_FALSE};
 
    ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
@@ -759,7 +759,9 @@ main(int argc, char **argv)
      {
         int i, cw, ch;
         int len;
-        char *rp;
+        char buf[64];
+        char *path;
+        Eina_List *dirs = NULL;
 
         evas = ecore_evas_get(ee);
         echo_off();
@@ -806,7 +808,9 @@ main(int argc, char **argv)
           }
         EINA_LIST_FREE(dirs, path)
           {
-            if ((rp = ecore_file_realpath(path))
+             char *rp;
+
+             if ((rp = ecore_file_realpath(path))
                  && ecore_file_is_dir(rp))
                {
                   list_dir(rp, &options);
@@ -814,7 +818,6 @@ main(int argc, char **argv)
                }
           }
         fflush(stdout);
-//        ecore_main_loop_begin();
         ecore_evas_free(ee);
      }
    emotion_shutdown();

-- 


Reply via email to