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 | |
parent | 7827f0bdba0c75376e59443975f3638df4cce044 (diff) | |
download | lynx-snapshots-81905f18dc0594e372cf38cfb0e0b71b69849a43.tar.gz |
snapshot of project "lynx", label v2-8-8dev-15b
51 files changed, 880 insertions, 808 deletions
diff --git a/CHANGES b/CHANGES index 360be685..f89ed501 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,13 @@ --- $LynxId: CHANGES,v 1.634 2012/11/18 21:54:53 tom Exp $ +-- $LynxId: CHANGES,v 1.638 2013/04/30 09:55:16 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== +2013-04-30 (2.8.8dev.16) ++ make DONT_TRACK_INTERNAL_LINKS logic configurable via lynx.cfg as + TRACK_INTERNAL_LINKS; the configure script now sets the default value -TD +* fix issues found by Coverity scan -TD + 2012-11-18 (2.8.8dev.15) * corrected position of highlighting from search/whereis function when using multibyte characters (Debian #673385) -TD @@ -271,7 +276,7 @@ Changes since Lynx 2.8 release * remind user how to cancel message (Debian #292787) -TD * add HTML5_CHARSETS feature, which allows the user to choose whether to interpret pages without an explicit charset according to the HTML5 - "compatibility" feature (Debian #604466, #514897) -TD + "compatibility" feature (Debian #604466, Debian #514897) -TD * add EXTERNAL_MENU feature to lynx.cfg, which allows the user to customize the menu-entry shown, e.g., to suppress the display of the URL (Debian #603646) -TD @@ -910,7 +915,7 @@ Changes since Lynx 2.8 release by discussion by Chuck Houpt and TG) -TD * fix an off-by-one in HText_canScrollDown() and total_pages in GridText.c -TH * rewrite strcasecomp_asterisk() to support wildcards as in RFC 2818 (prompted - by less-complete Debian patch for #401447, see also #268102) -TD + by less-complete patch from Debian #401447, see also Debian #268102) -TD * improve X.509 certificate validation -TG This is tested for OpenSSL, ifdef'd to not break gnutls. Changes: + peer certificate is cached, no need to call SSL_get_peer_certificate() @@ -1202,7 +1207,7 @@ Changes since Lynx 2.8 release if it cannot find the lss file. cf: 2000-07-16 (2.8.4dev.5) -TD * fix a sign-extension in alignment case-statement in split_line() which could cause a large indent for lines which are wider than the display (Debian - #360832, #372670) -TD + #360832, Debian #372670) -TD * fix ifdef's in LYOptions.c to make --disable-menu-options work (report by PW) -TD @@ -8211,16 +8216,16 @@ recently, FreeBSD 4.1, NetBSD 1.5 and OpenBSD 2.8 (curses/ncurses). 1998-09-08 (2.8.1dev25-intl) * Resynch with dev tree - JES -1998-09-07 (2.8.1dev.21-intl) +1998-09-07 (2.8.1dev.21-intl p3) * About half through language hooks in WWW/Lib... - JES Integrated part of Chebucto's French translations - JES * Included latest ABOUT-NLS from GNU project, -1998-08-27 (2.8.1dev.21-intl) +1998-08-27 (2.8.1dev.21-intl p2) * Tested language hooks using src/LYNews.c and Italian messages file provided by Sabato De Rosa <sabato.derosa@usa.net>. Made changes to LYMain.c, LYMainLoop.c, LYNews.c and HTNews.c - JES -1998-08-27 (2.8.1dev.21-intl) +1998-08-27 (2.8.1dev.21-intl p1) * add hooks to GNU gettext for international language support - JES (This is an experimental modification that will be patched into the main Lynx release after other platform testing. I've only done diff --git a/INSTALLATION b/INSTALLATION index b530a22f..9c1f865e 100644 --- a/INSTALLATION +++ b/INSTALLATION @@ -460,7 +460,7 @@ II. Compile instructions -- UNIX generate an HTMLized copy of lynx.cfg which will be installed with the other help files. - --enable-internal-links (prevent defining DONT_TRACK_INTERNAL_LINKS) + --enable-internal-links (define TRACK_INTERNAL_LINKS) With `internal links' (links within a document to a location within the same document) enabled, Lynx will distinguish between, for example, `<A HREF="foo#frag">' and `<A HREF="#frag">' within a document whose @@ -1455,4 +1455,4 @@ VIII. Acknowledgment -- 1999/04/24 - H. Nelson <lynx-admin@irm.nara.kindai.ac.jp> -- vile:txtmode --- $LynxId: INSTALLATION,v 1.120 2012/07/06 11:53:52 tom Exp $ +-- $LynxId: INSTALLATION,v 1.121 2013/04/30 09:47:15 tom Exp $ diff --git a/PACKAGE/debian/changelog b/PACKAGE/debian/changelog index 3e937ac5..f6fac4bc 100644 --- a/PACKAGE/debian/changelog +++ b/PACKAGE/debian/changelog @@ -1,3 +1,9 @@ +lynx-dev (2.8.8dev.16) unstable; urgency=high + + * changes for dev.16 + + -- Thomas E. Dickey <dickey@invisible-island.net> Tue, 30 Apr 2013 04:32:34 -0400 + lynx-dev (2.8.8dev.15) unstable; urgency=high * changes for dev.15 diff --git a/PACKAGE/lynx.spec b/PACKAGE/lynx.spec index 6a0949a8..128bc394 100644 --- a/PACKAGE/lynx.spec +++ b/PACKAGE/lynx.spec @@ -1,8 +1,8 @@ -# $LynxId: lynx.spec,v 1.16 2012/11/17 01:55:11 tom Exp $ +# $LynxId: lynx.spec,v 1.17 2013/04/30 08:32:37 tom Exp $ Summary: A text-based Web browser Name: lynx Version: 2.8.8 -Release: dev.15 +Release: dev.16 License: GPLv2 Group: Applications/Internet Source: lynx%{version}%{release}.tgz diff --git a/WWW/Library/Implementation/HTAABrow.c b/WWW/Library/Implementation/HTAABrow.c index 3e25deaf..bb32c94b 100644 --- a/WWW/Library/Implementation/HTAABrow.c +++ b/WWW/Library/Implementation/HTAABrow.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAABrow.c,v 1.34 2010/09/24 08:27:42 tom Exp $ + * $LynxId: HTAABrow.c,v 1.38 2013/04/30 09:11:00 tom Exp $ * * MODULE HTAABrow.c * BROWSER SIDE ACCESS AUTHORIZATION MODULE @@ -638,7 +638,7 @@ static char *compose_auth_string(HTAAScheme scheme, HTAASetup * setup, int IsPro NonNull(thePort)); FREE(proxiedHost); FREE(thePort); - username = realm->username; + StrAllocCopy(username, realm->username); password = NULL; HTPromptUsernameAndPassword(msg, &username, &password, IsProxy); @@ -1058,6 +1058,7 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, HTAssocList **scheme_specifics = NULL; char *ctemplate = NULL; char *temp = NULL; + BOOL result = NO; /* * Setup atexit() freeing if not done already. - FM @@ -1147,12 +1148,12 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, * No proxy authorization valid */ proxy_setup = NULL; - return NO; + result = NO; } /* * Doing it for proxy. -AJL */ - if (proxy_setup && proxy_setup->server) { + else if (proxy_setup && proxy_setup->server) { /* * We have already tried with proxy authorization. Either we don't * have access or username or password was misspelled. @@ -1164,13 +1165,14 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, if (NO == HTConfirm(AUTH_FAILED_PROMPT)) { proxy_setup = NULL; - return NO; + result = NO; } else { /* * Re-ask username+password (if misspelled). */ + HTList_delete(valid_schemes); proxy_setup->retry = YES; - return YES; + result = YES; } } else { /* @@ -1196,21 +1198,19 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, FREE(ctemplate); HTAlert(gettext("Proxy authorization required -- retrying")); - return YES; + result = YES; } - /* Never reached */ } /* * Normal WWW authorization. */ - if (num_schemes == 0) { + else if (num_schemes == 0) { /* * No authorization valid. */ current_setup = NULL; - return NO; - } - if (current_setup && current_setup->server) { + result = NO; + } else if (current_setup && current_setup->server) { /* * So we have already tried with WWW authorization. Either we don't * have access or username or password was misspelled. @@ -1222,13 +1222,13 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, if (NO == HTConfirm(AUTH_FAILED_PROMPT)) { current_setup = NULL; - return NO; + result = NO; } else { /* * Re-ask username+password (if misspelled). */ current_setup->retry = YES; - return YES; + result = YES; } } else { /* @@ -1254,9 +1254,13 @@ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, FREE(ctemplate); HTAlert(gettext("Access without authorization denied -- retrying")); - return YES; + result = YES; + } + + if (result == NO) { + HTList_delete(valid_schemes); } - /* Never reached */ + return result; } /* diff --git a/WWW/Library/Implementation/HTAAUtil.c b/WWW/Library/Implementation/HTAAUtil.c index 8a6caab6..2113b400 100644 --- a/WWW/Library/Implementation/HTAAUtil.c +++ b/WWW/Library/Implementation/HTAAUtil.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAAUtil.c,v 1.31 2010/09/24 23:51:22 tom Exp $ + * $LynxId: HTAAUtil.c,v 1.34 2013/04/30 23:16:09 tom Exp $ * * MODULE HTAAUtil.c * COMMON PARTS OF ACCESS AUTHORIZATION MODULE @@ -557,6 +557,8 @@ char *HTAA_getUnfoldedLine(void) in_soc = -1; return line; } + if (count > (int) buffer_length) + count = (int) buffer_length; start_pointer = buffer; end_pointer = buffer + count; *end_pointer = '\0'; diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 5bfcce4e..cfb5a450 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAccess.c,v 1.77 2012/02/23 00:39:40 tom Exp $ + * $LynxId: HTAccess.c,v 1.78 2013/04/30 22:59:03 tom Exp $ * * Access Manager HTAccess.c * ============== @@ -858,7 +858,7 @@ static BOOL HTLoadDocument(const char *full_address, /* may include #fragment */ * (3) we are repositioning within the currently loaded document based * on the target anchor's address (URL_Reference). * - * If DONT_TRACK_INTERNAL_LINKS is defined, HText_AreDifferent() is + * If track_internal_links is false, HText_AreDifferent() is * used to determine whether (3) applies. If the target address * differs from that of the current document only by a fragment and the * target address has an appended fragment, repositioning without @@ -873,7 +873,7 @@ static BOOL HTLoadDocument(const char *full_address, /* may include #fragment */ * (e.g., user requested RELOAD, or HTTP response with no-cache header * and we are not overriding). * - * If DONT_TRACK_INTERNAL_LINKS is undefined, a target address that + * If track_internal_links is true, a target address that * points to the same URL as the current document may still result in * reloading, depending on whether the original URL-Reference was given * as an internal link in the context of the previously loaded @@ -897,14 +897,12 @@ static BOOL HTLoadDocument(const char *full_address, /* may include #fragment */ */ if ((reloading != REAL_RELOAD) && (LYoverride_no_cache || -#ifdef DONT_TRACK_INTERNAL_LINKS - !HText_hasNoCacheSet(text) || - !HText_AreDifferent(anchor, full_address) -#else - ((LYinternal_flag || !HText_hasNoCacheSet(text)) && - !isLYNXIMGMAP(full_address)) -#endif /* TRACK_INTERNAL_LINKS */ - )) { + ((!track_internal_links && + (!HText_hasNoCacheSet(text) || + !HText_AreDifferent(anchor, full_address))) || + (track_internal_links && + (((LYinternal_flag || !HText_hasNoCacheSet(text)) && + !isLYNXIMGMAP(full_address))))))) { CTRACE((tfp, "HTAccess: Document already in memory.\n")); HText_select(text); diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index e8dea73b..b2edabd1 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFTP.c,v 1.106 2012/11/15 23:51:23 tom Exp $ + * $LynxId: HTFTP.c,v 1.114 2013/01/05 01:35:12 tom Exp $ * * File Transfer Protocol (FTP) Client * for a WorldWideWeb browser @@ -351,9 +351,13 @@ char *HTVMS_name(const char *nn, HTSprintf0(&vmsname, "%s%s:[%s]%s", nodename, filename + 1, second + 1, last + 1); *second = *last = '/'; /* restore filename */ - for (p = strchr(vmsname, '['); *p != ']'; p++) - if (*p == '/') - *p = '.'; /* Convert dir sep. to dots */ + if ((p = strchr(vmsname, '[')) != 0) { + while (*p != '\0' && *p != ']') { + if (*p == '/') + *p = '.'; /* Convert dir sep. to dots */ + ++p; + } + } } FREE(nodename); FREE(filename); @@ -764,6 +768,15 @@ static void set_unix_dirstyle(eServerType *ServerType, BOOLEAN *UseList) } } +#define CheckForInterrupt(msg) \ + if (status == HT_INTERRUPTED) { \ + CTRACE((tfp, "HTFTP: Interrupted %s.\n", msg)); \ + _HTProgress(CONNECTION_INTERRUPTED); \ + NETCLOSE(control->socket); \ + control->socket = -1; \ + return HT_INTERRUPTED; \ + } + /* Get a valid connection to the host * ---------------------------------- * @@ -821,13 +834,13 @@ static int get_connection(const char *arg, } con->socket = -1; - if (!arg) + if (isEmpty(arg)) { + free(con); return -1; /* Bad if no name specified */ - if (!*arg) - return -1; /* Bad if name had zero length */ + } -/* Get node name: -*/ + /* Get node name: + */ CTRACE((tfp, "get_connection(%s)\n", arg)); { char *p1 = HTParse(arg, "", PARSE_HOST); @@ -914,17 +927,11 @@ static int get_connection(const char *arg, HTInitInput(control->socket); init_help_message_cache(); /* Clear the login message buffer. */ -/* Now we log in Look up username, prompt for pw. -*/ + /* Now we log in Look up username, prompt for pw. + */ status = response((char *) 0); /* Get greeting */ + CheckForInterrupt("at beginning of login"); - if (status == HT_INTERRUPTED) { - CTRACE((tfp, "HTFTP: Interrupted at beginning of login.\n")); - _HTProgress(CONNECTION_INTERRUPTED); - NETCLOSE(control->socket); - control->socket = -1; - return HT_INTERRUPTED; - } server_type = GENERIC_SERVER; /* reset */ if (status == 2) { /* Send username */ char *cp; /* look at greeting text */ @@ -947,13 +954,7 @@ static int get_connection(const char *arg, ? username : "anonymous"); - if (status == HT_INTERRUPTED) { - CTRACE((tfp, "HTFTP: Interrupted while sending username.\n")); - _HTProgress(CONNECTION_INTERRUPTED); - NETCLOSE(control->socket); - control->socket = -1; - return HT_INTERRUPTED; - } + CheckForInterrupt("while sending username"); } if (status == 3) { /* Send password */ if (password) { @@ -1001,26 +1002,13 @@ static int get_connection(const char *arg, } status = response(command); FREE(command); - if (status == HT_INTERRUPTED) { - CTRACE((tfp, "HTFTP: Interrupted while sending password.\n")); - _HTProgress(CONNECTION_INTERRUPTED); - NETCLOSE(control->socket); - control->socket = -1; - return HT_INTERRUPTED; - } + CheckForInterrupt("while sending password"); } FREE(username); if (status == 3) { status = send_cmd_1("ACCT noaccount"); - if (status == HT_INTERRUPTED) { - CTRACE((tfp, "HTFTP: Interrupted while sending password.\n")); - _HTProgress(CONNECTION_INTERRUPTED); - NETCLOSE(control->socket); - control->socket = -1; - return HT_INTERRUPTED; - } - + CheckForInterrupt("while sending password"); } if (status != 2) { CTRACE((tfp, "HTFTP: Login fail: %s", response_text)); @@ -1127,20 +1115,6 @@ static int get_connection(const char *arg, get_ftp_pwd(&server_type, &use_list); } -/* Now we inform the server of the port number we will listen on -*/ -#ifdef NOTREPEAT_PORT - { - int status = response(port_command); - - if (status != 2) { - if (control->socket) - close_connection(control->socket); - return -status; /* Bad return */ - } - CTRACE((tfp, "HTFTP: Port defined.\n")); - } -#endif /* NOTREPEAT_PORT */ return con->socket; /* Good return */ } @@ -1319,8 +1293,10 @@ static int get_listen_socket(void) status = getsockname(control->socket, (struct sockaddr *) &soc_address, &address_length); - if (status < 0) + if (status < 0) { + close(new_socket); return HTInetStatus("getsockname"); + } #ifdef INET6 CTRACE((tfp, "HTFTP: This host is %s\n", HTInetString((void *) soc_in))); @@ -1349,8 +1325,10 @@ static int get_listen_socket(void) /* Cast to generic sockaddr */ SOCKADDR_LEN(soc_address) ); - if (status < 0) + if (status < 0) { + close(new_socket); return HTInetStatus("bind"); + } address_length = sizeof(soc_address); #ifdef SOCKS @@ -1363,8 +1341,10 @@ static int get_listen_socket(void) status = getsockname(new_socket, (struct sockaddr *) &soc_address, &address_length); - if (status < 0) + if (status < 0) { + close(new_socket); return HTInetStatus("getsockname"); + } } #endif /* POLL_PORTS */ @@ -1790,7 +1770,7 @@ static void parse_dls_line(char *line, StrAllocCopy(entry_info->type, ""); } else { StrAllocCopy(entry_info->filename, line); - if (cps && cps != line && *(cps - 1) == '/') + if (cps != line && *(cps - 1) == '/') StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY); else StrAllocCopy(entry_info->type, ""); @@ -2345,7 +2325,7 @@ static EntryInfo *parse_dir_entry(char *entry, /* if still unchanged... */ parse_dls_line(entry, entry_info, pspilledname); - if (!entry_info->filename || *entry_info->filename == '\0') { + if (isEmpty(entry_info->filename)) { entry_info->display = FALSE; return (entry_info); } @@ -2577,7 +2557,11 @@ static EntryInfo *parse_dir_entry(char *entry, } #endif - if (entry_info->filename && strlen(entry_info->filename) > 3) { + if (isEmpty(entry_info->filename)) { + entry_info->display = FALSE; + return (entry_info); + } + if (strlen(entry_info->filename) > 3) { if (((cp = strrchr(entry_info->filename, '.')) != NULL && 0 == strncasecomp(cp, ".me", 3)) && (cp[3] == '\0' || cp[3] == ';')) { @@ -2980,6 +2964,7 @@ static void LYListFmtParse(const char *fmtstr, FREE(str); } #endif /* LONG_LIST */ + /* Read a directory into an hypertext object from the data socket * -------------------------------------------------------------- * @@ -3080,6 +3065,7 @@ static int read_directory(HTParentAnchor *parent, ABORT_TARGET; HTBTreeAndObject_free(bt); FREE(spilledname); + HTChunkFree(chunk); return HT_INTERRUPTED; } } @@ -3101,6 +3087,7 @@ static int read_directory(HTParentAnchor *parent, ABORT_TARGET; HTBTreeAndObject_free(bt); FREE(spilledname); + HTChunkFree(chunk); return HT_INTERRUPTED; } } else if ((char) ic == CR || (char) ic == LF) { /* Terminator? */ @@ -3433,7 +3420,7 @@ static int setup_connection(const char *name, ; /* null body */ } for ( /*nothing */ ; - *p && *p && *p != '('; + *p && *p != '('; p++) { /*) */ ; /* null body */ } diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index 301214aa..a0640512 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFile.c,v 1.132 2012/08/15 22:10:08 tom Exp $ + * $LynxId: HTFile.c,v 1.135 2013/05/01 00:09:25 tom Exp $ * * File Access HTFile.c * =========== @@ -1169,10 +1169,10 @@ void LYGetFileInfo(const char *filename, LYLocalFileToURL(&Aname, Afn); file_anchor = HTAnchor_findSimpleAddress(Aname); - file_csname = file_anchor->charset; format = HTFileFormat(filename, &myEnc, pdesc); format = HTCharsetFormat(format, file_anchor, UCLYhndl_HTFile_for_unspec); file_cs = HTAnchor_getUCLYhndl(file_anchor, UCT_STAGE_MIME); + file_csname = file_anchor->charset; if (!file_csname) { if (file_cs >= 0) file_csname = LYCharSet_UC[file_cs].MIMEname; @@ -2289,12 +2289,14 @@ static BOOL sniffStream(FILE *fp, char *buffer, size_t needed) long offset = ftell(fp); BOOL result = FALSE; - if (fread(buffer, sizeof(char), needed, fp) == needed) { - result = TRUE; - } - if (fseek(fp, offset, SEEK_SET) < 0) { - CTRACE((tfp, "error seeking in stream\n")); - result = FALSE; + if (offset >= 0) { + if (fread(buffer, sizeof(char), needed, fp) == needed) { + result = TRUE; + } + if (fseek(fp, offset, SEEK_SET) < 0) { + CTRACE((tfp, "error seeking in stream\n")); + result = FALSE; + } } return result; } @@ -2385,6 +2387,7 @@ static int decompressAndParse(HTParentAnchor *anchor, char *localname = filename; int bin; FILE *fp; + int result = FALSE; #ifdef VMS /* @@ -2443,6 +2446,7 @@ static int decompressAndParse(HTParentAnchor *anchor, if (isDOWNLOAD(cftGzip)) { if (isGzipStream(fp)) { fclose(fp); + fp = 0; gzfp = gzopen(localname, BIN_R); CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", @@ -2464,6 +2468,7 @@ static int decompressAndParse(HTParentAnchor *anchor, if (isDOWNLOAD(cftBzip2)) { if (isBzip2Stream(fp)) { fclose(fp); + fp = 0; bzfp = BZ2_bzopen(localname, BIN_R); CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", @@ -2520,6 +2525,7 @@ static int decompressAndParse(HTParentAnchor *anchor, if (strcmp(format_out->name, "www/download") != 0) { if (isGzipStream(fp)) { fclose(fp); + fp = 0; gzfp = gzopen(localname, BIN_R); CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", @@ -2537,6 +2543,7 @@ static int decompressAndParse(HTParentAnchor *anchor, if (strcmp(format_out->name, "www/download") != 0) { if (isBzip2Stream(fp)) { fclose(fp); + fp = 0; bzfp = BZ2_bzopen(localname, BIN_R); CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", @@ -2621,11 +2628,14 @@ static int decompressAndParse(HTParentAnchor *anchor, #endif /* USE_ZLIB || USE_BZLIB */ { *statusp = HTParseFile(format, format_out, anchor, fp, sink); + } + if (fp != 0) { fclose(fp); + fp = 0; } - return TRUE; + result = TRUE; } /* If successful open */ - return FALSE; + return result; } /* Load a document. diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c index 0dfc7a68..ebf18db7 100644 --- a/WWW/Library/Implementation/HTFinger.c +++ b/WWW/Library/Implementation/HTFinger.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFinger.c,v 1.29 2011/05/24 09:21:13 tom Exp $ + * $LynxId: HTFinger.c,v 1.30 2013/01/04 21:40:19 tom Exp $ * * FINGER ACCESS HTFinger.c * ============= @@ -163,11 +163,7 @@ static int response(char *command, PUTS(sitename); END(HTML_EM); PUTS(": "); - if (command) { - StrAllocCopy(cmd, command); - } else { - StrAllocCopy(cmd, ""); - } + StrAllocCopy(cmd, command); for (i = ((int) strlen(cmd) - 1); i >= 0; i--) { if (cmd[i] == LF || cmd[i] == CR) { cmd[i] = '\0'; diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c index 3ce376d6..57492b1d 100644 --- a/WWW/Library/Implementation/HTGopher.c +++ b/WWW/Library/Implementation/HTGopher.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTGopher.c,v 1.56 2012/11/17 01:33:36 tom Exp $ + * $LynxId: HTGopher.c,v 1.58 2013/01/04 21:10:29 tom Exp $ * * GOPHER ACCESS HTGopher.c * ============= @@ -742,6 +742,7 @@ static void free_CSOfields(void) */ static void interpret_cso_key(const char *key, char *buf, + size_t bufsize, int *length, CSOformgen_context * ctx, HTStream *Target) @@ -856,7 +857,7 @@ static void interpret_cso_key(const char *key, while (*key && (*key != ')')) { buf[out++] = (*key++); - if (out > sizeof(buf) - 2) { + if (out > bufsize - 2) { buf[out] = '\0'; (*Target->isa->put_block) (Target, buf, (int) strlen(buf)); out = 0; @@ -1087,6 +1088,7 @@ static int parse_cso_fields(char *buf, static int generate_cso_form(char *host, int port, char *buf, + size_t bufsize, HTStream *Target) { int i, j, length; @@ -1159,7 +1161,7 @@ static int generate_cso_form(char *host, */ ctx.cur_line = i; ctx.cur_off = j; - interpret_cso_key(key, buf, &length, &ctx, Target); + interpret_cso_key(key, buf, bufsize, &length, &ctx, Target); i = ctx.cur_line; j = ctx.cur_off; line = ctemplate[i]; @@ -1202,7 +1204,7 @@ static int generate_cso_form(char *host, * Non-command text, add to output buffer. */ buf[out++] = line[j]; - if (out > (sizeof(buf) - 3)) { + if (out > (bufsize - 3)) { buf[out] = '\0'; (*Target->isa->put_block) (Target, buf, (int) strlen(buf)); out = 0; @@ -1537,7 +1539,7 @@ static int HTLoadCSO(const char *arg, } anAnchor->safe = TRUE; if (isBEmpty(anAnchor->post_data)) { - generate_cso_form(host, port, buf, Target); + generate_cso_form(host, port, buf, sizeof(buf), Target); (*Target->isa->_free) (Target); FREE(host); NETCLOSE(s); diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c index fee62404..996bea3d 100644 --- a/WWW/Library/Implementation/HTList.c +++ b/WWW/Library/Implementation/HTList.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTList.c,v 1.18 2010/04/29 09:59:31 tom Exp $ + * $LynxId: HTList.c,v 1.19 2013/01/04 00:31:27 tom Exp $ * * A small List class HTList.c * ================== @@ -263,23 +263,23 @@ void *HTList_removeObjectAt(HTList *me, int position) HTList *temp = me; HTList *prevNode; int pos = position; + void *result = NULL; - if (!temp || pos < 0) - return NULL; - - prevNode = temp; - while ((temp = temp->next)) { - if (pos == 0) { - prevNode->next = temp->next; + if (temp != NULL && pos >= 0) { + prevNode = temp; + while ((temp = temp->next) != NULL) { + if (pos == 0) { + prevNode->next = temp->next; + result = temp->object; + FREE(temp); + break; + } prevNode = temp; - FREE(temp); - return prevNode->object; + pos--; } - prevNode = temp; - pos--; } - return NULL; /* Reached the end of the list */ + return result; } /* Unlink object from START of list (the Last one inserted diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index a8e41974..8a420736 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTMIME.c,v 1.79 2012/08/22 09:48:46 tom Exp $ + * $LynxId: HTMIME.c,v 1.84 2013/04/30 08:46:21 tom Exp $ * * MIME Message Parse HTMIME.c * ================== @@ -625,7 +625,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Cache-Control: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Convert to lowercase and indicate in anchor. - FM @@ -687,7 +687,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Base: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -698,7 +698,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Disposition: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -747,7 +747,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Encoding: '%s'\n", me->value)); - if (!(me->value && *me->value) || + if (me->value[0] == '\0' || !strcasecomp(me->value, "identity")) break; /* @@ -779,7 +779,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Language: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Convert to lowercase and indicate in anchor. - FM @@ -791,7 +791,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Length: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Convert to integer and indicate in anchor. - FM @@ -806,7 +806,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Location: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -817,7 +817,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-MD5: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -833,7 +833,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Transfer-Encoding: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Force the Content-Transfer-Encoding value to all lower case. - FM @@ -845,7 +845,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Content-Type: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Force the Content-Type value to all lower case and strip spaces and @@ -864,7 +864,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Date: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -877,7 +877,7 @@ static int dispatchField(HTStream *me) */ CTRACE((tfp, "HTMIME: PICKED UP ETag: %s\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -888,7 +888,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Expires: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -904,7 +904,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Last-Modified: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -930,7 +930,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Pragma: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Check whether to set no_cache for the anchor. - FM @@ -963,7 +963,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Safe: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor if "YES" or "TRUE". - FM @@ -984,7 +984,7 @@ static int dispatchField(HTStream *me) HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Server: '%s'\n", me->value)); - if (!(me->value && *me->value)) + if (me->value[0] == '\0') break; /* * Indicate in anchor. - FM @@ -2332,6 +2332,7 @@ static void HTmmdec_base64(char **t, for (j = 0; j <= count; j++) { if (!(p = strchr(HTmm64, s[j]))) { + FREE(buf); return; } d = (int) (p - HTmm64); diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c index 35b36719..941d19af 100644 --- a/WWW/Library/Implementation/HTRules.c +++ b/WWW/Library/Implementation/HTRules.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTRules.c,v 1.42 2010/06/17 21:33:35 tom Exp $ + * $LynxId: HTRules.c,v 1.43 2013/05/01 00:45:32 tom Exp $ * * Configuration manager for Hypertext Daemon HTRules.c * ========================================== @@ -453,7 +453,7 @@ int HTSetConfiguration(char *config) { HTRuleOp op; char *line = NULL; - char *pointer = line; + char *pointer = NULL; char *word1; const char *word2; const char *word3; diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 0a8f7411..1539a8b8 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTTP.c,v 1.126 2012/11/13 22:49:46 tom Exp $ + * $LynxId: HTTP.c,v 1.127 2013/01/04 09:42:02 tom Exp $ * * HyperText Tranfer Protocol - Client implementation HTTP.c * ========================== @@ -194,10 +194,8 @@ void HTSSLInitPRNG(void) RAND_file_name(rand_file, 256L); CTRACE((tfp, "HTTP: Seeding PRNG\n")); - if (rand_file != NULL) { - /* Seed as much as 1024 bytes from RAND_file_name */ - RAND_load_file(rand_file, 1024L); - } + /* Seed as much as 1024 bytes from RAND_file_name */ + RAND_load_file(rand_file, 1024L); /* Seed in time (mod_ssl does this) */ RAND_seed((unsigned char *) &t, (int) sizeof(time_t)); @@ -212,10 +210,8 @@ void HTSSLInitPRNG(void) l = lynx_rand(); RAND_seed((unsigned char *) &l, (int) sizeof(long)); } - if (rand_file != NULL) { - /* Write a rand_file */ - RAND_write_file(rand_file); - } + /* Write a rand_file */ + RAND_write_file(rand_file); } #endif /* SSLEAY_VERSION_NUMBER >= 0x00905100 */ return; diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c index f525d5c7..4e01a912 100644 --- a/WWW/Library/Implementation/HTTelnet.c +++ b/WWW/Library/Implementation/HTTelnet.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTTelnet.c,v 1.39 2009/11/21 17:05:33 Bela.Lubkin Exp $ + * $LynxId: HTTelnet.c,v 1.40 2013/01/04 21:42:42 tom Exp $ * * Telnet Access, Rlogin, etc HTTelnet.c * ========================== @@ -101,7 +101,7 @@ static int remote_session(char *acc_method, char *host) if (port) *port++ = '\0'; /* Split */ - if (!hostname || *hostname == '\0') { + if (*hostname == '\0') { CTRACE((tfp, "HTTelnet: No host specified!\n")); return HT_NO_DATA; } else if (!valid_hostname(hostname)) { diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h index 60106f72..a083df4a 100644 --- a/WWW/Library/Implementation/HTUtils.h +++ b/WWW/Library/Implementation/HTUtils.h @@ -1,5 +1,5 @@ /* - * $LynxId: HTUtils.h,v 1.112 2012/08/15 23:11:48 tom Exp $ + * $LynxId: HTUtils.h,v 1.113 2013/04/30 22:45:03 tom Exp $ * * Utility macros for the W3 code library * MACROS FOR GENERAL USE @@ -55,8 +55,6 @@ char *alloca(); #include <sys/types.h> #include <stdio.h> -#define DONT_TRACK_INTERNAL_LINKS 1 - /* Explicit system-configure */ #ifdef VMS #define NO_SIZECHANGE diff --git a/config.hin b/config.hin index 24270671..190e6040 100644 --- a/config.hin +++ b/config.hin @@ -1,5 +1,5 @@ /* - * $LynxId: config.hin,v 1.127 2012/08/03 12:24:16 tom Exp $ + * $LynxId: config.hin,v 1.128 2013/04/30 10:57:49 tom Exp $ * vile:cmode * * The configure script translates "config.hin" into "lynx_cfg.h" @@ -32,7 +32,6 @@ #undef DISABLE_NEWS /* CF_ARG_DISABLE(news) */ #undef DISP_PARTIAL /* CF_ARG_ENABLE(partial) */ #undef DONT_HAVE_TM_GMTOFF /* CF_TM_GMTOFF */ -#undef DONT_TRACK_INTERNAL_LINKS /* CF_ARG_DISABLE(internal-links) */ #undef ENABLE_IPV6 /* CF_CHECK_IPV6 */ #undef ENABLE_NLS /* defined if NLS is requested */ #undef ENABLE_OPTS_CHANGE_EXEC /* CF_ARG_ENABLE(change-exec) */ @@ -176,6 +175,7 @@ #undef HAVE_WINSOCK_H /* CF_NETLIBS */ #undef HAVE_WREDRAWLN #undef HAVE_WRESIZE +#undef TRACK_INTERNAL_LINKS /* CF_ARG_DISABLE(internal-links) */ #undef HAVE_XCURSES /* CF_PDCURSES_X11 */ #undef HAVE_ZERROR #undef HAVE__NC_FREEALL /* ncurses debugging extension */ diff --git a/configure b/configure index cd18d13a..6624171b 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in 2.8.8dev.14. +# From configure.in 2.8.8dev.15. # Guess values for system-dependent variables and create Makefiles. # Generated by Autoconf 2.52.20121002. # @@ -33616,9 +33616,9 @@ else fi; echo "$as_me:33617: result: $use_internal_links" >&5 echo "${ECHO_T}$use_internal_links" >&6 -test $use_internal_links = no && +test $use_internal_links = yes && cat >>confdefs.h <<\EOF -#define DONT_TRACK_INTERNAL_LINKS 1 +#define TRACK_INTERNAL_LINKS 1 EOF echo "$as_me:33624: checking if you want to fork NSL requests" >&5 diff --git a/configure.in b/configure.in index 75c46d9b..c5378745 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $LynxId: configure.in,v 1.245 2012/11/19 00:20:40 tom Exp $ +dnl $LynxId: configure.in,v 1.246 2013/04/30 09:56:33 tom Exp $ dnl dnl Process this file with autoconf to produce a configure script. dnl @@ -7,7 +7,7 @@ dnl by T.E.Dickey <dickey@invisible-island.net> dnl and Jim Spath <jspath@mail.bcpl.lib.md.us> dnl dnl --------------------------------------------------------------------------- -dnl Copyright 1997-2010,2011 by Thomas E. Dickey +dnl Copyright 1997-2012,2013 by Thomas E. Dickey dnl dnl Permission to use, copy, modify, and distribute this software and its dnl documentation for any purpose and without fee is hereby granted, @@ -1179,7 +1179,7 @@ CF_ARG_ENABLE(internal-links, [use_internal_links=yes], [use_internal_links=no]) AC_MSG_RESULT($use_internal_links) -test $use_internal_links = no && AC_DEFINE(DONT_TRACK_INTERNAL_LINKS,1,[Define to 1 if you want internal-links feature]) +test $use_internal_links = yes && AC_DEFINE(TRACK_INTERNAL_LINKS,1,[Define to 1 if you want internal-links feature]) dnl -------------------------------------------------------------------------- AC_MSG_CHECKING(if you want to fork NSL requests) diff --git a/lynx.cfg b/lynx.cfg index cecf9963..8cff66f2 100644 --- a/lynx.cfg +++ b/lynx.cfg @@ -1,4 +1,4 @@ -# $LynxId: lynx.cfg,v 1.223 2012/11/19 00:20:40 tom Exp $ +# $LynxId: lynx.cfg,v 1.224 2013/04/30 09:50:29 tom Exp $ # lynx.cfg file. # The default placement for this file is /usr/local/lib/lynx.cfg (Unix) # or Lynx_Dir:lynx.cfg (VMS) @@ -3650,3 +3650,16 @@ COLOR:6:brightred:black # # See also BLAT_MAIL and SYSTEM_MAIL flags. #ALT_BLAT_MAIL:FALSE +.h1 Internal Behavior +.h2 TRACK_INTERNAL_LINKS +# With `internal links' (links within a document to a location within the same +# document) enabled, Lynx will distinguish between, for example, `<A +# HREF="foo#frag">' and `<A HREF="#frag">' within a document whose URL is +# `foo'. It may handle such links differently, although practical differences +# would appear only if the document containing them resulted from a POST +# request or had a no-cache flag set. This feature attempts to interpret +# URL-references as suggested by RFC 2396, and to prevent mistaken +# resubmissions of form content with the POST method. An alternate opinion +# asserts that the feature could actually result in inappropriate resubmission +# of form content. +#TRACK_INTERNAL_LINKS:FALSE 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) |