aboutsummaryrefslogtreecommitdiffstats
path: root/buffer.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2003-01-25 17:42:17 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2003-01-25 17:42:17 +0000
commit6e58e83e1237f1d9ba3dda1aa0cb054253bc4d0e (patch)
treecbccee3a42bd309dd2fe85a5dbbb1b12ba29bfb7 /buffer.c
parentfix indent (diff)
downloadw3m-6e58e83e1237f1d9ba3dda1aa0cb054253bc4d0e.tar.gz
w3m-6e58e83e1237f1d9ba3dda1aa0cb054253bc4d0e.zip
[w3m-dev 03686] Re: fold patch
* buffer.c (writeBufferCache): rewrite (readBufferCache): rewrite * etc.c (calcPosition): short -> int realColumn * fm.h (Line): short -> int len,width,size,bpos,bwidth (BufferPoint): short->int pos (Buffer): short->int currentColumn,pos,visualpos (BufferPos): short->int currentColumn,pos * frame.h (frameset_queue): short->int pos,currentColumn * main.c (clear_mark): short->int pos (dispincsrch): short->int pos (backBf): short->int pos (set_buffer_environ): short->int prev_pos From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/buffer.c b/buffer.c
index de1908f..e4b929b 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1,4 +1,4 @@
-/* $Id: buffer.c,v 1.22 2003/01/24 17:30:50 ukai Exp $ */
+/* $Id: buffer.c,v 1.23 2003/01/25 17:42:17 ukai Exp $ */
#include "fm.h"
#ifdef USE_MOUSE
@@ -637,16 +637,25 @@ writeBufferCache(Buffer *buf)
fwrite1(l->usrflags, cache) ||
fwrite1(l->width, cache) ||
fwrite1(l->len, cache) ||
- fwrite(l->lineBuf, 1, l->len, cache) < l->len ||
- fwrite(l->propBuf, sizeof(Lineprop), l->len, cache) < l->len)
+ fwrite1(l->size, cache) ||
+ fwrite1(l->bpos, cache) ||
+ fwrite1(l->bwidth, cache))
goto _error;
+ if (l->bpos == 0) {
+ if (fwrite(l->lineBuf, 1, l->size, cache) < l->size ||
+ fwrite(l->propBuf, sizeof(Lineprop), l->size, cache) < l->size)
+ goto _error;
+ }
#ifdef USE_ANSI_COLOR
colorflag = l->colorBuf ? 1 : 0;
if (fwrite1(colorflag, cache))
goto _error;
if (colorflag) {
- if (fwrite(l->colorBuf, sizeof(Linecolor), l->len, cache) < l->len)
- goto _error;
+ if (l->bpos == 0) {
+ if (fwrite(l->colorBuf, sizeof(Linecolor), l->size, cache) <
+ l->size)
+ goto _error;
+ }
}
#endif
}
@@ -665,7 +674,7 @@ int
readBufferCache(Buffer *buf)
{
FILE *cache;
- Line *l = NULL, *prevl = NULL;
+ Line *l = NULL, *prevl = NULL, *basel = NULL;
long lnum = 0, clnum, tlnum;
#ifdef USE_ANSI_COLOR
int colorflag;
@@ -696,19 +705,36 @@ readBufferCache(Buffer *buf)
buf->topLine = l;
if (fread1(l->real_linenumber, cache) ||
fread1(l->usrflags, cache) ||
- fread1(l->width, cache) || fread1(l->len, cache))
+ fread1(l->width, cache) ||
+ fread1(l->len, cache) ||
+ fread1(l->size, cache) ||
+ fread1(l->bpos, cache) ||
+ fread1(l->bwidth, cache))
+ break;
+ if (l->bpos == 0) {
+ basel = l;
+ l->lineBuf = NewAtom_N(char, l->size + 1);
+ fread(l->lineBuf, 1, l->size, cache);
+ l->lineBuf[l->size] = '\0';
+ l->propBuf = NewAtom_N(Lineprop, l->size);
+ fread(l->propBuf, sizeof(Lineprop), l->size, cache);
+ }
+ else if (basel) {
+ l->lineBuf = basel->lineBuf + l->bpos;
+ l->propBuf = basel->propBuf + l->bpos;
+ }
+ else
break;
- l->lineBuf = NewAtom_N(char, l->len + 1);
- fread(l->lineBuf, 1, l->len, cache);
- l->lineBuf[l->len] = '\0';
- l->propBuf = NewAtom_N(Lineprop, l->len);
- fread(l->propBuf, sizeof(Lineprop), l->len, cache);
#ifdef USE_ANSI_COLOR
if (fread1(colorflag, cache))
break;
if (colorflag) {
- l->colorBuf = NewAtom_N(Linecolor, l->len);
- fread(l->colorBuf, sizeof(Linecolor), l->len, cache);
+ if (l->bpos == 0) {
+ l->colorBuf = NewAtom_N(Linecolor, l->size);
+ fread(l->colorBuf, sizeof(Linecolor), l->size, cache);
+ }
+ else
+ l->colorBuf = basel->colorBuf + l->bpos;
}
else {
l->colorBuf = NULL;