w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 1c14af49d3f8895b842445bddecc83ece6c33eda
parent 490dddd970d9eddf1d7a43f329d10682118bac93
Author: ukai <ukai>
Date:   Thu, 29 Nov 2001 09:34:14 +0000

[w3m-dev 02584] code cleanup again
From: Fumitoshi UKAI <ukai@debian.or.jp>

Diffstat:
MChangeLog | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MStr.c | 2+-
Mbuffer.c | 2+-
Mconfigure | 2+-
Mconv.c | 6+++---
Mdisplay.c | 2+-
Mfile.c | 109++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mfm.h | 3+--
Mform.c | 2+-
Mframe.c | 2+-
Mftp.c | 8++++----
Mlinein.c | 11++++++-----
Mlocal.c | 4++--
Mmailcap.c | 24++++++++++++------------
Mmain.c | 41+++++++++++++++++++++--------------------
Mmenu.c | 142++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mparsetagx.c | 2+-
Mproto.h | 12++++++------
Mrc.c | 8+++++---
Mtable.c | 8++++----
Mterms.c | 2+-
Murl.c | 12++++++------
Mversion.c | 2+-
23 files changed, 302 insertions(+), 201 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,100 @@ +2001-11-29 Fumitoshi UKAI <ukai@debian.or.jp> + + * [w3m-dev 02584] code cleanup + + * linein.c (_esc): fix #ifdef EMACS_LIKE_LINEEDIT + + * fix shadow variables (partially) + * version.c: s/version/w3m_version/ + * configure: ditto + * fm.h: ditto + * local.c (set_environ): ditto + * main.c (fusage): ditto + * main.c (MAIN): ditto + * main.c (dispVer): ditto + * rc.c (load_option_panel): ditto + * url.c (otherinfo): ditto + * file.c (readHeader): s/tmp/tmp2/ + * file.c (loadGeneralFile): s/tmp/cmd/ + * file.c (flushline): s/f/df/ + * file.c (doExternal): s/stat/mc_stat/ + * proto.h: ditto + * mailcap.c (unquote_mailcap_loop): ditto + * mailcap.c (unquote_mailcap): ditto + * main.c (cmd_loadBuffer): s/link/linkid/ + * main.c (sig_chld): s/stat/p_stat/ + * fm.h: remove config_file + * main.c (MAIN): s/config_file/config_filename/ + * rc.c (init_rc): ditto + * proto.h: ditto + * rc.c: add config_file + * menu.c (goem_menu): s/select/mselect/ + * menu.c (draw_menu_item): ditto + * menu.c (select_menu): ditto + * menu.c (goto_menu): ditto + * menu.c (action_menu): ditto + * menu.c (mNext): ditto + * menu.c (mPrev): ditto + * menu.c (mOk): ditto + * menu.c (mSrchF): ditto + * menu.c (mSrchB): ditto + * menu.c (mSrchN): ditto + * menu.c (mSrchP): ditto + * menu.c (process_mMouse): ditto + * menu.c (smDelBuf): ditto + * proto.h: ditto + + * printf format + * display.c (redrawLine): use %*ld instead of %*d + + * require parentheses + * ftp.c (FtpLogin): add paren + + * fix variable might be clobbered by `longjmp' or `vfork' + * file.c (loadGeneralFile): add volatile + * file.c (loadHTMLString): ditto + * file.c (loadBuffer): ditto + * file.c (doExternal): ditto + * frame.c (createFrameFile): ditto + * main.c (srchfor): ditto + * main.c (srchbak): ditto + * main.c (srch_nxtprv): ditto + * url.c (openSocket): ditto + + * fix unused variables + * file.c (readHeader): emssg if USE_COOKIE defined + * file.c (HTMLlineproc2body: remove tmp + * file.c (saveBufferDelNum): remove p + * linein.c (_esc): c2 if JP_CHARSET defined + + * fix uninitialized variables + * Str.c (Sprintf): initialize p + * buffer.c (readBufferCache): initialize prevl + * conv.c (cConvSE): initialize ub + * conv.c (_cConvEE): initialize ub + * conv.c (cConvES): initialize ub + * file.c (loadGeneralFile): initialize proc, t, prevtral, ss, realm + * file.c (HTMLlineproc2body): initialize debug + * file.c (HTMLlineproc0): initialize tbl_mode, tbl_width + * file.c (loadHTMLstream): initialize prevtrap + * file.c (loadHTMLString): initialize prevtrap + * file.c (loadBuffer): initialize prevtrap + * form.c (formUpdateBuffer): initialize col + * ftp.c (openFTP): initialize pwd + * local.c (dirBuffer): initialize nrow + * main.c (gpm_process_mouse): initialize btn + * menu.c (gpm_process_menu_mouse): ditto + * menu.c (initMenu): initialize nmenu, nitem, item + * parsetagx.c (parse_tag): initialize attr_id + * rc.c (show_params): initialize t + * table.c (visible_length): initialize amp_len + * table.c (set_integered_width): initialize x + * table.c (check_table_height): initialize space + * table.c (renderTable): initialize vrulea, vruleb, vrulec + * terms.c (putchars): initialize s + * url.c (openSocket): initialize trap, result + * url.c (openURL): initialize sslh + 2001-11-28 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> * [w3m-dev 02579] diff --git a/Str.c b/Str.c @@ -428,7 +428,7 @@ Sprintf(char *fmt, ...) { int len = 0; int status = SP_NORMAL; - int p; + int p = 0; char *f; Str s; va_list ap; diff --git a/buffer.c b/buffer.c @@ -630,7 +630,7 @@ int readBufferCache(Buffer *buf) { FILE *cache; - Line *l = NULL, *prevl; + Line *l = NULL, *prevl = NULL; long lnum = 0, clnum, tlnum; #ifdef USE_ANSI_COLOR int colorflag; diff --git a/configure b/configure @@ -1839,7 +1839,7 @@ cat > extrvers.c << EOF #include "version.c" main() { - char *p = strchr(version,'/'); + char *p = strchr(w3m_version,'/'); if (p == NULL) printf("unknown\n"); else diff --git a/conv.c b/conv.c @@ -268,7 +268,7 @@ cConvSE(Str is) static Str cConvJE(Str is) { /* Convert ISO-2022-JP to EUC-JP */ - uchar *p, ub; + uchar *p, ub = 0; char cset = CSET_ASCII; int state = ISO_NOSTATE; Str os = Strnew_size(is->length); @@ -354,7 +354,7 @@ static Str _cConvEE(Str is, char is_euc) { /* Convert EUC-JP to EUC-JP / ISO-2022-JP * (no JIS X 0201-Kana, 0212, 0213-2) */ - uchar *p, ub, euc = 0; + uchar *p, ub = 0, euc = 0; int state = EUC_NOSTATE; char cset = CSET_ASCII; Str os; @@ -462,7 +462,7 @@ put_sjis(Str os, uchar ub, uchar lb) static Str cConvES(Str is) { /* Convert EUC-JP to Shift-JIS */ - uchar *p, ub; + uchar *p, ub = 0; int state = EUC_NOSTATE; Str os = Strnew_size(is->length); uchar *endp = (uchar *) & is->ptr[is->length]; diff --git a/display.c b/display.c @@ -402,7 +402,7 @@ redrawLine(Buffer *buf, Line *l, int i) buf->COLS = COLS - buf->rootX; } if (l->real_linenumber) - sprintf(tmp, "%*d:", buf->rootX - 1, l->real_linenumber); + sprintf(tmp, "%*ld:", buf->rootX - 1, l->real_linenumber); else sprintf(tmp, "%*s ", buf->rootX - 1, ""); addstr(tmp); diff --git a/file.c b/file.c @@ -413,7 +413,10 @@ matchattr(char *p, char *attr, int len, Str *value) void readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) { - char *p, *q, *emsg; + char *p, *q; +#ifdef USE_COOKIE + char *emsg; +#endif char c; Str lineBuf2 = NULL; Str tmp; @@ -552,7 +555,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) (!strncasecmp(lineBuf2->ptr, "Set-Cookie:", 11) || !strncasecmp(lineBuf2->ptr, "Set-Cookie2:", 12))) { Str name = Strnew(), value = Strnew(), domain = NULL, path = NULL, - comment = NULL, commentURL = NULL, port = NULL, tmp; + comment = NULL, commentURL = NULL, port = NULL, tmp2; int version, quoted, flag = 0; time_t expires = (time_t) - 1; @@ -589,36 +592,36 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) while (*p == ';') { p++; SKIP_BLANKS(p); - if (matchattr(p, "expires", 7, &tmp)) { + if (matchattr(p, "expires", 7, &tmp2)) { /* version 0 */ - expires = mymktime(tmp->ptr); + expires = mymktime(tmp2->ptr); } - else if (matchattr(p, "max-age", 7, &tmp)) { + else if (matchattr(p, "max-age", 7, &tmp2)) { /* XXX Is there any problem with max-age=0? (RFC 2109 ss. 4.2.1, 4.2.2 */ - expires = time(NULL) + atol(tmp->ptr); + expires = time(NULL) + atol(tmp2->ptr); } - else if (matchattr(p, "domain", 6, &tmp)) { - domain = tmp; + else if (matchattr(p, "domain", 6, &tmp2)) { + domain = tmp2; } - else if (matchattr(p, "path", 4, &tmp)) { - path = tmp; + else if (matchattr(p, "path", 4, &tmp2)) { + path = tmp2; } else if (matchattr(p, "secure", 6, NULL)) { flag |= COO_SECURE; } - else if (matchattr(p, "comment", 7, &tmp)) { - comment = tmp; + else if (matchattr(p, "comment", 7, &tmp2)) { + comment = tmp2; } - else if (matchattr(p, "version", 7, &tmp)) { - version = atoi(tmp->ptr); + else if (matchattr(p, "version", 7, &tmp2)) { + version = atoi(tmp2->ptr); } - else if (matchattr(p, "port", 4, &tmp)) { + else if (matchattr(p, "port", 4, &tmp2)) { /* version 1, Set-Cookie2 */ - port = tmp; + port = tmp2; } - else if (matchattr(p, "commentURL", 10, &tmp)) { + else if (matchattr(p, "commentURL", 10, &tmp2)) { /* version 1, Set-Cookie2 */ - commentURL = tmp; + commentURL = tmp2; } else if (matchattr(p, "discard", 7, NULL)) { /* version 1, Set-Cookie2 */ @@ -893,24 +896,24 @@ same_url_p(ParsedURL *pu1, ParsedURL *pu2) * loadGeneralFile: load file to buffer */ Buffer * -loadGeneralFile(char *path, ParsedURL *current, char *referer, int flag, - FormList *request) +loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, + int flag, FormList *volatile request) { - URLFile f, *of = NULL; + URLFile f, *volatile of = NULL; ParsedURL pu, *volatile puv = NULL; int volatile nredir = 0; int volatile nredir_size = 0; - Buffer *b = NULL, *(*proc) (); - char *tpath; - char *t, *p, *real_type = NULL; - Buffer *t_buf = NULL; - int searchHeader = SearchHeader; - int searchHeader_through = TRUE; - MySignalHandler(*prevtrap) (); + Buffer *b = NULL, *(*volatile proc)() = loadBuffer; + char *volatile tpath; + char *volatile t = "text/plain", *p, *volatile real_type = NULL; + Buffer *volatile t_buf = NULL; + int volatile searchHeader = SearchHeader; + int volatile searchHeader_through = TRUE; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; TextList *extra_header = newTextList(); - Str ss; - Str realm; - int add_auth_cookie_flag; + volatile Str ss = NULL; + volatile Str realm = NULL; + int volatile add_auth_cookie_flag; unsigned char status = HTST_NORMAL; URLOption url_option; Str tmp; @@ -961,10 +964,10 @@ loadGeneralFile(char *path, ParsedURL *current, char *referer, int flag, return NULL; if (S_ISDIR(st.st_mode)) { if (UseExternalDirBuffer) { - Str tmp = Strnew_charp(DirBufferCommand); - Strcat_m_charp(tmp, "?dir=", + Str cmd = Strnew_charp(DirBufferCommand); + Strcat_m_charp(cmd, "?dir=", pu.real_file, "#current", NULL); - b = loadGeneralFile(tmp->ptr, NULL, NO_REFERER, 0, + b = loadGeneralFile(cmd->ptr, NULL, NO_REFERER, 0, NULL); if (b != NULL && b != NO_BUFFER) { copyParsedURL(&b->currentURL, &pu); @@ -1798,16 +1801,16 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, *hidden_under = NULL, *hidden = NULL; if (w3m_debug) { - FILE *f = fopen("zzzproc1", "a"); - fprintf(f, "flushline(%s,%d,%d,%d)\n", obuf->line->ptr, indent, force, + FILE *df = fopen("zzzproc1", "a"); + fprintf(df, "flushline(%s,%d,%d,%d)\n", obuf->line->ptr, indent, force, width); if (buf) { TextLineListItem *p; for (p = buf->first; p; p = p->next) { - fprintf(f, "buf=\"%s\"\n", p->ptr->line->ptr); + fprintf(df, "buf=\"%s\"\n", p->ptr->line->ptr); } } - fclose(f); + fclose(df); } if (!(obuf->flag & (RB_SPECIAL & ~RB_NOBR)) && Strlastchar(line) == ' ') { @@ -3749,12 +3752,11 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) Lineprop outp[LINELEN], mode, effect; int pos; int nlines; - FILE *debug; + FILE *debug = NULL; struct frameset *frameset_s[FRAMESTACK_SIZE]; int frameset_sp = -1; union frameset_element *idFrame = NULL; char *id = NULL; - Str tmp; int hseq; Str line; char *endp; @@ -4192,8 +4194,8 @@ HTMLlineproc0(char *istr, struct html_feed_environ *h_env, int internal) struct parsed_tag *tag; Str tokbuf; struct table *tbl = NULL; - struct table_mode *tbl_mode; - int tbl_width; + struct table_mode *tbl_mode = NULL; + int tbl_width = 0; if (w3m_debug) { FILE *f = fopen("zzzproc1", "a"); @@ -4867,7 +4869,7 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) char code; struct html_feed_environ htmlenv1; struct readbuffer obuf; - MySignalHandler(*prevtrap) (); + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; n_textarea = 0; cur_textarea = NULL; @@ -4988,10 +4990,10 @@ Buffer * loadHTMLString(Str page) { URLFile f; - MySignalHandler(*prevtrap) (); + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; Buffer *newBuf; Str tmp; - FILE *src = NULL; + FILE *volatile src = NULL; newBuf = newBuffer(INIT_BUFFER_WIDTH); if (SETJMP(AbortLoading) != 0) { @@ -5141,19 +5143,19 @@ loadGopherDir(URLFile *uf, Buffer *newBuf) * loadBuffer: read file and make new buffer */ Buffer * -loadBuffer(URLFile *uf, Buffer *newBuf) +loadBuffer(URLFile *uf, Buffer *volatile newBuf) { - FILE *src = NULL; + FILE *volatile src = NULL; char code; Str lineBuf2; - char pre_lbuf = '\0'; + volatile char pre_lbuf = '\0'; int nlines; Str tmpf; int linelen = 0, trbyte = 0; #ifdef USE_ANSI_COLOR int check_color; #endif - MySignalHandler(*prevtrap) (); + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; if (newBuf == NULL) newBuf = newBuffer(INIT_BUFFER_WIDTH); @@ -5280,7 +5282,6 @@ saveBufferDelNum(Buffer *buf, FILE * f, int del) { Line *l = buf->firstLine; Str tmp; - char *p; #ifndef KANJI_SYMBOLS int is_html = FALSE; @@ -5598,7 +5599,7 @@ save2tmp(URLFile uf, char *tmpf) FILE *ff; int check; int linelen = 0, trbyte = 0; - MySignalHandler(*prevtrap) (); + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; static JMP_BUF env_bak; ff = fopen(tmpf, "wb"); @@ -5665,7 +5666,7 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp, { Str tmpf, command; struct mailcap *mcap; - int stat; + int mc_stat; Buffer *buf = NULL; char *header; @@ -5693,9 +5694,9 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp, header = checkHeader(defaultbuf, "Content-Type:"); if (header) header = conv_to_system(header); - command = unquote_mailcap(mcap->viewer, type, tmpf->ptr, header, &stat); + command = unquote_mailcap(mcap->viewer, type, tmpf->ptr, header, &mc_stat); #ifndef __EMX__ - if (!(stat & MCSTAT_REPNAME)) { + if (!(mc_stat & MCSTAT_REPNAME)) { Str tmp = Sprintf("(%s) < %s", command->ptr, shell_quote(tmpf->ptr)); command = tmp; } diff --git a/fm.h b/fm.h @@ -674,7 +674,7 @@ global char *CurrentMenuData; #endif extern char *ullevel[]; -extern char *version; +extern char *w3m_version; #define DUMP_BUFFER 0x01 #define DUMP_HEAD 0x02 @@ -749,7 +749,6 @@ global char *DirBufferCommand init("file:///$LIB/dirlist.cmd"); #else global char *DirBufferCommand init("file:///$LIB/dirlist.cgi"); #endif /* __EMX__ */ -global char *config_file init(NULL); global int ignore_null_img_alt init(TRUE); global struct auth_cookie *Auth_cookie init(NULL); diff --git a/form.c b/form.c @@ -258,7 +258,7 @@ formUpdateBuffer(Anchor *a, Buffer *buf, FormItemList *form) int i, j, k; Buffer save; char *p; - int spos, epos, c_len, rows, c_rows, pos, col; + int spos, epos, c_len, rows, c_rows, pos, col = 0; Lineprop c_type; Line *l; diff --git a/frame.c b/frame.c @@ -429,7 +429,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, #endif /* JP_CHARSET */ char *d_target, *p_target, *s_target, *t_target; ParsedURL *currentURL, base; - MySignalHandler(*prevtrap) (SIGNAL_ARG) = NULL; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; int flag; if (f == NULL) diff --git a/ftp.c b/ftp.c @@ -121,9 +121,9 @@ FtpLogin(FTP * ftp_return, char *host, char *user, char *pass) struct hostent *sockent; Str tmp2 = Strnew_charp(pass); - if (sockent = gethostbyaddr((char *)&sockname.sin_addr, - sizeof(sockname.sin_addr), - sockname.sin_family)) + if ((sockent = gethostbyaddr((char *)&sockname.sin_addr, + sizeof(sockname.sin_addr), + sockname.sin_family))) Strcat_charp(tmp2, sockent->h_name); else Strcat_m_charp(tmp2, "[", inet_ntoa(sockname.sin_addr), @@ -401,7 +401,7 @@ openFTP(ParsedURL *pu) char *qdir; char **flist; int i, nfile, nfile_max = 100; - Str pwd; + Str pwd = NULL; int add_auth_cookie_flag; char *realpath = NULL; #ifdef JP_CHARSET diff --git a/linein.c b/linein.c @@ -411,7 +411,10 @@ ins_kanji(Str tmp) static void _esc(void) { - char c, c2; + char c; +#ifdef JP_CHARSET + char c2; +#endif switch (c = getch()) { case '[': @@ -440,16 +443,14 @@ _esc(void) need_redraw = TRUE; } else -#else - _rcompl(); #endif + _rcompl(); break; case CTRL_D: #ifdef EMACS_LIKE_LINEEDIT if (!emacs_like_lineedit) -#else - _rdcompl(); #endif + _rdcompl(); need_redraw = TRUE; break; #ifdef EMACS_LIKE_LINEEDIT diff --git a/local.c b/local.c @@ -47,7 +47,7 @@ dirBuffer(char *dname) struct stat lst; char lbuf[1024]; #endif /* HAVE_READLINK */ - int i, l, nrow, n = 0, maxlen = 0; + int i, l, nrow = 0, n = 0, maxlen = 0; int nfile, nfile_max = 100; Str dirname; Buffer *buf; @@ -256,7 +256,7 @@ set_environ(char *var, char *value) static void set_cgi_environ(char *name, char *fn, char *req_uri) { - set_environ("SERVER_SOFTWARE", version); + set_environ("SERVER_SOFTWARE", w3m_version); set_environ("SERVER_PROTOCOL", "HTTP/1.0"); set_environ("SERVER_NAME", "localhost"); set_environ("SERVER_PORT", "80"); /* dummy */ diff --git a/mailcap.c b/mailcap.c @@ -300,15 +300,15 @@ quote_mailcap(char *s, int flag) static Str -unquote_mailcap_loop(char *qstr, char *type, char *name, char *attr, int *stat, - int flag0) +unquote_mailcap_loop(char *qstr, char *type, char *name, char *attr, + int *mc_stat, int flag0) { Str str, tmp, test, then; char *p; int status = MC_NORMAL, prev_status = MC_NORMAL, sp = 0, flag; - if (stat) - *stat = 0; + if (mc_stat) + *mc_stat = 0; if (qstr == NULL) return NULL; @@ -357,15 +357,15 @@ unquote_mailcap_loop(char *qstr, char *type, char *name, char *attr, int *stat, case 's': if (name) { Strcat_charp(str, quote_mailcap(name, flag)->ptr); - if (stat) - *stat |= MCSTAT_REPNAME; + if (mc_stat) + *mc_stat |= MCSTAT_REPNAME; } break; case 't': if (type) { Strcat_charp(str, quote_mailcap(type, flag)->ptr); - if (stat) - *stat |= MCSTAT_REPTYPE; + if (mc_stat) + *mc_stat |= MCSTAT_REPTYPE; } break; } @@ -401,8 +401,8 @@ unquote_mailcap_loop(char *qstr, char *type, char *name, char *attr, int *stat, (q == attr || IS_SPACE(*(q - 1)) || *(q - 1) == ';') && matchattr(q, tmp->ptr, tmp->length, &tmp)) { Strcat_charp(str, quote_mailcap(tmp->ptr, flag)->ptr); - if (stat) - *stat |= MCSTAT_REPPARAM; + if (mc_stat) + *mc_stat |= MCSTAT_REPPARAM; } status = MC_NORMAL; } @@ -416,7 +416,7 @@ unquote_mailcap_loop(char *qstr, char *type, char *name, char *attr, int *stat, } Str -unquote_mailcap(char *qstr, char *type, char *name, char *attr, int *stat) +unquote_mailcap(char *qstr, char *type, char *name, char *attr, int *mc_stat) { - return unquote_mailcap_loop(qstr, type, name, attr, stat, 0); + return unquote_mailcap_loop(qstr, type, name, attr, mc_stat, 0); } diff --git a/main.c b/main.c @@ -56,7 +56,7 @@ JMP_BUF IntReturn; static void cmd_loadfile(char *path); static void cmd_loadURL(char *url, ParsedURL *current); -static void cmd_loadBuffer(Buffer *buf, int prop, int link); +static void cmd_loadBuffer(Buffer *buf, int prop, int linkid); static void keyPressEventProc(int c); #ifdef USE_MARK static void cmd_mark(Lineprop *p); @@ -88,7 +88,7 @@ static int searchKeyNum(void); static void fusage(FILE * f, int err) { - fprintf(f, "version %s\n", version); + fprintf(f, "version %s\n", w3m_version); fprintf(f, "usage: w3m [options] [URL or filename]\noptions:\n"); fprintf(f, " -t tab set tab width\n"); fprintf(f, " -r ignore backspace effect\n"); @@ -211,21 +211,21 @@ wrap_GC_warn_proc(char *msg, GC_word arg) static void sig_chld(int signo) { - int stat; + int p_stat; #ifdef HAVE_WAITPID pid_t pid; - while ((pid = waitpid(-1, &stat, WNOHANG)) > 0) { + while ((pid = waitpid(-1, &p_stat, WNOHANG)) > 0) { ; } #elif HAVE_WAIT3 int pid; - while ((pid = wait3(&stat, WNOHANG, NULL)) > 0) { + while ((pid = wait3(&p_stat, WNOHANG, NULL)) > 0) { ; } #else - wait(&stat); + wait(&p_stat); #endif signal(SIGCHLD, sig_chld); return; @@ -274,6 +274,7 @@ MAIN(int argc, char **argv, char **envp) char search_header = FALSE; char *default_type = NULL; char *post_file = NULL; + char *config_filename = NULL; Str err_msg; #ifndef HAVE_SYS_ERRLIST @@ -294,7 +295,7 @@ MAIN(int argc, char **argv, char **envp) i = strlen(rc_dir); if (i > 1 && rc_dir[i - 1] == '/') rc_dir[i - 1] = '\0'; - config_file = rcFile(CONFIG_FILE); + config_filename = rcFile(CONFIG_FILE); create_option_search_table(); /* argument search 1 */ @@ -304,7 +305,7 @@ MAIN(int argc, char **argv, char **envp) argv[i] = "-dummy"; if (++i >= argc) usage(); - config_file = argv[i]; + config_filename = argv[i]; argv[i] = "-dummy"; } else if (!strcmp("-h", argv[i])) @@ -313,7 +314,7 @@ MAIN(int argc, char **argv, char **envp) } /* initializations */ - init_rc(config_file); + init_rc(config_filename); #ifdef USE_COOKIE initCookie(); #endif /* USE_COOKIE */ @@ -644,7 +645,7 @@ MAIN(int argc, char **argv, char **envp) Strcat_charp(s_page, "<a href='http://w3m.sourceforge.net/'>"); Strcat_m_charp(s_page, "w3m</a>!<p><p>This is w3m version ", - version, + w3m_version, "<br>Written by <a href='mailto:aito@fw.ipsj.or.jp'>Akinori Ito</a>", NULL); #ifdef DEBIAN @@ -1237,7 +1238,7 @@ srchfor(void) MySignalHandler(*prevtrap) (); char *str; int i, n = searchKeyNum(); - int wrapped = 0; + volatile int wrapped = 0; str = inputStrHist("Forward: ", NULL, TextHist); if (str != NULL && *str == '\0') @@ -1269,7 +1270,7 @@ srchbak(void) MySignalHandler(*prevtrap) (); char *str; int i, n = searchKeyNum(); - int wrapped = 0; + volatile int wrapped = 0; str = inputStrHist("Backward: ", NULL, TextHist); if (str != NULL && *str == '\0') @@ -1295,10 +1296,10 @@ srchbak(void) } static void -srch_nxtprv(int reverse) +srch_nxtprv(volatile int reverse) { int i; - int wrapped = 0; + volatile int wrapped = 0; static int (*routine[2]) (Buffer *, char *) = { forwardSearch, backwardSearch}; MySignalHandler(*prevtrap) (); @@ -3498,7 +3499,7 @@ goURL(void) } static void -cmd_loadBuffer(Buffer *buf, int prop, int link) +cmd_loadBuffer(Buffer *buf, int prop, int linkid) { if (buf == NULL) { disp_err_message("Can't load string", FALSE); @@ -3507,9 +3508,9 @@ cmd_loadBuffer(Buffer *buf, int prop, int link) buf->bufferprop |= (BP_INTERNAL | prop); if (!(buf->bufferprop & BP_NO_URL)) copyParsedURL(&buf->currentURL, &Currentbuf->currentURL); - if (link != LB_NOLINK) { - buf->linkBuffer[REV_LB[link]] = Currentbuf; - Currentbuf->linkBuffer[link] = buf; + if (linkid != LB_NOLINK) { + buf->linkBuffer[REV_LB[linkid]] = Currentbuf; + Currentbuf->linkBuffer[linkid] = buf; } pushBuffer(buf); } @@ -4401,7 +4402,7 @@ mouse() int gpm_process_mouse(Gpm_Event * event, void *data) { - int btn, x, y; + int btn = MOUSE_BTN_RESET, x, y; if (event->type & GPM_UP) btn = MOUSE_BTN_UP; else if (event->type & GPM_DOWN) { @@ -4454,7 +4455,7 @@ sysm_process_mouse(int x, int y, int nbs, int obs) void dispVer() { - disp_message(Sprintf("w3m version %s", version)->ptr, FALSE); + disp_message(Sprintf("w3m version %s", w3m_version)->ptr, FALSE); } void diff --git a/menu.c b/menu.c @@ -383,11 +383,11 @@ new_menu(Menu *menu, MenuItem *item) } void -geom_menu(Menu *menu, int x, int y, int select) +geom_menu(Menu *menu, int x, int y, int mselect) { int win_x, win_y, win_w, win_h; - menu->select = select; + menu->select = mselect; if (menu->width % FRAME_WIDTH) menu->width = (menu->width / FRAME_WIDTH + 1) * FRAME_WIDTH; @@ -405,7 +405,7 @@ geom_menu(Menu *menu, int x, int y, int select) } menu->x = win_x + FRAME_WIDTH; - win_y = menu->y - select - 1; + win_y = menu->y - mselect - 1; win_h = menu->height + 2; if (win_y + win_h > LASTLINE) win_y = LASTLINE - win_h; @@ -414,8 +414,8 @@ geom_menu(Menu *menu, int x, int y, int select) if (win_y + win_h > LASTLINE) { win_h = LASTLINE - win_y; menu->height = win_h - 2; - if (menu->height <= select) - menu->offset = select - menu->height + 1; + if (menu->height <= mselect) + menu->offset = mselect - menu->height + 1; } } menu->y = win_y + 1; @@ -506,32 +506,32 @@ draw_menu(Menu *menu) } void -draw_menu_item(Menu *menu, int select) +draw_menu_item(Menu *menu, int mselect) { - mvaddnstr(menu->y + select - menu->offset, menu->x, - menu->item[select].label, menu->width); + mvaddnstr(menu->y + mselect - menu->offset, menu->x, + menu->item[mselect].label, menu->width); } int -select_menu(Menu *menu, int select) +select_menu(Menu *menu, int mselect) { - if (select < 0 || select >= menu->nitem) + if (mselect < 0 || mselect >= menu->nitem) return (MENU_NOTHING); - if (select < menu->offset) - up_menu(menu, menu->offset - select); - else if (select >= menu->offset + menu->height) - down_menu(menu, select - menu->offset - menu->height + 1); + if (mselect < menu->offset) + up_menu(menu, menu->offset - mselect); + else if (mselect >= menu->offset + menu->height) + down_menu(menu, mselect - menu->offset - menu->height + 1); if (menu->select >= menu->offset && menu->select < menu->offset + menu->height) draw_menu_item(menu, menu->select); - menu->select = select; + menu->select = mselect; standout(); draw_menu_item(menu, menu->select); standend(); /* * move(menu->cursorY, menu->cursorX); */ - move(menu->y + select - menu->offset, menu->x); + move(menu->y + mselect - menu->offset, menu->x); toggle_stand(); refresh(); @@ -539,26 +539,26 @@ select_menu(Menu *menu, int select) } void -goto_menu(Menu *menu, int select, int down) +goto_menu(Menu *menu, int mselect, int down) { int select_in; - if (select >= menu->nitem) - select = menu->nitem - 1; - else if (select < 0) - select = 0; - select_in = select; - while (menu->item[select].type == MENU_NOP) { + if (mselect >= menu->nitem) + mselect = menu->nitem - 1; + else if (mselect < 0) + mselect = 0; + select_in = mselect; + while (menu->item[mselect].type == MENU_NOP) { if (down > 0) { - if (++select >= menu->nitem) { + if (++mselect >= menu->nitem) { down_menu(menu, select_in - menu->select); - select = menu->select; + mselect = menu->select; break; } } else if (down < 0) { - if (--select < 0) { + if (--mselect < 0) { up_menu(menu, menu->select - select_in); - select = menu->select; + mselect = menu->select; break; } } @@ -566,7 +566,7 @@ goto_menu(Menu *menu, int select, int down) return; } } - select_menu(menu, select); + select_menu(menu, mselect); } void @@ -597,7 +597,7 @@ int action_menu(Menu *menu) { char c; - int select; + int mselect; MenuItem item; if (menu->active == 0) { @@ -619,21 +619,21 @@ action_menu(Menu *menu) mouse_inactive(); #if defined(USE_GPM) || defined(USE_SYSMOUSE) if (c == X_MOUSE_SELECTED) { - select = X_Mouse_Selection; - if (select != MENU_NOTHING) + mselect = X_Mouse_Selection; + if (mselect != MENU_NOTHING) break; } #endif /* defined(USE_GPM) || * * * * * * * defined(USE_SYSMOUSE) */ #endif /* USE_MOUSE */ if (IS_ASCII(c)) { /* Ascii */ - select = (*menu->keymap[(int)c]) (c); - if (select != MENU_NOTHING) + mselect = (*menu->keymap[(int)c]) (c); + if (mselect != MENU_NOTHING) break; } } - if (select >= 0 && select < menu->nitem) { - item = menu->item[select]; + if (mselect >= 0 && mselect < menu->nitem) { + item = menu->item[mselect]; if (item.type & MENU_POPUP) { popup_menu(menu, item.popup); return (1); @@ -650,7 +650,7 @@ action_menu(Menu *menu) CurrentMenuData = NULL; } } - else if (select == MENU_CLOSE) { + else if (mselect == MENU_CLOSE) { if (menu->parent != NULL) menu->parent->active = 0; } @@ -845,24 +845,24 @@ mTop(char c) static int mNext(char c) { - int select = CurrentMenu->select + CurrentMenu->height; + int mselect = CurrentMenu->select + CurrentMenu->height; - if (select >= CurrentMenu->nitem) + if (mselect >= CurrentMenu->nitem) return mLast(c); down_menu(CurrentMenu, CurrentMenu->height); - goto_menu(CurrentMenu, select, -1); + goto_menu(CurrentMenu, mselect, -1); return (MENU_NOTHING); } static int mPrev(char c) { - int select = CurrentMenu->select - CurrentMenu->height; + int mselect = CurrentMenu->select - CurrentMenu->height; - if (select < 0) + if (mselect < 0) return mTop(c); up_menu(CurrentMenu, CurrentMenu->height); - goto_menu(CurrentMenu, select, 1); + goto_menu(CurrentMenu, mselect, 1); return (MENU_NOTHING); } @@ -889,11 +889,11 @@ mBack(char c) static int mOk(char c) { - int select = CurrentMenu->select; + int mselect = CurrentMenu->select; - if (CurrentMenu->item[select].type == MENU_NOP) + if (CurrentMenu->item[mselect].type == MENU_NOP) return (MENU_NOTHING); - return (select); + return (mselect); } static int @@ -963,10 +963,10 @@ menu_search_forward(Menu *menu, int from) static int mSrchF(char c) { - int select; - select = menu_search_forward(CurrentMenu, CurrentMenu->select); - if (select >= 0) - goto_menu(CurrentMenu, select, 1); + int mselect; + mselect = menu_search_forward(CurrentMenu, CurrentMenu->select); + if (mselect >= 0) + goto_menu(CurrentMenu, mselect, 1); return (MENU_NOTHING); } @@ -1012,10 +1012,10 @@ menu_search_backward(Menu *menu, int from) static int mSrchB(char c) { - int select; - select = menu_search_backward(CurrentMenu, CurrentMenu->select); - if (select >= 0) - goto_menu(CurrentMenu, select, -1); + int mselect; + mselect = menu_search_backward(CurrentMenu, CurrentMenu->select); + if (mselect >= 0) + goto_menu(CurrentMenu, mselect, -1); return (MENU_NOTHING); } @@ -1048,20 +1048,20 @@ menu_search_next_previous(Menu *menu, int from, int reverse) static int mSrchN(char c) { - int select; - select = menu_search_next_previous(CurrentMenu, CurrentMenu->select, 0); - if (select >= 0) - goto_menu(CurrentMenu, select, 1); + int mselect; + mselect = menu_search_next_previous(CurrentMenu, CurrentMenu->select, 0); + if (mselect >= 0) + goto_menu(CurrentMenu, mselect, 1); return (MENU_NOTHING); } static int mSrchP(char c) { - int select; - select = menu_search_next_previous(CurrentMenu, CurrentMenu->select, 1); - if (select >= 0) - goto_menu(CurrentMenu, select, -1); + int mselect; + mselect = menu_search_next_previous(CurrentMenu, CurrentMenu->select, 1); + if (mselect >= 0) + goto_menu(CurrentMenu, mselect, -1); return (MENU_NOTHING); } @@ -1081,7 +1081,7 @@ static int process_mMouse(int btn, int x, int y) { Menu *menu; - int select; + int mselect; static int press_btn = MOUSE_BTN_RESET, press_x, press_y; char c = ' '; @@ -1112,10 +1112,10 @@ process_mMouse(int btn, int x, int y) return (MENU_NOTHING); } else { - select = y - menu->y + menu->offset; - if (menu->item[select].type == MENU_NOP) + mselect = y - menu->y + menu->offset; + if (menu->item[mselect].type == MENU_NOP) return (MENU_NOTHING); - return (select_menu(menu, select)); + return (select_menu(menu, mselect)); } } } @@ -1149,7 +1149,7 @@ mMouse(char c) static int gpm_process_menu_mouse(Gpm_Event * event, void *data) { - int btn, x, y; + int btn = MOUSE_BTN_RESET, x, y; if (event->type & GPM_UP) btn = MOUSE_BTN_UP; else if (event->type & GPM_DOWN) { @@ -1340,7 +1340,7 @@ smChBuf(void) static int smDelBuf(char c) { - int i, x, y, select; + int i, x, y, mselect; Buffer *buf; if (CurrentMenu->select < 0 || CurrentMenu->select >= SelectMenu.nitem) @@ -1359,7 +1359,7 @@ smDelBuf(char c) x = CurrentMenu->x; y = CurrentMenu->y; - select = CurrentMenu->select; + mselect = CurrentMenu->select; initSelectMenu(); @@ -1368,7 +1368,7 @@ smDelBuf(char c) geom_menu(CurrentMenu, x, y, 0); - CurrentMenu->select = (select <= CurrentMenu->nitem - 2) ? select + CurrentMenu->select = (mselect <= CurrentMenu->nitem - 2) ? mselect : (CurrentMenu->nitem - 2); displayBuffer(Currentbuf, B_FORCE_REDRAW); @@ -1407,8 +1407,8 @@ initMenu(void) FILE *mf; Str line; char *p, *s; - int in_menu, nmenu, nitem, type; - MenuItem *item; + int in_menu, nmenu = 0, nitem = 0, type; + MenuItem *item = NULL; MenuList *list; w3mMenuList = New_N(MenuList, 3); diff --git a/parsetagx.c b/parsetagx.c @@ -102,7 +102,7 @@ parse_tag(char **s, int internal) int tag_id; char tagname[MAX_TAG_LEN], attrname[MAX_TAG_LEN]; char *p, *q; - int i, attr_id, nattr; + int i, attr_id = 0, nattr; /* Parse tag name */ q = (*s) + 1; diff --git a/proto.h b/proto.h @@ -415,7 +415,7 @@ extern struct mailcap *searchMailcap(struct mailcap *table, char *type); extern void initMailcap(); extern struct mailcap *searchExtViewer(char *type); extern Str unquote_mailcap(char *qstr, char *type, char *name, char *attr, - int *stat); + int *mc_stat); extern char *guessContentType(char *filename); extern TextList *make_domain_list(char *domain_list); extern int check_no_proxy(char *domain); @@ -456,7 +456,7 @@ extern Str encodeB(char *a); extern int set_param_option(char *option); extern char *get_param_option(char *name); extern void create_option_search_table(); -extern void init_rc(char *config_file); +extern void init_rc(char *config_filename); extern Buffer *load_option_panel(void); extern void panel_set_option(struct parsed_tagarg *); extern void sync_with_option(void); @@ -533,12 +533,12 @@ extern char *getQWord(char **str); #ifdef USE_MENU extern void new_menu(Menu *menu, MenuItem *item); -extern void geom_menu(Menu *menu, int x, int y, int select); +extern void geom_menu(Menu *menu, int x, int y, int mselect); extern void draw_all_menu(Menu *menu); extern void draw_menu(Menu *menu); -extern void draw_menu_item(Menu *menu, int select); -extern int select_menu(Menu *menu, int select); -extern void goto_menu(Menu *menu, int select, int down); +extern void draw_menu_item(Menu *menu, int mselect); +extern int select_menu(Menu *menu, int mselect); +extern void goto_menu(Menu *menu, int mselect, int down); extern void up_menu(Menu *menu, int n); extern void down_menu(Menu *menu, int n); extern int action_menu(Menu *menu); diff --git a/rc.c b/rc.c @@ -34,6 +34,7 @@ static struct rc_search_table *RC_search_table; static int RC_table_size; static int rc_initialized = 0; +static char *config_file = NULL; #define P_INT 0 #define P_SHORT 1 @@ -702,7 +703,7 @@ void show_params(FILE * fp) { int i, j, l; - char *t; + char *t = NULL; char *cmt; fputs("\nconfiguration parameters\n", fp); @@ -1153,7 +1154,7 @@ sync_with_option(void) } void -init_rc(char *config_file) +init_rc(char *config_filename) { struct stat st; FILE *f; @@ -1200,6 +1201,7 @@ init_rc(char *config_file) interpret_rc(f); fclose(f); } + config_file = config_filename; if (config_file == NULL) config_file = rcFile(CONFIG_FILE); if ((f = fopen(config_file, "rt")) != NULL) { @@ -1248,7 +1250,7 @@ to_str(struct param_ptr *p) Buffer * load_option_panel(void) { - Str src = Sprintf(optionpanel_src1, version, CMT_HELPER); + Str src = Sprintf(optionpanel_src1, w3m_version, CMT_HELPER); struct param_ptr *p; struct sel_c *s; int x, i; diff --git a/table.c b/table.c @@ -470,7 +470,7 @@ visible_length(char *str) int prev_status = status; Str tagbuf = Strnew(); char *t, *r2; - int amp_len; + int amp_len = 0; t = str; while (*str) { @@ -938,7 +938,7 @@ set_integered_width(struct table *t, double *dwidth, short *iwidth) int i, j, k, n, bcol, ecol, step; char *index, *fixed; double *mod; - double sum = 0., x; + double sum = 0., x = 0.; struct table_cell *cell = &t->cell; int rulewidth = table_rule_width(t); @@ -1483,7 +1483,7 @@ check_table_height(struct table *t) short maxcell; short height[MAXCELL]; } cell; - int space; + int space = 0; cell.maxcell = -1; @@ -1680,7 +1680,7 @@ renderTable(struct table *t, int max_width, struct html_feed_environ *h_env) #endif /* MATRIX */ int width; int rulewidth; - Str vrulea, vruleb, vrulec; + Str vrulea = NULL, vruleb = NULL, vrulec = NULL; #ifdef ID_EXT Str idtag; #endif /* ID_EXT */ diff --git a/terms.c b/terms.c @@ -842,7 +842,7 @@ switch_wchar(FILE * f) void putchars(unsigned char c1, unsigned char c2, FILE * f) { - Str s; + Str s = NULL; char *p; switch (DisplayCode) { diff --git a/url.c b/url.c @@ -349,10 +349,10 @@ baseURL(Buffer *buf) } int -openSocket(char *hostname, +openSocket(char *volatile hostname, char *remoteport_name, unsigned short remoteport_num) { - int sock = -1; + volatile int sock = -1; #ifdef INET6 int *af; struct addrinfo hints, *res0, *res; @@ -365,7 +365,7 @@ openSocket(char *hostname, int a1, a2, a3, a4; unsigned long adr; #endif /* not INET6 */ - MySignalHandler(*trap) (); + MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL; if (fmInitialized) { message(Sprintf("Opening socket...")->ptr, 0, 0); @@ -481,7 +481,7 @@ openSocket(char *hostname, } else { char **h_addr_list; - int result; + int result = -1; if (fmInitialized) { message(Sprintf("Performing hostname lookup on %s", hostname)->ptr, 0, 0); @@ -1123,7 +1123,7 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer) Strcat_charp(s, "User-Agent: "); if (UserAgent == NULL || *UserAgent == '\0') - Strcat_charp(s, version); + Strcat_charp(s, w3m_version); else Strcat_charp(s, UserAgent); Strcat_charp(s, "\r\n"); @@ -1289,7 +1289,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, URLFile uf; HRequest hr; #ifdef USE_SSL - SSL *sslh; + SSL *sslh = NULL; #endif /* USE_SSL */ #ifdef USE_NNTP FILE *fw; diff --git a/version.c b/version.c @@ -2,5 +2,5 @@ #define CURRENT_VERSION "w3m/0.2.2" #ifndef FM_H -char *version = CURRENT_VERSION; +char *w3m_version = CURRENT_VERSION; #endif /* not FM_H */