diff --git a/arabic.c b/arabic.c index 37c8bd5..41769a5 100644 --- a/arabic.c +++ b/arabic.c @@ -196,6 +196,7 @@ static const unsigned short transparent[] = { static int is_transparent(int ch) { int i; + for (i = 0; i < (int)(sizeof(transparent)/sizeof(transparent[0])); i++) { if (transparent[i] == ch) return 1; @@ -206,6 +207,7 @@ static int is_transparent(int ch) static const ArabicChar *find_char(int ch) { const ArabicChar *c; + c = arabic_table; while (c->ch != 0 && c->ch != ch) c++; @@ -219,7 +221,7 @@ int arab_join(unsigned int *line, unsigned int *ctog, int len) const ArabicChar *aa, *bb, *cc; a = 0; - for(i=0;iitems); for (b = qs->first_buffer; b != NULL; b = b->next) { - if (!(b->flags & BF_SYSTEM) || (hs->flags & BUFED_ALL_VISIBLE)) + if (!(b->flags & BF_SYSTEM) || (hs->flags & BUFED_ALL_VISIBLE)) add_string(&hs->items, b->name); } @@ -51,12 +51,12 @@ static void build_bufed_list(EditState *s) eb_delete(b, 0, b->total_size); for (i = 0; i < hs->items.nb_items; i++) { eb_printf(b, " %-20s", hs->items.items[i]->str); - b1 = eb_find(hs->items.items[i]->str); - if (b1) { - /* CG: should also display mode */ - eb_printf(b, " %10d %s", b1->total_size, b1->filename); - } - eb_printf(b, "\n"); + b1 = eb_find(hs->items.items[i]->str); + if (b1) { + /* CG: should also display mode */ + eb_printf(b, " %10d %s", b1->total_size, b1->filename); + } + eb_printf(b, "\n"); } s->offset = eb_goto_pos(s->b, last_index, 0); } @@ -86,7 +86,7 @@ static void bufed_select(EditState *s, int temp) return; if (temp && index == bs->last_index) - return; + return; item = bs->items.items[index]; b = eb_find(item->str); @@ -94,18 +94,18 @@ static void bufed_select(EditState *s, int temp) return; e = find_window(s, KEY_RIGHT); if (temp) { - if (e) { - bs->last_index = index; - switch_to_buffer(e, b); - } - return; + if (e) { + bs->last_index = index; + switch_to_buffer(e, b); + } + return; } if (e) { - /* delete dired window */ - do_delete_window(s, 1); - switch_to_buffer(e, b); + /* delete dired window */ + do_delete_window(s, 1); + switch_to_buffer(e, b); } else { - switch_to_buffer(s, b); + switch_to_buffer(s, b); } } @@ -120,7 +120,7 @@ void string_selection_iterate(StringArray *cs, int count, i; count = 0; - for(i=0;inb_items;i++) { + for (i = 0; i < cs->nb_items; i++) { item = cs->items[i]; if (item->selected) { func_item(opaque, item); @@ -175,14 +175,14 @@ static void do_list_buffers(EditState *s) e1 = find_window(e, KEY_RIGHT); if (e1) - b0 = e1->b; + b0 = e1->b; bs = e->mode_data; /* if active buffer is found, go directly on it */ for (i = 0; i < bs->items.nb_items; i++) { if (!strcmp(bs->items.items[i]->str, b0->name)) { - e->offset = eb_goto_pos(e->b, i, 0); + e->offset = eb_goto_pos(e->b, i, 0); break; } } @@ -197,7 +197,7 @@ static void bufed_clear_modified(EditState *s) b = bufed_get_buffer(s); if (!b) - return; + return; b->modified = 0; build_bufed_list(s); @@ -209,7 +209,7 @@ static void bufed_toggle_read_only(EditState *s) b = bufed_get_buffer(s); if (!b) - return; + return; b->flags ^= BF_READONLY; build_bufed_list(s); @@ -220,7 +220,7 @@ static void bufed_refresh(EditState *s, int toggle) BufedState *bs = s->mode_data; if (toggle) - bs->flags ^= BUFED_ALL_VISIBLE; + bs->flags ^= BUFED_ALL_VISIBLE; build_bufed_list(s); } @@ -229,7 +229,7 @@ static void bufed_display_hook(EditState *s) { /* Prevent point from going beyond list */ if (s->offset && s->offset == s->b->total_size) - do_up_down(s, -1); + do_up_down(s, -1); bufed_select(s, 1); } diff --git a/charset.c b/charset.c index dc0be34..06362b7 100644 --- a/charset.c +++ b/charset.c @@ -53,15 +53,15 @@ void charset_init(void) l++; } - for(i=0;i<256;i++) + for (i = 0; i < 256; i++) table_idem[i] = i; /* utf8 table */ - for(i=0;i<256;i++) + for (i = 0; i < 256; i++) table_utf8[i] = INVALID_CHAR; - for(i=0;i<0x80;i++) + for (i = 0; i < 0x80; i++) table_utf8[i] = i; - for(i=0xc0;i<0xfe;i++) + for (i = 0xc0; i < 0xfe; i++) table_utf8[i] = ESCAPE_CHAR; qe_register_charset(&charset_8859_1); @@ -73,6 +73,7 @@ void charset_init(void) void qe_register_charset(QECharset *charset) { QECharset **pp; + pp = &first_charset; while (*pp != NULL) pp = &(*pp)->next; @@ -117,7 +118,7 @@ static void decode_vt100_init(CharsetDecodeState *s) } static unsigned char *encode_vt100(QECharset *charset, - unsigned char *p, int c) + unsigned char *p, int c) { if (c <= 0xff) { *p++ = c; @@ -179,7 +180,7 @@ int utf8_decode(const char **pp) if (l == 1) goto fail; /* can only be multi byte code here */ c = c & first_code_mask[l]; - for(i=1;i= 0xc0) goto fail; @@ -245,7 +246,7 @@ int utf8_to_unicode(unsigned int *dest, int dest_length, p = str; uq = dest; uq_end = dest + dest_length - 1; - for(;;) { + for (;;) { if (uq >= uq_end) break; c = utf8_decode(&p); @@ -289,12 +290,12 @@ QECharset *find_charset(const char *str) { QECharset *p; const char **pp; - for(p = first_charset; p != NULL; p = p->next) { + for (p = first_charset; p != NULL; p = p->next) { if (!strcasecmp(str, p->name)) return p; pp = p->aliases; if (pp) { - for(; *pp != NULL; pp++) { + for (; *pp != NULL; pp++) { if (!strcasecmp(str, *pp)) return p; } @@ -337,7 +338,7 @@ QECharset *detect_charset (const unsigned char *buf, int size) int i, l, c, has_utf8; has_utf8 = 0; - for(i = 0; i < size;) { + for (i = 0; i < size;) { c = buf[i++]; if ((c >= 0x80 && c < 0xc0) || c >= 0xfe) goto no_utf8; diff --git a/charsetmore.c b/charsetmore.c index c32ff7e..9474fb5 100644 --- a/charsetmore.c +++ b/charsetmore.c @@ -53,12 +53,12 @@ void decode_8bit_init(CharsetDecodeState *s) int i, n; table = s->table; - for(i=0;imin_char;i++) + for (i = 0; i < charset->min_char; i++) *table++ = i; n = charset->max_char - charset->min_char + 1; - for(i=0;iprivate_table[i]; - for(i=charset->max_char + 1;i<256;i++) + for (i = charset->max_char + 1; i < 256;i++) *table++ = i; } @@ -75,7 +75,7 @@ unsigned char *encode_8bit(QECharset *charset, unsigned char *q, int c) } else { n = charset->max_char - charset->min_char + 1; table = charset->private_table; - for(i=0;i 76) return 0; - switch(b1) { + + switch (b1) { case 0: case 2: case 3: @@ -149,11 +151,12 @@ static void decode_euc_jp_init(CharsetDecodeState *s) { unsigned short *table = s->table; int i; - for(i=0;i<256;i++) + + for (i = 0; i < 256; i++) table[i] = i; table[0x8e] = ESCAPE_CHAR; table[0x8f] = ESCAPE_CHAR; - for(i=0xa1;i<=0xfe;i++) + for (i = 0xa1; i <= 0xfe; i++) table[i] = ESCAPE_CHAR; } @@ -224,17 +227,17 @@ static void decode_sjis_init(CharsetDecodeState *s) unsigned short *table = s->table; int i; - for(i=0;i<256;i++) + for (i = 0; i < 256; i++) table[i] = i; table['\\'] = 0x00a5; table[0x80] = '\\'; - for(i=0x81;i<=0x9f;i++) + for (i = 0x81; i <= 0x9f; i++) table[i] = ESCAPE_CHAR; - for(i=0xa1;i<=0xdf;i++) + for (i = 0xa1; i <= 0xdf; i++) table[i] = i - 0xa1 + 0xff61; - for(i=0xe0;i<=0xef;i++) + for (i = 0xe0; i <= 0xef; i++) table[i] = ESCAPE_CHAR; - for(i=0xf0;i<=0xfc;i++) + for (i = 0xf0; i <= 0xfc; i++) table[i] = ESCAPE_CHAR; table[0xfd] = 0xa9; table[0xfe] = 0x2122; diff --git a/clang.c b/clang.c index cf34db9..a13d8a1 100644 --- a/clang.c +++ b/clang.c @@ -71,10 +71,10 @@ void c_colorize_line(unsigned int *buf, int len, p = buf; p_start = p; type_decl = 0; - c = 0; /* turn off stupid egcs-2.91.66 warning */ + c = 0; /* turn off stupid egcs-2.91.66 warning */ /* if already in a state, go directly in the code parsing it */ - switch(state) { + switch (state) { case C_COMMENT: goto parse_comment; case C_STRING: @@ -86,10 +86,10 @@ void c_colorize_line(unsigned int *buf, int len, break; } - for(;;) { + for (;;) { p_start = p; c = *p; - switch(c) { + switch (c) { case '\n': goto the_end; case '/': @@ -164,12 +164,12 @@ void c_colorize_line(unsigned int *buf, int len, l = get_c_keyword(kbuf, sizeof(kbuf), &p); p1 = p; - while (*p == ' ' || *p == '\t') - p++; + while (*p == ' ' || *p == '\t') + p++; if (strfind(c_keywords, kbuf, 0)) { set_color(p_start, p1 - p_start, QE_STYLE_KEYWORD); } else - if (strfind(c_types, kbuf, 0)) { + if (strfind(c_types, kbuf, 0)) { /* c type */ /* if not cast, assume type declaration */ if (*p != ')') { @@ -216,7 +216,7 @@ static int find_indent1(EditState *s, unsigned int *buf) p = buf; pos = 0; - for(;;) { + for (;;) { c = *p++ & CHAR_MASK; if (c == '\t') pos += s->tab_size - (pos % s->tab_size); @@ -233,7 +233,7 @@ static int find_pos(EditState *s, unsigned int *buf, int size) int pos, c, i; pos = 0; - for(i=0;itab_size - (pos % s->tab_size); @@ -301,7 +301,7 @@ static void do_c_indent(EditState *s) eoi_found = 0; stack_ptr = 0; state = INDENT_NORM; - for(;;) { + for (;;) { if (offsetl == 0) break; line_num--; @@ -333,7 +333,7 @@ static void do_c_indent(EditState *s) goto check_instr; } } else { - switch(c) { + switch (c) { case '}': if (stack_ptr >= MAX_STACK_SIZE) return; @@ -430,15 +430,15 @@ static void do_c_indent(EditState *s) len = get_colorized_line(s, buf, MAX_BUF_SIZE - 1, offset, line_num1); if (stack_ptr == 0) { - if (!pos && lpos >= 0) { - /* start of instruction already found */ - pos = lpos; - if (!eoi_found) - pos += s->indent_size; - } + if (!pos && lpos >= 0) { + /* start of instruction already found */ + pos = lpos; + if (!eoi_found) + pos += s->indent_size; + } } - for(i=0;i> STYLE_SHIFT; /* if preprocess, no indent */ @@ -463,7 +463,7 @@ static void do_c_indent(EditState *s) /* suppress leading spaces */ offset1 = offset; - for(;;) { + for (;;) { c = eb_nextc(s->b, offset1, &offset2); if (c != ' ' && c != '\t') break; @@ -495,8 +495,8 @@ void do_c_indent_region(EditState *s) p2 = tmp; } - for(;p1<=p2;p1++) { - s->offset = eb_goto_pos(s->b, p1, 0); + for (;p1 <= p2; p1++) { + s->offset = eb_goto_pos(s->b, p1, 0); do_c_indent(s); } } @@ -514,7 +514,7 @@ static int c_mode_probe(ModeProbeData *p) /* currently, only use the file extension */ r = extension(p->filename); if (*r) { - if (strfind("|c|e|h|js|cs|jav|java|cxx|cpp|", r + 1, 1)) + if (strfind("|c|e|h|js|cs|jav|java|cxx|cpp|", r + 1, 1)) return 100; } return 0; @@ -523,6 +523,7 @@ static int c_mode_probe(ModeProbeData *p) int c_mode_init(EditState *s, ModeSavedData *saved_data) { int ret; + ret = text_mode_init(s, saved_data); if (ret) return ret; diff --git a/cptoqe.c b/cptoqe.c index b148a58..6ac2aa2 100644 --- a/cptoqe.c +++ b/cptoqe.c @@ -32,10 +32,10 @@ void handle_cp(FILE *f, const char *name) getline(line, sizeof(line), f); printf("static const char *aliases_%s[] = { %s, NULL };\n\n", name, line); - for(i=0;i<256;i++) + for (i = 0; i < 256; i++) table[i] = i; nb = 0; - for(;;) { + for (;;) { if (!getline(line, sizeof(line), f)) break; if (!strcasecmp(line, "# compatibility")) @@ -59,7 +59,7 @@ void handle_cp(FILE *f, const char *name) min_code = 0x7fffffff; max_code = -1; - for(i=0;i<256;i++) { + for (i = 0; i < 256; i++) { if (table[i] != i) { if (i < min_code) min_code = i; @@ -73,7 +73,7 @@ void handle_cp(FILE *f, const char *name) printf("static const unsigned short table_%s[%d] = {\n", name, max_code - min_code + 1); j = 0; - for(i=min_code;i<=max_code;i++) { + for (i = min_code; i <= max_code; i++) { printf("0x%04x, ", table[i]); if ((j++ & 7) == 7) printf("\n"); @@ -84,7 +84,7 @@ void handle_cp(FILE *f, const char *name) } q = name1; - for(p = name; *p != '\0'; p++) { + for (p = name; *p != '\0'; p++) { c = *p; if (c == '_') c = '-'; @@ -122,7 +122,7 @@ void handle_jis(FILE *f, int is_jis208) b1_max = 0; b2_max = 0; nb = 0; - for(;;) { + for (;;) { if (!getline(line, sizeof(line), f)) break; if (line[0] == '\0' || line[0] == '#') @@ -150,7 +150,7 @@ void handle_jis(FILE *f, int is_jis208) } printf("/* max row = %d. The following rows are excluded:", b1_max); n = 0; - for(i=0;i<=b1_max;i++) { + for (i = 0; i <= b1_max; i++) { if (table_b2_max[i] == 0) { printf(" %d", i); } else { @@ -162,9 +162,9 @@ void handle_jis(FILE *f, int is_jis208) printf("const unsigned short table_%s[%d] = {\n", name, n * (b2_max + 1)); n = 0; - for(i=0;i<=b1_max;i++) { + for (i = 0; i <= b1_max; i++) { if (table_b2_max[i] != 0) { - for(j=0;j<=b2_max;j++) { + for (j = 0; j <= b2_max; j++) { printf("0x%04x, ", table[i * 94 + j]); if ((n++ & 7) == 7) printf("\n"); @@ -186,7 +186,7 @@ int main(int argc, char **argv) printf("#include \"qe.h\"\n\n"); - for(i=1;istyle == style && fc->size == size) { @@ -174,9 +174,9 @@ QEFont *select_font(QEditScreen *s, int style, int size) close_font(s, font_cache[min_index]); fc = open_font(s, style, size); if (!fc) { - /* select_font never returns NULL */ + /* select_font never returns NULL */ fc = &dummy_font; - fc->system_font = 1; + fc->system_font = 1; } fc->style = style; diff --git a/docbook.c b/docbook.c index 4353669..775b641 100644 --- a/docbook.c +++ b/docbook.c @@ -33,7 +33,8 @@ static int docbook_mode_probe(ModeProbeData *p1) static int docbook_mode_init(EditState *s, ModeSavedData *saved_data) { - return gxml_mode_init(s, saved_data, XML_IGNORE_CASE | XML_DOCBOOK, docbook_style); + return gxml_mode_init(s, saved_data, XML_IGNORE_CASE | XML_DOCBOOK, + docbook_style); } ModeDef docbook_mode; diff --git a/fbftoqe.c b/fbftoqe.c index 87ec13f..5065311 100644 --- a/fbftoqe.c +++ b/fbftoqe.c @@ -20,7 +20,7 @@ void dump_font(const char *filename, const char *name) } printf("static const unsigned char font_%s[] = {\n", name); j = 0; - for(;;) { + for (;;) { c = fgetc(f); if (c == EOF) break; @@ -62,7 +62,7 @@ int main(int argc, char **argv) printf("#include \"qe.h\"\n\n"); - for(i=1;i s->disp_width) len = s->disp_width; if (s->mode == &hex_mode) { - for(j=0;jdisp_width;j++) { + for (j = 0; j < s->disp_width; j++) { display_char(ds, -1, -1, ' '); offset1 = offset + j; if (j < len) { @@ -67,7 +67,7 @@ static int hex_display(EditState *s, DisplayState *ds, int offset) display_char(ds, -1, -1, ' '); } eof = 0; - for(j=0;jdisp_width;j++) { + for (j = 0; j < s->disp_width; j++) { offset1 = offset + j; if (j < len) { eb_read(s->b, offset + j, &b, 1); @@ -172,10 +172,10 @@ int detect_binary(const unsigned char *buf, int size) for (i = 0; i < size; i++) { c = buf[i]; - if (c < 32 && + if (c < 32 && (c != '\r' && c != '\n' && c != '\t' && - c != '\e' && c != '\b' && c != '\f')) - return 1; + c != '\e' && c != '\b' && c != '\f')) + return 1; } return 0; } diff --git a/html.c b/html.c index e9c98c9..f97da3d 100644 --- a/html.c +++ b/html.c @@ -71,7 +71,7 @@ static int recompute_offset_func(void *opaque, CSSBox *box, if (len == 0) return 0; offset = data->wanted_offset; - for(i=0;idmin) { data->dmin = d; @@ -394,8 +394,8 @@ static void html_scroll_up_down(EditState *s, int dir) h = SCROLL_MHEIGHT; if (abs(dir) == 2) { - h = s->height - SCROLL_MHEIGHT; - dir /= 2; + h = s->height - SCROLL_MHEIGHT; + dir /= 2; } if (h < SCROLL_MHEIGHT) h = s->height; @@ -834,11 +834,11 @@ static int html_mode_probe(ModeProbeData *p1) int c, score; score = 0; - for(;;) { + for (;;) { c = *p; if (c == '\0') break; - if (c < 32 && (c != '\r' && c != '\n' && c != '\t' && c != '\e')) + if (c < 32 && (c != '\r' && c != '\n' && c != '\t' && c != '\e')) return 0; if (stristart(p, "height; fprintf(f, "P6\n%d %d\n%d\n", w, h, 255); - for(y=0;y> 16) & 0xff; g = (v >> 8) & 0xff; @@ -243,9 +243,9 @@ int png_save(QEditScreen *s, const char *filename) row_pointers[0] = row; - for(y=0;y> 16) & 0xff; g = (v >> 8) & 0xff; @@ -332,7 +332,7 @@ int draw_html(QEditScreen *scr, xml = xml_begin(s->style_sheet, flags, html_test_abort, NULL, filename, charset); - for(;;) { + for (;;) { len = css_read(f, buf, IO_BUF_SIZE); if (len <= 0) break; @@ -415,11 +415,11 @@ int main(int argc, char **argv) charset = &charset_8859_1; strict_xml = 0; - for(;;) { + for (;;) { c = getopt(argc, argv, "h?w:o:f:x"); if (c == -1) break; - switch(c) { + switch (c) { case 'h': case '?': help(); @@ -436,7 +436,7 @@ int main(int argc, char **argv) QECharset *p; fprintf(stderr, "Unknown charset '%s'\n", optarg); fprintf(stderr, "Supported charsets are:"); - for(p = first_charset; p != NULL; p = p->next) + for (p = first_charset; p != NULL; p = p->next) fprintf(stderr, " %s", p->name); fprintf(stderr, "\n"); exit(1); diff --git a/image.c b/image.c index ac2204f..31821bb 100644 --- a/image.c +++ b/image.c @@ -45,7 +45,7 @@ int qe_bitmap_format_to_pix_fmt(int format) { int dst_pix_fmt; - switch(format) { + switch (format) { case QEBITMAP_FORMAT_YUV420P: dst_pix_fmt = PIX_FMT_YUV420P; break; @@ -113,8 +113,8 @@ void draw_alpha_grid(EditState *s, int x1, int y1, int w, int h) int state, x, y; unsigned int color; - for(y = 0; y < h; y += 16) { - for(x = 0; x < w; x += 16) { + for (y = 0; y < h; y += 16) { + for (x = 0; x < w; x += 16) { state = (x ^ y) & 16; if (state) color = QERGB(0x94, 0x94, 0x94); @@ -301,7 +301,7 @@ static int read_image_cb(void *opaque, AVImageInfo *info) return AVERROR_NOMEM; ib->interleaved = info->interleaved; b->data = ib; - for(i=0;i<4;i++) { + for (i = 0; i < 4; i++) { info->pict.linesize[i] = ib->pict.linesize[i]; info->pict.data[i] = ib->pict.data[i]; } @@ -425,9 +425,9 @@ static void update_bmp(EditState *s) bg_r = (is->background_color >> 16) & 0xff; bg_g = (is->background_color >> 8) & 0xff; bg_b = (is->background_color) & 0xff; - for(y = 0; y < is->h; y++) { + for (y = 0; y < is->h; y++) { d = d1; - for(x = 0; x < is->w; x++) { + for (x = 0; x < is->w; x++) { if (is->background_color == 0) { state = (x ^ y) & 16; if (state) { @@ -459,7 +459,7 @@ static void update_bmp(EditState *s) bmp_lock(s->screen, is->disp_bmp, &pict, 0, 0, is->w, is->h); - for(i=0;i<4;i++) { + for (i = 0; i < 4; i++) { avpict.data[i] = pict.data[i]; avpict.linesize[i] = pict.linesize[i]; } @@ -557,9 +557,9 @@ static void image_scroll_up_down(EditState *s, int dir) h = SCROLL_MHEIGHT; if (abs(dir) == 2) { - /* move 50% */ - d = s->height / 2; - dir /= 2; + /* move 50% */ + d = s->height / 2; + dir /= 2; } if (d < 1) d = 1; @@ -597,7 +597,7 @@ static int img_rotate(AVPicture *dst, uint8_t *d, *d1; const uint8_t *s, *s1; - switch(pix_fmt) { + switch (pix_fmt) { case PIX_FMT_GRAY8: case PIX_FMT_PAL8: bpp = 1; @@ -617,14 +617,14 @@ static int img_rotate(AVPicture *dst, dlinesize = dst->linesize[0]; d1 = dst->data[0] + (h - 1) * bpp; - for(y=0;y', KEY_NONE, "image-double-size", image_mult_size, 100) @@ -812,7 +812,7 @@ static CmdDef image_commands[] = { CMD1( '.', KEY_NONE, "image-larger-10", image_mult_size, 10) CMD1( ',', KEY_NONE, "image-smaller-10", image_mult_size, -10) CMD_( 'S', KEY_NONE, "image-set-display-size", image_set_size, - "i{Displayed width: }i{Displayed height: }") + "i{Displayed width: }i{Displayed height: }") #endif CMD_DEF_END, }; diff --git a/indic.c b/indic.c index 811c29a..433719e 100644 --- a/indic.c +++ b/indic.c @@ -65,7 +65,7 @@ int devanagari_log2vis(unsigned int *str, unsigned int *ctog, int len) /* Rule 1 : dead consonant rule */ q = buf; len1 = len - 1; - for(i=0;i 30) - delta = 30; - else if (delta < -1) - delta = -1; - freq[delta + 1]++; -#endif - - if (is_chinese_cj) { - assert(input[len-1] == ' '); - len--; - } - - first = 0; - if (gen_table) - first = 1; - - /* c = 0 : end of table - c = 1..0x1d : delta unicode - c = 0x1e : unicode char follows. - c = 0x1f : unicode mapping follows - bit 7 : eof and delta == 1 - */ - for(j=first;j= 0x20 && c <= 0x7f) { - put_byte(c | d); - } else { - put_byte(d | 0x1f); - put_byte((c >> 8) & 0xff); - put_byte(c & 0xff); - } - } - /* XXX: potential problem if first == len. We avoid it - by forcing an emission of a unicode char */ - if (first == len) - delta = 0; - if (delta != 1) { - if (delta >= 1 && delta <= 0x1d) { - put_byte(delta); - } else { - put_byte(0x1e); - put_byte((output >> 8) & 0xff); - put_byte(output & 0xff); - } + if (gen_table) { + if (last_input0 != inputs[k].input[0]) { + if (last_input0 != 0) + put_byte(0); + last_input0 = inputs[k].input[0]; + table_val[nb_starts] = last_input0; + table_start[nb_starts++] = offset; + last = 0; } } - put_byte(0); + + len = inputs[k].len; + output = inputs[k].output; + delta = output - last; + last = output; + +#ifdef TEST + /* frequencies */ + if (delta > 30) + delta = 30; + else if (delta < -1) + delta = -1; + freq[delta + 1]++; +#endif + + if (is_chinese_cj) { + assert(input[len-1] == ' '); + len--; + } + + first = 0; + if (gen_table) + first = 1; + + /* c = 0 : end of table + c = 1..0x1d : delta unicode + c = 0x1e : unicode char follows. + c = 0x1f : unicode mapping follows + bit 7 : eof and delta == 1 + */ + for (j = first; j < len; j++) { + c = input[j]; + d = 0; + if ((j == (len - 1) && delta == 1)) + d = 0x80; + if (c >= 0x20 && c <= 0x7f) { + put_byte(c | d); + } else { + put_byte(d | 0x1f); + put_byte((c >> 8) & 0xff); + put_byte(c & 0xff); + } + } + /* XXX: potential problem if first == len. We avoid it + by forcing an emission of a unicode char */ + if (first == len) + delta = 0; + if (delta != 1) { + if (delta >= 1 && delta <= 0x1d) { + put_byte(delta); + } else { + put_byte(0x1e); + put_byte((output >> 8) & 0xff); + put_byte(output & 0xff); + } + } + } + put_byte(0); } int main(int argc, char **argv) @@ -160,7 +160,7 @@ int main(int argc, char **argv) memset(freq, 0, sizeof(freq)); nb_kmaps = 0; - for(i=2;icontent_type) { + switch (box->content_type) { case CSS_CONTENT_TYPE_STRING: return str_nextc; case CSS_CONTENT_TYPE_BUFFER: @@ -339,7 +339,7 @@ static void css_init_idents(void) if (table_ident_nb != 0) return; - for(p = css_idents; *p != '\1'; p = r + 1) { + for (p = css_idents; *p != '\1'; p = r + 1) { r = p; while (*r) r++; @@ -356,7 +356,7 @@ static void css_init_idents(void) static void set_counter(CSSContext *s, CSSIdent counter_id, int value) { CSSCounterValue *p; - for(p = s->counter_stack_ptr; p != s->counter_stack_base; p = p->prev) { + for (p = s->counter_stack_ptr; p != s->counter_stack_base; p = p->prev) { if (p->counter_id == counter_id) { p->value = value; } @@ -384,7 +384,7 @@ static void pop_counters(CSSContext *s, CSSCounterValue *p2) { CSSCounterValue *p, *p1; - for(p = s->counter_stack_ptr; p != s->counter_stack_base; p = p1) { + for (p = s->counter_stack_ptr; p != s->counter_stack_base; p = p1) { p1 = p->prev; free(p); p = p1; @@ -396,7 +396,7 @@ static void pop_counters(CSSContext *s, CSSCounterValue *p2) static void incr_counter(CSSContext *s, CSSIdent counter_id, int incr) { CSSCounterValue *p; - for(p = s->counter_stack_ptr; p != NULL; p = p->prev) { + for (p = s->counter_stack_ptr; p != NULL; p = p->prev) { if (p->counter_id == counter_id) { p->value += incr; return; @@ -409,7 +409,7 @@ static void incr_counter(CSSContext *s, CSSIdent counter_id, int incr) static int get_counter(CSSContext *s, CSSIdent counter_id) { CSSCounterValue *p; - for(p = s->counter_stack_ptr; p != NULL; p = p->prev) { + for (p = s->counter_stack_ptr; p != NULL; p = p->prev) { if (p->counter_id == counter_id) { return p->value; } @@ -436,7 +436,7 @@ static void css_eval_property(CSSContext *s, ptr = (int *)((char *)state + def->struct_offset); if (p->value.u.val == CSS_INHERIT) { /* XXX: invalid if pointer */ - switch(def->storage) { + switch (def->storage) { default: case CSS_STORAGE_INT: *ptr = *(int *)((char *)state_parent + def->struct_offset); @@ -449,7 +449,7 @@ static void css_eval_property(CSSContext *s, if (def->storage == CSS_STORAGE_PTR) { *(void **)ptr = p; } else { - switch(p->value.type) { + switch (p->value.type) { case CSS_VALUE_COLOR: case CSS_UNIT_NONE: case CSS_VALUE_INTEGER: @@ -499,7 +499,7 @@ static inline int attribute_match(CSSStyleSheetAttributeEntry *e, op = e->op; do { if (attr == a->attr) { - switch(op) { + switch (op) { case CSS_ATTR_OP_SET: return 1; case CSS_ATTR_OP_EQUAL: @@ -537,7 +537,7 @@ static int selector_match(CSSSimpleSelector *ss, return 0; } - switch(ss->tree_op) { + switch (ss->tree_op) { case CSS_TREE_OP_DESCENDANT: box1 = box->parent; while (box1 != NULL) { @@ -632,13 +632,13 @@ static char *eval_content(CSSContext *s, CSSProperty *p, CSSBox *box) buf[0] = '\0'; value = &p->value; - for(i=0;inb_values;i++) { - switch(value->type) { + for (i = 0; i < p->nb_values; i++) { + switch (value->type) { case CSS_VALUE_STRING: pstrcat(buf, sizeof(buf), value->u.str); break; case CSS_VALUE_ATTR: - for(attr = box->attrs; attr != NULL; attr = attr->next) { + for (attr = box->attrs; attr != NULL; attr = attr->next) { if (attr->attr == value->u.attr_id) { pstrcat(buf, sizeof(buf), attr->value); break; @@ -665,7 +665,7 @@ static void eval_counter_update(CSSContext *s, CSSProperty *p) CSSPropertyValue *value = &p->value; int counter_id, n, i; - for(i=0;inb_values;) { + for (i = 0; i < p->nb_values;) { if (value->type != CSS_VALUE_IDENT) break; counter_id = value->u.attr_id; @@ -756,7 +756,7 @@ static int css_eval(CSSContext *s, } /* border colors are set to color by default */ - for(i=0;i<4;i++) { + for (i = 0; i < 4; i++) { if (state->border_colors[i] == COLOR_TRANSPARENT) state->border_colors[i] = state->color; } @@ -798,7 +798,7 @@ static inline unsigned int hash_bytes(unsigned int h, const unsigned char *p_end; p_end = p + len; - for(; p < p_end; p++) { + for (; p < p_end; p++) { h = ((h << 8) + p[0]) % PROPS_HASH_SIZE; } return h; @@ -826,7 +826,7 @@ static CSSState *allocate_props(CSSContext *s, CSSState *props) { CSSState **pp, *p; pp = &s->hash_props[hash_props(props)]; - for(;;) { + for (;;) { p = *pp; if (!p) break; @@ -921,7 +921,7 @@ static void css_counter_str(char *text, int text_size, int index, int list_style_type, int adjust) { /* insert marker text */ - switch(list_style_type) { + switch (list_style_type) { case CSS_LIST_STYLE_TYPE_DISC: strcpy(text, "o"); break; @@ -1043,7 +1043,7 @@ static int css_compute_block(CSSContext *s, CSSBox *box, counter_stack = push_counters(s); - for(box1 = box->u.child.first; box1 != NULL; box1 = box_next) { + for (box1 = box->u.child.first; box1 != NULL; box1 = box_next) { /* need to take next here because of :after inserted boxes */ box_next = box1->next; if (css_compute_block(s, box1, props) < 0) @@ -1320,7 +1320,7 @@ static int bidir_compute_attributes(CSSContext *ctx, TypeLink *list_tab, int max s->ltype = FRIBIDI_TYPE_SOT; s->pos = 0; - for(box = first_box; box != NULL; box = box->next_inline) { + for (box = first_box; box != NULL; box = box->next_inline) { bidir_compute_attributes_box(s, box); } @@ -1395,7 +1395,7 @@ static void css_bidir_split(CSSContext *s, CSSBox *first_box, TypeLink *l) bidir_split.ctx = s; bidir_split.l = l + 1; bidir_split.pos = 0; - for(box = first_box; box != NULL; box = box->next_inline) { + for (box = first_box; box != NULL; box = box->next_inline) { css_bidir_split_box(&bidir_split, box); } } @@ -1435,7 +1435,7 @@ static void bidir_end_inline(BidirComputeState *s) TypeLink *p; p = embeds; printf("bidi_start:\n"); - for(;;) { + for (;;) { printf("type=%d pos=%d len=%d level=%d\n", p->type, p->pos, p->len, p->level); if (p->type == FRIBIDI_TYPE_EOT) break; @@ -1466,7 +1466,7 @@ static int css_layout_bidir_box(BidirComputeState *s, CSSBox *box) css_layout_bidir_block(s->ctx, box); } else { /* now do the layout, according to the display type */ - switch(props->display) { + switch (props->display) { case CSS_DISPLAY_INLINE: case CSS_DISPLAY_INLINE_TABLE: case CSS_DISPLAY_INLINE_BLOCK: @@ -1482,7 +1482,7 @@ static int css_layout_bidir_box(BidirComputeState *s, CSSBox *box) props->display != CSS_DISPLAY_INLINE_BLOCK && box->content_type == CSS_CONTENT_TYPE_CHILDS) { /* recurse inside in same formatting context */ - for(box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { + for (box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { ret = css_layout_bidir_box(s, box1); if (ret) return ret; @@ -1520,7 +1520,7 @@ static int css_layout_bidir_block(CSSContext *ctx, CSSBox *box) s->inline_layout = 0; s->ctx = ctx; - for(box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { + for (box1 = box->u.child.first; box1 != NULL; box1 = box1->next) { ret = css_layout_bidir_box(s, box1); if (ret) return ret; @@ -1542,9 +1542,9 @@ static void reverse_boxes(InlineBox *str, int len) int i, len2 = len / 2; for (i = 0; i < len2; i++) { - InlineBox tmp = str[i]; - str[i] = str[len - 1 - i]; - str[len - 1 - i] = tmp; + InlineBox tmp = str[i]; + str[i] = str[len - 1 - i]; + str[len - 1 - i] = tmp; } } @@ -1557,7 +1557,7 @@ static void embed_boxes(InlineBox *line, int len, int level_max) while (pos < len) { if (line[pos].box->embedding_level >= level) { /* find all chars >= level */ - for(p = pos + 1; p < len && line[p].box->embedding_level >= level; p++); + for (p = pos + 1; p < len && line[p].box->embedding_level >= level; p++); reverse_boxes(line + pos, p - pos); pos = p + 1; } else { @@ -1661,11 +1661,11 @@ static int css_layout_float(InlineLayout *s, FloatBlock *b) /* we go down until we find no floats or enough space to put the new float */ y = s->y0 + s->y; - for(;;) { + for (;;) { x1 = s->x0; x2 = s->x0 + s->total_width; y_next = MAXINT; - for(b1 = s->layout_state->first_float; b1 != NULL; b1 = b1->next) { + for (b1 = s->layout_state->first_float; b1 != NULL; b1 = b1->next) { if (b1->float_type != -1) { /* if intersection in y, then update x1 and x2 */ y2 = b1->y + b1->height; @@ -1711,7 +1711,7 @@ static int css_layout_floats(InlineLayout *s) FloatBlock *b; int ret; - for(b = s->layout_state->first_float; b != NULL; b = b->next) { + for (b = s->layout_state->first_float; b != NULL; b = b->next) { if (b->float_type == -1) { ret = css_layout_float(s, b); if (ret) @@ -1821,7 +1821,7 @@ static void css_flush_line(InlineLayout *s, baseline = 0; descent = 0; level_max = 0; - for(i=0;iprops; line_width += box->width; @@ -1869,7 +1869,7 @@ static void css_flush_line(InlineLayout *s, box_table1 = line_boxes; /* now do the real layout ! */ - switch(line_props->text_align) { + switch (line_props->text_align) { case CSS_TEXT_ALIGN_LEFT: default: x = 0; @@ -1886,7 +1886,7 @@ static void css_flush_line(InlineLayout *s, x += s->xstart; y = s->y; - for(i=0;ibox; @@ -1900,7 +1900,7 @@ static void css_flush_line(InlineLayout *s, } x += left_pad; box->x = x; - switch(box->props->vertical_align) { + switch (box->props->vertical_align) { case CSS_VERTICAL_ALIGN_TOP: box->y = y; break; @@ -1988,7 +1988,7 @@ static int css_flush_fragment(InlineLayout *s, CSSBox *box, CSSState *props, { int i; printf("flush_word: '"); - for(i=0;iword_index;i++) + for (i = 0; i < s->word_index; i++) printf("%c", s->word_buf[i]); printf("' x=%d w=%d avail=%d white_space=%d word_index=%d\n", s->x, w, s->avail_width, props->white_space, s->word_index); @@ -2028,7 +2028,7 @@ static int css_flush_fragment(InlineLayout *s, CSSBox *box, CSSState *props, /* try to put as much chars as possible on the line (maybe none) */ /* XXX: use dichotomy */ - for(;;) { + for (;;) { s->word_index--; text_metrics(s->ctx->screen, font, &metrics, s->word_buf, s->word_index); @@ -2067,7 +2067,7 @@ static int css_flush_fragment(InlineLayout *s, CSSBox *box, CSSState *props, /* push in the stack all remaining boxes for the next line */ if (s->box_stack_index < BOX_STACK_SIZE) s->box_stack[s->box_stack_index++] = box_bow; - for(i=s->index_bow + 1;iline_pos;i++) { + for (i = s->index_bow + 1; i < s->line_pos; i++) { if (s->box_stack_index < BOX_STACK_SIZE) s->box_stack[s->box_stack_index++] = s->line_boxes[i].box; } @@ -2118,7 +2118,7 @@ static int css_layout_inline_box(InlineLayout *s, descent = parent_font->descent; /* align vertically with respect to the parent */ - switch(props->vertical_align) { + switch (props->vertical_align) { case CSS_VERTICAL_ALIGN_SUPER: baseline -= (ascent * SUPER_PERCENT) / 100; break; @@ -2251,7 +2251,7 @@ static int css_layout_inline_box(InlineLayout *s, s->line_pos++; } - for(;;) { + for (;;) { /* end of block reached ? */ if (offset >= box->u.buffer.end) { css_flush_fragment(s, box, props, font); @@ -2341,7 +2341,7 @@ static int css_layout_inline_box(InlineLayout *s, /* layout boxes at the end of the line if needed */ /* XXX: use another function */ - for(i=box_stack_base; i < s->box_stack_index; i++) { + for (i = box_stack_base; i < s->box_stack_index; i++) { css_layout_inline_box(s, s->box_stack[i], baseline); } /* remove all boxes from the stack */ @@ -2456,14 +2456,13 @@ static void layout_table_row_fixed(TableLayout *s, CSSBox *row) if (s->row != 0) return; - for(cell = row->u.child.first; cell != NULL; - cell = cell->next) { + for (cell = row->u.child.first; cell != NULL; cell = cell->next) { cell_props = cell->props; if (cell_props->display == CSS_DISPLAY_TABLE_CELL) { colspan = cell_props->column_span; if (colspan < 1) colspan = 1; - for(i=0;iwidth / colspan; if (w < 1) w = 1; - for(i=0;icols[s->nb_cols - colspan + i].width_fixed = 1; s->cols[s->nb_cols - colspan + i].width = max(w, s->cols[s->nb_cols - colspan + i].width); @@ -2492,7 +2491,7 @@ static int layout_table_fixed(TableLayout *s, CSSBox *parent_box) box = parent_box->u.child.first; while (box != NULL) { props = box->props; - switch(props->display) { + switch (props->display) { case CSS_DISPLAY_TABLE_ROW: layout_table_row_fixed(s, box); s->row++; @@ -2545,7 +2544,7 @@ static int layout_table_fixed1(TableLayout *tl, CSSBox *table_box) available_width -= tl->border_h * (tl->nb_cols + 1); available_width1 = available_width; nb_auto_cols = 0; - for(i=0;inb_cols;i++) { + for (i = 0; i < tl->nb_cols; i++) { if (tl->cols[i].width_fixed) available_width -= tl->cols[i].width; else @@ -2559,7 +2558,7 @@ static int layout_table_fixed1(TableLayout *tl, CSSBox *table_box) } tot_width = 0; - for(i=0;inb_cols;i++) { + for (i = 0; i < tl->nb_cols; i++) { if (!tl->cols[i].width_fixed) tl->cols[i].width = cell_width; tot_width += tl->cols[i].width; @@ -2595,7 +2594,7 @@ static int layout_table_row_auto(TableLayout *s, CSSBox *row) col = 0; cell1 = row->u.child.first; - for(;;) { + for (;;) { /* XXX: factorize with rendering step */ if (col < s->nb_cols) c = &s->cols[col]; @@ -2621,7 +2620,7 @@ static int layout_table_row_auto(TableLayout *s, CSSBox *row) } else { /* increase number of column if needed */ col1 = col + colspan; - for(i=s->nb_cols;inb_cols; i < col1; i++) allocate_column(s); /* compute min & max size for the cell */ @@ -2666,7 +2665,7 @@ static int layout_table_row_auto(TableLayout *s, CSSBox *row) larger enough for the cell */ min_w1 = 0; max_w1 = 0; - for(i=0;iwidth_fixed = fixed; min_w1 += c->min_width; max_w1 += c->max_width; @@ -2677,7 +2676,7 @@ static int layout_table_row_auto(TableLayout *s, CSSBox *row) d = delta / colspan; r = delta % colspan; c = &s->cols[col]; - for(i=0;imin_width += d; if (i < r) c->min_width++; @@ -2689,7 +2688,7 @@ static int layout_table_row_auto(TableLayout *s, CSSBox *row) d = delta / colspan; r = delta % colspan; c = &s->cols[col]; - for(i=0;imax_width += d; if (i < r) c->max_width++; @@ -2712,7 +2711,7 @@ static int layout_table_auto(TableLayout *s, CSSBox *parent_box) box = parent_box->u.child.first; while (box != NULL) { props = box->props; - switch(props->display) { + switch (props->display) { case CSS_DISPLAY_TABLE_ROW: if (layout_table_row_auto(s, box) < 0) return -1; @@ -2756,7 +2755,7 @@ static int layout_table_auto1(TableLayout *s, CSSBox *table_box) /* compute the minimum and maximum table width */ min_tw = s->border_h * (s->nb_cols + 1); max_tw = min_tw; - for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) { + for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) { min_tw += c->min_width; max_tw += c->max_width; } @@ -2789,11 +2788,11 @@ static int layout_table_auto1(TableLayout *s, CSSBox *table_box) /* compute the cell widths from the computed table width */ if (tw < max_tw) { - for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) + for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) c->width = c->min_width; delta = tw - min_tw; } else { - for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) + for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) c->width = c->max_width; delta = tw - max_tw; } @@ -2802,7 +2801,7 @@ static int layout_table_auto1(TableLayout *s, CSSBox *table_box) fast */ d = delta / s->nb_cols; r = delta % s->nb_cols; - for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) { + for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) { c->width += d; if (i < r) c->width++; @@ -2810,7 +2809,7 @@ static int layout_table_auto1(TableLayout *s, CSSBox *table_box) } /* init again row span left, in case the row spans were incorrect */ - for(i = 0, c = s->cols; i < s->nb_cols; i++, c++) + for (i = 0, c = s->cols; i < s->nb_cols; i++, c++) c->row_span_left = 0; s->table_width = tw; @@ -2844,7 +2843,7 @@ static int render_table_row(TableLayout *s, baseline = 0; cell1 = row->u.child.first; col = 0; - for(;;) { + for (;;) { ColStruct *c = &s->cols[col]; /* compute which cell we examine */ @@ -2871,7 +2870,7 @@ static int render_table_row(TableLayout *s, if (c->row_span_left != 0) { c->row_span_left--; /* modify x to skip column */ - for(i=0;iborder_h + s->cols[col + i].width; } else { c->cell = cell; @@ -2886,7 +2885,7 @@ static int render_table_row(TableLayout *s, /* set the cell width */ w = s->cols[col].width; - for(i=1;iborder_h + s->cols[col + i].width; cell->width = w - props->padding.x1 - props->padding.x2 - @@ -2918,7 +2917,7 @@ static int render_table_row(TableLayout *s, /* now compute vertical position of cells if baseline and compute row_height */ row_height = 0; - for(col = 0; col < nb_cols;) { + for (col = 0; col < nb_cols;) { ColStruct *c = &s->cols[col]; cell = c->cell; colspan = cell->props->column_span; @@ -2945,7 +2944,7 @@ static int render_table_row(TableLayout *s, } /* we know row_height: definitive vertical positionning */ - for(col = 0; col < nb_cols;) { + for (col = 0; col < nb_cols;) { ColStruct *c = &s->cols[col]; int delta, cell_height; @@ -2953,7 +2952,7 @@ static int render_table_row(TableLayout *s, cell_height = c->prev_row_height + row_height; if (c->row_span_left == 0) { h = c->height; - switch(c->vertical_align) { + switch (c->vertical_align) { case CSS_VERTICAL_ALIGN_BOTTOM: delta = cell_height - c->height; cell->padding_top = delta; @@ -2995,7 +2994,7 @@ static int layout_table_render(TableLayout *s, CSSBox *parent_box) box = parent_box->u.child.first; while (box != NULL) { props = box->props; - switch(props->display) { + switch (props->display) { case CSS_DISPLAY_TABLE_ROW: if (render_table_row(s, box)) return -1; @@ -3105,7 +3104,7 @@ static int css_layout_table(CSSContext *s, LayoutOutput *table_layout, caption_box->props->border.y2 + caption_box->props->padding.y2; /* put the caption in the table margin */ /* XXX: potentially incorrect: table margins */ - switch(caption_box->props->caption_side) { + switch (caption_box->props->caption_side) { case CSS_CAPTION_SIDE_TOP: caption_box->x = (table_box->width - caption_box->width) / 2; caption_box->y = -h; @@ -3173,7 +3172,7 @@ static int css_layout_block_iterate(InlineLayout *il, CSSBox *box, int baseline) CSSBox *box1, *box2; int ret; - for(box1 = box->u.child.first; box1 != NULL; box1 = box2) { + for (box1 = box->u.child.first; box1 != NULL; box1 = box2) { box2 = box1->next; /* need to do that first because boxes may be split */ ret = css_layout_block_recurse1(il, box1, baseline); if (ret) @@ -3228,7 +3227,7 @@ static int css_layout_block_recurse1(InlineLayout *il, CSSBox *box, } } else { /* now do the layout, according to the display type */ - switch(props->display) { + switch (props->display) { case CSS_DISPLAY_LIST_ITEM: case CSS_DISPLAY_BLOCK: case CSS_DISPLAY_TABLE: @@ -3503,7 +3502,7 @@ static int css_layout_box_min_max(InlineLayout *il, CSSBox *box) il->max_width = max(il->max_width, max_w1); } } else { - switch(props->display) { + switch (props->display) { case CSS_DISPLAY_LIST_ITEM: case CSS_DISPLAY_BLOCK: case CSS_DISPLAY_TABLE: @@ -3537,7 +3536,7 @@ static int css_layout_box_min_max(InlineLayout *il, CSSBox *box) props->display != CSS_DISPLAY_INLINE_BLOCK && box->content_type == CSS_CONTENT_TYPE_CHILDS) { CSSBox *box1, *box2; - for(box1 = box->u.child.first; box1 != NULL; box1 = box2) { + for (box1 = box->u.child.first; box1 != NULL; box1 = box2) { box2 = box1->next; /* need to do that first because boxes may be split */ ret = css_layout_box_min_max(il, box1); if (ret) @@ -3585,7 +3584,7 @@ static int css_layout_block_min_max(CSSContext *s, if (block_box->props->width != CSS_AUTO) il->min_width = il->max_width = block_box->props->width; } else { - for(;box != NULL; box = box1) { + for (; box != NULL; box = box1) { box1 = box->next; ret = css_layout_box_min_max(il, box); if (ret) @@ -3726,7 +3725,7 @@ static void draw_borders(QEditScreen *scr, int dir, i, t1, t2, u1, v1, u2, v2, u1incr, u2incr, style, w, v; unsigned int color, color1, color2; - for(dir=0;dir<4;dir++) { + for (dir = 0; dir < 4; dir++) { style = props->border_styles[dir]; if (style == CSS_BORDER_STYLE_NONE || style == CSS_BORDER_STYLE_HIDDEN) @@ -3758,7 +3757,7 @@ static void draw_borders(QEditScreen *scr, w = ((int *)&props->border)[dir]; if (w <= 0) continue; - switch(dir) { + switch (dir) { case 2: case 0: u1 = y1; @@ -3778,10 +3777,10 @@ static void draw_borders(QEditScreen *scr, u1 = u1 << BFRAC; u2 = u2 << BFRAC; - for(i=0;i> BFRAC; t2 = u2 >> BFRAC; - switch(dir) { + switch (dir) { case 0: fill_rectangle(scr, x1 - i - 1, t1, 1, t2 - t1, color); break; @@ -3878,7 +3877,7 @@ static void box_display_text(CSSContext *s, CSSBox *box, int x0, int y0) /* slower and more complicated code for selection handling */ offsets[len1] = box->u.buffer.end; x = x0; - for(i=0;i= s->selection_start && @@ -3930,7 +3929,7 @@ static void box_display_image(CSSContext *s, CSSBox *box, int x0, int y0) img_props.border.y1 = 1; img_props.border.x2 = 1; img_props.border.y2 = 1; - for(i=0;i<4;i++) { + for (i = 0; i < 4; i++) { img_props.border_colors[i] = QERGB(0, 0, 0); img_props.border_styles[i] = CSS_BORDER_STYLE_INSET; } @@ -4017,7 +4016,7 @@ static void css_display_block(CSSContext *s, } /* now display the content ! */ - switch(box->content_type) { + switch (box->content_type) { case CSS_CONTENT_TYPE_IMAGE: box_display_image(s, box, x0, y0); break; @@ -4127,7 +4126,7 @@ static int css_get_cursor_func(void *opaque, len = box_get_text(s->ctx, line_buf, MAX_LINE_SIZE, offsets, box); offsets[len] = box->u.buffer.end; - for(i=0;ioffset >= offsets[i] && s->offset < offsets[i + 1]) { posc = i; goto found1; @@ -4143,7 +4142,7 @@ static int css_get_cursor_func(void *opaque, font = css_select_font(scr, props); x = 0; - for(i=0;i 0 && x > xc) || (dir < 0 && x < xc)) { @@ -4280,7 +4279,7 @@ void css_dump_box(CSSBox *box, int level) CSSBox *b; const char *tag; - for(i=0;itag == CSS_ID_NIL) { tag = "anon"; @@ -4290,7 +4289,7 @@ void css_dump_box(CSSBox *box, int level) printf("<%s x=%d y=%d w=%d h=%d el=%d>\n", tag, box->x, box->y, box->width, box->height, box->embedding_level); - switch(box->content_type) { + switch (box->content_type) { case CSS_CONTENT_TYPE_CHILDS: b = box->u.child.first; while (b != NULL) { @@ -4299,7 +4298,7 @@ void css_dump_box(CSSBox *box, int level) } break; case CSS_CONTENT_TYPE_BUFFER: - for(i=0;iu.buffer.start, box->u.buffer.end); @@ -4307,10 +4306,10 @@ void css_dump_box(CSSBox *box, int level) case CSS_CONTENT_TYPE_STRING: { unsigned long ptr; - for(i=0;iu.buffer.start; ptr < box->u.buffer.end; ptr++) + for (ptr = box->u.buffer.start; ptr < box->u.buffer.end; ptr++) printf("%c", *(unsigned char *)ptr); printf("'\n"); } @@ -4319,7 +4318,7 @@ void css_dump_box(CSSBox *box, int level) printf("[IMAGE]\n"); break; } - for(i=0;i\n", tag); } @@ -4372,7 +4371,7 @@ void css_delete_box(CSSBox *box) CSSProperty *p1, *p; while (box != NULL) { - switch(box->content_type) { + switch (box->content_type) { case CSS_CONTENT_TYPE_CHILDS: css_delete_box(box->u.child.first); break; @@ -4481,8 +4480,8 @@ void css_delete_document(CSSContext *s) int i; CSSState *props, *props_next; - for(i=0;ihash_props[i]; props != NULL; props = props_next) { + for (i = 0; i < PROPS_HASH_SIZE; i++) { + for (props = s->hash_props[i]; props != NULL; props = props_next) { props_next = props->hash_next; free_props(props); } diff --git a/libqhtml/cssparse.c b/libqhtml/cssparse.c index b782c86..faa6b54 100644 --- a/libqhtml/cssparse.c +++ b/libqhtml/cssparse.c @@ -83,7 +83,7 @@ static int css_get_length(int *length_ptr, int *unit_ptr, const char *p) unit++; if (f < 0 && unit != CSS_UNIT_PERCENT) return -1; - switch(unit) { + switch (unit) { case CSS_UNIT_PIXEL: num = (int)(f); break; @@ -156,7 +156,7 @@ static char *css_parse_string(const char **pp) p = *pp; q = buf; sep = *p++; - for(;;) { + for (;;) { c = *p++; if (c == sep || c == '\0') break; @@ -249,12 +249,12 @@ CSSProperty *css_parse_properties(CSSParseState *b, const char *props_str) skip_spaces(&p); /* find the property */ def = css_properties; - for(;;) { + for (;;) { if (def >= css_properties + NB_PROPERTIES) { css_error1(b, "unsupported property '%s'", property); /* property not found skip it: find next ';' */ - while (*p && *p != ';') - p++; + while (*p && *p != ';') + p++; goto next; } if (!strcmp(def->name, property)) @@ -265,7 +265,7 @@ CSSProperty *css_parse_properties(CSSParseState *b, const char *props_str) type = def->type; nb_args = 0; - for(;;) { + for (;;) { /* get argument */ skip_spaces(&p); if (*p == ';' || *p == '\0') @@ -395,7 +395,7 @@ CSSProperty *css_parse_properties(CSSParseState *b, const char *props_str) goto next; got_val: /* specific handling may be necessary. We do them here */ - switch(property_index) { + switch (property_index) { case CSS_font_size: if (unit == CSS_UNIT_NONE) { if (val == 7) { @@ -432,7 +432,7 @@ CSSProperty *css_parse_properties(CSSParseState *b, const char *props_str) args[0].type = unit; args[0].u.val = val; if (property_index == CSS_border) { - for(i=0;i<4;i++) + for (i = 0; i < 4; i++) css_add_prop(&last_prop, property_index1 + 1 + i, &args[0]); } else { @@ -457,7 +457,7 @@ CSSProperty *css_parse_properties(CSSParseState *b, const char *props_str) CSSPropertyValue v1, v2, v3, v4; /* handle specifically the four args case */ v1 = args[0]; - switch(nb_args) { + switch (nb_args) { case 1: args[1] = args[2] = args[3] = v1; break; @@ -485,12 +485,12 @@ CSSProperty *css_parse_properties(CSSParseState *b, const char *props_str) args[0] = v4; break; } - for(i=0;i<4;i++) + for (i = 0; i < 4; i++) css_add_prop(&last_prop, property_index + 1 + i, &args[i]); } else if (type & CSS_TYPE_TWO) { if (nb_args == 1) args[1] = args[0]; - for(i=0;i<2;i++) + for (i = 0; i < 2; i++) css_add_prop(&last_prop, property_index + 1 + i, &args[i]); } else if (type & CSS_TYPE_ARGS) { /* unbounded number of args */ @@ -524,9 +524,9 @@ void css_dump_properties(CSSProperty *prop) printf("inherit"); } else { value = &prop->value; - for(j=0;jnb_values;j++) { + for (j = 0; j < prop-> nb_values;j++) { val = value->u.val; - switch(value->type) { + switch (value->type) { case CSS_UNIT_EX: printf("%0.1fex", (double)val / CSS_LENGTH_FRAC_BASE); break; @@ -550,7 +550,7 @@ void css_dump_properties(CSSProperty *prop) else p = def->name + strlen(def->name) + 1; i = 0; - for(;;) { + for (;;) { p1 = strchr(p, ','); if (i == val) { if (!p1) @@ -619,7 +619,7 @@ static void free_selector(CSSSimpleSelector *ss) { CSSStyleSheetAttributeEntry *attr, *attr1; - for(attr = ss->attrs; attr != NULL; attr = attr1) { + for (attr = ss->attrs; attr != NULL; attr = attr1) { attr1 = attr->next; free(attr); } @@ -632,17 +632,17 @@ void css_free_style_sheet(CSSStyleSheet *s) CSSProperty *p, *p1; CSSSimpleSelector *ss, *ss1; - for(e = s->first_entry; e != NULL; e = e1) { + for (e = s->first_entry; e != NULL; e = e1) { e1 = e->next; - for(ss = e->sel.next; ss != NULL; ss = ss1) { + for (ss = e->sel.next; ss != NULL; ss = ss1) { ss1 = ss->next; free_selector(ss); free(ss); } free_selector(&e->sel); - for(p = e->props; p != NULL; p = p1) { + for (p = e->props; p != NULL; p = p1) { p1 = p->next; free(p); } @@ -677,7 +677,7 @@ static int bgetc(CSSParseState *b) b->ptr--; return '/'; } - for(;;) { + for (;;) { ch = bgetc1(b); if (ch != '*') continue; @@ -699,7 +699,7 @@ static void read_string(CSSParseState *b, int *ch_ptr, char *ident, int ident_si quote = *ch_ptr; q = ident; - for(;;) { + for (;;) { ch = bgetc(b); if (ch == quote) break; @@ -718,7 +718,7 @@ static void read_ident(CSSParseState *b, int *ch_ptr, char *ident, int ident_siz c = *ch_ptr; q = ident; - for(;;) { + for (;;) { if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || @@ -793,7 +793,7 @@ static void dup_selector(CSSSimpleSelector *dest, CSSSimpleSelector *src) first_attr = NULL; plast_attr = &first_attr; - for(attr = src->attrs; attr != NULL; attr = attr->next) + for (attr = src->attrs; attr != NULL; attr = attr->next) add_attribute(&plast_attr, attr->attr, attr->op, attr->value); memcpy(dest, src, sizeof(CSSSimpleSelector)); @@ -806,7 +806,7 @@ static CSSProperty *dup_properties(CSSProperty *props) CSSProperty *p, *first_p, **plast_p; first_p = NULL; plast_p = &first_p; - for(p = props; p != NULL; p = p->next) { + for (p = props; p != NULL; p = p->next) { css_add_prop_values(&plast_p, p->property, p->nb_values, &p->value); } return first_p; @@ -818,14 +818,14 @@ void css_merge_style_sheet(CSSStyleSheet *s, CSSStyleSheet *a) CSSStyleSheetEntry *e, *e1; CSSSimpleSelector *ss, *ss1, ss2, **pss; - for(e = a->first_entry; e != NULL; e = e->next) { + for (e = a->first_entry; e != NULL; e = e->next) { /* add selector */ dup_selector(&ss2, &e->sel); e1 = add_style_entry(s, &ss2, e->media); /* add selector operations */ pss = &e1->sel.next; - for(ss = e->sel.next; ss != NULL; ss = ss->next) { + for (ss = e->sel.next; ss != NULL; ss = ss->next) { ss1 = malloc(sizeof(CSSSimpleSelector)); dup_selector(ss1, ss); *pss = ss1; @@ -874,7 +874,7 @@ static void parse_simple_selector(CSSSimpleSelector *ss, CSSParseState *b, css_strtolower(tag, sizeof(tag)); /* read '.class', '[xxx]', ':pseudo-class' */ - for(;;) { + for (;;) { bskip_spaces(b, &ch); if (ch == '.') { /* read the class and add it as an attribute */ @@ -893,7 +893,7 @@ static void parse_simple_selector(CSSSimpleSelector *ss, CSSParseState *b, if (b->ignore_case) css_strtolower(attribute, sizeof(attribute)); - switch(ch) { + switch (ch) { case '~': op = CSS_ATTR_OP_IN_LIST; ch = bgetc(b); @@ -966,7 +966,7 @@ void css_parse_style_sheet(CSSStyleSheet *s, CSSParseState *b) ch = bgetc(b); media = CSS_MEDIA_ALL; - for(;;) { + for (;;) { redo: first_eprops = s->plast_entry; bskip_spaces(b, &ch); @@ -985,11 +985,11 @@ void css_parse_style_sheet(CSSStyleSheet *s, CSSParseState *b) if (ch == '@') { ch = bgetc(b); read_ident(b, &ch, tag, sizeof(tag)); - switch(css_get_enum(tag, "media,page")) { + switch (css_get_enum(tag, "media,page")) { case 0: /* @media */ media = 0; - for(;;) { + for (;;) { bskip_spaces(b, &ch); read_ident(b, &ch, tag, sizeof(tag)); val = css_get_enum(tag, "tty,screen,print,tv,speech,all"); @@ -1030,11 +1030,11 @@ void css_parse_style_sheet(CSSStyleSheet *s, CSSParseState *b) } /* parse a selector list */ - for(;;) { + for (;;) { /* parse simple selectors with operations */ last_ss = NULL; last_tree_op = CSS_TREE_OP_NONE; - for(;;) { + for (;;) { int tree_op; bskip_spaces(b, &ch); parse_simple_selector(ss, b, &ch); @@ -1094,7 +1094,7 @@ void css_parse_style_sheet(CSSStyleSheet *s, CSSParseState *b) problems, but it would still not be sufficient. */ props = css_parse_properties(b, value); i = 0; - for(e = *first_eprops; e != NULL; e = e->next) { + for (e = *first_eprops; e != NULL; e = e->next) { if (i == 0) e->props = props; else @@ -1122,7 +1122,7 @@ static void dump_selector(CSSSimpleSelector *ss) { CSSStyleSheetAttributeEntry *ae; - switch(ss->tree_op) { + switch (ss->tree_op) { case CSS_TREE_OP_DESCENDANT: dump_selector(ss->next); printf(" "); @@ -1148,7 +1148,7 @@ static void dump_selector(CSSSimpleSelector *ss) ae = ss->attrs; while (ae != NULL) { printf("[%s", css_ident_str(ae->attr)); - switch(ae->op) { + switch (ae->op) { case CSS_ATTR_OP_EQUAL: printf("=%s", ae->value); break; diff --git a/libqhtml/csstoqe.c b/libqhtml/csstoqe.c index 9a9cd36..444cd14 100644 --- a/libqhtml/csstoqe.c +++ b/libqhtml/csstoqe.c @@ -14,7 +14,7 @@ int main(int argc, char **argv) got_space = 0; last_c = 0; in_string = 0; - for(;;) { + for (;;) { c = getchar(); redo: if (c == EOF) @@ -31,7 +31,7 @@ int main(int argc, char **argv) putchar('/'); goto redo; } - for(;;) { + for (;;) { c = getchar(); if (c == EOF) goto the_end; diff --git a/ligtoqe.c b/ligtoqe.c index 7f3911a..a90df2a 100644 --- a/ligtoqe.c +++ b/ligtoqe.c @@ -93,11 +93,11 @@ int main(int argc, char **argv) int subst1_count, subst2_count, subst_long_count; to_utf8 = 0; - for(;;) { + for (;;) { c = getopt(argc, argv, "uh"); if (c == -1) break; - switch(c) { + switch (c) { case 'h': help(); break; @@ -116,7 +116,7 @@ int main(int argc, char **argv) perror(lig_filename); return 1; } - for(;;) { + for (;;) { if (fgets(buf, sizeof(buf), f) == NULL) break; p = buf + strlen(buf) - 1; @@ -137,7 +137,7 @@ int main(int argc, char **argv) l = &ligs[nb_ligs++]; l->buf_in_size = 0; - for(;;) { + for (;;) { while (isspace(*p)) p++; if (*p == '=') @@ -151,7 +151,7 @@ int main(int argc, char **argv) p++; l->buf_out_size = 0; - for(;;) { + for (;;) { while (isspace(*p)) p++; /* stop at the first comment */ @@ -169,12 +169,12 @@ int main(int argc, char **argv) /* output UTF8 encoded list */ if (to_utf8) { printf("%s // ", buf); - for(i=0;ibuf_in_size;i++) { + for (i = 0; i < l->buf_in_size; i++) { unicode_to_utf8(buf1, l->buf_in[i]); printf("%s ", buf1); } printf("="); - for(i=0;ibuf_out_size;i++) { + for (i = 0; i < l->buf_out_size; i++) { unicode_to_utf8(buf1, l->buf_out[i]); printf(" %s", buf1); } @@ -203,7 +203,7 @@ int main(int argc, char **argv) /* output the subst table */ n = 0; - for(i=0;ibuf_in_size == 1) { if (l->buf_out_size != 1) { @@ -222,7 +222,7 @@ int main(int argc, char **argv) l1 = 0; l2 = 0; n = 0; - for(i=0;ibuf_in_size >= 2) { if (l->buf_in_size > 2 || l->buf_out_size > 1) { @@ -249,14 +249,14 @@ int main(int argc, char **argv) /* output the long ligature table */ n = 0; - for(i=0;ibuf_in_size > 2 || l->buf_out_size > 1) { put_be16(outfile, l->buf_in_size); put_be16(outfile, l->buf_out_size); - for(j=0;jbuf_in_size;j++) + for (j = 0; j < l->buf_in_size; j++) put_be16(outfile, l->buf_in[j]); - for(j=0;jbuf_out_size;j++) + for (j = 0; j < l->buf_out_size; j++) put_be16(outfile, l->buf_out[j]); n += 2 + l->buf_in_size + l->buf_out_size; } diff --git a/mpeg.c b/mpeg.c index 4160bc6..02365d4 100644 --- a/mpeg.c +++ b/mpeg.c @@ -18,14 +18,14 @@ */ #include "qe.h" -#define SEQ_END_CODE 0x000001b7 -#define SEQ_START_CODE 0x000001b3 -#define GOP_START_CODE 0x000001b8 -#define PICTURE_START_CODE 0x00000100 -#define SLICE_MIN_START_CODE 0x00000101 -#define SLICE_MAX_START_CODE 0x000001af -#define EXT_START_CODE 0x000001b5 -#define USER_START_CODE 0x000001b2 +#define SEQ_END_CODE 0x000001b7 +#define SEQ_START_CODE 0x000001b3 +#define GOP_START_CODE 0x000001b8 +#define PICTURE_START_CODE 0x00000100 +#define SLICE_MIN_START_CODE 0x00000101 +#define SLICE_MAX_START_CODE 0x000001af +#define EXT_START_CODE 0x000001b5 +#define USER_START_CODE 0x000001b2 #define PACK_START_CODE 0x000001ba #define SYSTEM_HEADER_START_CODE 0x000001bb @@ -43,7 +43,7 @@ static int mpeg_display(EditState *s, DisplayState *ds, int offset) display_bol(ds); display_printf(ds, -1, -1, "%08x:", offset); - for(;;) { + for (;;) { ret = eb_read(s->b, offset, buf, 4); if (ret == 0) { if (badchars) @@ -77,7 +77,7 @@ static int mpeg_display(EditState *s, DisplayState *ds, int offset) offset += 4; display_printf(ds, offset_start, offset, " [%08x] ", startcode); - switch(startcode) { + switch (startcode) { case SEQ_END_CODE: display_printf(ds, -1, -1, "SEQ_END"); break; @@ -121,7 +121,7 @@ static int mpeg_backward_offset(EditState *s, int offset) unsigned int startcode; int ret; - for(;;) { + for (;;) { if (offset <= 0) break; ret = eb_read(s->b, offset, buf, 4); diff --git a/qfribidi.c b/qfribidi.c index bacc749..e303c65 100644 --- a/qfribidi.c +++ b/qfribidi.c @@ -246,7 +246,7 @@ static void compact_list(TypeLink * list_tab) p = list_tab; q = list_tab; - for(;;) { + for (;;) { lp = p; type = p->type; len = p->len; @@ -276,42 +276,42 @@ static void compact_list(TypeLink * list_tab) /* Rules for overriding current type */ #define TYPE_RULE1(old_this, \ - new_this) \ + new_this) \ if (this_type == TYPE_ ## old_this) \ RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ /* Rules for current and previous type */ #define TYPE_RULE2(old_prev, old_this, \ - new_prev, new_this) \ + new_prev, new_this) \ if ( prev_type == FRIBIDI_TYPE_ ## old_prev \ - && this_type == FRIBIDI_TYPE_ ## old_this) \ + && this_type == FRIBIDI_TYPE_ ## old_this) \ { \ - RL_TYPE(pp->prev) = FRIBIDI_TYPE_ ## new_prev; \ - RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ + RL_TYPE(pp->prev) = FRIBIDI_TYPE_ ## new_prev; \ + RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ continue; \ } /* A full rule that assigns all three types */ #define TYPE_RULE(old_prev, old_this, old_next, \ - new_prev, new_this, new_next) \ + new_prev, new_this, new_next) \ if ( prev_type == FRIBIDI_TYPE_ ## old_prev \ - && this_type == FRIBIDI_TYPE_ ## old_this \ - && next_type == FRIBIDI_TYPE_ ## old_next) \ + && this_type == FRIBIDI_TYPE_ ## old_this \ + && next_type == FRIBIDI_TYPE_ ## old_next) \ { \ - RL_TYPE(pp->prev) = FRIBIDI_TYPE_ ## new_prev; \ - RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ - RL_TYPE(pp->next) = FRIBIDI_TYPE_ ## new_next; \ + RL_TYPE(pp->prev) = FRIBIDI_TYPE_ ## new_prev; \ + RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ + RL_TYPE(pp->next) = FRIBIDI_TYPE_ ## new_next; \ continue; \ } /* For optimization the following macro only assigns the center type */ #define TYPE_RULE_C(old_prev, old_this, old_next, \ - new_this) \ + new_this) \ if ( prev_type == FRIBIDI_TYPE_ ## old_prev \ - && this_type == FRIBIDI_TYPE_ ## old_this \ - && next_type == FRIBIDI_TYPE_ ## old_next) \ + && this_type == FRIBIDI_TYPE_ ## old_this \ + && next_type == FRIBIDI_TYPE_ ## old_next) \ { \ - RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ + RL_TYPE(pp) = FRIBIDI_TYPE_ ## new_this; \ continue; \ } @@ -345,8 +345,8 @@ static void print_types_re(TypeLink * pp_tab, int level) { TypeLink *pp; - for(pp = pp_tab + 1; pp->type != FRIBIDI_TYPE_EOT; pp++) { - printf("%d:%c(%d)[%d] ", RL_POS(pp), type_to_char(RL_TYPE(pp)), RL_LEN(pp), level ? RL_LEVEL(pp) : 0); + for (pp = pp_tab + 1; pp->type != FRIBIDI_TYPE_EOT; pp++) { + printf("%d:%c(%d)[%d] ", RL_POS(pp), type_to_char(RL_TYPE(pp)), RL_LEN(pp), level ? RL_LEVEL(pp) : 0); } printf("\n"); } @@ -380,47 +380,47 @@ void fribidi_analyse_string(TypeLink * type_rl_list, /* Find the base level */ if (*pbase_dir == FRIBIDI_TYPE_L) { - base_dir = FRIBIDI_TYPE_L; - base_level = 0; + base_dir = FRIBIDI_TYPE_L; + base_level = 0; } else if (*pbase_dir == FRIBIDI_TYPE_R) { - base_dir = FRIBIDI_TYPE_R; - base_level = 1; + base_dir = FRIBIDI_TYPE_R; + base_level = 1; } /* Search for first strong character and use its direction as base direction */ else { - base_level = 0; /* Default */ - base_dir = FRIBIDI_TYPE_N; - for (pp = type_rl_list; pp->type != FRIBIDI_TYPE_EOT; pp++) { + base_level = 0; /* Default */ + base_dir = FRIBIDI_TYPE_N; + for (pp = type_rl_list; pp->type != FRIBIDI_TYPE_EOT; pp++) { int type; type = RL_TYPE(pp); - if (type == FRIBIDI_TYPE_R || + if (type == FRIBIDI_TYPE_R || type == FRIBIDI_TYPE_RLE || type == FRIBIDI_TYPE_RLO) { - base_level = 1; - base_dir = FRIBIDI_TYPE_R; - break; - } else if (type == FRIBIDI_TYPE_L || + base_level = 1; + base_dir = FRIBIDI_TYPE_R; + break; + } else if (type == FRIBIDI_TYPE_L || type == FRIBIDI_TYPE_LRE || type == FRIBIDI_TYPE_LRO) { - base_level = 0; - base_dir = FRIBIDI_TYPE_L; - break; - } - } + base_level = 0; + base_dir = FRIBIDI_TYPE_L; + break; + } + } - /* If no strong base_dir was found, resort to the weak direction - * that was passed on input. - */ - if (base_dir == FRIBIDI_TYPE_N) { - if (*pbase_dir == FRIBIDI_TYPE_WR) { - base_dir = FRIBIDI_TYPE_RTL; - base_level = 1; - } else if (*pbase_dir == FRIBIDI_TYPE_WL) { - base_dir = FRIBIDI_TYPE_LTR; - base_level = 0; - } - } + /* If no strong base_dir was found, resort to the weak direction + * that was passed on input. + */ + if (base_dir == FRIBIDI_TYPE_N) { + if (*pbase_dir == FRIBIDI_TYPE_WR) { + base_dir = FRIBIDI_TYPE_RTL; + base_level = 1; + } else if (*pbase_dir == FRIBIDI_TYPE_WL) { + base_dir = FRIBIDI_TYPE_LTR; + base_level = 0; + } + } } /* hack for RLE/LRE/RLO/LRO/PDF. It is not complete in case of @@ -436,7 +436,7 @@ void fribidi_analyse_string(TypeLink * type_rl_list, type == FRIBIDI_TYPE_RLE || type == FRIBIDI_TYPE_LRO || type == FRIBIDI_TYPE_RLO) { - for(i=0;i 0) { stack_index--; /* pop level & override */ @@ -482,66 +482,66 @@ void fribidi_analyse_string(TypeLink * type_rl_list, /* 4. Resolving weak types */ last_strong = base_dir; for (pp = type_rl_list + 1; pp->type != FRIBIDI_TYPE_EOT; pp++) { - int prev_type = RL_TYPE(pp-1); - int this_type = RL_TYPE(pp); - int next_type = RL_TYPE(pp+1); + int prev_type = RL_TYPE(pp-1); + int this_type = RL_TYPE(pp); + int next_type = RL_TYPE(pp+1); - /* Remember the last strong character */ - if (prev_type == FRIBIDI_TYPE_AL - || prev_type == FRIBIDI_TYPE_R - || prev_type == FRIBIDI_TYPE_L) - last_strong = prev_type; + /* Remember the last strong character */ + if (prev_type == FRIBIDI_TYPE_AL + || prev_type == FRIBIDI_TYPE_R + || prev_type == FRIBIDI_TYPE_L) + last_strong = prev_type; - /* W1. NSM */ - if (this_type == FRIBIDI_TYPE_NSM) { - if (prev_type == FRIBIDI_TYPE_SOT) - RL_TYPE(pp) = FRIBIDI_TYPE_N; /* Will be resolved to base dir */ - else - RL_TYPE(pp) = prev_type; - } - /* W2: European numbers */ - if (this_type == FRIBIDI_TYPE_N - && last_strong == FRIBIDI_TYPE_AL) - RL_TYPE(pp) = FRIBIDI_TYPE_AN; + /* W1. NSM */ + if (this_type == FRIBIDI_TYPE_NSM) { + if (prev_type == FRIBIDI_TYPE_SOT) + RL_TYPE(pp) = FRIBIDI_TYPE_N; /* Will be resolved to base dir */ + else + RL_TYPE(pp) = prev_type; + } + /* W2: European numbers */ + if (this_type == FRIBIDI_TYPE_N + && last_strong == FRIBIDI_TYPE_AL) + RL_TYPE(pp) = FRIBIDI_TYPE_AN; - /* W3: Change ALs to R - We have to do this for prev character as we would otherwise - interfer with the next last_strong which is FRIBIDI_TYPE_AL. - */ - if (prev_type == FRIBIDI_TYPE_AL) - RL_TYPE(pp-1) = FRIBIDI_TYPE_R; + /* W3: Change ALs to R + We have to do this for prev character as we would otherwise + interfer with the next last_strong which is FRIBIDI_TYPE_AL. + */ + if (prev_type == FRIBIDI_TYPE_AL) + RL_TYPE(pp-1) = FRIBIDI_TYPE_R; - /* W4. A single european separator changes to a european number. - A single common separator between two numbers of the same type - changes to that type. - */ - if (RL_LEN(pp) == 1) { - TYPE_RULE_C(EN, ES, EN, EN); - TYPE_RULE_C(EN, CS, EN, EN); - TYPE_RULE_C(AN, CS, AN, AN); - } - /* W5. A sequence of European terminators adjacent to European - numbers changes to All European numbers. - */ - if (this_type == FRIBIDI_TYPE_ET) { - if (next_type == FRIBIDI_TYPE_EN - || prev_type == FRIBIDI_TYPE_EN) { - RL_TYPE(pp) = FRIBIDI_TYPE_EN; - } - } - /* This type may have been overriden */ - this_type = RL_TYPE(pp); + /* W4. A single european separator changes to a european number. + A single common separator between two numbers of the same type + changes to that type. + */ + if (RL_LEN(pp) == 1) { + TYPE_RULE_C(EN, ES, EN, EN); + TYPE_RULE_C(EN, CS, EN, EN); + TYPE_RULE_C(AN, CS, AN, AN); + } + /* W5. A sequence of European terminators adjacent to European + numbers changes to All European numbers. + */ + if (this_type == FRIBIDI_TYPE_ET) { + if (next_type == FRIBIDI_TYPE_EN + || prev_type == FRIBIDI_TYPE_EN) { + RL_TYPE(pp) = FRIBIDI_TYPE_EN; + } + } + /* This type may have been overriden */ + this_type = RL_TYPE(pp); - /* W6. Otherwise change separators and terminators to other neutral */ - if (this_type == FRIBIDI_TYPE_ET - || this_type == FRIBIDI_TYPE_CS - || this_type == FRIBIDI_TYPE_ES) - RL_TYPE(pp) = FRIBIDI_TYPE_ON; + /* W6. Otherwise change separators and terminators to other neutral */ + if (this_type == FRIBIDI_TYPE_ET + || this_type == FRIBIDI_TYPE_CS + || this_type == FRIBIDI_TYPE_ES) + RL_TYPE(pp) = FRIBIDI_TYPE_ON; - /* W7. Change european numbers to L. */ - if (prev_type == FRIBIDI_TYPE_EN - && last_strong == FRIBIDI_TYPE_L) - RL_TYPE(pp-1) = FRIBIDI_TYPE_L; + /* W7. Change european numbers to L. */ + if (prev_type == FRIBIDI_TYPE_EN + && last_strong == FRIBIDI_TYPE_L) + RL_TYPE(pp-1) = FRIBIDI_TYPE_L; } compact_list(type_rl_list); @@ -551,42 +551,42 @@ void fribidi_analyse_string(TypeLink * type_rl_list, /* We can now collapse all separators and other neutral types to plain neutrals */ for (pp = type_rl_list + 1; pp->type != FRIBIDI_TYPE_EOT; pp++) { - int this_type = RL_TYPE(pp); + int this_type = RL_TYPE(pp); - if (this_type == FRIBIDI_TYPE_WS - || this_type == FRIBIDI_TYPE_ON - || this_type == FRIBIDI_TYPE_ES - || this_type == FRIBIDI_TYPE_ET - || this_type == FRIBIDI_TYPE_CS - || this_type == FRIBIDI_TYPE_BN) - RL_TYPE(pp) = FRIBIDI_TYPE_N; + if (this_type == FRIBIDI_TYPE_WS + || this_type == FRIBIDI_TYPE_ON + || this_type == FRIBIDI_TYPE_ES + || this_type == FRIBIDI_TYPE_ET + || this_type == FRIBIDI_TYPE_CS + || this_type == FRIBIDI_TYPE_BN) + RL_TYPE(pp) = FRIBIDI_TYPE_N; } compact_list(type_rl_list); for (pp = type_rl_list + 1; pp->type != FRIBIDI_TYPE_EOT; pp++) { - int prev_type = RL_TYPE(pp-1); - int this_type = RL_TYPE(pp); - int next_type = RL_TYPE(pp+1); + int prev_type = RL_TYPE(pp-1); + int this_type = RL_TYPE(pp); + int next_type = RL_TYPE(pp+1); - if (this_type == FRIBIDI_TYPE_N) { /* optimization! */ - /* "European and arabic numbers are treated - as though they were R" */ + if (this_type == FRIBIDI_TYPE_N) { /* optimization! */ + /* "European and arabic numbers are treated + as though they were R" */ - if (prev_type == FRIBIDI_TYPE_EN || prev_type == FRIBIDI_TYPE_AN) - prev_type = FRIBIDI_TYPE_R; + if (prev_type == FRIBIDI_TYPE_EN || prev_type == FRIBIDI_TYPE_AN) + prev_type = FRIBIDI_TYPE_R; - if (next_type == FRIBIDI_TYPE_EN || next_type == FRIBIDI_TYPE_AN) - next_type = FRIBIDI_TYPE_R; + if (next_type == FRIBIDI_TYPE_EN || next_type == FRIBIDI_TYPE_AN) + next_type = FRIBIDI_TYPE_R; - /* N1. */ - TYPE_RULE_C(R, N, R, R); - TYPE_RULE_C(L, N, L, L); + /* N1. */ + TYPE_RULE_C(R, N, R, R); + TYPE_RULE_C(L, N, L, L); - /* N2. Any remaining neutrals takes the embedding direction */ - if (RL_TYPE(pp) == FRIBIDI_TYPE_N) - RL_TYPE(pp) = FRIBIDI_TYPE_E; - } + /* N2. Any remaining neutrals takes the embedding direction */ + if (RL_TYPE(pp) == FRIBIDI_TYPE_N) + RL_TYPE(pp) = FRIBIDI_TYPE_E; + } } compact_list(type_rl_list); diff --git a/qfribidi.h b/qfribidi.h index 6410a31..0ad1ff3 100644 --- a/qfribidi.h +++ b/qfribidi.h @@ -4,36 +4,36 @@ typedef int FriBidiChar; typedef enum { /* do not change the order of these constants since 'property_val' depends on them */ - FRIBIDI_TYPE_LTR, /* Strong left to right */ - FRIBIDI_TYPE_RTL, /* Right to left characters */ - FRIBIDI_TYPE_WL, /* Weak left to right */ - FRIBIDI_TYPE_WR, /* Weak right to left */ - FRIBIDI_TYPE_EN, /* European digit */ - FRIBIDI_TYPE_ES, /* European number separator */ - FRIBIDI_TYPE_ET, /* European number terminator */ - FRIBIDI_TYPE_AN, /* Arabic digit */ - FRIBIDI_TYPE_CS, /* Common Separator */ - FRIBIDI_TYPE_BS, /* Block separator */ - FRIBIDI_TYPE_SS, /* Segment separator */ - FRIBIDI_TYPE_WS, /* Whitespace */ - FRIBIDI_TYPE_AL, /* Arabic characters */ - FRIBIDI_TYPE_NSM, /* Non spacing mark */ + FRIBIDI_TYPE_LTR, /* Strong left to right */ + FRIBIDI_TYPE_RTL, /* Right to left characters */ + FRIBIDI_TYPE_WL, /* Weak left to right */ + FRIBIDI_TYPE_WR, /* Weak right to left */ + FRIBIDI_TYPE_EN, /* European digit */ + FRIBIDI_TYPE_ES, /* European number separator */ + FRIBIDI_TYPE_ET, /* European number terminator */ + FRIBIDI_TYPE_AN, /* Arabic digit */ + FRIBIDI_TYPE_CS, /* Common Separator */ + FRIBIDI_TYPE_BS, /* Block separator */ + FRIBIDI_TYPE_SS, /* Segment separator */ + FRIBIDI_TYPE_WS, /* Whitespace */ + FRIBIDI_TYPE_AL, /* Arabic characters */ + FRIBIDI_TYPE_NSM, /* Non spacing mark */ FRIBIDI_TYPE_BN, - FRIBIDI_TYPE_ON, /* Other Neutral */ - FRIBIDI_TYPE_LRE, /* Left-To-Right embedding */ - FRIBIDI_TYPE_RLE, /* Right-To-Left embedding */ - FRIBIDI_TYPE_PDF, /* Pop directional override */ - FRIBIDI_TYPE_LRO, /* Left-To-Right override */ - FRIBIDI_TYPE_RLO, /* Right-To-Left override */ + FRIBIDI_TYPE_ON, /* Other Neutral */ + FRIBIDI_TYPE_LRE, /* Left-To-Right embedding */ + FRIBIDI_TYPE_RLE, /* Right-To-Left embedding */ + FRIBIDI_TYPE_PDF, /* Pop directional override */ + FRIBIDI_TYPE_LRO, /* Left-To-Right override */ + FRIBIDI_TYPE_RLO, /* Right-To-Left override */ /* The following are only used internally */ FRIBIDI_TYPE_SOT, FRIBIDI_TYPE_EOT, FRIBIDI_TYPE_N, FRIBIDI_TYPE_E, - FRIBIDI_TYPE_CTL, /* Control units */ - FRIBIDI_TYPE_EO, /* Control units */ - FRIBIDI_TYPE_NULL, /* type record is to be deleted */ + FRIBIDI_TYPE_CTL, /* Control units */ + FRIBIDI_TYPE_EO, /* Control units */ + FRIBIDI_TYPE_NULL, /* type record is to be deleted */ FRIBIDI_TYPE_L = FRIBIDI_TYPE_LTR, FRIBIDI_TYPE_R = FRIBIDI_TYPE_RTL, FRIBIDI_TYPE_CM = FRIBIDI_TYPE_ON + 2, @@ -53,7 +53,7 @@ FriBidiCharType fribidi_get_type(FriBidiChar ch); FriBidiCharType fribidi_get_type_test(FriBidiChar ch); FriBidiChar fribidi_get_mirror_char(FriBidiChar ch); -void fribidi_analyse_string(TypeLink * type_rl_list, - FriBidiCharType * pbase_dir, +void fribidi_analyse_string(TypeLink *type_rl_list, + FriBidiCharType *pbase_dir, int *pmax_level); diff --git a/tty.c b/tty.c index 59de7e0..ea2db2a 100644 --- a/tty.c +++ b/tty.c @@ -341,7 +341,7 @@ static void tty_read_handler(void *opaque) break; } ts->input_state = IS_NORM; - switch(ch) { + switch (ch) { case '[': ts->input_state = IS_CSI2; break; @@ -379,7 +379,7 @@ static void tty_read_handler(void *opaque) case IS_CSI2: /* cygwin/linux terminal */ ts->input_state = IS_NORM; - switch(ch) { + switch (ch) { case 'A': ch = KEY_F1; goto the_end; case 'B': ch = KEY_F2; goto the_end; case 'C': ch = KEY_F3; goto the_end; @@ -390,7 +390,7 @@ static void tty_read_handler(void *opaque) case IS_ESC2: // "\EO" /* xterm/vt100 fn */ ts->input_state = IS_NORM; - switch(ch) { + switch (ch) { case 'A': ch = KEY_UP; goto the_end; case 'B': ch = KEY_DOWN; goto the_end; case 'C': ch = KEY_RIGHT; goto the_end; @@ -442,7 +442,7 @@ static int get_tty_color(QEColor color) dmin = MAXINT; cmin = 0; - for(i=0;iscreen + y1 * s->width + x1; if (color == QECOLOR_XOR) { - for(y=y1;yline_updated[y] = 1; - for(x=x1;xbgcolor ^= 7; ptr->fgcolor ^= 7; ptr++; @@ -476,9 +476,9 @@ static void term_fill_rectangle(QEditScreen *s, } } else { bgcolor = get_tty_color(color); - for(y=y1;yline_updated[y] = 1; - for(x=x1;xbgcolor = bgcolor; ptr->ch = ' '; ptr->fgcolor = 7; @@ -540,7 +540,7 @@ static void term_text_metrics(QEditScreen *s, QEFont *font, metrics->font_ascent = font->ascent; metrics->font_descent = font->descent; x = 0; - for(i=0;iwidth = x; } @@ -578,7 +578,7 @@ static void term_draw_text(QEditScreen *s, QEFont *font, if (s->clip_x2 < n) n = s->clip_x2; n -= s->clip_x1; - for(; n > 0; n--) { + for (; n > 0; n--) { ptr->fgcolor = fgcolor; ptr->ch = ' '; ptr++; diff --git a/unihex.c b/unihex.c index f3be869..72e68f8 100644 --- a/unihex.c +++ b/unihex.c @@ -56,7 +56,7 @@ static int unihex_display(EditState *s, DisplayState *ds, int offset) display_printf(ds, -1, -1, "%08x ", offset); len = 0; - for(j=0;jdisp_width;j++) { + for (j = 0; j < s->disp_width; j++) { if (offset < s->b->total_size) { b = eb_nextc(s->b, offset, &offset1); pos[len] = offset; @@ -67,7 +67,7 @@ static int unihex_display(EditState *s, DisplayState *ds, int offset) } pos[len] = offset; - for(j=0;jdisp_width;j++) { + for (j = 0; j < s->disp_width; j++) { display_char(ds, -1, -1, ' '); if (j < len) { display_printhex(ds, pos[j], pos[j+1], buf[j], 4); @@ -85,7 +85,7 @@ static int unihex_display(EditState *s, DisplayState *ds, int offset) display_char(ds, -1, -1, ' '); display_char(ds, -1, -1, ' '); - for(j=0;jdisp_width;j++) { + for (j = 0; j < s->disp_width; j++) { if (j < len) { b = buf[j]; if (b < ' ' || b == 127) diff --git a/unix.c b/unix.c index 43df160..6fa439a 100644 --- a/unix.c +++ b/unix.c @@ -198,7 +198,7 @@ static inline int check_timers(int max_delay) cur_time = get_clock_ms(); timeout = cur_time + max_delay; pt = &first_timer; - for(;;) { + for (;;) { ti = *pt; if (ti == NULL) break; @@ -255,7 +255,7 @@ static void url_block(void) /* call each handler */ if (ret > 0) { uh = url_handlers; - for(i = 0;i <= url_fdmax; i++) { + for (i = 0;i <= url_fdmax; i++) { if (FD_ISSET(i, &rfds)) { uh->read_cb(uh->read_opaque); call_bottom_halves(); @@ -269,7 +269,7 @@ static void url_block(void) } /* handle terminated children */ - for(;;) { + for (;;) { if (list_empty(&pid_handlers)) break; pid = waitpid(-1, &status, WNOHANG); @@ -289,7 +289,7 @@ void url_main_loop(void (*init)(void *opaque), void *opaque) { url_block_reset(); init(opaque); - for(;;) { + for (;;) { if (url_exit_request) break; url_block(); diff --git a/video.c b/video.c index 89c684e..c4a45b6 100644 --- a/video.c +++ b/video.c @@ -121,7 +121,7 @@ static void packet_queue_end(PacketQueue *q) { AVPacketList *pkt, *pkt1; - for(pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { + for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { pkt1 = pkt->next; av_free_packet(&pkt->pkt); } @@ -176,7 +176,7 @@ static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block) pthread_mutex_lock(&q->mutex); - for(;;) { + for (;;) { if (q->abort_request) { ret = -1; break; @@ -308,7 +308,7 @@ static void video_audio_display(EditState *s) i = 0; y1 = (s->height >> 1) + s->ytop; h = y1; - for(x = 0; x < s->width; x++) { + for (x = 0; x < s->width; x++) { y = (is->sample_array[i] * h) >> 15; if (y < 0) { y = -y; @@ -355,7 +355,7 @@ static void alloc_picture(void *opaque) if (vp->bmp) bmp_free(s->screen, vp->bmp); /* XXX: use generic function */ - switch(is->video_st->codec.pix_fmt) { + switch (is->video_st->codec.pix_fmt) { case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: case PIX_FMT_YUV444P: @@ -448,7 +448,7 @@ static int output_picture(VideoState *is, AVPicture *src_pict) bmp_lock(s->screen, vp->bmp, &qepict, 0, 0, vp->bmp->width, vp->bmp->height); dst_pix_fmt = qe_bitmap_format_to_pix_fmt(vp->bmp->format); - for(i=0;i<4;i++) { + for (i = 0; i < 4; i++) { pict.data[i] = qepict.data[i]; pict.linesize[i] = qepict.linesize[i]; } @@ -483,7 +483,7 @@ static void *video_thread(void *arg) AVFrame frame; AVPicture pict; - for(;;) { + for (;;) { while (is->paused && !is->videoq.abort_request) { usleep(10000); } @@ -505,7 +505,7 @@ static void *video_thread(void *arg) if (len1 < 0) break; if (got_picture) { - for(i=0;i<4;i++) { + for (i = 0; i < 4; i++) { pict.data[i] = frame.data[i]; pict.linesize[i] = frame.linesize[i]; } @@ -536,7 +536,7 @@ static void output_audio(VideoState *is, short *samples, int samples_size) len = n; out = is->sample_array + is->sample_array_index; in = samples; - for(i = 0; i < len; i++) { + for (i = 0; i < len; i++) { out[i] = in[0]; in += channels; } @@ -555,7 +555,7 @@ static void *audio_thread(void *arg) int len, len1, data_size; short samples[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2]; - for(;;) { + for (;;) { while (is->paused && !is->audioq.abort_request) { usleep(10000); } @@ -612,7 +612,7 @@ static int stream_open(EditState *s, int stream_index) if (!codec || avcodec_open(enc, codec) < 0) return -1; - switch(enc->codec_type) { + switch (enc->codec_type) { case CODEC_TYPE_AUDIO: is->audio_stream = stream_index; is->audio_st = ic->streams[stream_index]; @@ -641,7 +641,7 @@ static void stream_close(EditState *s, int stream_index) enc = &ic->streams[stream_index]->codec; - switch(enc->codec_type) { + switch (enc->codec_type) { case CODEC_TYPE_AUDIO: packet_queue_abort(&is->audioq); pthread_join(is->audio_tid, NULL); @@ -670,7 +670,7 @@ static void stream_close(EditState *s, int stream_index) } avcodec_close(enc); - switch(enc->codec_type) { + switch (enc->codec_type) { case CODEC_TYPE_AUDIO: is->audio_st = NULL; is->audio_stream = -1; @@ -707,9 +707,9 @@ static void *decode_thread(void *arg) if (err < 0) goto fail; - for(i = 0; i < ic->nb_streams; i++) { + for (i = 0; i < ic->nb_streams; i++) { AVCodecContext *enc = &ic->streams[i]->codec; - switch(enc->codec_type) { + switch (enc->codec_type) { case CODEC_TYPE_AUDIO: if (audio_index < 0) audio_index = i; @@ -739,7 +739,7 @@ static void *decode_thread(void *arg) goto fail; } - for(;;) { + for (;;) { if (is->abort_request) break; /* if the queue are full, no need to read more */ @@ -809,7 +809,7 @@ static int video_mode_init(EditState *s, ModeSavedData *saved_data) /* if there is already a window with this video playing, then we stop this new instance (C-x 2 case) */ video_playing = 0; - for(e = qs->first_window; e != NULL; e = e->next_window) { + for (e = qs->first_window; e != NULL; e = e->next_window) { if (e->mode == s->mode && e != s && e->b == s->b) { VideoState *is1 = e->mode_data; if (!is1->paused) @@ -837,7 +837,7 @@ static void video_mode_close(EditState *s) is->abort_request = 1; pthread_join(is->parse_tid, NULL); /* free all pictures */ - for(i=0;ipictq[i]; if (vp->bmp) { bmp_free(s->screen, vp->bmp); @@ -922,7 +922,7 @@ static void av_cycle_stream(EditState *s, int codec_type) } stream_index = start_index; - for(;;) { + for (;;) { if (++stream_index >= ic->nb_streams) stream_index = 0; if (stream_index == start_index) { diff --git a/win32.c b/win32.c index 316c229..4621bea 100644 --- a/win32.c +++ b/win32.c @@ -64,7 +64,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, p = command_line; count = 0; - for(;;) { + for (;;) { skip_spaces((const char **)&p); if (*p == '\0') break; @@ -79,7 +79,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, argc = 0; p = command_line; - for(;;) { + for (;;) { skip_spaces((const char **)&p); if (*p == '\0') break; @@ -95,7 +95,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, #if 0 { int i; - for(i=0;i> 16) & 0x1FF); - switch(scan) { + switch (scan) { case 0x00E: ignore_wchar_msg = 1; push_key(KEY_DEL); @@ -277,37 +277,37 @@ LRESULT CALLBACK qe_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) else push_key(KEY_CTRL('@')); break; - case 0x147: /* home */ + case 0x147: /* home */ push_key(KEY_HOME); break; - case 0x148: /* UP */ + case 0x148: /* UP */ push_key(KEY_UP); break; - case 0x149: /* PGUP */ + case 0x149: /* PGUP */ push_key(KEY_PAGEUP); break; - case 0x14B: /* LEFT */ + case 0x14B: /* LEFT */ push_key(KEY_LEFT); break; - case 0x14D: /* RIGHT */ + case 0x14D: /* RIGHT */ push_key(KEY_RIGHT); break; - case 0x14F: /* END */ + case 0x14F: /* END */ push_key(KEY_END); break; - case 0x150: /* DOWN */ + case 0x150: /* DOWN */ push_key(KEY_DOWN); break; - case 0x151: /* PGDN */ + case 0x151: /* PGDN */ push_key(KEY_PAGEDOWN); break; - case 0x153: /* DEL */ + case 0x153: /* DEL */ push_key(KEY_DELETE); break; - case 0x152: /* INSERT */ + case 0x152: /* INSERT */ push_key(KEY_INSERT); break; - case 0x3b: /* F1 */ + case 0x3b: /* F1 */ case 0x3c: case 0x3d: case 0x3e: @@ -318,7 +318,7 @@ LRESULT CALLBACK qe_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case 0x43: case 0x44: case 0x57: - case 0x58: /* F12 */ + case 0x58: /* F12 */ key = scan - 0x3b; if (key > 9) key -= 0x12; @@ -344,7 +344,7 @@ LRESULT CALLBACK qe_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) return DefWindowProc(hWnd, msg, wParam, lParam); case WM_SIZE: - if (wParam != SIZE_MINIMIZED) { + if (wParam != SIZE_MINIMIZED) { QEmacsState *qs = &qe_state; QEEvent ev; @@ -353,7 +353,7 @@ LRESULT CALLBACK qe_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ev.expose_event.type = QE_EXPOSE_EVENT; push_event(&ev); } - break; + break; case WM_PAINT: { PAINTSTRUCT ps; @@ -367,14 +367,14 @@ LRESULT CALLBACK qe_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) EndPaint(win_ctx.w, &ps); win_ctx.hdc = saved_hdc; } - break; + break; case WM_SETFOCUS: case WM_KILLFOCUS: break; default: - return DefWindowProc(hWnd, msg, wParam, lParam); + return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; } @@ -384,7 +384,7 @@ static int get_unicode_key(QEditScreen *s, QEPollData *pd, QEEvent *ev) MSG msg; QEEventQ *e; - for(;;) { + for (;;) { /* check if events queued */ if (first_event != NULL) { e = first_event; @@ -451,7 +451,7 @@ static void win_text_metrics(QEditScreen *s, QEFont *font, metrics->font_ascent = font->ascent; metrics->font_descent = font->descent; x = 0; - for(i=0;iwidth = x; } @@ -464,7 +464,7 @@ static void win_draw_text(QEditScreen *s, QEFont *font, WORD buf[len]; COLORREF col; - for(i=0;i> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); SetTextColor(win_ctx.hdc, col); diff --git a/xml.c b/xml.c index ed6ce59..027f3d1 100644 --- a/xml.c +++ b/xml.c @@ -41,7 +41,7 @@ void xml_colorize_line(unsigned int *buf, int len, /* if already in a state, go directly in the code parsing it */ if (state & XML_SCRIPT) goto parse_script; - switch(state) { + switch (state) { case XML_COMMENT: goto parse_comment; case XML_TAG: @@ -53,7 +53,7 @@ void xml_colorize_line(unsigned int *buf, int len, break; } - for(;;) { + for (;;) { p_start = p; c = *p; if (c == '\n') { @@ -102,7 +102,7 @@ void xml_colorize_line(unsigned int *buf, int len, /* javascript coloring */ p_start = p; parse_script: - for(;;) { + for (;;) { if (*p == '\n') { state &= ~XML_SCRIPT; c_colorize_line(p_start, p - p_start, &state, state_only); @@ -129,7 +129,7 @@ void xml_colorize_line(unsigned int *buf, int len, /* stylesheet coloring */ p_start = p; parse_style: - for(;;) { + for (;;) { if (*p == '\n') { set_color(p_start, p - p_start, QE_STYLE_CSS); break;