about summary refs log tree commit diff stats
path: root/WWW/Library
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2005-06-02 22:50:02 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2005-06-02 22:50:02 -0400
commit1367261dc669476df3a799f0de45e4bfb2437b8b (patch)
tree3bf6e1c020aab95b4133f2c29baffef454d3d60b /WWW/Library
parentaaa10562f4a02971f712964cb2fd1014d2a75d33 (diff)
downloadlynx-snapshots-1367261dc669476df3a799f0de45e4bfb2437b8b.tar.gz
snapshot of project "lynx", label v2-8-6dev_12
Diffstat (limited to 'WWW/Library')
-rw-r--r--WWW/Library/Implementation/HTAccess.c1
-rw-r--r--WWW/Library/Implementation/HTAnchor.c2
-rw-r--r--WWW/Library/Implementation/HTAnchor.h2
-rw-r--r--WWW/Library/Implementation/HTChunk.c83
-rw-r--r--WWW/Library/Implementation/HTChunk.h32
-rw-r--r--WWW/Library/Implementation/HTFTP.c6
-rw-r--r--WWW/Library/Implementation/HTFormat.c14
-rw-r--r--WWW/Library/Implementation/HTStream.h29
-rw-r--r--WWW/Library/Implementation/HTTCP.c7
-rw-r--r--WWW/Library/Implementation/HTTP.c6
-rw-r--r--WWW/Library/Implementation/SGML.c28
-rw-r--r--WWW/Library/Implementation/SGML.h16
12 files changed, 164 insertions, 62 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 8deb5162..4f4ebd8e 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -637,7 +637,6 @@ void LYUCPushAssumed(HTParentAnchor *anchor)
  */
 int LYUCPopAssumed(void)
 {
-
     if (pushed_assume_LYhndl >= 0) {
 	/* some diagnostics */
 	if (UCLYhndl_for_unspec != pushed_assume_LYhndl)
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 347c0f62..8c6a6304 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -13,7 +13,7 @@
  *	(c) Copyright CERN 1991 - See Copyright.html
  */
 
-#define HASH_SIZE 101		/* Arbitrary prime.  Memory/speed tradeoff */
+#define HASH_SIZE 1001		/* Arbitrary prime.  Memory/speed tradeoff */
 
 #include <HTUtils.h>
 #include <HTAnchor.h>
diff --git a/WWW/Library/Implementation/HTAnchor.h b/WWW/Library/Implementation/HTAnchor.h
index 2cbe0d4a..e1a15784 100644
--- a/WWW/Library/Implementation/HTAnchor.h
+++ b/WWW/Library/Implementation/HTAnchor.h
@@ -32,7 +32,7 @@ extern "C" {
 #endif
 /*			Main definition of anchor
  *			=========================
-				 */ struct _HTAnchor {
+ */ struct _HTAnchor {
 	/* Generic anchor */
 	HTParentAnchor0 *parent;	/* Parent of this anchor (self for adults) */
     };
diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c
index dc187c3f..7f41c687 100644
--- a/WWW/Library/Implementation/HTChunk.c
+++ b/WWW/Library/Implementation/HTChunk.c
@@ -83,13 +83,19 @@ void HTChunkClear(HTChunk *ch)
     ch->allocated = 0;
 }
 
-/*	Free a chunk
- *	------------
+/*     Free a chunk (and it's chain, if any)
+ *     -------------------------------------
  */
 void HTChunkFree(HTChunk *ch)
 {
-    FREE(ch->data);
-    FREE(ch);
+    HTChunk *next;
+
+    do {
+	next = ch->next;
+	FREE(ch->data);
+	FREE(ch);
+	ch = next;
+    } while (ch != NULL);
 }
 
 /*	Realloc the chunk
@@ -119,8 +125,6 @@ BOOL HTChunkRealloc(HTChunk *ch, int growby)
 /*	Append a character
  *	------------------
  */
-/* Warning: the code of this function is defined as macro in SGML.c. Change
-  the macro or undefine it in SGML.c when changing this function. -VH */
 void HTChunkPutc(HTChunk *ch, char c)
 {
     if (ch->size >= ch->allocated) {
@@ -130,6 +134,20 @@ void HTChunkPutc(HTChunk *ch, char c)
     ch->data[ch->size++] = c;
 }
 
+/* like above but no realloc: extend to another chunk if necessary */
+HTChunk *HTChunkPutc2(HTChunk *ch, char c)
+{
+    if (ch->size >= ch->allocated) {
+	HTChunk *chunk = HTChunkCreateMayFail(ch->growby, ch->failok);
+
+	ch->next = chunk;
+	HTChunkPutc(chunk, c);
+	return chunk;
+    }
+    ch->data[ch->size++] = c;
+    return ch;
+}
+
 /*	Ensure a certain size
  *	---------------------
  */
@@ -139,13 +157,17 @@ void HTChunkEnsure(HTChunk *ch, int needed)
 	return;
     ch->allocated = needed - 1 - ((needed - 1) % ch->growby)
 	+ ch->growby;		/* Round up */
-    ch->data = ch->data ? (char *) realloc(ch->data, ch->allocated)
-	: typecallocn(char, ch->allocated);
+    ch->data = (ch->data
+		? (char *) realloc(ch->data, ch->allocated)
+		: typecallocn(char, ch->allocated));
 
     if (ch->data == NULL)
 	outofmem(__FILE__, "HTChunkEnsure");
 }
 
+/*
+ * Append a block of characters.
+ */
 void HTChunkPutb(HTChunk *ch, const char *b, int l)
 {
     if (l <= 0)
@@ -160,9 +182,34 @@ void HTChunkPutb(HTChunk *ch, const char *b, int l)
     ch->size += l;
 }
 
+/* like above but no realloc: extend to another chunk if necessary */
+HTChunk *HTChunkPutb2(HTChunk *ch, const char *b, int l)
+{
+    if (l <= 0)
+	return ch;
+    if (ch->size + l > ch->allocated) {
+	HTChunk *chunk;
+	int m = ch->allocated - ch->size;
+
+	memcpy(ch->data + ch->size, b, m);
+	ch->size += m;
+
+	chunk = HTChunkCreateMayFail(ch->growby, ch->failok);
+	ch->next = chunk;
+	HTChunkPutb(chunk, b + m, l - m);
+	return chunk;
+    }
+    memcpy(ch->data + ch->size, b, l);
+    ch->size += l;
+    return ch;
+}
+
 #define PUTC(code)  ch->data[ch->size++] = (char)(code)
 #define PUTC2(code) ch->data[ch->size++] = (char)(0x80|(0x3f &(code)))
 
+/*
+ * Append a character encoded as UTF-8.
+ */
 void HTChunkPutUtf8Char(HTChunk *ch, UCode_t code)
 {
     int utflen;
@@ -255,3 +302,23 @@ void HTChunkPuts(HTChunk *ch, const char *s)
 	}
     }
 }
+
+/* like above but no realloc: extend to another chunk if necessary */
+HTChunk *HTChunkPuts2(HTChunk *ch, const char *s)
+{
+    const char *p;
+
+    if (s != NULL) {
+	for (p = s; *p; p++) {
+	    if (ch->size >= ch->allocated) {
+		HTChunk *chunk = HTChunkCreateMayFail(ch->growby, ch->failok);
+
+		ch->next = chunk;
+		HTChunkPuts(chunk, p);
+		return chunk;
+	    }
+	    ch->data[ch->size++] = *p;
+	}
+    }
+    return ch;
+}
diff --git a/WWW/Library/Implementation/HTChunk.h b/WWW/Library/Implementation/HTChunk.h
index 8a5ade18..18e2b8f3 100644
--- a/WWW/Library/Implementation/HTChunk.h
+++ b/WWW/Library/Implementation/HTChunk.h
@@ -19,13 +19,16 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-    typedef struct {
+    typedef struct _HTChunk HTChunk;
+
+    struct _HTChunk {
 	int size;		/* In bytes                     */
 	int growby;		/* Allocation unit in bytes     */
 	int allocated;		/* Current size of *data        */
 	char *data;		/* Pointer to malloc'd area or 0 */
 	int failok;		/* allowed to fail without exiting program? */
-    } HTChunk;
+	HTChunk *next;		/* pointer to the next chunk */
+    };
 
 /*
  * Initialize a chunk's allocation data and allocation-increment.
@@ -191,6 +194,31 @@ extern "C" {
 
     extern void HTChunkTerminate(HTChunk *ch);
 
+/* like the above but no realloc: extend to another chunk if necessary */
+/*
+ *
+ * Append a character (string, data) to a chunk
+ *
+ *   ON ENTRY,
+ *
+ *   ch                        A valid chunk pointer made by HTChunkCreate()
+ *
+ *   c                 The character to be appended
+ *
+ *   ON EXIT,
+ *
+ *   returns           original chunk or a pointer to the new chunk
+ *                     (orginal chunk is referenced to the new one
+ *                     by the field 'next')
+ *
+ */
+    extern HTChunk *HTChunkPutc2(HTChunk *ch, char c);
+    extern HTChunk *HTChunkPuts2(HTChunk *ch, const char *str);
+    extern HTChunk *HTChunkPutb2(HTChunk *ch, const char *b, int l);
+
+/* New pool infrastructure: UNlike the above, store data using alignment */
+    extern HTChunk *HTChunkPutb0(HTChunk *ch, const char *b, int l);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index a6242d42..2319043d 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -130,7 +130,7 @@ typedef struct _connection {
 #elif defined(SYS_HPUX)
 #  if defined(_XOPEN_SOURCE_EXTENDED) && defined(SO_PROTOTYPE)
 #    define LY_SOCKLEN socklen_t
-#  else	/* HPUX 10.20, etc. */
+#  else				/* HPUX 10.20, etc. */
 #    define LY_SOCKLEN int
 #  endif
 #elif defined(SYS_TRU64)
@@ -1278,11 +1278,7 @@ static int get_listen_socket(void)
 	    /* Cast to generic sockaddr */
 			   sizeof(soc_address)
 #ifndef SHORTENED_RBIND
-#ifdef INET6
-			   socks_bind_remoteAddr
-#else
 			   ,socks_bind_remoteAddr
-#endif /* INET6 */
 #endif /* !SHORTENED_RBIND */
 		);
 	else
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index 85bca424..7f52a81e 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -968,24 +968,18 @@ int HTMemCopy(HTChunk *chunk, HTStream *sink)
 {
     HTStreamClass targetClass;
     int bytes = 0;
-    const char *data = chunk->data;
     int rv = HT_OK;
 
     targetClass = *(sink->isa);
     HTReadProgress(0, 0);
-    for (;;) {
+    for (; chunk != NULL; chunk = chunk->next) {
+
 	/* Push the data down the stream a piece at a time, in case we're
 	 * running a large document on a slow machine.
 	 */
-	int n = INPUT_BUFFER_SIZE;
+	(*targetClass.put_block) (sink, chunk->data, chunk->size);
+	bytes += chunk->size;
 
-	if (n > chunk->size - bytes)
-	    n = chunk->size - bytes;
-	if (n == 0)
-	    break;
-	(*targetClass.put_block) (sink, data, n);
-	bytes += n;
-	data += n;
 	HTReadProgress(bytes, 0);
 	HTDisplayPartial();
 
diff --git a/WWW/Library/Implementation/HTStream.h b/WWW/Library/Implementation/HTStream.h
index 43ce9725..7a6d79ff 100644
--- a/WWW/Library/Implementation/HTStream.h
+++ b/WWW/Library/Implementation/HTStream.h
@@ -1,14 +1,14 @@
 /*                                                      The Stream class definition -- libwww
                                  STREAM OBJECT DEFINITION
-                                             
+
    A Stream object is something which accepts a stream of text.
-   
+
    The creation methods will vary on the type of Stream Object.  All creation
    methods return a pointer to the stream type below.
-   
+
    As you can see, but the methods used to write to the stream and close it are
    pointed to be the object itself.
-   
+
  */
 #ifndef HTSTREAM_H
 #define HTSTREAM_H
@@ -25,12 +25,8 @@ extern "C" {
 /*
 
    These are the common methods of all streams.  They should be
-   self-explanatory, except for end_document which must be called before free. 
-   It should be merged with free in fact:  it should be dummy for new streams.
-   
-   The put_block method was write, but this upset systems which had macros for
-   write().
-   
+   self-explanatory.
+
  */
     typedef struct _HTStreamClass {
 
@@ -38,18 +34,13 @@ extern "C" {
 
 	void (*_free) (HTStream *me);
 
-	void (*_abort) (HTStream *me,
-			HTError e);
+	void (*_abort) (HTStream *me, HTError e);
 
-	void (*put_character) (HTStream *me,
-			       char ch);
+	void (*put_character) (HTStream *me, char ch);
 
-	void (*put_string) (HTStream *me,
-			    const char *str);
+	void (*put_string) (HTStream *me, const char *str);
 
-	void (*put_block) (HTStream *me,
-			   const char *str,
-			   int len);
+	void (*put_block) (HTStream *me, const char *str, int len);
 
     } HTStreamClass;
 
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 5b938571..452dfae7 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -1643,11 +1643,10 @@ int HTDoConnect(const char *url,
 #else
 	    status = Rconnect(*s, (struct sockaddr *) &soc_address,
 			      sizeof(soc_address));
-#endif /* INET6 */
-	    /*
-	     * For long Rbind.
-	     */
+#ifndef SHORTENED_RBIND
 	    socks_bind_remoteAddr = soc_address.sin_addr.s_addr;
+#endif
+#endif /* INET6 */
 	} else
 #endif /* SOCKS */
 #ifdef INET6
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 27c0dcc0..0743cffc 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -304,11 +304,13 @@ int ws_netread(int fd, char *buf, int len)
 		HTInfoMsg("Thread terminate Failed");
 	    }
 	    now_TickCount = GetTickCount();
-	    if (now_TickCount > save_TickCount)
+	    if (now_TickCount >= save_TickCount)
 		process_time = now_TickCount - save_TickCount;
 	    else
 		process_time = now_TickCount + (0xffffffff - save_TickCount);
 
+	    if (process_time == 0)
+		process_time = 1;
 	    g_total_times += process_time;
 	    g_total_bytes += exitcode;
 
@@ -326,7 +328,7 @@ int ws_netread(int fd, char *buf, int len)
     LeaveCriticalSection(&critSec_READ);
     return ret_val;
 }
-#endif
+#endif /* _WINDOWS */
 
 /*
  * Strip any username from the given string so we retain only the host.
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index eae3db3d..c73d312c 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -20,7 +20,8 @@
 
 #include <SGML.h>
 #include <HTMLDTD.h>
-#include <HTCJK.h>
+#include <HTAccess.h>
+#include <HTCJK.h>		/* FIXME: this doesn't belong in SGML.c */
 #include <UCMap.h>
 #include <UCDefs.h>
 #include <UCAux.h>
@@ -33,6 +34,7 @@
 #include <LYGlobalDefs.h>
 #include <LYStrings.h>
 #include <LYLeaks.h>
+#include <LYUtils.h>
 
 #ifdef USE_COLOR_STYLE
 # include <LYStyle.h>
@@ -43,6 +45,8 @@
 
 #define INVALID (-1)
 
+static int sgml_offset;
+
 #ifdef USE_PRETTYSRC
 
 static char *entity_string;	/* this is used for printing entity name.
@@ -854,9 +858,9 @@ static void handle_marked(HTStream *context)
 	   charset once it is in include - kw */
 
     } else if (!strncmp(context->string->data, "![CDATA[", 8)) {
-	(*context->actions->_write) (context->target,
-				     context->string->data + 8,
-				     context->string->size - 11);
+	(*context->actions->put_block) (context->target,
+					context->string->data + 8,
+					context->string->size - 11);
 
     }
     return;
@@ -1499,6 +1503,8 @@ static void SGML_character(HTStream *context, char c_in)
 #endif
     char saved_char_in = '\0';
 
+    ++sgml_offset;
+
     /*
      * Now some fun with the preprocessor.  Use copies for c and unsign_c ==
      * clong, so that we can revert back to the unchanged c_in.  - KW
@@ -4474,9 +4480,23 @@ HTStream *SGML_new(const SGML_dtd * dtd,
     }
 #endif
 
+    sgml_offset = 0;
     return context;
 }
 
+/*
+ * Return the offset within the document where we're parsing.  This is used
+ * to help identify anchors which shift around while reparsing.
+ */
+int SGML_offset(void)
+{
+#ifdef USE_PRETTYSRC
+    return sgml_offset + psrc_view;
+#else
+    return sgml_offset;
+#endif
+}
+
 /*		Asian character conversion functions
  *		====================================
  *
diff --git a/WWW/Library/Implementation/SGML.h b/WWW/Library/Implementation/SGML.h
index c595dc91..836d1377 100644
--- a/WWW/Library/Implementation/SGML.h
+++ b/WWW/Library/Implementation/SGML.h
@@ -25,9 +25,9 @@
 extern "C" {
 #endif
 /*
-
-SGML content types
-
+ *
+ * SGML content types
+ *
  */ typedef enum {
 	SGML_EMPTY,		/* No content. */
 	SGML_LITTERAL,		/* Literal character data.  Recognize exact close tag only.
@@ -203,8 +203,9 @@ Structured Object definition
 
 	void (*put_string) (HTStructured * me, const char *str);
 
-	void (*_write) (HTStructured * me, const char *str,
-			int len);
+	void (*put_block) (HTStructured * me, const char *str, int len);
+
+	/* HTStreamClass ends here */
 
 	int (*start_element) (HTStructured * me, int element_number,
 			      const BOOL *attribute_present,
@@ -239,6 +240,11 @@ Find a Tag by Name
 			      const char *string);
 
 /*
+ * Return the current offset within the file that SGML is parsing
+ */
+    extern int SGML_offset(void);
+
+/*
 
 Create an SGML parser