diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2013-05-01 01:00:38 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2013-05-01 01:00:38 -0400 |
commit | 81905f18dc0594e372cf38cfb0e0b71b69849a43 (patch) | |
tree | 8eb23ef6f907e1a4f53bd7c2247522b077037e63 /src | |
parent | 7827f0bdba0c75376e59443975f3638df4cce044 (diff) | |
download | lynx-snapshots-81905f18dc0594e372cf38cfb0e0b71b69849a43.tar.gz |
snapshot of project "lynx", label v2-8-8dev-15b
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 220 | ||||
-rw-r--r-- | src/HTInit.c | 4 | ||||
-rw-r--r-- | src/HTML.c | 6 | ||||
-rw-r--r-- | src/LYBookmark.c | 6 | ||||
-rw-r--r-- | src/LYCgi.c | 4 | ||||
-rw-r--r-- | src/LYCharSets.c | 4 | ||||
-rw-r--r-- | src/LYCharUtils.c | 7 | ||||
-rw-r--r-- | src/LYCurses.c | 41 | ||||
-rw-r--r-- | src/LYEditmap.c | 6 | ||||
-rw-r--r-- | src/LYExtern.c | 16 | ||||
-rw-r--r-- | src/LYForms.c | 34 | ||||
-rw-r--r-- | src/LYGetFile.c | 13 | ||||
-rw-r--r-- | src/LYGlobalDefs.h | 3 | ||||
-rw-r--r-- | src/LYHistory.c | 14 | ||||
-rw-r--r-- | src/LYJump.c | 10 | ||||
-rw-r--r-- | src/LYKeymap.c | 4 | ||||
-rw-r--r-- | src/LYList.c | 12 | ||||
-rw-r--r-- | src/LYLocal.c | 95 | ||||
-rw-r--r-- | src/LYMain.c | 13 | ||||
-rw-r--r-- | src/LYMainLoop.c | 457 | ||||
-rw-r--r-- | src/LYMap.c | 43 | ||||
-rw-r--r-- | src/LYReadCFG.c | 17 | ||||
-rw-r--r-- | src/LYShowInfo.c | 9 | ||||
-rw-r--r-- | src/LYStrings.c | 4 | ||||
-rw-r--r-- | src/LYUtils.c | 16 | ||||
-rw-r--r-- | src/LYrcFile.h | 3 | ||||
-rw-r--r-- | src/TRSTable.c | 6 | ||||
-rw-r--r-- | src/UCAuto.c | 7 | ||||
-rw-r--r-- | src/parsdate.c | 126 | ||||
-rw-r--r-- | src/parsdate.y | 116 |
30 files changed, 685 insertions, 631 deletions
diff --git a/src/GridText.c b/src/GridText.c index 0f8b1e14..1ba334b2 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.243 2012/11/18 22:09:20 tom Exp $ + * $LynxId: GridText.c,v 1.252 2013/05/01 00:43:19 tom Exp $ * * Character grid hypertext object * =============================== @@ -993,7 +993,7 @@ HText *HText_new(HTParentAnchor *anchor) HText *self = typecalloc(HText); if (!self) - return self; + outofmem(__FILE__, "HText_New"); CTRACE((tfp, "GridText: start HText_new\n")); @@ -2308,13 +2308,12 @@ static void display_page(HText *text, { auto char *cp_AnchorAddress = NULL; - if (traversal) + if (traversal) { cp_AnchorAddress = stub_HTAnchor_address(link_dest); - else { -#ifndef DONT_TRACK_INTERNAL_LINKS + } else if (track_internal_links) { if (Anchor_ptr->link_type == INTERNAL_LINK_ANCHOR) { - link_dest_intl = HTAnchor_followTypedLink( - Anchor_ptr->anchor, HTInternalLink); + link_dest_intl = HTAnchor_followTypedLink(Anchor_ptr->anchor, + HTInternalLink); if (link_dest_intl && link_dest_intl != link_dest) { CTRACE((tfp, @@ -2322,15 +2321,18 @@ static void display_page(HText *text, link_dest_intl->parent->address)); link_dest_intl = NULL; } - } else + } else { link_dest_intl = NULL; + } if (link_dest_intl) { char *cp2 = HTAnchor_address(link_dest_intl); cp_AnchorAddress = cp2; - } else -#endif + } else { cp_AnchorAddress = HTAnchor_address(link_dest); + } + } else { + cp_AnchorAddress = HTAnchor_address(link_dest); } FREE(links[nlinks].lname); @@ -4873,42 +4875,41 @@ void HText_cancelStbl(HText *me) */ void HText_startStblTABLE(HText *me, int alignment) { + if (me) { #ifdef EXP_NESTED_TABLES - STable_info *current = me->stbl; + STable_info *current = me->stbl; #endif - if (!me) - return; - #ifdef EXP_NESTED_TABLES - if (nested_tables) { - if (current) - new_line(me); - } else + if (nested_tables) { + if (current) + new_line(me); + } else #endif - { - if (me->stbl) - HText_cancelStbl(me); /* auto cancel previously open table */ - } + { + if (me->stbl) + HText_cancelStbl(me); /* auto cancel previously open table */ + } - me->stbl = Stbl_startTABLE(alignment); - if (me->stbl) { - CTRACE((tfp, "startStblTABLE: started.\n")); + me->stbl = Stbl_startTABLE(alignment); + if (me->stbl) { + CTRACE((tfp, "startStblTABLE: started.\n")); #ifdef EXP_NESTED_TABLES - if (nested_tables) { - Stbl_set_enclosing(me->stbl, current, me->last_anchor_before_stbl); - } + if (nested_tables) { + Stbl_set_enclosing(me->stbl, current, me->last_anchor_before_stbl); + } #endif - me->last_anchor_before_stbl = me->last_anchor; - } else { - CTRACE((tfp, "startStblTABLE: failed.\n")); + me->last_anchor_before_stbl = me->last_anchor; + } else { + CTRACE((tfp, "startStblTABLE: failed.\n")); + } } } #ifdef EXP_NESTED_TABLES static void free_enclosed_stbl(HText *me) { - if (me->enclosed_stbl != NULL) { + if (me != NULL && me->enclosed_stbl != NULL) { HTList *list = me->enclosed_stbl; STable_info *stbl; @@ -5174,13 +5175,11 @@ int HText_beginAnchor(HText *text, int underline, a->link_type = HYPERTEXT_ANCHOR; text->last_anchor = a; -#ifndef DONT_TRACK_INTERNAL_LINKS - if (HTAnchor_followTypedLink(anc, HTInternalLink)) { + if (track_internal_links + && HTAnchor_followTypedLink(anc, HTInternalLink)) { a->number = ++(text->last_anchor_number); a->link_type = INTERNAL_LINK_ANCHOR; - } else -#endif - if (HTAnchor_followLink(anc)) { + } else if (HTAnchor_followLink(anc)) { a->number = ++(text->last_anchor_number); } else { a->number = 0; @@ -5960,8 +5959,7 @@ static void HText_trimHightext(HText *text, /* * Copy the link name into the data structure. */ - if (line_ptr->data - && anchor_ptr->extent > 0 + if (anchor_ptr->extent > 0 && anchor_ptr->line_pos >= 0) { int size = (int) line_ptr->size - anchor_ptr->line_pos; @@ -6329,9 +6327,7 @@ int HTGetLinkInfo(int number, TextAnchor *a; HTAnchor *link_dest; -#ifndef DONT_TRACK_INTERNAL_LINKS HTAnchor *link_dest_intl = NULL; -#endif int anchors_this_line = 0, anchors_this_screen = 0; int prev_anchor_line = -1, prev_prev_anchor_line = -1; @@ -6446,8 +6442,7 @@ int HTGetLinkInfo(int number, if (traversal) { cp_freeme = stub_HTAnchor_address(link_dest); - } else { -#ifndef DONT_TRACK_INTERNAL_LINKS + } else if (track_internal_links) { if (a->link_type == INTERNAL_LINK_ANCHOR) { link_dest_intl = HTAnchor_followTypedLink(a->anchor, HTInternalLink); @@ -6465,9 +6460,11 @@ int HTGetLinkInfo(int number, FREE(*lname); *lname = cp2; return (WWW_INTERN_LINK_TYPE); - } else -#endif + } else { cp_freeme = HTAnchor_address(link_dest); + } + } else { + cp_freeme = HTAnchor_address(link_dest); } StrAllocCopy(*lname, cp_freeme); FREE(cp_freeme); @@ -9733,9 +9730,8 @@ static char *HText_skipOptionNumPrefix(char *opname) } /* - * We couldn't set the value field for the previous option - * tag so we have to do it now. Assume that the last anchor - * was the previous options tag. + * We couldn't set the value field for the previous option tag so we have to do + * it now. Assume that the last anchor was the previous options' tag. */ char *HText_setLastOptionValue(HText *text, char *value, char *submit_value, @@ -9846,11 +9842,11 @@ char *HText_setLastOptionValue(HText *text, char *value, return NULL; } - new_ptr = text->last_anchor->input_field->select_list = - typecalloc(OptionType); + new_ptr = typecalloc(OptionType); if (new_ptr == NULL) outofmem(__FILE__, "HText_setLastOptionValue"); + text->last_anchor->input_field->select_list = new_ptr; first_option = TRUE; } else { while (op_ptr->next) { @@ -9887,10 +9883,7 @@ char *HText_setLastOptionValue(HText *text, char *value, } cp[j] = '\0'; if (IS_CJK_TTY) { - if (cp && - (tmp = typecallocn(unsigned char, strlen(cp) * 2 + 1)) != 0) { - if (tmp == NULL) - outofmem(__FILE__, "HText_setLastOptionValue"); + if ((tmp = typecallocn(unsigned char, strlen(cp) * 2 + 1)) != 0) { if (kanji_code == EUC) { TO_EUC((unsigned char *) cp, tmp); val_cs = current_char_set; @@ -9906,6 +9899,8 @@ char *HText_setLastOptionValue(HText *text, char *value, } StrAllocCopy(new_ptr->name, (const char *) tmp); FREE(tmp); + } else { + outofmem(__FILE__, "HText_setLastOptionValue"); } } else { StrAllocCopy(new_ptr->name, cp); @@ -12564,12 +12559,17 @@ static int increment_tagged_htline(HTLine *ht, TextAnchor *a, int *lx_val, && (n + post_n + 2) < MAX_LINE) { val = atoi(lx); if ((val == *old_val) || (*old_val == 0)) { + const char *r; + if (*old_val != 0) (*old_val)++; val += incr; sprintf(lx, "%d", val); new_n = (int) strlen(lx); - strcat(lx, strchr(ht->next->data, ']')); + if ((r = strchr(ht->next->data, ']')) == 0) { + r = ""; + } + strcat(lx, r); /* * We keep the the same number of chars from the @@ -12959,10 +12959,13 @@ static char *readEditedFile(char *ed_temp) } assert(ebuf != NULL); - fp = fopen(ed_temp, "r"); - size = fread(ebuf, (size_t) 1, size, fp); - LYCloseInput(fp); - ebuf[size] = '\0'; /* Terminate! - kw */ + if ((fp = fopen(ed_temp, "r")) != 0) { + size = fread(ebuf, (size_t) 1, size, fp); + LYCloseInput(fp); + ebuf[size] = '\0'; /* Terminate! - kw */ + } else { + size = 0; + } } /* @@ -13225,76 +13228,73 @@ int HText_EditTextArea(LinkInfo * form_link) int start_line = 0; int entry_line = form_link->anchor_line_num; int orig_cnt = 0; - int offset; + int offset = 0; FormInfo *form = form_link->l_form; CTRACE((tfp, "GridText: entered HText_EditTextArea()\n")); - ed_temp = typeMallocn(char, LY_MAXPATH); + if ((ed_temp = typeMallocn(char, LY_MAXPATH)) == 0) { + outofmem(__FILE__, "HText_EditTextArea"); + } else if ((fp = LYOpenTemp(ed_temp, "", "w")) != 0) { - if ((fp = LYOpenTemp(ed_temp, "", "w")) == 0) { - FREE(ed_temp); - return (0); - } - - /* - * Begin at the beginning, to find 1st anchor in the TEXTAREA, then - * write all of its lines (anchors) out to the edit temp file. - */ - anchor_ptr = HTMainText->first_anchor; + /* + * Begin at the beginning, to find 1st anchor in the TEXTAREA, then + * write all of its lines (anchors) out to the edit temp file. + */ + anchor_ptr = HTMainText->first_anchor; - while (anchor_ptr) { + while (anchor_ptr) { - if (IsFormsTextarea(form, anchor_ptr)) { + if (IsFormsTextarea(form, anchor_ptr)) { - if (firstanchor) { - firstanchor = FALSE; - start_anchor = anchor_ptr; - start_line = anchor_ptr->line_num; - } - orig_cnt++; + if (firstanchor) { + firstanchor = FALSE; + start_anchor = anchor_ptr; + start_line = anchor_ptr->line_num; + } + orig_cnt++; - /* - * Write the anchors' text to the temp edit file. - */ - fputs(anchor_ptr->input_field->value, fp); - fputc('\n', fp); + /* + * Write the anchors' text to the temp edit file. + */ + fputs(anchor_ptr->input_field->value, fp); + fputc('\n', fp); - } else { + } else { - if (!firstanchor) - break; + if (!firstanchor) + break; + } + anchor_ptr = anchor_ptr->next; } - anchor_ptr = anchor_ptr->next; - } - LYCloseTempFP(fp); - - CTRACE((tfp, "GridText: TEXTAREA name=|%s| dumped to tempfile\n", form->name)); - CTRACE((tfp, "GridText: invoking editor (%s) on tempfile\n", editor)); + LYCloseTempFP(fp); - /* - * Go edit the TEXTAREA temp file, with the initial editor line - * corresponding to the TEXTAREA line the cursor is on (if such - * positioning is supported by the editor [as lynx knows it]). - */ - ed_offset[0] = 0; /* pre-ANSI compilers don't initialize aggregates - TD */ - if (((entry_line - start_line) > 0) && editor_can_position()) - sprintf(ed_offset, "%d", ((entry_line - start_line) + 1)); + if (start_anchor != 0) { + CTRACE((tfp, "GridText: TEXTAREA name=|%s| dumped to tempfile\n", form->name)); + CTRACE((tfp, "GridText: invoking editor (%s) on tempfile\n", editor)); - edit_temporary_file(ed_temp, ed_offset, NULL); + /* + * Go edit the TEXTAREA temp file, with the initial editor line + * corresponding to the TEXTAREA line the cursor is on (if such + * positioning is supported by the editor [as lynx knows it]). + */ + ed_offset[0] = 0; /* pre-ANSI compilers don't initialize aggregates - TD */ + if (((entry_line - start_line) > 0) && editor_can_position()) + sprintf(ed_offset, "%d", ((entry_line - start_line) + 1)); - CTRACE((tfp, "GridText: returned from editor (%s)\n", editor)); + edit_temporary_file(ed_temp, ed_offset, NULL); - if (form->disabled) - offset = 0; - else - offset = finish_ExtEditForm(form_link, start_anchor, ed_temp, orig_cnt); + CTRACE((tfp, "GridText: returned from editor (%s)\n", editor)); - LYRemoveTemp(ed_temp); - FREE(ed_temp); + if (!form->disabled) + offset = finish_ExtEditForm(form_link, start_anchor, ed_temp, orig_cnt); - CTRACE((tfp, "GridText: exiting HText_EditTextArea()\n")); + CTRACE((tfp, "GridText: exiting HText_EditTextArea()\n")); + } + LYRemoveTemp(ed_temp); + FREE(ed_temp); + } /* * Return the offset needed to move the cursor from its current diff --git a/src/HTInit.c b/src/HTInit.c index 4989be12..6dbed814 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTInit.c,v 1.77 2010/09/25 18:08:10 tom Exp $ + * $LynxId: HTInit.c,v 1.78 2013/01/04 21:44:57 tom Exp $ * * Configuration-specific Initialization HTInit.c * ---------------------------------------- @@ -698,7 +698,7 @@ static int BuildCommand(HTChunk *cmd, } break; case 's': - if (TmpFileLen && TmpFileName) { + if (TmpFileLen) { HTChunkPuts(cmd, TmpFileName); } break; diff --git a/src/HTML.c b/src/HTML.c index dae978c3..f6b8ead9 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTML.c,v 1.155 2012/02/10 18:36:39 tom Exp $ + * $LynxId: HTML.c,v 1.156 2013/04/30 22:13:50 tom Exp $ * * Structured stream to Rich hypertext converter * ============================================ @@ -689,7 +689,7 @@ void HTML_write(HTStructured * me, const char *s, int l) * request (doesn't have a URL from which the document can be retrieved * with GET), and can only be used from within that document. * - * *If DONT_TRACK_INTERNAL_LINKS is not defined, we keep track of whether a + * *If track_internal_links is true, we keep track of whether a * link destination was given as an internal link. This information is * recorded in the type of the link between anchor objects, and is available * to the HText object and the mainloop from there. URL References to @@ -705,7 +705,7 @@ void HTML_write(HTStructured * me, const char *s, int l) * e. HREF="" -> [...]/mypath/mydoc.htm (marked internal) * f. HREF="#frag" -> [...]/mypath/mydoc.htm#frag (marked internal) * - * *If DONT_TRACK_INTERNAL_LINKS is defined, URL-less URL-References are + * *If track_internal_links is false, URL-less URL-References are * resolved differently from URL-References with a non-empty URL (using the * current stream's retrieval address instead of the base), but we make no * further distinction. Resolution is then as in the examples above, execept diff --git a/src/LYBookmark.c b/src/LYBookmark.c index 0a448764..481533b9 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYBookmark.c,v 1.71 2012/02/09 13:01:39 tom Exp $ + * $LynxId: LYBookmark.c,v 1.72 2013/01/04 21:05:08 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -468,7 +468,6 @@ void remove_bookmark_link(int cur, #ifdef UNIX struct stat stat_buf; - mode_t mode; BOOLEAN regular = FALSE; #endif /* UNIX */ #endif /* VMS */ @@ -500,8 +499,7 @@ void remove_bookmark_link(int cur, */ if (stat(filename_buffer, &stat_buf) == 0) { regular = (BOOLEAN) (S_ISREG(stat_buf.st_mode) && stat_buf.st_nlink == 1); - mode = ((stat_buf.st_mode & HIDE_CHMOD) | 0600); /* make it writable */ - (void) chmod(newfile, mode); + (void) chmod(newfile, HIDE_CHMOD); if ((nfp = LYReopenTemp(newfile)) == NULL) { (void) LYCloseInput(fp); HTAlert(BOOKTEMP_REOPEN_FAIL_FOR_DEL); diff --git a/src/LYCgi.c b/src/LYCgi.c index 832bb89f..d65f7827 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCgi.c,v 1.64 2011/06/11 12:35:20 tom Exp $ + * $LynxId: LYCgi.c,v 1.65 2013/01/04 09:44:59 tom Exp $ * Lynx CGI support LYCgi.c * ================ * @@ -220,7 +220,7 @@ static int LYLoadCGI(const char *arg, } StrAllocCopy(orig_pgm, pgm); - if ((cp = trimPoundSelector(pgm)) != NULL) { + if (trimPoundSelector(pgm) != NULL) { /* * Strip a #fragment from path. In this case any pgm_args found above * will also be bogus, since the '?' came after the '#' and is part of diff --git a/src/LYCharSets.c b/src/LYCharSets.c index f3114ac4..47623479 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharSets.c,v 1.67 2012/02/10 18:43:40 tom Exp $ + * $LynxId: LYCharSets.c,v 1.68 2013/01/04 21:47:16 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> @@ -712,10 +712,10 @@ int UCGetLYhndl_byAnyName(char *value) { int i; - LYTrimTrailing(value); if (value == NULL) return -1; + LYTrimTrailing(value); CTRACE((tfp, "UCGetLYhndl_byAnyName(%s)\n", value)); /* search by name */ diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 6ef515cc..42e86003 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCharUtils.c,v 1.117 2012/02/10 18:36:39 tom Exp $ + * $LynxId: LYCharUtils.c,v 1.118 2013/04/30 22:16:02 tom Exp $ * * Functions associated with LYCharSets.c and the Lynx version of HTML.c - FM * ========================================================================== @@ -2457,15 +2457,14 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, * Check for an anchor in http or https URLs. - FM */ cp = NULL; -#ifndef DONT_TRACK_INTERNAL_LINKS /* id_string seems to be used wrong below if given. not that it matters much. avoid setting it here. - kw */ - if ((StrNCmp(href, "http", 4) == 0) && + if (track_internal_links && + (StrNCmp(href, "http", 4) == 0) && (cp = strchr(href, '#')) != NULL) { StrAllocCopy(id_string, cp); *cp = '\0'; } -#endif if (me->inA) { /* * Ugh! The META tag, which is a HEAD element, is in an diff --git a/src/LYCurses.c b/src/LYCurses.c index c4575ff3..17bd2169 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.c,v 1.164 2012/02/10 18:22:15 tom Exp $ */ +/* $LynxId: LYCurses.c,v 1.168 2013/05/01 00:07:08 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -448,18 +448,29 @@ void curses_w_style(WINDOW * win, int style, #endif int YP, XP; + bucket *ds; + BOOL free_ds = TRUE; -#if !OMIT_SCN_KEEPING - bucket *ds = (style == NOSTYLE ? nostyle_bucket() : &hashStyles[style]); - -#else - bucket *ds = (style == NOSTYLE ? &nostyle_bucket : - (style == SPECIAL_STYLE ? special_bucket() : &hashStyles[style])); + switch (style) { +#if OMIT_SCN_KEEPING + case SPECIAL_STYLE: + ds = special_bucket(); + break; #endif + case NOSTYLE: + ds = nostyle_bucket(); + break; + default: + ds = &hashStyles[style]; + free_ds = FALSE; + break; + } if (!ds->name) { CTRACE2(TRACE_STYLE, (tfp, "CSS.CS:Style %d not configured\n", style)); #if !OMIT_SCN_KEEPING + if (free_ds) + free(ds); return; #endif } @@ -474,6 +485,8 @@ void curses_w_style(WINDOW * win, int style, LYAttrset(win, ds->color, ds->mono); if (win == LYwin) SetCachedStyle(YP, XP, (unsigned) s_normal); + if (free_ds) + free(ds); return; } @@ -524,6 +537,11 @@ void curses_w_style(WINDOW * win, int style, LYAttrset(win, ds->color, ds->mono); break; } + + if (free_ds) + free(ds); + + return; } /* @@ -775,7 +793,8 @@ static void lynx_map_color(int n) CTRACE((tfp, "lynx_map_color(%d)\n", n)); - if (n + 1 < (int) TABLESIZE(lynx_color_pairs)) { + if (n + 1 < (int) TABLESIZE(lynx_color_pairs) + && n < (int) TABLESIZE(lynx_color_cfg)) { for (j = n + 1; j < COLOR_PAIRS_MAX; j += COLOR_CFG_MAX) { lynx_color_pairs[j].fg = lynx_color_cfg[n].fg; lynx_color_pairs[j].bg = lynx_color_cfg[n].bg; @@ -2140,6 +2159,8 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED, && (LYshiftWin == 0) && LYwideLines == FALSE && ((int) len > (LYcolLimit - x0)) + && (y0 >= 0) + && (x0 >= 0) && (x0 < LYcolLimit)) { WINDOW *sub = derwin(LYwin, LYlines, LYcolLimit, 0, 0); @@ -2860,6 +2881,10 @@ void LYrefresh(void) int y, x; getyx(LYwin, y, x); + if (y < 0) + y = 0; + if (x < 0) + x = 0; if (x > LYcolLimit) x = LYcolLimit; wmove(stdscr, y, x); diff --git a/src/LYEditmap.c b/src/LYEditmap.c index 7e748748..669c2a38 100644 --- a/src/LYEditmap.c +++ b/src/LYEditmap.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYEditmap.c,v 1.28 2011/05/28 13:07:55 tom Exp $ + * $LynxId: LYEditmap.c,v 1.29 2013/01/04 00:03:24 tom Exp $ * * LYEditMap.c * Keybindings for line and form editting. @@ -282,7 +282,7 @@ LYE_NOP, LYE_NOP, LYE_NOP, LYE_NOP, /* Why the difference for tab? - kw */ #ifdef USE_ALT_BINDINGS -static LYEditCode BetterEditBinding[KEYMAP_SIZE-1]={ +static LYEditCode BetterEditBinding[KEYMAP_SIZE - 1]={ LYE_NOP, LYE_BOL, LYE_BACK, LYE_ABORT, /* nul ^A ^B ^C */ @@ -540,7 +540,7 @@ LYE_NOP, LYE_NOP, LYE_NOP, LYE_NOP, /* M-bs,M-del=delete-prev-word, M-d=delete-next-word, */ /* M-b=BACKW, M-f=FORWW, */ -static LYEditCode BashlikeEditBinding[KEYMAP_SIZE-1]={ +static LYEditCode BashlikeEditBinding[KEYMAP_SIZE - 1] = { LYE_SETMARK, LYE_BOL, LYE_BACK, LYE_ABORT, /* nul ^A ^B ^C */ diff --git a/src/LYExtern.c b/src/LYExtern.c index bbd0d545..3f636f51 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYExtern.c,v 1.50 2012/08/15 23:16:22 tom Exp $ + * $LynxId: LYExtern.c,v 1.51 2013/01/04 09:30:03 tom Exp $ * External application support. This feature allows lynx to pass a given URL to an external program. @@ -311,9 +311,23 @@ static char *lookup_external(char *param, } FREE(choices[pass]); } + } + + if (actions) { + for (pass = 0; actions[pass] != 0; ++pass) { + if (actions[pass] != cmdbuf) + FREE(actions[pass]); + } FREE(actions); + } + + if (choices) { + for (pass = 0; choices[pass] != 0; ++pass) { + FREE(choices[pass]); + } FREE(choices); } + return cmdbuf; } diff --git a/src/LYForms.c b/src/LYForms.c index 10640fa5..75492637 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -1,4 +1,4 @@ -/* $LynxId: LYForms.c,v 1.98 2012/02/12 17:40:17 tom Exp $ */ +/* $LynxId: LYForms.c,v 1.101 2013/01/04 21:50:03 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <HTTP.h> @@ -65,8 +65,8 @@ int change_form_link_ex(int cur, int redraw_only) { FormInfo *form = links[cur].l_form; - char *link_name = form->name; - char *link_value = form->value; + char *link_name; + char *link_value; int newdoc_changed = 0; int c = DO_NOTHING; int title_adjust = (no_title ? -TITLE_LINES : 0); @@ -78,6 +78,8 @@ int change_form_link_ex(int cur, if (form == NULL) { return (c); } + link_name = form->name; + link_value = form->value; my_data = options_list(form->select_list); /* @@ -758,17 +760,23 @@ static int form_getstr(int cur, so we deduce it ourselves. We don't have the info to do it inside LYLineEdit(). This should work for prompts too. */ - if ((action != LYE_BACK_LL && action != LYE_FORW_RL) - || (cur >= 0 - && cur < nlinks - && (action == LYE_FORW_RL - ? cur < nlinks - 1 - : cur > 0) - && links[cur + ((action == LYE_FORW_RL) - ? 1 - : -1)].ly - == links[cur].ly)) + switch (action) { + case LYE_BACK_LL: + if (cur > 0 + && links[cur - 1].ly == links[cur].ly) { + goto breakfor; + } + break; + case LYE_FORW_RL: + if (cur >= 0 + && cur < nlinks - 1 + && links[cur + 1].ly == links[cur].ly) { + goto breakfor; + } + break; + default: goto breakfor; + } } #ifdef SUPPORT_MULTIBYTE_EDIT if (rc == 0) { diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 2c6ebe1a..c979b5f9 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -1,4 +1,4 @@ -/* $LynxId: LYGetFile.c,v 1.87 2012/02/08 21:01:03 tom Exp $ */ +/* $LynxId: LYGetFile.c,v 1.89 2013/05/01 00:21:02 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> #include <HTAnchor.h> /* Anchor class */ @@ -430,12 +430,9 @@ int getfile(DocInfo *doc, int *target) WWWDoc.bookmark = doc->bookmark; WWWDoc.isHEAD = doc->isHEAD; WWWDoc.safe = doc->safe; -#ifndef DONT_TRACK_INTERNAL_LINKS - if (doc->internal_link && !reloading) { + if (track_internal_links && doc->internal_link && !reloading) { LYinternal_flag = TRUE; } -#endif - #ifdef DIRED_SUPPORT lynx_edit_mode = FALSE; #endif /* DIRED_SUPPORT */ @@ -1519,8 +1516,10 @@ static int fix_httplike_urls(DocInfo *doc, UrlTypes type) char *second = strchr(first, ':'); CTRACE((tfp, "fix_httplike_urls: URL '%s'\n", doc->address)); - - *second++ = '\0'; + if (second == 0) + second = first + strlen(first); + else + *second++ = '\0'; HTSprintf0(&path, "%s//%s%s", STR_FTP_URL, first, second); FREE(doc->address); doc->address = path; diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 1fe79b0d..d448a878 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYGlobalDefs.h,v 1.133 2012/11/14 01:09:44 tom Exp $ + * $LynxId: LYGlobalDefs.h,v 1.134 2013/04/30 09:51:46 tom Exp $ * * global variable definitions */ @@ -422,6 +422,7 @@ extern "C" { extern BOOLEAN LYRestricted; /* whether we had -anonymous option */ extern BOOLEAN LYValidate; extern BOOLEAN LYPermitURL; + extern BOOLEAN track_internal_links; extern BOOLEAN enable_scrollback; /* Clear screen before displaying new page */ extern BOOLEAN keep_mime_headers; /* Include mime headers and * diff --git a/src/LYHistory.c b/src/LYHistory.c index a1b6a092..32e6b3c7 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYHistory.c,v 1.84 2011/06/11 12:36:10 tom Exp $ + * $LynxId: LYHistory.c,v 1.85 2013/04/30 22:20:30 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -762,12 +762,12 @@ BOOLEAN historytarget(DocInfo *newdoc) HDOC(nhist - 1).internal_link && number == history[nhist - 1].intern_seq_start)) && !(LYforce_no_cache == TRUE && LYoverride_no_cache == FALSE)) { -#ifndef DONT_TRACK_INTERNAL_LINKS - LYforce_no_cache = FALSE; - LYinternal_flag = TRUE; - newdoc->internal_link = TRUE; - treat_as_intern = TRUE; -#endif + if (track_internal_links) { + LYforce_no_cache = FALSE; + LYinternal_flag = TRUE; + newdoc->internal_link = TRUE; + treat_as_intern = TRUE; + } } else { newdoc->internal_link = FALSE; } diff --git a/src/LYJump.c b/src/LYJump.c index 10cd50b6..96df697f 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYJump.c,v 1.43 2012/02/09 13:02:30 tom Exp $ + * $LynxId: LYJump.c,v 1.45 2013/01/05 00:28:46 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -422,6 +422,7 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp) if (read(fd, mp, (size_t) st.st_size) < st.st_size) { HTAlert(ERROR_READING_JUMP_FILE); FREE(mp); + close(fd); return 0; } mp[st.st_size] = '\0'; @@ -432,12 +433,15 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp) if (fgets(mp, blocksize, fp) == NULL) { HTAlert(ERROR_READING_JUMP_FILE); FREE(mp); + close(fd); return 0; - } else + } else { while (fgets(mp + strlen(mp), blocksize, fp) != NULL) { ; } + } LYCloseInput(fp); + close(fd); } #endif /* VMS */ @@ -492,8 +496,6 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp) CTRACE((tfp, "Read jumpfile[%u] key='%s', url='%s'\n", i, jtp->table[i].key, jtp->table[i].url)); i++; - if (!cp) - break; } return i; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 5c708aa4..a1b522e9 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,4 @@ -/* $LynxId: LYKeymap.c,v 1.83 2012/02/12 18:35:32 tom Exp $ */ +/* $LynxId: LYKeymap.c,v 1.84 2013/01/04 00:04:03 tom Exp $ */ #include <HTUtils.h> #include <LYUtils.h> #include <LYGlobalDefs.h> @@ -1802,7 +1802,7 @@ char *key_for_func_ext(int lac, BOOLEAN LYisNonAlnumKeyname(int ch, int KeyName) { - if (ch < 0 || ch >= KEYMAP_SIZE) + if (ch < 0 || (ch + 1) >= KEYMAP_SIZE) return (FALSE); if (ch > 0 && strchr("0123456789\ diff --git a/src/LYList.c b/src/LYList.c index 5cd12a45..ff0b5e0c 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYList.c,v 1.50 2011/05/28 13:05:14 tom Exp $ + * $LynxId: LYList.c,v 1.51 2013/04/30 22:09:43 tom Exp $ * * Lynx Document Reference List Support LYList.c * ==================================== @@ -131,11 +131,11 @@ int showlist(DocInfo *newdoc, int titles) cnt, cnt, desc); } } else if (value >= result) { -#ifndef DONT_TRACK_INTERNAL_LINKS - dest_intl = HTAnchor_followTypedLink(child, HTInternalLink); -#endif - dest = dest_intl ? - dest_intl : HTAnchor_followLink(child); + if (track_internal_links) + dest_intl = HTAnchor_followTypedLink(child, HTInternalLink); + dest = (dest_intl + ? dest_intl + : HTAnchor_followLink(child)); parent = HTAnchor_parent(dest); if (!intern_w_post && dest_intl && HTMainAnchor && diff --git a/src/LYLocal.c b/src/LYLocal.c index 54d43c85..3cfd5d0c 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYLocal.c,v 1.119 2012/11/18 22:25:54 tom Exp $ + * $LynxId: LYLocal.c,v 1.123 2013/04/30 08:51:14 tom Exp $ * * Routines to manipulate the local filesystem. * Written by: Rick Mallett, Carleton University @@ -2045,7 +2045,7 @@ int dired_options(DocInfo *doc, char **newfile) { static char tempfile[LY_MAXPATH]; const char *my_suffix; - char *path; + char *path = NULL; char *dir; lynx_list_item_type *nxt; struct stat dir_info; @@ -2497,6 +2497,7 @@ void add_menu_item(char *str) { struct dired_menu *tmp, *mp; char *cp; + BOOL used = FALSE; /* * First custom menu definition causes entire default menu to be discarded. @@ -2514,48 +2515,60 @@ void add_menu_item(char *str) /* * Conditional on tagged != NULL ? */ - cp = strchr(str, ':'); - *cp++ = '\0'; - if (strcasecomp(str, "tag") == 0) { - tmp->cond = DE_TAG; - } else if (strcasecomp(str, "dir") == 0) { - tmp->cond = DE_DIR; - } else if (strcasecomp(str, "file") == 0) { - tmp->cond = DE_FILE; + if ((cp = strchr(str, ':')) != 0) { + *cp++ = '\0'; + if (strcasecomp(str, "tag") == 0) { + tmp->cond = DE_TAG; + } else if (strcasecomp(str, "dir") == 0) { + tmp->cond = DE_DIR; + } else if (strcasecomp(str, "file") == 0) { + tmp->cond = DE_FILE; #ifdef S_IFLNK - } else if (strcasecomp(str, "link") == 0) { - tmp->cond = DE_SYMLINK; + } else if (strcasecomp(str, "link") == 0) { + tmp->cond = DE_SYMLINK; #endif /* S_IFLNK */ - } + } - /* - * Conditional on matching suffix. - */ - str = cp; - cp = strchr(str, ':'); - *cp++ = '\0'; - StrAllocCopy(tmp->sfx, str); - - str = cp; - cp = strchr(str, ':'); - *cp++ = '\0'; - StrAllocCopy(tmp->link, str); - - str = cp; - cp = strchr(str, ':'); - *cp++ = '\0'; - StrAllocCopy(tmp->rest, str); - - StrAllocCopy(tmp->href, cp); - - if (menu_head) { - for (mp = menu_head; mp && mp->next != NULL; mp = mp->next) { - ; - } - if (mp != NULL) - mp->next = tmp; - } else - menu_head = tmp; + /* + * Conditional on matching suffix. + */ + str = cp; + if ((cp = strchr(str, ':')) != 0) { + *cp++ = '\0'; + StrAllocCopy(tmp->sfx, str); + + str = cp; + if ((cp = strchr(str, ':')) != 0) { + *cp++ = '\0'; + StrAllocCopy(tmp->link, str); + + str = cp; + if ((cp = strchr(str, ':')) != 0) { + *cp++ = '\0'; + StrAllocCopy(tmp->rest, str); + + StrAllocCopy(tmp->href, cp); + + if (menu_head) { + for (mp = menu_head; + mp && mp->next != NULL; + mp = mp->next) { + ; + } + if (mp != NULL) { + mp->next = tmp; + used = TRUE; + } + } else { + menu_head = tmp; + used = TRUE; + } + } + } + } + } + if (!used) + FREE(tmp); } void reset_dired_menu(void) diff --git a/src/LYMain.c b/src/LYMain.c index 9528be2f..75e84d63 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMain.c,v 1.238 2012/08/05 01:03:03 tom Exp $ + * $LynxId: LYMain.c,v 1.240 2013/04/30 09:52:15 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -151,6 +151,13 @@ LOCAL_EXECUTION_LINKS_ON_BUT_NOT_REMOTE; char *LYCgiDocumentRoot = NULL; /* DOCUMENT_ROOT in the lynxcgi env */ #endif /* LYNXCGI_LINKS */ +#ifdef TRACK_INTERNAL_LINKS +BOOLEAN track_internal_links = TRUE; + +#else +BOOLEAN track_internal_links = FALSE; +#endif + #ifdef REVERSE_CLEAR_SCREEN_PROBLEM BOOLEAN enable_scrollback = TRUE; @@ -4251,7 +4258,9 @@ static BOOL parse_arg(char **argv, */ if (*arg_name != '-' #if EXTENDED_OPTION_LOGIC - || (no_options_further == TRUE && nof_index < (*countp)) + || ((no_options_further == TRUE) + && (countp != 0) + && (nof_index < (*countp))) #endif ) { #if EXTENDED_STARTFILE_RECALL diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 0584f9a5..5521ed6b 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMainLoop.c,v 1.211 2012/08/15 23:18:03 tom Exp $ + * $LynxId: LYMainLoop.c,v 1.215 2013/04/30 22:39:19 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -148,14 +148,13 @@ static void set_ws_title(char *str) HTLinkType *HTInternalLink = 0; HTAtom *WWW_SOURCE = 0; -#ifndef DONT_TRACK_INTERNAL_LINKS -#define NO_INTERNAL_OR_DIFFERENT(c,n) TRUE -#define NONINTERNAL_OR_PHYS_DIFFERENT(p,n) (!curdoc.internal_link || \ - are_phys_different(p,n)) -#else /* TRACK_INTERNAL_LINKS */ -#define NO_INTERNAL_OR_DIFFERENT(c,n) are_different(c,n) -#define NONINTERNAL_OR_PHYS_DIFFERENT(p,n) are_different(p,n) -#endif /* TRACK_INTERNAL_LINKS */ +#define NONINTERNAL_OR_PHYS_DIFFERENT(p,n) \ + ((track_internal_links && \ + (!curdoc.internal_link || are_phys_different(p,n))) || \ + are_different(p,n)) + +#define NO_INTERNAL_OR_DIFFERENT(c,n) \ + (track_internal_links || are_different(c,n)) static void exit_immediately_with_error_message(int state, int first_file); static void status_link(char *curlink_name, int show_more, int show_indx); @@ -163,9 +162,7 @@ static void show_main_statusline(const LinkInfo curlink, int for_what); static void form_noviceline(int); static int are_different(DocInfo *doc1, DocInfo *doc2); -#ifndef DONT_TRACK_INTERNAL_LINKS static int are_phys_different(DocInfo *doc1, DocInfo *doc2); -#endif #define FASTTAB @@ -991,7 +988,6 @@ static int DoTraversal(int c, return c; } -#ifndef DONT_TRACK_INTERNAL_LINKS static BOOLEAN check_history(void) { const char *base; @@ -1026,7 +1022,6 @@ static BOOLEAN check_history(void) } return FALSE; } -#endif static int handle_LYK_ACTIVATE(int *c, int cmd GCC_UNUSED, @@ -1346,7 +1341,6 @@ static int handle_LYK_ACTIVATE(int *c, */ set_address(&newdoc, links[curdoc.link].lname); StrAllocCopy(newdoc.title, LYGetHiliteStr(curdoc.link, 0)); -#ifndef DONT_TRACK_INTERNAL_LINKS /* * For internal links, retain POST content if present. If we are * on the List Page, prevent pushing it on the history stack. @@ -1354,86 +1348,87 @@ static int handle_LYK_ACTIVATE(int *c, * should attempt to reposition directly, without calling getfile. * - kw */ - /* - * Might be an internal link anchor in the same doc. If so, take - * the try_internal shortcut if we didn't fall through from - * LYK_NOCACHE. - kw - */ - newdoc.internal_link = - (links[curdoc.link].type == WWW_INTERN_LINK_TYPE); - if (newdoc.internal_link) { + if (track_internal_links) { /* - * Special case of List Page document with an internal link - * indication, which may really stand for an internal link - * within the document the List Page is about. - kw + * Might be an internal link anchor in the same doc. If so, take + * the try_internal shortcut if we didn't fall through from + * LYK_NOCACHE. - kw */ - if (LYIsListpageTitle(NonNull(curdoc.title)) && - (LYIsUIPage(curdoc.address, UIP_LIST_PAGE) || - LYIsUIPage(curdoc.address, UIP_ADDRLIST_PAGE))) { - if (check_history()) { - LYinternal_flag = TRUE; - } else { - HTLastConfirmCancelled(); /* reset flag */ - if (!confirm_post_resub(newdoc.address, - newdoc.title, - ((LYresubmit_posts && - HText_POSTReplyLoaded(&newdoc)) - ? 1 - : 2), - 2)) { - if (HTLastConfirmCancelled() || - (LYresubmit_posts && - cmd != LYK_NOCACHE && - !HText_POSTReplyLoaded(&newdoc))) { - /* cancel the whole thing */ - LYforce_no_cache = FALSE; - reloading = FALSE; - copy_address(&newdoc, &curdoc); - StrAllocCopy(newdoc.title, curdoc.title); - newdoc.internal_link = curdoc.internal_link; - HTInfoMsg(CANCELLED); - return 1; - } else if (LYresubmit_posts && - cmd != LYK_NOCACHE) { - /* If LYresubmit_posts is set, and the - answer was No, and the key wasn't - NOCACHE, and we have a cached copy, - then use it. - kw */ - LYforce_no_cache = FALSE; - } else { - /* if No, but not ^C or ^G, drop - * the post data. Maybe the link - * wasn't meant to be internal after - * all, here we can recover from that - * assumption. - kw */ - LYFreePostData(&newdoc); - newdoc.internal_link = FALSE; - HTAlert(DISCARDING_POST_DATA); + newdoc.internal_link = + (links[curdoc.link].type == WWW_INTERN_LINK_TYPE); + if (newdoc.internal_link) { + /* + * Special case of List Page document with an internal link + * indication, which may really stand for an internal link + * within the document the List Page is about. - kw + */ + if (LYIsListpageTitle(NonNull(curdoc.title)) && + (LYIsUIPage(curdoc.address, UIP_LIST_PAGE) || + LYIsUIPage(curdoc.address, UIP_ADDRLIST_PAGE))) { + if (check_history()) { + LYinternal_flag = TRUE; + } else { + HTLastConfirmCancelled(); /* reset flag */ + if (!confirm_post_resub(newdoc.address, + newdoc.title, + ((LYresubmit_posts && + HText_POSTReplyLoaded(&newdoc)) + ? 1 + : 2), + 2)) { + if (HTLastConfirmCancelled() || + (LYresubmit_posts && + cmd != LYK_NOCACHE && + !HText_POSTReplyLoaded(&newdoc))) { + /* cancel the whole thing */ + LYforce_no_cache = FALSE; + reloading = FALSE; + copy_address(&newdoc, &curdoc); + StrAllocCopy(newdoc.title, curdoc.title); + newdoc.internal_link = curdoc.internal_link; + HTInfoMsg(CANCELLED); + return 1; + } else if (LYresubmit_posts && + cmd != LYK_NOCACHE) { + /* If LYresubmit_posts is set, and the + answer was No, and the key wasn't + NOCACHE, and we have a cached copy, + then use it. - kw */ + LYforce_no_cache = FALSE; + } else { + /* if No, but not ^C or ^G, drop + * the post data. Maybe the link + * wasn't meant to be internal after + * all, here we can recover from that + * assumption. - kw */ + LYFreePostData(&newdoc); + newdoc.internal_link = FALSE; + HTAlert(DISCARDING_POST_DATA); + } } } + /* + * Don't push the List Page if we follow an internal link + * given by it. - kw + */ + free_address(&curdoc); + } else if (cmd != LYK_NOCACHE) { + *try_internal = TRUE; } + if (!(LYresubmit_posts && newdoc.post_data)) + LYinternal_flag = TRUE; + /* We still set force_load so that history pushing + * etc. will be done. - kw + */ + *force_load = TRUE; + return 1; + } else { /* - * Don't push the List Page if we follow an internal link - * given by it. - kw + * Free POST content if not an internal link. - kw */ - free_address(&curdoc); - } else if (cmd != LYK_NOCACHE) { - *try_internal = TRUE; + LYFreePostData(&newdoc); } - if (!(LYresubmit_posts && newdoc.post_data)) - LYinternal_flag = TRUE; - /* We still set force_load so that history pushing - * etc. will be done. - kw - */ - *force_load = TRUE; - return 1; - } else { - /* - * Free POST content if not an internal link. - kw - */ - LYFreePostData(&newdoc); } -#endif /* TRACK_INTERNAL_LINKS */ /* * Might be an anchor in the same doc from a POST form. If so, * don't free the content. -- FM @@ -2322,24 +2317,28 @@ static int handle_LYK_DOWNLOAD(int *cmd, */ set_address(&newdoc, links[curdoc.link].lname); StrAllocCopy(newdoc.title, LYGetHiliteStr(curdoc.link, 0)); -#ifndef DONT_TRACK_INTERNAL_LINKS /* * Might be an internal link in the same doc from a POST form. If * so, don't free the content. - kw */ - if (links[curdoc.link].type != WWW_INTERN_LINK_TYPE) -#else - /* - * Might be an anchor in the same doc from a POST form. If so, - * don't free the content. -- FM - */ - if (are_different(&curdoc, &newdoc)) -#endif /* TRACK_INTERNAL_LINKS */ - { - LYFreePostData(&newdoc); - FREE(newdoc.bookmark); - newdoc.isHEAD = FALSE; - newdoc.safe = FALSE; + if (track_internal_links) { + if (links[curdoc.link].type != WWW_INTERN_LINK_TYPE) { + LYFreePostData(&newdoc); + FREE(newdoc.bookmark); + newdoc.isHEAD = FALSE; + newdoc.safe = FALSE; + } + } else { + /* + * Might be an anchor in the same doc from a POST form. If so, + * don't free the content. -- FM + */ + if (are_different(&curdoc, &newdoc)) { + LYFreePostData(&newdoc); + FREE(newdoc.bookmark); + newdoc.isHEAD = FALSE; + newdoc.safe = FALSE; + } } newdoc.internal_link = FALSE; newdoc.link = (user_mode == NOVICE_MODE) ? 1 : 0; @@ -3515,7 +3514,7 @@ static char *urlencode(char *str) char *ptr; int ch; - if (non_empty(str)) { + if (str != NULL) { result = malloc(strlen(str) * 3 + 1); ptr = result; @@ -3564,6 +3563,10 @@ static BOOLEAN check_JUMP_param(char **url_template) sprintf(prompt, gettext("Query parameter %d: "), param++); statusline(prompt); BStrCopy0(input, ""); + + if (encoded) + FREE(encoded); + if (LYgetBString(&input, VISIBLE, 0, recall) < 0) { /* * cancelled via ^G @@ -5082,78 +5085,78 @@ static void handle_LYK_digit(int c, */ set_address(&newdoc, links[lindx].lname); StrAllocCopy(newdoc.title, LYGetHiliteStr(lindx, 0)); -#ifndef DONT_TRACK_INTERNAL_LINKS /* * For internal links, retain POST content if present. If we are on * the List Page, prevent pushing it on the history stack. Otherwise * set try_internal to signal that the top of the loop should attempt * to reposition directly, without calling getfile. - kw */ - if (links[lindx].type == WWW_INTERN_LINK_TYPE) { - LYinternal_flag = TRUE; - newdoc.internal_link = TRUE; - if (LYIsListpageTitle(NonNull(curdoc.title)) && - (LYIsUIPage(curdoc.address, UIP_LIST_PAGE) || - LYIsUIPage(curdoc.address, UIP_ADDRLIST_PAGE))) { - if (check_history()) { - LYinternal_flag = TRUE; - } else { - HTLastConfirmCancelled(); /* reset flag */ - if (!confirm_post_resub(newdoc.address, - newdoc.title, - ((LYresubmit_posts && - HText_POSTReplyLoaded(&newdoc)) - ? 1 - : 2), - 2)) { - if (HTLastConfirmCancelled() || - (LYresubmit_posts && - !HText_POSTReplyLoaded(&newdoc))) { - /* cancel the whole thing */ - LYforce_no_cache = FALSE; - reloading = FALSE; - copy_address(&newdoc, &curdoc); - StrAllocCopy(newdoc.title, curdoc.title); - newdoc.internal_link = curdoc.internal_link; - HTInfoMsg(CANCELLED); - if (nlinks > 0) - HText_pageDisplay(curdoc.line, prev_target->str); - break; - } else if (LYresubmit_posts) { - /* If LYresubmit_posts is set, and the - answer was No, and we have a cached - copy, then use it. - kw */ - LYforce_no_cache = FALSE; - } else { - /* if No, but not ^C or ^G, drop - * the post data. Maybe the link - * wasn't meant to be internal after - * all, here we can recover from that - * assumption. - kw */ - LYFreePostData(&newdoc); - newdoc.internal_link = FALSE; - HTAlert(DISCARDING_POST_DATA); + if (track_internal_links) { + if (links[lindx].type == WWW_INTERN_LINK_TYPE) { + LYinternal_flag = TRUE; + newdoc.internal_link = TRUE; + if (LYIsListpageTitle(NonNull(curdoc.title)) && + (LYIsUIPage(curdoc.address, UIP_LIST_PAGE) || + LYIsUIPage(curdoc.address, UIP_ADDRLIST_PAGE))) { + if (check_history()) { + LYinternal_flag = TRUE; + } else { + HTLastConfirmCancelled(); /* reset flag */ + if (!confirm_post_resub(newdoc.address, + newdoc.title, + ((LYresubmit_posts && + HText_POSTReplyLoaded(&newdoc)) + ? 1 + : 2), + 2)) { + if (HTLastConfirmCancelled() || + (LYresubmit_posts && + !HText_POSTReplyLoaded(&newdoc))) { + /* cancel the whole thing */ + LYforce_no_cache = FALSE; + reloading = FALSE; + copy_address(&newdoc, &curdoc); + StrAllocCopy(newdoc.title, curdoc.title); + newdoc.internal_link = curdoc.internal_link; + HTInfoMsg(CANCELLED); + if (nlinks > 0) + HText_pageDisplay(curdoc.line, prev_target->str); + break; + } else if (LYresubmit_posts) { + /* If LYresubmit_posts is set, and the + answer was No, and we have a cached + copy, then use it. - kw */ + LYforce_no_cache = FALSE; + } else { + /* if No, but not ^C or ^G, drop + * the post data. Maybe the link + * wasn't meant to be internal after + * all, here we can recover from that + * assumption. - kw */ + LYFreePostData(&newdoc); + newdoc.internal_link = FALSE; + HTAlert(DISCARDING_POST_DATA); + } } } - } + /* + * Don't push the List Page if we follow an internal link given + * by it. - kw + */ + free_address(&curdoc); + } else + *try_internal = TRUE; + if (!(LYresubmit_posts && newdoc.post_data)) + LYinternal_flag = TRUE; + *force_load = TRUE; + break; + } else { /* - * Don't push the List Page if we follow an internal link given - * by it. - kw + * Free POST content if not an internal link. - kw */ - free_address(&curdoc); - } else - *try_internal = TRUE; - if (!(LYresubmit_posts && newdoc.post_data)) - LYinternal_flag = TRUE; - *force_load = TRUE; - break; - } else { - /* - * Free POST content if not an internal link. - kw - */ - LYFreePostData(&newdoc); + LYFreePostData(&newdoc); + } } -#endif /* DONT_TRACK_INTERNAL_LINKS */ /* * Might be an anchor in the same doc from a POST form. If so, don't * free the content. -- FM @@ -5669,22 +5672,20 @@ int mainloop(void) LYhist_prev(&newdoc); popped_doc = TRUE; -#ifndef DONT_TRACK_INTERNAL_LINKS /* * If curdoc had been reached via an internal * (fragment) link from what we now have just * popped into newdoc, then override non-caching in * all cases. - kw */ - if (curdoc.internal_link && + if (track_internal_links && + curdoc.internal_link && !are_phys_different(&curdoc, &newdoc)) { LYinternal_flag = TRUE; LYoverride_no_cache = TRUE; LYforce_no_cache = FALSE; try_internal = TRUE; - } else -#endif /* TRACK_INTERNAL_LINKS */ - { + } else { /* * Force a no_cache override unless it's a bookmark file, * or it has POST content and LYresubmit_posts is set @@ -5792,51 +5793,62 @@ int mainloop(void) if (popped_doc) LYNoRefererForThis = TRUE; -#ifndef DONT_TRACK_INTERNAL_LINKS - if (try_internal) { - if (newdoc.address && - isLYNXIMGMAP(newdoc.address)) { - try_internal = FALSE; - } else if (curdoc.address && - isLYNXIMGMAP(curdoc.address)) { - try_internal = FALSE; + if (track_internal_links) { + if (try_internal) { + if (newdoc.address && + isLYNXIMGMAP(newdoc.address)) { + try_internal = FALSE; + } else if (curdoc.address && + isLYNXIMGMAP(curdoc.address)) { + try_internal = FALSE; + } } - } - if (try_internal) { - char *hashp = findPoundSelector(newdoc.address); + if (try_internal) { + char *hashp = findPoundSelector(newdoc.address); - if (hashp) { - HTFindPoundSelector(hashp + 1); - } - getresult = (HTMainText != NULL) ? NORMAL : NOT_FOUND; - try_internal = FALSE; /* done */ - /* fix up newdoc.address which may have been fragment-only */ - if (getresult == NORMAL && (!hashp || hashp == newdoc.address)) { - if (!hashp) { - set_address(&newdoc, HTLoadedDocumentURL()); + if (hashp) { + HTFindPoundSelector(hashp + 1); + } + getresult = (HTMainText != NULL) ? NORMAL : NOT_FOUND; + try_internal = FALSE; /* done */ + /* fix up newdoc.address which may have been fragment-only */ + if (getresult == NORMAL && (!hashp || hashp == newdoc.address)) { + if (!hashp) { + set_address(&newdoc, HTLoadedDocumentURL()); + } else { + StrAllocCopy(temp, HTLoadedDocumentURL()); + StrAllocCat(temp, hashp); /* append fragment */ + set_address(&newdoc, temp); + FREE(temp); + } + } + } else { + if (newdoc.internal_link && newdoc.address && + *newdoc.address == '#' && nhist > 0) { + char *cp0; + + if (isLYNXIMGMAP(HDOC(nhist_1).address)) + cp0 = HDOC(nhist_1).address + LEN_LYNXIMGMAP; + else + cp0 = HDOC(nhist_1).address; + StrAllocCopy(temp, cp0); + (void) trimPoundSelector(temp); + StrAllocCat(temp, newdoc.address); + free_address(&newdoc); + newdoc.address = temp; + temp = NULL; + } + tmpDocInfo = newdoc; + tmpNewline = -1; + fill_JUMP_Params(&newdoc.address); + getresult = getfile(&newdoc, &tmpNewline); + if (!reloading && !popped_doc && (tmpNewline >= 0)) { + LYSetNewline(tmpNewline); } else { - StrAllocCopy(temp, HTLoadedDocumentURL()); - StrAllocCat(temp, hashp); /* append fragment */ - set_address(&newdoc, temp); - FREE(temp); + newdoc.link = tmpDocInfo.link; } } } else { - if (newdoc.internal_link && newdoc.address && - *newdoc.address == '#' && nhist > 0) { - char *cp0; - - if (isLYNXIMGMAP(HDOC(nhist_1).address)) - cp0 = HDOC(nhist_1).address + LEN_LYNXIMGMAP; - else - cp0 = HDOC(nhist_1).address; - StrAllocCopy(temp, cp0); - (void) trimPoundSelector(temp); - StrAllocCat(temp, newdoc.address); - free_address(&newdoc); - newdoc.address = temp; - temp = NULL; - } tmpDocInfo = newdoc; tmpNewline = -1; fill_JUMP_Params(&newdoc.address); @@ -5847,17 +5859,6 @@ int mainloop(void) newdoc.link = tmpDocInfo.link; } } -#else /* TRACK_INTERNAL_LINKS */ - tmpDocInfo = newdoc; - tmpNewline = -1; - fill_JUMP_Params(&newdoc.address); - getresult = getfile(&newdoc, &tmpNewline); - if (!reloading && !popped_doc && (tmpNewline >= 0)) { - LYSetNewline(tmpNewline); - } else { - newdoc.link = tmpDocInfo.link; - } -#endif /* TRACK_INTERNAL_LINKS */ #ifdef INACTIVE_INPUT_STYLE_VH textinput_redrawn = FALSE; /* for sure */ @@ -7277,7 +7278,7 @@ int mainloop(void) } if (!nl2) { while (s1 < s) { - if (*s1 != '\r' && *s1 != '\r') + if (*s1 != '\r' && *s1 != '\n') *t = *s1; t++, s1++; } @@ -7782,7 +7783,6 @@ static int are_different(DocInfo *doc1, DocInfo *doc2) /* This determines whether two docs are _physically_ different, * meaning they are "from different files". - kw */ -#ifndef DONT_TRACK_INTERNAL_LINKS static int are_phys_different(DocInfo *doc1, DocInfo *doc2) { char *cp1, *cp2, *ap1 = doc1->address, *ap2 = doc2->address; @@ -7848,7 +7848,6 @@ static int are_phys_different(DocInfo *doc1, DocInfo *doc2) */ return (FALSE); } -#endif /* * Utility for freeing the list of goto URLs. - FM @@ -8075,18 +8074,20 @@ static void exit_immediately_with_error_message(int state, int first_file) if (!dump_output_immediately) cleanup(); + if (buf != 0) { #ifdef UNIX - if (dump_output_immediately) { - fputs(buf, stderr); - } else + if (dump_output_immediately) { + fputs(buf, stderr); + } else #endif /* UNIX */ - { - SetOutputMode(O_TEXT); - fputs(buf, stdout); - SetOutputMode(O_BINARY); - } + { + SetOutputMode(O_TEXT); + fputs(buf, stdout); + SetOutputMode(O_BINARY); + } - FREE(buf); + FREE(buf); + } if (!dump_output_immediately) { exit_immediately(EXIT_FAILURE); diff --git a/src/LYMap.c b/src/LYMap.c index b5965a8f..f15e68a2 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMap.c,v 1.43 2011/06/11 12:36:41 tom Exp $ + * $LynxId: LYMap.c,v 1.45 2013/04/30 23:16:59 tom Exp $ * Lynx Client-side Image MAP Support LYMap.c * ================================== * @@ -36,9 +36,7 @@ typedef struct _LYMapElement { char *address; char *title; -#ifndef DONT_TRACK_INTERNAL_LINKS - BOOL intern_flag; -#endif + BOOLEAN intern_flag; } LYMapElement; typedef struct _LYImageMap { @@ -110,7 +108,7 @@ static void LYLynxMaps_free(void) * and List Page screens are logically part of the document on which * they are based. - kw * - * If DONT_TRACK_INTERNAL_LINKS is defined, only the global list will be used + * If track_internal_links is false, only the global list will be used * for all MAPs. * */ @@ -142,8 +140,7 @@ BOOL LYAddImageMap(char *address, * with post data, the specific list. The list is created if it doesn't * already exist. - kw */ -#ifndef DONT_TRACK_INTERNAL_LINKS - if (node_anchor->post_data) { + if (track_internal_links && node_anchor->post_data) { /* * We are handling a MAP element found while parsing node_anchor's * stream of data, and node_anchor has post_data associated and should @@ -153,9 +150,7 @@ BOOL LYAddImageMap(char *address, if (!theList) { theList = node_anchor->imaps = HTList_new(); } - } else -#endif - { + } else { if (!LynxMaps) { LynxMaps = HTList_new(); #ifdef LY_FIND_LEAKS @@ -230,8 +225,7 @@ BOOL LYAddMapElement(char *map, * a MAP element in node_anchor's stream of data, so that LYAddImageMap has * been called. - kw */ -#ifndef DONT_TRACK_INTERNAL_LINKS - if (node_anchor->post_data) { + if (track_internal_links && node_anchor->post_data) { /* * We are handling an AREA tag found while parsing node_anchor's stream * of data, and node_anchor has post_data associated and should @@ -241,9 +235,7 @@ BOOL LYAddMapElement(char *map, if (!theList) { return FALSE; } - } else -#endif - { + } else { if (!LynxMaps) LYAddImageMap(map, NULL, node_anchor); theList = LynxMaps; @@ -280,9 +272,8 @@ BOOL LYAddMapElement(char *map, StrAllocCopy(tmp->title, title); else StrAllocCopy(tmp->title, address); -#ifndef DONT_TRACK_INTERNAL_LINKS - tmp->intern_flag = intern_flag; -#endif + if (track_internal_links) + tmp->intern_flag = intern_flag; HTList_appendObject(theMap->elements, tmp); CTRACE((tfp, @@ -370,7 +361,7 @@ static void fill_DocAddress(DocAddress *wwwdoc, * requested; if it is associated with POST data, we want the * specific list for this combination of address+post_data. * - * if DONT_TRACK_INTERNAL_LINKS is defined, the Anchor passed to + * if track_internal_links is false, the Anchor passed to * LYLoadIMGmap() will never have post_data, so that the global list * will be used. - kw */ @@ -519,9 +510,8 @@ static int LYLoadIMGmap(const char *arg, return (HT_NOT_LOADED); } } -#ifdef DONT_TRACK_INTERNAL_LINKS - anAnchor->no_cache = TRUE; -#endif + if (track_internal_links) + anAnchor->no_cache = TRUE; target = HTStreamStack(format_in, format_out, @@ -587,10 +577,9 @@ static int LYLoadIMGmap(const char *arg, PUTS("<li><a href=\""); PUTS(MapAddress); PUTS("\""); -#ifndef DONT_TRACK_INTERNAL_LINKS - if (tmp->intern_flag) + if (track_internal_links && tmp->intern_flag) { PUTS(" TYPE=\"internal link\""); -#endif + } PUTS("\n>"); LYformTitle(&MapTitle, tmp->title); LYEntify(&MapTitle, TRUE); @@ -635,10 +624,8 @@ void LYPrintImgMaps(FILE *fp) count = 0; while (NULL != (elt = (LYMapElement *) HTList_nextObject(inner))) { fprintf(fp, "%4d. %s", ++count, elt->address); -#ifndef DONT_TRACK_INTERNAL_LINKS - if (elt->intern_flag) + if (track_internal_links && elt->intern_flag) fprintf(fp, " TYPE=\"internal link\""); -#endif fprintf(fp, "\n"); } } diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index ea6845d3..34333bc1 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.c,v 1.168 2012/08/13 00:09:29 tom Exp $ + * $LynxId: LYReadCFG.c,v 1.171 2013/04/30 09:52:44 tom Exp $ */ #ifndef NO_RULES #include <HTRules.h> @@ -756,7 +756,7 @@ static int keymap_fun(char *key) fprintf(stderr, gettext("key remapping of %s to %s for %s failed\n"), key, func, efunc + 1); - } else if (func && !strcmp("TOGGLE_HELP", func)) { + } else if (!strcmp("TOGGLE_HELP", func)) { LYUseNoviceLineTwo = FALSE; } return 0; @@ -764,7 +764,7 @@ static int keymap_fun(char *key) fprintf(stderr, gettext("key remapping of %s to %s failed\n"), key, func); } else { - if (func && !strcmp("TOGGLE_HELP", func)) + if (!strcmp("TOGGLE_HELP", func)) LYUseNoviceLineTwo = FALSE; } if (efunc) { @@ -1724,6 +1724,7 @@ static Config_Type Config_Table [] = PARSE_INT(RC_TIMEOUT, lynx_timeout), #endif PARSE_PRG(RC_TOUCH_PATH, ppTOUCH), + PARSE_SET(RC_TRACK_INTERNAL_LINKS, track_internal_links), PARSE_SET(RC_TRIM_INPUT_FIELDS, LYtrimInputFields), #ifdef EXEC_LINKS PARSE_DEF(RC_TRUSTED_EXEC, EXEC_PATH), @@ -1990,12 +1991,10 @@ BOOL LYSetConfigValue(const char *name, if (*(q->lst_value) == NULL) { *(q->lst_value) = HTList_new(); } - if (q->lst_value != 0) { - char *my_value = NULL; - - StrAllocCopy(my_value, value); - HTList_appendObject(*(q->lst_value), my_value); - } + temp_value = NULL; + StrAllocCopy(temp_value, value); + HTList_appendObject(*(q->lst_value), temp_value); + temp_value = NULL; break; #if defined(EXEC_LINKS) || defined(LYNXCGI_LINKS) diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index f3b7f8fb..ef20791f 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -1,4 +1,4 @@ -/* $LynxId: LYShowInfo.c,v 1.72 2010/09/25 00:47:28 tom Exp $ */ +/* $LynxId: LYShowInfo.c,v 1.73 2013/01/04 01:20:17 tom Exp $ */ #include <HTUtils.h> #include <HTFile.h> #include <HTParse.h> @@ -209,11 +209,14 @@ int LYShowInfo(DocInfo *doc, if (S_ISLNK(dir_info.st_mode)) { char buf[MAX_LINE]; int buf_size; + size_t limit = sizeof(buf) - 1; - if ((buf_size = (int) readlink(temp, buf, sizeof(buf) - 1)) != -1) { + if ((buf_size = (int) readlink(temp, buf, limit)) != -1) { + if (buf_size > (int) limit) + buf_size = (int) limit; buf[buf_size] = '\0'; } else { - sprintf(buf, "%.*s", (int) sizeof(buf) - 1, + sprintf(buf, "%.*s", (int) limit, gettext("Unable to follow link")); } ADD_SS(gettext("Points to file:"), buf); diff --git a/src/LYStrings.c b/src/LYStrings.c index 47570b33..9d16fb99 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.206 2012/08/13 00:18:00 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.208 2013/01/04 01:40:27 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -5413,6 +5413,7 @@ int LYscanFloat2(const char **source, float *result) const char *src = *source; src = LYSkipCBlanks(src); + *result = 0.0; if (strchr(src, '.') != 0) { long frc_part = 0; float scale = 1.0; @@ -5447,6 +5448,7 @@ int LYscanFloat2(const char **source, float *result) if (sscanf(extra, "%f", &scale) == 1) { *result *= scale; } + FREE(extra); src = LYSkipCNonBlanks(src); } else { src = 0; diff --git a/src/LYUtils.c b/src/LYUtils.c index a82e30c2..19bf4b67 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.227 2012/08/15 23:11:03 tom Exp $ + * $LynxId: LYUtils.c,v 1.230 2013/04/30 23:56:38 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -546,7 +546,8 @@ static BOOL show_whereis_targets(int flag, * characters of the hightext if we're making the link current. * -FM */ - if ((Offset < offset) && + if (offset >= 0 && + (Offset < offset) && ((Offset + tLen) > offset)) { itmp = 0; written = 0; @@ -2930,10 +2931,6 @@ void LYExtSignal(int sig, act.sa_handler = handler; sigemptyset(&act.sa_mask); act.sa_flags = 0; -#ifdef SA_RESTART - if (sig != SIGWINCH) - act.sa_flags |= SA_RESTART; -#endif /* SA_RESTART */ sigaction(sig, &act, NULL); } else #endif /* defined(SIGWINCH) */ @@ -3188,9 +3185,10 @@ void change_sug_filename(char *fname) HTSprintf0(&temp, "file://localhost/%s" PID_FMT, cp2, GETPID()); } if (!StrNCmp(fname, temp, strlen(temp))) { - cp = strrchr(fname, '.'); - if (strlen(cp) > (strlen(temp) - 4)) - cp = NULL; + if ((cp = strrchr(fname, '.')) != 0) { + if (strlen(cp) > (strlen(temp) - 4)) + cp = NULL; + } StrAllocCopy(temp, NonNull(cp)); sprintf(fname, "temp%.*s", LY_MAXPATH - 10, temp); } diff --git a/src/LYrcFile.h b/src/LYrcFile.h index c84ab3d5..ae1f095c 100644 --- a/src/LYrcFile.h +++ b/src/LYrcFile.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYrcFile.h,v 1.43 2012/08/13 00:16:53 tom Exp $ + * $LynxId: LYrcFile.h,v 1.44 2013/04/30 09:53:05 tom Exp $ */ #ifndef LYRCFILE_H #define LYRCFILE_H @@ -246,6 +246,7 @@ #define RC_TIMEOUT "timeout" #define RC_TN3270_PATH "tn3270_path" #define RC_TOUCH_PATH "touch_path" +#define RC_TRACK_INTERNAL_LINKS "track_internal_links" #define RC_TRIM_INPUT_FIELDS "trim_input_fields" #define RC_TRUSTED_EXEC "trusted_exec" #define RC_TRUSTED_LYNXCGI "trusted_lynxcgi" diff --git a/src/TRSTable.c b/src/TRSTable.c index ea07bc90..fddb70c7 100644 --- a/src/TRSTable.c +++ b/src/TRSTable.c @@ -1,5 +1,5 @@ /* - * $LynxId: TRSTable.c,v 1.29 2010/10/27 00:15:10 tom Exp $ + * $LynxId: TRSTable.c,v 1.31 2013/05/01 01:00:38 tom Exp $ * Simple table object * =================== * Authors @@ -646,6 +646,7 @@ static int Stbl_finishCellInRow(STable_rowinfo *me, STable_states *s, int end_td if (me->Line != lastcell->cLine) goto trace_and_return; } + newstate = CS__cb; } else { if (!me->fixed_line) { me->fixed_line = YES; /* type=b def of fixed_line ii */ @@ -654,7 +655,6 @@ static int Stbl_finishCellInRow(STable_rowinfo *me, STable_states *s, int end_td s->state = CS__cbc; goto trace_and_return; } - newstate = empty ? CS__cb : CS__cbc; break; case CS__ef: ret = 0; @@ -776,10 +776,10 @@ static int Stbl_finishCellInRow(STable_rowinfo *me, STable_states *s, int end_td if (me->Line != lastcell->cLine) goto trace_and_return; } + newstate = CS__cf; } else { goto trace_and_return; } - newstate = empty ? CS__cf : CS__cbc; break; case CS__ef: /* ignored error */ case CS__cf: /* ignored error */ diff --git a/src/UCAuto.c b/src/UCAuto.c index 8bf66abc..92936546 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -1,5 +1,5 @@ /* - * $LynxId: UCAuto.c,v 1.47 2012/02/12 17:30:42 tom Exp $ + * $LynxId: UCAuto.c,v 1.49 2013/04/30 09:20:19 tom Exp $ * * This file contains code for changing the Linux console mode. * Currently some names for font files are hardwired in here. @@ -75,7 +75,6 @@ typedef enum { */ typedef enum { GN_Blat1, /* Latin-1 */ - GN_0decgraf, /* VT100 graphics */ GN_Ucp437, /* PC -> PC */ GN_Kuser, /* user-defined */ GN_dunno, @@ -346,8 +345,6 @@ void UCChangeTerminalCodepage(int newcs, } else { if (fp1) LYRemoveTemp(old_font); - if (fp2) - LYRemoveTemp(old_umap); FREE(old_font); FREE(old_umap); } @@ -513,8 +510,6 @@ void UCChangeTerminalCodepage(int newcs, * Switch Linux console to lat1 table. */ write_esc("\033(B"); - } else if (TransT == GN_0decgraf) { - write_esc("\033(0"); } else if (TransT == GN_Ucp437) { /* * Switch Linux console to 437 table? diff --git a/src/parsdate.c b/src/parsdate.c index 94e594a0..26a344bc 100644 --- a/src/parsdate.c +++ b/src/parsdate.c @@ -5,7 +5,7 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 -#define YYPATCH 20120114 +#define YYPATCH 20121003 #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) @@ -21,7 +21,7 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #include <LYLeaks.h> /* - * $LynxId: parsdate.c,v 1.14 2012/08/03 18:36:10 tom Exp $ + * $LynxId: parsdate.c,v 1.16 2013/01/05 02:00:30 tom Exp $ * * This module is adapted and extended from tin, to use for LYmktime(). * @@ -185,8 +185,12 @@ typedef union { #endif /* Parameters sent to yyerror. */ +#ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) +#endif +#ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) +#endif extern int YYPARSE_DECL(); @@ -802,74 +806,72 @@ static int date_lex(void) int i; int nesting; + /* Get first character after the whitespace. */ for (;;) { - /* Get first character after the whitespace. */ - for (;;) { - while (CTYPE(isspace, *yyInput)) - yyInput++; - c = *yyInput; - - /* Ignore RFC 822 comments, typically time zone names. */ - if (c != LPAREN) - break; - for (nesting = 1; - (c = *++yyInput) != RPAREN || --nesting; - ) { - if (c == LPAREN) { - nesting++; - } else if (!IS7BIT(c) || c == '\0' || c == '\r' - || (c == '\\' - && ((c = *++yyInput) == '\0' - || !IS7BIT(c)))) { - /* Lexical error: bad comment. */ - return '?'; - } - } + while (CTYPE(isspace, *yyInput)) yyInput++; - } + c = *yyInput; - /* A number? */ - if (CTYPE(isdigit, c) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - yyInput++; - if (!CTYPE(isdigit, *yyInput)) { - /* Return the isolated plus or minus sign. */ - --yyInput; - return *yyInput++; - } - } else { - sign = 0; - } - for (p = buff; - (c = *yyInput++) != '\0' && CTYPE(isdigit, c); - ) { - if (p < &buff[sizeof buff - 1]) - *p++ = (char) c; + /* Ignore RFC 822 comments, typically time zone names. */ + if (c != LPAREN) + break; + for (nesting = 1; + (c = *++yyInput) != RPAREN || --nesting; + ) { + if (c == LPAREN) { + nesting++; + } else if (!IS7BIT(c) || c == '\0' || c == '\r' + || (c == '\\' + && ((c = *++yyInput) == '\0' + || !IS7BIT(c)))) { + /* Lexical error: bad comment. */ + return '?'; } - *p = '\0'; - i = atoi(buff); - - yyInput--; - yylval.Number = sign < 0 ? -i : i; - return sign ? tSNUMBER : tUNUMBER; } + yyInput++; + } - /* A word? */ - if (CTYPE(isalpha, c)) { - for (p = buff; - (c = *yyInput++) == '.' || CTYPE(isalpha, c); - ) { - if (p < &buff[sizeof buff - 1]) - *p++ = (char) (CTYPE(isupper, c) ? tolower(c) : c); + /* A number? */ + if (CTYPE(isdigit, c) || c == '-' || c == '+') { + if (c == '-' || c == '+') { + sign = c == '-' ? -1 : 1; + yyInput++; + if (!CTYPE(isdigit, *yyInput)) { + /* Return the isolated plus or minus sign. */ + --yyInput; + return *yyInput++; } - *p = '\0'; - yyInput--; - return LookupWord(buff, (int) (p - buff)); + } else { + sign = 0; + } + for (p = buff; + (c = *yyInput++) != '\0' && CTYPE(isdigit, c); + ) { + if (p < &buff[sizeof buff - 1]) + *p++ = (char) c; } + *p = '\0'; + i = atoi(buff); - return *yyInput++; + yyInput--; + yylval.Number = sign < 0 ? -i : i; + return sign ? tSNUMBER : tUNUMBER; } + + /* A word? */ + if (CTYPE(isalpha, c)) { + for (p = buff; + (c = *yyInput++) == '.' || CTYPE(isalpha, c); + ) { + if (p < &buff[sizeof buff - 1]) + *p++ = (char) (CTYPE(isupper, c) ? tolower(c) : c); + } + *p = '\0'; + yyInput--; + return LookupWord(buff, (int) (p - buff)); + } + + return *yyInput++; } static int GetTimeInfo(TIMEINFO * Now) @@ -984,7 +986,7 @@ time_t parsedate(char *p, * from the error return value. (Alternately could set errno on error.) */ return (Start == (time_t) -1) ? 0 : Start; } -#line 987 "y.tab.c" +#line 989 "y.tab.c" #if YYDEBUG #include <stdio.h> /* needed for printf */ @@ -1476,7 +1478,7 @@ case 35: yyval.Meridian = yystack.l_mark[0].Meridian; } break; -#line 1479 "y.tab.c" +#line 1481 "y.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/src/parsdate.y b/src/parsdate.y index 0605863c..f60a649d 100644 --- a/src/parsdate.y +++ b/src/parsdate.y @@ -3,7 +3,7 @@ #include <LYLeaks.h> /* - * $LynxId: parsdate.y,v 1.19 2012/02/09 20:05:26 tom Exp $ + * $LynxId: parsdate.y,v 1.20 2013/01/05 01:58:50 tom Exp $ * * This module is adapted and extended from tin, to use for LYmktime(). * @@ -756,74 +756,72 @@ static int date_lex(void) int i; int nesting; + /* Get first character after the whitespace. */ for (;;) { - /* Get first character after the whitespace. */ - for (;;) { - while (CTYPE(isspace, *yyInput)) - yyInput++; - c = *yyInput; - - /* Ignore RFC 822 comments, typically time zone names. */ - if (c != LPAREN) - break; - for (nesting = 1; - (c = *++yyInput) != RPAREN || --nesting; - ) { - if (c == LPAREN) { - nesting++; - } else if (!IS7BIT(c) || c == '\0' || c == '\r' - || (c == '\\' - && ((c = *++yyInput) == '\0' - || !IS7BIT(c)))) { - /* Lexical error: bad comment. */ - return '?'; - } - } + while (CTYPE(isspace, *yyInput)) yyInput++; - } + c = *yyInput; - /* A number? */ - if (CTYPE(isdigit, c) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - yyInput++; - if (!CTYPE(isdigit, *yyInput)) { - /* Return the isolated plus or minus sign. */ - --yyInput; - return *yyInput++; - } - } else { - sign = 0; - } - for (p = buff; - (c = *yyInput++) != '\0' && CTYPE(isdigit, c); - ) { - if (p < &buff[sizeof buff - 1]) - *p++ = (char) c; + /* Ignore RFC 822 comments, typically time zone names. */ + if (c != LPAREN) + break; + for (nesting = 1; + (c = *++yyInput) != RPAREN || --nesting; + ) { + if (c == LPAREN) { + nesting++; + } else if (!IS7BIT(c) || c == '\0' || c == '\r' + || (c == '\\' + && ((c = *++yyInput) == '\0' + || !IS7BIT(c)))) { + /* Lexical error: bad comment. */ + return '?'; } - *p = '\0'; - i = atoi(buff); - - yyInput--; - yylval.Number = sign < 0 ? -i : i; - return sign ? tSNUMBER : tUNUMBER; } + yyInput++; + } - /* A word? */ - if (CTYPE(isalpha, c)) { - for (p = buff; - (c = *yyInput++) == '.' || CTYPE(isalpha, c); - ) { - if (p < &buff[sizeof buff - 1]) - *p++ = (char) (CTYPE(isupper, c) ? tolower(c) : c); + /* A number? */ + if (CTYPE(isdigit, c) || c == '-' || c == '+') { + if (c == '-' || c == '+') { + sign = c == '-' ? -1 : 1; + yyInput++; + if (!CTYPE(isdigit, *yyInput)) { + /* Return the isolated plus or minus sign. */ + --yyInput; + return *yyInput++; } - *p = '\0'; - yyInput--; - return LookupWord(buff, (int) (p - buff)); + } else { + sign = 0; + } + for (p = buff; + (c = *yyInput++) != '\0' && CTYPE(isdigit, c); + ) { + if (p < &buff[sizeof buff - 1]) + *p++ = (char) c; } + *p = '\0'; + i = atoi(buff); - return *yyInput++; + yyInput--; + yylval.Number = sign < 0 ? -i : i; + return sign ? tSNUMBER : tUNUMBER; } + + /* A word? */ + if (CTYPE(isalpha, c)) { + for (p = buff; + (c = *yyInput++) == '.' || CTYPE(isalpha, c); + ) { + if (p < &buff[sizeof buff - 1]) + *p++ = (char) (CTYPE(isupper, c) ? tolower(c) : c); + } + *p = '\0'; + yyInput--; + return LookupWord(buff, (int) (p - buff)); + } + + return *yyInput++; } static int GetTimeInfo(TIMEINFO * Now) |