diff options
-rw-r--r-- | src/ChangeLog | 1 | ||||
-rw-r--r-- | src/acconfig.h | 2 | ||||
-rw-r--r-- | src/ansi.c | 71 | ||||
-rw-r--r-- | src/display.c | 2 | ||||
-rw-r--r-- | src/encoding.c | 145 | ||||
-rw-r--r-- | src/fileio.c | 36 | ||||
-rw-r--r-- | src/image.h | 22 | ||||
-rw-r--r-- | src/layer.c | 2 | ||||
-rw-r--r-- | src/mark.c | 46 | ||||
-rw-r--r-- | src/resize.c | 51 | ||||
-rw-r--r-- | src/search.c | 6 | ||||
-rw-r--r-- | src/window.c | 5 |
12 files changed, 250 insertions, 139 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1b29f87..37e4eea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -79,6 +79,7 @@ Version 4.1.0 (??/??/20??): * Increased default maximum number of windows from 40 to 100. * Increased number color/attribute changes in caption/hardstatus string from 16 to 256. * Some commands can be remotely queried using the -Q command-line flag. + * Support for 32-bit unicode. In-Progress: * Scripting support (thanks to Google Summer of Code 2009 project by Rui Guo) diff --git a/src/acconfig.h b/src/acconfig.h index 2e46985..4431a82 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -129,7 +129,7 @@ * define COLOR to include ansi color support. This may expose * a bug in x11r6-color-xterm. * define DW_CHARS to include support for double-width character - * sets. + * (i.e. multi-byte) sets. * define ENCODINGS to include support for encodings like euc or big5. * Needs FONT to work. * define UTF8 if you want support for UTF-8 encoding. @@ -1,4 +1,7 @@ -/* Copyright (c) 2008, 2009 +/* Copyright (c) 2010 + * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) + * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net) + * Copyright (c) 2008, 2009 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) * Micah Cowan (micah@cowan.name) @@ -2202,7 +2205,7 @@ static void FillWithEs() { register int i; - register unsigned char *p, *ep; + register unsigned int *p, *ep; LClearAll(&curr->w_layer, 1); curr->w_y = curr->w_x = 0; @@ -2253,12 +2256,30 @@ int l; WindowChanged((struct win *)0, 'W'); } +static int +strncmpint(const char *s, const int *i, int len) +{ + while (len--) + { + if (!*s && !*i) + return 0; + if (*s < *i) + return -1; + else if (*s > *i) + return 1; + s++; + i++; + } + return 0; +} + static void FindAKA() { - register unsigned char *cp, *line; + register unsigned int *cp, *line, *i; register struct win *wp = curr; register int len = strlen(wp->w_akabuf); + char aka[MAXSTR], *paka; int y; y = (wp->w_autoaka > 0 && wp->w_autoaka <= wp->w_height) ? wp->w_autoaka - 1 : wp->w_y; @@ -2275,7 +2296,7 @@ FindAKA() goto try_line; return; } - if (strncmp((char *)cp, wp->w_akabuf, len) == 0) + if (strncmpint(wp->w_akabuf, cp, len) == 0) break; cp++; } @@ -2296,7 +2317,12 @@ FindAKA() line = cp; len--; } - ChangeAKA(wp, (char *)line, cp - line); + if (cp - line > MAXSTR) + cp = line + MAXSTR; + paka = aka; + for (i = line; i < cp; i++) + *paka++ = (unsigned char) *i; + ChangeAKA(wp, aka, paka - aka); } else wp->w_autoaka = 0; @@ -2371,11 +2397,11 @@ struct mchar *mc; } } #ifdef FONT - if (mc->font && ml->font == null) + if (mc->font && (unsigned char *)ml->font == null) { - if ((ml->font = (unsigned char *)calloc(p->w_width + 1, 1)) == 0) + if ((ml->font = (unsigned int *)calloc(p->w_width + 1, sizeof(int))) == 0) { - ml->font = null; + ml->font = (unsigned int *)null; p->w_FontL = p->w_charsets[p->w_ss ? p->w_ss : p->w_Charset] = 0; p->w_FontR = p->w_charsets[p->w_ss ? p->w_ss : p->w_CharsetR] = 0; mc->font = p->w_rend.font = 0; @@ -2516,9 +2542,9 @@ int n, ys, ye, bce; free(ml->attr); ml->attr = null; #ifdef FONT - if (ml->font != null) + if (ml->font != (unsigned int *)null) free(ml->font); - ml->font = null; + ml->font = (unsigned int *)null; #endif #ifdef COLOR if (ml->color != null) @@ -2530,7 +2556,7 @@ int n, ys, ye, bce; ml->colorx = null; # endif #endif - bclear((char *)ml->image, p->w_width + 1); + bclear((char *)ml->image, (p->w_width + 1) * sizeof(int)); #ifdef COLOR if (bce) MBceLine(p, i, 0, p->w_width, bce); @@ -2561,9 +2587,9 @@ int n, ys, ye, bce; free(ml->attr); ml->attr = null; #ifdef FONT - if (ml->font != null) + if (ml->font != (unsigned int *)null) free(ml->font); - ml->font = null; + ml->font = (unsigned int *)null; #endif #ifdef COLOR if (ml->color != null) @@ -2575,7 +2601,7 @@ int n, ys, ye, bce; ml->colorx = null; # endif #endif - bclear((char *)ml->image, p->w_width + 1); + bclear((char *)ml->image, (p->w_width + 1) * sizeof(int)); #ifdef COLOR if (bce) MBceLine(p, i, 0, p->w_width, bce); @@ -2759,6 +2785,7 @@ int x, y; struct mline *ml; int i; unsigned char *b; + unsigned int *ip; if (n <= 0) return; @@ -2766,14 +2793,16 @@ int x, y; ml = &p->w_mlines[y]; MKillDwRight(p, ml, x); MKillDwLeft(p, ml, x + n - 1); - bcopy(s, (char *)ml->image + x, n); + ip = ml->image + x; + for (i = 0; i <= n; i++) + *ip++ = *s++; b = ml->attr + x; for (i = n; i-- > 0;) *b++ = r->attr; #ifdef FONT - b = ml->font + x; + ip = ml->font + x; for (i = n; i-- > 0;) - *b++ = r->font; + *ip++ = r->font; #endif #ifdef COLOR b = ml->color + x; @@ -2824,7 +2853,7 @@ WAddLineToHist(wp, ml) struct win *wp; struct mline *ml; { - register unsigned char *q, *o; + register void *q, *o; struct mline *hml; if (wp->w_histheight == 0) @@ -2835,9 +2864,9 @@ struct mline *ml; q = ml->attr; o = hml->attr; hml->attr = q; ml->attr = null; if (o != null) free(o); - + #ifdef FONT - q = ml->font; o = hml->font; hml->font = q; ml->font = null; + q = ml->font; o = hml->font; hml->font = q; ml->font = (unsigned int *)null; if (o != null) free(o); #endif @@ -2869,7 +2898,7 @@ int ys, ye; debug2("MFindUsedLine: %d %d\n", ye, ys); for (y = ye; y >= ys; y--, ml--) { - if (bcmp((char*)ml->image, blank, p->w_width)) + if (bcmp((char*)ml->image, blank, p->w_width * sizeof(int))) break; if (ml->attr != null && bcmp((char*)ml->attr, null, p->w_width)) break; diff --git a/src/display.c b/src/display.c index 5fa11cb..a967e66 100644 --- a/src/display.c +++ b/src/display.c @@ -595,7 +595,7 @@ int c; # ifdef UTF8 if (D_encoding == UTF8) { - c = (c & 255) | (unsigned char)D_rend.font << 8; + c = (c & 255) | (unsigned int )D_rend.font << 8; # ifdef DW_CHARS if (D_mbcs) { diff --git a/src/encoding.c b/src/encoding.c index 6c1567a..c8b3d1a 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -1,4 +1,12 @@ -/* Copyright (c) 1993-2003 +/* Copyright (c) 2010 + * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) + * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net) + * Copyright (c) 2008, 2009 + * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) + * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) + * Micah Cowan (micah@cowan.name) + * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net) + * Copyright (c) 1993-2003 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) * Copyright (c) 1987 Oliver Laumann @@ -542,20 +550,20 @@ int from, to; if (from == to || (from != UTF8 && to != UTF8) || w == 0) return ml; - if (ml->font == null && encodings[from].deffont == 0) + if (ml->font == (unsigned int *)null && encodings[from].deffont == 0) return ml; if (w > maxlen) { for (i = 0; i < 2; i++) { if (rml[i].image == 0) - rml[i].image = malloc(w); + rml[i].image = malloc(w * sizeof(int)); else - rml[i].image = realloc(rml[i].image, w); + rml[i].image = realloc(rml[i].image, w * sizeof(int)); if (rml[i].font == 0) - rml[i].font = malloc(w); + rml[i].font = malloc(w * sizeof(int)); else - rml[i].font = realloc(rml[i].font, w); + rml[i].font = realloc(rml[i].font, w * sizeof(int)); if (rml[i].image == 0 || rml[i].font == 0) { maxlen = 0; @@ -639,29 +647,93 @@ struct combchar { }; struct combchar **combchars; +/** Thank you Ken! http://www.cl.cam.ac.uk/~mgk25/ucs/utf-8-history.txt */ +typedef struct +{ + int cmask; + int cval; + int shift; + long lmask; + long lval; +} Tab; + +static Tab tab[] = +{ + 0x80, 0x00, 0*6, 0x7F, 0, /* 1 byte sequence */ + 0xE0, 0xC0, 1*6, 0x7FF, 0x80, /* 2 byte sequence */ + 0xF0, 0xE0, 2*6, 0xFFFF, 0x800, /* 3 byte sequence */ + 0xF8, 0xF0, 3*6, 0x1FFFFF, 0x10000, /* 4 byte sequence */ + 0xFC, 0xF8, 4*6, 0x3FFFFFF, 0x200000, /* 5 byte sequence */ + 0xFE, 0xFC, 5*6, 0x7FFFFFFF, 0x4000000, /* 6 byte sequence */ + 0, /* end of table */ +}; + +#define FOR_EACH_BYTE_IN_UTF8(c, bytefn, combfn) do \ + { \ + int byte = 0; \ + if (c >= 0xe000) \ + { \ + int _tm = 0; \ + Tab *_t; \ + for (_t = tab; _t->cmask; _t++) \ + { \ + if (c <= _t->lmask) \ + { \ + _tm = _t->shift; \ + byte = _t->cval | (c>>_tm); \ + bytefn \ + while (_tm > 0) \ + { \ + _tm -= 6; \ + byte = 0x80 | ((c>>_tm) & 0x3F); \ + bytefn \ + } \ + break; \ + } \ + } \ + break; \ + } \ + \ + if (c >= 0xd800 && c < 0xe000 && combchars && combchars[c - 0xd800]) \ + { \ + combfn \ + } \ + if (c >= 0x800) \ + { \ + byte = (c & 0xf000) >> 12 | 0xe0; \ + bytefn \ + c = (c & 0x0fff) | 0x1000; \ + } \ + if (c >= 0x80) \ + { \ + byte = (c & 0x1fc0) >> 6 ^ 0xc0; \ + bytefn \ + c = (c & 0x3f) | 0x80; \ + } \ + byte = c; \ + bytefn \ + } while (0) + void AddUtf8(c) int c; { ASSERT(D_encoding == UTF8); - if (c >= 0xd800 && c < 0xe000 && combchars && combchars[c - 0xd800]) + + FOR_EACH_BYTE_IN_UTF8(c, + { + AddChar(byte); + }, { AddUtf8(combchars[c - 0xd800]->c1); c = combchars[c - 0xd800]->c2; } - if (c >= 0x800) - { - AddChar((c & 0xf000) >> 12 | 0xe0); - c = (c & 0x0fff) | 0x1000; - } - if (c >= 0x80) - { - AddChar((c & 0x1fc0) >> 6 ^ 0xc0); - c = (c & 0x3f) | 0x80; - } - AddChar(c); + ); } +#if 0 +/* It feels like a good idea to simply use one ToUtf8, instead of having both + * ToUtf8_comb and ToUtf8. */ int ToUtf8_comb(p, c) char *p; @@ -676,29 +748,27 @@ int c; } return ToUtf8(p, c); } +#endif int ToUtf8(p, c) char *p; int c; { - int l = 1; - if (c >= 0x800) + int l = 0; + FOR_EACH_BYTE_IN_UTF8(c, { if (p) - *p++ = (c & 0xf000) >> 12 | 0xe0; + *p++ = byte; l++; - c = (c & 0x0fff) | 0x1000; - } - if (c >= 0x80) + }, { + l += ToUtf8(p, combchars[c - 0xd800]->c1); + c = combchars[c - 0xd800]->c2; if (p) - *p++ = (c & 0x1fc0) >> 6 ^ 0xc0; - l++; - c = (c & 0x3f) | 0x80; + p += l; } - if (p) - *p++ = c; + ); return l; } @@ -758,8 +828,6 @@ int c, *utf8charp; *utf8charp = utf8char = (c & 0x80000000) ? c : 0; if (utf8char) return -1; - if (c & 0xffff0000) - c = UCS_REPL; /* sorry, only know 16bit Unicode */ if (c >= 0xd800 && (c <= 0xdfff || c == 0xfffe || c == 0xffff)) c = UCS_REPL; /* illegal code */ return c; @@ -803,7 +871,7 @@ int encoding; #else ml = &p->w_mlines[j]; #endif - if (ml->font == null && encodings[p->w_encoding].deffont == 0) + if (ml->font == (unsigned int *)null && encodings[p->w_encoding].deffont == 0) continue; for (i = 0; i < p->w_width; i++) { @@ -812,11 +880,11 @@ int encoding; c |= encodings[p->w_encoding].deffont << 8; if (c < 256) continue; - if (ml->font == null) + if (ml->font == (unsigned int *)null) { - if ((ml->font = (unsigned char *)calloc(p->w_width + 1, 1)) == 0) + if ((ml->font = (unsigned int *)calloc(p->w_width + 1, sizeof(int))) == 0) { - ml->font = null; + ml->font = (unsigned int *)null; break; } } @@ -1350,6 +1418,9 @@ int *fontp; #ifdef UTF8 if (encoding == UTF8) { +#if 0 + /* We didn't use to handle 16+bit unicode correctly. But since now we do (in ToUtf8), + * do we need this? */ if (f) { # ifdef DW_CHARS @@ -1366,6 +1437,7 @@ int *fontp; c = recode_char_to_encoding(c, encoding); } } +#endif return ToUtf8(bp, c); } if ((c & 0xff00) && f == 0) /* is_utf8? */ @@ -1612,7 +1684,8 @@ struct mline *ml; int xs, xe; int encoding; { - unsigned char *f, *i; + unsigned int *f; + unsigned int *i; int c, x, dx; if (encoding == UTF8 || encodings[encoding].deffont == 0) diff --git a/src/fileio.c b/src/fileio.c index 88fbf64..5f17327 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -408,6 +408,7 @@ int dump; */ register int i, j, k; register char *p; + register int *pi; register FILE *f; char fnbuf[1024]; char *mode = "w"; @@ -528,27 +529,30 @@ int dump; } if (dump == DUMP_SCROLLBACK) { +#define DUMP_LINE(line) do \ + { \ + pi = (line)->image; \ + for (k = fore->w_width - 1; k >= 0 && pi[k] == ' '; k--) \ + ; \ + for (j = 0; j <= k; j++) \ + { \ + unsigned char str[16]; \ + int l = EncodeChar(str, pi[j], fore->w_encoding, 0), ll; \ + for (ll = 0; ll < l; ll++) \ + putc(str[ll], f); \ + if (j < k && dw_left((line), j, fore->w_encoding)) \ + j++; \ + } \ + putc('\n', f); \ + } while (0) + #ifdef COPY_PASTE for (i = 0; i < fore->w_histheight; i++) - { - p = (char *)(WIN(i)->image); - for (k = fore->w_width - 1; k >= 0 && p[k] == ' '; k--) - ; - for (j = 0; j <= k; j++) - putc(p[j], f); - putc('\n', f); - } + DUMP_LINE(WIN(i)); #endif } for (i = 0; i < fore->w_height; i++) - { - p = (char *)fore->w_mlines[i].image; - for (k = fore->w_width - 1; k >= 0 && p[k] == ' '; k--) - ; - for (j = 0; j <= k; j++) - putc(p[j], f); - putc('\n', f); - } + DUMP_LINE(fore->w_mlines + i); break; case DUMP_TERMCAP: if ((p = index(MakeTermcap(fore->w_aflag), '=')) != NULL) diff --git a/src/image.h b/src/image.h index c105949..a06c95b 100644 --- a/src/image.h +++ b/src/image.h @@ -56,18 +56,18 @@ #endif struct mchar { - unsigned char image; + unsigned int image; unsigned char attr; -IFFONT( unsigned char font; ) +IFFONT( unsigned int font; ) IFCOLOR( unsigned char color; ) IFCOLORX(unsigned char colorx; ) -IFDWCHAR(unsigned char mbcs; ) +IFDWCHAR(unsigned int mbcs; ) }; struct mline { - unsigned char *image; + unsigned int *image; unsigned char *attr; -IFFONT( unsigned char *font; ) +IFFONT( unsigned int *font; ) IFCOLOR( unsigned char *color; ) IFCOLORX(unsigned char *colorx; ) }; @@ -75,25 +75,25 @@ IFCOLORX(unsigned char *colorx; ) #define save_mline(ml, n) do { \ - bcopy((char *)(ml)->image, (char *)mline_old.image, (n)); \ + bcopy((char *)(ml)->image, (char *)mline_old.image, (n) * sizeof(int)); \ bcopy((char *)(ml)->attr, (char *)mline_old.attr, (n)); \ -IFFONT( bcopy((char *)(ml)->font, (char *)mline_old.font, (n)); ) \ +IFFONT( bcopy((char *)(ml)->font, (char *)mline_old.font, (n) * sizeof(int)); ) \ IFCOLOR( bcopy((char *)(ml)->color, (char *)mline_old.color, (n)); ) \ IFCOLORX(bcopy((char *)(ml)->colorx, (char *)mline_old.colorx, (n)); ) \ } while (0) #define bcopy_mline(ml, xf, xt, n) do { \ - bcopy((char *)(ml)->image + (xf), (char *)(ml)->image + (xt), (n)); \ + bcopy((char *)((ml)->image + (xf)), (char *)((ml)->image + (xt)), (n) * sizeof(int)); \ bcopy((char *)(ml)->attr + (xf), (char *)(ml)->attr + (xt), (n)); \ -IFFONT( bcopy((char *)(ml)->font + (xf), (char *)(ml)->font + (xt), (n)); ) \ +IFFONT( bcopy((char *)((ml)->font + (xf)), (char *)((ml)->font + (xt)), (n) * sizeof(int)); ) \ IFCOLOR( bcopy((char *)(ml)->color + (xf), (char *)(ml)->color + (xt), (n)); ) \ IFCOLORX(bcopy((char *)(ml)->colorx + (xf), (char *)(ml)->colorx + (xt), (n));) \ } while (0) #define clear_mline(ml, x, n) do { \ - bclear((char *)(ml)->image + (x), (n)); \ + bclear((char *)((ml)->image + (x)), (n) * sizeof(int)); \ if ((ml)->attr != null) bzero((char *)(ml)->attr + (x), (n)); \ -IFFONT( if ((ml)->font != null) bzero((char *)(ml)->font + (x), (n)); ) \ +IFFONT( if ((unsigned char*)(ml)->font != null) bzero((char *)((ml)->font + (x)), (n) * sizeof(int)); ) \ IFCOLOR( if ((ml)->color!= null) bzero((char *)(ml)->color + (x), (n)); ) \ IFCOLORX(if ((ml)->colorx!= null) bzero((char *)(ml)->colorx + (x), (n)); ) \ } while (0) diff --git a/src/layer.c b/src/layer.c index aeea318..d581671 100644 --- a/src/layer.c +++ b/src/layer.c @@ -1266,7 +1266,7 @@ int pause; if (layer->l_encoding == UTF8 && xe < vp->v_xe && win) { struct mline *ml = win->w_mlines + line; - if (dw_left(ml, xe, UTF8)) + if (utf8_isdouble(ml->image[xe])) xe++; } #endif @@ -116,7 +116,7 @@ linestart(y) int y; { register int x; - register unsigned char *i; + register unsigned int *i; for (x = markdata->left_mar, i = WIN(y)->image + x; x < fore->w_width - 1; x++) if (*i++ != ' ') @@ -131,7 +131,7 @@ lineend(y) int y; { register int x; - register unsigned char *i; + register unsigned int *i; for (x = markdata->right_mar, i = WIN(y)->image + x; x >= 0; x--) if (*i-- != ' ') @@ -153,15 +153,15 @@ nextchar(int *xp, int *yp, int direction, char target, int num) int x; /* x coordinate of the current cursor position. */ int step; /* amount to increment x (+1 or -1) */ int adjust; /* Final adjustment of cursor position. */ - char *displayed_line; /* Line in which search takes place. */ - + int *displayed_line; /* Line in which search takes place. */ + debug("nextchar\n"); - + x = *xp; adjust = 0; width = fore->w_width; - displayed_line = (char *)WIN(*yp) -> image; - + displayed_line = WIN(*yp) -> image; + switch(direction) { case 't': adjust = -1; /* fall through */ @@ -176,13 +176,13 @@ nextchar(int *xp, int *yp, int direction, char target, int num) default: ASSERT(0); } - + x += step; - + debug1("ml->image = %s\n", displayed_line); debug2("num = %d, width = %d\n",num, width); debug2("x = %d target = %c\n", x, target ); - + for ( ;x>=0 && x <= width; x += step) { if (displayed_line[x] == target) { if (--num == 0) { @@ -279,11 +279,11 @@ char *pt; { int i, j, from, to, ry, c; int l = 0; - unsigned char *im; + unsigned int *im; struct mline *ml; #ifdef FONT int cf, font; - unsigned char *fo; + unsigned int *fo; #endif markdata->second = 0; @@ -335,16 +335,16 @@ char *pt; #endif for (; j <= to; j++) { - c = (unsigned char)*im++; + c = (unsigned int)*im++; #ifdef FONT - cf = (unsigned char)*fo++; + cf = (unsigned int)*fo++; # ifdef UTF8 if (fore->w_encoding == UTF8) { c |= cf << 8; if (c == UCS_HIDDEN) continue; - c = ToUtf8_comb(pt, c); + c = ToUtf8(pt, c); l += c; if (pt) pt += c; @@ -354,7 +354,7 @@ char *pt; # ifdef DW_CHARS if (is_dw_font(cf)) { - c = c << 8 | (unsigned char)*im++; + c = c << 8 | (unsigned int)*im++; fo++; j++; } @@ -443,7 +443,7 @@ int GetHistory() /* return value 1 if copybuffer changed */ { int i = 0, q = 0, xx, yy, x, y; - unsigned char *linep; + unsigned int *linep; struct mline *ml; ASSERT(display && fore); @@ -474,13 +474,13 @@ GetHistory() /* return value 1 if copybuffer changed */ return 0; if (D_user->u_plop.buf) UserFreeCopyBuffer(D_user); - if ((D_user->u_plop.buf = (char *)malloc((unsigned) (i - x + 2))) == NULL) + if ((D_user->u_plop.buf = (char *)malloc((unsigned) (i - x + 2) * sizeof (int))) == NULL) { LMsg(0, "Not enough memory... Sorry."); return 0; } - bcopy((char *)linep - i + x + 1, D_user->u_plop.buf, i - x + 1); - D_user->u_plop.len = i - x + 1; + bcopy((char *)(linep - i + x + 1), D_user->u_plop.buf, (i - x + 1) * sizeof(int)); + D_user->u_plop.len = (i - x + 1) * sizeof(int); #ifdef ENCODINGS D_user->u_plop.enc = fore->w_encoding; #endif @@ -1112,7 +1112,7 @@ int tx, ty, line; int x, y, t, revst, reven, qq, ff, tt, st, en, ce = 0; int ystart = 0, yend = fore->w_height-1; int i, ry; - unsigned char *wi; + unsigned int *wi; struct mline *ml; struct mchar mc; @@ -1295,7 +1295,7 @@ int isblank; { int wy, x, i, rm; int sta, sto, cp; /* NOTE: these 3 are in WINDOW coords system */ - unsigned char *wi; + unsigned int *wi; struct mline *ml; struct mchar mchar_marked; @@ -1384,7 +1384,7 @@ int ry, xs, xe, doit; struct mchar *rend; { int dx, x, y, st, en, t, rm; - unsigned char *i; + unsigned int *i; struct mline *ml; struct mchar mchar_marked; diff --git a/src/resize.c b/src/resize.c index 7516751..1bbd169 100644 --- a/src/resize.c +++ b/src/resize.c @@ -45,14 +45,15 @@ static void CheckMaxSize __P((int)); static void FreeMline __P((struct mline *)); static int AllocMline __P((struct mline *ml, int)); -static void MakeBlankLine __P((unsigned char *, int)); +static void MakeBlankLine __P((unsigned int *, int)); static void kaablamm __P((void)); static int BcopyMline __P((struct mline *, int, struct mline *, int, int, int)); static void SwapAltScreen __P((struct win *)); extern struct layer *flayer; extern struct display *display, *displays; -extern unsigned char *blank, *null; +extern unsigned char *null; +extern unsigned int *blank; extern struct mline mline_blank, mline_null, mline_old; extern struct win *windows; extern int Z0width, Z1width; @@ -63,10 +64,10 @@ struct winsize glwz; #endif static struct mline mline_zero = { - (unsigned char *)0, + (unsigned int *)0, (unsigned char *)0 #ifdef FONT - ,(unsigned char *)0 + ,(unsigned int *)0 #endif #ifdef COLOR ,(unsigned char *)0 @@ -426,7 +427,7 @@ struct mline *ml; if (ml->attr && ml->attr != null) free(ml->attr); #ifdef FONT - if (ml->font && ml->font != null) + if (ml->font && ml->font != (unsigned int *)null) free(ml->font); #endif #ifdef COLOR @@ -445,10 +446,10 @@ AllocMline(ml, w) struct mline *ml; int w; { - ml->image = malloc(w); + ml->image = malloc(w * sizeof(int)); ml->attr = null; #ifdef FONT - ml->font = null; + ml->font = (unsigned int *)null; #endif #ifdef COLOR ml->color = null; @@ -469,7 +470,7 @@ int xf, xt, l, w; { int r = 0; - bcopy((char *)mlf->image + xf, (char *)mlt->image + xt, l); + bcopy((char *)(mlf->image + xf), (char *)(mlt->image + xt), l * sizeof(int)); if (mlf->attr != null && mlt->attr == null) { if ((mlt->attr = (unsigned char *)calloc(w, 1)) == 0) @@ -478,13 +479,13 @@ int xf, xt, l, w; if (mlt->attr != null) bcopy((char *)mlf->attr + xf, (char *)mlt->attr + xt, l); #ifdef FONT - if (mlf->font != null && mlt->font == null) + if (mlf->font != (unsigned int *)null && mlt->font == (unsigned int *)null) { - if ((mlt->font = (unsigned char *)calloc(w, 1)) == 0) - mlt->font = null, r = -1; + if ((mlt->font = (unsigned int *)calloc(w, sizeof(int))) == 0) + mlt->font = (unsigned int *)null, r = -1; } - if (mlt->font != null) - bcopy((char *)mlf->font + xf, (char *)mlt->font + xt, l); + if (mlt->font != (unsigned int *)null) + bcopy((char *)(mlf->font + xf), (char *)(mlt->font + xt), l * sizeof(int)); #endif #ifdef COLOR if (mlf->color != null && mlt->color == null) @@ -515,7 +516,7 @@ CheckMaxSize(wi) int wi; { unsigned char *oldnull = null; - unsigned char *oldblank = blank; + unsigned int *oldblank = blank; struct win *p; int i; struct mline *ml; @@ -525,12 +526,12 @@ int wi; return; maxwidth = wi; debug1("New maxwidth: %d\n", maxwidth); - blank = (unsigned char *)xrealloc((char *)blank, maxwidth); - null = (unsigned char *)xrealloc((char *)null, maxwidth); - mline_old.image = (unsigned char *)xrealloc((char *)mline_old.image, maxwidth); + blank = (unsigned int *)xrealloc((char *)blank, maxwidth * sizeof(int)); + null = (unsigned char *)xrealloc((char *)null, maxwidth * sizeof(int)); + mline_old.image = (unsigned int *)xrealloc((char *)mline_old.image, maxwidth * sizeof(int)); mline_old.attr = (unsigned char *)xrealloc((char *)mline_old.attr, maxwidth); #ifdef FONT - mline_old.font = (unsigned char *)xrealloc((char *)mline_old.font, maxwidth); + mline_old.font = (unsigned int *)xrealloc((char *)mline_old.font, maxwidth * sizeof(int)); #endif #ifdef COLOR mline_old.color = (unsigned char *)xrealloc((char *)mline_old.color, maxwidth); @@ -542,15 +543,15 @@ int wi; Panic(0, "%s", strnomem); MakeBlankLine(blank, maxwidth); - bzero((char *)null, maxwidth); + bzero((char *)null, maxwidth * sizeof(int)); mline_blank.image = blank; mline_blank.attr = null; - mline_null.image = null; + mline_null.image = (unsigned int *)null; mline_null.attr = null; #ifdef FONT - mline_blank.font = null; - mline_null.font = null; + mline_blank.font = (unsigned int *)null; + mline_null.font = (unsigned int *)null; #endif #ifdef COLOR mline_blank.color = null; @@ -561,7 +562,7 @@ int wi; # endif #endif -#define RESET_AFC(x, bl) do { if (x == old##bl) x = bl; } while (0) +#define RESET_AFC(x, bl) do { if (x == (void *)old##bl) x = (void *)bl; } while (0) #define RESET_LINES(lines, count) \ do { \ @@ -610,7 +611,7 @@ int len; static void MakeBlankLine(p, n) -register unsigned char *p; +register unsigned int *p; register int n; { while (n--) @@ -817,7 +818,7 @@ int wi, he, hi; { if (AllocMline(mlt, wi + 1)) goto nomem; - MakeBlankLine(mlt->image + lt, wi - lt); + MakeBlankLine(mlt->image + lt, wi - lt); mlt->image[wi] = ((oty == ty) ? ' ' : 0); } if (BcopyMline(mlf, lf - lx, mlt, lt - lx, lx, wi + 1)) diff --git a/src/search.c b/src/search.c index cd2693e..7d49027 100644 --- a/src/search.c +++ b/src/search.c @@ -137,7 +137,8 @@ matchword(pattern, y, sx, ex) char *pattern; int y, sx, ex; { - unsigned char *ip, *ipe, *cp, *pp; + unsigned int *ip, *ipe, *cp; + unsigned char *pp; struct mline *ml; /* *sigh* to make WIN work */ @@ -189,7 +190,8 @@ int l, p, end, dir; { int tab[256]; int i, q; - unsigned char *s, c; + unsigned char *s; + unsigned int c; int w = flayer->l_width; /* *sigh* to make WIN work */ diff --git a/src/window.c b/src/window.c index 55bcf5d..9a0df28 100644 --- a/src/window.c +++ b/src/window.c @@ -398,9 +398,10 @@ int y, x1, x2, doit; struct mchar *rend; { register int cost, dx; - register unsigned char *p, *i; + register unsigned char *p; + register unsigned int *i; #ifdef FONT - register unsigned char *f; + register unsigned int *f; #endif #ifdef COLOR register unsigned char *c; |