w3m

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

commit 39a016b1dd687f746fba2b12ff3eff4e2fc1dd84
parent f67c089a5f31b4c4c43955b96d46836e75d6febc
Author: ukai <ukai>
Date:   Sun,  9 Dec 2001 13:59:04 +0000

[w3m-dev 02646]
From: Kiyokazu SUTO <suto@ks-and-ks.ne.jp>

Diffstat:
MChangeLog | 14++++++++++++++
Mconfigure | 26++++++++++++++------------
Metc.c | 45++++++++++-----------------------------------
Mfile.c | 13+++++++------
Mfm.h | 3+++
Mproto.h | 2+-
Mterms.c | 11+++--------
7 files changed, 52 insertions(+), 62 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,17 @@ +2001-12-09 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> + + * [w3m-dev 02646] Some code cleanups + * configure: use host libgc instead of gc/gc.a on Linux and/or AIX + if possible + * etc.c (get_cmd): deleted, merged into gethtmlcmd() + * etc.c (gethtmlcmd): merge get_cmd() code + * file.c (uncompressed_file_type): initialize slen + * file.c (passthrough): status deleted + * file.c (HTMLlineproc0): istr deleted, gethtmlcmd() argument fix + * fm.h (_GNU_SOURCE): ifndef _GNU_SOURCE + * proto.h (gethtmlcmd): fix prototypes + * terms.c: include <sys/ioctl.h> always + 2001-12-09 Fumitoshi UKAI <ukai@debian.or.jp> * [w3m-dev 02645] diff --git a/configure b/configure @@ -967,18 +967,20 @@ done case $sysname in linux|Linux|LINUX|aix|Aix|AIX) - case $cflags in - *DEBIAN*) - # on Debian, we can use libgc*.deb - :;; - *) - # these OS requires gcmain.c, which include gc/gc_priv.h - # therefore we use gc library comes with w3m - echo "Your OS is $sysname; using gc library comes with w3m." - gcinclude="" - gclib="" - ;; - esac + if [ ! -f "$gcinclude/private/gc_priv.h" ]; then + case $cflags in + *DEBIAN*) + # on Debian, we can use libgc*.deb + :;; + *) + # these OS requires gcmain.c, which include gc/gc_priv.h + # therefore we use gc library comes with w3m + echo "Your OS is $sysname; using gc library comes with w3m." + gcinclude="" + gclib="" + ;; + esac + fi ;; esac diff --git a/etc.c b/etc.c @@ -171,24 +171,21 @@ currentLineSkip(Buffer *buf, Line *line, int offset, int last) #define MAX_CMD_LEN 128 -static int -get_cmd(Hash_si * hash, - char **s, - char *args, - char termchar, int defaultcmd, int allow_space, int *status) +int +gethtmlcmd(char **s) { + extern Hash_si tagtable; char cmdstr[MAX_CMD_LEN]; char *p = cmdstr; char *save = *s; int cmd; - if (status) - *status = 0; + (*s)++; /* first character */ if (IS_ALNUM(**s) || **s == '_' || **s == '/') *(p++) = tolower(*((*s)++)); else - return defaultcmd; + return HTML_UNKNOWN; if (p[-1] == '/') SKIP_BLANKS(*s); while ((IS_ALNUM(**s) || **s == '_') && p - cmdstr < MAX_CMD_LEN) { @@ -197,41 +194,19 @@ get_cmd(Hash_si * hash, if (p - cmdstr == MAX_CMD_LEN) { /* buffer overflow: perhaps caused by bad HTML source */ *s = save + 1; - if (status) - *status = -1; - return defaultcmd; + return HTML_UNKNOWN; } *p = '\0'; /* hash search */ - cmd = getHash_si(hash, cmdstr, defaultcmd); - if (args != NULL) { - p = args; - while (**s == ' ' || **s == '\t') - (*s)++; - while (**s && **s != '\n' && **s != '\r' && **s != termchar) { - *(p++) = *((*s)++); - } - *p = '\0'; - } - else if (allow_space) { - while (**s && **s != termchar) - (*s)++; - } - if (**s == termchar) + cmd = getHash_si(&tagtable, cmdstr, HTML_UNKNOWN); + while (**s && **s != '>') + (*s)++; + if (**s == '>') (*s)++; - else if (status) - *status = -1; return cmd; } -int -gethtmlcmd(char **s, int *status) -{ - extern Hash_si tagtable; - return get_cmd(&tagtable, s, NULL, '>', HTML_UNKNOWN, TRUE, status); -} - static char * searchAnchorArg(char **arg) { diff --git a/file.c b/file.c @@ -293,6 +293,7 @@ uncompressed_file_type(char *path, char **ext) if (path == NULL) return NULL; + slen = 0; len = strlen(path); for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { if (d->ext == NULL) @@ -1804,7 +1805,7 @@ sloppy_parse_line(char **str) static void passthrough(struct readbuffer *obuf, char *str, int back) { - int status, cmd; + int cmd; Str tok = Strnew(); char *str_bak; @@ -1817,7 +1818,7 @@ passthrough(struct readbuffer *obuf, char *str, int back) str_bak = str; if (sloppy_parse_line(&str)) { char *q = str_bak; - cmd = gethtmlcmd(&q, &status); + cmd = gethtmlcmd(&q); if (back) { struct link_stack *p; for (p = link_stack; p; p = p->next) { @@ -4276,10 +4277,10 @@ table_width(struct html_feed_environ *h_env, int table_level) /* HTML processing first pass */ void -HTMLlineproc0(char *istr, struct html_feed_environ *h_env, int internal) +HTMLlineproc0(char *str, struct html_feed_environ *h_env, int internal) { Lineprop mode; - char *str = istr, *q; + char *q; int cmd; struct readbuffer *obuf = h_env->obuf; int indent, delta; @@ -4296,7 +4297,7 @@ HTMLlineproc0(char *istr, struct html_feed_environ *h_env, int internal) (obuf->table_level >= 0) ? 'T' : ' ', (obuf->flag & RB_INTXTA) ? 'X' : ' ', (obuf->flag & RB_IGNORE) ? 'I' : ' '); - fprintf(f, "HTMLlineproc1(\"%s\",%d,%lx)\n", istr, h_env->limit, + fprintf(f, "HTMLlineproc1(\"%s\",%d,%lx)\n", str, h_env->limit, (unsigned long)h_env); fclose(f); } @@ -4387,7 +4388,7 @@ HTMLlineproc0(char *istr, struct html_feed_environ *h_env, int internal) } else { char *p = q; - cmd = gethtmlcmd(&p, NULL); + cmd = gethtmlcmd(&p); } /* textarea */ diff --git a/fm.h b/fm.h @@ -10,7 +10,10 @@ #ifndef FM_H #define FM_H + +#ifndef _GNU_SOURCE #define _GNU_SOURCE /* strcasestr() */ +#endif #include <stdio.h> #include <stdlib.h> diff --git a/proto.h b/proto.h @@ -234,7 +234,7 @@ extern int columnSkip(Buffer *buf, int offset); extern int columnPos(Line *line, int column); extern Line *lineSkip(Buffer *buf, Line *line, int offset, int last); extern Line *currentLineSkip(Buffer *buf, Line *line, int offset, int last); -extern int gethtmlcmd(char **s, int *status); +extern int gethtmlcmd(char **s); extern char *getAnchor(char *arg, char **arg_return); extern Str checkType(Str s, Lineprop *oprop, #ifdef USE_ANSI_COLOR diff --git a/terms.c b/terms.c @@ -15,6 +15,7 @@ #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> #endif +#include <sys/ioctl.h> #ifdef USE_MOUSE #ifdef USE_GPM #include <gpm.h> @@ -234,8 +235,7 @@ void flush_tty(); #endif /* not SIGIOT */ #ifdef HAVE_TERMIO_H -#include <sys/ioctl.h> -#include <termio.h> +#include <termio.h> typedef struct termio TerminalMode; #define TerminalSet(fd,x) ioctl(fd,TCSETA,x) #define TerminalGet(fd,x) ioctl(fd,TCGETA,x) @@ -254,8 +254,7 @@ typedef struct termios TerminalMode; #endif /* HAVE_TERMIOS_H */ #ifdef HAVE_SGTTY_H -#include <sys/ioctl.h> -#include <sgtty.h> +#include <sgtty.h> typedef struct sgttyb TerminalMode; #define TerminalSet(fd,x) ioctl(fd,TIOCSETP,x) #define TerminalGet(fd,x) ioctl(fd,TIOCGETP,x) @@ -655,10 +654,6 @@ getTCstr(void) setgraphchar(); } -#ifndef TIOCGWINSZ -#include <sys/ioctl.h> -#endif /* not TIOCGWINSZ */ - void setlinescols(void) {