commit 69699f75cfaaebafc0ffb08744bc667b65385528
parent 1c14af49d3f8895b842445bddecc83ece6c33eda
Author: ukai <ukai>
Date: Thu, 29 Nov 2001 10:22:58 +0000
[w3m-dev 02586] code cleanup again
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat:
M | .cvsignore | | | 2 | +- |
M | ChangeLog | | | 26 | ++++++++++++++++++++++++++ |
M | configure | | | 2 | +- |
M | file.c | | | 19 | ++++++++++--------- |
M | ftp.c | | | 84 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
M | matrix.c | | | 20 | ++++++++++---------- |
M | table.c | | | 61 | +++++++++++++++++++++++++++++++------------------------------ |
M | terms.c | | | 3 | ++- |
8 files changed, 123 insertions(+), 94 deletions(-)
diff --git a/.cvsignore b/.cvsignore
@@ -10,4 +10,4 @@ mktable
w3m
w3mbookmark
w3mhelperpanel
-_zdmachdep.c
+_zmachdep.c
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,31 @@
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
* linein.c (_esc): fix #ifdef EMACS_LIKE_LINEEDIT
diff --git a/configure b/configure
@@ -1606,7 +1606,7 @@ fi
# check alarm()
if [ "$use_alarm" = y ]; then
- cat > _zdmachdep.c <<EOF
+ cat > _zmachdep.c <<EOF
#include <unistd.h>
#include <signal.h>
main()
diff --git a/file.c b/file.c
@@ -3598,7 +3598,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
else
#endif
if (p && q && !strcasecmp(p, "refresh")) {
- int refresh = atoi(q);
+ int refresh_interval = atoi(q);
Str s_tmp = NULL;
while (*q) {
@@ -3630,28 +3630,29 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
tmp =
Sprintf
("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);
flushline(h_env, obuf, envs[h_env->envc].indent, 0,
h_env->limit);
- if (!is_redisplay && refresh == 0 && MetaRefresh) {
+ if (!is_redisplay && refresh_interval == 0 && MetaRefresh) {
pushEvent(FUNCNAME_goURL, s_tmp->ptr);
/* pushEvent(deletePrevBuf,NULL); */
}
#ifdef USE_ALARM
- else if (!is_redisplay && refresh > 0 && MetaRefresh) {
- setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_goURL,
- s_tmp->ptr);
+ else if (!is_redisplay && refresh_interval > 0 && MetaRefresh) {
+ setAlarmEvent(refresh_interval, AL_IMPLICIT,
+ FUNCNAME_goURL, s_tmp->ptr);
}
#endif
}
#ifdef USE_ALARM
- else if (!is_redisplay && refresh > 0 && MetaRefresh) {
- tmp = Sprintf("Refresh (%d sec)", refresh);
+ else if (!is_redisplay && refresh_interval > 0 && MetaRefresh) {
+ tmp = Sprintf("Refresh (%d sec)", refresh_interval);
push_str(obuf, 0, tmp, PC_ASCII);
flushline(h_env, obuf, envs[h_env->envc].indent, 0,
h_env->limit);
- setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_reload, NULL);
+ setAlarmEvent(refresh_interval, AL_IMPLICIT, FUNCNAME_reload,
+ NULL);
}
#endif
}
diff --git a/ftp.c b/ftp.c
@@ -32,7 +32,7 @@ typedef struct _FTP {
typedef int STATUS;
-static FTP ftp;
+static FTP current_ftp;
static Str
read_response1(FTP ftp)
@@ -105,7 +105,7 @@ FtpLogin(FTP * ftp_return, char *host, char *user, char *pass)
Str tmp;
FTP ftp = New(struct _FTP);
int fd;
- *ftp_return = ftp;
+ *ftp_return = current_ftp = ftp;
fd = openSocket(host, "ftp", 21);
if (fd < 0)
return -1;
@@ -191,18 +191,18 @@ ftp_pasv(FTP ftp)
Str tmp;
int family;
#ifdef INET6
- struct sockaddr_storage sin;
- int sinlen, port;
+ struct sockaddr_storage sockaddr;
+ int sockaddrlen, port;
unsigned char d1, d2, d3, d4;
char abuf[INET6_ADDRSTRLEN];
#endif
#ifdef INET6
- sinlen = sizeof(sin);
+ sockaddrlen = sizeof(sockaddr);
if (getpeername(fileno(ftp->wcontrol),
- (struct sockaddr *)&sin, &sinlen) < 0)
+ (struct sockaddr *)&sockaddr, &sockaddrlen) < 0)
return -1;
- family = sin.ss_family;
+ family = sockaddr.ss_family;
#else
family = AF_INET;
#endif
@@ -220,7 +220,7 @@ ftp_pasv(FTP ftp)
if (sscanf(++p, "%c%c%c%d%c", &d1, &d2, &d3, &port, &d4) != 5
|| d1 != d2 || d1 != d3 || d1 != d4)
return -1;
- if (getnameinfo((struct sockaddr *)&sin, sinlen,
+ if (getnameinfo((struct sockaddr *)&sockaddr, sockaddrlen,
abuf, sizeof(abuf), NULL, 0, NI_NUMERICHOST) != 0)
return -1;
tmp = Sprintf("%s", abuf);
@@ -296,9 +296,9 @@ int
Ftpfclose(FILE * f)
{
fclose(f);
- if (f == ftp->data)
- ftp->data = NULL;
- read_response(ftp);
+ if (f == current_ftp->data)
+ current_ftp->data = NULL;
+ read_response(current_ftp);
return 0;
}
@@ -403,7 +403,7 @@ openFTP(ParsedURL *pu)
int i, nfile, nfile_max = 100;
Str pwd = NULL;
int add_auth_cookie_flag;
- char *realpath = NULL;
+ char *realpathname = NULL;
#ifdef JP_CHARSET
char code = '\0', ic;
Str pathStr;
@@ -446,7 +446,7 @@ openFTP(ParsedURL *pu)
Strcat_char(tmp2, '@');
pass = tmp2->ptr;
}
- s = FtpLogin(&ftp, pu->host, user, pass);
+ s = FtpLogin(¤t_ftp, pu->host, user, pass);
if (FtpError(s))
return NULL;
if (add_auth_cookie_flag)
@@ -454,69 +454,69 @@ openFTP(ParsedURL *pu)
if (pu->file == NULL || *pu->file == '\0')
goto ftp_dir;
else
- realpath = file_unquote(pu->file);
+ realpathname = file_unquote(pu->file);
if (pu->file[strlen(pu->file) - 1] == '/')
goto ftp_dir;
/* Get file */
- FtpBinary(ftp);
- if (ftp_pasv(ftp) < 0) {
- FtpBye(ftp);
+ FtpBinary(current_ftp);
+ if (ftp_pasv(current_ftp) < 0) {
+ FtpBye(current_ftp);
return NULL;
}
- s = FtpOpenReadBody(ftp, realpath);
+ s = FtpOpenReadBody(current_ftp, realpathname);
if (!FtpError(s)) {
#ifdef JP_CHARSET
- pathStr = Strnew_charp(realpath);
+ pathStr = Strnew_charp(realpathname);
if ((ic = checkShiftCode(pathStr, code)) != '\0') {
pathStr = conv_str(pathStr, (code = ic), InnerCode);
- realpath = pathStr->ptr;
+ realpathname = pathStr->ptr;
}
#endif /* JP_CHARSET */
- pu->file = realpath;
- return FTPDATA(ftp);
+ pu->file = realpathname;
+ return FTPDATA(current_ftp);
}
goto ftp_dir1;
/* Get directory */
ftp_dir:
- if (ftp_pasv(ftp) < 0) {
- FtpBye(ftp);
+ if (ftp_pasv(current_ftp) < 0) {
+ FtpBye(current_ftp);
return NULL;
}
ftp_dir1:
pu->scheme = SCM_FTPDIR;
FTPDIRtmp = Strnew();
- sv_type = ftp_system(ftp);
+ sv_type = ftp_system(current_ftp);
if (pu->file == NULL || *pu->file == '\0') {
if (sv_type == UNIXLIKE_SERVER) {
- s = FtpDataBody(ftp, "LIST", NULL, "r");
+ s = FtpDataBody(current_ftp, "LIST", NULL, "r");
}
else {
- s = FtpDataBody(ftp, "NLST", NULL, "r");
+ s = FtpDataBody(current_ftp, "NLST", NULL, "r");
}
curdir = Strnew_charp("/");
}
else {
if (sv_type == UNIXLIKE_SERVER) {
- s = FtpCwd(ftp, realpath);
+ s = FtpCwd(current_ftp, realpathname);
if (!FtpError(s)) {
- s = FtpDataBody(ftp, "LIST", NULL, "r");
+ s = FtpDataBody(current_ftp, "LIST", NULL, "r");
}
}
else {
- s = FtpDataBody(ftp, "NLST %s", realpath, "r");
+ s = FtpDataBody(current_ftp, "NLST %s", realpathname, "r");
}
- if (realpath[0] == '/')
- curdir = Strnew_charp(realpath);
+ if (realpathname[0] == '/')
+ curdir = Strnew_charp(realpathname);
else
- curdir = Sprintf("/%s", realpath);
+ curdir = Sprintf("/%s", realpathname);
if (Strlastchar(curdir) != '/')
Strcat_char(curdir, '/');
}
if (FtpError(s)) {
- FtpBye(ftp);
+ FtpBye(current_ftp);
return NULL;
}
host = Strnew_charp("ftp://");
@@ -552,11 +552,11 @@ openFTP(ParsedURL *pu)
nfile = 0;
if (sv_type == UNIXLIKE_SERVER) {
char *name, *date, *size, *type_str;
- int ftype, max_len, len, i, j;
+ int ftype, max_len, len, j;
Str line_tmp;
max_len = 0;
- while (tmp2 = Strfgets(FTPDATA(ftp)), tmp2->length > 0) {
+ while (tmp2 = Strfgets(FTPDATA(current_ftp)), tmp2->length > 0) {
Strchop(tmp2);
if ((ftype =
ex_ftpdir_name_size_date(tmp2->ptr, &name, &date, &size))
@@ -635,7 +635,7 @@ openFTP(ParsedURL *pu)
Strcat_charp(FTPDIRtmp, "</pre></body></html>\n");
}
else {
- while (tmp2 = Strfgets(FTPDATA(ftp)), tmp2->length > 0) {
+ while (tmp2 = Strfgets(FTPDATA(current_ftp)), tmp2->length > 0) {
Strchop(tmp2);
flist[nfile++] = mybasename(tmp2->ptr);
if (nfile == nfile_max) {
@@ -654,8 +654,8 @@ openFTP(ParsedURL *pu)
Strcat_charp(FTPDIRtmp, "</ul></body></html>\n");
}
- FtpClose(ftp);
- FtpBye(ftp);
+ FtpClose(current_ftp);
+ FtpBye(current_ftp);
return NULL;
}
@@ -841,8 +841,8 @@ closeFTP(FILE * f)
{
if (f) {
fclose(f);
- if (f == ftp->data)
- ftp->data = NULL;
+ if (f == current_ftp->data)
+ current_ftp->data = NULL;
}
- FtpBye(ftp);
+ FtpBye(current_ftp);
}
diff --git a/matrix.c b/matrix.c
@@ -67,7 +67,7 @@ static double Tiny = 1.0e-30;
*/
int
-LUfactor(Matrix A, int *index)
+LUfactor(Matrix A, int *indexarray)
{
int dim = A->dim, i, j, k, i_max, k_max;
Vector scale;
@@ -76,7 +76,7 @@ LUfactor(Matrix A, int *index)
scale = new_vector(dim);
for (i = 0; i < dim; i++)
- index[i] = i;
+ indexarray[i] = i;
for (i = 0; i < dim; i++) {
mx = 0.;
@@ -107,7 +107,7 @@ LUfactor(Matrix A, int *index)
}
if (i_max != k) {
- SWAPI(index[i_max], index[k]);
+ SWAPI(indexarray[i_max], indexarray[k]);
for (j = 0; j < dim; j++)
SWAPD(M_VAL(A, i_max, j), M_VAL(A, k, j));
}
@@ -126,12 +126,12 @@ LUfactor(Matrix A, int *index)
*/
int
-LUsolve(Matrix A, int *index, Vector b, Vector x)
+LUsolve(Matrix A, int *indexarray, Vector b, Vector x)
{
int i, dim = A->dim;
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)
return -1;
@@ -144,16 +144,16 @@ LUsolve(Matrix A, int *index, Vector b, Vector x)
Matrix
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);
m_copy(A, A1);
- LUfactor(A1, index);
- return LUinverse(A1, index, out);
+ LUfactor(A1, indexarray);
+ return LUinverse(A1, indexarray, out);
}
#endif /* 0 */
Matrix
-LUinverse(Matrix A, int *index, Matrix out)
+LUinverse(Matrix A, int *indexarray, Matrix out)
{
int i, j, dim = A->dim;
Vector tmp, tmp2;
@@ -166,7 +166,7 @@ LUinverse(Matrix A, int *index, Matrix out)
for (j = 0; j < dim; j++)
tmp->ve[j] = 0.;
tmp->ve[i] = 1.;
- if (LUsolve(A, index, tmp, tmp2) == -1)
+ if (LUsolve(A, indexarray, tmp, tmp2) == -1)
return NULL;
for (j = 0; j < dim; j++)
M_VAL(out, j, i) = tmp2->ve[j];
diff --git a/table.c b/table.c
@@ -155,7 +155,7 @@ weight3(int x)
static int
bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base,
- char *index, int nent)
+ char *indexarray, int nent)
{
int n = nent;
int k = 0;
@@ -163,7 +163,7 @@ bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base,
int e = e1 * base + e2;
while (n > 0) {
int nn = n / 2;
- int idx = index[k + nn];
+ int idx = indexarray[k + nn];
int ne = ent1[idx] * base + ent2[idx];
if (ne == e) {
k += nn;
@@ -181,14 +181,14 @@ bsearch_2short(short e1, short *ent1, short e2, short *ent2, int base,
}
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 k = 0;
while (n > 0) {
int nn = n / 2;
- int idx = index[k + nn];
+ int idx = indexarray[k + nn];
double ne = ent[idx];
if (ne == e) {
k += nn;
@@ -234,11 +234,11 @@ static void
dv2sv(double *dv, short *iv, int size)
{
int i, k, iw;
- char *index;
+ char *indexarray;
double *edv;
double w = 0., x;
- index = NewAtom_N(char, size);
+ indexarray = NewAtom_N(char, size);
edv = NewAtom_N(double, size);
for (i = 0; i < size; i++) {
iv[i] = ceil(dv[i]);
@@ -249,17 +249,17 @@ dv2sv(double *dv, short *iv, int size)
for (k = 0; k < size; k++) {
x = edv[k];
w += x;
- i = bsearch_double(x, edv, index, k);
+ i = bsearch_double(x, edv, indexarray, k);
if (k > i)
- bcopy(index + i, index + i + 1, k - i);
- index[i] = k;
+ bcopy(indexarray + i, indexarray + i + 1, k - i);
+ indexarray[i] = k;
}
iw = min((int)(w + 0.5), size);
if (iw == 0)
return;
- x = edv[(int)index[iw - 1]];
+ x = edv[(int)indexarray[iw - 1]];
for (i = 0; i < size; i++) {
- k = index[i];
+ k = indexarray[i];
if (i >= iw && abs(edv[k] - x) > 1e-6)
break;
iv[k]--;
@@ -856,13 +856,13 @@ table_rule_width(struct table *t)
static void
check_cell_width(short *tabwidth, short *cellwidth,
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 swidth, width;
for (k = 0; k <= maxcell; k++) {
- j = index[k];
+ j = indexarray[k];
if (cellwidth[j] <= 0)
continue;
bcol = col[j];
@@ -936,13 +936,13 @@ static void
set_integered_width(struct table *t, double *dwidth, short *iwidth)
{
int i, j, k, n, bcol, ecol, step;
- char *index, *fixed;
+ char *indexarray, *fixed;
double *mod;
double sum = 0., x = 0.;
struct table_cell *cell = &t->cell;
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);
for (i = 0; i <= t->maxcol; i++) {
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++) {
x = mod[k];
sum += x;
- i = bsearch_double(x, mod, index, k);
+ i = bsearch_double(x, mod, indexarray, k);
if (k > i)
- bcopy(index + i, index + i + 1, k - i);
- index[i] = k;
+ bcopy(indexarray + i, indexarray + i + 1, k - i);
+ indexarray[i] = k;
}
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)
return;
for (n = 0; i + n <= t->maxcol; n++) {
- int ii = index[i + n];
+ int ii = indexarray[i + n];
if (n == 0)
x = mod[ii];
else if (fabs(mod[ii] - x) > 1e-6)
break;
}
for (k = 0; k < n; k++) {
- int ii = index[i + k];
+ int ii = indexarray[i + k];
if (fixed[ii] < 2 &&
iwidth[ii] - rulewidth < t->minimum_width[ii])
fixed[ii] = 2;
@@ -993,7 +993,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
ecol = bcol + cell->colspan[j];
m = 0;
for (kk = 0; kk < n; kk++) {
- int ii = index[i + kk];
+ int ii = indexarray[i + kk];
if (ii >= bcol && ii < ecol) {
idx[m] = ii;
m++;
@@ -1031,7 +1031,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
}
nn = 0;
for (k = 0; k < n; k++) {
- int ii = index[i + k];
+ int ii = indexarray[i + k];
if (fixed[ii] <= step)
nn++;
}
@@ -1039,7 +1039,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth)
if (nsum < 0. && fabs(sum) <= fabs(nsum))
return;
for (k = 0; k < n; k++) {
- int ii = index[i + k];
+ int ii = indexarray[i + k];
if (fixed[ii] <= step) {
iwidth[ii] -= rulewidth;
fixed[ii] = 3;
@@ -1382,7 +1382,7 @@ set_table_width(struct table *t, short *newwidth, int maxwidth)
}
for (k = 0; k <= cell->maxcell; k++) {
- j = cell->index[k];
+ j = cell->indexarray[k];
bcol = cell->col[j];
ecol = bcol + cell->colspan[j];
@@ -1479,7 +1479,7 @@ check_table_height(struct table *t)
struct {
short row[MAXCELL];
short rowspan[MAXCELL];
- char index[MAXCELL];
+ char indexarray[MAXCELL];
short maxcell;
short height[MAXCELL];
} cell;
@@ -1504,9 +1504,10 @@ check_table_height(struct table *t)
if (rowspan > 1) {
int c = cell.maxcell + 1;
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) {
- int idx = cell.index[k];
+ int idx = cell.indexarray[k];
if (cell.row[idx] == j && cell.rowspan[idx] == rowspan)
c = idx;
}
@@ -1517,9 +1518,9 @@ check_table_height(struct table *t)
cell.rowspan[cell.maxcell] = rowspan;
cell.height[cell.maxcell] = 0;
if (cell.maxcell > k)
- bcopy(cell.index + k, cell.index + k + 1,
+ bcopy(cell.indexarray + k, cell.indexarray + k + 1,
cell.maxcell - k);
- cell.index[k] = cell.maxcell;
+ cell.indexarray[k] = cell.maxcell;
}
if (cell.height[c] < t_dep)
@@ -1542,7 +1543,7 @@ check_table_height(struct table *t)
space = 0;
}
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
diff --git a/terms.c b/terms.c
@@ -380,7 +380,7 @@ void clear(), wrap(), touch_line(), touch_column(int);
void switch_wchar(FILE *);
void switch_ascii(FILE *);
#endif
-void need_clrtoeol(void), clrtoeol(void);
+void need_clrtoeol(void), clrtoeol(void); /* conflicts with curs_clear(3)? */
int write1(char);
@@ -1492,6 +1492,7 @@ need_clrtoeol(void)
}
#endif /* 0 */
+/* XXX: conflicts with curses's clrtoeol(3) ? */
void
clrtoeol(void)
{ /* Clear to the end of line */