aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c17
-rw-r--r--src/HTInit.c3
-rw-r--r--src/LYBookmark.c11
-rw-r--r--src/LYCookie.c4
-rw-r--r--src/LYCurses.c2
-rw-r--r--src/LYHistory.c5
-rw-r--r--src/LYMail.c5
-rw-r--r--src/LYMain.c11
-rw-r--r--src/LYMainLoop.c102
-rw-r--r--src/LYNews.c12
-rw-r--r--src/LYReadCFG.c2
-rw-r--r--src/LYStrings.c29
-rw-r--r--src/LYStrings.h2
-rw-r--r--src/LYStyle.c4
-rw-r--r--src/LYTraversal.c4
-rw-r--r--src/LYrcFile.c2
16 files changed, 101 insertions, 114 deletions
diff --git a/src/GridText.c b/src/GridText.c
index 4b836bfd..43cf525f 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -562,7 +562,7 @@ PUBLIC HText * HText_new ARGS1(
self->LastChar = '\0';
self->IgnoreExcess = FALSE;
-#ifndef USE_PSRC
+#ifndef PSRC_TEST
if (HTOutputFormat == WWW_SOURCE)
self->source = YES;
else
@@ -6231,10 +6231,6 @@ PUBLIC BOOLEAN HTreparse_document NOARGS
if (!ok) {
FREE(source_cache_filename);
}
-#ifdef USE_PSRC
- else if (LYpsrc && psrc_view)
- HTMainText->source = TRUE;
-#endif
}
if (LYCacheSource == SOURCE_CACHE_MEMORY &&
@@ -6271,10 +6267,6 @@ PUBLIC BOOLEAN HTreparse_document NOARGS
HTChunkFree(source_cache_chunk);
source_cache_chunk = NULL;
}
-#ifdef USE_PSRC
- else if (LYpsrc && psrc_view)
- HTMainText->source = TRUE;
-#endif
}
/*
@@ -6284,13 +6276,8 @@ PUBLIC BOOLEAN HTreparse_document NOARGS
CTRACE(tfp, "Reparse %s\n", (ok ? "succeeded" : "failed"));
- if (ok) {/* fix few flags: */
+ if (ok) {
from_source_cache = TRUE; /* flag for mainloop events */
-#ifdef USE_PSRC
- if (LYpsrc && psrc_view)
- HTMainText->source = TRUE;
-#endif
- more = HText_canScrollDown(); /* the length may be changed */
}
return ok;
diff --git a/src/HTInit.c b/src/HTInit.c
index 836a3422..e08d9b63 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -279,7 +279,7 @@ PRIVATE int ProcessMailcapEntry ARGS2(
if (!rawentry)
ExitWithError(MEMORY_EXHAUSTED_ABORT);
*rawentry = '\0';
- while ((LineBuf = LYSafeGets(LineBuf, fp)) != 0) {
+ while (LYSafeGets(&LineBuf, fp) != 0) {
if (LineBuf[0] == '#')
continue;
len = strlen(LineBuf);
@@ -301,6 +301,7 @@ PRIVATE int ProcessMailcapEntry ARGS2(
break;
}
}
+ FREE(LineBuf);
s = LYSkipBlanks(rawentry);
if (!*s) {
diff --git a/src/LYBookmark.c b/src/LYBookmark.c
index 4fe72e30..2cd5d7cf 100644
--- a/src/LYBookmark.c
+++ b/src/LYBookmark.c
@@ -53,7 +53,7 @@ PUBLIC char * get_bookmark_filename ARGS1(
char **, URL)
{
static char filename_buffer[LY_MAXPATH];
- char *string_buffer;
+ char *string_buffer = 0;
FILE *fp;
int MBM_tmp;
@@ -107,7 +107,7 @@ success:
* We now have the file open.
* Check if it is a mosaic hotlist.
*/
- if ((string_buffer = LYSafeGets(NULL, fp)) != 0
+ if (LYSafeGets(&string_buffer, fp) != 0
&& !strncmp(string_buffer, "ncsa-xmosaic-hotlist-format-1", 29)) {
char *newname;
/*
@@ -157,7 +157,7 @@ PRIVATE char * convert_mosaic_bookmark_file ARGS1(
remove bookmark command, it is usually the 'R' key but may have\n\
been remapped by you or your system administrator."));
- while ((buf = LYSafeGets(buf, fp)) != NULL) {
+ while ((LYSafeGets(&buf, fp)) != NULL) {
if(line >= 0) {
endline = &buf[strlen(buf)-1];
if(*endline == '\n')
@@ -466,7 +466,7 @@ PUBLIC void remove_bookmark_link ARGS2(
if (is_mosaic_hotlist) {
int del_line = cur*2; /* two lines per entry */
n = -3; /* skip past cookie and name lines */
- while ((buf = LYSafeGets(buf, fp)) != NULL) {
+ while (LYSafeGets(&buf, fp) != NULL) {
n++;
if (n == del_line || n == del_line+1)
continue; /* remove two lines */
@@ -480,7 +480,7 @@ PUBLIC void remove_bookmark_link ARGS2(
int seen;
n = -1;
- while ((buf = LYSafeGets(buf, fp)) != NULL) {
+ while (LYSafeGets(&buf, fp) != NULL) {
retain = TRUE;
seen = 0;
cp = buf;
@@ -563,6 +563,7 @@ PUBLIC void remove_bookmark_link ARGS2(
#endif /* UNIX */
failure:
+ FREE(buf);
HTAlert(BOOKMARK_DEL_FAILED);
LYCloseTempFP(nfp);
if (fp != NULL)
diff --git a/src/LYCookie.c b/src/LYCookie.c
index 162bd765..1597d49a 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -1976,7 +1976,7 @@ PUBLIC void LYLoadCookies ARGS1 (
CTRACE(tfp, "LYLoadCookies: reading cookies from %s\n", cookie_file);
number_of_file_cookies = 0;
- while ((buf = LYSafeGets(buf, cookie_handle)) != 0) {
+ while (LYSafeGets(&buf, cookie_handle) != 0) {
cookie *moo;
unsigned i = 0;
int tok_loop;
@@ -1993,7 +1993,7 @@ PUBLIC void LYLoadCookies ARGS1 (
* cookie.
*/
- while(buf[i] != '\n' && i < sizeof(buf)) {
+ while(buf[i] != '\n' && buf[i] != 0) {
i++;
}
buf[i] = '\0';
diff --git a/src/LYCurses.c b/src/LYCurses.c
index f836bb4d..df255d2d 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -1108,7 +1108,7 @@ PUBLIC BOOLEAN setup ARGS1(
printf("\n\n %s\n\n", gettext("Your Terminal type is unknown!"));
printf(" %s [vt100] ", gettext("Enter a terminal type:"));
- if ((buffer = LYSafeGets(buffer, stdin)) != 0)
+ if (LYSafeGets(&buffer, stdin) != 0)
if ((s = strchr(buffer, '\n')) != NULL)
*s = '\0';
diff --git a/src/LYHistory.c b/src/LYHistory.c
index a25e6602..afaa0512 100644
--- a/src/LYHistory.c
+++ b/src/LYHistory.c
@@ -68,7 +68,10 @@ PUBLIC void LYAddVisitedLink ARGS1(
* or list files. - FM
*/
if (doc->post_data || doc->isHEAD || doc->bookmark ||
- (!strncmp(doc->address, "file://localhost/", 17) && (
+ (/* special url or a temp file */
+ (!strncmp(doc->address, "LYNX", 4) ||
+ !strncmp(doc->address, "file://localhost/", 17))
+ && (
!strcmp((doc->title ? doc->title : ""), HISTORY_PAGE_TITLE) ||
!strcmp((doc->title ? doc->title : ""), PRINT_OPTIONS_TITLE) ||
!strcmp((doc->title ? doc->title : ""), DOWNLOAD_OPTIONS_TITLE) ||
diff --git a/src/LYMail.c b/src/LYMail.c
index eeb96cd5..a5558fae 100644
--- a/src/LYMail.c
+++ b/src/LYMail.c
@@ -744,8 +744,7 @@ PUBLIC void mailmsg ARGS4(
if ((LynxSigFile != NULL) &&
(fp = fopen(LynxSigFile, "r")) != NULL) {
fputs("-- \n", fd);
- FREE(cmd);
- while ((cmd = LYSafeGets(cmd, fp) )!= NULL)
+ while (LYSafeGets(&cmd, fp) != NULL)
fputs(cmd, fd);
fclose(fp);
}
@@ -1691,7 +1690,7 @@ PUBLIC void reply_by_mail ARGS4(
if ((fd = fopen(my_tmpfile, "a")) != NULL) {
char *buffer = NULL;
fputs("-- \n", fd);
- while ((buffer = LYSafeGets(buffer, fp)) != NULL) {
+ while (LYSafeGets(&buffer, fp) != NULL) {
fputs(buffer, fd);
}
fclose(fd);
diff --git a/src/LYMain.c b/src/LYMain.c
index f726f2b9..50c06151 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -974,7 +974,7 @@ PUBLIC int main ARGS2(
if (LYGetStdinArgs == TRUE) {
char *buf = NULL;
- while ((buf = LYSafeGets(buf, stdin)) != 0) {
+ while (LYSafeGets(&buf, stdin) != 0) {
int j;
for (j = strlen(buf) - 1; j > 0 &&
@@ -1051,7 +1051,7 @@ PUBLIC int main ARGS2(
* Build GET data for later. Stop reading when we see
* a line with "---" as its first three characters.
*/
- while ((buf = LYSafeGets(buf, stdin)) != 0 &&
+ while (LYSafeGets(&buf, stdin) != 0 &&
strncmp(buf, "---", 3) != 0) {
int j2;
@@ -1089,7 +1089,7 @@ PUBLIC int main ARGS2(
* Build post data for later. Stop reading when we see
* a line with "---" as its first three characters.
*/
- while ((buf = LYSafeGets(buf, stdin)) != 0 &&
+ while (LYSafeGets(&buf, stdin) != 0 &&
strncmp(buf, "---", 3) != 0) {
int j2;
@@ -1115,6 +1115,7 @@ PUBLIC int main ARGS2(
HTList_appendObject(LYStdinArgs, argument);
}
}
+ FREE(buf);
}
#ifdef SOCKS
@@ -2230,7 +2231,7 @@ static int get_data_fun ARGS1(
* Build GET data for later. Stop reading when we see a line
* with "---" as its first three characters.
*/
- while ((buf = LYSafeGets(buf, stdin)) != 0 &&
+ while (LYSafeGets(&buf, stdin) != 0 &&
strncmp(buf, "---", 3) != 0) {
int j;
@@ -2398,7 +2399,7 @@ static int post_data_fun ARGS1(
* Build post data for later. Stop reading when we see a line with "---"
* as its first three characters.
*/
- while ((buf = LYSafeGets(buf, stdin)) != 0 &&
+ while (LYSafeGets(&buf, stdin) != 0 &&
strncmp(buf, "---", 3) != 0) {
int j;
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 8249e4e7..1106bcb4 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -738,28 +738,28 @@ try_again:
newdoc.internal_link = FALSE;
goto try_again;
} else {
- if (!dump_output_immediately)
+ if (!dump_output_immediately)
cleanup();
#ifdef UNIX
- if (dump_output_immediately) {
+ if (dump_output_immediately) {
fprintf(stderr,
gettext("\nlynx: Start file could not be found or is not text/html or text/plain\n"));
- fprintf(stderr,gettext(" Exiting...\n"));
- } else
+ fprintf(stderr, gettext(" Exiting...\n"));
+ } else
#endif /* UNIX */
- {
- SetOutputMode( O_TEXT );
+ {
+ SetOutputMode( O_TEXT );
- printf(
- "\nlynx: Start file could not be found or is not text/html or text/plain\n");
- printf(" Exiting...\n");
+ printf(
+ gettext("\nlynx: Start file could not be found or is not text/html or text/plain\n"));
+ printf(gettext(" Exiting...\n"));
- SetOutputMode( O_BINARY );
- }
- if (!dump_output_immediately) {
- exit_immediately(-1);
- }
- return(-1);
+ SetOutputMode( O_BINARY );
+ }
+ if (!dump_output_immediately) {
+ exit_immediately(-1);
+ }
+ return(-1);
}
}
@@ -1218,42 +1218,41 @@ try_again:
/*
* If the parse settings have changed since this HText was
* generated, we need to reparse and redraw it. -dsb
+ *
+ * Should be configured to avoid shock for experienced lynx users.
+ * Currently enabled for cached sources only.
*/
if (HTdocument_settings_changed()) {
- HTUserMsg(gettext("Reparsing document under current settings..."));
- if (HTreparse_document()) {}
- else {
+ if (HTcan_reparse_document()) {
+ HTUserMsg(gettext("Reparsing document under current settings..."));
+ if (HTreparse_document()) {}
+ } else {
/*
* Urk. I have no idea how to recover from a failure here.
* At a guess, I'll try reloading. -dsb
*/
+ /* currently disabled ***
+ HTUserMsg(gettext("Reparsing document under current settings..."));
cmd = LYK_RELOAD;
goto new_cmd;
+ */
}
}
/*
* Trying to accomodate HTreparse_document() logic
- * with mainloop events. Set all the necessaty flags here...
+ * with mainloop events. Working out of force_load cycle
+ * set all the necessary flags here, from case NORMAL
+ * (see also LYK_SOURCE, some staff implemented directly there).
*/
if (from_source_cache) {
- from_source_cache = FALSE; /* reset */
-
- /*
- * Make sure curdoc.line will not be equal
- * to Newline, so we get a redraw.
- */
- curdoc.line = -1;
+ from_source_cache = FALSE; /* done */
/*
- * This information can get clobbered if we go to an internal
- * page while viewing source. Normally it would be recreated
- * by reloading the file; we have to do it ourselves. -dsb
+ * Make sure curdoc.line will not be equal
+ * to Newline, so we get a redraw.
*/
- if (curdoc.link < 0 && nlinks > 0)
- curdoc.link = 0;
-
- refresh_screen = TRUE; /* ? */
+ curdoc.line = -1;
}
#endif
@@ -1262,6 +1261,7 @@ try_again:
* If the curdoc.line is different than Newline then there must
* have been a change since last update. Run HText_pageDisplay()
* create a fresh screen of text out.
+ * All display_partial calls ends here for final redraw.
*/
if (curdoc.line != Newline) {
@@ -1344,16 +1344,6 @@ try_again:
*/
more = HText_canScrollDown();
-#ifdef SOURCE_CACHE
- /*
- * This information can get clobbered if we go to an internal
- * page while viewing source, or if the page length changes
- * between reparses. Normally it would be recreated by
- * reloading the file; we have to do it ourselves. -dsb
- */
- if (curdoc.link < 0 && nlinks > 0)
- curdoc.link = 0;
-#endif
if (user_mode == NOVICE_MODE)
noviceline(more); /* print help message */
refresh_screen = FALSE;
@@ -2083,14 +2073,14 @@ new_cmd: /*
}
#ifdef SOURCE_CACHE
if (HTreparse_document()) {
- break; /* OK */
+ break; /* OK */
}
#endif
break;
case LYK_SOFT_DQUOTES:
#ifdef SOURCE_CACHE
- if (!HTcan_reparse_document()) {
+ if (!HTcan_reparse_document()) {
#endif
/*
* Check if this is a reply from a POST, and if so,
@@ -2171,24 +2161,24 @@ new_cmd: /*
#endif /* NO_ASSUME_SAME_DOC */
}
#ifdef SOURCE_CACHE
- } /* end if no bypass */
+ } /* end if no bypass */
#endif
Old_DTD = !Old_DTD;
HTSwitchDTD(!Old_DTD);
HTUserMsg(Old_DTD ? USING_DTD_0 : USING_DTD_1);
#ifdef SOURCE_CACHE
- if (HTcan_reparse_document()) {
- if (HTisDocumentSource() && LYPreparsedSource) {
+ if (HTcan_reparse_document()) {
+ if (HTisDocumentSource() && LYPreparsedSource) {
#ifdef USE_PSRC
- if (LYpsrc)
- psrc_view = TRUE;
- else
+ if (LYpsrc)
+ psrc_view = TRUE;
+ else
#endif
- HTOutputFormat = WWW_SOURCE;
- }
- if (HTreparse_document()) {
- break;
- }
+ HTOutputFormat = WWW_SOURCE;
+ }
+ if (HTreparse_document()) {
+ break;
+ }
} /* end if no bypass */
#endif
break;
diff --git a/src/LYNews.c b/src/LYNews.c
index d5106bb7..1b27f644 100644
--- a/src/LYNews.c
+++ b/src/LYNews.c
@@ -37,7 +37,7 @@ PRIVATE BOOLEAN message_has_content ARGS1(
filename ? filename : "(<null>)");
return FALSE;
}
- while ((buffer = LYSafeGets(buffer, fp)) != NULL) {
+ while (LYSafeGets(&buffer, fp) != NULL) {
char *cp = buffer;
char firstnonblank = '\0';
if (*cp == '\0') {
@@ -70,6 +70,7 @@ PRIVATE BOOLEAN message_has_content ARGS1(
in_headers = FALSE;
}
}
+ FREE(buffer);
fclose(fp);
return FALSE;
}
@@ -239,8 +240,8 @@ PUBLIC char *LYNewsPost ARGS2(
StrAllocCat(cp, org);
#ifndef VMS
} else if ((fp = fopen("/etc/organization", "r")) != NULL) {
- char *buffer;
- if ((buffer = LYSafeGets(NULL, fp)) != NULL) {
+ char *buffer = 0;
+ if (LYSafeGets(&buffer, fp) != NULL) {
if ((org = strchr(buffer, '\n')) != NULL) {
*org = '\0';
}
@@ -248,6 +249,7 @@ PUBLIC char *LYNewsPost ARGS2(
StrAllocCat(cp, buffer);
}
}
+ FREE(buffer);
fclose(fp);
#endif /* !VMS */
}
@@ -384,7 +386,7 @@ PUBLIC char *LYNewsPost ARGS2(
if ((fd = LYAppendToTxtFile (my_tempfile)) != NULL) {
char *buffer = NULL;
fputs("-- \n", fd);
- while ((buffer = LYSafeGets(buffer, fp)) != NULL) {
+ while (LYSafeGets(&buffer, fp) != NULL) {
fputs(buffer, fd);
}
fclose(fd);
@@ -406,7 +408,7 @@ PUBLIC char *LYNewsPost ARGS2(
if (CJKfile[0] != '\0') {
if ((fd = fopen(my_tempfile, "r")) != NULL) {
char *buffer = NULL;
- while ((buffer = LYSafeGets(buffer, fd)) != NULL) {
+ while (LYSafeGets(&buffer, fd) != NULL) {
TO_JIS((unsigned char *)buffer,
(unsigned char *)CJKinput);
fputs(CJKinput, fc);
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index afdfbd77..dacdc65d 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1294,7 +1294,7 @@ PRIVATE void do_read_cfg ARGS5(
/*
* Process each line in the file.
*/
- while ((buffer = LYSafeGets(buffer, fp)) != 0) {
+ while (LYSafeGets(&buffer, fp) != 0) {
char *name, *value;
char *cp;
Config_Type *tbl;
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 357a8d65..572af317 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -905,7 +905,7 @@ PRIVATE int read_keymap_file NOARGS
linenum = 0;
ret = 0;
- while ((line = LYSafeGets(line, fp)) != 0 && (ret == 0))
+ while (LYSafeGets(&line, fp) != 0 && (ret == 0))
{
char *s = LYSkipBlanks(line);
@@ -2947,29 +2947,32 @@ PUBLIC int UPPER8 ARGS2(int,ch1, int,ch2)
/*
* Replaces 'fgets()' calls into a fixed-size buffer with reads into a buffer
- * that is allocated. When an EOF or error is found, the buffer is automatically
- * freed.
+ * that is allocated. When an EOF or error is found, the buffer is freed
+ * automatically.
*/
PUBLIC char *LYSafeGets ARGS2(
- char *, src,
- FILE *, fp)
+ char **, src,
+ FILE *, fp)
{
char buffer[BUFSIZ];
char *result = 0;
if (src != 0)
- *src = 0;
+ result = *src;
+ if (result != 0)
+ *result = 0;
- while (fgets(buffer, sizeof(buffer)-1, fp) != 0) {
+ while (fgets(buffer, sizeof(buffer), fp) != 0) {
if (*buffer)
- result = StrAllocCat(src, buffer);
+ result = StrAllocCat(result, buffer);
if (strchr(buffer, '\n') != 0)
break;
- if (feof(fp)
- || ferror(fp)) {
- FREE(src);
- break;
- }
}
+ if (feof(fp)
+ || ferror(fp)) {
+ FREE(result);
+ }
+ if (src != 0)
+ *src = result;
return result;
}
diff --git a/src/LYStrings.h b/src/LYStrings.h
index 14092080..d3f4b582 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -82,7 +82,7 @@ extern char * SNACat PARAMS((
#define StrnAllocCopy(dest, src, n) SNACopy (&(dest), src, n)
#define StrnAllocCat(dest, src, n) SNACat (&(dest), src, n)
-extern char *LYSafeGets PARAMS((char * src, FILE * fp));
+extern char *LYSafeGets PARAMS((char ** src, FILE * fp));
/* values for LYgetch */
#define UPARROW 256 /* 0x100 */
diff --git a/src/LYStyle.c b/src/LYStyle.c
index ae172168..cab00fa7 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,6 +1,6 @@
/* character level styles for Lynx
* (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
- * @Id: LYStyle.c 1.25 Fri, 23 Apr 1999 08:56:35 -0600 dickey @
+ * @Id: LYStyle.c 1.26 Tue, 27 Apr 1999 06:59:06 -0600 dickey @
*/
#include <HTUtils.h>
#include <HTML.h>
@@ -415,7 +415,7 @@ PUBLIC int style_readFromFile ARGS1(char*, file)
style_initialiseHashTable();
style_deleteStyleList();
- while ((buffer = LYSafeGets(buffer, fh)) != NULL)
+ while (LYSafeGets(&buffer, fh) != NULL)
{
LYTrimTrailing(buffer);
LYTrimTail(buffer);
diff --git a/src/LYTraversal.c b/src/LYTraversal.c
index fd528ecc..afa4d289 100644
--- a/src/LYTraversal.c
+++ b/src/LYTraversal.c
@@ -48,7 +48,7 @@ PUBLIC BOOLEAN lookup ARGS1(char *,target)
HTSprintf0(&line, "%s\n", target);
- while((buffer = LYSafeGets(buffer, ifp)) != NULL) {
+ while (LYSafeGets(&buffer, ifp) != NULL) {
if (STREQ(line,buffer)) {
result = TRUE;
break;
@@ -151,7 +151,7 @@ PUBLIC BOOLEAN lookup_reject ARGS1(char *,target)
HTSprintf0(&line, "%s\n", target);
- while ((buffer = LYSafeGets(buffer, ifp)) != NULL && !result) {
+ while (LYSafeGets(&buffer, ifp) != NULL && !result) {
frag = strlen(buffer) - 1; /* real length, minus trailing null */
ch = buffer[frag - 1]; /* last character in buffer */
if (frag > 0) { /* if not an empty line */
diff --git a/src/LYrcFile.c b/src/LYrcFile.c
index 531a03c2..5f5227de 100644
--- a/src/LYrcFile.c
+++ b/src/LYrcFile.c
@@ -56,7 +56,7 @@ PUBLIC void read_rc NOPARAMS
/*
* Process the entries.
*/
- while ((line_buffer = LYSafeGets(line_buffer, fp)) != NULL) {
+ while (LYSafeGets(&line_buffer, fp) != NULL) {
/*
* Remove any trailing white space.
*/