*** backend.c.orig Thu Jan 30 03:28:32 2003 --- backend.c Fri Jul 25 06:04:56 2003 *************** *** 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) { *** buffer.c.orig Fri Feb 7 20:56:39 2003 --- buffer.c Fri Jul 25 06:04:57 2003 *************** *** 552,558 **** WcOption.auto_detect = WC_OPT_DETECT_OFF; UseContentCharset = FALSE; #endif ! if (!strcasecmp(buf->type, "text/html")) loadHTMLBuffer(&f, buf); else loadBuffer(&f, buf); --- 552,558 ---- WcOption.auto_detect = WC_OPT_DETECT_OFF; UseContentCharset = FALSE; #endif ! if (IS_HTML(buf->type)) loadHTMLBuffer(&f, buf); else loadBuffer(&f, buf); *************** *** 584,590 **** gotoLine(buf, cur->linenumber); } buf->pos -= buf->currentLine->bpos; ! if (FoldLine && strcasecmp(buf->type, "text/html")) buf->currentColumn = 0; else buf->currentColumn = sbuf.currentColumn; --- 584,590 ---- gotoLine(buf, cur->linenumber); } buf->pos -= buf->currentLine->bpos; ! if (FoldLine && !IS_HTML(buf->type)) buf->currentColumn = 0; else buf->currentColumn = sbuf.currentColumn; *** display.c.orig Sat Mar 8 02:20:37 2003 --- display.c Fri Jul 25 06:04:57 2003 *************** *** 373,379 **** if (buf->height == 0) buf->height = LASTLINE + 1; if ((buf->width != INIT_BUFFER_WIDTH && ! ((buf->type && !strcmp(buf->type, "text/html")) || FoldLine)) || buf->need_reshape) { buf->need_reshape = TRUE; reshapeBuffer(buf); --- 373,379 ---- if (buf->height == 0) buf->height = LASTLINE + 1; if ((buf->width != INIT_BUFFER_WIDTH && ! ((buf->type && IS_HTML(buf->type)) || FoldLine)) || buf->need_reshape) { buf->need_reshape = TRUE; reshapeBuffer(buf); *** file.c.orig Sat Mar 8 02:20:38 2003 --- file.c Fri Jul 25 06:04:57 2003 *************** *** 261,273 **** { 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))); } --- 261,275 ---- { return (type == NULL || type[0] == '\0' || strncasecmp(type, "text/", 5) == 0 || + (strncasecmp(type, "application/", 12) == 0 && + strstr(type, "xhtml") != NULL) || strncasecmp(type, "message/", sizeof("message/") - 1) == 0); } static int is_plain_text_type(char *type) { ! return ((type && IS_PLAINTEXT(type)) || (is_text_type(type) && !is_dump_text_type(type))); } *************** *** 372,378 **** 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); --- 374,380 ---- 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); *************** *** 1994,2000 **** } #endif ! if (!strcasecmp(t, "text/html")) proc = loadHTMLBuffer; else if (is_plain_text_type(t)) proc = loadBuffer; --- 1996,2002 ---- } #endif ! if (IS_HTML(t)) proc = loadHTMLBuffer; else if (is_plain_text_type(t)) proc = loadBuffer; *************** *** 2058,2064 **** 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); --- 2060,2066 ---- b->real_type = real_type; 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); *************** *** 6972,6978 **** wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; #endif ! if (buf->type && !strcasecmp(buf->type, "text/html")) is_html = TRUE; pager_next: --- 6974,6980 ---- wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; #endif ! if (buf->type && IS_HTML(buf->type)) is_html = TRUE; pager_next: *************** *** 7130,7136 **** t = DefaultType; DefaultType = NULL; } ! if (!strcasecmp(t, "text/html")) { buf = loadHTMLBuffer(&uf, t_buf); buf->type = "text/html"; } --- 7132,7138 ---- t = DefaultType; DefaultType = NULL; } ! if (IS_HTML(t)) { buf = loadHTMLBuffer(&uf, t_buf); buf->type = "text/html"; } *************** *** 7915,7921 **** buf->hmarklist->nmark = 0; if (buf->imarklist) buf->imarklist->nmark = 0; ! if (!strcasecmp(buf->type, "text/html")) loadHTMLBuffer(&uf, buf); else loadBuffer(&uf, buf); --- 7917,7923 ---- buf->hmarklist->nmark = 0; if (buf->imarklist) buf->imarklist->nmark = 0; ! if (IS_HTML(buf->type)) loadHTMLBuffer(&uf, buf); else loadBuffer(&uf, buf); *** frame.c.orig Thu Jan 30 03:28:33 2003 --- frame.c Fri Jul 25 06:04:57 2003 *************** *** 523,530 **** 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) {
--- 523,529 ----
  		    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) {
*** main.c.orig	Sat Mar  8 02:20:38 2003
--- main.c	Fri Jul 25 06:04:57 2003
***************
*** 4525,4528 ****
      }
      if (Currentbuf->sourcefile == NULL) {
  	if (Currentbuf->pagerSource &&
! 	    !strcasecmp(Currentbuf->type, "text/plain")) {
--- 4525,4528 ----
      }
      if (Currentbuf->sourcefile == NULL) {
  	if (Currentbuf->pagerSource &&
! 	    IS_PLAINTEXT(Currentbuf->type)) {
***************
*** 4557,4566 ****
  
      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;
--- 4557,4566 ----
  
      buf = newBuffer(INIT_BUFFER_WIDTH);
  
!     if (IS_HTML(Currentbuf->type)) {
  	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;
***************
*** 4568,4577 ****
  	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;
--- 4568,4577 ----
  	buf->linkBuffer[LB_N_SOURCE] = Currentbuf;
  	Currentbuf->linkBuffer[LB_SOURCE] = buf;
      }
!     else if (IS_PLAINTEXT(Currentbuf->type)) {
  	buf->type = "text/html";
  	if (Currentbuf->real_type &&
! 	    IS_PLAINTEXT(Currentbuf->real_type))
  	    buf->real_type = "text/html";
  	else
  	    buf->real_type = Currentbuf->real_type;
***************
*** 4704,4713 ****
  	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);
--- 4704,4713 ----
  	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);
***************
*** 5033,5039 ****
  	return;
      displayImage = TRUE;
      /*
!      * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html")))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_AUTO;
--- 5033,5039 ----
  	return;
      displayImage = TRUE;
      /*
!      * if (!(Currentbuf->type && IS_HTML(Currentbuf->type)))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_AUTO;
***************
*** 5047,5053 ****
      if (!activeImage)
  	return;
      /*
!      * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html")))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_SKIP;
--- 5047,5053 ----
      if (!activeImage)
  	return;
      /*
!      * if (!(Currentbuf->type && IS_HTML(Currentbuf->type)))
       * return;
       */
      Currentbuf->image_flag = IMG_FLAG_SKIP;
*** myctype.h.orig	Wed Jan  1 20:48:57 2003
--- myctype.h	Fri Jul 25 06:04:57 2003
***************
*** 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
*** url.c.orig	Fri Feb  7 20:56:48 2003
--- url.c	Fri Jul 25 06:04:57 2003
***************
*** 11,16 ****
--- 11,17 ----
  #include 
  
  #include 
+ #include 
  #ifdef __EMX__
  #include 			/* ?? */
  #endif				/* __EMX__ */
***************
*** 88,93 ****
--- 89,96 ----
      {"html", "text/html"},
      {"htm", "text/html"},
      {"shtml", "text/html"},
+     {"xhtml", "application/xhtml+xml"},
+     {"xht", "application/xhtml+xml"},
      {"gif", "image/gif"},
      {"jpeg", "image/jpeg"},
      {"jpg", "image/jpeg"},
***************
*** 1242,1253 ****
  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);
--- 1245,1293 ----
  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);