diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2003-02-05 02:18:27 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2003-02-05 02:18:27 -0500 |
commit | c812b42f4248ea1ab6641616f6aef08d402d9f92 (patch) | |
tree | f3a1dc7217619392dcbffcfe58840ba92b84436d /WWW/Library/Implementation | |
parent | 533c7482785176296637df81cd1a6318a0c29f97 (diff) | |
download | lynx-snapshots-c812b42f4248ea1ab6641616f6aef08d402d9f92.tar.gz |
snapshot of project "lynx", label v2-8-5dev_14
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 244 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.h | 31 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTChunk.c | 77 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTChunk.h | 23 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTDOS.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTDOS.h | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTList.c | 18 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTParse.c | 7 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 26 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTVMSUtils.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/LYLeaks.h | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/LYexit.h | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/SGML.c | 45 |
14 files changed, 215 insertions, 274 deletions
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index 4a9e9419..2d40df15 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -250,64 +250,71 @@ PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4( CONST char *, href, /* May be "" or 0 */ HTLinkType *, ltype) /* May be 0 */ { - HTChildAnchor * child = HTAnchor_findChild(parent, tag); - + HTChildAnchor * child; CTRACE((tfp,"Entered HTAnchor_findChildAndLink: tag=`%s',%s href=`%s'\n", NonNull(tag), (ltype == HTInternalLink) ? " (internal link)" : "", NonNull(href) )); + child = HTAnchor_findChild(parent, tag); + if (href && *href) { CONST char *fragment = NULL; HTParentAnchor * dest; - if (ltype == HTInternalLink) { + if (ltype == HTInternalLink && *href == '#') { dest = parent; } else { - CONST char *relative_to = parent->parent->address; + CONST char *relative_to = parent->address; DocAddress parsed_doc; parsed_doc.address = HTParse(href, relative_to, PARSE_ACCESS | PARSE_HOST | PARSE_PATH | PARSE_PUNCTUATION); parsed_doc.post_data = NULL; parsed_doc.post_content_type = NULL; +#ifndef DONT_TRACK_INTERNAL_LINKS + if (ltype && parent->post_data && ltype == HTInternalLink) { + /* for internal links, find a destination with the same + post data if the source of the link has post data. - kw + not sure this ever happens when *href != '#' - LP */ + parsed_doc.post_data = parent->post_data; + parsed_doc.post_content_type = parent->post_content_type; + } +#endif parsed_doc.bookmark = NULL; parsed_doc.isHEAD = FALSE; parsed_doc.safe = FALSE; + dest = HTAnchor_findAddress_nofragment(&parsed_doc); FREE(parsed_doc.address); } - if (*href == '#') - fragment = href+1; - else - fragment = HTParseAnchor(href); - /* - ** [comment from HTAnchor_findAddress()] - ** If the address represents a sub-anchor, we load its parent, + ** [from HTAnchor_findAddress()] + ** If the address represents a sub-anchor, we load its parent (above), ** then we create a child anchor within that document. */ + fragment = (*href == '#') ? href+1 : HTParseAnchor(href); + if (*fragment) dest = (HTParentAnchor *)HTAnchor_findChild(dest, fragment); -#define DUPLICATE_ANCHOR_NAME_WORKAROUND +#define DUPLICATE_ANCHOR_NAME_WORKAROUND /*it will not work without*/ #ifdef DUPLICATE_ANCHOR_NAME_WORKAROUND if (tag && *tag) { - HTAnchor *testdest1; - int child_links; - testdest1 = child->mainLink.dest; - if (testdest1) { - child_links = 1 + HTList_count(child->links); + if (child->dest) { CTRACE((tfp, - "*** Duplicate ChildAnchor %p named `%s' with %d links", - child, tag, child_links)); - if ((HTAnchor *)dest == testdest1 && ltype == child->mainLink.type) { - CTRACE((tfp,", same dest %p and type, keeping it\n", - testdest1)); + "*** Duplicate ChildAnchor %p named `%s'", + child, tag)); + if ((HTAnchor *)dest == child->dest && ltype == child->type) { + CTRACE((tfp,", same dest %p and type, already linked\n", + child->dest)); + /* skip HTAnchor_link() */ + return child; + } else { CTRACE((tfp,", different dest %p, creating unnamed child\n", - testdest1)); + child->dest)); child = HTAnchor_findChild(parent, 0); } } @@ -315,7 +322,7 @@ PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4( #endif HTAnchor_link(child, (HTAnchor *)dest, ltype); } - return(child); + return child; } #ifdef LY_FIND_LEAKS @@ -368,8 +375,8 @@ PUBLIC HTAnchor * HTAnchor_findAddress ARGS1( CTRACE((tfp,"Entered HTAnchor_findAddress\n")); /* - ** If the address represents a sub-anchor, we recursively load its - ** parent, then we create a child anchor within that document. + ** If the address represents a sub-anchor, we load its parent, + ** then we create a child anchor within that document. */ if (*tag) { DocAddress parsed_doc; @@ -399,7 +406,7 @@ PRIVATE HTParentAnchor * HTAnchor_findAddress_nofragment ARGS1( CONST DocAddress *, newdoc) { /* - ** check whether we have this node. + ** Check whether we have this node. */ int hash; HTList * adults; @@ -481,17 +488,24 @@ PUBLIC HTAnchor * HTAnchor_findSimpleAddress ARGS1( return HTAnchor_findAddress(&urldoc); } + /* Delete an anchor and possibly related things (auto garbage collection) ** -------------------------------------------- ** ** The anchor is only deleted if the corresponding document is not loaded. ** All outgoing links from parent and children are deleted, and this anchor -** is removed from the sources list of all its targets. +** is removed from the sources list of its target. ** We also try to delete the targets whose documents are not loaded. ** If this anchor's source list is empty, we delete it and its children. */ + +/* + * Recursively try to delete destination anchor of this child. + * In any event, this will tell destination anchor that we + * no longer consider it a destination. + */ PRIVATE void deleteLinks ARGS1( - HTAnchor *, me) + HTChildAnchor *, me) { /* * Memory leaks fixed. @@ -506,22 +520,22 @@ PRIVATE void deleteLinks ARGS1( } /* - * Unregister me with our mainLink destination anchor's parent. + * Unregister me with our destination anchor's parent. */ - if (me->mainLink.dest) { - HTParentAnchor *parent = me->mainLink.dest->parent; + if (me->dest) { + HTParentAnchor *parent = me->dest->parent; /* - * Set the mainLink pointer to zero NOW. If we don't, + * Set the dest pointer to zero NOW. If we don't, * and we get somehow called recursively again for this * same old me during the HTAnchor_delete below, weird * things can occasionally happen. - kw */ - me->mainLink.dest = NULL; + me->dest = NULL; /* * Remove me from the parent's sources so that the - * parent knows one less anchor is it's dest. + * parent knows one less anchor is its dest. */ if (!HTList_isEmpty(&parent->sources)) { /* @@ -534,87 +548,20 @@ PRIVATE void deleteLinks ARGS1( * Test here to avoid calling overhead. * If the parent has no loaded document, then we should * tell it to attempt to delete itself. - * Don't do this jazz if the anchor passed in is the same - * as the anchor to delete. * Also, don't do this if the destination parent is our * parent. */ if (!parent->document && - parent != (HTParentAnchor *)me && me->parent != parent) { HTAnchor_delete(parent); } /* - * At this point, we haven't a mainLink. Set it to be - * so. + * At this point, we haven't a destination. Set it to be so. * Leave the HTAtom pointed to by type up to other code to * handle (reusable, near static). */ - me->mainLink.type = NULL; - } - - /* - * Check for extra destinations in our links list. - */ - if (!HTList_isEmpty(me->links)) { - HTLink *target; - HTParentAnchor *parent; - - /* - * Take out our extra non mainLinks one by one, calling - * their parents to know that they are no longer - * the destination of me's anchor. - */ - while ((target = (HTLink *)HTList_removeLastObject(me->links)) != 0) { - parent = target->dest->parent; - if (!HTList_isEmpty(&parent->sources)) { - /* - * Only need to tell destination parent - * anchor once. - */ - HTList_unlinkObject(&parent->sources, (void *)me); - } - - /* - * Avoid calling overhead. - * If the parent hasn't a loaded document, then - * we will attempt to have the parent - * delete itself. - * Don't call twice if this is the same anchor - * that we are trying to delete. - * Also, don't do this if we are trying to delete - * our parent. - */ - if (!parent->document && - (HTParentAnchor *)me != parent && - me->parent != parent) { - HTAnchor_delete(parent); - } - /* - * The link structure has to be deleted, too! - * That was missing, but this code probably never - * got exercised by Lynx. - KW - */ - FREE(target); - } - - /* - * At this point, me no longer has any destination in - * the links list. Get rid of it. - */ - if (me->links) { - HTList_delete(me->links); - me->links = NULL; - } - } - - /* - * Catch in case links list exists but nothing in it. - */ - if (me->links) { - HTList_delete(me->links); - me->links = NULL; + me->type = NULL; } } @@ -672,16 +619,9 @@ PUBLIC BOOL HTAnchor_delete ARGS1( me->underway = TRUE; /* - * Recursively try to delete destination anchors of this parent. - * In any event, this will tell all destination anchors that we - * no longer consider them a destination. - */ - deleteLinks((HTAnchor *)me); - - /* * There are still incoming links to this one (we are the * destination of another anchor). - * Don't actually delete this anchor, but children are OK to + * Don't actually delete this parent anchor, but children are OK to * delete their links. */ if (!HTList_isEmpty(&me->sources)) { @@ -692,14 +632,14 @@ PUBLIC BOOL HTAnchor_delete ARGS1( if (!HTList_isEmpty(&me->children_notag)) { cur = &me->children_notag; while ((child = (HTChildAnchor *)HTList_nextObject(cur)) != 0) { - deleteLinks((HTAnchor *)child); + deleteLinks(child); } } if (me->children) { ele = HTBTree_next(me->children, NULL); while (ele != NULL) { child = (HTChildAnchor *)HTBTree_object(ele); - deleteLinks((HTAnchor *)child); + deleteLinks(child); ele = HTBTree_next(me->children, ele); } } @@ -719,7 +659,7 @@ PUBLIC BOOL HTAnchor_delete ARGS1( ele = HTBTree_next(me->children, NULL); while (ele != NULL) { child = (HTChildAnchor *)HTBTree_object(ele); - deleteLinks((HTAnchor *)child); + deleteLinks(child); FREE(child->tag); ele = HTBTree_next(me->children, ele); } @@ -730,7 +670,7 @@ PUBLIC BOOL HTAnchor_delete ARGS1( if (!HTList_isEmpty(&me->children_notag)) { while ((child = (HTChildAnchor *)HTList_unlinkLastObject( &me->children_notag)) != 0) { - deleteLinks((HTAnchor *)child); + deleteLinks(child); FREE(child); } } @@ -1198,20 +1138,16 @@ PUBLIC BOOL HTAnchor_link ARGS3( { if (!(source && destination)) return(NO); /* Can't link to/from non-existing anchor */ + CTRACE((tfp, "Linking anchor %p to anchor %p\n", source, destination)); - if (!source->mainLink.dest) { - source->mainLink.dest = destination; - source->mainLink.type = type; - } else { - HTLink * newLink = typecalloc(HTLink); - if (newLink == NULL) - outofmem(__FILE__, "HTAnchor_link"); - newLink->dest = destination; - newLink->type = type; - if (!source->links) - source->links = HTList_new(); - HTList_addObject (source->links, newLink); + if (source->dest) { + CTRACE((tfp, "*** ERR: child anchor already has destination!\n")); + return(NO); } + + source->dest = destination; + source->type = type; + HTList_linkObject(&destination->parent->sources, source, &source->_add_sources); return(YES); /* Success */ } @@ -1220,55 +1156,19 @@ PUBLIC BOOL HTAnchor_link ARGS3( /* Manipulation of links ** --------------------- */ -PUBLIC HTAnchor * HTAnchor_followMainLink ARGS1( - HTAnchor *, me) +PUBLIC HTAnchor * HTAnchor_followLink ARGS1( + HTChildAnchor *, me) { - return( me->mainLink.dest); + return( me->dest); } PUBLIC HTAnchor * HTAnchor_followTypedLink ARGS2( - HTAnchor *, me, - HTLinkType *, type) -{ - if (me->mainLink.type == type) - return( me->mainLink.dest); - if (me->links) { - HTList *links = me->links; - HTLink *the_link; - while (NULL != (the_link=(HTLink *)HTList_nextObject(links))) { - if (the_link->type == type) { - return( the_link->dest); - } - } - } - return(NULL); /* No link of me type */ -} - - -/* Make main link -*/ -PUBLIC BOOL HTAnchor_makeMainLink ARGS2( - HTAnchor *, me, - HTLink *, movingLink) + HTChildAnchor *, me, + HTLinkType *, type) { - /* Check that everything's OK */ - if (!(me && HTList_removeObject (me->links, movingLink))) { - return(NO); /* link not found or NULL anchor */ - } else { - /* First push current main link onto top of links list */ - HTLink *newLink = typecalloc(HTLink); - if (newLink == NULL) - outofmem(__FILE__, "HTAnchor_makeMainLink"); - memcpy((void *)newLink, - (CONST char *)&me->mainLink, sizeof (HTLink)); - HTList_addObject (me->links, newLink); - - /* Now make movingLink the new main link, and free it */ - memcpy((void *)&me->mainLink, - (CONST void *)movingLink, sizeof (HTLink)); - FREE(movingLink); - return(YES); - } + if (me->type == type) + return( me->dest); + return(NULL); /* No link of me type */ } diff --git a/WWW/Library/Implementation/HTAnchor.h b/WWW/Library/Implementation/HTAnchor.h index cbf27076..fea5b928 100644 --- a/WWW/Library/Implementation/HTAnchor.h +++ b/WWW/Library/Implementation/HTAnchor.h @@ -31,25 +31,13 @@ typedef struct _HTParentAnchor HTParentAnchor; /* After definition of HTFormat: */ #include <HTFormat.h> -typedef HTAtom HTLinkType; - -typedef struct { - HTAnchor * dest; /* The anchor to which this leads */ - HTLinkType * type; /* Semantics of this link */ -} HTLink; -struct _HTAnchor { /* Generic anchor : just links */ - HTLink mainLink; /* Main (or default) destination of this */ - HTList * links; /* List of extra links from this, if any */ - /* We separate the first link from the others to avoid too many small mallocs - involved by a list creation. Most anchors only point to one place. */ +struct _HTAnchor { /* Generic anchor */ HTParentAnchor * parent; /* Parent of this anchor (self for adults) */ }; struct _HTParentAnchor { /* Common part from the generic anchor structure */ - HTLink mainLink; /* Main (or default) destination of this */ - HTList * links; /* List of extra links from this, if any */ HTParentAnchor * parent; /* Parent of this anchor (self) */ /* ParentAnchor-specific information */ @@ -110,15 +98,18 @@ struct _HTParentAnchor { HTList * imaps; /* client side image maps */ }; +typedef HTAtom HTLinkType; + typedef struct { /* Common part from the generic anchor structure */ - HTLink mainLink; /* Main (or default) destination of this */ - HTList * links; /* List of extra links from this, if any */ HTParentAnchor * parent; /* Parent of this anchor */ /* ChildAnchor-specific information */ char * tag; /* #fragment, relative to the parent */ + HTAnchor * dest; /* The anchor to which this leads */ + HTLinkType * type; /* Semantics of this link */ + HTList _add_children_notag; /* - just a memory for list entry:) */ HTList _add_sources; /* - just a memory for list entry:) */ } HTChildAnchor; @@ -375,17 +366,13 @@ extern BOOL HTAnchor_link PARAMS(( /* Manipulation of links ** --------------------- */ -extern HTAnchor * HTAnchor_followMainLink PARAMS(( - HTAnchor * me)); +extern HTAnchor * HTAnchor_followLink PARAMS(( + HTChildAnchor * me)); extern HTAnchor * HTAnchor_followTypedLink PARAMS(( - HTAnchor * me, + HTChildAnchor * me, HTLinkType * type)); -extern BOOL HTAnchor_makeMainLink PARAMS(( - HTAnchor * me, - HTLink * movingLink)); - /* Read and write methods ** ---------------------- */ diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c index 6c2d1687..bc6eefcb 100644 --- a/WWW/Library/Implementation/HTChunk.c +++ b/WWW/Library/Implementation/HTChunk.c @@ -91,6 +91,28 @@ PUBLIC void HTChunkFree ARGS1 (HTChunk *,ch) } +/* Realloc the chunk +** ----------------- +*/ +PUBLIC BOOL HTChunkRealloc ARGS2 (HTChunk *,ch, int,growby) +{ + char *data; + ch->allocated = ch->allocated + growby; + + data = ch->data ? (char *)realloc(ch->data, ch->allocated) + : typecallocn(char, ch->allocated); + if (data) { + ch->data = data; + } else if (ch->failok) { + HTChunkClear(ch); /* allocation failed, clear all data - kw */ + return FALSE; /* caller should check ch->allocated - kw */ + } else { + outofmem(__FILE__, "HTChunkRealloc"); + } + return TRUE; +} + + /* Append a character ** ------------------ */ @@ -99,18 +121,8 @@ PUBLIC void HTChunkFree ARGS1 (HTChunk *,ch) PUBLIC void HTChunkPutc ARGS2 (HTChunk *,ch, char,c) { if (ch->size >= ch->allocated) { - char *data; - ch->allocated = ch->allocated + ch->growby; - data = ch->data ? (char *)realloc(ch->data, ch->allocated) - : typecallocn(char, ch->allocated); - if (data) { - ch->data = data; - } else if (ch->failok) { - HTChunkClear(ch); /* allocation failed, clear all data - kw */ - return; /* caller should check ch->allocated - kw */ - } else { - outofmem(__FILE__, "HTChunkPutc"); - } + if (!HTChunkRealloc(ch, ch->growby)) + return; } ch->data[ch->size++] = c; } @@ -132,22 +144,11 @@ PUBLIC void HTChunkEnsure ARGS2 (HTChunk *,ch, int,needed) PUBLIC void HTChunkPutb ARGS3 (HTChunk *,ch, CONST char *,b, int,l) { - int needed = ch->size + l; if (l <= 0) return; - if (needed > ch->allocated) { - char *data; - ch->allocated = needed-1 - ((needed-1) % ch->growby) - + ch->growby; /* Round up */ - data = ch->data ? (char *)realloc(ch->data, ch->allocated) - : typecallocn(char, ch->allocated); - if (data) { - ch->data = data; - } else if (ch->failok) { - HTChunkClear(ch); /* allocation failed, clear all data - kw */ - return; /* caller should check ch->allocated - kw */ - } else { - outofmem(__FILE__, "HTChunkPutb"); - } + if (ch->size + l > ch->allocated) { + int growby = l - (l % ch->growby) + ch->growby; /* Round up */ + if (!HTChunkRealloc(ch, growby)) + return; } memcpy(ch->data + ch->size, b, l); ch->size += l; @@ -178,19 +179,9 @@ PUBLIC void HTChunkPutUtf8Char ARGS2( utflen = 0; if (ch->size + utflen > ch->allocated) { - char *data; int growby = (ch->growby >= utflen) ? ch->growby : utflen; - ch->allocated = ch->allocated + growby; - data = ch->data ? (char *)realloc(ch->data, ch->allocated) - : typecallocn(char, ch->allocated); - if (data) { - ch->data = data; - } else if (ch->failok) { - HTChunkClear(ch); /* allocation failed, clear all data - kw */ - return; /* caller should check ch->allocated - kw */ - } else { - outofmem(__FILE__, "HTChunkPutUtf8Char"); - } + if (!HTChunkRealloc(ch, growby)) + return; } switch (utflen) { @@ -250,8 +241,10 @@ PUBLIC void HTChunkPuts ARGS2 (HTChunk *,ch, CONST char *,s) { CONST char * p; for (p = s; *p; p++) { - HTChunkPutc(ch, *p); - if (ch->allocated == 0) - return; /* must have been allocation failure - kw */ + if (ch->size >= ch->allocated) { + if (!HTChunkRealloc(ch, ch->growby)) + return; + } + ch->data[ch->size++] = *p; } } diff --git a/WWW/Library/Implementation/HTChunk.h b/WWW/Library/Implementation/HTChunk.h index a243b2b4..2c393261 100644 --- a/WWW/Library/Implementation/HTChunk.h +++ b/WWW/Library/Implementation/HTChunk.h @@ -13,7 +13,7 @@ #ifndef HTUTILS_H #include <HTUtils.h> #endif - + #include <UCMap.h> typedef struct { @@ -100,6 +100,25 @@ extern void HTChunkClear PARAMS((HTChunk * ch)); /* * + * Realloc a chunk + * + * ON ENTRY, + * + * ch A valid chunk pointer made by HTChunkCreate() + * + * growby growby + * + * ON EXIT, + * + * *ch Expanded by growby + * + */ + +extern BOOL HTChunkRealloc PARAMS((HTChunk * ch, int growby)); + + +/* + * * Ensure a chunk has a certain space in * * ON ENTRY, @@ -145,7 +164,7 @@ extern void HTChunkPutUtf8Char PARAMS((HTChunk * ch, UCode_t code)); * * ch A valid chunk pointer made by HTChunkCreate() * - * str Tpoints to a zero-terminated string to be appended + * str Points to a zero-terminated string to be appended * * ON EXIT, * diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c index 91e6db41..58241d08 100644 --- a/WWW/Library/Implementation/HTDOS.c +++ b/WWW/Library/Implementation/HTDOS.c @@ -7,6 +7,8 @@ #include <HTDOS.h> #include <LYStrings.h> +#include <LYLeaks.h> + /* * Make a copy of the source argument in the result, allowing some extra * space so we can append directly onto the result without reallocating. @@ -76,7 +78,7 @@ char * HTDOS_wwwName ARGS1(CONST char *, dosname) /* * Convert slashes from Unix to DOS */ -char * HTDOS_slashes (char * path) +char * HTDOS_slashes ARGS1(char *, path) { char *s; diff --git a/WWW/Library/Implementation/HTDOS.h b/WWW/Library/Implementation/HTDOS.h index 6aa61bda..128608d9 100644 --- a/WWW/Library/Implementation/HTDOS.h +++ b/WWW/Library/Implementation/HTDOS.h @@ -21,7 +21,7 @@ char * HTDOS_wwwName PARAMS((CONST char * dosname)); /* * Converts Unix slashes to DOS */ -char * HTDOS_slashes (char * path); +char * HTDOS_slashes PARAMS((char * path)); /* PUBLIC HTDOS_name() ** CONVERTS WWW name into a DOS name diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 3c884e63..555bb176 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -2767,7 +2767,7 @@ AgainForMultiNet: FREE(spilledname); CTRACE((tfp, "Adding file to BTree: %s\n", entry_info->filename)); - HTBTree_add(bt, (EntryInfo *)entry_info); + HTBTree_add(bt, entry_info); } else { free_entryinfo_struct_contents(entry_info); FREE(entry_info); diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c index 7a856833..35d865cf 100644 --- a/WWW/Library/Implementation/HTList.c +++ b/WWW/Library/Implementation/HTList.c @@ -99,9 +99,21 @@ PUBLIC void HTList_linkObject ARGS3( HTList *, newNode) { if (me) { - newNode->object = newObject; - newNode->next = me->next; - me->next = newNode; + if (newNode->object == 0 && newNode->next == 0) { + /* It is safe: */ + newNode->object = newObject; + newNode->next = me->next; + me->next = newNode; + + } else { + /* + * This node was already linked to some list (probably this one), + * so refuse changing node pointers to keep the list valid!!! + */ + CTRACE((tfp, "*** HTList: Refuse linking already linked obj ")); + CTRACE((tfp, "%p, node %p, list %p\n", + newObject, newNode, me)); + } } else { CTRACE((tfp, "HTList: Trying to link object %p to a nonexisting list\n", diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c index e0945d18..08480133 100644 --- a/WWW/Library/Implementation/HTParse.c +++ b/WWW/Library/Implementation/HTParse.c @@ -182,7 +182,7 @@ PUBLIC char * HTParse ARGS3( int, wanted) { char * result = NULL; - char *tail = NULL; /* a pointer within 'result' string */ + char * tail = NULL; /* a pointer to the end of the 'result' string */ char * return_value = NULL; int len, len1, len2; char * name = NULL; @@ -363,9 +363,9 @@ PUBLIC char * HTParse ARGS3( /* * Trim any blanks from the result so far - there's no excuse for blanks - * in a hostname. + * in a hostname. Also update the tail here. */ - LYRemoveBlanks(result); + tail = LYRemoveBlanks(result); /* ** If host in given or related was ended directly with a '?' (no @@ -424,7 +424,6 @@ PUBLIC char * HTParse ARGS3( } } - tail = result + strlen(result); if (given.absolute) { /* All is given */ if (wanted & PARSE_PUNCTUATION) *tail++ = '/'; diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 9270209d..87073b38 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -601,20 +601,30 @@ use_tunnel: X509_NAME_oneline(X509_get_subject_name(SSL_get_peer_certificate(handle)), ssl_dn, sizeof(ssl_dn)); - cert_host = strstr(ssl_dn, "/CN=") + 4; - if ((p = strchr(cert_host, '/')) != NULL) - *p = '\0'; - ssl_host = HTParse(url, "", PARSE_HOST); - if (strcmp(ssl_host, cert_host)) { + if ((cert_host = strstr(ssl_dn, "/CN=")) == NULL) { HTSprintf0(&msg, - gettext("SSL error:host(%s)!=cert(%s)-Continue?"), - ssl_host, - cert_host); + gettext("SSL error:Can't find common name in certificate-Continue?")); if (! HTConfirmDefault(msg, TRUE)) { status = HT_NOT_LOADED; FREE(msg); goto done; } + } else { + cert_host += 4; + if ((p = strchr(cert_host, '/')) != NULL) + *p = '\0'; + ssl_host = HTParse(url, "", PARSE_HOST); + if (strcmp(ssl_host, cert_host)) { + HTSprintf0(&msg, + gettext("SSL error:host(%s)!=cert(%s)-Continue?"), + ssl_host, + cert_host); + if (! HTConfirmDefault(msg, TRUE)) { + status = HT_NOT_LOADED; + FREE(msg); + goto done; + } + } } HTSprintf0(&msg, diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c index 98dc8f77..49c03f0a 100644 --- a/WWW/Library/Implementation/HTVMSUtils.c +++ b/WWW/Library/Implementation/HTVMSUtils.c @@ -1027,7 +1027,7 @@ PUBLIC int HTVMSBrowseDir ARGS4( { CTRACE((tfp,"Adding file to BTree: %s\n", entry_info->filename)); - HTBTree_add(bt, (VMSEntryInfo *)entry_info); + HTBTree_add(bt, entry_info); } } /* End while HTVMSreaddir() */ diff --git a/WWW/Library/Implementation/LYLeaks.h b/WWW/Library/Implementation/LYLeaks.h index ebcc2e1b..99c0f4d0 100644 --- a/WWW/Library/Implementation/LYLeaks.h +++ b/WWW/Library/Implementation/LYLeaks.h @@ -196,7 +196,9 @@ typedef struct AllocationList_tag { ** Function declarations ** See the appropriate source file for usage. */ +#ifndef LYLeakSequence extern long LYLeakSequence NOPARAMS; +#endif extern void LYLeaks NOPARAMS; #ifdef LY_FIND_LEAKS_EXTENDED extern AllocationList *LYLeak_mark_malloced PARAMS(( diff --git a/WWW/Library/Implementation/LYexit.h b/WWW/Library/Implementation/LYexit.h index 347ee0d3..005e13d9 100644 --- a/WWW/Library/Implementation/LYexit.h +++ b/WWW/Library/Implementation/LYexit.h @@ -27,14 +27,14 @@ /* * Constant defines */ -#ifdef _WINDOWS +#ifdef exit #undef exit #endif /* _WINDOWS */ -#define exit LYexit +#define exit(code) LYexit(code) #define atexit LYatexit -#define ATEXITSIZE 40 +#define ATEXITSIZE 50 /* * Data structures diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c index 4c8062f0..4c3b3b5a 100644 --- a/WWW/Library/Implementation/SGML.c +++ b/WWW/Library/Implementation/SGML.c @@ -60,19 +60,36 @@ PRIVATE void fake_put_character ARGS2( #endif - /* will use an inlined version */ -#ifdef USE_INLINE_PUTC + /* will use partially inlined version */ +#define orig_HTChunkPutUtf8Char HTChunkPutUtf8Char +#undef HTChunkPutUtf8Char + +/* ...used for comments and attributes value like href... */ +#define HTChunkPutUtf8Char(ch,x) \ + { \ + if ((TOASCII(x) < 128) && (ch->size < ch->allocated)) \ + ch->data[ch->size++] = (char)x; \ + else \ + orig_HTChunkPutUtf8Char(ch,x); \ + } + +#if 0 +#define orig_HTChunkPutc HTChunkPutc #undef HTChunkPutc -#define HTChunkPutc(ch,c)\ - if (ch->size >= ch->allocated) {\ - ch->allocated = ch->allocated + ch->growby;\ - ch->data = ch->data ? (char *)realloc(ch->data, ch->allocated)\ - : typecallocn(char, ch->allocated);\ - if (!ch->data)\ - outofmem(__FILE__, "HTChunkPutc");\ - }\ - ch->data[ch->size++] = c; -#endif + +#define HTChunkPutc(ch,x) \ + { \ + if (ch->size < ch->allocated) \ + ch->data[ch->size++] = x; \ + else \ + orig_HTChunkPutc(ch,x); \ + } + +#undef HTChunkTerminate + +#define HTChunkTerminate(ch) \ + HTChunkPutc(ch, (char)0) +#endif /* */ #define PUTS(str) ((*context->actions->put_string)(context->target, str)) #define PUTC(ch) ((*context->actions->put_character)(context->target, ch)) @@ -277,7 +294,7 @@ PRIVATE char *state_name ARGS1(sgml_state, n) static HTElement pool[DEPTH]; static int depth = 0; -PRIVATE HTElement* pool_get NOARGS +PRIVATE HTElement* pool_alloc NOARGS { depth++; if (depth > DEPTH) @@ -1332,7 +1349,7 @@ PRIVATE void start_element ARGS1( if (status == HT_PARSER_OTHER_CONTENT) new_tag = ALT_TAGP(new_tag); /* this is only returned for OBJECT */ if (new_tag->contents != SGML_EMPTY) { /* i.e., tag not empty */ - HTElement * N = pool_get(); + HTElement * N = pool_alloc(); if (N == NULL) outofmem(__FILE__, "start_element"); N->next = context->element_stack; |