reduce scope of variables

This commit is contained in:
Boris Faure 2020-04-17 23:09:07 +02:00
parent 3172c2cf30
commit 0b48853597
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
18 changed files with 250 additions and 222 deletions

View File

@ -58,7 +58,6 @@ about_show(Evas_Object *win, Evas_Object *base, Evas_Object *term,
Evas_Object *o; Evas_Object *o;
About_Ctx *ctx; About_Ctx *ctx;
Config *config = termio_config_get(term); Config *config = termio_config_get(term);
char buf[PATH_MAX];
const char *txt; const char *txt;
ctx = malloc(sizeof(*ctx)); 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), if (elm_layout_file_set(o, config_theme_path_get(config),
"terminology/about") == 0) "terminology/about") == 0)
{ {
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/themes/default.edj", snprintf(buf, sizeof(buf), "%s/themes/default.edj",
elm_app_data_dir_get()); elm_app_data_dir_get());
elm_layout_file_set(o, buf, "terminology/about"); elm_layout_file_set(o, buf, "terminology/about");

View File

@ -385,14 +385,14 @@ colors_term_init(Evas_Object *textgrid,
const Evas_Object *bg, const Evas_Object *bg,
const Config *config) const Config *config)
{ {
int c, n; int c;
char buf[32]; char buf[32];
int r, g , b, a; int r, g , b, a;
const Color *color; const Color *color;
for (c = 0; c < (4 * 12); c++) for (c = 0; c < (4 * 12); c++)
{ {
n = c + (24 * (c / 24)); int n = c + (24 * (c / 24));
if (config->colors_use) if (config->colors_use)
{ {
r = config->colors[c].r; r = config->colors[c].r;

View File

@ -48,7 +48,6 @@ _ipc_hash_get(void)
const char *disp, *session, *xdg_session, *xdg_id, *xdg_seat, *xdg_vt; const char *disp, *session, *xdg_session, *xdg_id, *xdg_seat, *xdg_vt;
char *s; char *s;
unsigned int i; unsigned int i;
unsigned char c1, c2;
/* dumb stoopid hash - i'm feeling lazy */ /* dumb stoopid hash - i'm feeling lazy */
disp = getenv("DISPLAY"); disp = getenv("DISPLAY");
@ -70,6 +69,8 @@ _ipc_hash_get(void)
memset(hash+12, 'x', 32); memset(hash+12, 'x', 32);
for (i = 0, s = buf; *s; s++) for (i = 0, s = buf; *s; s++)
{ {
unsigned char c1, c2;
c1 = (((unsigned char)*s) >> 4) & 0xf; c1 = (((unsigned char)*s) >> 4) & 0xf;
c2 = ((unsigned char)*s) & 0x0f; c2 = ((unsigned char)*s) & 0x0f;
hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c1) % 26) + 'a'; hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c1) % 26) + 'a';

View File

@ -382,11 +382,9 @@ cb_term_right(Evas_Object *termio_obj)
static Eina_Bool static Eina_Bool
cb_term_new(Evas_Object *termio_obj) 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; RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
const char *template = "%s -d %s";
int length;
#if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 16) #if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 16)
eina_file_path_join(path, sizeof(path), elm_app_bin_dir_get(), eina_file_path_join(path, sizeof(path), elm_app_bin_dir_get(),
@ -397,6 +395,10 @@ cb_term_new(Evas_Object *termio_obj)
#endif #endif
if (termio_cwd_get(termio_obj, cwd, sizeof(cwd))) 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); length = (strlen(path) + strlen(cwd) + strlen(template) - 3);
cmd = malloc(sizeof(char) * length); cmd = malloc(sizeof(char) * length);
snprintf(cmd, length, template, path, cwd); snprintf(cmd, length, template, path, cwd);

View File

@ -32,9 +32,8 @@ void byteReverse(unsigned char *buf, unsigned longs);
*/ */
void byteReverse(unsigned char *buf, unsigned longs) void byteReverse(unsigned char *buf, unsigned longs)
{ {
uint32_t t;
do { 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]); ((unsigned) buf[1] << 8 | buf[0]);
*(uint32_t *) buf = t; *(uint32_t *) buf = t;
buf += 4; buf += 4;

View File

@ -54,14 +54,17 @@ static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
static const char * static const char *
_is_fmt(const char *f, const char **extn) _is_fmt(const char *f, const char **extn)
{ {
int i, len, l; int i;
size_t len;
len = strlen(f); len = strlen(f);
for (i = 0; extn[i]; i++) for (i = 0; extn[i]; i++)
{ {
l = strlen(extn[i]); size_t l = strlen(extn[i]);
if (len < l) continue; if (len < l)
if (!strcasecmp(extn[i], f + len - l)) return extn[i]; continue;
if (!strcasecmp(extn[i], f + len - l))
return extn[i];
} }
return NULL; return NULL;
} }
@ -472,7 +475,6 @@ _type_scale_init(Evas_Object *obj)
static void static void
_type_scale_calc(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) _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); Media *sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return;
if ((w <= 0) || (h <= 0) || (sd->iw <= 0) || (sd->ih <= 0)) 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 (lh < 256) lh = 256;
if ((lw != sd->sw) || (lh != sd->sh)) if ((lw != sd->sw) || (lh != sd->sh))
{ {
Evas_Object *o;
o = sd->o_tmp = evas_object_image_filled_add(evas_object_evas_get(obj)); o = sd->o_tmp = evas_object_image_filled_add(evas_object_evas_get(obj));
evas_object_smart_member_add(o, obj); evas_object_smart_member_add(o, obj);
evas_object_clip_set(o, sd->clip); evas_object_clip_set(o, sd->clip);

View File

@ -213,7 +213,6 @@ void
miniview_position_offset(const Evas_Object *obj, int by, Eina_Bool sanitize) miniview_position_offset(const Evas_Object *obj, int by, Eina_Bool sanitize)
{ {
Miniview *mv = evas_object_smart_data_get(obj); Miniview *mv = evas_object_smart_data_get(obj);
int remain = 0;
termio_scroll_get(mv->termio); termio_scroll_get(mv->termio);
EINA_SAFETY_ON_NULL_RETURN(mv); 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) if (!mv->fits_to_img)
{ {
int remain;
mv->screen.pos_val += (double) by / (mv->img_h - mv->rows); mv->screen.pos_val += (double) by / (mv->img_h - mv->rows);
edje_object_part_drag_value_set(mv->base, "miniview_screen", edje_object_part_drag_value_set(mv->base, "miniview_screen",
0.0, mv->screen.pos_val); 0.0, mv->screen.pos_val);
@ -517,7 +518,6 @@ _deferred_renderer(void *data)
int history_len, pos; int history_len, pos;
ssize_t wret; ssize_t wret;
unsigned int *pixels, y; unsigned int *pixels, y;
Termcell *cells;
Termpty *ty; Termpty *ty;
unsigned int colors[512]; unsigned int colors[512];
double bottom_bound; double bottom_bound;
@ -555,8 +555,10 @@ _deferred_renderer(void *data)
for (y = 0; y < mv->img_h; y++) for (y = 0; y < mv->img_h; y++)
{ {
cells = termpty_cellrow_get(ty, mv->img_hist + y, &wret); Termcell *cells = termpty_cellrow_get(ty, mv->img_hist + y, &wret);
if (!cells) break;
if (!cells)
break;
_draw_line(ty, &pixels[y * mv->cols], cells, wret, colors); _draw_line(ty, &pixels[y * mv->cols], cells, wret, colors);
} }
evas_object_image_data_set(mv->img, pixels); evas_object_image_data_set(mv->img, pixels);

View File

@ -173,12 +173,11 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
Background_Ctx *ctx = evas_object_data_get(obj, "ctx"); Background_Ctx *ctx = evas_object_data_get(obj, "ctx");
assert(ctx); assert(ctx);
Background_Item *item = data; Background_Item *item = data;
Evas_Object *o, *oe;
Config *config = ctx->config; 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; int i;
@ -194,6 +193,9 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
} }
else else
{ {
Evas_Object *o, *oe;
char path[PATH_MAX];
if (!config->theme) if (!config->theme)
return NULL; return NULL;
snprintf(path, PATH_MAX, "%s/themes/%s", elm_app_data_dir_get(), snprintf(path, PATH_MAX, "%s/themes/%s", elm_app_data_dir_get(),
@ -208,8 +210,7 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
evas_object_show(o); evas_object_show(o);
return o; return o;
} }
} return NULL; /* unreached */
return NULL;
} }
static void static void
@ -389,7 +390,6 @@ _cb_entry_changed(void *data,
static void static void
_cb_hoversel_select(Background_Ctx *ctx, const Eina_Stringshare *path) _cb_hoversel_select(Background_Ctx *ctx, const Eina_Stringshare *path)
{ {
Evas_Object *o;
if (path) if (path)
{ {
elm_flip_go_to(ctx->flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT); 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 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_fileselector_path_set(o, elm_object_text_get(ctx->entry));
elm_flip_go_to(ctx->flip, EINA_FALSE, ELM_FLIP_PAGE_RIGHT); 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; Evas_Object *o, *bx, *bx_front;
Config *config = termio_config_get(term); Config *config = termio_config_get(term);
char path[PATH_MAX], *config_background_dir; char path[PATH_MAX];
Background_Ctx *ctx; Background_Ctx *ctx;
ctx = calloc(1, sizeof(*ctx)); ctx = calloc(1, sizeof(*ctx));
@ -706,6 +706,7 @@ options_background(Evas_Object *opbox, Evas_Object *term)
if (config->background) if (config->background)
{ {
char *config_background_dir;
config_background_dir = ecore_file_dir_get(config->background); config_background_dir = ecore_file_dir_get(config->background);
elm_object_text_set(ctx->entry, config_background_dir); elm_object_text_set(ctx->entry, config_background_dir);
free(config_background_dir); free(config_background_dir);

View File

@ -236,7 +236,6 @@ _cb_op_font_preview_delayed_eval(void *data)
goto done; goto done;
if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh)) if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
{ {
char buf[4096];
int r, g, b, a; int r, g, b, a;
Evas *evas = evas_object_evas_get(obj); Evas *evas = evas_object_evas_get(obj);
Evas_Object *textgrid = termio_textgrid_get(f->ctx->term); 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()); evas_object_scale_set(o, elm_config_scale_get());
if (f->bitmap) if (f->bitmap)
{ {
char buf[4096];
snprintf(buf, sizeof(buf), "%s/fonts/%s", snprintf(buf, sizeof(buf), "%s/fonts/%s",
elm_app_data_dir_get(), f->full_name); elm_app_data_dir_get(), f->full_name);
evas_object_text_font_set(o, buf, config->font.size); evas_object_text_font_set(o, buf, config->font.size);

View File

@ -51,11 +51,12 @@ _cb_op_theme_content_get(void *data, Evas_Object *obj, const char *part)
if (!strcmp(part, "elm.swallow.icon")) if (!strcmp(part, "elm.swallow.icon"))
{ {
Evas_Object *o;
Config *config = t->ctx->config; Config *config = t->ctx->config;
if (config) if (config)
{ {
Evas_Object *o;
o = options_theme_preview_add(obj, config, o = options_theme_preview_add(obj, config,
theme_path_get(t->name), theme_path_get(t->name),
128 * elm_config_scale_get(), 128 * elm_config_scale_get(),

View File

@ -80,7 +80,6 @@ ty_sb_spaces_rtrim(struct ty_sb *sb)
char * char *
ty_sb_steal_buf(struct ty_sb *sb) ty_sb_steal_buf(struct ty_sb *sb)
{ {
size_t i;
char *buf; char *buf;
if (!sb->len) if (!sb->len)
@ -88,6 +87,8 @@ ty_sb_steal_buf(struct ty_sb *sb)
if (sb->gap != 0) if (sb->gap != 0)
{ {
size_t i;
sb->buf -= sb->gap; sb->buf -= sb->gap;
for (i = 0; i <= sb->len; i++) for (i = 0; i <= sb->len; i++)
{ {

View File

@ -401,7 +401,6 @@ termio_config_update(Evas_Object *obj)
{ {
Termio *sd = evas_object_smart_data_get(obj); Termio *sd = evas_object_smart_data_get(obj);
Evas_Coord w, h, ow = 0, oh = 0; Evas_Coord w, h, ow = 0, oh = 0;
char buf[4096];
EINA_SAFETY_ON_NULL_RETURN(sd); EINA_SAFETY_ON_NULL_RETURN(sd);
@ -410,6 +409,8 @@ termio_config_update(Evas_Object *obj)
if (sd->config->font.bitmap) if (sd->config->font.bitmap)
{ {
char buf[4096];
snprintf(buf, sizeof(buf), "%s/fonts/%s", snprintf(buf, sizeof(buf), "%s/fonts/%s",
elm_app_data_dir_get(), sd->config->font.name); elm_app_data_dir_get(), sd->config->font.name);
sd->font.name = eina_stringshare_add(buf); sd->font.name = eina_stringshare_add(buf);
@ -931,7 +932,6 @@ _cb_ctxp_link_content_copy(void *data,
{ {
Evas_Object *term = data; Evas_Object *term = data;
Termio *sd = evas_object_smart_data_get(term); Termio *sd = evas_object_smart_data_get(term);
const char *raw_link;
EINA_SAFETY_ON_NULL_RETURN(sd); EINA_SAFETY_ON_NULL_RETURN(sd);
if (sd->link.id) if (sd->link.id)
@ -945,6 +945,8 @@ _cb_ctxp_link_content_copy(void *data,
else else
{ {
struct ty_sb sb = {.buf = NULL, .len = 0, .alloc = 0}; struct ty_sb sb = {.buf = NULL, .len = 0, .alloc = 0};
const char *raw_link;
termio_selection_get(sd, termio_selection_get(sd,
sd->link.x1, sd->link.y1, sd->link.x1, sd->link.y1,
sd->link.x2, sd->link.y2, sd->link.x2, sd->link.y2,
@ -1479,7 +1481,6 @@ _hyperlink_mouseover(Termio *sd,
uint16_t link_id) uint16_t link_id)
{ {
Evas_Coord ox, oy, ow, oh; Evas_Coord ox, oy, ow, oh;
Evas_Object *o;
int x, y; int x, y;
Term_Link *hl; Term_Link *hl;
@ -1506,8 +1507,9 @@ _hyperlink_mouseover(Termio *sd,
termpty_backscroll_adjust(sd->pty, &sd->scroll); termpty_backscroll_adjust(sd->pty, &sd->scroll);
for (y = 0; y < sd->grid.h; y++) for (y = 0; y < sd->grid.h; y++)
{ {
ssize_t w = 0;
Termcell *cells; Termcell *cells;
Evas_Object *o;
ssize_t w = 0;
int start_x = -1; int start_x = -1;
Eina_Bool add_tooltip = EINA_FALSE; 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; cmd = config->helper.local.general;
if (cmd) if (cmd)
{ {
char buf[PATH_MAX], *escaped; char *escaped;
escaped = ecore_file_escape_name(file); escaped = ecore_file_escape_name(file);
if (escaped) if (escaped)
{ {
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s %s", cmd, escaped); snprintf(buf, sizeof(buf), "%s %s", cmd, escaped);
ecore_exe_run(buf, NULL); ecore_exe_run(buf, NULL);
free(escaped); free(escaped);
@ -1896,7 +1900,6 @@ static void
_block_edje_cmds(Termpty *ty, Termblock *blk, Eina_List *cmds, Eina_Bool created) _block_edje_cmds(Termpty *ty, Termblock *blk, Eina_List *cmds, Eina_Bool created)
{ {
Eina_List *l; Eina_List *l;
char *s;
#define ISCMD(cmd) !strcmp(s, cmd) #define ISCMD(cmd) !strcmp(s, cmd)
#define GETS(var) l = l->next; if (!l) return; var = l->data #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; l = cmds;
while (l) while (l)
{ {
s = l->data; char *s = l->data;
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
if (ISCMD("text")) // set text part if (ISCMD("text")) // set text part
@ -3522,6 +3525,7 @@ _smart_pty_command(void *data)
char *pp; char *pp;
int ww = 0, hh = 0, repch; int ww = 0, hh = 0, repch;
Eina_List *strs = NULL; Eina_List *strs = NULL;
char *link = NULL;
// exact size in CHAR CELLS - WW (decimal) width CELLS, // exact size in CHAR CELLS - WW (decimal) width CELLS,
// HH (decimal) in CELLS. // HH (decimal) in CELLS.
@ -3536,9 +3540,8 @@ _smart_pty_command(void *data)
// CMD is the command, P1, P2, P3 etc. are parameters (P2 and // CMD is the command, P1, P2, P3 etc. are parameters (P2 and
// on are optional depending on CMD) // on are optional depending on CMD)
repch = ty->cur_cmd[2]; repch = ty->cur_cmd[2];
if (repch) if (!repch)
{ return;
char *link = NULL;
for (p0 = p = &(ty->cur_cmd[3]); *p; p++) for (p0 = p = &(ty->cur_cmd[3]); *p; p++)
{ {
@ -3644,7 +3647,6 @@ _smart_pty_command(void *data)
} }
free(link); free(link);
EINA_LIST_FREE(strs, pp) free(pp); EINA_LIST_FREE(strs, pp) free(pp);
}
return; return;
} }
else if (ty->cur_cmd[1] == 'C') 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 else if (ty->cur_cmd[1] == 'd') // data packet
{ {
int pksum = atoi(&(ty->cur_cmd[2]));
int sum;
char *p = strchr(ty->cur_cmd, ' '); char *p = strchr(ty->cur_cmd, ' ');
Eina_Bool valid = EINA_TRUE; Eina_Bool valid = EINA_TRUE;
if (p) if (p)
{ {
Eina_Binbuf *bb = eina_binbuf_new(); Eina_Binbuf *bb = eina_binbuf_new();
unsigned char v;
if (bb) if (bb)
{ {
unsigned char localbuf[128]; unsigned char localbuf[128];
unsigned char localbufpos = 0; unsigned char localbufpos = 0;
int pksum = atoi(&(ty->cur_cmd[2]));
int sum;
eina_binbuf_expand(bb, 32 * 1024); eina_binbuf_expand(bb, 32 * 1024);
sum = 0;
for (sum = 0, p++; *p; p++) for (sum = 0, p++; *p; p++)
{ {
// high nibble // high nibble
v = (unsigned char)(*p); unsigned char v = (unsigned char)(*p);
sum += v; sum += v;
v = ((v - '@') & 0xf) << 4; v = ((v - '@') & 0xf) << 4;
// low nibble // low nibble
@ -3852,13 +3852,13 @@ _smart_cb_drop(void *data,
{ {
if (strchr(ev->data, '\n')) if (strchr(ev->data, '\n'))
{ {
char *p, *p2, *p3, *tb; char *tb = malloc(strlen(ev->data) + 1);
tb = malloc(strlen(ev->data) + 1);
if (tb) if (tb)
{ {
char *p;
for (p = ev->data; p;) for (p = ev->data; p;)
{ {
char *p2, *p3;
p2 = strchr(p, '\n'); p2 = strchr(p, '\n');
p3 = strchr(p, '\r'); p3 = strchr(p, '\r');
if (p2 && p3) if (p2 && p3)

View File

@ -2735,17 +2735,23 @@ termio_internal_render(Termio *sd,
preedit_str = term_preedit_str_get(sd->term); preedit_str = term_preedit_str_get(sd->term);
if (preedit_str && preedit_str[0]) if (preedit_str && preedit_str[0])
{ {
Eina_Unicode *uni, g; Eina_Unicode *uni;
int len = 0, i, jump, xx, backx; int len = 0;
Eina_Bool dbl;
Evas_Textgrid_Cell *tc;
x = sd->cursor.x, y = sd->cursor.y; x = sd->cursor.x, y = sd->cursor.y;
uni = eina_unicode_utf8_to_unicode(preedit_str, &len); uni = eina_unicode_utf8_to_unicode(preedit_str, &len);
if (uni) if (uni)
{ {
int i;
for (i = 0; i < len; 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; jump = 1;
g = uni[i]; g = uni[i];
dbl = _termpty_is_dblwidth_get(sd->pty, g); dbl = _termpty_is_dblwidth_get(sd->pty, g);

View File

@ -227,15 +227,15 @@ _pty_size(Termpty *ty)
static Eina_Bool static Eina_Bool
_handle_read(Termpty *ty, Eina_Bool false_on_empty) _handle_read(Termpty *ty, Eina_Bool false_on_empty)
{ {
char buf[4097]; int len, reads;
Eina_Unicode codepoint[4097];
int len, i, j, reads;
unsigned int k;
// read up to 64 * 4096 bytes // read up to 64 * 4096 bytes
for (reads = 0; reads < 64; reads++) for (reads = 0; reads < 64; reads++)
{ {
Eina_Unicode codepoint[4097];
char buf[4097];
char *rbuf = buf; char *rbuf = buf;
int i, j;
len = sizeof(buf) - 1; len = sizeof(buf) - 1;
for (i = 0; i < (int)sizeof(ty->oldbuf) && ty->oldbuf[i] & 0x80; i++) 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) && if ((0xdc80 <= g) && (g <= 0xdcff) &&
(len - prev_i) <= (int)sizeof(ty->oldbuf)) (len - prev_i) <= (int)sizeof(ty->oldbuf))
{ {
unsigned int k;
for (k = 0; for (k = 0;
(k < (unsigned int)sizeof(ty->oldbuf)) && (k < (unsigned int)sizeof(ty->oldbuf)) &&
(k < (unsigned int)(len - prev_i)); (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; unsigned int *new_tabs;
int i; int i;
size_t nb_elems, n; size_t nb_elems;
if ((new_w == old_w) && ty->tabs) return; 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) if (ty->tabs)
{ {
n = old_w; size_t n = old_w;
if (nb_elems < n) n = nb_elems; if (nb_elems < n) n = nb_elems;
if (n > 0) memcpy(new_tabs, ty->tabs, n * sizeof(unsigned int)); if (n > 0) memcpy(new_tabs, ty->tabs, n * sizeof(unsigned int));
free(ty->tabs); free(ty->tabs);
@ -707,12 +709,9 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
} }
if (!ty->pid) if (!ty->pid)
{ {
char buf[256];
int ret;
if (cd) if (cd)
{ {
ret = chdir(cd); int ret = chdir(cd);
if (ret != 0) if (ret != 0)
{ {
ERR(_("Could not change current directory to '%s': %s"), 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"); putenv("XTERM_256_COLORS=1");
if (window_id) if (window_id)
{ {
char buf[256];
snprintf(buf, sizeof(buf), "WINDOWID=%lu", window_id); snprintf(buf, sizeof(buf), "WINDOWID=%lu", window_id);
putenv(buf); putenv(buf);
} }
@ -931,7 +932,7 @@ _termpty_line_is_empty(const Termcell *cells, ssize_t nb_cells)
ssize_t ssize_t
termpty_line_length(const Termcell *cells, ssize_t nb_cells) termpty_line_length(const Termcell *cells, ssize_t nb_cells)
{ {
ssize_t len = nb_cells; ssize_t len;
if (!cells) if (!cells)
return 0; return 0;

View File

@ -38,8 +38,8 @@ termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
void void
termpty_text_scroll(Termpty *ty, Eina_Bool clear) termpty_text_scroll(Termpty *ty, Eina_Bool clear)
{ {
Termcell *cells = NULL, *cells2; Termcell *cells = NULL;
int y, start_y = 0, end_y = ty->h - 1; int start_y = 0, end_y = ty->h - 1;
start_y = ty->termstate.top_margin; start_y = ty->termstate.top_margin;
if (ty->termstate.bottom_margin != 0) 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 x = ty->termstate.left_margin;
int w = ty->w - x; int w = ty->w - x;
int y;
if (ty->termstate.right_margin) if (ty->termstate.right_margin)
w = ty->termstate.right_margin - x; 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)); cells = &(TERMPTY_SCREEN(ty, x, end_y));
for (y = start_y; y < end_y; y++) for (y = start_y; y < end_y; y++)
{ {
Termcell *cells2;
cells = &(TERMPTY_SCREEN(ty, x, (y + 1))); cells = &(TERMPTY_SCREEN(ty, x, (y + 1)));
cells2 = &(TERMPTY_SCREEN(ty, x, y)); cells2 = &(TERMPTY_SCREEN(ty, x, y));
TERMPTY_CELL_COPY(ty, cells, cells2, w); TERMPTY_CELL_COPY(ty, cells, cells2, w);
@ -88,8 +91,8 @@ termpty_text_scroll(Termpty *ty, Eina_Bool clear)
void void
termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear) termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear)
{ {
Termcell *cells, *cells2 = NULL; Termcell *cells;
int y, start_y = 0, end_y = ty->h - 1; int start_y = 0, end_y = ty->h - 1;
if (ty->termstate.bottom_margin != 0) 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 x = ty->termstate.left_margin;
int w = ty->w - x; int w = ty->w - x;
int y;
if (ty->termstate.right_margin) if (ty->termstate.right_margin)
w = ty->termstate.right_margin - x; 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)); cells = &(TERMPTY_SCREEN(ty, x, end_y));
for (y = end_y; y > start_y; y--) for (y = end_y; y > start_y; y--)
{ {
Termcell *cells2;
cells = &(TERMPTY_SCREEN(ty, x, (y - 1))); cells = &(TERMPTY_SCREEN(ty, x, (y - 1)));
cells2 = &(TERMPTY_SCREEN(ty, x, y)); cells2 = &(TERMPTY_SCREEN(ty, x, y));
TERMPTY_CELL_COPY(ty, cells, cells2, w); TERMPTY_CELL_COPY(ty, cells, cells2, w);

View File

@ -69,12 +69,12 @@ scaleterm(int w, int h, int *iw, int *ih)
static const char * static const char *
is_fmt(const char *f, const char **extn) is_fmt(const char *f, const char **extn)
{ {
int i, len, l; int i, len;
len = strlen(f); len = strlen(f);
for (i = 0; extn[i]; i++) for (i = 0; extn[i]; i++)
{ {
l = strlen(extn[i]); int l = strlen(extn[i]);
if (len < l) continue; if (len < l) continue;
if (!strcasecmp(extn[i], f + len - l)) return extn[i]; if (!strcasecmp(extn[i], f + len - l)) return extn[i];
} }

View File

@ -287,10 +287,6 @@ _termpty_init(Termpty *ty, Config *config)
int int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED) main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{ {
char buf[4097];
Eina_Unicode codepoint[4097];
int len, i, j, k;
eina_init(); eina_init();
#ifdef TYTEST #ifdef TYTEST
@ -319,8 +315,11 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
do do
{ {
char buf[4097];
Eina_Unicode codepoint[4097];
int i, j;
char *rbuf = buf; 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++) 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) && if ((0xdc80 <= g) && (g <= 0xdcff) &&
(len - prev_i) <= (int)sizeof(_ty.oldbuf)) (len - prev_i) <= (int)sizeof(_ty.oldbuf))
{ {
int k;
for (k = 0; for (k = 0;
(k < (int)sizeof(_ty.oldbuf)) && (k < (int)sizeof(_ty.oldbuf)) &&
(k < (len - prev_i)); (k < (len - prev_i));

View File

@ -590,7 +590,7 @@ list_dir(const char *dir, Tyls_Options *options)
{ {
Eina_List *files, *l; Eina_List *files, *l;
char *s, **names; 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); files = ecore_file_ls(dir);
if (!files) return; if (!files) return;
@ -618,7 +618,9 @@ list_dir(const char *dir, Tyls_Options *options)
maxlen += stuff; maxlen += stuff;
if (maxlen > 0) if (maxlen > 0)
{ {
cols = tw / maxlen; int rows;
int cols = tw / maxlen;
if (cols < 1) cols = 1; if (cols < 1) cols = 1;
if (cols == 1) if (cols == 1)
{ {
@ -632,6 +634,7 @@ list_dir(const char *dir, Tyls_Options *options)
{ {
char buf[4096]; char buf[4096];
const char *icon; const char *icon;
int c, j, cw;
if (options->mode == SMALL) if (options->mode == SMALL)
{ {
@ -738,9 +741,6 @@ print_usage(const char *argv0)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char buf[64];
char *path;
Eina_List *dirs = NULL;
Tyls_Options options = {SMALL, EINA_FALSE}; Tyls_Options options = {SMALL, EINA_FALSE};
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
@ -759,7 +759,9 @@ main(int argc, char **argv)
{ {
int i, cw, ch; int i, cw, ch;
int len; int len;
char *rp; char buf[64];
char *path;
Eina_List *dirs = NULL;
evas = ecore_evas_get(ee); evas = ecore_evas_get(ee);
echo_off(); echo_off();
@ -806,6 +808,8 @@ main(int argc, char **argv)
} }
EINA_LIST_FREE(dirs, path) EINA_LIST_FREE(dirs, path)
{ {
char *rp;
if ((rp = ecore_file_realpath(path)) if ((rp = ecore_file_realpath(path))
&& ecore_file_is_dir(rp)) && ecore_file_is_dir(rp))
{ {
@ -814,7 +818,6 @@ main(int argc, char **argv)
} }
} }
fflush(stdout); fflush(stdout);
// ecore_main_loop_begin();
ecore_evas_free(ee); ecore_evas_free(ee);
} }
emotion_shutdown(); emotion_shutdown();