[w3m-dev 02586] code cleanup again

From: Fumitoshi UKAI <ukai@debian.or.jp>
This commit is contained in:
Fumitoshi UKAI
2001-11-29 10:22:58 +00:00
parent c33cdfcd56
commit e0f9c00f5e
8 changed files with 129 additions and 100 deletions
+1 -1
View File
@@ -10,4 +10,4 @@ mktable
w3m w3m
w3mbookmark w3mbookmark
w3mhelperpanel w3mhelperpanel
_zdmachdep.c _zmachdep.c
+26
View File
@@ -1,5 +1,31 @@
2001-11-29 Fumitoshi UKAI <ukai@debian.or.jp> 2001-11-29 Fumitoshi UKAI <ukai@debian.or.jp>
* [w3m-dev 02586]
* configure: typo s/_zdmachdep.c/zmachdep.c/
* fix shadow variable
* main.c (HTMLtagproc1): s/refresh/refresh_interval/
* matrix.c (LUfactor): s/index/indexarray/
* matrix.c (LUsolve): ditto
* matrix.c (m_inverse): ditto
* matrix.c (LUinverse): ditto
* table.c (bsearch_2short): ditto
* table.c (bsearch_double): ditto
* table.c (dv2sv): ditto
* table.c (check_cell_width): ditto
* table.c (set_integered_width): ditto
* table.c (set_table_width): ditto
* table.c (check_table_height): ditto
* ftp.c: s/ftp/current_ftp/
* ftp.c (Ftpfclose): ditto
* ftp.c (openFTP): ditto
* ftp.c (closeFTP): ditto
* ftp.c (FtpLogin): save to current_ftp
* ftp.c (openFTP): s/realpath/realpathname/
* ftp.c (openFTP): remove i
* ftp.c (ftp_pasv): s/sin/sockaddr/
* [w3m-dev 02584] code cleanup * [w3m-dev 02584] code cleanup
* linein.c (_esc): fix #ifdef EMACS_LIKE_LINEEDIT * linein.c (_esc): fix #ifdef EMACS_LIKE_LINEEDIT
Vendored
+2 -2
View File
@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $Id: configure,v 1.25 2001/11/29 09:34:14 ukai Exp $ # $Id: configure,v 1.26 2001/11/29 10:22:58 ukai Exp $
# Configuration. # Configuration.
# #
@@ -1606,7 +1606,7 @@ fi
# check alarm() # check alarm()
if [ "$use_alarm" = y ]; then if [ "$use_alarm" = y ]; then
cat > _zdmachdep.c <<EOF cat > _zmachdep.c <<EOF
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
main() main()
+11 -10
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.17 2001/11/29 09:34:14 ukai Exp $ */ /* $Id: file.c,v 1.18 2001/11/29 10:22:58 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include "myctype.h" #include "myctype.h"
@@ -3598,7 +3598,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
else else
#endif #endif
if (p && q && !strcasecmp(p, "refresh")) { if (p && q && !strcasecmp(p, "refresh")) {
int refresh = atoi(q); int refresh_interval = atoi(q);
Str s_tmp = NULL; Str s_tmp = NULL;
while (*q) { while (*q) {
@@ -3630,28 +3630,29 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
tmp = tmp =
Sprintf Sprintf
("Refresh (%d sec) <a hseq=\"%d\" href=\"%s\">%s</a>", ("Refresh (%d sec) <a hseq=\"%d\" href=\"%s\">%s</a>",
refresh, cur_hseq++, q, q); refresh_interval, cur_hseq++, q, q);
push_str(obuf, s_tmp->length, tmp, PC_ASCII); push_str(obuf, s_tmp->length, tmp, PC_ASCII);
flushline(h_env, obuf, envs[h_env->envc].indent, 0, flushline(h_env, obuf, envs[h_env->envc].indent, 0,
h_env->limit); h_env->limit);
if (!is_redisplay && refresh == 0 && MetaRefresh) { if (!is_redisplay && refresh_interval == 0 && MetaRefresh) {
pushEvent(FUNCNAME_goURL, s_tmp->ptr); pushEvent(FUNCNAME_goURL, s_tmp->ptr);
/* pushEvent(deletePrevBuf,NULL); */ /* pushEvent(deletePrevBuf,NULL); */
} }
#ifdef USE_ALARM #ifdef USE_ALARM
else if (!is_redisplay && refresh > 0 && MetaRefresh) { else if (!is_redisplay && refresh_interval > 0 && MetaRefresh) {
setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_goURL, setAlarmEvent(refresh_interval, AL_IMPLICIT,
s_tmp->ptr); FUNCNAME_goURL, s_tmp->ptr);
} }
#endif #endif
} }
#ifdef USE_ALARM #ifdef USE_ALARM
else if (!is_redisplay && refresh > 0 && MetaRefresh) { else if (!is_redisplay && refresh_interval > 0 && MetaRefresh) {
tmp = Sprintf("Refresh (%d sec)", refresh); tmp = Sprintf("Refresh (%d sec)", refresh_interval);
push_str(obuf, 0, tmp, PC_ASCII); push_str(obuf, 0, tmp, PC_ASCII);
flushline(h_env, obuf, envs[h_env->envc].indent, 0, flushline(h_env, obuf, envs[h_env->envc].indent, 0,
h_env->limit); h_env->limit);
setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_reload, NULL); setAlarmEvent(refresh_interval, AL_IMPLICIT, FUNCNAME_reload,
NULL);
} }
#endif #endif
} }
+43 -43
View File
@@ -1,4 +1,4 @@
/* $Id: ftp.c,v 1.7 2001/11/29 09:34:14 ukai Exp $ */ /* $Id: ftp.c,v 1.8 2001/11/29 10:22:58 ukai Exp $ */
#include <stdio.h> #include <stdio.h>
#include <pwd.h> #include <pwd.h>
#include <Str.h> #include <Str.h>
@@ -32,7 +32,7 @@ typedef struct _FTP {
typedef int STATUS; typedef int STATUS;
static FTP ftp; static FTP current_ftp;
static Str static Str
read_response1(FTP ftp) read_response1(FTP ftp)
@@ -105,7 +105,7 @@ FtpLogin(FTP * ftp_return, char *host, char *user, char *pass)
Str tmp; Str tmp;
FTP ftp = New(struct _FTP); FTP ftp = New(struct _FTP);
int fd; int fd;
*ftp_return = ftp; *ftp_return = current_ftp = ftp;
fd = openSocket(host, "ftp", 21); fd = openSocket(host, "ftp", 21);
if (fd < 0) if (fd < 0)
return -1; return -1;
@@ -191,18 +191,18 @@ ftp_pasv(FTP ftp)
Str tmp; Str tmp;
int family; int family;
#ifdef INET6 #ifdef INET6
struct sockaddr_storage sin; struct sockaddr_storage sockaddr;
int sinlen, port; int sockaddrlen, port;
unsigned char d1, d2, d3, d4; unsigned char d1, d2, d3, d4;
char abuf[INET6_ADDRSTRLEN]; char abuf[INET6_ADDRSTRLEN];
#endif #endif
#ifdef INET6 #ifdef INET6
sinlen = sizeof(sin); sockaddrlen = sizeof(sockaddr);
if (getpeername(fileno(ftp->wcontrol), if (getpeername(fileno(ftp->wcontrol),
(struct sockaddr *)&sin, &sinlen) < 0) (struct sockaddr *)&sockaddr, &sockaddrlen) < 0)
return -1; return -1;
family = sin.ss_family; family = sockaddr.ss_family;
#else #else
family = AF_INET; family = AF_INET;
#endif #endif
@@ -220,7 +220,7 @@ ftp_pasv(FTP ftp)
if (sscanf(++p, "%c%c%c%d%c", &d1, &d2, &d3, &port, &d4) != 5 if (sscanf(++p, "%c%c%c%d%c", &d1, &d2, &d3, &port, &d4) != 5
|| d1 != d2 || d1 != d3 || d1 != d4) || d1 != d2 || d1 != d3 || d1 != d4)
return -1; return -1;
if (getnameinfo((struct sockaddr *)&sin, sinlen, if (getnameinfo((struct sockaddr *)&sockaddr, sockaddrlen,
abuf, sizeof(abuf), NULL, 0, NI_NUMERICHOST) != 0) abuf, sizeof(abuf), NULL, 0, NI_NUMERICHOST) != 0)
return -1; return -1;
tmp = Sprintf("%s", abuf); tmp = Sprintf("%s", abuf);
@@ -296,9 +296,9 @@ int
Ftpfclose(FILE * f) Ftpfclose(FILE * f)
{ {
fclose(f); fclose(f);
if (f == ftp->data) if (f == current_ftp->data)
ftp->data = NULL; current_ftp->data = NULL;
read_response(ftp); read_response(current_ftp);
return 0; return 0;
} }
@@ -403,7 +403,7 @@ openFTP(ParsedURL *pu)
int i, nfile, nfile_max = 100; int i, nfile, nfile_max = 100;
Str pwd = NULL; Str pwd = NULL;
int add_auth_cookie_flag; int add_auth_cookie_flag;
char *realpath = NULL; char *realpathname = NULL;
#ifdef JP_CHARSET #ifdef JP_CHARSET
char code = '\0', ic; char code = '\0', ic;
Str pathStr; Str pathStr;
@@ -446,7 +446,7 @@ openFTP(ParsedURL *pu)
Strcat_char(tmp2, '@'); Strcat_char(tmp2, '@');
pass = tmp2->ptr; pass = tmp2->ptr;
} }
s = FtpLogin(&ftp, pu->host, user, pass); s = FtpLogin(&current_ftp, pu->host, user, pass);
if (FtpError(s)) if (FtpError(s))
return NULL; return NULL;
if (add_auth_cookie_flag) if (add_auth_cookie_flag)
@@ -454,69 +454,69 @@ openFTP(ParsedURL *pu)
if (pu->file == NULL || *pu->file == '\0') if (pu->file == NULL || *pu->file == '\0')
goto ftp_dir; goto ftp_dir;
else else
realpath = file_unquote(pu->file); realpathname = file_unquote(pu->file);
if (pu->file[strlen(pu->file) - 1] == '/') if (pu->file[strlen(pu->file) - 1] == '/')
goto ftp_dir; goto ftp_dir;
/* Get file */ /* Get file */
FtpBinary(ftp); FtpBinary(current_ftp);
if (ftp_pasv(ftp) < 0) { if (ftp_pasv(current_ftp) < 0) {
FtpBye(ftp); FtpBye(current_ftp);
return NULL; return NULL;
} }
s = FtpOpenReadBody(ftp, realpath); s = FtpOpenReadBody(current_ftp, realpathname);
if (!FtpError(s)) { if (!FtpError(s)) {
#ifdef JP_CHARSET #ifdef JP_CHARSET
pathStr = Strnew_charp(realpath); pathStr = Strnew_charp(realpathname);
if ((ic = checkShiftCode(pathStr, code)) != '\0') { if ((ic = checkShiftCode(pathStr, code)) != '\0') {
pathStr = conv_str(pathStr, (code = ic), InnerCode); pathStr = conv_str(pathStr, (code = ic), InnerCode);
realpath = pathStr->ptr; realpathname = pathStr->ptr;
} }
#endif /* JP_CHARSET */ #endif /* JP_CHARSET */
pu->file = realpath; pu->file = realpathname;
return FTPDATA(ftp); return FTPDATA(current_ftp);
} }
goto ftp_dir1; goto ftp_dir1;
/* Get directory */ /* Get directory */
ftp_dir: ftp_dir:
if (ftp_pasv(ftp) < 0) { if (ftp_pasv(current_ftp) < 0) {
FtpBye(ftp); FtpBye(current_ftp);
return NULL; return NULL;
} }
ftp_dir1: ftp_dir1:
pu->scheme = SCM_FTPDIR; pu->scheme = SCM_FTPDIR;
FTPDIRtmp = Strnew(); FTPDIRtmp = Strnew();
sv_type = ftp_system(ftp); sv_type = ftp_system(current_ftp);
if (pu->file == NULL || *pu->file == '\0') { if (pu->file == NULL || *pu->file == '\0') {
if (sv_type == UNIXLIKE_SERVER) { if (sv_type == UNIXLIKE_SERVER) {
s = FtpDataBody(ftp, "LIST", NULL, "r"); s = FtpDataBody(current_ftp, "LIST", NULL, "r");
} }
else { else {
s = FtpDataBody(ftp, "NLST", NULL, "r"); s = FtpDataBody(current_ftp, "NLST", NULL, "r");
} }
curdir = Strnew_charp("/"); curdir = Strnew_charp("/");
} }
else { else {
if (sv_type == UNIXLIKE_SERVER) { if (sv_type == UNIXLIKE_SERVER) {
s = FtpCwd(ftp, realpath); s = FtpCwd(current_ftp, realpathname);
if (!FtpError(s)) { if (!FtpError(s)) {
s = FtpDataBody(ftp, "LIST", NULL, "r"); s = FtpDataBody(current_ftp, "LIST", NULL, "r");
} }
} }
else { else {
s = FtpDataBody(ftp, "NLST %s", realpath, "r"); s = FtpDataBody(current_ftp, "NLST %s", realpathname, "r");
} }
if (realpath[0] == '/') if (realpathname[0] == '/')
curdir = Strnew_charp(realpath); curdir = Strnew_charp(realpathname);
else else
curdir = Sprintf("/%s", realpath); curdir = Sprintf("/%s", realpathname);
if (Strlastchar(curdir) != '/') if (Strlastchar(curdir) != '/')
Strcat_char(curdir, '/'); Strcat_char(curdir, '/');
} }
if (FtpError(s)) { if (FtpError(s)) {
FtpBye(ftp); FtpBye(current_ftp);
return NULL; return NULL;
} }
host = Strnew_charp("ftp://"); host = Strnew_charp("ftp://");
@@ -552,11 +552,11 @@ openFTP(ParsedURL *pu)
nfile = 0; nfile = 0;
if (sv_type == UNIXLIKE_SERVER) { if (sv_type == UNIXLIKE_SERVER) {
char *name, *date, *size, *type_str; char *name, *date, *size, *type_str;
int ftype, max_len, len, i, j; int ftype, max_len, len, j;
Str line_tmp; Str line_tmp;
max_len = 0; max_len = 0;
while (tmp2 = Strfgets(FTPDATA(ftp)), tmp2->length > 0) { while (tmp2 = Strfgets(FTPDATA(current_ftp)), tmp2->length > 0) {
Strchop(tmp2); Strchop(tmp2);
if ((ftype = if ((ftype =
ex_ftpdir_name_size_date(tmp2->ptr, &name, &date, &size)) ex_ftpdir_name_size_date(tmp2->ptr, &name, &date, &size))
@@ -635,7 +635,7 @@ openFTP(ParsedURL *pu)
Strcat_charp(FTPDIRtmp, "</pre></body></html>\n"); Strcat_charp(FTPDIRtmp, "</pre></body></html>\n");
} }
else { else {
while (tmp2 = Strfgets(FTPDATA(ftp)), tmp2->length > 0) { while (tmp2 = Strfgets(FTPDATA(current_ftp)), tmp2->length > 0) {
Strchop(tmp2); Strchop(tmp2);
flist[nfile++] = mybasename(tmp2->ptr); flist[nfile++] = mybasename(tmp2->ptr);
if (nfile == nfile_max) { if (nfile == nfile_max) {
@@ -654,8 +654,8 @@ openFTP(ParsedURL *pu)
Strcat_charp(FTPDIRtmp, "</ul></body></html>\n"); Strcat_charp(FTPDIRtmp, "</ul></body></html>\n");
} }
FtpClose(ftp); FtpClose(current_ftp);
FtpBye(ftp); FtpBye(current_ftp);
return NULL; return NULL;
} }
@@ -841,8 +841,8 @@ closeFTP(FILE * f)
{ {
if (f) { if (f) {
fclose(f); fclose(f);
if (f == ftp->data) if (f == current_ftp->data)
ftp->data = NULL; current_ftp->data = NULL;
} }
FtpBye(ftp); FtpBye(current_ftp);
} }
+11 -11
View File
@@ -1,7 +1,7 @@
/* /*
* matrix.h, matrix.c: Liner equation solver using LU decomposition. * matrix.h, matrix.c: Liner equation solver using LU decomposition.
* $Id: matrix.c,v 1.4 2001/11/16 22:02:00 ukai Exp $ * $Id: matrix.c,v 1.5 2001/11/29 10:22:58 ukai Exp $
* *
* by K.Okabe Aug. 1999 * by K.Okabe Aug. 1999
* *
@@ -67,7 +67,7 @@ static double Tiny = 1.0e-30;
*/ */
int int
LUfactor(Matrix A, int *index) LUfactor(Matrix A, int *indexarray)
{ {
int dim = A->dim, i, j, k, i_max, k_max; int dim = A->dim, i, j, k, i_max, k_max;
Vector scale; Vector scale;
@@ -76,7 +76,7 @@ LUfactor(Matrix A, int *index)
scale = new_vector(dim); scale = new_vector(dim);
for (i = 0; i < dim; i++) for (i = 0; i < dim; i++)
index[i] = i; indexarray[i] = i;
for (i = 0; i < dim; i++) { for (i = 0; i < dim; i++) {
mx = 0.; mx = 0.;
@@ -107,7 +107,7 @@ LUfactor(Matrix A, int *index)
} }
if (i_max != k) { if (i_max != k) {
SWAPI(index[i_max], index[k]); SWAPI(indexarray[i_max], indexarray[k]);
for (j = 0; j < dim; j++) for (j = 0; j < dim; j++)
SWAPD(M_VAL(A, i_max, j), M_VAL(A, k, j)); SWAPD(M_VAL(A, i_max, j), M_VAL(A, k, j));
} }
@@ -126,12 +126,12 @@ LUfactor(Matrix A, int *index)
*/ */
int int
LUsolve(Matrix A, int *index, Vector b, Vector x) LUsolve(Matrix A, int *indexarray, Vector b, Vector x)
{ {
int i, dim = A->dim; int i, dim = A->dim;
for (i = 0; i < dim; i++) for (i = 0; i < dim; i++)
x->ve[i] = b->ve[index[i]]; x->ve[i] = b->ve[indexarray[i]];
if (Lsolve(A, x, x, 1.) == -1 || Usolve(A, x, x, 0.) == -1) if (Lsolve(A, x, x, 1.) == -1 || Usolve(A, x, x, 0.) == -1)
return -1; return -1;
@@ -144,16 +144,16 @@ LUsolve(Matrix A, int *index, Vector b, Vector x)
Matrix Matrix
m_inverse(Matrix A, Matrix out) m_inverse(Matrix A, Matrix out)
{ {
int *index = NewAtom_N(int, A->dim); int *indexarray = NewAtom_N(int, A->dim);
Matrix A1 = new_matrix(A->dim); Matrix A1 = new_matrix(A->dim);
m_copy(A, A1); m_copy(A, A1);
LUfactor(A1, index); LUfactor(A1, indexarray);
return LUinverse(A1, index, out); return LUinverse(A1, indexarray, out);
} }
#endif /* 0 */ #endif /* 0 */
Matrix Matrix
LUinverse(Matrix A, int *index, Matrix out) LUinverse(Matrix A, int *indexarray, Matrix out)
{ {
int i, j, dim = A->dim; int i, j, dim = A->dim;
Vector tmp, tmp2; Vector tmp, tmp2;
@@ -166,7 +166,7 @@ LUinverse(Matrix A, int *index, Matrix out)
for (j = 0; j < dim; j++) for (j = 0; j < dim; j++)
tmp->ve[j] = 0.; tmp->ve[j] = 0.;
tmp->ve[i] = 1.; tmp->ve[i] = 1.;
if (LUsolve(A, index, tmp, tmp2) == -1) if (LUsolve(A, indexarray, tmp, tmp2) == -1)
return NULL; return NULL;
for (j = 0; j < dim; j++) for (j = 0; j < dim; j++)
M_VAL(out, j, i) = tmp2->ve[j]; M_VAL(out, j, i) = tmp2->ve[j];
+32 -31
View File
@@ -1,4 +1,4 @@
/* $Id: table.c,v 1.9 2001/11/29 09:34:15 ukai Exp $ */ /* $Id: table.c,v 1.10 2001/11/29 10:22:58 ukai Exp $ */
/* /*
* HTML table * HTML table
*/ */
@@ -155,7 +155,7 @@ weight3(int x)
static int static int
bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base, bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base,
char *index, int nent) char *indexarray, int nent)
{ {
int n = nent; int n = nent;
int k = 0; int k = 0;
@@ -163,7 +163,7 @@ bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base,
int e = e1 * base + e2; int e = e1 * base + e2;
while (n > 0) { while (n > 0) {
int nn = n / 2; int nn = n / 2;
int idx = index[k + nn]; int idx = indexarray[k + nn];
int ne = ent1[idx] * base + ent2[idx]; int ne = ent1[idx] * base + ent2[idx];
if (ne == e) { if (ne == e) {
k += nn; k += nn;
@@ -181,14 +181,14 @@ bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base,
} }
static int static int
bsearch_double(double e, double *ent, char *index, int nent) bsearch_double(double e, double *ent, char *indexarray, int nent)
{ {
int n = nent; int n = nent;
int k = 0; int k = 0;
while (n > 0) { while (n > 0) {
int nn = n / 2; int nn = n / 2;
int idx = index[k + nn]; int idx = indexarray[k + nn];
double ne = ent[idx]; double ne = ent[idx];
if (ne == e) { if (ne == e) {
k += nn; k += nn;
@@ -234,11 +234,11 @@ static void
dv2sv(double *dv, short *iv, int size) dv2sv(double *dv, short *iv, int size)
{ {
int i, k, iw; int i, k, iw;
char *index; char *indexarray;
double *edv; double *edv;
double w = 0., x; double w = 0., x;
index = NewAtom_N(char, size); indexarray = NewAtom_N(char, size);
edv = NewAtom_N(double, size); edv = NewAtom_N(double, size);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
iv[i] = ceil(dv[i]); iv[i] = ceil(dv[i]);
@@ -249,17 +249,17 @@ dv2sv(double *dv, short *iv, int size)
for (k = 0; k < size; k++) { for (k = 0; k < size; k++) {
x = edv[k]; x = edv[k];
w += x; w += x;
i = bsearch_double(x, edv, index, k); i = bsearch_double(x, edv, indexarray, k);
if (k > i) if (k > i)
bcopy(index + i, index + i + 1, k - i); bcopy(indexarray + i, indexarray + i + 1, k - i);
index[i] = k; indexarray[i] = k;
} }
iw = min((int)(w + 0.5), size); iw = min((int)(w + 0.5), size);
if (iw == 0) if (iw == 0)
return; return;
x = edv[(int)index[iw - 1]]; x = edv[(int)indexarray[iw - 1]];
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
k = index[i]; k = indexarray[i];
if (i >= iw && abs(edv[k] - x) > 1e-6) if (i >= iw && abs(edv[k] - x) > 1e-6)
break; break;
iv[k]--; iv[k]--;
@@ -856,13 +856,13 @@ table_rule_width(struct table *t)
static void static void
check_cell_width(short *tabwidth, short *cellwidth, check_cell_width(short *tabwidth, short *cellwidth,
short *col, short *colspan, short maxcell, short *col, short *colspan, short maxcell,
char *index, int space, int dir) char *indexarray, int space, int dir)
{ {
int i, j, k, bcol, ecol; int i, j, k, bcol, ecol;
int swidth, width; int swidth, width;
for (k = 0; k <= maxcell; k++) { for (k = 0; k <= maxcell; k++) {
j = index[k]; j = indexarray[k];
if (cellwidth[j] <= 0) if (cellwidth[j] <= 0)
continue; continue;
bcol = col[j]; bcol = col[j];
@@ -936,13 +936,13 @@ static void
set_integered_width(struct table *t, double *dwidth, short *iwidth) set_integered_width(struct table *t, double *dwidth, short *iwidth)
{ {
int i, j, k, n, bcol, ecol, step; int i, j, k, n, bcol, ecol, step;
char *index, *fixed; char *indexarray, *fixed;
double *mod; double *mod;
double sum = 0., x = 0.; double sum = 0., x = 0.;
struct table_cell *cell = &t->cell; struct table_cell *cell = &t->cell;
int rulewidth = table_rule_width(t); int rulewidth = table_rule_width(t);
index = NewAtom_N(char, t->maxcol + 1); indexarray = NewAtom_N(char, t->maxcol + 1);
mod = NewAtom_N(double, t->maxcol + 1); mod = NewAtom_N(double, t->maxcol + 1);
for (i = 0; i <= t->maxcol; i++) { for (i = 0; i <= t->maxcol; i++) {
iwidth[i] = ceil_at_intervals(ceil(dwidth[i]), rulewidth); iwidth[i] = ceil_at_intervals(ceil(dwidth[i]), rulewidth);
@@ -953,10 +953,10 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
for (k = 0; k <= t->maxcol; k++) { for (k = 0; k <= t->maxcol; k++) {
x = mod[k]; x = mod[k];
sum += x; sum += x;
i = bsearch_double(x, mod, index, k); i = bsearch_double(x, mod, indexarray, k);
if (k > i) if (k > i)
bcopy(index + i, index + i + 1, k - i); bcopy(indexarray + i, indexarray + i + 1, k - i);
index[i] = k; indexarray[i] = k;
} }
fixed = NewAtom_N(char, t->maxcol + 1); fixed = NewAtom_N(char, t->maxcol + 1);
@@ -969,14 +969,14 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
if (sum < 0.5) if (sum < 0.5)
return; return;
for (n = 0; i + n <= t->maxcol; n++) { for (n = 0; i + n <= t->maxcol; n++) {
int ii = index[i + n]; int ii = indexarray[i + n];
if (n == 0) if (n == 0)
x = mod[ii]; x = mod[ii];
else if (fabs(mod[ii] - x) > 1e-6) else if (fabs(mod[ii] - x) > 1e-6)
break; break;
} }
for (k = 0; k < n; k++) { for (k = 0; k < n; k++) {
int ii = index[i + k]; int ii = indexarray[i + k];
if (fixed[ii] < 2 && if (fixed[ii] < 2 &&
iwidth[ii] - rulewidth < t->minimum_width[ii]) iwidth[ii] - rulewidth < t->minimum_width[ii])
fixed[ii] = 2; fixed[ii] = 2;
@@ -993,7 +993,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
ecol = bcol + cell->colspan[j]; ecol = bcol + cell->colspan[j];
m = 0; m = 0;
for (kk = 0; kk < n; kk++) { for (kk = 0; kk < n; kk++) {
int ii = index[i + kk]; int ii = indexarray[i + kk];
if (ii >= bcol && ii < ecol) { if (ii >= bcol && ii < ecol) {
idx[m] = ii; idx[m] = ii;
m++; m++;
@@ -1031,7 +1031,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
} }
nn = 0; nn = 0;
for (k = 0; k < n; k++) { for (k = 0; k < n; k++) {
int ii = index[i + k]; int ii = indexarray[i + k];
if (fixed[ii] <= step) if (fixed[ii] <= step)
nn++; nn++;
} }
@@ -1039,7 +1039,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
if (nsum < 0. && fabs(sum) <= fabs(nsum)) if (nsum < 0. && fabs(sum) <= fabs(nsum))
return; return;
for (k = 0; k < n; k++) { for (k = 0; k < n; k++) {
int ii = index[i + k]; int ii = indexarray[i + k];
if (fixed[ii] <= step) { if (fixed[ii] <= step) {
iwidth[ii] -= rulewidth; iwidth[ii] -= rulewidth;
fixed[ii] = 3; fixed[ii] = 3;
@@ -1382,7 +1382,7 @@ set_table_width(struct table *t, short *newwidth, int maxwidth)
} }
for (k = 0; k <= cell->maxcell; k++) { for (k = 0; k <= cell->maxcell; k++) {
j = cell->index[k]; j = cell->indexarray[k];
bcol = cell->col[j]; bcol = cell->col[j];
ecol = bcol + cell->colspan[j]; ecol = bcol + cell->colspan[j];
@@ -1479,7 +1479,7 @@ check_table_height(struct table *t)
struct { struct {
short row[MAXCELL]; short row[MAXCELL];
short rowspan[MAXCELL]; short rowspan[MAXCELL];
char index[MAXCELL]; char indexarray[MAXCELL];
short maxcell; short maxcell;
short height[MAXCELL]; short height[MAXCELL];
} cell; } cell;
@@ -1504,9 +1504,10 @@ check_table_height(struct table *t)
if (rowspan > 1) { if (rowspan > 1) {
int c = cell.maxcell + 1; int c = cell.maxcell + 1;
k = bsearch_2short(rowspan, cell.rowspan, k = bsearch_2short(rowspan, cell.rowspan,
j, cell.row, t->maxrow + 1, cell.index, c); j, cell.row, t->maxrow + 1, cell.indexarray,
c);
if (k <= cell.maxcell) { if (k <= cell.maxcell) {
int idx = cell.index[k]; int idx = cell.indexarray[k];
if (cell.row[idx] == j && cell.rowspan[idx] == rowspan) if (cell.row[idx] == j && cell.rowspan[idx] == rowspan)
c = idx; c = idx;
} }
@@ -1517,9 +1518,9 @@ check_table_height(struct table *t)
cell.rowspan[cell.maxcell] = rowspan; cell.rowspan[cell.maxcell] = rowspan;
cell.height[cell.maxcell] = 0; cell.height[cell.maxcell] = 0;
if (cell.maxcell > k) if (cell.maxcell > k)
bcopy(cell.index + k, cell.index + k + 1, bcopy(cell.indexarray + k, cell.indexarray + k + 1,
cell.maxcell - k); cell.maxcell - k);
cell.index[k] = cell.maxcell; cell.indexarray[k] = cell.maxcell;
} }
if (cell.height[c] < t_dep) if (cell.height[c] < t_dep)
@@ -1542,7 +1543,7 @@ check_table_height(struct table *t)
space = 0; space = 0;
} }
check_cell_width(t->tabheight, cell.height, cell.row, cell.rowspan, check_cell_width(t->tabheight, cell.height, cell.row, cell.rowspan,
cell.maxcell, cell.index, space, 1); cell.maxcell, cell.indexarray, space, 1);
} }
#define CHECK_MINIMUM 1 #define CHECK_MINIMUM 1
+3 -2
View File
@@ -1,4 +1,4 @@
/* $Id: terms.c,v 1.17 2001/11/29 09:34:15 ukai Exp $ */ /* $Id: terms.c,v 1.18 2001/11/29 10:22:58 ukai Exp $ */
/* /*
* An original curses library for EUC-kanji by Akinori ITO, December 1989 * An original curses library for EUC-kanji by Akinori ITO, December 1989
* revised by Akinori ITO, January 1995 * revised by Akinori ITO, January 1995
@@ -380,7 +380,7 @@ void clear(), wrap(), touch_line(), touch_column(int);
void switch_wchar(FILE *); void switch_wchar(FILE *);
void switch_ascii(FILE *); void switch_ascii(FILE *);
#endif #endif
void need_clrtoeol(void), clrtoeol(void); void need_clrtoeol(void), clrtoeol(void); /* conflicts with curs_clear(3)? */
int write1(char); int write1(char);
@@ -1492,6 +1492,7 @@ need_clrtoeol(void)
} }
#endif /* 0 */ #endif /* 0 */
/* XXX: conflicts with curses's clrtoeol(3) ? */
void void
clrtoeol(void) clrtoeol(void)
{ /* Clear to the end of line */ { /* Clear to the end of line */