commit 5bcc05f1675deb6f7a7a9f2c5b164f7cd392a4cd
parent b445c1295c4d50023d4b713f0089b2966ef4b2fe
Author: ukai <ukai>
Date: Sat, 25 Jan 2003 17:42:17 +0000
[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:
6 files changed, 75 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,19 @@
+2003-01-26 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
+ * [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
+
2003-01-25 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03684] Re: fold patch
diff --git a/buffer.c b/buffer.c
@@ -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;
diff --git a/etc.c b/etc.c
@@ -481,7 +481,7 @@ checkType(Str s, Lineprop **oprop
int
calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
{
- static short *realColumn = NULL;
+ static int *realColumn = NULL;
static int size = 0;
static char *prevl = NULL;
int i, j;
@@ -494,7 +494,7 @@ calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
}
if (size < len + 1) {
size = (len + 1 > LINELEN) ? (len + 1) : LINELEN;
- realColumn = New_Reuse(short, realColumn, size);
+ realColumn = New_Reuse(int, realColumn, size);
}
prevl = l;
j = bpos;
diff --git a/fm.h b/fm.h
@@ -310,19 +310,19 @@ typedef struct _Line {
#endif
struct _Line *next;
struct _Line *prev;
- short len;
- short width;
+ int len;
+ int width;
long linenumber; /* on buffer */
long real_linenumber; /* on file */
unsigned short usrflags;
- short size;
- short bpos;
- short bwidth;
+ int size;
+ int bpos;
+ int bwidth;
} Line;
typedef struct {
int line;
- short pos;
+ int pos;
} BufferPoint;
#ifdef USE_IMAGE
@@ -413,11 +413,11 @@ typedef struct _Buffer {
char *real_type;
int allLine;
short bufferprop;
- short currentColumn;
+ int currentColumn;
short cursorX;
short cursorY;
- short pos;
- short visualpos;
+ int pos;
+ int visualpos;
short rootX;
short rootY;
short COLS;
@@ -469,8 +469,8 @@ typedef struct _Buffer {
typedef struct _BufferPos {
long top_linenumber;
long cur_linenumber;
- short currentColumn;
- short pos;
+ int currentColumn;
+ int pos;
struct _BufferPos *next;
struct _BufferPos *prev;
} BufferPos;
diff --git a/frame.h b/frame.h
@@ -54,8 +54,8 @@ struct frameset_queue {
struct frameset *frameset;
long linenumber;
long top_linenumber;
- short pos;
- short currentColumn;
+ int pos;
+ int currentColumn;
struct _anchorList *formitem;
};
diff --git a/main.c b/main.c
@@ -1545,7 +1545,7 @@ rdrwSc(void)
static void
clear_mark(Line *l)
{
- short pos;
+ int pos;
if (!l)
return;
for (pos = 0; pos < l->size; pos++)
@@ -1592,7 +1592,7 @@ dispincsrch(int ch, Str buf, Lineprop *prop)
{
static Buffer sbuf;
static Line *currentLine;
- static short pos;
+ static int pos;
char *str;
int do_next_search = FALSE;
@@ -3770,8 +3770,8 @@ backBf(void)
struct frameset *fs;
long linenumber = buf->frameQ->linenumber;
long top = buf->frameQ->top_linenumber;
- short pos = buf->frameQ->pos;
- short currentColumn = buf->frameQ->currentColumn;
+ int pos = buf->frameQ->pos;
+ int currentColumn = buf->frameQ->currentColumn;
AnchorList *formitem = buf->frameQ->formitem;
fs = popFrameTree(&(buf->frameQ));
@@ -5344,7 +5344,7 @@ set_buffer_environ(Buffer *buf)
{
static Buffer *prev_buf = NULL;
static Line *prev_line = NULL;
- static short prev_pos = -1;
+ static int prev_pos = -1;
Line *l;
if (buf == NULL)