links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: ef2d2af58ce9e24c5c9ecb95fa0f1f5ecbe8e32f
Parent: 07aab85a05b5f026fd1a10e16363749045c9fa51
Author: opask
Date:   Sun, 29 Jul 2018 19:46:37 -0600

cleanup comma misuse

Diffstat:
Mbfu.c | 76+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mcache.c | 19+++++++++++++++----
Mcharsets.c | 52++++++++++++++++++++++++++++++----------------------
Mcompress.c | 3++-
Mdefault.c | 15++++++++++++---
Mdip.c | 12++++++++----
Mdither.c | 5++++-
Mfile.c | 3++-
Mhtml.c | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Mhtml_gr.c | 13++++++++++---
Mhtml_r.c | 72+++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mhtml_tbl.c | 147+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Mkbd.c | 5++++-
Mmain.c | 16++++++++++++----
Mos_dep.c | 5++++-
Msched.c | 16++++++++++++----
Msession.c | 160++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mstring.c | 29++++++++++++++++++++++-------
Mterminal.c | 48+++++++++++++++++++++++++++++++++++++-----------
Mtypes.c | 163+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Murl.c | 13++++++++-----
Mview.c | 160++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mview_gr.c | 67++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mx.c | 51++++++++++++++++++++++++++++++++++++++++-----------
24 files changed, 983 insertions(+), 311 deletions(-)

diff --git a/bfu.c b/bfu.c @@ -341,7 +341,12 @@ static void display_menu_txt(struct terminal *term, void *menu_) int h = 0; unsigned c; unsigned char *tmptext = get_text_translation(menu->items[p].text, term); - unsigned char co = p == menu->selected ? h = 1, COLOR_MENU_SELECTED : COLOR_MENU_TEXT; + unsigned char co; + if (p == menu->selected) { + h = 1; + co = COLOR_MENU_SELECTED; + } else + co = COLOR_MENU_TEXT; if (h) { setc = 1; set_cursor(term, menu->x + 1 + !!term->spec->braille, s, term->x - 1, term->y - 1); @@ -366,7 +371,15 @@ static void display_menu_txt(struct terminal *term, void *menu_) for (x = 0; x < menu->xw - 4; x++) { c = GET_TERM_CHAR(term, &tmptext); if (!c) break; - set_char(term, menu->x + x + 2 + 2 * !!term->spec->braille, s, c, !h && charset_upcase(c, term_charset(term)) == menu->hotkeys[p] ? h = 1, COLOR_MENU_HOTKEY : co); + if (!h && charset_upcase(c, term_charset(term)) == menu->hotkeys[p]) { + h = 1; + set_char(term, + menu->x + x + 2 + 2 * !!term->spec->braille, + s, c, COLOR_MENU_HOTKEY); + } else + set_char(term, + menu->x + x + 2 + 2 * !!term->spec->braille, + s, c, co); } if (term->spec->braille && menu->hotkeys[p]) { set_char(term, menu->x + 2, s, menu->hotkeys[p], COLOR_MENU_HOTKEY); @@ -578,9 +591,13 @@ static void menu_func(struct window *win, struct links_event *ev, int fwd) menu_oldsel = menu->selected; if (ev->x == KBD_UP) scroll_menu(menu, -1); else if (ev->x == KBD_DOWN) scroll_menu(menu, 1); - else if (ev->x == KBD_HOME || (upcase(ev->x) == 'A' && ev->y & KBD_CTRL)) menu->selected = -1, scroll_menu(menu, 1); - else if (ev->x == KBD_END || (upcase(ev->x) == 'E' && ev->y & KBD_CTRL)) menu->selected = menu->ni, scroll_menu(menu, -1); - else if (ev->x == KBD_PAGE_UP || (upcase(ev->x) == 'B' && ev->y & KBD_CTRL)) { + else if (ev->x == KBD_HOME || (upcase(ev->x) == 'A' && ev->y & KBD_CTRL)) { + menu->selected = -1; + scroll_menu(menu, 1); + } else if (ev->x == KBD_END || (upcase(ev->x) == 'E' && ev->y & KBD_CTRL)) { + menu->selected = menu->ni; + scroll_menu(menu, -1); + } else if (ev->x == KBD_PAGE_UP || (upcase(ev->x) == 'B' && ev->y & KBD_CTRL)) { if ((menu->selected -= menu->yw / gf_val(1, G_BFU_FONT_SIZE) - 3) < -1) menu->selected = -1; if ((menu->view -= menu->yw / gf_val(1, G_BFU_FONT_SIZE) - 2) < 0) menu->view = 0; scroll_menu(menu, -1); @@ -671,7 +688,12 @@ static void display_mainmenu(struct terminal *term, void *menu_) int s = 0; unsigned c; unsigned char *tmptext = get_text_translation(menu->items[i].text, term); - unsigned char co = i == menu->selected ? s = 1, COLOR_MAINMENU_SELECTED : COLOR_MAINMENU; + unsigned char co; + if (i == menu->selected) { + s = 1; + co = COLOR_MAINMENU_SELECTED; + } else + co = COLOR_MAINMENU; if (i == menu->selected) { fill_area(term, p, 0, 2, 1, ' ', co); menu->sp = p; @@ -686,7 +708,11 @@ static void display_mainmenu(struct terminal *term, void *menu_) for (;; p++) { c = GET_TERM_CHAR(term, &tmptext); if (!c) break; - set_char(term, p, 0, c, !s && charset_upcase(c, term_charset(term)) == menu->hotkeys[i] ? s = 1, COLOR_MAINMENU_HOTKEY : co); + if (!s && charset_upcase(c, term_charset(term)) == menu->hotkeys[i]) { + s = 1; + set_char(term, p, 0, c, COLOR_MAINMENU_HOTKEY); + } else + set_char(term, p, 0, c, co); } if (i == menu->selected) { fill_area(term, p, 0, 2, 1, ' ', co); @@ -948,8 +974,13 @@ void display_dlg_item(struct dialog_data *dlg, struct dialog_item_data *di, int } else { int s = g_text_width(bfu_style_bw, di->item->gid?cast_uchar G_DIALOG_RADIO_X:cast_uchar G_DIALOG_CHECKBOX_X); g_print_text(dev, di->x, di->y, bfu_style_bw, di->item->gid?cast_uchar G_DIALOG_RADIO_L:cast_uchar G_DIALOG_CHECKBOX_L, &p); - if (!sel) drv->fill_area(dev, p, di->y, p + s, di->y + G_BFU_FONT_SIZE, bfu_bg_color), p += s; - else { + if (!sel) { + drv->fill_area(dev, p, di->y, + p + s, + di->y + G_BFU_FONT_SIZE, + bfu_bg_color); + p += s; + } else { restrict_clip_area(dev, &r, p, di->y, p + s, di->y + G_BFU_FONT_SIZE); g_print_text(dev, p, di->y, bfu_style_bw_u, cast_uchar " ", NULL); p += s; @@ -1057,7 +1088,9 @@ static void u_display_dlg_item(struct terminal *term, void *p) static void x_display_dlg_item(struct dialog_data *dlg, struct dialog_item_data *di, int sel) { struct dspd dspd; - dspd.dlg = dlg, dspd.di = di, dspd.sel = sel; + dspd.dlg = dlg; + dspd.di = di; + dspd.sel = sel; draw_to_window(dlg->win, u_display_dlg_item, &dspd); } @@ -1399,7 +1432,8 @@ void dialog_func(struct window *win, struct links_event *ev, int fwd) if (cp2u(ev->x, term_charset(term)) == -1) break; if (!is_utf_8(term)) { - p[0] = (unsigned char)ev->x, u = p; + p[0] = (unsigned char)ev->x; + u = p; } else { u = encode_utf_8(ev->x); } @@ -1800,8 +1834,10 @@ void max_text_width(struct terminal *term, unsigned char *text, int *width, int do { int c = 0; while (*text && *text != '\n') { - if (!is_utf_8(term)) text++, c++; - else { + if (!is_utf_8(term)) { + text++; + c++; + } else { int u; GET_UTF_8(text, u); if (!F) c++; @@ -1821,8 +1857,10 @@ void min_text_width(struct terminal *term, unsigned char *text, int *width, int do { int c = 0; while (*text && *text != '\n' && *text != ' ') { - if (!is_utf_8(term)) text++, c++; - else { + if (!is_utf_8(term)) { + text++; + c++; + } else { int u; GET_UTF_8(text, u); if (!F) c++; @@ -2035,7 +2073,10 @@ void dlg_format_text_and_field(struct dialog_data *dlg, struct terminal *term, u dlg_format_field(dlg, term, item, x, y, w, rw, align); } else { int pos = dlg_format_text(dlg, term, text, x, y, w, rw, co, align); - if (pos >= w - 4) (*y)++, pos = 0; + if (pos >= w - 4) { + (*y)++; + pos = 0; + } if (term) { item->x = x + pos; item->y = *y - 1; @@ -2283,7 +2324,8 @@ void msg_box(struct terminal *term, struct memory_list *ml, unsigned char *title msg_fn = va_arg(ap, msg_button_fn); flags = va_arg(ap, int); if (!m) { - i--, n--; + i--; + n--; continue; } dlg->items[i].type = D_BUTTON; diff --git a/cache.c b/cache.c @@ -353,8 +353,10 @@ void truncate_entry(struct cache_entry *e, off_t off, int final) int modified = final == 2; struct fragment *f, *g; struct list_head *lf; - if (e->length > off) - e->length = off, e->incomplete = 1; + if (e->length > off) { + e->length = off; + e->incomplete = 1; + } foreach(struct fragment, f, lf, e->frag) { if (f->offset >= off) { modified = 1; @@ -477,8 +479,17 @@ static int shrink_file_cache(int u) ccs += (my_uintptr_t)e->data_size; ccs2 += e->decompressed_len; } - if (ccs != cache_size) internal("cache size badly computed: %lu != %lu", (unsigned long)cache_size, (unsigned long)ccs), cache_size = ccs; - if (ccs2 != decompressed_cache_size) internal("decompressed cache size badly computed: %lu != %lu", (unsigned long)decompressed_cache_size, (unsigned long)ccs2), decompressed_cache_size = ccs2; + if (ccs != cache_size) { + internal("cache size badly computed: %lu != %lu", + (unsigned long)cache_size, (unsigned long)ccs); + cache_size = ccs; + } + if (ccs2 != decompressed_cache_size) { + internal("decompressed cache size badly computed: %lu != %lu", + (unsigned long)decompressed_cache_size, + (unsigned long)ccs2); + decompressed_cache_size = ccs2; + } if (u == SH_CHECK_QUOTA && ncs <= (my_uintptr_t)memory_cache_size) goto ret; foreachback(struct cache_entry, e, le, cache) { if (u == SH_CHECK_QUOTA && (longlong)ncs <= (longlong)memory_cache_size * MEMORY_CACHE_GC_PERCENT) goto g; diff --git a/charsets.c b/charsets.c @@ -153,30 +153,32 @@ unsigned char *encode_utf_8(int u) if (u < 0); else if (u < 0x80) utf_buffer[0] = (unsigned char)u; - else if (u < 0x800) - utf_buffer[0] = 0xc0 | ((u >> 6) & 0x1f), + else if (u < 0x800) { + utf_buffer[0] = 0xc0 | ((u >> 6) & 0x1f); utf_buffer[1] = 0x80 | (u & 0x3f); - else if (u < 0x10000) - utf_buffer[0] = 0xe0 | ((u >> 12) & 0x0f), - utf_buffer[1] = 0x80 | ((u >> 6) & 0x3f), + } else if (u < 0x10000) { + utf_buffer[0] = 0xe0 | ((u >> 12) & 0x0f); + utf_buffer[1] = 0x80 | ((u >> 6) & 0x3f); utf_buffer[2] = 0x80 | (u & 0x3f); - else if (u < 0x200000) - utf_buffer[0] = 0xf0 | ((u >> 18) & 0x0f), - utf_buffer[1] = 0x80 | ((u >> 12) & 0x3f), - utf_buffer[2] = 0x80 | ((u >> 6) & 0x3f), + } else if (u < 0x200000) { + utf_buffer[0] = 0xf0 | ((u >> 18) & 0x0f); + utf_buffer[1] = 0x80 | ((u >> 12) & 0x3f); + utf_buffer[2] = 0x80 | ((u >> 6) & 0x3f); utf_buffer[3] = 0x80 | (u & 0x3f); - else if (u < 0x4000000) - utf_buffer[0] = 0xf8 | ((u >> 24) & 0x0f), - utf_buffer[1] = 0x80 | ((u >> 18) & 0x3f), - utf_buffer[2] = 0x80 | ((u >> 12) & 0x3f), - utf_buffer[3] = 0x80 | ((u >> 6) & 0x3f), + } else if (u < 0x4000000) { + utf_buffer[0] = 0xf8 | ((u >> 24) & 0x0f); + utf_buffer[1] = 0x80 | ((u >> 18) & 0x3f); + utf_buffer[2] = 0x80 | ((u >> 12) & 0x3f); + utf_buffer[3] = 0x80 | ((u >> 6) & 0x3f); utf_buffer[4] = 0x80 | (u & 0x3f); - else utf_buffer[0] = 0xfc | ((u >> 30) & 0x01), - utf_buffer[1] = 0x80 | ((u >> 24) & 0x3f), - utf_buffer[2] = 0x80 | ((u >> 18) & 0x3f), - utf_buffer[3] = 0x80 | ((u >> 12) & 0x3f), - utf_buffer[4] = 0x80 | ((u >> 6) & 0x3f), + } else { + utf_buffer[0] = 0xfc | ((u >> 30) & 0x01); + utf_buffer[1] = 0x80 | ((u >> 24) & 0x3f); + utf_buffer[2] = 0x80 | ((u >> 18) & 0x3f); + utf_buffer[3] = 0x80 | ((u >> 12) & 0x3f); + utf_buffer[4] = 0x80 | ((u >> 6) & 0x3f); utf_buffer[5] = 0x80 | (u & 0x3f); + } return utf_buffer; } @@ -313,7 +315,10 @@ struct conv_table *get_translation_table(int from, int to) static int lto = -1; if (/*from == to ||*/ from == -1 || to == -1) return NULL; if (to == utf8_table) return get_translation_table_to_utf_8(from); - if (table_init) memset(table, 0, sizeof(struct conv_table) * 256), table_init = 0; + if (table_init) { + memset(table, 0, sizeof(struct conv_table) * 256); + table_init = 0; + } if (from == lfr && to == lto) return table; lfr = from; lto = to; new_translation_table(table); @@ -340,7 +345,9 @@ static inline int xxstrcmp(unsigned char *s1, unsigned char *s2, int l2) while (l2) { if (*s1 > *s2) return 1; if (!*s1 || *s1 < *s2) return -1; - s1++, s2++, l2--; + s1++; + s2++; + l2--; } return !!*s1; } @@ -349,7 +356,8 @@ int get_entity_number(unsigned char *st, int l) { int n = 0; if (upcase(st[0]) == 'X') { - st++, l--; + st++; + l--; if (!l) return -1; do { unsigned char c = upcase(*(st++)); diff --git a/compress.c b/compress.c @@ -288,7 +288,8 @@ int get_file_by_term(struct terminal *term, struct cache_entry *ce, unsigned cha if (list_empty(ce->frag)) return 1; fr = list_struct(ce->frag.next, struct fragment); if (fr->offset || !fr->length) return 1; - *start = fr->data, *end = fr->data + fr->length; + *start = fr->data; + *end = fr->data + fr->length; return 0; } diff --git a/default.c b/default.c @@ -61,7 +61,8 @@ static unsigned char *p_arse_options(int argc, unsigned char *argv[], struct opt } } while (argc) { - argv++, argc--; + argv++; + argc--; if (argv[-1][0] == '-') { struct option *options; struct option **op; @@ -164,7 +165,12 @@ static void parse_config_file(unsigned char *name, unsigned char *file, struct o for (i = 0; options[i].p; i++) if (options[i].cfg_name && (size_t)nl == strlen(cast_const_char options[i].cfg_name) && !casecmp(tok, cast_uchar options[i].cfg_name, nl)) { unsigned char *o = memacpy(p, pl); if ((e = options[i].rd_cfg(&options[i], o))) { - if (e[0]) fprintf(stderr, "Error parsing config file %s, line %d: %s\n", name, line, e), err = 1; + if (e[0]) { + fprintf(stderr, + "Error parsing config file %s, line %d: %s\n", + name, line, e); + err = 1; + } } free(o); goto f; @@ -174,7 +180,10 @@ static void parse_config_file(unsigned char *name, unsigned char *file, struct o f: free(tok); } - if (err) fprintf(stderr, "\007"), portable_sleep(1000); + if (err) { + fprintf(stderr, "\007"); + portable_sleep(1000); + } } static unsigned char *create_config_string(struct option *options) diff --git a/dip.c b/dip.c @@ -857,7 +857,8 @@ static void decimate_3(unsigned short **data0, int x, int y) data[0]=(ahead[-3]+ahead[0]+ahead[3])/3; data[1]=(ahead[1]+ahead[4]+ahead[7])/3; data[2]=(ahead[5]+ahead[8]+ahead[8])/3; - ahead+=9,data+=3; + ahead += 9; + data += 3; } } }else{ @@ -881,7 +882,8 @@ static void decimate_3(unsigned short **data0, int x, int y) data[0]=(ahead[3]+ahead[6]+ahead[6])/3; data[1]=(ahead[1]+ahead[4]+ahead[7])/3; data[2]=(ahead[-1]+ahead[2]+ahead[5])/3; - ahead+=9,data+=3; + ahead += 9; + data += 3; } } } @@ -1930,8 +1932,10 @@ int g_wrap_text(struct wrap_struct *w) int u; int s; unsigned char *l_text = w->text; - if (*l_text == ' ') w->last_wrap = l_text, - w->last_wrap_obj = w->obj; + if (*l_text == ' ') { + w->last_wrap = l_text; + w->last_wrap_obj = w->obj; + } GET_UTF_8(w->text, u); if (!u) continue; s = g_get_width(w->style, u); diff --git a/dither.c b/dither.c @@ -704,7 +704,10 @@ static void make_16_table(int *table, int bits, int pos, float_double gamma, int if (!(j & (j - 1))) { uttime now = get_time(); if (!sample_state) { - if (now != start_time) start_time = now, sample_state = 1; + if (now != start_time) { + start_time = now; + sample_state = 1; + } } else { if (now - start_time > SLOW_FPU_DETECT_THRESHOLD && (now - start_time) * 65536 / j > SLOW_FPU_MAX_STARTUP / 3) { x_slow_fpu = 1; diff --git a/file.c b/file.c @@ -193,7 +193,8 @@ static unsigned char *get_filename(unsigned char *url) int ml; for (p = url + 7; *p && *p != POST_CHAR; p++) ; - m = init_str(), ml = 0; + m = init_str(); + ml = 0; add_conv_str(&m, &ml, url + 7, (int)(p - url - 7), -2); return m; } diff --git a/html.c b/html.c @@ -127,9 +127,15 @@ unsigned char *get_attr_val(unsigned char *e, unsigned char *name) while (WHITECHAR(*e)) e++; if (*e == '>' || *e == '<') return NULL; n = name; - while (*n && upcase(*e) == upcase(*n)) e++, n++; + while (*n && upcase(*e) == upcase(*n)) { + e++; + n++; + } f = *n; - while (atchr(*e)) f = 1, e++; + while (atchr(*e)) { + f = 1; + e++; + } while (WHITECHAR(*e)) e++; if (*e != '=') goto ea; e++; @@ -608,7 +614,10 @@ int empty_format; static void ln_break(int n) { if (!n || html_top.invisible) return; - while (n > line_breax) line_breax++, line_break_f(ff); + while (n > line_breax) { + line_breax++; + line_break_f(ff); + } pos = 0; putsp = -1; } @@ -704,9 +713,15 @@ static void put_chrs(unsigned char *start, int len) { if (par_format.align == AL_NO || par_format.align == AL_NO_BREAKABLE) putsp = 0; if (!len || html_top.invisible) return; - if (putsp == 1) pos += put_chars_conv(cast_uchar " ", 1), putsp = -1; + if (putsp == 1) { + pos += put_chars_conv(cast_uchar " ", 1); + putsp = -1; + } if (putsp == -1) { - if (start[0] == ' ') start++, len--; + if (start[0] == ' ') { + start++; + len--; + } putsp = 0; } if (!len) { @@ -798,7 +813,10 @@ static int parse_width(unsigned char *w, int trunc) ; while (l && WHITECHAR(w[l - 1])) l--; if (!l) return -1; - if (w[l - 1] == '%') l--, p = 1; + if (w[l - 1] == '%') { + l--; + p = 1; + } while (l && WHITECHAR(w[l - 1])) l--; if (!l) return -1; s = strtoul(cast_const_char w, (char **)(void *)&end, 10); @@ -987,8 +1005,14 @@ static void html_font(unsigned char *a) unsigned long s; unsigned char *nn = al; unsigned char *end; - if (*al == '+') p = 1, nn++; - if (*al == '-') p = -1, nn++; + if (*al == '+') { + p = 1; + nn++; + } + if (*al == '-') { + p = -1; + nn++; + } s = strtoul(cast_const_char nn, (char **)(void *)&end, 10); if (*nn && !*end) { if (s > 7) s = 7; @@ -1129,7 +1153,8 @@ static void html_img(unsigned char *a) i.url = stracpy(format_.image); - i.src = orig_link, orig_link = NULL; + i.src = orig_link; + orig_link = NULL; /* i.xsize = get_num(a, cast_uchar "width"); i.ysize = get_num(a, cast_uchar "height"); @@ -1216,7 +1241,11 @@ static void html_obj(unsigned char *a, int obj) free(url); } ret: - if (base) free(format_.href_base), format_.href_base = old_base, free(base); + if (base) { + free(format_.href_base); + format_.href_base = old_base; + free(base); + } free(type); } @@ -1559,7 +1588,12 @@ static void html_li(unsigned char *a) if (F) par_format.leftmargin += 4; #endif if (s != -1) par_format.list_number = s; - if ((t != P_roman && t != P_ROMAN && par_format.list_number < 10) || t == P_alpha || t == P_ALPHA) put_chrs(cast_uchar "&nbsp;", 6), c = 1; + if ((t != P_roman && t != P_ROMAN + && par_format.list_number < 10) + || t == P_alpha || t == P_ALPHA) { + put_chrs(cast_uchar "&nbsp;", 6); + c = 1; + } if (t == P_ALPHA || t == P_alpha) { n[0] = par_format.list_number ? (par_format.list_number - 1) % 26 + (t == P_ALPHA ? 'A' : 'a') : 0; n[1] = 0; @@ -1676,7 +1710,8 @@ static void find_form_for_input(unsigned char *i) lf = last_form_tag; s = last_input_tag; } else { - lf = NULL, la = NULL; + lf = NULL; + la = NULL; s = startf; } se: @@ -1950,7 +1985,8 @@ static void html_option(unsigned char *a) while (p < eoff && WHITECHAR(*p)) p++; while (p < eoff && !WHITECHAR(*p) && *p != '<') { pppp: - add_chr_to_str(&val, &l, *p), p++; + add_chr_to_str(&val, &l, *p); + p++; } r = p; while (r < eoff && WHITECHAR(*r)) r++; @@ -2159,7 +2195,9 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha vlbl = NULL; vlbl_l = 0; val = NULL; - order = 0, group = 0, preselect = -1; + order = 0; + group = 0; + preselect = -1; init_menu(); se: en = html; @@ -2182,7 +2220,10 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha if (lbl) { unsigned char *q, *s = en; int l = (int)(html - en); - while (l && WHITECHAR(s[0])) s++, l--; + while (l && WHITECHAR(s[0])) { + s++; + l--; + } while (l && WHITECHAR(s[l-1])) l--; q = convert_string(ct, s, l, d_opt); if (q) { @@ -2202,8 +2243,10 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha if (t_namelen == 7 && !casecmp(t_name, cast_uchar "/SELECT", 7)) { if (lbl) { if (!val[order - 1]) val[order - 1] = stracpy(vlbl); - if (!nnmi) new_menu_item(lbl, order - 1, 1), lbl = NULL; - else { + if (!nnmi) { + new_menu_item(lbl, order - 1, 1); + lbl = NULL; + } else { free(lbl); lbl = NULL; } @@ -2215,8 +2258,10 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha if (t_namelen == 7 && !casecmp(t_name, cast_uchar "/OPTION", 7)) { if (lbl) { if (!val[order - 1]) val[order - 1] = stracpy(vlbl); - if (!nnmi) new_menu_item(lbl, order - 1, 1), lbl = NULL; - else { + if (!nnmi) { + new_menu_item(lbl, order - 1, 1); + lbl = NULL; + } else { free(lbl); lbl = NULL; } @@ -2229,8 +2274,10 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha unsigned char *v, *vx; if (lbl) { if (!val[order - 1]) val[order - 1] = stracpy(vlbl); - if (!nnmi) new_menu_item(lbl, order - 1, 1), lbl = NULL; - else { + if (!nnmi) { + new_menu_item(lbl, order - 1, 1); + lbl = NULL; + } else { free(lbl); lbl = NULL; } @@ -2252,8 +2299,10 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha free(vx); } if (!v || !vx) { - lbl = init_str(), lbl_l = 0; - vlbl = init_str(), vlbl_l = 0; + lbl = init_str(); + lbl_l = 0; + vlbl = init_str(); + vlbl_l = 0; nnmi = !!vx; } goto see; @@ -2261,15 +2310,20 @@ static int do_html_select(unsigned char *attr, unsigned char *html, unsigned cha if ((t_namelen == 8 && !casecmp(t_name, cast_uchar "OPTGROUP", 8)) || (t_namelen == 9 && !casecmp(t_name, cast_uchar "/OPTGROUP", 9))) { if (lbl) { if (!val[order - 1]) val[order - 1] = stracpy(vlbl); - if (!nnmi) new_menu_item(lbl, order - 1, 1), lbl = NULL; - else { + if (!nnmi) { + new_menu_item(lbl, order - 1, 1); + lbl = NULL; + } else { free(lbl); lbl = NULL; } free(vlbl); vlbl = NULL; } - if (group) new_menu_item(NULL, -1, 0), group = 0; + if (group) { + new_menu_item(NULL, -1, 0); + group = 0; + } } if (t_namelen == 8 && !casecmp(t_name, cast_uchar "OPTGROUP", 8)) { unsigned char *la; @@ -2514,8 +2568,16 @@ static void parse_frame_widths(unsigned char *a, int ww, int www, int **op, int while (q) { nn = 0; for (i = 0; i < ol; i++) { - if (q < 0) o[i]++, q++, nn = 1; - if (q > 0 && o[i] > 1) o[i]--, q--, nn = 1; + if (q < 0) { + o[i]++; + q++; + nn = 1; + } + if (q > 0 && o[i] > 1) { + o[i]--; + q--; + nn = 1; + } if (!q) break; } if (!nn) break; @@ -2542,7 +2604,10 @@ static void parse_frame_widths(unsigned char *a, int ww, int www, int **op, int /*internal("parse_frame_widths: q < 0"); may happen when page contains too big values */ } for (i = 0; i < ol; i++) if (oo[i] < 0) { - if (q) o[i]++, q--; + if (q) { + o[i]++; + q--; + } } if (q > 0) { q = 0; @@ -2554,8 +2619,15 @@ static void parse_frame_widths(unsigned char *a, int ww, int www, int **op, int int j; int m = 0; int mj = 0; - for (j = 0; j < ol; j++) if (o[j] > m) m = o[j], mj = j; - if (m) o[i] = 1, o[mj]--; + for (j = 0; j < ol; j++) + if (o[j] > m) { + m = o[j]; + mj = j; + } + if (m) { + o[i] = 1; + o[mj]--; + } } } @@ -3405,8 +3477,14 @@ void scan_http_equiv(unsigned char *s, unsigned char *eof, unsigned char **head, } } if (namelen == 4 && !casecmp(name, cast_uchar "BODY", 4)) { - if (background) *background = get_attr_val(attr, cast_uchar "background"), background = NULL; - if (bgcolor) *bgcolor = get_attr_val(attr, cast_uchar "bgcolor"), bgcolor = NULL; + if (background) { + *background = get_attr_val(attr, cast_uchar "background"); + background = NULL; + } + if (bgcolor) { + *bgcolor = get_attr_val(attr, cast_uchar "bgcolor"); + bgcolor = NULL; + } /*return;*/ } if (title && !tlen && namelen == 5 && !casecmp(name, cast_uchar "TITLE", 5)) { diff --git a/html_gr.c b/html_gr.c @@ -131,7 +131,10 @@ void flush_pending_line_to_obj(struct g_part *p, int minheight) if (go->draw == g_text_draw) { struct g_object_text *got = get_struct(go, struct g_object_text, goti.go); int l = (int)strlen(cast_const_char got->text); - while (l && got->text[l - 1] == ' ') got->text[--l] = 0, got->goti.go.xw -= g_char_width(got->style, ' '); + while (l && got->text[l - 1] == ' ') { + got->text[--l] = 0; + got->goti.go.xw -= g_char_width(got->style, ' '); + } if (got->goti.go.xw < 0) internal("xw(%d) < 0", got->goti.go.xw); } @@ -568,7 +571,10 @@ static void do_image(struct g_part *p, struct image_description *im) while (*p && (*p < '0' || *p > '9')) p++; if (!*p) goto noc; - while (*p >= '0' && *p <= '9' && num < 10000000) num = num * 10 + *p - '0', p++; + while (*p >= '0' && *p <= '9' && num < 10000000) { + num = num * 10 + *p - '0'; + p++; + } if (*p == '.') { p++; while (*p >= '0' && *p <= '9') @@ -857,7 +863,8 @@ static void g_put_chars(void *p_, unsigned char *s, int l) p->w.last_wrap_obj = &t->goti.go; p->text = t; } - memcpy(p->text->text + p->pending_text_len, s, l), p->text->text[p->pending_text_len = safe_add(p->pending_text_len, l)] = 0; + memcpy(p->text->text + p->pending_text_len, s, l); + p->text->text[p->pending_text_len = safe_add(p->pending_text_len, l)] = 0; qw = g_text_width(p->text->style, p->text->text + p->pending_text_len - l); p->text->goti.go.xw = safe_add(p->text->goti.go.xw, qw); /* !!! FIXME: move to g_wrap_text */ if (par_format.align != AL_NO /*&& par_format.align != AL_NO_BREAKABLE*/) { diff --git a/html_r.c b/html_r.c @@ -205,8 +205,11 @@ int find_nearest_color(struct rgb *r, int l) if (rgb_cache[h].color != -1 && rgb_cache[h].l == l && rgb_cache[h].rgb.r == r->r && rgb_cache[h].rgb.g == r->g && rgb_cache[h].rgb.b == r->b) return rgb_cache[h].color; dist = 0xffffff; min = 0; - for (i = 0; i < l; i++) if ((dst = color_distance(r, &palette_16_colors[i])) < dist) - dist = dst, min = i; + for (i = 0; i < l; i++) + if ((dst = color_distance(r, &palette_16_colors[i])) < dist) { + dist = dst; + min = i; + } rgb_cache[h].color = min; rgb_cache[h].l = l; rgb_cache[h].rgb.r = r->r; @@ -419,8 +422,12 @@ static inline void move_links(struct part *p, int xf, int yf, int xt, int yt) link->pos[i].x = safe_add(link->pos[i].x, -xf + xt); else link->pos[i].x = link->pos[i].x -xf + xt; + } else { + memmove(&link->pos[i], &link->pos[i+1], + (link->n-i-1) * sizeof(struct point)); + link->n--; + i--; } - else memmove(&link->pos[i], &link->pos[i+1], (link->n-i-1) * sizeof(struct point)), link->n--, i--; } } else { link->first_point_to_move = safe_add(i, 1); @@ -594,7 +601,11 @@ static void put_chars(void *p_, unsigned char *c, int l) if (l < 0) overalloc(); /*printf("%d-", p->cx);for (i=0; i<l; i++) printf("%c", c[i]); printf("-\n");portable_sleep(1000);*/ - while (p->cx <= par_format.leftmargin && l && *c == ' ' && par_format.align != AL_NO && par_format.align != AL_NO_BREAKABLE) c++, l--; + while (p->cx <= par_format.leftmargin && l && *c == ' ' + && par_format.align != AL_NO && par_format.align != AL_NO_BREAKABLE) { + c++; + l--; + } if (!l) return; if (p->cx < par_format.leftmargin) p->cx = par_format.leftmargin; if (c[0] != ' ' || (c[1] && c[1] != ' ')) { @@ -665,7 +676,8 @@ static void put_chars(void *p_, unsigned char *c, int l) no_l: /*printf("%d %d\n",p->cx, p->cy);*/ if (memcmp(&ta_cache, &format_, sizeof(struct text_attrib_beginning))) goto format_change; - bg = bg_cache, fg = fg_cache; + bg = bg_cache; + fg = fg_cache; end_format_change: if (p->y < safe_add(p->cy, 1)) p->y = p->cy + 1; if (nowrap && safe_add(p->cx, ll) > rm(par_format)) { @@ -740,7 +752,9 @@ static void put_chars(void *p_, unsigned char *c, int l) put_chars(p, s, (int)strlen(cast_const_char s)); if (ff && ff->type == FC_TEXTAREA) line_break(p); if (p->cx < par_format.leftmargin) p->cx = par_format.leftmargin; - format_.link = fl, format_.target = ft, format_.image = fi; + format_.link = fl; + format_.target = ft; + format_.image = fi; format_.form = ff; format_.js_event = js; } @@ -779,8 +793,10 @@ static void put_chars(void *p_, unsigned char *c, int l) overalloc(); pt = xrealloc(link->pos, (link->n + ll) * sizeof(struct point)); link->pos = pt; - for (i = 0; i < ll; i++) pt[link->n + i].x = X(p->cx) + i, - pt[link->n + i].y = Y(p->cy); + for (i = 0; i < ll; i++) { + pt[link->n + i].x = X(p->cx) + i; + pt[link->n + i].y = Y(p->cy); + } link->n += ll; } goto no_l; @@ -813,7 +829,12 @@ static void line_break(void *p_) } if (!p->data) goto e; xpand_lines(p, safe_add(p->cy, 1)); - if (p->cx > par_format.leftmargin && LEN(p->cy) > p->cx - 1 && POS(p->cx-1, p->cy).ch == ' ') del_chars(p, p->cx-1, p->cy), p->cx--; + if (p->cx > par_format.leftmargin + && LEN(p->cy) > p->cx - 1 + && POS(p->cx-1, p->cy).ch == ' ') { + del_chars(p, p->cx-1, p->cy); + p->cx--; + } if (p->cx > 0) align_line(p, p->cy); if (p->data) foreachbackfrom(struct tag, t, lt, p->data->tags, last_tag_for_newline) { t->x = X(0); @@ -847,8 +868,11 @@ static void html_form_control(struct part *p, struct form_control *fc) if (fc->type == FC_TEXTAREA) { unsigned char *p; for (p = fc->default_value; p[0]; p++) if (p[0] == '\r') { - if (p[1] == '\n') memmove(p, p + 1, strlen(cast_const_char p)), p--; - else p[0] = '\n'; + if (p[1] == '\n') { + memmove(p, p + 1, strlen(cast_const_char p)); + p--; + } else + p[0] = '\n'; } } add_to_list(p->data->forms, fc); @@ -863,7 +887,10 @@ static void add_frameset_entry(struct frameset_desc *fsd, struct frameset_desc * fsd->f[fsd->xp + fsd->yp * fsd->x].marginwidth = marginwidth; fsd->f[fsd->xp + fsd->yp * fsd->x].marginheight = marginheight; fsd->f[fsd->xp + fsd->yp * fsd->x].scrolling = scrolling; - if (++fsd->xp >= fsd->x) fsd->xp = 0, fsd->yp++; + if (++fsd->xp >= fsd->x) { + fsd->xp = 0; + fsd->yp++; + } } struct frameset_desc *create_frameset(struct f_data *fda, struct frameset_param *fp) @@ -1181,7 +1208,8 @@ void really_format_html(struct cache_entry *ce, unsigned char *start, unsigned c screen->use_tag = ce->count; startf = start; eofff = end; - head = init_str(), hdl = 0; + head = init_str(); + hdl = 0; if (ce->head) add_to_str(&head, &hdl, ce->head); scan_http_equiv(start, end, &head, &hdl, &t, d_opt->plain ? NULL : &bg, d_opt->plain || d_opt->col < 2 ? NULL : &bgcolor, &implicit_pre_wrap, NULL ); if (d_opt->break_long_lines) implicit_pre_wrap = 1; @@ -1219,7 +1247,8 @@ void really_format_html(struct cache_entry *ce, unsigned char *start, unsigned c if (screen->x > w) w = screen->x; if (screen->y > h) h = screen->y; g_x_extend_area(rp->root, w, h, AL_LEFT); - screen->root = &rp->root->go, rp->root = NULL; + screen->root = &rp->root->go; + rp->root = NULL; g_release_part(rp); free(rp); get_parents(screen, screen->root); @@ -1345,14 +1374,23 @@ static int sort_srch(struct f_data *f) } for (i = 0; i < f->y; i++) f->slines1[i] = f->slines2[i] = -1; - for (i = 0; i < f->y; i++) min[i] = MAXINT, max[i] = 0; + for (i = 0; i < f->y; i++) { + min[i] = MAXINT; + max[i] = 0; + } for (i = 0; i < f->nsearch_pos; i++) { struct search *s = &f->search_pos[i]; int xe; - if (s->x < min[s->y]) min[s->y] = s->x, f->slines1[s->y] = s->idx; + if (s->x < min[s->y]) { + min[s->y] = s->x; + f->slines1[s->y] = s->idx; + } if (s->n == 1) xe = safe_add(s->x, s->co); else xe = safe_add(s->x, s->n); - if (xe > max[s->y]) max[s->y] = xe, f->slines2[s->y] = s->idx + s->co - 1; + if (xe > max[s->y]) { + max[s->y] = xe; + f->slines2[s->y] = s->idx + s->co - 1; + } } free(min); free(max); diff --git a/html_tbl.c b/html_tbl.c @@ -474,7 +474,10 @@ static struct table *parse_table(unsigned char *html, unsigned char *eof, unsign } if (t_namelen == 8 && !casecmp(t_name, cast_uchar "COLGROUP", 8)) { if (c_span) new_columns(t, c_span, c_width, c_al, c_val, 1); - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } c_al = AL_TR; c_val = VAL_TR; c_width = W_AUTO; @@ -486,7 +489,10 @@ static struct table *parse_table(unsigned char *html, unsigned char *eof, unsign } if (t_namelen == 9 && !casecmp(t_name, cast_uchar "/COLGROUP", 9)) { if (c_span) new_columns(t, c_span, c_width, c_al, c_val, 1); - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } c_span = 0; c_al = AL_TR; c_val = VAL_TR; @@ -495,7 +501,10 @@ static struct table *parse_table(unsigned char *html, unsigned char *eof, unsign } if (t_namelen == 3 && !casecmp(t_name, cast_uchar "COL", 3)) { int sp, wi, al, val; - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } if ((sp = get_num(t_attr, cast_uchar "span")) == -1) sp = 1; wi = c_width; al = c_al; @@ -509,13 +518,25 @@ static struct table *parse_table(unsigned char *html, unsigned char *eof, unsign } if (t_namelen == 3 && (!casecmp(t_name, cast_uchar "/TR", 3) || !casecmp(t_name, cast_uchar "/TD", 3) || !casecmp(t_name, cast_uchar "/TH", 3))) { if (c_span) new_columns(t, c_span, c_width, c_al, c_val, 1); - if (p) CELL(t, x, y)->end = html, p = 0; - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; + if (p) { + CELL(t, x, y)->end = html; + p = 0; + } + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } } if (t_namelen == 2 && !casecmp(t_name, cast_uchar "TR", 2)) { if (c_span) new_columns(t, c_span, c_width, c_al, c_val, 1); - if (p) CELL(t, x, y)->end = html, p = 0; - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; + if (p) { + CELL(t, x, y)->end = html; + p = 0; + } + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } if (group) group--; l_al = default_line_align(); l_val = VAL_MIDDLE; @@ -523,19 +544,32 @@ static struct table *parse_table(unsigned char *html, unsigned char *eof, unsign get_align(t_attr, &l_al); get_valign(t_attr, &l_val); get_bgcolor(t_attr, &l_col); - y++, x = 0; + y++; + x = 0; goto see; } if (t_namelen == 5 && ((!casecmp(t_name, cast_uchar "THEAD", 5)) || (!casecmp(t_name, cast_uchar "TBODY", 5)) || (!casecmp(t_name, cast_uchar "TFOOT", 5)))) { if (c_span) new_columns(t, c_span, c_width, c_al, c_val, 1); - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } group = 2; } if (t_namelen != 2 || (casecmp(t_name, cast_uchar "TD", 2) && casecmp(t_name, cast_uchar "TH", 2))) goto see; if (c_span) new_columns(t, c_span, c_width, c_al, c_val, 1); - if (lbhp) (*bad_html)[*bhp-1].e = html, lbhp = NULL; - if (p) CELL(t, x, y)->end = html, p = 0; - if (y == -1) y = 0, x = 0; + if (lbhp) { + (*bad_html)[*bhp-1].e = html; + lbhp = NULL; + } + if (p) { + CELL(t, x, y)->end = html; + p = 0; + } + if (y == -1) { + y = 0; + x = 0; + } nc: if (!(cell = new_cell(t, x, y))) goto see; if (cell->used) { @@ -714,7 +748,10 @@ static void dst_width(int *p, int n, int w, int *lim) w = 0; for (i = 0; i < n; i++) { p[i] = safe_add(p[i], d + (i < r)); - if (lim && p[i] > lim[i]) w = safe_add(w, p[i] - lim[i]), p[i] = lim[i]; + if (lim && p[i] > lim[i]) { + w = safe_add(w, p[i] - lim[i]); + p[i] = lim[i]; + } } if (w) { /*if (!lim) internal("bug in dst_width");*/ @@ -760,8 +797,13 @@ static int g_get_vline_pad(struct table *t, int col, int *plpos, int *plsize) if (!col || col == t->x) { border = (!col && t->frame & F_LHS) || (col == t->x && t->frame & F_RHS) ? t->border : 0; pad = safe_add(safe_add(border, t->cellsp), t->cellpd); - if (!col) lpos = 0, lsize = border + t->cellsp; - else lpos = pad - border - t->cellsp, lsize = border + t->cellsp; + if (!col) { + lpos = 0; + lsize = border + t->cellsp; + } else { + lpos = pad - border - t->cellsp; + lsize = border + t->cellsp; + } } else { border = t->rules == R_COLS || t->rules == R_ALL || (t->rules == R_GROUPS && col < t->c && t->cols[col].group) ? t->border : 0; pad = safe_add(safe_add(t->cellpd, t->cellpd), t->cellsp); @@ -786,8 +828,13 @@ static int g_get_hline_pad(struct table *t, int row, int *plpos, int *plsize) if (!row || row == t->y) { border = (!row && t->frame & F_ABOVE) || (row == t->y && t->frame & F_BELOW) ? t->border : 0; pad = safe_add(safe_add(border, t->cellsp), t->cellpd); - if (!row) lpos = 0, lsize = border + t->cellsp; - else lpos = pad - border - t->cellsp, lsize = border + t->cellsp; + if (!row) { + lpos = 0; + lsize = border + t->cellsp; + } else { + lpos = pad - border - t->cellsp; + lsize = border + t->cellsp; + } } else { border = t->rules == R_ROWS || t->rules == R_ALL ? t->border : 0; if (t->rules == R_GROUPS) { @@ -872,20 +919,24 @@ static void get_table_width(struct table *t) vl = g_get_vline_pad(t, i, NULL, NULL); } else vl = 0; #endif - min = safe_add(min, vl), max = safe_add(max, vl); + min = safe_add(min, vl); + max = safe_add(max, vl); min = safe_add(min, t->min_c[i]); if (t->xcols[i] > t->max_c[i]) max = safe_add(max, t->xcols[i]); max = safe_add(max, t->max_c[i]); } if (!F) { vl = (!!(t->frame & F_LHS) + !!(t->frame & F_RHS)) * !!t->border; - min = safe_add(min, vl), max = safe_add(max, vl); + min = safe_add(min, vl); + max = safe_add(max, vl); #ifdef G } else { vl = g_get_vline_pad(t, 0, NULL, NULL); - min = safe_add(min, vl), max = safe_add(max, vl); + min = safe_add(min, vl); + max = safe_add(max, vl); vl = g_get_vline_pad(t, t->x, NULL, NULL); - min = safe_add(min, vl), max = safe_add(max, vl); + min = safe_add(min, vl); + max = safe_add(max, vl); #endif } t->min_t = min; @@ -925,7 +976,9 @@ static void distribute_widths(struct table *t, int width) switch (om) { case 0: if (t->w_c[i] < t->xcols[i]) { - w[i] = 1, mx[i] = (t->xcols[i] > t->max_c[i] ? t->max_c[i] : t->xcols[i]) - t->w_c[i]; + w[i] = 1; + mx[i] = (t->xcols[i] > t->max_c[i] ? t->max_c[i] + : t->xcols[i]) - t->w_c[i]; if (mx[i] <= 0) w[i] = 0; } break; @@ -940,21 +993,27 @@ static void distribute_widths(struct table *t, int width) case 3: if (t->w_c[i] < t->max_c[i] && (om == 3 || t->xcols[i] == W_AUTO)) { mx[i] = t->max_c[i] - t->w_c[i]; - if (mmax_c) w[i] = safe_add(gf_val(5, 5 * HTML_CHAR_WIDTH), t->max_c[i] * 10 / mmax_c); + if (mmax_c) + w[i] = safe_add(gf_val(5, 5 * HTML_CHAR_WIDTH), t->max_c[i] * 10 / mmax_c); else w[i] = 1; } break; case 4: if (t->xcols[i] >= 0) { - w[i] = 1, mx[i] = t->xcols[i] - t->w_c[i]; + w[i] = 1; + mx[i] = t->xcols[i] - t->w_c[i]; if (mx[i] <= 0) w[i] = 0; } break; case 5: - if (t->xcols[i] < 0) w[i] = t->xcols[i] <= -2 ? -2 - t->xcols[i] : 1, mx[i] = MAXINT; + if (t->xcols[i] < 0) { + w[i] = t->xcols[i] <= -2 ? -2 - t->xcols[i] : 1; + mx[i] = MAXINT; + } break; case 6: - w[i] = 1, mx[i] = MAXINT; + w[i] = 1; + mx[i] = MAXINT; break; default: /*internal("could not expand table");*/ @@ -976,14 +1035,20 @@ static void distribute_widths(struct table *t, int width) if (u && u[i]) continue; if (!(ss = dd * w[i] / p)) ss = 1; if (ss > mx[i]) ss = mx[i]; - if (ss > mss) mss = ss, mii = i; + if (ss > mss) { + mss = ss; + mii = i; + } } if (mii != -1) { int q = t->w_c[mii]; if (u) u[mii] = 1; t->w_c[mii] = safe_add(t->w_c[mii], mss); d -= t->w_c[mii] - q; - while (d < 0) t->w_c[mii]--, d++; + while (d < 0) { + t->w_c[mii]--; + d++; + } if (t->w_c[mii] < q) { /*internal("shrinking cell");*/ t->w_c[mii] = q; @@ -1054,7 +1119,8 @@ static void check_table_widths(struct table *t) s = 0; ns = 0; for (i = 0; i < t->x; i++) { - s = safe_add(s, t->w_c[i]), ns = safe_add(ns, w[i]); + s = safe_add(s, t->w_c[i]); + ns = safe_add(ns, w[i]); /*if (w[i] > t->w_c[i]) { int k; for (k = 0; k < t->x; k++) debug("%d, %d", t->w_c[k], w[k]); @@ -1069,7 +1135,10 @@ static void check_table_widths(struct table *t) m = -1; for (i = 0; i < t->x; i++) { /*if (table_level == 1) debug("%d: %d %d %d %d", i, t->max_c[i], t->min_c[i], t->w_c[i], w[i]);*/ - if (t->max_c[i] > m) m = t->max_c[i], mi = i; + if (t->max_c[i] > m) { + m = t->max_c[i]; + mi = i; + } } /*if (table_level == 1) debug("%d %d", mi, s - ns);*/ if (m != -1) { @@ -1771,7 +1840,8 @@ static void process_g_table(struct g_part *gp, struct table *t) yw = safe_add(yw, er); } } - c->root->go.x = x, c->root->go.y = y; + c->root->go.x = x; + c->root->go.y = y; c->root->go.y = safe_add(c->root->go.y, c->valign != VAL_MIDDLE && c->valign != VAL_BOTTOM ? 0 : (yw - c->root->go.yw) / (c->valign == VAL_MIDDLE ? 2 : 1)); } x = safe_add(x, t->w_c[i]); @@ -1822,13 +1892,17 @@ static void process_g_table(struct g_part *gp, struct table *t) /*debug("C: %d %d %d %d", c->xpos, c->ypos, c->xw, c->yw);*/ /*debug("%d %d %d", y, ypos, c->ypos);*/ if (!c->used && !c->spanned) { - r.x1 = c->xpos, r.x2 = c->xpos + c->xw; - r.y1 = c->ypos, r.y2 = c->ypos + c->yw; + r.x1 = c->xpos; + r.x2 = c->xpos + c->xw; + r.y1 = c->ypos; + r.y2 = c->ypos + c->yw; add_to_rect_sets(&t->r_bg, &t->nr_bg, &r); } } - r.x1 = x + xpos, r.x2 = x + xpos + xsize; - r.y1 = y + ypos, r.y2 = y + ypos + ysize; + r.x1 = x + xpos; + r.x2 = x + xpos + xsize; + r.y1 = y + ypos; + r.y2 = y + ypos + ysize; if (H_LINE(i-1,j) || H_LINE(i,j) || V_LINE(i,j-1) || V_LINE(i,j)) add_to_rect_sets(&t->r_frame, &t->nr_frame, &r); else if (H_LINE_X(i-1,j) != -2 || H_LINE_X(i,j) != -2 || V_LINE_X(i,j-1) != -2 || V_LINE_X(i,j) != -2) add_to_rect_sets(&t->r_bg, &t->nr_bg, &r); @@ -1844,7 +1918,8 @@ static void process_g_table(struct g_part *gp, struct table *t) else if (l > 0) add_to_rect_sets(&t->r_frame, &t->nr_frame, &r); else add_to_rect_sets(&t->r_bg, &t->nr_bg, &r); } - r.x1 = x + xpos, r.x2 = x + xpos + xsize; + r.x1 = x + xpos; + r.x2 = x + xpos + xsize; if (j < t->y) { int l; int b; diff --git a/kbd.c b/kbd.c @@ -1099,7 +1099,10 @@ static void in_kbd(void *itrm_) struct itrm *itrm = (struct itrm *)itrm_; int r; if (!can_read(itrm->std_in)) return; - if (itrm->tm != NULL) kill_timer(itrm->tm), itrm->tm = NULL; + if (itrm->tm != NULL) { + kill_timer(itrm->tm); + itrm->tm = NULL; + } if (itrm->qlen >= IN_BUF_SIZE) { set_handlers(itrm->std_in, NULL, NULL, itrm); while (process_queue(itrm)) diff --git a/main.c b/main.c @@ -180,7 +180,10 @@ void unhandle_terminal_signals(struct terminal *term) #ifdef SIGCONT install_signal_handler(SIGCONT, NULL, NULL, 0); #endif - if (fg_poll_timer != NULL) kill_timer(fg_poll_timer), fg_poll_timer = NULL; + if (fg_poll_timer != NULL) { + kill_timer(fg_poll_timer); + fg_poll_timer = NULL; + } } static void unhandle_basic_signals(struct terminal *term) @@ -200,7 +203,10 @@ static void unhandle_basic_signals(struct terminal *term) #ifdef SIGCONT install_signal_handler(SIGCONT, NULL, NULL, 0); #endif - if (fg_poll_timer != NULL) kill_timer(fg_poll_timer), fg_poll_timer = NULL; + if (fg_poll_timer != NULL) { + kill_timer(fg_poll_timer); + fg_poll_timer = NULL; + } } int terminal_pipe[2] = { -1, -1 }; @@ -517,8 +523,10 @@ static void terminate_all_subsystems(void) GF(free_dither()); GF(shutdown_graphics()); os_free_clipboard(); - if (fg_poll_timer != NULL) - kill_timer(fg_poll_timer), fg_poll_timer = NULL; + if (fg_poll_timer != NULL) { + kill_timer(fg_poll_timer); + fg_poll_timer = NULL; + } terminate_select(); } diff --git a/os_dep.c b/os_dep.c @@ -197,7 +197,10 @@ int c_pipe(int *fd) { int r; EINTRLOOP(r, pipe(fd)); - if (!r) new_fd_bin(fd[0]), new_fd_bin(fd[1]); + if (!r) { + new_fd_bin(fd[0]); + new_fd_bin(fd[1]); + } return r; } diff --git a/sched.c b/sched.c @@ -142,7 +142,10 @@ void setcstate(struct connection *c, int state) } } else { struct remaining_info *r = &c->prg; - if (r->timer != NULL) kill_timer(r->timer), r->timer = NULL; + if (r->timer != NULL) { + kill_timer(r->timer); + r->timer = NULL; + } } foreach(struct status, stat, lstat, c->statuss) { stat->state = state; @@ -352,8 +355,10 @@ static void check_keepalive_connections(void) struct list_head *lkc; uttime ct = get_absolute_time(); int p = 0; - if (keepalive_timeout != NULL) - kill_timer(keepalive_timeout), keepalive_timeout = NULL; + if (keepalive_timeout != NULL) { + kill_timer(keepalive_timeout); + keepalive_timeout = NULL; + } foreach(struct k_conn, kc, lkc, keepalive_connections) { if (can_read(kc->conn) || ct - kc->add_time > kc->timeout) { lkc = lkc->prev; @@ -1017,7 +1022,10 @@ static void connection_timeout_1(void *c_) void clear_connection_timeout(struct connection *c) { - if (c->timer != NULL) kill_timer(c->timer), c->timer = NULL; + if (c->timer != NULL) { + kill_timer(c->timer); + c->timer = NULL; + } } void set_connection_timeout(struct connection *c) diff --git a/session.c b/session.c @@ -150,11 +150,24 @@ static void add_xnum_to_str(unsigned char **s, int *l, off_t n) { unsigned char suff = 0; int d = -1; - if (n >= 1000000000) suff = 'G', d = (int)((n / 100000000) % 10), n /= 1000000000; - else if (n >= 1000000) suff = 'M', d = (int)((n / 100000) % 10), n /= 1000000; - else if (n >= 1000) suff = 'k', d = (int)((n / 100) % 10), n /= 1000; + if (n >= 1000000000) { + suff = 'G'; + d = (int)((n / 100000000) % 10); + n /= 1000000000; + } else if (n >= 1000000) { + suff = 'M'; + d = (int)((n / 100000) % 10); + n /= 1000000; + } else if (n >= 1000) { + suff = 'k'; + d = (int)((n / 100) % 10); + n /= 1000; + } add_num_to_str(s, l, n); - if (n < 10 && d != -1) add_chr_to_str(s, l, '.'), add_num_to_str(s, l, d); + if (n < 10 && d != -1) { + add_chr_to_str(s, l, '.'); + add_num_to_str(s, l, d); + } add_chr_to_str(s, l, ' '); if (suff) add_chr_to_str(s, l, suff); add_chr_to_str(s, l, 'B'); @@ -163,10 +176,20 @@ static void add_xnum_to_str(unsigned char **s, int *l, off_t n) static void add_time_to_str(unsigned char **s, int *l, uttime t) { unsigned char q[64]; - if (t >= 86400) sprintf(cast_char q, "%lud ", (unsigned long)(t / 86400)), add_to_str(s, l, q); - if (t >= 3600) t %= 86400, sprintf(cast_char q, "%d:%02d", (int)(t / 3600), (int)(t / 60 % 60)), add_to_str(s, l, q); - else sprintf(cast_char q, "%d", (int)(t / 60)), add_to_str(s, l, q); - sprintf(cast_char q, ":%02d", (int)(t % 60)), add_to_str(s, l, q); + if (t >= 86400) { + sprintf(cast_char q, "%lud ", (unsigned long)(t / 86400)); + add_to_str(s, l, q); + } + if (t >= 3600) { + t %= 86400; + sprintf(cast_char q, "%d:%02d", (int)(t / 3600), (int)(t / 60 % 60)); + add_to_str(s, l, q); + } else { + sprintf(cast_char q, "%d", (int)(t / 60)); + add_to_str(s, l, q); + } + sprintf(cast_char q, ":%02d", (int)(t % 60)); + add_to_str(s, l, q); } static unsigned char *get_stat_msg(struct status *stat, struct terminal *term) @@ -177,17 +200,28 @@ static unsigned char *get_stat_msg(struct status *stat, struct terminal *term) add_to_str(&m, &l, get_text_translation(TEXT_(T_RECEIVED), term)); add_to_str(&m, &l, cast_uchar " "); add_xnum_to_str(&m, &l, stat->prg->pos); - if (stat->prg->size >= 0) - add_to_str(&m, &l, cast_uchar " "), add_to_str(&m, &l, get_text_translation(TEXT_(T_OF), term)), add_to_str(&m, &l, cast_uchar " "), add_xnum_to_str(&m, &l, stat->prg->size); + if (stat->prg->size >= 0) { + add_to_str(&m, &l, cast_uchar " "); + add_to_str(&m, &l, get_text_translation(TEXT_(T_OF), + term)); + add_to_str(&m, &l, cast_uchar " "); + add_xnum_to_str(&m, &l, stat->prg->size); + } add_to_str(&m, &l, cast_uchar ", "); - if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) - add_to_str(&m, &l, get_text_translation(TEXT_(T_AVG), term)), add_to_str(&m, &l, cast_uchar " "); + if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) { + add_to_str(&m, &l, get_text_translation(TEXT_(T_AVG), + term)); + add_to_str(&m, &l, cast_uchar " "); + } add_xnum_to_str(&m, &l, stat->prg->loaded * 10 / (stat->prg->elapsed / 100)); add_to_str(&m, &l, cast_uchar "/s"); - if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) - add_to_str(&m, &l, cast_uchar ", "), add_to_str(&m, &l, get_text_translation(TEXT_(T_CUR), term)), add_to_str(&m, &l, cast_uchar " "), - add_xnum_to_str(&m, &l, stat->prg->cur_loaded / (CURRENT_SPD_SEC * SPD_DISP_TIME / 1000)), + if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) { + add_to_str(&m, &l, cast_uchar ", "); + add_to_str(&m, &l, get_text_translation(TEXT_(T_CUR), term)); + add_to_str(&m, &l, cast_uchar " "); + add_xnum_to_str(&m, &l, stat->prg->cur_loaded / (CURRENT_SPD_SEC * SPD_DISP_TIME / 1000)); add_to_str(&m, &l, cast_uchar "/s"); + } return m; } return stracpy(get_text_translation(get_err_msg(stat->state), term)); @@ -295,7 +329,13 @@ void print_screen_status(struct session *ses) draw_to_window(ses->win, x_print_screen_title, ses); m = stracpy(cast_uchar "Links"); - if (ses->screen && ses->screen->f_data && ses->screen->f_data->title && ses->screen->f_data->title[0]) add_to_strn(&m, cast_uchar " - "), add_to_strn(&m, ses->screen->f_data->title); + if (ses->screen + && ses->screen->f_data + && ses->screen->f_data->title + && ses->screen->f_data->title[0]) { + add_to_strn(&m, cast_uchar " - "); + add_to_strn(&m, ses->screen->f_data->title); + } set_terminal_title(ses->term, m); if (!F && ses->brl_cursor_mode) { @@ -339,7 +379,11 @@ unsigned char *encode_url(unsigned char *url) add_to_str(&u, &l, cast_uchar "+++"); for (; *url; url++) { if (is_safe_in_shell(*url) && *url != '+') add_chr_to_str(&u, &l, *url); - else add_chr_to_str(&u, &l, '+'), add_chr_to_str(&u, &l, hx(*url >> 4)), add_chr_to_str(&u, &l, hx(*url & 0xf)); + else { + add_chr_to_str(&u, &l, '+'); + add_chr_to_str(&u, &l, hx(*url >> 4)); + add_chr_to_str(&u, &l, hx(*url & 0xf)); + } } return u; } @@ -354,7 +398,10 @@ unsigned char *decode_url(unsigned char *url) l = 0; for (; *url; url++) { if (*url != '+' || unhx(url[1]) == -1 || unhx(url[2]) == -1) add_chr_to_str(&u, &l, *url); - else add_chr_to_str(&u, &l, (unhx(url[1]) << 4) + unhx(url[2])), url += 2; + else { + add_chr_to_str(&u, &l, (unhx(url[1]) << 4) + unhx(url[2])); + url += 2; + } } return u; } @@ -533,8 +580,13 @@ void download_window_function(struct dialog_data *dlg) add_to_str(&m, &l, get_text_translation(TEXT_(T_RECEIVED), term)); add_to_str(&m, &l, cast_uchar " "); add_xnum_to_str(&m, &l, stat->prg->pos); - if (stat->prg->size >= 0) - add_to_str(&m, &l, cast_uchar " "), add_to_str(&m, &l, get_text_translation(TEXT_(T_OF),term)), add_to_str(&m, &l, cast_uchar " "), add_xnum_to_str(&m, &l, stat->prg->size), add_to_str(&m, &l, cast_uchar " "); + if (stat->prg->size >= 0) { + add_to_str(&m, &l, cast_uchar " "); + add_to_str(&m, &l, get_text_translation(TEXT_(T_OF),term)); + add_to_str(&m, &l, cast_uchar " "); + add_xnum_to_str(&m, &l, stat->prg->size); + add_to_str(&m, &l, cast_uchar " "); + } add_to_str(&m, &l, cast_uchar "\n"); if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) add_to_str(&m, &l, get_text_translation(TEXT_(T_AVERAGE_SPEED), term)); @@ -542,10 +594,13 @@ void download_window_function(struct dialog_data *dlg) add_to_str(&m, &l, cast_uchar " "); add_xnum_to_str(&m, &l, (longlong)stat->prg->loaded * 10 / (stat->prg->elapsed / 100)); add_to_str(&m, &l, cast_uchar "/s"); - if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) - add_to_str(&m, &l, cast_uchar ", "), add_to_str(&m, &l, get_text_translation(TEXT_(T_CURRENT_SPEED), term)), add_to_str(&m, &l, cast_uchar " "), - add_xnum_to_str(&m, &l, stat->prg->cur_loaded / (CURRENT_SPD_SEC * SPD_DISP_TIME / 1000)), + if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) { + add_to_str(&m, &l, cast_uchar ", "); + add_to_str(&m, &l, get_text_translation(TEXT_(T_CURRENT_SPEED), term)); + add_to_str(&m, &l, cast_uchar " "); + add_xnum_to_str(&m, &l, stat->prg->cur_loaded / (CURRENT_SPD_SEC * SPD_DISP_TIME / 1000)); add_to_str(&m, &l, cast_uchar "/s"); + } add_to_str(&m, &l, cast_uchar "\n"); add_to_str(&m, &l, get_text_translation(TEXT_(T_ELAPSED_TIME), term)); add_to_str(&m, &l, cast_uchar " "); @@ -926,7 +981,8 @@ have_frag: download_file_error(down, errno); } else if (down->prog) { exec_on_terminal(get_download_ses(down)->term, down->prog, down->orig_file, !!down->prog_flag_block); - free(down->prog), down->prog = NULL; + free(down->prog); + down->prog = NULL; } else if (down->remotetime && download_utime) { struct timeval utv[2]; unsigned char *file = stracpy(down->orig_file); @@ -1403,12 +1459,15 @@ void init_fcache(void) static void calculate_scrollbars(struct f_data_c *fd, struct f_data *f) { - fd->hsb = 0, fd->vsb = 0; - fd->hsbsize = 0, fd->vsbsize = 0; + fd->hsb = 0; + fd->vsb = 0; + fd->hsbsize = 0; + fd->vsbsize = 0; if (!f) return; if (f->opt.scrolling == SCROLLING_YES) { - fd->hsb = 1, fd->vsb = 1; + fd->hsb = 1; + fd->vsb = 1; } else if (f->opt.scrolling == SCROLLING_AUTO) { x: if (!fd->hsb && f->x > fd->xw - fd->vsb * G_SCROLL_BAR_WIDTH) { @@ -1435,7 +1494,10 @@ struct f_data *cached_format_html(struct f_data_c *fd, struct object_request *rq int marg = (fd->marginwidth + G_HTML_MARGIN - 1) / G_HTML_MARGIN; if (marg >= 0 && marg < 9) opt->margin = marg; } - if (opt->plain == 2) opt->margin = 0, opt->display_images = 1; + if (opt->plain == 2) { + opt->margin = 0; + opt->display_images = 1; + } pr( if (ses) { if (fd->f_data && !strcmp(cast_const_char fd->f_data->rq->url, cast_const_char url) && !compare_opt(&fd->f_data->opt, opt) && is_format_cache_entry_uptodate(fd->f_data)) { @@ -1792,8 +1854,14 @@ void reinit_f_data_c(struct f_data_c *fd) fd->next_update_interval = 0; fd->done = 0; fd->parsed_done = 0; - if (fd->image_timer != NULL) kill_timer(fd->image_timer), fd->image_timer = NULL; - if (fd->refresh_timer != NULL) kill_timer(fd->refresh_timer), fd->refresh_timer = NULL; + if (fd->image_timer != NULL) { + kill_timer(fd->image_timer); + fd->image_timer = NULL; + } + if (fd->refresh_timer != NULL) { + kill_timer(fd->refresh_timer); + fd->refresh_timer = NULL; + } } struct f_data_c *create_f_data_c(struct session *ses, struct f_data_c *parent) @@ -1871,7 +1939,10 @@ void fd_loaded(struct object_request *rq, void *fd_) int first = !fd->f_data; if (fd->done) { if (f_is_finished(fd->f_data)) goto priint; - else fd->done = 0, fd->parsed_done = 1; + else { + fd->done = 0; + fd->parsed_done = 1; + } } if (fd->parsed_done && f_need_reparse(fd->f_data)) fd->parsed_done = 0; if (fd->vs->plain == -1 && rq->state != O_WAITING) { @@ -1881,8 +1952,10 @@ void fd_loaded(struct object_request *rq, void *fd_) if (!fd->parsed_done) { html_interpret(fd, 1); if (fd->went_to_position) { - if (!fd->goto_position) fd->goto_position = fd->went_to_position, fd->went_to_position = NULL; - else { + if (!fd->goto_position) { + fd->goto_position = fd->went_to_position; + fd->went_to_position = NULL; + } else { free(fd->went_to_position); fd->went_to_position = NULL; } @@ -1904,8 +1977,10 @@ fn: html_interpret(fd, rq == fd->rq && rq->state < 0); if (fd->rq->state < 0 && !f_need_reparse(fd->f_data)) { if (fd->went_to_position) { - if (!fd->goto_position) fd->goto_position = fd->went_to_position, fd->went_to_position = NULL; - else { + if (!fd->goto_position) { + fd->goto_position = fd->went_to_position; + fd->went_to_position = NULL; + } else { free(fd->went_to_position); fd->went_to_position = NULL; } @@ -2003,7 +2078,10 @@ static struct f_data_c *new_main_location(struct session *ses) reinit_f_data_c(ses->screen); ses->screen->loc = loc; ses->screen->vs = loc->vs; - if (ses->wanted_framename) loc->name=ses->wanted_framename, ses->wanted_framename=NULL; + if (ses->wanted_framename) { + loc->name=ses->wanted_framename; + ses->wanted_framename=NULL; + } return ses->screen; } @@ -2310,7 +2388,9 @@ static int prog_sel_open(struct dialog_data *dlg, struct dialog_item_data *idata struct session *ses = (struct session *)dlg->dlg->udata2; if (!a) internal("This should not happen.\n"); - ses->tq_prog = stracpy(a->prog), ses->tq_prog_flag_block = a->block, ses->tq_prog_flag_direct = direct_download_possible(ses->tq, a); + ses->tq_prog = stracpy(a->prog); + ses->tq_prog_flag_block = a->block; + ses->tq_prog_flag_direct = direct_download_possible(ses->tq, a); tp_open(ses); cancel_dialog(dlg,idata); return 0; @@ -2387,7 +2467,11 @@ static void type_query(struct session *ses, unsigned char *ct, struct assoc *a, return; } - if (a) ses->tq_prog = stracpy(a[0].prog), ses->tq_prog_flag_block = a[0].block, ses->tq_prog_flag_direct = direct_download_possible(ses->tq, a); + if (a) { + ses->tq_prog = stracpy(a[0].prog); + ses->tq_prog_flag_block = a[0].block; + ses->tq_prog_flag_direct = direct_download_possible(ses->tq, a); + } if (a && !a[0].ask) { tp_open(ses); if (n) diff --git a/string.c b/string.c @@ -21,7 +21,11 @@ int snprint(unsigned char *s, int n, my_uintptr_t num) int snzprint(unsigned char *s, int n, off_t num) { off_t q = 1; - if (n > 1 && num < 0) *(s++) = '-', num = -num, n--; + if (n > 1 && num < 0) { + *(s++) = '-'; + num = -num; + n--; + } while (q <= num / 10) q *= 10; while (n-- > 1 && q) { *(s++) = (unsigned char)(num / q + '0'); @@ -111,9 +115,16 @@ void add_num_to_str(unsigned char **s, int *l, off_t n) void add_knum_to_str(unsigned char **s, int *l, off_t n) { unsigned char a[13]; - if (n && n / (1024 * 1024) * (1024 * 1024) == n) snzprint(a, 12, n / (1024 * 1024)), a[strlen(cast_const_char a) + 1] = 0, a[strlen(cast_const_char a)] = 'M'; - else if (n && n / 1024 * 1024 == n) snzprint(a, 12, n / 1024), a[strlen(cast_const_char a) + 1] = 0, a[strlen(cast_const_char a)] = 'k'; - else snzprint(a, 13, n); + if (n && n / (1024 * 1024) * (1024 * 1024) == n) { + snzprint(a, 12, n / (1024 * 1024)); + a[strlen(cast_const_char a) + 1] = 0; + a[strlen(cast_const_char a)] = 'M'; + } else if (n && n / 1024 * 1024 == n) { + snzprint(a, 12, n / 1024); + a[strlen(cast_const_char a) + 1] = 0; + a[strlen(cast_const_char a)] = 'k'; + } else + snzprint(a, 13, n); add_to_str(s, l, a); } @@ -166,7 +177,8 @@ int casestrcmp(const unsigned char *s1, const unsigned char *s2) return (int)c1 - (int)c2; } if (!*s1) break; - s1++, s2++; + s1++; + s2++; } return 0; } @@ -192,8 +204,11 @@ int casestrstr(const unsigned char *h, const unsigned char *n) const unsigned char *q, *r; for (q=n, r=p;*r&&*q;) { - if (!srch_cmp(*q,*r)) r++,q++; /* same */ - else break; + if (!srch_cmp(*q,*r)) { + r++; + q++; /* same */ + } else + break; } if (!*q) return 1; } diff --git a/terminal.c b/terminal.c @@ -313,7 +313,10 @@ void exclude_rect_from_set(struct rect_set **s, struct rect *r) int restrict_clip_area(struct graphics_device *dev, struct rect *r, int x1, int y1, int x2, int y2) { struct rect v, rr; - rr.x1 = x1, rr.x2 = x2, rr.y1 = y1, rr.y2 = y2; + rr.x1 = x1; + rr.x2 = x2; + rr.y1 = y1; + rr.y2 = y2; if (r) memcpy(r, &dev->clip, sizeof(struct rect)); intersect_rect(&v, &dev->clip, &rr); drv->set_clip_area(dev, &v); @@ -400,7 +403,10 @@ void set_window_pos(struct window *win, int x1, int y1, int x2, int y2) { struct terminal *term = win->term; struct rect r; - r.x1 = x1, r.y1 = y1, r.x2 = x2, r.y2 = y2; + r.x1 = x1; + r.y1 = y1; + r.x2 = x2; + r.y2 = y2; if (is_rect_valid(&win->pos) && (x1 > win->pos.x1 || x2 < win->pos.x2 || y1 > win->pos.y1 || y2 < win->pos.y2) && term->redrawing < 2) { struct window *w; struct list_head *lw; @@ -578,7 +584,10 @@ struct term_spec *new_term_spec(unsigned char *term) t = xmalloc(sizeof(struct term_spec)); memcpy(t, default_term_spec(term), sizeof(struct term_spec)); if (strlen(cast_const_char term) < MAX_TERM_LEN) strcpy(cast_char t->term, cast_const_char term); - else memcpy(t->term, term, MAX_TERM_LEN - 1), t->term[MAX_TERM_LEN - 1] = 0; + else { + memcpy(t->term, term, MAX_TERM_LEN - 1); + t->term[MAX_TERM_LEN - 1] = 0; + } add_to_list(term_specs, t); sync_term_specs(); return t; @@ -629,8 +638,12 @@ static int process_utf_8(struct terminal *term, struct links_event *ev) term->utf8_paste_mode = ev->y & KBD_PASTE; term->utf8_buffer[0] = 0; } - if ((l = strlen(cast_const_char term->utf8_buffer)) >= sizeof(term->utf8_buffer) - 1 || ev->x < 0x80 || ev->x >= 0xc0) - term->utf8_buffer[0] = 0, l = 0; + if ((l = strlen(cast_const_char term->utf8_buffer)) + >= sizeof(term->utf8_buffer) - 1 + || ev->x < 0x80 || ev->x >= 0xc0) { + term->utf8_buffer[0] = 0; + l = 0; + } term->utf8_buffer[l] = (unsigned char)ev->x; term->utf8_buffer[l + 1] = 0; p = term->utf8_buffer; @@ -733,7 +746,8 @@ void t_kbd(struct graphics_device *dev, int key, int flags) struct terminal *term = dev->user_data; struct links_event ev = { EV_KBD, 0, 0, 0 }; struct rect r = { 0, 0, 0, 0 }; - r.x2 = dev->size.x2, r.y2 = dev->size.y2; + r.x2 = dev->size.x2; + r.y2 = dev->size.y2; ev.x = key; ev.y = flags; if (upcase(key) == 'L' && flags == KBD_CTRL) { @@ -774,8 +788,11 @@ void t_mouse(struct graphics_device *dev, int x, int y, int b) } else { term->last_mouse_x = term->last_mouse_y = term->last_mouse_b = MAXINT; } - r.x2 = dev->size.x2, r.y2 = dev->size.y2; - ev.x = x, ev.y = y, ev.b = b; + r.x2 = dev->size.x2; + r.y2 = dev->size.y2; + ev.x = x; + ev.y = y; + ev.b = b; drv->set_clip_area(dev, &r); if (list_empty(term->windows)) return; next = list_struct(term->windows.next, struct window); @@ -1205,10 +1222,16 @@ void fill_area(struct terminal *t, int x, int y, int xw, int yw, unsigned ch, un { int i; chr *p, *ps; - if (x < 0) xw += x, x = 0; + if (x < 0) { + xw += x; + x = 0; + } if (x + xw > t->x) xw = t->x - x; if (xw <= 0) return; - if (y < 0) yw += y, y = 0; + if (y < 0) { + yw += y; + y = 0; + } if (y + yw > t->y) yw = t->y - y; if (yw <= 0) return; t->dirty = 1; @@ -1254,7 +1277,10 @@ void print_text(struct terminal *t, int x, int y, int l, unsigned char *text, un void set_cursor(struct terminal *term, int x, int y, int altx, int alty) { term->dirty = 1; - if (term->spec->block_cursor && !term->spec->braille) x = altx, y = alty; + if (term->spec->block_cursor && !term->spec->braille) { + x = altx; + y = alty; + } if (x >= term->x) x = term->x - 1; if (y >= term->y) y = term->y - 1; if (x < 0) x = 0; diff --git a/types.c b/types.c @@ -745,46 +745,126 @@ void create_initial_extensions(void) if (!list_empty(extensions.list_entry)) return; /* here you can add any default extension you want */ - ext.ext = cast_uchar "xpm", ext.ct=cast_uchar "image/x-xpixmap", update_ext(&ext); - ext.ext = cast_uchar "xls", ext.ct=cast_uchar "application/excel", update_ext(&ext); - ext.ext = cast_uchar "xbm", ext.ct=cast_uchar "image/x-xbitmap", update_ext(&ext); - ext.ext = cast_uchar "wav", ext.ct=cast_uchar "audio/x-wav", update_ext(&ext); - ext.ext = cast_uchar "tiff,tif", ext.ct=cast_uchar "image/tiff", update_ext(&ext); - ext.ext = cast_uchar "tga", ext.ct=cast_uchar "image/targa", update_ext(&ext); - ext.ext = cast_uchar "sxw", ext.ct=cast_uchar "application/x-openoffice", update_ext(&ext); - ext.ext = cast_uchar "swf", ext.ct=cast_uchar "application/x-shockwave-flash", update_ext(&ext); - ext.ext = cast_uchar "svg", ext.ct=cast_uchar "image/svg+xml", update_ext(&ext); - ext.ext = cast_uchar "sch", ext.ct=cast_uchar "application/gschem", update_ext(&ext); - ext.ext = cast_uchar "rtf", ext.ct=cast_uchar "application/rtf", update_ext(&ext); - ext.ext = cast_uchar "ra,rm,ram", ext.ct=cast_uchar "audio/x-pn-realaudio", update_ext(&ext); - ext.ext = cast_uchar "qt,mov", ext.ct=cast_uchar "video/quicktime", update_ext(&ext); - ext.ext = cast_uchar "ps,eps,ai", ext.ct=cast_uchar "application/postscript", update_ext(&ext); - ext.ext = cast_uchar "ppt", ext.ct=cast_uchar "application/powerpoint", update_ext(&ext); - ext.ext = cast_uchar "ppm", ext.ct=cast_uchar "image/x-portable-pixmap", update_ext(&ext); - ext.ext = cast_uchar "pnm", ext.ct=cast_uchar "image/x-portable-anymap", update_ext(&ext); - ext.ext = cast_uchar "png", ext.ct=cast_uchar "image/png", update_ext(&ext); - ext.ext = cast_uchar "pgp", ext.ct=cast_uchar "application/pgp-signature", update_ext(&ext); - ext.ext = cast_uchar "pgm", ext.ct=cast_uchar "image/x-portable-graymap", update_ext(&ext); - ext.ext = cast_uchar "pdf", ext.ct=cast_uchar "application/pdf", update_ext(&ext); - ext.ext = cast_uchar "pcb", ext.ct=cast_uchar "application/pcb", update_ext(&ext); - ext.ext = cast_uchar "pbm", ext.ct=cast_uchar "image/x-portable-bitmap", update_ext(&ext); - ext.ext = cast_uchar "mpeg,mpg,mpe", ext.ct=cast_uchar "video/mpeg", update_ext(&ext); - ext.ext = cast_uchar "mp3", ext.ct=cast_uchar "audio/mpeg", update_ext(&ext); - ext.ext = cast_uchar "mid,midi", ext.ct=cast_uchar "audio/midi", update_ext(&ext); - ext.ext = cast_uchar "jpg,jpeg,jpe", ext.ct=cast_uchar "image/jpeg", update_ext(&ext); - ext.ext = cast_uchar "grb", ext.ct=cast_uchar "application/gerber", update_ext(&ext); - ext.ext = cast_uchar "gl", ext.ct=cast_uchar "video/gl", update_ext(&ext); - ext.ext = cast_uchar "gif", ext.ct=cast_uchar "image/gif", update_ext(&ext); - ext.ext = cast_uchar "gbr", ext.ct=cast_uchar "application/gerber", update_ext(&ext); - ext.ext = cast_uchar "g", ext.ct=cast_uchar "application/brlcad", update_ext(&ext); - ext.ext = cast_uchar "fli", ext.ct=cast_uchar "video/fli", update_ext(&ext); - ext.ext = cast_uchar "dxf", ext.ct=cast_uchar "application/dxf", update_ext(&ext); - ext.ext = cast_uchar "dvi", ext.ct=cast_uchar "application/x-dvi", update_ext(&ext); - ext.ext = cast_uchar "dl", ext.ct=cast_uchar "video/dl", update_ext(&ext); - ext.ext = cast_uchar "deb", ext.ct=cast_uchar "application/x-debian-package", update_ext(&ext); - ext.ext = cast_uchar "avi", ext.ct=cast_uchar "video/x-msvideo", update_ext(&ext); - ext.ext = cast_uchar "au,snd", ext.ct=cast_uchar "audio/basic", update_ext(&ext); - ext.ext = cast_uchar "aif,aiff,aifc", ext.ct=cast_uchar "audio/x-aiff", update_ext(&ext); + ext.ext = cast_uchar "xpm"; + ext.ct = cast_uchar "image/x-xpixmap"; + update_ext(&ext); + ext.ext = cast_uchar "xls"; + ext.ct = cast_uchar "application/excel"; + update_ext(&ext); + ext.ext = cast_uchar "xbm"; + ext.ct = cast_uchar "image/x-xbitmap"; + update_ext(&ext); + ext.ext = cast_uchar "wav"; + ext.ct = cast_uchar "audio/x-wav"; + update_ext(&ext); + ext.ext = cast_uchar "tiff,tif"; + ext.ct = cast_uchar "image/tiff"; + update_ext(&ext); + ext.ext = cast_uchar "tga"; + ext.ct = cast_uchar "image/targa"; + update_ext(&ext); + ext.ext = cast_uchar "sxw"; + ext.ct = cast_uchar "application/x-openoffice"; + update_ext(&ext); + ext.ext = cast_uchar "swf"; + ext.ct = cast_uchar "application/x-shockwave-flash"; + update_ext(&ext); + ext.ext = cast_uchar "svg"; + ext.ct = cast_uchar "image/svg+xml"; + update_ext(&ext); + ext.ext = cast_uchar "sch"; + ext.ct = cast_uchar "application/gschem"; + update_ext(&ext); + ext.ext = cast_uchar "rtf"; + ext.ct = cast_uchar "application/rtf"; + update_ext(&ext); + ext.ext = cast_uchar "ra,rm,ram"; + ext.ct = cast_uchar "audio/x-pn-realaudio"; + update_ext(&ext); + ext.ext = cast_uchar "qt,mov"; + ext.ct = cast_uchar "video/quicktime"; + update_ext(&ext); + ext.ext = cast_uchar "ps,eps,ai"; + ext.ct = cast_uchar "application/postscript"; + update_ext(&ext); + ext.ext = cast_uchar "ppt"; + ext.ct = cast_uchar "application/powerpoint"; + update_ext(&ext); + ext.ext = cast_uchar "ppm"; + ext.ct = cast_uchar "image/x-portable-pixmap"; + update_ext(&ext); + ext.ext = cast_uchar "pnm"; + ext.ct = cast_uchar "image/x-portable-anymap"; + update_ext(&ext); + ext.ext = cast_uchar "png"; + ext.ct = cast_uchar "image/png"; + update_ext(&ext); + ext.ext = cast_uchar "pgp"; + ext.ct = cast_uchar "application/pgp-signature"; + update_ext(&ext); + ext.ext = cast_uchar "pgm"; + ext.ct = cast_uchar "image/x-portable-graymap"; + update_ext(&ext); + ext.ext = cast_uchar "pdf"; + ext.ct = cast_uchar "application/pdf"; + update_ext(&ext); + ext.ext = cast_uchar "pcb"; + ext.ct = cast_uchar "application/pcb"; + update_ext(&ext); + ext.ext = cast_uchar "pbm"; + ext.ct = cast_uchar "image/x-portable-bitmap"; + update_ext(&ext); + ext.ext = cast_uchar "mpeg,mpg,mpe"; + ext.ct = cast_uchar "video/mpeg"; + update_ext(&ext); + ext.ext = cast_uchar "mp3"; + ext.ct = cast_uchar "audio/mpeg"; + update_ext(&ext); + ext.ext = cast_uchar "mid,midi"; + ext.ct = cast_uchar "audio/midi"; + update_ext(&ext); + ext.ext = cast_uchar "jpg,jpeg,jpe"; + ext.ct = cast_uchar "image/jpeg"; + update_ext(&ext); + ext.ext = cast_uchar "grb"; + ext.ct = cast_uchar "application/gerber"; + update_ext(&ext); + ext.ext = cast_uchar "gl"; + ext.ct = cast_uchar "video/gl"; + update_ext(&ext); + ext.ext = cast_uchar "gif"; + ext.ct = cast_uchar "image/gif"; + update_ext(&ext); + ext.ext = cast_uchar "gbr"; + ext.ct = cast_uchar "application/gerber"; + update_ext(&ext); + ext.ext = cast_uchar "g"; + ext.ct = cast_uchar "application/brlcad"; + update_ext(&ext); + ext.ext = cast_uchar "fli"; + ext.ct = cast_uchar "video/fli"; + update_ext(&ext); + ext.ext = cast_uchar "dxf"; + ext.ct = cast_uchar "application/dxf"; + update_ext(&ext); + ext.ext = cast_uchar "dvi"; + ext.ct = cast_uchar "application/x-dvi"; + update_ext(&ext); + ext.ext = cast_uchar "dl"; + ext.ct = cast_uchar "video/dl"; + update_ext(&ext); + ext.ext = cast_uchar "deb"; + ext.ct = cast_uchar "application/x-debian-package"; + update_ext(&ext); + ext.ext = cast_uchar "avi"; + ext.ct = cast_uchar "video/x-msvideo"; + update_ext(&ext); + ext.ext = cast_uchar "au,snd"; + ext.ct = cast_uchar "audio/basic"; + update_ext(&ext); + ext.ext = cast_uchar "aif,aiff,aifc"; + ext.ct = cast_uchar "audio/x-aiff"; + update_ext(&ext); } /* --------------------------- PROG -----------------------------*/ @@ -867,7 +947,8 @@ unsigned char *get_content_type_by_extension(unsigned char *url) struct list_head *ll; unsigned char *ct, *eod, *ext, *exxt; int extl, el; - ext = NULL, extl = 0; + ext = NULL; + extl = 0; if (!(ct = get_url_data(url))) ct = url; for (eod = ct; *eod && !end_of_dir(url, *eod); eod++); diff --git a/url.c b/url.c @@ -614,12 +614,15 @@ unsigned char *translate_url(unsigned char *url, unsigned char *cwd) g = memacpy(e, f - e); tl = is_tld(g); free(g); - if (tl) - http: prefix = cast_uchar "http://", sl = 1; + if (tl) { + http: prefix = cast_uchar "http://"; + sl = 1; + } + } + if (*ch == '@' || *ch == ':' || !cmpbeg(url, cast_uchar "ftp.")) { + prefix = cast_uchar "ftp://"; + sl = 1; } - if (*ch == '@' || *ch == ':' || !cmpbeg(url, cast_uchar "ftp.")) prefix = cast_uchar "ftp://", sl = 1; - goto set_prefix; - set_prefix: nu = stracpy(prefix); add_to_strn(&nu, url); if (sl && !strchr(cast_const_char url, '/')) add_to_strn(&nu, cast_uchar "/"); diff --git a/view.c b/view.c @@ -153,7 +153,11 @@ void sort_links(struct f_data *f) if (link->pos[j].y < p) p = link->pos[j].y; if (link->pos[j].y > q) q = link->pos[j].y; } - if (p > q) j = p, p = q, q = j; + if (p > q) { + j = p; + p = q; + q = j; + } for (j = p; j <= q; j++) { if (j >= f->y) { internal("link out of screen"); @@ -373,7 +377,10 @@ static void draw_link(struct terminal *t, struct f_data_c *scr, int l) if (!f || (link->type == L_CHECKBOX && i == 1) || (link->type == L_BUTTON && i == 2) || ((link->type == L_FIELD || link->type == L_AREA) && i == q)) { int xx = x, yy = y; if (link->type != L_FIELD && link->type != L_AREA) { - if ((unsigned)(co->at & 0x38) != (link->sel_color & 0x38)) xx = xp + xw - 1, yy = yp + yw - 1; + if ((unsigned)(co->at & 0x38) != (link->sel_color & 0x38)) { + xx = xp + xw - 1; + yy = yp + yw - 1; + } } set_cursor(t, x, y, xx, yy); set_window_ptr(scr->ses->win, x, y); @@ -453,7 +460,8 @@ static int is_in_range(struct f_data *f, int y, int yw, unsigned char *txt, int int found = 0; int l; int s1, s2; - *min = MAXINT, *max = 0; + *min = MAXINT; + *max = 0; if (!utf8) { l = (int)strlen(cast_const_char txt); @@ -767,7 +775,10 @@ static void draw_form_entry(struct terminal *t, struct f_data_c *f, struct link lnx = format_text(fs->value, form->cols, form->wrap, f->f_data->opt.cp); ln = lnx; sl = fs->vypos; - while (ln->st && sl) sl--, ln++; + while (ln->st && sl) { + sl--; + ln++; + } for (; ln->st && y < l->pos[0].y + yp - vy + form->rows; ln++, y++) { s = textptr_add(ln->st, fs->vpos, f->f_data->opt.cp); for (i = 0; i < form->cols; i++) { @@ -851,7 +862,8 @@ static void y_draw_form_entry(struct terminal *t, void *x_) static void x_draw_form_entry(struct session *ses, struct f_data_c *f, struct link *l) { struct xdfe x; - x.f = f, x.l = l; + x.f = f; + x.l = l; draw_to_window(ses->win, y_draw_form_entry, &x); } @@ -1029,7 +1041,10 @@ void draw_doc(struct terminal *t, void *scr_) if (!scr->f_data->y) return; while (vs->view_pos >= scr->f_data->y) vs->view_pos -= yw ? yw : 1; if (vs->view_pos < 0) vs->view_pos = 0; - if (vy != vs->view_pos) vy = vs->view_pos, check_vs(scr); + if (vy != vs->view_pos) { + vy = vs->view_pos; + check_vs(scr); + } for (y = vy <= 0 ? 0 : vy; y < (-vy + scr->f_data->y <= yw ? scr->f_data->y : yw + vy); y++) { int st = vx <= 0 ? 0 : vx; int en = -vx + scr->f_data->data[y].l <= xw ? scr->f_data->data[y].l : xw + vx; @@ -1159,8 +1174,16 @@ int dump_to_file(struct f_data *fd, int h) else if (fc->type == FC_FILE) add_to_str(&s, &l, cast_uchar "File upload"); else if (fc->type == FC_PASSWORD) add_to_str(&s, &l, cast_uchar "Password field"); else goto unknown; - if (fc->name && fc->name[0]) add_to_str(&s, &l, cast_uchar ", Name "), add_to_str(&s, &l, fc->name); - if ((fc->type == FC_CHECKBOX || fc->type == FC_RADIO) && fc->default_value && fc->default_value[0]) add_to_str(&s, &l, cast_uchar ", Value "), add_to_str(&s, &l, fc->default_value); + if (fc->name && fc->name[0]) { + add_to_str(&s, &l, cast_uchar ", Name "); + add_to_str(&s, &l, fc->name); + } + if ((fc->type == FC_CHECKBOX || fc->type == FC_RADIO) + && fc->default_value + && fc->default_value[0]) { + add_to_str(&s, &l, cast_uchar ", Value "); + add_to_str(&s, &l, fc->default_value); + } } unknown: add_to_str(&s, &l, cast_uchar "\n"); @@ -1506,7 +1529,10 @@ static void cursor_word(struct session *ses, struct f_data_c *f, int a) return; } x++; - if (x >= f->f_data->x) x = 0, y++; + if (x >= f->f_data->x) { + x = 0; + y++; + } p = q; } } @@ -1520,9 +1546,13 @@ static void cursor_word_back(struct session *ses, struct f_data_c *f, int a) int x = f->vs->brl_x, y = f->vs->brl_y; int px, py; while (1) { - px = x, py = y; + px = x; + py = y; x--; - if (x < 0) x = f->f_data->x - 1, y--; + if (x < 0) { + x = f->f_data->x - 1; + y--; + } if (x < 0) x = 0; q = get_at_pos(f->f_data, x, y); if (q == -1) return; @@ -1572,7 +1602,8 @@ static void br_next_link(struct session *ses, struct f_data_c *f, int a) for (y = vs->brl_y; y < f_data->y; y++) if (f_data->lines1[y]) goto o; return; o: - cl = NULL, ol = NULL; + cl = NULL; + ol = NULL; for (l = f_data->lines1[y]; l && l < f_data->links + f_data->nlinks && (!cl || l <= cl); l++) { if (!l->n) continue; if (a && !l->form) continue; @@ -1609,7 +1640,8 @@ static void br_prev_link(struct session *ses, struct f_data_c *f, int a) for (y = vs->brl_y; y >= 0; y--) if (f_data->lines2[y]) goto o; return; o: - cl = NULL, ol = NULL; + cl = NULL; + ol = NULL; for (l = f_data->lines2[y]; l && l >= f_data->links && (!cl || l >= cl); l--) { if (!l->n) goto cont; if (l->pos[0].y < vs->brl_y || (l->pos[0].y == vs->brl_y && l->pos[0].x < vs->brl_x)) if (vs->current_link == -1 || l != f_data->links + vs->current_link) { @@ -2365,14 +2397,22 @@ static int textarea_adjust_viewport(struct f_data_c *fd, struct link *l) struct form_control *fc = l->form; struct view_state *vs = fd->vs; int r = 0; - if (l->pos[0].x + fc->cols > fd->xw + vs->view_posx) - vs->view_posx = l->pos[0].x + fc->cols - fd->xw, r = 1; - if (l->pos[0].x < vs->view_posx) - vs->view_posx = l->pos[0].x, r = 1; - if (l->pos[0].y + fc->rows > fd->yw + vs->view_pos) - vs->view_pos = l->pos[0].y + fc->rows - fd->yw, r = 1; - if (l->pos[0].y < vs->view_pos) - vs->view_pos = l->pos[0].y, r = 1; + if (l->pos[0].x + fc->cols > fd->xw + vs->view_posx) { + vs->view_posx = l->pos[0].x + fc->cols - fd->xw; + r = 1; + } + if (l->pos[0].x < vs->view_posx) { + vs->view_posx = l->pos[0].x; + r = 1; + } + if (l->pos[0].y + fc->rows > fd->yw + vs->view_pos) { + vs->view_pos = l->pos[0].y + fc->rows - fd->yw; + r = 1; + } + if (l->pos[0].y < vs->view_pos) { + vs->view_pos = l->pos[0].y; + r = 1; + } vs->orig_view_pos = vs->view_pos; vs->orig_view_posx = vs->view_posx; return r; @@ -2493,7 +2533,10 @@ int field_op(struct session *ses, struct f_data_c *f, struct link *l, struct lin goto b; xx: if (rep) goto rep1; - } else x = 0, f->vs->brl_in_field = 0; + } else { + x = 0; + f->vs->brl_in_field = 0; + } } else if (ev->x == KBD_DOWN && (!ses->term->spec->braille || f->vs->brl_in_field)) { if (form->type == FC_TEXTAREA) { struct line_info *ln; @@ -2514,7 +2557,10 @@ int field_op(struct session *ses, struct f_data_c *f, struct link *l, struct lin yy: if (rep) goto rep2; - } else x = 0, f->vs->brl_in_field = 0; + } else { + x = 0; + f->vs->brl_in_field = 0; + } } else if ((ev->x == KBD_END || (upcase(ev->x) == 'E' && ev->y & KBD_CTRL)) /*&& (!ses->term->spec->braille || f->vs->brl_in_field)*/) { if (form->type == FC_TEXTAREA) { struct line_info *ln; @@ -2685,7 +2731,10 @@ static int point_intersect(struct point *p1, int l1, struct point *p2, int l2) int i, j; static unsigned char hash[HASH_SIZE]; static unsigned char init = 0; - if (!init) memset(hash, 0, HASH_SIZE), init = 1; + if (!init) { + memset(hash, 0, HASH_SIZE); + init = 1; + } for (i = 0; i < l1; i++) hash[HASH(p1[i])] = 1; for (j = 0; j < l2; j++) if (hash[HASH(p2[j])]) { for (i = 0; i < l1; i++) if (p1[i].x == p2[j].x && p1[i].y == p2[j].y) { @@ -2863,7 +2912,12 @@ static int find_pos_in_link(struct f_data_c *fd, struct link *l, struct links_ev for (a = 0; a < l->n; a++) { if (l->pos[a].x < minx) minx = l->pos[a].x; if (l->pos[a].y < miny) miny = l->pos[a].y; - if (l->pos[a].x - fd->vs->view_posx == ev->x && l->pos[a].y - fd->vs->view_pos == ev->y) (*xx = l->pos[a].x), (*yy = l->pos[a].y), found = 1; + if (l->pos[a].x - fd->vs->view_posx == ev->x + && l->pos[a].y - fd->vs->view_pos == ev->y) { + (*xx = l->pos[a].x); + (*yy = l->pos[a].y); + found = 1; + } } if (!found) return 1; *xx -= minx; @@ -2941,8 +2995,12 @@ static int frame_ev(struct session *ses, struct f_data_c *fd, struct links_event unsigned char d[2]; d[0] = (unsigned char)ev->x; d[1] = 0; - nl = f_data->nlinks, lnl = 1; - while (nl) nl /= 10, lnl++; + nl = f_data->nlinks; + lnl = 1; + while (nl) { + nl /= 10; + lnl++; + } if (lnl > 1) input_field(ses->term, NULL, TEXT_(T_GO_TO_LINK), TEXT_(T_ENTER_LINK_NUMBER), ses, NULL, lnl, d, 1, f_data->nlinks, check_number, 2, TEXT_(T_OK), goto_link_number, TEXT_(T_CANCEL), input_field_null); } else x = 0; @@ -3827,8 +3885,22 @@ static unsigned char *print_current_linkx(struct f_data_c *fd, struct terminal * free(m); return NULL; } - if (l->form->name && l->form->name[0]) add_to_str(&m, &ll, cast_uchar ", "), add_to_str(&m, &ll, get_text_translation(TEXT_(T_NAME), term)), add_to_str(&m, &ll, cast_uchar " "), add_to_str(&m, &ll, l->form->name); - if ((l->form->type == FC_CHECKBOX || l->form->type == FC_RADIO) && l->form->default_value && l->form->default_value[0]) add_to_str(&m, &ll, cast_uchar ", "), add_to_str(&m, &ll, get_text_translation(TEXT_(T_VALUE), term)), add_to_str(&m, &ll, cast_uchar " "), add_to_str(&m, &ll, l->form->default_value); + if (l->form->name && l->form->name[0]) { + add_to_str(&m, &ll, cast_uchar ", "); + add_to_str(&m, &ll, get_text_translation(TEXT_(T_NAME), + term)); + add_to_str(&m, &ll, cast_uchar " "); + add_to_str(&m, &ll, l->form->name); + } + if ((l->form->type == FC_CHECKBOX || l->form->type == FC_RADIO) + && l->form->default_value + && l->form->default_value[0]) { + add_to_str(&m, &ll, cast_uchar ", "); + add_to_str(&m, &ll, get_text_translation(TEXT_(T_VALUE), + term)); + add_to_str(&m, &ll, cast_uchar " "); + add_to_str(&m, &ll, l->form->default_value); + } /* pri enteru se bude posilat vzdycky -- Brain */ if (l->type == L_FIELD && !has_form_submit(fd->f_data, l->form) && l->form->action) { add_to_str(&m, &ll, cast_uchar ", "); @@ -3965,8 +4037,22 @@ static unsigned char *print_current_linkx_plus(struct f_data_c *fd, struct termi free(m); return NULL; } - if (l->form->name && l->form->name[0]) add_to_str(&m, &ll, cast_uchar ", "), add_to_str(&m, &ll, get_text_translation(TEXT_(T_NAME), term)), add_to_str(&m, &ll, cast_uchar " "), add_to_str(&m, &ll, l->form->name); - if ((l->form->type == FC_CHECKBOX || l->form->type == FC_RADIO) && l->form->default_value && l->form->default_value[0]) add_to_str(&m, &ll, cast_uchar ", "), add_to_str(&m, &ll, get_text_translation(TEXT_(T_VALUE), term)), add_to_str(&m, &ll, cast_uchar " "), add_to_str(&m, &ll, l->form->default_value); + if (l->form->name && l->form->name[0]) { + add_to_str(&m, &ll, cast_uchar ", "); + add_to_str(&m, &ll, get_text_translation(TEXT_(T_NAME), + term)); + add_to_str(&m, &ll, cast_uchar " "); + add_to_str(&m, &ll, l->form->name); + } + if ((l->form->type == FC_CHECKBOX || l->form->type == FC_RADIO) + && l->form->default_value + && l->form->default_value[0]) { + add_to_str(&m, &ll, cast_uchar ", "); + add_to_str(&m, &ll, get_text_translation(TEXT_(T_VALUE), + term)); + add_to_str(&m, &ll, cast_uchar " "); + add_to_str(&m, &ll, l->form->default_value); + } /* pri enteru se bude posilat vzdycky -- Brain */ if (l->type == L_FIELD && !has_form_submit(fd->f_data, l->form) && l->form->action) { add_to_str(&m, &ll, cast_uchar ", "); @@ -4056,8 +4142,16 @@ void loc_msg(struct terminal *term, struct location *lo, struct f_data_c *frame) add_to_str(&s, &l, get_text_translation(TEXT_(T_CODEPAGE), term)); add_to_str(&s, &l, cast_uchar ": "); add_to_str(&s, &l, get_cp_name(frame->f_data->cp)); - if (frame->f_data->ass == 1) add_to_str(&s, &l, cast_uchar " ("), add_to_str(&s, &l, get_text_translation(TEXT_(T_ASSUMED), term)), add_to_str(&s, &l, cast_uchar ")"); - if (frame->f_data->ass == 2) add_to_str(&s, &l, cast_uchar " ("), add_to_str(&s, &l, get_text_translation(TEXT_(T_IGNORING_SERVER_SETTING), term)), add_to_str(&s, &l, cast_uchar ")"); + if (frame->f_data->ass == 1) { + add_to_str(&s, &l, cast_uchar " ("); + add_to_str(&s, &l, get_text_translation(TEXT_(T_ASSUMED), term)); + add_to_str(&s, &l, cast_uchar ")"); + } + if (frame->f_data->ass == 2) { + add_to_str(&s, &l, cast_uchar " ("); + add_to_str(&s, &l, get_text_translation(TEXT_(T_IGNORING_SERVER_SETTING), term)); + add_to_str(&s, &l, cast_uchar ")"); + } } if (ce->head && ce->head[0] != '\n' && ce->head[0] != '\r' && (a = parse_http_header(ce->head, cast_uchar "Content-Type", NULL))) { add_to_str(&s, &l, cast_uchar "\n"); diff --git a/view_gr.c b/view_gr.c @@ -139,20 +139,44 @@ void g_text_draw(struct f_data_c *fd, struct g_object *t_, int x, int y) struct style *inv; int in; case FC_RADIO: - if (link && fd->active && fd->vs->g_display_link && fd->vs->current_link == link - fd->f_data->links) inv = g_invert_style(t->style), in = 1; - else inv = t->style, in = 0; + if (link + && fd->active + && fd->vs->g_display_link + && fd->vs->current_link == link - fd->f_data->links) { + inv = g_invert_style(t->style); + in = 1; + } else { + inv = t->style; + in = 0; + } g_print_text(dev, x, y, inv, fs->state ? cast_uchar "[X]" : cast_uchar "[ ]", NULL); if (in) g_free_style(inv); return; case FC_CHECKBOX: - if (link && fd->active && fd->vs->g_display_link && fd->vs->current_link == link - fd->f_data->links) inv = g_invert_style(t->style), in = 1; - else inv = t->style, in = 0; + if (link + && fd->active + && fd->vs->g_display_link + && fd->vs->current_link == link - fd->f_data->links) { + inv = g_invert_style(t->style); + in = 1; + } else { + inv = t->style; + in = 0; + } g_print_text(dev, x, y, inv, fs->state ? cast_uchar "[X]" : cast_uchar "[ ]", NULL); if (in) g_free_style(inv); return; case FC_SELECT: - if (link && fd->active && fd->vs->g_display_link && fd->vs->current_link == link - fd->f_data->links) inv = g_invert_style(t->style), in = 1; - else inv = t->style, in = 0; + if (link + && fd->active + && fd->vs->g_display_link + && fd->vs->current_link == link - fd->f_data->links) { + inv = g_invert_style(t->style); + in = 1; + } else { + inv = t->style; + in = 0; + } fixup_select_state(form, fs); l = 0; if (fs->state < form->nvalues) g_print_text(dev, x, y, inv, form->labels[fs->state], &l); @@ -189,10 +213,15 @@ void g_text_draw(struct f_data_c *fd, struct g_object *t_, int x, int y) sm = 1; } if (fs->vpos + i >= ll) { - tx[0] = '_', tx[1] = 0, i++; + tx[0] = '_'; + tx[1] = 0; + i++; } else { i += prepare_input_field_char(fs->value + fs->vpos + i, tx); - if (form->type == FC_PASSWORD) tx[0] = '*', tx[1] = 0; + if (form->type == FC_PASSWORD) { + tx[0] = '*'; + tx[1] = 0; + } } g_print_text(dev, x + l, y, st, tx, &l); if (sm) g_free_style(st); @@ -395,7 +424,8 @@ void g_area_draw(struct f_data_c *fd, struct g_object *a_, int xx, int yy) if (fd->ses->term->dev->clip.y1 == fd->ses->term->dev->clip.y2 || fd->ses->term->dev->clip.x1 == fd->ses->term->dev->clip.x2) return; l1 = g_find_line(a->lines, a->n_lines, y1); l2 = g_find_line(a->lines, a->n_lines, y2); - root_x = xx, root_y = yy; + root_x = xx; + root_y = yy; if (!l1) { if (y1 > a->go.yw) return; else l1 = &a->lines[0]; @@ -408,7 +438,8 @@ void g_area_draw(struct f_data_c *fd, struct g_object *a_, int xx, int yy) struct g_object *o = &(*i)->go; o->draw(fd, o, xx + o->x, yy + o->y); } - root_x = rx, root_y = ry; + root_x = rx; + root_y = ry; } void g_area_destruct(struct g_object *a_) @@ -746,7 +777,10 @@ static void get_parents_sub(struct g_object *p, struct g_object *c) int x = 0, y = 0; struct g_object *o; c->y -= c->parent->yw; - for (o = c; o; o = o->parent) x += o->x, y += o->y; + for (o = c; o; o = o->parent) { + x += o->x; + y += o->y; + } html_tag(ffff, tg->name, x, y); } if (c->mouse_event == g_text_mouse) { @@ -756,7 +790,10 @@ static void get_parents_sub(struct g_object *p, struct g_object *c) struct link *link = &ffff->links[l]; int x = 0, y = 0; struct g_object *o; - for (o = c; o; o = o->parent) x += o->x, y += o->y; + for (o = c; o; o = o->parent) { + x += o->x; + y += o->y; + } if (x < link->r.x1) link->r.x1 = x; if (y < link->r.y1) link->r.y1 = y; if (x + c->xw > link->r.x2) link->r.x2 = x + c->xw; @@ -981,7 +1018,11 @@ int g_next_link(struct f_data_c *fd, int dir) if (fd->vs->current_link >= 0 && fd->vs->current_link < fd->f_data->nlinks) { orig_link = fd->vs->current_link; n = (pn = fd->vs->current_link) + dir; - } else retry: n = dir > 0 ? 0 : fd->f_data->nlinks - 1, pn = -1; + } else { +retry: + n = dir > 0 ? 0 : fd->f_data->nlinks - 1; + pn = -1; + } again: if (n < 0 || n >= fd->f_data->nlinks) { if (r == 1) { diff --git a/x.c b/x.c @@ -353,7 +353,10 @@ static int x_translate_key(struct graphics_device *gd, XKeyEvent *e,int *key,int len = XLookupString(e,cast_char str,str_size,&ks,&comp); str[len>str_size?str_size:len]=0; - if (!len) str[0]=(unsigned char)ks, str[1]=0; + if (!len) { + str[0] = (unsigned char)ks; + str[1] = 0; + } *flag=0; *key=0; @@ -519,14 +522,36 @@ static void x_free_hash_table(void) static_color_table = NULL; if (x_display) { - if (x_icon) XFreePixmap(x_display, x_icon), x_icon = 0; - if (fake_window_initialized) XDestroyWindow(x_display,fake_window), fake_window_initialized = 0; - if (x_normal_gc) XFreeGC(x_display,x_normal_gc), x_normal_gc = 0; - if (x_copy_gc) XFreeGC(x_display,x_copy_gc), x_copy_gc = 0; - if (x_drawbitmap_gc) XFreeGC(x_display,x_drawbitmap_gc), x_drawbitmap_gc = 0; - if (x_scroll_gc) XFreeGC(x_display,x_scroll_gc), x_scroll_gc = 0; - if (xim) XCloseIM(xim), xim = NULL; - XCloseDisplay(x_display), x_display = NULL; + if (x_icon) { + XFreePixmap(x_display, x_icon); + x_icon = 0; + } + if (fake_window_initialized) { + XDestroyWindow(x_display, fake_window); + fake_window_initialized = 0; + } + if (x_normal_gc) { + XFreeGC(x_display, x_normal_gc); + x_normal_gc = 0; + } + if (x_copy_gc) { + XFreeGC(x_display, x_copy_gc); + x_copy_gc = 0; + } + if (x_drawbitmap_gc) { + XFreeGC(x_display, x_drawbitmap_gc); + x_drawbitmap_gc = 0; + } + if (x_scroll_gc) { + XFreeGC(x_display, x_scroll_gc); + x_scroll_gc = 0; + } + if (xim) { + XCloseIM(xim); + xim = NULL; + } + XCloseDisplay(x_display); + x_display = NULL; } free(x_driver_param); @@ -1351,7 +1376,8 @@ visual_found:; if (xic) { XDestroyIC(xic); } else { - XCloseIM(xim), xim = NULL; + XCloseIM(xim); + xim = NULL; } } #if defined(LC_CTYPE) @@ -1624,7 +1650,10 @@ no_pixmap: return; cant_create: - if (bmp->data) free(bmp->data), bmp->data = NULL; + if (bmp->data) { + free(bmp->data); + bmp->data = NULL; + } bmp->flags=NULL; return; }