about summary refs log tree commit diff stats
path: root/WWW/Library
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2009-03-11 00:40:00 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2009-03-11 00:40:00 -0400
commit089dd372933a775165f70ae0b32713eb3aebee98 (patch)
tree1ad37766e42512ccb3f397d6217dbf49495c1285 /WWW/Library
parentf71b2b3a35fa25f2be897b75870d3ab81170b857 (diff)
downloadlynx-snapshots-089dd372933a775165f70ae0b32713eb3aebee98.tar.gz
snapshot of project "lynx", label v2-8-7dev_13b
Diffstat (limited to 'WWW/Library')
-rw-r--r--WWW/Library/Implementation/HTAAProt.c42
-rw-r--r--WWW/Library/Implementation/HTAAProt.h32
-rw-r--r--WWW/Library/Implementation/HTTP.c9
-rw-r--r--WWW/Library/Implementation/SGML.c69
-rw-r--r--WWW/Library/Implementation/UCAux.h4
-rw-r--r--WWW/Library/Implementation/UCDefs.h56
-rw-r--r--WWW/Library/Implementation/www_tcp.h5
7 files changed, 107 insertions, 110 deletions
diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c
index 263b4a2c..224723c7 100644
--- a/WWW/Library/Implementation/HTAAProt.c
+++ b/WWW/Library/Implementation/HTAAProt.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAAProt.c,v 1.30 2009/02/01 21:19:48 tom Exp $
+ * $LynxId: HTAAProt.c,v 1.31 2009/03/10 00:27:20 tom Exp $
  *
  * MODULE							HTAAProt.c
  *		PROTECTION FILE PARSING MODULE
@@ -75,44 +75,6 @@ static BOOL isNumber(const char *s)
     }
     return YES;
 }
-#endif /* !NOUSERS */
-
-#if defined (NOUSERS)
-/* PUBLIC							HTAA_getUidName()
- *		GET THE USER ID NAME (VMS ONLY)
- * ON ENTRY:
- *	No arguments.
- *
- * ON EXIT:
- *	returns	the user name
- *		Default is "" (nobody).
- */
-const char *HTAA_getUidName(void)
-{
-    if (current_prot && current_prot->uid_name
-	&& (0 != strcmp(current_prot->uid_name, "nobody")))
-	return (current_prot->uid_name);
-    else
-	return ("");
-}
-
-/* PUBLIC							HTAA_getFileName
- *		GET THE FILENAME (VMS ONLY)
- * ON ENTRY:
- *	No arguments.
- *
- * ON EXIT:
- *	returns	the filename
- */
-const char *HTAA_getFileName(void)
-{
-    if (current_prot && current_prot->filename)
-	return (current_prot->filename);
-    else
-	return ("");
-}
-
-#else /* not VMS */
 
 /* PUBLIC							HTAA_getUid()
  *		GET THE USER ID TO CHANGE THE PROCESS UID TO
@@ -187,7 +149,7 @@ int HTAA_getGid(void)
      */
     return NOBODY;		/* nogroup */
 }
-#endif /* not VMS */
+#endif /* !NOUSERS */
 
 /* static							HTAA_setIds()
  *		SET UID AND GID (AS NAMES OR NUMBERS)
diff --git a/WWW/Library/Implementation/HTAAProt.h b/WWW/Library/Implementation/HTAAProt.h
index 8595ca66..22e3d928 100644
--- a/WWW/Library/Implementation/HTAAProt.h
+++ b/WWW/Library/Implementation/HTAAProt.h
@@ -156,7 +156,7 @@ Get User and Group IDs to Which Set to
 
  */
 
-#ifndef VMS
+#ifndef NOUSERS
 /* PUBLIC                                                       HTAA_getUid()
  *              GET THE USER ID TO CHANGE THE PROCESS UID TO
  * ON ENTRY:
@@ -178,35 +178,7 @@ Get User and Group IDs to Which Set to
  *              Default is 65534 (nogroup).
  */
     extern int HTAA_getGid(void);
-#endif				/* not VMS */
-/*
-
-   For VMS:
-
- */
-
-#ifdef VMS
-/* PUBLIC                                                       HTAA_getUidName()
- *              GET THE USER ID NAME (VMS ONLY)
- * ON ENTRY:
- *      No arguments.
- *
- * ON EXIT:
- *      returns the user name
- *              Default is "" (nobody).
- */
-    extern const char *HTAA_getUidName(void);
-
-/* PUBLIC                                                       HTAA_getFileName
- *              GET THE FILENAME (VMS ONLY)
- * ON ENTRY:
- *      No arguments.
- *
- * ON EXIT:
- *      returns the filename
- */
-    extern const char *HTAA_getFileName(void);
-#endif				/* VMS */
+#endif				/* !NOUSERS */
 
 /* PUBLIC                                                       HTAA_UidToName
  *              GET THE USER NAME
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index d1be845d..3d87d441 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTP.c,v 1.105 2009/02/01 21:22:22 tom Exp $
+ * $LynxId: HTTP.c,v 1.106 2009/03/10 15:31:22 tom Exp $
  *
  * HyperText Tranfer Protocol	- Client implementation		HTTP.c
  * ==========================
@@ -285,9 +285,6 @@ int ws_netread(int fd, char *buf, int len)
 
     static recv_data_t para;
 
-    extern int lynx_timeout;	/* LYMain.c */
-    extern CRITICAL_SECTION critSec_READ;	/* LYMain.c */
-
 #define TICK	5
 #define STACK_SIZE	0x2000uL
 
@@ -1032,12 +1029,12 @@ static int HTLoadHTTP(const char *arg,
 		if (pres->quality < 1.0) {
 		    if (pres->maxbytes > 0) {
 			sprintf(temp, ";q=%4.3f;mxb=%" PRI_off_t "",
-				pres->quality, pres->maxbytes);
+				pres->quality, CAST_off_t(pres->maxbytes));
 		    } else {
 			sprintf(temp, ";q=%4.3f", pres->quality);
 		    }
 		} else if (pres->maxbytes > 0) {
-		    sprintf(temp, ";mxb=%" PRI_off_t "", pres->maxbytes);
+		    sprintf(temp, ";mxb=%" PRI_off_t "", CAST_off_t(pres->maxbytes));
 		} else {
 		    temp[0] = '\0';
 		}
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 709586e5..5fd3a09e 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: SGML.c,v 1.120 2009/01/03 01:12:28 tom Exp $
+ * $LynxId: SGML.c,v 1.122 2009/03/10 21:16:57 tom Exp $
  *
  *			General SGML Parser code		SGML.c
  *			========================
@@ -4382,12 +4382,23 @@ static void SGML_character(HTStream *context, char c_in)
     }
 }				/* SGML_character */
 
-static void SGML_string(HTStream *context, const char *str)
+static void InferUtfFromBom(HTStream *context, int chndl)
 {
-    const char *p;
+    HTAnchor_setUCInfoStage(context->node_anchor, chndl,
+			    UCT_STAGE_PARSER,
+			    UCT_SETBY_PARSER);
+    change_chartrans_handling(context);
+}
 
-    for (p = str; *p; p++)
-	SGML_character(context, *p);
+/*
+ * Avoid rewrite of SGML_character() to handle hypothetical case of UTF-16
+ * webpages, by pretending that the data is UTF-8.
+ */
+static void SGML_widechar(HTStream *context, long ch)
+{
+    if (!UCPutUtf8_charstring(context, SGML_character, ch)) {
+	SGML_character(context, UCH(ch));
+    }
 }
 
 static void SGML_write(HTStream *context, const char *str, int l)
@@ -4395,8 +4406,45 @@ static void SGML_write(HTStream *context, const char *str, int l)
     const char *p;
     const char *e = str + l;
 
-    for (p = str; p < e; p++)
-	SGML_character(context, *p);
+    if (sgml_offset == 0) {
+	if (l > 3
+	    && !memcmp(str, "\357\273\277", 3)) {
+	    CTRACE((tfp, "SGML_write found UTF-8 BOM\n"));
+	    InferUtfFromBom(context, UTF8_handle);
+	    str += 3;
+	} else if (l > 2) {
+	    if (!memcmp(str, "\377\376", 2)) {
+		CTRACE((tfp, "SGML_write found UCS-2 LE BOM\n"));
+		InferUtfFromBom(context, UTF8_handle);
+		str += 2;
+		context->T.ucs_mode = -1;
+	    } else if (!memcmp(str, "\376\377", 2)) {
+		CTRACE((tfp, "SGML_write found UCS-2 BE BOM\n"));
+		InferUtfFromBom(context, UTF8_handle);
+		str += 2;
+		context->T.ucs_mode = 1;
+	    }
+	}
+    }
+    switch (context->T.ucs_mode) {
+    case -1:
+	for (p = str; p < e; p += 2)
+	    SGML_widechar(context, (UCH(p[1]) << 8) | UCH(p[0]));
+	break;
+    case 1:
+	for (p = str; p < e; p += 2)
+	    SGML_widechar(context, (UCH(p[0]) << 8) | UCH(p[1]));
+	break;
+    default:
+	for (p = str; p < e; p++)
+	    SGML_character(context, *p);
+	break;
+    }
+}
+
+static void SGML_string(HTStream *context, const char *str)
+{
+    SGML_write(context, str, strlen(str));
 }
 
 /*_______________________________________________________________________
@@ -4507,11 +4555,12 @@ HTStream *SGML_new(const SGML_dtd * dtd,
  */
 int SGML_offset(void)
 {
+    int result = sgml_offset;
+
 #ifdef USE_PRETTYSRC
-    return sgml_offset + psrc_view;
-#else
-    return sgml_offset;
+    result += psrc_view;
 #endif
+    return result;
 }
 
 /*		Asian character conversion functions
diff --git a/WWW/Library/Implementation/UCAux.h b/WWW/Library/Implementation/UCAux.h
index c962095e..4d4bd84e 100644
--- a/WWW/Library/Implementation/UCAux.h
+++ b/WWW/Library/Implementation/UCAux.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: UCAux.h,v 1.16 2009/03/10 21:17:21 tom Exp $
+ */
 #ifndef UCAUX_H
 #define UCAUX_H
 
@@ -39,6 +42,7 @@ extern "C" {
 	BOOL trans_C0_to_uni;
 	BOOL repl_translated_C0;
 	BOOL trans_from_uni;
+	int ucs_mode;
     };
     typedef struct _UCTransParams UCTransParams;
 
diff --git a/WWW/Library/Implementation/UCDefs.h b/WWW/Library/Implementation/UCDefs.h
index 8677824c..7555beaa 100644
--- a/WWW/Library/Implementation/UCDefs.h
+++ b/WWW/Library/Implementation/UCDefs.h
@@ -1,4 +1,8 @@
-/* Definitions for Unicode character-translations */
+/*
+ * $LynxId: UCDefs.h,v 1.17 2009/03/10 20:02:44 tom Exp $
+ *
+ * Definitions for Unicode character-translations
+ */
 
 #ifndef UCDEFS_H
 #define UCDEFS_H
@@ -27,14 +31,16 @@ typedef struct _LYUCcharset {
 				   "for which ranges is it like 8859-1" */
 } LYUCcharset;
 
-#define UCT_ENC_7BIT 0
-#define UCT_ENC_8BIT 1
-#define UCT_ENC_8859 2		/* no displayable chars in 0x80-0x9F */
-#define UCT_ENC_8BIT_C0 3	/* 8-bit + some chars in C0 control area */
-#define UCT_ENC_MAYBE2022 4
-#define UCT_ENC_CJK 5
-#define UCT_ENC_16BIT 6
-#define UCT_ENC_UTF8 7
+typedef enum {
+    UCT_ENC_7BIT,
+    UCT_ENC_8BIT,
+    UCT_ENC_8859,		/* no displayable chars in 0x80-0x9F */
+    UCT_ENC_8BIT_C0,		/* 8-bit + some chars in C0 control area */
+    UCT_ENC_MAYBE2022,
+    UCT_ENC_CJK,
+    UCT_ENC_16BIT,
+    UCT_ENC_UTF8
+} eUCT_ENC;
 
 #define UCT_REP_SUBSETOF_LAT1 0x01
 #define UCT_REP_SUPERSETOF_LAT1 0x02
@@ -64,24 +70,28 @@ typedef struct _LYUCcharset {
 #define UCT_R_HIGH8BIT 0x100	/* rest of 0xA0-0xFF range */
 
 #define UCT_R_ASCII UCT_R_7BITINV | UCT_R_7BITNAT	/* displayable US-ASCII */
-#define UCT_R_LAT1 UCT_R_ASCII | UCT_R_8859SPECL | UCT_R_HIGH8BIT
-#define UCT_R_8BIT UCT_R_LAT1 | UCT_R_HIGHCTRL	/* full 8bit range */
+#define UCT_R_LAT1  UCT_R_ASCII   | UCT_R_8859SPECL | UCT_R_HIGH8BIT
+#define UCT_R_8BIT  UCT_R_LAT1    | UCT_R_HIGHCTRL	/* full 8bit range */
 
 /*
  *  For the following some comments are in HTAnchor.c.
  */
-#define UCT_STAGE_MIME 0
-#define UCT_STAGE_PARSER 1	/* What the parser (SGML.c) gets to see */
-#define UCT_STAGE_STRUCTURED 2	/* What the structured stream (HTML) gets fed */
-#define UCT_STAGE_HTEXT 3	/* What gets fed to the HText_* functions */
-#define UCT_STAGEMAX 4
-
-#define UCT_SETBY_NONE 0
-#define UCT_SETBY_DEFAULT 1
-#define UCT_SETBY_LINK 2	/* set by A or LINK CHARSET= hint */
-#define UCT_SETBY_STRUCTURED 3	/* structured stream stage (HTML.c) */
-#define UCT_SETBY_PARSER 4	/* set by SGML parser or similar */
-#define UCT_SETBY_MIME 5	/* set explicitly by MIME charset parameter */
+typedef enum {
+    UCT_STAGE_MIME,
+    UCT_STAGE_PARSER,		/* What the parser (SGML.c) gets to see */
+    UCT_STAGE_STRUCTURED,	/* What the structured stream (HTML) gets fed */
+    UCT_STAGE_HTEXT,		/* What gets fed to the HText_* functions */
+    UCT_STAGEMAX
+} eUCT_STAGE;
+
+typedef enum {
+    UCT_SETBY_NONE,
+    UCT_SETBY_DEFAULT,
+    UCT_SETBY_LINK,		/* set by A or LINK CHARSET= hint */
+    UCT_SETBY_STRUCTURED,	/* structured stream stage (HTML.c) */
+    UCT_SETBY_PARSER,		/* set by SGML parser or similar */
+    UCT_SETBY_MIME		/* set explicitly by MIME charset parameter */
+} eUCT_SETBY;
 
 typedef struct _UCStageInfo {
     int lock;			/* by what it has been set */
diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h
index 45216f7f..392fbd99 100644
--- a/WWW/Library/Implementation/www_tcp.h
+++ b/WWW/Library/Implementation/www_tcp.h
@@ -1,5 +1,5 @@
 /*                System dependencies in the W3 library
- * $LynxId: www_tcp.h,v 1.38 2008/12/30 01:01:34 Paul.Gilmartin Exp $
+ * $LynxId: www_tcp.h,v 1.39 2009/03/09 22:43:29 Doug.Kaufman Exp $
  *
                                    SYSTEM DEPENDENCIES
 
@@ -632,6 +632,9 @@ extern int errno;
 #ifdef word
 #undef word
 #endif /* word */
+#ifdef set_timeout
+#undef set_timeout
+#endif /* set_timeout */
 #define select select_s
 
 #undef NETWRITE