diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 35 | ||||
-rw-r--r-- | src/HTML.c | 14 | ||||
-rw-r--r-- | src/LYList.c | 15 | ||||
-rw-r--r-- | src/LYMainLoop.c | 8 | ||||
-rw-r--r-- | src/LYStrings.c | 40 | ||||
-rw-r--r-- | src/LYUtils.h | 12 | ||||
-rw-r--r-- | src/LYexit.c | 2 |
7 files changed, 74 insertions, 52 deletions
diff --git a/src/GridText.c b/src/GridText.c index d5189c46..f957c7fd 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -234,7 +234,7 @@ lines, anchors, and FormInfo. Arrays of HTStyleChange are stored as is, other objects are stored using a cast.] Pool is referenced by the pointer to the last chunk that contains free slots. -Functions that allocate memory in pool update that pointer if needed. +Functions that allocate memory in the pool update that pointer if needed. There are 3 functions - POOL_NEW, POOL_FREE, and ALLOC_IN_POOL. - VH @@ -271,6 +271,7 @@ PRIVATE pool_data* ALLOC_IN_POOL ARGS2( if (j != 0) n += (ALIGN_SIZE - j); n /= sizeof(pool_data); + if (POOL_SIZE >= (pool->used + n)) { ptr = pool->data + pool->used; pool->used += n; @@ -282,11 +283,10 @@ PRIVATE pool_data* ALLOC_IN_POOL ARGS2( newpool->prev = pool; newpool->used = n; ptr = newpool->data; - pool = newpool; + *ppoolptr = newpool; } } } - *ppoolptr = pool; return ptr; } @@ -297,8 +297,8 @@ PRIVATE HTPool* POOL_NEW NOARGS { HTPool* poolptr = (HTPool*)LY_CALLOC(1, sizeof(HTPool)); if (poolptr) { - (poolptr)->prev = NULL; - (poolptr)->used = 0; + poolptr->prev = NULL; + poolptr->used = 0; } return poolptr; } @@ -2171,8 +2171,7 @@ PRIVATE void display_page ARGS3( links[nlinks].anchor_number = Anchor_ptr->number; links[nlinks].anchor_line_num = Anchor_ptr->line_num; - link_dest = HTAnchor_followMainLink( - (HTAnchor *)Anchor_ptr->anchor); + link_dest = HTAnchor_followLink(Anchor_ptr->anchor); { /* * Memory leak fixed 05-27-94 @@ -2185,7 +2184,7 @@ PRIVATE void display_page ARGS3( #ifndef DONT_TRACK_INTERNAL_LINKS if (Anchor_ptr->link_type == INTERNAL_LINK_ANCHOR) { link_dest_intl = HTAnchor_followTypedLink( - (HTAnchor *)Anchor_ptr->anchor, HTInternalLink); + Anchor_ptr->anchor, HTInternalLink); if (link_dest_intl && link_dest_intl != link_dest) { CTRACE((tfp, @@ -4978,12 +4977,12 @@ PUBLIC int HText_beginAnchor ARGS3( text->last_anchor = a; #ifndef DONT_TRACK_INTERNAL_LINKS - if (HTAnchor_followTypedLink((HTAnchor*)anc, HTInternalLink)) { + if (HTAnchor_followTypedLink(anc, HTInternalLink)) { a->number = ++(text->last_anchor_number); a->link_type = INTERNAL_LINK_ANCHOR; } else #endif - if (HTAnchor_followMainLink((HTAnchor*)anc)) { + if (HTAnchor_followLink(anc)) { a->number = ++(text->last_anchor_number); } else { a->number = 0; @@ -5053,7 +5052,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( (LYNoISMAPifUSEMAP && !(text->node_anchor && text->node_anchor->bookmark) && HTAnchor_isISMAPScript( - HTAnchor_followMainLink((HTAnchor *)a->anchor)))))); + HTAnchor_followLink(a->anchor)))))); HTLine *last = text->last_line; HTLine *prev = text->last_line->prev; HTLine *start = last; @@ -6180,7 +6179,7 @@ PUBLIC int HTGetLinkInfo ARGS6( return(LINK_LINE_FOUND); } else { *hightext = LYGetHiTextStr(a, 0); - link_dest = HTAnchor_followMainLink((HTAnchor *)a->anchor); + link_dest = HTAnchor_followLink(a->anchor); { char *cp_freeme = NULL; if (traversal) { @@ -6189,7 +6188,7 @@ PUBLIC int HTGetLinkInfo ARGS6( #ifndef DONT_TRACK_INTERNAL_LINKS if (a->link_type == INTERNAL_LINK_ANCHOR) { link_dest_intl = HTAnchor_followTypedLink( - (HTAnchor *)a->anchor, HTInternalLink); + a->anchor, HTInternalLink); if (link_dest_intl && link_dest_intl != link_dest) { CTRACE((tfp, "HTGetLinkInfo: unexpected typed link to %s!\n", @@ -7565,7 +7564,12 @@ PUBLIC void print_wwwfile_to_fd ARGS2( line = FirstHTLine(HTMainText); for (;; line = line->next) { - if (!first && line->data[0] != LY_SOFT_NEWLINE) { + if (first) { + first = FALSE; + if (is_reply) { + fputc('>',fp); + } + } else if (line->data[0] != LY_SOFT_NEWLINE) { fputc('\n',fp); /* * Add news-style quotation if requested. -FM @@ -7575,7 +7579,6 @@ PUBLIC void print_wwwfile_to_fd ARGS2( } } - first = FALSE; write_offset(fp, line); /* @@ -8764,7 +8767,7 @@ PRIVATE void HText_AddHiddenLink ARGS2( * so that first in will be first out on * retrievals. -FM */ - if ((dest = HTAnchor_followMainLink((HTAnchor *)textanchor->anchor)) && + if ((dest = HTAnchor_followLink(textanchor->anchor)) && (text->hiddenlinkflag != HIDDENLINKS_IGNORE || HTList_isEmpty(text->hidden_links))) HTList_appendObject(text->hidden_links, HTAnchor_address(dest)); diff --git a/src/HTML.c b/src/HTML.c index 93e0cdb2..0de7db0f 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1573,7 +1573,7 @@ PRIVATE int HTML_start_element ARGS6( : INTERN_LT); /* Type */ FREE(temp); if ((dest = HTAnchor_parent( - HTAnchor_followMainLink((HTAnchor*)me->CurrentA) + HTAnchor_followLink(me->CurrentA) )) != NULL) { if (pdoctitle && !HTAnchor_title(dest)) HTAnchor_setTitle(dest, *pdoctitle); @@ -3125,7 +3125,7 @@ PRIVATE int HTML_start_element ARGS6( } if (title != NULL || dest_ismap == TRUE || dest_char_set >= 0) { dest = HTAnchor_parent( - HTAnchor_followMainLink((HTAnchor*)me->CurrentA) + HTAnchor_followLink(me->CurrentA) ); } if (dest && title != NULL && HTAnchor_title(dest) == NULL) @@ -3187,7 +3187,7 @@ PRIVATE int HTML_start_element ARGS6( */ if (me->inA && me->CurrentA) { if ((dest = HTAnchor_parent( - HTAnchor_followMainLink((HTAnchor*)me->CurrentA) + HTAnchor_followLink(me->CurrentA) )) != NULL) { if (dest->isISMAPScript == TRUE) { dest_ismap = TRUE; @@ -3476,7 +3476,7 @@ PRIVATE int HTML_start_element ARGS6( INTERN_LT); /* Type */ if (me->CurrentA && title) { if ((dest = HTAnchor_parent( - HTAnchor_followMainLink((HTAnchor*)me->CurrentA) + HTAnchor_followLink(me->CurrentA) )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); @@ -3538,7 +3538,7 @@ PRIVATE int HTML_start_element ARGS6( INTERN_LT); /* Type */ if (me->CurrentA && title) { if ((dest = HTAnchor_parent( - HTAnchor_followMainLink((HTAnchor*)me->CurrentA) + HTAnchor_followLink(me->CurrentA) )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); @@ -3642,7 +3642,7 @@ PRIVATE int HTML_start_element ARGS6( INTERN_LT); /* Type */ if (me->CurrentA && title) { if ((dest = HTAnchor_parent( - HTAnchor_followMainLink((HTAnchor*)me->CurrentA) + HTAnchor_followLink(me->CurrentA) )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); @@ -4596,7 +4596,7 @@ PRIVATE int HTML_start_element ARGS6( NULL, action, (HTLinkType*)0); - if ((link_dest = HTAnchor_followMainLink((HTAnchor *)source)) != NULL) { + if ((link_dest = HTAnchor_followLink(source)) != NULL) { /* * Memory leak fixed. * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe diff --git a/src/LYList.c b/src/LYList.c index 724f5689..3bd66456 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -127,11 +127,10 @@ PUBLIC int showlist ARGS2( continue; } #ifndef DONT_TRACK_INTERNAL_LINKS - dest_intl = HTAnchor_followTypedLink((HTAnchor *)child, - HTInternalLink); + dest_intl = HTAnchor_followTypedLink(child, HTInternalLink); #endif dest = dest_intl ? - dest_intl : HTAnchor_followMainLink((HTAnchor *)child); + dest_intl : HTAnchor_followLink(child); parent = HTAnchor_parent(dest); if (!intern_w_post && dest_intl && HTMainAnchor && HTMainAnchor->post_data && @@ -150,11 +149,11 @@ PUBLIC int showlist ARGS2( title = titles ? HTAnchor_title(parent) : NULL; if (dest_intl) { HTSprintf0(&LinkTitle, "(internal)"); - } else if (titles && child->mainLink.type && - dest == child->mainLink.dest && - !strncmp(HTAtom_name(child->mainLink.type), + } else if (titles && child->type && + dest == child->dest && + !strncmp(HTAtom_name(child->type), "RelTitle: ", 10)) { - HTSprintf0(&LinkTitle, "(%s)", HTAtom_name(child->mainLink.type)+10); + HTSprintf0(&LinkTitle, "(%s)", HTAtom_name(child->type)+10); } else { FREE(LinkTitle); } @@ -288,7 +287,7 @@ PUBLIC void printlist ARGS2( } continue; } - dest = HTAnchor_followMainLink((HTAnchor *)child); + dest = HTAnchor_followLink(child); /* * Ignore if child anchor points to itself, i.e., we had * something like <A NAME=xyz HREF="#xyz"> and it is not diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index e57b882c..581b834f 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -4257,10 +4257,12 @@ PRIVATE void handle_LYK_SHELL ARGS3( stop_curses(); printf("%s\r\n", SPAWNING_MSG); #if defined(__CYGWIN__) - Cygwin_Shell(); -#else - LYSystem(LYSysShell()); + /* handling "exec $SHELL" does not work if $SHELL is null */ + if (LYGetEnv("SHELL") == NULL) { + Cygwin_Shell(); + } else #endif + LYSystem(LYSysShell()); start_curses(); *refresh_screen = TRUE; /* for an HText_pageDisplay() */ } else { diff --git a/src/LYStrings.c b/src/LYStrings.c index b981540c..362dc497 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -2436,30 +2436,44 @@ PUBLIC BOOLEAN LYRemoveNewlines ARGS1( char *, buffer) { if (buffer != 0) { - size_t i, j; - for (i = j = 0; buffer[i]; i++) - if (buffer[i] != '\n' && buffer[i] != '\r') - buffer[j++] = buffer[i]; - buffer[j] = 0; - return (i != j); + register char* buf = buffer; + for ( ; *buf && *buf != '\n' && *buf != '\r'; buf++) + ; + if (*buf) { + /* runs very seldom */ + char * old = buf; + for ( ; *old; old++) { + if (*old != '\n' && *old != '\r') + *buf++ = *old; + } + *buf = '\0'; + return TRUE; + } } return FALSE; } /* - * Remove ALL whitespace from a string (including embedded blanks). + * Remove ALL whitespace from a string (including embedded blanks), and returns + * a pointer to the end of the trimmed string. */ PUBLIC char * LYRemoveBlanks ARGS1( char *, buffer) { if (buffer != 0) { - size_t i, j; - for (i = j = 0; buffer[i]; i++) { - if (!isspace(UCH((buffer[i])))) - buffer[j++] = buffer[i]; + register char* buf = buffer; + for ( ; *buf && !isspace(UCH(*buf)); buf++) + ; + if (*buf) { + /* runs very seldom */ + char * old = buf; + for ( ; *old; old++) { + if (!isspace(UCH(*old))) + *buf++ = *old; + } + *buf = '\0'; } - buffer[j] = 0; - return buffer+j; + return buf; } return NULL; } diff --git a/src/LYUtils.h b/src/LYUtils.h index 9e1ee115..9600d16d 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -337,7 +337,8 @@ typedef enum { #define STR_FILE_URL "file:" #define LEN_FILE_URL 5 -#define isFILE_URL(addr) !strncasecomp(addr, STR_FILE_URL, LEN_FILE_URL) +#define isFILE_URL(addr) ((*addr == 'f' || *addr == 'F') &&\ + !strncasecomp(addr, STR_FILE_URL, LEN_FILE_URL)) #define STR_FINGER_URL "finger:" #define LEN_FINGER_URL 7 @@ -402,7 +403,8 @@ typedef enum { #define STR_LYNXCGI "lynxcgi:" #define LEN_LYNXCGI 8 -#define isLYNXCGI(addr) !strncasecomp(addr, STR_LYNXCGI, LEN_LYNXCGI) +#define isLYNXCGI(addr) ((*addr == 'l' || *addr == 'L') &&\ + !strncasecomp(addr, STR_LYNXCGI, LEN_LYNXCGI)) #define STR_LYNXCOOKIE "LYNXCOOKIE:" #define LEN_LYNXCOOKIE 11 @@ -414,7 +416,8 @@ typedef enum { #define STR_LYNXEXEC "lynxexec:" #define LEN_LYNXEXEC 9 -#define isLYNXEXEC(addr) !strncasecomp(addr, STR_LYNXEXEC, LEN_LYNXEXEC) +#define isLYNXEXEC(addr) ((*addr == 'l' || *addr == 'L') &&\ + !strncasecomp(addr, STR_LYNXEXEC, LEN_LYNXEXEC)) #define STR_LYNXDOWNLOAD "LYNXDOWNLOAD:" #define LEN_LYNXDOWNLOAD 13 @@ -446,7 +449,8 @@ typedef enum { #define STR_LYNXPROG "lynxprog:" #define LEN_LYNXPROG 9 -#define isLYNXPROG(addr) !strncasecomp(addr, STR_LYNXPROG, LEN_LYNXPROG) +#define isLYNXPROG(addr) ((*addr == 'l' || *addr == 'L') &&\ + !strncasecomp(addr, STR_LYNXPROG, LEN_LYNXPROG)) /* * For change_sug_filename(). diff --git a/src/LYexit.c b/src/LYexit.c index 8341180f..d5ce758b 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -78,7 +78,7 @@ PRIVATE void LYCompleteExit NOPARAMS } /* - * Purpose: Terminates program. + * Purpose: Terminates program, reports memory not freed. * Arguments: status Exit code. * Return Value: void * Remarks/Portability/Dependencies/Restrictions: |