aboutsummaryrefslogtreecommitdiffstats
path: root/etc.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2003-01-30 16:39:29 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2003-01-30 16:39:29 +0000
commit0c0438352c1677443670f1348ddc4c014e4a3ffa (patch)
tree5ca48b97eeea65f7b12ab1b21842b60c702f18f2 /etc.c
parent[w3m-dev 03717] print newline before exec shell command. (diff)
downloadw3m-0c0438352c1677443670f1348ddc4c014e4a3ffa.tar.gz
w3m-0c0438352c1677443670f1348ddc4c014e4a3ffa.zip
[w3m-dev 03718] Too slow when loading big file with fold_line=1
* etc.c (nextColumn): added (calcPosition): use New_N rewrite with nextColumn (columnLen): added * file.c (addnewline): rewrite with columnLen * proto.h (columnLen): added From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r--etc.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/etc.c b/etc.c
index 13adf25..27caa3b 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.61 2003/01/29 17:10:30 ukai Exp $ */
+/* $Id: etc.c,v 1.62 2003/01/30 16:39:34 ukai Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -478,6 +478,22 @@ checkType(Str s, Lineprop **oprop
return s;
}
+static int
+nextColumn(int n, char *p, Lineprop *pr)
+{
+ if (*p == '\t' && *pr == PC_CTRL)
+ return (n + Tabstop) / Tabstop * Tabstop;
+#ifndef KANJI_SYMBOLS
+ else if (*pr & PC_RULE)
+ return n + 1;
+#endif
+ else if (IS_UNPRINTABLE_ASCII(*p, *pr))
+ return n + 4;
+ else if (IS_UNPRINTABLE_CONTROL(*p, *pr))
+ return n + 2;
+ return n + 1;
+}
+
int
calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
{
@@ -494,7 +510,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(int, realColumn, size);
+ realColumn = New_N(int, size);
}
prevl = l;
j = bpos;
@@ -502,24 +518,31 @@ calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
realColumn[i] = j;
if (i == len)
break;
- if (l[i] == '\t' && pr[i] == PC_CTRL)
- j = (j + Tabstop) / Tabstop * Tabstop;
-#ifndef KANJI_SYMBOLS
- else if (pr[i] & PC_RULE)
- j++;
-#endif
- else if (IS_UNPRINTABLE_ASCII(l[i], pr[i]))
- j = j + 4;
- else if (IS_UNPRINTABLE_CONTROL(l[i], pr[i]))
- j = j + 2;
- else
- j++;
+ j = nextColumn(j, &l[i], &pr[i]);
}
if (pos >= i)
return j;
return realColumn[pos];
}
+int
+columnLen(Line *line, int column)
+{
+ int i, j;
+
+ for (i = 0, j = 0; i < line->len; i++) {
+ j = nextColumn(j, &line->lineBuf[i], &line->propBuf[i]);
+ if (j > column) {
+#ifdef JP_CHARSET
+ if (CharType(line->propBuf[i]) == PC_KANJI2)
+ return i - 1;
+#endif
+ return i;
+ }
+ }
+ return line->len;
+}
+
char *
lastFileName(char *path)
{