diff options
135 files changed, 2290 insertions, 16645 deletions
| diff --git a/.#file.c.1.243 b/.#file.c.1.243 deleted file mode 100644 index 411aa7a..0000000 --- a/.#file.c.1.243 +++ /dev/null @@ -1,8188 +0,0 @@ -/* $Id: file.c,v 1.243 2006/05/29 12:54:26 inu Exp $ */ -#include "fm.h" -#include <sys/types.h> -#include "myctype.h" -#include <signal.h> -#include <setjmp.h> -#if defined(HAVE_WAITPID) || defined(HAVE_WAIT3) -#include <sys/wait.h> -#endif -#include <stdio.h> -#include <time.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <utime.h> -/* foo */ - -#include "html.h" -#include "parsetagx.h" -#include "local.h" -#include "regex.h" - -#ifndef max -#define max(a,b)        ((a) > (b) ? (a) : (b)) -#endif				/* not max */ -#ifndef min -#define min(a,b)        ((a) > (b) ? (b) : (a)) -#endif				/* not min */ - -static int frame_source = 0; - -static char *guess_filename(char *file); -static int _MoveFile(char *path1, char *path2); -static void uncompress_stream(URLFile *uf, char **src); -static FILE *lessopen_stream(char *path); -static Buffer *loadcmdout(char *cmd, -			  Buffer *(*loadproc) (URLFile *, Buffer *), -			  Buffer *defaultbuf); -#ifndef USE_ANSI_COLOR -#define addnewline(a,b,c,d,e,f,g) _addnewline(a,b,c,e,f,g) -#endif -static void addnewline(Buffer *buf, char *line, Lineprop *prop, -		       Linecolor *color, int pos, int width, int nlines); -static void addLink(Buffer *buf, struct parsed_tag *tag); - -static JMP_BUF AbortLoading; - -static struct table *tables[MAX_TABLE]; -static struct table_mode table_mode[MAX_TABLE]; - -#ifdef USE_IMAGE -static ParsedURL *cur_baseURL = NULL; -#ifdef USE_M17N -static char cur_document_charset; -#endif -#endif - -static Str cur_title; -static Str cur_select; -static Str select_str; -static int select_is_multiple; -static int n_selectitem; -static Str cur_option; -static Str cur_option_value; -static Str cur_option_label; -static int cur_option_selected; -static int cur_status; -#ifdef MENU_SELECT -/* menu based <select>  */ -FormSelectOption *select_option; -static int max_select = MAX_SELECT; -static int n_select; -static int cur_option_maxwidth; -#endif				/* MENU_SELECT */ - -static Str cur_textarea; -Str *textarea_str; -static int cur_textarea_size; -static int cur_textarea_rows; -static int cur_textarea_readonly; -static int n_textarea; -static int ignore_nl_textarea; -static int max_textarea = MAX_TEXTAREA; - -static int http_response_code; - -#ifdef USE_M17N -static wc_ces content_charset = 0; -static wc_ces meta_charset = 0; -static char *check_charset(char *p); -static char *check_accept_charset(char *p); -#endif - -#define set_prevchar(x,y,n) Strcopy_charp_n((x),(y),(n)) -#define set_space_to_prevchar(x) Strcopy_charp_n((x)," ",1) - -struct link_stack { -    int cmd; -    short offset; -    short pos; -    struct link_stack *next; -}; - -static struct link_stack *link_stack = NULL; - -#define FORMSTACK_SIZE 10 -#define FRAMESTACK_SIZE 10 - -#ifdef USE_NNTP -#define Str_news_endline(s) ((s)->ptr[0]=='.'&&((s)->ptr[1]=='\n'||(s)->ptr[1]=='\r'||(s)->ptr[1]=='\0')) -#endif				/* USE_NNTP */ - -#define INITIAL_FORM_SIZE 10 -static FormList **forms; -static int *form_stack; -static int form_max = -1; -static int forms_size = 0; -#define cur_form_id ((form_sp >= 0)? form_stack[form_sp] : -1) -static int form_sp = 0; - -static clen_t current_content_length; - -static int cur_hseq; -#ifdef USE_IMAGE -static int cur_iseq; -#endif - -#define MAX_UL_LEVEL	9 -#define UL_SYMBOL(x)	(N_GRAPH_SYMBOL + (x)) -#define UL_SYMBOL_DISC		UL_SYMBOL(9) -#define UL_SYMBOL_CIRCLE	UL_SYMBOL(10) -#define UL_SYMBOL_SQUARE	UL_SYMBOL(11) -#define IMG_SYMBOL		UL_SYMBOL(12) -#define HR_SYMBOL	26 - -#ifdef USE_COOKIE -/* This array should be somewhere else */ -/* FIXME: gettextize? */ -char *violations[COO_EMAX] = { -    "internal error", -    "tail match failed", -    "wrong number of dots", -    "RFC 2109 4.3.2 rule 1", -    "RFC 2109 4.3.2 rule 2.1", -    "RFC 2109 4.3.2 rule 2.2", -    "RFC 2109 4.3.2 rule 3", -    "RFC 2109 4.3.2 rule 4", -    "RFC XXXX 4.3.2 rule 5" -}; -#endif - -/* *INDENT-OFF* */ -static struct compression_decoder { -    int type; -    char *ext; -    char *mime_type; -    int auxbin_p; -    char *cmd; -    char *name; -    char *encoding; -    char *encodings[4]; -} compression_decoders[] = { -    { CMP_COMPRESS, ".gz", "application/x-gzip", -      0, GUNZIP_CMDNAME, GUNZIP_NAME, "gzip",  -      {"gzip", "x-gzip", NULL} },  -    { CMP_COMPRESS, ".Z", "application/x-compress", -      0, GUNZIP_CMDNAME, GUNZIP_NAME, "compress", -      {"compress", "x-compress", NULL} },  -    { CMP_BZIP2, ".bz2", "application/x-bzip", -      0, BUNZIP2_CMDNAME, BUNZIP2_NAME, "bzip, bzip2", -      {"x-bzip", "bzip", "bzip2", NULL} },  -    { CMP_DEFLATE, ".deflate", "application/x-deflate", -      1, INFLATE_CMDNAME, INFLATE_NAME, "deflate", -      {"deflate", "x-deflate", NULL} },  -    { CMP_NOCOMPRESS, NULL, NULL, 0, NULL, NULL, NULL, {NULL}}, -}; -/* *INDENT-ON* */ - -#define SAVE_BUF_SIZE 1536 - -static MySignalHandler -KeyAbort(SIGNAL_ARG) -{ -    LONGJMP(AbortLoading, 1); -    SIGNAL_RETURN; -} - -static void -UFhalfclose(URLFile *f) -{ -    switch (f->scheme) { -    case SCM_FTP: -	closeFTP(); -	break; -#ifdef USE_NNTP -    case SCM_NEWS: -    case SCM_NNTP: -	closeNews(); -	break; -#endif -    default: -	UFclose(f); -	break; -    } -} - -int -currentLn(Buffer *buf) -{ -    if (buf->currentLine) -	/*     return buf->currentLine->real_linenumber + 1;      */ -	return buf->currentLine->linenumber + 1; -    else -	return 1; -} - -static Buffer * -loadSomething(URLFile *f, -	      char *path, -	      Buffer *(*loadproc) (URLFile *, Buffer *), Buffer *defaultbuf) -{ -    Buffer *buf; - -    if ((buf = loadproc(f, defaultbuf)) == NULL) -	return NULL; - -    buf->filename = path; -    if (buf->buffername == NULL || buf->buffername[0] == '\0') { -	buf->buffername = checkHeader(buf, "Subject:"); -	if (buf->buffername == NULL) -	    buf->buffername = conv_from_system(lastFileName(path)); -    } -    if (buf->currentURL.scheme == SCM_UNKNOWN) -	buf->currentURL.scheme = f->scheme; -    buf->real_scheme = f->scheme; -    if (f->scheme == SCM_LOCAL && buf->sourcefile == NULL) -	buf->sourcefile = path; -    return buf; -} - -int -dir_exist(char *path) -{ -    struct stat stbuf; - -    if (path == NULL || *path == '\0') -	return 0; -    if (stat(path, &stbuf) == -1) -	return 0; -    return IS_DIRECTORY(stbuf.st_mode); -} - -static int -is_dump_text_type(char *type) -{ -    struct mailcap *mcap; -    return (type && (mcap = searchExtViewer(type)) && -	    (mcap->flags & (MAILCAP_HTMLOUTPUT | MAILCAP_COPIOUSOUTPUT))); -} - -static int -is_text_type(char *type) -{ -    return (type == NULL || type[0] == '\0' || -	    strncasecmp(type, "text/", 5) == 0 || -	    strncasecmp(type, "message/", sizeof("message/") - 1) == 0); -} - -static int -is_plain_text_type(char *type) -{ -    return ((type && strcasecmp(type, "text/plain") == 0) || -	    (is_text_type(type) && !is_dump_text_type(type))); -} - -static void -check_compression(char *path, URLFile *uf) -{ -    int len; -    struct compression_decoder *d; - -    if (path == NULL) -	return; - -    len = strlen(path); -    uf->compression = CMP_NOCOMPRESS; -    for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { -	int elen; -	if (d->ext == NULL) -	    continue; -	elen = strlen(d->ext); -	if (len > elen && strcasecmp(&path[len - elen], d->ext) == 0) { -	    uf->compression = d->type; -	    uf->guess_type = d->mime_type; -	    break; -	} -    } -} - -static char * -compress_application_type(int compression) -{ -    struct compression_decoder *d; - -    for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { -	if (d->type == compression) -	    return d->mime_type; -    } -    return NULL; -} - -static char * -uncompressed_file_type(char *path, char **ext) -{ -    int len, slen; -    Str fn; -    char *t0; -    struct compression_decoder *d; - -    if (path == NULL) -	return NULL; - -    slen = 0; -    len = strlen(path); -    for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { -	if (d->ext == NULL) -	    continue; -	slen = strlen(d->ext); -	if (len > slen && strcasecmp(&path[len - slen], d->ext) == 0) -	    break; -    } -    if (d->type == CMP_NOCOMPRESS) -	return NULL; - -    fn = Strnew_charp(path); -    Strshrink(fn, slen); -    if (ext) -	*ext = filename_extension(fn->ptr, 0); -    t0 = guessContentType(fn->ptr); -    if (t0 == NULL) -	t0 = "text/plain"; -    return t0; -} - -static int -setModtime(char *path, time_t modtime) -{ -    struct utimbuf t; -    struct stat st; - -    if (stat(path, &st) == 0) -	t.actime = st.st_atime; -    else -	t.actime = time(NULL); -    t.modtime = modtime; -    return utime(path, &t); -} - -void -examineFile(char *path, URLFile *uf) -{ -    struct stat stbuf; - -    uf->guess_type = NULL; -    if (path == NULL || *path == '\0' || -	stat(path, &stbuf) == -1 || NOT_REGULAR(stbuf.st_mode)) { -	uf->stream = NULL; -	return; -    } -    uf->stream = openIS(path); -    if (!do_download) { -	if (use_lessopen && getenv("LESSOPEN") != NULL) { -	    FILE *fp; -	    uf->guess_type = guessContentType(path); -	    if (uf->guess_type == NULL) -		uf->guess_type = "text/plain"; -	    if (strcasecmp(uf->guess_type, "text/html") == 0) -		return; -	    if ((fp = lessopen_stream(path))) { -		UFclose(uf); -		uf->stream = newFileStream(fp, (void (*)())pclose); -		uf->guess_type = "text/plain"; -		return; -	    } -	} -	check_compression(path, uf); -	if (uf->compression != CMP_NOCOMPRESS) { -	    char *ext = uf->ext; -	    char *t0 = uncompressed_file_type(path, &ext); -	    uf->guess_type = t0; -	    uf->ext = ext; -	    uncompress_stream(uf, NULL); -	    return; -	} -    } -} - -#define S_IXANY	(S_IXUSR|S_IXGRP|S_IXOTH) - -int -check_command(char *cmd, int auxbin_p) -{ -    static char *path = NULL; -    Str dirs; -    char *p, *np; -    Str pathname; -    struct stat st; - -    if (path == NULL) -	path = getenv("PATH"); -    if (auxbin_p) -	dirs = Strnew_charp(w3m_auxbin_dir()); -    else -	dirs = Strnew_charp(path); -    for (p = dirs->ptr; p != NULL; p = np) { -	np = strchr(p, PATH_SEPARATOR); -	if (np) -	    *np++ = '\0'; -	pathname = Strnew(); -	Strcat_charp(pathname, p); -	Strcat_char(pathname, '/'); -	Strcat_charp(pathname, cmd); -	if (stat(pathname->ptr, &st) == 0 && S_ISREG(st.st_mode) -	    && (st.st_mode & S_IXANY) != 0) -	    return 1; -    } -    return 0; -} - -char * -acceptableEncoding() -{ -    static Str encodings = NULL; -    struct compression_decoder *d; -    TextList *l; -    char *p; - -    if (encodings != NULL) -	return encodings->ptr; -    l = newTextList(); -    for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { -	if (check_command(d->cmd, d->auxbin_p)) { -	    pushText(l, d->encoding); -	} -    } -    encodings = Strnew(); -    while ((p = popText(l)) != NULL) { -	if (encodings->length) -	    Strcat_charp(encodings, ", "); -	Strcat_charp(encodings, p); -    } -    return encodings->ptr; -} - -/*  - * convert line - */ -#ifdef USE_M17N -Str -convertLine(URLFile *uf, Str line, int mode, wc_ces * charset, -	    wc_ces doc_charset) -#else -Str -convertLine0(URLFile *uf, Str line, int mode) -#endif -{ -#ifdef USE_M17N -    line = wc_Str_conv_with_detect(line, charset, doc_charset, InnerCharset); -#endif -    if (mode != RAW_MODE) -	cleanup_line(line, mode); -#ifdef USE_NNTP -    if (uf && uf->scheme == SCM_NEWS) -	Strchop(line); -#endif				/* USE_NNTP */ -    return line; -} - -/*  - * loadFile: load file to buffer - */ -Buffer * -loadFile(char *path) -{ -    Buffer *buf; -    URLFile uf; -    init_stream(&uf, SCM_LOCAL, NULL); -    examineFile(path, &uf); -    if (uf.stream == NULL) -	return NULL; -    buf = newBuffer(INIT_BUFFER_WIDTH); -    current_content_length = 0; -#ifdef USE_M17N -    content_charset = 0; -#endif -    buf = loadSomething(&uf, path, loadBuffer, buf); -    UFclose(&uf); -    return buf; -} - -int -matchattr(char *p, char *attr, int len, Str *value) -{ -    int quoted; -    char *q = NULL; - -    if (strncasecmp(p, attr, len) == 0) { -	p += len; -	SKIP_BLANKS(p); -	if (value) { -	    *value = Strnew(); -	    if (*p == '=') { -		p++; -		SKIP_BLANKS(p); -		quoted = 0; -		while (!IS_ENDL(*p) && (quoted || *p != ';')) { -		    if (!IS_SPACE(*p)) -			q = p; -		    if (*p == '"') -			quoted = (quoted) ? 0 : 1; -		    else -			Strcat_char(*value, *p); -		    p++; -		} -		if (q) -		    Strshrink(*value, p - q - 1); -	    } -	    return 1; -	} -	else { -	    if (IS_ENDT(*p)) { -		return 1; -	    } -	} -    } -    return 0; -} - -#ifdef USE_IMAGE -#ifdef USE_XFACE -static char * -xface2xpm(char *xface) -{ -    Image image; -    ImageCache *cache; -    FILE *f; -    struct stat st; - -    SKIP_BLANKS(xface); -    image.url = xface; -    image.ext = ".xpm"; -    image.width = 48; -    image.height = 48; -    image.cache = NULL; -    cache = getImage(&image, NULL, IMG_FLAG_AUTO); -    if (cache->loaded & IMG_FLAG_LOADED && !stat(cache->file, &st)) -	return cache->file; -    cache->loaded = IMG_FLAG_ERROR; - -    f = popen(Sprintf("%s > %s", shell_quote(auxbinFile(XFACE2XPM)), -		      shell_quote(cache->file))->ptr, "w"); -    if (!f) -	return NULL; -    fputs(xface, f); -    pclose(f); -    if (stat(cache->file, &st) || !st.st_size) -	return NULL; -    cache->loaded = IMG_FLAG_LOADED | IMG_FLAG_DONT_REMOVE; -    cache->index = 0; -    return cache->file; -} -#endif -#endif - -void -readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) -{ -    char *p, *q; -#ifdef USE_COOKIE -    char *emsg; -#endif -    char c; -    Str lineBuf2 = NULL; -    Str tmp; -    TextList *headerlist; -#ifdef USE_M17N -    wc_ces charset = WC_CES_US_ASCII, mime_charset; -#endif -    char *tmpf; -    FILE *src = NULL; -    Lineprop *propBuffer; - -    headerlist = newBuf->document_header = newTextList(); -    if (uf->scheme == SCM_HTTP -#ifdef USE_SSL -	|| uf->scheme == SCM_HTTPS -#endif				/* USE_SSL */ -	) -	http_response_code = -1; -    else -	http_response_code = 0; - -    if (thru && !newBuf->header_source -#ifdef USE_IMAGE -	&& !image_source -#endif -	) { -	tmpf = tmpfname(TMPF_DFL, NULL)->ptr; -	src = fopen(tmpf, "w"); -	if (src) -	    newBuf->header_source = tmpf; -    } -    while ((tmp = StrmyUFgets(uf))->length) { -#ifdef USE_NNTP -	if (uf->scheme == SCM_NEWS && tmp->ptr[0] == '.') -	    Strshrinkfirst(tmp, 1); -#endif -#ifdef HTTP_DEBUG -	{ -	    FILE *ff; -	    ff = fopen("zzrequest", "a"); -	    Strfputs(tmp, ff); -	    fclose(ff); -	} -#endif				/* HTTP_DEBUG */ -	if (src) -	    Strfputs(tmp, src); -	cleanup_line(tmp, HEADER_MODE); -	if (tmp->ptr[0] == '\n' || tmp->ptr[0] == '\r' || tmp->ptr[0] == '\0') { -	    if (!lineBuf2) -		/* there is no header */ -		break; -	    /* last header */ -	} -	else if (!(w3m_dump & DUMP_HEAD)) { -	    if (lineBuf2) { -		Strcat(lineBuf2, tmp); -	    } -	    else { -		lineBuf2 = tmp; -	    } -	    c = UFgetc(uf); -	    UFundogetc(uf); -	    if (c == ' ' || c == '\t') -		/* header line is continued */ -		continue; -	    lineBuf2 = decodeMIME(lineBuf2, &mime_charset); -	    lineBuf2 = convertLine(NULL, lineBuf2, RAW_MODE, -				   mime_charset ? &mime_charset : &charset, -				   mime_charset ? mime_charset -				   : DocumentCharset); -	    /* separated with line and stored */ -	    tmp = Strnew_size(lineBuf2->length); -	    for (p = lineBuf2->ptr; *p; p = q) { -		for (q = p; *q && *q != '\r' && *q != '\n'; q++) ; -		lineBuf2 = checkType(Strnew_charp_n(p, q - p), &propBuffer, -				     NULL); -		Strcat(tmp, lineBuf2); -		if (thru) -		    addnewline(newBuf, lineBuf2->ptr, propBuffer, NULL, -			       lineBuf2->length, FOLD_BUFFER_WIDTH, -1); -		for (; *q && (*q == '\r' || *q == '\n'); q++) ; -	    } -#ifdef USE_IMAGE -	    if (thru && activeImage && displayImage) { -		Str src = NULL; -		if (!strncasecmp(tmp->ptr, "X-Image-URL:", 12)) { -		    tmpf = &tmp->ptr[12]; -		    SKIP_BLANKS(tmpf); -		    src = Strnew_m_charp("<img src=\"", html_quote(tmpf), -					 "\" alt=\"X-Image-URL\">", NULL); -		} -#ifdef USE_XFACE -		else if (!strncasecmp(tmp->ptr, "X-Face:", 7)) { -		    tmpf = xface2xpm(&tmp->ptr[7]); -		    if (tmpf) -			src = Strnew_m_charp("<img src=\"file:", -					     html_quote(tmpf), -					     "\" alt=\"X-Face\"", -					     " width=48 height=48>", NULL); -		} -#endif -		if (src) { -		    URLFile f; -		    Line *l; -#ifdef USE_M17N -		    wc_ces old_charset = newBuf->document_charset; -#endif -		    init_stream(&f, SCM_LOCAL, newStrStream(src)); -		    loadHTMLstream(&f, newBuf, NULL, TRUE); -		    for (l = newBuf->lastLine; l && l->real_linenumber; -			 l = l->prev) -			l->real_linenumber = 0; -#ifdef USE_M17N -		    newBuf->document_charset = old_charset; -#endif -		} -	    } -#endif -	    lineBuf2 = tmp; -	} -	else { -	    lineBuf2 = tmp; -	} -	if ((uf->scheme == SCM_HTTP -#ifdef USE_SSL -	     || uf->scheme == SCM_HTTPS -#endif				/* USE_SSL */ -	    ) && http_response_code == -1) { -	    p = lineBuf2->ptr; -	    while (*p && !IS_SPACE(*p)) -		p++; -	    while (*p && IS_SPACE(*p)) -		p++; -	    http_response_code = atoi(p); -	    if (fmInitialized) { -		message(lineBuf2->ptr, 0, 0); -		refresh(); -	    } -	} -	if (!strncasecmp(lineBuf2->ptr, "content-transfer-encoding:", 26)) { -	    p = lineBuf2->ptr + 26; -	    while (IS_SPACE(*p)) -		p++; -	    if (!strncasecmp(p, "base64", 6)) -		uf->encoding = ENC_BASE64; -	    else if (!strncasecmp(p, "quoted-printable", 16)) -		uf->encoding = ENC_QUOTE; -	    else if (!strncasecmp(p, "uuencode", 8) || -		     !strncasecmp(p, "x-uuencode", 10)) -		uf->encoding = ENC_UUENCODE; -	    else -		uf->encoding = ENC_7BIT; -	} -	else if (!strncasecmp(lineBuf2->ptr, "content-encoding:", 17)) { -	    struct compression_decoder *d; -	    p = lineBuf2->ptr + 17; -	    while (IS_SPACE(*p)) -		p++; -	    uf->compression = CMP_NOCOMPRESS; -	    for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { -		char **e; -		for (e = d->encodings; *e != NULL; e++) { -		    if (strncasecmp(p, *e, strlen(*e)) == 0) { -			uf->compression = d->type; -			break; -		    } -		} -		if (uf->compression != CMP_NOCOMPRESS) -		    break; -	    } -	    uf->content_encoding = uf->compression; -	} -#ifdef USE_COOKIE -	else if (use_cookie && accept_cookie && -		 pu && check_cookie_accept_domain(pu->host) && -		 (!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, tmp2; -	    int version, quoted, flag = 0; -	    time_t expires = (time_t) - 1; - -	    q = NULL; -	    if (lineBuf2->ptr[10] == '2') { -		p = lineBuf2->ptr + 12; -		version = 1; -	    } -	    else { -		p = lineBuf2->ptr + 11; -		version = 0; -	    } -#ifdef DEBUG -	    fprintf(stderr, "Set-Cookie: [%s]\n", p); -#endif				/* DEBUG */ -	    SKIP_BLANKS(p); -	    while (*p != '=' && !IS_ENDT(*p)) -		Strcat_char(name, *(p++)); -	    Strremovetrailingspaces(name); -	    if (*p == '=') { -		p++; -		SKIP_BLANKS(p); -		quoted = 0; -		while (!IS_ENDL(*p) && (quoted || *p != ';')) { -		    if (!IS_SPACE(*p)) -			q = p; -		    if (*p == '"') -			quoted = (quoted) ? 0 : 1; -		    Strcat_char(value, *(p++)); -		} -		if (q) -		    Strshrink(value, p - q - 1); -	    } -	    while (*p == ';') { -		p++; -		SKIP_BLANKS(p); -		if (matchattr(p, "expires", 7, &tmp2)) { -		    /* version 0 */ -		    expires = mymktime(tmp2->ptr); -		} -		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(tmp2->ptr); -		} -		else if (matchattr(p, "domain", 6, &tmp2)) { -		    domain = tmp2; -		} -		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, &tmp2)) { -		    comment = tmp2; -		} -		else if (matchattr(p, "version", 7, &tmp2)) { -		    version = atoi(tmp2->ptr); -		} -		else if (matchattr(p, "port", 4, &tmp2)) { -		    /* version 1, Set-Cookie2 */ -		    port = tmp2; -		} -		else if (matchattr(p, "commentURL", 10, &tmp2)) { -		    /* version 1, Set-Cookie2 */ -		    commentURL = tmp2; -		} -		else if (matchattr(p, "discard", 7, NULL)) { -		    /* version 1, Set-Cookie2 */ -		    flag |= COO_DISCARD; -		} -		quoted = 0; -		while (!IS_ENDL(*p) && (quoted || *p != ';')) { -		    if (*p == '"') -			quoted = (quoted) ? 0 : 1; -		    p++; -		} -	    } -	    if (pu && name->length > 0) { -		int err; -		if (show_cookie) { -		    if (flag & COO_SECURE) -		        disp_message_nsec("Received a secured cookie", FALSE, 1, -				      TRUE, FALSE); -		    else -		        disp_message_nsec(Sprintf("Received cookie: %s=%s", -					      name->ptr, value->ptr)->ptr, -				      FALSE, 1, TRUE, FALSE); -		} -		err = -		    add_cookie(pu, name, value, expires, domain, path, flag, -			       comment, version, port, commentURL); -		if (err) { -		    char *ans = (accept_bad_cookie == ACCEPT_BAD_COOKIE_ACCEPT) -			? "y" : NULL; -		    if (fmInitialized && (err & COO_OVERRIDE_OK) && -			accept_bad_cookie == ACCEPT_BAD_COOKIE_ASK) { -			Str msg = Sprintf("Accept bad cookie from %s for %s?", -					  pu->host, -					  ((domain && domain->ptr) -					   ? domain->ptr : "<localdomain>")); -			if (msg->length > COLS - 10) -			    Strshrink(msg, msg->length - (COLS - 10)); -			Strcat_charp(msg, " (y/n)"); -			ans = inputAnswer(msg->ptr); -		    } -		    if (ans == NULL || TOLOWER(*ans) != 'y' || -			(err = -			 add_cookie(pu, name, value, expires, domain, path, -				    flag | COO_OVERRIDE, comment, version, -				    port, commentURL))) { -			err = (err & ~COO_OVERRIDE_OK) - 1; -			if (err >= 0 && err < COO_EMAX) -			    emsg = Sprintf("This cookie was rejected " -					   "to prevent security violation. [%s]", -					   violations[err])->ptr; -			else -			    emsg = -				"This cookie was rejected to prevent security violation."; -			record_err_message(emsg); -			if (show_cookie) -			    disp_message_nsec(emsg, FALSE, 1, TRUE, FALSE); -		    } -		    else -			if (show_cookie) -			    disp_message_nsec(Sprintf -					  ("Accepting invalid cookie: %s=%s", -					   name->ptr, value->ptr)->ptr, FALSE, -					  1, TRUE, FALSE); -		} -	    } -	} -#endif				/* USE_COOKIE */ -	else if (!strncasecmp(lineBuf2->ptr, "w3m-control:", 12) && -		 uf->scheme == SCM_LOCAL_CGI) { -	    Str funcname = Strnew(); -	    int f; - -	    p = lineBuf2->ptr + 12; -	    SKIP_BLANKS(p); -	    while (*p && !IS_SPACE(*p)) -		Strcat_char(funcname, *(p++)); -	    SKIP_BLANKS(p); -	    f = getFuncList(funcname->ptr); -	    if (f >= 0) { -		tmp = Strnew_charp(p); -		Strchop(tmp); -		pushEvent(f, tmp->ptr); -	    } -	} -	if (headerlist) -	    pushText(headerlist, lineBuf2->ptr); -	Strfree(lineBuf2); -	lineBuf2 = NULL; -    } -    if (thru) -	addnewline(newBuf, "", propBuffer, NULL, 0, -1, -1); -    if (src) -	fclose(src); -} - -char * -checkHeader(Buffer *buf, char *field) -{ -    int len; -    TextListItem *i; -    char *p; - -    if (buf == NULL || field == NULL || buf->document_header == NULL) -	return NULL; -    len = strlen(field); -    for (i = buf->document_header->first; i != NULL; i = i->next) { -	if (!strncasecmp(i->ptr, field, len)) { -	    p = i->ptr + len; -	    return remove_space(p); -	} -    } -    return NULL; -} - -char * -checkContentType(Buffer *buf) -{ -    char *p; -    Str r; -    p = checkHeader(buf, "Content-Type:"); -    if (p == NULL) -	return NULL; -    r = Strnew(); -    while (*p && *p != ';' && !IS_SPACE(*p)) -	Strcat_char(r, *p++); -#ifdef USE_M17N -    if ((p = strcasestr(p, "charset")) != NULL) { -	p += 7; -	SKIP_BLANKS(p); -	if (*p == '=') { -	    p++; -	    SKIP_BLANKS(p); -	    if (*p == '"') -		p++; -	    content_charset = wc_guess_charset(p, 0); -	} -    } -#endif -    return r->ptr; -} - -struct auth_param { -    char *name; -    Str val; -}; - -struct http_auth { -    int pri; -    char *scheme; -    struct auth_param *param; -    Str (*cred) (struct http_auth * ha, Str uname, Str pw, ParsedURL *pu, -		 HRequest *hr, FormList *request); -}; - -enum { -    AUTHCHR_NUL, -    AUTHCHR_SEP, -    AUTHCHR_TOKEN, -}; - -static int -skip_auth_token(char **pp) -{ -    char *p; -    int first = AUTHCHR_NUL, typ; - -    for (p = *pp ;; ++p) { -	switch (*p) { -	case '\0': -	    goto endoftoken; -	default: -	    if ((unsigned char)*p > 037) { -		typ = AUTHCHR_TOKEN; -		break; -	    } -	    /* thru */ -	case '\177': -	case '[': -	case ']': -	case '(': -	case ')': -	case '<': -	case '>': -	case '@': -	case ';': -	case ':': -	case '\\': -	case '"': -	case '/': -	case '?': -	case '=': -	case ' ': -	case '\t': -	case ',': -	    typ = AUTHCHR_SEP; -	    break; -	} - -	if (!first) -	    first = typ; -	else if (first != typ) -	    break; -    } -endoftoken: -    *pp = p; -    return first; -} - -static Str -extract_auth_val(char **q) -{ -    unsigned char *qq = *(unsigned char **)q; -    int quoted = 0; -    Str val = Strnew(); - -    SKIP_BLANKS(qq); -    if (*qq == '"') { -	quoted = TRUE; -	Strcat_char(val, *qq++); -    } -    while (*qq != '\0') { -	if (quoted && *qq == '"') { -	    Strcat_char(val, *qq++); -	    break; -	} -	if (!quoted) { -	    switch (*qq) { -	    case '[': -	    case ']': -	    case '(': -	    case ')': -	    case '<': -	    case '>': -	    case '@': -	    case ';': -	    case ':': -	    case '\\': -	    case '"': -	    case '/': -	    case '?': -	    case '=': -	    case ' ': -	    case '\t': -		qq++; -	    case ',': -		goto end_token; -	    default: -		if (*qq <= 037 || *qq == 0177) { -		    qq++; -		    goto end_token; -		} -	    } -	} -	else if (quoted && *qq == '\\') -	    Strcat_char(val, *qq++); -	Strcat_char(val, *qq++); -    } -  end_token: -    *q = (char *)qq; -    return val; -} - -static Str -qstr_unquote(Str s) -{ -    char *p; - -    if (s == NULL) -	return NULL; -    p = s->ptr; -    if (*p == '"') { -	Str tmp = Strnew(); -	for (p++; *p != '\0'; p++) { -	    if (*p == '\\') -		p++; -	    Strcat_char(tmp, *p); -	} -	if (Strlastchar(tmp) == '"') -	    Strshrink(tmp, 1); -	return tmp; -    } -    else -	return s; -} - -static char * -extract_auth_param(char *q, struct auth_param *auth) -{ -    struct auth_param *ap; -    char *p; - -    for (ap = auth; ap->name != NULL; ap++) { -	ap->val = NULL; -    } - -    while (*q != '\0') { -	SKIP_BLANKS(q); -	for (ap = auth; ap->name != NULL; ap++) { -	    size_t len; - -	    len = strlen(ap->name); -	    if (strncasecmp(q, ap->name, len) == 0 && -		(IS_SPACE(q[len]) || q[len] == '=')) { -		p = q + len; -		SKIP_BLANKS(p); -		if (*p != '=') -		    return q; -		q = p + 1; -		ap->val = extract_auth_val(&q); -		break; -	    } -	} -	if (ap->name == NULL) { -	    /* skip unknown param */ -	    int token_type; -	    p = q; -	    if ((token_type = skip_auth_token(&q)) == AUTHCHR_TOKEN && -		(IS_SPACE(*q) || *q == '=')) { -		SKIP_BLANKS(q); -		if (*q != '=') -		    return p; -		q++; -		extract_auth_val(&q); -	    } -	    else -		return p; -	} -	if (*q != '\0') { -	    SKIP_BLANKS(q); -	    if (*q == ',') -		q++; -	    else -		break; -	} -    } -    return q; -} - -static Str -get_auth_param(struct auth_param *auth, char *name) -{ -    struct auth_param *ap; -    for (ap = auth; ap->name != NULL; ap++) { -	if (strcasecmp(name, ap->name) == 0) -	    return ap->val; -    } -    return NULL; -} - -static Str -AuthBasicCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu, -	      HRequest *hr, FormList *request) -{ -    Str s = Strdup(uname); -    Strcat_char(s, ':'); -    Strcat(s, pw); -    return Strnew_m_charp("Basic ", encodeB(s->ptr)->ptr, NULL); -} - -#ifdef USE_DIGEST_AUTH -#include <openssl/md5.h> - -/* RFC2617: 3.2.2 The Authorization Request Header - *  - * credentials      = "Digest" digest-response - * digest-response  = 1#( username | realm | nonce | digest-uri - *                    | response | [ algorithm ] | [cnonce] | - *                     [opaque] | [message-qop] | - *                         [nonce-count]  | [auth-param] ) - * - * username         = "username" "=" username-value - * username-value   = quoted-string - * digest-uri       = "uri" "=" digest-uri-value - * digest-uri-value = request-uri   ; As specified by HTTP/1.1 - * message-qop      = "qop" "=" qop-value - * cnonce           = "cnonce" "=" cnonce-value - * cnonce-value     = nonce-value - * nonce-count      = "nc" "=" nc-value - * nc-value         = 8LHEX - * response         = "response" "=" request-digest - * request-digest = <"> 32LHEX <"> - * LHEX             =  "0" | "1" | "2" | "3" | - *                     "4" | "5" | "6" | "7" | - *                     "8" | "9" | "a" | "b" | - *                     "c" | "d" | "e" | "f" - */ - -static Str -digest_hex(char *p) -{ -    char *h = "0123456789abcdef"; -    Str tmp = Strnew_size(MD5_DIGEST_LENGTH * 2 + 1); -    int i; -    for (i = 0; i < MD5_DIGEST_LENGTH; i++, p++) { -	Strcat_char(tmp, h[(*p >> 4) & 0x0f]); -	Strcat_char(tmp, h[*p & 0x0f]); -    } -    return tmp; -} - -enum { -    QOP_NONE, -    QOP_AUTH, -    QOP_AUTH_INT, -}; - -static Str -AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu, -	       HRequest *hr, FormList *request) -{ -    Str tmp, a1buf, a2buf, rd, s; -    char md5[MD5_DIGEST_LENGTH + 1]; -    Str uri = HTTPrequestURI(pu, hr); -    char nc[] = "00000001"; - -    Str algorithm = qstr_unquote(get_auth_param(ha->param, "algorithm")); -    Str nonce = qstr_unquote(get_auth_param(ha->param, "nonce")); -    Str cnonce /* = qstr_unquote(get_auth_param(ha->param, "cnonce")) */; -    /* cnonce is what client should generate. */ -    Str qop = qstr_unquote(get_auth_param(ha->param, "qop")); - -    static union { -	int r[4]; -	char s[sizeof(int) * 4]; -    } cnonce_seed; -    int qop_i = QOP_NONE; - -    cnonce_seed.r[0] = rand(); -    cnonce_seed.r[1] = rand(); -    cnonce_seed.r[2] = rand(); -    MD5(cnonce_seed.s, sizeof(cnonce_seed.s), md5); -    cnonce = digest_hex(md5); -    cnonce_seed.r[3]++; - -    if (qop) { -	char *p; -	size_t i; - -	p = qop->ptr; -	SKIP_BLANKS(p); - -	for (;;) { -	    if ((i = strcspn(p, " \t,")) > 0) { -		if (i == sizeof("auth-int") - sizeof("") && !strncasecmp(p, "auth-int", i)) { -		    if (qop_i < QOP_AUTH_INT) -			qop_i = QOP_AUTH_INT; -		} -		else if (i == sizeof("auth") - sizeof("") && !strncasecmp(p, "auth", i)) { -		    if (qop_i < QOP_AUTH) -			qop_i = QOP_AUTH; -		} -	    } - -	    if (p[i]) { -		p += i + 1; -		SKIP_BLANKS(p); -	    } -	    else -		break; -	} -    } - -    /* A1 = unq(username-value) ":" unq(realm-value) ":" passwd */ -    tmp = Strnew_m_charp(uname->ptr, ":", -			 qstr_unquote(get_auth_param(ha->param, "realm"))->ptr, -			 ":", pw->ptr, NULL); -    MD5(tmp->ptr, strlen(tmp->ptr), md5); -    a1buf = digest_hex(md5); - -    if (algorithm) { -	if (strcasecmp(algorithm->ptr, "MD5-sess") == 0) { -	    /* A1 = H(unq(username-value) ":" unq(realm-value) ":" passwd) -	     *      ":" unq(nonce-value) ":" unq(cnonce-value) -	     */ -	    if (nonce == NULL) -		return NULL; -	    tmp = Strnew_m_charp(a1buf->ptr, ":", -				 qstr_unquote(nonce)->ptr, -				 ":", qstr_unquote(cnonce)->ptr, NULL); -	    MD5(tmp->ptr, strlen(tmp->ptr), md5); -	    a1buf = digest_hex(md5); -	} -	else if (strcasecmp(algorithm->ptr, "MD5") == 0) -	    /* ok default */ -	    ; -	else -	    /* unknown algorithm */ -	    return NULL; -    } - -    /* A2 = Method ":" digest-uri-value */ -    tmp = Strnew_m_charp(HTTPrequestMethod(hr)->ptr, ":", uri->ptr, NULL); -    if (qop_i == QOP_AUTH_INT) { -	/*  A2 = Method ":" digest-uri-value ":" H(entity-body) */ -	if (request && request->body) { -	    if (request->method == FORM_METHOD_POST && request->enctype == FORM_ENCTYPE_MULTIPART) { -		FILE *fp = fopen(request->body, "r"); -		if (fp != NULL) { -		    Str ebody; -		    ebody = Strfgetall(fp); -		    MD5(ebody->ptr, strlen(ebody->ptr), md5); -		} -		else { -		    MD5("", 0, md5); -		} -	    } -	    else { -		MD5(request->body, request->length, md5); -	    } -	} -	else { -	    MD5("", 0, md5); -	} -	Strcat_char(tmp, ':'); -	Strcat(tmp, digest_hex(md5)); -    } -    MD5(tmp->ptr, strlen(tmp->ptr), md5); -    a2buf = digest_hex(md5); - -    if (qop_i >= QOP_AUTH) { -	/* request-digest  = <"> < KD ( H(A1),     unq(nonce-value) -	 *                      ":" nc-value -	 *                      ":" unq(cnonce-value) -	 *                      ":" unq(qop-value) -	 *                      ":" H(A2) -	 *                      ) <"> -	 */ -	if (nonce == NULL) -	    return NULL; -	tmp = Strnew_m_charp(a1buf->ptr, ":", qstr_unquote(nonce)->ptr, -			     ":", nc, -			     ":", qstr_unquote(cnonce)->ptr, -			     ":", qop_i == QOP_AUTH ? "auth" : "auth-int", -			     ":", a2buf->ptr, NULL); -	MD5(tmp->ptr, strlen(tmp->ptr), md5); -	rd = digest_hex(md5); -    } -    else { -	/* compatibility with RFC 2069 -	 * request_digest = KD(H(A1),  unq(nonce), H(A2)) -	 */ -	tmp = Strnew_m_charp(a1buf->ptr, ":", -			     qstr_unquote(get_auth_param(ha->param, "nonce"))-> -			     ptr, ":", a2buf->ptr, NULL); -	MD5(tmp->ptr, strlen(tmp->ptr), md5); -	rd = digest_hex(md5); -    } - -    /* -     * digest-response  = 1#( username | realm | nonce | digest-uri -     *                          | response | [ algorithm ] | [cnonce] | -     *                          [opaque] | [message-qop] | -     *                          [nonce-count]  | [auth-param] ) -     */ - -    tmp = Strnew_m_charp("Digest username=\"", uname->ptr, "\"", NULL); -    Strcat_m_charp(tmp, ", realm=", -		   get_auth_param(ha->param, "realm")->ptr, NULL); -    Strcat_m_charp(tmp, ", nonce=", -		   get_auth_param(ha->param, "nonce")->ptr, NULL); -    Strcat_m_charp(tmp, ", uri=\"", uri->ptr, "\"", NULL); -    Strcat_m_charp(tmp, ", response=\"", rd->ptr, "\"", NULL); - -    if (algorithm) -	Strcat_m_charp(tmp, ", algorithm=", -		       get_auth_param(ha->param, "algorithm")->ptr, NULL); - -    if (cnonce) -	Strcat_m_charp(tmp, ", cnonce=\"", cnonce->ptr, "\"", NULL); - -    if ((s = get_auth_param(ha->param, "opaque")) != NULL) -	Strcat_m_charp(tmp, ", opaque=", s->ptr, NULL); - -    if (qop_i >= QOP_AUTH) { -	Strcat_m_charp(tmp, ", qop=", -		       qop_i == QOP_AUTH ? "auth" : "auth-int", -		       NULL); -	/* XXX how to count? */ -	/* Since nonce is unique up to each *-Authenticate and w3m does not re-use *-Authenticate: headers, -	   nonce-count should be always "00000001". */ -	Strcat_m_charp(tmp, ", nc=", nc, NULL); -    } - -    return tmp; -} -#endif - -/* *INDENT-OFF* */ -struct auth_param none_auth_param[] = { -    {NULL, NULL} -}; - -struct auth_param basic_auth_param[] = { -    {"realm", NULL}, -    {NULL, NULL} -}; - -#ifdef USE_DIGEST_AUTH -/* RFC2617: 3.2.1 The WWW-Authenticate Response Header - * challenge        =  "Digest" digest-challenge - *  - * digest-challenge  = 1#( realm | [ domain ] | nonce | - *                       [ opaque ] |[ stale ] | [ algorithm ] | - *                        [ qop-options ] | [auth-param] ) - * - * domain            = "domain" "=" <"> URI ( 1*SP URI ) <"> - * URI               = absoluteURI | abs_path - * nonce             = "nonce" "=" nonce-value - * nonce-value       = quoted-string - * opaque            = "opaque" "=" quoted-string - * stale             = "stale" "=" ( "true" | "false" ) - * algorithm         = "algorithm" "=" ( "MD5" | "MD5-sess" | - *                        token ) - * qop-options       = "qop" "=" <"> 1#qop-value <"> - * qop-value         = "auth" | "auth-int" | token - */ -struct auth_param digest_auth_param[] = { -    {"realm", NULL}, -    {"domain", NULL}, -    {"nonce", NULL}, -    {"opaque", NULL}, -    {"stale", NULL}, -    {"algorithm", NULL}, -    {"qop", NULL}, -    {NULL, NULL} -}; -#endif -/* for RFC2617: HTTP Authentication */ -struct http_auth www_auth[] = { -    { 1, "Basic ", basic_auth_param, AuthBasicCred }, -#ifdef USE_DIGEST_AUTH -    { 10, "Digest ", digest_auth_param, AuthDigestCred }, -#endif -    { 0, NULL, NULL, NULL,} -}; -/* *INDENT-ON* */ - -static struct http_auth * -findAuthentication(struct http_auth *hauth, Buffer *buf, char *auth_field) -{ -    struct http_auth *ha; -    int len = strlen(auth_field), slen; -    TextListItem *i; -    char *p0, *p; - -    bzero(hauth, sizeof(struct http_auth)); -    for (i = buf->document_header->first; i != NULL; i = i->next) { -	if (strncasecmp(i->ptr, auth_field, len) == 0) { -	    for (p = i->ptr + len; p != NULL && *p != '\0';) { -		SKIP_BLANKS(p); -		p0 = p; -		for (ha = &www_auth[0]; ha->scheme != NULL; ha++) { -		    slen = strlen(ha->scheme); -		    if (strncasecmp(p, ha->scheme, slen) == 0) { -			p += slen; -			SKIP_BLANKS(p); -			if (hauth->pri < ha->pri) { -			    *hauth = *ha; -			    p = extract_auth_param(p, hauth->param); -			    break; -			} -			else { -			    /* weak auth */ -			    p = extract_auth_param(p, none_auth_param); -			} -		    } -		} -		if (p0 == p) { -		    /* all unknown auth failed */ -		    int token_type; -		    if ((token_type = skip_auth_token(&p)) == AUTHCHR_TOKEN && IS_SPACE(*p)) { -			SKIP_BLANKS(p); -			p = extract_auth_param(p, none_auth_param); -		    } -		    else -			break; -		} -	    } -	} -    } -    return hauth->scheme ? hauth : NULL; -} - -static void -getAuthCookie(struct http_auth *hauth, char *auth_header, -	      TextList *extra_header, ParsedURL *pu, HRequest *hr, -	      FormList *request, -	      volatile Str *uname, volatile Str *pwd) -{ -    Str ss = NULL; -    Str tmp; -    TextListItem *i; -    int a_found; -    int auth_header_len = strlen(auth_header); -    char *realm = NULL; -    int proxy; - -    if (hauth) -	realm = qstr_unquote(get_auth_param(hauth->param, "realm"))->ptr; - -    if (!realm) -	return; - -    a_found = FALSE; -    for (i = extra_header->first; i != NULL; i = i->next) { -	if (!strncasecmp(i->ptr, auth_header, auth_header_len)) { -	    a_found = TRUE; -	    break; -	} -    } -    proxy = !strncasecmp("Proxy-Authorization:", auth_header, -			 auth_header_len); -    if (a_found) { -	/* This means that *-Authenticate: header is received after -	 * Authorization: header is sent to the server.  -	 */ -	if (fmInitialized) { -	    message("Wrong username or password", 0, 0); -	    refresh(); -	} -	else -	    fprintf(stderr, "Wrong username or password\n"); -	sleep(1); -	/* delete Authenticate: header from extra_header */ -	delText(extra_header, i); -	invalidate_auth_user_passwd(pu, realm, *uname, *pwd, proxy); -    } -    *uname = NULL; -    *pwd = NULL; - -    if (!a_found && find_auth_user_passwd(pu, realm, (Str*)uname, (Str*)pwd,  -					  proxy)) { -	/* found username & password in passwd file */ ; -    } -    else { -	if (QuietMessage) -	    return; -	/* input username and password */ -	sleep(2); -	if (fmInitialized) { -	    char *pp; -	    term_raw(); -	    /* FIXME: gettextize? */ -	    if ((pp = inputStr(Sprintf("Username for %s: ", realm)->ptr, -			       NULL)) == NULL) -		return; -	    *uname = Str_conv_to_system(Strnew_charp(pp)); -	    if ((pp = inputLine(Sprintf("Password for %s: ", realm)->ptr, NULL, -				IN_PASSWORD)) == NULL) { -		*uname = NULL; -		return; -	    } -	    *pwd = Str_conv_to_system(Strnew_charp(pp)); -	    term_cbreak(); -	} -	else { -	    /* -	     * If post file is specified as '-', stdin is closed at this -	     * point. -	     * In this case, w3m cannot read username from stdin. -	     * So exit with error message. -	     * (This is same behavior as lwp-request.) -	     */ -	    if (feof(stdin) || ferror(stdin)) { -		/* FIXME: gettextize? */ -		fprintf(stderr, "w3m: Authorization required for %s\n", -			realm); -		exit(1); -	    } -	     -	    /* FIXME: gettextize? */ -	    printf(proxy ? "Proxy Username for %s: " : "Username for %s: ", -		   realm); -	    fflush(stdout); -	    *uname = Strfgets(stdin); -	    Strchop(*uname); -#ifdef HAVE_GETPASSPHRASE -	    *pwd = Strnew_charp((char *) -				getpassphrase(proxy ? "Proxy Password: " : -					      "Password: ")); -#else -	    *pwd = Strnew_charp((char *) -				getpass(proxy ? "Proxy Password: " : -					"Password: ")); -#endif -	} -    } -    ss = hauth->cred(hauth, *uname, *pwd, pu, hr, request); -    if (ss) { -	tmp = Strnew_charp(auth_header); -	Strcat_m_charp(tmp, " ", ss->ptr, "\r\n", NULL); -	pushText(extra_header, tmp->ptr); -    } -    else { -	*uname = NULL; -	*pwd = NULL; -    } -    return; -} - -static int -same_url_p(ParsedURL *pu1, ParsedURL *pu2) -{ -    return (pu1->scheme == pu2->scheme && pu1->port == pu2->port && -	    (pu1->host ? pu2->host ? !strcasecmp(pu1->host, pu2->host) : 0 : 1) -	    && (pu1->file ? pu2-> -		file ? !strcmp(pu1->file, pu2->file) : 0 : 1)); -} - -static int -checkRedirection(ParsedURL *pu) -{ -    static ParsedURL *puv = NULL; -    static int nredir = 0; -    static int nredir_size = 0; -    Str tmp; - -    if (pu == NULL) { -	nredir = 0; -	nredir_size = 0; -	puv = NULL; -	return TRUE; -    } -    if (nredir >= FollowRedirection) { -	/* FIXME: gettextize? */ -	tmp = Sprintf("Number of redirections exceeded %d at %s", -		      FollowRedirection, parsedURL2Str(pu)->ptr); -	disp_err_message(tmp->ptr, FALSE); -	return FALSE; -    } -    else if (nredir_size > 0 && -	     (same_url_p(pu, &puv[(nredir - 1) % nredir_size]) || -	      (!(nredir % 2) -	       && same_url_p(pu, &puv[(nredir / 2) % nredir_size])))) { -	/* FIXME: gettextize? */ -	tmp = Sprintf("Redirection loop detected (%s)", -		      parsedURL2Str(pu)->ptr); -	disp_err_message(tmp->ptr, FALSE); -	return FALSE; -    } -    if (!puv) { -	nredir_size = FollowRedirection / 2 + 1; -	puv = New_N(ParsedURL, nredir_size); -	memset(puv, 0, sizeof(ParsedURL) * nredir_size); -    } -    copyParsedURL(&puv[nredir % nredir_size], pu); -    nredir++; -    return TRUE; -} - -/*  - * loadGeneralFile: load file to buffer - */ -Buffer * -loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, -		int flag, FormList *volatile request) -{ -    URLFile f, *volatile of = NULL; -    ParsedURL pu; -    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(); -    volatile Str uname = NULL; -    volatile Str pwd = NULL; -    volatile Str realm = NULL; -    int volatile add_auth_cookie_flag; -    unsigned char status = HTST_NORMAL; -    URLOption url_option; -    Str tmp; -    Str volatile page = NULL; -#ifdef USE_M17N -    wc_ces charset = WC_CES_US_ASCII; -#endif -    HRequest hr; -    ParsedURL *volatile auth_pu; - -    tpath = path; -    prevtrap = NULL; -    add_auth_cookie_flag = 0; - -    checkRedirection(NULL); -  load_doc: -    TRAP_OFF; -    url_option.referer = referer; -    url_option.flag = flag; -    f = openURL(tpath, &pu, current, &url_option, request, extra_header, of, -		&hr, &status); -    of = NULL; -#ifdef USE_M17N -    content_charset = 0; -#endif -    if (f.stream == NULL) { -	switch (f.scheme) { -	case SCM_LOCAL: -	    { -		struct stat st; -		if (stat(pu.real_file, &st) < 0) -		    return NULL; -		if (S_ISDIR(st.st_mode)) { -		    if (UseExternalDirBuffer) { -			Str cmd = Sprintf("%s?dir=%s#current", -					  DirBufferCommand, pu.file); -			b = loadGeneralFile(cmd->ptr, NULL, NO_REFERER, 0, -					    NULL); -			if (b != NULL && b != NO_BUFFER) { -			    copyParsedURL(&b->currentURL, &pu); -			    b->filename = b->currentURL.real_file; -			} -			return b; -		    } -		    else { -			page = loadLocalDir(pu.real_file); -			t = "local:directory"; -#ifdef USE_M17N -			charset = SystemCharset; -#endif -		    } -		} -	    } -	    break; -	case SCM_FTPDIR: -	    page = loadFTPDir(&pu, &charset); -	    t = "ftp:directory"; -	    break; -#ifdef USE_NNTP -	case SCM_NEWS_GROUP: -	    page = loadNewsgroup(&pu, &charset); -	    t = "news:group"; -	    break; -#endif -	case SCM_UNKNOWN: -#ifdef USE_EXTERNAL_URI_LOADER -	    tmp = searchURIMethods(&pu); -	    if (tmp != NULL) { -		b = loadGeneralFile(tmp->ptr, current, referer, flag, request); -		if (b != NULL && b != NO_BUFFER) -		    copyParsedURL(&b->currentURL, &pu); -		return b; -	    } -#endif -	    /* FIXME: gettextize? */ -	    disp_err_message(Sprintf("Unknown URI: %s", -				     parsedURL2Str(&pu)->ptr)->ptr, FALSE); -	    break; -	} -	if (page && page->length > 0) -	    goto page_loaded; -	return NULL; -    } - -    if (status == HTST_MISSING) { -	TRAP_OFF; -	UFclose(&f); -	return NULL; -    } - -    /* openURL() succeeded */ -    if (SETJMP(AbortLoading) != 0) { -	/* transfer interrupted */ -	TRAP_OFF; -	if (b) -	    discardBuffer(b); -	UFclose(&f); -	return NULL; -    } - -    b = NULL; -    if (f.is_cgi) { -	/* local CGI */ -	searchHeader = TRUE; -	searchHeader_through = FALSE; -    } -    if (header_string) -	header_string = NULL; -    TRAP_ON; -    if (pu.scheme == SCM_HTTP || -#ifdef USE_SSL -	pu.scheme == SCM_HTTPS || -#endif				/* USE_SSL */ -	(( -#ifdef USE_GOPHER -	     (pu.scheme == SCM_GOPHER && non_null(GOPHER_proxy)) || -#endif				/* USE_GOPHER */ -	     (pu.scheme == SCM_FTP && non_null(FTP_proxy)) -	 ) && !Do_not_use_proxy && !check_no_proxy(pu.host))) { - -	if (fmInitialized) { -	    term_cbreak(); -	    /* FIXME: gettextize? */ -	    message(Sprintf("%s contacted. Waiting for reply...", pu.host)-> -		    ptr, 0, 0); -	    refresh(); -	} -	if (t_buf == NULL) -	    t_buf = newBuffer(INIT_BUFFER_WIDTH); -#if 0				/* USE_SSL */ -	if (IStype(f.stream) == IST_SSL) { -	    Str s = ssl_get_certificate(f.stream, pu.host); -	    if (s == NULL) -		return NULL; -	    else -		t_buf->ssl_certificate = s->ptr; -	} -#endif -	readHeader(&f, t_buf, FALSE, &pu); -	if (((http_response_code >= 301 && http_response_code <= 303) -	     || http_response_code == 307) -	    && (p = checkHeader(t_buf, "Location:")) != NULL -	    && checkRedirection(&pu)) { -	    /* document moved */ -	    /* 301: Moved Permanently */ -	    /* 302: Found */ -	    /* 303: See Other */ -	    /* 307: Temporary Redirect (HTTP/1.1) */ -	    tpath = url_quote_conv(p, DocumentCharset); -	    request = NULL; -	    UFclose(&f); -	    current = New(ParsedURL); -	    copyParsedURL(current, &pu); -	    t_buf = newBuffer(INIT_BUFFER_WIDTH); -	    t_buf->bufferprop |= BP_REDIRECTED; -	    status = HTST_NORMAL; -	    goto load_doc; -	} -	t = checkContentType(t_buf); -	if (t == NULL && pu.file != NULL) { -	    if (!((http_response_code >= 400 && http_response_code <= 407) || -		  (http_response_code >= 500 && http_response_code <= 505))) -		t = guessContentType(pu.file); -	} -	if (t == NULL) -	    t = "text/plain"; -	if (add_auth_cookie_flag && realm && uname && pwd) { -	    /* If authorization is required and passed */ -	    add_auth_user_passwd(&pu, qstr_unquote(realm)->ptr, uname, pwd,  -				  0); -	    add_auth_cookie_flag = 0; -	} -	if ((p = checkHeader(t_buf, "WWW-Authenticate:")) != NULL && -	    http_response_code == 401) { -	    /* Authentication needed */ -	    struct http_auth hauth; -	    if (findAuthentication(&hauth, t_buf, "WWW-Authenticate:") != NULL -		&& (realm = get_auth_param(hauth.param, "realm")) != NULL) { -		auth_pu = &pu; -		getAuthCookie(&hauth, "Authorization:", extra_header, -			      auth_pu, &hr, request, &uname, &pwd); -		if (uname == NULL) { -		    /* abort */ -		    TRAP_OFF; -		    goto page_loaded; -		} -		UFclose(&f); -		add_auth_cookie_flag = 1; -		status = HTST_NORMAL; -		goto load_doc; -	    } -	} -	if ((p = checkHeader(t_buf, "Proxy-Authenticate:")) != NULL && -	    http_response_code == 407) { -	    /* Authentication needed */ -	    struct http_auth hauth; -	    if (findAuthentication(&hauth, t_buf, "Proxy-Authenticate:") -		!= NULL -		&& (realm = get_auth_param(hauth.param, "realm")) != NULL) { -		auth_pu = schemeToProxy(pu.scheme); -		getAuthCookie(&hauth, "Proxy-Authorization:", -			      extra_header, auth_pu, &hr, request,  -			      &uname, &pwd); -		if (uname == NULL) { -		    /* abort */ -		    TRAP_OFF; -		    goto page_loaded; -		} -		UFclose(&f); -		add_auth_cookie_flag = 1; -		status = HTST_NORMAL; -		goto load_doc; -	    } -	} -	/* XXX: RFC2617 3.2.3 Authentication-Info: ? */ - -	if (status == HTST_CONNECT) { -	    of = &f; -	    goto load_doc; -	} - -	f.modtime = mymktime(checkHeader(t_buf, "Last-Modified:")); -    } -#ifdef USE_NNTP -    else if (pu.scheme == SCM_NEWS || pu.scheme == SCM_NNTP) { -	if (t_buf == NULL) -	    t_buf = newBuffer(INIT_BUFFER_WIDTH); -	readHeader(&f, t_buf, TRUE, &pu); -	t = checkContentType(t_buf); -	if (t == NULL) -	    t = "text/plain"; -    } -#endif				/* USE_NNTP */ -#ifdef USE_GOPHER -    else if (pu.scheme == SCM_GOPHER) { -	switch (*pu.file) { -	case '0': -	    t = "text/plain"; -	    break; -	case '1': -	case 'm': -	    page = loadGopherDir(&f, &pu, &charset); -	    t = "gopher:directory"; -	    TRAP_OFF; -	    goto page_loaded; -	case 's': -	    t = "audio/basic"; -	    break; -	case 'g': -	    t = "image/gif"; -	    break; -	case 'h': -	    t = "text/html"; -	    break; -	} -    } -#endif				/* USE_GOPHER */ -    else if (pu.scheme == SCM_FTP) { -	check_compression(path, &f); -	if (f.compression != CMP_NOCOMPRESS) { -	    char *t1 = uncompressed_file_type(pu.file, NULL); -	    real_type = f.guess_type; -#if 0 -	    if (t1 && strncasecmp(t1, "application/", 12) == 0) { -		f.compression = CMP_NOCOMPRESS; -		t = real_type; -	    } -	    else -#endif -	    if (t1) -		t = t1; -	    else -		t = real_type; -	} -	else { -	    real_type = guessContentType(pu.file); -	    if (real_type == NULL) -		real_type = "text/plain"; -	    t = real_type; -	} -#if 0 -	if (!strncasecmp(t, "application/", 12)) { -	    char *tmpf = tmpfname(TMPF_DFL, NULL)->ptr; -	    current_content_length = 0; -	    if (save2tmp(f, tmpf) < 0) -		UFclose(&f); -	    else { -		UFclose(&f); -		TRAP_OFF; -		doFileMove(tmpf, guess_save_name(t_buf, pu.file)); -	    } -	    return NO_BUFFER; -	} -#endif -    } -    else if (pu.scheme == SCM_DATA) { -	t = f.guess_type; -    } -    else if (searchHeader) { -	searchHeader = SearchHeader = FALSE; -	if (t_buf == NULL) -	    t_buf = newBuffer(INIT_BUFFER_WIDTH); -	readHeader(&f, t_buf, searchHeader_through, &pu); -	if (f.is_cgi && (p = checkHeader(t_buf, "Location:")) != NULL && -	    checkRedirection(&pu)) { -	    /* document moved */ -	    tpath = url_quote_conv(remove_space(p), DocumentCharset); -	    request = NULL; -	    UFclose(&f); -	    add_auth_cookie_flag = 0; -	    current = New(ParsedURL); -	    copyParsedURL(current, &pu); -	    t_buf = newBuffer(INIT_BUFFER_WIDTH); -	    t_buf->bufferprop |= BP_REDIRECTED; -	    status = HTST_NORMAL; -	    goto load_doc; -	} -#ifdef AUTH_DEBUG -	if ((p = checkHeader(t_buf, "WWW-Authenticate:")) != NULL) { -	    /* Authentication needed */ -	    struct http_auth hauth; -	    if (findAuthentication(&hauth, t_buf, "WWW-Authenticate:") != NULL -		&& (realm = get_auth_param(hauth.param, "realm")) != NULL) { -		auth_pu = &pu; -		getAuthCookie(&hauth, "Authorization:", extra_header, -			      auth_pu, &hr, request, &uname, &pwd); -		if (uname == NULL) { -		    /* abort */ -		    TRAP_OFF; -		    goto page_loaded; -		} -		UFclose(&f); -		add_auth_cookie_flag = 1; -		status = HTST_NORMAL; -		goto load_doc; -	    } -	} -#endif /* defined(AUTH_DEBUG) */ -	t = checkContentType(t_buf); -	if (t == NULL) -	    t = "text/plain"; -    } -    else if (DefaultType) { -	t = DefaultType; -	DefaultType = NULL; -    } -    else { -	t = guessContentType(pu.file); -	if (t == NULL) -	    t = "text/plain"; -	real_type = t; -	if (f.guess_type) -	    t = f.guess_type; -    } - -  page_loaded: -    if (page) { -	FILE *src; -#ifdef USE_IMAGE -	if (image_source) -	    return NULL; -#endif -	tmp = tmpfname(TMPF_SRC, ".html"); -	src = fopen(tmp->ptr, "w"); -	if (src) { -	    Str s; -	    s = wc_Str_conv_strict(page, InnerCharset, charset); -	    Strfputs(s, src); -	    fclose(src); -	} -	if (do_download) { -	    char *file; -	    if (!src) -		return NULL; -	    file = guess_filename(pu.file); -#ifdef USE_GOPHER -	    if (f.scheme == SCM_GOPHER) -		file = Sprintf("%s.html", file)->ptr; -#endif -#ifdef USE_NNTP -	    if (f.scheme == SCM_NEWS_GROUP) -		file = Sprintf("%s.html", file)->ptr; -#endif -	    doFileMove(tmp->ptr, file); -	    return NO_BUFFER; -	} -	b = loadHTMLString(page); -	if (b) { -	    copyParsedURL(&b->currentURL, &pu); -	    b->real_scheme = pu.scheme; -	    b->real_type = t; -	    if (src) -		b->sourcefile = tmp->ptr; -#ifdef USE_M17N -	    b->document_charset = charset; -#endif -	} -	return b; -    } - -    if (real_type == NULL) -	real_type = t; -    proc = loadBuffer; -#ifdef USE_IMAGE -    cur_baseURL = New(ParsedURL); -    copyParsedURL(cur_baseURL, &pu); -#endif - -    current_content_length = 0; -    if ((p = checkHeader(t_buf, "Content-Length:")) != NULL) -	current_content_length = strtoclen(p); -    if (do_download) { -	/* download only */ -	char *file; -	TRAP_OFF; -	if (DecodeCTE && IStype(f.stream) != IST_ENCODED) -	    f.stream = newEncodedStream(f.stream, f.encoding); -	if (pu.scheme == SCM_LOCAL) { -	    struct stat st; -	    if (PreserveTimestamp && !stat(pu.real_file, &st)) -		f.modtime = st.st_mtime; -	    file = conv_from_system(guess_save_name(NULL, pu.real_file)); -	} -	else -	    file = guess_save_name(t_buf, pu.file); -	if (doFileSave(f, file) == 0) -	    UFhalfclose(&f); -	else -	    UFclose(&f); -	return NO_BUFFER; -    } - -    if (f.content_encoding != CMP_NOCOMPRESS) { -	uncompress_stream(&f, &pu.real_file); -    } -    else if (f.compression != CMP_NOCOMPRESS) { -	if (!(w3m_dump & DUMP_SOURCE) && -	    (w3m_dump & ~DUMP_FRAME || is_text_type(t) -	     || searchExtViewer(t))) { -	    if (t_buf == NULL) -		t_buf = newBuffer(INIT_BUFFER_WIDTH); -	    uncompress_stream(&f, &t_buf->sourcefile); -	    uncompressed_file_type(pu.file, &f.ext); -	} -	else { -	    t = compress_application_type(f.compression); -	    f.compression = CMP_NOCOMPRESS; -	} -    } -#ifdef USE_IMAGE -    if (image_source) { -	Buffer *b = NULL; -	if (IStype(f.stream) != IST_ENCODED) -	    f.stream = newEncodedStream(f.stream, f.encoding); -	if (save2tmp(f, image_source) == 0) { -	    b = newBuffer(INIT_BUFFER_WIDTH); -	    b->sourcefile = image_source; -	    b->real_type = t; -	} -	UFclose(&f); -	TRAP_OFF; -	return b; -    } -#endif - -    if (!strcasecmp(t, "text/html")) -	proc = loadHTMLBuffer; -    else if (is_plain_text_type(t)) -	proc = loadBuffer; -#ifdef USE_IMAGE -    else if (activeImage && displayImage && !useExtImageViewer && -	     !(w3m_dump & ~DUMP_FRAME) && !strncasecmp(t, "image/", 6)) -	proc = loadImageBuffer; -#endif -    else if (w3m_backend) ; -    else if (!(w3m_dump & ~DUMP_FRAME) || is_dump_text_type(t)) { -	if (!do_download && doExternal(f, -				       pu.real_file ? pu.real_file : pu.file, -				       t, &b, t_buf)) { -	    if (b && b != NO_BUFFER) { -		b->real_scheme = f.scheme; -		b->real_type = real_type; -		if (b->currentURL.host == NULL && b->currentURL.file == NULL) -		    copyParsedURL(&b->currentURL, &pu); -	    } -	    UFclose(&f); -	    TRAP_OFF; -	    return b; -	} -	else { -	    TRAP_OFF; -	    if (pu.scheme == SCM_LOCAL) { -		UFclose(&f); -		_doFileCopy(pu.real_file, -			    conv_from_system(guess_save_name -					     (NULL, pu.real_file)), TRUE); -	    } -	    else { -		if (DecodeCTE && IStype(f.stream) != IST_ENCODED) -		    f.stream = newEncodedStream(f.stream, f.encoding); -		if (doFileSave(f, guess_save_name(t_buf, pu.file)) == 0) -		    UFhalfclose(&f); -		else -		    UFclose(&f); -	    } -	    return NO_BUFFER; -	} -    } -    else if (w3m_dump & DUMP_FRAME) -	return NULL; - -    if (flag & RG_FRAME) { -	if (t_buf == NULL) -	    t_buf = newBuffer(INIT_BUFFER_WIDTH); -	t_buf->bufferprop |= BP_FRAME; -    } -#ifdef USE_SSL -    if (t_buf) -	t_buf->ssl_certificate = f.ssl_certificate; -#endif -    frame_source = flag & RG_FRAME_SRC; -    b = loadSomething(&f, pu.real_file ? pu.real_file : pu.file, proc, t_buf); -    UFclose(&f); -    frame_source = 0; -    if (b) { -	b->real_scheme = f.scheme; -	b->real_type = real_type; -	if (b->currentURL.host == NULL && b->currentURL.file == NULL) -	    copyParsedURL(&b->currentURL, &pu); -	if (!strcasecmp(t, "text/html")) -	    b->type = "text/html"; -	else if (w3m_backend) { -	    Str s = Strnew_charp(t); -	    b->type = s->ptr; -	} -#ifdef USE_IMAGE -	else if (proc == loadImageBuffer) -	    b->type = "text/html"; -#endif -	else -	    b->type = "text/plain"; -	if (pu.label) { -	    if (proc == loadHTMLBuffer) { -		Anchor *a; -		a = searchURLLabel(b, pu.label); -		if (a != NULL) { -		    gotoLine(b, a->start.line); -		    if (label_topline) -			b->topLine = lineSkip(b, b->topLine, -					      b->currentLine->linenumber -					      - b->topLine->linenumber, FALSE); -		    b->pos = a->start.pos; -		    arrangeCursor(b); -		} -	    } -	    else {		/* plain text */ -		int l = atoi(pu.label); -		gotoLine(b, l); -		b->pos = 0; -		arrangeCursor(b); -	    } -	} -    } -    if (header_string) -	header_string = NULL; -#ifdef USE_NNTP -    if (f.scheme == SCM_NNTP || f.scheme == SCM_NEWS) -	reAnchorNewsheader(b); -#endif -    preFormUpdateBuffer(b); -    TRAP_OFF; -    return b; -} - -#define TAG_IS(s,tag,len)\ -  (strncasecmp(s,tag,len)==0&&(s[len] == '>' || IS_SPACE((int)s[len]))) - -static char * -has_hidden_link(struct readbuffer *obuf, int cmd) -{ -    Str line = obuf->line; -    struct link_stack *p; - -    if (Strlastchar(line) != '>') -	return NULL; - -    for (p = link_stack; p; p = p->next) -	if (p->cmd == cmd) -	    break; -    if (!p) -	return NULL; - -    if (obuf->pos == p->pos) -	return line->ptr + p->offset; - -    return NULL; -} - -static void -push_link(int cmd, int offset, int pos) -{ -    struct link_stack *p; -    p = New(struct link_stack); -    p->cmd = cmd; -    p->offset = offset; -    p->pos = pos; -    p->next = link_stack; -    link_stack = p; -} - -static int -is_period_char(unsigned char *ch) -{ -    switch (*ch) { -    case ',': -    case '.': -    case ':': -    case ';': -    case '?': -    case '!': -    case ')': -    case ']': -    case '}': -    case '>': -	return 1; -    default: -	return 0; -    } -} - -static int -is_beginning_char(unsigned char *ch) -{ -    switch (*ch) { -    case '(': -    case '[': -    case '{': -    case '`': -    case '<': -	return 1; -    default: -	return 0; -    } -} - -static int -is_word_char(unsigned char *ch) -{ -    Lineprop ctype = get_mctype(ch); - -#ifdef USE_M17N -    if (ctype & (PC_CTRL | PC_KANJI | PC_UNKNOWN)) -	return 0; -    if (ctype & (PC_WCHAR1 | PC_WCHAR2)) -	return 1; -#else -    if (ctype == PC_CTRL) -	return 0; -#endif - -    if (IS_ALNUM(*ch)) -	return 1; - -    switch (*ch) { -    case ',': -    case '.': -    case ':': -    case '\"':			/* " */ -    case '\'': -    case '$': -    case '%': -    case '*': -    case '+': -    case '-': -    case '@': -    case '~': -    case '_': -	return 1; -    } -#ifdef USE_M17N -    if (*ch == NBSP_CODE) -	return 1; -#else -    if (*ch == TIMES_CODE || *ch == DIVIDE_CODE || *ch == ANSP_CODE) -	return 0; -    if (*ch >= AGRAVE_CODE || *ch == NBSP_CODE) -	return 1; -#endif -    return 0; -} - -#ifdef USE_M17N -static int -is_combining_char(unsigned char *ch) -{ -    Lineprop ctype = get_mctype(ch); - -    if (ctype & PC_WCHAR2) -	return 1; -    return 0; -} -#endif - -int -is_boundary(unsigned char *ch1, unsigned char *ch2) -{ -    if (!*ch1 || !*ch2) -	return 1; - -    if (*ch1 == ' ' && *ch2 == ' ') -	return 0; - -    if (*ch1 != ' ' && is_period_char(ch2)) -	return 0; - -    if (*ch2 != ' ' && is_beginning_char(ch1)) -	return 0; - -#ifdef USE_M17N -    if (is_combining_char(ch2)) -	return 0; -#endif -    if (is_word_char(ch1) && is_word_char(ch2)) -	return 0; - -    return 1; -} - - -static void -set_breakpoint(struct readbuffer *obuf, int tag_length) -{ -    obuf->bp.len = obuf->line->length; -    obuf->bp.pos = obuf->pos; -    obuf->bp.tlen = tag_length; -    obuf->bp.flag = obuf->flag; -#ifdef FORMAT_NICE -    obuf->bp.flag &= ~RB_FILL; -#endif				/* FORMAT_NICE */ -    obuf->bp.top_margin = obuf->top_margin; -    obuf->bp.bottom_margin = obuf->bottom_margin; - -    if (!obuf->bp.init_flag) -	return; - -    bcopy((void *)&obuf->anchor, (void *)&obuf->bp.anchor, -	  sizeof(obuf->anchor)); -    obuf->bp.img_alt = obuf->img_alt; -    obuf->bp.in_bold = obuf->in_bold; -    obuf->bp.in_under = obuf->in_under; -    obuf->bp.nobr_level = obuf->nobr_level; -    obuf->bp.prev_ctype = obuf->prev_ctype; -    obuf->bp.init_flag = 0; -} - -static void -back_to_breakpoint(struct readbuffer *obuf) -{ -    obuf->flag = obuf->bp.flag; -    bcopy((void *)&obuf->bp.anchor, (void *)&obuf->anchor, -	  sizeof(obuf->anchor)); -    obuf->img_alt = obuf->bp.img_alt; -    obuf->in_bold = obuf->bp.in_bold; -    obuf->in_under = obuf->bp.in_under; -    obuf->prev_ctype = obuf->bp.prev_ctype; -    obuf->pos = obuf->bp.pos; -    obuf->top_margin = obuf->bp.top_margin; -    obuf->bottom_margin = obuf->bp.bottom_margin; -    if (obuf->flag & RB_NOBR) -	obuf->nobr_level = obuf->bp.nobr_level; -} - -static void -append_tags(struct readbuffer *obuf) -{ -    int i; -    int len = obuf->line->length; -    int set_bp = 0; - -    for (i = 0; i < obuf->tag_sp; i++) { -	switch (obuf->tag_stack[i]->cmd) { -	case HTML_A: -	case HTML_IMG_ALT: -	case HTML_B: -	case HTML_U: -	    push_link(obuf->tag_stack[i]->cmd, obuf->line->length, obuf->pos); -	    break; -	} -	Strcat_charp(obuf->line, obuf->tag_stack[i]->cmdname); -	switch (obuf->tag_stack[i]->cmd) { -	case HTML_NOBR: -	    if (obuf->nobr_level > 1) -		break; -	case HTML_WBR: -	    set_bp = 1; -	    break; -	} -    } -    obuf->tag_sp = 0; -    if (set_bp) -	set_breakpoint(obuf, obuf->line->length - len); -} - -static void -push_tag(struct readbuffer *obuf, char *cmdname, int cmd) -{ -    obuf->tag_stack[obuf->tag_sp] = New(struct cmdtable); -    obuf->tag_stack[obuf->tag_sp]->cmdname = allocStr(cmdname, -1); -    obuf->tag_stack[obuf->tag_sp]->cmd = cmd; -    obuf->tag_sp++; -    if (obuf->tag_sp >= TAG_STACK_SIZE || obuf->flag & (RB_SPECIAL & ~RB_NOBR)) -	append_tags(obuf); -} - -static void -push_nchars(struct readbuffer *obuf, int width, -	    char *str, int len, Lineprop mode) -{ -    append_tags(obuf); -    Strcat_charp_n(obuf->line, str, len); -    obuf->pos += width; -    if (width > 0) { -	set_prevchar(obuf->prevchar, str, len); -	obuf->prev_ctype = mode; -    } -    obuf->flag |= RB_NFLUSHED; -} - -#define push_charp(obuf, width, str, mode)\ -push_nchars(obuf, width, str, strlen(str), mode) - -#define push_str(obuf, width, str, mode)\ -push_nchars(obuf, width, str->ptr, str->length, mode) - -static void -check_breakpoint(struct readbuffer *obuf, int pre_mode, char *ch) -{ -    int tlen, len = obuf->line->length; - -    append_tags(obuf); -    if (pre_mode) -	return; -    tlen = obuf->line->length - len; -    if (tlen > 0 -	|| is_boundary((unsigned char *)obuf->prevchar->ptr, -		       (unsigned char *)ch)) -	set_breakpoint(obuf, tlen); -} - -static void -push_char(struct readbuffer *obuf, int pre_mode, char ch) -{ -    check_breakpoint(obuf, pre_mode, &ch); -    Strcat_char(obuf->line, ch); -    obuf->pos++; -    set_prevchar(obuf->prevchar, &ch, 1); -    if (ch != ' ') -	obuf->prev_ctype = PC_ASCII; -    obuf->flag |= RB_NFLUSHED; -} - -#define PUSH(c) push_char(obuf, obuf->flag & RB_SPECIAL, c) - -static void -push_spaces(struct readbuffer *obuf, int pre_mode, int width) -{ -    int i; - -    if (width <= 0) -	return; -    check_breakpoint(obuf, pre_mode, " "); -    for (i = 0; i < width; i++) -	Strcat_char(obuf->line, ' '); -    obuf->pos += width; -    set_space_to_prevchar(obuf->prevchar); -    obuf->flag |= RB_NFLUSHED; -} - -static void -proc_mchar(struct readbuffer *obuf, int pre_mode, -	   int width, char **str, Lineprop mode) -{ -    check_breakpoint(obuf, pre_mode, *str); -    obuf->pos += width; -    Strcat_charp_n(obuf->line, *str, get_mclen(*str)); -    if (width > 0) { -	set_prevchar(obuf->prevchar, *str, 1); -	if (**str != ' ') -	    obuf->prev_ctype = mode; -    } -    (*str) += get_mclen(*str); -    obuf->flag |= RB_NFLUSHED; -} - -void -push_render_image(Str str, int width, int limit, -		  struct html_feed_environ *h_env) -{ -    struct readbuffer *obuf = h_env->obuf; -    int indent = h_env->envs[h_env->envc].indent; - -    push_spaces(obuf, 1, (limit - width) / 2); -    push_str(obuf, width, str, PC_ASCII); -    push_spaces(obuf, 1, (limit - width + 1) / 2); -    if (width > 0) -	flushline(h_env, obuf, indent, 0, h_env->limit); -} - -static int -sloppy_parse_line(char **str) -{ -    if (**str == '<') { -	while (**str && **str != '>') -	    (*str)++; -	if (**str == '>') -	    (*str)++; -	return 1; -    } -    else { -	while (**str && **str != '<') -	    (*str)++; -	return 0; -    } -} - -static void -passthrough(struct readbuffer *obuf, char *str, int back) -{ -    int cmd; -    Str tok = Strnew(); -    char *str_bak; - -    if (back) { -	Str str_save = Strnew_charp(str); -	Strshrink(obuf->line, obuf->line->ptr + obuf->line->length - str); -	str = str_save->ptr; -    } -    while (*str) { -	str_bak = str; -	if (sloppy_parse_line(&str)) { -	    char *q = str_bak; -	    cmd = gethtmlcmd(&q); -	    if (back) { -		struct link_stack *p; -		for (p = link_stack; p; p = p->next) { -		    if (p->cmd == cmd) { -			link_stack = p->next; -			break; -		    } -		} -		back = 0; -	    } -	    else { -		Strcat_charp_n(tok, str_bak, str - str_bak); -		push_tag(obuf, tok->ptr, cmd); -		Strclear(tok); -	    } -	} -	else { -	    push_nchars(obuf, 0, str_bak, str - str_bak, obuf->prev_ctype); -	} -    } -} - -#if 0 -int -is_blank_line(char *line, int indent) -{ -    int i, is_blank = 0; - -    for (i = 0; i < indent; i++) { -	if (line[i] == '\0') { -	    is_blank = 1; -	} -	else if (line[i] != ' ') { -	    break; -	} -    } -    if (i == indent && line[i] == '\0') -	is_blank = 1; -    return is_blank; -} -#endif - -void -fillline(struct readbuffer *obuf, int indent) -{ -    push_spaces(obuf, 1, indent - obuf->pos); -    obuf->flag &= ~RB_NFLUSHED; -} - -void -flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, -	  int force, int width) -{ -    TextLineList *buf = h_env->buf; -    FILE *f = h_env->f; -    Str line = obuf->line, pass = NULL; -    char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL, -	*hidden_under = NULL, *hidden = NULL; - -#ifdef DEBUG -    if (w3m_debug) { -	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(df, "buf=\"%s\"\n", p->ptr->line->ptr); -	    } -	} -	fclose(df); -    } -#endif - -    if (!(obuf->flag & (RB_SPECIAL & ~RB_NOBR)) && Strlastchar(line) == ' ') { -	Strshrink(line, 1); -	obuf->pos--; -    } - -    append_tags(obuf); - -    if (obuf->anchor.url) -	hidden = hidden_anchor = has_hidden_link(obuf, HTML_A); -    if (obuf->img_alt) { -	if ((hidden_img = has_hidden_link(obuf, HTML_IMG_ALT)) != NULL) { -	    if (!hidden || hidden_img < hidden) -		hidden = hidden_img; -	} -    } -    if (obuf->in_bold) { -	if ((hidden_bold = has_hidden_link(obuf, HTML_B)) != NULL) { -	    if (!hidden || hidden_bold < hidden) -		hidden = hidden_bold; -	} -    } -    if (obuf->in_under) { -	if ((hidden_under = has_hidden_link(obuf, HTML_U)) != NULL) { -	    if (!hidden || hidden_under < hidden) -		hidden = hidden_under; -	} -    } -    if (hidden) { -	pass = Strnew_charp(hidden); -	Strshrink(line, line->ptr + line->length - hidden); -    } - -    if (!(obuf->flag & (RB_SPECIAL & ~RB_NOBR)) && obuf->pos > width) { -	char *tp = &line->ptr[obuf->bp.len - obuf->bp.tlen]; -	char *ep = &line->ptr[line->length]; - -	if (obuf->bp.pos == obuf->pos && tp <= ep && -	    tp > line->ptr && tp[-1] == ' ') { -	    bcopy(tp, tp - 1, ep - tp + 1); -	    line->length--; -	    obuf->pos--; -	} -    } - -    if (obuf->anchor.url && !hidden_anchor) -	Strcat_charp(line, "</a>"); -    if (obuf->img_alt && !hidden_img) -	Strcat_charp(line, "</img_alt>"); -    if (obuf->in_bold && !hidden_bold) -	Strcat_charp(line, "</b>"); -    if (obuf->in_under && !hidden_under) -	Strcat_charp(line, "</u>"); - -    if (obuf->top_margin > 0) { -	int i; -	struct html_feed_environ h; -	struct readbuffer o; -	struct environment e[1]; - -	init_henv(&h, &o, e, 1, NULL, width, indent); -	o.line = Strnew_size(width + 20); -	o.pos = obuf->pos; -	o.flag = obuf->flag; -	o.top_margin = -1; -	o.bottom_margin = -1; -	Strcat_charp(o.line, "<pre_int>"); -	for (i = 0; i < o.pos; i++) -	    Strcat_char(o.line, ' '); -	Strcat_charp(o.line, "</pre_int>"); -	for (i = 0; i < obuf->top_margin; i++) -	    flushline(h_env, &o, indent, force, width); -    } - -    if (force == 1 || obuf->flag & RB_NFLUSHED) { -	TextLine *lbuf = newTextLine(line, obuf->pos); -	if (RB_GET_ALIGN(obuf) == RB_CENTER) { -	    align(lbuf, width, ALIGN_CENTER); -	} -	else if (RB_GET_ALIGN(obuf) == RB_RIGHT) { -	    align(lbuf, width, ALIGN_RIGHT); -	} -	else if (RB_GET_ALIGN(obuf) == RB_LEFT && obuf->flag & RB_INTABLE) { -	    align(lbuf, width, ALIGN_LEFT); -	} -#ifdef FORMAT_NICE -	else if (obuf->flag & RB_FILL) { -	    char *p; -	    int rest, rrest; -	    int nspace, d, i; - -	    rest = width - get_Str_strwidth(line); -	    if (rest > 1) { -		nspace = 0; -		for (p = line->ptr + indent; *p; p++) { -		    if (*p == ' ') -			nspace++; -		} -		if (nspace > 0) { -		    int indent_here = 0; -		    d = rest / nspace; -		    p = line->ptr; -		    while (IS_SPACE(*p)) { -			p++; -			indent_here++; -		    } -		    rrest = rest - d * nspace; -		    line = Strnew_size(width + 1); -		    for (i = 0; i < indent_here; i++) -			Strcat_char(line, ' '); -		    for (; *p; p++) { -			Strcat_char(line, *p); -			if (*p == ' ') { -			    for (i = 0; i < d; i++) -				Strcat_char(line, ' '); -			    if (rrest > 0) { -				Strcat_char(line, ' '); -				rrest--; -			    } -			} -		    } -		    lbuf = newTextLine(line, width); -		} -	    } -	} -#endif				/* FORMAT_NICE */ -#ifdef TABLE_DEBUG -	if (w3m_debug) { -	    FILE *f = fopen("zzzproc1", "a"); -	    fprintf(f, "pos=%d,%d, maxlimit=%d\n", -		    visible_length(lbuf->line->ptr), lbuf->pos, -		    h_env->maxlimit); -	    fclose(f); -	} -#endif -	if (lbuf->pos > h_env->maxlimit) -	    h_env->maxlimit = lbuf->pos; -	if (buf) -	    pushTextLine(buf, lbuf); -	else if (f) { -	    Strfputs(Str_conv_to_halfdump(lbuf->line), f); -	    fputc('\n', f); -	} -	if (obuf->flag & RB_SPECIAL || obuf->flag & RB_NFLUSHED) -	    h_env->blank_lines = 0; -	else -	    h_env->blank_lines++; -    } -    else { -	char *p = line->ptr, *q; -	Str tmp = Strnew(), tmp2 = Strnew(); - -#define APPEND(str) \ -	if (buf) \ -	    appendTextLine(buf,(str),0); \ -	else if (f) \ -	    Strfputs((str),f) - -	while (*p) { -	    q = p; -	    if (sloppy_parse_line(&p)) { -		Strcat_charp_n(tmp, q, p - q); -		if (force == 2) { -		    APPEND(tmp); -		} -		else -		    Strcat(tmp2, tmp); -		Strclear(tmp); -	    } -	} -	if (force == 2) { -	    if (pass) { -		APPEND(pass); -	    } -	    pass = NULL; -	} -	else { -	    if (pass) -		Strcat(tmp2, pass); -	    pass = tmp2; -	} -    } - -    if (obuf->bottom_margin > 0) { -	int i; -	struct html_feed_environ h; -	struct readbuffer o; -	struct environment e[1]; - -	init_henv(&h, &o, e, 1, NULL, width, indent); -	o.line = Strnew_size(width + 20); -	o.pos = obuf->pos; -	o.flag = obuf->flag; -	o.top_margin = -1; -	o.bottom_margin = -1; -	Strcat_charp(o.line, "<pre_int>"); -	for (i = 0; i < o.pos; i++) -	    Strcat_char(o.line, ' '); -	Strcat_charp(o.line, "</pre_int>"); -	for (i = 0; i < obuf->bottom_margin; i++) -	    flushline(h_env, &o, indent, force, width); -    } -    if (obuf->top_margin < 0 || obuf->bottom_margin < 0) -	return; - -    obuf->line = Strnew_size(256); -    obuf->pos = 0; -    obuf->top_margin = 0; -    obuf->bottom_margin = 0; -    set_space_to_prevchar(obuf->prevchar); -    obuf->bp.init_flag = 1; -    obuf->flag &= ~RB_NFLUSHED; -    set_breakpoint(obuf, 0); -    obuf->prev_ctype = PC_ASCII; -    link_stack = NULL; -    fillline(obuf, indent); -    if (pass) -	passthrough(obuf, pass->ptr, 0); -    if (!hidden_anchor && obuf->anchor.url) { -	Str tmp; -	if (obuf->anchor.hseq > 0) -	    obuf->anchor.hseq = -obuf->anchor.hseq; -	tmp = Sprintf("<A HSEQ=\"%d\" HREF=\"", obuf->anchor.hseq); -	Strcat_charp(tmp, html_quote(obuf->anchor.url)); -	if (obuf->anchor.target) { -	    Strcat_charp(tmp, "\" TARGET=\""); -	    Strcat_charp(tmp, html_quote(obuf->anchor.target)); -	} -	if (obuf->anchor.referer) { -	    Strcat_charp(tmp, "\" REFERER=\""); -	    Strcat_charp(tmp, html_quote(obuf->anchor.referer)); -	} -	if (obuf->anchor.title) { -	    Strcat_charp(tmp, "\" TITLE=\""); -	    Strcat_charp(tmp, html_quote(obuf->anchor.title)); -	} -	if (obuf->anchor.accesskey) { -	    char *c = html_quote_char(obuf->anchor.accesskey); -	    Strcat_charp(tmp, "\" ACCESSKEY=\""); -	    if (c) -		Strcat_charp(tmp, c); -	    else -		Strcat_char(tmp, obuf->anchor.accesskey); -	} -	Strcat_charp(tmp, "\">"); -	push_tag(obuf, tmp->ptr, HTML_A); -    } -    if (!hidden_img && obuf->img_alt) { -	Str tmp = Strnew_charp("<IMG_ALT SRC=\""); -	Strcat_charp(tmp, html_quote(obuf->img_alt->ptr)); -	Strcat_charp(tmp, "\">"); -	push_tag(obuf, tmp->ptr, HTML_IMG_ALT); -    } -    if (!hidden_bold && obuf->in_bold) -	push_tag(obuf, "<B>", HTML_B); -    if (!hidden_under && obuf->in_under) -	push_tag(obuf, "<U>", HTML_U); -} - -void -do_blankline(struct html_feed_environ *h_env, struct readbuffer *obuf, -	     int indent, int indent_incr, int width) -{ -    if (h_env->blank_lines == 0) -	flushline(h_env, obuf, indent, 1, width); -} - -void -purgeline(struct html_feed_environ *h_env) -{ -    char *p, *q; -    Str tmp; - -    if (h_env->buf == NULL || h_env->blank_lines == 0) -	return; - -    p = rpopTextLine(h_env->buf)->line->ptr; -    tmp = Strnew(); -    while (*p) { -	q = p; -	if (sloppy_parse_line(&p)) { -	    Strcat_charp_n(tmp, q, p - q); -	} -    } -    appendTextLine(h_env->buf, tmp, 0); -    h_env->blank_lines--; -} - -static int -close_effect0(struct readbuffer *obuf, int cmd) -{ -    int i; -    char *p; - -    for (i = obuf->tag_sp - 1; i >= 0; i--) { -	if (obuf->tag_stack[i]->cmd == cmd) -	    break; -    } -    if (i >= 0) { -	obuf->tag_sp--; -	bcopy(&obuf->tag_stack[i + 1], &obuf->tag_stack[i], -	      (obuf->tag_sp - i) * sizeof(struct cmdtable *)); -	return 1; -    } -    else if ((p = has_hidden_link(obuf, cmd)) != NULL) { -	passthrough(obuf, p, 1); -	return 1; -    } -    return 0; -} - -static void -close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf) -{ -    if (obuf->anchor.url) { -	int i; -	char *p = NULL; -	int is_erased = 0; - -	for (i = obuf->tag_sp - 1; i >= 0; i--) { -	    if (obuf->tag_stack[i]->cmd == HTML_A) -		break; -	} -	if (i < 0 && obuf->anchor.hseq > 0 && Strlastchar(obuf->line) == ' ') { -	    Strshrink(obuf->line, 1); -	    obuf->pos--; -	    is_erased = 1; -	} - -	if (i >= 0 || (p = has_hidden_link(obuf, HTML_A))) { -	    if (obuf->anchor.hseq > 0) { -		HTMLlineproc1(ANSP, h_env); -		set_space_to_prevchar(obuf->prevchar); -	    } -	    else { -		if (i >= 0) { -		    obuf->tag_sp--; -		    bcopy(&obuf->tag_stack[i + 1], &obuf->tag_stack[i], -			  (obuf->tag_sp - i) * sizeof(struct cmdtable *)); -		} -		else { -		    passthrough(obuf, p, 1); -		} -		bzero((void *)&obuf->anchor, sizeof(obuf->anchor)); -		return; -	    } -	    is_erased = 0; -	} -	if (is_erased) { -	    Strcat_char(obuf->line, ' '); -	    obuf->pos++; -	} - -	push_tag(obuf, "</a>", HTML_N_A); -    } -    bzero((void *)&obuf->anchor, sizeof(obuf->anchor)); -} - -void -save_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf) -{ -    if (obuf->fontstat_sp < FONT_STACK_SIZE) -	bcopy(obuf->fontstat, obuf->fontstat_stack[obuf->fontstat_sp], -	      FONTSTAT_SIZE); -    obuf->fontstat_sp++; -    if (obuf->in_bold) -	push_tag(obuf, "</b>", HTML_N_B); -    if (obuf->in_under) -	push_tag(obuf, "</u>", HTML_N_U); -    bzero(obuf->fontstat, FONTSTAT_SIZE); -} - -void -restore_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf) -{ -    if (obuf->fontstat_sp > 0) -	obuf->fontstat_sp--; -    if (obuf->fontstat_sp < FONT_STACK_SIZE) -	bcopy(obuf->fontstat_stack[obuf->fontstat_sp], obuf->fontstat, -	      FONTSTAT_SIZE); -    if (obuf->in_bold) -	push_tag(obuf, "<b>", HTML_B); -    if (obuf->in_under) -	push_tag(obuf, "<u>", HTML_U); -} - -static Str -process_title(struct parsed_tag *tag) -{ -    cur_title = Strnew(); -    return NULL; -} - -static Str -process_n_title(struct parsed_tag *tag) -{ -    Str tmp; - -    if (!cur_title) -	return NULL; -    Strremovefirstspaces(cur_title); -    Strremovetrailingspaces(cur_title); -    tmp = Strnew_m_charp("<title_alt title=\"", -			 html_quote(cur_title->ptr), "\">", NULL); -    cur_title = NULL; -    return tmp; -} - -static void -feed_title(char *str) -{ -    if (!cur_title) -	return; -    while (*str) { -	if (*str == '&') -	    Strcat_charp(cur_title, getescapecmd(&str)); -	else if (*str == '\n' || *str == '\r') { -	    Strcat_char(cur_title, ' '); -	    str++; -	} -	else -	    Strcat_char(cur_title, *(str++)); -    } -} - -Str -process_img(struct parsed_tag *tag, int width) -{ -    char *p, *q, *r, *r2 = NULL, *s, *t; -#ifdef USE_IMAGE -    int w, i, nw, ni = 1, n, w0 = -1, i0 = -1; -    int align, xoffset, yoffset, top, bottom, ismap = 0; -    int use_image = activeImage && displayImage; -#else -    int w, i, nw, n; -#endif -    int pre_int = FALSE; -    Str tmp = Strnew(); - -    if (!parsedtag_get_value(tag, ATTR_SRC, &p)) -	return tmp; -    p = remove_space(p); -    q = NULL; -    parsedtag_get_value(tag, ATTR_ALT, &q); -    t = q; -    parsedtag_get_value(tag, ATTR_TITLE, &t); -    w = -1; -    if (parsedtag_get_value(tag, ATTR_WIDTH, &w)) { -	if (w < 0) { -	    if (width > 0) -		w = (int)(-width * pixel_per_char * w / 100 + 0.5); -	    else -		w = -1; -	} -#ifdef USE_IMAGE -	if (use_image) { -	    if (w > 0) { -		w = (int)(w * image_scale / 100 + 0.5); -		if (w == 0) -		    w = 1; -		else if (w > MAX_IMAGE_SIZE) -		    w = MAX_IMAGE_SIZE; -	    } -	} -#endif -    } -#ifdef USE_IMAGE -    if (use_image) { -	i = -1; -	if (parsedtag_get_value(tag, ATTR_HEIGHT, &i)) { -	    if (i > 0) { -		i = (int)(i * image_scale / 100 + 0.5); -		if (i == 0) -		    i = 1; -		else if (i > MAX_IMAGE_SIZE) -		    i = MAX_IMAGE_SIZE; -	    } -	    else { -		i = -1; -	    } -	} -	align = -1; -	parsedtag_get_value(tag, ATTR_ALIGN, &align); -	ismap = 0; -	if (parsedtag_exists(tag, ATTR_ISMAP)) -	    ismap = 1; -    } -    else -#endif -	parsedtag_get_value(tag, ATTR_HEIGHT, &i); -    r = NULL; -    parsedtag_get_value(tag, ATTR_USEMAP, &r); - -    tmp = Strnew_size(128); -#ifdef USE_IMAGE -    if (use_image) { -	switch (align) { -	case ALIGN_LEFT: -	    Strcat_charp(tmp, "<div_int align=left>"); -	    break; -	case ALIGN_CENTER: -	    Strcat_charp(tmp, "<div_int align=center>"); -	    break; -	case ALIGN_RIGHT: -	    Strcat_charp(tmp, "<div_int align=right>"); -	    break; -	} -    } -#endif -    if (r) { -	Str tmp2; -	r2 = strchr(r, '#'); -	s = "<form_int method=internal action=map>"; -	tmp2 = process_form(parse_tag(&s, TRUE)); -	if (tmp2) -	    Strcat(tmp, tmp2); -	Strcat(tmp, Sprintf("<input_alt fid=\"%d\" " -			    "type=hidden name=link value=\"", cur_form_id)); -	Strcat_charp(tmp, html_quote((r2) ? r2 + 1 : r)); -	Strcat(tmp, Sprintf("\"><input_alt hseq=\"%d\" fid=\"%d\" " -			    "type=submit no_effect=true>", -			    cur_hseq++, cur_form_id)); -    } -#ifdef USE_IMAGE -    if (use_image) { -	w0 = w; -	i0 = i; -	if (w < 0 || i < 0) { -	    Image image; -	    ParsedURL u; - -#ifdef USE_M17N -	    parseURL2(wc_conv(p, InnerCharset, cur_document_charset)->ptr, &u, -		      cur_baseURL); -#else -	    parseURL2(p, &u, cur_baseURL); -#endif -	    image.url = parsedURL2Str(&u)->ptr; -	    if (!uncompressed_file_type(u.file, &image.ext)) -		image.ext = filename_extension(u.file, TRUE); -	    image.cache = NULL; -	    image.width = w; -	    image.height = i; - -	    image.cache = getImage(&image, cur_baseURL, IMG_FLAG_SKIP); -	    if (image.cache && image.cache->width > 0 && -		image.cache->height > 0) { -		w = w0 = image.cache->width; -		i = i0 = image.cache->height; -	    } -	    if (w < 0) -		w = 8 * pixel_per_char; -	    if (i < 0) -		i = pixel_per_line; -	} -	nw = (w > 3) ? (int)((w - 3) / pixel_per_char + 1) : 1; -	ni = (i > 3) ? (int)((i - 3) / pixel_per_line + 1) : 1; -	Strcat(tmp, -	       Sprintf("<pre_int><img_alt hseq=\"%d\" src=\"", cur_iseq++)); -	pre_int = TRUE; -    } -    else -#endif -    { -	if (w < 0) -	    w = 12 * pixel_per_char; -	nw = w ? (int)((w - 1) / pixel_per_char + 1) : 1; -	if (r) { -	    Strcat_charp(tmp, "<pre_int>"); -	    pre_int = TRUE; -	} -	Strcat_charp(tmp, "<img_alt src=\""); -    } -    Strcat_charp(tmp, html_quote(p)); -    Strcat_charp(tmp, "\""); -    if (t) { -	Strcat_charp(tmp, " title=\""); -	Strcat_charp(tmp, html_quote(t)); -	Strcat_charp(tmp, "\""); -    } -#ifdef USE_IMAGE -    if (use_image) { -	if (w0 >= 0) -	    Strcat(tmp, Sprintf(" width=%d", w0)); -	if (i0 >= 0) -	    Strcat(tmp, Sprintf(" height=%d", i0)); -	switch (align) { -	case ALIGN_TOP: -	    top = 0; -	    bottom = ni - 1; -	    yoffset = 0; -	    break; -	case ALIGN_MIDDLE: -	    top = ni / 2; -	    bottom = top; -	    if (top * 2 == ni) -		yoffset = (int)(((ni + 1) * pixel_per_line - i) / 2); -	    else -		yoffset = (int)((ni * pixel_per_line - i) / 2); -	    break; -	case ALIGN_BOTTOM: -	    top = ni - 1; -	    bottom = 0; -	    yoffset = (int)(ni * pixel_per_line - i); -	    break; -	default: -	    top = ni - 1; -	    bottom = 0; -	    if (ni == 1 && ni * pixel_per_line > i) -		yoffset = 0; -	    else { -		yoffset = (int)(ni * pixel_per_line - i); -		if (yoffset <= -2) -		    yoffset++; -	    } -	    break; -	} -	xoffset = (int)((nw * pixel_per_char - w) / 2); -	if (xoffset) -	    Strcat(tmp, Sprintf(" xoffset=%d", xoffset)); -	if (yoffset) -	    Strcat(tmp, Sprintf(" yoffset=%d", yoffset)); -	if (top) -	    Strcat(tmp, Sprintf(" top_margin=%d", top)); -	if (bottom) -	    Strcat(tmp, Sprintf(" bottom_margin=%d", bottom)); -	if (r) { -	    Strcat_charp(tmp, " usemap=\""); -	    Strcat_charp(tmp, html_quote((r2) ? r2 + 1 : r)); -	    Strcat_charp(tmp, "\""); -	} -	if (ismap) -	    Strcat_charp(tmp, " ismap"); -    } -#endif -    Strcat_charp(tmp, ">"); -    if (q != NULL && *q == '\0' && ignore_null_img_alt) -	q = NULL; -    if (q != NULL) { -	n = get_strwidth(q); -#ifdef USE_IMAGE -	if (use_image) { -	    if (n > nw) { -		char *r; -		for (r = q, n = 0; r; r += get_mclen(r), n += get_mcwidth(r)) { -		    if (n + get_mcwidth(r) > nw) -			break; -		} -		Strcat_charp(tmp, html_quote(Strnew_charp_n(q, r - q)->ptr)); -	    } -	    else -		Strcat_charp(tmp, html_quote(q)); -	} -	else -#endif -	    Strcat_charp(tmp, html_quote(q)); -	goto img_end; -    } -    if (w > 0 && i > 0) { -	/* guess what the image is! */ -	if (w < 32 && i < 48) { -	    /* must be an icon or space */ -	    n = 1; -	    if (strcasestr(p, "space") || strcasestr(p, "blank")) -		Strcat_charp(tmp, "_"); -	    else { -		if (w * i < 8 * 16) -		    Strcat_charp(tmp, "*"); -		else { -		    if (!pre_int) { -			Strcat_charp(tmp, "<pre_int>"); -			pre_int = TRUE; -		    } -		    push_symbol(tmp, IMG_SYMBOL, symbol_width, 1); -		    n = symbol_width; -		} -	    } -	    goto img_end; -	} -	if (w > 200 && i < 13) { -	    /* must be a horizontal line */ -	    if (!pre_int) { -		Strcat_charp(tmp, "<pre_int>"); -		pre_int = TRUE; -	    } -	    w = w / pixel_per_char / symbol_width; -	    if (w <= 0) -		w = 1; -	    push_symbol(tmp, HR_SYMBOL, symbol_width, w); -	    n = w * symbol_width; -	    goto img_end; -	} -    } -    for (q = p; *q; q++) ; -    while (q > p && *q != '/') -	q--; -    if (*q == '/') -	q++; -    Strcat_char(tmp, '['); -    n = 1; -    p = q; -    for (; *q; q++) { -	if (!IS_ALNUM(*q) && *q != '_' && *q != '-') { -	    break; -	} -	Strcat_char(tmp, *q); -	n++; -	if (n + 1 >= nw) -	    break; -    } -    Strcat_char(tmp, ']'); -    n++; -  img_end: -#ifdef USE_IMAGE -    if (use_image) { -	for (; n < nw; n++) -	    Strcat_char(tmp, ' '); -    } -#endif -    Strcat_charp(tmp, "</img_alt>"); -    if (pre_int) -	Strcat_charp(tmp, "</pre_int>"); -    if (r) { -	Strcat_charp(tmp, "</input_alt>"); -	process_n_form(); -    } -#ifdef USE_IMAGE -    if (use_image) { -	switch (align) { -	case ALIGN_RIGHT: -	case ALIGN_CENTER: -	case ALIGN_LEFT: -	    Strcat_charp(tmp, "</div_int>"); -	    break; -	} -    } -#endif -    return tmp; -} - -Str -process_anchor(struct parsed_tag *tag, char *tagbuf) -{ -    if (parsedtag_need_reconstruct(tag)) { -	parsedtag_set_value(tag, ATTR_HSEQ, Sprintf("%d", cur_hseq++)->ptr); -	return parsedtag2str(tag); -    } -    else { -	Str tmp = Sprintf("<a hseq=\"%d\"", cur_hseq++); -	Strcat_charp(tmp, tagbuf + 2); -	return tmp; -    } -} - -Str -process_input(struct parsed_tag *tag) -{ -    int i, w, v, x, y, z, iw, ih; -    char *q, *p, *r, *p2, *s; -    Str tmp = NULL; -    char *qq = ""; -    int qlen = 0; - -    if (cur_form_id < 0) { -	char *s = "<form_int method=internal action=none>"; -	tmp = process_form(parse_tag(&s, TRUE)); -    } -    if (tmp == NULL) -	tmp = Strnew(); - -    p = "text"; -    parsedtag_get_value(tag, ATTR_TYPE, &p); -    q = NULL; -    parsedtag_get_value(tag, ATTR_VALUE, &q); -    r = ""; -    parsedtag_get_value(tag, ATTR_NAME, &r); -    w = 20; -    parsedtag_get_value(tag, ATTR_SIZE, &w); -    i = 20; -    parsedtag_get_value(tag, ATTR_MAXLENGTH, &i); -    p2 = NULL; -    parsedtag_get_value(tag, ATTR_ALT, &p2); -    x = parsedtag_exists(tag, ATTR_CHECKED); -    y = parsedtag_exists(tag, ATTR_ACCEPT); -    z = parsedtag_exists(tag, ATTR_READONLY); - -    v = formtype(p); -    if (v == FORM_UNKNOWN) -	return NULL; - -    if (!q) { -	switch (v) { -	case FORM_INPUT_IMAGE: -	case FORM_INPUT_SUBMIT: -	case FORM_INPUT_BUTTON: -	    q = "SUBMIT"; -	    break; -	case FORM_INPUT_RESET: -	    q = "RESET"; -	    break; -	    /* if no VALUE attribute is specified in  -	     * <INPUT TYPE=CHECKBOX> tag, then the value "on" is used  -	     * as a default value. It is not a part of HTML4.0  -	     * specification, but an imitation of Netscape behaviour.  -	     */ -	case FORM_INPUT_CHECKBOX: -	    q = "on"; -	} -    } -    /* VALUE attribute is not allowed in <INPUT TYPE=FILE> tag. */ -    if (v == FORM_INPUT_FILE) -	q = NULL; -    if (q) { -	qq = html_quote(q); -	qlen = get_strwidth(q); -    } - -    Strcat_charp(tmp, "<pre_int>"); -    switch (v) { -    case FORM_INPUT_PASSWORD: -    case FORM_INPUT_TEXT: -    case FORM_INPUT_FILE: -    case FORM_INPUT_CHECKBOX: -	Strcat_char(tmp, '['); -	break; -    case FORM_INPUT_RADIO: -	Strcat_char(tmp, '('); -    } -    Strcat(tmp, Sprintf("<input_alt hseq=\"%d\" fid=\"%d\" type=%s " -			"name=\"%s\" width=%d maxlength=%d value=\"%s\"", -			cur_hseq++, cur_form_id, p, html_quote(r), w, i, qq)); -    if (x) -	Strcat_charp(tmp, " checked"); -    if (y) -	Strcat_charp(tmp, " accept"); -    if (z) -	Strcat_charp(tmp, " readonly"); -    Strcat_char(tmp, '>'); - -    if (v == FORM_INPUT_HIDDEN) -	Strcat_charp(tmp, "</input_alt></pre_int>"); -    else { -	switch (v) { -	case FORM_INPUT_PASSWORD: -	case FORM_INPUT_TEXT: -	case FORM_INPUT_FILE: -	    Strcat_charp(tmp, "<u>"); -	    break; -	case FORM_INPUT_IMAGE: -	    s = NULL; -	    parsedtag_get_value(tag, ATTR_SRC, &s); -	    if (s) { -		Strcat(tmp, Sprintf("<img src=\"%s\"", html_quote(s))); -		if (p2) -		    Strcat(tmp, Sprintf(" alt=\"%s\"", html_quote(p2))); -		if (parsedtag_get_value(tag, ATTR_WIDTH, &iw)) -		    Strcat(tmp, Sprintf(" width=\"%d\"", iw)); -		if (parsedtag_get_value(tag, ATTR_HEIGHT, &ih)) -		    Strcat(tmp, Sprintf(" height=\"%d\"", ih)); -		Strcat_charp(tmp, ">"); -		Strcat_charp(tmp, "</input_alt></pre_int>"); -		return tmp; -	    } -	case FORM_INPUT_SUBMIT: -	case FORM_INPUT_BUTTON: -	case FORM_INPUT_RESET: -	    Strcat_charp(tmp, "["); -	    break; -	} -	switch (v) { -	case FORM_INPUT_PASSWORD: -	    i = 0; -	    if (q) { -		for (; i < qlen && i < w; i++) -		    Strcat_char(tmp, '*'); -	    } -	    for (; i < w; i++) -		Strcat_char(tmp, ' '); -	    break; -	case FORM_INPUT_TEXT: -	case FORM_INPUT_FILE: -	    if (q) -		Strcat(tmp, textfieldrep(Strnew_charp(q), w)); -	    else { -		for (i = 0; i < w; i++) -		    Strcat_char(tmp, ' '); -	    } -	    break; -	case FORM_INPUT_SUBMIT: -	case FORM_INPUT_BUTTON: -	    if (p2) -		Strcat_charp(tmp, html_quote(p2)); -	    else -		Strcat_charp(tmp, qq); -	    break; -	case FORM_INPUT_RESET: -	    Strcat_charp(tmp, qq); -	    break; -	case FORM_INPUT_RADIO: -	case FORM_INPUT_CHECKBOX: -	    if (x) -		Strcat_char(tmp, '*'); -	    else -		Strcat_char(tmp, ' '); -	    break; -	} -	switch (v) { -	case FORM_INPUT_PASSWORD: -	case FORM_INPUT_TEXT: -	case FORM_INPUT_FILE: -	    Strcat_charp(tmp, "</u>"); -	    break; -	case FORM_INPUT_IMAGE: -	case FORM_INPUT_SUBMIT: -	case FORM_INPUT_BUTTON: -	case FORM_INPUT_RESET: -	    Strcat_charp(tmp, "]"); -	} -	Strcat_charp(tmp, "</input_alt>"); -	switch (v) { -	case FORM_INPUT_PASSWORD: -	case FORM_INPUT_TEXT: -	case FORM_INPUT_FILE: -	case FORM_INPUT_CHECKBOX: -	    Strcat_char(tmp, ']'); -	    break; -	case FORM_INPUT_RADIO: -	    Strcat_char(tmp, ')'); -	} -	Strcat_charp(tmp, "</pre_int>"); -    } -    return tmp; -} - -Str -process_select(struct parsed_tag *tag) -{ -    Str tmp = NULL; -    char *p; - -    if (cur_form_id < 0) { -	char *s = "<form_int method=internal action=none>"; -	tmp = process_form(parse_tag(&s, TRUE)); -    } - -    p = ""; -    parsedtag_get_value(tag, ATTR_NAME, &p); -    cur_select = Strnew_charp(p); -    select_is_multiple = parsedtag_exists(tag, ATTR_MULTIPLE); - -#ifdef MENU_SELECT -    if (!select_is_multiple) { -	select_str = Sprintf("<pre_int>[<input_alt hseq=\"%d\" " -			     "fid=\"%d\" type=select name=\"%s\" selectnumber=%d", -			     cur_hseq++, cur_form_id, html_quote(p), n_select); -	Strcat_charp(select_str, ">"); -	if (n_select == max_select) { -	    max_select *= 2; -	    select_option = -		New_Reuse(FormSelectOption, select_option, max_select); -	} -	select_option[n_select].first = NULL; -	select_option[n_select].last = NULL; -	cur_option_maxwidth = 0; -    } -    else -#endif				/* MENU_SELECT */ -	select_str = Strnew(); -    cur_option = NULL; -    cur_status = R_ST_NORMAL; -    n_selectitem = 0; -    return tmp; -} - -Str -process_n_select(void) -{ -    if (cur_select == NULL) -	return NULL; -    process_option(); -#ifdef MENU_SELECT -    if (!select_is_multiple) { -	if (select_option[n_select].first) { -	    FormItemList sitem; -	    chooseSelectOption(&sitem, select_option[n_select].first); -	    Strcat(select_str, textfieldrep(sitem.label, cur_option_maxwidth)); -	} -	Strcat_charp(select_str, "</input_alt>]</pre_int>"); -	n_select++; -    } -    else -#endif				/* MENU_SELECT */ -	Strcat_charp(select_str, "<br>"); -    cur_select = NULL; -    n_selectitem = 0; -    return select_str; -} - -void -feed_select(char *str) -{ -    Str tmp = Strnew(); -    int prev_status = cur_status; -    static int prev_spaces = -1; -    char *p; - -    if (cur_select == NULL) -	return; -    while (read_token(tmp, &str, &cur_status, 0, 0)) { -	if (cur_status != R_ST_NORMAL || prev_status != R_ST_NORMAL) -	    continue; -	p = tmp->ptr; -	if (tmp->ptr[0] == '<' && Strlastchar(tmp) == '>') { -	    struct parsed_tag *tag; -	    char *q; -	    if (!(tag = parse_tag(&p, FALSE))) -		continue; -	    switch (tag->tagid) { -	    case HTML_OPTION: -		process_option(); -		cur_option = Strnew(); -		if (parsedtag_get_value(tag, ATTR_VALUE, &q)) -		    cur_option_value = Strnew_charp(q); -		else -		    cur_option_value = NULL; -		if (parsedtag_get_value(tag, ATTR_LABEL, &q)) -		    cur_option_label = Strnew_charp(q); -		else -		    cur_option_label = NULL; -		cur_option_selected = parsedtag_exists(tag, ATTR_SELECTED); -		prev_spaces = -1; -		break; -	    case HTML_N_OPTION: -		/* do nothing */ -		break; -	    default: -		/* never happen */ -		break; -	    } -	} -	else if (cur_option) { -	    while (*p) { -		if (IS_SPACE(*p) && prev_spaces != 0) { -		    p++; -		    if (prev_spaces > 0) -			prev_spaces++; -		} -		else { -		    if (IS_SPACE(*p)) -			prev_spaces = 1; -		    else -			prev_spaces = 0; -		    if (*p == '&') -			Strcat_charp(cur_option, getescapecmd(&p)); -		    else -			Strcat_char(cur_option, *(p++)); -		} -	    } -	} -    } -} - -void -process_option(void) -{ -    char begin_char = '[', end_char = ']'; -    int len; - -    if (cur_select == NULL || cur_option == NULL) -	return; -    while (cur_option->length > 0 && IS_SPACE(Strlastchar(cur_option))) -	Strshrink(cur_option, 1); -    if (cur_option_value == NULL) -	cur_option_value = cur_option; -    if (cur_option_label == NULL) -	cur_option_label = cur_option; -#ifdef MENU_SELECT -    if (!select_is_multiple) { -	len = get_Str_strwidth(cur_option_label); -	if (len > cur_option_maxwidth) -	    cur_option_maxwidth = len; -	addSelectOption(&select_option[n_select], -			cur_option_value, -			cur_option_label, cur_option_selected); -	return; -    } -#endif				/* MENU_SELECT */ -    if (!select_is_multiple) { -	begin_char = '('; -	end_char = ')'; -    } -    Strcat(select_str, Sprintf("<br><pre_int>%c<input_alt hseq=\"%d\" " -			       "fid=\"%d\" type=%s name=\"%s\" value=\"%s\"", -			       begin_char, cur_hseq++, cur_form_id, -			       select_is_multiple ? "checkbox" : "radio", -			       html_quote(cur_select->ptr), -			       html_quote(cur_option_value->ptr))); -    if (cur_option_selected) -	Strcat_charp(select_str, " checked>*</input_alt>"); -    else -	Strcat_charp(select_str, "> </input_alt>"); -    Strcat_char(select_str, end_char); -    Strcat_charp(select_str, html_quote(cur_option_label->ptr)); -    Strcat_charp(select_str, "</pre_int>"); -    n_selectitem++; -} - -Str -process_textarea(struct parsed_tag *tag, int width) -{ -    Str tmp = NULL; -    char *p; - -    if (cur_form_id < 0) { -	char *s = "<form_int method=internal action=none>"; -	tmp = process_form(parse_tag(&s, TRUE)); -    } - -    p = ""; -    parsedtag_get_value(tag, ATTR_NAME, &p); -    cur_textarea = Strnew_charp(p); -    cur_textarea_size = 20; -    if (parsedtag_get_value(tag, ATTR_COLS, &p)) { -	cur_textarea_size = atoi(p); -	if (p[strlen(p) - 1] == '%') -	    cur_textarea_size = width * cur_textarea_size / 100 - 2; -	if (cur_textarea_size <= 0) -	    cur_textarea_size = 20; -    } -    cur_textarea_rows = 1; -    if (parsedtag_get_value(tag, ATTR_ROWS, &p)) { -	cur_textarea_rows = atoi(p); -	if (cur_textarea_rows <= 0) -	    cur_textarea_rows = 1; -    } -    cur_textarea_readonly = parsedtag_exists(tag, ATTR_READONLY); -    if (n_textarea >= max_textarea) { -	max_textarea *= 2; -	textarea_str = New_Reuse(Str, textarea_str, max_textarea); -    } -    textarea_str[n_textarea] = Strnew(); -    ignore_nl_textarea = TRUE; - -    return tmp; -} - -Str -process_n_textarea(void) -{ -    Str tmp; -    int i; - -    if (cur_textarea == NULL) -	return NULL; - -    tmp = Strnew(); -    Strcat(tmp, Sprintf("<pre_int>[<input_alt hseq=\"%d\" fid=\"%d\" " -			"type=textarea name=\"%s\" size=%d rows=%d " -			"top_margin=%d textareanumber=%d", -			cur_hseq, cur_form_id, -			html_quote(cur_textarea->ptr), -			cur_textarea_size, cur_textarea_rows, -			cur_textarea_rows - 1, n_textarea)); -    if (cur_textarea_readonly) -	Strcat_charp(tmp, " readonly"); -    Strcat_charp(tmp, "><u>"); -    for (i = 0; i < cur_textarea_size; i++) -	Strcat_char(tmp, ' '); -    Strcat_charp(tmp, "</u></input_alt>]</pre_int>\n"); -    cur_hseq++; -    n_textarea++; -    cur_textarea = NULL; - -    return tmp; -} - -void -feed_textarea(char *str) -{ -    if (cur_textarea == NULL) -	return; -    if (ignore_nl_textarea) { -	if (*str == '\r') -	    str++; -	if (*str == '\n') -	    str++; -    } -    ignore_nl_textarea = FALSE; -    while (*str) { -	if (*str == '&') -	    Strcat_charp(textarea_str[n_textarea], getescapecmd(&str)); -	else if (*str == '\n') { -	    Strcat_charp(textarea_str[n_textarea], "\r\n"); -	    str++; -	} -	else if (*str != '\r') -	    Strcat_char(textarea_str[n_textarea], *(str++)); -    } -} - -Str -process_hr(struct parsed_tag *tag, int width, int indent_width) -{ -    Str tmp = Strnew_charp("<nobr>"); -    int w = 0; -    int x = ALIGN_CENTER; - -    if (width > indent_width) -	width -= indent_width; -    if (parsedtag_get_value(tag, ATTR_WIDTH, &w)) -	w = REAL_WIDTH(w, width); -    else -	w = width; - -    parsedtag_get_value(tag, ATTR_ALIGN, &x); -    switch (x) { -    case ALIGN_CENTER: -	Strcat_charp(tmp, "<div_int align=center>"); -	break; -    case ALIGN_RIGHT: -	Strcat_charp(tmp, "<div_int align=right>"); -	break; -    case ALIGN_LEFT: -	Strcat_charp(tmp, "<div_int align=left>"); -	break; -    } -    w /= symbol_width; -    if (w <= 0) -	w = 1; -    push_symbol(tmp, HR_SYMBOL, symbol_width, w); -    Strcat_charp(tmp, "</div_int></nobr>"); -    return tmp; -} - -#ifdef USE_M17N -static char * -check_charset(char *p) -{ -    return wc_guess_charset(p, 0) ? p : NULL; -} - -static char * -check_accept_charset(char *ac) -{ -    char *s = ac, *e; - -    while (*s) { -	while (*s && (IS_SPACE(*s) || *s == ',')) -	    s++; -	if (!*s) -	    break; -	e = s; -	while (*e && !(IS_SPACE(*e) || *e == ',')) -	    e++; -	if (wc_guess_charset(Strnew_charp_n(s, e - s)->ptr, 0)) -	    return ac; -	s = e; -    } -    return NULL; -} -#endif - -static Str -process_form_int(struct parsed_tag *tag, int fid) -{ -    char *p, *q, *r, *s, *tg, *n; - -    p = "get"; -    parsedtag_get_value(tag, ATTR_METHOD, &p); -    q = "!CURRENT_URL!"; -    parsedtag_get_value(tag, ATTR_ACTION, &q); -    r = NULL; -#ifdef USE_M17N -    if (parsedtag_get_value(tag, ATTR_ACCEPT_CHARSET, &r)) -	r = check_accept_charset(r); -    if (!r && parsedtag_get_value(tag, ATTR_CHARSET, &r)) -	r = check_charset(r); -#endif -    s = NULL; -    parsedtag_get_value(tag, ATTR_ENCTYPE, &s); -    tg = NULL; -    parsedtag_get_value(tag, ATTR_TARGET, &tg); -    n = NULL; -    parsedtag_get_value(tag, ATTR_NAME, &n); - -    if (fid < 0) { -	form_max++; -	form_sp++; -	fid = form_max; -    } -    else {			/* <form_int> */ -	if (form_max < fid) -	    form_max = fid; -	form_sp = fid; -    } -    if (forms_size == 0) { -	forms_size = INITIAL_FORM_SIZE; -	forms = New_N(FormList *, forms_size); -	form_stack = NewAtom_N(int, forms_size); -    } -    else if (forms_size <= form_max) { -	forms_size += form_max; -	forms = New_Reuse(FormList *, forms, forms_size); -	form_stack = New_Reuse(int, form_stack, forms_size); -    } -    form_stack[form_sp] = fid; - -    if (w3m_halfdump) { -	Str tmp = Sprintf("<form_int fid=\"%d\" action=\"%s\" method=\"%s\"", -			  fid, html_quote(q), html_quote(p)); -	if (s) -	    Strcat(tmp, Sprintf(" enctype=\"%s\"", html_quote(s))); -	if (tg) -	    Strcat(tmp, Sprintf(" target=\"%s\"", html_quote(tg))); -	if (n) -	    Strcat(tmp, Sprintf(" name=\"%s\"", html_quote(n))); -#ifdef USE_M17N -	if (r) -	    Strcat(tmp, Sprintf(" accept-charset=\"%s\"", html_quote(r))); -#endif -	Strcat_charp(tmp, ">"); -	return tmp; -    } - -    forms[fid] = newFormList(q, p, r, s, tg, n, NULL); -    return NULL; -} - -Str -process_form(struct parsed_tag *tag) -{ -    return process_form_int(tag, -1); -} - -Str -process_n_form(void) -{ -    if (form_sp >= 0) -	form_sp--; -    return NULL; -} - -static void -clear_ignore_p_flag(int cmd, struct readbuffer *obuf) -{ -    static int clear_flag_cmd[] = { -	HTML_HR, HTML_UNKNOWN -    }; -    int i; - -    for (i = 0; clear_flag_cmd[i] != HTML_UNKNOWN; i++) { -	if (cmd == clear_flag_cmd[i]) { -	    obuf->flag &= ~RB_IGNORE_P; -	    return; -	} -    } -} - -static void -set_alignment(struct readbuffer *obuf, struct parsed_tag *tag) -{ -    long flag = -1; -    int align; - -    if (parsedtag_get_value(tag, ATTR_ALIGN, &align)) { -	switch (align) { -	case ALIGN_CENTER: -	    flag = RB_CENTER; -	    break; -	case ALIGN_RIGHT: -	    flag = RB_RIGHT; -	    break; -	case ALIGN_LEFT: -	    flag = RB_LEFT; -	} -    } -    RB_SAVE_FLAG(obuf); -    if (flag != -1) { -	RB_SET_ALIGN(obuf, flag); -    } -} - -#ifdef ID_EXT -static void -process_idattr(struct readbuffer *obuf, int cmd, struct parsed_tag *tag) -{ -    char *id = NULL, *framename = NULL; -    Str idtag = NULL; - -    /*  -     * HTML_TABLE is handled by the other process. -     */ -    if (cmd == HTML_TABLE) -	return; - -    parsedtag_get_value(tag, ATTR_ID, &id); -    parsedtag_get_value(tag, ATTR_FRAMENAME, &framename); -    if (id == NULL) -	return; -    if (framename) -	idtag = Sprintf("<_id id=\"%s\" framename=\"%s\">", -			html_quote(id), html_quote(framename)); -    else -	idtag = Sprintf("<_id id=\"%s\">", html_quote(id)); -    push_tag(obuf, idtag->ptr, HTML_NOP); -} -#endif				/* ID_EXT */ - -#define CLOSE_P if (obuf->flag & RB_P) { \ -      flushline(h_env, obuf, envs[h_env->envc].indent,0,h_env->limit);\ -      RB_RESTORE_FLAG(obuf);\ -      obuf->flag &= ~RB_P;\ -    } - -#define CLOSE_A \ -    CLOSE_P; \ -    close_anchor(h_env, obuf); - -#define CLOSE_DT \ -    if (obuf->flag & RB_IN_DT) { \ -      obuf->flag &= ~RB_IN_DT; \ -      HTMLlineproc1("</b>", h_env); \ -    } - -#define PUSH_ENV(cmd) \ -    if (++h_env->envc_real < h_env->nenv) { \ -      ++h_env->envc; \ -      envs[h_env->envc].env = cmd; \ -      envs[h_env->envc].count = 0; \ -      if (h_env->envc <= MAX_INDENT_LEVEL) \ -        envs[h_env->envc].indent = envs[h_env->envc - 1].indent + INDENT_INCR; \ -      else \ -        envs[h_env->envc].indent = envs[h_env->envc - 1].indent; \ -    } - -#define POP_ENV \ -    if (h_env->envc_real-- < h_env->nenv) \ -      h_env->envc--; - -static int -ul_type(struct parsed_tag *tag, int default_type) -{ -    char *p; -    if (parsedtag_get_value(tag, ATTR_TYPE, &p)) { -	if (!strcasecmp(p, "disc")) -	    return (int)'d'; -	else if (!strcasecmp(p, "circle")) -	    return (int)'c'; -	else if (!strcasecmp(p, "square")) -	    return (int)'s'; -    } -    return default_type; -} - -int -getMetaRefreshParam(char *q, Str *refresh_uri) -{ -    int refresh_interval; -    char *r; -    Str s_tmp = NULL; - -    if (q == NULL || refresh_uri == NULL) -	return 0; - -    refresh_interval = atoi(q); -    if (refresh_interval < 0) -	return 0; - -    while (*q) { -	if (!strncasecmp(q, "url=", 4)) { -	    q += 4; -	    if (*q == '\"')	/* " */ -		q++; -	    r = q; -	    while (*r && !IS_SPACE(*r) && *r != ';') -		r++; -	    s_tmp = Strnew_charp_n(q, r - q); - -	    if (s_tmp->ptr[s_tmp->length - 1] == '\"') {	/* "  -								 */ -		s_tmp->length--; -		s_tmp->ptr[s_tmp->length] = '\0'; -	    } -	    q = r; -	} -	while (*q && *q != ';') -	    q++; -	if (*q == ';') -	    q++; -	while (*q && *q == ' ') -	    q++; -    } -    *refresh_uri = s_tmp; -    return refresh_interval; -} - -int -HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) -{ -    char *p, *q, *r; -    int i, w, x, y, z, count, width; -    struct readbuffer *obuf = h_env->obuf; -    struct environment *envs = h_env->envs; -    Str tmp; -    int hseq; -    int cmd; -#ifdef ID_EXT -    char *id = NULL; -#endif				/* ID_EXT */ - -    cmd = tag->tagid; - -    if (obuf->flag & RB_PRE) { -	switch (cmd) { -	case HTML_NOBR: -	case HTML_N_NOBR: -	case HTML_PRE_INT: -	case HTML_N_PRE_INT: -	    return 1; -	} -    } - -    switch (cmd) { -    case HTML_B: -	obuf->in_bold++; -	if (obuf->in_bold > 1) -	    return 1; -	return 0; -    case HTML_N_B: -	if (obuf->in_bold == 1 && close_effect0(obuf, HTML_B)) -	    obuf->in_bold = 0; -	if (obuf->in_bold > 0) { -	    obuf->in_bold--; -	    if (obuf->in_bold == 0) -		return 0; -	} -	return 1; -    case HTML_U: -	obuf->in_under++; -	if (obuf->in_under > 1) -	    return 1; -	return 0; -    case HTML_N_U: -	if (obuf->in_under == 1 && close_effect0(obuf, HTML_U)) -	    obuf->in_under = 0; -	if (obuf->in_under > 0) { -	    obuf->in_under--; -	    if (obuf->in_under == 0) -		return 0; -	} -	return 1; -    case HTML_EM: -	HTMLlineproc1("<b>", h_env); -	return 1; -    case HTML_N_EM: -	HTMLlineproc1("</b>", h_env); -	return 1; -    case HTML_Q: -	HTMLlineproc1("`", h_env); -	return 1; -    case HTML_N_Q: -	HTMLlineproc1("'", h_env); -	return 1; -    case HTML_P: -    case HTML_N_P: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 1, h_env->limit); -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	} -	obuf->flag |= RB_IGNORE_P; -	if (cmd == HTML_P) { -	    set_alignment(obuf, tag); -	    obuf->flag |= RB_P; -	} -	return 1; -    case HTML_BR: -	flushline(h_env, obuf, envs[h_env->envc].indent, 1, h_env->limit); -	h_env->blank_lines = 0; -	return 1; -    case HTML_H: -	if (!(obuf->flag & (RB_PREMODE | RB_IGNORE_P))) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	} -	HTMLlineproc1("<b>", h_env); -	set_alignment(obuf, tag); -	return 1; -    case HTML_N_H: -	HTMLlineproc1("</b>", h_env); -	if (!(obuf->flag & RB_PREMODE)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	} -	do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	RB_RESTORE_FLAG(obuf); -	close_anchor(h_env, obuf); -	obuf->flag |= RB_IGNORE_P; -	return 1; -    case HTML_UL: -    case HTML_OL: -    case HTML_BLQ: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    if (!(obuf->flag & RB_PREMODE) && -		(h_env->envc == 0 || cmd == HTML_BLQ)) -		do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			     h_env->limit); -	} -	PUSH_ENV(cmd); -	if (cmd == HTML_UL || cmd == HTML_OL) { -	    if (parsedtag_get_value(tag, ATTR_START, &count)) { -		envs[h_env->envc].count = count - 1; -	    } -	} -	if (cmd == HTML_OL) { -	    envs[h_env->envc].type = '1'; -	    if (parsedtag_get_value(tag, ATTR_TYPE, &p)) { -		envs[h_env->envc].type = (int)*p; -	    } -	} -	if (cmd == HTML_UL) -	    envs[h_env->envc].type = ul_type(tag, 0); -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	return 1; -    case HTML_N_UL: -    case HTML_N_OL: -    case HTML_N_DL: -    case HTML_N_BLQ: -	CLOSE_DT; -	CLOSE_A; -	if (h_env->envc > 0) { -	    flushline(h_env, obuf, envs[h_env->envc - 1].indent, 0, -		      h_env->limit); -	    POP_ENV; -	    if (!(obuf->flag & RB_PREMODE) && -		(h_env->envc == 0 || cmd == HTML_N_DL || cmd == HTML_N_BLQ)) { -		do_blankline(h_env, obuf, -			     envs[h_env->envc].indent, -			     INDENT_INCR, h_env->limit); -		obuf->flag |= RB_IGNORE_P; -	    } -	} -	close_anchor(h_env, obuf); -	return 1; -    case HTML_DL: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    if (!(obuf->flag & RB_PREMODE)) -		do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			     h_env->limit); -	} -	PUSH_ENV(cmd); -	if (parsedtag_exists(tag, ATTR_COMPACT)) -	    envs[h_env->envc].env = HTML_DL_COMPACT; -	obuf->flag |= RB_IGNORE_P; -	return 1; -    case HTML_LI: -	CLOSE_A; -	CLOSE_DT; -	if (h_env->envc > 0) { -	    Str num; -	    flushline(h_env, obuf, -		      envs[h_env->envc - 1].indent, 0, h_env->limit); -	    envs[h_env->envc].count++; -	    if (parsedtag_get_value(tag, ATTR_VALUE, &p)) { -		count = atoi(p); -		if (count > 0) -		    envs[h_env->envc].count = count; -		else -		    envs[h_env->envc].count = 0; -	    } -	    switch (envs[h_env->envc].env) { -	    case HTML_UL: -		envs[h_env->envc].type = ul_type(tag, envs[h_env->envc].type); -		for (i = 0; i < INDENT_INCR - 3; i++) -		    push_charp(obuf, 1, NBSP, PC_ASCII); -		tmp = Strnew(); -		switch (envs[h_env->envc].type) { -		case 'd': -		    push_symbol(tmp, UL_SYMBOL_DISC, symbol_width, 1); -		    break; -		case 'c': -		    push_symbol(tmp, UL_SYMBOL_CIRCLE, symbol_width, 1); -		    break; -		case 's': -		    push_symbol(tmp, UL_SYMBOL_SQUARE, symbol_width, 1); -		    break; -		default: -		    push_symbol(tmp, -				UL_SYMBOL((h_env->envc_real - -					   1) % MAX_UL_LEVEL), symbol_width, -				1); -		    break; -		} -		if (symbol_width == 1) -		    push_charp(obuf, 1, NBSP, PC_ASCII); -		push_str(obuf, symbol_width, tmp, PC_ASCII); -		push_charp(obuf, 1, NBSP, PC_ASCII); -		set_space_to_prevchar(obuf->prevchar); -		break; -	    case HTML_OL: -		if (parsedtag_get_value(tag, ATTR_TYPE, &p)) -		    envs[h_env->envc].type = (int)*p; -		switch ((envs[h_env->envc].count > 0)? envs[h_env->envc].type: '1') { -		case 'i': -		    num = romanNumeral(envs[h_env->envc].count); -		    break; -		case 'I': -		    num = romanNumeral(envs[h_env->envc].count); -		    Strupper(num); -		    break; -		case 'a': -		    num = romanAlphabet(envs[h_env->envc].count); -		    break; -		case 'A': -		    num = romanAlphabet(envs[h_env->envc].count); -		    Strupper(num); -		    break; -		default: -		    num = Sprintf("%d", envs[h_env->envc].count); -		    break; -		} -		if (INDENT_INCR >= 4) -		    Strcat_charp(num, ". "); -		else -		    Strcat_char(num, '.'); -		push_spaces(obuf, 1, INDENT_INCR - num->length); -		push_str(obuf, num->length, num, PC_ASCII); -		if (INDENT_INCR >= 4) -		    set_space_to_prevchar(obuf->prevchar); -		break; -	    default: -		push_spaces(obuf, 1, INDENT_INCR); -		break; -	    } -	} -	else { -	    flushline(h_env, obuf, 0, 0, h_env->limit); -	} -	obuf->flag |= RB_IGNORE_P; -	return 1; -    case HTML_DT: -	CLOSE_A; -	if (h_env->envc == 0 || -	    (h_env->envc_real < h_env->nenv && -	     envs[h_env->envc].env != HTML_DL && -	     envs[h_env->envc].env != HTML_DL_COMPACT)) { -	    PUSH_ENV(HTML_DL); -	} -	if (h_env->envc > 0) { -	    flushline(h_env, obuf, -		      envs[h_env->envc - 1].indent, 0, h_env->limit); -	} -	if (!(obuf->flag & RB_IN_DT)) { -	    HTMLlineproc1("<b>", h_env); -	    obuf->flag |= RB_IN_DT; -	} -	obuf->flag |= RB_IGNORE_P; -	return 1; -    case HTML_DD: -	CLOSE_A; -	CLOSE_DT; -	if (envs[h_env->envc].env == HTML_DL_COMPACT) { -	    if (obuf->pos > envs[h_env->envc].indent) -		flushline(h_env, obuf, envs[h_env->envc].indent, 0, -			  h_env->limit); -	    else -		push_spaces(obuf, 1, envs[h_env->envc].indent - obuf->pos); -	} -	else -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	/* obuf->flag |= RB_IGNORE_P; */ -	return 1; -    case HTML_TITLE: -	close_anchor(h_env, obuf); -	process_title(tag); -	obuf->flag |= RB_TITLE; -	obuf->end_tag = HTML_N_TITLE; -	return 1; -    case HTML_N_TITLE: -	if (!(obuf->flag & RB_TITLE)) -	    return 1; -	obuf->flag &= ~RB_TITLE; -	obuf->end_tag = 0; -	tmp = process_n_title(tag); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_TITLE_ALT: -	if (parsedtag_get_value(tag, ATTR_TITLE, &p)) -	    h_env->title = html_unquote(p); -	return 0; -    case HTML_FRAMESET: -	PUSH_ENV(cmd); -	push_charp(obuf, 9, "--FRAME--", PC_ASCII); -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	return 0; -    case HTML_N_FRAMESET: -	if (h_env->envc > 0) { -	    POP_ENV; -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	} -	return 0; -    case HTML_NOFRAMES: -	CLOSE_A; -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	obuf->flag |= (RB_NOFRAMES | RB_IGNORE_P); -	/* istr = str; */ -	return 1; -    case HTML_N_NOFRAMES: -	CLOSE_A; -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	obuf->flag &= ~RB_NOFRAMES; -	return 1; -    case HTML_FRAME: -	q = r = NULL; -	parsedtag_get_value(tag, ATTR_SRC, &q); -	parsedtag_get_value(tag, ATTR_NAME, &r); -	if (q) { -	    q = html_quote(q); -	    push_tag(obuf, Sprintf("<a hseq=\"%d\" href=\"%s\">", -				   cur_hseq++, q)->ptr, HTML_A); -	    if (r) -		q = html_quote(r); -	    push_charp(obuf, get_strwidth(q), q, PC_ASCII); -	    push_tag(obuf, "</a>", HTML_N_A); -	} -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	return 0; -    case HTML_HR: -	close_anchor(h_env, obuf); -	tmp = process_hr(tag, h_env->limit, envs[h_env->envc].indent); -	HTMLlineproc1(tmp->ptr, h_env); -	set_space_to_prevchar(obuf->prevchar); -	return 1; -    case HTML_PRE: -	x = parsedtag_exists(tag, ATTR_FOR_TABLE); -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    if (!x) -		do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			     h_env->limit); -	} -	else -	    fillline(obuf, envs[h_env->envc].indent); -	obuf->flag |= (RB_PRE | RB_IGNORE_P); -	/* istr = str; */ -	return 1; -    case HTML_N_PRE: -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	if (!(obuf->flag & RB_IGNORE_P)) { -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	    obuf->flag |= RB_IGNORE_P; -	} -	obuf->flag &= ~RB_PRE; -	close_anchor(h_env, obuf); -	return 1; -    case HTML_PRE_INT: -	i = obuf->line->length; -	append_tags(obuf); -	if (!(obuf->flag & RB_SPECIAL)) { -	    set_breakpoint(obuf, obuf->line->length - i); -	} -	obuf->flag |= RB_PRE_INT; -	return 0; -    case HTML_N_PRE_INT: -	push_tag(obuf, "</pre_int>", HTML_N_PRE_INT); -	obuf->flag &= ~RB_PRE_INT; -	if (!(obuf->flag & RB_SPECIAL) && obuf->pos > obuf->bp.pos) { -	    set_prevchar(obuf->prevchar, "", 0); -	    obuf->prev_ctype = PC_CTRL; -	} -	return 1; -    case HTML_NOBR: -	obuf->flag |= RB_NOBR; -	obuf->nobr_level++; -	return 0; -    case HTML_N_NOBR: -	if (obuf->nobr_level > 0) -	    obuf->nobr_level--; -	if (obuf->nobr_level == 0) -	    obuf->flag &= ~RB_NOBR; -	return 0; -    case HTML_PRE_PLAIN: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	} -	obuf->flag |= (RB_PRE | RB_IGNORE_P); -	return 1; -    case HTML_N_PRE_PLAIN: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	    obuf->flag |= RB_IGNORE_P; -	} -	obuf->flag &= ~RB_PRE; -	return 1; -    case HTML_LISTING: -    case HTML_XMP: -    case HTML_PLAINTEXT: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	} -	obuf->flag |= (RB_PLAIN | RB_IGNORE_P); -	switch (cmd) { -	case HTML_LISTING: -	    obuf->end_tag = HTML_N_LISTING; -	    break; -	case HTML_XMP: -	    obuf->end_tag = HTML_N_XMP; -	    break; -	case HTML_PLAINTEXT: -	    obuf->end_tag = MAX_HTMLTAG; -	    break; -	} -	return 1; -    case HTML_N_LISTING: -    case HTML_N_XMP: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) { -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	    do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			 h_env->limit); -	    obuf->flag |= RB_IGNORE_P; -	} -	obuf->flag &= ~RB_PLAIN; -	obuf->end_tag = 0; -	return 1; -    case HTML_SCRIPT: -	obuf->flag |= RB_SCRIPT; -	obuf->end_tag = HTML_N_SCRIPT; -	return 1; -    case HTML_STYLE: -	obuf->flag |= RB_STYLE; -	obuf->end_tag = HTML_N_STYLE; -	return 1; -    case HTML_N_SCRIPT: -	obuf->flag &= ~RB_SCRIPT; -	obuf->end_tag = 0; -	return 1; -    case HTML_N_STYLE: -	obuf->flag &= ~RB_STYLE; -	obuf->end_tag = 0; -	return 1; -    case HTML_A: -	if (obuf->anchor.url) -	    close_anchor(h_env, obuf); - -	hseq = 0; - -	if (parsedtag_get_value(tag, ATTR_HREF, &p)) -	    obuf->anchor.url = Strnew_charp(p)->ptr; -	if (parsedtag_get_value(tag, ATTR_TARGET, &p)) -	    obuf->anchor.target = Strnew_charp(p)->ptr; -	if (parsedtag_get_value(tag, ATTR_REFERER, &p)) -	    obuf->anchor.referer = Strnew_charp(p)->ptr; -	if (parsedtag_get_value(tag, ATTR_TITLE, &p)) -	    obuf->anchor.title = Strnew_charp(p)->ptr; -	if (parsedtag_get_value(tag, ATTR_ACCESSKEY, &p)) -	    obuf->anchor.accesskey = (unsigned char)*p; -	if (parsedtag_get_value(tag, ATTR_HSEQ, &hseq)) -	    obuf->anchor.hseq = hseq; - -	if (hseq == 0 && obuf->anchor.url) { -	    obuf->anchor.hseq = cur_hseq; -	    tmp = process_anchor(tag, h_env->tagbuf->ptr); -	    push_tag(obuf, tmp->ptr, HTML_A); -	    return 1; -	} -	return 0; -    case HTML_N_A: -	close_anchor(h_env, obuf); -	return 1; -    case HTML_IMG: -	tmp = process_img(tag, h_env->limit); -	HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_IMG_ALT: -	if (parsedtag_get_value(tag, ATTR_SRC, &p)) -	    obuf->img_alt = Strnew_charp(p); -#ifdef USE_IMAGE -	i = 0; -	if (parsedtag_get_value(tag, ATTR_TOP_MARGIN, &i)) { -	    if (i > obuf->top_margin) -		obuf->top_margin = i; -	} -	i = 0; -	if (parsedtag_get_value(tag, ATTR_BOTTOM_MARGIN, &i)) { -	    if (i > obuf->bottom_margin) -		obuf->bottom_margin = i; -	} -#endif -	return 0; -    case HTML_N_IMG_ALT: -	if (obuf->img_alt) { -	    if (!close_effect0(obuf, HTML_IMG_ALT)) -		push_tag(obuf, "</img_alt>", HTML_N_IMG_ALT); -	    obuf->img_alt = NULL; -	} -	return 1; -    case HTML_INPUT_ALT: -	i = 0; -	if (parsedtag_get_value(tag, ATTR_TOP_MARGIN, &i)) { -	    if (i > obuf->top_margin) -		obuf->top_margin = i; -	} -	i = 0; -	if (parsedtag_get_value(tag, ATTR_BOTTOM_MARGIN, &i)) { -	    if (i > obuf->bottom_margin) -		obuf->bottom_margin = i; -	} -	return 0; -    case HTML_TABLE: -	close_anchor(h_env, obuf); -	obuf->table_level++; -	if (obuf->table_level >= MAX_TABLE) -	    break; -	w = BORDER_NONE; -	/* x: cellspacing, y: cellpadding */ -	x = 2; -	y = 1; -	z = 0; -	width = 0; -	if (parsedtag_exists(tag, ATTR_BORDER)) { -	    if (parsedtag_get_value(tag, ATTR_BORDER, &w)) { -		if (w > 2) -		    w = BORDER_THICK; -		else if (w < 0) {	/* weird */ -		    w = BORDER_THIN; -		} -	    } -	    else -		w = BORDER_THIN; -	} -	if (parsedtag_get_value(tag, ATTR_WIDTH, &i)) { -	    if (obuf->table_level == 0) -		width = REAL_WIDTH(i, h_env->limit - envs[h_env->envc].indent); -	    else -		width = RELATIVE_WIDTH(i); -	} -	if (parsedtag_exists(tag, ATTR_HBORDER)) -	    w = BORDER_NOWIN; -	parsedtag_get_value(tag, ATTR_CELLSPACING, &x); -	parsedtag_get_value(tag, ATTR_CELLPADDING, &y); -	parsedtag_get_value(tag, ATTR_VSPACE, &z); -#ifdef ID_EXT -	parsedtag_get_value(tag, ATTR_ID, &id); -#endif				/* ID_EXT */ -	tables[obuf->table_level] = begin_table(w, x, y, z); -#ifdef ID_EXT -	if (id != NULL) -	    tables[obuf->table_level]->id = Strnew_charp(id); -#endif				/* ID_EXT */ -	table_mode[obuf->table_level].pre_mode = 0; -	table_mode[obuf->table_level].indent_level = 0; -	table_mode[obuf->table_level].nobr_level = 0; -	table_mode[obuf->table_level].caption = 0; -	table_mode[obuf->table_level].end_tag = 0;	/* HTML_UNKNOWN */ -#ifndef TABLE_EXPAND -	tables[obuf->table_level]->total_width = width; -#else -	tables[obuf->table_level]->real_width = width; -	tables[obuf->table_level]->total_width = 0; -#endif -	return 1; -    case HTML_N_TABLE: -	/* should be processed in HTMLlineproc() */ -	return 1; -    case HTML_CENTER: -	CLOSE_A; -	if (!(obuf->flag & (RB_PREMODE | RB_IGNORE_P))) -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	RB_SAVE_FLAG(obuf); -	RB_SET_ALIGN(obuf, RB_CENTER); -	return 1; -    case HTML_N_CENTER: -	CLOSE_A; -	if (!(obuf->flag & RB_PREMODE)) -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	RB_RESTORE_FLAG(obuf); -	return 1; -    case HTML_DIV: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	set_alignment(obuf, tag); -	return 1; -    case HTML_N_DIV: -	CLOSE_A; -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	RB_RESTORE_FLAG(obuf); -	return 1; -    case HTML_DIV_INT: -	CLOSE_P; -	if (!(obuf->flag & RB_IGNORE_P)) -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	set_alignment(obuf, tag); -	return 1; -    case HTML_N_DIV_INT: -	CLOSE_P; -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	RB_RESTORE_FLAG(obuf); -	return 1; -    case HTML_FORM: -	CLOSE_A; -	if (!(obuf->flag & RB_IGNORE_P)) -	    flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	tmp = process_form(tag); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_N_FORM: -	CLOSE_A; -	flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); -	obuf->flag |= RB_IGNORE_P; -	process_n_form(); -	return 1; -    case HTML_INPUT: -	close_anchor(h_env, obuf); -	tmp = process_input(tag); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_SELECT: -	close_anchor(h_env, obuf); -	tmp = process_select(tag); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	obuf->flag |= RB_INSELECT; -	obuf->end_tag = HTML_N_SELECT; -	return 1; -    case HTML_N_SELECT: -	obuf->flag &= ~RB_INSELECT; -	obuf->end_tag = 0; -	tmp = process_n_select(); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_OPTION: -	/* nothing */ -	return 1; -    case HTML_TEXTAREA: -	close_anchor(h_env, obuf); -	tmp = process_textarea(tag, h_env->limit); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	obuf->flag |= RB_INTXTA; -	obuf->end_tag = HTML_N_TEXTAREA; -	return 1; -    case HTML_N_TEXTAREA: -	obuf->flag &= ~RB_INTXTA; -	obuf->end_tag = 0; -	tmp = process_n_textarea(); -	if (tmp) -	    HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_ISINDEX: -	p = ""; -	q = "!CURRENT_URL!"; -	parsedtag_get_value(tag, ATTR_PROMPT, &p); -	parsedtag_get_value(tag, ATTR_ACTION, &q); -	tmp = Strnew_m_charp("<form method=get action=\"", -			     html_quote(q), -			     "\">", -			     html_quote(p), -			     "<input type=text name=\"\" accept></form>", -			     NULL); -	HTMLlineproc1(tmp->ptr, h_env); -	return 1; -    case HTML_META: -	p = q = NULL; -	parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &p); -	parsedtag_get_value(tag, ATTR_CONTENT, &q); -#ifdef USE_M17N -	if (p && q && !strcasecmp(p, "Content-Type") && -	    (q = strcasestr(q, "charset")) != NULL) { -	    q += 7; -	    SKIP_BLANKS(q); -	    if (*q == '=') { -		q++; -		SKIP_BLANKS(q); -		meta_charset = wc_guess_charset(q, 0); -	    } -	} -	else -#endif -	if (p && q && !strcasecmp(p, "refresh")) { -	    int refresh_interval; -	    tmp = NULL; -	    refresh_interval = getMetaRefreshParam(q, &tmp); -	    if (tmp) { -		q = html_quote(tmp->ptr); -		tmp = Sprintf("Refresh (%d sec) <a href=\"%s\">%s</a>", -			      refresh_interval, q, q); -	    } -	    else if (refresh_interval > 0) -		tmp = Sprintf("Refresh (%d sec)", refresh_interval); -	    if (tmp) { -		HTMLlineproc1(tmp->ptr, h_env); -		do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, -			     h_env->limit); -		if (!is_redisplay && -		    !((obuf->flag & RB_NOFRAMES) && RenderFrame)) { -		    tag->need_reconstruct = TRUE; -		    return 0; -		} -	    } -	} -	return 1; -    case HTML_BASE: -#ifdef USE_IMAGE -	p = NULL; -	if (parsedtag_get_value(tag, ATTR_HREF, &p)) { -	    if (!cur_baseURL) -		cur_baseURL = New(ParsedURL); -	    parseURL(p, cur_baseURL, NULL); -	} -#endif -    case HTML_MAP: -    case HTML_N_MAP: -    case HTML_AREA: -	return 0; -    case HTML_DEL: -	if (displayInsDel) -	    HTMLlineproc1("<U>[DEL:</U>", h_env); -	else -	    obuf->flag |= RB_DEL; -	return 1; -    case HTML_N_DEL: -	if (displayInsDel) -	    HTMLlineproc1("<U>:DEL]</U>", h_env); -	else -	    obuf->flag &= ~RB_DEL; -	return 1; -    case HTML_S: -	if (displayInsDel) -	    HTMLlineproc1("<U>[S:</U>", h_env); -	else -	    obuf->flag |= RB_S; -	return 1; -    case HTML_N_S: -	if (displayInsDel) -	    HTMLlineproc1("<U>:S]</U>", h_env); -	else -	    obuf->flag &= ~RB_S; -	return 1; -    case HTML_INS: -	if (displayInsDel) -	    HTMLlineproc1("<U>[INS:</U>", h_env); -	return 1; -    case HTML_N_INS: -	if (displayInsDel) -	    HTMLlineproc1("<U>:INS]</U>", h_env); -	return 1; -    case HTML_SUP: -	if (!(obuf->flag & (RB_DEL | RB_S))) -	    HTMLlineproc1("^", h_env); -	return 1; -    case HTML_N_SUP: -	return 1; -    case HTML_SUB: -	if (!(obuf->flag & (RB_DEL | RB_S))) -	    HTMLlineproc1("[", h_env); -	return 1; -    case HTML_N_SUB: -	if (!(obuf->flag & (RB_DEL | RB_S))) -	    HTMLlineproc1("]", h_env); -	return 1; -    case HTML_FONT: -    case HTML_N_FONT: -    case HTML_NOP: -	return 1; -    case HTML_BGSOUND: -	if (view_unseenobject) { -	    if (parsedtag_get_value(tag, ATTR_SRC, &p)) { -		Str s; -		q = html_quote(p); -		s = Sprintf("<A HREF=\"%s\">bgsound(%s)</A>", q, q); -		HTMLlineproc1(s->ptr, h_env); -	    } -	} -	return 1; -    case HTML_EMBED: -	if (view_unseenobject) { -	    if (parsedtag_get_value(tag, ATTR_SRC, &p)) { -		Str s; -		q = html_quote(p); -		s = Sprintf("<A HREF=\"%s\">embed(%s)</A>", q, q); -		HTMLlineproc1(s->ptr, h_env); -	    } -	} -	return 1; -    case HTML_APPLET: -	if (view_unseenobject) { -	    if (parsedtag_get_value(tag, ATTR_ARCHIVE, &p)) { -		Str s; -		q = html_quote(p); -		s = Sprintf("<A HREF=\"%s\">applet archive(%s)</A>", q, q); -		HTMLlineproc1(s->ptr, h_env); -	    } -	} -	return 1; -    case HTML_BODY: -	if (view_unseenobject) { -	    if (parsedtag_get_value(tag, ATTR_BACKGROUND, &p)) { -		Str s; -		q = html_quote(p); -		s = Sprintf("<IMG SRC=\"%s\" ALT=\"bg image(%s)\"><BR>", q, q); -		HTMLlineproc1(s->ptr, h_env); -	    } -	} -    case HTML_N_HEAD: -	if (obuf->flag & RB_TITLE) -	    HTMLlineproc1("</title>", h_env); -    case HTML_HEAD: -    case HTML_N_BODY: -	return 1; -    default: -	/* obuf->prevchar = '\0'; */ -	return 0; -    } -    /* not reached */ -    return 0; -} - -#define PPUSH(p,c) {outp[pos]=(p);outc[pos]=(c);pos++;} -#define PSIZE	\ -    if (out_size <= pos + 1) {	\ -	out_size = pos * 3 / 2;	\ -	outc = New_Reuse(char, outc, out_size);	\ -	outp = New_Reuse(Lineprop, outp, out_size);	\ -    } - -static TextLineListItem *_tl_lp2; - -static Str -textlist_feed() -{ -    TextLine *p; -    if (_tl_lp2 != NULL) { -	p = _tl_lp2->ptr; -	_tl_lp2 = _tl_lp2->next; -	return p->line; -    } -    return NULL; -} - -static void -HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) -{ -    static char *outc = NULL; -    static Lineprop *outp = NULL; -    static int out_size = 0; -    Anchor *a_href = NULL, *a_img = NULL, *a_form = NULL; -    char *p, *q, *r, *s, *t, *str; -    Lineprop mode, effect; -    int pos; -    int nlines; -#ifdef DEBUG -    FILE *debug = NULL; -#endif -    struct frameset *frameset_s[FRAMESTACK_SIZE]; -    int frameset_sp = -1; -    union frameset_element *idFrame = NULL; -    char *id = NULL; -    int hseq, form_id; -    Str line; -    char *endp; -    char symbol = '\0'; -    int internal = 0; -    Anchor **a_textarea = NULL; -#ifdef MENU_SELECT -    Anchor **a_select = NULL; -#endif - -    if (out_size == 0) { -	out_size = LINELEN; -	outc = NewAtom_N(char, out_size); -	outp = NewAtom_N(Lineprop, out_size); -    } - -    n_textarea = -1; -    if (!max_textarea) {	/* halfload */ -	max_textarea = MAX_TEXTAREA; -	textarea_str = New_N(Str, max_textarea); -	a_textarea = New_N(Anchor *, max_textarea); -    } -#ifdef MENU_SELECT -    n_select = -1; -    if (!max_select) {		/* halfload */ -	max_select = MAX_SELECT; -	select_option = New_N(FormSelectOption, max_select); -	a_select = New_N(Anchor *, max_select); -    } -#endif - -#ifdef DEBUG -    if (w3m_debug) -	debug = fopen("zzzerr", "a"); -#endif - -    effect = 0; -    nlines = 0; -    while ((line = feed()) != NULL) { -#ifdef DEBUG -	if (w3m_debug) { -	    Strfputs(line, debug); -	    fputc('\n', debug); -	} -#endif -	if (n_textarea >= 0 && *(line->ptr) != '<') {	/* halfload */ -	    Strcat(textarea_str[n_textarea], line); -	    continue; -	} -      proc_again: -	if (++nlines == llimit) -	    break; -	pos = 0; -#ifdef ENABLE_REMOVE_TRAILINGSPACES -	Strremovetrailingspaces(line); -#endif -	str = line->ptr; -	endp = str + line->length; -	while (str < endp) { -	    PSIZE; -	    mode = get_mctype(str); -	    if (effect & PC_SYMBOL && *str != '<') { -#ifdef USE_M17N -		char **buf = set_symbol(symbol_width0); -		int len; - -		p = buf[(int)symbol]; -		len = get_mclen(p); -		mode = get_mctype(p); -		PPUSH(mode | effect, *(p++)); -		if (--len) { -		    mode = (mode & ~PC_WCHAR1) | PC_WCHAR2; -		    while (len--) { -			PSIZE; -			PPUSH(mode | effect, *(p++)); -		    } -		} -#else -		PPUSH(PC_ASCII | effect, SYMBOL_BASE + symbol); -#endif -		str += symbol_width; -	    } -#ifdef USE_M17N -	    else if (mode == PC_CTRL || mode == PC_UNDEF) { -#else -	    else if (mode == PC_CTRL || IS_INTSPACE(*str)) { -#endif -		PPUSH(PC_ASCII | effect, ' '); -		str++; -	    } -#ifdef USE_M17N -	    else if (mode & PC_UNKNOWN) { -		PPUSH(PC_ASCII | effect, ' '); -		str += get_mclen(str); -	    } -#endif -	    else if (*str != '<' && *str != '&') { -#ifdef USE_M17N -		int len = get_mclen(str); -#endif -		PPUSH(mode | effect, *(str++)); -#ifdef USE_M17N -		if (--len) { -		    mode = (mode & ~PC_WCHAR1) | PC_WCHAR2; -		    while (len--) { -			PSIZE; -			PPUSH(mode | effect, *(str++)); -		    } -		} -#endif -	    } -	    else if (*str == '&') { -		/*  -		 * & escape processing -		 */ -		p = getescapecmd(&str); -		while (*p) { -		    PSIZE; -		    mode = get_mctype((unsigned char *)p); -#ifdef USE_M17N -		    if (mode == PC_CTRL || mode == PC_UNDEF) { -#else -		    if (mode == PC_CTRL || IS_INTSPACE(*str)) { -#endif -			PPUSH(PC_ASCII | effect, ' '); -			p++; -		    } -#ifdef USE_M17N -		    else if (mode & PC_UNKNOWN) { -			PPUSH(PC_ASCII | effect, ' '); -			p += get_mclen(p); -		    } -#endif -		    else { -#ifdef USE_M17N -			int len = get_mclen(p); -#endif -			PPUSH(mode | effect, *(p++)); -#ifdef USE_M17N -			if (--len) { -			    mode = (mode & ~PC_WCHAR1) | PC_WCHAR2; -			    while (len--) { -				PSIZE; -				PPUSH(mode | effect, *(p++)); -			    } -			} -#endif -		    } -		} -	    } -	    else { -		/* tag processing */ -		struct parsed_tag *tag; -		if (!(tag = parse_tag(&str, TRUE))) -		    continue; -		switch (tag->tagid) { -		case HTML_B: -		    effect |= PE_BOLD; -		    break; -		case HTML_N_B: -		    effect &= ~PE_BOLD; -		    break; -		case HTML_U: -		    effect |= PE_UNDER; -		    break; -		case HTML_N_U: -		    effect &= ~PE_UNDER; -		    break; -		case HTML_A: -		    if (renderFrameSet && -			parsedtag_get_value(tag, ATTR_FRAMENAME, &p)) { -			p = url_quote_conv(p, buf->document_charset); -			if (!idFrame || strcmp(idFrame->body->name, p)) { -			    idFrame = search_frame(renderFrameSet, p); -			    if (idFrame && idFrame->body->attr != F_BODY) -				idFrame = NULL; -			} -		    } -		    p = r = s = NULL; -		    q = buf->baseTarget; -		    t = ""; -		    hseq = 0; -		    id = NULL; -		    if (parsedtag_get_value(tag, ATTR_NAME, &id)) { -			id = url_quote_conv(id, buf->document_charset); -			registerName(buf, id, currentLn(buf), pos); -		    } -		    if (parsedtag_get_value(tag, ATTR_HREF, &p)) -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); -		    if (parsedtag_get_value(tag, ATTR_TARGET, &q)) -			q = url_quote_conv(q, buf->document_charset); -		    if (parsedtag_get_value(tag, ATTR_REFERER, &r)) -			r = url_quote_conv(r, buf->document_charset); -		    parsedtag_get_value(tag, ATTR_TITLE, &s); -		    parsedtag_get_value(tag, ATTR_ACCESSKEY, &t); -		    parsedtag_get_value(tag, ATTR_HSEQ, &hseq); -		    if (hseq > 0) -			buf->hmarklist = -			    putHmarker(buf->hmarklist, currentLn(buf), -				       pos, hseq - 1); -		    else if (hseq < 0) { -			int h = -hseq - 1; -			if (buf->hmarklist && -			    h < buf->hmarklist->nmark && -			    buf->hmarklist->marks[h].invalid) { -			    buf->hmarklist->marks[h].pos = pos; -			    buf->hmarklist->marks[h].line = currentLn(buf); -			    buf->hmarklist->marks[h].invalid = 0; -			    hseq = -hseq; -			} -		    } -		    if (id && idFrame) -			idFrame->body->nameList = -			    putAnchor(idFrame->body->nameList, id, NULL, -				      (Anchor **)NULL, NULL, NULL, '\0', -				      currentLn(buf), pos); -		    if (p) { -			effect |= PE_ANCHOR; -			a_href = registerHref(buf, p, q, r, s, -					      *t, currentLn(buf), pos); -			a_href->hseq = ((hseq > 0) ? hseq : -hseq) - 1; -			a_href->slave = (hseq > 0) ? FALSE : TRUE; -		    } -		    break; -		case HTML_N_A: -		    effect &= ~PE_ANCHOR; -		    if (a_href) { -			a_href->end.line = currentLn(buf); -			a_href->end.pos = pos; -			if (a_href->start.line == a_href->end.line && -			    a_href->start.pos == a_href->end.pos) { -			    if (buf->hmarklist && -				a_href->hseq < buf->hmarklist->nmark) -				buf->hmarklist->marks[a_href->hseq].invalid = 1; -			    a_href->hseq = -1; -			} -			a_href = NULL; -		    } -		    break; - -		case HTML_LINK: -		    addLink(buf, tag); -		    break; - -		case HTML_IMG_ALT: -		    if (parsedtag_get_value(tag, ATTR_SRC, &p)) { -#ifdef USE_IMAGE -			int w = -1, h = -1, iseq = 0, ismap = 0; -			int xoffset = 0, yoffset = 0, top = 0, bottom = 0; -			parsedtag_get_value(tag, ATTR_HSEQ, &iseq); -			parsedtag_get_value(tag, ATTR_WIDTH, &w); -			parsedtag_get_value(tag, ATTR_HEIGHT, &h); -			parsedtag_get_value(tag, ATTR_XOFFSET, &xoffset); -			parsedtag_get_value(tag, ATTR_YOFFSET, &yoffset); -			parsedtag_get_value(tag, ATTR_TOP_MARGIN, &top); -			parsedtag_get_value(tag, ATTR_BOTTOM_MARGIN, &bottom); -			if (parsedtag_exists(tag, ATTR_ISMAP)) -			    ismap = 1; -			q = NULL; -			parsedtag_get_value(tag, ATTR_USEMAP, &q); -			if (iseq > 0) { -			    buf->imarklist = putHmarker(buf->imarklist, -							currentLn(buf), pos, -							iseq - 1); -			} -#endif -			s = NULL; -			parsedtag_get_value(tag, ATTR_TITLE, &s); -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); -			a_img = registerImg(buf, p, s, currentLn(buf), pos); -#ifdef USE_IMAGE -			a_img->hseq = iseq; -			a_img->image = NULL; -			if (iseq > 0) { -			    ParsedURL u; -			    Image *image; - -			    parseURL2(a_img->url, &u, cur_baseURL); -			    a_img->image = image = New(Image); -			    image->url = parsedURL2Str(&u)->ptr; -			    if (!uncompressed_file_type(u.file, &image->ext)) -				image->ext = filename_extension(u.file, TRUE); -			    image->cache = NULL; -			    image->width = -				(w > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE : w; -			    image->height = -				(h > MAX_IMAGE_SIZE) ? MAX_IMAGE_SIZE : h; -			    image->xoffset = xoffset; -			    image->yoffset = yoffset; -			    image->y = currentLn(buf) - top; -			    if (image->xoffset < 0 && pos == 0) -				image->xoffset = 0; -			    if (image->yoffset < 0 && image->y == 1) -				image->yoffset = 0; -			    image->rows = 1 + top + bottom; -			    image->map = q; -			    image->ismap = ismap; -			    image->touch = 0; -			    image->cache = getImage(image, cur_baseURL, -						    IMG_FLAG_SKIP); -			} -			else if (iseq < 0) { -			    BufferPoint *po = buf->imarklist->marks - iseq - 1; -			    Anchor *a = retrieveAnchor(buf->img, -						       po->line, po->pos); -			    if (a) { -				a_img->url = a->url; -				a_img->image = a->image; -			    } -			} -#endif -		    } -		    effect |= PE_IMAGE; -		    break; -		case HTML_N_IMG_ALT: -		    effect &= ~PE_IMAGE; -		    if (a_img) { -			a_img->end.line = currentLn(buf); -			a_img->end.pos = pos; -		    } -		    a_img = NULL; -		    break; -		case HTML_INPUT_ALT: -		    { -			FormList *form; -			int top = 0, bottom = 0; -			int textareanumber = -1; -#ifdef MENU_SELECT -			int selectnumber = -1; -#endif -			hseq = 0; -			form_id = -1; - -			parsedtag_get_value(tag, ATTR_HSEQ, &hseq); -			parsedtag_get_value(tag, ATTR_FID, &form_id); -			parsedtag_get_value(tag, ATTR_TOP_MARGIN, &top); -			parsedtag_get_value(tag, ATTR_BOTTOM_MARGIN, &bottom); -			if (form_id < 0 || form_id > form_max || forms == NULL) -			    break;	/* outside of <form>..</form> */ -			form = forms[form_id]; -			if (hseq > 0) { -			    int hpos = pos; -			    if (*str == '[') -				hpos++; -			    buf->hmarklist = -				putHmarker(buf->hmarklist, currentLn(buf), -					   hpos, hseq - 1); -			} -			if (!form->target) -			    form->target = buf->baseTarget; -			if (a_textarea && -			    parsedtag_get_value(tag, ATTR_TEXTAREANUMBER, -						&textareanumber)) { -			    if (textareanumber >= max_textarea) { -				max_textarea = 2 * textareanumber; -				textarea_str = New_Reuse(Str, textarea_str, -							 max_textarea); -				a_textarea = New_Reuse(Anchor *, a_textarea, -						       max_textarea); -			    } -			} -#ifdef MENU_SELECT -			if (a_select && -			    parsedtag_get_value(tag, ATTR_SELECTNUMBER, -						&selectnumber)) { -			    if (selectnumber >= max_select) { -				max_select = 2 * selectnumber; -				select_option = New_Reuse(FormSelectOption, -							  select_option, -							  max_select); -				a_select = New_Reuse(Anchor *, a_select, -						     max_select); -			    } -			} -#endif -			a_form = -			    registerForm(buf, form, tag, currentLn(buf), pos); -			if (a_textarea && textareanumber >= 0) -			    a_textarea[textareanumber] = a_form; -#ifdef MENU_SELECT -			if (a_select && selectnumber >= 0) -			    a_select[selectnumber] = a_form; -#endif -			if (a_form) { -			    a_form->hseq = hseq - 1; -			    a_form->y = currentLn(buf) - top; -			    a_form->rows = 1 + top + bottom; -			    if (!parsedtag_exists(tag, ATTR_NO_EFFECT)) -				effect |= PE_FORM; -			    break; -			} -		    } -		case HTML_N_INPUT_ALT: -		    effect &= ~PE_FORM; -		    if (a_form) { -			a_form->end.line = currentLn(buf); -			a_form->end.pos = pos; -			if (a_form->start.line == a_form->end.line && -			    a_form->start.pos == a_form->end.pos) -			    a_form->hseq = -1; -		    } -		    a_form = NULL; -		    break; -		case HTML_MAP: -		    if (parsedtag_get_value(tag, ATTR_NAME, &p)) { -			MapList *m = New(MapList); -			m->name = Strnew_charp(p); -			m->area = newGeneralList(); -			m->next = buf->maplist; -			buf->maplist = m; -		    } -		    break; -		case HTML_N_MAP: -		    /* nothing to do */ -		    break; -		case HTML_AREA: -		    if (buf->maplist == NULL)	/* outside of <map>..</map> */ -			break; -		    if (parsedtag_get_value(tag, ATTR_HREF, &p)) { -			MapArea *a; -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); -			t = NULL; -			parsedtag_get_value(tag, ATTR_TARGET, &t); -			q = ""; -			parsedtag_get_value(tag, ATTR_ALT, &q); -			r = NULL; -			s = NULL; -#ifdef USE_IMAGE -			parsedtag_get_value(tag, ATTR_SHAPE, &r); -			parsedtag_get_value(tag, ATTR_COORDS, &s); -#endif -			a = newMapArea(p, t, q, r, s); -			pushValue(buf->maplist->area, (void *)a); -		    } -		    break; -		case HTML_FRAMESET: -		    frameset_sp++; -		    if (frameset_sp >= FRAMESTACK_SIZE) -			break; -		    frameset_s[frameset_sp] = newFrameSet(tag); -		    if (frameset_s[frameset_sp] == NULL) -			break; -		    if (frameset_sp == 0) { -			if (buf->frameset == NULL) { -			    buf->frameset = frameset_s[frameset_sp]; -			} -			else -			    pushFrameTree(&(buf->frameQ), -					  frameset_s[frameset_sp], NULL); -		    } -		    else -			addFrameSetElement(frameset_s[frameset_sp - 1], -					   *(union frameset_element *) -					   &frameset_s[frameset_sp]); -		    break; -		case HTML_N_FRAMESET: -		    if (frameset_sp >= 0) -			frameset_sp--; -		    break; -		case HTML_FRAME: -		    if (frameset_sp >= 0 && frameset_sp < FRAMESTACK_SIZE) { -			union frameset_element element; - -			element.body = newFrame(tag, buf); -			addFrameSetElement(frameset_s[frameset_sp], element); -		    } -		    break; -		case HTML_BASE: -		    if (parsedtag_get_value(tag, ATTR_HREF, &p)) { -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); -			if (!buf->baseURL) -			    buf->baseURL = New(ParsedURL); -			parseURL(p, buf->baseURL, NULL); -		    } -		    if (parsedtag_get_value(tag, ATTR_TARGET, &p)) -			buf->baseTarget = -			    url_quote_conv(p, buf->document_charset); -		    break; -		case HTML_META: -		    p = q = NULL; -		    parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &p); -		    parsedtag_get_value(tag, ATTR_CONTENT, &q); -		    if (p && q && !strcasecmp(p, "refresh") && MetaRefresh) { -			Str tmp = NULL; -			int refresh_interval = getMetaRefreshParam(q, &tmp); -#ifdef USE_ALARM -			if (tmp) { -			    p = url_quote_conv(remove_space(tmp->ptr), -					       buf->document_charset); -			    buf->event = setAlarmEvent(buf->event, -						       refresh_interval, -						       AL_IMPLICIT_ONCE, -						       FUNCNAME_gorURL, p); -			} -			else if (refresh_interval > 0) -			    buf->event = setAlarmEvent(buf->event, -						       refresh_interval, -						       AL_IMPLICIT, -						       FUNCNAME_reload, NULL); -#else -			if (tmp && refresh_interval == 0) { -			    p = url_quote_conv(remove_space(tmp->ptr), -					       buf->document_charset); -			    pushEvent(FUNCNAME_gorURL, p); -			} -#endif -		    } -		    break; -		case HTML_INTERNAL: -		    internal = HTML_INTERNAL; -		    break; -		case HTML_N_INTERNAL: -		    internal = HTML_N_INTERNAL; -		    break; -		case HTML_FORM_INT: -		    if (parsedtag_get_value(tag, ATTR_FID, &form_id)) -			process_form_int(tag, form_id); -		    break; -		case HTML_TEXTAREA_INT: -		    if (parsedtag_get_value(tag, ATTR_TEXTAREANUMBER, -					    &n_textarea) -			&& n_textarea < max_textarea) { -			textarea_str[n_textarea] = Strnew(); -		    } -		    else -			n_textarea = -1; -		    break; -		case HTML_N_TEXTAREA_INT: -		    if (n_textarea >= 0) { -			FormItemList *item = -			    (FormItemList *)a_textarea[n_textarea]->url; -			item->init_value = item->value = -			    textarea_str[n_textarea]; -		    } -		    break; -#ifdef MENU_SELECT -		case HTML_SELECT_INT: -		    if (parsedtag_get_value(tag, ATTR_SELECTNUMBER, &n_select) -			&& n_select < max_select) { -			select_option[n_select].first = NULL; -			select_option[n_select].last = NULL; -		    } -		    else -			n_select = -1; -		    break; -		case HTML_N_SELECT_INT: -		    if (n_select >= 0) { -			FormItemList *item = -			    (FormItemList *)a_select[n_select]->url; -			item->select_option = select_option[n_select].first; -			chooseSelectOption(item, item->select_option); -			item->init_selected = item->selected; -			item->init_value = item->value; -			item->init_label = item->label; -		    } -		    break; -		case HTML_OPTION_INT: -		    if (n_select >= 0) { -			int selected; -			q = ""; -			parsedtag_get_value(tag, ATTR_LABEL, &q); -			p = q; -			parsedtag_get_value(tag, ATTR_VALUE, &p); -			selected = parsedtag_exists(tag, ATTR_SELECTED); -			addSelectOption(&select_option[n_select], -					Strnew_charp(p), Strnew_charp(q), -					selected); -		    } -		    break; -#endif -		case HTML_TITLE_ALT: -		    if (parsedtag_get_value(tag, ATTR_TITLE, &p)) -			buf->buffername = html_unquote(p); -		    break; -		case HTML_SYMBOL: -		    effect |= PC_SYMBOL; -		    if (parsedtag_get_value(tag, ATTR_TYPE, &p)) -			symbol = (char)atoi(p); -		    break; -		case HTML_N_SYMBOL: -		    effect &= ~PC_SYMBOL; -		    break; -		} -#ifdef	ID_EXT -		id = NULL; -		if (parsedtag_get_value(tag, ATTR_ID, &id)) { -		    id = url_quote_conv(id, buf->document_charset); -		    registerName(buf, id, currentLn(buf), pos); -		} -		if (renderFrameSet && -		    parsedtag_get_value(tag, ATTR_FRAMENAME, &p)) { -		    p = url_quote_conv(p, buf->document_charset); -		    if (!idFrame || strcmp(idFrame->body->name, p)) { -			idFrame = search_frame(renderFrameSet, p); -			if (idFrame && idFrame->body->attr != F_BODY) -			    idFrame = NULL; -		    } -		} -		if (id && idFrame) -		    idFrame->body->nameList = -			putAnchor(idFrame->body->nameList, id, NULL, -				  (Anchor **)NULL, NULL, NULL, '\0', -				  currentLn(buf), pos); -#endif				/* ID_EXT */ -	    } -	} -	/* end of processing for one line */ -	if (!internal) -	    addnewline(buf, outc, outp, NULL, pos, -1, nlines); -	if (internal == HTML_N_INTERNAL) -	    internal = 0; -	if (str != endp) { -	    line = Strsubstr(line, str - line->ptr, endp - str); -	    goto proc_again; -	} -    } -#ifdef DEBUG -    if (w3m_debug) -	fclose(debug); -#endif -    for (form_id = 1; form_id <= form_max; form_id++) -	forms[form_id]->next = forms[form_id - 1]; -    buf->formlist = (form_max >= 0) ? forms[form_max] : NULL; -    if (n_textarea) -	addMultirowsForm(buf, buf->formitem); -#ifdef USE_IMAGE -    addMultirowsImg(buf, buf->img); -#endif -} - -static void -addLink(Buffer *buf, struct parsed_tag *tag) -{ -    char *href = NULL, *title = NULL, *ctype = NULL, *rel = NULL, *rev = NULL; -    char type = LINK_TYPE_NONE; -    LinkList *l; - -    parsedtag_get_value(tag, ATTR_HREF, &href); -    if (href) -	href = url_quote_conv(remove_space(href), buf->document_charset); -    parsedtag_get_value(tag, ATTR_TITLE, &title); -    parsedtag_get_value(tag, ATTR_TYPE, &ctype); -    parsedtag_get_value(tag, ATTR_REL, &rel); -    if (rel != NULL) { -	/* forward link type */ -	type = LINK_TYPE_REL; -	if (title == NULL) -	    title = rel; -    } -    parsedtag_get_value(tag, ATTR_REV, &rev); -    if (rev != NULL) { -	/* reverse link type */ -	type = LINK_TYPE_REV; -	if (title == NULL) -	    title = rev; -    } - -    l = New(LinkList); -    l->url = href; -    l->title = title; -    l->ctype = ctype; -    l->type = type; -    l->next = NULL; -    if (buf->linklist) { -	LinkList *i; -	for (i = buf->linklist; i->next; i = i->next) ; -	i->next = l; -    } -    else -	buf->linklist = l; -} - -void -HTMLlineproc2(Buffer *buf, TextLineList *tl) -{ -    _tl_lp2 = tl->first; -    HTMLlineproc2body(buf, textlist_feed, -1); -} - -static InputStream _file_lp2; - -static Str -file_feed() -{ -    Str s; -    s = StrISgets(_file_lp2); -    if (s->length == 0) { -	ISclose(_file_lp2); -	return NULL; -    } -    return s; -} - -void -HTMLlineproc3(Buffer *buf, InputStream stream) -{ -    _file_lp2 = stream; -    HTMLlineproc2body(buf, file_feed, -1); -} - -static void -proc_escape(struct readbuffer *obuf, char **str_return) -{ -    char *str = *str_return, *estr; -    int ech = getescapechar(str_return); -    int width, n_add = *str_return - str; -    Lineprop mode = PC_ASCII; - -    if (ech < 0) { -	*str_return = str; -	proc_mchar(obuf, obuf->flag & RB_SPECIAL, 1, str_return, PC_ASCII); -	return; -    } -    mode = IS_CNTRL(ech) ? PC_CTRL : PC_ASCII; - -    estr = conv_entity(ech); -    check_breakpoint(obuf, obuf->flag & RB_SPECIAL, estr); -    width = get_strwidth(estr); -    if (width == 1 && ech == (unsigned char)*estr && -	ech != '&' && ech != '<' && ech != '>') { -	if (IS_CNTRL(ech)) -	    mode = PC_CTRL; -	push_charp(obuf, width, estr, mode); -    } -    else -	push_nchars(obuf, width, str, n_add, mode); -    set_prevchar(obuf->prevchar, estr, strlen(estr)); -    obuf->prev_ctype = mode; -} - - -static int -need_flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, -	       Lineprop mode) -{ -    char ch; - -    if (obuf->flag & RB_PRE_INT) { -	if (obuf->pos > h_env->limit) -	    return 1; -	else -	    return 0; -    } - -    ch = Strlastchar(obuf->line); -    /* if (ch == ' ' && obuf->tag_sp > 0) */ -    if (ch == ' ') -	return 0; - -    if (obuf->pos > h_env->limit) -	return 1; - -    return 0; -} - -static int -table_width(struct html_feed_environ *h_env, int table_level) -{ -    int width; -    if (table_level < 0) -	return 0; -    width = tables[table_level]->total_width; -    if (table_level > 0 || width > 0) -	return width; -    return h_env->limit - h_env->envs[h_env->envc].indent; -} - -/* HTML processing first pass */ -void -HTMLlineproc0(char *line, struct html_feed_environ *h_env, int internal) -{ -    Lineprop mode; -    int cmd; -    struct readbuffer *obuf = h_env->obuf; -    int indent, delta; -    struct parsed_tag *tag; -    Str tokbuf; -    struct table *tbl = NULL; -    struct table_mode *tbl_mode = NULL; -    int tbl_width = 0; -#ifdef USE_M17N -    int is_hangul, prev_is_hangul = 0; -#endif - -#ifdef DEBUG -    if (w3m_debug) { -	FILE *f = fopen("zzzproc1", "a"); -	fprintf(f, "%c%c%c%c", -		(obuf->flag & RB_PREMODE) ? 'P' : ' ', -		(obuf->table_level >= 0) ? 'T' : ' ', -		(obuf->flag & RB_INTXTA) ? 'X' : ' ', -		(obuf->flag & (RB_SCRIPT | RB_STYLE)) ? 'S' : ' '); -	fprintf(f, "HTMLlineproc1(\"%s\",%d,%lx)\n", line, h_env->limit, -		(unsigned long)h_env); -	fclose(f); -    } -#endif - -    tokbuf = Strnew(); - -  table_start: -    if (obuf->table_level >= 0) { -	int level = min(obuf->table_level, MAX_TABLE - 1); -	tbl = tables[level]; -	tbl_mode = &table_mode[level]; -	tbl_width = table_width(h_env, level); -    } - -    while (*line != '\0') { -	char *str, *p; -	int is_tag = FALSE; -	int pre_mode = (obuf->table_level >= 0) ? tbl_mode->pre_mode : -	    obuf->flag; -	int end_tag = (obuf->table_level >= 0) ? tbl_mode->end_tag : -	    obuf->end_tag; - -	if (*line == '<' || obuf->status != R_ST_NORMAL) { -	    /*  -	     * Tag processing -	     */ -	    if (obuf->status == R_ST_EOL) -		obuf->status = R_ST_NORMAL; -	    else { -		read_token(h_env->tagbuf, &line, &obuf->status, -			   pre_mode & RB_PREMODE, obuf->status != R_ST_NORMAL); -		if (obuf->status != R_ST_NORMAL) -		    return; -	    } -	    if (h_env->tagbuf->length == 0) -		continue; -	    str = h_env->tagbuf->ptr; -	    if (*str == '<') { -		if (str[1] && REALLY_THE_BEGINNING_OF_A_TAG(str)) -		    is_tag = TRUE; -		else if (!(pre_mode & (RB_PLAIN | RB_INTXTA | RB_INSELECT | -				       RB_SCRIPT | RB_STYLE | RB_TITLE))) { -		    line = Strnew_m_charp(str + 1, line, NULL)->ptr; -		    str = "<"; -		} -	    } -	} -	else { -	    read_token(tokbuf, &line, &obuf->status, pre_mode & RB_PREMODE, 0); -	    if (obuf->status != R_ST_NORMAL)	/* R_ST_AMP ? */ -		obuf->status = R_ST_NORMAL; -	    str = tokbuf->ptr; -	} - -	if (pre_mode & (RB_PLAIN | RB_INTXTA | RB_INSELECT | RB_SCRIPT | -			RB_STYLE | RB_TITLE)) { -	    if (is_tag) { -		p = str; -		if ((tag = parse_tag(&p, internal))) { -		    if (tag->tagid == end_tag || -			(pre_mode & RB_INSELECT && tag->tagid == HTML_N_FORM) -			|| (pre_mode & RB_TITLE -			    && (tag->tagid == HTML_N_HEAD -				|| tag->tagid == HTML_BODY))) -			goto proc_normal; -		} -	    } -	    /* title */ -	    if (pre_mode & RB_TITLE) { -		feed_title(str); -		continue; -	    } -	    /* select */ -	    if (pre_mode & RB_INSELECT) { -		if (obuf->table_level >= 0) -		    goto proc_normal; -		feed_select(str); -		continue; -	    } -	    if (is_tag) { -		if (strncmp(str, "<!--", 4) && (p = strchr(str + 1, '<'))) { -		    str = Strnew_charp_n(str, p - str)->ptr; -		    line = Strnew_m_charp(p, line, NULL)->ptr; -		} -		is_tag = FALSE; -	    } -	    if (obuf->table_level >= 0) -		goto proc_normal; -	    /* textarea */ -	    if (pre_mode & RB_INTXTA) { -		feed_textarea(str); -		continue; -	    } -	    /* script */ -	    if (pre_mode & RB_SCRIPT) -		continue; -	    /* style */ -	    if (pre_mode & RB_STYLE) -		continue; -	} - -      proc_normal: -	if (obuf->table_level >= 0) { -	    /*  -	     * within table: in <table>..</table>, all input tokens -	     * are fed to the table renderer, and then the renderer -	     * makes HTML output. -	     */ -	    switch (feed_table(tbl, str, tbl_mode, tbl_width, internal)) { -	    case 0: -		/* </table> tag */ -		obuf->table_level--; -		if (obuf->table_level >= MAX_TABLE - 1) -		    continue; -		end_table(tbl); -		if (obuf->table_level >= 0) { -		    struct table *tbl0 = tables[obuf->table_level]; -		    str = Sprintf("<table_alt tid=%d>", tbl0->ntable)->ptr; -		    pushTable(tbl0, tbl); -		    tbl = tbl0; -		    tbl_mode = &table_mode[obuf->table_level]; -		    tbl_width = table_width(h_env, obuf->table_level); -		    feed_table(tbl, str, tbl_mode, tbl_width, TRUE); -		    continue; -		    /* continue to the next */ -		} -		if (obuf->flag & RB_DEL) -		    continue; -		/* all tables have been read */ -		if (tbl->vspace > 0 && !(obuf->flag & RB_IGNORE_P)) { -		    int indent = h_env->envs[h_env->envc].indent; -		    flushline(h_env, obuf, indent, 0, h_env->limit); -		    do_blankline(h_env, obuf, indent, 0, h_env->limit); -		} -		save_fonteffect(h_env, obuf); -		renderTable(tbl, tbl_width, h_env); -		restore_fonteffect(h_env, obuf); -		obuf->flag &= ~RB_IGNORE_P; -		if (tbl->vspace > 0) { -		    int indent = h_env->envs[h_env->envc].indent; -		    do_blankline(h_env, obuf, indent, 0, h_env->limit); -		    obuf->flag |= RB_IGNORE_P; -		} -		set_space_to_prevchar(obuf->prevchar); -		continue; -	    case 1: -		/* <table> tag */ -		break; -	    default: -		continue; -	    } -	} - -	if (is_tag) { -/*** Beginning of a new tag ***/ -	    if ((tag = parse_tag(&str, internal))) -		cmd = tag->tagid; -	    else -		continue; -	    /* process tags */ -	    if (HTMLtagproc1(tag, h_env) == 0) { -		/* preserve the tag for second-stage processing */ -		if (parsedtag_need_reconstruct(tag)) -		    h_env->tagbuf = parsedtag2str(tag); -		push_tag(obuf, h_env->tagbuf->ptr, cmd); -	    } -#ifdef ID_EXT -	    else { -		process_idattr(obuf, cmd, tag); -	    } -#endif				/* ID_EXT */ -	    obuf->bp.init_flag = 1; -	    clear_ignore_p_flag(cmd, obuf); -	    if (cmd == HTML_TABLE) -		goto table_start; -	    else -		continue; -	} - -	if (obuf->flag & (RB_DEL | RB_S)) -	    continue; -	while (*str) { -	    mode = get_mctype(str); -	    delta = get_mcwidth(str); -	    if (obuf->flag & (RB_SPECIAL & ~RB_NOBR)) { -		char ch = *str; -		if (!(obuf->flag & RB_PLAIN) && (*str == '&')) { -		    char *p = str; -		    int ech = getescapechar(&p); -		    if (ech == '\n' || ech == '\r') { -			ch = '\n'; -			str = p - 1; -		    } -		    else if (ech == '\t') { -			ch = '\t'; -			str = p - 1; -		    } -		} -		if (ch != '\n') -		    obuf->flag &= ~RB_IGNORE_P; -		if (ch == '\n') { -		    str++; -		    if (obuf->flag & RB_IGNORE_P) { -			obuf->flag &= ~RB_IGNORE_P; -			continue; -		    } -		    if (obuf->flag & RB_PRE_INT) -			PUSH(' '); -		    else -			flushline(h_env, obuf, h_env->envs[h_env->envc].indent, -				  1, h_env->limit); -		} -		else if (ch == '\t') { -		    do { -			PUSH(' '); -		    } while ((h_env->envs[h_env->envc].indent + obuf->pos) -			     % Tabstop != 0); -		    str++; -		} -		else if (obuf->flag & RB_PLAIN) { -		    char *p = html_quote_char(*str); -		    if (p) { -			push_charp(obuf, 1, p, PC_ASCII); -			str++; -		    } -		    else { -			proc_mchar(obuf, 1, delta, &str, mode); -		    } -		} -		else { -		    if (*str == '&') -			proc_escape(obuf, &str); -		    else -			proc_mchar(obuf, 1, delta, &str, mode); -		} -		if (obuf->flag & (RB_SPECIAL & ~RB_PRE_INT)) -		    continue; -	    } -	    else { -		if (!IS_SPACE(*str)) -		    obuf->flag &= ~RB_IGNORE_P; -		if ((mode == PC_ASCII || mode == PC_CTRL) && IS_SPACE(*str)) { -		    if (*obuf->prevchar->ptr != ' ') { -			PUSH(' '); -		    } -		    str++; -		} -		else { -#ifdef USE_M17N -		    if (mode == PC_KANJI1) -			is_hangul = wtf_is_hangul((wc_uchar *) str); -		    else -			is_hangul = 0; -		    if (mode == PC_KANJI1 && -			!is_hangul && !prev_is_hangul && -			obuf->pos > h_env->envs[h_env->envc].indent && -			Strlastchar(obuf->line) == ' ') { -			while (obuf->line->length >= 2 && -			       !strncmp(obuf->line->ptr + obuf->line->length - -					2, "  ", 2) -			       && obuf->pos >= h_env->envs[h_env->envc].indent) { -			    Strshrink(obuf->line, 1); -			    obuf->pos--; -			} -			if (obuf->line->length >= 3 && -			    obuf->prev_ctype == PC_KANJI1 && -			    Strlastchar(obuf->line) == ' ' && -			    obuf->pos >= h_env->envs[h_env->envc].indent) { -			    Strshrink(obuf->line, 1); -			    obuf->pos--; -			} -		    } -		    prev_is_hangul = is_hangul; -#endif -		    if (*str == '&') -			proc_escape(obuf, &str); -		    else -			proc_mchar(obuf, obuf->flag & RB_SPECIAL, delta, &str, -				   mode); -		} -	    } -	    if (need_flushline(h_env, obuf, mode)) { -		char *bp = obuf->line->ptr + obuf->bp.len; -		char *tp = bp - obuf->bp.tlen; -		int i = 0; - -		if (tp > obuf->line->ptr && tp[-1] == ' ') -		    i = 1; - -		indent = h_env->envs[h_env->envc].indent; -		if (obuf->bp.pos - i > indent) { -		    Str line; -		    append_tags(obuf); -		    line = Strnew_charp(bp); -		    Strshrink(obuf->line, obuf->line->length - obuf->bp.len); -#ifdef FORMAT_NICE -		    if (obuf->pos - i > h_env->limit) -			obuf->flag |= RB_FILL; -#endif				/* FORMAT_NICE */ -		    back_to_breakpoint(obuf); -		    flushline(h_env, obuf, indent, 0, h_env->limit); -#ifdef FORMAT_NICE -		    obuf->flag &= ~RB_FILL; -#endif				/* FORMAT_NICE */ -		    HTMLlineproc1(line->ptr, h_env); -		} -	    } -	} -    } -    if (!(obuf->flag & (RB_SPECIAL | RB_INTXTA | RB_INSELECT))) { -	char *tp; -	int i = 0; - -	if (obuf->bp.pos == obuf->pos) { -	    tp = &obuf->line->ptr[obuf->bp.len - obuf->bp.tlen]; -	} -	else { -	    tp = &obuf->line->ptr[obuf->line->length]; -	} - -	if (tp > obuf->line->ptr && tp[-1] == ' ') -	    i = 1; -	indent = h_env->envs[h_env->envc].indent; -	if (obuf->pos - i > h_env->limit) { -#ifdef FORMAT_NICE -	    obuf->flag |= RB_FILL; -#endif				/* FORMAT_NICE */ -	    flushline(h_env, obuf, indent, 0, h_env->limit); -#ifdef FORMAT_NICE -	    obuf->flag &= ~RB_FILL; -#endif				/* FORMAT_NICE */ -	} -    } -} - -extern char *NullLine; -extern Lineprop NullProp[]; - -#ifndef USE_ANSI_COLOR -#define addnewline2(a,b,c,d,e,f) _addnewline2(a,b,c,e,f) -#endif -static void -addnewline2(Buffer *buf, char *line, Lineprop *prop, Linecolor *color, int pos, -	    int nlines) -{ -    Line *l; -    l = New(Line); -    l->next = NULL; -    l->lineBuf = line; -    l->propBuf = prop; -#ifdef USE_ANSI_COLOR -    l->colorBuf = color; -#endif -    l->len = pos; -    l->width = -1; -    l->size = pos; -    l->bpos = 0; -    l->bwidth = 0; -    l->prev = buf->currentLine; -    if (buf->currentLine) { -	l->next = buf->currentLine->next; -	buf->currentLine->next = l; -    } -    else -	l->next = NULL; -    if (buf->lastLine == NULL || buf->lastLine == buf->currentLine) -	buf->lastLine = l; -    buf->currentLine = l; -    if (buf->firstLine == NULL) -	buf->firstLine = l; -    l->linenumber = ++buf->allLine; -    if (nlines < 0) { -	/*     l->real_linenumber = l->linenumber;     */ -	l->real_linenumber = 0; -    } -    else { -	l->real_linenumber = nlines; -    } -    l = NULL; -} - -static void -addnewline(Buffer *buf, char *line, Lineprop *prop, Linecolor *color, int pos, -	   int width, int nlines) -{ -    char *s; -    Lineprop *p; -#ifdef USE_ANSI_COLOR -    Linecolor *c; -#endif -    Line *l; -    int i, bpos, bwidth; - -    if (pos > 0) { -	s = allocStr(line, pos); -	p = NewAtom_N(Lineprop, pos); -	bcopy((void *)prop, (void *)p, pos * sizeof(Lineprop)); -    } -    else { -	s = NullLine; -	p = NullProp; -    } -#ifdef USE_ANSI_COLOR -    if (pos > 0 && color) { -	c = NewAtom_N(Linecolor, pos); -	bcopy((void *)color, (void *)c, pos * sizeof(Linecolor)); -    } -    else { -	c = NULL; -    } -#endif -    addnewline2(buf, s, p, c, pos, nlines); -    if (pos <= 0 || width <= 0) -	return; -    bpos = 0; -    bwidth = 0; -    while (1) { -	l = buf->currentLine; -	l->bpos = bpos; -	l->bwidth = bwidth; -	i = columnLen(l, width); -	if (i == 0) { -	    i++; -#ifdef USE_M17N -	    while (i < l->len && p[i] & PC_WCHAR2) -		i++; -#endif -	} -	l->len = i; -	l->width = COLPOS(l, l->len); -	if (pos <= i) -	    return; -	bpos += l->len; -	bwidth += l->width; -	s += i; -	p += i; -#ifdef USE_ANSI_COLOR -	if (c) -	    c += i; -#endif -	pos -= i; -	addnewline2(buf, s, p, c, pos, nlines); -    } -} - -/*  - * loadHTMLBuffer: read file and make new buffer - */ -Buffer * -loadHTMLBuffer(URLFile *f, Buffer *newBuf) -{ -    FILE *src = NULL; -    Str tmp; - -    if (newBuf == NULL) -	newBuf = newBuffer(INIT_BUFFER_WIDTH); -    if (newBuf->sourcefile == NULL && -	(f->scheme != SCM_LOCAL || newBuf->mailcap)) { -	tmp = tmpfname(TMPF_SRC, ".html"); -	src = fopen(tmp->ptr, "w"); -	if (src) -	    newBuf->sourcefile = tmp->ptr; -    } - -    loadHTMLstream(f, newBuf, src, newBuf->bufferprop & BP_FRAME); - -    newBuf->topLine = newBuf->firstLine; -    newBuf->lastLine = newBuf->currentLine; -    newBuf->currentLine = newBuf->firstLine; -    if (n_textarea) -	formResetBuffer(newBuf, newBuf->formitem); -    if (src) -	fclose(src); - -    return newBuf; -} - -static char *_size_unit[] = { "b", "kb", "Mb", "Gb", "Tb", -    "Pb", "Eb", "Zb", "Bb", "Yb", NULL -}; - -char * -convert_size(clen_t size, int usefloat) -{ -    float csize; -    int sizepos = 0; -    char **sizes = _size_unit; - -    csize = (float)size; -    while (csize >= 999.495 && sizes[sizepos + 1]) { -	csize = csize / 1024.0; -	sizepos++; -    } -    return Sprintf(usefloat ? "%.3g%s" : "%.0f%s", -		   floor(csize * 100.0 + 0.5) / 100.0, sizes[sizepos])->ptr; -} - -char * -convert_size2(clen_t size1, clen_t size2, int usefloat) -{ -    char **sizes = _size_unit; -    float csize, factor = 1; -    int sizepos = 0; - -    csize = (float)((size1 > size2) ? size1 : size2); -    while (csize / factor >= 999.495 && sizes[sizepos + 1]) { -	factor *= 1024.0; -	sizepos++; -    } -    return Sprintf(usefloat ? "%.3g/%.3g%s" : "%.0f/%.0f%s", -		   floor(size1 / factor * 100.0 + 0.5) / 100.0, -		   floor(size2 / factor * 100.0 + 0.5) / 100.0, -		   sizes[sizepos])->ptr; -} - -void -showProgress(clen_t * linelen, clen_t * trbyte) -{ -    int i, j, rate, duration, eta, pos; -    static time_t last_time, start_time; -    time_t cur_time; -    Str messages; -    char *fmtrbyte, *fmrate; - -    if (!fmInitialized) -	return; - -    if (*linelen < 1024) -	return; -    if (current_content_length > 0) { -	double ratio; -	cur_time = time(0); -	if (*trbyte == 0) { -	    move(LASTLINE, 0); -	    clrtoeolx(); -	    start_time = cur_time; -	} -	*trbyte += *linelen; -	*linelen = 0; -	if (cur_time == last_time) -	    return; -	last_time = cur_time; -	move(LASTLINE, 0); -	ratio = 100.0 * (*trbyte) / current_content_length; -	fmtrbyte = convert_size2(*trbyte, current_content_length, 1); -	duration = cur_time - start_time; -	if (duration) { -	    rate = *trbyte / duration; -	    fmrate = convert_size(rate, 1); -	    eta = rate ? (current_content_length - *trbyte) / rate : -1; -	    messages = Sprintf("%11s %3.0f%% " -			       "%7s/s " -			       "eta %02d:%02d:%02d     ", -			       fmtrbyte, ratio, -			       fmrate, -			       eta / (60 * 60), (eta / 60) % 60, eta % 60); -	} -	else { -	    messages = Sprintf("%11s %3.0f%%                          ", -			       fmtrbyte, ratio); -	} -	addstr(messages->ptr); -	pos = 42; -	i = pos + (COLS - pos - 1) * (*trbyte) / current_content_length; -	move(LASTLINE, pos); -	standout(); -	addch(' '); -	for (j = pos + 1; j <= i; j++) -	    addch('|'); -	standend(); -	/* no_clrtoeol(); */ -	refresh(); -    } -    else { -	cur_time = time(0); -	if (*trbyte == 0) { -	    move(LASTLINE, 0); -	    clrtoeolx(); -	    start_time = cur_time; -	} -	*trbyte += *linelen; -	*linelen = 0; -	if (cur_time == last_time) -	    return; -	last_time = cur_time; -	move(LASTLINE, 0); -	fmtrbyte = convert_size(*trbyte, 1); -	duration = cur_time - start_time; -	if (duration) { -	    fmrate = convert_size(*trbyte / duration, 1); -	    messages = Sprintf("%7s loaded %7s/s", fmtrbyte, fmrate); -	} -	else { -	    messages = Sprintf("%7s loaded", fmtrbyte); -	} -	message(messages->ptr, 0, 0); -	refresh(); -    } -} - -void -init_henv(struct html_feed_environ *h_env, struct readbuffer *obuf, -	  struct environment *envs, int nenv, TextLineList *buf, -	  int limit, int indent) -{ -    envs[0].indent = indent; - -    obuf->line = Strnew(); -    obuf->cprop = 0; -    obuf->pos = 0; -    obuf->prevchar = Strnew_size(8); -    set_space_to_prevchar(obuf->prevchar); -    obuf->flag = RB_IGNORE_P; -    obuf->flag_sp = 0; -    obuf->status = R_ST_NORMAL; -    obuf->table_level = -1; -    obuf->nobr_level = 0; -    bzero((void *)&obuf->anchor, sizeof(obuf->anchor)); -    obuf->img_alt = 0; -    obuf->in_bold = 0; -    obuf->in_under = 0; -    obuf->prev_ctype = PC_ASCII; -    obuf->tag_sp = 0; -    obuf->fontstat_sp = 0; -    obuf->top_margin = 0; -    obuf->bottom_margin = 0; -    obuf->bp.init_flag = 1; -    set_breakpoint(obuf, 0); - -    h_env->buf = buf; -    h_env->f = NULL; -    h_env->obuf = obuf; -    h_env->tagbuf = Strnew(); -    h_env->limit = limit; -    h_env->maxlimit = 0; -    h_env->envs = envs; -    h_env->nenv = nenv; -    h_env->envc = 0; -    h_env->envc_real = 0; -    h_env->title = NULL; -    h_env->blank_lines = 0; -} - -void -completeHTMLstream(struct html_feed_environ *h_env, struct readbuffer *obuf) -{ -    close_anchor(h_env, obuf); -    if (obuf->img_alt) { -	push_tag(obuf, "</img_alt>", HTML_N_IMG_ALT); -	obuf->img_alt = NULL; -    } -    if (obuf->in_bold) { -	push_tag(obuf, "</b>", HTML_N_B); -	obuf->in_bold = 0; -    } -    if (obuf->in_under) { -	push_tag(obuf, "</u>", HTML_N_U); -	obuf->in_under = 0; -    } -    if (obuf->flag & RB_INTXTA) -	HTMLlineproc1("</textarea>", h_env); -    /* for unbalanced select tag */ -    if (obuf->flag & RB_INSELECT) -	HTMLlineproc1("</select>", h_env); -    if (obuf->flag & RB_TITLE) -	HTMLlineproc1("</title>", h_env); - -    /* for unbalanced table tag */ -    if (obuf->table_level >= MAX_TABLE) -	obuf->table_level = MAX_TABLE - 1; - -    while (obuf->table_level >= 0) { -	table_mode[obuf->table_level].pre_mode -	    &= ~(TBLM_SCRIPT | TBLM_STYLE | TBLM_PLAIN); -	HTMLlineproc1("</table>", h_env); -    } -} - -static void -print_internal_information(struct html_feed_environ *henv) -{ -    int i; -    Str s; -    TextLineList *tl = newTextLineList(); - -    s = Strnew_charp("<internal>"); -    pushTextLine(tl, newTextLine(s, 0)); -    if (henv->title) { -	s = Strnew_m_charp("<title_alt title=\"", -			   html_quote(henv->title), "\">", NULL); -	pushTextLine(tl, newTextLine(s, 0)); -    } -#if 0 -    if (form_max >= 0) { -	FormList *fp; -	for (i = 0; i <= form_max; i++) { -	    fp = forms[i]; -	    s = Sprintf("<form_int fid=\"%d\" action=\"%s\" method=\"%s\"", -			i, html_quote(fp->action->ptr), -			(fp->method == FORM_METHOD_POST) ? "post" -			: ((fp->method == -			    FORM_METHOD_INTERNAL) ? "internal" : "get")); -	    if (fp->target) -		Strcat(s, Sprintf(" target=\"%s\"", html_quote(fp->target))); -	    if (fp->enctype == FORM_ENCTYPE_MULTIPART) -		Strcat_charp(s, " enctype=\"multipart/form-data\""); -#ifdef USE_M17N -	    if (fp->charset) -		Strcat(s, Sprintf(" accept-charset=\"%s\"", -				  html_quote(fp->charset))); -#endif -	    Strcat_charp(s, ">"); -	    pushTextLine(tl, newTextLine(s, 0)); -	} -    } -#endif -#ifdef MENU_SELECT -    if (n_select > 0) { -	FormSelectOptionItem *ip; -	for (i = 0; i < n_select; i++) { -	    s = Sprintf("<select_int selectnumber=%d>", i); -	    pushTextLine(tl, newTextLine(s, 0)); -	    for (ip = select_option[i].first; ip; ip = ip->next) { -		s = Sprintf("<option_int value=\"%s\" label=\"%s\"%s>", -			    html_quote(ip->value ? ip->value->ptr : -				       ip->label->ptr), -			    html_quote(ip->label->ptr), -			    ip->checked ? " selected" : ""); -		pushTextLine(tl, newTextLine(s, 0)); -	    } -	    s = Strnew_charp("</select_int>"); -	    pushTextLine(tl, newTextLine(s, 0)); -	} -    } -#endif				/* MENU_SELECT */ -    if (n_textarea > 0) { -	for (i = 0; i < n_textarea; i++) { -	    s = Sprintf("<textarea_int textareanumber=%d>", i); -	    pushTextLine(tl, newTextLine(s, 0)); -	    s = Strnew_charp(html_quote(textarea_str[i]->ptr)); -	    Strcat_charp(s, "</textarea_int>"); -	    pushTextLine(tl, newTextLine(s, 0)); -	} -    } -    s = Strnew_charp("</internal>"); -    pushTextLine(tl, newTextLine(s, 0)); - -    if (henv->buf) -	appendTextLineList(henv->buf, tl); -    else if (henv->f) { -	TextLineListItem *p; -	for (p = tl->first; p; p = p->next) -	    fprintf(henv->f, "%s\n", Str_conv_to_halfdump(p->ptr->line)->ptr); -    } -} - -void -loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) -{ -    struct environment envs[MAX_ENV_LEVEL]; -    clen_t linelen = 0; -    clen_t trbyte = 0; -    Str lineBuf2 = Strnew(); -#ifdef USE_M17N -    wc_ces charset = WC_CES_US_ASCII; -    wc_ces volatile doc_charset = DocumentCharset; -#endif -    struct html_feed_environ htmlenv1; -    struct readbuffer obuf; -#ifdef USE_IMAGE -    int volatile image_flag; -#endif -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; - -#ifdef USE_M17N -    if (fmInitialized && graph_ok()) { -	symbol_width = symbol_width0 = 1; -    } -    else { -	symbol_width0 = 0; -	get_symbol(DisplayCharset, &symbol_width0); -	symbol_width = WcOption.use_wide ? symbol_width0 : 1; -    } -#else -    symbol_width = symbol_width0 = 1; -#endif - -    cur_title = NULL; -    n_textarea = 0; -    cur_textarea = NULL; -    max_textarea = MAX_TEXTAREA; -    textarea_str = New_N(Str, max_textarea); -#ifdef MENU_SELECT -    n_select = 0; -    max_select = MAX_SELECT; -    select_option = New_N(FormSelectOption, max_select); -#endif				/* MENU_SELECT */ -    cur_select = NULL; -    form_sp = -1; -    form_max = -1; -    forms_size = 0; -    forms = NULL; -    cur_hseq = 1; -#ifdef USE_IMAGE -    cur_iseq = 1; -    if (newBuf->image_flag) -	image_flag = newBuf->image_flag; -    else if (activeImage && displayImage && autoImage) -	image_flag = IMG_FLAG_AUTO; -    else -	image_flag = IMG_FLAG_SKIP; -    if (newBuf->currentURL.file) -	cur_baseURL = baseURL(newBuf); -#endif - -    if (w3m_halfload) { -	newBuf->buffername = "---"; -#ifdef USE_M17N -	newBuf->document_charset = InnerCharset; -#endif -	max_textarea = 0; -#ifdef MENU_SELECT -	max_select = 0; -#endif -	HTMLlineproc3(newBuf, f->stream); -	w3m_halfload = FALSE; -	return; -    } - -    init_henv(&htmlenv1, &obuf, envs, MAX_ENV_LEVEL, NULL, newBuf->width, 0); - -    if (w3m_halfdump) -	htmlenv1.f = stdout; -    else -	htmlenv1.buf = newTextLineList(); - -    if (SETJMP(AbortLoading) != 0) { -	HTMLlineproc1("<br>Transfer Interrupted!<br>", &htmlenv1); -	goto phase2; -    } -    TRAP_ON; - -#ifdef USE_M17N -    if (newBuf != NULL) { -	if (newBuf->bufferprop & BP_FRAME) -	    charset = InnerCharset; -	else if (newBuf->document_charset) -	    charset = doc_charset = newBuf->document_charset; -    } -    if (content_charset && UseContentCharset) -	doc_charset = content_charset; -    meta_charset = 0; -#endif -#if	0 -    do_blankline(&htmlenv1, &obuf, 0, 0, htmlenv1.limit); -    obuf.flag = RB_IGNORE_P; -#endif -    if (IStype(f->stream) != IST_ENCODED) -	f->stream = newEncodedStream(f->stream, f->encoding); -    while ((lineBuf2 = StrmyUFgets(f))->length) { -#ifdef USE_NNTP -	if (f->scheme == SCM_NEWS && lineBuf2->ptr[0] == '.') { -	    Strshrinkfirst(lineBuf2, 1); -	    if (lineBuf2->ptr[0] == '\n' || lineBuf2->ptr[0] == '\r' || -		lineBuf2->ptr[0] == '\0') { -		/* -		 * iseos(f->stream) = TRUE; -		 */ -		break; -	    } -	} -#endif				/* USE_NNTP */ -	if (src) -	    Strfputs(lineBuf2, src); -	linelen += lineBuf2->length; -	if (w3m_dump & DUMP_EXTRA) -	    printf("W3m-in-progress: %s?n", convert_size2(linelen, current_content_length, TRUE)); -	if (w3m_dump & DUMP_SOURCE) -	    continue; -	showProgress(&linelen, &trbyte); -	/* -	 * if (frame_source) -	 * continue; -	 */ -#ifdef USE_M17N -	if (meta_charset) {	/* <META> */ -	    if (content_charset == 0 && UseContentCharset) { -		doc_charset = meta_charset; -		charset = WC_CES_US_ASCII; -	    } -	    meta_charset = 0; -	} -#endif -	lineBuf2 = convertLine(f, lineBuf2, HTML_MODE, &charset, doc_charset); -#if defined(USE_M17N) && defined(USE_IMAGE) -	cur_document_charset = charset; -#endif -	HTMLlineproc0(lineBuf2->ptr, &htmlenv1, internal); -    } -    if (obuf.status != R_ST_NORMAL) { -	obuf.status = R_ST_EOL; -	HTMLlineproc0("\n", &htmlenv1, internal); -    } -    obuf.status = R_ST_NORMAL; -    completeHTMLstream(&htmlenv1, &obuf); -    flushline(&htmlenv1, &obuf, 0, 2, htmlenv1.limit); -    if (htmlenv1.title) -	newBuf->buffername = htmlenv1.title; -    if (w3m_halfdump) { -	TRAP_OFF; -	print_internal_information(&htmlenv1); -	return; -    } -    if (w3m_backend) { -	TRAP_OFF; -	print_internal_information(&htmlenv1); -	backend_halfdump_buf = htmlenv1.buf; -	return; -    } -  phase2: -    newBuf->trbyte = trbyte + linelen; -    TRAP_OFF; -#ifdef USE_M17N -    if (!(newBuf->bufferprop & BP_FRAME)) -	newBuf->document_charset = charset; -#endif -#ifdef USE_IMAGE -    newBuf->image_flag = image_flag; -#endif -    HTMLlineproc2(newBuf, htmlenv1.buf); -} - -/*  - * loadHTMLString: read string and make new buffer - */ -Buffer * -loadHTMLString(Str page) -{ -    URLFile f; -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; -    Buffer *newBuf; - -    newBuf = newBuffer(INIT_BUFFER_WIDTH); -    if (SETJMP(AbortLoading) != 0) { -	TRAP_OFF; -	discardBuffer(newBuf); -	return NULL; -    } -    TRAP_ON; - -    init_stream(&f, SCM_LOCAL, newStrStream(page)); - -#ifdef USE_M17N -    newBuf->document_charset = InnerCharset; -#endif -    loadHTMLstream(&f, newBuf, NULL, TRUE); -#ifdef USE_M17N -    newBuf->document_charset = WC_CES_US_ASCII; -#endif - -    TRAP_OFF; -    newBuf->topLine = newBuf->firstLine; -    newBuf->lastLine = newBuf->currentLine; -    newBuf->currentLine = newBuf->firstLine; -    newBuf->type = "text/html"; -    newBuf->real_type = newBuf->type; -    if (n_textarea) -	formResetBuffer(newBuf, newBuf->formitem); -    return newBuf; -} - -#ifdef USE_GOPHER - -/*  - * loadGopherDir: get gopher directory - */ -Str -loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset) -{ -    Str volatile tmp; -    Str lbuf, name, file, host, port; -    char *volatile p, *volatile q; -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; -#ifdef USE_M17N -    wc_ces doc_charset = DocumentCharset; -#endif - -    tmp = parsedURL2Str(pu); -    p = html_quote(tmp->ptr); -    tmp = -	convertLine(NULL, Strnew_charp(file_unquote(tmp->ptr)), RAW_MODE, -		    charset, doc_charset); -    q = html_quote(tmp->ptr); -    tmp = Strnew_m_charp("<html>\n<head>\n<base href=\"", p, "\">\n<title>", q, -			 "</title>\n</head>\n<body>\n<h1>Index of ", q, -			 "</h1>\n<table>\n", NULL); - -    if (SETJMP(AbortLoading) != 0) -	goto gopher_end; -    TRAP_ON; - -    while (1) { -	if (lbuf = StrUFgets(uf), lbuf->length == 0) -	    break; -	if (lbuf->ptr[0] == '.' && -	    (lbuf->ptr[1] == '\n' || lbuf->ptr[1] == '\r')) -	    break; -	lbuf = convertLine(uf, lbuf, HTML_MODE, charset, doc_charset); -	p = lbuf->ptr; -	for (q = p; *q && *q != '\t'; q++) ; -	name = Strnew_charp_n(p, q - p); -	if (!*q) -	    continue; -	p = q + 1; -	for (q = p; *q && *q != '\t'; q++) ; -	file = Strnew_charp_n(p, q - p); -	if (!*q) -	    continue; -	p = q + 1; -	for (q = p; *q && *q != '\t'; q++) ; -	host = Strnew_charp_n(p, q - p); -	if (!*q) -	    continue; -	p = q + 1; -	for (q = p; *q && *q != '\t' && *q != '\r' && *q != '\n'; q++) ; -	port = Strnew_charp_n(p, q - p); - -	switch (name->ptr[0]) { -	case '0': -	    p = "[text file]"; -	    break; -	case '1': -	    p = "[directory]"; -	    break; -	case 'm': -	    p = "[message]"; -	    break; -	case 's': -	    p = "[sound]"; -	    break; -	case 'g': -	    p = "[gif]"; -	    break; -	case 'h': -	    p = "[HTML]"; -	    break; -	default: -	    p = "[unsupported]"; -	    break; -	} -	q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr, -			   "/", file->ptr, NULL)->ptr; -	Strcat_m_charp(tmp, "<a href=\"", -		       html_quote(url_quote_conv(q, *charset)), -		       "\">", p, html_quote(name->ptr + 1), "</a>\n", NULL); -    } - -  gopher_end: -    TRAP_OFF; - -    Strcat_charp(tmp, "</table>\n</body>\n</html>\n"); -    return tmp; -} -#endif				/* USE_GOPHER */ - -/*  - * loadBuffer: read file and make new buffer - */ -Buffer * -loadBuffer(URLFile *uf, Buffer *volatile newBuf) -{ -    FILE *volatile src = NULL; -#ifdef USE_M17N -    wc_ces charset = WC_CES_US_ASCII; -    wc_ces volatile doc_charset = DocumentCharset; -#endif -    Str lineBuf2; -    volatile char pre_lbuf = '\0'; -    int nlines; -    Str tmpf; -    clen_t linelen = 0, trbyte = 0; -    Lineprop *propBuffer = NULL; -#ifdef USE_ANSI_COLOR -    Linecolor *colorBuffer = NULL; -#endif -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; - -    if (newBuf == NULL) -	newBuf = newBuffer(INIT_BUFFER_WIDTH); -    lineBuf2 = Strnew(); - -    if (SETJMP(AbortLoading) != 0) { -	goto _end; -    } -    TRAP_ON; - -    if (newBuf->sourcefile == NULL && -	(uf->scheme != SCM_LOCAL || newBuf->mailcap)) { -	tmpf = tmpfname(TMPF_SRC, NULL); -	src = fopen(tmpf->ptr, "w"); -	if (src) -	    newBuf->sourcefile = tmpf->ptr; -    } -#ifdef USE_M17N -    if (newBuf->document_charset) -	charset = doc_charset = newBuf->document_charset; -    if (content_charset && UseContentCharset) -	doc_charset = content_charset; -#endif - -    nlines = 0; -    if (IStype(uf->stream) != IST_ENCODED) -	uf->stream = newEncodedStream(uf->stream, uf->encoding); -    while ((lineBuf2 = StrmyISgets(uf->stream))->length) { -#ifdef USE_NNTP -	if (uf->scheme == SCM_NEWS && lineBuf2->ptr[0] == '.') { -	    Strshrinkfirst(lineBuf2, 1); -	    if (lineBuf2->ptr[0] == '\n' || lineBuf2->ptr[0] == '\r' || -		lineBuf2->ptr[0] == '\0') { -		/* -		 * iseos(uf->stream) = TRUE; -		 */ -		break; -	    } -	} -#endif				/* USE_NNTP */ -	if (src) -	    Strfputs(lineBuf2, src); -	linelen += lineBuf2->length; -	if (w3m_dump & DUMP_SOURCE) -	    continue; -	showProgress(&linelen, &trbyte); -	if (frame_source) -	    continue; -	lineBuf2 = -	    convertLine(uf, lineBuf2, PAGER_MODE, &charset, doc_charset); -	if (squeezeBlankLine) { -	    if (lineBuf2->ptr[0] == '\n' && pre_lbuf == '\n') { -		++nlines; -		continue; -	    } -	    pre_lbuf = lineBuf2->ptr[0]; -	} -	++nlines; -	Strchop(lineBuf2); -	lineBuf2 = checkType(lineBuf2, &propBuffer, NULL); -	addnewline(newBuf, lineBuf2->ptr, propBuffer, colorBuffer, -		   lineBuf2->length, FOLD_BUFFER_WIDTH, nlines); -    } -  _end: -    TRAP_OFF; -    newBuf->topLine = newBuf->firstLine; -    newBuf->lastLine = newBuf->currentLine; -    newBuf->currentLine = newBuf->firstLine; -    newBuf->trbyte = trbyte + linelen; -#ifdef USE_M17N -    newBuf->document_charset = charset; -#endif -    if (src) -	fclose(src); - -    return newBuf; -} - -#ifdef USE_IMAGE -Buffer * -loadImageBuffer(URLFile *uf, Buffer *newBuf) -{ -    Image image; -    ImageCache *cache; -    Str tmp, tmpf; -    FILE *src = NULL; -    URLFile f; -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; -    struct stat st; - -    loadImage(newBuf, IMG_FLAG_STOP); -    image.url = uf->url; -    image.ext = uf->ext; -    image.width = -1; -    image.height = -1; -    image.cache = NULL; -    cache = getImage(&image, cur_baseURL, IMG_FLAG_AUTO); -    if (!cur_baseURL->is_nocache && cache->loaded & IMG_FLAG_LOADED && -	!stat(cache->file, &st)) -	goto image_buffer; - -    TRAP_ON; -    if (IStype(uf->stream) != IST_ENCODED) -	uf->stream = newEncodedStream(uf->stream, uf->encoding); -    if (save2tmp(*uf, cache->file) < 0) { -	UFclose(uf); -	TRAP_OFF; -	return NULL; -    } -    UFclose(uf); -    TRAP_OFF; - -    cache->loaded = IMG_FLAG_LOADED; -    cache->index = 0; - -  image_buffer: -    if (newBuf == NULL) -	newBuf = newBuffer(INIT_BUFFER_WIDTH); -    cache->loaded |= IMG_FLAG_DONT_REMOVE; -    if (newBuf->sourcefile == NULL && uf->scheme != SCM_LOCAL) -	newBuf->sourcefile = cache->file; - -    tmp = Sprintf("<img src=\"%s\"><br><br>", html_quote(image.url)); -    tmpf = tmpfname(TMPF_SRC, ".html"); -    src = fopen(tmpf->ptr, "w"); -    newBuf->mailcap_source = tmpf->ptr; - -    init_stream(&f, SCM_LOCAL, newStrStream(tmp)); -    loadHTMLstream(&f, newBuf, src, TRUE); -    if (src) -	fclose(src); - -    newBuf->topLine = newBuf->firstLine; -    newBuf->lastLine = newBuf->currentLine; -    newBuf->currentLine = newBuf->firstLine; -    newBuf->image_flag = IMG_FLAG_AUTO; -    return newBuf; -} -#endif - -static Str -conv_symbol(Line *l) -{ -    Str tmp = NULL; -    char *p = l->lineBuf, *ep = p + l->len; -    Lineprop *pr = l->propBuf; -#ifdef USE_M17N -    int w; -    char **symbol = NULL; -#else -    char **symbol = get_symbol(); -#endif - -    for (; p < ep; p++, pr++) { -	if (*pr & PC_SYMBOL) { -#ifdef USE_M17N -	    char c = ((char)wtf_get_code((wc_uchar *) p) & 0x7f) - SYMBOL_BASE; -	    int len = get_mclen(p); -#else -	    char c = *p - SYMBOL_BASE; -#endif -	    if (tmp == NULL) { -		tmp = Strnew_size(l->len); -		Strcopy_charp_n(tmp, l->lineBuf, p - l->lineBuf); -#ifdef USE_M17N -		w = (*pr & PC_KANJI) ? 2 : 1; -		symbol = get_symbol(DisplayCharset, &w); -#endif -	    } -	    Strcat_charp(tmp, symbol[(int)c]); -#ifdef USE_M17N -	    p += len - 1; -	    pr += len - 1; -#endif -	} -	else if (tmp != NULL) -	    Strcat_char(tmp, *p); -    } -    if (tmp) -	return tmp; -    else -	return Strnew_charp_n(l->lineBuf, l->len); -} - -/*  - * saveBuffer: write buffer to file - */ -static void -_saveBuffer(Buffer *buf, Line *l, FILE * f, int cont) -{ -    Str tmp; -    int is_html = FALSE; -#ifdef USE_M17N -    int set_charset = !DisplayCharset; -    wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; -#endif - -    if (buf->type && !strcasecmp(buf->type, "text/html")) -	is_html = TRUE; - -  pager_next: -    for (; l != NULL; l = l->next) { -	if (is_html) -	    tmp = conv_symbol(l); -	else -	    tmp = Strnew_charp_n(l->lineBuf, l->len); -	tmp = wc_Str_conv(tmp, InnerCharset, charset); -	Strfputs(tmp, f); -	if (Strlastchar(tmp) != '\n' && !(cont && l->next && l->next->bpos)) -	    putc('\n', f); -    } -    if (buf->pagerSource && !(buf->bufferprop & BP_CLOSE)) { -	l = getNextPage(buf, PagerMax); -#ifdef USE_M17N -	if (set_charset) -	    charset = buf->document_charset; -#endif -	goto pager_next; -    } -} - -void -saveBuffer(Buffer *buf, FILE * f, int cont) -{ -    _saveBuffer(buf, buf->firstLine, f, cont); -} - -void -saveBufferBody(Buffer *buf, FILE * f, int cont) -{ -    Line *l = buf->firstLine; - -    while (l != NULL && l->real_linenumber == 0) -	l = l->next; -    _saveBuffer(buf, l, f, cont); -} - -static Buffer * -loadcmdout(char *cmd, -	   Buffer *(*loadproc) (URLFile *, Buffer *), Buffer *defaultbuf) -{ -    FILE *f, *popen(const char *, const char *); -    Buffer *buf; -    URLFile uf; - -    if (cmd == NULL || *cmd == '\0') -	return NULL; -    f = popen(cmd, "r"); -    if (f == NULL) -	return NULL; -    init_stream(&uf, SCM_UNKNOWN, newFileStream(f, (void (*)())pclose)); -    buf = loadproc(&uf, defaultbuf); -    UFclose(&uf); -    return buf; -} - -/*  - * getshell: execute shell command and get the result into a buffer - */ -Buffer * -getshell(char *cmd) -{ -    Buffer *buf; - -    buf = loadcmdout(cmd, loadBuffer, NULL); -    if (buf == NULL) -	return NULL; -    buf->filename = cmd; -    buf->buffername = Sprintf("%s %s", SHELLBUFFERNAME, -			      conv_from_system(cmd))->ptr; -    return buf; -} - -/*  - * getpipe: execute shell command and connect pipe to the buffer - */ -Buffer * -getpipe(char *cmd) -{ -    FILE *f, *popen(const char *, const char *); -    Buffer *buf; - -    if (cmd == NULL || *cmd == '\0') -	return NULL; -    f = popen(cmd, "r"); -    if (f == NULL) -	return NULL; -    buf = newBuffer(INIT_BUFFER_WIDTH); -    buf->pagerSource = newFileStream(f, (void (*)())pclose); -    buf->filename = cmd; -    buf->buffername = Sprintf("%s %s", PIPEBUFFERNAME, -			      conv_from_system(cmd))->ptr; -    buf->bufferprop |= BP_PIPE; -#ifdef USE_M17N -    buf->document_charset = WC_CES_US_ASCII; -#endif -    return buf; -} - -/*  - * Open pager buffer - */ -Buffer * -openPagerBuffer(InputStream stream, Buffer *buf) -{ - -    if (buf == NULL) -	buf = newBuffer(INIT_BUFFER_WIDTH); -    buf->pagerSource = stream; -    buf->buffername = getenv("MAN_PN"); -    if (buf->buffername == NULL) -	buf->buffername = PIPEBUFFERNAME; -    else -	buf->buffername = conv_from_system(buf->buffername); -    buf->bufferprop |= BP_PIPE; -#ifdef USE_M17N -    if (content_charset && UseContentCharset) -	buf->document_charset = content_charset; -    else -	buf->document_charset = WC_CES_US_ASCII; -#endif -    buf->currentLine = buf->firstLine; - -    return buf; -} - -Buffer * -openGeneralPagerBuffer(InputStream stream) -{ -    Buffer *buf; -    char *t = "text/plain"; -    Buffer *t_buf = NULL; -    URLFile uf; - -    init_stream(&uf, SCM_UNKNOWN, stream); - -#ifdef USE_M17N -    content_charset = 0; -#endif -    if (SearchHeader) { -	t_buf = newBuffer(INIT_BUFFER_WIDTH); -	readHeader(&uf, t_buf, TRUE, NULL); -	t = checkContentType(t_buf); -	if (t == NULL) -	    t = "text/plain"; -	if (t_buf) { -	    t_buf->topLine = t_buf->firstLine; -	    t_buf->currentLine = t_buf->lastLine; -	} -	SearchHeader = FALSE; -    } -    else if (DefaultType) { -	t = DefaultType; -	DefaultType = NULL; -    } -    if (!strcasecmp(t, "text/html")) { -	buf = loadHTMLBuffer(&uf, t_buf); -	buf->type = "text/html"; -    } -    else if (is_plain_text_type(t)) { -	if (IStype(stream) != IST_ENCODED) -	    stream = newEncodedStream(stream, uf.encoding); -	buf = openPagerBuffer(stream, t_buf); -	buf->type = "text/plain"; -    } -#ifdef USE_IMAGE -    else if (activeImage && displayImage && !useExtImageViewer && -	     !(w3m_dump & ~DUMP_FRAME) && !strncasecmp(t, "image/", 6)) { -	cur_baseURL = New(ParsedURL); -	parseURL("-", cur_baseURL, NULL); -	buf = loadImageBuffer(&uf, t_buf); -	buf->type = "text/html"; -    } -#endif -    else { -	if (doExternal(uf, "-", t, &buf, t_buf)) { -	    UFclose(&uf); -	    if (buf == NULL || buf == NO_BUFFER) -		return buf; -	} -	else {			/* unknown type is regarded as text/plain */ -	    if (IStype(stream) != IST_ENCODED) -		stream = newEncodedStream(stream, uf.encoding); -	    buf = openPagerBuffer(stream, t_buf); -	    buf->type = "text/plain"; -	} -    } -    buf->real_type = t; -    buf->currentURL.scheme = SCM_LOCAL; -    buf->currentURL.file = "-"; -    return buf; -} - -Line * -getNextPage(Buffer *buf, int plen) -{ -    Line *volatile top = buf->topLine, *volatile last = buf->lastLine, -	*volatile cur = buf->currentLine; -    int i; -    int volatile nlines = 0; -    clen_t linelen = 0, trbyte = buf->trbyte; -    Str lineBuf2; -    char volatile pre_lbuf = '\0'; -    URLFile uf; -#ifdef USE_M17N -    wc_ces charset; -    wc_ces volatile doc_charset = DocumentCharset; -    wc_uint8 old_auto_detect = WcOption.auto_detect; -#endif -    int volatile squeeze_flag = FALSE; -    Lineprop *propBuffer = NULL; - -#ifdef USE_ANSI_COLOR -    Linecolor *colorBuffer = NULL; -#endif -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; - -    if (buf->pagerSource == NULL) -	return NULL; - -    if (last != NULL) { -	nlines = last->real_linenumber; -	pre_lbuf = *(last->lineBuf); -	if (pre_lbuf == '\0') -	    pre_lbuf = '\n'; -	buf->currentLine = last; -    } - -#ifdef USE_M17N -    charset = buf->document_charset; -    if (buf->document_charset != WC_CES_US_ASCII) -	doc_charset = buf->document_charset; -    else if (UseContentCharset) { -	content_charset = 0; -	checkContentType(buf); -	if (content_charset) -	    doc_charset = content_charset; -    } -    WcOption.auto_detect = buf->auto_detect; -#endif - -    if (SETJMP(AbortLoading) != 0) { -	goto pager_end; -    } -    TRAP_ON; - -    init_stream(&uf, SCM_UNKNOWN, NULL); -    for (i = 0; i < plen; i++) { -	lineBuf2 = StrmyISgets(buf->pagerSource); -	if (lineBuf2->length == 0) { -	    /* Assume that `cmd == buf->filename' */ -	    if (buf->filename) -		buf->buffername = Sprintf("%s %s", -					  CPIPEBUFFERNAME, -					  conv_from_system(buf->filename))-> -		    ptr; -	    else if (getenv("MAN_PN") == NULL) -		buf->buffername = CPIPEBUFFERNAME; -	    buf->bufferprop |= BP_CLOSE; -	    break; -	} -	linelen += lineBuf2->length; -	showProgress(&linelen, &trbyte); -	lineBuf2 = -	    convertLine(&uf, lineBuf2, PAGER_MODE, &charset, doc_charset); -	if (squeezeBlankLine) { -	    squeeze_flag = FALSE; -	    if (lineBuf2->ptr[0] == '\n' && pre_lbuf == '\n') { -		++nlines; -		--i; -		squeeze_flag = TRUE; -		continue; -	    } -	    pre_lbuf = lineBuf2->ptr[0]; -	} -	++nlines; -	Strchop(lineBuf2); -	lineBuf2 = checkType(lineBuf2, &propBuffer, &colorBuffer); -	addnewline(buf, lineBuf2->ptr, propBuffer, colorBuffer, -		   lineBuf2->length, FOLD_BUFFER_WIDTH, nlines); -	if (!top) { -	    top = buf->firstLine; -	    cur = top; -	} -	if (buf->lastLine->real_linenumber - buf->firstLine->real_linenumber -	    >= PagerMax) { -	    Line *l = buf->firstLine; -	    do { -		if (top == l) -		    top = l->next; -		if (cur == l) -		    cur = l->next; -		if (last == l) -		    last = NULL; -		l = l->next; -	    } while (l && l->bpos); -	    buf->firstLine = l; -	    buf->firstLine->prev = NULL; -	} -    } -  pager_end: -    TRAP_OFF; - -    buf->trbyte = trbyte + linelen; -#ifdef USE_M17N -    buf->document_charset = charset; -    WcOption.auto_detect = old_auto_detect; -#endif -    buf->topLine = top; -    buf->currentLine = cur; -    if (!last) -	last = buf->firstLine; -    else if (last && (last->next || !squeeze_flag)) -	last = last->next; -    return last; -} - -int -save2tmp(URLFile uf, char *tmpf) -{ -    FILE *ff; -    int check; -    clen_t linelen = 0, trbyte = 0; -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; -    static JMP_BUF env_bak; - -    ff = fopen(tmpf, "wb"); -    if (ff == NULL) { -	/* fclose(f); */ -	return -1; -    } -    bcopy(AbortLoading, env_bak, sizeof(JMP_BUF)); -    if (SETJMP(AbortLoading) != 0) { -	goto _end; -    } -    TRAP_ON; -    check = 0; -#ifdef USE_NNTP -    if (uf.scheme == SCM_NEWS) { -	char c; -	while (c = UFgetc(&uf), !iseos(uf.stream)) { -	    if (c == '\n') { -		if (check == 0) -		    check++; -		else if (check == 3) -		    break; -	    } -	    else if (c == '.' && check == 1) -		check++; -	    else if (c == '\r' && check == 2) -		check++; -	    else -		check = 0; -	    putc(c, ff); -	    linelen += sizeof(c); -	    showProgress(&linelen, &trbyte); -	} -    } -    else -#endif				/* USE_NNTP */ -    { -	Str buf = Strnew_size(SAVE_BUF_SIZE); -	while (UFread(&uf, buf, SAVE_BUF_SIZE)) { -	    Strfputs(buf, ff); -	    linelen += buf->length; -	    showProgress(&linelen, &trbyte); -	} -    } -  _end: -    bcopy(env_bak, AbortLoading, sizeof(JMP_BUF)); -    TRAP_OFF; -    fclose(ff); -    current_content_length = 0; -    return 0; -} - -int -doExternal(URLFile uf, char *path, char *type, Buffer **bufp, -	   Buffer *defaultbuf) -{ -    Str tmpf, command; -    struct mailcap *mcap; -    int mc_stat; -    Buffer *buf = NULL; -    char *header, *src = NULL, *ext = uf.ext; - -    if (!(mcap = searchExtViewer(type))) -	return 0; - -    if (mcap->nametemplate) { -	tmpf = unquote_mailcap(mcap->nametemplate, NULL, "", NULL, NULL); -	if (tmpf->ptr[0] == '.') -	    ext = tmpf->ptr; -    } -    tmpf = tmpfname(TMPF_DFL, (ext && *ext) ? ext : NULL); - -    if (IStype(uf.stream) != IST_ENCODED) -	uf.stream = newEncodedStream(uf.stream, uf.encoding); -    header = checkHeader(defaultbuf, "Content-Type:"); -    if (header) -	header = conv_to_system(header); -    command = unquote_mailcap(mcap->viewer, type, tmpf->ptr, header, &mc_stat); -#ifndef __EMX__ -    if (!(mc_stat & MCSTAT_REPNAME)) { -	Str tmp = Sprintf("(%s) < %s", command->ptr, shell_quote(tmpf->ptr)); -	command = tmp; -    } -#endif - -#ifdef HAVE_SETPGRP -    if (!(mcap->flags & (MAILCAP_HTMLOUTPUT | MAILCAP_COPIOUSOUTPUT)) && -	!(mcap->flags & MAILCAP_NEEDSTERMINAL) && BackgroundExtViewer) { -	flush_tty(); -	if (!fork()) { -	    setup_child(FALSE, 0, UFfileno(&uf)); -	    if (save2tmp(uf, tmpf->ptr) < 0) -		exit(1); -	    UFclose(&uf); -	    myExec(command->ptr); -	} -	*bufp = NO_BUFFER; -	return 1; -    } -    else -#endif -    { -	if (save2tmp(uf, tmpf->ptr) < 0) { -	    *bufp = NULL; -	    return 1; -	} -    } -    if (mcap->flags & (MAILCAP_HTMLOUTPUT | MAILCAP_COPIOUSOUTPUT)) { -	if (defaultbuf == NULL) -	    defaultbuf = newBuffer(INIT_BUFFER_WIDTH); -	if (defaultbuf->sourcefile) -	    src = defaultbuf->sourcefile; -	else -	    src = tmpf->ptr; -	defaultbuf->sourcefile = NULL; -	defaultbuf->mailcap = mcap; -    } -    if (mcap->flags & MAILCAP_HTMLOUTPUT) { -	buf = loadcmdout(command->ptr, loadHTMLBuffer, defaultbuf); -	if (buf && buf != NO_BUFFER) { -	    buf->type = "text/html"; -	    buf->mailcap_source = buf->sourcefile; -	    buf->sourcefile = src; -	} -    } -    else if (mcap->flags & MAILCAP_COPIOUSOUTPUT) { -	buf = loadcmdout(command->ptr, loadBuffer, defaultbuf); -	if (buf && buf != NO_BUFFER) { -	    buf->type = "text/plain"; -	    buf->mailcap_source = buf->sourcefile; -	    buf->sourcefile = src; -	} -    } -    else { -	if (mcap->flags & MAILCAP_NEEDSTERMINAL || !BackgroundExtViewer) { -	    fmTerm(); -	    mySystem(command->ptr, 0); -	    fmInit(); -	    if (CurrentTab && Currentbuf) -		displayBuffer(Currentbuf, B_FORCE_REDRAW); -	} -	else { -	    mySystem(command->ptr, 1); -	} -	buf = NO_BUFFER; -    } -    if (buf && buf != NO_BUFFER) { -	buf->filename = path; -	if (buf->buffername == NULL || buf->buffername[0] == '\0') -	    buf->buffername = conv_from_system(lastFileName(path)); -	buf->edit = mcap->edit; -	buf->mailcap = mcap; -    } -    *bufp = buf; -    return 1; -} - -static int -_MoveFile(char *path1, char *path2) -{ -    InputStream f1; -    FILE *f2; -    int is_pipe; -    clen_t linelen = 0, trbyte = 0; -    Str buf; - -    f1 = openIS(path1); -    if (f1 == NULL) -	return -1; -    if (*path2 == '|' && PermitSaveToPipe) { -	is_pipe = TRUE; -	f2 = popen(path2 + 1, "w"); -    } -    else { -	is_pipe = FALSE; -	f2 = fopen(path2, "wb"); -    } -    if (f2 == NULL) { -	ISclose(f1); -	return -1; -    } -    current_content_length = 0; -    buf = Strnew_size(SAVE_BUF_SIZE); -    while (ISread(f1, buf, SAVE_BUF_SIZE)) { -	Strfputs(buf, f2); -	linelen += buf->length; -	showProgress(&linelen, &trbyte); -    } -    ISclose(f1); -    if (is_pipe) -	pclose(f2); -    else -	fclose(f2); -    return 0; -} - -int -_doFileCopy(char *tmpf, char *defstr, int download) -{ -    Str msg; -    Str filen; -    char *p, *q = NULL; -    pid_t pid; -    char *lock; -#if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)) -    FILE *f; -#endif -    struct stat st; -    clen_t size = 0; -    int is_pipe = FALSE; - -    if (fmInitialized) { -	p = searchKeyData(); -	if (p == NULL || *p == '\0') { -	    /* FIXME: gettextize? */ -	    q = inputLineHist("(Download)Save file to: ", -			      defstr, IN_COMMAND, SaveHist); -	    if (q == NULL || *q == '\0') -		return FALSE; -	    p = conv_to_system(q); -	} -	if (*p == '|' && PermitSaveToPipe) -	    is_pipe = TRUE; -	else { -	    if (q) { -		p = unescape_spaces(Strnew_charp(q))->ptr; -		p = conv_to_system(q); -	    } -	    p = expandPath(p); -	    if (checkOverWrite(p) < 0) -		return -1; -	} -	if (checkCopyFile(tmpf, p) < 0) { -	    /* FIXME: gettextize? */ -	    msg = Sprintf("Can't copy. %s and %s are identical.", -			  conv_from_system(tmpf), conv_from_system(p)); -	    disp_err_message(msg->ptr, FALSE); -	    return -1; -	} -	if (!download) { -	    if (_MoveFile(tmpf, p) < 0) { -		/* FIXME: gettextize? */ -		msg = Sprintf("Can't save to %s", conv_from_system(p)); -		disp_err_message(msg->ptr, FALSE); -	    } -	    return -1; -	} -	lock = tmpfname(TMPF_DFL, ".lock")->ptr; -#if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT) -	symlink(p, lock); -#else -	f = fopen(lock, "w"); -	if (f) -	    fclose(f); -#endif -	flush_tty(); -	pid = fork(); -	if (!pid) { -	    setup_child(FALSE, 0, -1); -	    if (!_MoveFile(tmpf, p) && PreserveTimestamp && !is_pipe && -		!stat(tmpf, &st)) -		setModtime(p, st.st_mtime); -	    unlink(lock); -	    exit(0); -	} -	if (!stat(tmpf, &st)) -	    size = st.st_size; -	addDownloadList(pid, conv_from_system(tmpf), p, lock, size); -    } -    else { -	q = searchKeyData(); -	if (q == NULL || *q == '\0') { -	    /* FIXME: gettextize? */ -	    printf("(Download)Save file to: "); -	    fflush(stdout); -	    filen = Strfgets(stdin); -	    if (filen->length == 0) -		return -1; -	    q = filen->ptr; -	} -	for (p = q + strlen(q) - 1; IS_SPACE(*p); p--) ; -	*(p + 1) = '\0'; -	if (*q == '\0') -	    return -1; -	p = q; -	if (*p == '|' && PermitSaveToPipe) -	    is_pipe = TRUE; -	else { -	    p = expandPath(p); -	    if (checkOverWrite(p) < 0) -		return -1; -	} -	if (checkCopyFile(tmpf, p) < 0) { -	    /* FIXME: gettextize? */ -	    printf("Can't copy. %s and %s are identical.", tmpf, p); -	    return -1; -	} -	if (_MoveFile(tmpf, p) < 0) { -	    /* FIXME: gettextize? */ -	    printf("Can't save to %s\n", p); -	    return -1; -	} -	if (PreserveTimestamp && !is_pipe && !stat(tmpf, &st)) -	    setModtime(p, st.st_mtime); -    } -    return 0; -} - -int -doFileMove(char *tmpf, char *defstr) -{ -    int ret = doFileCopy(tmpf, defstr); -    unlink(tmpf); -    return ret; -} - -int -doFileSave(URLFile uf, char *defstr) -{ -    Str msg; -    Str filen; -    char *p, *q; -    pid_t pid; -    char *lock; -    char *tmpf = NULL;  -#if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)) -    FILE *f; -#endif - -    if (fmInitialized) { -	p = searchKeyData(); -	if (p == NULL || *p == '\0') { -	    /* FIXME: gettextize? */ -	    p = inputLineHist("(Download)Save file to: ", -			      defstr, IN_FILENAME, SaveHist); -	    if (p == NULL || *p == '\0') -		return -1; -	    p = conv_to_system(p); -	} -	if (checkOverWrite(p) < 0) -	    return -1; -	if (checkSaveFile(uf.stream, p) < 0) { -	    /* FIXME: gettextize? */ -	    msg = Sprintf("Can't save. Load file and %s are identical.", -			  conv_from_system(p)); -	    disp_err_message(msg->ptr, FALSE); -	    return -1; -	} -	/* -	 * if (save2tmp(uf, p) < 0) { -	 * msg = Sprintf("Can't save to %s", conv_from_system(p)); -	 * disp_err_message(msg->ptr, FALSE); -	 * } -	 */ -	lock = tmpfname(TMPF_DFL, ".lock")->ptr; -#if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT) -	symlink(p, lock); -#else -	f = fopen(lock, "w"); -	if (f) -	    fclose(f); -#endif -	flush_tty(); -	pid = fork(); -	if (!pid) { -	    if (uf.content_encoding != CMP_NOCOMPRESS) { -		uncompress_stream(&uf, &tmpf); -		if (tmpf) -		    unlink(tmpf); -	    } -	    setup_child(FALSE, 0, UFfileno(&uf)); -	    if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1) -		setModtime(p, uf.modtime); -	    UFclose(&uf); -	    unlink(lock); -	    exit(0); -	} -	addDownloadList(pid, uf.url, p, lock, current_content_length); -    } -    else { -	q = searchKeyData(); -	if (q == NULL || *q == '\0') { -	    /* FIXME: gettextize? */ -	    printf("(Download)Save file to: "); -	    fflush(stdout); -	    filen = Strfgets(stdin); -	    if (filen->length == 0) -		return -1; -	    q = filen->ptr; -	} -	for (p = q + strlen(q) - 1; IS_SPACE(*p); p--) ; -	*(p + 1) = '\0'; -	if (*q == '\0') -	    return -1; -	p = expandPath(q); -	if (checkOverWrite(p) < 0) -	    return -1; -	if (checkSaveFile(uf.stream, p) < 0) { -	    /* FIXME: gettextize? */ -	    printf("Can't save. Load file and %s are identical.", p); -	    return -1; -	} -	if (uf.content_encoding != CMP_NOCOMPRESS) { -	    uncompress_stream(&uf, &tmpf); -	    if (tmpf) -		unlink(tmpf); -	} -	if (save2tmp(uf, p) < 0) { -	    /* FIXME: gettextize? */ -	    printf("Can't save to %s\n", p); -	    return -1; -	} -	if (PreserveTimestamp && uf.modtime != -1) -	    setModtime(p, uf.modtime); -    } -    return 0; -} - -int -checkCopyFile(char *path1, char *path2) -{ -    struct stat st1, st2; - -    if (*path2 == '|' && PermitSaveToPipe) -	return 0; -    if ((stat(path1, &st1) == 0) && (stat(path2, &st2) == 0)) -	if (st1.st_ino == st2.st_ino) -	    return -1; -    return 0; -} - -int -checkSaveFile(InputStream stream, char *path2) -{ -    struct stat st1, st2; -    int des = ISfileno(stream); - -    if (des < 0) -	return 0; -    if (*path2 == '|' && PermitSaveToPipe) -	return 0; -    if ((fstat(des, &st1) == 0) && (stat(path2, &st2) == 0)) -	if (st1.st_ino == st2.st_ino) -	    return -1; -    return 0; -} - -int -checkOverWrite(char *path) -{ -    struct stat st; -    char *ans; - -    if (stat(path, &st) < 0) -	return 0; -    /* FIXME: gettextize? */ -    ans = inputAnswer("File exists. Overwrite? (y/n)"); -    if (ans && TOLOWER(*ans) == 'y') -	return 0; -    else -	return -1; -} - -char * -inputAnswer(char *prompt) -{ -    char *ans; - -    if (QuietMessage) -	return "n"; -    if (fmInitialized) { -	term_raw(); -	ans = inputChar(prompt); -    } -    else { -	printf(prompt); -	fflush(stdout); -	ans = Strfgets(stdin)->ptr; -    } -    return ans; -} - -static void -uncompress_stream(URLFile *uf, char **src) -{ -    pid_t pid1; -    FILE *f1; -    char *expand_cmd = GUNZIP_CMDNAME; -    char *expand_name = GUNZIP_NAME; -    char *tmpf = NULL; -    char *ext = NULL; -    struct compression_decoder *d; - -    if (IStype(uf->stream) != IST_ENCODED) { -	uf->stream = newEncodedStream(uf->stream, uf->encoding); -	uf->encoding = ENC_7BIT; -    } -    for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { -	if (uf->compression == d->type) { -	    if (d->auxbin_p) -		expand_cmd = auxbinFile(d->cmd); -	    else -		expand_cmd = d->cmd; -	    expand_name = d->name; -	    ext = d->ext; -	    break; -	} -    } -    uf->compression = CMP_NOCOMPRESS; - -    if (uf->scheme != SCM_LOCAL -#ifdef USE_IMAGE -	&& !image_source -#endif -	) { -	tmpf = tmpfname(TMPF_DFL, ext)->ptr; -    } - -    /* child1 -- stdout|f1=uf -> parent */ -    pid1 = open_pipe_rw(&f1, NULL); -    if (pid1 < 0) { -	UFclose(uf); -	return; -    } -    if (pid1 == 0) { -	/* child */ -	pid_t pid2; -	FILE *f2 = stdin; - -	/* uf -> child2 -- stdout|stdin -> child1 */ -	pid2 = open_pipe_rw(&f2, NULL); -	if (pid2 < 0) { -	    UFclose(uf); -	    exit(1); -	} -	if (pid2 == 0) { -	    /* child2 */ -	    Str buf = Strnew_size(SAVE_BUF_SIZE); -	    FILE *f = NULL; - -	    setup_child(TRUE, 2, UFfileno(uf)); -	    if (tmpf) -		f = fopen(tmpf, "wb"); -	    while (UFread(uf, buf, SAVE_BUF_SIZE)) { -		if (Strfputs(buf, stdout) < 0) -		    break; -		if (f) -		    Strfputs(buf, f); -	    } -	    UFclose(uf); -	    if (f) -		fclose(f); -	    exit(0); -	} -	/* child1 */ -	dup2(1, 2);		/* stderr>&stdout */ -	setup_child(TRUE, -1, -1); -	execlp(expand_cmd, expand_name, NULL); -	exit(1); -    } -    if (tmpf) { -	if (src) -	    *src = tmpf; -	else -	    uf->scheme = SCM_LOCAL; -    } -    UFhalfclose(uf); -    uf->stream = newFileStream(f1, (void (*)())fclose); -} - -static FILE * -lessopen_stream(char *path) -{ -    char *lessopen; -    FILE *fp; - -    lessopen = getenv("LESSOPEN"); -    if (lessopen == NULL) { -	return NULL; -    } -    if (lessopen[0] == '\0') { -	return NULL; -    } - -    if (lessopen[0] == '|') { -	/* pipe mode */ -	Str tmpf; -	int c; - -	++lessopen; -	tmpf = Sprintf(lessopen, shell_quote(path)); -	fp = popen(tmpf->ptr, "r"); -	if (fp == NULL) { -	    return NULL; -	} -	c = getc(fp); -	if (c == EOF) { -	    fclose(fp); -	    return NULL; -	} -	ungetc(c, fp); -    } -    else { -	/* filename mode */ -	/* not supported m(__)m */ -	fp = NULL; -    } -    return fp; -} - -#if 0 -void -reloadBuffer(Buffer *buf) -{ -    URLFile uf; - -    if (buf->sourcefile == NULL || buf->pagerSource != NULL) -	return; -    init_stream(&uf, SCM_UNKNOWN, NULL); -    examineFile(buf->mailcap_source ? buf->mailcap_source : buf->sourcefile, -		&uf); -    if (uf.stream == NULL) -	return; -    is_redisplay = TRUE; -    buf->allLine = 0; -    buf->href = NULL; -    buf->name = NULL; -    buf->img = NULL; -    buf->formitem = NULL; -    buf->linklist = NULL; -    buf->maplist = NULL; -    if (buf->hmarklist) -	buf->hmarklist->nmark = 0; -    if (buf->imarklist) -	buf->imarklist->nmark = 0; -    if (!strcasecmp(buf->type, "text/html")) -	loadHTMLBuffer(&uf, buf); -    else -	loadBuffer(&uf, buf); -    UFclose(&uf); -    is_redisplay = FALSE; -} -#endif - -static char * -guess_filename(char *file) -{ -    char *p = NULL, *s; - -    if (file != NULL) -	p = mybasename(file); -    if (p == NULL || *p == '\0') -	return DEF_SAVE_FILE; -    s = p; -    if (*p == '#') -	p++; -    while (*p != '\0') { -	if ((*p == '#' && *(p + 1) != '\0') || *p == '?') { -	    *p = '\0'; -	    break; -	} -	p++; -    } -    return s; -} - -char * -guess_save_name(Buffer *buf, char *path) -{ -    if (buf && buf->document_header) { -	Str name = NULL; -	char *p, *q; -	if ((p = checkHeader(buf, "Content-Disposition:")) != NULL && -	    (q = strcasestr(p, "filename")) != NULL && -	    (q == p || IS_SPACE(*(q - 1)) || *(q - 1) == ';') && -	    matchattr(q, "filename", 8, &name)) -	    path = name->ptr; -	else if ((p = checkHeader(buf, "Content-Type:")) != NULL && -		 (q = strcasestr(p, "name")) != NULL && -		 (q == p || IS_SPACE(*(q - 1)) || *(q - 1) == ';') && -		 matchattr(q, "name", 4, &name)) -	    path = name->ptr; -    } -    return guess_filename(path); -} - -/* Local Variables:    */ -/* c-basic-offset: 4   */ -/* tab-width: 8        */ -/* End:                */ diff --git a/.#main.c.1.253 b/.#main.c.1.253 deleted file mode 100644 index 9a4c755..0000000 --- a/.#main.c.1.253 +++ /dev/null @@ -1,6600 +0,0 @@ -/* $Id: main.c,v 1.253 2006/12/10 10:49:23 inu Exp $ */ -#define MAINPROGRAM -#include "fm.h" -#include <signal.h> -#include <setjmp.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> -#include <fcntl.h> -#if defined(HAVE_WAITPID) || defined(HAVE_WAIT3) -#include <sys/wait.h> -#endif -#include <time.h> -#include "terms.h" -#include "myctype.h" -#include "regex.h" -#ifdef USE_MOUSE -#ifdef USE_GPM -#include <gpm.h> -#endif				/* USE_GPM */ -#if defined(USE_GPM) || defined(USE_SYSMOUSE) -extern int do_getch(); -#define getch()	do_getch() -#endif				/* defined(USE_GPM) || defined(USE_SYSMOUSE) */ -#endif - -#define DSTR_LEN	256 - -Hist *LoadHist; -Hist *SaveHist; -Hist *URLHist; -Hist *ShellHist; -Hist *TextHist; - -typedef struct _Event { -    int cmd; -    void *data; -    struct _Event *next; -} Event; -static Event *CurrentEvent = NULL; -static Event *LastEvent = NULL; - -#ifdef USE_ALARM -static AlarmEvent DefaultAlarm = { -    0, AL_UNSET, FUNCNAME_nulcmd, NULL -}; -static AlarmEvent *CurrentAlarm = &DefaultAlarm; -static MySignalHandler SigAlarm(SIGNAL_ARG); -#endif - -#ifdef SIGWINCH -static int need_resize_screen = FALSE; -static MySignalHandler resize_hook(SIGNAL_ARG); -static void resize_screen(void); -#endif - -#ifdef SIGPIPE -static MySignalHandler SigPipe(SIGNAL_ARG); -#endif - -#ifdef USE_MARK -static char *MarkString = NULL; -#endif -static char *SearchString = NULL; -int (*searchRoutine) (Buffer *, char *); - -JMP_BUF IntReturn; - -static void delBuffer(Buffer *buf); -static void cmd_loadfile(char *path); -static void cmd_loadURL(char *url, ParsedURL *current, char *referer, -			FormList *request); -static void cmd_loadBuffer(Buffer *buf, int prop, int linkid); -static void keyPressEventProc(int c); -int show_params_p = 0; -void show_params(FILE * fp); - -static char *getCurWord(Buffer *buf, int *spos, int *epos, -			const char *badchars); - -static int display_ok = FALSE; -static void do_dump(Buffer *); -int prec_num = 0; -int prev_key = -1; -int on_target = 1; -static int add_download_list = FALSE; - -void set_buffer_environ(Buffer *); -static void save_buffer_position(Buffer *buf); - -static void _followForm(int); -static void _goLine(char *); -static void _newT(void); -static void followTab(TabBuffer * tab); -static void moveTab(TabBuffer * t, TabBuffer * t2, int right); -static void _nextA(int); -static void _prevA(int); -static int check_target = TRUE; -#define PREC_NUM (prec_num ? prec_num : 1) -#define PREC_LIMIT 10000 -static int searchKeyNum(void); - -#define help() fusage(stdout, 0) -#define usage() fusage(stderr, 1) - -static void -fversion(FILE * f) -{ -    fprintf(f, "w3m version %s, options %s\n", w3m_version, -#if LANG == JA -	    "lang=ja" -#else -	    "lang=en" -#endif -#ifdef USE_M17N -	    ",m17n" -#endif -#ifdef USE_IMAGE -	    ",image" -#endif -#ifdef USE_COLOR -	    ",color" -#ifdef USE_ANSI_COLOR -	    ",ansi-color" -#endif -#endif -#ifdef USE_MOUSE -	    ",mouse" -#ifdef USE_GPM -	    ",gpm" -#endif -#ifdef USE_SYSMOUSE -	    ",sysmouse" -#endif -#endif -#ifdef USE_MENU -	    ",menu" -#endif -#ifdef USE_COOKIE -	    ",cookie" -#endif -#ifdef USE_SSL -	    ",ssl" -#ifdef USE_SSL_VERIFY -	    ",ssl-verify" -#endif -#endif -#ifdef USE_EXTERNAL_URI_LOADER -	    ",external-uri-loader" -#endif -#ifdef USE_W3MMAILER -	    ",w3mmailer" -#endif -#ifdef USE_NNTP -	    ",nntp" -#endif -#ifdef USE_GOPHER -	    ",gopher" -#endif -#ifdef INET6 -	    ",ipv6" -#endif -#ifdef USE_ALARM -	    ",alarm" -#endif -#ifdef USE_MARK -	    ",mark" -#endif -#ifdef USE_MIGEMO -	    ",migemo" -#endif -	); -} - -static void -fusage(FILE * f, int err) -{ -    fversion(f); -    /* FIXME: gettextize? */ -    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"); -    fprintf(f, "    -l line          # of preserved line (default 10000)\n"); -#ifdef USE_M17N -    fprintf(f, "    -I charset       document charset\n"); -    fprintf(f, "    -O charset       display/output charset\n"); -#ifndef DEBIAN			/* disabled by ukai: -s is used for squeeze multi lines */ -    fprintf(f, "    -e               EUC-JP\n"); -    fprintf(f, "    -s               Shift_JIS\n"); -    fprintf(f, "    -j               JIS\n"); -#endif -#endif -    fprintf(f, "    -B               load bookmark\n"); -    fprintf(f, "    -bookmark file   specify bookmark file\n"); -    fprintf(f, "    -T type          specify content-type\n"); -    fprintf(f, "    -m               internet message mode\n"); -    fprintf(f, "    -v               visual startup mode\n"); -#ifdef USE_COLOR -    fprintf(f, "    -M               monochrome display\n"); -#endif				/* USE_COLOR */ -    fprintf(f, -	    "    -N               open URL of command line on each new tab\n"); -    fprintf(f, "    -F               automatically render frame\n"); -    fprintf(f, -	    "    -cols width      specify column width (used with -dump)\n"); -    fprintf(f, -	    "    -ppc count       specify the number of pixels per character (4.0...32.0)\n"); -#ifdef USE_IMAGE -    fprintf(f, -	    "    -ppl count       specify the number of pixels per line (4.0...64.0)\n"); -#endif -    fprintf(f, "    -dump            dump formatted page into stdout\n"); -    fprintf(f, -	    "    -dump_head       dump response of HEAD request into stdout\n"); -    fprintf(f, "    -dump_source     dump page source into stdout\n"); -    fprintf(f, "    -dump_both       dump HEAD and source into stdout\n"); -    fprintf(f, -	    "    -dump_extra      dump HEAD, source, and extra information into stdout\n"); -    fprintf(f, "    -post file       use POST method with file content\n"); -    fprintf(f, "    -header string   insert string as a header\n"); -    fprintf(f, "    +<num>           goto <num> line\n"); -    fprintf(f, "    -num             show line number\n"); -    fprintf(f, "    -no-proxy        don't use proxy\n"); -#ifdef INET6 -    fprintf(f, "    -4               IPv4 only (-o dns_order=4)\n"); -    fprintf(f, "    -6               IPv6 only (-o dns_order=6)\n"); -#endif -#ifdef USE_MOUSE -    fprintf(f, "    -no-mouse        don't use mouse\n"); -#endif				/* USE_MOUSE */ -#ifdef USE_COOKIE -    fprintf(f, -	    "    -cookie          use cookie (-no-cookie: don't use cookie)\n"); -#endif				/* USE_COOKIE */ -    fprintf(f, "    -pauth user:pass proxy authentication\n"); -    fprintf(f, "    -graph           use graphic character\n"); -    fprintf(f, "    -no-graph        don't use graphic character\n"); -#ifdef DEBIAN			/* replaced by ukai: pager requires -s */ -    fprintf(f, "    -s               squeeze multiple blank lines\n"); -#else -    fprintf(f, "    -S               squeeze multiple blank lines\n"); -#endif -    fprintf(f, "    -W               toggle wrap search mode\n"); -    fprintf(f, "    -X               don't use termcap init/deinit\n"); -    fprintf(f, -	    "    -title[=TERM]    set buffer name to terminal title string\n"); -    fprintf(f, "    -o opt=value     assign value to config option\n"); -    fprintf(f, "    -show-option     print all config options\n"); -    fprintf(f, "    -config file     specify config file\n"); -    fprintf(f, "    -help            print this usage message\n"); -    fprintf(f, "    -version         print w3m version\n"); -    fprintf(f, "    -reqlog          write request logfile\n"); -    fprintf(f, "    -debug           DO NOT USE\n"); -    if (show_params_p) -	show_params(f); -    exit(err); -} - -#ifdef USE_M17N -#ifdef __EMX__ -static char *getCodePage(void); -#endif -#endif - -static GC_warn_proc orig_GC_warn_proc = NULL; -#define GC_WARN_KEEP_MAX (20) - -static void -wrap_GC_warn_proc(char *msg, GC_word arg) -{ -    if (fmInitialized) { -	/* *INDENT-OFF* */ -	static struct { -	    char *msg; -	    GC_word arg; -	} msg_ring[GC_WARN_KEEP_MAX]; -	/* *INDENT-ON* */ -	static int i = 0; -	static int n = 0; -	static int lock = 0; -	int j; - -	j = (i + n) % (sizeof(msg_ring) / sizeof(msg_ring[0])); -	msg_ring[j].msg = msg; -	msg_ring[j].arg = arg; - -	if (n < sizeof(msg_ring) / sizeof(msg_ring[0])) -	    ++n; -	else -	    ++i; - -	if (!lock) { -	    lock = 1; - -	    for (; n > 0; --n, ++i) { -		i %= sizeof(msg_ring) / sizeof(msg_ring[0]); - -		printf(msg_ring[i].msg,	(unsigned long)msg_ring[i].arg); -		sleep_till_anykey(1, 1); -	    } - -	    lock = 0; -	} -    } -    else if (orig_GC_warn_proc) -	orig_GC_warn_proc(msg, arg); -    else -	fprintf(stderr, msg, (unsigned long)arg); -} - -#ifdef SIGCHLD -static void -sig_chld(int signo) -{ -    int p_stat; -#ifdef HAVE_WAITPID -    pid_t pid; - -    while ((pid = waitpid(-1, &p_stat, WNOHANG)) > 0) { -	; -    } -#elif HAVE_WAIT3 -    int pid; - -    while ((pid = wait3(&p_stat, WNOHANG, NULL)) > 0) { -	; -    } -#else -    wait(&p_stat); -#endif -    mySignal(SIGCHLD, sig_chld); -    return; -} -#endif - -Str -make_optional_header_string(char *s) -{ -    char *p; -    Str hs; - -    if (strchr(s, '\n') || strchr(s, '\r')) -	return NULL; -    for (p = s; *p && *p != ':'; p++) ; -    if (*p != ':' || p == s) -	return NULL; -    hs = Strnew_size(strlen(s) + 3); -    Strcopy_charp_n(hs, s, p - s); -    if (!Strcasecmp_charp(hs, "content-type")) -	override_content_type = TRUE; -    Strcat_charp(hs, ": "); -    if (*(++p)) {		/* not null header */ -	SKIP_BLANKS(p);		/* skip white spaces */ -	Strcat_charp(hs, p); -    } -    Strcat_charp(hs, "\r\n"); -    return hs; -} - -int -main(int argc, char **argv, char **envp) -{ -    Buffer *newbuf = NULL; -    char *p, c; -    int i; -    InputStream redin; -    char *line_str = NULL; -    char **load_argv; -    FormList *request; -    int load_argc = 0; -    int load_bookmark = FALSE; -    int visual_start = FALSE; -    int open_new_tab = FALSE; -    char search_header = FALSE; -    char *default_type = NULL; -    char *post_file = NULL; -    Str err_msg; -#ifdef USE_M17N -    char *Locale = NULL; -    wc_uint8 auto_detect; -#ifdef __EMX__ -    wc_ces CodePage; -#endif -#endif -    GC_init(); -#if ENABLE_NLS -    setlocale(LC_ALL, ""); -    bindtextdomain(PACKAGE, LOCALEDIR); -    textdomain(PACKAGE); -#endif - -#ifndef HAVE_SYS_ERRLIST -    prepare_sys_errlist(); -#endif				/* not HAVE_SYS_ERRLIST */ - -    NO_proxy_domains = newTextList(); -    fileToDelete = newTextList(); - -    load_argv = New_N(char *, argc - 1); -    load_argc = 0; - -    CurrentDir = currentdir(); -    CurrentPid = (int)getpid(); -    BookmarkFile = NULL; -    config_file = NULL; - -    /* argument search 1 */ -    for (i = 1; i < argc; i++) { -	if (*argv[i] == '-') { -	    if (!strcmp("-config", argv[i])) { -		argv[i] = "-dummy"; -		if (++i >= argc) -		    usage(); -		config_file = argv[i]; -		argv[i] = "-dummy"; -	    } -	    else if (!strcmp("-h", argv[i]) || !strcmp("-help", argv[i])) -		help(); -	    else if (!strcmp("-V", argv[i]) || !strcmp("-version", argv[i])) { -		fversion(stdout); -		exit(0); -	    } -	} -    } - -#ifdef USE_M17N -    if (non_null(Locale = getenv("LC_ALL")) || -	non_null(Locale = getenv("LC_CTYPE")) || -	non_null(Locale = getenv("LANG"))) { -	DisplayCharset = wc_guess_locale_charset(Locale, DisplayCharset); -	DocumentCharset = wc_guess_locale_charset(Locale, DocumentCharset); -	SystemCharset = wc_guess_locale_charset(Locale, SystemCharset); -    } -#ifdef __EMX__ -    CodePage = wc_guess_charset(getCodePage(), 0); -    if (CodePage) -	DisplayCharset = DocumentCharset = SystemCharset = CodePage; -#endif -#endif - -    /* initializations */ -    init_rc(); - -    LoadHist = newHist(); -    SaveHist = newHist(); -    ShellHist = newHist(); -    TextHist = newHist(); -    URLHist = newHist(); - -#ifdef USE_M17N -    if (FollowLocale && Locale) { -	DisplayCharset = wc_guess_locale_charset(Locale, DisplayCharset); -	SystemCharset = wc_guess_locale_charset(Locale, SystemCharset); -    } -    auto_detect = WcOption.auto_detect; -    BookmarkCharset = DocumentCharset; -#endif - -    if (!non_null(HTTP_proxy) && -	((p = getenv("HTTP_PROXY")) || -	 (p = getenv("http_proxy")) || (p = getenv("HTTP_proxy")))) -	HTTP_proxy = p; -#ifdef USE_SSL -    if (!non_null(HTTPS_proxy) && -	((p = getenv("HTTPS_PROXY")) || -	 (p = getenv("https_proxy")) || (p = getenv("HTTPS_proxy")))) -	HTTPS_proxy = p; -    if (HTTPS_proxy == NULL && non_null(HTTP_proxy)) -	HTTPS_proxy = HTTP_proxy; -#endif				/* USE_SSL */ -#ifdef USE_GOPHER -    if (!non_null(GOPHER_proxy) && -	((p = getenv("GOPHER_PROXY")) || -	 (p = getenv("gopher_proxy")) || (p = getenv("GOPHER_proxy")))) -	GOPHER_proxy = p; -#endif				/* USE_GOPHER */ -    if (!non_null(FTP_proxy) && -	((p = getenv("FTP_PROXY")) || -	 (p = getenv("ftp_proxy")) || (p = getenv("FTP_proxy")))) -	FTP_proxy = p; -    if (!non_null(NO_proxy) && -	((p = getenv("NO_PROXY")) || -	 (p = getenv("no_proxy")) || (p = getenv("NO_proxy")))) -	NO_proxy = p; -#ifdef USE_NNTP -    if (!non_null(NNTP_server) && (p = getenv("NNTPSERVER")) != NULL) -	NNTP_server = p; -    if (!non_null(NNTP_mode) && (p = getenv("NNTPMODE")) != NULL) -	NNTP_mode = p; -#endif - -    if (!non_null(Editor) && (p = getenv("EDITOR")) != NULL) -	Editor = p; -    if (!non_null(Mailer) && (p = getenv("MAILER")) != NULL) -	Mailer = p; - -    /* argument search 2 */ -    i = 1; -    while (i < argc) { -	if (*argv[i] == '-') { -	    if (!strcmp("-t", argv[i])) { -		if (++i >= argc) -		    usage(); -		if (atoi(argv[i]) > 0) -		    Tabstop = atoi(argv[i]); -	    } -	    else if (!strcmp("-r", argv[i])) -		ShowEffect = FALSE; -	    else if (!strcmp("-l", argv[i])) { -		if (++i >= argc) -		    usage(); -		if (atoi(argv[i]) > 0) -		    PagerMax = atoi(argv[i]); -	    } -#ifdef USE_M17N -#ifndef DEBIAN			/* XXX: use -o kanjicode={S|J|E} */ -	    else if (!strcmp("-s", argv[i])) -		DisplayCharset = WC_CES_SHIFT_JIS; -	    else if (!strcmp("-j", argv[i])) -		DisplayCharset = WC_CES_ISO_2022_JP; -	    else if (!strcmp("-e", argv[i])) -		DisplayCharset = WC_CES_EUC_JP; -#endif -	    else if (!strncmp("-I", argv[i], 2)) { -		if (argv[i][2] != '\0') -		    p = argv[i] + 2; -		else { -		    if (++i >= argc) -			usage(); -		    p = argv[i]; -		} -		DocumentCharset = wc_guess_charset_short(p, DocumentCharset); -		WcOption.auto_detect = WC_OPT_DETECT_OFF; -		UseContentCharset = FALSE; -	    } -	    else if (!strncmp("-O", argv[i], 2)) { -		if (argv[i][2] != '\0') -		    p = argv[i] + 2; -		else { -		    if (++i >= argc) -			usage(); -		    p = argv[i]; -		} -		DisplayCharset = wc_guess_charset_short(p, DisplayCharset); -	    } -#endif -	    else if (!strcmp("-graph", argv[i])) -		UseGraphicChar = TRUE; -	    else if (!strcmp("-no-graph", argv[i])) -		UseGraphicChar = FALSE; -	    else if (!strcmp("-T", argv[i])) { -		if (++i >= argc) -		    usage(); -		DefaultType = default_type = argv[i]; -	    } -	    else if (!strcmp("-m", argv[i])) -		SearchHeader = search_header = TRUE; -	    else if (!strcmp("-v", argv[i])) -		visual_start = TRUE; -	    else if (!strcmp("-N", argv[i])) -		open_new_tab = TRUE; -#ifdef USE_COLOR -	    else if (!strcmp("-M", argv[i])) -		useColor = FALSE; -#endif				/* USE_COLOR */ -	    else if (!strcmp("-B", argv[i])) -		load_bookmark = TRUE; -	    else if (!strcmp("-bookmark", argv[i])) { -		if (++i >= argc) -		    usage(); -		BookmarkFile = argv[i]; -		if (BookmarkFile[0] != '~' && BookmarkFile[0] != '/') { -		    Str tmp = Strnew_charp(CurrentDir); -		    if (Strlastchar(tmp) != '/') -			Strcat_char(tmp, '/'); -		    Strcat_charp(tmp, BookmarkFile); -		    BookmarkFile = cleanupName(tmp->ptr); -		} -	    } -	    else if (!strcmp("-F", argv[i])) -		RenderFrame = TRUE; -	    else if (!strcmp("-W", argv[i])) { -		if (WrapDefault) -		    WrapDefault = FALSE; -		else -		    WrapDefault = TRUE; -	    } -	    else if (!strcmp("-dump", argv[i])) -		w3m_dump = DUMP_BUFFER; -	    else if (!strcmp("-dump_source", argv[i])) -		w3m_dump = DUMP_SOURCE; -	    else if (!strcmp("-dump_head", argv[i])) -		w3m_dump = DUMP_HEAD; -	    else if (!strcmp("-dump_both", argv[i])) -		w3m_dump = (DUMP_HEAD | DUMP_SOURCE); -	    else if (!strcmp("-dump_extra", argv[i])) -		w3m_dump = (DUMP_HEAD | DUMP_SOURCE | DUMP_EXTRA); -	    else if (!strcmp("-halfdump", argv[i])) -		w3m_dump = DUMP_HALFDUMP; -	    else if (!strcmp("-halfload", argv[i])) { -		w3m_dump = 0; -		w3m_halfload = TRUE; -		DefaultType = default_type = "text/html"; -	    } -	    else if (!strcmp("-backend", argv[i])) { -		w3m_backend = TRUE; -	    } -	    else if (!strcmp("-backend_batch", argv[i])) { -		w3m_backend = TRUE; -		if (++i >= argc) -		    usage(); -		if (!backend_batch_commands) -		    backend_batch_commands = newTextList(); -		pushText(backend_batch_commands, argv[i]); -	    } -	    else if (!strcmp("-cols", argv[i])) { -		if (++i >= argc) -		    usage(); -		COLS = atoi(argv[i]); -	    } -	    else if (!strcmp("-ppc", argv[i])) { -		double ppc; -		if (++i >= argc) -		    usage(); -		ppc = atof(argv[i]); -		if (ppc >= MINIMUM_PIXEL_PER_CHAR && -		    ppc <= MAXIMUM_PIXEL_PER_CHAR) { -		    pixel_per_char = ppc; -		    set_pixel_per_char = TRUE; -		} -	    } -#ifdef USE_IMAGE -	    else if (!strcmp("-ppl", argv[i])) { -		double ppc; -		if (++i >= argc) -		    usage(); -		ppc = atof(argv[i]); -		if (ppc >= MINIMUM_PIXEL_PER_CHAR && -		    ppc <= MAXIMUM_PIXEL_PER_CHAR * 2) { -		    pixel_per_line = ppc; -		    set_pixel_per_line = TRUE; -		} -	    } -#endif -	    else if (!strcmp("-num", argv[i])) -		showLineNum = TRUE; -	    else if (!strcmp("-no-proxy", argv[i])) -		use_proxy = FALSE; -#ifdef INET6 -	    else if (!strcmp("-4", argv[i]) || !strcmp("-6", argv[i])) -		set_param_option(Sprintf("dns_order=%c", argv[i][1])->ptr); -#endif -	    else if (!strcmp("-post", argv[i])) { -		if (++i >= argc) -		    usage(); -		post_file = argv[i]; -	    } -	    else if (!strcmp("-header", argv[i])) { -		Str hs; -		if (++i >= argc) -		    usage(); -		if ((hs = make_optional_header_string(argv[i])) != NULL) { -		    if (header_string == NULL) -			header_string = hs; -		    else -			Strcat(header_string, hs); -		} -		while (argv[i][0]) { -		    argv[i][0] = '\0'; -		    argv[i]++; -		} -	    } -#ifdef USE_MOUSE -	    else if (!strcmp("-no-mouse", argv[i])) { -		use_mouse = FALSE; -	    } -#endif				/* USE_MOUSE */ -#ifdef USE_COOKIE -	    else if (!strcmp("-no-cookie", argv[i])) { -		use_cookie = FALSE; -		accept_cookie = FALSE; -	    } -	    else if (!strcmp("-cookie", argv[i])) { -		use_cookie = TRUE; -		accept_cookie = TRUE; -	    } -#endif				/* USE_COOKIE */ -	    else if (!strcmp("-pauth", argv[i])) { -		if (++i >= argc) -		    usage(); -		proxy_auth_cookie = Strnew_m_charp("Basic ", -						   encodeB(argv[i])->ptr, -						   NULL); -		while (argv[i][0]) { -		    argv[i][0] = '\0'; -		    argv[i]++; -		} -	    } -#ifdef DEBIAN -	    else if (!strcmp("-s", argv[i])) -#else -	    else if (!strcmp("-S", argv[i])) -#endif -		squeezeBlankLine = TRUE; -	    else if (!strcmp("-X", argv[i])) -		Do_not_use_ti_te = TRUE; -	    else if (!strcmp("-title", argv[i])) -		displayTitleTerm = getenv("TERM"); -	    else if (!strncmp("-title=", argv[i], 7)) -		displayTitleTerm = argv[i] + 7; -	    else if (!strcmp("-o", argv[i]) || -		     !strcmp("-show-option", argv[i])) { -		if (!strcmp("-show-option", argv[i]) || ++i >= argc || -		    !strcmp(argv[i], "?")) { -		    show_params(stdout); -		    exit(0); -		} -		if (!set_param_option(argv[i])) { -		    /* option set failed */ -		    /* FIXME: gettextize? */ -		    fprintf(stderr, "%s: bad option\n", argv[i]); -		    show_params_p = 1; -		    usage(); -		} -	    } -	    else if (!strcmp("-dummy", argv[i])) { -		/* do nothing */ -	    } -	    else if (!strcmp("-debug", argv[i])) { -		w3m_debug = TRUE; -	    } -	    else if (!strcmp("-reqlog",argv[i])) { -		w3m_reqlog=rcFile("request.log"); -	    } -	    else { -		usage(); -	    } -	} -	else if (*argv[i] == '+') { -	    line_str = argv[i] + 1; -	} -	else { -	    load_argv[load_argc++] = argv[i]; -	} -	i++; -    } - -#ifdef	__WATT32__ -    if (w3m_debug) -	dbug_init(); -    sock_init(); -#endif - -    FirstTab = NULL; -    LastTab = NULL; -    nTab = 0; -    CurrentTab = NULL; -    CurrentKey = -1; -    if (BookmarkFile == NULL) -	BookmarkFile = rcFile(BOOKMARK); - -    if (!isatty(1) && !w3m_dump) { -	/* redirected output */ -	w3m_dump = DUMP_BUFFER; -    } -    if (w3m_dump) { -	if (COLS == 0) -	    COLS = 80; -    } - -#ifdef USE_BINMODE_STREAM -    setmode(fileno(stdout), O_BINARY); -#endif -    if (!w3m_dump && !w3m_backend) { -	fmInit(); -#ifdef SIGWINCH -	mySignal(SIGWINCH, resize_hook); -#else				/* not SIGWINCH */ -	setlinescols(); -	setupscreen(); -#endif				/* not SIGWINCH */ -    } -#ifdef USE_IMAGE -    else if (w3m_halfdump && displayImage) -	activeImage = TRUE; -#endif - -    sync_with_option(); -#ifdef USE_COOKIE -    initCookie(); -#endif				/* USE_COOKIE */ -#ifdef USE_HISTORY -    if (UseHistory) -	loadHistory(URLHist); -#endif				/* not USE_HISTORY */ - -#ifdef USE_M17N -    wtf_init(DocumentCharset, DisplayCharset); -    /*  if (w3m_dump) -     *    WcOption.pre_conv = WC_TRUE;  -     */ -#endif - -    if (w3m_backend) -	backend(); - -    if (w3m_dump) -	mySignal(SIGINT, SIG_IGN); -#ifdef SIGCHLD -    mySignal(SIGCHLD, sig_chld); -#endif -#ifdef SIGPIPE -    mySignal(SIGPIPE, SigPipe); -#endif - -    orig_GC_warn_proc = GC_set_warn_proc(wrap_GC_warn_proc); -    err_msg = Strnew(); -    if (load_argc == 0) { -	/* no URL specified */ -	if (!isatty(0)) { -	    redin = newFileStream(fdopen(dup(0), "rb"), (void (*)())pclose); -	    newbuf = openGeneralPagerBuffer(redin); -	    dup2(1, 0); -	} -	else if (load_bookmark) { -	    newbuf = loadGeneralFile(BookmarkFile, NULL, NO_REFERER, 0, NULL); -	    if (newbuf == NULL) -		Strcat_charp(err_msg, "w3m: Can't load bookmark.\n"); -	} -	else if (visual_start) { -	    /* FIXME: gettextize? */ -	    Str s_page; -	    s_page = -		Strnew_charp -		("<title>W3M startup page</title><center><b>Welcome to "); -	    Strcat_charp(s_page, "<a href='http://w3m.sourceforge.net/'>"); -	    Strcat_m_charp(s_page, -			   "w3m</a>!<p><p>This is w3m version ", -			   w3m_version, -			   "<br>Written by <a href='mailto:aito@fw.ipsj.or.jp'>Akinori Ito</a>", -			   NULL); -#ifdef DEBIAN -	    Strcat_m_charp(s_page, -			   "<p>Debian package is maintained by <a href='mailto:ukai@debian.or.jp'>Fumitoshi UKAI</a>.", -			   "You can read <a href='file:///usr/share/doc/w3m/'>w3m documents on your local system</a>.", -			   NULL); -#endif				/* DEBIAN */ -	    newbuf = loadHTMLString(s_page); -	    if (newbuf == NULL) -		Strcat_charp(err_msg, "w3m: Can't load string.\n"); -	    else if (newbuf != NO_BUFFER) -		newbuf->bufferprop |= (BP_INTERNAL | BP_NO_URL); -	} -	else if ((p = getenv("HTTP_HOME")) != NULL || -		 (p = getenv("WWW_HOME")) != NULL) { -	    newbuf = loadGeneralFile(p, NULL, NO_REFERER, 0, NULL); -	    if (newbuf == NULL) -		Strcat(err_msg, Sprintf("w3m: Can't load %s.\n", p)); -	    else if (newbuf != NO_BUFFER) -		pushHashHist(URLHist, parsedURL2Str(&newbuf->currentURL)->ptr); -	} -	else { -	    if (fmInitialized) -		fmTerm(); -	    usage(); -	} -	if (newbuf == NULL) { -	    if (fmInitialized) -		fmTerm(); -	    if (err_msg->length) -		fprintf(stderr, "%s", err_msg->ptr); -	    w3m_exit(2); -	} -	i = -1; -    } -    else { -	i = 0; -    } -    for (; i < load_argc; i++) { -	if (i >= 0) { -	    SearchHeader = search_header; -	    DefaultType = default_type; -	    if (w3m_dump == DUMP_HEAD) { -		request = New(FormList); -		request->method = FORM_METHOD_HEAD; -		newbuf = -		    loadGeneralFile(load_argv[i], NULL, NO_REFERER, 0, -				    request); -	    } -	    else { -		if (post_file && i == 0) { -		    FILE *fp; -		    Str body; -		    if (!strcmp(post_file, "-")) -			fp = stdin; -		    else -			fp = fopen(post_file, "r"); -		    if (fp == NULL) { -			/* FIXME: gettextize? */ -			Strcat(err_msg, -			       Sprintf("w3m: Can't open %s.\n", post_file)); -			continue; -		    } -		    body = Strfgetall(fp); -		    if (fp != stdin) -			fclose(fp); -		    request = -			newFormList(NULL, "post", NULL, NULL, NULL, NULL, -				    NULL); -		    request->body = body->ptr; -		    request->boundary = NULL; -		    request->length = body->length; -		} -		else { -		    request = NULL; -		} -		newbuf = -		    loadGeneralFile(load_argv[i], NULL, NO_REFERER, 0, -				    request); -	    } -	    if (newbuf == NULL) { -		/* FIXME: gettextize? */ -		Strcat(err_msg, -		       Sprintf("w3m: Can't load %s.\n", load_argv[i])); -		continue; -	    } -	    else if (newbuf == NO_BUFFER) -		continue; -	    switch (newbuf->real_scheme) { -	    case SCM_MAILTO: -		break; -	    case SCM_LOCAL: -	    case SCM_LOCAL_CGI: -		unshiftHist(LoadHist, conv_from_system(load_argv[i])); -	    default: -		pushHashHist(URLHist, parsedURL2Str(&newbuf->currentURL)->ptr); -		break; -	    } -	} -	else if (newbuf == NO_BUFFER) -	    continue; -	if (newbuf->pagerSource || -	    (newbuf->real_scheme == SCM_LOCAL && newbuf->header_source && -	     newbuf->currentURL.file && strcmp(newbuf->currentURL.file, "-"))) -	    newbuf->search_header = search_header; -	if (CurrentTab == NULL) { -	    FirstTab = LastTab = CurrentTab = newTab(); -	    nTab = 1; -	    Firstbuf = Currentbuf = newbuf; -	} -	else if (open_new_tab) { -	    _newT(); -	    Currentbuf->nextBuffer = newbuf; -	    delBuffer(Currentbuf); -	} -	else { -	    Currentbuf->nextBuffer = newbuf; -	    Currentbuf = newbuf; -	} -	if (!w3m_dump || w3m_dump == DUMP_BUFFER) { -	    if (Currentbuf->frameset != NULL && RenderFrame) -		rFrame(); -	} -	if (w3m_dump) -	    do_dump(Currentbuf); -	else { -	    Currentbuf = newbuf; -#ifdef USE_BUFINFO -	    saveBufferInfo(); -#endif -	} -    } -    if (w3m_dump) { -	if (err_msg->length) -	    fprintf(stderr, "%s", err_msg->ptr); -#ifdef USE_COOKIE -	save_cookies(); -#endif				/* USE_COOKIE */ -	w3m_exit(0); -    } - -    if (add_download_list) { -	add_download_list = FALSE; -	CurrentTab = LastTab; -	if (!FirstTab) { -	    FirstTab = LastTab = CurrentTab = newTab(); -	    nTab = 1; -	} -	if (!Firstbuf || Firstbuf == NO_BUFFER) { -	    Firstbuf = Currentbuf = newBuffer(INIT_BUFFER_WIDTH); -	    Currentbuf->bufferprop = BP_INTERNAL | BP_NO_URL; -	    Currentbuf->buffername = DOWNLOAD_LIST_TITLE; -	} -	else -	    Currentbuf = Firstbuf; -	ldDL(); -    } -    else -	CurrentTab = FirstTab; -    if (!FirstTab || !Firstbuf || Firstbuf == NO_BUFFER) { -	if (newbuf == NO_BUFFER) { -	    if (fmInitialized) -		/* FIXME: gettextize? */ -		inputChar("Hit any key to quit w3m:"); -	} -	if (fmInitialized) -	    fmTerm(); -	if (err_msg->length) -	    fprintf(stderr, "%s", err_msg->ptr); -	if (newbuf == NO_BUFFER) { -#ifdef USE_COOKIE -	    save_cookies(); -#endif				/* USE_COOKIE */ -	    if (!err_msg->length) -		w3m_exit(0); -	} -	w3m_exit(2); -    } -    if (err_msg->length) -	disp_message_nsec(err_msg->ptr, FALSE, 1, TRUE, FALSE); - -    SearchHeader = FALSE; -    DefaultType = NULL; -#ifdef USE_M17N -    UseContentCharset = TRUE; -    WcOption.auto_detect = auto_detect; -#endif - -    Currentbuf = Firstbuf; -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -    if (line_str) { -	_goLine(line_str); -    } -    for (;;) { -	if (add_download_list) { -	    add_download_list = FALSE; -	    ldDL(); -	} -	if (Currentbuf->submit) { -	    Anchor *a = Currentbuf->submit; -	    Currentbuf->submit = NULL; -	    gotoLine(Currentbuf, a->start.line); -	    Currentbuf->pos = a->start.pos; -	    _followForm(TRUE); -	    continue; -	} -	/* event processing */ -	if (CurrentEvent) { -	    CurrentKey = -1; -	    CurrentKeyData = NULL; -	    CurrentCmdData = (char *)CurrentEvent->data; -	    w3mFuncList[CurrentEvent->cmd].func(); -	    CurrentCmdData = NULL; -	    CurrentEvent = CurrentEvent->next; -	    continue; -	} -	/* get keypress event */ -#ifdef USE_ALARM -	if (Currentbuf->event) { -	    if (Currentbuf->event->status != AL_UNSET) { -		CurrentAlarm = Currentbuf->event; -		if (CurrentAlarm->sec == 0) {	/* refresh (0sec) */ -		    Currentbuf->event = NULL; -		    CurrentKey = -1; -		    CurrentKeyData = NULL; -		    CurrentCmdData = (char *)CurrentAlarm->data; -		    w3mFuncList[CurrentAlarm->cmd].func(); -		    CurrentCmdData = NULL; -		    continue; -		} -	    } -	    else -		Currentbuf->event = NULL; -	} -	if (!Currentbuf->event) -	    CurrentAlarm = &DefaultAlarm; -#endif -#ifdef USE_MOUSE -	mouse_action.in_action = FALSE; -	if (use_mouse) -	    mouse_active(); -#endif				/* USE_MOUSE */ -#ifdef USE_ALARM -	if (CurrentAlarm->sec > 0) { -	    mySignal(SIGALRM, SigAlarm); -	    alarm(CurrentAlarm->sec); -	} -#endif -#ifdef SIGWINCH -	mySignal(SIGWINCH, resize_hook); -#endif -#ifdef USE_IMAGE -	if (activeImage && displayImage && Currentbuf->img && -	    !Currentbuf->image_loaded) { -	    do { -#ifdef SIGWINCH -		if (need_resize_screen) -		    resize_screen(); -#endif -		loadImage(Currentbuf, IMG_FLAG_NEXT); -	    } while (sleep_till_anykey(1, 0) <= 0); -	} -#ifdef SIGWINCH -	else -#endif -#endif -#ifdef SIGWINCH -	{ -	    do { -		if (need_resize_screen) -		    resize_screen(); -	    } while (sleep_till_anykey(1, 0) <= 0); -	} -#endif -	c = getch(); -#ifdef USE_ALARM -	if (CurrentAlarm->sec > 0) { -	    alarm(0); -	} -#endif -#ifdef USE_MOUSE -	if (use_mouse) -	    mouse_inactive(); -#endif				/* USE_MOUSE */ -	if (IS_ASCII(c)) {	/* Ascii */ -	    if(((prec_num && c == '0') || '1' <= c) && (c <= '9')) { -		prec_num = prec_num * 10 + (int)(c - '0'); -		if (prec_num > PREC_LIMIT) -	    	prec_num = PREC_LIMIT; -	    } -	    else { -		set_buffer_environ(Currentbuf); -		save_buffer_position(Currentbuf); -		keyPressEventProc((int)c); -		prec_num = 0; -	    } -	} -	prev_key = CurrentKey; -	CurrentKey = -1; -	CurrentKeyData = NULL; -    } -} - -static void -keyPressEventProc(int c) -{ -    CurrentKey = c; -    w3mFuncList[(int)GlobalKeymap[c]].func(); -} - -void -pushEvent(int cmd, void *data) -{ -    Event *event; - -    event = New(Event); -    event->cmd = cmd; -    event->data = data; -    event->next = NULL; -    if (CurrentEvent) -	LastEvent->next = event; -    else -	CurrentEvent = event; -    LastEvent = event; -} - -static void -dump_source(Buffer *buf) -{ -    FILE *f; -    char c; -    if (buf->sourcefile == NULL) -	return; -    f = fopen(buf->sourcefile, "r"); -    if (f == NULL) -	return; -    while (c = fgetc(f), !feof(f)) { -	putchar(c); -    } -    fclose(f); -} - -static void -dump_head(Buffer *buf) -{ -    TextListItem *ti; - -    if (buf->document_header == NULL) { -	if (w3m_dump & DUMP_EXTRA) -	    printf("\n"); -	return; -    } -    for (ti = buf->document_header->first; ti; ti = ti->next) { -#ifdef USE_M17N -	printf("%s", -	       wc_conv_strict(ti->ptr, InnerCharset, -			      buf->document_charset)->ptr); -#else -	printf("%s", ti->ptr); -#endif -    } -    puts(""); -} - -static void -dump_extra(Buffer *buf) -{ -    printf("W3m-current-url: %s\n", parsedURL2Str(&buf->currentURL)->ptr); -    if (buf->baseURL) -	printf("W3m-base-url: %s\n", parsedURL2Str(buf->baseURL)->ptr); -#ifdef USE_M17N -    printf("W3m-document-charset: %s\n", -	   wc_ces_to_charset(buf->document_charset)); -#endif -#ifdef USE_SSL -    if (buf->ssl_certificate) { -	Str tmp = Strnew(); -	char *p; -	for (p = buf->ssl_certificate; *p; p++) { -	    Strcat_char(tmp, *p); -	    if (*p == '\n') { -		for (; *(p + 1) == '\n'; p++) ; -		if (*(p + 1)) -		    Strcat_char(tmp, '\t'); -	    } -	} -	if (Strlastchar(tmp) != '\n') -	    Strcat_char(tmp, '\n'); -	printf("W3m-ssl-certificate: %s", tmp->ptr); -    } -#endif -} - -static void -do_dump(Buffer *buf) -{ -    MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; - -    prevtrap = mySignal(SIGINT, intTrap); -    if (SETJMP(IntReturn) != 0) { -	mySignal(SIGINT, prevtrap); -	return; -    } -    if (w3m_dump & DUMP_EXTRA) -	dump_extra(buf); -    if (w3m_dump & DUMP_HEAD) -	dump_head(buf); -    if (w3m_dump & DUMP_SOURCE) -	dump_source(buf); -    if (w3m_dump == DUMP_BUFFER) -	saveBuffer(buf, stdout, FALSE); -    mySignal(SIGINT, prevtrap); -} - -DEFUN(nulcmd, NOTHING NULL @@@, "Do nothing") -{				/* do nothing */ -} - -#ifdef __EMX__ -DEFUN(pcmap, PCMAP, "pcmap") -{ -    w3mFuncList[(int)PcKeymap[(int)getch()]].func(); -} -#else				/* not __EMX__ */ -void -pcmap(void) -{ -} -#endif - -static void -escKeyProc(int c, int esc, unsigned char *map) -{ -    if (CurrentKey >= 0 && CurrentKey & K_MULTI) { -	unsigned char **mmap; -	mmap = (unsigned char **)getKeyData(MULTI_KEY(CurrentKey)); -	if (!mmap) -	    return; -	switch (esc) { -	case K_ESCD: -	    map = mmap[3]; -	    break; -	case K_ESCB: -	    map = mmap[2]; -	    break; -	case K_ESC: -	    map = mmap[1]; -	    break; -	default: -	    map = mmap[0]; -	    break; -	} -	esc |= (CurrentKey & ~0xFFFF); -    } -    CurrentKey = esc | c; -    w3mFuncList[(int)map[c]].func(); -} - -DEFUN(escmap, ESCMAP, "ESC map") -{ -    char c; -    c = getch(); -    if (IS_ASCII(c)) -	escKeyProc((int)c, K_ESC, EscKeymap); -} - -DEFUN(escbmap, ESCBMAP, "ESC [ map") -{ -    char c; -    c = getch(); -    if (IS_DIGIT(c)) { -	escdmap(c); -	return; -    } -    if (IS_ASCII(c)) -	escKeyProc((int)c, K_ESCB, EscBKeymap); -} - -void -escdmap(char c) -{ -    int d; -    d = (int)c - (int)'0'; -    c = getch(); -    if (IS_DIGIT(c)) { -	d = d * 10 + (int)c - (int)'0'; -	c = getch(); -    } -    if (c == '~') -	escKeyProc((int)d, K_ESCD, EscDKeymap); -} - -DEFUN(multimap, MULTIMAP, "multimap") -{ -    char c; -    c = getch(); -    if (IS_ASCII(c)) { -	CurrentKey = K_MULTI | (CurrentKey << 16) | c; -	escKeyProc((int)c, 0, NULL); -    } -} - -void -tmpClearBuffer(Buffer *buf) -{ -    if (buf->pagerSource == NULL && writeBufferCache(buf) == 0) { -	buf->firstLine = NULL; -	buf->topLine = NULL; -	buf->currentLine = NULL; -	buf->lastLine = NULL; -    } -} - -static Str currentURL(void); - -#ifdef USE_BUFINFO -void -saveBufferInfo() -{ -    FILE *fp; - -    if (w3m_dump) -	return; -    if ((fp = fopen(rcFile("bufinfo"), "w")) == NULL) { -	return; -    } -    fprintf(fp, "%s\n", currentURL()->ptr); -    fclose(fp); -} -#endif - -static void -pushBuffer(Buffer *buf) -{ -    Buffer *b; - -#ifdef USE_IMAGE -    deleteImage(Currentbuf); -#endif -    if (clear_buffer) -	tmpClearBuffer(Currentbuf); -    if (Firstbuf == Currentbuf) { -	buf->nextBuffer = Firstbuf; -	Firstbuf = Currentbuf = buf; -    } -    else if ((b = prevBuffer(Firstbuf, Currentbuf)) != NULL) { -	b->nextBuffer = buf; -	buf->nextBuffer = Currentbuf; -	Currentbuf = buf; -    } -#ifdef USE_BUFINFO -    saveBufferInfo(); -#endif - -} - -static void -delBuffer(Buffer *buf) -{ -    if (buf == NULL) -	return; -    if (Currentbuf == buf) -	Currentbuf = buf->nextBuffer; -    Firstbuf = deleteBuffer(Firstbuf, buf); -    if (!Currentbuf) -	Currentbuf = Firstbuf; -} - -static void -repBuffer(Buffer *oldbuf, Buffer *buf) -{ -    Firstbuf = replaceBuffer(Firstbuf, oldbuf, buf); -    Currentbuf = buf; -} - - -MySignalHandler -intTrap(SIGNAL_ARG) -{				/* Interrupt catcher */ -    LONGJMP(IntReturn, 0); -    SIGNAL_RETURN; -} - -#ifdef SIGWINCH -static MySignalHandler -resize_hook(SIGNAL_ARG) -{ -    need_resize_screen = TRUE; -    mySignal(SIGWINCH, resize_hook); -    SIGNAL_RETURN; -} - -static void -resize_screen(void) -{ -    need_resize_screen = FALSE; -    setlinescols(); -    setupscreen(); -    if (CurrentTab) -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -} -#endif				/* SIGWINCH */ - -#ifdef SIGPIPE -static MySignalHandler -SigPipe(SIGNAL_ARG) -{ -#ifdef USE_MIGEMO -    init_migemo(); -#endif -    mySignal(SIGPIPE, SigPipe); -    SIGNAL_RETURN; -} -#endif - -/*  - * Command functions: These functions are called with a keystroke. - */ - -#define MAX(a, b)  ((a) > (b) ? (a) : (b)) -#define MIN(a, b)  ((a) < (b) ? (a) : (b)) - -static void -nscroll(int n, int mode) -{ -    Buffer *buf = Currentbuf; -    Line *top = buf->topLine, *cur = buf->currentLine; -    int lnum, tlnum, llnum, diff_n; - -    if (buf->firstLine == NULL) -	return; -    lnum = cur->linenumber; -    buf->topLine = lineSkip(buf, top, n, FALSE); -    if (buf->topLine == top) { -	lnum += n; -	if (lnum < buf->topLine->linenumber) -	    lnum = buf->topLine->linenumber; -	else if (lnum > buf->lastLine->linenumber) -	    lnum = buf->lastLine->linenumber; -    } -    else { -	tlnum = buf->topLine->linenumber; -	llnum = buf->topLine->linenumber + buf->LINES - 1; -	if (nextpage_topline) -	    diff_n = 0; -	else -	    diff_n = n - (tlnum - top->linenumber); -	if (lnum < tlnum) -	    lnum = tlnum + diff_n; -	if (lnum > llnum) -	    lnum = llnum + diff_n; -    } -    gotoLine(buf, lnum); -    arrangeLine(buf); -    if (n > 0) { -	if (buf->currentLine->bpos && -	    buf->currentLine->bwidth >= buf->currentColumn + buf->visualpos) -	    cursorDown(buf, 1); -	else { -	    while (buf->currentLine->next && buf->currentLine->next->bpos && -		   buf->currentLine->bwidth + buf->currentLine->width < -		   buf->currentColumn + buf->visualpos) -		cursorDown0(buf, 1); -	} -    } -    else { -	if (buf->currentLine->bwidth + buf->currentLine->width < -	    buf->currentColumn + buf->visualpos) -	    cursorUp(buf, 1); -	else { -	    while (buf->currentLine->prev && buf->currentLine->bpos && -		   buf->currentLine->bwidth >= -		   buf->currentColumn + buf->visualpos) -		cursorUp0(buf, 1); -	} -    } -    displayBuffer(buf, mode); -} - -/* Move page forward */ -DEFUN(pgFore, NEXT_PAGE, "Move to next page") -{ -    if (vi_prec_num) -	nscroll(searchKeyNum() * (Currentbuf->LINES - 1), B_NORMAL); -    else -	nscroll(prec_num ? searchKeyNum() : searchKeyNum() -		* (Currentbuf->LINES - 1), prec_num ? B_SCROLL : B_NORMAL); -} - -/* Move page backward */ -DEFUN(pgBack, PREV_PAGE, "Move to previous page") -{ -    if (vi_prec_num) -	nscroll(-searchKeyNum() * (Currentbuf->LINES - 1), B_NORMAL); -    else -	nscroll(-(prec_num ? searchKeyNum() : searchKeyNum() -		  * (Currentbuf->LINES - 1)), prec_num ? B_SCROLL : B_NORMAL); -} - -/* 1 line up */ -DEFUN(lup1, UP, "Scroll up one line") -{ -    nscroll(searchKeyNum(), B_SCROLL); -} - -/* 1 line down */ -DEFUN(ldown1, DOWN, "Scroll down one line") -{ -    nscroll(-searchKeyNum(), B_SCROLL); -} - -/* move cursor position to the center of screen */ -DEFUN(ctrCsrV, CENTER_V, "Move to the center column") -{ -    int offsety; -    if (Currentbuf->firstLine == NULL) -	return; -    offsety = Currentbuf->LINES / 2 - Currentbuf->cursorY; -    if (offsety != 0) { -#if 0 -	Currentbuf->currentLine = lineSkip(Currentbuf, -					   Currentbuf->currentLine, offsety, -					   FALSE); -#endif -	Currentbuf->topLine = -	    lineSkip(Currentbuf, Currentbuf->topLine, -offsety, FALSE); -	arrangeLine(Currentbuf); -	displayBuffer(Currentbuf, B_NORMAL); -    } -} - -DEFUN(ctrCsrH, CENTER_H, "Move to the center line") -{ -    int offsetx; -    if (Currentbuf->firstLine == NULL) -	return; -    offsetx = Currentbuf->cursorX - Currentbuf->COLS / 2; -    if (offsetx != 0) { -	columnSkip(Currentbuf, offsetx); -	arrangeCursor(Currentbuf); -	displayBuffer(Currentbuf, B_NORMAL); -    } -} - -/* Redraw screen */ -DEFUN(rdrwSc, REDRAW, "Redraw screen") -{ -    clear(); -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -static void -clear_mark(Line *l) -{ -    int pos; -    if (!l) -	return; -    for (pos = 0; pos < l->size; pos++) -	l->propBuf[pos] &= ~PE_MARK; -} - -/* search by regular expression */ -static int -srchcore(char *volatile str, int (*func) (Buffer *, char *)) -{ -    MySignalHandler(*prevtrap) (); -    volatile int i, result = SR_NOTFOUND; - -    if (str != NULL && str != SearchString) -	SearchString = str; -    if (SearchString == NULL || *SearchString == '\0') -	return SR_NOTFOUND; - -    str = conv_search_string(SearchString, DisplayCharset); -    prevtrap = mySignal(SIGINT, intTrap); -    crmode(); -    if (SETJMP(IntReturn) == 0) { -	for (i = 0; i < PREC_NUM; i++) { -	    result = func(Currentbuf, str); -	    if (i < PREC_NUM - 1 && result & SR_FOUND) -		clear_mark(Currentbuf->currentLine); -	} -    } -    mySignal(SIGINT, prevtrap); -    term_raw(); -    return result; -} - -static void -disp_srchresult(int result, char *prompt, char *str) -{ -    if (str == NULL) -	str = ""; -    if (result & SR_NOTFOUND) -	disp_message(Sprintf("Not found: %s", str)->ptr, TRUE); -    else if (result & SR_WRAPPED) -	disp_message(Sprintf("Search wrapped: %s", str)->ptr, TRUE); -    else if (show_srch_str) -	disp_message(Sprintf("%s%s", prompt, str)->ptr, TRUE); -} - -static int -dispincsrch(int ch, Str buf, Lineprop *prop) -{ -    static Buffer sbuf; -    static Line *currentLine; -    static int pos; -    char *str; -    int do_next_search = FALSE; - -    if (ch == 0 && buf == NULL) { -	SAVE_BUFPOSITION(&sbuf);	/* search starting point */ -	currentLine = sbuf.currentLine; -	pos = sbuf.pos; -	return -1; -    } - -    str = buf->ptr; -    switch (ch) { -    case 022:			/* C-r */ -	searchRoutine = backwardSearch; -	do_next_search = TRUE; -	break; -    case 023:			/* C-s */ -	searchRoutine = forwardSearch; -	do_next_search = TRUE; -	break; - -#ifdef USE_MIGEMO -    case 034: -	migemo_active = -migemo_active; -	goto done; -#endif - -    default: -	if (ch >= 0) -	    return ch;		/* use InputKeymap */ -    } - -    if (do_next_search) { -	if (*str) { -	    if (searchRoutine == forwardSearch) -		Currentbuf->pos += 1; -	    SAVE_BUFPOSITION(&sbuf); -	    if (srchcore(str, searchRoutine) == SR_NOTFOUND -		&& searchRoutine == forwardSearch) { -		Currentbuf->pos -= 1; -		SAVE_BUFPOSITION(&sbuf); -	    } -	    arrangeCursor(Currentbuf); -	    displayBuffer(Currentbuf, B_FORCE_REDRAW); -	    clear_mark(Currentbuf->currentLine); -	    return -1; -	} -	else -	    return 020;		/* _prev completion for C-s C-s */ -    } -    else if (*str) { -	RESTORE_BUFPOSITION(&sbuf); -	arrangeCursor(Currentbuf); -	srchcore(str, searchRoutine); -	arrangeCursor(Currentbuf); -	currentLine = Currentbuf->currentLine; -	pos = Currentbuf->pos; -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -    clear_mark(Currentbuf->currentLine); -#ifdef USE_MIGEMO -  done: -    while (*str++ != '\0') { -	if (migemo_active > 0) -	    *prop++ |= PE_UNDER; -	else -	    *prop++ &= ~PE_UNDER; -    } -#endif -    return -1; -} - -void -isrch(int (*func) (Buffer *, char *), char *prompt) -{ -    char *str; -    Buffer sbuf; -    SAVE_BUFPOSITION(&sbuf); -    dispincsrch(0, NULL, NULL);	/* initialize incremental search state */ - -    searchRoutine = func; -    str = inputLineHistSearch(prompt, NULL, IN_STRING, TextHist, dispincsrch); -    if (str == NULL) { -	RESTORE_BUFPOSITION(&sbuf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -void -srch(int (*func) (Buffer *, char *), char *prompt) -{ -    char *str; -    int result; -    int disp = FALSE; -    int pos; - -    str = searchKeyData(); -    if (str == NULL || *str == '\0') { -	str = inputStrHist(prompt, NULL, TextHist); -	if (str != NULL && *str == '\0') -	    str = SearchString; -	if (str == NULL) { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -	disp = TRUE; -    } -    pos = Currentbuf->pos; -    if (func == forwardSearch) -	Currentbuf->pos += 1; -    result = srchcore(str, func); -    if (result & SR_FOUND) -	clear_mark(Currentbuf->currentLine); -    else -	Currentbuf->pos = pos; -    displayBuffer(Currentbuf, B_NORMAL); -    if (disp) -	disp_srchresult(result, prompt, str); -    searchRoutine = func; -} - -/* Search regular expression forward */ - -DEFUN(srchfor, SEARCH SEARCH_FORE WHEREIS, "Search forward") -{ -    srch(forwardSearch, "Forward: "); -} - -DEFUN(isrchfor, ISEARCH, "Incremental search forward") -{ -    isrch(forwardSearch, "I-search: "); -} - -/* Search regular expression backward */ - -DEFUN(srchbak, SEARCH_BACK, "Search backward") -{ -    srch(backwardSearch, "Backward: "); -} - -DEFUN(isrchbak, ISEARCH_BACK, "Incremental search backward") -{ -    isrch(backwardSearch, "I-search backward: "); -} - -static void -srch_nxtprv(int reverse) -{ -    int result; -    /* *INDENT-OFF* */ -    static int (*routine[2]) (Buffer *, char *) = { -	forwardSearch, backwardSearch -    }; -    /* *INDENT-ON* */ - -    if (searchRoutine == NULL) { -	/* FIXME: gettextize? */ -	disp_message("No previous regular expression", TRUE); -	return; -    } -    if (reverse != 0) -	reverse = 1; -    if (searchRoutine == backwardSearch) -	reverse ^= 1; -    if (reverse == 0) -	Currentbuf->pos += 1; -    result = srchcore(SearchString, routine[reverse]); -    if (result & SR_FOUND) -	clear_mark(Currentbuf->currentLine); -    displayBuffer(Currentbuf, B_NORMAL); -    disp_srchresult(result, (reverse ? "Backward: " : "Forward: "), -		    SearchString); -} - -/* Search next matching */ -DEFUN(srchnxt, SEARCH_NEXT, "Search next regexp") -{ -    srch_nxtprv(0); -} - -/* Search previous matching */ -DEFUN(srchprv, SEARCH_PREV, "Search previous regexp") -{ -    srch_nxtprv(1); -} - -static void -shiftvisualpos(Buffer *buf, int shift) -{ -    Line *l = buf->currentLine; -    buf->visualpos -= shift; -    if (buf->visualpos - l->bwidth >= buf->COLS) -	buf->visualpos = l->bwidth + buf->COLS - 1; -    else if (buf->visualpos - l->bwidth < 0) -	buf->visualpos = l->bwidth; -    arrangeLine(buf); -    if (buf->visualpos - l->bwidth == -shift && buf->cursorX == 0) -	buf->visualpos = l->bwidth; -} - -/* Shift screen left */ -DEFUN(shiftl, SHIFT_LEFT, "Shift screen left") -{ -    int column; - -    if (Currentbuf->firstLine == NULL) -	return; -    column = Currentbuf->currentColumn; -    columnSkip(Currentbuf, searchKeyNum() * (-Currentbuf->COLS + 1) + 1); -    shiftvisualpos(Currentbuf, Currentbuf->currentColumn - column); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* Shift screen right */ -DEFUN(shiftr, SHIFT_RIGHT, "Shift screen right") -{ -    int column; - -    if (Currentbuf->firstLine == NULL) -	return; -    column = Currentbuf->currentColumn; -    columnSkip(Currentbuf, searchKeyNum() * (Currentbuf->COLS - 1) - 1); -    shiftvisualpos(Currentbuf, Currentbuf->currentColumn - column); -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(col1R, RIGHT, "Shift screen one column right") -{ -    Buffer *buf = Currentbuf; -    Line *l = buf->currentLine; -    int j, column, n = searchKeyNum(); - -    if (l == NULL) -	return; -    for (j = 0; j < n; j++) { -	column = buf->currentColumn; -	columnSkip(Currentbuf, 1); -	if (column == buf->currentColumn) -	    break; -	shiftvisualpos(Currentbuf, 1); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(col1L, LEFT, "Shift screen one column") -{ -    Buffer *buf = Currentbuf; -    Line *l = buf->currentLine; -    int j, n = searchKeyNum(); - -    if (l == NULL) -	return; -    for (j = 0; j < n; j++) { -	if (buf->currentColumn == 0) -	    break; -	columnSkip(Currentbuf, -1); -	shiftvisualpos(Currentbuf, -1); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(setEnv, SETENV, "Set environment variable") -{ -    char *env; -    char *var, *value; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    env = searchKeyData(); -    if (env == NULL || *env == '\0' || strchr(env, '=') == NULL) { -	if (env != NULL && *env != '\0') -	    env = Sprintf("%s=", env)->ptr; -	env = inputStrHist("Set environ: ", env, TextHist); -	if (env == NULL || *env == '\0') { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    if ((value = strchr(env, '=')) != NULL && value > env) { -	var = allocStr(env, value - env); -	value++; -	set_environ(var, value); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(pipeBuf, PIPE_BUF, "Send rendered document to pipe") -{ -    Buffer *buf; -    char *cmd, *tmpf; -    FILE *f; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    cmd = searchKeyData(); -    if (cmd == NULL || *cmd == '\0') { -	/* FIXME: gettextize? */ -	cmd = inputLineHist("Pipe buffer to: ", "", IN_COMMAND, ShellHist); -    } -    if (cmd != NULL) -	cmd = conv_to_system(cmd); -    if (cmd == NULL || *cmd == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    tmpf = tmpfname(TMPF_DFL, NULL)->ptr; -    f = fopen(tmpf, "w"); -    if (f == NULL) { -	/* FIXME: gettextize? */ -	disp_message(Sprintf("Can't save buffer to %s", cmd)->ptr, TRUE); -	return; -    } -    saveBuffer(Currentbuf, f, TRUE); -    fclose(f); -    buf = getpipe(myExtCommand(cmd, shell_quote(tmpf), TRUE)->ptr); -    if (buf == NULL) { -	disp_message("Execution failed", TRUE); -	return; -    } -    else { -	buf->filename = cmd; -	buf->buffername = Sprintf("%s %s", PIPEBUFFERNAME, -				  conv_from_system(cmd))->ptr; -	buf->bufferprop |= (BP_INTERNAL | BP_NO_URL); -	if (buf->type == NULL) -	    buf->type = "text/plain"; -	buf->currentURL.file = "-"; -	pushBuffer(buf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Execute shell command and read output ac pipe. */ -DEFUN(pipesh, PIPE_SHELL, "Execute shell command and browse") -{ -    Buffer *buf; -    char *cmd; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    cmd = searchKeyData(); -    if (cmd == NULL || *cmd == '\0') { -	cmd = inputLineHist("(read shell[pipe])!", "", IN_COMMAND, ShellHist); -    } -    if (cmd != NULL) -	cmd = conv_to_system(cmd); -    if (cmd == NULL || *cmd == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    buf = getpipe(cmd); -    if (buf == NULL) { -	disp_message("Execution failed", TRUE); -	return; -    } -    else { -	buf->bufferprop |= (BP_INTERNAL | BP_NO_URL); -	if (buf->type == NULL) -	    buf->type = "text/plain"; -	pushBuffer(buf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Execute shell command and load entire output to buffer */ -DEFUN(readsh, READ_SHELL, "Execute shell command and load") -{ -    Buffer *buf; -    MySignalHandler(*prevtrap) (); -    char *cmd; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    cmd = searchKeyData(); -    if (cmd == NULL || *cmd == '\0') { -	cmd = inputLineHist("(read shell)!", "", IN_COMMAND, ShellHist); -    } -    if (cmd != NULL) -	cmd = conv_to_system(cmd); -    if (cmd == NULL || *cmd == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    prevtrap = mySignal(SIGINT, intTrap); -    crmode(); -    buf = getshell(cmd); -    mySignal(SIGINT, prevtrap); -    term_raw(); -    if (buf == NULL) { -	/* FIXME: gettextize? */ -	disp_message("Execution failed", TRUE); -	return; -    } -    else { -	buf->bufferprop |= (BP_INTERNAL | BP_NO_URL); -	if (buf->type == NULL) -	    buf->type = "text/plain"; -	pushBuffer(buf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Execute shell command */ -DEFUN(execsh, EXEC_SHELL SHELL, "Execute shell command") -{ -    char *cmd; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    cmd = searchKeyData(); -    if (cmd == NULL || *cmd == '\0') { -	cmd = inputLineHist("(exec shell)!", "", IN_COMMAND, ShellHist); -    } -    if (cmd != NULL) -	cmd = conv_to_system(cmd); -    if (cmd != NULL && *cmd != '\0') { -	fmTerm(); -	printf("\n"); -	system(cmd); -	/* FIXME: gettextize? */ -	printf("\n[Hit any key]"); -	fflush(stdout); -	fmInit(); -	getch(); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Load file */ -DEFUN(ldfile, LOAD, "Load local file") -{ -    char *fn; - -    fn = searchKeyData(); -    if (fn == NULL || *fn == '\0') { -	/* FIXME: gettextize? */ -	fn = inputFilenameHist("(Load)Filename? ", NULL, LoadHist); -    } -    if (fn != NULL) -	fn = conv_to_system(fn); -    if (fn == NULL || *fn == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    cmd_loadfile(fn); -} - -/* Load help file */ -DEFUN(ldhelp, HELP, "View help") -{ -#ifdef USE_HELP_CGI -    char *lang; -    int n; -    Str tmp; - -    lang = AcceptLang; -    n = strcspn(lang, ";, \t"); -    tmp = Sprintf("file:///$LIB/" HELP_CGI CGI_EXTENSION "?version=%s&lang=%s", -		  Str_form_quote(Strnew_charp(w3m_version))->ptr, -		  Str_form_quote(Strnew_charp_n(lang, n))->ptr); -    cmd_loadURL(tmp->ptr, NULL, NO_REFERER, NULL); -#else -    cmd_loadURL(helpFile(HELP_FILE), NULL, NO_REFERER, NULL); -#endif -} - -static void -cmd_loadfile(char *fn) -{ -    Buffer *buf; - -    buf = loadGeneralFile(file_to_url(fn), NULL, NO_REFERER, 0, NULL); -    if (buf == NULL) { -	/* FIXME: gettextize? */ -	char *emsg = Sprintf("%s not found", conv_from_system(fn))->ptr; -	disp_err_message(emsg, FALSE); -    } -    else if (buf != NO_BUFFER) { -	pushBuffer(buf); -	if (RenderFrame && Currentbuf->frameset != NULL) -	    rFrame(); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* Move cursor left */ -static void -_movL(int n) -{ -    int i, m = searchKeyNum(); -    if (Currentbuf->firstLine == NULL) -	return; -    for (i = 0; i < m; i++) -	cursorLeft(Currentbuf, n); -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(movL, MOVE_LEFT, -      "Move cursor left (a half screen shift at the left edge)") -{ -    _movL(Currentbuf->COLS / 2); -} - -DEFUN(movL1, MOVE_LEFT1, "Move cursor left (1 columns shift at the left edge)") -{ -    _movL(1); -} - -/* Move cursor downward */ -static void -_movD(int n) -{ -    int i, m = searchKeyNum(); -    if (Currentbuf->firstLine == NULL) -	return; -    for (i = 0; i < m; i++) -	cursorDown(Currentbuf, n); -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(movD, MOVE_DOWN, -      "Move cursor down (a half screen scroll at the end of screen)") -{ -    _movD((Currentbuf->LINES + 1) / 2); -} - -DEFUN(movD1, MOVE_DOWN1, -      "Move cursor down (1 line scroll at the end of screen)") -{ -    _movD(1); -} - -/* move cursor upward */ -static void -_movU(int n) -{ -    int i, m = searchKeyNum(); -    if (Currentbuf->firstLine == NULL) -	return; -    for (i = 0; i < m; i++) -	cursorUp(Currentbuf, n); -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(movU, MOVE_UP, -      "Move cursor up (a half screen scroll at the top of screen)") -{ -    _movU((Currentbuf->LINES + 1) / 2); -} - -DEFUN(movU1, MOVE_UP1, "Move cursor up (1 line scrol at the top of screen)") -{ -    _movU(1); -} - -/* Move cursor right */ -static void -_movR(int n) -{ -    int i, m = searchKeyNum(); -    if (Currentbuf->firstLine == NULL) -	return; -    for (i = 0; i < m; i++) -	cursorRight(Currentbuf, n); -    displayBuffer(Currentbuf, B_NORMAL); -} - -DEFUN(movR, MOVE_RIGHT, -      "Move cursor right (a half screen shift at the right edge)") -{ -    _movR(Currentbuf->COLS / 2); -} - -DEFUN(movR1, MOVE_RIGHT1, -      "Move cursor right (1 columns shift at the right edge)") -{ -    _movR(1); -} - -/* movLW, movRW */ -/*  - * From: Takashi Nishimoto <g96p0935@mse.waseda.ac.jp> Date: Mon, 14 Jun - * 1999 09:29:56 +0900  - */ -#define IS_WORD_CHAR(c,p) (IS_ALNUM(c) && CharType(p) == PC_ASCII) - -static int -prev_nonnull_line(Line *line) -{ -    Line *l; - -    for (l = line; l != NULL && l->len == 0; l = l->prev) ; -    if (l == NULL || l->len == 0) -	return -1; - -    Currentbuf->currentLine = l; -    if (l != line) -	Currentbuf->pos = Currentbuf->currentLine->len; -    return 0; -} - -DEFUN(movLW, PREV_WORD, "Move to previous word") -{ -    char *lb; -    Lineprop *pb; -    Line *pline; -    int ppos; -    int i, n = searchKeyNum(); - -    if (Currentbuf->firstLine == NULL) -	return; - -    for (i = 0; i < n; i++) { -	pline = Currentbuf->currentLine; -	ppos = Currentbuf->pos; - -	if (prev_nonnull_line(Currentbuf->currentLine) < 0) -	    goto end; - -	while (1) { -	    lb = Currentbuf->currentLine->lineBuf; -	    pb = Currentbuf->currentLine->propBuf; -	    while (Currentbuf->pos > 0 && -		   !IS_WORD_CHAR(lb[Currentbuf->pos - 1], -				 pb[Currentbuf->pos - 1])) { -		Currentbuf->pos--; -	    } -	    if (Currentbuf->pos > 0) -		break; -	    if (prev_nonnull_line(Currentbuf->currentLine->prev) < 0) { -		Currentbuf->currentLine = pline; -		Currentbuf->pos = ppos; -		goto end; -	    } -	    Currentbuf->pos = Currentbuf->currentLine->len; -	} - -	lb = Currentbuf->currentLine->lineBuf; -	pb = Currentbuf->currentLine->propBuf; -	while (Currentbuf->pos > 0 && -	       IS_WORD_CHAR(lb[Currentbuf->pos - 1], -			    pb[Currentbuf->pos - 1])) { -	    Currentbuf->pos--; -	} -    } -  end: -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -static int -next_nonnull_line(Line *line) -{ -    Line *l; - -    for (l = line; l != NULL && l->len == 0; l = l->next) ; - -    if (l == NULL || l->len == 0) -	return -1; - -    Currentbuf->currentLine = l; -    if (l != line) -	Currentbuf->pos = 0; -    return 0; -} - -DEFUN(movRW, NEXT_WORD, "Move to next word") -{ -    char *lb; -    Lineprop *pb; -    Line *pline; -    int ppos; -    int i, n = searchKeyNum(); - -    if (Currentbuf->firstLine == NULL) -	return; - -    for (i = 0; i < n; i++) { -	pline = Currentbuf->currentLine; -	ppos = Currentbuf->pos; - -	if (next_nonnull_line(Currentbuf->currentLine) < 0) -	    goto end; - -	lb = Currentbuf->currentLine->lineBuf; -	pb = Currentbuf->currentLine->propBuf; - -	while (lb[Currentbuf->pos] && -	       IS_WORD_CHAR(lb[Currentbuf->pos], pb[Currentbuf->pos])) -	    Currentbuf->pos++; - -	while (1) { -	    while (lb[Currentbuf->pos] && -		   !IS_WORD_CHAR(lb[Currentbuf->pos], pb[Currentbuf->pos])) -		Currentbuf->pos++; -	    if (lb[Currentbuf->pos]) -		break; -	    if (next_nonnull_line(Currentbuf->currentLine->next) < 0) { -		Currentbuf->currentLine = pline; -		Currentbuf->pos = ppos; -		goto end; -	    } -	    Currentbuf->pos = 0; -	    lb = Currentbuf->currentLine->lineBuf; -	    pb = Currentbuf->currentLine->propBuf; -	} -    } -  end: -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -static void -_quitfm(int confirm) -{ -    char *ans = "y"; - -    if (checkDownloadList()) -	/* FIXME: gettextize? */ -	ans = inputChar("Download process retains. " -			"Do you want to exit w3m? (y/n)"); -    else if (confirm) -	/* FIXME: gettextize? */ -	ans = inputChar("Do you want to exit w3m? (y/n)"); -    if (!(ans && TOLOWER(*ans) == 'y')) { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } - -    term_title("");		/* XXX */ -#ifdef USE_IMAGE -    if (activeImage) -	termImage(); -#endif -    fmTerm(); -#ifdef USE_COOKIE -    save_cookies(); -#endif				/* USE_COOKIE */ -#ifdef USE_HISTORY -    if (UseHistory && SaveURLHist) -	saveHistory(URLHist, URLHistSize); -#endif				/* USE_HISTORY */ -    w3m_exit(0); -} - -/* Quit */ -DEFUN(quitfm, ABORT EXIT, "Quit w3m without confirmation") -{ -    _quitfm(FALSE); -} - -/* Question and Quit */ -DEFUN(qquitfm, QUIT, "Quit w3m") -{ -    _quitfm(confirm_on_quit); -} - -/* Select buffer */ -DEFUN(selBuf, SELECT, "Go to buffer selection panel") -{ -    Buffer *buf; -    int ok; -    char cmd; - -    ok = FALSE; -    do { -	buf = selectBuffer(Firstbuf, Currentbuf, &cmd); -	switch (cmd) { -	case 'B': -	    ok = TRUE; -	    break; -	case '\n': -	case ' ': -	    Currentbuf = buf; -	    ok = TRUE; -	    break; -	case 'D': -	    delBuffer(buf); -	    if (Firstbuf == NULL) { -		/* No more buffer */ -		Firstbuf = nullBuffer(); -		Currentbuf = Firstbuf; -	    } -	    break; -	case 'q': -	    qquitfm(); -	    break; -	case 'Q': -	    quitfm(); -	    break; -	} -    } while (!ok); - -    for (buf = Firstbuf; buf != NULL; buf = buf->nextBuffer) { -	if (buf == Currentbuf) -	    continue; -#ifdef USE_IMAGE -	deleteImage(buf); -#endif -	if (clear_buffer) -	    tmpClearBuffer(buf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Suspend (on BSD), or run interactive shell (on SysV) */ -DEFUN(susp, INTERRUPT SUSPEND, "Stop loading document") -{ -#ifndef SIGSTOP -    char *shell; -#endif				/* not SIGSTOP */ -    move(LASTLINE, 0); -    clrtoeolx(); -    refresh(); -    fmTerm(); -#ifndef SIGSTOP -    shell = getenv("SHELL"); -    if (shell == NULL) -	shell = "/bin/sh"; -    system(shell); -#else				/* SIGSTOP */ -    kill((pid_t) 0, SIGSTOP); -#endif				/* SIGSTOP */ -    fmInit(); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Go to specified line */ -static void -_goLine(char *l) -{ -    if (l == NULL || *l == '\0' || Currentbuf->currentLine == NULL) { -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	return; -    } -    Currentbuf->pos = 0; -    if (((*l == '^') || (*l == '$')) && prec_num) { -	gotoRealLine(Currentbuf, prec_num); -    } -    else if (*l == '^') { -	Currentbuf->topLine = Currentbuf->currentLine = Currentbuf->firstLine; -    } -    else if (*l == '$') { -	Currentbuf->topLine = -	    lineSkip(Currentbuf, Currentbuf->lastLine, -		     -(Currentbuf->LINES + 1) / 2, TRUE); -	Currentbuf->currentLine = Currentbuf->lastLine; -    } -    else -	gotoRealLine(Currentbuf, atoi(l)); -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(goLine, GOTO_LINE, "Go to specified line") -{ - -    char *str = searchKeyData(); -    if (prec_num) -	_goLine("^"); -    else if (str) -	_goLine(str); -    else -	/* FIXME: gettextize? */ -	_goLine(inputStr("Goto line: ", "")); -} - - -DEFUN(goLineF, BEGIN, "Go to the first line") -{ -    _goLine("^"); -} - -DEFUN(goLineL, END, "Go to the last line") -{ -    _goLine("$"); -} - -/* Go to the beginning of the line */ -DEFUN(linbeg, LINE_BEGIN, "Go to the beginning of line") -{ -    if (Currentbuf->firstLine == NULL) -	return; -    while (Currentbuf->currentLine->prev && Currentbuf->currentLine->bpos) -	cursorUp0(Currentbuf, 1); -    Currentbuf->pos = 0; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* Go to the bottom of the line */ -DEFUN(linend, LINE_END, "Go to the end of line") -{ -    if (Currentbuf->firstLine == NULL) -	return; -    while (Currentbuf->currentLine->next -	   && Currentbuf->currentLine->next->bpos) -	cursorDown0(Currentbuf, 1); -    Currentbuf->pos = Currentbuf->currentLine->len - 1; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -static int -cur_real_linenumber(Buffer *buf) -{ -    Line *l, *cur = buf->currentLine; -    int n; - -    if (!cur) -	return 1; -    n = cur->real_linenumber ? cur->real_linenumber : 1; -    for (l = buf->firstLine; l && l != cur && l->real_linenumber == 0; l = l->next) {	/* header */ -	if (l->bpos == 0) -	    n++; -    } -    return n; -} - -/* Run editor on the current buffer */ -DEFUN(editBf, EDIT, "Edit current document") -{ -    char *fn = Currentbuf->filename; -    Str cmd; - -    if (fn == NULL || Currentbuf->pagerSource != NULL ||	/* Behaving as a pager */ -	(Currentbuf->type == NULL && Currentbuf->edit == NULL) ||	/* Reading shell */ -	Currentbuf->real_scheme != SCM_LOCAL || !strcmp(Currentbuf->currentURL.file, "-") ||	/* file is std input  */ -	Currentbuf->bufferprop & BP_FRAME) {	/* Frame */ -	disp_err_message("Can't edit other than local file", TRUE); -	return; -    } -    if (Currentbuf->edit) -	cmd = unquote_mailcap(Currentbuf->edit, Currentbuf->real_type, fn, -			      checkHeader(Currentbuf, "Content-Type:"), NULL); -    else -	cmd = myEditor(Editor, shell_quote(fn), -		       cur_real_linenumber(Currentbuf)); -    fmTerm(); -    system(cmd->ptr); -    fmInit(); - -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -    reload(); -} - -/* Run editor on the current screen */ -DEFUN(editScr, EDIT_SCREEN, "Edit currently rendered document") -{ -    char *tmpf; -    FILE *f; - -    tmpf = tmpfname(TMPF_DFL, NULL)->ptr; -    f = fopen(tmpf, "w"); -    if (f == NULL) { -	/* FIXME: gettextize? */ -	disp_err_message(Sprintf("Can't open %s", tmpf)->ptr, TRUE); -	return; -    } -    saveBuffer(Currentbuf, f, TRUE); -    fclose(f); -    fmTerm(); -    system(myEditor(Editor, shell_quote(tmpf), -		    cur_real_linenumber(Currentbuf))->ptr); -    fmInit(); -    unlink(tmpf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -#ifdef USE_MARK - -/* Set / unset mark */ -DEFUN(_mark, MARK, "Set/unset mark") -{ -    Line *l; -    if (!use_mark) -	return; -    if (Currentbuf->firstLine == NULL) -	return; -    l = Currentbuf->currentLine; -    l->propBuf[Currentbuf->pos] ^= PE_MARK; -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* Go to next mark */ -DEFUN(nextMk, NEXT_MARK, "Move to next word") -{ -    Line *l; -    int i; - -    if (!use_mark) -	return; -    if (Currentbuf->firstLine == NULL) -	return; -    i = Currentbuf->pos + 1; -    l = Currentbuf->currentLine; -    if (i >= l->len) { -	i = 0; -	l = l->next; -    } -    while (l != NULL) { -	for (; i < l->len; i++) { -	    if (l->propBuf[i] & PE_MARK) { -		Currentbuf->currentLine = l; -		Currentbuf->pos = i; -		arrangeCursor(Currentbuf); -		displayBuffer(Currentbuf, B_NORMAL); -		return; -	    } -	} -	l = l->next; -	i = 0; -    } -    /* FIXME: gettextize? */ -    disp_message("No mark exist after here", TRUE); -} - -/* Go to previous mark */ -DEFUN(prevMk, PREV_MARK, "Move to previous mark") -{ -    Line *l; -    int i; - -    if (!use_mark) -	return; -    if (Currentbuf->firstLine == NULL) -	return; -    i = Currentbuf->pos - 1; -    l = Currentbuf->currentLine; -    if (i < 0) { -	l = l->prev; -	if (l != NULL) -	    i = l->len - 1; -    } -    while (l != NULL) { -	for (; i >= 0; i--) { -	    if (l->propBuf[i] & PE_MARK) { -		Currentbuf->currentLine = l; -		Currentbuf->pos = i; -		arrangeCursor(Currentbuf); -		displayBuffer(Currentbuf, B_NORMAL); -		return; -	    } -	} -	l = l->prev; -	if (l != NULL) -	    i = l->len - 1; -    } -    /* FIXME: gettextize? */ -    disp_message("No mark exist before here", TRUE); -} - -/* Mark place to which the regular expression matches */ -DEFUN(reMark, REG_MARK, "Set mark using regexp") -{ -    Line *l; -    char *str; -    char *p, *p1, *p2; - -    if (!use_mark) -	return; -    str = searchKeyData(); -    if (str == NULL || *str == '\0') { -	str = inputStrHist("(Mark)Regexp: ", MarkString, TextHist); -	if (str == NULL || *str == '\0') { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    str = conv_search_string(str, DisplayCharset); -    if ((str = regexCompile(str, 1)) != NULL) { -	disp_message(str, TRUE); -	return; -    } -    MarkString = str; -    for (l = Currentbuf->firstLine; l != NULL; l = l->next) { -	p = l->lineBuf; -	for (;;) { -	    if (regexMatch(p, &l->lineBuf[l->len] - p, p == l->lineBuf) == 1) { -		matchedPosition(&p1, &p2); -		l->propBuf[p1 - l->lineBuf] |= PE_MARK; -		p = p2; -	    } -	    else -		break; -	} -    } - -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} -#endif				/* USE_MARK */ - -static Buffer * -loadNormalBuf(Buffer *buf, int renderframe) -{ -    pushBuffer(buf); -    if (renderframe && RenderFrame && Currentbuf->frameset != NULL) -	rFrame(); -    return buf; -} - -static Buffer * -loadLink(char *url, char *target, char *referer, FormList *request) -{ -    Buffer *buf, *nfbuf; -    union frameset_element *f_element = NULL; -    int flag = 0; -    ParsedURL *base, pu; - -    message(Sprintf("loading %s", url)->ptr, 0, 0); -    refresh(); - -    base = baseURL(Currentbuf); -    if (base == NULL || -	base->scheme == SCM_LOCAL || base->scheme == SCM_LOCAL_CGI) -	referer = NO_REFERER; -    if (referer == NULL) -	referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; -    buf = loadGeneralFile(url, baseURL(Currentbuf), referer, flag, request); -    if (buf == NULL) { -	char *emsg = Sprintf("Can't load %s", url)->ptr; -	disp_err_message(emsg, FALSE); -	return NULL; -    } - -    parseURL2(url, &pu, base); -    pushHashHist(URLHist, parsedURL2Str(&pu)->ptr); - -    if (buf == NO_BUFFER) { -	return NULL; -    } -    if (!on_target)		/* open link as an indivisual page */ -	return loadNormalBuf(buf, TRUE); - -    if (do_download)		/* download (thus no need to render frame) */ -	return loadNormalBuf(buf, FALSE); - -    if (target == NULL ||	/* no target specified (that means this page is not a frame page) */ -	!strcmp(target, "_top") ||	/* this link is specified to be opened as an indivisual * page */ -	!(Currentbuf->bufferprop & BP_FRAME)	/* This page is not a frame page */ -	) { -	return loadNormalBuf(buf, TRUE); -    } -    nfbuf = Currentbuf->linkBuffer[LB_N_FRAME]; -    if (nfbuf == NULL) { -	/* original page (that contains <frameset> tag) doesn't exist */ -	return loadNormalBuf(buf, TRUE); -    } - -    f_element = search_frame(nfbuf->frameset, target); -    if (f_element == NULL) { -	/* specified target doesn't exist in this frameset */ -	return loadNormalBuf(buf, TRUE); -    } - -    /* frame page */ - -    /* stack current frameset */ -    pushFrameTree(&(nfbuf->frameQ), copyFrameSet(nfbuf->frameset), Currentbuf); -    /* delete frame view buffer */ -    delBuffer(Currentbuf); -    Currentbuf = nfbuf; -    /* nfbuf->frameset = copyFrameSet(nfbuf->frameset); */ -    resetFrameElement(f_element, buf, referer, request); -    discardBuffer(buf); -    rFrame(); -    { -	Anchor *al = NULL; -	char *label = pu.label; - -	if (label && f_element->element->attr == F_BODY) { -	    al = searchAnchor(f_element->body->nameList, label); -	} -	if (!al) { -	    label = Strnew_m_charp("_", target, NULL)->ptr; -	    al = searchURLLabel(Currentbuf, label); -	} -	if (al) { -	    gotoLine(Currentbuf, al->start.line); -	    if (label_topline) -		Currentbuf->topLine = lineSkip(Currentbuf, Currentbuf->topLine, -					       Currentbuf->currentLine-> -					       linenumber - -					       Currentbuf->topLine->linenumber, -					       FALSE); -	    Currentbuf->pos = al->start.pos; -	    arrangeCursor(Currentbuf); -	} -    } -    displayBuffer(Currentbuf, B_NORMAL); -    return buf; -} - -static void -gotoLabel(char *label) -{ -    Buffer *buf; -    Anchor *al; -    int i; - -    al = searchURLLabel(Currentbuf, label); -    if (al == NULL) { -	/* FIXME: gettextize? */ -	disp_message(Sprintf("%s is not found", label)->ptr, TRUE); -	return; -    } -    buf = newBuffer(Currentbuf->width); -    copyBuffer(buf, Currentbuf); -    for (i = 0; i < MAX_LB; i++) -	buf->linkBuffer[i] = NULL; -    buf->currentURL.label = allocStr(label, -1); -    pushHashHist(URLHist, parsedURL2Str(&buf->currentURL)->ptr); -    (*buf->clone)++; -    pushBuffer(buf); -    gotoLine(Currentbuf, al->start.line); -    if (label_topline) -	Currentbuf->topLine = lineSkip(Currentbuf, Currentbuf->topLine, -				       Currentbuf->currentLine->linenumber -				       - Currentbuf->topLine->linenumber, -				       FALSE); -    Currentbuf->pos = al->start.pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -    return; -} - -/* follow HREF link */ -DEFUN(followA, GOTO_LINK, "Go to current link") -{ -    Line *l; -    Anchor *a; -    ParsedURL u; -#ifdef USE_IMAGE -    int x = 0, y = 0, map = 0; -#endif -    char *url; - -    if (Currentbuf->firstLine == NULL) -	return; -    l = Currentbuf->currentLine; - -#ifdef USE_IMAGE -    a = retrieveCurrentImg(Currentbuf); -    if (a && a->image && a->image->map) { -	_followForm(FALSE); -	return; -    } -    if (a && a->image && a->image->ismap) { -	getMapXY(Currentbuf, a, &x, &y); -	map = 1; -    } -#else -    a = retrieveCurrentMap(Currentbuf); -    if (a) { -	_followForm(FALSE); -	return; -    } -#endif -    a = retrieveCurrentAnchor(Currentbuf); -    if (a == NULL) { -	_followForm(FALSE); -	return; -    } -    if (*a->url == '#') {	/* index within this buffer */ -	gotoLabel(a->url + 1); -	return; -    } -    parseURL2(a->url, &u, baseURL(Currentbuf)); -    if (Strcmp(parsedURL2Str(&u), parsedURL2Str(&Currentbuf->currentURL)) == 0) { -	/* index within this buffer */ -	if (u.label) { -	    gotoLabel(u.label); -	    return; -	} -    } -    if (!strncasecmp(a->url, "mailto:", 7) -#ifdef USE_W3MMAILER -	&& non_null(Mailer) && strchr(a->url, '?') == NULL -#endif -	) { -	/* invoke external mailer */ -	Str to = Strnew_charp(a->url + 7); -#ifndef USE_W3MMAILER -	char *pos; -	if (!non_null(Mailer)) { -	    /* FIXME: gettextize? */ -	    disp_err_message("no mailer is specified", TRUE); -	    return; -	} -	if ((pos = strchr(to->ptr, '?')) != NULL) -	    Strtruncate(to, pos - to->ptr); -#endif -	fmTerm(); -	system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)), -			    FALSE)->ptr); -	fmInit(); -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	pushHashHist(URLHist, a->url); -	return; -    } -#if 0 -    else if (!strncasecmp(a->url, "news:", 5) && strchr(a->url, '@') == NULL) { -	/* news:newsgroup is not supported */ -	/* FIXME: gettextize? */ -	disp_err_message("news:newsgroup_name is not supported", TRUE); -	return; -    } -#endif				/* USE_NNTP */ -    url = a->url; -#ifdef USE_IMAGE -    if (map) -	url = Sprintf("%s?%d,%d", a->url, x, y)->ptr; -#endif - -    if (check_target && open_tab_blank && a->target && -	(!strcasecmp(a->target, "_new") || !strcasecmp(a->target, "_blank"))) { -	Buffer *buf; - -	_newT(); -	buf = Currentbuf; -	loadLink(url, a->target, a->referer, NULL); -	if (buf != Currentbuf) -	    delBuffer(buf); -	else -	    deleteTab(CurrentTab); -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	return; -    } -    loadLink(url, a->target, a->referer, NULL); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* follow HREF link in the buffer */ -void -bufferA(void) -{ -    on_target = FALSE; -    followA(); -    on_target = TRUE; -} - -/* view inline image */ -DEFUN(followI, VIEW_IMAGE, "View image") -{ -    Line *l; -    Anchor *a; -    Buffer *buf; - -    if (Currentbuf->firstLine == NULL) -	return; -    l = Currentbuf->currentLine; - -    a = retrieveCurrentImg(Currentbuf); -    if (a == NULL) -	return; -    /* FIXME: gettextize? */ -    message(Sprintf("loading %s", a->url)->ptr, 0, 0); -    refresh(); -    buf = loadGeneralFile(a->url, baseURL(Currentbuf), NULL, 0, NULL); -    if (buf == NULL) { -	/* FIXME: gettextize? */ -	char *emsg = Sprintf("Can't load %s", a->url)->ptr; -	disp_err_message(emsg, FALSE); -    } -    else if (buf != NO_BUFFER) { -	pushBuffer(buf); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -static FormItemList * -save_submit_formlist(FormItemList *src) -{ -    FormList *list; -    FormList *srclist; -    FormItemList *srcitem; -    FormItemList *item; -    FormItemList *ret = NULL; -#ifdef MENU_SELECT -    FormSelectOptionItem *opt; -    FormSelectOptionItem *curopt; -    FormSelectOptionItem *srcopt; -#endif				/* MENU_SELECT */ - -    if (src == NULL) -	return NULL; -    srclist = src->parent; -    list = New(FormList); -    list->method = srclist->method; -    list->action = Strdup(srclist->action); -#ifdef USE_M17N -    list->charset = srclist->charset; -#endif -    list->enctype = srclist->enctype; -    list->nitems = srclist->nitems; -    list->body = srclist->body; -    list->boundary = srclist->boundary; -    list->length = srclist->length; - -    for (srcitem = srclist->item; srcitem; srcitem = srcitem->next) { -	item = New(FormItemList); -	item->type = srcitem->type; -	item->name = Strdup(srcitem->name); -	item->value = Strdup(srcitem->value); -	item->checked = srcitem->checked; -	item->accept = srcitem->accept; -	item->size = srcitem->size; -	item->rows = srcitem->rows; -	item->maxlength = srcitem->maxlength; -	item->readonly = srcitem->readonly; -#ifdef MENU_SELECT -	opt = curopt = NULL; -	for (srcopt = srcitem->select_option; srcopt; srcopt = srcopt->next) { -	    if (!srcopt->checked) -		continue; -	    opt = New(FormSelectOptionItem); -	    opt->value = Strdup(srcopt->value); -	    opt->label = Strdup(srcopt->label); -	    opt->checked = srcopt->checked; -	    if (item->select_option == NULL) { -		item->select_option = curopt = opt; -	    } -	    else { -		curopt->next = opt; -		curopt = curopt->next; -	    } -	} -	item->select_option = opt; -	if (srcitem->label) -	    item->label = Strdup(srcitem->label); -#endif				/* MENU_SELECT */ -	item->parent = list; -	item->next = NULL; - -	if (list->lastitem == NULL) { -	    list->item = list->lastitem = item; -	} -	else { -	    list->lastitem->next = item; -	    list->lastitem = item; -	} - -	if (srcitem == src) -	    ret = item; -    } - -    return ret; -} - -#ifdef USE_M17N -static Str -conv_form_encoding(Str val, FormItemList *fi, Buffer *buf) -{ -    wc_ces charset = SystemCharset; - -    if (fi->parent->charset) -	charset = fi->parent->charset; -    else if (buf->document_charset && buf->document_charset != WC_CES_US_ASCII) -	charset = buf->document_charset; -    return wc_Str_conv_strict(val, InnerCharset, charset); -} -#else -#define conv_form_encoding(val, fi, buf) (val) -#endif - -static void -query_from_followform(Str *query, FormItemList *fi, int multipart) -{ -    FormItemList *f2; -    FILE *body = NULL; - -    if (multipart) { -	*query = tmpfname(TMPF_DFL, NULL); -	body = fopen((*query)->ptr, "w"); -	if (body == NULL) { -	    return; -	} -	fi->parent->body = (*query)->ptr; -	fi->parent->boundary = -	    Sprintf("------------------------------%d%ld%ld%ld", CurrentPid, -		    fi->parent, fi->parent->body, fi->parent->boundary)->ptr; -    } -    *query = Strnew(); -    for (f2 = fi->parent->item; f2; f2 = f2->next) { -	if (f2->name == NULL) -	    continue; -	/* <ISINDEX> is translated into single text form */ -	if (f2->name->length == 0 && -	    (multipart || f2->type != FORM_INPUT_TEXT)) -	    continue; -	switch (f2->type) { -	case FORM_INPUT_RESET: -	    /* do nothing */ -	    continue; -	case FORM_INPUT_SUBMIT: -	case FORM_INPUT_IMAGE: -	    if (f2 != fi || f2->value == NULL) -		continue; -	    break; -	case FORM_INPUT_RADIO: -	case FORM_INPUT_CHECKBOX: -	    if (!f2->checked) -		continue; -	} -	if (multipart) { -	    if (f2->type == FORM_INPUT_IMAGE) { -		int x = 0, y = 0; -#ifdef USE_IMAGE -		getMapXY(Currentbuf, retrieveCurrentImg(Currentbuf), &x, &y); -#endif -		*query = Strdup(conv_form_encoding(f2->name, fi, Currentbuf)); -		Strcat_charp(*query, ".x"); -		form_write_data(body, fi->parent->boundary, (*query)->ptr, -				Sprintf("%d", x)->ptr); -		*query = Strdup(conv_form_encoding(f2->name, fi, Currentbuf)); -		Strcat_charp(*query, ".y"); -		form_write_data(body, fi->parent->boundary, (*query)->ptr, -				Sprintf("%d", y)->ptr); -	    } -	    else if (f2->name && f2->name->length > 0 && f2->value != NULL) { -		/* not IMAGE */ -		*query = conv_form_encoding(f2->value, fi, Currentbuf); -		if (f2->type == FORM_INPUT_FILE) -		    form_write_from_file(body, fi->parent->boundary, -					 conv_form_encoding(f2->name, fi, -							    Currentbuf)->ptr, -					 (*query)->ptr, -					 Str_conv_to_system(f2->value)->ptr); -		else -		    form_write_data(body, fi->parent->boundary, -				    conv_form_encoding(f2->name, fi, -						       Currentbuf)->ptr, -				    (*query)->ptr); -	    } -	} -	else { -	    /* not multipart */ -	    if (f2->type == FORM_INPUT_IMAGE) { -		int x = 0, y = 0; -#ifdef USE_IMAGE -		getMapXY(Currentbuf, retrieveCurrentImg(Currentbuf), &x, &y); -#endif -		Strcat(*query, -		       Str_form_quote(conv_form_encoding -				      (f2->name, fi, Currentbuf))); -		Strcat(*query, Sprintf(".x=%d&", x)); -		Strcat(*query, -		       Str_form_quote(conv_form_encoding -				      (f2->name, fi, Currentbuf))); -		Strcat(*query, Sprintf(".y=%d", y)); -	    } -	    else { -		/* not IMAGE */ -		if (f2->name && f2->name->length > 0) { -		    Strcat(*query, -			   Str_form_quote(conv_form_encoding -					  (f2->name, fi, Currentbuf))); -		    Strcat_char(*query, '='); -		} -		if (f2->value != NULL) { -		    if (fi->parent->method == FORM_METHOD_INTERNAL) -			Strcat(*query, Str_form_quote(f2->value)); -		    else { -			Strcat(*query, -			       Str_form_quote(conv_form_encoding -					      (f2->value, fi, Currentbuf))); -		    } -		} -	    } -	    if (f2->next) -		Strcat_char(*query, '&'); -	} -    } -    if (multipart) { -	fprintf(body, "--%s--\r\n", fi->parent->boundary); -	fclose(body); -    } -    else { -	/* remove trailing & */ -	while (Strlastchar(*query) == '&') -	    Strshrink(*query, 1); -    } -} - -/* submit form */ -DEFUN(submitForm, SUBMIT, "Submit form") -{ -    _followForm(TRUE); -} - -/* process form */ -void -followForm(void) -{ -    _followForm(FALSE); -} - -static void -_followForm(int submit) -{ -    Line *l; -    Anchor *a, *a2; -    char *p; -    FormItemList *fi, *f2; -    Str tmp, tmp2; -    int multipart = 0, i; - -    if (Currentbuf->firstLine == NULL) -	return; -    l = Currentbuf->currentLine; - -    a = retrieveCurrentForm(Currentbuf); -    if (a == NULL) -	return; -    fi = (FormItemList *)a->url; -    switch (fi->type) { -    case FORM_INPUT_TEXT: -	if (submit) -	    goto do_submit; -	if (fi->readonly) -	    /* FIXME: gettextize? */ -	    disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE); -	/* FIXME: gettextize? */ -	p = inputStrHist("TEXT:", fi->value ? fi->value->ptr : NULL, TextHist); -	if (p == NULL || fi->readonly) -	    break; -	fi->value = Strnew_charp(p); -	formUpdateBuffer(a, Currentbuf, fi); -	if (fi->accept || fi->parent->nitems == 1) -	    goto do_submit; -	break; -    case FORM_INPUT_FILE: -	if (submit) -	    goto do_submit; -	if (fi->readonly) -	    /* FIXME: gettextize? */ -	    disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE); -	/* FIXME: gettextize? */ -	p = inputFilenameHist("Filename:", fi->value ? fi->value->ptr : NULL, -			      NULL); -	if (p == NULL || fi->readonly) -	    break; -	fi->value = Strnew_charp(p); -	formUpdateBuffer(a, Currentbuf, fi); -	if (fi->accept || fi->parent->nitems == 1) -	    goto do_submit; -	break; -    case FORM_INPUT_PASSWORD: -	if (submit) -	    goto do_submit; -	if (fi->readonly) { -	    /* FIXME: gettextize? */ -	    disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE); -	    break; -	} -	/* FIXME: gettextize? */ -	p = inputLine("Password:", fi->value ? fi->value->ptr : NULL, -		      IN_PASSWORD); -	if (p == NULL) -	    break; -	fi->value = Strnew_charp(p); -	formUpdateBuffer(a, Currentbuf, fi); -	if (fi->accept) -	    goto do_submit; -	break; -    case FORM_TEXTAREA: -	if (submit) -	    goto do_submit; -	if (fi->readonly) -	    /* FIXME: gettextize? */ -	    disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE); -	input_textarea(fi); -	formUpdateBuffer(a, Currentbuf, fi); -	break; -    case FORM_INPUT_RADIO: -	if (submit) -	    goto do_submit; -	if (fi->readonly) { -	    /* FIXME: gettextize? */ -	    disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE); -	    break; -	} -	formRecheckRadio(a, Currentbuf, fi); -	break; -    case FORM_INPUT_CHECKBOX: -	if (submit) -	    goto do_submit; -	if (fi->readonly) { -	    /* FIXME: gettextize? */ -	    disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE); -	    break; -	} -	fi->checked = !fi->checked; -	formUpdateBuffer(a, Currentbuf, fi); -	break; -#ifdef MENU_SELECT -    case FORM_SELECT: -	if (submit) -	    goto do_submit; -	if (!formChooseOptionByMenu(fi, -				    Currentbuf->cursorX - Currentbuf->pos + -				    a->start.pos + Currentbuf->rootX, -				    Currentbuf->cursorY + Currentbuf->rootY)) -	    break; -	formUpdateBuffer(a, Currentbuf, fi); -	if (fi->parent->nitems == 1) -	    goto do_submit; -	break; -#endif				/* MENU_SELECT */ -    case FORM_INPUT_IMAGE: -    case FORM_INPUT_SUBMIT: -    case FORM_INPUT_BUTTON: -      do_submit: -	tmp = Strnew(); -	tmp2 = Strnew(); -	multipart = (fi->parent->method == FORM_METHOD_POST && -		     fi->parent->enctype == FORM_ENCTYPE_MULTIPART); -	query_from_followform(&tmp, fi, multipart); - -	tmp2 = Strdup(fi->parent->action); -	if (!Strcmp_charp(tmp2, "!CURRENT_URL!")) { -	    /* It means "current URL" */ -	    tmp2 = parsedURL2Str(&Currentbuf->currentURL); -	    if ((p = strchr(tmp2->ptr, '?')) != NULL) -		Strshrink(tmp2, (tmp2->ptr + tmp2->length) - p); -	} - -	if (fi->parent->method == FORM_METHOD_GET) { -	    if ((p = strchr(tmp2->ptr, '?')) != NULL) -		Strshrink(tmp2, (tmp2->ptr + tmp2->length) - p); -	    Strcat_charp(tmp2, "?"); -	    Strcat(tmp2, tmp); -	    loadLink(tmp2->ptr, a->target, NULL, NULL); -	} -	else if (fi->parent->method == FORM_METHOD_POST) { -	    Buffer *buf; -	    if (multipart) { -		struct stat st; -		stat(fi->parent->body, &st); -		fi->parent->length = st.st_size; -	    } -	    else { -		fi->parent->body = tmp->ptr; -		fi->parent->length = tmp->length; -	    } -	    buf = loadLink(tmp2->ptr, a->target, NULL, fi->parent); -	    if (multipart) { -		unlink(fi->parent->body); -	    } -	    if (buf && !(buf->bufferprop & BP_REDIRECTED)) {	/* buf must be Currentbuf */ -		/* BP_REDIRECTED means that the buffer is obtained through -		 * Location: header. In this case, buf->form_submit must not be set -		 * because the page is not loaded by POST method but GET method. -		 */ -		buf->form_submit = save_submit_formlist(fi); -	    } -	} -	else if ((fi->parent->method == FORM_METHOD_INTERNAL && (!Strcmp_charp(fi->parent->action, "map") || !Strcmp_charp(fi->parent->action, "none"))) || Currentbuf->bufferprop & BP_INTERNAL) {	/* internal */ -	    do_internal(tmp2->ptr, tmp->ptr); -	} -	else { -	    disp_err_message("Can't send form because of illegal method.", -			     FALSE); -	} -	break; -    case FORM_INPUT_RESET: -	for (i = 0; i < Currentbuf->formitem->nanchor; i++) { -	    a2 = &Currentbuf->formitem->anchors[i]; -	    f2 = (FormItemList *)a2->url; -	    if (f2->parent == fi->parent && -		f2->name && f2->value && -		f2->type != FORM_INPUT_SUBMIT && -		f2->type != FORM_INPUT_HIDDEN && -		f2->type != FORM_INPUT_RESET) { -		f2->value = f2->init_value; -		f2->checked = f2->init_checked; -#ifdef MENU_SELECT -		f2->label = f2->init_label; -		f2->selected = f2->init_selected; -#endif				/* MENU_SELECT */ -		formUpdateBuffer(a2, Currentbuf, f2); -	    } -	} -	break; -    case FORM_INPUT_HIDDEN: -    default: -	break; -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* go to the top anchor */ -DEFUN(topA, LINK_BEGIN, "Go to the first link") -{ -    HmarkerList *hl = Currentbuf->hmarklist; -    BufferPoint *po; -    Anchor *an; -    int hseq = 0; - -    if (Currentbuf->firstLine == NULL) -	return; -    if (!hl || hl->nmark == 0) -	return; - -    if (prec_num > hl->nmark) -	hseq = hl->nmark - 1; -    else if (prec_num > 0) -	hseq = prec_num - 1; -    do { -	if (hseq >= hl->nmark) -	    return; -	po = hl->marks + hseq; -	an = retrieveAnchor(Currentbuf->href, po->line, po->pos); -	if (an == NULL) -	    an = retrieveAnchor(Currentbuf->formitem, po->line, po->pos); -	hseq++; -    } while (an == NULL); - -    gotoLine(Currentbuf, po->line); -    Currentbuf->pos = po->pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* go to the last anchor */ -DEFUN(lastA, LINK_END, "Go to the last link") -{ -    HmarkerList *hl = Currentbuf->hmarklist; -    BufferPoint *po; -    Anchor *an; -    int hseq; - -    if (Currentbuf->firstLine == NULL) -	return; -    if (!hl || hl->nmark == 0) -	return; - -    if (prec_num >= hl->nmark) -	hseq = 0; -    else if (prec_num > 0) -	hseq = hl->nmark - prec_num; -    else -	hseq = hl->nmark - 1; -    do { -	if (hseq < 0) -	    return; -	po = hl->marks + hseq; -	an = retrieveAnchor(Currentbuf->href, po->line, po->pos); -	if (an == NULL) -	    an = retrieveAnchor(Currentbuf->formitem, po->line, po->pos); -	hseq--; -    } while (an == NULL); - -    gotoLine(Currentbuf, po->line); -    Currentbuf->pos = po->pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* go to the next anchor */ -DEFUN(nextA, NEXT_LINK, "Move to next link") -{ -    _nextA(FALSE); -} - -/* go to the previous anchor */ -DEFUN(prevA, PREV_LINK, "Move to previous link") -{ -    _prevA(FALSE); -} - -/* go to the next visited anchor */ -DEFUN(nextVA, NEXT_VISITED, "Move to next visited link") -{ -    _nextA(TRUE); -} - -/* go to the previous visited anchor */ -DEFUN(prevVA, PREV_VISITED, "Move to previous visited link") -{ -    _prevA(TRUE); -} - -/* go to the next [visited] anchor */ -static void -_nextA(int visited) -{ -    HmarkerList *hl = Currentbuf->hmarklist; -    BufferPoint *po; -    Anchor *an, *pan; -    int i, x, y, n = searchKeyNum(); -    ParsedURL url; - -    if (Currentbuf->firstLine == NULL) -	return; -    if (!hl || hl->nmark == 0) -	return; - -    an = retrieveCurrentAnchor(Currentbuf); -    if (visited != TRUE && an == NULL) -	an = retrieveCurrentForm(Currentbuf); - -    y = Currentbuf->currentLine->linenumber; -    x = Currentbuf->pos; - -    if (visited == TRUE) { -	n = hl->nmark; -    } - -    for (i = 0; i < n; i++) { -	pan = an; -	if (an && an->hseq >= 0) { -	    int hseq = an->hseq + 1; -	    do { -		if (hseq >= hl->nmark) { -		    if (visited == TRUE) -			return; -		    an = pan; -		    goto _end; -		} -		po = &hl->marks[hseq]; -		an = retrieveAnchor(Currentbuf->href, po->line, po->pos); -		if (visited != TRUE && an == NULL) -		    an = retrieveAnchor(Currentbuf->formitem, po->line, -					po->pos); -		hseq++; -		if (visited == TRUE && an) { -		    parseURL2(an->url, &url, baseURL(Currentbuf)); -		    if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) { -			goto _end; -		    } -		} -	    } while (an == NULL || an == pan); -	} -	else { -	    an = closest_next_anchor(Currentbuf->href, NULL, x, y); -	    if (visited != TRUE) -		an = closest_next_anchor(Currentbuf->formitem, an, x, y); -	    if (an == NULL) { -		if (visited == TRUE) -		    return; -		an = pan; -		break; -	    } -	    x = an->start.pos; -	    y = an->start.line; -	    if (visited == TRUE) { -		parseURL2(an->url, &url, baseURL(Currentbuf)); -		if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) { -		    goto _end; -		} -	    } -	} -    } -    if (visited == TRUE) -	return; - -  _end: -    if (an == NULL || an->hseq < 0) -	return; -    po = &hl->marks[an->hseq]; -    gotoLine(Currentbuf, po->line); -    Currentbuf->pos = po->pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* go to the previous anchor */ -static void -_prevA(int visited) -{ -    HmarkerList *hl = Currentbuf->hmarklist; -    BufferPoint *po; -    Anchor *an, *pan; -    int i, x, y, n = searchKeyNum(); -    ParsedURL url; - -    if (Currentbuf->firstLine == NULL) -	return; -    if (!hl || hl->nmark == 0) -	return; - -    an = retrieveCurrentAnchor(Currentbuf); -    if (visited != TRUE && an == NULL) -	an = retrieveCurrentForm(Currentbuf); - -    y = Currentbuf->currentLine->linenumber; -    x = Currentbuf->pos; - -    if (visited == TRUE) { -	n = hl->nmark; -    } - -    for (i = 0; i < n; i++) { -	pan = an; -	if (an && an->hseq >= 0) { -	    int hseq = an->hseq - 1; -	    do { -		if (hseq < 0) { -		    if (visited == TRUE) -			return; -		    an = pan; -		    goto _end; -		} -		po = hl->marks + hseq; -		an = retrieveAnchor(Currentbuf->href, po->line, po->pos); -		if (visited != TRUE && an == NULL) -		    an = retrieveAnchor(Currentbuf->formitem, po->line, -					po->pos); -		hseq--; -		if (visited == TRUE && an) { -		    parseURL2(an->url, &url, baseURL(Currentbuf)); -		    if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) { -			goto _end; -		    } -		} -	    } while (an == NULL || an == pan); -	} -	else { -	    an = closest_prev_anchor(Currentbuf->href, NULL, x, y); -	    if (visited != TRUE) -		an = closest_prev_anchor(Currentbuf->formitem, an, x, y); -	    if (an == NULL) { -		if (visited == TRUE) -		    return; -		an = pan; -		break; -	    } -	    x = an->start.pos; -	    y = an->start.line; -	    if (visited == TRUE && an) { -		parseURL2(an->url, &url, baseURL(Currentbuf)); -		if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) { -		    goto _end; -		} -	    } -	} -    } -    if (visited == TRUE) -	return; - -  _end: -    if (an == NULL || an->hseq < 0) -	return; -    po = hl->marks + an->hseq; -    gotoLine(Currentbuf, po->line); -    Currentbuf->pos = po->pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* go to the next left/right anchor */ -static void -nextX(int d, int dy) -{ -    HmarkerList *hl = Currentbuf->hmarklist; -    Anchor *an, *pan; -    Line *l; -    int i, x, y, n = searchKeyNum(); - -    if (Currentbuf->firstLine == NULL) -	return; -    if (!hl || hl->nmark == 0) -	return; - -    an = retrieveCurrentAnchor(Currentbuf); -    if (an == NULL) -	an = retrieveCurrentForm(Currentbuf); - -    l = Currentbuf->currentLine; -    x = Currentbuf->pos; -    y = l->linenumber; -    pan = NULL; -    for (i = 0; i < n; i++) { -	if (an) -	    x = (d > 0) ? an->end.pos : an->start.pos - 1; -	an = NULL; -	while (1) { -	    for (; x >= 0 && x < l->len; x += d) { -		an = retrieveAnchor(Currentbuf->href, y, x); -		if (!an) -		    an = retrieveAnchor(Currentbuf->formitem, y, x); -		if (an) { -		    pan = an; -		    break; -		} -	    } -	    if (!dy || an) -		break; -	    l = (dy > 0) ? l->next : l->prev; -	    if (!l) -		break; -	    x = (d > 0) ? 0 : l->len - 1; -	    y = l->linenumber; -	} -	if (!an) -	    break; -    } - -    if (pan == NULL) -	return; -    gotoLine(Currentbuf, y); -    Currentbuf->pos = pan->start.pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* go to the next downward/upward anchor */ -static void -nextY(int d) -{ -    HmarkerList *hl = Currentbuf->hmarklist; -    Anchor *an, *pan; -    int i, x, y, n = searchKeyNum(); -    int hseq; - -    if (Currentbuf->firstLine == NULL) -	return; -    if (!hl || hl->nmark == 0) -	return; - -    an = retrieveCurrentAnchor(Currentbuf); -    if (an == NULL) -	an = retrieveCurrentForm(Currentbuf); - -    x = Currentbuf->pos; -    y = Currentbuf->currentLine->linenumber + d; -    pan = NULL; -    hseq = -1; -    for (i = 0; i < n; i++) { -	if (an) -	    hseq = abs(an->hseq); -	an = NULL; -	for (; y >= 0 && y <= Currentbuf->lastLine->linenumber; y += d) { -	    an = retrieveAnchor(Currentbuf->href, y, x); -	    if (!an) -		an = retrieveAnchor(Currentbuf->formitem, y, x); -	    if (an && hseq != abs(an->hseq)) { -		pan = an; -		break; -	    } -	} -	if (!an) -	    break; -    } - -    if (pan == NULL) -	return; -    gotoLine(Currentbuf, pan->start.line); -    arrangeLine(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* go to the next left anchor */ -DEFUN(nextL, NEXT_LEFT, "Move to next left link") -{ -    nextX(-1, 0); -} - -/* go to the next left-up anchor */ -DEFUN(nextLU, NEXT_LEFT_UP, "Move to next left (or upward) link") -{ -    nextX(-1, -1); -} - -/* go to the next right anchor */ -DEFUN(nextR, NEXT_RIGHT, "Move to next right link") -{ -    nextX(1, 0); -} - -/* go to the next right-down anchor */ -DEFUN(nextRD, NEXT_RIGHT_DOWN, "Move to next right (or downward) link") -{ -    nextX(1, 1); -} - -/* go to the next downward anchor */ -DEFUN(nextD, NEXT_DOWN, "Move to next downward link") -{ -    nextY(1); -} - -/* go to the next upward anchor */ -DEFUN(nextU, NEXT_UP, "Move to next upward link") -{ -    nextY(-1); -} - -/* go to the next bufferr */ -DEFUN(nextBf, NEXT, "Move to next buffer") -{ -    Buffer *buf; -    int i; - -    for (i = 0; i < PREC_NUM; i++) { -	buf = prevBuffer(Firstbuf, Currentbuf); -	if (!buf) { -	    if (i == 0) -		return; -	    break; -	} -	Currentbuf = buf; -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* go to the previous bufferr */ -DEFUN(prevBf, PREV, "Move to previous buffer") -{ -    Buffer *buf; -    int i; - -    for (i = 0; i < PREC_NUM; i++) { -	buf = Currentbuf->nextBuffer; -	if (!buf) { -	    if (i == 0) -		return; -	    break; -	} -	Currentbuf = buf; -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -static int -checkBackBuffer(Buffer *buf) -{ -    Buffer *fbuf = buf->linkBuffer[LB_N_FRAME]; - -    if (fbuf) { -	if (fbuf->frameQ) -	    return TRUE;	/* Currentbuf has stacked frames */ -	/* when no frames stacked and next is frame source, try next's -	 * nextBuffer */ -	if (RenderFrame && fbuf == buf->nextBuffer) { -	    if (fbuf->nextBuffer != NULL) -		return TRUE; -	    else -		return FALSE; -	} -    } - -    if (buf->nextBuffer) -	return TRUE; - -    return FALSE; -} - -/* delete current buffer and back to the previous buffer */ -DEFUN(backBf, BACK, "Back to previous buffer") -{ -    Buffer *buf = Currentbuf->linkBuffer[LB_N_FRAME]; - -    if (!checkBackBuffer(Currentbuf)) { -	if (close_tab_back && nTab >= 1) { -	    deleteTab(CurrentTab); -	    displayBuffer(Currentbuf, B_FORCE_REDRAW); -	} -	else -	    /* FIXME: gettextize? */ -	    disp_message("Can't back...", TRUE); -	return; -    } - -    delBuffer(Currentbuf); - -    if (buf) { -	if (buf->frameQ) { -	    struct frameset *fs; -	    long linenumber = buf->frameQ->linenumber; -	    long top = buf->frameQ->top_linenumber; -	    int pos = buf->frameQ->pos; -	    int currentColumn = buf->frameQ->currentColumn; -	    AnchorList *formitem = buf->frameQ->formitem; - -	    fs = popFrameTree(&(buf->frameQ)); -	    deleteFrameSet(buf->frameset); -	    buf->frameset = fs; - -	    if (buf == Currentbuf) { -		rFrame(); -		Currentbuf->topLine = lineSkip(Currentbuf, -					       Currentbuf->firstLine, top - 1, -					       FALSE); -		gotoLine(Currentbuf, linenumber); -		Currentbuf->pos = pos; -		Currentbuf->currentColumn = currentColumn; -		arrangeCursor(Currentbuf); -		formResetBuffer(Currentbuf, formitem); -	    } -	} -	else if (RenderFrame && buf == Currentbuf) { -	    delBuffer(Currentbuf); -	} -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(deletePrevBuf, DELETE_PREVBUF, -      "Delete previous buffer (mainly for local-CGI)") -{ -    Buffer *buf = Currentbuf->nextBuffer; -    if (buf) -	delBuffer(buf); -} - -static void -cmd_loadURL(char *url, ParsedURL *current, char *referer, FormList *request) -{ -    Buffer *buf; - -    if (!strncasecmp(url, "mailto:", 7) -#ifdef USE_W3MMAILER -	&& non_null(Mailer) && strchr(url, '?') == NULL -#endif -	) { -	/* invoke external mailer */ -	Str to = Strnew_charp(url + 7); -#ifndef USE_W3MMAILER -	char *pos; -	if (!non_null(Mailer)) { -	    /* FIXME: gettextize? */ -	    disp_err_message("no mailer is specified", TRUE); -	    return; -	} -	if ((pos = strchr(to->ptr, '?')) != NULL) -	    Strtruncate(to, pos - to->ptr); -#endif -	fmTerm(); -	system(myExtCommand(Mailer, shell_quote(file_unquote(to->ptr)), -			    FALSE)->ptr); -	fmInit(); -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	pushHashHist(URLHist, url); -	return; -    } -#if 0 -    if (!strncasecmp(url, "news:", 5) && strchr(url, '@') == NULL) { -	/* news:newsgroup is not supported */ -	/* FIXME: gettextize? */ -	disp_err_message("news:newsgroup_name is not supported", TRUE); -	return; -    } -#endif				/* USE_NNTP */ - -    refresh(); -    buf = loadGeneralFile(url, current, referer, 0, request); -    if (buf == NULL) { -	/* FIXME: gettextize? */ -	char *emsg = Sprintf("Can't load %s", conv_from_system(url))->ptr; -	disp_err_message(emsg, FALSE); -    } -    else if (buf != NO_BUFFER) { -	pushBuffer(buf); -	if (RenderFrame && Currentbuf->frameset != NULL) -	    rFrame(); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - - -/* go to specified URL */ -static void -goURL0(char *prompt, int relative) -{ -    char *url, *referer; -    ParsedURL p_url, *current; -    Buffer *cur_buf = Currentbuf; - -    url = searchKeyData(); -    if (url == NULL) { -	Hist *hist = copyHist(URLHist); -	Anchor *a; - -	current = baseURL(Currentbuf); -	if (current) { -	    char *c_url = parsedURL2Str(current)->ptr; -	    if (DefaultURLString == DEFAULT_URL_CURRENT) { -		url = c_url; -		if (DecodeURL) -		    url = url_unquote_conv(url, 0); -	    } -	    else -		pushHist(hist, c_url); -	} -	a = retrieveCurrentAnchor(Currentbuf); -	if (a) { -	    char *a_url; -	    parseURL2(a->url, &p_url, current); -	    a_url = parsedURL2Str(&p_url)->ptr; -	    if (DefaultURLString == DEFAULT_URL_LINK) { -		url = a_url; -		if (DecodeURL) -		    url = url_unquote_conv(url, Currentbuf->document_charset); -	    } -	    else -		pushHist(hist, a_url); -	} -	url = inputLineHist(prompt, url, IN_URL, hist); -	if (url != NULL) -	    SKIP_BLANKS(url); -    } -#ifdef USE_M17N -    if (url != NULL) { -	if ((relative || *url == '#') && Currentbuf->document_charset) -	    url = wc_conv_strict(url, InnerCharset, -				 Currentbuf->document_charset)->ptr; -	else -	    url = conv_to_system(url); -    } -#endif -    if (url == NULL || *url == '\0') { -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	return; -    } -    if (*url == '#') { -	gotoLabel(url + 1); -	return; -    } -    if (relative) { -	current = baseURL(Currentbuf); -	referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; -    } -    else { -	current = NULL; -	referer = NULL; -    } -    parseURL2(url, &p_url, current); -    pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr); -    cmd_loadURL(url, current, referer, NULL); -    if (Currentbuf != cur_buf)	/* success */ -	pushHashHist(URLHist, parsedURL2Str(&Currentbuf->currentURL)->ptr); -} - -DEFUN(goURL, GOTO, "Go to URL") -{ -    goURL0("Goto URL: ", FALSE); -} - -DEFUN(gorURL, GOTO_RELATIVE, "Go to relative URL") -{ -    goURL0("Goto relative URL: ", TRUE); -} - -static void -cmd_loadBuffer(Buffer *buf, int prop, int linkid) -{ -    if (buf == NULL) { -	disp_err_message("Can't load string", FALSE); -    } -    else if (buf != NO_BUFFER) { -	buf->bufferprop |= (BP_INTERNAL | prop); -	if (!(buf->bufferprop & BP_NO_URL)) -	    copyParsedURL(&buf->currentURL, &Currentbuf->currentURL); -	if (linkid != LB_NOLINK) { -	    buf->linkBuffer[REV_LB[linkid]] = Currentbuf; -	    Currentbuf->linkBuffer[linkid] = buf; -	} -	pushBuffer(buf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* load bookmark */ -DEFUN(ldBmark, BOOKMARK VIEW_BOOKMARK, "Read bookmark") -{ -    cmd_loadURL(BookmarkFile, NULL, NO_REFERER, NULL); -} - - -/* Add current to bookmark */ -DEFUN(adBmark, ADD_BOOKMARK, "Add current page to bookmark") -{ -    Str tmp; -    FormList *request; - -    tmp = Sprintf("mode=panel&cookie=%s&bmark=%s&url=%s&title=%s" -#ifdef USE_M17N -		    "&charset=%s" -#endif -		    , -		  (Str_form_quote(localCookie()))->ptr, -		  (Str_form_quote(Strnew_charp(BookmarkFile)))->ptr, -		  (Str_form_quote(parsedURL2Str(&Currentbuf->currentURL)))-> -		  ptr, -#ifdef USE_M17N -		  (Str_form_quote(wc_conv_strict(Currentbuf->buffername, -						 InnerCharset, -						 BookmarkCharset)))->ptr, -		  wc_ces_to_charset(BookmarkCharset)); -#else -		  (Str_form_quote(Strnew_charp(Currentbuf->buffername)))->ptr); -#endif -    request = newFormList(NULL, "post", NULL, NULL, NULL, NULL, NULL); -    request->body = tmp->ptr; -    request->length = tmp->length; -    cmd_loadURL("file:///$LIB/" W3MBOOKMARK_CMDNAME, NULL, NO_REFERER, -		request); -} - -/* option setting */ -DEFUN(ldOpt, OPTIONS, "Option setting panel") -{ -    cmd_loadBuffer(load_option_panel(), BP_NO_URL, LB_NOLINK); -} - -/* set an option */ -DEFUN(setOpt, SET_OPTION, "Set option") -{ -    char *opt; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    opt = searchKeyData(); -    if (opt == NULL || *opt == '\0' || strchr(opt, '=') == NULL) { -	if (opt != NULL && *opt != '\0') { -	    char *v = get_param_option(opt); -	    opt = Sprintf("%s=%s", opt, v ? v : "")->ptr; -	} -	opt = inputStrHist("Set option: ", opt, TextHist); -	if (opt == NULL || *opt == '\0') { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    if (set_param_option(opt)) -	sync_with_option(); -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} - -/* error message list */ -DEFUN(msgs, MSGS, "Display error messages") -{ -    cmd_loadBuffer(message_list_panel(), BP_NO_URL, LB_NOLINK); -} - -/* page info */ -DEFUN(pginfo, INFO, "View info of current document") -{ -    Buffer *buf; - -    if ((buf = Currentbuf->linkBuffer[LB_N_INFO]) != NULL) { -	Currentbuf = buf; -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    if ((buf = Currentbuf->linkBuffer[LB_INFO]) != NULL) -	delBuffer(buf); -    buf = page_info_panel(Currentbuf); -    cmd_loadBuffer(buf, BP_NORMAL, LB_INFO); -} - -void -follow_map(struct parsed_tagarg *arg) -{ -    char *name = tag_get_value(arg, "link"); -#if defined(MENU_MAP) || defined(USE_IMAGE) -    Anchor *an; -    MapArea *a; -    int x, y; -    ParsedURL p_url; - -    an = retrieveCurrentImg(Currentbuf); -    x = Currentbuf->cursorX + Currentbuf->rootX; -    y = Currentbuf->cursorY + Currentbuf->rootY; -    a = follow_map_menu(Currentbuf, name, an, x, y); -    if (a == NULL || a->url == NULL || *(a->url) == '\0') { -#endif -#ifndef MENU_MAP -	Buffer *buf = follow_map_panel(Currentbuf, name); - -	if (buf != NULL) -	    cmd_loadBuffer(buf, BP_NORMAL, LB_NOLINK); -#endif -#if defined(MENU_MAP) || defined(USE_IMAGE) -	return; -    } -    if (*(a->url) == '#') { -	gotoLabel(a->url + 1); -	return; -    } -    parseURL2(a->url, &p_url, baseURL(Currentbuf)); -    pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr); -    if (check_target && open_tab_blank && a->target && -	(!strcasecmp(a->target, "_new") || !strcasecmp(a->target, "_blank"))) { -	Buffer *buf; - -	_newT(); -	buf = Currentbuf; -	cmd_loadURL(a->url, baseURL(Currentbuf), -		    parsedURL2Str(&Currentbuf->currentURL)->ptr, NULL); -	if (buf != Currentbuf) -	    delBuffer(buf); -	else -	    deleteTab(CurrentTab); -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	return; -    } -    cmd_loadURL(a->url, baseURL(Currentbuf), -		parsedURL2Str(&Currentbuf->currentURL)->ptr, NULL); -#endif -} - -#ifdef USE_MENU -/* link menu */ -DEFUN(linkMn, LINK_MENU, "Popup link element menu") -{ -    LinkList *l = link_menu(Currentbuf); -    ParsedURL p_url; - -    if (!l || !l->url) -	return; -    if (*(l->url) == '#') { -	gotoLabel(l->url + 1); -	return; -    } -    parseURL2(l->url, &p_url, baseURL(Currentbuf)); -    pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr); -    cmd_loadURL(l->url, baseURL(Currentbuf), -		parsedURL2Str(&Currentbuf->currentURL)->ptr, NULL); -} - -static void -anchorMn(Anchor *(*menu_func) (Buffer *), int go) -{ -    Anchor *a; -    BufferPoint *po; - -    if (!Currentbuf->href || !Currentbuf->hmarklist) -	return; -    a = menu_func(Currentbuf); -    if (!a || a->hseq < 0) -	return; -    po = &Currentbuf->hmarklist->marks[a->hseq]; -    gotoLine(Currentbuf, po->line); -    Currentbuf->pos = po->pos; -    arrangeCursor(Currentbuf); -    displayBuffer(Currentbuf, B_NORMAL); -    if (go) -	followA(); -} - -/* accesskey */ -DEFUN(accessKey, ACCESSKEY, "Popup acceskey menu") -{ -    anchorMn(accesskey_menu, TRUE); -} - -/* list menu */ -DEFUN(listMn, LIST_MENU, "Popup link list menu and go to selected link") -{ -    anchorMn(list_menu, TRUE); -} - -DEFUN(movlistMn, MOVE_LIST_MENU, -      "Popup link list menu and move cursor to selected link") -{ -    anchorMn(list_menu, FALSE); -} -#endif - -/* link,anchor,image list */ -DEFUN(linkLst, LIST, "Show all links and images") -{ -    Buffer *buf; - -    buf = link_list_panel(Currentbuf); -    if (buf != NULL) { -#ifdef USE_M17N -	buf->document_charset = Currentbuf->document_charset; -#endif -	cmd_loadBuffer(buf, BP_NORMAL, LB_NOLINK); -    } -} - -#ifdef USE_COOKIE -/* cookie list */ -DEFUN(cooLst, COOKIE, "View cookie list") -{ -    Buffer *buf; - -    buf = cookie_list_panel(); -    if (buf != NULL) -	cmd_loadBuffer(buf, BP_NO_URL, LB_NOLINK); -} -#endif				/* USE_COOKIE */ - -#ifdef USE_HISTORY -/* History page */ -DEFUN(ldHist, HISTORY, "View history of URL") -{ -    cmd_loadBuffer(historyBuffer(URLHist), BP_NO_URL, LB_NOLINK); -} -#endif				/* USE_HISTORY */ - -/* download HREF link */ -DEFUN(svA, SAVE_LINK, "Save link to file") -{ -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    do_download = TRUE; -    followA(); -    do_download = FALSE; -} - -/* download IMG link */ -DEFUN(svI, SAVE_IMAGE, "Save image to file") -{ -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    do_download = TRUE; -    followI(); -    do_download = FALSE; -} - -/* save buffer */ -DEFUN(svBuf, PRINT SAVE_SCREEN, "Save rendered document to file") -{ -    char *qfile = NULL, *file; -    FILE *f; -    int is_pipe; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    file = searchKeyData(); -    if (file == NULL || *file == '\0') { -	/* FIXME: gettextize? */ -	qfile = inputLineHist("Save buffer to: ", NULL, IN_COMMAND, SaveHist); -	if (qfile == NULL || *qfile == '\0') { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    file = conv_to_system(qfile ? qfile : file); -    if (*file == '|') { -	is_pipe = TRUE; -	f = popen(file + 1, "w"); -    } -    else { -	if (qfile) { -	    file = unescape_spaces(Strnew_charp(qfile))->ptr; -	    file = conv_to_system(file); -	} -	file = expandPath(file); -	if (checkOverWrite(file) < 0) { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -	f = fopen(file, "w"); -	is_pipe = FALSE; -    } -    if (f == NULL) { -	/* FIXME: gettextize? */ -	char *emsg = Sprintf("Can't open %s", conv_from_system(file))->ptr; -	disp_err_message(emsg, TRUE); -	return; -    } -    saveBuffer(Currentbuf, f, TRUE); -    if (is_pipe) -	pclose(f); -    else -	fclose(f); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* save source */ -DEFUN(svSrc, DOWNLOAD SAVE, "Save document source to file") -{ -    char *file; - -    if (Currentbuf->sourcefile == NULL) -	return; -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    PermitSaveToPipe = TRUE; -    if (Currentbuf->real_scheme == SCM_LOCAL) -	file = conv_from_system(guess_save_name(NULL, -						Currentbuf->currentURL. -						real_file)); -    else -	file = guess_save_name(Currentbuf, Currentbuf->currentURL.file); -    doFileCopy(Currentbuf->sourcefile, file); -    PermitSaveToPipe = FALSE; -    displayBuffer(Currentbuf, B_NORMAL); -} - -static void -_peekURL(int only_img) -{ - -    Anchor *a; -    ParsedURL pu; -    static Str s = NULL; -#ifdef USE_M17N -    static Lineprop *p = NULL; -    Lineprop *pp; -#endif -    static int offset = 0, n; - -    if (Currentbuf->firstLine == NULL) -	return; -    if (CurrentKey == prev_key && s != NULL) { -	if (s->length - offset >= COLS) -	    offset++; -	else if (s->length <= offset)	/* bug ? */ -	    offset = 0; -	goto disp; -    } -    else { -	offset = 0; -    } -    s = NULL; -    a = (only_img ? NULL : retrieveCurrentAnchor(Currentbuf)); -    if (a == NULL) { -	a = (only_img ? NULL : retrieveCurrentForm(Currentbuf)); -	if (a == NULL) { -	    a = retrieveCurrentImg(Currentbuf); -	    if (a == NULL) -		return; -	} -	else -	    s = Strnew_charp(form2str((FormItemList *)a->url)); -    } -    if (s == NULL) { -	parseURL2(a->url, &pu, baseURL(Currentbuf)); -	s = parsedURL2Str(&pu); -    } -    if (DecodeURL) -	s = Strnew_charp(url_unquote_conv -			 (s->ptr, Currentbuf->document_charset)); -#ifdef USE_M17N -    s = checkType(s, &pp, NULL); -    p = NewAtom_N(Lineprop, s->length); -    bcopy((void *)pp, (void *)p, s->length * sizeof(Lineprop)); -#endif -  disp: -    n = searchKeyNum(); -    if (n > 1 && s->length > (n - 1) * (COLS - 1)) -	offset = (n - 1) * (COLS - 1); -#ifdef USE_M17N -    while (offset < s->length && p[offset] & PC_WCHAR2) -	offset++; -#endif -    disp_message_nomouse(&s->ptr[offset], TRUE); -} - -/* peek URL */ -DEFUN(peekURL, PEEK_LINK, "Peek link URL") -{ -    _peekURL(0); -} - -/* peek URL of image */ -DEFUN(peekIMG, PEEK_IMG, "Peek image URL") -{ -    _peekURL(1); -} - -/* show current URL */ -static Str -currentURL(void) -{ -    if (Currentbuf->bufferprop & BP_INTERNAL) -	return Strnew_size(0); -    return parsedURL2Str(&Currentbuf->currentURL); -} - -DEFUN(curURL, PEEK, "Peek current URL") -{ -    static Str s = NULL; -#ifdef USE_M17N -    static Lineprop *p = NULL; -    Lineprop *pp; -#endif -    static int offset = 0, n; - -    if (Currentbuf->bufferprop & BP_INTERNAL) -	return; -    if (CurrentKey == prev_key && s != NULL) { -	if (s->length - offset >= COLS) -	    offset++; -	else if (s->length <= offset)	/* bug ? */ -	    offset = 0; -    } -    else { -	offset = 0; -	s = currentURL(); -	if (DecodeURL) -	    s = Strnew_charp(url_unquote_conv(s->ptr, 0)); -#ifdef USE_M17N -	s = checkType(s, &pp, NULL); -	p = NewAtom_N(Lineprop, s->length); -	bcopy((void *)pp, (void *)p, s->length * sizeof(Lineprop)); -#endif -    } -    n = searchKeyNum(); -    if (n > 1 && s->length > (n - 1) * (COLS - 1)) -	offset = (n - 1) * (COLS - 1); -#ifdef USE_M17N -    while (offset < s->length && p[offset] & PC_WCHAR2) -	offset++; -#endif -    disp_message_nomouse(&s->ptr[offset], TRUE); -} -/* view HTML source */ - -DEFUN(vwSrc, SOURCE VIEW, "View HTML source") -{ -    Buffer *buf; - -    if (Currentbuf->type == NULL || Currentbuf->bufferprop & BP_FRAME) -	return; -    if ((buf = Currentbuf->linkBuffer[LB_SOURCE]) != NULL || -	(buf = Currentbuf->linkBuffer[LB_N_SOURCE]) != NULL) { -	Currentbuf = buf; -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    if (Currentbuf->sourcefile == NULL) { -	if (Currentbuf->pagerSource && -	    !strcasecmp(Currentbuf->type, "text/plain")) { -#ifdef USE_M17N -	    wc_ces old_charset; -	    wc_bool old_fix_width_conv; -#endif -	    FILE *f; -	    Str tmpf = tmpfname(TMPF_SRC, NULL); -	    f = fopen(tmpf->ptr, "w"); -	    if (f == NULL) -		return; -#ifdef USE_M17N -	    old_charset = DisplayCharset; -	    old_fix_width_conv = WcOption.fix_width_conv; -	    DisplayCharset = (Currentbuf->document_charset != WC_CES_US_ASCII) -		? Currentbuf->document_charset : 0; -	    WcOption.fix_width_conv = WC_FALSE; -#endif -	    saveBufferBody(Currentbuf, f, TRUE); -#ifdef USE_M17N -	    DisplayCharset = old_charset; -	    WcOption.fix_width_conv = old_fix_width_conv; -#endif -	    fclose(f); -	    Currentbuf->sourcefile = tmpf->ptr; -	} -	else { -	    return; -	} -    } - -    buf = newBuffer(INIT_BUFFER_WIDTH); - -    if (!strcasecmp(Currentbuf->type, "text/html")) { -	buf->type = "text/plain"; -	if (Currentbuf->real_type && -	    !strcasecmp(Currentbuf->real_type, "text/html")) -	    buf->real_type = "text/plain"; -	else -	    buf->real_type = Currentbuf->real_type; -	buf->buffername = Sprintf("source of %s", Currentbuf->buffername)->ptr; -	buf->linkBuffer[LB_N_SOURCE] = Currentbuf; -	Currentbuf->linkBuffer[LB_SOURCE] = buf; -    } -    else if (!strcasecmp(Currentbuf->type, "text/plain")) { -	buf->type = "text/html"; -	if (Currentbuf->real_type && -	    !strcasecmp(Currentbuf->real_type, "text/plain")) -	    buf->real_type = "text/html"; -	else -	    buf->real_type = Currentbuf->real_type; -	buf->buffername = Sprintf("HTML view of %s", -				  Currentbuf->buffername)->ptr; -	buf->linkBuffer[LB_SOURCE] = Currentbuf; -	Currentbuf->linkBuffer[LB_N_SOURCE] = buf; -    } -    else { -	return; -    } -    buf->currentURL = Currentbuf->currentURL; -    buf->real_scheme = Currentbuf->real_scheme; -    buf->filename = Currentbuf->filename; -    buf->sourcefile = Currentbuf->sourcefile; -    buf->header_source = Currentbuf->header_source; -    buf->search_header = Currentbuf->search_header; -#ifdef USE_M17N -    buf->document_charset = Currentbuf->document_charset; -#endif -    buf->clone = Currentbuf->clone; -    (*buf->clone)++; - -    buf->need_reshape = TRUE; -    reshapeBuffer(buf); -    pushBuffer(buf); -    displayBuffer(Currentbuf, B_NORMAL); -} - -/* reload */ -DEFUN(reload, RELOAD, "Reload buffer") -{ -    Buffer *buf, *fbuf = NULL, sbuf; -#ifdef USE_M17N -    wc_ces old_charset; -#endif -    Str url; -    FormList *request; -    int multipart; - -    if (Currentbuf->bufferprop & BP_INTERNAL) { -	if (!strcmp(Currentbuf->buffername, DOWNLOAD_LIST_TITLE)) { -	    ldDL(); -	    return; -	} -	/* FIXME: gettextize? */ -	disp_err_message("Can't reload...", TRUE); -	return; -    } -    if (Currentbuf->currentURL.scheme == SCM_LOCAL && -	!strcmp(Currentbuf->currentURL.file, "-")) { -	/* file is std input */ -	/* FIXME: gettextize? */ -	disp_err_message("Can't reload stdin", TRUE); -	return; -    } -    copyBuffer(&sbuf, Currentbuf); -    if (Currentbuf->bufferprop & BP_FRAME && -	(fbuf = Currentbuf->linkBuffer[LB_N_FRAME])) { -	if (fmInitialized) { -	    message("Rendering frame", 0, 0); -	    refresh(); -	} -	if (!(buf = renderFrame(fbuf, 1))) { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -	if (fbuf->linkBuffer[LB_FRAME]) { -	    if (buf->sourcefile && -		fbuf->linkBuffer[LB_FRAME]->sourcefile && -		!strcmp(buf->sourcefile, -			fbuf->linkBuffer[LB_FRAME]->sourcefile)) -		fbuf->linkBuffer[LB_FRAME]->sourcefile = NULL; -	    delBuffer(fbuf->linkBuffer[LB_FRAME]); -	} -	fbuf->linkBuffer[LB_FRAME] = buf; -	buf->linkBuffer[LB_N_FRAME] = fbuf; -	pushBuffer(buf); -	Currentbuf = buf; -	if (Currentbuf->firstLine) -	    restorePosition(Currentbuf, &sbuf); -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -	return; -    } -    else if (Currentbuf->frameset != NULL) -	fbuf = Currentbuf->linkBuffer[LB_FRAME]; -    multipart = 0; -    if (Currentbuf->form_submit) { -	request = Currentbuf->form_submit->parent; -	if (request->method == FORM_METHOD_POST -	    && request->enctype == FORM_ENCTYPE_MULTIPART) { -	    Str query; -	    struct stat st; -	    multipart = 1; -	    query_from_followform(&query, Currentbuf->form_submit, multipart); -	    stat(request->body, &st); -	    request->length = st.st_size; -	} -    } -    else { -	request = NULL; -    } -    url = parsedURL2Str(&Currentbuf->currentURL); -    /* FIXME: gettextize? */ -    message("Reloading...", 0, 0); -    refresh(); -#ifdef USE_M17N -    old_charset = DocumentCharset; -    if (Currentbuf->document_charset != WC_CES_US_ASCII) -	DocumentCharset = Currentbuf->document_charset; -#endif -    SearchHeader = Currentbuf->search_header; -    DefaultType = Currentbuf->real_type; -    buf = loadGeneralFile(url->ptr, NULL, NO_REFERER, RG_NOCACHE, request); -#ifdef USE_M17N -    DocumentCharset = old_charset; -#endif -    SearchHeader = FALSE; -    DefaultType = NULL; - -    if (multipart) -	unlink(request->body); -    if (buf == NULL) { -	/* FIXME: gettextize? */ -	disp_err_message("Can't reload...", TRUE); -	return; -    } -    else if (buf == NO_BUFFER) { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    if (fbuf != NULL) -	Firstbuf = deleteBuffer(Firstbuf, fbuf); -    repBuffer(Currentbuf, buf); -    if ((buf->type != NULL) && (sbuf.type != NULL) && -	((!strcasecmp(buf->type, "text/plain") && -	  !strcasecmp(sbuf.type, "text/html")) || -	 (!strcasecmp(buf->type, "text/html") && -	  !strcasecmp(sbuf.type, "text/plain")))) { -	vwSrc(); -	if (Currentbuf != buf) -	    Firstbuf = deleteBuffer(Firstbuf, buf); -    } -    Currentbuf->search_header = sbuf.search_header; -    Currentbuf->form_submit = sbuf.form_submit; -    if (Currentbuf->firstLine) -	restorePosition(Currentbuf, &sbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* reshape */ -DEFUN(reshape, RESHAPE, "Re-render buffer") -{ -    Currentbuf->need_reshape = TRUE; -    reshapeBuffer(Currentbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -#ifdef USE_M17N -static void -_docCSet(wc_ces charset) -{ -    if (Currentbuf->bufferprop & BP_INTERNAL) -	return; -    if (Currentbuf->sourcefile == NULL) { -	disp_message("Can't reload...", FALSE); -	return; -    } -    Currentbuf->document_charset = charset; -    Currentbuf->need_reshape = TRUE; -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -void -change_charset(struct parsed_tagarg *arg) -{ -    Buffer *buf = Currentbuf->linkBuffer[LB_N_INFO]; -    wc_ces charset; - -    if (buf == NULL) -	return; -    delBuffer(Currentbuf); -    Currentbuf = buf; -    if (Currentbuf->bufferprop & BP_INTERNAL) -	return; -    charset = Currentbuf->document_charset; -    for (; arg; arg = arg->next) { -	if (!strcmp(arg->arg, "charset")) -	    charset = atoi(arg->value); -    } -    _docCSet(charset); -} - -DEFUN(docCSet, CHARSET, "Change the current document charset") -{ -    char *cs; -    wc_ces charset; - -    cs = searchKeyData(); -    if (cs == NULL || *cs == '\0') -	/* FIXME: gettextize? */ -	cs = inputStr("Document charset: ", -		      wc_ces_to_charset(Currentbuf->document_charset)); -    charset = wc_guess_charset_short(cs, 0); -    if (charset == 0) { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    _docCSet(charset); -} - -DEFUN(defCSet, DEFAULT_CHARSET, "Change the default document charset") -{ -    char *cs; -    wc_ces charset; - -    cs = searchKeyData(); -    if (cs == NULL || *cs == '\0') -	/* FIXME: gettextize? */ -	cs = inputStr("Default document charset: ", -		      wc_ces_to_charset(DocumentCharset)); -    charset = wc_guess_charset_short(cs, 0); -    if (charset != 0) -	DocumentCharset = charset; -    displayBuffer(Currentbuf, B_NORMAL); -} -#endif - -/* mark URL-like patterns as anchors */ -void -chkURLBuffer(Buffer *buf) -{ -    static char *url_like_pat[] = { -	"https?://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$;]*[a-zA-Z0-9_/=\\-]", -	"file:/[a-zA-Z0-9:%\\-\\./=_\\+@#,\\$;]*", -#ifdef USE_GOPHER -	"gopher://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./_]*", -#endif				/* USE_GOPHER */ -	"ftp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./=_+@#,\\$]*[a-zA-Z0-9_/]", -#ifdef USE_NNTP -	"news:[^<> 	][^<> 	]*", -	"nntp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./_]*", -#endif				/* USE_NNTP */ -#ifndef USE_W3MMAILER		/* see also chkExternalURIBuffer() */ -	"mailto:[^<> 	][^<> 	]*@[a-zA-Z0-9][a-zA-Z0-9\\-\\._]*[a-zA-Z0-9]", -#endif -#ifdef INET6 -	"https?://[a-zA-Z0-9:%\\-\\./_@]*\\[[a-fA-F0-9:][a-fA-F0-9:\\.]*\\][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$;]*", -	"ftp://[a-zA-Z0-9:%\\-\\./_@]*\\[[a-fA-F0-9:][a-fA-F0-9:\\.]*\\][a-zA-Z0-9:%\\-\\./=_+@#,\\$]*", -#endif				/* INET6 */ -	NULL -    }; -    int i; -    for (i = 0; url_like_pat[i]; i++) { -	reAnchor(buf, url_like_pat[i]); -    } -#ifdef USE_EXTERNAL_URI_LOADER -    chkExternalURIBuffer(buf); -#endif -    buf->check_url |= CHK_URL; -} - -DEFUN(chkURL, MARK_URL, "Mark URL-like strings as anchors") -{ -    chkURLBuffer(Currentbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(chkWORD, MARK_WORD, "Mark current word as anchor") -{ -    char *p; -    int spos, epos; -    p = getCurWord(Currentbuf, &spos, &epos, ":\"\'`<>()[]{}&|;*?$"); -    if (p == NULL) -	return; -    reAnchorWord(Currentbuf, Currentbuf->currentLine, spos, epos); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -#ifdef USE_NNTP -/* mark Message-ID-like patterns as NEWS anchors */ -void -chkNMIDBuffer(Buffer *buf) -{ -    static char *url_like_pat[] = { -	"<[!-;=?-~]+@[a-zA-Z0-9\\.\\-_]+>", -	NULL, -    }; -    int i; -    for (i = 0; url_like_pat[i]; i++) { -	reAnchorNews(buf, url_like_pat[i]); -    } -    buf->check_url |= CHK_NMID; -} - -DEFUN(chkNMID, MARK_MID, "Mark Message-ID-like strings as anchors") -{ -    chkNMIDBuffer(Currentbuf); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} -#endif				/* USE_NNTP */ - -/* render frame */ -DEFUN(rFrame, FRAME, "Render frame") -{ -    Buffer *buf; - -    if ((buf = Currentbuf->linkBuffer[LB_FRAME]) != NULL) { -	Currentbuf = buf; -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    if (Currentbuf->frameset == NULL) { -	if ((buf = Currentbuf->linkBuffer[LB_N_FRAME]) != NULL) { -	    Currentbuf = buf; -	    displayBuffer(Currentbuf, B_NORMAL); -	} -	return; -    } -    if (fmInitialized) { -	message("Rendering frame", 0, 0); -	refresh(); -    } -    buf = renderFrame(Currentbuf, 0); -    if (buf == NULL) { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    buf->linkBuffer[LB_N_FRAME] = Currentbuf; -    Currentbuf->linkBuffer[LB_FRAME] = buf; -    pushBuffer(buf); -    if (fmInitialized && display_ok) -	displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -/* spawn external browser */ -static void -invoke_browser(char *url) -{ -    Str cmd; -    char *browser = NULL; -    int bg = 0, len; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    browser = searchKeyData(); -    if (browser == NULL || *browser == '\0') { -	switch (prec_num) { -	case 0: -	case 1: -	    browser = ExtBrowser; -	    break; -	case 2: -	    browser = ExtBrowser2; -	    break; -	case 3: -	    browser = ExtBrowser3; -	    break; -	} -	if (browser == NULL || *browser == '\0') { -	    browser = inputStr("Browse command: ", NULL); -	    if (browser != NULL) -		browser = conv_to_system(browser); -	} -    } -    else { -	browser = conv_to_system(browser); -    } -    if (browser == NULL || *browser == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } - -    if ((len = strlen(browser)) >= 2 && browser[len - 1] == '&' && -	browser[len - 2] != '\\') { -	browser = allocStr(browser, len - 2); -	bg = 1; -    } -    cmd = myExtCommand(browser, shell_quote(url), FALSE); -    Strremovetrailingspaces(cmd); -    fmTerm(); -    mySystem(cmd->ptr, bg); -    fmInit(); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(extbrz, EXTERN, "Execute external browser") -{ -    if (Currentbuf->bufferprop & BP_INTERNAL) { -	/* FIXME: gettextize? */ -	disp_err_message("Can't browse...", TRUE); -	return; -    } -    if (Currentbuf->currentURL.scheme == SCM_LOCAL && -	!strcmp(Currentbuf->currentURL.file, "-")) { -	/* file is std input */ -	/* FIXME: gettextize? */ -	disp_err_message("Can't browse stdin", TRUE); -	return; -    } -    invoke_browser(parsedURL2Str(&Currentbuf->currentURL)->ptr); -} - -DEFUN(linkbrz, EXTERN_LINK, "View current link using external browser") -{ -    Anchor *a; -    ParsedURL pu; - -    if (Currentbuf->firstLine == NULL) -	return; -    a = retrieveCurrentAnchor(Currentbuf); -    if (a == NULL) -	return; -    parseURL2(a->url, &pu, baseURL(Currentbuf)); -    invoke_browser(parsedURL2Str(&pu)->ptr); -} - -/* show current line number and number of lines in the entire document */ -DEFUN(curlno, LINE_INFO, "Show current line number") -{ -    Line *l = Currentbuf->currentLine; -    Str tmp; -    int cur = 0, all = 0, col = 0, len = 0; - -    if (l != NULL) { -	cur = l->real_linenumber; -	col = l->bwidth + Currentbuf->currentColumn + Currentbuf->cursorX + 1; -	while (l->next && l->next->bpos) -	    l = l->next; -	if (l->width < 0) -	    l->width = COLPOS(l, l->len); -	len = l->bwidth + l->width; -    } -    if (Currentbuf->lastLine) -	all = Currentbuf->lastLine->real_linenumber; -    if (Currentbuf->pagerSource && !(Currentbuf->bufferprop & BP_CLOSE)) -	tmp = Sprintf("line %d col %d/%d", cur, col, len); -    else -	tmp = Sprintf("line %d/%d (%d%%) col %d/%d", cur, all, -		      (int)((double)cur * 100.0 / (double)(all ? all : 1) -			    + 0.5), col, len); -#ifdef USE_M17N -    Strcat_charp(tmp, "  "); -    Strcat_charp(tmp, wc_ces_to_charset_desc(Currentbuf->document_charset)); -#endif - -    disp_message(tmp->ptr, FALSE); -} - -#ifdef USE_IMAGE -DEFUN(dispI, DISPLAY_IMAGE, "Restart loading and drawing of images") -{ -    if (!displayImage) -	initImage(); -    if (!activeImage) -	return; -    displayImage = TRUE; -    /* -     * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html"))) -     * return; -     */ -    Currentbuf->image_flag = IMG_FLAG_AUTO; -    Currentbuf->need_reshape = TRUE; -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} - -DEFUN(stopI, STOP_IMAGE, "Stop loading and drawing of images") -{ -    if (!activeImage) -	return; -    /* -     * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html"))) -     * return; -     */ -    Currentbuf->image_flag = IMG_FLAG_SKIP; -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} -#endif - -#ifdef USE_MOUSE - -static int -mouse_scroll_line(void) -{ -    if (relative_wheel_scroll) -	return (relative_wheel_scroll_ratio * LASTLINE + 99) / 100; -    else -	return fixed_wheel_scroll_count; -} - -static TabBuffer * -posTab(int x, int y) -{ -    TabBuffer *tab; - -    if (mouse_action.menu_str && x < mouse_action.menu_width && y == 0) -	return NO_TABBUFFER; -    if (y > LastTab->y) -	return NULL; -    for (tab = FirstTab; tab; tab = tab->nextTab) { -	if (tab->x1 <= x && x <= tab->x2 && tab->y == y) -	    return tab; -    } -    return NULL; -} - -static void -do_mouse_action(int btn, int x, int y) -{ -    MouseActionMap *map = NULL; -    int ny = -1; - -    if (nTab > 1 || mouse_action.menu_str) -	ny = LastTab->y + 1; - -    switch (btn) { -    case MOUSE_BTN1_DOWN: -	btn = 0; -	break; -    case MOUSE_BTN2_DOWN: -	btn = 1; -	break; -    case MOUSE_BTN3_DOWN: -	btn = 2; -	break; -    default: -	return; -    } -    if (y < ny) { -	if (mouse_action.menu_str && x >= 0 && x < mouse_action.menu_width) { -	    if (mouse_action.menu_map[btn]) -		map = &mouse_action.menu_map[btn][x]; -	} -	else -	    map = &mouse_action.tab_map[btn]; -    } -    else if (y == LASTLINE) { -	if (mouse_action.lastline_str && x >= 0 && -	    x < mouse_action.lastline_width) { -	    if (mouse_action.lastline_map[btn]) -		map = &mouse_action.lastline_map[btn][x]; -	} -    } -    else if (y > ny) { -	if (y == Currentbuf->cursorY + Currentbuf->rootY && -	    (x == Currentbuf->cursorX + Currentbuf->rootX -#ifdef USE_M17N -	     || (WcOption.use_wide && Currentbuf->currentLine != NULL && -		 (CharType(Currentbuf->currentLine->propBuf[Currentbuf->pos]) -		  == PC_KANJI1) -		 && x == Currentbuf->cursorX + Currentbuf->rootX + 1) -#endif -	    )) { -	    if (retrieveCurrentAnchor(Currentbuf) || -		retrieveCurrentForm(Currentbuf)) { -		map = &mouse_action.active_map[btn]; -		if (!(map && map->func)) -		    map = &mouse_action.anchor_map[btn]; -	    } -	} -	else { -	    int cx = Currentbuf->cursorX, cy = Currentbuf->cursorY; -	    cursorXY(Currentbuf, x - Currentbuf->rootX, y - Currentbuf->rootY); -	    if (y == Currentbuf->cursorY + Currentbuf->rootY && -		(x == Currentbuf->cursorX + Currentbuf->rootX -#ifdef USE_M17N -		 || (WcOption.use_wide && Currentbuf->currentLine != NULL && -		     (CharType(Currentbuf->currentLine-> -			       propBuf[Currentbuf->pos]) == PC_KANJI1) -		     && x == Currentbuf->cursorX + Currentbuf->rootX + 1) -#endif -		) && -		(retrieveCurrentAnchor(Currentbuf) || -		 retrieveCurrentForm(Currentbuf))) -		map = &mouse_action.anchor_map[btn]; -	    cursorXY(Currentbuf, cx, cy); -	} -    } -    if (!(map && map->func)) -	map = &mouse_action.default_map[btn]; -    if (map && map->func) { -	mouse_action.in_action = TRUE; -	mouse_action.cursorX = x; -	mouse_action.cursorY = y; -	CurrentKey = -1; -	CurrentKeyData = NULL; -	CurrentCmdData = map->data; -	(*map->func) (); -	CurrentCmdData = NULL; -    } -} - -static void -process_mouse(int btn, int x, int y) -{ -    int delta_x, delta_y, i; -    static int press_btn = MOUSE_BTN_RESET, press_x, press_y; -    TabBuffer *t; -    int ny = -1; - -    if (nTab > 1 || mouse_action.menu_str) -	ny = LastTab->y + 1; -    if (btn == MOUSE_BTN_UP) { -	switch (press_btn) { -	case MOUSE_BTN1_DOWN: -	    if (press_y == y && press_x == x) -		do_mouse_action(press_btn, x, y); -	    else if (ny > 0 && y < ny) { -		if (press_y < ny) { -		    moveTab(posTab(press_x, press_y), posTab(x, y), -			    (press_y == y) ? (press_x < x) : (press_y < y)); -		    return; -		} -		else if (press_x >= Currentbuf->rootX) { -		    Buffer *buf = Currentbuf; -		    int cx = Currentbuf->cursorX, cy = Currentbuf->cursorY; - -		    t = posTab(x, y); -		    if (t == NULL) -			return; -		    if (t == NO_TABBUFFER) -			t = NULL;	/* open new tab */ -		    cursorXY(Currentbuf, press_x - Currentbuf->rootX, -			     press_y - Currentbuf->rootY); -		    if (Currentbuf->cursorY == press_y - Currentbuf->rootY && -			(Currentbuf->cursorX == press_x - Currentbuf->rootX -#ifdef USE_M17N -			 || (WcOption.use_wide && -			     Currentbuf->currentLine != NULL && -			     (CharType(Currentbuf->currentLine-> -				       propBuf[Currentbuf->pos]) == PC_KANJI1) -			     && Currentbuf->cursorX == press_x -			     - Currentbuf->rootX - 1) -#endif -			)) { -			displayBuffer(Currentbuf, B_NORMAL); -			followTab(t); -		    } -		    if (buf == Currentbuf) -			cursorXY(Currentbuf, cx, cy); -		} -		return; -	    } -	    else { -		delta_x = x - press_x; -		delta_y = y - press_y; - -		if (abs(delta_x) < abs(delta_y) / 3) -		    delta_x = 0; -		if (abs(delta_y) < abs(delta_x) / 3) -		    delta_y = 0; -		if (reverse_mouse) { -		    delta_y = -delta_y; -		    delta_x = -delta_x; -		} -		if (delta_y > 0) { -		    prec_num = delta_y; -		    ldown1(); -		} -		else if (delta_y < 0) { -		    prec_num = -delta_y; -		    lup1(); -		} -		if (delta_x > 0) { -		    prec_num = delta_x; -		    col1L(); -		} -		else if (delta_x < 0) { -		    prec_num = -delta_x; -		    col1R(); -		} -	    } -	    break; -	case MOUSE_BTN2_DOWN: -	case MOUSE_BTN3_DOWN: -	    if (press_y == y && press_x == x) -		do_mouse_action(press_btn, x, y); -	    break; -	case MOUSE_BTN4_DOWN_RXVT: -	    for (i = 0; i < mouse_scroll_line(); i++) -		ldown1(); -	    break; -	case MOUSE_BTN5_DOWN_RXVT: -	    for (i = 0; i < mouse_scroll_line(); i++) -		lup1(); -	    break; -	} -    } -    else if (btn == MOUSE_BTN4_DOWN_XTERM) { -	for (i = 0; i < mouse_scroll_line(); i++) -	    ldown1(); -    } -    else if (btn == MOUSE_BTN5_DOWN_XTERM) { -	for (i = 0; i < mouse_scroll_line(); i++) -	    lup1(); -    } - -    if (btn != MOUSE_BTN4_DOWN_RXVT || press_btn == MOUSE_BTN_RESET) { -	press_btn = btn; -	press_x = x; -	press_y = y; -    } -    else { -	press_btn = MOUSE_BTN_RESET; -    } -} - -DEFUN(msToggle, MOUSE_TOGGLE, "Toggle activity of mouse") -{ -    if (use_mouse) { -	use_mouse = FALSE; -    } -    else { -	use_mouse = TRUE; -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(mouse, MOUSE, "mouse operation") -{ -    int btn, x, y; - -    btn = (unsigned char)getch() - 32; -#if defined(__CYGWIN__) && CYGWIN_VERSION_DLL_MAJOR < 1005 -    if (cygwin_mouse_btn_swapped) { -	if (btn == MOUSE_BTN2_DOWN) -	    btn = MOUSE_BTN3_DOWN; -	else if (btn == MOUSE_BTN3_DOWN) -	    btn = MOUSE_BTN2_DOWN; -    } -#endif -    x = (unsigned char)getch() - 33; -    if (x < 0) -	x += 0x100; -    y = (unsigned char)getch() - 33; -    if (y < 0) -	y += 0x100; - -    if (x < 0 || x >= COLS || y < 0 || y > LASTLINE) -	return; -    process_mouse(btn, x, y); -} - -#ifdef USE_GPM -int -gpm_process_mouse(Gpm_Event * event, void *data) -{ -    int btn = MOUSE_BTN_RESET, x, y; -    if (event->type & GPM_UP) -	btn = MOUSE_BTN_UP; -    else if (event->type & GPM_DOWN) { -	switch (event->buttons) { -	case GPM_B_LEFT: -	    btn = MOUSE_BTN1_DOWN; -	    break; -	case GPM_B_MIDDLE: -	    btn = MOUSE_BTN2_DOWN; -	    break; -	case GPM_B_RIGHT: -	    btn = MOUSE_BTN3_DOWN; -	    break; -	} -    } -    else { -	GPM_DRAWPOINTER(event); -	return 0; -    } -    x = event->x; -    y = event->y; -    process_mouse(btn, x - 1, y - 1); -    return 0; -} -#endif				/* USE_GPM */ - -#ifdef USE_SYSMOUSE -int -sysm_process_mouse(int x, int y, int nbs, int obs) -{ -    int btn; -    int bits; - -    if (obs & ~nbs) -	btn = MOUSE_BTN_UP; -    else if (nbs & ~obs) { -	bits = nbs & ~obs; -	btn = bits & 0x1 ? MOUSE_BTN1_DOWN : -	    (bits & 0x2 ? MOUSE_BTN2_DOWN : -	     (bits & 0x4 ? MOUSE_BTN3_DOWN : 0)); -    } -    else			/* nbs == obs */ -	return 0; -    process_mouse(btn, x, y); -    return 0; -} -#endif				/* USE_SYSMOUSE */ - -DEFUN(movMs, MOVE_MOUSE, "Move cursor to mouse cursor (for mouse action)") -{ -    if (!mouse_action.in_action) -	return; -    if ((nTab > 1 || mouse_action.menu_str) && -	mouse_action.cursorY < LastTab->y + 1) -	return; -    else if (mouse_action.cursorX >= Currentbuf->rootX && -	     mouse_action.cursorY < LASTLINE) { -	cursorXY(Currentbuf, mouse_action.cursorX - Currentbuf->rootX, -		 mouse_action.cursorY - Currentbuf->rootY); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -#ifdef USE_MENU -#ifdef KANJI_SYMBOLS -#define FRAME_WIDTH 2 -#else -#define FRAME_WIDTH 1 -#endif - -DEFUN(menuMs, MENU_MOUSE, "Popup menu at mouse cursor (for mouse action)") -{ -    if (!mouse_action.in_action) -	return; -    if ((nTab > 1 || mouse_action.menu_str) && -	mouse_action.cursorY < LastTab->y + 1) -	mouse_action.cursorX -= FRAME_WIDTH + 1; -    else if (mouse_action.cursorX >= Currentbuf->rootX && -	     mouse_action.cursorY < LASTLINE) { -	cursorXY(Currentbuf, mouse_action.cursorX - Currentbuf->rootX, -		 mouse_action.cursorY - Currentbuf->rootY); -	displayBuffer(Currentbuf, B_NORMAL); -    } -    mainMn(); -} -#endif - -DEFUN(tabMs, TAB_MOUSE, "Move to tab on mouse cursor (for mouse action)") -{ -    TabBuffer *tab; - -    if (!mouse_action.in_action) -	return; -    tab = posTab(mouse_action.cursorX, mouse_action.cursorY); -    if (!tab || tab == NO_TABBUFFER) -	return; -    CurrentTab = tab; -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(closeTMs, CLOSE_TAB_MOUSE, -      "Close tab on mouse cursor (for mouse action)") -{ -    TabBuffer *tab; - -    if (!mouse_action.in_action) -	return; -    tab = posTab(mouse_action.cursorX, mouse_action.cursorY); -    if (!tab || tab == NO_TABBUFFER) -	return; -    deleteTab(tab); -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} -#endif				/* USE_MOUSE */ - -DEFUN(dispVer, VERSION, "Display version of w3m") -{ -    disp_message(Sprintf("w3m version %s", w3m_version)->ptr, TRUE); -} - -DEFUN(wrapToggle, WRAP_TOGGLE, "Toggle wrap search mode") -{ -    if (WrapSearch) { -	WrapSearch = FALSE; -	/* FIXME: gettextize? */ -	disp_message("Wrap search off", TRUE); -    } -    else { -	WrapSearch = TRUE; -	/* FIXME: gettextize? */ -	disp_message("Wrap search on", TRUE); -    } -} - -static int -is_wordchar(int c, const char *badchars) -{ -    if (badchars) -	return !(IS_SPACE(c) || strchr(badchars, c)); -    else -	return IS_ALPHA(c); -} - -static char * -getCurWord(Buffer *buf, int *spos, int *epos, const char *badchars) -{ -    char *p; -    Line *l = buf->currentLine; -    int b, e; - -    *spos = 0; -    *epos = 0; -    if (l == NULL) -	return NULL; -    p = l->lineBuf; -    e = buf->pos; -    while (e > 0 && !is_wordchar(p[e], badchars)) -	e--; -    if (!is_wordchar(p[e], badchars)) -	return NULL; -    b = e; -    while (b > 0 && is_wordchar(p[b - 1], badchars)) -	b--; -    while (e < l->len && is_wordchar(p[e], badchars)) -	e++; -    *spos = b; -    *epos = e; -    return &p[b]; -} - -static char * -GetWord(Buffer *buf) -{ -    int b, e; -    char *p; - -    if ((p = getCurWord(buf, &b, &e, 0)) != NULL) { -	return Strnew_charp_n(p, e - b)->ptr; -    } -    return NULL; -} - -#ifdef USE_DICT -static void -execdict(char *word) -{ -    char *w, *dictcmd; -    Buffer *buf; - -    if (!UseDictCommand || word == NULL || *word == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    w = conv_to_system(word); -    if (*w == '\0') { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    dictcmd = Sprintf("%s?%s", DictCommand, -		      Str_form_quote(Strnew_charp(w))->ptr)->ptr; -    buf = loadGeneralFile(dictcmd, NULL, NO_REFERER, 0, NULL); -    if (buf == NULL) { -	disp_message("Execution failed", TRUE); -	return; -    } -    else { -	buf->filename = w; -	buf->buffername = Sprintf("%s %s", DICTBUFFERNAME, word)->ptr; -	if (buf->type == NULL) -	    buf->type = "text/plain"; -	pushBuffer(buf); -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(dictword, DICT_WORD, "Execute dictionary command (see README.dict)") -{ -    execdict(inputStr("(dictionary)!", "")); -} - -DEFUN(dictwordat, DICT_WORD_AT, -      "Execute dictionary command for word at cursor") -{ -    execdict(GetWord(Currentbuf)); -} -#endif				/* USE_DICT */ - -void -set_buffer_environ(Buffer *buf) -{ -    static Buffer *prev_buf = NULL; -    static Line *prev_line = NULL; -    static int prev_pos = -1; -    Line *l; - -    if (buf == NULL) -	return; -    if (buf != prev_buf) { -	set_environ("W3M_SOURCEFILE", buf->sourcefile); -	set_environ("W3M_FILENAME", buf->filename); -	set_environ("W3M_TITLE", buf->buffername); -	set_environ("W3M_URL", parsedURL2Str(&buf->currentURL)->ptr); -	set_environ("W3M_TYPE", buf->real_type ? buf->real_type : "unknown"); -#ifdef USE_M17N -	set_environ("W3M_CHARSET", wc_ces_to_charset(buf->document_charset)); -#endif -    } -    l = buf->currentLine; -    if (l && (buf != prev_buf || l != prev_line || buf->pos != prev_pos)) { -	Anchor *a; -	ParsedURL pu; -	char *s = GetWord(buf); -	set_environ("W3M_CURRENT_WORD", s ? s : ""); -	a = retrieveCurrentAnchor(buf); -	if (a) { -	    parseURL2(a->url, &pu, baseURL(buf)); -	    set_environ("W3M_CURRENT_LINK", parsedURL2Str(&pu)->ptr); -	} -	else -	    set_environ("W3M_CURRENT_LINK", ""); -	a = retrieveCurrentImg(buf); -	if (a) { -	    parseURL2(a->url, &pu, baseURL(buf)); -	    set_environ("W3M_CURRENT_IMG", parsedURL2Str(&pu)->ptr); -	} -	else -	    set_environ("W3M_CURRENT_IMG", ""); -	a = retrieveCurrentForm(buf); -	if (a) -	    set_environ("W3M_CURRENT_FORM", form2str((FormItemList *)a->url)); -	else -	    set_environ("W3M_CURRENT_FORM", ""); -	set_environ("W3M_CURRENT_LINE", Sprintf("%d", -						l->real_linenumber)->ptr); -	set_environ("W3M_CURRENT_COLUMN", Sprintf("%d", -						  buf->currentColumn + -						  buf->cursorX + 1)->ptr); -    } -    else if (!l) { -	set_environ("W3M_CURRENT_WORD", ""); -	set_environ("W3M_CURRENT_LINK", ""); -	set_environ("W3M_CURRENT_IMG", ""); -	set_environ("W3M_CURRENT_FORM", ""); -	set_environ("W3M_CURRENT_LINE", "0"); -	set_environ("W3M_CURRENT_COLUMN", "0"); -    } -    prev_buf = buf; -    prev_line = l; -    prev_pos = buf->pos; -} - -char * -searchKeyData(void) -{ -    char *data = NULL; - -    if (CurrentKeyData != NULL && *CurrentKeyData != '\0') -	data = CurrentKeyData; -    else if (CurrentCmdData != NULL && *CurrentCmdData != '\0') -	data = CurrentCmdData; -    else if (CurrentKey >= 0) -	data = getKeyData(CurrentKey); -    CurrentKeyData = NULL; -    CurrentCmdData = NULL; -    if (data == NULL || *data == '\0') -	return NULL; -    return allocStr(data, -1); -} - -static int -searchKeyNum(void) -{ -    char *d; -    int n = 1; - -    d = searchKeyData(); -    if (d != NULL) -	n = atoi(d); -    return n * PREC_NUM; -} - -#ifdef __EMX__ -#ifdef USE_M17N -static char * -getCodePage(void) -{ -    unsigned long CpList[8], CpSize; - -    if (!getenv("WINDOWID") && !DosQueryCp(sizeof(CpList), CpList, &CpSize)) -	return Sprintf("CP%d", *CpList)->ptr; -    return NULL; -} -#endif -#endif - -void -deleteFiles() -{ -    Buffer *buf; -    char *f; - -    for (CurrentTab = FirstTab; CurrentTab; CurrentTab = CurrentTab->nextTab) { -	while (Firstbuf && Firstbuf != NO_BUFFER) { -	    buf = Firstbuf->nextBuffer; -	    discardBuffer(Firstbuf); -	    Firstbuf = buf; -	} -    } -    while ((f = popText(fileToDelete)) != NULL) -	unlink(f); -} - -void -w3m_exit(int i) -{ -#ifdef USE_MIGEMO -    init_migemo();		/* close pipe to migemo */ -#endif -    stopDownload(); -    deleteFiles(); -#ifdef USE_SSL -    free_ssl_ctx(); -#endif -    disconnectFTP(); -#ifdef USE_NNTP -    disconnectNews(); -#endif -    exit(i); -} - -DEFUN(execCmd, COMMAND, "Execute w3m command(s)") -{ -    char *data, *p; -    int cmd; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    data = searchKeyData(); -    if (data == NULL || *data == '\0') { -	data = inputStrHist("command [; ...]: ", "", TextHist); -	if (data == NULL) { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    /* data: FUNC [DATA] [; FUNC [DATA] ...] */ -    while (*data) { -	SKIP_BLANKS(data); -	if (*data == ';') { -	    data++; -	    continue; -	} -	p = getWord(&data); -	cmd = getFuncList(p); -	if (cmd < 0) -	    break; -	p = getQWord(&data); -	CurrentKey = -1; -	CurrentKeyData = NULL; -	CurrentCmdData = *p ? p : NULL; -#ifdef USE_MOUSE -	if (use_mouse) -	    mouse_inactive(); -#endif -	w3mFuncList[cmd].func(); -#ifdef USE_MOUSE -	if (use_mouse) -	    mouse_active(); -#endif -	CurrentCmdData = NULL; -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -#ifdef USE_ALARM -static MySignalHandler -SigAlarm(SIGNAL_ARG) -{ -    char *data; - -    if (CurrentAlarm->sec > 0) { -	CurrentKey = -1; -	CurrentKeyData = NULL; -	CurrentCmdData = data = (char *)CurrentAlarm->data; -#ifdef USE_MOUSE -	if (use_mouse) -	    mouse_inactive(); -#endif -	w3mFuncList[CurrentAlarm->cmd].func(); -#ifdef USE_MOUSE -	if (use_mouse) -	    mouse_active(); -#endif -	CurrentCmdData = NULL; -	if (CurrentAlarm->status == AL_IMPLICIT_ONCE) { -	    CurrentAlarm->sec = 0; -	    CurrentAlarm->status = AL_UNSET; -	} -	if (Currentbuf->event) { -	    if (Currentbuf->event->status != AL_UNSET) -		CurrentAlarm = Currentbuf->event; -	    else -		Currentbuf->event = NULL; -	} -	if (!Currentbuf->event) -	    CurrentAlarm = &DefaultAlarm; -	if (CurrentAlarm->sec > 0) { -	    mySignal(SIGALRM, SigAlarm); -	    alarm(CurrentAlarm->sec); -	} -    } -    SIGNAL_RETURN; -} - - -DEFUN(setAlarm, ALARM, "Set alarm") -{ -    char *data; -    int sec = 0, cmd = -1; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    data = searchKeyData(); -    if (data == NULL || *data == '\0') { -	data = inputStrHist("(Alarm)sec command: ", "", TextHist); -	if (data == NULL) { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    if (*data != '\0') { -	sec = atoi(getWord(&data)); -	if (sec > 0) -	    cmd = getFuncList(getWord(&data)); -    } -    if (cmd >= 0) { -	data = getQWord(&data); -	setAlarmEvent(&DefaultAlarm, sec, AL_EXPLICIT, cmd, data); -	disp_message_nsec(Sprintf("%dsec %s %s", sec, w3mFuncList[cmd].id, -				  data)->ptr, FALSE, 1, FALSE, TRUE); -    } -    else { -	setAlarmEvent(&DefaultAlarm, 0, AL_UNSET, FUNCNAME_nulcmd, NULL); -    } -    displayBuffer(Currentbuf, B_NORMAL); -} - -AlarmEvent * -setAlarmEvent(AlarmEvent * event, int sec, short status, int cmd, void *data) -{ -    if (event == NULL) -	event = New(AlarmEvent); -    event->sec = sec; -    event->status = status; -    event->cmd = cmd; -    event->data = data; -    return event; -} -#endif - -DEFUN(reinit, REINIT, "Reload configuration files") -{ -    char *resource = searchKeyData(); - -    if (resource == NULL) { -	init_rc(); -	sync_with_option(); -#ifdef USE_COOKIE -	initCookie(); -#endif -	displayBuffer(Currentbuf, B_REDRAW_IMAGE); -	return; -    } - -    if (!strcasecmp(resource, "CONFIG") || !strcasecmp(resource, "RC")) { -	init_rc(); -	sync_with_option(); -	displayBuffer(Currentbuf, B_REDRAW_IMAGE); -	return; -    } - -#ifdef USE_COOKIE -    if (!strcasecmp(resource, "COOKIE")) { -	initCookie(); -	return; -    } -#endif - -    if (!strcasecmp(resource, "KEYMAP")) { -	initKeymap(TRUE); -	return; -    } - -    if (!strcasecmp(resource, "MAILCAP")) { -	initMailcap(); -	return; -    } - -#ifdef USE_MOUSE -    if (!strcasecmp(resource, "MOUSE")) { -	initMouseAction(); -	displayBuffer(Currentbuf, B_REDRAW_IMAGE); -	return; -    } -#endif - -#ifdef USE_MENU -    if (!strcasecmp(resource, "MENU")) { -	initMenu(); -	return; -    } -#endif - -    if (!strcasecmp(resource, "MIMETYPES")) { -	initMimeTypes(); -	return; -    } - -#ifdef USE_EXTERNAL_URI_LOADER -    if (!strcasecmp(resource, "URIMETHODS")) { -	initURIMethods(); -	return; -    } -#endif - -    disp_err_message(Sprintf("Don't know how to reinitialize '%s'", resource)-> -		     ptr, FALSE); -} - -DEFUN(defKey, DEFINE_KEY, -      "Define a binding between a key stroke and a user command") -{ -    char *data; - -    CurrentKeyData = NULL;	/* not allowed in w3m-control: */ -    data = searchKeyData(); -    if (data == NULL || *data == '\0') { -	data = inputStrHist("Key definition: ", "", TextHist); -	if (data == NULL || *data == '\0') { -	    displayBuffer(Currentbuf, B_NORMAL); -	    return; -	} -    } -    setKeymap(allocStr(data, -1), -1, TRUE); -    displayBuffer(Currentbuf, B_NORMAL); -} - -TabBuffer * -newTab(void) -{ -    TabBuffer *n; - -    n = New(TabBuffer); -    if (n == NULL) -	return NULL; -    n->nextTab = NULL; -    n->currentBuffer = NULL; -    n->firstBuffer = NULL; -    return n; -} - -static void -_newT(void) -{ -    TabBuffer *tag; -    Buffer *buf; -    int i; - -    tag = newTab(); -    if (!tag) -	return; - -    buf = newBuffer(Currentbuf->width); -    copyBuffer(buf, Currentbuf); -    buf->nextBuffer = NULL; -    for (i = 0; i < MAX_LB; i++) -	buf->linkBuffer[i] = NULL; -    (*buf->clone)++; -    tag->firstBuffer = tag->currentBuffer = buf; - -    tag->nextTab = CurrentTab->nextTab; -    tag->prevTab = CurrentTab; -    if (CurrentTab->nextTab) -	CurrentTab->nextTab->prevTab = tag; -    else -	LastTab = tag; -    CurrentTab->nextTab = tag; -    CurrentTab = tag; -    nTab++; -} - -DEFUN(newT, NEW_TAB, "Open new tab") -{ -    _newT(); -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} - -static TabBuffer * -numTab(int n) -{ -    TabBuffer *tab; -    int i; - -    if (n == 0) -	return CurrentTab; -    if (n == 1) -	return FirstTab; -    if (nTab <= 1) -	return NULL; -    for (tab = FirstTab, i = 1; tab && i < n; tab = tab->nextTab, i++) ; -    return tab; -} - -void -calcTabPos(void) -{ -    TabBuffer *tab; -#if 0 -    int lcol = 0, rcol = 2, col; -#else -    int lcol = 0, rcol = 0, col; -#endif -    int n1, n2, na, nx, ny, ix, iy; - -#ifdef USE_MOUSE -    lcol = mouse_action.menu_str ? mouse_action.menu_width : 0; -#endif - -    if (nTab <= 0) -	return; -    n1 = (COLS - rcol - lcol) / TabCols; -    if (n1 >= nTab) { -	n2 = 1; -	ny = 1; -    } -    else { -	if (n1 < 0) -	    n1 = 0; -	n2 = COLS / TabCols; -	if (n2 == 0) -	    n2 = 1; -	ny = (nTab - n1 - 1) / n2 + 2; -    } -    na = n1 + n2 * (ny - 1); -    n1 -= (na - nTab) / ny; -    if (n1 < 0) -	n1 = 0; -    na = n1 + n2 * (ny - 1); -    tab = FirstTab; -    for (iy = 0; iy < ny && tab; iy++) { -	if (iy == 0) { -	    nx = n1; -	    col = COLS - rcol - lcol; -	} -	else { -	    nx = n2 - (na - nTab + (iy - 1)) / (ny - 1); -	    col = COLS; -	} -	for (ix = 0; ix < nx && tab; ix++, tab = tab->nextTab) { -	    tab->x1 = col * ix / nx; -	    tab->x2 = col * (ix + 1) / nx - 1; -	    tab->y = iy; -	    if (iy == 0) { -		tab->x1 += lcol; -		tab->x2 += lcol; -	    } -	} -    } -} - -TabBuffer * -deleteTab(TabBuffer * tab) -{ -    Buffer *buf, *next; - -    if (nTab <= 1) -	return FirstTab; -    if (tab->prevTab) { -	if (tab->nextTab) -	    tab->nextTab->prevTab = tab->prevTab; -	else -	    LastTab = tab->prevTab; -	tab->prevTab->nextTab = tab->nextTab; -	if (tab == CurrentTab) -	    CurrentTab = tab->prevTab; -    } -    else {			/* tab == FirstTab */ -	tab->nextTab->prevTab = NULL; -	FirstTab = tab->nextTab; -	if (tab == CurrentTab) -	    CurrentTab = tab->nextTab; -    } -    nTab--; -    buf = tab->firstBuffer; -    while (buf && buf != NO_BUFFER) { -	next = buf->nextBuffer; -	discardBuffer(buf); -	buf = next; -    } -    return FirstTab; -} - -DEFUN(closeT, CLOSE_TAB, "Close current tab") -{ -    TabBuffer *tab; - -    if (nTab <= 1) -	return; -    if (prec_num) -	tab = numTab(PREC_NUM); -    else -	tab = CurrentTab; -    if (tab) -	deleteTab(tab); -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} - -DEFUN(nextT, NEXT_TAB, "Move to next tab") -{ -    int i; - -    if (nTab <= 1) -	return; -    for (i = 0; i < PREC_NUM; i++) { -	if (CurrentTab->nextTab) -	    CurrentTab = CurrentTab->nextTab; -	else -	    CurrentTab = FirstTab; -    } -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} - -DEFUN(prevT, PREV_TAB, "Move to previous tab") -{ -    int i; - -    if (nTab <= 1) -	return; -    for (i = 0; i < PREC_NUM; i++) { -	if (CurrentTab->prevTab) -	    CurrentTab = CurrentTab->prevTab; -	else -	    CurrentTab = LastTab; -    } -    displayBuffer(Currentbuf, B_REDRAW_IMAGE); -} - -void -followTab(TabBuffer * tab) -{ -    Buffer *buf; -    Anchor *a; - -#ifdef USE_IMAGE -    a = retrieveCurrentImg(Currentbuf); -    if (!(a && a->image && a->image->map)) -#endif -	a = retrieveCurrentAnchor(Currentbuf); -    if (a == NULL) -	return; - -    if (tab == CurrentTab) { -	check_target = FALSE; -	followA(); -	check_target = TRUE; -	return; -    } -    _newT(); -    buf = Currentbuf; -    check_target = FALSE; -    followA(); -    check_target = TRUE; -    if (tab == NULL) { -	if (buf != Currentbuf) -	    delBuffer(buf); -	else -	    deleteTab(CurrentTab); -    } -    else if (buf != Currentbuf) { -	/* buf <- p <- ... <- Currentbuf = c */ -	Buffer *c, *p; - -	c = Currentbuf; -	p = prevBuffer(c, buf); -	p->nextBuffer = NULL; -	Firstbuf = buf; -	deleteTab(CurrentTab); -	CurrentTab = tab; -	for (buf = p; buf; buf = p) { -	    p = prevBuffer(c, buf); -	    pushBuffer(buf); -	} -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(tabA, TAB_LINK, "Open current link on new tab") -{ -    followTab(prec_num ? numTab(PREC_NUM) : NULL); -} - -static void -tabURL0(TabBuffer * tab, char *prompt, int relative) -{ -    Buffer *buf; - -    if (tab == CurrentTab) { -	goURL0(prompt, relative); -	return; -    } -    _newT(); -    buf = Currentbuf; -    goURL0(prompt, relative); -    if (tab == NULL) { -	if (buf != Currentbuf) -	    delBuffer(buf); -	else -	    deleteTab(CurrentTab); -    } -    else if (buf != Currentbuf) { -	/* buf <- p <- ... <- Currentbuf = c */ -	Buffer *c, *p; - -	c = Currentbuf; -	p = prevBuffer(c, buf); -	p->nextBuffer = NULL; -	Firstbuf = buf; -	deleteTab(CurrentTab); -	CurrentTab = tab; -	for (buf = p; buf; buf = p) { -	    p = prevBuffer(c, buf); -	    pushBuffer(buf); -	} -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(tabURL, TAB_GOTO, "Open URL on new tab") -{ -    tabURL0(prec_num ? numTab(PREC_NUM) : NULL, -	    "Goto URL on new tab: ", FALSE); -} - -DEFUN(tabrURL, TAB_GOTO_RELATIVE, "Open relative URL on new tab") -{ -    tabURL0(prec_num ? numTab(PREC_NUM) : NULL, -	    "Goto relative URL on new tab: ", TRUE); -} - -void -moveTab(TabBuffer * t, TabBuffer * t2, int right) -{ -    if (t2 == NO_TABBUFFER) -	t2 = FirstTab; -    if (!t || !t2 || t == t2 || t == NO_TABBUFFER) -	return; -    if (t->prevTab) { -	if (t->nextTab) -	    t->nextTab->prevTab = t->prevTab; -	else -	    LastTab = t->prevTab; -	t->prevTab->nextTab = t->nextTab; -    } -    else { -	t->nextTab->prevTab = NULL; -	FirstTab = t->nextTab; -    } -    if (right) { -	t->nextTab = t2->nextTab; -	t->prevTab = t2; -	if (t2->nextTab) -	    t2->nextTab->prevTab = t; -	else -	    LastTab = t; -	t2->nextTab = t; -    } -    else { -	t->prevTab = t2->prevTab; -	t->nextTab = t2; -	if (t2->prevTab) -	    t2->prevTab->nextTab = t; -	else -	    FirstTab = t; -	t2->prevTab = t; -    } -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(tabR, TAB_RIGHT, "Move current tab right") -{ -    TabBuffer *tab; -    int i; - -    for (tab = CurrentTab, i = 0; tab && i < PREC_NUM; -	 tab = tab->nextTab, i++) ; -    moveTab(CurrentTab, tab ? tab : LastTab, TRUE); -} - -DEFUN(tabL, TAB_LEFT, "Move current tab left") -{ -    TabBuffer *tab; -    int i; - -    for (tab = CurrentTab, i = 0; tab && i < PREC_NUM; -	 tab = tab->prevTab, i++) ; -    moveTab(CurrentTab, tab ? tab : FirstTab, FALSE); -} - -void -addDownloadList(pid_t pid, char *url, char *save, char *lock, clen_t size) -{ -    DownloadList *d; - -    d = New(DownloadList); -    d->pid = pid; -    d->url = url; -    if (save[0] != '/' && save[0] != '~') -	save = Strnew_m_charp(CurrentDir, "/", save, NULL)->ptr; -    d->save = expandPath(save); -    d->lock = lock; -    d->size = size; -    d->time = time(0); -    d->ok = FALSE; -    d->next = NULL; -    d->prev = LastDL; -    if (LastDL) -	LastDL->next = d; -    else -	FirstDL = d; -    LastDL = d; -    add_download_list = TRUE; -} - -int -checkDownloadList(void) -{ -    DownloadList *d; -    struct stat st; - -    if (!FirstDL) -	return FALSE; -    for (d = FirstDL; d != NULL; d = d->next) { -	if (!d->ok && !lstat(d->lock, &st)) -	    return TRUE; -    } -    return FALSE; -} - -static char * -convert_size3(clen_t size) -{ -    Str tmp = Strnew(); -    int n; - -    do { -	n = size % 1000; -	size /= 1000; -	tmp = Sprintf(size ? ",%.3d%s" : "%d%s", n, tmp->ptr); -    } while (size); -    return tmp->ptr; -} - -static Buffer * -DownloadListBuffer(void) -{ -    DownloadList *d; -    Str src = NULL; -    struct stat st; -    time_t cur_time; -    int duration, rate, eta; -    size_t size; - -    if (!FirstDL) -	return NULL; -    cur_time = time(0); -    /* FIXME: gettextize? */ -    src = Strnew_charp("<html><head><title>" DOWNLOAD_LIST_TITLE -		       "</title></head>\n<body><h1 align=center>" -		       DOWNLOAD_LIST_TITLE "</h1>\n" -		       "<form method=internal action=download><hr>\n"); -    for (d = LastDL; d != NULL; d = d->prev) { -	if (lstat(d->lock, &st)) -	    d->ok = TRUE; -	Strcat_charp(src, "<pre>\n"); -	Strcat(src, Sprintf("%s\n  --> %s\n  ", html_quote(d->url), -			    html_quote(conv_from_system(d->save)))); -	duration = cur_time - d->time; -	if (!stat(d->save, &st)) { -	    size = st.st_size; -	    if (d->ok) { -		d->size = size; -		duration = st.st_mtime - d->time; -	    } -	} -	else -	    size = 0; -	if (d->size) { -	    int i, l = COLS - 6; -	    if (size < d->size) -		i = 1.0 * l * size / d->size; -	    else -		i = l; -	    l -= i; -	    while (i-- > 0) -		Strcat_char(src, '#'); -	    while (l-- > 0) -		Strcat_char(src, '_'); -	    Strcat_char(src, '\n'); -	} -	if (!d->ok && size < d->size) -	    Strcat(src, Sprintf("  %s / %s bytes (%d%%)", -				convert_size3(size), convert_size3(d->size), -				(int)(100.0 * size / d->size))); -	else -	    Strcat(src, Sprintf("  %s bytes loaded", convert_size3(size))); -	if (duration > 0) { -	    rate = size / duration; -	    Strcat(src, Sprintf("  %02d:%02d:%02d  rate %s/sec", -				duration / (60 * 60), (duration / 60) % 60, -				duration % 60, convert_size(rate, 1))); -	    if (!d->ok && size < d->size && rate) { -		eta = (d->size - size) / rate; -		Strcat(src, Sprintf("  eta %02d:%02d:%02d", eta / (60 * 60), -				    (eta / 60) % 60, eta % 60)); -	    } -	} -	Strcat_char(src, '\n'); -	if (d->ok) { -	    Strcat(src, Sprintf("<input type=submit name=ok%d value=OK>", -				d->pid)); -	    if (size < d->size) -		Strcat_charp(src, " Download incompleted"); -	    else -		Strcat_charp(src, " Download completed"); -	} -	else -	    Strcat(src, Sprintf("<input type=submit name=stop%d value=STOP>", -				d->pid)); -	Strcat_charp(src, "\n</pre><hr>\n"); -    } -    Strcat_charp(src, "</form></body></html>"); -    return loadHTMLString(src); -} - -void -download_action(struct parsed_tagarg *arg) -{ -    DownloadList *d; -    pid_t pid; - -    for (; arg; arg = arg->next) { -	if (!strncmp(arg->arg, "stop", 4)) { -	    pid = (pid_t) atoi(&arg->arg[4]); -	    kill(pid, SIGKILL); -	} -	else if (!strncmp(arg->arg, "ok", 2)) -	    pid = (pid_t) atoi(&arg->arg[2]); -	else -	    continue; -	for (d = FirstDL; d; d = d->next) { -	    if (d->pid == pid) { -		unlink(d->lock); -		if (d->prev) -		    d->prev->next = d->next; -		else -		    FirstDL = d->next; -		if (d->next) -		    d->next->prev = d->prev; -		else -		    LastDL = d->prev; -		break; -	    } -	} -    } -    ldDL(); -} - -void -stopDownload(void) -{ -    DownloadList *d; - -    if (!FirstDL) -	return; -    for (d = FirstDL; d != NULL; d = d->next) { -	if (d->ok) -	    continue; -	kill(d->pid, SIGKILL); -	unlink(d->lock); -    } -} - -/* download panel */ -DEFUN(ldDL, DOWNLOAD_LIST, "Display download list panel") -{ -    Buffer *buf; -    int replace = FALSE, new_tab = FALSE; -#ifdef USE_ALARM -    int reload; -#endif - -    if (Currentbuf->bufferprop & BP_INTERNAL && -	!strcmp(Currentbuf->buffername, DOWNLOAD_LIST_TITLE)) -	replace = TRUE; -    if (!FirstDL) { -	if (replace) { -	    if (Currentbuf == Firstbuf && Currentbuf->nextBuffer == NULL) { -		if (nTab > 1) -		    deleteTab(CurrentTab); -	    } -	    else -		delBuffer(Currentbuf); -	    displayBuffer(Currentbuf, B_FORCE_REDRAW); -	} -	return; -    } -#ifdef USE_ALARM -    reload = checkDownloadList(); -#endif -    buf = DownloadListBuffer(); -    if (!buf) { -	displayBuffer(Currentbuf, B_NORMAL); -	return; -    } -    buf->bufferprop |= (BP_INTERNAL | BP_NO_URL); -    if (replace) -	restorePosition(buf, Currentbuf); -    if (!replace && open_tab_dl_list) { -	_newT(); -	new_tab = TRUE; -    } -    pushBuffer(buf); -    if (replace || new_tab) -	deletePrevBuf(); -#ifdef USE_ALARM -    if (reload) -	Currentbuf->event = setAlarmEvent(Currentbuf->event, 1, AL_IMPLICIT, -					  FUNCNAME_reload, NULL); -#endif -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -static void -save_buffer_position(Buffer *buf) -{ -    BufferPos *b = buf->undo; - -    if (!buf->firstLine) -	return; -    if (b && b->top_linenumber == TOP_LINENUMBER(buf) && -	b->cur_linenumber == CUR_LINENUMBER(buf) && -	b->currentColumn == buf->currentColumn && b->pos == buf->pos) -	return; -    b = New(BufferPos); -    b->top_linenumber = TOP_LINENUMBER(buf); -    b->cur_linenumber = CUR_LINENUMBER(buf); -    b->currentColumn = buf->currentColumn; -    b->pos = buf->pos; -    b->bpos = buf->currentLine ? buf->currentLine->bpos : 0; -    b->next = NULL; -    b->prev = buf->undo; -    if (buf->undo) -	buf->undo->next = b; -    buf->undo = b; -} - -static void -resetPos(BufferPos * b) -{ -    Buffer buf; -    Line top, cur; - -    top.linenumber = b->top_linenumber; -    cur.linenumber = b->cur_linenumber; -    cur.bpos = b->bpos; -    buf.topLine = ⊤ -    buf.currentLine = &cur; -    buf.pos = b->pos; -    buf.currentColumn = b->currentColumn; -    restorePosition(Currentbuf, &buf); -    Currentbuf->undo = b; -    displayBuffer(Currentbuf, B_FORCE_REDRAW); -} - -DEFUN(undoPos, UNDO, "Cancel the last cursor movement") -{ -    BufferPos *b = Currentbuf->undo; -    int i; - -    if (!Currentbuf->firstLine) -	return; -    if (!b || !b->prev) -	return; -    for (i = 0; i < PREC_NUM && b->prev; i++, b = b->prev) ; -    resetPos(b); -} - -DEFUN(redoPos, REDO, "Cancel the last undo") -{ -    BufferPos *b = Currentbuf->undo; -    int i; - -    if (!Currentbuf->firstLine) -	return; -    if (!b || !b->next) -	return; -    for (i = 0; i < PREC_NUM && b->next; i++, b = b->next) ; -    resetPos(b); -} diff --git a/Bonus/CVS/Entries b/Bonus/CVS/Entries deleted file mode 100644 index b22f196..0000000 --- a/Bonus/CVS/Entries +++ /dev/null @@ -1,15 +0,0 @@ -/2ch.cgi/1.3/Sat Apr 26 17:01:02 2003// -/README/1.4/Wed Jan 15 15:51:29 2003// -/README.eng/1.4/Wed Jan 15 15:51:30 2003// -/backslash_to_slash.cgi/1.1/Tue Apr 15 14:46:23 2003// -/goodict.cgi/1.2/Sat Apr 12 14:28:56 2003// -/google.cgi/1.1/Fri Jan 10 16:24:01 2003// -/html2latex/1.2/Fri Nov  9 04:59:18 2001// -/htmldump/1.1.1.1/Thu Nov  8 05:16:01 2001// -/makeref/1.1.1.1/Thu Nov  8 05:16:01 2001// -/oldconfigure.sh/1.3/Wed Mar 12 17:20:47 2003// -/scanhist.rb/1.1.1.1/Thu Nov  8 05:16:01 2001// -/smb.cgi/1.3/Fri Jan 31 16:25:12 2003// -/utf8.cgi/1.1/Thu Feb 27 15:14:42 2003// -/wrap3m/1.1.1.1/Thu Nov  8 05:16:01 2001// -D diff --git a/Bonus/CVS/Repository b/Bonus/CVS/Repository deleted file mode 100644 index a8a0516..0000000 --- a/Bonus/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/Bonus diff --git a/Bonus/CVS/Root b/Bonus/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/Bonus/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/CVS/Entries b/CVS/Entries deleted file mode 100644 index 55c22e0..0000000 --- a/CVS/Entries +++ /dev/null @@ -1,114 +0,0 @@ -/.cvsignore/1.12/Fri Sep 26 20:45:53 2003// -/README/1.1.1.1/Thu Nov  8 05:14:08 2001// -/Str.c/1.8/Tue Dec 24 17:20:46 2002// -/Str.h/1.6/Fri Apr  7 13:35:35 2006// -/TODO/1.21/Sun Apr  4 16:47:20 2004// -/anchor.c/1.33/Sat Apr  8 11:33:16 2006// -/charset-list/1.1/Mon Sep 22 21:02:16 2003// -/config.guess/1.2/Wed Aug  4 17:32:27 2004// -/config.h.dist/1.36/Fri Apr  9 17:18:49 2004// -/config.sub/1.2/Wed Aug  4 17:32:27 2004// -/ctrlcode.h/1.3/Mon Sep 22 21:02:17 2003// -/entity.c/1.7/Wed Sep 24 18:48:59 2003// -/entity.tab/1.1/Fri Nov  9 04:59:17 2001// -/form.h/1.6/Mon Sep 22 21:02:18 2003// -/frame.c/1.34/Fri Sep 26 17:59:51 2003// -/frame.h/1.6/Sat Jan 25 17:42:17 2003// -/func.c/1.27/Fri Sep 26 17:59:51 2003// -/func.h/1.4/Tue Dec  3 16:01:33 2002// -/funcname0.awk/1.1.1.1/Thu Nov  8 05:14:56 2001// -/funcname1.awk/1.1.1.1/Thu Nov  8 05:14:56 2001// -/funcname2.awk/1.1.1.1/Thu Nov  8 05:14:56 2001// -/functable.awk/1.1/Mon Dec 10 17:02:44 2001// -/hash.c/1.5/Mon Apr  7 16:27:10 2003// -/hash.h/1.6/Wed Sep 24 18:48:59 2003// -/history.c/1.11/Fri Sep 26 17:59:51 2003// -/history.h/1.5/Sat Jan 26 17:24:01 2002// -/indep.h/1.16/Mon Sep 22 21:02:19 2003// -/inflate.c/1.7/Thu Jan 31 18:28:24 2002// -/islang.c/1.3/Sat Feb 26 17:06:44 2005// -/istream.h/1.12/Mon Oct 20 16:41:56 2003// -/local.h/1.3/Tue Nov 20 17:49:23 2001// -/map.c/1.30/Wed Sep 24 18:49:00 2003// -/matrix.c/1.8/Mon Apr  7 16:27:10 2003// -/matrix.h/1.7/Thu Jul 18 14:59:02 2002// -/menu.h/1.2/Tue Nov 20 17:49:23 2001// -/mimehead.c/1.10/Sun Oct  5 18:52:51 2003// -/mkinstalldirs/1.1/Tue Sep 23 18:42:25 2003// -/myctype.c/1.7/Mon Sep 22 21:02:20 2003// -/myctype.h/1.6/Mon Sep 22 21:02:20 2003// -/news.c/1.17/Sun Oct  5 18:52:51 2003// -/parsetag.c/1.4/Tue Nov 20 17:49:23 2001// -/parsetag.h/1.2/Tue Nov 20 17:49:23 2001// -/parsetagx.h/1.4/Sat Nov 24 02:01:26 2001// -/posubst.in/1.1/Thu Sep 25 18:15:47 2003// -/regex.h/1.6/Mon Sep 22 21:02:21 2003// -/scrsize.c/1.2/Sat Nov 24 02:01:26 2001// -/search.c/1.31/Tue Mar 23 16:44:02 2004// -/table.h/1.12/Mon Sep 22 21:02:21 2003// -/terms.h/1.10/Thu Jul 15 16:32:39 2004// -/textlist.c/1.6/Mon Apr  7 16:27:11 2003// -/textlist.h/1.6/Mon Jan 20 15:30:22 2003// -/w3mhelp-lynx_en.html.in/1.1/Fri Dec 21 22:02:39 2001// -/w3mhelp-lynx_ja.html.in/1.1/Fri Dec 21 22:02:39 2001// -/w3mhelp-w3m_en.html.in/1.1/Fri Dec 21 22:02:39 2001// -/w3mhelp-w3m_ja.html.in/1.1/Fri Dec 21 22:02:39 2001// -D/Bonus//// -D/Patches//// -D/Symbols//// -D/doc//// -D/doc-jp//// -D/gc//// -D/intl//// -D/libwc//// -D/po//// -D/scripts//// -D/w3m-doc//// -D/w3mimg//// -/keybind.c/1.10/Sat Jun 10 09:52:18 2006// -/keybind_lynx.c/1.8/Sat Jun 10 09:52:18 2006// -/parsetagx.c/1.18/Sat Jun 10 09:52:18 2006// -/mailcap.c/1.13/Tue Jan 23 12:24:11 2007// -/Makefile.in/1.44/Tue Jan  4 09:22:18 2011// -/acinclude.m4/1.45/Tue Jan  4 09:22:18 2011// -/aclocal.m4/1.46/Tue Jan  4 09:22:18 2011// -/backend.c/1.15/Tue Jan  4 09:22:19 2011// -/buffer.c/1.30/Tue Jan  4 09:22:19 2011// -/config.h.in/1.21/Tue Jan  4 09:22:19 2011// -/cookie.c/1.11/Tue Jan  4 09:22:20 2011// -/display.c/1.71/Tue Jan  4 09:22:20 2011// -/etc.c/1.81/Tue Jan  4 09:22:20 2011// -/file.c/1.265/Tue Jan  4 09:22:21 2011// -/fm.h/1.149/Tue Jan  4 09:22:21 2011// -/form.c/1.35/Tue Jan  4 09:22:21 2011// -/ftp.c/1.42/Tue Jan  4 09:22:21 2011// -/html.c/1.32/Tue Jan  4 09:22:21 2011// -/html.h/1.31/Tue Jan  4 09:22:21 2011// -/image.c/1.37/Tue Jan  4 09:22:22 2011// -/indep.c/1.38/Tue Jan  4 09:22:22 2011// -/istream.c/1.27/Tue Jan  4 09:22:22 2011// -/linein.c/1.35/Tue Jan  4 09:22:22 2011// -/local.c/1.35/Tue Jan  4 09:22:22 2011// -/menu.c/1.46/Tue Jan  4 09:22:23 2011// -/mktable.c/1.16/Tue Jan  4 09:22:23 2011// -/proto.h/1.104/Tue Jan  4 09:22:23 2011// -/rc.c/1.116/Tue Jan  4 09:22:23 2011// -/regex.c/1.23/Tue Jan  4 09:22:23 2011// -/symbol.c/1.4/Tue Jan  4 09:22:23 2011// -/table.c/1.58/Tue Jan  4 09:22:23 2011// -/tagtable.tab/1.14/Tue Jan  4 09:22:23 2011// -/terms.c/1.63/Tue Jan  4 09:22:23 2011// -/url.c/1.100/Tue Jan  4 09:22:24 2011// -/w3mbookmark.c/1.12/Tue Jan  4 09:22:24 2011// -/w3mhelperpanel.c/1.14/Tue Jan  4 09:22:24 2011// -/w3mimgdisplay.c/1.19/Tue Jan  4 09:22:24 2011// -/main.c/1.270/Tue Jan  4 09:42:19 2011// -/ABOUT-NLS/1.2/Tue Jan  4 12:39:27 2011// -/config.rpath/1.2/Tue Jan  4 12:39:29 2011// -/entity.h/1.6/Tue Jan  4 12:39:29 2011// -/install-sh/1.8/Tue Jan  4 12:39:29 2011// -/ChangeLog/1.1050/Sat Jan 15 07:52:48 2011// -/NEWS/1.80/Sat Jan 15 03:01:36 2011// -/configure/1.164/Sat Jan 15 03:04:22 2011// -/configure.ac/1.12/Sat Jan 15 03:01:55 2011// -/version.c.in/1.48/Sat Jan 15 07:52:48 2011// diff --git a/CVS/Repository b/CVS/Repository deleted file mode 100644 index 625add0..0000000 --- a/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m diff --git a/CVS/Root b/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -1,12 +1,178 @@ +2013-08-08  Tatsuya Kinoshita  <tats@debian.org> + +	* version.c.in: Update to 0.5.3+debian-11 + +2013-08-04  Tatsuya Kinoshita  <tats@debian.org> + +	* Str.c: Check length for Strchop() + +	* main.c: Fix potentially segfault of execdict() + +	* version.c.in: Update to 0.5.3+debian-10+ + +	* file.c: Fix segfault of loadGeneralFile() +	Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718612 + +2013-08-02  Tatsuya Kinoshita  <tats@debian.org> + +	* version.c.in: Update to 0.5.3+debian-10 + +2013-08-02  Piotr P. Karwasz <piotr.p@karwasz.org> + +	* scripts/w3mman/w3mman2html.cgi.in: +	Correct underline processing and more UTF-8 support for w3mman2html.cgi +	Patch from <https://bugs.launchpad.net/ubuntu/+source/w3m/+bug/680202> +	on 2010-11-23. + +2013-08-01  Hilko Bengen  <bengen@debian.org> + +	* entity.c: Ignore SOFT HYPHEN to prevent drawing hyphens everywhere +	Patch from <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441934> +	on 2011-03-01. + +2013-08-01  Tatsuya Kinoshita  <tats@debian.org> + +	* doc-jp/README, doc/README: Update contact list in README +	Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=696209 + +2013-07-30  Tatsuya Kinoshita  <tats@debian.org> + +	* config.guess, config.sub: +	Update config.guess and config.sub to supprot aarch64 +	Updated with Debian autotools-dev version 20130515.1. + +2013-07-30  Conrad J.C. Hughes  <debbugs@xrad.org> + +	* main.c: Sort anchors by sequence number in -dump +	Patch from <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657666> +	on 2012-01-27. + +2013-07-30  Tatsuya Kinoshita  <tats@debian.org> + +	* version.c.in: Update to 0.5.3+debian-9+ + +2013-07-29  Tatsuya Kinoshita  <tats@debian.org> + +	* version.c.in: Update version to w3m/0.5.3+debian-9 + +	* version.c.in: Set CURRENT_VERSION to debian version + +2013-07-28  Tatsuya Kinoshita  <tats@debian.org> + +	* file.c: Fix segfault of process_button() + +2013-04-08  AIDA Shinra  <shinra@j10n.org> + +	* file.c: One more patch for siteconf from [w3m-dev 04464] + +	* anchor.c, config.h.in, display.c, doc-jp/README.siteconf: +	* doc/README.siteconf, file.c, fm.h, form.c, frame.c, func.c: +	* history.c, indep.c, indep.h, linein.c, main.c, map.c, menu.c: +	* po/ja.po, proto.h, rc.c, url.c: Support the siteconf feature +	Patch to support the siteconf feature, from [w3m-dev 04463] +	on 2012-06-27. + +2013-04-08  Hayaki Saito  <user@zuse.jp> + +	* keybind.c, main.c, proto.h, terms.c: +	Support SGR 1006 mouse reporting +	Patch to support SGR 1006 mouse reporting, from [w3m-dev 04466] +	on 2012-07-15. + +2012-05-19  Hilko Bengen  <bengen@debian.org> + +	* form.c: Assume "text" if an input type is unknown +	Patch from <http://bugs.debian.org/615843> on 2011-03-01. + +2012-05-19  Simon Ruderich  <simon@ruderich.org> + +	* Makefile.in: Use $(CPPFLAGS) with $(CPP) +	Patch from <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665491> +	on 2012-03-24. + +2012-05-03  Miroslav Šulc  <fordfrog@gentoo.org> + +	* w3mimg/Makefile.in: Fix parallel make issue +	Patch from Gentoo +	<http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/www-client/w3m/files/w3m-0.5.3-parallel-make.patch?revision=1.1&view=markup> +	<https://bugs.gentoo.org/show_bug.cgi?id=353390> on 2011-02-01. + +2012-05-03  MATSUU Takuto  <matsuu@gentoo.org> + +	* main.c: Support Boehm GC 7.2 +	Patch from Gentoo +	<http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/www-client/w3m/files/w3m-0.5.2-gc72.patch?revision=1.1&view=markup> +	on 2009-12-13. + +2012-05-02  Reinhard Tartler  <siretart@tauware.de> + +	* istream.c, istream.h: +	Fix that struct file_handle conflicts with glibc 2.14 +	Patch from <https://bugs.launchpad.net/ubuntu/+source/w3m/+bug/935540> +	on 2012-02-19. + +2011-10-30  Colin Watson  <cjwatson@ubuntu.com> + +	* acinclude.m4, configure, w3mbookmark.c: +	Appease gcc -Werror=format-security. +	Patch from 0.5.3-3ubuntu1 on 2011-10-23. +	Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646321 + +2011-06-19  Martin Pitt  <martin.pitt@ubuntu.com> + +	* Makefile.in: +	Explicitly link w3mimgdisplay with -lX11 to build with gcc 4.5 +	Patch from 0.5.2-10ubuntu1 on 2010-12-03. +	Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=605761 + +2011-06-19  Fumitoshi UKAI  <ukai@debian.or.jp> + +	* main.c: +	Change the -s option to "squeeze multiple blank lines" for pager +	Change the -s option from "display charset Shift_JIS" to "squeeze +	multiple blank lines" to work as /usr/bin/pager.  In addition, the +	options -j and -e are disabled.  To specify the display charset, +	use -O{s|j|e} instead. +	Patch from [w3m-dev 01275] on 2000-10-26. +	Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=75527 + +2011-06-19  Hiroyuki Ito  <ZXB01226@nifty.com> + +	* file.c, fm.h, html.c, html.h, proto.h, table.c, tagtable.tab: +	Support the button element as defined in HTML 4.01 +	Patch from upstream, [w3m-dev 04411] on 2010-09-17, to support the +	button element.  It is discussed upstream and incomplete, but enough +	to login Launchpad. +	Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=136810 + +2012-05-22  Tatsuya Kinoshita <tats@vega.ocn.ne.jp> + +	* [w3m-dev 04451] w3m/entity.h should be removed when `make clean' +	* Makefile.in: add entity.h to "make clean" target. + +2012-05-22  Tatsuya Kinoshita <tats@vega.ocn.ne.jp> + +	* [w3m-dev 04452] Re: w3m on macosx 10.6.6 +	* doc/w3m.1, doc/STORY.html, doc-jp/STORY.html:  +	  delete words about formerly included Boehm GC library. + +2012-05-22  Enu <theme.of.n@gmail.com> + +	* file.c, HTML.c: parse META CHARSET. + +2011-01-17  Dai Sato <satodai@w3m.jp> + +	* correction: ChangeLog of 2011-01-15 (0.5.2 -> 0.5.3) +  2011-01-15  Dai Sato <satodai@w3m.jp> -	* w3m 0.5.2 +	* w3m 0.5.3  	* version.c.in: update -	* doc/README: version 0.5.2, release date, maintainer +	* doc/README: version 0.5.3, release date, maintainer  	* doc-jp/README: ditto  	* po/w3m.pot, ja.po: ditto  	* NEWS: update -	* configure.ac: version 0.5.2 +	* configure.ac: version 0.5.3  	* configure: regenerated  2011-01-05  SAKAI Kiyotaka <kiyotaka.sakai@ntt-at.co.jp> @@ -9300,4 +9466,4 @@ a	* [w3m-dev 03276] compile error on EWS4800  	* release-0-2-1  	* import w3m-0.2.1 -$Id: ChangeLog,v 1.1050 2011/01/15 07:52:48 inu Exp $ +$Id: ChangeLog,v 1.1055 2012/05/22 10:20:45 inu Exp $ diff --git a/Makefile.in b/Makefile.in index 0137211..339c95e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -150,7 +150,7 @@ parsetagx.o: html.c  funcname.tab: $(DEFUNS)  	(echo '#define DEFUN(x,y,z) x y';\ -	 sed -ne '/^DEFUN/{p;n;/^[ 	]/p;}' $(DEFUNS)) | $(CPP) - | \ +	 sed -ne '/^DEFUN/{p;n;/^[ 	]/p;}' $(DEFUNS)) | $(CPP) $(CPPFLAGS) - | \  	 awk '$$1 ~ /^[_A-Za-z]/ { \  	       for (i=2;i<=NF;i++) { print $$i, $$1} \  	 }' > $@.tmp @@ -199,7 +199,7 @@ dummy.o: entity.c  	$(CC) $(CFLAGS) -DDUMMY -c -o $@ $?  $(IMGDISPLAY): w3mimgdisplay.o $(ALIB) w3mimg/w3mimg.a -	$(IMGLINK) $(CFLAGS) -o $(IMGDISPLAY) w3mimgdisplay.o w3mimg/w3mimg.a $(LDFLAGS) $(LIBS) $(IMGLDFLAGS) +	$(IMGLINK) $(CFLAGS) -o $(IMGDISPLAY) w3mimgdisplay.o w3mimg/w3mimg.a $(LDFLAGS) $(LIBS) -lX11 $(IMGLDFLAGS)  w3mimgdisplay.o: w3mimgdisplay.c w3mimg/w3mimg.h  	$(CC) $(CFLAGS) $(IMGCFLAGS) -o $@ -c $(srcdir)/w3mimgdisplay.c @@ -288,7 +288,7 @@ uninstall:  clean: sweep  	-$(RM) -f *.o *.a $(TARGETS) mktable$(EXT)  	-$(RM) -f funcname.tab -	-$(RM) -f funcname.c funcname1.h funcname2.h tagtable.c functable.c +	-$(RM) -f entity.h funcname.c funcname1.h funcname2.h tagtable.c functable.c  	-for dir in w3mimg libwc; \  	do \  		(cd $$dir && $(MAKE) clean RM="$(RM)"); \ diff --git a/Patches/CVS/Entries b/Patches/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/Patches/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/Patches/CVS/Repository b/Patches/CVS/Repository deleted file mode 100644 index cd4278c..0000000 --- a/Patches/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/Patches diff --git a/Patches/CVS/Root b/Patches/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/Patches/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -278,8 +278,8 @@ void  Strchop(Str s)  {      STR_LENGTH_CHECK(s); -    while ((s->ptr[s->length - 1] == '\n' || s->ptr[s->length - 1] == '\r') && -	   s->length > 0) { +    while (s->length > 0 && +	   (s->ptr[s->length - 1] == '\n' || s->ptr[s->length - 1] == '\r')) {  	s->length--;      }      s->ptr[s->length] = '\0'; diff --git a/Symbols/CVS/Entries b/Symbols/CVS/Entries deleted file mode 100644 index dc12f1a..0000000 --- a/Symbols/CVS/Entries +++ /dev/null @@ -1,11 +0,0 @@ -/alt.sym/1.1/Mon Sep 22 21:02:22 2003// -/big5.sym/1.1/Mon Sep 22 21:02:22 2003// -/cp850.sym/1.1/Mon Sep 22 21:02:22 2003// -/euccn.sym/1.1/Mon Sep 22 21:02:22 2003// -/eucjp.sym/1.1/Mon Sep 22 21:02:22 2003// -/euckr.sym/1.1/Mon Sep 22 21:02:22 2003// -/euctw.sym/1.1/Mon Sep 22 21:02:22 2003// -/graph.sym/1.1/Mon Sep 22 21:02:22 2003// -/sym.pl/1.1/Mon Sep 22 21:02:22 2003// -/utf8.sym/1.1/Mon Sep 22 21:02:22 2003// -D diff --git a/Symbols/CVS/Repository b/Symbols/CVS/Repository deleted file mode 100644 index 9d32bc6..0000000 --- a/Symbols/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/Symbols diff --git a/Symbols/CVS/Root b/Symbols/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/Symbols/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/acinclude.m4 b/acinclude.m4 index e4ccc3d..52c8874 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -866,7 +866,7 @@ AC_MSG_CHECKING(for sys_errlist)  AC_TRY_COMPILE(  changequote(<<,>>)dnl  <<extern char *sys_errlist[];>>, -<<printf(sys_errlist[0]);>>, +<<printf("%s", sys_errlist[0]);>>,  changequote([,])dnl  [have_sys_errlist="yes"; AC_DEFINE(HAVE_SYS_ERRLIST)],  [have_sys_errlist="no"]) @@ -200,10 +200,11 @@ _put_anchor_news(Buffer *buf, char *p1, char *p2, int line, int pos)  	if (*(p2 - 1) == '>')  	    p2--;      } -    tmp = wc_Str_conv_strict(Strnew_charp_n(p1, p2 - p1), InnerCharset, -			     buf->document_charset); -    tmp = Sprintf("news:%s", file_quote(tmp->ptr)); -    return registerHref(buf, tmp->ptr, NULL, NO_REFERER, NULL, '\0', line, +    tmp = Strnew_charp("news:"); +    Strcat_charp_n(tmp, p1, p2 - p1); +    return registerHref(buf, url_encode(tmp->ptr, baseURL(buf), +					buf->document_charset), +			NULL, NO_REFERER, NULL, '\0', line,  			pos);  }  #endif				/* USE_NNTP */ @@ -213,9 +214,10 @@ _put_anchor_all(Buffer *buf, char *p1, char *p2, int line, int pos)  {      Str tmp; -    tmp = wc_Str_conv_strict(Strnew_charp_n(p1, p2 - p1), InnerCharset, -			     buf->document_charset); -    return registerHref(buf, url_quote(tmp->ptr), NULL, NO_REFERER, NULL, +    tmp = Strnew_charp_n(p1, p2 - p1); +    return registerHref(buf, url_encode(tmp->ptr, baseURL(buf), +					buf->document_charset), +			NULL, NO_REFERER, NULL,  			'\0', line, pos);  } @@ -756,7 +758,7 @@ link_list_panel(Buffer *buf)  		p = parsedURL2Str(&pu)->ptr;  		u = html_quote(p);  		if (DecodeURL) -		    p = html_quote(url_unquote_conv(p, buf->document_charset)); +		    p = html_quote(url_decode2(p, buf));  		else  		    p = u;  	    } @@ -787,7 +789,7 @@ link_list_panel(Buffer *buf)  	    p = parsedURL2Str(&pu)->ptr;  	    u = html_quote(p);  	    if (DecodeURL) -		p = html_quote(url_unquote_conv(p, buf->document_charset)); +		p = html_quote(url_decode2(p, buf));  	    else  		p = u;  	    t = getAnchorText(buf, al, a); @@ -809,16 +811,13 @@ link_list_panel(Buffer *buf)  	    p = parsedURL2Str(&pu)->ptr;  	    u = html_quote(p);  	    if (DecodeURL) -		p = html_quote(url_unquote_conv(p, buf->document_charset)); +		p = html_quote(url_decode2(p, buf));  	    else  		p = u;  	    if (a->title && *a->title)  		t = html_quote(a->title); -	    else if (DecodeURL) -		t = html_quote(url_unquote_conv -			       (a->url, buf->document_charset));  	    else -		t = html_quote(a->url); +		t = html_quote(url_decode2(a->url, buf));  	    Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", p,  			   "\n", NULL);  	    a = retrieveAnchor(buf->formitem, a->start.line, a->start.pos); @@ -842,19 +841,13 @@ link_list_panel(Buffer *buf)  		    p = parsedURL2Str(&pu)->ptr;  		    u = html_quote(p);  		    if (DecodeURL) -			p = html_quote(url_unquote_conv(p, -							buf-> -							document_charset)); +			p = html_quote(url_decode2(p, buf));  		    else  			p = u;  		    if (m->alt && *m->alt)  			t = html_quote(m->alt); -		    else if (DecodeURL) -			t = html_quote(url_unquote_conv(m->url, -							buf-> -							document_charset));  		    else -			t = html_quote(m->url); +			t = html_quote(url_decode2(m->url, buf));  		    Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t,  				   "</a><br>", p, "\n", NULL);  		} diff --git a/config.guess b/config.guess index 51fab47..120cc0d 100755 --- a/config.guess +++ b/config.guess @@ -1,13 +1,12 @@  #! /bin/sh  # Attempt to guess a canonical system name. -#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -#   2000, 2001, 2002, 2003 Free Software Foundation, Inc. +#   Copyright 1992-2013 Free Software Foundation, Inc. -timestamp='2004-03-12' +timestamp='2013-05-16'  # This file is free software; you can redistribute it and/or modify it  # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or  # (at your option) any later version.  #  # This program is distributed in the hope that it will be useful, but @@ -16,24 +15,22 @@ timestamp='2004-03-12'  # General Public License for more details.  #  # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>.  #  # As a special exception to the GNU General Public License, if you  # distribute this file as part of a program that contains a  # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner <per@bothner.com>. -# Please send patches to <config-patches@gnu.org>.  Submit a context -# diff and a properly formatted ChangeLog entry. +# the same distribution terms that you use for the rest of that +# program.  This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner.  # -# This script attempts to guess a canonical system name similar to -# config.sub.  If it succeeds, it prints the system name on stdout, and -# exits with 0.  Otherwise, it exits with 1. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD  # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# Please send patches with a ChangeLog entry to config-patches@gnu.org. +  me=`echo "$0" | sed -e 's,.*/,,'` @@ -53,8 +50,7 @@ version="\  GNU config.guess ($timestamp)  Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright 1992-2013 Free Software Foundation, Inc.  This is free software; see the source for copying conditions.  There is NO  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -66,11 +62,11 @@ Try \`$me --help' for more information."  while test $# -gt 0 ; do    case $1 in      --time-stamp | --time* | -t ) -       echo "$timestamp" ; exit 0 ;; +       echo "$timestamp" ; exit ;;      --version | -v ) -       echo "$version" ; exit 0 ;; +       echo "$version" ; exit ;;      --help | --h* | -h ) -       echo "$usage"; exit 0 ;; +       echo "$usage"; exit ;;      -- )     # Stop option processing         shift; break ;;      - )	# Use stdin as input. @@ -104,7 +100,7 @@ set_cc_for_build='  trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;  trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;  : ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||   { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||   { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||   { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; @@ -123,7 +119,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in  	;;   ,,*)   CC_FOR_BUILD=$CC ;;   ,*,*)  CC_FOR_BUILD=$HOST_CC ;; -esac ;' +esac ; set_cc_for_build= ;'  # This is needed to find uname on a Pyramid OSx when run in the BSD universe.  # (ghazi@noc.rutgers.edu 1994-08-24) @@ -136,12 +132,33 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown  UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown  UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) +	# If the system lacks a compiler, then just pick glibc. +	# We could probably try harder. +	LIBC=gnu + +	eval $set_cc_for_build +	cat <<-EOF > $dummy.c +	#include <features.h> +	#if defined(__UCLIBC__) +	LIBC=uclibc +	#elif defined(__dietlibc__) +	LIBC=dietlibc +	#else +	LIBC=gnu +	#endif +	EOF +	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` +	;; +esac +  # Note: order is significant - the case branches are not exclusive.  case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in      *:NetBSD:*:*)  	# NetBSD (nbsd) targets should (where applicable) match one or -	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, +	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,  	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently  	# switched to ELF, *-*-netbsd* would select the old  	# object file format.  This provides both forward @@ -158,6 +175,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	    arm*) machine=arm-unknown ;;  	    sh3el) machine=shl-unknown ;;  	    sh3eb) machine=sh-unknown ;; +	    sh5el) machine=sh5le-unknown ;;  	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;  	esac  	# The Operating System including object format, if it has switched @@ -166,7 +184,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)  		eval $set_cc_for_build  		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ -			| grep __ELF__ >/dev/null +			| grep -q __ELF__  		then  		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).  		    # Return netbsd for either.  FIX? @@ -176,7 +194,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  		fi  		;;  	    *) -	        os=netbsd +		os=netbsd  		;;  	esac  	# The OS release @@ -196,71 +214,34 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	# contains redundant information, the shorter form:  	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.  	echo "${machine}-${os}${release}" -	exit 0 ;; -    amd64:OpenBSD:*:*) -	echo x86_64-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    amiga:OpenBSD:*:*) -	echo m68k-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    arc:OpenBSD:*:*) -	echo mipsel-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    cats:OpenBSD:*:*) -	echo arm-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    hp300:OpenBSD:*:*) -	echo m68k-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    mac68k:OpenBSD:*:*) -	echo m68k-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    macppc:OpenBSD:*:*) -	echo powerpc-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    mvme68k:OpenBSD:*:*) -	echo m68k-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    mvme88k:OpenBSD:*:*) -	echo m88k-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    mvmeppc:OpenBSD:*:*) -	echo powerpc-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    pegasos:OpenBSD:*:*) -	echo powerpc-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    pmax:OpenBSD:*:*) -	echo mipsel-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    sgi:OpenBSD:*:*) -	echo mipseb-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    sun3:OpenBSD:*:*) -	echo m68k-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; -    wgrisc:OpenBSD:*:*) -	echo mipsel-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; +	exit ;; +    *:Bitrig:*:*) +	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` +	echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} +	exit ;;      *:OpenBSD:*:*) -	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} -	exit 0 ;; +	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` +	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} +	exit ;;      *:ekkoBSD:*:*)  	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} -	exit 0 ;; +	exit ;; +    *:SolidBSD:*:*) +	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} +	exit ;;      macppc:MirBSD:*:*) -	echo powerppc-unknown-mirbsd${UNAME_RELEASE} -	exit 0 ;; +	echo powerpc-unknown-mirbsd${UNAME_RELEASE} +	exit ;;      *:MirBSD:*:*)  	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      alpha:OSF1:*:*)  	case $UNAME_RELEASE in  	*4.0)  		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`  		;;  	*5.*) -	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` +		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`  		;;  	esac  	# According to Compaq, /usr/sbin/psrinfo has been available on @@ -306,40 +287,46 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	# A Xn.n version is an unreleased experimental baselevel.  	# 1.2 uses "1.2" for uname -r.  	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -	exit 0 ;; -    Alpha*:OpenVMS:*:*) -	echo alpha-hp-vms -	exit 0 ;; +	# Reset EXIT trap before exiting to avoid spurious non-zero exit code. +	exitcode=$? +	trap '' 0 +	exit $exitcode ;;      Alpha\ *:Windows_NT*:*)  	# How do we know it's Interix rather than the generic POSIX subsystem?  	# Should we change UNAME_MACHINE based on the output of uname instead  	# of the specific Alpha model?  	echo alpha-pc-interix -	exit 0 ;; +	exit ;;      21064:Windows_NT:50:3)  	echo alpha-dec-winnt3.5 -	exit 0 ;; +	exit ;;      Amiga*:UNIX_System_V:4.0:*)  	echo m68k-unknown-sysv4 -	exit 0;; +	exit ;;      *:[Aa]miga[Oo][Ss]:*:*)  	echo ${UNAME_MACHINE}-unknown-amigaos -	exit 0 ;; +	exit ;;      *:[Mm]orph[Oo][Ss]:*:*)  	echo ${UNAME_MACHINE}-unknown-morphos -	exit 0 ;; +	exit ;;      *:OS/390:*:*)  	echo i370-ibm-openedition -	exit 0 ;; +	exit ;; +    *:z/VM:*:*) +	echo s390-ibm-zvmoe +	exit ;;      *:OS400:*:*) -        echo powerpc-ibm-os400 -	exit 0 ;; +	echo powerpc-ibm-os400 +	exit ;;      arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)  	echo arm-acorn-riscix${UNAME_RELEASE} -	exit 0;; +	exit ;; +    arm*:riscos:*:*|arm*:RISCOS:*:*) +	echo arm-unknown-riscos +	exit ;;      SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)  	echo hppa1.1-hitachi-hiuxmpp -	exit 0;; +	exit ;;      Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)  	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.  	if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -347,32 +334,51 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	else  		echo pyramid-pyramid-bsd  	fi -	exit 0 ;; +	exit ;;      NILE*:*:*:dcosx)  	echo pyramid-pyramid-svr4 -	exit 0 ;; +	exit ;;      DRS?6000:unix:4.0:6*)  	echo sparc-icl-nx6 -	exit 0 ;; -    DRS?6000:UNIX_SV:4.2*:7*) +	exit ;; +    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)  	case `/usr/bin/uname -p` in -	    sparc) echo sparc-icl-nx7 && exit 0 ;; +	    sparc) echo sparc-icl-nx7; exit ;;  	esac ;; +    s390x:SunOS:*:*) +	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` +	exit ;;      sun4H:SunOS:5.*:*)  	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -	exit 0 ;; +	exit ;;      sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)  	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -	exit 0 ;; -    i86pc:SunOS:5.*:*) -	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -	exit 0 ;; +	exit ;; +    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) +	echo i386-pc-auroraux${UNAME_RELEASE} +	exit ;; +    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) +	eval $set_cc_for_build +	SUN_ARCH="i386" +	# If there is a compiler, see if it is configured for 64-bit objects. +	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does. +	# This test works for both compilers. +	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then +	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ +		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ +		grep IS_64BIT_ARCH >/dev/null +	    then +		SUN_ARCH="x86_64" +	    fi +	fi +	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` +	exit ;;      sun4*:SunOS:6*:*)  	# According to config.sub, this is the proper way to canonicalize  	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but  	# it's likely to be more like Solaris than SunOS4.  	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -	exit 0 ;; +	exit ;;      sun4*:SunOS:*:*)  	case "`/usr/bin/arch -k`" in  	    Series*|S4*) @@ -381,10 +387,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	esac  	# Japanese Language versions have a version number like `4.1.3-JL'.  	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` -	exit 0 ;; +	exit ;;      sun3*:SunOS:*:*)  	echo m68k-sun-sunos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      sun*:*:4.2BSD:*)  	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`  	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 @@ -396,10 +402,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  		echo sparc-sun-sunos${UNAME_RELEASE}  		;;  	esac -	exit 0 ;; +	exit ;;      aushp:SunOS:*:*)  	echo sparc-auspex-sunos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      # The situation for MiNT is a little confusing.  The machine name      # can be virtually everything (everything which is not      # "atarist" or "atariste" at least should have a processor @@ -409,41 +415,41 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in      # MiNT.  But MiNT is downward compatible to TOS, so this should      # be no problem.      atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) -        echo m68k-atari-mint${UNAME_RELEASE} -	exit 0 ;; +	echo m68k-atari-mint${UNAME_RELEASE} +	exit ;;      atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)  	echo m68k-atari-mint${UNAME_RELEASE} -        exit 0 ;; +	exit ;;      *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) -        echo m68k-atari-mint${UNAME_RELEASE} -	exit 0 ;; +	echo m68k-atari-mint${UNAME_RELEASE} +	exit ;;      milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) -        echo m68k-milan-mint${UNAME_RELEASE} -        exit 0 ;; +	echo m68k-milan-mint${UNAME_RELEASE} +	exit ;;      hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) -        echo m68k-hades-mint${UNAME_RELEASE} -        exit 0 ;; +	echo m68k-hades-mint${UNAME_RELEASE} +	exit ;;      *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) -        echo m68k-unknown-mint${UNAME_RELEASE} -        exit 0 ;; +	echo m68k-unknown-mint${UNAME_RELEASE} +	exit ;;      m68k:machten:*:*)  	echo m68k-apple-machten${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      powerpc:machten:*:*)  	echo powerpc-apple-machten${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      RISC*:Mach:*:*)  	echo mips-dec-mach_bsd4.3 -	exit 0 ;; +	exit ;;      RISC*:ULTRIX:*:*)  	echo mips-dec-ultrix${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      VAX*:ULTRIX*:*:*)  	echo vax-dec-ultrix${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      2020:CLIX:*:* | 2430:CLIX:*:*)  	echo clipper-intergraph-clix${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      mips:*:*:UMIPS | mips:*:*:RISCos)  	eval $set_cc_for_build  	sed 's/^	//' << EOF >$dummy.c @@ -467,35 +473,36 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in  	  exit (-1);  	}  EOF -	$CC_FOR_BUILD -o $dummy $dummy.c \ -	  && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ -	  && exit 0 +	$CC_FOR_BUILD -o $dummy $dummy.c && +	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && +	  SYSTEM_NAME=`$dummy $dummyarg` && +	    { echo "$SYSTEM_NAME"; exit; }  	echo mips-mips-riscos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      Motorola:PowerMAX_OS:*:*)  	echo powerpc-motorola-powermax -	exit 0 ;; +	exit ;;      Motorola:*:4.3:PL8-*)  	echo powerpc-harris-powermax -	exit 0 ;; +	exit ;;      Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)  	echo powerpc-harris-powermax -	exit 0 ;; +	exit ;;      Night_Hawk:Power_UNIX:*:*)  	echo powerpc-harris-powerunix -	exit 0 ;; +	exit ;;      m88k:CX/UX:7*:*)  	echo m88k-harris-cxux7 -	exit 0 ;; +	exit ;;      m88k:*:4*:R4*)  	echo m88k-motorola-sysv4 -	exit 0 ;; +	exit ;;      m88k:*:3*:R3*)  	echo m88k-motorola-sysv3 -	exit 0 ;; +	exit ;;      AViiON:dgux:*:*) -        # DG/UX returns AViiON for all architectures -        UNAME_PROCESSOR=`/usr/bin/uname -p` +	# DG/UX returns AViiON for all architectures +	UNAME_PROCESSOR=`/usr/bin/uname -p`  	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]  	then  	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -508,29 +515,29 @@ EOF  	else  	    echo i586-dg-dgux${UNAME_RELEASE}  	fi - 	exit 0 ;; +	exit ;;      M88*:DolphinOS:*:*)	# DolphinOS (SVR3)  	echo m88k-dolphin-sysv3 -	exit 0 ;; +	exit ;;      M88*:*:R3*:*)  	# Delta 88k system running SVR3  	echo m88k-motorola-sysv3 -	exit 0 ;; +	exit ;;      XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)  	echo m88k-tektronix-sysv3 -	exit 0 ;; +	exit ;;      Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)  	echo m68k-tektronix-bsd -	exit 0 ;; +	exit ;;      *:IRIX*:*:*)  	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` -	exit 0 ;; +	exit ;;      ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. -	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id -	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX ' +	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id +	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '      i*86:AIX:*:*)  	echo i386-ibm-aix -	exit 0 ;; +	exit ;;      ia64:AIX:*:*)  	if [ -x /usr/bin/oslevel ] ; then  		IBM_REV=`/usr/bin/oslevel` @@ -538,7 +545,7 @@ EOF  		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}  	fi  	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} -	exit 0 ;; +	exit ;;      *:AIX:2:3)  	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then  		eval $set_cc_for_build @@ -553,15 +560,19 @@ EOF  			exit(0);  			}  EOF -		$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 -		echo rs6000-ibm-aix3.2.5 +		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` +		then +			echo "$SYSTEM_NAME" +		else +			echo rs6000-ibm-aix3.2.5 +		fi  	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then  		echo rs6000-ibm-aix3.2.4  	else  		echo rs6000-ibm-aix3.2  	fi -	exit 0 ;; -    *:AIX:*:[45]) +	exit ;; +    *:AIX:*:[4567])  	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`  	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then  		IBM_ARCH=rs6000 @@ -574,28 +585,28 @@ EOF  		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}  	fi  	echo ${IBM_ARCH}-ibm-aix${IBM_REV} -	exit 0 ;; +	exit ;;      *:AIX:*:*)  	echo rs6000-ibm-aix -	exit 0 ;; +	exit ;;      ibmrt:4.4BSD:*|romp-ibm:BSD:*)  	echo romp-ibm-bsd4.4 -	exit 0 ;; +	exit ;;      ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and  	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to -	exit 0 ;;                           # report: romp-ibm BSD 4.3 +	exit ;;                             # report: romp-ibm BSD 4.3      *:BOSX:*:*)  	echo rs6000-bull-bosx -	exit 0 ;; +	exit ;;      DPX/2?00:B.O.S.:*:*)  	echo m68k-bull-sysv3 -	exit 0 ;; +	exit ;;      9000/[34]??:4.3bsd:1.*:*)  	echo m68k-hp-bsd -	exit 0 ;; +	exit ;;      hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)  	echo m68k-hp-bsd4.4 -	exit 0 ;; +	exit ;;      9000/[34678]??:HP-UX:*:*)  	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`  	case "${UNAME_MACHINE}" in @@ -604,52 +615,52 @@ EOF  	    9000/[678][0-9][0-9])  		if [ -x /usr/bin/getconf ]; then  		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` -                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` -                    case "${sc_cpu_version}" in -                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 -                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 -                      532)                      # CPU_PA_RISC2_0 -                        case "${sc_kernel_bits}" in -                          32) HP_ARCH="hppa2.0n" ;; -                          64) HP_ARCH="hppa2.0w" ;; +		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` +		    case "${sc_cpu_version}" in +		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 +		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 +		      532)                      # CPU_PA_RISC2_0 +			case "${sc_kernel_bits}" in +			  32) HP_ARCH="hppa2.0n" ;; +			  64) HP_ARCH="hppa2.0w" ;;  			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20 -                        esac ;; -                    esac +			esac ;; +		    esac  		fi  		if [ "${HP_ARCH}" = "" ]; then  		    eval $set_cc_for_build -		    sed 's/^              //' << EOF >$dummy.c +		    sed 's/^		//' << EOF >$dummy.c -              #define _HPUX_SOURCE -              #include <stdlib.h> -              #include <unistd.h> +		#define _HPUX_SOURCE +		#include <stdlib.h> +		#include <unistd.h> -              int main () -              { -              #if defined(_SC_KERNEL_BITS) -                  long bits = sysconf(_SC_KERNEL_BITS); -              #endif -                  long cpu  = sysconf (_SC_CPU_VERSION); +		int main () +		{ +		#if defined(_SC_KERNEL_BITS) +		    long bits = sysconf(_SC_KERNEL_BITS); +		#endif +		    long cpu  = sysconf (_SC_CPU_VERSION); -                  switch (cpu) -              	{ -              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break; -              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break; -              	case CPU_PA_RISC2_0: -              #if defined(_SC_KERNEL_BITS) -              	    switch (bits) -              		{ -              		case 64: puts ("hppa2.0w"); break; -              		case 32: puts ("hppa2.0n"); break; -              		default: puts ("hppa2.0"); break; -              		} break; -              #else  /* !defined(_SC_KERNEL_BITS) */ -              	    puts ("hppa2.0"); break; -              #endif -              	default: puts ("hppa1.0"); break; -              	} -                  exit (0); -              } +		    switch (cpu) +			{ +			case CPU_PA_RISC1_0: puts ("hppa1.0"); break; +			case CPU_PA_RISC1_1: puts ("hppa1.1"); break; +			case CPU_PA_RISC2_0: +		#if defined(_SC_KERNEL_BITS) +			    switch (bits) +				{ +				case 64: puts ("hppa2.0w"); break; +				case 32: puts ("hppa2.0n"); break; +				default: puts ("hppa2.0"); break; +				} break; +		#else  /* !defined(_SC_KERNEL_BITS) */ +			    puts ("hppa2.0"); break; +		#endif +			default: puts ("hppa1.0"); break; +			} +		    exit (0); +		}  EOF  		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`  		    test -z "$HP_ARCH" && HP_ARCH=hppa @@ -657,9 +668,19 @@ EOF  	esac  	if [ ${HP_ARCH} = "hppa2.0w" ]  	then -	    # avoid double evaluation of $set_cc_for_build -	    test -n "$CC_FOR_BUILD" || eval $set_cc_for_build -	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null +	    eval $set_cc_for_build + +	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating +	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler +	    # generating 64-bit code.  GNU and HP use different nomenclature: +	    # +	    # $ CC_FOR_BUILD=cc ./config.guess +	    # => hppa2.0w-hp-hpux11.23 +	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess +	    # => hppa64-hp-hpux11.23 + +	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | +		grep -q __LP64__  	    then  		HP_ARCH="hppa2.0w"  	    else @@ -667,11 +688,11 @@ EOF  	    fi  	fi  	echo ${HP_ARCH}-hp-hpux${HPUX_REV} -	exit 0 ;; +	exit ;;      ia64:HP-UX:*:*)  	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`  	echo ia64-hp-hpux${HPUX_REV} -	exit 0 ;; +	exit ;;      3050*:HI-UX:*:*)  	eval $set_cc_for_build  	sed 's/^	//' << EOF >$dummy.c @@ -699,340 +720,339 @@ EOF  	  exit (0);  	}  EOF -	$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 +	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && +		{ echo "$SYSTEM_NAME"; exit; }  	echo unknown-hitachi-hiuxwe2 -	exit 0 ;; +	exit ;;      9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )  	echo hppa1.1-hp-bsd -	exit 0 ;; +	exit ;;      9000/8??:4.3bsd:*:*)  	echo hppa1.0-hp-bsd -	exit 0 ;; +	exit ;;      *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)  	echo hppa1.0-hp-mpeix -	exit 0 ;; +	exit ;;      hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )  	echo hppa1.1-hp-osf -	exit 0 ;; +	exit ;;      hp8??:OSF1:*:*)  	echo hppa1.0-hp-osf -	exit 0 ;; +	exit ;;      i*86:OSF1:*:*)  	if [ -x /usr/sbin/sysversion ] ; then  	    echo ${UNAME_MACHINE}-unknown-osf1mk  	else  	    echo ${UNAME_MACHINE}-unknown-osf1  	fi -	exit 0 ;; +	exit ;;      parisc*:Lites*:*:*)  	echo hppa1.1-hp-lites -	exit 0 ;; +	exit ;;      C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)  	echo c1-convex-bsd -        exit 0 ;; +	exit ;;      C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)  	if getsysinfo -f scalar_acc  	then echo c32-convex-bsd  	else echo c2-convex-bsd  	fi -        exit 0 ;; +	exit ;;      C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)  	echo c34-convex-bsd -        exit 0 ;; +	exit ;;      C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)  	echo c38-convex-bsd -        exit 0 ;; +	exit ;;      C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)  	echo c4-convex-bsd -        exit 0 ;; +	exit ;;      CRAY*Y-MP:*:*:*)  	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -	exit 0 ;; +	exit ;;      CRAY*[A-Z]90:*:*:*)  	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \  	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \  	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \  	      -e 's/\.[^.]*$/.X/' -	exit 0 ;; +	exit ;;      CRAY*TS:*:*:*)  	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -	exit 0 ;; +	exit ;;      CRAY*T3E:*:*:*)  	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -	exit 0 ;; +	exit ;;      CRAY*SV1:*:*:*)  	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -	exit 0 ;; +	exit ;;      *:UNICOS/mp:*:*) -	echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' -	exit 0 ;; +	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' +	exit ;;      F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)  	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` -        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` -        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -        exit 0 ;; +	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` +	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` +	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" +	exit ;;      5000:UNIX_System_V:4.*:*) -        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` -        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` -        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" -	exit 0 ;; +	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` +	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` +	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" +	exit ;;      i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)  	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      sparc*:BSD/OS:*:*)  	echo sparc-unknown-bsdi${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:BSD/OS:*:*)  	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:FreeBSD:*:*) -	# Determine whether the default compiler uses glibc. -	eval $set_cc_for_build -	sed 's/^	//' << EOF >$dummy.c -	#include <features.h> -	#if __GLIBC__ >= 2 -	LIBC=gnu -	#else -	LIBC= -	#endif -EOF -	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` -	# GNU/KFreeBSD systems have a "k" prefix to indicate we are using -	# FreeBSD's kernel, but not the complete OS. -	case ${LIBC} in gnu) kernel_only='k' ;; esac -	echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} -	exit 0 ;; +	UNAME_PROCESSOR=`/usr/bin/uname -p` +	case ${UNAME_PROCESSOR} in +	    amd64) +		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; +	    *) +		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; +	esac +	exit ;;      i*:CYGWIN*:*)  	echo ${UNAME_MACHINE}-pc-cygwin -	exit 0 ;; -    i*:MINGW*:*) +	exit ;; +    *:MINGW64*:*) +	echo ${UNAME_MACHINE}-pc-mingw64 +	exit ;; +    *:MINGW*:*)  	echo ${UNAME_MACHINE}-pc-mingw32 -	exit 0 ;; +	exit ;; +    i*:MSYS*:*) +	echo ${UNAME_MACHINE}-pc-msys +	exit ;; +    i*:windows32*:*) +	# uname -m includes "-pc" on this system. +	echo ${UNAME_MACHINE}-mingw32 +	exit ;;      i*:PW*:*)  	echo ${UNAME_MACHINE}-pc-pw32 -	exit 0 ;; -    x86:Interix*:[34]*) -	echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' -	exit 0 ;; +	exit ;; +    *:Interix*:*) +	case ${UNAME_MACHINE} in +	    x86) +		echo i586-pc-interix${UNAME_RELEASE} +		exit ;; +	    authenticamd | genuineintel | EM64T) +		echo x86_64-unknown-interix${UNAME_RELEASE} +		exit ;; +	    IA64) +		echo ia64-unknown-interix${UNAME_RELEASE} +		exit ;; +	esac ;;      [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)  	echo i${UNAME_MACHINE}-pc-mks -	exit 0 ;; +	exit ;; +    8664:Windows_NT:*) +	echo x86_64-pc-mks +	exit ;;      i*:Windows_NT*:* | Pentium*:Windows_NT*:*)  	# How do we know it's Interix rather than the generic POSIX subsystem?  	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we  	# UNAME_MACHINE based on the output of uname instead of i386?  	echo i586-pc-interix -	exit 0 ;; +	exit ;;      i*:UWIN*:*)  	echo ${UNAME_MACHINE}-pc-uwin -	exit 0 ;; +	exit ;; +    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) +	echo x86_64-unknown-cygwin +	exit ;;      p*:CYGWIN*:*)  	echo powerpcle-unknown-cygwin -	exit 0 ;; +	exit ;;      prep*:SunOS:5.*:*)  	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` -	exit 0 ;; +	exit ;;      *:GNU:*:*)  	# the GNU system -	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` -	exit 0 ;; +	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` +	exit ;;      *:GNU/*:*:*)  	# other systems with GNU libc and userland -	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} +	exit ;;      i*86:Minix:*:*)  	echo ${UNAME_MACHINE}-pc-minix -	exit 0 ;; +	exit ;; +    aarch64:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    aarch64_be:Linux:*:*) +	UNAME_MACHINE=aarch64_be +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    alpha:Linux:*:*) +	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in +	  EV5)   UNAME_MACHINE=alphaev5 ;; +	  EV56)  UNAME_MACHINE=alphaev56 ;; +	  PCA56) UNAME_MACHINE=alphapca56 ;; +	  PCA57) UNAME_MACHINE=alphapca56 ;; +	  EV6)   UNAME_MACHINE=alphaev6 ;; +	  EV67)  UNAME_MACHINE=alphaev67 ;; +	  EV68*) UNAME_MACHINE=alphaev68 ;; +	esac +	objdump --private-headers /bin/sh | grep -q ld.so.1 +	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    arc:Linux:*:* | arceb:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      arm*:Linux:*:*) -	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; +	eval $set_cc_for_build +	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ +	    | grep -q __ARM_EABI__ +	then +	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	else +	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ +		| grep -q __ARM_PCS_VFP +	    then +		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi +	    else +		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf +	    fi +	fi +	exit ;; +    avr32*:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      cris:Linux:*:*) -	echo cris-axis-linux-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-axis-linux-${LIBC} +	exit ;; +    crisv32:Linux:*:*) +	echo ${UNAME_MACHINE}-axis-linux-${LIBC} +	exit ;; +    frv:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    hexagon:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    i*86:Linux:*:*) +	echo ${UNAME_MACHINE}-pc-linux-${LIBC} +	exit ;;      ia64:Linux:*:*) -	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      m32r*:Linux:*:*) -	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      m68*:Linux:*:*) -	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; -    mips:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    mips:Linux:*:* | mips64:Linux:*:*)  	eval $set_cc_for_build  	sed 's/^	//' << EOF >$dummy.c  	#undef CPU -	#undef mips -	#undef mipsel +	#undef ${UNAME_MACHINE} +	#undef ${UNAME_MACHINE}el  	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) -	CPU=mipsel +	CPU=${UNAME_MACHINE}el  	#else  	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) -	CPU=mips +	CPU=${UNAME_MACHINE}  	#else  	CPU=  	#endif  	#endif  EOF -	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` -	test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 +	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` +	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }  	;; -    mips64:Linux:*:*) -	eval $set_cc_for_build -	sed 's/^	//' << EOF >$dummy.c -	#undef CPU -	#undef mips64 -	#undef mips64el -	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) -	CPU=mips64el -	#else -	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) -	CPU=mips64 -	#else -	CPU= -	#endif -	#endif -EOF -	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` -	test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 -	;; -    ppc:Linux:*:*) -	echo powerpc-unknown-linux-gnu -	exit 0 ;; -    ppc64:Linux:*:*) -	echo powerpc64-unknown-linux-gnu -	exit 0 ;; -    alpha:Linux:*:*) -	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in -	  EV5)   UNAME_MACHINE=alphaev5 ;; -	  EV56)  UNAME_MACHINE=alphaev56 ;; -	  PCA56) UNAME_MACHINE=alphapca56 ;; -	  PCA57) UNAME_MACHINE=alphapca56 ;; -	  EV6)   UNAME_MACHINE=alphaev6 ;; -	  EV67)  UNAME_MACHINE=alphaev67 ;; -	  EV68*) UNAME_MACHINE=alphaev68 ;; -        esac -	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null -	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi -	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} -	exit 0 ;; +    or1k:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    or32:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    padre:Linux:*:*) +	echo sparc-unknown-linux-${LIBC} +	exit ;; +    parisc64:Linux:*:* | hppa64:Linux:*:*) +	echo hppa64-unknown-linux-${LIBC} +	exit ;;      parisc:Linux:*:* | hppa:Linux:*:*)  	# Look for CPU level  	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in -	  PA7*) echo hppa1.1-unknown-linux-gnu ;; -	  PA8*) echo hppa2.0-unknown-linux-gnu ;; -	  *)    echo hppa-unknown-linux-gnu ;; +	  PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; +	  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; +	  *)    echo hppa-unknown-linux-${LIBC} ;;  	esac -	exit 0 ;; -    parisc64:Linux:*:* | hppa64:Linux:*:*) -	echo hppa64-unknown-linux-gnu -	exit 0 ;; +	exit ;; +    ppc64:Linux:*:*) +	echo powerpc64-unknown-linux-${LIBC} +	exit ;; +    ppc:Linux:*:*) +	echo powerpc-unknown-linux-${LIBC} +	exit ;;      s390:Linux:*:* | s390x:Linux:*:*) -	echo ${UNAME_MACHINE}-ibm-linux -	exit 0 ;; +	echo ${UNAME_MACHINE}-ibm-linux-${LIBC} +	exit ;;      sh64*:Linux:*:*) -    	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      sh*:Linux:*:*) -	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      sparc:Linux:*:* | sparc64:Linux:*:*) -	echo ${UNAME_MACHINE}-unknown-linux-gnu -	exit 0 ;; +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    tile*:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    vax:Linux:*:*) +	echo ${UNAME_MACHINE}-dec-linux-${LIBC} +	exit ;;      x86_64:Linux:*:*) -	echo x86_64-unknown-linux-gnu -	exit 0 ;; -    i*86:Linux:*:*) -	# The BFD linker knows what the default object file format is, so -	# first see if it will tell us. cd to the root directory to prevent -	# problems with other programs or directories called `ld' in the path. -	# Set LC_ALL=C to ensure ld outputs messages in English. -	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ -			 | sed -ne '/supported targets:/!d -				    s/[ 	][ 	]*/ /g -				    s/.*supported targets: *// -				    s/ .*// -				    p'` -        case "$ld_supported_targets" in -	  elf32-i386) -		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" -		;; -	  a.out-i386-linux) -		echo "${UNAME_MACHINE}-pc-linux-gnuaout" -		exit 0 ;; -	  coff-i386) -		echo "${UNAME_MACHINE}-pc-linux-gnucoff" -		exit 0 ;; -	  "") -		# Either a pre-BFD a.out linker (linux-gnuoldld) or -		# one that does not give us useful --help. -		echo "${UNAME_MACHINE}-pc-linux-gnuoldld" -		exit 0 ;; -	esac -	# Determine whether the default compiler is a.out or elf -	eval $set_cc_for_build -	sed 's/^	//' << EOF >$dummy.c -	#include <features.h> -	#ifdef __ELF__ -	# ifdef __GLIBC__ -	#  if __GLIBC__ >= 2 -	LIBC=gnu -	#  else -	LIBC=gnulibc1 -	#  endif -	# else -	LIBC=gnulibc1 -	# endif -	#else -	#ifdef __INTEL_COMPILER -	LIBC=gnu -	#else -	LIBC=gnuaout -	#endif -	#endif -	#ifdef __dietlibc__ -	LIBC=dietlibc -	#endif -EOF -	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` -	test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 -	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 -	;; +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;; +    xtensa*:Linux:*:*) +	echo ${UNAME_MACHINE}-unknown-linux-${LIBC} +	exit ;;      i*86:DYNIX/ptx:4*:*)  	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  	# earlier versions are messed up and put the nodename in both  	# sysname and nodename.  	echo i386-sequent-sysv4 -	exit 0 ;; +	exit ;;      i*86:UNIX_SV:4.2MP:2.*) -        # Unixware is an offshoot of SVR4, but it has its own version -        # number series starting with 2... -        # I am not positive that other SVR4 systems won't match this, +	# Unixware is an offshoot of SVR4, but it has its own version +	# number series starting with 2... +	# I am not positive that other SVR4 systems won't match this,  	# I just have to hope.  -- rms. -        # Use sysv4.2uw... so that sysv4* matches it. +	# Use sysv4.2uw... so that sysv4* matches it.  	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} -	exit 0 ;; +	exit ;;      i*86:OS/2:*:*)  	# If we were able to find `uname', then EMX Unix compatibility  	# is probably installed.  	echo ${UNAME_MACHINE}-pc-os2-emx -	exit 0 ;; +	exit ;;      i*86:XTS-300:*:STOP)  	echo ${UNAME_MACHINE}-unknown-stop -	exit 0 ;; +	exit ;;      i*86:atheos:*:*)  	echo ${UNAME_MACHINE}-unknown-atheos -	exit 0 ;; -	i*86:syllable:*:*) +	exit ;; +    i*86:syllable:*:*)  	echo ${UNAME_MACHINE}-pc-syllable -	exit 0 ;; -    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) +	exit ;; +    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)  	echo i386-unknown-lynxos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      i*86:*DOS:*:*)  	echo ${UNAME_MACHINE}-pc-msdosdjgpp -	exit 0 ;; +	exit ;;      i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)  	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`  	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -1040,15 +1060,16 @@ EOF  	else  		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}  	fi -	exit 0 ;; -    i*86:*:5:[78]*) +	exit ;; +    i*86:*:5:[678]*) +	# UnixWare 7.x, OpenUNIX and OpenServer 6.  	case `/bin/uname -X | grep "^Machine"` in  	    *486*)	     UNAME_MACHINE=i486 ;;  	    *Pentium)	     UNAME_MACHINE=i586 ;;  	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;  	esac  	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} -	exit 0 ;; +	exit ;;      i*86:*:3.2:*)  	if test -f /usr/options/cb.name; then  		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` @@ -1066,73 +1087,86 @@ EOF  	else  		echo ${UNAME_MACHINE}-pc-sysv32  	fi -	exit 0 ;; +	exit ;;      pc:*:*:*)  	# Left here for compatibility: -        # uname -m prints for DJGPP always 'pc', but it prints nothing about -        # the processor, so we play safe by assuming i386. -	echo i386-pc-msdosdjgpp -        exit 0 ;; +	# uname -m prints for DJGPP always 'pc', but it prints nothing about +	# the processor, so we play safe by assuming i586. +	# Note: whatever this is, it MUST be the same as what config.sub +	# prints for the "djgpp" host, or else GDB configury will decide that +	# this is a cross-build. +	echo i586-pc-msdosdjgpp +	exit ;;      Intel:Mach:3*:*)  	echo i386-pc-mach3 -	exit 0 ;; +	exit ;;      paragon:*:*:*)  	echo i860-intel-osf1 -	exit 0 ;; +	exit ;;      i860:*:4.*:*) # i860-SVR4  	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then  	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4  	else # Add other i860-SVR4 vendors below as they are discovered.  	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4  	fi -	exit 0 ;; +	exit ;;      mini*:CTIX:SYS*5:*)  	# "miniframe"  	echo m68010-convergent-sysv -	exit 0 ;; +	exit ;;      mc68k:UNIX:SYSTEM5:3.51m)  	echo m68k-convergent-sysv -	exit 0 ;; +	exit ;;      M680?0:D-NIX:5.3:*)  	echo m68k-diab-dnix -	exit 0 ;; -    M68*:*:R3V[567]*:*) -	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; -    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) +	exit ;; +    M68*:*:R3V[5678]*:*) +	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; +    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)  	OS_REL=''  	test -r /etc/.relid \  	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`  	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0 +	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }  	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ -	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; +	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;      3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) -        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ -          && echo i486-ncr-sysv4 && exit 0 ;; +	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \ +	  && { echo i486-ncr-sysv4; exit; } ;; +    NCR*:*:4.2:* | MPRAS*:*:4.2:*) +	OS_REL='.3' +	test -r /etc/.relid \ +	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` +	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \ +	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; } +	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ +	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } +	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ +	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;      m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)  	echo m68k-unknown-lynxos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      mc68030:UNIX_System_V:4.*:*)  	echo m68k-atari-sysv4 -	exit 0 ;; +	exit ;;      TSUNAMI:LynxOS:2.*:*)  	echo sparc-unknown-lynxos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      rs6000:LynxOS:2.*:*)  	echo rs6000-unknown-lynxos${UNAME_RELEASE} -	exit 0 ;; -    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) +	exit ;; +    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)  	echo powerpc-unknown-lynxos${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      SM[BE]S:UNIX_SV:*:*)  	echo mips-dde-sysv${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      RM*:ReliantUNIX-*:*:*)  	echo mips-sni-sysv4 -	exit 0 ;; +	exit ;;      RM*:SINIX-*:*:*)  	echo mips-sni-sysv4 -	exit 0 ;; +	exit ;;      *:SINIX-*:*:*)  	if uname -p 2>/dev/null >/dev/null ; then  		UNAME_MACHINE=`(uname -p) 2>/dev/null` @@ -1140,68 +1174,99 @@ EOF  	else  		echo ns32k-sni-sysv  	fi -	exit 0 ;; -    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort -                      # says <Richard.M.Bartel@ccMail.Census.GOV> -        echo i586-unisys-sysv4 -        exit 0 ;; +	exit ;; +    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort +			# says <Richard.M.Bartel@ccMail.Census.GOV> +	echo i586-unisys-sysv4 +	exit ;;      *:UNIX_System_V:4*:FTX*)  	# From Gerald Hewes <hewes@openmarket.com>.  	# How about differentiating between stratus architectures? -djm  	echo hppa1.1-stratus-sysv4 -	exit 0 ;; +	exit ;;      *:*:*:FTX*)  	# From seanf@swdc.stratus.com.  	echo i860-stratus-sysv4 -	exit 0 ;; +	exit ;; +    i*86:VOS:*:*) +	# From Paul.Green@stratus.com. +	echo ${UNAME_MACHINE}-stratus-vos +	exit ;;      *:VOS:*:*)  	# From Paul.Green@stratus.com.  	echo hppa1.1-stratus-vos -	exit 0 ;; +	exit ;;      mc68*:A/UX:*:*)  	echo m68k-apple-aux${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      news*:NEWS-OS:6*:*)  	echo mips-sony-newsos6 -	exit 0 ;; +	exit ;;      R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)  	if [ -d /usr/nec ]; then -	        echo mips-nec-sysv${UNAME_RELEASE} +		echo mips-nec-sysv${UNAME_RELEASE}  	else -	        echo mips-unknown-sysv${UNAME_RELEASE} +		echo mips-unknown-sysv${UNAME_RELEASE}  	fi -        exit 0 ;; +	exit ;;      BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.  	echo powerpc-be-beos -	exit 0 ;; +	exit ;;      BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.  	echo powerpc-apple-beos -	exit 0 ;; +	exit ;;      BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.  	echo i586-pc-beos -	exit 0 ;; +	exit ;; +    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible. +	echo i586-pc-haiku +	exit ;; +    x86_64:Haiku:*:*) +	echo x86_64-unknown-haiku +	exit ;;      SX-4:SUPER-UX:*:*)  	echo sx4-nec-superux${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      SX-5:SUPER-UX:*:*)  	echo sx5-nec-superux${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      SX-6:SUPER-UX:*:*)  	echo sx6-nec-superux${UNAME_RELEASE} -	exit 0 ;; +	exit ;; +    SX-7:SUPER-UX:*:*) +	echo sx7-nec-superux${UNAME_RELEASE} +	exit ;; +    SX-8:SUPER-UX:*:*) +	echo sx8-nec-superux${UNAME_RELEASE} +	exit ;; +    SX-8R:SUPER-UX:*:*) +	echo sx8r-nec-superux${UNAME_RELEASE} +	exit ;;      Power*:Rhapsody:*:*)  	echo powerpc-apple-rhapsody${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:Rhapsody:*:*)  	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:Darwin:*:*) -	case `uname -p` in -	    *86) UNAME_PROCESSOR=i686 ;; -	    powerpc) UNAME_PROCESSOR=powerpc ;; -	esac +	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown +	eval $set_cc_for_build +	if test "$UNAME_PROCESSOR" = unknown ; then +	    UNAME_PROCESSOR=powerpc +	fi +	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then +	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ +		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ +		grep IS_64BIT_ARCH >/dev/null +	    then +		case $UNAME_PROCESSOR in +		    i386) UNAME_PROCESSOR=x86_64 ;; +		    powerpc) UNAME_PROCESSOR=powerpc64 ;; +		esac +	    fi +	fi  	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:procnto*:*:* | *:QNX:[0123456789]*:*)  	UNAME_PROCESSOR=`uname -p`  	if test "$UNAME_PROCESSOR" = "x86"; then @@ -1209,22 +1274,28 @@ EOF  		UNAME_MACHINE=pc  	fi  	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:QNX:*:4*)  	echo i386-pc-qnx -	exit 0 ;; +	exit ;; +    NEO-?:NONSTOP_KERNEL:*:*) +	echo neo-tandem-nsk${UNAME_RELEASE} +	exit ;; +    NSE-*:NONSTOP_KERNEL:*:*) +	echo nse-tandem-nsk${UNAME_RELEASE} +	exit ;;      NSR-?:NONSTOP_KERNEL:*:*)  	echo nsr-tandem-nsk${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:NonStop-UX:*:*)  	echo mips-compaq-nonstopux -	exit 0 ;; +	exit ;;      BS2000:POSIX*:*:*)  	echo bs2000-siemens-sysv -	exit 0 ;; +	exit ;;      DS/*:UNIX_System_V:*:*)  	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} -	exit 0 ;; +	exit ;;      *:Plan9:*:*)  	# "uname -m" is not consistent, so use $cputype instead. 386  	# is converted to i386 for consistency with other x86 @@ -1235,36 +1306,55 @@ EOF  	    UNAME_MACHINE="$cputype"  	fi  	echo ${UNAME_MACHINE}-unknown-plan9 -	exit 0 ;; +	exit ;;      *:TOPS-10:*:*)  	echo pdp10-unknown-tops10 -	exit 0 ;; +	exit ;;      *:TENEX:*:*)  	echo pdp10-unknown-tenex -	exit 0 ;; +	exit ;;      KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)  	echo pdp10-dec-tops20 -	exit 0 ;; +	exit ;;      XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)  	echo pdp10-xkl-tops20 -	exit 0 ;; +	exit ;;      *:TOPS-20:*:*)  	echo pdp10-unknown-tops20 -	exit 0 ;; +	exit ;;      *:ITS:*:*)  	echo pdp10-unknown-its -	exit 0 ;; +	exit ;;      SEI:*:*:SEIUX) -        echo mips-sei-seiux${UNAME_RELEASE} -	exit 0 ;; +	echo mips-sei-seiux${UNAME_RELEASE} +	exit ;;      *:DragonFly:*:*)  	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` -	exit 0 ;; +	exit ;; +    *:*VMS:*:*) +	UNAME_MACHINE=`(uname -p) 2>/dev/null` +	case "${UNAME_MACHINE}" in +	    A*) echo alpha-dec-vms ; exit ;; +	    I*) echo ia64-dec-vms ; exit ;; +	    V*) echo vax-dec-vms ; exit ;; +	esac ;; +    *:XENIX:*:SysV) +	echo i386-pc-xenix +	exit ;; +    i*86:skyos:*:*) +	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' +	exit ;; +    i*86:rdos:*:*) +	echo ${UNAME_MACHINE}-pc-rdos +	exit ;; +    i*86:AROS:*:*) +	echo ${UNAME_MACHINE}-pc-aros +	exit ;; +    x86_64:VMkernel:*:*) +	echo ${UNAME_MACHINE}-unknown-esx +	exit ;;  esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 -  eval $set_cc_for_build  cat >$dummy.c <<EOF  #ifdef _SEQUENT_ @@ -1282,16 +1372,16 @@ main ()  #include <sys/param.h>    printf ("m68k-sony-newsos%s\n",  #ifdef NEWSOS4 -          "4" +	"4"  #else -	  "" +	""  #endif -         ); exit (0); +	); exit (0);  #endif  #endif  #if defined (__arm) && defined (__acorn) && defined (__unix) -  printf ("arm-acorn-riscix"); exit (0); +  printf ("arm-acorn-riscix\n"); exit (0);  #endif  #if defined (hp300) && !defined (hpux) @@ -1380,11 +1470,12 @@ main ()  }  EOF -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && +	{ echo "$SYSTEM_NAME"; exit; }  # Apollos put the system type in the environment. -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }  # Convex versions that predate uname can use getsysinfo(1) @@ -1393,22 +1484,22 @@ then      case `getsysinfo -f cpu_type` in      c1*)  	echo c1-convex-bsd -	exit 0 ;; +	exit ;;      c2*)  	if getsysinfo -f scalar_acc  	then echo c32-convex-bsd  	else echo c2-convex-bsd  	fi -	exit 0 ;; +	exit ;;      c34*)  	echo c34-convex-bsd -	exit 0 ;; +	exit ;;      c38*)  	echo c38-convex-bsd -	exit 0 ;; +	exit ;;      c4*)  	echo c4-convex-bsd -	exit 0 ;; +	exit ;;      esac  fi @@ -1419,7 +1510,9 @@ This script, last modified $timestamp, has failed to recognize  the operating system you are using. It is advised that you  download the most up to date version of the config scripts from -    ftp://ftp.gnu.org/pub/gnu/config/ +  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +and +  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD  If the version you run ($0) is already up to date, please  send the following data and any information you think might be diff --git a/config.h.in b/config.h.in index 2f41eed..59997b4 100644 --- a/config.h.in +++ b/config.h.in @@ -25,6 +25,7 @@  #define PASSWD_FILE	RC_DIR "/passwd"  #define PRE_FORM_FILE	RC_DIR "/pre_form" +#define SITECONF_FILE	RC_DIR "/siteconf"  #define USER_MAILCAP	RC_DIR "/mailcap"  #define SYS_MAILCAP	CONF_DIR "/mailcap"  #define USER_MIMETYPES	"~/.mime.types" @@ -1,42 +1,40 @@  #! /bin/sh  # Configuration validation subroutine script. -#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -#   2000, 2001, 2002, 2003 Free Software Foundation, Inc. +#   Copyright 1992-2013 Free Software Foundation, Inc. -timestamp='2004-03-12' +timestamp='2013-04-24' -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine.  It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or  # (at your option) any later version.  # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +# General Public License for more details.  #  # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - +# along with this program; if not, see <http://www.gnu.org/licenses/>. +#  # As a special exception to the GNU General Public License, if you  # distribute this file as part of a program that contains a  # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program.  This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to <config-patches@gnu.org>.  Submit a context -# diff and a properly formatted ChangeLog entry. + +# Please send patches with a ChangeLog entry to config-patches@gnu.org.  #  # Configuration subroutine to validate and canonicalize a configuration type.  # Supply the specified configuration type as an argument.  # If it is invalid, we print an error message on stderr and exit with code 1.  # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +  # This file is supposed to be the same for all GNU packages  # and recognize all the CPU types, system types and aliases  # that are meaningful with *any* GNU software. @@ -70,8 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."  version="\  GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright 1992-2013 Free Software Foundation, Inc.  This is free software; see the source for copying conditions.  There is NO  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -83,11 +80,11 @@ Try \`$me --help' for more information."  while test $# -gt 0 ; do    case $1 in      --time-stamp | --time* | -t ) -       echo "$timestamp" ; exit 0 ;; +       echo "$timestamp" ; exit ;;      --version | -v ) -       echo "$version" ; exit 0 ;; +       echo "$version" ; exit ;;      --help | --h* | -h ) -       echo "$usage"; exit 0 ;; +       echo "$usage"; exit ;;      -- )     # Stop option processing         shift; break ;;      - )	# Use stdin as input. @@ -99,7 +96,7 @@ while test $# -gt 0 ; do      *local*)         # First pass through any local machine types.         echo $1 -       exit 0;; +       exit ;;      * )         break ;; @@ -118,11 +115,18 @@ esac  # Here we must recognize all the valid KERNEL-OS combinations.  maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`  case $maybe_os in -  nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ -  kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) +  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ +  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ +  knetbsd*-gnu* | netbsd*-gnu* | \ +  kopensolaris*-gnu* | \ +  storm-chaos* | os2-emx* | rtmk-nova*)      os=-$maybe_os      basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`      ;; +  android-linux) +    os=-linux-android +    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown +    ;;    *)      basic_machine=`echo $1 | sed 's/-[^-]*$//'`      if [ $basic_machine != $1 ] @@ -145,10 +149,13 @@ case $os in  	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\  	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \  	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -	-apple | -axis) +	-apple | -axis | -knuth | -cray | -microblaze*)  		os=  		basic_machine=$1  		;; +	-bluegene*) +		os=-cnk +		;;  	-sim | -cisco | -oki | -wec | -winbond)  		os=  		basic_machine=$1 @@ -163,13 +170,17 @@ case $os in  		os=-chorusos  		basic_machine=$1  		;; - 	-chorusrdb) - 		os=-chorusrdb +	-chorusrdb) +		os=-chorusrdb  		basic_machine=$1 - 		;; +		;;  	-hiux*)  		os=-hiuxwe2  		;; +	-sco6) +		os=-sco5v6 +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` +		;;  	-sco5)  		os=-sco3.2v5  		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -186,6 +197,10 @@ case $os in  		# Don't forget version if it is 3.2v4 or newer.  		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`  		;; +	-sco5v6*) +		# Don't forget version if it is 3.2v4 or newer. +		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` +		;;  	-sco*)  		os=-sco3.2v2  		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -203,6 +218,12 @@ case $os in  	-isc*)  		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`  		;; +	-lynx*178) +		os=-lynxos178 +		;; +	-lynx*5) +		os=-lynxos5 +		;;  	-lynx*)  		os=-lynxos  		;; @@ -227,57 +248,106 @@ case $basic_machine in  	# Some are omitted here because they have special meanings below.  	1750a | 580 \  	| a29k \ +	| aarch64 | aarch64_be \  	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \  	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \  	| am33_2.0 \ -	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ +	| arc | arceb \ +	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ +	| avr | avr32 \ +	| be32 | be64 \ +	| bfin \  	| c4x | clipper \  	| d10v | d30v | dlx | dsp16xx \ -	| fr30 | frv \ +	| epiphany \ +	| fido | fr30 | frv \  	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ +	| hexagon \  	| i370 | i860 | i960 | ia64 \  	| ip2k | iq2000 \ -	| m32r | m32rle | m68000 | m68k | m88k | mcore \ +	| le32 | le64 \ +	| lm32 \ +	| m32c | m32r | m32rle | m68000 | m68k | m88k \ +	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \  	| mips | mipsbe | mipseb | mipsel | mipsle \  	| mips16 \  	| mips64 | mips64el \ -	| mips64vr | mips64vrel \ +	| mips64octeon | mips64octeonel \  	| mips64orion | mips64orionel \ +	| mips64r5900 | mips64r5900el \ +	| mips64vr | mips64vrel \  	| mips64vr4100 | mips64vr4100el \  	| mips64vr4300 | mips64vr4300el \  	| mips64vr5000 | mips64vr5000el \ +	| mips64vr5900 | mips64vr5900el \  	| mipsisa32 | mipsisa32el \  	| mipsisa32r2 | mipsisa32r2el \  	| mipsisa64 | mipsisa64el \  	| mipsisa64r2 | mipsisa64r2el \  	| mipsisa64sb1 | mipsisa64sb1el \  	| mipsisa64sr71k | mipsisa64sr71kel \ +	| mipsr5900 | mipsr5900el \  	| mipstx39 | mipstx39el \  	| mn10200 | mn10300 \ +	| moxie \ +	| mt \  	| msp430 \ +	| nds32 | nds32le | nds32be \ +	| nios | nios2 | nios2eb | nios2el \  	| ns16k | ns32k \ -	| openrisc | or32 \ +	| open8 \ +	| or1k | or32 \  	| pdp10 | pdp11 | pj | pjl \ -	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ +	| powerpc | powerpc64 | powerpc64le | powerpcle \  	| pyramid \ -	| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ +	| rl78 | rx \ +	| score \ +	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \  	| sh64 | sh64le \ -	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ -	| strongarm \ -	| tahoe | thumb | tic4x | tic80 | tron \ -	| v850 | v850e \ +	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ +	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \ +	| spu \ +	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ +	| ubicom32 \ +	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \  	| we32k \ -	| x86 | xscale | xstormy16 | xtensa \ -	| z8k) +	| x86 | xc16x | xstormy16 | xtensa \ +	| z8k | z80)  		basic_machine=$basic_machine-unknown  		;; -	m6811 | m68hc11 | m6812 | m68hc12) -		# Motorola 68HC11/12. +	c54x) +		basic_machine=tic54x-unknown +		;; +	c55x) +		basic_machine=tic55x-unknown +		;; +	c6x) +		basic_machine=tic6x-unknown +		;; +	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)  		basic_machine=$basic_machine-unknown  		os=-none  		;;  	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)  		;; +	ms1) +		basic_machine=mt-unknown +		;; + +	strongarm | thumb | xscale) +		basic_machine=arm-unknown +		;; +	xgate) +		basic_machine=$basic_machine-unknown +		os=-none +		;; +	xscaleeb) +		basic_machine=armeb-unknown +		;; + +	xscaleel) +		basic_machine=armel-unknown +		;;  	# We use `pc' rather than `unknown'  	# because (1) that's what they normally are, and @@ -293,59 +363,82 @@ case $basic_machine in  	# Recognize the basic CPU types with company name.  	580-* \  	| a29k-* \ +	| aarch64-* | aarch64_be-* \  	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \  	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ -	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ +	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \  	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \ -	| avr-* \ -	| bs2000-* \ -	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ -	| clipper-* | cydra-* \ +	| avr-* | avr32-* \ +	| be32-* | be64-* \ +	| bfin-* | bs2000-* \ +	| c[123]* | c30-* | [cjt]90-* | c4x-* \ +	| clipper-* | craynv-* | cydra-* \  	| d10v-* | d30v-* | dlx-* \  	| elxsi-* \ -	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ +	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \  	| h8300-* | h8500-* \  	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ +	| hexagon-* \  	| i*86-* | i860-* | i960-* | ia64-* \  	| ip2k-* | iq2000-* \ -	| m32r-* | m32rle-* \ +	| le32-* | le64-* \ +	| lm32-* \ +	| m32c-* | m32r-* | m32rle-* \  	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ -	| m88110-* | m88k-* | mcore-* \ +	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ +	| microblaze-* | microblazeel-* \  	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \  	| mips16-* \  	| mips64-* | mips64el-* \ -	| mips64vr-* | mips64vrel-* \ +	| mips64octeon-* | mips64octeonel-* \  	| mips64orion-* | mips64orionel-* \ +	| mips64r5900-* | mips64r5900el-* \ +	| mips64vr-* | mips64vrel-* \  	| mips64vr4100-* | mips64vr4100el-* \  	| mips64vr4300-* | mips64vr4300el-* \  	| mips64vr5000-* | mips64vr5000el-* \ +	| mips64vr5900-* | mips64vr5900el-* \  	| mipsisa32-* | mipsisa32el-* \  	| mipsisa32r2-* | mipsisa32r2el-* \  	| mipsisa64-* | mipsisa64el-* \  	| mipsisa64r2-* | mipsisa64r2el-* \  	| mipsisa64sb1-* | mipsisa64sb1el-* \  	| mipsisa64sr71k-* | mipsisa64sr71kel-* \ +	| mipsr5900-* | mipsr5900el-* \  	| mipstx39-* | mipstx39el-* \ +	| mmix-* \ +	| mt-* \  	| msp430-* \ -	| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ +	| nds32-* | nds32le-* | nds32be-* \ +	| nios-* | nios2-* | nios2eb-* | nios2el-* \ +	| none-* | np1-* | ns16k-* | ns32k-* \ +	| open8-* \  	| orion-* \  	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ -	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ +	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \  	| pyramid-* \ -	| romp-* | rs6000-* \ -	| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ +	| rl78-* | romp-* | rs6000-* | rx-* \ +	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \  	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ -	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ -	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ -	| tahoe-* | thumb-* \ +	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ +	| sparclite-* \ +	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ +	| tahoe-* \  	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ +	| tile*-* \  	| tron-* \ -	| v850-* | v850e-* | vax-* \ +	| ubicom32-* \ +	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ +	| vax-* \  	| we32k-* \ -	| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ -	| xtensa-* \ +	| x86-* | x86_64-* | xc16x-* | xps100-* \ +	| xstormy16-* | xtensa*-* \  	| ymp-* \ -	| z8k-*) +	| z8k-* | z80-*) +		;; +	# Recognize the basic CPU types without company name, with glob match. +	xtensa*) +		basic_machine=$basic_machine-unknown  		;;  	# Recognize the various machine names and aliases which stand  	# for a CPU type and a company and sometimes even an OS. @@ -363,7 +456,7 @@ case $basic_machine in  		basic_machine=a29k-amd  		os=-udi  		;; -    	abacus) +	abacus)  		basic_machine=abacus-unknown  		;;  	adobe68k) @@ -409,6 +502,10 @@ case $basic_machine in  		basic_machine=m68k-apollo  		os=-bsd  		;; +	aros) +		basic_machine=i386-pc +		os=-aros +		;;  	aux)  		basic_machine=m68k-apple  		os=-aux @@ -417,10 +514,35 @@ case $basic_machine in  		basic_machine=ns32k-sequent  		os=-dynix  		;; +	blackfin) +		basic_machine=bfin-unknown +		os=-linux +		;; +	blackfin-*) +		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` +		os=-linux +		;; +	bluegene*) +		basic_machine=powerpc-ibm +		os=-cnk +		;; +	c54x-*) +		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` +		;; +	c55x-*) +		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` +		;; +	c6x-*) +		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` +		;;  	c90)  		basic_machine=c90-cray  		os=-unicos  		;; +	cegcc) +		basic_machine=arm-unknown +		os=-cegcc +		;;  	convex-c1)  		basic_machine=c1-convex  		os=-bsd @@ -445,13 +567,20 @@ case $basic_machine in  		basic_machine=j90-cray  		os=-unicos  		;; -	cr16c) -		basic_machine=cr16c-unknown +	craynv) +		basic_machine=craynv-cray +		os=-unicosmp +		;; +	cr16 | cr16-*) +		basic_machine=cr16-unknown  		os=-elf  		;;  	crds | unos)  		basic_machine=m68k-crds  		;; +	crisv32 | crisv32-* | etraxfs*) +		basic_machine=crisv32-axis +		;;  	cris | cris-* | etrax*)  		basic_machine=cris-axis  		;; @@ -481,6 +610,14 @@ case $basic_machine in  		basic_machine=m88k-motorola  		os=-sysv3  		;; +	dicos) +		basic_machine=i686-pc +		os=-dicos +		;; +	djgpp) +		basic_machine=i586-pc +		os=-msdosdjgpp +		;;  	dpx20 | dpx20-*)  		basic_machine=rs6000-bull  		os=-bosx @@ -592,7 +729,6 @@ case $basic_machine in  	i370-ibm* | ibm*)  		basic_machine=i370-ibm  		;; -# I'm not sure what "Sysv32" means.  Should this be sysv3.2?  	i*86v32)  		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`  		os=-sysv32 @@ -631,6 +767,14 @@ case $basic_machine in  		basic_machine=m68k-isi  		os=-sysv  		;; +	m68knommu) +		basic_machine=m68k-unknown +		os=-linux +		;; +	m68knommu-*) +		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` +		os=-linux +		;;  	m88k-omron*)  		basic_machine=m88k-omron  		;; @@ -642,10 +786,21 @@ case $basic_machine in  		basic_machine=ns32k-utek  		os=-sysv  		;; +	microblaze*) +		basic_machine=microblaze-xilinx +		;; +	mingw64) +		basic_machine=x86_64-pc +		os=-mingw64 +		;;  	mingw32)  		basic_machine=i386-pc  		os=-mingw32  		;; +	mingw32ce) +		basic_machine=arm-unknown +		os=-mingw32ce +		;;  	miniframe)  		basic_machine=m68000-convergent  		;; @@ -659,10 +814,6 @@ case $basic_machine in  	mips3*)  		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown  		;; -	mmix*) -		basic_machine=mmix-knuth -		os=-mmixware -		;;  	monitor)  		basic_machine=m68k-rom68k  		os=-coff @@ -675,10 +826,21 @@ case $basic_machine in  		basic_machine=i386-pc  		os=-msdos  		;; +	ms1-*) +		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` +		;; +	msys) +		basic_machine=i386-pc +		os=-msys +		;;  	mvs)  		basic_machine=i370-ibm  		os=-mvs  		;; +	nacl) +		basic_machine=le32-unknown +		os=-nacl +		;;  	ncr3000)  		basic_machine=i486-ncr  		os=-sysv4 @@ -743,9 +905,11 @@ case $basic_machine in  	np1)  		basic_machine=np1-gould  		;; -	nv1) -		basic_machine=nv1-cray -		os=-unicosmp +	neo-tandem) +		basic_machine=neo-tandem +		;; +	nse-tandem) +		basic_machine=nse-tandem  		;;  	nsr-tandem)  		basic_machine=nsr-tandem @@ -754,9 +918,8 @@ case $basic_machine in  		basic_machine=hppa1.1-oki  		os=-proelf  		;; -	or32 | or32-*) +	openrisc | openrisc-*)  		basic_machine=or32-unknown -		os=-coff  		;;  	os400)  		basic_machine=powerpc-ibm @@ -778,6 +941,14 @@ case $basic_machine in  		basic_machine=i860-intel  		os=-osf  		;; +	parisc) +		basic_machine=hppa-unknown +		os=-linux +		;; +	parisc-*) +		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` +		os=-linux +		;;  	pbd)  		basic_machine=sparc-tti  		;; @@ -787,6 +958,12 @@ case $basic_machine in  	pc532 | pc532-*)  		basic_machine=ns32k-pc532  		;; +	pc98) +		basic_machine=i386-pc +		;; +	pc98-*) +		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` +		;;  	pentium | p5 | k5 | k6 | nexgen | viac3)  		basic_machine=i586-pc  		;; @@ -816,9 +993,10 @@ case $basic_machine in  		;;  	power)	basic_machine=power-ibm  		;; -	ppc)	basic_machine=powerpc-unknown +	ppc | ppcbe)	basic_machine=powerpc-unknown  		;; -	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` +	ppc-* | ppcbe-*) +		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`  		;;  	ppcle | powerpclittle | ppc-le | powerpc-little)  		basic_machine=powerpcle-unknown @@ -843,6 +1021,14 @@ case $basic_machine in  		basic_machine=i586-unknown  		os=-pw32  		;; +	rdos | rdos64) +		basic_machine=x86_64-pc +		os=-rdos +		;; +	rdos32) +		basic_machine=i386-pc +		os=-rdos +		;;  	rom68k)  		basic_machine=m68k-rom68k  		os=-coff @@ -869,6 +1055,10 @@ case $basic_machine in  	sb1el)  		basic_machine=mipsisa64sb1el-unknown  		;; +	sde) +		basic_machine=mipsisa32-sde +		os=-elf +		;;  	sei)  		basic_machine=mips-sei  		os=-seiux @@ -880,6 +1070,9 @@ case $basic_machine in  		basic_machine=sh-hitachi  		os=-hms  		;; +	sh5el) +		basic_machine=sh5le-unknown +		;;  	sh64)  		basic_machine=sh64-unknown  		;; @@ -901,6 +1094,9 @@ case $basic_machine in  		basic_machine=i860-stratus  		os=-sysv4  		;; +	strongarm-* | thumb-*) +		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` +		;;  	sun2)  		basic_machine=m68000-sun  		;; @@ -957,17 +1153,9 @@ case $basic_machine in  		basic_machine=t90-cray  		os=-unicos  		;; -	tic54x | c54x*) -		basic_machine=tic54x-unknown -		os=-coff -		;; -	tic55x | c55x*) -		basic_machine=tic55x-unknown -		os=-coff -		;; -	tic6x | c6x*) -		basic_machine=tic6x-unknown -		os=-coff +	tile*) +		basic_machine=$basic_machine-unknown +		os=-linux-gnu  		;;  	tx39)  		basic_machine=mipstx39-unknown @@ -1029,9 +1217,16 @@ case $basic_machine in  		basic_machine=hppa1.1-winbond  		os=-proelf  		;; +	xbox) +		basic_machine=i686-pc +		os=-mingw32 +		;;  	xps | xps100)  		basic_machine=xps100-honeywell  		;; +	xscale-* | xscalee[bl]-*) +		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` +		;;  	ymp)  		basic_machine=ymp-cray  		os=-unicos @@ -1040,6 +1235,10 @@ case $basic_machine in  		basic_machine=z8k-unknown  		os=-sim  		;; +	z80-*-coff) +		basic_machine=z80-unknown +		os=-sim +		;;  	none)  		basic_machine=none-none  		os=-none @@ -1059,6 +1258,9 @@ case $basic_machine in  	romp)  		basic_machine=romp-ibm  		;; +	mmix) +		basic_machine=mmix-knuth +		;;  	rs6000)  		basic_machine=rs6000-ibm  		;; @@ -1075,13 +1277,10 @@ case $basic_machine in  	we32k)  		basic_machine=we32k-att  		;; -	sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) +	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)  		basic_machine=sh-unknown  		;; -	sh64) -		basic_machine=sh64-unknown -		;; -	sparc | sparcv8 | sparcv9 | sparcv9b) +	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)  		basic_machine=sparc-sun  		;;  	cydra) @@ -1125,9 +1324,12 @@ esac  if [ x"$os" != x"" ]  then  case $os in -        # First match some system type aliases -        # that might get confused with valid system types. +	# First match some system type aliases +	# that might get confused with valid system types.  	# -solaris* is a basic system type, with this one exception. +	-auroraux) +		os=-auroraux +		;;  	-solaris1 | -solaris1.*)  		os=`echo $os | sed -e 's|solaris1|sunos4|'`  		;; @@ -1148,26 +1350,31 @@ case $os in  	# Each alternative MUST END IN A *, to match a version number.  	# -sysv* is not here because it comes later, after sysvr4.  	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ -	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ +	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ +	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ +	      | -sym* | -kopensolaris* | -plan9* \  	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ -	      | -aos* \ +	      | -aos* | -aros* \  	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \  	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ -	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ +	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +	      | -bitrig* | -openbsd* | -solidbsd* \  	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \  	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \  	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \  	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ -	      | -chorusos* | -chorusrdb* \ -	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ -	      | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ +	      | -chorusos* | -chorusrdb* | -cegcc* \ +	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ +	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ +	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \ +	      | -uxpv* | -beos* | -mpeix* | -udk* \  	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \  	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \  	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \  	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \  	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ -	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) +	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ +	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)  	# Remember, each alternative MUST END IN *, to match a version number.  		;;  	-qnx*) @@ -1185,7 +1392,7 @@ case $os in  		os=`echo $os | sed -e 's|nto|nto-qnx|'`  		;;  	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ +	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \  	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)  		;;  	-mac*) @@ -1206,7 +1413,7 @@ case $os in  	-opened*)  		os=-openedition  		;; -        -os400*) +	-os400*)  		os=-os400  		;;  	-wince*) @@ -1255,7 +1462,7 @@ case $os in  	-sinix*)  		os=-sysv4  		;; -        -tpf*) +	-tpf*)  		os=-tpf  		;;  	-triton*) @@ -1291,8 +1498,13 @@ case $os in  	-aros*)  		os=-aros  		;; -	-kaos*) -		os=-kaos +	-zvmoe) +		os=-zvmoe +		;; +	-dicos*) +		os=-dicos +		;; +	-nacl*)  		;;  	-none)  		;; @@ -1316,6 +1528,12 @@ else  # system, and we'll never get to this point.  case $basic_machine in +	score-*) +		os=-elf +		;; +	spu-*) +		os=-elf +		;;  	*-acorn)  		os=-riscix1.2  		;; @@ -1325,9 +1543,21 @@ case $basic_machine in  	arm*-semi)  		os=-aout  		;; -    c4x-* | tic4x-*) -        os=-coff -        ;; +	c4x-* | tic4x-*) +		os=-coff +		;; +	hexagon-*) +		os=-elf +		;; +	tic54x-*) +		os=-coff +		;; +	tic55x-*) +		os=-coff +		;; +	tic6x-*) +		os=-coff +		;;  	# This must come before the *-dec entry.  	pdp10-*)  		os=-tops20 @@ -1346,19 +1576,22 @@ case $basic_machine in  		;;  	m68000-sun)  		os=-sunos3 -		# This also exists in the configure program, but was not the -		# default. -		# os=-sunos4  		;;  	m68*-cisco)  		os=-aout  		;; +	mep-*) +		os=-elf +		;;  	mips*-cisco)  		os=-elf  		;;  	mips*-*)  		os=-elf  		;; +	or1k-*) +		os=-elf +		;;  	or32-*)  		os=-coff  		;; @@ -1371,9 +1604,15 @@ case $basic_machine in  	*-be)  		os=-beos  		;; +	*-haiku) +		os=-haiku +		;;  	*-ibm)  		os=-aix  		;; +	*-knuth) +		os=-mmixware +		;;  	*-wec)  		os=-proelf  		;; @@ -1476,7 +1715,7 @@ case $basic_machine in  			-sunos*)  				vendor=sun  				;; -			-aix*) +			-cnk*|-aix*)  				vendor=ibm  				;;  			-beos*) @@ -1539,7 +1778,7 @@ case $basic_machine in  esac  echo $basic_machine$os -exit 0 +exit  # Local variables:  # eval: (add-hook 'write-file-hooks 'time-stamp) @@ -8986,7 +8986,7 @@ extern char *sys_errlist[];  int  main ()  { -printf(sys_errlist[0]); +printf("%s", sys_errlist[0]);    ;    return 0;  } @@ -257,7 +257,7 @@ make_lastline_link(Buffer *buf, char *title, char *url)      parseURL2(url, &pu, baseURL(buf));      u = parsedURL2Str(&pu);      if (DecodeURL) -	u = Strnew_charp(url_unquote_conv(u->ptr, buf->document_charset)); +	u = Strnew_charp(url_decode2(u->ptr, buf));  #ifdef USE_M17N      u = checkType(u, &pr, NULL);  #endif diff --git a/doc-jp/CVS/Entries b/doc-jp/CVS/Entries deleted file mode 100644 index cfd3d8e..0000000 --- a/doc-jp/CVS/Entries +++ /dev/null @@ -1,26 +0,0 @@ -/FAQ.html/1.9/Sat Apr  8 11:26:23 2006// -/HISTORY/1.1.1.1/Thu Nov  8 05:16:27 2001// -/README.SSL/1.4/Tue May 13 17:17:54 2003// -/README.cygwin/1.4/Sun Feb 23 16:00:17 2003// -/README.dict/1.4/Wed Apr 24 18:46:48 2002// -/README.func/1.22/Mon Sep 22 21:02:23 2003// -/README.keymap/1.1.1.1/Thu Nov  8 05:16:34 2001// -/README.mailcap/1.2/Fri Nov  9 04:59:18 2001// -/README.menu/1.2/Wed Nov 27 16:28:37 2002// -/README.migemo/1.2/Tue May 13 17:17:54 2003// -/README.mouse/1.1/Mon Nov 25 17:23:47 2002// -/README.pre_form/1.3/Mon May 12 16:24:53 2003// -/README.tab/1.1/Tue Nov  5 17:24:48 2002// -/STORY.html/1.3/Tue May 13 17:17:54 2003// -/keymap.lynx/1.4/Fri Dec 13 03:02:04 2002// -/menu.default/1.4/Fri Apr  7 15:22:07 2006// -/menu.submenu/1.3/Fri Apr  7 15:22:07 2006// -/keymap.default/1.8/Sat Jun 10 09:52:18 2006// -/MANUAL.html/1.9/Tue Jan  4 09:22:24 2011// -/README.img/1.7/Tue Jan  4 09:22:24 2011// -/README.m17n/1.3/Tue Jan  4 09:22:24 2011// -/README.passwd/1.1/Tue Aug  3 10:02:16 2010// -/w3m.1/1.7/Tue Jan  4 09:22:24 2011// -/README.cookie/1.4/Sat Jan 15 01:57:39 2011// -/README/1.26/Sat Jan 15 02:17:10 2011// -D diff --git a/doc-jp/CVS/Repository b/doc-jp/CVS/Repository deleted file mode 100644 index f7f574e..0000000 --- a/doc-jp/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/doc-jp diff --git a/doc-jp/CVS/Root b/doc-jp/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/doc-jp/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/doc-jp/README b/doc-jp/README index 074766f..e5e59b1 100644 --- a/doc-jp/README +++ b/doc-jp/README @@ -122,7 +122,6 @@ w3m ϡƣ§°Ƥޤ  	±  	satodai@w3m.jp -ոۤMLޤǤ -	w3m-dev@sic.med.tohoku.ac.jp (ܸ) -	w3m-dev-en@sic.med.tohoku.ac.jp (Ѹ) +ոۤ  	http://w3m.sourceforge.net/ +	https://sourceforge.net/projects/w3m/ diff --git a/doc-jp/README.siteconf b/doc-jp/README.siteconf new file mode 100644 index 0000000..58b51c7 --- /dev/null +++ b/doc-jp/README.siteconf @@ -0,0 +1,60 @@ +siteconf: ̥ޥ + +siteconf ϡ URL Υѥȡɳդ줿꤫ޤ +siteconf Ȥȡʸɤꤷ "decode_url" +νϤꡢ Google Υ쥯ǽ +ץ饤Х夵ꤹ뤳ȤǤޤ + +ǥեȤǤ siteconf  ~/.w3m/siteconf ɤ߹ޤޤ + +===== ʸ ===== + +url <url>|/<re-url>/|m@<re-url>@i [exact] +substitute_url "<destination-url>" +url_charset <charset> +no_referer_from on|off +no_referer_to on|off + +˽줿Τͥ褵ޤ + +=====  ===== + +url "http://twitter.com/#!/" +substitute_url "http://mobile.twitter.com/" + +twitter.com Х륵Ȥžޤ + +url "http://your.bookmark.net/" +no_referer_from on + +your.bookmark.net ĥäéݤˡ HTTP referer  +ʤ褦ˤޤ + +url "http://www.google.com/url?" exact +substitute_url "file:///cgi-bin/your-redirector.cgi?" + +Google Υ쥯 local CGI žޤ + +url /^http:\/\/[a-z]*\.wikipedia\.org\// +url_charset utf-8 + +Ʊ "decode_url" ץˤȡ Wikipedia ؤ + UTF-8 Ȥƥǥɤɽޤ + +===== ɽˤĤ ===== + +ɽϤƱ̣ɽޤ + +/http:\/\/www\.example\.com\// +m/http:\/\/www\.example\.com\// +m@http://www\.example\.com/@ +m!http://www\.example\.com/! + +Ǹ 'i' Ҥդȡʸʸ̤˾ȹԤޤ +㤨С m@^http://www\.example\.com/abc/@i ϰʲΤȤפޤ + +http://www.example.com/abc/ +http://www.example.com/Abc/ +http://www.example.com/ABC/ + +ۥ̾ʬϾ˾ʸѴƤӤޤ diff --git a/doc-jp/STORY.html b/doc-jp/STORY.html index c261b47..a3b22a4 100644 --- a/doc-jp/STORY.html +++ b/doc-jp/STORY.html @@ -158,6 +158,9 @@ w3m ϡ  <a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">Boehm GC</a>  Ȥ饤֥ѤƤ롥ϻ䤬ΤǤϤʤ  ѥصͤۥѥå˴ޤƤ롥 +<P> +# Boehm GC ϡw3m-0.4.2 ʹߤΥѥåˤϴޤޤƤޤ +<P>  ʤlibwww ϻȤäƤʤ  <P>  Boehm GCϡCȤ륬١쥯table ˤ diff --git a/doc/CVS/Entries b/doc/CVS/Entries deleted file mode 100644 index 8cae998..0000000 --- a/doc/CVS/Entries +++ /dev/null @@ -1,21 +0,0 @@ -/HISTORY/1.2/Tue Jul  9 05:54:46 2002// -/README.cygwin/1.5/Sun Feb 23 16:00:16 2003// -/README.dict/1.4/Wed Apr 24 18:46:48 2002// -/README.func/1.21/Mon Sep 22 21:02:22 2003// -/README.mouse/1.1/Mon Nov 25 17:23:45 2002// -/README.pre_form/1.3/Mon May 12 16:24:53 2003// -/README.tab/1.1/Tue Nov  5 17:24:47 2002// -/STORY.html/1.3/Wed Nov 21 04:29:14 2001// -/keymap.lynx/1.4/Fri Dec 13 03:02:04 2002// -/menu.default/1.4/Fri Apr  7 15:05:49 2006// -/menu.submenu/1.3/Fri Apr  7 15:05:49 2006// -/keymap.default/1.8/Sat Jun 10 09:52:18 2006// -/FAQ.html/1.9/Tue Jan  4 09:22:24 2011// -/MANUAL.html/1.6/Tue Jan  4 09:22:24 2011// -/README.img/1.6/Tue Jan  4 09:22:24 2011// -/README.m17n/1.3/Tue Jan  4 09:22:24 2011// -/README.passwd/1.1/Tue Aug  3 10:02:16 2010// -/README.cookie/1.2/Sat Jan 15 01:57:39 2011// -/README/1.26/Sat Jan 15 02:17:25 2011// -/w3m.1/1.9/Sat Jan 15 06:37:24 2011// -D diff --git a/doc/CVS/Repository b/doc/CVS/Repository deleted file mode 100644 index 5431c7e..0000000 --- a/doc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/doc diff --git a/doc/CVS/Root b/doc/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/doc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -115,7 +115,6 @@ Current Maintainer  	Tohoku University Hospital  	satodai@w3m.jp -Feel free to send your opinion to the w3m mailing-lists. -	w3m-dev@sic.med.tohoku.ac.jp (Japanese) -	w3m-dev-en@sic.med.tohoku.ac.jp (English) +Feel free to send your opinion to:  	http://w3m.sourceforge.net/ +	https://sourceforge.net/projects/w3m/ diff --git a/doc/README.img b/doc/README.img index 0c10114..f11362f 100644 --- a/doc/README.img +++ b/doc/README.img @@ -41,7 +41,7 @@ Key functions    Specify the following keymaps in ~/.w3m/keymap.        keymap  X    DISPLAY_IMAGE        keymap  C-c  STOP_IMAGE -      keyamp  t    SET_OPTION  display_image=toggle +      keymap  t    SET_OPTION  display_image=toggle  Commandline options diff --git a/doc/README.siteconf b/doc/README.siteconf new file mode 100644 index 0000000..f173087 --- /dev/null +++ b/doc/README.siteconf @@ -0,0 +1,60 @@ +The siteconf: Site-specific preferences  + +The siteconf consists of URL patterns and preferences associated to them. +You can improve "decode_url" feature by giving charsets of URLs site by site, +or bypass Google's redirector for performance and your privacy. + +The siteconf is read from ~/.w3m/siteconf by default. + +===== The syntax ===== + +url <url>|/<re-url>/|m@<re-url>@i [exact] +substitute_url "<destination-url>" +url_charset <charset> +no_referer_from on|off +no_referer_to on|off + +The last match wins. + +===== Examples ===== + +url "http://twitter.com/#!/" +substitute_url "http://mobile.twitter.com/" + +This forwards the twitter.com to its mobile site. + +url "http://your.bookmark.net/" +no_referer_from on + +This prevents HTTP referers from being sent when you follow links +at the your.bookmark.net. + +url "http://www.google.com/url?" exact +substitute_url "file:///cgi-bin/your-redirector.cgi?" + +This forwards the Google's redirector to your local CGI. + +url /^http:\/\/[a-z]*\.wikipedia\.org\// +url_charset utf-8 + +When combinated with "decode_url" option turned on, links to +Wikipedia will be human-readable. + +===== Regular expressions notes ===== + +Following expressions are all equivalent: + +/http:\/\/www\.example\.com\// +m/http:\/\/www\.example\.com\// +m@http://www\.example\.com/@ +m!http://www\.example\.com/! + +With a trailing 'i' modifier, you can specify a case-insensitive match. +For example, m@^http://www\.example\.com/abc/@i matches to: + +http://www.example.com/abc/ +http://www.example.com/Abc/ +http://www.example.com/ABC/ + +Hostnames, however, are always converted to lowercases before compared. + diff --git a/doc/STORY.html b/doc/STORY.html index 8e89f8c..4ac29ec 100644 --- a/doc/STORY.html +++ b/doc/STORY.html @@ -182,6 +182,10 @@ library. This library was written by H. Boehm and A. Demers.  I could distribute w3m without this library because one can  get the library separately, but I decided to contain it in the  w3m distribution for the convenience of an installer. +<P> +# Boehm GC library is no longer included into w3m packages +# after w3m-0.4.2. +<P>  W3m doesn't use libwww.  <P>  Boehm GC is a garbage collector for C and C++. I began to use this @@ -245,8 +245,6 @@ or on its English version of the site at:  .I  w3m  has incorporated code from several sources. -Hans J. Boehm, Alan J. Demers, Xerox Corp. and Silicon Graphics -have the copyright of the GC library comes with w3m package.  Users have contributed patches and suggestions over time.  .SH AUTHOR  Akinori ITO <aito@fw.ipsj.or.jp> @@ -44,6 +44,8 @@ conv_entity(unsigned int c)  	return " ";      if (c == 0xa0)  	return NBSP; +    if (c == 0xad)		/* SOFT HYPHEN */ +        return "";      if (c < 0x100) {		/* Latin1 (ISO 8859-1) */  	if (UseAltEntity)  	    return alt_latin1[c - 0xa0]; diff --git a/entity.h b/entity.h deleted file mode 100644 index e338883..0000000 --- a/entity.h +++ /dev/null @@ -1,366 +0,0 @@ -/* $Id: entity.h,v 1.6 2011/01/04 11:03:20 htrb Exp $ */ -#include "hash.h" -static HashItem_si MyHashItem[] = { -    /* 0 */ {"otimes", 0x2297, &MyHashItem[1]}, -    /* 1 */ {"laquo", 0xAB, NULL}, -    /* 2 */ {"cap", 0x2229, &MyHashItem[3]}, -    /* 3 */ {"dArr", 0x21D3, &MyHashItem[4]}, -    /* 4 */ {"euml", 0xEB, NULL}, -    /* 5 */ {"sum", 0x2211, &MyHashItem[6]}, -    /* 6 */ {"Ocirc", 0xD4, NULL}, -    /* 7 */ {"dagger", 0x2020, &MyHashItem[8]}, -    /* 8 */ {"Scaron", 0x0160, &MyHashItem[9]}, -    /* 9 */ {"Omicron", 0x039F, &MyHashItem[10]}, -    /* 10 */ {"brvbar", 0xA6, NULL}, -    /* 11 */ {"Eta", 0x0397, &MyHashItem[12]}, -    /* 12 */ {"iacute", 0xED, &MyHashItem[13]}, -    /* 13 */ {"aelig", 0xE6, &MyHashItem[14]}, -    /* 14 */ {"Ugrave", 0xD9, &MyHashItem[15]}, -    /* 15 */ {"deg", 0xB0, NULL}, -    /* 16 */ {"Yuml", 0x0178, &MyHashItem[17]}, -    /* 17 */ {"sup", 0x2283, &MyHashItem[18]}, -    /* 18 */ {"middot", 0xB7, NULL}, -    /* 19 */ {"ge", 0x2265, &MyHashItem[20]}, -    /* 20 */ {"alefsym", 0x2135, &MyHashItem[21]}, -    /* 21 */ {"sigma", 0x03C3, &MyHashItem[22]}, -    /* 22 */ {"aring", 0xE5, &MyHashItem[23]}, -    /* 23 */ {"Icirc", 0xCE, NULL}, -    /* 24 */ {"and", 0x2227, &MyHashItem[25]}, -    /* 25 */ {"weierp", 0x2118, &MyHashItem[26]}, -    /* 26 */ {"frac12", 0xBD, NULL}, -    /* 27 */ {"radic", 0x221A, &MyHashItem[28]}, -    /* 28 */ {"chi", 0x03C7, &MyHashItem[29]}, -    /* 29 */ {"zeta", 0x03B6, &MyHashItem[30]}, -    /* 30 */ {"Theta", 0x0398, &MyHashItem[31]}, -    /* 31 */ {"Atilde", 0xC3, &MyHashItem[32]}, -    /* 32 */ {"para", 0xB6, NULL}, -    /* 33 */ {"frac14", 0xBC, &MyHashItem[34]}, -    /* 34 */ {"cedil", 0xB8, &MyHashItem[35]}, -    /* 35 */ {"quot", 0x22, NULL}, -    /* 36 */ {"ang", 0x2220, &MyHashItem[37]}, -    /* 37 */ {"ucirc", 0xFB, NULL}, -    /* 38 */ {"supe", 0x2287, &MyHashItem[39]}, -    /* 39 */ {"iota", 0x03B9, &MyHashItem[40]}, -    /* 40 */ {"Ograve", 0xD2, NULL}, -    /* 41 */ {"rArr", 0x21D2, &MyHashItem[42]}, -    /* 42 */ {"Auml", 0xC4, &MyHashItem[43]}, -    /* 43 */ {"frac34", 0xBE, &MyHashItem[44]}, -    /* 44 */ {"nbsp", 0xA0, NULL}, -    /* 45 */ {"euro", 0x20AC, &MyHashItem[46]}, -    /* 46 */ {"ocirc", 0xF4, NULL}, -    /* 47 */ {"equiv", 0x2261, &MyHashItem[48]}, -    /* 48 */ {"upsilon", 0x03C5, &MyHashItem[49]}, -    /* 49 */ {"sigmaf", 0x03C2, &MyHashItem[50]}, -    /* 50 */ {"ETH", 0xD0, NULL}, -    /* 51 */ {"le", 0x2264, &MyHashItem[52]}, -    /* 52 */ {"beta", 0x03B2, &MyHashItem[53]}, -    /* 53 */ {"yacute", 0xFD, &MyHashItem[54]}, -    /* 54 */ {"egrave", 0xE8, NULL}, -    /* 55 */ {"lowast", 0x2217, &MyHashItem[56]}, -    /* 56 */ {"real", 0x211C, &MyHashItem[57]}, -    /* 57 */ {"amp", 0x26, NULL}, -    /* 58 */ {"icirc", 0xEE, &MyHashItem[59]}, -    /* 59 */ {"micro", 0xB5, NULL}, -    /* 60 */ {"isin", 0x2208, &MyHashItem[61]}, -    /* 61 */ {"curren", 0xA4, NULL}, -    /* 62 */ {"rdquo", 0x201D, &MyHashItem[63]}, -    /* 63 */ {"sbquo", 0x201A, &MyHashItem[64]}, -    /* 64 */ {"ne", 0x2260, &MyHashItem[65]}, -    /* 65 */ {"theta", 0x03B8, &MyHashItem[66]}, -    /* 66 */ {"Igrave", 0xCC, NULL}, -    /* 67 */ {"gt", 0x3E, NULL}, -    /* 68 */ {"hearts", 0x2665, &MyHashItem[69]}, -    /* 69 */ {"rang", 0x232A, NULL}, -    /* 70 */ {"rfloor", 0x230B, NULL}, -    /* 71 */ {"ldquo", 0x201C, &MyHashItem[72]}, -    /* 72 */ {"ni", 0x220B, &MyHashItem[73]}, -    /* 73 */ {"Ntilde", 0xD1, &MyHashItem[74]}, -    /* 74 */ {"Aacute", 0xC1, NULL}, -    /* 75 */ {"crarr", 0x21B5, &MyHashItem[76]}, -    /* 76 */ {"Ouml", 0xD6, &MyHashItem[77]}, -    /* 77 */ {"GT", 0x3E, NULL}, -    /* 78 */ {"clubs", 0x2663, NULL}, -    /* 79 */ {"scaron", 0x0161, &MyHashItem[80]}, -    /* 80 */ {"part", 0x2202, NULL}, -    /* 81 */ {"tilde", 0x02DC, &MyHashItem[82]}, -    /* 82 */ {"oelig", 0x0153, &MyHashItem[83]}, -    /* 83 */ {"pi", 0x03C0, &MyHashItem[84]}, -    /* 84 */ {"ugrave", 0xF9, NULL}, -    /* 85 */ {"darr", 0x2193, &MyHashItem[86]}, -    /* 86 */ {"uuml", 0xFC, &MyHashItem[87]}, -    /* 87 */ {"QUOT", 0x22, NULL}, -    /* 88 */ {"Prime", 0x2033, NULL}, -    /* 89 */ {"zwj", 0x200D, &MyHashItem[90]}, -    /* 90 */ {"lfloor", 0x230A, &MyHashItem[91]}, -    /* 91 */ {"notin", 0x2209, &MyHashItem[92]}, -    /* 92 */ {"cent", 0xA2, &MyHashItem[93]}, -    /* 93 */ {"lt", 0x3C, NULL}, -    /* 94 */ {"eta", 0x03B7, &MyHashItem[95]}, -    /* 95 */ {"Phi", 0x03A6, &MyHashItem[96]}, -    /* 96 */ {"atilde", 0xE3, NULL}, -    /* 97 */ {"hArr", 0x21D4, &MyHashItem[98]}, -    /* 98 */ {"iuml", 0xEF, &MyHashItem[99]}, -    /* 99 */ {"NBSP", 0xA0, NULL}, -    /* 100 */ {"mu", 0x03BC, NULL}, -    /* 101 */ {"or", 0x2228, &MyHashItem[102]}, -    /* 102 */ {"plusmn", 0xB1, &MyHashItem[103]}, -    /* 103 */ {"LT", 0x3C, NULL}, -    /* 104 */ {"nu", 0x03BD, &MyHashItem[105]}, -    /* 105 */ {"ograve", 0xF2, &MyHashItem[106]}, -    /* 106 */ {"AElig", 0xC6, NULL}, -    /* 107 */ {"rceil", 0x2309, &MyHashItem[108]}, -    /* 108 */ {"uArr", 0x21D1, &MyHashItem[109]}, -    /* 109 */ {"sect", 0xA7, NULL}, -    /* 110 */ {"circ", 0x02C6, NULL}, -    /* 111 */ {"perp", 0x22A5, &MyHashItem[112]}, -    /* 112 */ {"eth", 0xF0, NULL}, -    /* 113 */ {"rsquo", 0x2019, &MyHashItem[114]}, -    /* 114 */ {"nabla", 0x2207, NULL}, -    /* 115 */ {"lceil", 0x2308, &MyHashItem[116]}, -    /* 116 */ {"cup", 0x222A, &MyHashItem[117]}, -    /* 117 */ {"exist", 0x2203, &MyHashItem[118]}, -    /* 118 */ {"rarr", 0x2192, &MyHashItem[119]}, -    /* 119 */ {"upsih", 0x03D2, NULL}, -    /* 120 */ {"prime", 0x2032, &MyHashItem[121]}, -    /* 121 */ {"Omega", 0x03A9, &MyHashItem[122]}, -    /* 122 */ {"Ecirc", 0xCA, NULL}, -    /* 123 */ {"Epsilon", 0x0395, NULL}, -    /* 124 */ {"lsquo", 0x2018, &MyHashItem[125]}, -    /* 125 */ {"xi", 0x03BE, &MyHashItem[126]}, -    /* 126 */ {"Lambda", 0x039B, &MyHashItem[127]}, -    /* 127 */ {"Kappa", 0x039A, &MyHashItem[128]}, -    /* 128 */ {"divide", 0xF7, &MyHashItem[129]}, -    /* 129 */ {"igrave", 0xEC, &MyHashItem[130]}, -    /* 130 */ {"acute", 0xB4, NULL}, -    /* 131 */ {"Euml", 0xCB, &MyHashItem[132]}, -    /* 132 */ {"ordf", 0xAA, NULL}, -    /* 133 */ {"image", 0x2111, &MyHashItem[134]}, -    /* 134 */ {"Tau", 0x03A4, &MyHashItem[135]}, -    /* 135 */ {"Rho", 0x03A1, NULL}, -    /* 136 */ {"ntilde", 0xF1, &MyHashItem[137]}, -    /* 137 */ {"aacute", 0xE1, &MyHashItem[138]}, -    /* 138 */ {"times", 0xD7, NULL}, -    /* 139 */ {"omicron", 0x03BF, NULL}, -    /* 140 */ {"oplus", 0x2295, &MyHashItem[141]}, -    /* 141 */ {"Zeta", 0x0396, &MyHashItem[142]}, -    /* 142 */ {"Eacute", 0xC9, &MyHashItem[143]}, -    /* 143 */ {"ordm", 0xBA, NULL}, -    /* 144 */ {"Oslash", 0xD8, &MyHashItem[145]}, -    /* 145 */ {"Ccedil", 0xC7, &MyHashItem[146]}, -    /* 146 */ {"iquest", 0xBF, NULL}, -    /* 147 */ {"omega", 0x03C9, &MyHashItem[148]}, -    /* 148 */ {"Psi", 0x03A8, &MyHashItem[149]}, -    /* 149 */ {"ecirc", 0xEA, NULL}, -    /* 150 */ {"int", 0x222B, NULL}, -    /* 151 */ {"trade", 0x2122, &MyHashItem[152]}, -    /* 152 */ {"kappa", 0x03BA, &MyHashItem[153]}, -    /* 153 */ {"Iota", 0x0399, &MyHashItem[154]}, -    /* 154 */ {"Delta", 0x0394, &MyHashItem[155]}, -    /* 155 */ {"Alpha", 0x0391, &MyHashItem[156]}, -    /* 156 */ {"Otilde", 0xD5, NULL}, -    /* 157 */ {"sdot", 0x22C5, NULL}, -    /* 158 */ {"cong", 0x2245, NULL}, -    /* 159 */ {"rsaquo", 0x203A, &MyHashItem[160]}, -    /* 160 */ {"OElig", 0x0152, &MyHashItem[161]}, -    /* 161 */ {"diams", 0x2666, &MyHashItem[162]}, -    /* 162 */ {"phi", 0x03C6, &MyHashItem[163]}, -    /* 163 */ {"Beta", 0x0392, &MyHashItem[164]}, -    /* 164 */ {"szlig", 0xDF, &MyHashItem[165]}, -    /* 165 */ {"sup1", 0xB9, &MyHashItem[166]}, -    /* 166 */ {"reg", 0xAE, NULL}, -    /* 167 */ {"harr", 0x2194, &MyHashItem[168]}, -    /* 168 */ {"hellip", 0x2026, &MyHashItem[169]}, -    /* 169 */ {"yuml", 0xFF, &MyHashItem[170]}, -    /* 170 */ {"sup2", 0xB2, NULL}, -    /* 171 */ {"Gamma", 0x0393, &MyHashItem[172]}, -    /* 172 */ {"sup3", 0xB3, NULL}, -    /* 173 */ {"forall", 0x2200, NULL}, -    /* 174 */ {"bdquo", 0x201E, &MyHashItem[175]}, -    /* 175 */ {"spades", 0x2660, &MyHashItem[176]}, -    /* 176 */ {"Pi", 0x03A0, &MyHashItem[177]}, -    /* 177 */ {"Uacute", 0xDA, &MyHashItem[178]}, -    /* 178 */ {"Agrave", 0xC0, NULL}, -    /* 179 */ {"permil", 0x2030, &MyHashItem[180]}, -    /* 180 */ {"mdash", 0x2014, &MyHashItem[181]}, -    /* 181 */ {"lArr", 0x21D0, &MyHashItem[182]}, -    /* 182 */ {"uarr", 0x2191, NULL}, -    /* 183 */ {"Upsilon", 0x03A5, &MyHashItem[184]}, -    /* 184 */ {"pound", 0xA3, NULL}, -    /* 185 */ {"lsaquo", 0x2039, &MyHashItem[186]}, -    /* 186 */ {"lrm", 0x200E, &MyHashItem[187]}, -    /* 187 */ {"lambda", 0x03BB, &MyHashItem[188]}, -    /* 188 */ {"delta", 0x03B4, &MyHashItem[189]}, -    /* 189 */ {"alpha", 0x03B1, NULL}, -    /* 190 */ {"frasl", 0x2044, &MyHashItem[191]}, -    /* 191 */ {"thorn", 0xFE, &MyHashItem[192]}, -    /* 192 */ {"auml", 0xE4, NULL}, -    /* 193 */ {"Mu", 0x039C, NULL}, -    /* 194 */ {"nsub", 0x2284, &MyHashItem[195]}, -    /* 195 */ {"macr", 0xAF, NULL}, -    /* 196 */ {"minus", 0x2212, &MyHashItem[197]}, -    /* 197 */ {"Nu", 0x039D, &MyHashItem[198]}, -    /* 198 */ {"Oacute", 0xD3, NULL}, -    /* 199 */ {"prod", 0x220F, &MyHashItem[200]}, -    /* 200 */ {"Uuml", 0xDC, &MyHashItem[201]}, -    /* 201 */ {"iexcl", 0xA1, NULL}, -    /* 202 */ {"lang", 0x2329, &MyHashItem[203]}, -    /* 203 */ {"tau", 0x03C4, &MyHashItem[204]}, -    /* 204 */ {"rho", 0x03C1, &MyHashItem[205]}, -    /* 205 */ {"gamma", 0x03B3, NULL}, -    /* 206 */ {"loz", 0x25CA, &MyHashItem[207]}, -    /* 207 */ {"bull", 0x2022, &MyHashItem[208]}, -    /* 208 */ {"piv", 0x03D6, NULL}, -    /* 209 */ {"eacute", 0xE9, NULL}, -    /* 210 */ {"zwnj", 0x200C, &MyHashItem[211]}, -    /* 211 */ {"oslash", 0xF8, &MyHashItem[212]}, -    /* 212 */ {"ccedil", 0xE7, &MyHashItem[213]}, -    /* 213 */ {"THORN", 0xDE, &MyHashItem[214]}, -    /* 214 */ {"Iuml", 0xCF, &MyHashItem[215]}, -    /* 215 */ {"not", 0xAC, NULL}, -    /* 216 */ {"sim", 0x223C, &MyHashItem[217]}, -    /* 217 */ {"thetasym", 0x03D1, &MyHashItem[218]}, -    /* 218 */ {"Acirc", 0xC2, NULL}, -    /* 219 */ {"Dagger", 0x2021, &MyHashItem[220]}, -    /* 220 */ {"fnof", 0x0192, NULL}, -    /* 221 */ {"rlm", 0x200F, &MyHashItem[222]}, -    /* 222 */ {"oline", 0x203E, &MyHashItem[223]}, -    /* 223 */ {"Chi", 0x03A7, &MyHashItem[224]}, -    /* 224 */ {"Xi", 0x039E, &MyHashItem[225]}, -    /* 225 */ {"otilde", 0xF5, &MyHashItem[226]}, -    /* 226 */ {"Iacute", 0xCD, &MyHashItem[227]}, -    /* 227 */ {"copy", 0xA9, NULL}, -    /* 228 */ {"ndash", 0x2013, &MyHashItem[229]}, -    /* 229 */ {"ouml", 0xF6, NULL}, -    /* 230 */ {"psi", 0x03C8, NULL}, -    /* 231 */ {"sube", 0x2286, NULL}, -    /* 232 */ {"emsp", 0x2003, &MyHashItem[233]}, -    /* 233 */ {"asymp", 0x2248, &MyHashItem[234]}, -    /* 234 */ {"prop", 0x221D, NULL}, -    /* 235 */ {"infin", 0x221E, NULL}, -    /* 236 */ {"empty", 0x2205, &MyHashItem[237]}, -    /* 237 */ {"uacute", 0xFA, &MyHashItem[238]}, -    /* 238 */ {"agrave", 0xE0, &MyHashItem[239]}, -    /* 239 */ {"shy", 0xAD, NULL}, -    /* 240 */ {"ensp", 0x2002, NULL}, -    /* 241 */ {"acirc", 0xE2, NULL}, -    /* 242 */ {"sub", 0x2282, &MyHashItem[243]}, -    /* 243 */ {"epsilon", 0x03B5, NULL}, -    /* 244 */ {"Yacute", 0xDD, &MyHashItem[245]}, -    /* 245 */ {"Egrave", 0xC8, NULL}, -    /* 246 */ {"there4", 0x2234, &MyHashItem[247]}, -    /* 247 */ {"larr", 0x2190, &MyHashItem[248]}, -    /* 248 */ {"uml", 0xA8, &MyHashItem[249]}, -    /* 249 */ {"AMP", 0x26, NULL}, -    /* 250 */ {"Sigma", 0x03A3, &MyHashItem[251]}, -    /* 251 */ {"Aring", 0xC5, NULL}, -    /* 252 */ {"yen", 0xA5, NULL}, -    /* 253 */ {"oacute", 0xF3, &MyHashItem[254]}, -    /* 254 */ {"raquo", 0xBB, NULL}, -    /* 255 */ {"thinsp", 0x2009, NULL}, -    /* 256 */ {"Ucirc", 0xDB, NULL}, -}; - -static HashItem_si *MyHashItemTbl[] = { -    NULL, -    &MyHashItem[0], -    &MyHashItem[2], -    &MyHashItem[5], -    &MyHashItem[7], -    &MyHashItem[11], -    &MyHashItem[16], -    &MyHashItem[19], -    &MyHashItem[24], -    &MyHashItem[27], -    &MyHashItem[33], -    &MyHashItem[36], -    NULL, -    &MyHashItem[38], -    &MyHashItem[41], -    &MyHashItem[45], -    &MyHashItem[47], -    &MyHashItem[51], -    &MyHashItem[55], -    &MyHashItem[58], -    &MyHashItem[60], -    &MyHashItem[62], -    &MyHashItem[67], -    &MyHashItem[68], -    &MyHashItem[70], -    &MyHashItem[71], -    &MyHashItem[75], -    &MyHashItem[78], -    &MyHashItem[79], -    &MyHashItem[81], -    &MyHashItem[85], -    &MyHashItem[88], -    &MyHashItem[89], -    &MyHashItem[94], -    &MyHashItem[97], -    &MyHashItem[100], -    &MyHashItem[101], -    &MyHashItem[104], -    &MyHashItem[107], -    &MyHashItem[110], -    &MyHashItem[111], -    &MyHashItem[113], -    &MyHashItem[115], -    &MyHashItem[120], -    &MyHashItem[123], -    &MyHashItem[124], -    &MyHashItem[131], -    &MyHashItem[133], -    NULL, -    &MyHashItem[136], -    NULL, -    NULL, -    &MyHashItem[139], -    &MyHashItem[140], -    &MyHashItem[144], -    &MyHashItem[147], -    &MyHashItem[150], -    &MyHashItem[151], -    &MyHashItem[157], -    &MyHashItem[158], -    NULL, -    &MyHashItem[159], -    &MyHashItem[167], -    &MyHashItem[171], -    &MyHashItem[173], -    &MyHashItem[174], -    &MyHashItem[179], -    NULL, -    &MyHashItem[183], -    &MyHashItem[185], -    &MyHashItem[190], -    &MyHashItem[193], -    &MyHashItem[194], -    &MyHashItem[196], -    &MyHashItem[199], -    &MyHashItem[202], -    &MyHashItem[206], -    &MyHashItem[209], -    &MyHashItem[210], -    &MyHashItem[216], -    &MyHashItem[219], -    &MyHashItem[221], -    &MyHashItem[228], -    &MyHashItem[230], -    NULL, -    &MyHashItem[231], -    &MyHashItem[232], -    NULL, -    &MyHashItem[235], -    &MyHashItem[236], -    &MyHashItem[240], -    &MyHashItem[241], -    &MyHashItem[242], -    &MyHashItem[244], -    &MyHashItem[246], -    &MyHashItem[250], -    &MyHashItem[252], -    &MyHashItem[253], -    &MyHashItem[255], -    &MyHashItem[256], -}; - -Hash_si entity = { 100, MyHashItemTbl }; @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.265 2010/12/15 10:50:24 htrb Exp $ */ +/* $Id: file.c,v 1.266 2012/05/22 09:45:56 inu Exp $ */  #include "fm.h"  #include <sys/types.h>  #include "myctype.h" @@ -47,11 +47,11 @@ static JMP_BUF AbortLoading;  static struct table *tables[MAX_TABLE];  static struct table_mode table_mode[MAX_TABLE]; -#ifdef USE_IMAGE +#if defined(USE_M17N) || defined(USE_IMAGE)  static ParsedURL *cur_baseURL = NULL; -#ifdef USE_M17N -static char cur_document_charset;  #endif +#ifdef USE_M17N +static wc_ces cur_document_charset = 0;  #endif  static Str cur_title; @@ -215,7 +215,6 @@ currentLn(Buffer *buf)  static Buffer *  loadSomething(URLFile *f, -	      char *path,  	      Buffer *(*loadproc) (URLFile *, Buffer *), Buffer *defaultbuf)  {      Buffer *buf; @@ -223,17 +222,23 @@ loadSomething(URLFile *f,      if ((buf = loadproc(f, defaultbuf)) == NULL)  	return NULL; -    buf->filename = path;      if (buf->buffername == NULL || buf->buffername[0] == '\0') {  	buf->buffername = checkHeader(buf, "Subject:"); -	if (buf->buffername == NULL) -	    buf->buffername = conv_from_system(lastFileName(path)); +	if (buf->buffername == NULL && buf->filename != NULL) +	    buf->buffername = conv_from_system(lastFileName(buf->filename));      }      if (buf->currentURL.scheme == SCM_UNKNOWN)  	buf->currentURL.scheme = f->scheme; -    buf->real_scheme = f->scheme;      if (f->scheme == SCM_LOCAL && buf->sourcefile == NULL) -	buf->sourcefile = path; +	buf->sourcefile = buf->filename; +    if (loadproc == loadHTMLBuffer +#ifdef USE_IMAGE +	|| loadproc == loadImageBuffer +#endif +       ) +	buf->type = "text/html"; +    else +	buf->type = "text/plain";      return buf;  } @@ -484,28 +489,6 @@ convertLine0(URLFile *uf, Str line, int mode)      return line;  } -/*  - * loadFile: load file to buffer - */ -Buffer * -loadFile(char *path) -{ -    Buffer *buf; -    URLFile uf; -    init_stream(&uf, SCM_LOCAL, NULL); -    examineFile(path, &uf); -    if (uf.stream == NULL) -	return NULL; -    buf = newBuffer(INIT_BUFFER_WIDTH); -    current_content_length = 0; -#ifdef USE_M17N -    content_charset = 0; -#endif -    buf = loadSomething(&uf, path, loadBuffer, buf); -    UFclose(&uf); -    return buf; -} -  int  matchattr(char *p, char *attr, int len, Str *value)  { @@ -1697,13 +1680,15 @@ getLinkNumberStr(int correction)  /*    * loadGeneralFile: load file to buffer   */ +#define DO_EXTERNAL ((Buffer *(*)(URLFile *, Buffer *))doExternal)  Buffer *  loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,  		int flag, FormList *volatile request)  {      URLFile f, *volatile of = NULL;      ParsedURL pu; -    Buffer *b = NULL, *(*volatile proc)() = loadBuffer; +    Buffer *b = NULL; +    Buffer *(*volatile proc)(URLFile *, Buffer *) = loadBuffer;      char *volatile tpath;      char *volatile t = "text/plain", *p, *volatile real_type = NULL;      Buffer *volatile t_buf = NULL; @@ -1730,7 +1715,22 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,      add_auth_cookie_flag = 0;      checkRedirection(NULL); +    load_doc: +    { +	const char *sc_redirect; +	parseURL2(tpath, &pu, current); +	sc_redirect = query_SCONF_SUBSTITUTE_URL(&pu); +	if (sc_redirect && *sc_redirect && checkRedirection(&pu)) { +	    tpath = (char *)sc_redirect; +	    request = NULL; +	    add_auth_cookie_flag = 0; +	    current = New(ParsedURL); +	    *current = pu; +	    status = HTST_NORMAL; +	    goto load_doc; +	} +    }      TRAP_OFF;      url_option.referer = referer;      url_option.flag = flag; @@ -1863,7 +1863,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,  	    /* 302: Found */  	    /* 303: See Other */  	    /* 307: Temporary Redirect (HTTP/1.1) */ -	    tpath = url_quote_conv(p, DocumentCharset); +	    tpath = url_encode(p, NULL, 0);  	    request = NULL;  	    UFclose(&f);  	    current = New(ParsedURL); @@ -2022,7 +2022,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,  	if (f.is_cgi && (p = checkHeader(t_buf, "Location:")) != NULL &&  	    checkRedirection(&pu)) {  	    /* document moved */ -	    tpath = url_quote_conv(remove_space(p), DocumentCharset); +	    tpath = url_encode(remove_space(p), NULL, 0);  	    request = NULL;  	    UFclose(&f);  	    add_auth_cookie_flag = 0; @@ -2123,10 +2123,6 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,      if (real_type == NULL)  	real_type = t;      proc = loadBuffer; -#ifdef USE_IMAGE -    cur_baseURL = New(ParsedURL); -    copyParsedURL(cur_baseURL, &pu); -#endif      current_content_length = 0;      if ((p = checkHeader(t_buf, "Content-Length:")) != NULL) @@ -2197,18 +2193,8 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,  #endif      else if (w3m_backend) ;      else if (!(w3m_dump & ~DUMP_FRAME) || is_dump_text_type(t)) { -	if (!do_download && doExternal(f, -				       pu.real_file ? pu.real_file : pu.file, -				       t, &b, t_buf)) { -	    if (b && b != NO_BUFFER) { -		b->real_scheme = f.scheme; -		b->real_type = real_type; -		if (b->currentURL.host == NULL && b->currentURL.file == NULL) -		    copyParsedURL(&b->currentURL, &pu); -	    } -	    UFclose(&f); -	    TRAP_OFF; -	    return b; +	if (!do_download && searchExtViewer(t) != NULL) { +	    proc = DO_EXTERNAL;  	}  	else {  	    TRAP_OFF; @@ -2232,36 +2218,30 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,      else if (w3m_dump & DUMP_FRAME)  	return NULL; +    if (t_buf == NULL) +	t_buf = newBuffer(INIT_BUFFER_WIDTH); +    copyParsedURL(&t_buf->currentURL, &pu); +    t_buf->filename = pu.real_file ? pu.real_file : +	pu.file ? conv_to_system(pu.file) : NULL;      if (flag & RG_FRAME) { -	if (t_buf == NULL) -	    t_buf = newBuffer(INIT_BUFFER_WIDTH);  	t_buf->bufferprop |= BP_FRAME;      }  #ifdef USE_SSL -    if (t_buf) -	t_buf->ssl_certificate = f.ssl_certificate; +    t_buf->ssl_certificate = f.ssl_certificate;  #endif      frame_source = flag & RG_FRAME_SRC; -    b = loadSomething(&f, pu.real_file ? pu.real_file : pu.file, proc, t_buf); +    if (proc == DO_EXTERNAL) { +	b = doExternal(f, t, t_buf); +    } else { +	b = loadSomething(&f, proc, t_buf); +    }      UFclose(&f);      frame_source = 0; -    if (b) { +    if (b && b != NO_BUFFER) {  	b->real_scheme = f.scheme;  	b->real_type = real_type; -	if (b->currentURL.host == NULL && b->currentURL.file == NULL) -	    copyParsedURL(&b->currentURL, &pu); -	if (is_html_type(t)) -	    b->type = "text/html"; -	else if (w3m_backend) { -	    Str s = Strnew_charp(t); -	    b->type = s->ptr; -	} -#ifdef USE_IMAGE -	else if (proc == loadImageBuffer) -	    b->type = "text/html"; -#endif -	else -	    b->type = "text/plain"; +	if (w3m_backend) +	    b->type = allocStr(t, -1);  	if (pu.label) {  	    if (proc == loadHTMLBuffer) {  		Anchor *a; @@ -2287,10 +2267,11 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,      if (header_string)  	header_string = NULL;  #ifdef USE_NNTP -    if (f.scheme == SCM_NNTP || f.scheme == SCM_NEWS) +    if (b && b != NO_BUFFER && (f.scheme == SCM_NNTP || f.scheme == SCM_NEWS))  	reAnchorNewsheader(b);  #endif -    preFormUpdateBuffer(b); +    if (b && b != NO_BUFFER) +	preFormUpdateBuffer(b);      TRAP_OFF;      return b;  } @@ -2469,6 +2450,7 @@ set_breakpoint(struct readbuffer *obuf, int tag_length)      bcopy((void *)&obuf->anchor, (void *)&obuf->bp.anchor,  	  sizeof(obuf->anchor));      obuf->bp.img_alt = obuf->img_alt; +    obuf->bp.input_alt = obuf->input_alt;      obuf->bp.in_bold = obuf->in_bold;      obuf->bp.in_italic = obuf->in_italic;      obuf->bp.in_under = obuf->in_under; @@ -2486,6 +2468,7 @@ back_to_breakpoint(struct readbuffer *obuf)      bcopy((void *)&obuf->bp.anchor, (void *)&obuf->anchor,  	  sizeof(obuf->anchor));      obuf->img_alt = obuf->bp.img_alt; +    obuf->input_alt = obuf->bp.input_alt;      obuf->in_bold = obuf->bp.in_bold;      obuf->in_italic = obuf->bp.in_italic;      obuf->in_under = obuf->bp.in_under; @@ -2729,7 +2712,7 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,      Str line = obuf->line, pass = NULL;      char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL,  	*hidden_under = NULL, *hidden_italic = NULL, *hidden_strike = NULL, -	*hidden_ins = NULL, *hidden = NULL; +	*hidden_ins = NULL, *hidden_input, *hidden = NULL;  #ifdef DEBUG      if (w3m_debug) { @@ -2761,6 +2744,12 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,  		hidden = hidden_img;  	}      } +    if (obuf->input_alt.in) { +	if ((hidden_input = has_hidden_link(obuf, HTML_INPUT_ALT)) != NULL) { +	    if (!hidden || hidden_input < hidden) +		hidden = hidden_input; +	} +    }      if (obuf->in_bold) {  	if ((hidden_bold = has_hidden_link(obuf, HTML_B)) != NULL) {  	    if (!hidden || hidden_bold < hidden) @@ -2812,6 +2801,8 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,  	Strcat_charp(line, "</a>");      if (obuf->img_alt && !hidden_img)  	Strcat_charp(line, "</img_alt>"); +    if (obuf->input_alt.in && !hidden_input) +	Strcat_charp(line, "</input_alt>");      if (obuf->in_bold && !hidden_bold)  	Strcat_charp(line, "</b>");      if (obuf->in_italic && !hidden_italic) @@ -3022,6 +3013,18 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,  	Strcat_charp(tmp, "\">");  	push_tag(obuf, tmp->ptr, HTML_IMG_ALT);      } +    if (!hidden_input && obuf->input_alt.in) { +	Str tmp; +	if (obuf->input_alt.hseq > 0) +	    obuf->input_alt.hseq = - obuf->input_alt.hseq; +	tmp = Sprintf("<INPUT_ALT hseq=\"%d\" fid=\"%d\" name=\"%s\" type=\"%s\" value=\"%s\">", +		     obuf->input_alt.hseq, +		     obuf->input_alt.fid, +		     obuf->input_alt.name->ptr, +		     obuf->input_alt.type->ptr, +		     obuf->input_alt.value->ptr); +	push_tag(obuf, tmp->ptr, HTML_INPUT_ALT); +    }      if (!hidden_bold && obuf->in_bold)  	push_tag(obuf, "<B>", HTML_B);      if (!hidden_italic && obuf->in_italic) @@ -3228,7 +3231,7 @@ process_img(struct parsed_tag *tag, int width)      if (!parsedtag_get_value(tag, ATTR_SRC, &p))  	return tmp; -    p = remove_space(p); +    p = url_encode(remove_space(p), cur_baseURL, cur_document_charset);      q = NULL;      parsedtag_get_value(tag, ATTR_ALT, &q);      if (!pseudoInlines && (q == NULL || (*q == '\0' && ignore_null_img_alt))) @@ -3322,12 +3325,7 @@ process_img(struct parsed_tag *tag, int width)  	    Image image;  	    ParsedURL u; -#ifdef USE_M17N -	    parseURL2(wc_conv(p, InnerCharset, cur_document_charset)->ptr, &u, -		      cur_baseURL); -#else  	    parseURL2(p, &u, cur_baseURL); -#endif  	    image.url = parsedURL2Str(&u)->ptr;  	    if (!uncompressed_file_type(u.file, &image.ext))  		image.ext = filename_extension(u.file, TRUE); @@ -3732,6 +3730,63 @@ process_input(struct parsed_tag *tag)  }  Str +process_button(struct parsed_tag *tag) +{ +    Str tmp = NULL; +    char *p, *q, *r, *qq = ""; +    int qlen, v; + +    if (cur_form_id < 0) { +       char *s = "<form_int method=internal action=none>"; +       tmp = process_form(parse_tag(&s, TRUE)); +    } +    if (tmp == NULL) +       tmp = Strnew(); + +    p = "submit"; +    parsedtag_get_value(tag, ATTR_TYPE, &p); +    q = NULL; +    parsedtag_get_value(tag, ATTR_VALUE, &q); +    r = ""; +    parsedtag_get_value(tag, ATTR_NAME, &r); + +    v = formtype(p); +    if (v == FORM_UNKNOWN) +       return NULL; + +    if (!q) { +       switch (v) { +       case FORM_INPUT_SUBMIT: +       case FORM_INPUT_BUTTON: +           q = "SUBMIT"; +           break; +       case FORM_INPUT_RESET: +           q = "RESET"; +           break; +       } +    } +    if (q) { +       qq = html_quote(q); +       qlen = strlen(q); +    } + +    //    Strcat_charp(tmp, "<pre_int>"); +    Strcat(tmp, Sprintf("<input_alt hseq=\"%d\" fid=\"%d\" type=%s " +                       "name=\"%s\" value=\"%s\">", +                       cur_hseq++, cur_form_id, p, html_quote(r), qq)); +    return tmp; +} + +Str +process_n_button(void) +{ +    Str tmp = Strnew(); +    Strcat_charp(tmp, "</input_alt>"); +    //    Strcat_charp(tmp, "</pre_int>"); +    return tmp; +} + +Str  process_select(struct parsed_tag *tag)  {      Str tmp = NULL; @@ -4084,6 +4139,7 @@ process_form_int(struct parsed_tag *tag, int fid)      parsedtag_get_value(tag, ATTR_METHOD, &p);      q = "!CURRENT_URL!";      parsedtag_get_value(tag, ATTR_ACTION, &q); +    q = url_encode(remove_space(q), cur_baseURL, cur_document_charset);      r = NULL;  #ifdef USE_M17N      if (parsedtag_get_value(tag, ATTR_ACCEPT_CHARSET, &r)) @@ -4861,7 +4917,35 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)  	    if (i > obuf->bottom_margin)  		obuf->bottom_margin = i;  	} +	if (parsedtag_get_value(tag, ATTR_HSEQ, &hseq)) { +	    obuf->input_alt.hseq = hseq; +	} +	if (parsedtag_get_value(tag, ATTR_FID, &i)) { +	    obuf->input_alt.fid = i; +	} +	if (parsedtag_get_value(tag, ATTR_TYPE, &p)) { +	    obuf->input_alt.type = Strnew_charp(p); +	} +	if (parsedtag_get_value(tag, ATTR_VALUE, &p)) { +	    obuf->input_alt.value = Strnew_charp(p); +	} +	if (parsedtag_get_value(tag, ATTR_NAME, &p)) { +	    obuf->input_alt.name = Strnew_charp(p); +	} +	obuf->input_alt.in = 1;  	return 0; +    case HTML_N_INPUT_ALT: +	if (obuf->input_alt.in) { +	    if (!close_effect0(obuf, HTML_INPUT_ALT)) +		push_tag(obuf, "</input_alt>", HTML_N_INPUT_ALT); +	    obuf->input_alt.hseq = 0; +	    obuf->input_alt.fid = -1; +	    obuf->input_alt.in = 0; +	    obuf->input_alt.type = NULL; +	    obuf->input_alt.name = NULL; +	    obuf->input_alt.value = NULL; +	} +	return 1;      case HTML_TABLE:  	close_anchor(h_env, obuf);  	obuf->table_level++; @@ -4970,6 +5054,16 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)      case HTML_INPUT:  	close_anchor(h_env, obuf);  	tmp = process_input(tag); +       if (tmp) +           HTMLlineproc1(tmp->ptr, h_env); +       return 1; +    case HTML_BUTTON: +       tmp = process_button(tag); +       if (tmp) +           HTMLlineproc1(tmp->ptr, h_env); +       return 1; +    case HTML_N_BUTTON: +       tmp = process_n_button();  	if (tmp)  	    HTMLlineproc1(tmp->ptr, h_env);  	return 1; @@ -5020,10 +5114,17 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)  	HTMLlineproc1(tmp->ptr, h_env);  	return 1;      case HTML_META: -	p = q = NULL; +	p = q = r = NULL;  	parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &p);  	parsedtag_get_value(tag, ATTR_CONTENT, &q);  #ifdef USE_M17N +	parsedtag_get_value(tag, ATTR_CHARSET, &r); +	if (r) { +	    /* <meta charset=""> */ +	    SKIP_BLANKS(r); +	    meta_charset = wc_guess_charset(r, 0); +	} +	else  	if (p && q && !strcasecmp(p, "Content-Type") &&  	    (q = strcasestr(q, "charset")) != NULL) {  	    q += 7; @@ -5060,11 +5161,10 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)  	}  	return 1;      case HTML_BASE: -#ifdef USE_IMAGE +#if defined(USE_M17N) || defined(USE_IMAGE)  	p = NULL;  	if (parsedtag_get_value(tag, ATTR_HREF, &p)) { -	    if (!cur_baseURL) -		cur_baseURL = New(ParsedURL); +	    cur_baseURL = New(ParsedURL);  	    parseURL(p, cur_baseURL, NULL);  	}  #endif @@ -5322,6 +5422,13 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  #ifdef MENU_SELECT      Anchor **a_select = NULL;  #endif +#if defined(USE_M17N) || defined(USE_IMAGE) +    ParsedURL *base = baseURL(buf); +#endif +#ifdef USE_M17N +    wc_ces name_charset = url_to_charset(NULL, &buf->currentURL, +					 buf->document_charset); +#endif      if (out_size == 0) {  	out_size = LINELEN; @@ -5516,16 +5623,17 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  		    hseq = 0;  		    id = NULL;  		    if (parsedtag_get_value(tag, ATTR_NAME, &id)) { -			id = url_quote_conv(id, buf->document_charset); +			id = url_quote_conv(id, name_charset);  			registerName(buf, id, currentLn(buf), pos);  		    }  		    if (parsedtag_get_value(tag, ATTR_HREF, &p)) -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); +			p = url_encode(remove_space(p), base, +				       buf->document_charset);  		    if (parsedtag_get_value(tag, ATTR_TARGET, &q))  			q = url_quote_conv(q, buf->document_charset);  		    if (parsedtag_get_value(tag, ATTR_REFERER, &r)) -			r = url_quote_conv(r, buf->document_charset); +			r = url_encode(r, base, +				       buf->document_charset);  		    parsedtag_get_value(tag, ATTR_TITLE, &s);  		    parsedtag_get_value(tag, ATTR_ACCESSKEY, &t);  		    parsedtag_get_value(tag, ATTR_HSEQ, &hseq); @@ -5611,7 +5719,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  			    ParsedURL u;  			    Image *image; -			    parseURL2(a_img->url, &u, cur_baseURL); +			    parseURL2(a_img->url, &u, base);  			    a_img->image = image = New(Image);  			    image->url = parsedURL2Str(&u)->ptr;  			    if (!uncompressed_file_type(u.file, &image->ext)) @@ -5632,7 +5740,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  			    image->map = q;  			    image->ismap = ismap;  			    image->touch = 0; -			    image->cache = getImage(image, cur_baseURL, +			    image->cache = getImage(image, base,  						    IMG_FLAG_SKIP);  			}  			else if (iseq < 0) { @@ -5682,6 +5790,21 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  				putHmarker(buf->hmarklist, currentLn(buf),  					   hpos, hseq - 1);  			} +			else if (hseq < 0) { +			    int h = -hseq - 1; +			    int hpos = pos; +			    if (*str == '[') +				hpos++; +			    if (buf->hmarklist && +				h < buf->hmarklist->nmark && +				buf->hmarklist->marks[h].invalid) { +				buf->hmarklist->marks[h].pos = hpos; +				buf->hmarklist->marks[h].line = currentLn(buf); +				buf->hmarklist->marks[h].invalid = 0; +				hseq = -hseq; +			    } +			} +  			if (!form->target)  			    form->target = buf->baseTarget;  			if (a_textarea && @@ -5754,8 +5877,8 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  			break;  		    if (parsedtag_get_value(tag, ATTR_HREF, &p)) {  			MapArea *a; -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); +			p = url_encode(remove_space(p), base, +				       buf->document_charset);  			t = NULL;  			parsedtag_get_value(tag, ATTR_TARGET, &t);  			q = ""; @@ -5804,11 +5927,14 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  		    break;  		case HTML_BASE:  		    if (parsedtag_get_value(tag, ATTR_HREF, &p)) { -			p = url_quote_conv(remove_space(p), -					   buf->document_charset); +			p = url_encode(remove_space(p), NULL, +				       buf->document_charset);  			if (!buf->baseURL)  			    buf->baseURL = New(ParsedURL);  			parseURL(p, buf->baseURL, NULL); +#if defined(USE_M17N) || defined(USE_IMAGE) +			base = buf->baseURL; +#endif  		    }  		    if (parsedtag_get_value(tag, ATTR_TARGET, &p))  			buf->baseTarget = @@ -5823,8 +5949,8 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  			int refresh_interval = getMetaRefreshParam(q, &tmp);  #ifdef USE_ALARM  			if (tmp) { -			    p = url_quote_conv(remove_space(tmp->ptr), -					       buf->document_charset); +			    p = url_encode(remove_space(tmp->ptr), base, +					   buf->document_charset);  			    buf->event = setAlarmEvent(buf->event,  						       refresh_interval,  						       AL_IMPLICIT_ONCE, @@ -5837,8 +5963,8 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  						       FUNCNAME_reload, NULL);  #else  			if (tmp && refresh_interval == 0) { -			    p = url_quote_conv(remove_space(tmp->ptr), -					       buf->document_charset); +			    p = url_encode(remove_space(tmp->ptr), base, +					   buf->document_charset);  			    pushEvent(FUNCNAME_gorURL, p);  			}  #endif @@ -5922,7 +6048,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)  #ifdef	ID_EXT  		id = NULL;  		if (parsedtag_get_value(tag, ATTR_ID, &id)) { -		    id = url_quote_conv(id, buf->document_charset); +		    id = url_quote_conv(id, name_charset);  		    registerName(buf, id, currentLn(buf), pos);  		}  		if (renderFrameSet && @@ -5975,7 +6101,8 @@ addLink(Buffer *buf, struct parsed_tag *tag)      parsedtag_get_value(tag, ATTR_HREF, &href);      if (href) -	href = url_quote_conv(remove_space(href), buf->document_charset); +	href = url_encode(remove_space(href), baseURL(buf), +			  buf->document_charset);      parsedtag_get_value(tag, ATTR_TITLE, &title);      parsedtag_get_value(tag, ATTR_TYPE, &ctype);      parsedtag_get_value(tag, ATTR_REL, &rel); @@ -6749,6 +6876,12 @@ init_henv(struct html_feed_environ *h_env, struct readbuffer *obuf,      obuf->nobr_level = 0;      bzero((void *)&obuf->anchor, sizeof(obuf->anchor));      obuf->img_alt = 0; +    obuf->input_alt.hseq = 0; +    obuf->input_alt.fid = -1; +    obuf->input_alt.in = 0; +    obuf->input_alt.type = NULL; +    obuf->input_alt.name = NULL; +    obuf->input_alt.value = NULL;      obuf->in_bold = 0;      obuf->in_italic = 0;      obuf->in_under = 0; @@ -6784,6 +6917,15 @@ completeHTMLstream(struct html_feed_environ *h_env, struct readbuffer *obuf)  	push_tag(obuf, "</img_alt>", HTML_N_IMG_ALT);  	obuf->img_alt = NULL;      } +    if (obuf->input_alt.in) { +	push_tag(obuf, "</input_alt>", HTML_N_INPUT_ALT); +	obuf->input_alt.hseq = 0; +	obuf->input_alt.fid = -1; +	obuf->input_alt.in = 0; +	obuf->input_alt.type = NULL; +	obuf->input_alt.name = NULL; +	obuf->input_alt.value = NULL; +    }      if (obuf->in_bold) {  	push_tag(obuf, "</b>", HTML_N_B);  	obuf->in_bold = 0; @@ -6956,8 +7098,6 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)  	image_flag = IMG_FLAG_AUTO;      else  	image_flag = IMG_FLAG_SKIP; -    if (newBuf->currentURL.file) -	cur_baseURL = baseURL(newBuf);  #endif      if (w3m_halfload) { @@ -6980,6 +7120,9 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)  	htmlenv1.f = stdout;      else  	htmlenv1.buf = newTextLineList(); +#if defined(USE_M17N) || defined(USE_IMAGE) +    cur_baseURL = baseURL(newBuf); +#endif      if (SETJMP(AbortLoading) != 0) {  	HTMLlineproc1("<br>Transfer Interrupted!<br>", &htmlenv1); @@ -7041,7 +7184,7 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)  	}  #endif  	lineBuf2 = convertLine(f, lineBuf2, HTML_MODE, &charset, doc_charset); -#if defined(USE_M17N) && defined(USE_IMAGE) +#ifdef USE_M17N  	cur_document_charset = charset;  #endif  	HTMLlineproc0(lineBuf2->ptr, &htmlenv1, internal); @@ -7053,6 +7196,12 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)      obuf.status = R_ST_NORMAL;      completeHTMLstream(&htmlenv1, &obuf);      flushline(&htmlenv1, &obuf, 0, 2, htmlenv1.limit); +#if defined(USE_M17N) || defined(USE_IMAGE) +    cur_baseURL = NULL; +#endif +#ifdef USE_M17N +    cur_document_charset = 0; +#endif      if (htmlenv1.title)  	newBuf->buffername = htmlenv1.title;      if (w3m_halfdump) { @@ -7200,7 +7349,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset)  	q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr,  			   "/", file->ptr, NULL)->ptr;  	Strcat_m_charp(tmp, "<a href=\"", -		       html_quote(url_quote_conv(q, *charset)), +		       html_quote(url_encode(q, NULL, *charset)),  		       "\">", p, html_quote(name->ptr + 1), "</a>\n", NULL);      } @@ -7324,6 +7473,7 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf)      URLFile f;      MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;      struct stat st; +    const ParsedURL *pu = newBuf ? &newBuf->currentURL : NULL;      loadImage(newBuf, IMG_FLAG_STOP);      image.url = uf->url; @@ -7331,8 +7481,8 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf)      image.width = -1;      image.height = -1;      image.cache = NULL; -    cache = getImage(&image, cur_baseURL, IMG_FLAG_AUTO); -    if (!cur_baseURL->is_nocache && cache->loaded & IMG_FLAG_LOADED && +    cache = getImage(&image, (ParsedURL *)pu, IMG_FLAG_AUTO); +    if (!(pu && pu->is_nocache) && cache->loaded & IMG_FLAG_LOADED &&  	!stat(cache->file, &st))  	goto image_buffer; @@ -7573,8 +7723,11 @@ openGeneralPagerBuffer(InputStream stream)  #ifdef USE_M17N      content_charset = 0;  #endif +    t_buf = newBuffer(INIT_BUFFER_WIDTH); +    copyParsedURL(&t_buf->currentURL, NULL); +    t_buf->currentURL.scheme = SCM_LOCAL; +    t_buf->currentURL.file = "-";      if (SearchHeader) { -	t_buf = newBuffer(INIT_BUFFER_WIDTH);  	readHeader(&uf, t_buf, TRUE, NULL);  	t = checkContentType(t_buf);  	if (t == NULL) @@ -7602,14 +7755,13 @@ openGeneralPagerBuffer(InputStream stream)  #ifdef USE_IMAGE      else if (activeImage && displayImage && !useExtImageViewer &&  	     !(w3m_dump & ~DUMP_FRAME) && !strncasecmp(t, "image/", 6)) { -	cur_baseURL = New(ParsedURL); -	parseURL("-", cur_baseURL, NULL);  	buf = loadImageBuffer(&uf, t_buf);  	buf->type = "text/html";      }  #endif      else { -	if (doExternal(uf, "-", t, &buf, t_buf)) { +	if (searchExtViewer(t)) { +	    buf = doExternal(uf, t, t_buf);  	    UFclose(&uf);  	    if (buf == NULL || buf == NO_BUFFER)  		return buf; @@ -7622,8 +7774,6 @@ openGeneralPagerBuffer(InputStream stream)  	}      }      buf->real_type = t; -    buf->currentURL.scheme = SCM_LOCAL; -    buf->currentURL.file = "-";      return buf;  } @@ -7816,9 +7966,8 @@ save2tmp(URLFile uf, char *tmpf)      return 0;  } -int -doExternal(URLFile uf, char *path, char *type, Buffer **bufp, -	   Buffer *defaultbuf) +Buffer * +doExternal(URLFile uf, char *type, Buffer *defaultbuf)  {      Str tmpf, command;      struct mailcap *mcap; @@ -7827,7 +7976,7 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,      char *header, *src = NULL, *ext = uf.ext;      if (!(mcap = searchExtViewer(type))) -	return 0; +	return NULL;      if (mcap->nametemplate) {  	tmpf = unquote_mailcap(mcap->nametemplate, NULL, "", NULL, NULL); @@ -7860,15 +8009,13 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,  	    UFclose(&uf);  	    myExec(command->ptr);  	} -	*bufp = NO_BUFFER; -	return 1; +	return NO_BUFFER;      }      else  #endif      {  	if (save2tmp(uf, tmpf->ptr) < 0) { -	    *bufp = NULL; -	    return 1; +	    return NULL;  	}      }      if (mcap->flags & (MAILCAP_HTMLOUTPUT | MAILCAP_COPIOUSOUTPUT)) { @@ -7911,14 +8058,13 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,  	buf = NO_BUFFER;      }      if (buf && buf != NO_BUFFER) { -	buf->filename = path; -	if (buf->buffername == NULL || buf->buffername[0] == '\0') -	    buf->buffername = conv_from_system(lastFileName(path)); +	if ((buf->buffername == NULL || buf->buffername[0] == '\0') && +	    buf->filename) +	    buf->buffername = conv_from_system(lastFileName(buf->filename));  	buf->edit = mcap->edit;  	buf->mailcap = mcap;      } -    *bufp = buf; -    return 1; +    return buf;  }  static int @@ -264,6 +264,18 @@ extern int REV_LB[];  #define IMG_FLAG_ERROR		2  #define IMG_FLAG_DONT_REMOVE	4 +#define IS_EMPTY_PARSED_URL(pu) ((pu)->scheme == SCM_UNKNOWN && !(pu)->file) +#define SCONF_RESERVED		0 +#define SCONF_SUBSTITUTE_URL	1 +#define SCONF_URL_CHARSET	2 +#define SCONF_NO_REFERER_FROM	3 +#define SCONF_NO_REFERER_TO	4 +#define SCONF_N_FIELD		5 +#define query_SCONF_SUBSTITUTE_URL(pu) ((const char *)querySiteconf(pu, SCONF_SUBSTITUTE_URL)) +#define query_SCONF_URL_CHARSET(pu) ((const wc_ces *)querySiteconf(pu, SCONF_URL_CHARSET)) +#define query_SCONF_NO_REFERER_FROM(pu) ((const int *)querySiteconf(pu, SCONF_NO_REFERER_FROM)) +#define query_SCONF_NO_REFERER_TO(pu) ((const int *)querySiteconf(pu, SCONF_NO_REFERER_TO)) +  /*    * Macros.   */ @@ -562,6 +574,13 @@ typedef struct _DownloadList {  #define INIT_BUFFER_WIDTH ((_INIT_BUFFER_WIDTH > 0) ? _INIT_BUFFER_WIDTH : 0)  #define FOLD_BUFFER_WIDTH (FoldLine ? (INIT_BUFFER_WIDTH + 1) : -1) +struct input_alt_attr { +  int hseq; +  int fid; +  int in; +  Str type, name, value; +}; +  typedef struct {      int pos;      int len; @@ -569,6 +588,7 @@ typedef struct {      long flag;      Anchor anchor;      Str img_alt; +    struct input_alt_attr input_alt;      char fontstat[FONTSTAT_SIZE];      short nobr_level;      Lineprop prev_ctype; @@ -591,6 +611,7 @@ struct readbuffer {      short nobr_level;      Anchor anchor;      Str img_alt; +    struct input_alt_attr input_alt;      char fontstat[FONTSTAT_SIZE];      char fontstat_stack[FONT_STACK_SIZE][FONTSTAT_SIZE];      int fontstat_sp; @@ -972,6 +993,7 @@ global int BackgroundExtViewer init(TRUE);  global int disable_secret_security_check init(FALSE);  global char *passwd_file init(PASSWD_FILE);  global char *pre_form_file init(PRE_FORM_FILE); +global char *siteconf_file init(SITECONF_FILE);  global char *ftppasswd init(NULL);  global int ftppass_hostnamegen init(TRUE);  global int do_download init(FALSE); @@ -196,7 +196,7 @@ formtype(char *typestr)  	if (!strcasecmp(typestr, _formtypetbl[i]))  	    return i;      } -    return FORM_UNKNOWN; +    return FORM_INPUT_TEXT;  }  void @@ -787,7 +787,7 @@ struct pre_form {  static struct pre_form *PreForm = NULL;  static struct pre_form * -add_pre_form(struct pre_form *prev, char *url, char *name, char *action) +add_pre_form(struct pre_form *prev, char *url, Regex *re_url, char *name, char *action)  {      ParsedURL pu;      struct pre_form *new; @@ -796,21 +796,13 @@ add_pre_form(struct pre_form *prev, char *url, char *name, char *action)  	new = prev->next = New(struct pre_form);      else  	new = PreForm = New(struct pre_form); -    if (url && *url == '/') { -	int l = strlen(url); -	if (l > 1 && url[l - 1] == '/') -	    new->url = allocStr(url + 1, l - 2); -	else -	    new->url = url + 1; -	new->re_url = newRegex(new->url, FALSE, NULL, NULL); -	if (!new->re_url) -	    new->url = NULL; -    } -    else if (url) { +    if (url && !re_url) {  	parseURL2(url, &pu, NULL);  	new->url = parsedURL2Str(&pu)->ptr; -	new->re_url = NULL;      } +    else +	new->url = url; +    new->re_url = re_url;      new->name = (name && *name) ? name : NULL;      new->action = (action && *action) ? action : NULL;      new->item = NULL; @@ -834,7 +826,7 @@ add_pre_form_item(struct pre_form *pf, struct pre_form_item *prev, int type,      new->name = name;      new->value = value;      if (checked && *checked && (!strcmp(checked, "0") || -				strcasecmp(checked, "off") +				!strcasecmp(checked, "off")  				|| !strcasecmp(checked, "no")))  	new->checked = 0;      else @@ -875,6 +867,7 @@ loadPreForm(void)  	return;      while (1) {  	char *p, *s, *arg; +	Regex *re_arg;  	line = Strfgets(fp);  	if (line->length == 0) @@ -890,18 +883,20 @@ loadPreForm(void)  	if (*p == '#' || *p == '\0')  	    continue;		/* comment or empty line */  	s = getWord(&p); -	arg = getWord(&p);  	if (!strcmp(s, "url")) { +	    arg = getRegexWord((const char **)&p, &re_arg);  	    if (!arg || !*arg)  		continue;  	    p = getQWord(&p); -	    pf = add_pre_form(pf, arg, NULL, p); +	    pf = add_pre_form(pf, arg, re_arg, NULL, p);  	    pi = pf->item;  	    continue;  	}  	if (!pf)  	    continue; + +	arg = getWord(&p);  	if (!strcmp(s, "form")) {  	    if (!arg || !*arg)  		continue; @@ -913,7 +908,7 @@ loadPreForm(void)  	    }  	    if (pf->item) {  		struct pre_form *prev = pf; -		pf = add_pre_form(prev, "", s, p); +		pf = add_pre_form(prev, "", NULL, s, p);  		/* copy previous URL */  		pf->url = prev->url;  		pf->re_url = prev->re_url; @@ -91,7 +91,8 @@ newFrame(struct parsed_tag *tag, Buffer *buf)      body->baseURL = baseURL(buf);      if (tag) {  	if (parsedtag_get_value(tag, ATTR_SRC, &p)) -	    body->url = url_quote_conv(remove_space(p), buf->document_charset); +	    body->url = url_encode(remove_space(p), body->baseURL, +				   buf->document_charset);  	if (parsedtag_get_value(tag, ATTR_NAME, &p) && *p != '_')  	    body->name = url_quote_conv(p, buf->document_charset);      } @@ -639,7 +640,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level,  			case HTML_BASE:  			    /* "BASE" is prohibit tag */  			    if (parsedtag_get_value(tag, ATTR_HREF, &q)) { -				q = url_quote_conv(remove_space(q), charset); +				q = url_encode(remove_space(q), NULL, charset);  				parseURL(q, &base, NULL);  			    }  			    if (parsedtag_get_value(tag, ATTR_TARGET, &q)) { @@ -768,8 +769,8 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level,  				if (!tag->value[j])  				    break;  				tag->value[j] = -				    url_quote_conv(remove_space(tag->value[j]), -						   charset); +				    url_encode(remove_space(tag->value[j]), +					       &base, charset);  				tag->need_reconstruct = TRUE;  				parseURL2(tag->value[j], &url, &base);  				if (url.scheme == SCM_UNKNOWN || @@ -8,6 +8,7 @@  #include "fm.h"  #include "func.h"  #include "myctype.h" +#include "regex.h"  #include "funcname.c"  #include "functable.c" @@ -434,6 +435,93 @@ getQWord(char **str)      return tmp->ptr;  } +/* This extracts /regex/i or m@regex@i from the given string. + * Then advances *str to the end of regex. + * If the input does not seems to be a regex, this falls back to getQWord(). + *  + * Returns a word (no matter whether regex or not) in the give string. + * If regex_ret is non-NULL, compiles the regex and stores there. + * + * XXX: Actually this is unrelated to func.c. + */ +char * +getRegexWord(const char **str, Regex **regex_ret) +{ +    char *word = NULL; +    const char *p, *headp, *bodyp, *tailp; +    char delimiter; +    int esc; +    int igncase = 0; + +    p = *str; +    SKIP_BLANKS(p); +    headp = p; + +    /* Get the opening delimiter */ +    if (p[0] == 'm' && IS_PRINT(p[1]) && !IS_ALNUM(p[1]) && p[1] != '\\') { +	delimiter = p[1]; +	p += 2; +    } +    else if (p[0] == '/') { +	delimiter = '/'; +	p += 1; +    } +    else { +	goto not_regex; +    } +    bodyp = p; + +    /* Scan the end of the expression */ +    for (esc = 0; *p; ++p) { +	if (esc) { +	    esc = 0; +	} else { +	    if (*p == delimiter) +		break; +	    else if (*p == '\\') +		esc = 1; +	} +    } +    if (!*p && *headp == '/') +	goto not_regex; +    tailp = p; + +    /* Check the modifiers */ +    if (*p == delimiter) { +	while (*++p && !IS_SPACE(*p)) { +	    switch (*p) { +	    case 'i': +		igncase = 1; +		break; +	    } +	    /* ignore unknown modifiers */ +	} +    } + +    /* Save the expression */ +    word = allocStr(headp, p - headp); + +    /* Compile */ +    if (regex_ret) { +	if (*tailp == delimiter) +	    word[tailp - headp] = 0; +	*regex_ret = newRegex(word + (bodyp - headp), igncase, NULL, NULL); +	if (*tailp == delimiter) +	    word[tailp - headp] = delimiter; +    } +    goto last; + +not_regex: +    p = headp; +    word = getQWord((char **)&p); +    if (regex_ret) +	*regex_ret = NULL; + +last: +    *str = p; +    return word; +} +  #ifdef USE_MOUSE  static MouseAction default_mouse_action = {      NULL, diff --git a/gc/CVS/Entries b/gc/CVS/Entries deleted file mode 100644 index 7eb3836..0000000 --- a/gc/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -D/Mac_files//// -D/cord//// -D/doc//// -D/include//// -D/tests//// diff --git a/gc/CVS/Repository b/gc/CVS/Repository deleted file mode 100644 index e390d2f..0000000 --- a/gc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc diff --git a/gc/CVS/Root b/gc/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/Mac_files/CVS/Entries b/gc/Mac_files/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/gc/Mac_files/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/gc/Mac_files/CVS/Repository b/gc/Mac_files/CVS/Repository deleted file mode 100644 index 3832d0b..0000000 --- a/gc/Mac_files/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/Mac_files diff --git a/gc/Mac_files/CVS/Root b/gc/Mac_files/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/Mac_files/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/cord/CVS/Entries b/gc/cord/CVS/Entries deleted file mode 100644 index a7ce60a..0000000 --- a/gc/cord/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D/private//// diff --git a/gc/cord/CVS/Repository b/gc/cord/CVS/Repository deleted file mode 100644 index 656cb33..0000000 --- a/gc/cord/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/cord diff --git a/gc/cord/CVS/Root b/gc/cord/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/cord/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/cord/private/CVS/Entries b/gc/cord/private/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/gc/cord/private/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/gc/cord/private/CVS/Repository b/gc/cord/private/CVS/Repository deleted file mode 100644 index 8bf419d..0000000 --- a/gc/cord/private/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/cord/private diff --git a/gc/cord/private/CVS/Root b/gc/cord/private/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/cord/private/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/doc/CVS/Entries b/gc/doc/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/gc/doc/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/gc/doc/CVS/Repository b/gc/doc/CVS/Repository deleted file mode 100644 index 24977cc..0000000 --- a/gc/doc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/doc diff --git a/gc/doc/CVS/Root b/gc/doc/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/doc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/include/CVS/Entries b/gc/include/CVS/Entries deleted file mode 100644 index a7ce60a..0000000 --- a/gc/include/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D/private//// diff --git a/gc/include/CVS/Repository b/gc/include/CVS/Repository deleted file mode 100644 index cbc551f..0000000 --- a/gc/include/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/include diff --git a/gc/include/CVS/Root b/gc/include/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/include/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/include/private/CVS/Entries b/gc/include/private/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/gc/include/private/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/gc/include/private/CVS/Repository b/gc/include/private/CVS/Repository deleted file mode 100644 index 55fc1f1..0000000 --- a/gc/include/private/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/include/private diff --git a/gc/include/private/CVS/Root b/gc/include/private/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/include/private/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/gc/tests/CVS/Entries b/gc/tests/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/gc/tests/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/gc/tests/CVS/Repository b/gc/tests/CVS/Repository deleted file mode 100644 index aa9da7e..0000000 --- a/gc/tests/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/gc/tests diff --git a/gc/tests/CVS/Root b/gc/tests/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/gc/tests/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -17,7 +17,7 @@ historyBuffer(Hist *hist)  	for (item = hist->list->last; item; item = item->prev) {  	    q = html_quote((char *)item->ptr);  	    if (DecodeURL) -		p = html_quote(url_unquote_conv((char *)item->ptr, 0)); +		p = html_quote(url_decode2((char *)item->ptr, NULL));  	    else  		p = q;  	    Strcat_charp(src, "<li><a href=\""); @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.32 2010/08/14 01:29:40 htrb Exp $ */ +/* $Id: html.c,v 1.33 2012/05/22 09:45:56 inu Exp $ */  #include "html.h"  /* Define HTML Tag Infomation Table */ @@ -37,8 +37,8 @@ unsigned char ALST_TABLE[] =      ATTR_CELLPADDING, ATTR_VSPACE, ATTR_CORE  };  #define MAXA_TABLE	MAXA_CORE + 6 -unsigned char ALST_META[] = { ATTR_HTTP_EQUIV, ATTR_CONTENT, ATTR_CORE }; -#define MAXA_META	MAXA_CORE + 2 +unsigned char ALST_META[] = { ATTR_HTTP_EQUIV, ATTR_CONTENT, ATTR_CHARSET, ATTR_CORE }; +#define MAXA_META	MAXA_CORE + 3  unsigned char ALST_FRAME[] = { ATTR_SRC, ATTR_NAME, ATTR_CORE };  #define MAXA_FRAME	MAXA_CORE + 2  unsigned char ALST_FRAMESET[] = { ATTR_COLS, ATTR_ROWS, ATTR_CORE }; @@ -56,6 +56,9 @@ unsigned char ALST_INPUT[] =      ATTR_CORE  };  #define MAXA_INPUT      MAXA_CORE + 12 +unsigned char ALST_BUTTON[] = +    { ATTR_TYPE, ATTR_VALUE, ATTR_NAME, ATTR_CORE }; +#define MAXA_BUTTON	MAXA_CORE + 3  unsigned char ALST_TEXTAREA[] =      { ATTR_COLS, ATTR_ROWS, ATTR_NAME, ATTR_READONLY, ATTR_CORE };  #define MAXA_TEXTAREA   MAXA_CORE + 4 @@ -247,24 +250,24 @@ TagInfo TagMAP[MAX_HTMLTAG] = {      {"/bdo", NULL, 0, TFLG_END},	/* 121 HTML_N_BDO */      {"big", ALST_NOP, MAXA_NOP, 0},		/* 122 HTML_BIG */      {"/big", NULL, 0, TFLG_END},	/* 123 HTML_N_BIG */ -    {"button", ALST_NOP, MAXA_NOP, 0},		/* 124 HTML_BUTTON */ -    {"fieldset", ALST_NOP, MAXA_NOP, 0},	        /* 125 HTML_FIELDSET */ -    {"/fieldset", NULL, 0, TFLG_END},	/* 126 HTML_N_FIELDSET */ -    {"iframe", ALST_NOP, MAXA_NOP, 0},		/* 127 HTML_IFRAME */ -    {"label", ALST_NOP, MAXA_NOP, 0}, 		/* 128 HTML_LABEL */ -    {"/label", NULL, 0, TFLG_END},	/* 129 HTML_N_LABEL */ -    {"legend", ALST_NOP, MAXA_NOP, 0},		/* 130 HTML_LEGEND */ -    {"/legend", NULL, 0, TFLG_END},	/* 131 HTML_N_LEGEND */ -    {"noscript", ALST_NOP, MAXA_NOP, 0},	        /* 132 HTML_NOSCRIPT */ -    {"/noscript", NULL, 0, TFLG_END},	/* 133 HTML_N_NOSCRIPT */ -    {"object", ALST_NOP, MAXA_NOP, 0},		/* 134 HTML_OBJECT */ -    {"optgroup", ALST_NOP, MAXA_NOP, 0},	        /* 135 HTML_OPTGROUP */ -    {"/optgroup", NULL, 0, TFLG_END},	/* 136 HTML_N_OPTGROUP */ -    {"param", ALST_NOP, MAXA_NOP, 0},		/* 137 HTML_PARAM */ -    {"small", ALST_NOP, MAXA_NOP, 0}, 		/* 138 HTML_SMALL */ -    {"/small", NULL, 0, TFLG_END},	/* 139 HTML_N_SMALL */ +    {"button", ALST_BUTTON, MAXA_BUTTON, 0},	/* 124 HTML_BUTTON */ +    {"/button", NULL, 0, TFLG_END},	/* 125 HTML_N_BUTTON */ +    {"fieldset", ALST_NOP, MAXA_NOP, 0},	/* 126 HTML_FIELDSET */ +    {"/fieldset", NULL, 0, TFLG_END},	/* 127 HTML_N_FIELDSET */ +    {"iframe", ALST_NOP, MAXA_NOP, 0},		/* 128 HTML_IFRAME */ +    {"label", ALST_NOP, MAXA_NOP, 0}, 		/* 129 HTML_LABEL */ +    {"/label", NULL, 0, TFLG_END},	/* 130 HTML_N_LABEL */ +    {"legend", ALST_NOP, MAXA_NOP, 0},		/* 131 HTML_LEGEND */ +    {"/legend", NULL, 0, TFLG_END},	/* 132 HTML_N_LEGEND */ +    {"noscript", ALST_NOP, MAXA_NOP, 0},	        /* 133 HTML_NOSCRIPT */ +    {"/noscript", NULL, 0, TFLG_END},	/* 134 HTML_N_NOSCRIPT */ +    {"object", ALST_NOP, MAXA_NOP, 0},		/* 135 HTML_OBJECT */ +    {"optgroup", ALST_NOP, MAXA_NOP, 0},	        /* 136 HTML_OPTGROUP */ +    {"/optgroup", NULL, 0, TFLG_END},	/* 137 HTML_N_OPTGROUP */ +    {"param", ALST_NOP, MAXA_NOP, 0},		/* 138 HTML_PARAM */ +    {"small", ALST_NOP, MAXA_NOP, 0}, 		/* 139 HTML_SMALL */ +    {"/small", NULL, 0, TFLG_END},	/* 140 HTML_N_SMALL */ -    {NULL, NULL, 0, 0},		/* 140 Undefined */      {NULL, NULL, 0, 0},		/* 141 Undefined */      {NULL, NULL, 0, 0},		/* 142 Undefined */      {NULL, NULL, 0, 0},		/* 143 Undefined */ @@ -214,21 +214,22 @@ typedef struct {  #define HTML_BIG        122  #define HTML_N_BIG      123  #define HTML_BUTTON     124 -#define HTML_FIELDSET   125 -#define HTML_N_FIELDSET 126 -#define HTML_IFRAME     127 -#define HTML_LABEL      128 -#define HTML_N_LABEL    129 -#define HTML_LEGEND     130 -#define HTML_N_LEGEND   131 -#define HTML_NOSCRIPT   132 -#define HTML_N_NOSCRIPT 133 -#define HTML_OBJECT     134 -#define HTML_OPTGROUP   135 -#define HTML_N_OPTGROUP 136 -#define HTML_PARAM      137 -#define HTML_SMALL      138 -#define HTML_N_SMALL    139 +#define HTML_N_BUTTON   125 +#define HTML_FIELDSET   126 +#define HTML_N_FIELDSET 127 +#define HTML_IFRAME     128 +#define HTML_LABEL      129 +#define HTML_N_LABEL    130 +#define HTML_LEGEND     131 +#define HTML_N_LEGEND   132 +#define HTML_NOSCRIPT   133 +#define HTML_N_NOSCRIPT 134 +#define HTML_OBJECT     135 +#define HTML_OPTGROUP   136 +#define HTML_N_OPTGROUP 137 +#define HTML_PARAM      138 +#define HTML_SMALL      139 +#define HTML_N_SMALL    140     /* pseudo tag */  #define HTML_SELECT_INT     160 @@ -357,6 +357,20 @@ strcasemstr(char *str, char *srch[], char **ret_ptr)      return -1;  } +int +strmatchlen(const char *s1, const char *s2, int maxlen) +{ +    int i; + +    /* To allow the maxlen to be negatie (infinity), +     * compare by "!=" instead of "<=". */ +    for (i = 0; i != maxlen; ++i) { +	if (!s1[i] || !s2[i] || s1[i] != s2[i]) +	    break; +    } +    return i; +} +  char *  remove_space(char *str)  { @@ -52,6 +52,7 @@ extern int strncasecmp(const char *s1, const char *s2, size_t n);  extern char *strcasestr(const char *s1, const char *s2);  #endif  extern int strcasemstr(char *str, char *srch[], char **ret_ptr); +int strmatchlen(const char *s1, const char *s2, int maxlen);  extern char *remove_space(char *str);  extern int non_null(char *s);  extern void cleanup_line(Str s, int mode); diff --git a/intl/CVS/Entries b/intl/CVS/Entries deleted file mode 100644 index 1784810..0000000 --- a/intl/CVS/Entries +++ /dev/null @@ -1 +0,0 @@ -D diff --git a/intl/CVS/Repository b/intl/CVS/Repository deleted file mode 100644 index eb89a50..0000000 --- a/intl/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/intl diff --git a/intl/CVS/Root b/intl/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/intl/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -22,8 +22,8 @@  static void basic_close(int *handle);  static int basic_read(int *handle, char *buf, int len); -static void file_close(struct file_handle *handle); -static int file_read(struct file_handle *handle, char *buf, int len); +static void file_close(struct io_file_handle *handle); +static int file_read(struct io_file_handle *handle, char *buf, int len);  static int str_read(Str handle, char *buf, int len); @@ -114,7 +114,7 @@ newFileStream(FILE * f, void (*closep) ())      stream = New(union input_stream);      init_base_stream(&stream->base, STREAM_BUF_SIZE);      stream->file.type = IST_FILE; -    stream->file.handle = New(struct file_handle); +    stream->file.handle = New(struct io_file_handle);      stream->file.handle->f = f;      if (closep)  	stream->file.handle->close = closep; @@ -658,13 +658,13 @@ basic_read(int *handle, char *buf, int len)  }  static void -file_close(struct file_handle *handle) +file_close(struct io_file_handle *handle)  {      handle->close(handle->f);  }  static int -file_read(struct file_handle *handle, char *buf, int len) +file_read(struct io_file_handle *handle, char *buf, int len)  {      return fread(buf, 1, len, handle->f);  } @@ -20,7 +20,7 @@ struct stream_buffer {  typedef struct stream_buffer *StreamBuffer; -struct file_handle { +struct io_file_handle {      FILE *f;      void (*close) ();  }; @@ -53,7 +53,7 @@ struct base_stream {  struct file_stream {      struct stream_buffer stream; -    struct file_handle *handle; +    struct io_file_handle *handle;      char type;      char iseos;      int (*read) (); @@ -91,7 +91,7 @@ unsigned char EscBKeymap[128] = {      /*  0       1       2       3       4       5       6       7        */      nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd,      /*  8       9       :       ;       <       =       >       ?        */ -    nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, +    nulcmd, nulcmd, nulcmd, nulcmd, sgrmouse, nulcmd, nulcmd, nulcmd,      /*  @       A       B       C       D       E       F       G        */      nulcmd, movU, movD, movR, movL, nulcmd, goLineL, pgFore,      /*  H       I       J       K       L       M       N       O        */ diff --git a/libwc/CVS/Entries b/libwc/CVS/Entries deleted file mode 100644 index bdd6455..0000000 --- a/libwc/CVS/Entries +++ /dev/null @@ -1,53 +0,0 @@ -/.cvsignore/1.1/Mon Sep 22 22:53:53 2003// -/big5.c/1.1/Mon Sep 22 21:02:23 2003// -/big5.h/1.1/Mon Sep 22 21:02:23 2003// -/ccs.h/1.1/Mon Sep 22 21:02:23 2003// -/ces.c/1.1/Mon Sep 22 21:02:23 2003// -/char_conv.c/1.1/Mon Sep 22 21:02:23 2003// -/combining.c/1.1/Mon Sep 22 21:02:23 2003// -/conv.c/1.1/Mon Sep 22 21:02:23 2003// -/detect.c/1.3/Wed Apr  5 14:18:54 2006// -/gb18030.c/1.1/Mon Sep 22 21:02:23 2003// -/gb18030.h/1.1/Mon Sep 22 21:02:23 2003// -/gbk.c/1.1/Mon Sep 22 21:02:23 2003// -/gbk.h/1.1/Mon Sep 22 21:02:23 2003// -/hkscs.c/1.1/Mon Sep 22 21:02:23 2003// -/hkscs.h/1.1/Mon Sep 22 21:02:23 2003// -/hz.c/1.1/Mon Sep 22 21:02:23 2003// -/hz.h/1.1/Mon Sep 22 21:02:23 2003// -/iso2022.c/1.1/Mon Sep 22 21:02:23 2003// -/iso2022.h/1.1/Mon Sep 22 21:02:23 2003// -/jis.c/1.1/Mon Sep 22 21:02:23 2003// -/jis.h/1.1/Mon Sep 22 21:02:23 2003// -/johab.c/1.1/Mon Sep 22 21:02:23 2003// -/johab.h/1.1/Mon Sep 22 21:02:23 2003// -/priv.c/1.1/Mon Sep 22 21:02:23 2003// -/priv.h/1.1/Mon Sep 22 21:02:23 2003// -/putc.c/1.1/Mon Sep 22 21:02:23 2003// -/search.c/1.1/Mon Sep 22 21:02:23 2003// -/search.h/1.1/Mon Sep 22 21:02:23 2003// -/sjis.c/1.1/Mon Sep 22 21:02:23 2003// -/sjis.h/1.1/Mon Sep 22 21:02:23 2003// -/test.c/1.1/Mon Sep 22 21:02:23 2003// -/ucs.map/1.1/Mon Sep 22 21:02:23 2003// -/uhc.c/1.1/Mon Sep 22 21:02:23 2003// -/uhc.h/1.1/Mon Sep 22 21:02:23 2003// -/utf7.c/1.1/Mon Sep 22 21:02:23 2003// -/utf7.h/1.1/Mon Sep 22 21:02:23 2003// -/utf8.c/1.1/Mon Sep 22 21:02:23 2003// -/utf8.h/1.1/Mon Sep 22 21:02:23 2003// -/viet.c/1.1/Mon Sep 22 21:02:23 2003// -/viet.h/1.1/Mon Sep 22 21:02:23 2003// -/wc.h/1.1/Mon Sep 22 21:02:23 2003// -/wtf.c/1.1/Mon Sep 22 21:02:23 2003// -/wtf.h/1.1/Mon Sep 22 21:02:23 2003// -D/map//// -/EastAsianWidth.txt/1.1/Sun Jul 25 09:55:05 2010// -/Makefile.in/1.7/Tue Jan  4 09:22:27 2011// -/ambwidth_map.awk/1.1/Sun Jul 25 09:55:05 2010// -/ces.h/1.2/Tue Jan  4 09:22:27 2011// -/charset.c/1.4/Tue Jan  4 09:22:27 2011// -/status.c/1.2/Tue Jan  4 09:22:27 2011// -/ucs.c/1.4/Tue Jan  4 09:22:27 2011// -/ucs.h/1.4/Tue Jan  4 09:22:27 2011// -/wc_types.h/1.3/Tue Jan  4 09:22:27 2011// diff --git a/libwc/CVS/Repository b/libwc/CVS/Repository deleted file mode 100644 index 6ad67c0..0000000 --- a/libwc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/libwc diff --git a/libwc/CVS/Root b/libwc/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/libwc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/libwc/map/CVS/Entries b/libwc/map/CVS/Entries deleted file mode 100644 index 7e3a839..0000000 --- a/libwc/map/CVS/Entries +++ /dev/null @@ -1,112 +0,0 @@ -/big5_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cns11643_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1006_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1250_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1251_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1252_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1253_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1254_ucs.map/1.1/Mon Sep 22 21:02:24 2003// -/cp1255_combining.map/1.1/Mon Sep 22 21:02:25 2003// -/cp1255_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp1256_combining.map/1.1/Mon Sep 22 21:02:25 2003// -/cp1256_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp1257_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp1258_combining.map/1.1/Mon Sep 22 21:02:25 2003// -/cp1258_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp437_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp737_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp775_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp850_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp852_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp855_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp856_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp857_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp860_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp861_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp862_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp863_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp864_combining.map/1.1/Mon Sep 22 21:02:25 2003// -/cp864_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp865_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp866_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp869_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/cp874_combining.map/1.1/Mon Sep 22 21:02:25 2003// -/cp874_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/gb12345_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/gb18030_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/gb2312_gbk.map/1.1/Mon Sep 22 21:02:25 2003// -/gb2312_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/gbk_ucs.map/1.1/Mon Sep 22 21:02:25 2003// -/hkscs_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/hkscs_ucs_p2.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885910_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885911_combining.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885911_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885913_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885914_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885915_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso885916_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88591_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88592_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88593_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88594_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88595_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88596_combining.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88596_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88597_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88598_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/iso88599_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/jisx0201k_jisx0208.map/1.1/Mon Sep 22 21:02:26 2003// -/jisx0201k_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/jisx0208_jisx02131.map/1.1/Mon Sep 22 21:02:26 2003// -/jisx0208x0212x0213_ucs.map/1.1/Mon Sep 22 21:02:26 2003// -/jisx02132_sjis.map/1.1/Mon Sep 22 21:02:28 2003// -/jisx0213_ucs_p2.map/1.1/Mon Sep 22 21:02:28 2003// -/johab_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/koi8r_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/koi8u_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/ksx1001_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/mk_big5_txt.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_big5_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_cns_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_combining_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_cp1258_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_cp950_txt.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_gb18030_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_gb_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_gbk_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_hkscs_p2_txt.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_hkscs_txt.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_hkscs_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_hkscs_ucs_p2_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_jis_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_jisx0213_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_johab_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_ks_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_sjis_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_tis_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_uhc_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/mk_viet_ucs_map.pl/1.1/Mon Sep 22 21:02:28 2003// -/nextstep_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/sjis_ext_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/tcvn57123_tcvn5712.map/1.1/Mon Sep 22 21:02:28 2003// -/tcvn5712_combining.map/1.1/Mon Sep 22 21:02:28 2003// -/tcvn5712_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/ucs_combining.map/1.1/Mon Sep 22 21:02:28 2003// -/ucs_fullwidth.map/1.1/Mon Sep 22 21:02:28 2003// -/ucs_hangul.map/1.1/Mon Sep 22 21:02:28 2003// -/ucs_precompose.map/1.1/Mon Sep 22 21:02:28 2003// -/uhc_ucs.map/1.1/Mon Sep 22 21:02:28 2003// -/viscii11_ucs.map/1.1/Mon Sep 22 21:02:29 2003// -/vps_ucs.map/1.1/Mon Sep 22 21:02:29 2003// -/mk_ucs_case_map.pl/1.1/Tue Aug 24 10:11:51 2010// -/mk_ucs_isdigit_map.pl/1.1/Tue Aug 24 10:11:51 2010// -/ucs_ambwidth.map/1.1/Sun Jul 25 09:55:05 2010// -/ucs_case.map/1.1/Tue Aug 24 10:11:51 2010// -/ucs_isalpha.map/1.1/Tue Aug 24 10:11:51 2010// -/ucs_isdigit.map/1.1/Tue Aug 24 10:11:51 2010// -/ucs_islower.map/1.1/Tue Aug 24 10:11:51 2010// -/ucs_isupper.map/1.1/Tue Aug 24 10:11:51 2010// -/ucs_wide.map/1.2/Tue Jan  4 09:22:28 2011// -D diff --git a/libwc/map/CVS/Repository b/libwc/map/CVS/Repository deleted file mode 100644 index 487f8e5..0000000 --- a/libwc/map/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/libwc/map diff --git a/libwc/map/CVS/Root b/libwc/map/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/libwc/map/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -1026,7 +1026,7 @@ _prev(void)  	strCurrentBuf = strBuf;      }      if (DecodeURL && (cm_mode & CPL_URL) ) -	p = url_unquote_conv(p, 0); +	p = url_decode2(p, NULL);      strBuf = Strnew_charp(p);      CLen = CPos = setStrType(strBuf, strProp);      offset = 0; @@ -1045,7 +1045,7 @@ _next(void)      p = nextHist(hist);      if (p) {  	if (DecodeURL && (cm_mode & CPL_URL) ) -	    p = url_unquote_conv(p, 0); +	    p = url_decode2(p, NULL);  	strBuf = Strnew_charp(p);      }      else { @@ -317,7 +317,11 @@ wrap_GC_warn_proc(char *msg, GC_word arg)  	    lock = 0;  	}      } +#if GC_VERSION_MAJOR >= 7 && GC_VERSION_MINOR >= 2 +    else if (orig_GC_warn_proc = GC_get_warn_proc()) +#else      else if (orig_GC_warn_proc) +#endif  	orig_GC_warn_proc(msg, arg);      else  	fprintf(stderr, msg, (unsigned long)arg); @@ -845,7 +849,11 @@ main(int argc, char **argv, char **envp)      mySignal(SIGPIPE, SigPipe);  #endif +#if GC_VERSION_MAJOR >= 7 && GC_VERSION_MINOR >= 2 +    GC_set_warn_proc(wrap_GC_warn_proc); +#else      orig_GC_warn_proc = GC_set_warn_proc(wrap_GC_warn_proc); +#endif      err_msg = Strnew();      if (load_argc == 0) {  	/* no URL specified */ @@ -906,12 +914,17 @@ main(int argc, char **argv, char **envp)  	if (i >= 0) {  	    SearchHeader = search_header;  	    DefaultType = default_type; +	    char *url; +	     +	    url = load_argv[i]; +	    if (getURLScheme(&url) == SCM_MISSING && !ArgvIsURL) +		url = file_to_url(load_argv[i]); +	    else +		url = url_encode(conv_from_system(load_argv[i]), NULL, 0);  	    if (w3m_dump == DUMP_HEAD) {  		request = New(FormList);  		request->method = FORM_METHOD_HEAD; -		newbuf = -		    loadGeneralFile(load_argv[i], NULL, NO_REFERER, 0, -				    request); +		newbuf = loadGeneralFile(url, NULL, NO_REFERER, 0, request);  	    }  	    else {  		if (post_file && i == 0) { @@ -940,9 +953,7 @@ main(int argc, char **argv, char **envp)  		else {  		    request = NULL;  		} -		newbuf = -		    loadGeneralFile(load_argv[i], NULL, NO_REFERER, 0, -				    request); +		newbuf = loadGeneralFile(url, NULL, NO_REFERER, 0, request);  	    }  	    if (newbuf == NULL) {  		/* FIXME: gettextize? */ @@ -957,7 +968,7 @@ main(int argc, char **argv, char **envp)  		break;  	    case SCM_LOCAL:  	    case SCM_LOCAL_CGI: -		unshiftHist(LoadHist, conv_from_system(load_argv[i])); +		unshiftHist(LoadHist, url);  	    default:  		pushHashHist(URLHist, parsedURL2Str(&newbuf->currentURL)->ptr);  		break; @@ -1258,6 +1269,12 @@ dump_extra(Buffer *buf)  #endif  } +static int +cmp_anchor_hseq(const void *a, const void *b) +{ +    return (*((const Anchor **) a))->hseq - (*((const Anchor **) b))->hseq; +} +  static void  do_dump(Buffer *buf)  { @@ -1278,18 +1295,20 @@ do_dump(Buffer *buf)  	int i;  	saveBuffer(buf, stdout, FALSE);  	if (displayLinkNumber && buf->href) { +	    int nanchor = buf->href->nanchor;  	    printf("\nReferences:\n\n"); -	    for (i = 0; i < buf->href->nanchor; i++) { -	        ParsedURL pu; -	        static Str s = NULL; -		if (buf->href->anchors[i].slave) +	    Anchor **in_order = New_N(Anchor *, buf->href->nanchor); +	    for (i = 0; i < nanchor; i++) +		in_order[i] = buf->href->anchors + i; +	    qsort(in_order, nanchor, sizeof(Anchor *), cmp_anchor_hseq); +	    for (i = 0; i < nanchor; i++) { +		ParsedURL pu; +		char *url; +		if (in_order[i]->slave)  		    continue; -	        parseURL2(buf->href->anchors[i].url, &pu, baseURL(buf)); -	        s = parsedURL2Str(&pu); -    	        if (DecodeURL) -		    s = Strnew_charp(url_unquote_conv -				     (s->ptr, Currentbuf->document_charset)); -	        printf("[%d] %s\n", buf->href->anchors[i].hseq + 1, s->ptr); +		parseURL2(in_order[i]->url, &pu, baseURL(buf)); +		url = url_decode2(parsedURL2Str(&pu)->ptr, Currentbuf); +		printf("[%d] %s\n", in_order[i]->hseq + 1, url);  	    }  	}      } @@ -1578,6 +1597,18 @@ DEFUN(pgBack, PREV_PAGE, "Move to previous page")  		  * (Currentbuf->LINES - 1)), prec_num ? B_SCROLL : B_NORMAL);  } +/* Move half page forward */ +DEFUN(hpgFore, NEXT_HALF_PAGE, "Scroll down half page") +{ +	nscroll(searchKeyNum() * (Currentbuf->LINES / 2 - 1), B_NORMAL); +} + +/* Move half page backward */ +DEFUN(hpgBack, PREV_HALF_PAGE, "Scroll up half page") +{ +	nscroll(-searchKeyNum() * (Currentbuf->LINES / 2 - 1), B_NORMAL); +} +  /* 1 line up */  DEFUN(lup1, UP, "Scroll up one line")  { @@ -2273,7 +2304,7 @@ DEFUN(movR1, MOVE_RIGHT1,  static wc_uint32  getChar(char *p)  { -    return wc_any_to_ucs(wtf_parse1(&p)); +    return wc_any_to_ucs(wtf_parse1((wc_uchar **)&p));  }  static int @@ -2816,12 +2847,15 @@ loadLink(char *url, char *target, char *referer, FormList *request)      union frameset_element *f_element = NULL;      int flag = 0;      ParsedURL *base, pu; +    const int *no_referer_ptr;      message(Sprintf("loading %s", url)->ptr, 0, 0);      refresh(); +    no_referer_ptr = query_SCONF_NO_REFERER_FROM(&Currentbuf->currentURL);      base = baseURL(Currentbuf); -    if (base == NULL || +    if ((no_referer_ptr && *no_referer_ptr) || +	base == NULL ||  	base->scheme == SCM_LOCAL || base->scheme == SCM_LOCAL_CGI)  	referer = NO_REFERER;      if (referer == NULL) @@ -3580,6 +3614,33 @@ DEFUN(lastA, LINK_END, "Go to the last link")      displayBuffer(Currentbuf, B_NORMAL);  } +/* go to the nth anchor */ +DEFUN(nthA, LINK_N, "Go to the nth link") +{ +    HmarkerList *hl = Currentbuf->hmarklist; +	BufferPoint *po; +	Anchor *an; + +	int n = searchKeyNum(); +	if (n < 0 || n > hl->nmark) return; + +	if (Currentbuf->firstLine == NULL) +		return; +    if (!hl || hl->nmark == 0) +		return; + +	po = hl->marks + n-1; +	an = retrieveAnchor(Currentbuf->href, po->line, po->pos); +	if (an == NULL) +		an = retrieveAnchor(Currentbuf->formitem, po->line, po->pos); +	if (an == NULL) return; + +    gotoLine(Currentbuf, po->line); +    Currentbuf->pos = po->pos; +    arrangeCursor(Currentbuf); +    displayBuffer(Currentbuf, B_NORMAL); +} +  /* go to the next anchor */  DEFUN(nextA, NEXT_LINK, "Move to next link")  { @@ -4067,6 +4128,7 @@ goURL0(char *prompt, int relative)      char *url, *referer;      ParsedURL p_url, *current;      Buffer *cur_buf = Currentbuf; +    const int *no_referer_ptr;      url = searchKeyData();      if (url == NULL) { @@ -4076,11 +4138,8 @@ goURL0(char *prompt, int relative)  	current = baseURL(Currentbuf);  	if (current) {  	    char *c_url = parsedURL2Str(current)->ptr; -	    if (DefaultURLString == DEFAULT_URL_CURRENT) { -		url = c_url; -		if (DecodeURL) -		    url = url_unquote_conv(url, 0); -	    } +	    if (DefaultURLString == DEFAULT_URL_CURRENT) +		url = url_decode2(c_url, NULL);  	    else  		pushHist(hist, c_url);  	} @@ -4089,11 +4148,8 @@ goURL0(char *prompt, int relative)  	    char *a_url;  	    parseURL2(a->url, &p_url, current);  	    a_url = parsedURL2Str(&p_url)->ptr; -	    if (DefaultURLString == DEFAULT_URL_LINK) { -		url = a_url; -		if (DecodeURL) -		    url = url_unquote_conv(url, Currentbuf->document_charset); -	    } +	    if (DefaultURLString == DEFAULT_URL_LINK) +		url = url_decode2(a_url, Currentbuf);  	    else  		pushHist(hist, a_url);  	} @@ -4101,15 +4157,22 @@ goURL0(char *prompt, int relative)  	if (url != NULL)  	    SKIP_BLANKS(url);      } -#ifdef USE_M17N -    if (url != NULL) { -	if ((relative || *url == '#') && Currentbuf->document_charset) -	    url = wc_conv_strict(url, InnerCharset, -				 Currentbuf->document_charset)->ptr; +    if (relative) { +	no_referer_ptr = query_SCONF_NO_REFERER_FROM(&Currentbuf->currentURL); +	current = baseURL(Currentbuf); +	if ((no_referer_ptr && *no_referer_ptr) || +	    current == NULL || +	    current->scheme == SCM_LOCAL || current->scheme == SCM_LOCAL_CGI) +	    referer = NO_REFERER;  	else -	    url = conv_to_system(url); +	    referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; +	url = url_encode(url, current, Currentbuf->document_charset); +    } +    else { +	current = NULL; +	referer = NULL; +	url = url_encode(url, NULL, 0);      } -#endif      if (url == NULL || *url == '\0') {  	displayBuffer(Currentbuf, B_FORCE_REDRAW);  	return; @@ -4118,14 +4181,6 @@ goURL0(char *prompt, int relative)  	gotoLabel(url + 1);  	return;      } -    if (relative) { -	current = baseURL(Currentbuf); -	referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; -    } -    else { -	current = NULL; -	referer = NULL; -    }      parseURL2(url, &p_url, current);      pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr);      cmd_loadURL(url, current, referer, NULL); @@ -4522,8 +4577,7 @@ _peekURL(int only_img)  	s = parsedURL2Str(&pu);      }      if (DecodeURL) -	s = Strnew_charp(url_unquote_conv -			 (s->ptr, Currentbuf->document_charset)); +	s = Strnew_charp(url_decode2(s->ptr, Currentbuf));  #ifdef USE_M17N      s = checkType(s, &pp, NULL);      p = NewAtom_N(Lineprop, s->length); @@ -4582,7 +4636,7 @@ DEFUN(curURL, PEEK, "Peek current URL")  	offset = 0;  	s = currentURL();  	if (DecodeURL) -	    s = Strnew_charp(url_unquote_conv(s->ptr, 0)); +	    s = Strnew_charp(url_decode2(s->ptr, NULL));  #ifdef USE_M17N  	s = checkType(s, &pp, NULL);  	p = NewAtom_N(Lineprop, s->length); @@ -5410,6 +5464,58 @@ DEFUN(mouse, MOUSE, "mouse operation")      process_mouse(btn, x, y);  } +DEFUN(sgrmouse, SGRMOUSE, "SGR 1006 mouse operation") +{ +    int btn = 0, x = 0, y = 0; +    unsigned char c; + +    do { +	c = getch(); +	if (IS_DIGIT(c)) +	    btn = btn * 10 + c - '0'; +	else if (c == ';') +	    break; +	else +	    return; +    } while (1); + +#if defined(__CYGWIN__) && CYGWIN_VERSION_DLL_MAJOR < 1005 +    if (cygwin_mouse_btn_swapped) { +	if (btn == MOUSE_BTN2_DOWN) +	    btn = MOUSE_BTN3_DOWN; +	else if (btn == MOUSE_BTN3_DOWN) +	    btn = MOUSE_BTN2_DOWN; +    }; +#endif + +    do { +	c = getch(); +	if (IS_DIGIT(c)) +	    x = x * 10 + c - '0'; +	else if (c == ';') +	    break; +	else +	  return; +    } while (1); + +    do { +	c = getch(); +	if (IS_DIGIT(c)) +	    y = y * 10 + c - '0'; +	else if (c == 'M') +	    break; +	else if (c == 'm') { +	    btn |= 3; +	    break; +	} else +    return; +    } while (1); + +    if (x < 0 || x >= COLS || y < 0 || y > LASTLINE) +	return; +    process_mouse(btn, x, y); +} +  #ifdef USE_GPM  int  gpm_process_mouse(Gpm_Event * event, void *data) @@ -5616,7 +5722,7 @@ execdict(char *word)  	disp_message("Execution failed", TRUE);  	return;      } -    else { +    else if (buf != NO_BUFFER) {  	buf->filename = w;  	buf->buffername = Sprintf("%s %s", DICTBUFFERNAME, word)->ptr;  	if (buf->type == NULL) @@ -279,7 +279,7 @@ follow_map_panel(Buffer *buf, char *name)  	p = parsedURL2Str(&pu)->ptr;  	q = html_quote(p);  	if (DecodeURL) -	    p = html_quote(url_unquote_conv(p, buf->document_charset)); +	    p = html_quote(url_decode2(p, buf));  	else  	    p = q;  	Strcat_m_charp(mappage, "<tr valign=top><td><a href=\"", q, "\">", @@ -417,10 +417,7 @@ append_map_info(Buffer *buf, Str tmp, FormItemList *fi)  	    continue;  	parseURL2(a->url, &pu, baseURL(buf));  	q = html_quote(parsedURL2Str(&pu)->ptr); -	if (DecodeURL) -	    p = html_quote(url_unquote_conv(a->url, buf->document_charset)); -	else -	    p = html_quote(a->url); +	p = html_quote(url_decode2(a->url, buf));  	Strcat_m_charp(tmp, "<tr valign=top><td>  <td><a href=\"",  		       q, "\">",  		       html_quote(*a->alt ? a->alt : mybasename(a->url)), @@ -457,10 +454,8 @@ append_link_info(Buffer *buf, Str html, LinkList * link)  	    Strcat_charp(html, "[Rev]");  	if (!l->url)  	    url = "(empty)"; -	else if (DecodeURL) -	    url = html_quote(url_unquote_conv(l->url, buf->document_charset));  	else -	    url = html_quote(l->url); +	    url = html_quote(url_decode2(l->url, buf));  	Strcat_m_charp(html, "<td>", url, NULL);  	if (l->ctype)  	    Strcat_m_charp(html, " (", html_quote(l->ctype), ")", NULL); @@ -498,8 +493,7 @@ append_frame_info(Buffer *buf, Str html, struct frameset *set, int level)  		    Strcat_charp(html, p);  		}  		if (DecodeURL) -		    p = html_quote(url_unquote_conv(frame.body->url, -						    buf->document_charset)); +		    p = html_quote(url_decode2(frame.body->url, buf));  		else  		    p = q;  		Strcat_m_charp(html, " ", p, "</a></pre_int><br>\n", NULL); @@ -550,9 +544,7 @@ page_info_panel(Buffer *buf)  #ifdef USE_M17N      Strcat_charp(tmp, "<form method=internal action=charset>");  #endif -    p = parsedURL2Str(&buf->currentURL)->ptr; -    if (DecodeURL) -	p = url_unquote_conv(p, 0); +    p = url_decode2(parsedURL2Str(&buf->currentURL)->ptr, NULL);      Strcat_m_charp(tmp, "<table cellpadding=0>",  		   "<tr valign=top><td nowrap>Title<td>",  		   html_quote(buf->buffername), @@ -589,7 +581,7 @@ page_info_panel(Buffer *buf)  	p = parsedURL2Str(&pu)->ptr;  	q = html_quote(p);  	if (DecodeURL) -	    p = html_quote(url_unquote_conv(p, buf->document_charset)); +	    p = html_quote(url_decode2(p, buf));  	else  	    p = q;  	Strcat_m_charp(tmp, @@ -602,7 +594,7 @@ page_info_panel(Buffer *buf)  	p = parsedURL2Str(&pu)->ptr;  	q = html_quote(p);  	if (DecodeURL) -	    p = html_quote(url_unquote_conv(p, buf->document_charset)); +	    p = html_quote(url_decode2(p, buf));  	else  	    p = q;  	Strcat_m_charp(tmp, @@ -613,10 +605,7 @@ page_info_panel(Buffer *buf)      if (a != NULL) {  	FormItemList *fi = (FormItemList *)a->url;  	p = form2str(fi); -	if (DecodeURL) -	    p = html_quote(url_unquote_conv(p, buf->document_charset)); -	else -	    p = html_quote(p); +	p = html_quote(url_decode2(p, buf));  	Strcat_m_charp(tmp,  		       "<tr valign=top><td nowrap>Method/type of current form <td>",  		       p, NULL); @@ -1365,9 +1365,7 @@ initSelectMenu(void)  		break;  	    default:  		Strcat_char(str, ' '); -		p = parsedURL2Str(&buf->currentURL)->ptr; -		if (DecodeURL) -		    p = url_unquote_conv(p, 0); +		p = url_decode2(parsedURL2Str(&buf->currentURL)->ptr, NULL);  		Strcat_charp(str, p);  		break;  	    } @@ -1513,9 +1511,7 @@ initSelTabMenu(void)  	    case SCM_MISSING:  		break;  	    default: -		p = parsedURL2Str(&buf->currentURL)->ptr; -		if (DecodeURL) -		    p = url_unquote_conv(p, 0); +		p = url_decode2(parsedURL2Str(&buf->currentURL)->ptr, NULL);  		Strcat_charp(str, p);  		break;  	    } @@ -1845,10 +1841,8 @@ link_menu(Buffer *buf)  	    Strcat_charp(str, " ");  	if (!l->url)  	    p = ""; -	else if (DecodeURL) -	    p = url_unquote_conv(l->url, buf->document_charset);  	else -	    p = l->url; +	    p = url_decode2(l->url, buf);  	Strcat_charp(str, p);  	label[i] = str->ptr;  	if (len < str->length) diff --git a/po/CVS/Entries b/po/CVS/Entries deleted file mode 100644 index 1e7831b..0000000 --- a/po/CVS/Entries +++ /dev/null @@ -1,16 +0,0 @@ -/.cvsignore/1.2/Thu Sep 25 18:35:43 2003// -/LINGUAS/1.1/Wed Sep 24 18:35:06 2003// -/POTFILES.in/1.2/Wed Sep 24 18:35:06 2003// -/boldquot.sed/1.1/Tue Sep 23 18:42:25 2003// -/en@boldquot.header/1.1/Tue Sep 23 18:42:25 2003// -/en@quot.header/1.1/Tue Sep 23 18:42:25 2003// -/insert-header.sin/1.1/Tue Sep 23 18:42:25 2003// -/quot.sed/1.1/Tue Sep 23 18:42:25 2003// -/remove-potcdate.sin/1.1/Tue Sep 23 18:42:25 2003// -/Makevars/1.2/Tue Jan  4 09:22:28 2011// -/ChangeLog/1.2/Tue Jan  4 12:39:29 2011// -/Makefile.in.in/1.3/Tue Jan  4 12:39:29 2011// -/Rules-quot/1.2/Tue Jan  4 12:39:29 2011// -/ja.po/1.14/Sat Jan 15 04:29:58 2011// -/w3m.pot/1.14/Sat Jan 15 02:20:26 2011// -D diff --git a/po/CVS/Repository b/po/CVS/Repository deleted file mode 100644 index 139f7dd..0000000 --- a/po/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/po diff --git a/po/CVS/Root b/po/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/po/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m @@ -407,6 +407,10 @@ msgid "File for setting form on loading"  msgstr "文書読込時のフォーム設定用ファイル"  #: rc.c:149 +msgid "File for preferences for each site" +msgstr "サイト別設定のファイル" + +#: rc.c:149  msgid "Password for anonymous FTP (your mail address)"  msgstr "FTPのパスワード(普通は自分のmail addressを使う)" @@ -11,6 +11,8 @@ extern void pushEvent(int cmd, void *data);  extern MySignalHandler intTrap(SIGNAL_ARG);  extern void pgFore(void);  extern void pgBack(void); +extern void hpgFore(void); +extern void hpgBack(void);  extern void lup1(void);  extern void ldown1(void);  extern void ctrCsrV(void); @@ -61,6 +63,7 @@ extern void submitForm(void);  extern void followForm(void);  extern void topA(void);  extern void lastA(void); +extern void nthA(void);  extern void onA(void);  extern void nextA(void); @@ -162,6 +165,24 @@ extern Str searchURIMethods(ParsedURL *pu);  extern void chkExternalURIBuffer(Buffer *buf);  #endif  extern ParsedURL *schemeToProxy(int scheme); +#ifdef USE_M17N +extern wc_ces url_to_charset(const char *url, const ParsedURL *base, +			     wc_ces doc_charset); +extern char *url_encode(const char *url, const ParsedURL *base, +			wc_ces doc_charset); +#if 0 +extern char *url_decode(const char *url, const ParsedURL *base, +			wc_ces doc_charset); +#endif +extern char *url_decode2(const char *url, const Buffer *buf); +#else /* !defined(USE_M17N) */ +#define url_encode(url, base, cs) url_quote(url) +extern char *url_decode0(const char *url); +#if 0 +#define url_decode(url, base, cs) url_decode0(url) +#endif +#define url_decode2(url, buf) url_decode0(url) +#endif /* !defined(USE_M17N) */  extern void examineFile(char *path, URLFile *uf);  extern char *acceptableEncoding();  extern int dir_exist(char *path); @@ -180,7 +201,6 @@ extern void push_symbol(Str str, char symbol, int width, int n);  #ifdef USE_UNICODE  extern void update_utf8_symbol(void);  #endif -extern Buffer *loadFile(char *path);  extern Buffer *loadGeneralFile(char *path, ParsedURL *current, char *referer,  			       int flag, FormList *request);  extern int is_boundary(unsigned char *, unsigned char *); @@ -207,6 +227,8 @@ extern int getImageSize(ImageCache * cache);  extern Str process_img(struct parsed_tag *tag, int width);  extern Str process_anchor(struct parsed_tag *tag, char *tagbuf);  extern Str process_input(struct parsed_tag *tag); +extern Str process_button(struct parsed_tag *tag); +extern Str process_n_button(void);  extern Str process_select(struct parsed_tag *tag);  extern Str process_n_select(void);  extern void feed_select(char *str); @@ -249,8 +271,7 @@ extern Buffer *openPagerBuffer(InputStream stream, Buffer *buf);  extern Buffer *openGeneralPagerBuffer(InputStream stream);  extern Line *getNextPage(Buffer *buf, int plen);  extern int save2tmp(URLFile uf, char *tmpf); -extern int doExternal(URLFile uf, char *path, char *type, Buffer **bufp, -		      Buffer *defaultbuf); +extern Buffer *doExternal(URLFile uf, char *type, Buffer *defaultbuf);  extern int _doFileCopy(char *tmpf, char *defstr, int download);  #define doFileCopy(tmpf, defstr) _doFileCopy(tmpf, defstr, FALSE);  extern int doFileMove(char *tmpf, char *defstr); @@ -507,7 +528,7 @@ extern ParsedURL *baseURL(Buffer *buf);  extern int openSocket(char *hostname, char *remoteport_name,  		      unsigned short remoteport_num);  extern void parseURL(char *url, ParsedURL *p_url, ParsedURL *current); -extern void copyParsedURL(ParsedURL *p, ParsedURL *q); +extern void copyParsedURL(ParsedURL *p, const ParsedURL *q);  extern void parseURL2(char *url, ParsedURL *pu, ParsedURL *current);  extern Str parsedURL2Str(ParsedURL *pu);  extern int getURLScheme(char **url); @@ -611,6 +632,7 @@ extern char *confFile(char *base);  extern char *auxbinFile(char *base);  extern char *libFile(char *base);  extern char *helpFile(char *base); +extern const void *querySiteconf(const ParsedURL *query_pu, int field);  extern Str localCookie(void);  extern Str loadLocalDir(char *dirname);  extern void set_environ(char *var, char *value); @@ -683,6 +705,7 @@ extern void reMark(void);  #ifdef USE_MOUSE  extern void mouse(void); +extern void sgrmouse(void);  extern void mouse_init(void);  extern void mouse_end(void);  extern void mouse_active(void); @@ -723,6 +746,8 @@ extern int getKey(char *s);  extern char *getKeyData(int key);  extern char *getWord(char **str);  extern char *getQWord(char **str); +struct regex; +extern char *getRegexWord(const char **str, struct regex **regex_ret);  #ifdef USE_MOUSE  extern void initMouseAction(void);  #endif @@ -9,7 +9,9 @@  #include <errno.h>  #include "parsetag.h"  #include "local.h" +#include "regex.h"  #include <stdlib.h> +#include <stddef.h>  struct param_ptr {      char *name; @@ -146,6 +148,7 @@ static int OptionEncode = FALSE;  #define CMT_DISABLE_SECRET_SECURITY_CHECK	N_("Disable secret file security check")  #define CMT_PASSWDFILE	 N_("Password file")  #define CMT_PRE_FORM_FILE	N_("File for setting form on loading") +#define CMT_SITECONF_FILE	N_("File for preferences for each site")  #define CMT_FTPPASS      N_("Password for anonymous FTP (your mail address)")  #define CMT_FTPPASS_HOSTNAMEGEN N_("Generate domain part of password for FTP")  #define CMT_USERAGENT    N_("User-Agent identification string") @@ -619,6 +622,8 @@ struct param_ptr params9[] = {       CMT_FTPPASS_HOSTNAMEGEN, NULL},      {"pre_form_file", P_STRING, PI_TEXT, (void *)&pre_form_file,       CMT_PRE_FORM_FILE, NULL}, +    {"siteconf_file", P_STRING, PI_TEXT, (void *)&siteconf_file, +     CMT_SITECONF_FILE, NULL},      {"user_agent", P_STRING, PI_TEXT, (void *)&UserAgent, CMT_USERAGENT, NULL},      {"no_referer", P_INT, PI_ONOFF, (void *)&NoSendReferer, CMT_NOSENDREFERER,       NULL}, @@ -1173,6 +1178,8 @@ do_mkdir(const char *dir, long mode)  #endif				/* not __MINW32_VERSION */  #endif				/* not __EMX__ */ +static void loadSiteconf(void); +  void  sync_with_option(void)  { @@ -1199,6 +1206,7 @@ sync_with_option(void)  #endif      loadPasswd();      loadPreForm(); +    loadSiteconf();      if (AcceptLang == NULL || *AcceptLang == '\0') {  	/* TRANSLATORS:  @@ -1556,3 +1564,217 @@ helpFile(char *base)      return expandPath(Strnew_m_charp(w3m_help_dir(), "/", base, NULL)->ptr);  }  #endif + +/* siteconf */ +/* + * url "<url>"|/<re-url>/|m@<re-url>@i [exact] + * substitute_url "<destination-url>" + * url_charset <charset> + * no_referer_from on|off + * no_referer_to on|off + *  + * The last match wins. + */ + +struct siteconf_rec { +    struct siteconf_rec *next; +    char *url; +    Regex *re_url; +    int url_exact; +    unsigned char mask[(SCONF_N_FIELD + 7) >> 3]; + +    char *substitute_url; +#ifdef USE_M17N +    wc_ces url_charset; +#endif +    int no_referer_from; +    int no_referer_to; +}; +#define SCONF_TEST(ent, f) ((ent)->mask[(f)>>3] & (1U<<((f)&7))) +#define SCONF_SET(ent, f) ((ent)->mask[(f)>>3] |= (1U<<((f)&7))) +#define SCONF_CLEAR(ent, f) ((ent)->mask[(f)>>3] &= ~(1U<<((f)&7))) + +static struct siteconf_rec *siteconf_head = NULL; +static struct siteconf_rec *newSiteconfRec(void); + +static struct siteconf_rec * +newSiteconfRec(void) +{ +    struct siteconf_rec *ent; + +    ent = New(struct siteconf_rec); +    ent->next = NULL; +    ent->url = NULL; +    ent->re_url = NULL; +    ent->url_exact = FALSE; +    memset(ent->mask, 0, sizeof(ent->mask)); + +    ent->substitute_url = NULL; +#ifdef USE_M17N +    ent->url_charset = 0; +#endif +    return ent; +} + +static void +loadSiteconf(void) +{ +    char *efname; +    FILE *fp; +    Str line; +    struct siteconf_rec *ent = NULL; + +    siteconf_head = NULL; +    if (!siteconf_file) +	return; +    if ((efname = expandPath(siteconf_file)) == NULL) +	return; +    fp = fopen(efname, "r"); +    if (fp == NULL) +	return; +    while (line = Strfgets(fp), line->length > 0) { +	char *p, *s; + +	Strchop(line); +	p = line->ptr; +	SKIP_BLANKS(p); +	if (*p == '#' || *p == '\0') +	    continue; +	s = getWord(&p); + +	/* The "url" begins a new record. */ +	if (strcmp(s, "url") == 0) { +	    char *url, *opt; +	    struct siteconf_rec *newent; + +	    /* First, register the current record. */ +	    if (ent) { +		ent->next = siteconf_head; +		siteconf_head = ent; +		ent = NULL; +	    } + +	    /* Second, create a new record. */ +	    newent = newSiteconfRec(); +	    url = getRegexWord((const char **)&p, &newent->re_url); +	    opt = getWord(&p); +	    SKIP_BLANKS(p); +	    if (!newent->re_url) { +		ParsedURL pu; +		if (!url || !*url) +		    continue; +		parseURL2(url, &pu, NULL); +		newent->url = parsedURL2Str(&pu)->ptr; +	    } +	    /* If we have an extra or unknown option, ignore this record +	     * for future extensions. */ +	    if (strcmp(opt, "exact") == 0) { +		newent->url_exact = TRUE; +	    } +	    else if (*opt != 0) +		    continue; +	    if (*p) +		continue; +	    ent = newent; +	    continue; +	} + +	/* If the current record is broken, skip to the next "url". */ +	if (!ent) +	    continue; + +	/* Fill the new record. */ +	if (strcmp(s, "substitute_url") == 0) { +	    ent->substitute_url = getQWord(&p); +	    SCONF_SET(ent, SCONF_SUBSTITUTE_URL); +	} +#ifdef USE_M17N +	else if (strcmp(s, "url_charset") == 0) { +	    char *charset = getWord(&p); +	    ent->url_charset = (charset && *charset) ? +		wc_charset_to_ces(charset) : 0; +	    SCONF_SET(ent, SCONF_URL_CHARSET); +	} +#endif /* USE_M17N */ +	else if (strcmp(s, "no_referer_from") == 0) { +	    ent->no_referer_from = str_to_bool(getWord(&p), 0); +	    SCONF_SET(ent, SCONF_NO_REFERER_FROM); +	} +	else if (strcmp(s, "no_referer_to") == 0) { +	    ent->no_referer_to = str_to_bool(getWord(&p), 0); +	    SCONF_SET(ent, SCONF_NO_REFERER_TO); +	} +    } +    if (ent) { +	ent->next = siteconf_head; +	siteconf_head = ent; +	ent = NULL; +    } +    fclose(fp); +} + +const void * +querySiteconf(const ParsedURL *query_pu, int field) +{ +    const struct siteconf_rec *ent; +    Str u; +    char *firstp, *lastp; + +    if (field < 0 || field >= SCONF_N_FIELD) +	return NULL; +    if (!query_pu || IS_EMPTY_PARSED_URL(query_pu)) +	return NULL; +    u = parsedURL2Str((ParsedURL *)query_pu); +    if (u->length == 0) +	return NULL; + +    for (ent = siteconf_head; ent; ent = ent->next) { +	if (!SCONF_TEST(ent, field)) +	    continue; +	if (ent->re_url) { +	    if (RegexMatch(ent->re_url, u->ptr, u->length, 1)) { +		MatchedPosition(ent->re_url, &firstp, &lastp); +		if (!ent->url_exact) +		    goto url_found; +		if (firstp != u->ptr || lastp == firstp) +		    continue; +		if (*lastp == 0 || *lastp == '?' || *(lastp - 1) == '?' || +		    *lastp == '#' || *(lastp - 1) == '#') +		    goto url_found; +	    } +	} else { +	    int matchlen = strmatchlen(ent->url, u->ptr, u->length); +	    if (matchlen == 0 || ent->url[matchlen] != 0) +		continue; +	    firstp = u->ptr; +	    lastp = u->ptr + matchlen; +	    if (*lastp == 0 || *lastp == '?' || *(lastp - 1) == '?' || +		*lastp == '#' || *(lastp - 1) == '#') +		goto url_found; +	    if (!ent->url_exact && (*lastp == '/' || *(lastp - 1) == '/')) +		goto url_found; +	} +    } +    return NULL; + +url_found: +    switch (field) { +    case SCONF_SUBSTITUTE_URL: +	if (ent->substitute_url && *ent->substitute_url) { +	    Str tmp = Strnew_charp_n(u->ptr, firstp - u->ptr); +	    Strcat_charp(tmp, ent->substitute_url); +	    Strcat_charp(tmp, lastp); +	    return tmp->ptr; +	} +	return NULL; +#ifdef USE_M17N +    case SCONF_URL_CHARSET: +	return &ent->url_charset; +#endif +    case SCONF_NO_REFERER_FROM: +	return &ent->no_referer_from; +    case SCONF_NO_REFERER_TO: +	return &ent->no_referer_to; +    } +    return NULL; +} diff --git a/scripts/CVS/Entries b/scripts/CVS/Entries deleted file mode 100644 index 2d1a4e5..0000000 --- a/scripts/CVS/Entries +++ /dev/null @@ -1,13 +0,0 @@ -/.cvsignore/1.10/Mon Sep 22 22:53:53 2003// -/dirlist.cgi.in/1.7/Fri Feb  7 15:06:17 2003// -/w3mhelp-funcdesc.en.pl.in/1.4/Mon Mar 22 17:03:13 2004// -/w3mhelp-funcdesc.ja.pl.in/1.4/Mon Mar 22 17:03:13 2004// -/w3mhelp-funcname.pl.in/1.3/Mon Apr  7 15:19:43 2003// -/w3mmail.cgi.in/1.14/Mon Aug 30 16:32:24 2004// -/xface2xbm.in/1.3/Mon Nov 18 17:33:01 2002// -/xface2xpm.in/1.1/Tue Apr  9 14:45:58 2002// -D/bm2menu//// -D/multipart//// -D/w3mman//// -/Makefile.in/1.11/Tue Jan  4 09:22:28 2011// -/w3mhelp.cgi.in/1.29/Tue Jan  4 09:22:28 2011// diff --git a/scripts/CVS/Repository b/scripts/CVS/Repository deleted file mode 100644 index 578c817..0000000 --- a/scripts/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/scripts diff --git a/scripts/CVS/Root b/scripts/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/scripts/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/scripts/bm2menu/CVS/Entries b/scripts/bm2menu/CVS/Entries deleted file mode 100644 index 448ac0a..0000000 --- a/scripts/bm2menu/CVS/Entries +++ /dev/null @@ -1,3 +0,0 @@ -/README/1.1/Thu Nov 15 00:32:14 2001// -/bm2menu.pl/1.1/Thu Nov 15 00:32:14 2001// -D diff --git a/scripts/bm2menu/CVS/Repository b/scripts/bm2menu/CVS/Repository deleted file mode 100644 index c3eaf83..0000000 --- a/scripts/bm2menu/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/scripts/bm2menu diff --git a/scripts/bm2menu/CVS/Root b/scripts/bm2menu/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/scripts/bm2menu/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/scripts/multipart/CVS/Entries b/scripts/multipart/CVS/Entries deleted file mode 100644 index b503f2a..0000000 --- a/scripts/multipart/CVS/Entries +++ /dev/null @@ -1,6 +0,0 @@ -/.cvsignore/1.2/Mon Sep 22 22:53:53 2003// -/README/1.2/Wed Nov 21 09:21:59 2001// -/mailcap/1.1/Thu Nov 15 00:32:14 2001// -/multipart.cgi.in/1.11/Tue Feb 18 15:26:39 2003// -/Makefile.in/1.6/Tue Jan  4 09:22:28 2011// -D diff --git a/scripts/multipart/CVS/Repository b/scripts/multipart/CVS/Repository deleted file mode 100644 index cb383c6..0000000 --- a/scripts/multipart/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/scripts/multipart diff --git a/scripts/multipart/CVS/Root b/scripts/multipart/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/scripts/multipart/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/scripts/w3mman/CVS/Entries b/scripts/w3mman/CVS/Entries deleted file mode 100644 index 2cc31ff..0000000 --- a/scripts/w3mman/CVS/Entries +++ /dev/null @@ -1,8 +0,0 @@ -/.cvsignore/1.3/Mon Sep 22 22:53:53 2003// -/README/1.3/Wed Dec 18 16:48:02 2002// -/hlink.cgi/1.1/Thu Nov 15 00:32:14 2001// -/w3mman.1.in/1.6/Fri Apr  7 15:33:56 2006// -/w3mman.in/1.5/Fri Apr  7 15:33:56 2006// -/Makefile.in/1.5/Tue Jan  4 09:22:28 2011// -/w3mman2html.cgi.in/1.9/Tue Jan  4 09:22:28 2011// -D diff --git a/scripts/w3mman/CVS/Repository b/scripts/w3mman/CVS/Repository deleted file mode 100644 index 430e75e..0000000 --- a/scripts/w3mman/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/scripts/w3mman diff --git a/scripts/w3mman/CVS/Root b/scripts/w3mman/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/scripts/w3mman/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/scripts/w3mman/w3mman2html.cgi.in b/scripts/w3mman/w3mman2html.cgi.in index f430307..2e3576c 100644 --- a/scripts/w3mman/w3mman2html.cgi.in +++ b/scripts/w3mman/w3mman2html.cgi.in @@ -126,12 +126,14 @@ while(<F>) {    s/\&/\&/g;    s/\</\</g;    s/\>/\>/g; +  # non ASCII UTF-8 codepoint +  my $utf8="[\300-\337][\200-\277]|[\340-\357][\200-\277]{2}|[\360-\367][\200-\277]{3}|[\370-\373][\200-\277]{4}|[\374\375][\200-\277]{5}"; -  s@([\200-\377].)(\010{1,2}\1)+@<b>$1</b>@g; +  s@($utf8)(\010\1)+@<b>$1</b>@g;    s@(\&\w+;|.)(\010\1)+@<b>$1</b>@g; -  s@__\010{1,2}((\<b\>)?[\200-\377].(\</b\>)?)@<u>$1</u>@g; +  s@_\010((\<b\>)?($utf8)(\</b\>)?)@<u>$1</u>@g;    s@_\010((\<b\>)?(\&\w+\;|.)(\</b\>)?)@<u>$1</u>@g; -  s@((\<b\>)?[\200-\377].(\</b\>)?)\010{1,2}__@<u>$1</u>@g; +  s@((\<b\>)?($utf8)(\</b\>)?)\010_@<u>$1</u>@g;    s@((\<b\>)?(\&\w+\;|.)(\</b\>)?)\010_@<u>$1</u>@g;    s@.\010(.)@$1@g; @@ -2878,6 +2878,14 @@ feed_table_tag(struct table *tbl, char *line, struct table_mode *mode,  	tmp = process_input(tag);  	feed_table1(tbl, tmp, mode, width);  	break; +    case HTML_BUTTON: +       tmp = process_button(tag); +       feed_table1(tbl, tmp, mode, width); +       break; +    case HTML_N_BUTTON: +       tmp = process_n_button(); +       feed_table1(tbl, tmp, mode, width); +       break;      case HTML_SELECT:  	tmp = process_select(tag);  	if (tmp) @@ -17,7 +17,7 @@  #define MAX_TABLE_N 20		/* maximum number of table in same level */  #define MAXROW 50 -#define MAXCOL 50 +#define MAXCOL 256  #define MAX_WIDTH 80 diff --git a/tagtable.tab b/tagtable.tab index f9b7b76..f5a2c30 100644 --- a/tagtable.tab +++ b/tagtable.tab @@ -176,6 +176,7 @@ bdo		HTML_BDO  big		HTML_BIG  /big		HTML_N_BIG  button		HTML_BUTTON +/button		HTML_N_BUTTON  fieldset	HTML_FIELDSET  /fieldset	HTML_N_FIELDSET  iframe		HTML_IFRAME @@ -222,6 +222,7 @@ static void  check_cygwin_console(void)  {      char *term = getenv("TERM"); +    char *ctype;      HANDLE hWnd;      if (term == NULL) @@ -236,7 +237,9 @@ check_cygwin_console(void)  		isLocalConsole = 1;  	    }  	} -	if (strncmp(getenv("LANG"), "ja", 2) == 0) { +	if ((ctype = getenv("LC_ALL") || +	     ctype = getenv("LC_CTYPE") || +	     ctype = getenv("LANG")) && strncmp(ctype, "ja", 2) == 0) {  	    isWinConsole = TERM_CYGWIN_RESERVE_IME;  	}  #ifdef SUPPORT_WIN9X_CONSOLE_MBCS @@ -2027,8 +2030,8 @@ sleep_till_anykey(int sec, int purge)  #ifdef USE_MOUSE -#define XTERM_ON   {fputs("\033[?1001s\033[?1000h",ttyf); flush_tty();} -#define XTERM_OFF  {fputs("\033[?1000l\033[?1001r",ttyf); flush_tty();} +#define XTERM_ON   {fputs("\033[?1001s\033[?1000h\033[?1006h",ttyf); flush_tty();} +#define XTERM_OFF  {fputs("\033[?1006l\033[?1000l\033[?1001r",ttyf); flush_tty();}  #define CYGWIN_ON  {fputs("\033[?1000h",ttyf); flush_tty();}  #define CYGWIN_OFF {fputs("\033[?1000l",ttyf); flush_tty();} @@ -444,6 +444,8 @@ baseURL(Buffer *buf)  	/* <BASE> tag is defined in the document */  	return buf->baseURL;      } +    else if (IS_EMPTY_PARSED_URL(&buf->currentURL)) +	return NULL;      else  	return &buf->currentURL;  } @@ -638,16 +640,21 @@ openSocket(char *const hostname,  #define COPYPATH_SPC_ALLOW 0  #define COPYPATH_SPC_IGNORE 1  #define COPYPATH_SPC_REPLACE 2 +#define COPYPATH_SPC_MASK 3 +#define COPYPATH_LOWERCASE 4  static char *  copyPath(char *orgpath, int length, int option)  {      Str tmp = Strnew(); -    while (*orgpath && length != 0) { -	if (IS_SPACE(*orgpath)) { -	    switch (option) { +    char ch; +    while ((ch = *orgpath) != 0 && length != 0) { +	if (option & COPYPATH_LOWERCASE) +	    ch = TOLOWER(ch); +	if (IS_SPACE(ch)) { +	    switch (option & COPYPATH_SPC_MASK) {  	    case COPYPATH_SPC_ALLOW: -		Strcat_char(tmp, *orgpath); +		Strcat_char(tmp, ch);  		break;  	    case COPYPATH_SPC_IGNORE:  		/* do nothing */ @@ -658,7 +665,7 @@ copyPath(char *orgpath, int length, int option)  	    }  	}  	else -	    Strcat_char(tmp, *orgpath); +	    Strcat_char(tmp, ch);  	orgpath++;  	length--;      } @@ -668,22 +675,14 @@ copyPath(char *orgpath, int length, int option)  void  parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  { -    char *p, *q; +    char *p, *q, *qq;      Str tmp;      url = url_quote(url);	/* quote 0x01-0x20, 0x7F-0xFF */      p = url; +    copyParsedURL(p_url, NULL);      p_url->scheme = SCM_MISSING; -    p_url->port = 0; -    p_url->user = NULL; -    p_url->pass = NULL; -    p_url->host = NULL; -    p_url->is_nocache = 0; -    p_url->file = NULL; -    p_url->real_file = NULL; -    p_url->query = NULL; -    p_url->label = NULL;      /* RFC1808: Relative Uniform Resource Locators       * 4.  Resolving Relative URLs @@ -694,7 +693,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  	goto do_label;      }  #if defined( __EMX__ ) || defined( __CYGWIN__ ) -    if (!strncmp(url, "file://localhost/", 17)) { +    if (!strncasecmp(url, "file://localhost/", 17)) {  	p_url->scheme = SCM_LOCAL;  	p += 17 - 1;  	url += 17 - 1; @@ -802,19 +801,20 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  	/* scheme://user:pass@host or  	 * scheme://host:port  	 */ -	p_url->host = copyPath(q, p - q, COPYPATH_SPC_IGNORE); +	qq = q;  	q = ++p;  	while (*p && strchr("@/?#", *p) == NULL)  	    p++;  	if (*p == '@') {  	    /* scheme://user:pass@...       */ +	    p_url->user = copyPath(qq, q - 1 - qq, COPYPATH_SPC_IGNORE);  	    p_url->pass = copyPath(q, p - q, COPYPATH_SPC_ALLOW);  	    q = ++p; -	    p_url->user = p_url->host; -	    p_url->host = NULL;  	    goto analyze_url;  	}  	/* scheme://host:port/ */ +	p_url->host = copyPath(qq, q - 1 - qq, +			       COPYPATH_SPC_IGNORE | COPYPATH_LOWERCASE);  	tmp = Strnew_charp_n(q, p - q);  	p_url->port = atoi(tmp->ptr);  	/* *p is one of ['\0', '/', '?', '#'] */ @@ -829,7 +829,8 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)      case '/':      case '?':      case '#': -	p_url->host = copyPath(q, p - q, COPYPATH_SPC_IGNORE); +	p_url->host = copyPath(q, p - q, +			       COPYPATH_SPC_IGNORE | COPYPATH_LOWERCASE);  	p_url->port = DefaultPort[p_url->scheme];  	break;      } @@ -956,12 +957,16 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current)  	p_url->label = NULL;  } -#define initParsedURL(p) bzero(p,sizeof(ParsedURL))  #define ALLOC_STR(s) ((s)==NULL?NULL:allocStr(s,-1))  void -copyParsedURL(ParsedURL *p, ParsedURL *q) +copyParsedURL(ParsedURL *p, const ParsedURL *q)  { +    if (q == NULL) { +	memset(p, 0, sizeof(ParsedURL)); +	p->scheme = SCM_UNKNOWN; +	return; +    }      p->scheme = q->scheme;      p->port = q->port;      p->is_nocache = q->is_nocache; @@ -1283,6 +1288,8 @@ static char *  otherinfo(ParsedURL *target, ParsedURL *current, char *referer)  {      Str s = Strnew(); +    const int *no_referer_ptr; +    int no_referer;      Strcat_charp(s, "User-Agent: ");      if (UserAgent == NULL || *UserAgent == '\0') @@ -1306,7 +1313,12 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer)  	Strcat_charp(s, "Pragma: no-cache\r\n");  	Strcat_charp(s, "Cache-control: no-cache\r\n");      } -    if (!NoSendReferer) { +    no_referer = NoSendReferer; +    no_referer_ptr = query_SCONF_NO_REFERER_FROM(current); +    no_referer = NoSendReferer || (no_referer_ptr && *no_referer_ptr); +    no_referer_ptr = query_SCONF_NO_REFERER_TO(target); +    no_referer = no_referer || (no_referer_ptr && *no_referer_ptr); +    if (!no_referer) {  #ifdef USE_SSL          if (current && current->scheme == SCM_HTTPS && target->scheme != SCM_HTTPS) {  	  /* Don't send Referer: if https:// -> http:// */ @@ -1314,6 +1326,7 @@ otherinfo(ParsedURL *target, ParsedURL *current, char *referer)  	else  #endif  	if (referer == NULL && current && current->scheme != SCM_LOCAL && +	    current->scheme != SCM_LOCAL_CGI &&  	    (current->scheme != SCM_FTP ||  	     (current->user == NULL && current->pass == NULL))) {  	    char *p = current->label; @@ -2234,3 +2247,66 @@ schemeToProxy(int scheme)      }      return pu;  } + +#ifdef USE_M17N +wc_ces +url_to_charset(const char *url, const ParsedURL *base, wc_ces doc_charset) +{ +    const ParsedURL *pu; +    ParsedURL pu_buf; +    const wc_ces *csptr; + +    if (url && *url && *url != '#') { +	parseURL2((char *)url, &pu_buf, (ParsedURL *)base); +	pu = &pu_buf; +    } else { +	pu = base; +    } +    if (pu && (pu->scheme == SCM_LOCAL || pu->scheme == SCM_LOCAL_CGI)) +	return SystemCharset; +    csptr = query_SCONF_URL_CHARSET(pu); +    return (csptr && *csptr) ? *csptr : +	doc_charset ? doc_charset : DocumentCharset; +} + +char * +url_encode(const char *url, const ParsedURL *base, wc_ces doc_charset) +{ +    return url_quote_conv((char *)url, +			  url_to_charset(url, base, doc_charset)); +} + +#if 0 /* unused */ +char * +url_decode(const char *url, const ParsedURL *base, wc_ces doc_charset) +{ +    if (!DecodeURL) +	return (char *)url; +    return url_unquote_conv((char *)url, +			    url_to_charset(url, base, doc_charset)); +} +#endif + +char * +url_decode2(const char *url, const Buffer *buf) +{ +    wc_ces url_charset; + +    if (!DecodeURL) +	return (char *)url; +    url_charset = buf ? +	url_to_charset(url, baseURL((Buffer *)buf), buf->document_charset) : +	url_to_charset(url, NULL, 0); +    return url_unquote_conv((char *)url, url_charset); +} + +#else /* !defined(USE_M17N) */ + +char * +url_decode0(const char *url) +{ +    if (!DecodeURL) +	return (char *)url; +    return url_unquote_conv((char *)url, 0); +} +#endif /* !defined(USE_M17N) */ diff --git a/version.c.in b/version.c.in index 27dab36..f09d5b3 100644 --- a/version.c.in +++ b/version.c.in @@ -1,5 +1,5 @@ -/* $Id: version.c.in,v 1.48 2011/01/15 07:52:48 inu Exp $ */ -#define CURRENT_VERSION "w3m/0.5.3" +/* $Id: version.c.in,v 1.49 2012/05/22 09:45:56 inu Exp $ */ +#define CURRENT_VERSION "w3m/0.5.3+debian-11+"  #ifndef FM_H  char *w3m_version = CURRENT_VERSION; diff --git a/w3m-doc/CVS/Entries b/w3m-doc/CVS/Entries deleted file mode 100644 index f0a18f0..0000000 --- a/w3m-doc/CVS/Entries +++ /dev/null @@ -1,18 +0,0 @@ -/README.html/1.1.1.1/Thu Nov  8 05:18:53 2001// -/community.html.in/1.2/Tue Nov 27 03:54:49 2001// -/configuration.html.in/1.2/Tue Nov 27 03:54:49 2001// -/contain.wd/1.3/Tue Nov 27 03:54:49 2001// -/copyright.html.in/1.2/Tue Nov 27 03:54:49 2001// -/define.wd/1.2/Tue Nov 27 03:54:49 2001// -/detail.html.in/1.3/Tue Nov 27 03:54:49 2001// -/development.html.in/1.1/Fri Nov  9 04:59:18 2001// -/faq.html.in/1.2/Tue Nov 27 03:54:49 2001// -/function.html.in/1.2/Tue Nov 27 03:54:49 2001// -/index.html.in/1.3/Tue Nov 27 03:54:49 2001// -/install.html.in/1.3/Tue Jul  9 06:14:14 2002// -/mkdocs/1.2/Tue Nov 27 03:54:49 2001// -/operation.html.in/1.2/Tue Nov 27 03:54:49 2001// -/outline.html.in/1.2/Tue Nov 27 03:54:49 2001// -/prologue.html.in/1.3/Tue Oct 29 14:28:30 2002// -/w3mdoc.pl/1.1.1.1/Thu Nov  8 05:18:52 2001// -D/sample//// diff --git a/w3m-doc/CVS/Repository b/w3m-doc/CVS/Repository deleted file mode 100644 index 2dd7815..0000000 --- a/w3m-doc/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/w3m-doc diff --git a/w3m-doc/CVS/Root b/w3m-doc/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/w3m-doc/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/w3m-doc/sample/CVS/Entries b/w3m-doc/sample/CVS/Entries deleted file mode 100644 index 1207c1a..0000000 --- a/w3m-doc/sample/CVS/Entries +++ /dev/null @@ -1,9 +0,0 @@ -/README/1.1.1.1/Thu Nov  8 05:18:53 2001// -/define.wd/1.1.1.1/Thu Nov  8 05:18:53 2001// -/html.wd/1.1.1.1/Thu Nov  8 05:18:53 2001// -/keymap.cgi/1.1.1.1/Thu Nov  8 05:18:54 2001// -/s.wd/1.1.1.1/Thu Nov  8 05:18:54 2001// -/sample.html/1.1.1.1/Thu Nov  8 05:18:54 2001// -/sample.wd/1.1.1.1/Thu Nov  8 05:18:53 2001// -/w3mdoc.pl/1.1.1.1/Thu Nov  8 05:18:53 2001// -D diff --git a/w3m-doc/sample/CVS/Repository b/w3m-doc/sample/CVS/Repository deleted file mode 100644 index d328633..0000000 --- a/w3m-doc/sample/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/w3m-doc/sample diff --git a/w3m-doc/sample/CVS/Root b/w3m-doc/sample/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/w3m-doc/sample/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/w3mbookmark.c b/w3mbookmark.c index 4355536..fcbad11 100644 --- a/w3mbookmark.c +++ b/w3mbookmark.c @@ -99,7 +99,7 @@ create_new_bookmark(char *bmark, char *section, char *title, char *url,  	fprintf(f, "<body>\n<h1>Bookmarks</h1>\n");  	fprintf(f, "<h2>%s</h2>\n<ul>\n", section);  	fprintf(f, "<li><a href=\"%s\">%s</a>\n", url, title); -	fprintf(f, end_section); +	fprintf(f, "%s", end_section);  	fprintf(f, "</ul>\n</body>\n</html>\n");  	fclose(f);      } diff --git a/w3mimg/CVS/Entries b/w3mimg/CVS/Entries deleted file mode 100644 index ad83b16..0000000 --- a/w3mimg/CVS/Entries +++ /dev/null @@ -1,7 +0,0 @@ -/.cvsignore/1.1/Mon Sep 22 22:53:53 2003// -D/fb//// -D/x11//// -/Makefile.in/1.11/Tue Jan  4 09:22:28 2011// -/w3mimg.c/1.6/Tue Jan  4 09:22:28 2011// -/w3mimg.h/1.9/Tue Jan  4 09:22:28 2011// -D/win//// diff --git a/w3mimg/CVS/Repository b/w3mimg/CVS/Repository deleted file mode 100644 index d59666d..0000000 --- a/w3mimg/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/w3mimg diff --git a/w3mimg/CVS/Root b/w3mimg/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/w3mimg/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/w3mimg/Makefile.in b/w3mimg/Makefile.in index dfc550c..0a964a1 100644 --- a/w3mimg/Makefile.in +++ b/w3mimg/Makefile.in @@ -22,6 +22,8 @@ w3mimg.a: $(IMGOBJS)  	$(AR) rv $@ $(IMGOBJS)  	$(RANLIB) $@ +$(IMGOBJS): @IMGTARGETS@ +  w3mimg.o: w3mimg.c  	$(CC) $(CFLAGS) -c $< diff --git a/w3mimg/fb/CVS/Entries b/w3mimg/fb/CVS/Entries deleted file mode 100644 index 549e962..0000000 --- a/w3mimg/fb/CVS/Entries +++ /dev/null @@ -1,11 +0,0 @@ -/.cvsignore/1.1/Mon Sep 22 22:53:53 2003// -/Makefile.in/1.4/Mon Apr 26 17:00:38 2004// -/fb.c/1.16/Sun Jul 13 16:19:10 2003// -/fb.h/1.7/Mon Jul  7 15:48:17 2003// -/fb_gdkpixbuf.c/1.21/Mon Nov  8 17:14:06 2004// -/fb_img.c/1.6/Mon Jul  7 15:48:17 2003// -/fb_img.h/1.9/Wed Aug  4 17:32:28 2004// -/fb_imlib2.c/1.10/Wed Aug  4 17:32:28 2004// -/fb_w3mimg.c/1.14/Wed Aug  4 17:32:28 2004// -/readme.txt/1.2/Mon Jul 22 16:17:32 2002// -D diff --git a/w3mimg/fb/CVS/Repository b/w3mimg/fb/CVS/Repository deleted file mode 100644 index 336666e..0000000 --- a/w3mimg/fb/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/w3mimg/fb diff --git a/w3mimg/fb/CVS/Root b/w3mimg/fb/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/w3mimg/fb/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/w3mimg/win/CVS/Entries b/w3mimg/win/CVS/Entries deleted file mode 100644 index 5025b4b..0000000 --- a/w3mimg/win/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/Makefile.in/1.1/Tue Dec 21 10:13:55 2010// -/win_w3mimg.cpp/1.2/Fri Dec 24 09:52:06 2010// -/.cvsignore/1.1/Wed Jan  5 09:52:10 2011// -D diff --git a/w3mimg/win/CVS/Repository b/w3mimg/win/CVS/Repository deleted file mode 100644 index 06901a3..0000000 --- a/w3mimg/win/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/w3mimg/win diff --git a/w3mimg/win/CVS/Root b/w3mimg/win/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/w3mimg/win/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m diff --git a/w3mimg/x11/CVS/Entries b/w3mimg/x11/CVS/Entries deleted file mode 100644 index a3cf134..0000000 --- a/w3mimg/x11/CVS/Entries +++ /dev/null @@ -1,4 +0,0 @@ -/.cvsignore/1.1/Mon Sep 22 22:53:53 2003// -/Makefile.in/1.4/Mon Apr 26 17:00:38 2004// -/x11_w3mimg.c/1.29/Mon Nov  8 17:14:06 2004// -D diff --git a/w3mimg/x11/CVS/Repository b/w3mimg/x11/CVS/Repository deleted file mode 100644 index 1268050..0000000 --- a/w3mimg/x11/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -w3m/w3mimg/x11 diff --git a/w3mimg/x11/CVS/Root b/w3mimg/x11/CVS/Root deleted file mode 100644 index 121fa06..0000000 --- a/w3mimg/x11/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:inu@w3m.cvs.sourceforge.net:/cvsroot/w3m | 
