From a897a957215fb7ec8ee66e9f17c7f9dc7b656c0d Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Thu, 27 Jul 2006 09:49:49 +0200 Subject: [PATCH] Compilation fixes (CONFIG_UTF_8): move variables declarations at start of blocks. Old compilers do not support in-block declarations. --- src/bfu/menu.c | 5 ++++- src/terminal/draw.c | 10 ++++++---- src/viewer/text/textarea.c | 26 +++++++++++++++++--------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/bfu/menu.c b/src/bfu/menu.c index bb0b85fa..0b73fbc9 100644 --- a/src/bfu/menu.c +++ b/src/bfu/menu.c @@ -410,6 +410,9 @@ draw_menu_left_text_hk(struct terminal *term, unsigned char *text, int xbase = x + L_TEXT_SPACE; int w = width - (L_TEXT_SPACE + R_TEXT_SPACE); int hk_state = 0; +#ifdef CONFIG_UTF_8 + unsigned char *text2, *end; +#endif #ifdef CONFIG_DEBUG /* For redundant hotkeys highlighting. */ @@ -450,8 +453,8 @@ draw_menu_left_text_hk(struct terminal *term, unsigned char *text, } } return; + #ifdef CONFIG_UTF_8 - unsigned char *text2, *end; utf8: end = strchr(text, '\0'); text2 = text; diff --git a/src/terminal/draw.c b/src/terminal/draw.c index 000a9c23..1e31b442 100644 --- a/src/terminal/draw.c +++ b/src/terminal/draw.c @@ -150,9 +150,10 @@ draw_line(struct terminal *term, int x, int y, int l, struct screen_char *line) struct screen_char *sc; if (line->data == UCS_NO_CHAR && x == 0) { - sc = line; - unicode_val_T data_save = sc->data; + unicode_val_T data_save; + sc = line; + data_save = sc->data; sc->data = ' '; copy_screen_chars(screen_char, line, 1); sc->data = data_save; @@ -164,9 +165,10 @@ draw_line(struct terminal *term, int x, int y, int l, struct screen_char *line) /* Instead of displaying double-width character at last column * display only space. */ if (size - 1 > 0 && unicode_to_cell(line[size - 1].data) == 2) { + unicode_val_T data_save; + sc = &line[size - 1]; - unicode_val_T data_save = sc->data; - + data_save = sc->data; sc->data = ' '; copy_screen_chars(screen_char, line, size); sc->data = data_save; diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index cea578de..b3096267 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -785,6 +785,8 @@ do_op_home(struct form_state *fs, struct line_info *line, int current) static int do_op_up(struct form_state *fs, struct line_info *line, int current, int utf8) { + int old_state; + if (current == -1) return 0; if (!(current - !!fs->state_cell)) return 1; @@ -795,7 +797,7 @@ do_op_up(struct form_state *fs, struct line_info *line, int current, int utf8) return 0; } - int old_state = fs->state; + old_state = fs->state; if (fs->state_cell) { int len = utf8_ptr2cells(fs->value + line[current - 1].start, fs->value + fs->state_cell); @@ -839,6 +841,8 @@ do_op_up(struct form_state *fs, struct line_info *line, int current) static int do_op_down(struct form_state *fs, struct line_info *line, int current, int utf8) { + int old_state; + if (current == -1) return 0; if (line[current + 1 - !!fs->state_cell].start == -1) return 1; @@ -849,7 +853,7 @@ do_op_down(struct form_state *fs, struct line_info *line, int current, int utf8) return 0; } - int old_state = fs->state; + old_state = fs->state; if (fs->state_cell) { int len = utf8_ptr2cells(fs->value + line[current - 1].start, fs->value + fs->state_cell); @@ -1083,6 +1087,10 @@ textarea_op_enter(struct form_state *fs, struct form_control *fc) static int do_op_left(struct form_state *fs, struct line_info *line, int current, int utf8) { + int old_state; + int new_state; + unsigned char *new_value; + if (!utf8) { fs->state = int_max(fs->state - 1, 0); return 0; @@ -1094,10 +1102,7 @@ do_op_left(struct form_state *fs, struct line_info *line, int current, int utf8) return 0; } - int old_state = fs->state; - int new_state; - unsigned char *new_value; - + old_state = fs->state; new_value = utf8_prevchar(fs->value + fs->state, 1, fs->value); new_state = new_value - fs->value; @@ -1113,6 +1118,9 @@ do_op_left(struct form_state *fs, struct line_info *line, int current, int utf8) static int do_op_right(struct form_state *fs, struct line_info *line, int current, int utf8) { + unsigned char *text, *end; + int old_state; + if (!utf8) { /* TODO: zle */ fs->state = int_min(fs->state + 1, strlen(fs->value)); @@ -1124,9 +1132,9 @@ do_op_right(struct form_state *fs, struct line_info *line, int current, int utf8 return 0; } - unsigned char *text = fs->value + fs->state; - unsigned char *end = strchr(text, '\0'); - int old_state = fs->state; + text = fs->value + fs->state; + end = strchr(text, '\0'); + old_state = fs->state; utf_8_to_unicode(&text, end); fs->state = text - fs->value;