diff -crN -x CVS -x libwc w3m.orig/backend.c w3m/backend.c *** w3m.orig/backend.c Wed Dec 25 16:31:48 2002 --- w3m/backend.c Wed Dec 25 16:19:35 2002 *************** *** 3,8 **** --- 3,9 ---- #include #include #include "fm.h" + #include "myctype.h" #include "gc.h" #include "terms.h" *************** *** 95,101 **** buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request); do_download = FALSE; if (buf != NULL && buf != NO_BUFFER) { ! if (!strcasecmp(buf->type, "text/html") && backend_halfdump_buf) { TextLineListItem *p; Str first, last; int len = 0; --- 96,102 ---- buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request); do_download = FALSE; if (buf != NULL && buf != NO_BUFFER) { ! if (IS_HTML(buf->type) && backend_halfdump_buf) { TextLineListItem *p; Str first, last; int len = 0; *************** *** 114,120 **** printf("%s", last->ptr); } else { ! if (!strcasecmp(buf->type, "text/plain")) { Line *lp; int len = 0; for (lp = buf->firstLine; lp; lp = lp->next) { --- 115,121 ---- printf("%s", last->ptr); } else { ! if (IS_PLAINTEXT(buf->type)) { Line *lp; int len = 0; for (lp = buf->firstLine; lp; lp = lp->next) { diff -crN -x CVS -x libwc w3m.orig/buffer.c w3m/buffer.c *** w3m.orig/buffer.c Sat Dec 21 10:08:50 2002 --- w3m/buffer.c Wed Dec 25 16:21:32 2002 *************** *** 551,557 **** readHeader(&f, buf, TRUE, NULL); } ! if (!strcasecmp(buf->type, "text/html")) loadHTMLBuffer(&f, buf); else loadBuffer(&f, buf); --- 551,557 ---- readHeader(&f, buf, TRUE, NULL); } ! if (IS_HTML(buf->type)) loadHTMLBuffer(&f, buf); else loadBuffer(&f, buf); diff -crN -x CVS -x libwc w3m.orig/display.c w3m/display.c *** w3m.orig/display.c Sat Dec 21 10:08:50 2002 --- w3m/display.c Wed Dec 25 16:21:50 2002 *************** *** 354,360 **** if (buf->height == 0) buf->height = LASTLINE + 1; if ((buf->width != INIT_BUFFER_WIDTH && buf->type && ! !strcmp(buf->type, "text/html")) || buf->need_reshape) { buf->need_reshape = TRUE; reshapeBuffer(buf); } --- 354,360 ---- if (buf->height == 0) buf->height = LASTLINE + 1; if ((buf->width != INIT_BUFFER_WIDTH && buf->type && ! IS_HTML(buf->type)) || buf->need_reshape) { buf->need_reshape = TRUE; reshapeBuffer(buf); } diff -crN -x CVS -x libwc w3m.orig/file.c w3m/file.c *** w3m.orig/file.c Wed Dec 25 16:41:14 2002 --- w3m/file.c Wed Dec 25 16:20:19 2002 *************** *** 251,257 **** static int is_plain_text_type(char *type) { ! return ((type && strcasecmp(type, "text/plain") == 0) || (is_text_type(type) && !is_dump_text_type(type))); } --- 251,257 ---- static int is_plain_text_type(char *type) { ! return ((type && IS_PLAINTEXT(type)) || (is_text_type(type) && !is_dump_text_type(type))); } *************** *** 356,362 **** 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); --- 356,362 ---- uf->guess_type = guessContentType(path); if (uf->guess_type == NULL) uf->guess_type = "text/plain"; ! if (IS_HTML(uf->guess_type)) return; if ((fp = lessopen_stream(path))) { UFclose(uf); *************** *** 1973,1979 **** } #endif ! if (!strcasecmp(t, "text/html")) proc = loadHTMLBuffer; else if (is_plain_text_type(t)) proc = loadBuffer; --- 1973,1979 ---- } #endif ! if (IS_HTML(t)) proc = loadHTMLBuffer; else if (is_plain_text_type(t)) proc = loadBuffer; *************** *** 2045,2051 **** loaded: 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); --- 2045,2051 ---- loaded: if (b->currentURL.host == NULL && b->currentURL.file == NULL) copyParsedURL(&b->currentURL, &pu); ! if (IS_HTML(t)) b->type = "text/html"; else if (w3m_backend) { Str s = Strnew_charp(t); *************** *** 6963,6969 **** wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; #endif ! if (buf->type && !strcasecmp(buf->type, "text/html")) is_html = TRUE; pager_next: --- 6953,6959 ---- wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; #endif ! if (buf->type && IS_HTML(buf->type)) is_html = TRUE; pager_next: *************** *** 7107,7113 **** t = DefaultType; DefaultType = NULL; } ! if (!strcasecmp(t, "text/html")) { buf = loadHTMLBuffer(&uf, t_buf); buf->type = "text/html"; } --- 7097,7103 ---- t = DefaultType; DefaultType = NULL; } ! if (IS_HTML(t)) { buf = loadHTMLBuffer(&uf, t_buf); buf->type = "text/html"; } *************** *** 7954,7960 **** buf->hmarklist->nmark = 0; if (buf->imarklist) buf->imarklist->nmark = 0; ! if (!strcasecmp(buf->type, "text/html")) loadHTMLBuffer(&uf, buf); else loadBuffer(&uf, buf); --- 7944,7950 ---- buf->hmarklist->nmark = 0; if (buf->imarklist) buf->imarklist->nmark = 0; ! if (IS_HTML(buf->type)) loadHTMLBuffer(&uf, buf); else loadBuffer(&uf, buf); diff -crN -x CVS -x libwc w3m.orig/frame.c w3m/frame.c *** w3m.orig/frame.c Sat Dec 21 10:08:51 2002 --- w3m/frame.c Wed Dec 25 16:20:37 2002 *************** *** 553,560 **** doc_charset = DocumentCharset; #endif t_stack = 0; ! if (frame.body->type && ! !strcasecmp(frame.body->type, "text/plain")) { Str tmp; fprintf(f1, "
\n");
  		    while ((tmp = StrmyUFgets(&f2))->length) {
--- 553,559 ----
  		    doc_charset = DocumentCharset;
  #endif
  		t_stack = 0;
! 		if (frame.body->type && IS_PLAINTEXT(frame.body->type)) {
  		    Str tmp;
  		    fprintf(f1, "
\n");
  		    while ((tmp = StrmyUFgets(&f2))->length) {
diff -crN -x CVS -x libwc w3m.orig/main.c w3m/main.c
*** w3m.orig/main.c	Wed Dec 25 16:31:49 2002
--- w3m/main.c	Wed Dec 25 16:19:04 2002
***************
*** 2543,2552 ****
  	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);
--- 2543,2552 ----
  	Firstbuf = deleteBuffer(Firstbuf, fbuf);
      repBuffer(Currentbuf, buf);
      if ((buf->type != NULL) && (sbuf.type != NULL) &&
! 	((IS_PLAINTEXT(buf->type) &&
! 	  IS_HTML(sbuf.type)) ||
! 	 (IS_HTML(buf->type) &&
! 	  IS_PLAINTEXT(sbuf.type)))) {
  	vwSrc();
  	if (Currentbuf != buf)
  	    Firstbuf = deleteBuffer(Firstbuf, buf);
***************
*** 4441,4448 ****
  	return;
      }
      if (Currentbuf->sourcefile == NULL) {
! 	if (Currentbuf->pagerSource &&
! 	    !strcasecmp(Currentbuf->type, "text/plain")) {
  	    FILE *f;
  	    Str tmpf = tmpfname(TMPF_SRC, NULL);
  	    pushText(fileToDelete, tmpf->ptr);
--- 4441,4447 ----
  	return;
      }
      if (Currentbuf->sourcefile == NULL) {
! 	if (Currentbuf->pagerSource && IS_PLAINTEXT(Currentbuf->type)) {
  	    FILE *f;
  	    Str tmpf = tmpfname(TMPF_SRC, NULL);
  	    pushText(fileToDelete, tmpf->ptr);
***************
*** 4474,4480 ****
      else {
  	fn = Currentbuf->sourcefile;
      }
!     if (!strcasecmp(Currentbuf->type, "text/html")) {
  #ifdef USE_M17N
  	old_charset = DocumentCharset;
  	DocumentCharset = Currentbuf->document_charset;
--- 4473,4479 ----
      else {
  	fn = Currentbuf->sourcefile;
      }
!     if (IS_HTML(Currentbuf->type)) {
  #ifdef USE_M17N
  	old_charset = DocumentCharset;
  	DocumentCharset = Currentbuf->document_charset;
***************
*** 4487,4493 ****
  	    return;
  	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;
--- 4486,4492 ----
  	    return;
  	buf->type = "text/plain";
  	if (Currentbuf->real_type &&
! 	    IS_HTML(Currentbuf->real_type))
  	    buf->real_type = "text/plain";
  	else
  	    buf->real_type = Currentbuf->real_type;
***************
*** 4496,4502 ****
  	buf->linkBuffer[LB_N_SOURCE] = Currentbuf;
  	Currentbuf->linkBuffer[LB_SOURCE] = buf;
      }
!     else if (!strcasecmp(Currentbuf->type, "text/plain")) {
  	char *old_type = DefaultType;
  	DefaultType = "text/html";
  #ifdef USE_M17N
--- 4495,4501 ----
  	buf->linkBuffer[LB_N_SOURCE] = Currentbuf;
  	Currentbuf->linkBuffer[LB_SOURCE] = buf;
      }
!     else if (IS_PLAINTEXT(Currentbuf->type)) {
  	char *old_type = DefaultType;
  	DefaultType = "text/html";
  #ifdef USE_M17N
***************
*** 4510,4517 ****
  #endif
  	if (buf == NULL || buf == NO_BUFFER)
  	    return;
! 	if (Currentbuf->real_type &&
! 	    !strcasecmp(Currentbuf->real_type, "text/plain"))
  	    buf->real_type = "text/html";
  	else
  	    buf->real_type = Currentbuf->real_type;
--- 4509,4515 ----
  #endif
  	if (buf == NULL || buf == NO_BUFFER)
  	    return;
! 	if (Currentbuf->real_type && IS_PLAINTEXT(Currentbuf->real_type))
  	    buf->real_type = "text/html";
  	else
  	    buf->real_type = Currentbuf->real_type;
***************
*** 4636,4645 ****
  	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);
--- 4634,4643 ----
  	Firstbuf = deleteBuffer(Firstbuf, fbuf);
      repBuffer(Currentbuf, buf);
      if ((buf->type != NULL) && (sbuf.type != NULL) &&
! 	((IS_PLAINTEXT(buf->type) &&
! 	  IS_HTML(sbuf.type)) ||
! 	 (IS_HTML(buf->type) &&
! 	  IS_PLAINTEXT(sbuf.type)))) {
  	vwSrc();
  	if (Currentbuf != buf)
  	    Firstbuf = deleteBuffer(Firstbuf, buf);
***************
*** 4960,4966 ****
  	return;
      displayImage = TRUE;
      /*
!      * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html")))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_AUTO;
--- 4958,4964 ----
  	return;
      displayImage = TRUE;
      /*
!      * if (!(Currentbuf->type && IS_HTML(Currentbuf->type)))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_AUTO;
***************
*** 4974,4980 ****
      if (!activeImage)
  	return;
      /*
!      * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html")))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_SKIP;
--- 4972,4978 ----
      if (!activeImage)
  	return;
      /*
!      * if (!(Currentbuf->type && IS_HTML(Currentbuf->type)))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_SKIP;
diff -crN -x CVS -x libwc w3m.orig/myctype.h w3m/myctype.h
*** w3m.orig/myctype.h	Wed Dec 25 16:55:51 2002
--- w3m/myctype.h	Wed Dec 25 16:25:33 2002
***************
*** 32,35 ****
--- 32,40 ----
  #define	TOLOWER(x)	(IS_ALPHA(x) ? ((x)|0x20) : (x))
  #define	TOUPPER(x)	(IS_ALPHA(x) ? ((x)&~0x20) : (x))
  
+ #include 
+ #define IS_HTML(x)	(!strcasecmp(x, "text/html") || \
+ 			 !strcasecmp(x, "application/xhtml+xml"))
+ #define IS_PLAINTEXT(x)	(!strcasecmp(x, "text/plain"))
+ 
  #endif
diff -crN -x CVS -x libwc w3m.orig/url.c w3m/url.c
*** w3m.orig/url.c	Sun Dec 15 01:09:51 2002
--- w3m/url.c	Wed Dec 25 16:13:02 2002
***************
*** 11,16 ****
--- 11,17 ----
  #include 
  
  #include 
+ #include 
  #ifdef __EMX__
  #include 			/* ?? */
  #endif				/* __EMX__ */
***************
*** 85,90 ****
--- 86,95 ----
      {"HTM", "text/html"},
      {"shtml", "text/html"},
      {"SHTML", "text/html"},
+     {"xhtml", "application/xhtml+xml"},
+     {"XHTML", "application/xhtml+xml"},
+     {"xht", "application/xhtml+xml"},
+     {"XHT", "application/xhtml+xml"},
      {"gif", "image/gif"},
      {"GIF", "image/gif"},
      {"jpeg", "image/jpeg"},
***************
*** 1218,1229 ****
  otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
  {
      Str s = Strnew();
  
      Strcat_charp(s, "User-Agent: ");
      if (UserAgent == NULL || *UserAgent == '\0')
  	Strcat_charp(s, w3m_version);
!     else
! 	Strcat_charp(s, UserAgent);
      Strcat_charp(s, "\r\n");
  
      Strcat_m_charp(s, "Accept: ", AcceptMedia, "\r\n", NULL);
--- 1223,1271 ----
  otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
  {
      Str s = Strnew();
+     char buf[2];
+     char* p = NULL;
+     struct utsname hostinfo;
+     buf[0] = buf[1] = '\0';
  
      Strcat_charp(s, "User-Agent: ");
      if (UserAgent == NULL || *UserAgent == '\0')
  	Strcat_charp(s, w3m_version);
!     else {
! 	p = UserAgent;
! 	while (*p != '\0') {
! 	    if (*p == '%') {
! 		switch (*(p + 1)) {
! 		case 'v': /* w3m version */
! 		    Strcat_charp(s, w3m_version);
! 		    p++;
! 		    break;
! 		case 'V': /* OS version */
! 		    if (uname(&hostinfo) == 0) {
! 			Strcat_charp(s, hostinfo.sysname);
! 			buf[0] = ' ';
! 			Strcat_charp(s, buf);
! 			Strcat_charp(s, hostinfo.release);
! 			Strcat_charp(s, buf);
! 			Strcat_charp(s, hostinfo.machine);
! 			p++;
! 		    } else {
! 			buf[0] = *p;
! 			Strcat_charp(s, buf);
! 		    }
! 		    break;
! 		default: /* thru */
! 		    buf[0] = *p;
! 		    Strcat_charp(s, buf);
! 		    break;
! 		}
! 	    } else {
! 		buf[0] = *p;
! 		Strcat_charp(s, buf);
! 	    }
! 	    p++;
! 	}
!     }
      Strcat_charp(s, "\r\n");
  
      Strcat_m_charp(s, "Accept: ", AcceptMedia, "\r\n", NULL);