[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev PATCH [dev21]: source caching, take 2
From: |
Scott Bigham |
Subject: |
Re: lynx-dev PATCH [dev21]: source caching, take 2 |
Date: |
Mon, 12 Apr 1999 10:02:51 -0400 (EDT) |
On Mon, 12 Apr 1999 address@hidden wrote:
> I (or rather 'patch') cannot make sense of this file.
No? It's just a straightforward 'diff -c'; it seems to have worked for
Leonid, at least. Could it have gotten munged in the attachment
process? I'll try it again inline.
-sbigham
*** ./src/GridText.c.orig Tue Mar 30 12:10:37 1999
--- ./src/GridText.c Sun Apr 11 22:31:11 1999
***************
*** 46,51 ****
--- 46,55 ----
#undef DEBUG_APPCH
+ #ifdef SOURCE_CACHE
+ #include <HTFile.h>
+ #endif
+
#ifdef USE_COLOR_STYLE
#include <AttrList.h>
#include <LYHash.h>
***************
*** 114,119 ****
--- 118,129 ----
PUBLIC BOOLEAN underline_on = OFF;
PUBLIC BOOLEAN bold_on = OFF;
+ #ifdef SOURCE_CACHE
+ PUBLIC char * source_cache_filename = NULL;
+ PUBLIC HTChunk * source_cache_chunk = NULL;
+ PUBLIC int LYCacheSource = SOURCE_CACHE_NONE;
+ #endif
+
#if defined(USE_COLOR_STYLE)
#define MAX_STYLES_ON_LINE 64
***************
*** 173,178 ****
--- 183,204 ----
*/
struct _HText {
HTParentAnchor * node_anchor;
+ #ifdef SOURCE_CACHE
+ char * source_cache_file;
+ HTChunk * source_cache_chunk;
+ /*
+ * Parse settings when this HText was generated.
+ */
+ BOOLEAN clickable_images;
+ BOOLEAN pseudo_inline_alts;
+ BOOLEAN raw_mode;
+ BOOLEAN historical_comments;
+ BOOLEAN minimal_comments;
+ BOOLEAN soft_dquotes;
+ BOOLEAN old_dtd;
+ int lines; /* Screen size */
+ int cols;
+ #endif
HTLine * last_line;
int Lines; /* Number of them */
int chars; /* Number of them */
***************
*** 483,488 ****
--- 509,542 ----
self->stale = YES;
self->toolbar = NO;
self->tabs = NULL;
+ #ifdef SOURCE_CACHE
+ /*
+ * Yes, this is a Gross And Disgusting Hack(TM), I know...
+ */
+ self->source_cache_file = NULL;
+ if (LYCacheSource == SOURCE_CACHE_FILE && source_cache_filename) {
+ StrAllocCopy(self->source_cache_file, source_cache_filename);
+ FREE(source_cache_filename);
+ }
+ self->source_cache_chunk = NULL;
+ if (LYCacheSource == SOURCE_CACHE_MEMORY && source_cache_chunk) {
+ self->source_cache_chunk = source_cache_chunk;
+ source_cache_chunk = NULL;
+ }
+
+ /*
+ * Remember the parse settings.
+ */
+ self->clickable_images = clickable_images;
+ self->pseudo_inline_alts = pseudo_inline_alts;
+ self->raw_mode = LYRawMode;
+ self->historical_comments = historical_comments;
+ self->minimal_comments = minimal_comments;
+ self->soft_dquotes = soft_dquotes;
+ self->old_dtd = Old_DTD;
+ self->lines = LYlines;
+ self->cols = LYcols;
+ #endif
/*
* If we are going to render the List Page, always merge in hidden
* links to get the numbering consistent if form fields are numbered
***************
*** 729,734 ****
--- 783,805 ----
HTMainAnchor = NULL;
}
+ #ifdef SOURCE_CACHE
+ /*
+ * Clean up the source cache, if any.
+ */
+ if (self->source_cache_file) {
+ CTRACE(tfp, "Removing source cache file %s\n",
+ self->source_cache_file);
+ LYRemoveTemp(self->source_cache_file);
+ FREE(self->source_cache_file);
+ }
+ if (self->source_cache_chunk) {
+ CTRACE(tfp, "Removing memory source cache %p\n",
+ (void *)self->source_cache_chunk);
+ HTChunkFree(self->source_cache_chunk);
+ }
+ #endif
+
FREE(self);
}
***************
*** 6189,6194 ****
--- 6260,6438 ----
CTRACE(tfp, "HTuncache.. HTMainText already is NULL!\n");
}
}
+
+ #ifdef SOURCE_CACHE
+ /*
+ * This is copied more or less verbatim from HTParseFile() in HTFormat.c
+ */
+ PRIVATE int HTParseMem ARGS5(
+ HTFormat, rep_in,
+ HTFormat, format_out,
+ HTParentAnchor *, anchor,
+ HTChunk *, chunk,
+ HTStream *, sink)
+ {
+ HTStream * stream;
+ HTStreamClass targetClass;
+
+ stream = HTStreamStack(rep_in, format_out, sink, anchor);
+ if (!stream) {
+ int rv;
+ char *buffer = 0;
+ HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
+ HTAtom_name(rep_in), HTAtom_name(format_out));
+ CTRACE(tfp, "HTFormat(in HTParseMem): %s\n", buffer);
+ rv = HTLoadError(sink, 501, buffer);
+ FREE(buffer);
+ return rv;
+ }
+
+ /* Shove the data down the stream in one lump. ;) */
+ targetClass = *(stream->isa);
+ (*targetClass.put_block)(stream, chunk->data, chunk->size);
+ (*targetClass._free)(stream);
+ return HT_LOADED;
+ }
+
+ PUBLIC BOOLEAN HTreparse_document NOARGS
+ {
+ BOOLEAN ok = FALSE;
+
+ if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+ (LYCacheSource == SOURCE_CACHE_FILE &&
+ !HTMainText->source_cache_file) ||
+ (LYCacheSource == SOURCE_CACHE_MEMORY &&
+ !HTMainText->source_cache_chunk))
+ return FALSE;
+
+ if (LYCacheSource == SOURCE_CACHE_FILE && HTMainText->source_cache_file) {
+ FILE * fp;
+ HTFormat format;
+ int ret;
+
+ CTRACE(tfp, "Reparsing source cache file %s\n",
+ HTMainText->source_cache_file);
+
+ /*
+ * This is more or less copied out of HTLoadFile(), except we don't
+ * get a content encoding. This may be overkill...
+ */
+ if (HTMainText->node_anchor->content_type) {
+ format = HTAtom_for(HTMainText->node_anchor->content_type);
+ } else {
+ format = HTFileFormat(HTMainText->source_cache_file, NULL, NULL);
+ format = HTCharsetFormat(format, HTMainText->node_anchor,
+ UCLYhndl_HTFile_for_unspec);
+ }
+ CTRACE(tfp, " Content type is \"%s\"\n", format->name);
+
+ /*
+ * Pass the source cache filename on to the next HText. Mark it
+ * NULL here so that it won't get deleted by HText_free().
+ */
+ source_cache_filename = HTMainText->source_cache_file;
+ HTMainText->source_cache_file = NULL;
+
+ fp = fopen(source_cache_filename, "r");
+ if (!fp) {
+ CTRACE(tfp, " Cannot read file %s\n", source_cache_filename);
+ FREE(source_cache_filename);
+ return FALSE;
+ }
+ ret = HTParseFile(format, HTOutputFormat, HTMainText->node_anchor,
+ fp, NULL);
+ fclose(fp);
+ ok = (ret == HT_LOADED);
+ if (!ok)
+ FREE(source_cache_filename);
+ }
+
+ if (LYCacheSource == SOURCE_CACHE_MEMORY &&
+ HTMainText->source_cache_chunk) {
+ HTFormat format = WWW_HTML;
+ int ret;
+
+ CTRACE(tfp, "Reparsing from source memory cache %p\n",
+ (void *)HTMainText->source_cache_chunk);
+
+ /*
+ * Pass the source cache HTChunk on to the next HText. Clear it
+ * here so that it won't get deleted by HText_free().
+ */
+ source_cache_chunk = HTMainText->source_cache_chunk;
+ HTMainText->source_cache_chunk = NULL;
+
+ ret = HTParseMem(format, HTOutputFormat, HTMainText->node_anchor,
+ source_cache_chunk, NULL);
+ ok = (ret == HT_LOADED);
+ if (!ok) {
+ HTChunkFree(source_cache_chunk);
+ source_cache_chunk = NULL;
+ }
+ }
+
+ CTRACE(tfp, "Reparse %s\n", (ok ? "succeeded" : "failed"));
+ return ok;
+ }
+
+ PRIVATE void trace_setting_change ARGS3(
+ CONST char *, name,
+ BOOLEAN, prev_setting,
+ BOOLEAN, new_setting)
+ {
+ if (prev_setting != new_setting)
+ CTRACE(tfp, "HTdocument_settings_changed: %s setting has changed (was
%s, now %s)\n",
+ name, prev_setting ? "ON" : "OFF", new_setting ? "ON" : "OFF");
+ }
+
+ PUBLIC BOOLEAN HTdocument_settings_changed NOARGS
+ {
+ /*
+ * Annoying Hack(TM): If we don't have a source cache, we can't
+ * reparse anyway, so pretend the settings haven't changed.
+ */
+ if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+ (LYCacheSource == SOURCE_CACHE_FILE &&
+ !HTMainText->source_cache_file) ||
+ (LYCacheSource == SOURCE_CACHE_MEMORY &&
+ !HTMainText->source_cache_chunk))
+ return FALSE;
+
+ if (TRACE) {
+ /*
+ * If we're tracing, note everying that has changed.
+ */
+ trace_setting_change("CLICKABLE_IMAGES",
+ HTMainText->clickable_images, clickable_images);
+ trace_setting_change("PSEUDO_INLINE_ALTS",
+ HTMainText->pseudo_inline_alts,
+ pseudo_inline_alts);
+ trace_setting_change("RAW_MODE", HTMainText->raw_mode, LYRawMode);
+ trace_setting_change("HISTORICAL_COMMENTS",
+ HTMainText->historical_comments,
+ historical_comments);
+ trace_setting_change("MINIMAL_COMMENTS",
+ HTMainText->minimal_comments, minimal_comments);
+ trace_setting_change("SOFT_DQUOTES",
+ HTMainText->soft_dquotes, soft_dquotes);
+ trace_setting_change("OLD_DTD", HTMainText->old_dtd, Old_DTD);
+ if (HTMainText->lines != LYlines || HTMainText->cols != LYcols)
+ CTRACE(tfp,
+ "HTdocument_settings_changed: Screen size has changed (was
%dx%d, now %dx%d)\n",
+ HTMainText->cols, HTMainText->lines, LYcols, LYlines);
+ }
+
+ return (HTMainText->clickable_images != clickable_images ||
+ HTMainText->pseudo_inline_alts != pseudo_inline_alts ||
+ HTMainText->raw_mode != LYRawMode ||
+ HTMainText->historical_comments != historical_comments ||
+ HTMainText->minimal_comments != minimal_comments ||
+ HTMainText->soft_dquotes != soft_dquotes ||
+ HTMainText->old_dtd != Old_DTD ||
+ HTMainText->lines != LYlines ||
+ HTMainText->cols != LYcols);
+ }
+ #endif
PUBLIC int HTisDocumentSource NOARGS
{
*** ./src/HTML.c.orig Wed Mar 17 22:17:11 1999
--- ./src/HTML.c Sun Apr 11 22:37:43 1999
***************
*** 58,63 ****
--- 58,67 ----
#define pHText_changeStyle(X,Y,Z) {}
#endif
+ #ifdef SOURCE_CACHE
+ #include <HTAccess.h>
+ #endif
+
#include <LYexit.h>
#include <LYLeaks.h>
***************
*** 73,79 ****
--- 77,90 ----
struct _HTStream {
CONST HTStreamClass * isa;
+ #ifdef SOURCE_CACHE
+ FILE * fp;
+ HTChunk * chunk;
+ CONST HTStreamClass * actions;
+ HTStream * target;
+ #else
/* .... */
+ #endif
};
PRIVATE HTStyleSheet * styleSheet = NULL; /* Application-wide */
***************
*** 7300,7305 ****
--- 7311,7456 ----
return (HTStructured*) me;
}
+ #ifdef SOURCE_CACHE
+ /*
+ * Pass-thru cache HTStream
+ */
+
+ PRIVATE void CacheThru_free ARGS1(
+ HTStream *, me)
+ {
+ if (me->fp)
+ LYCloseTempFP(me->fp);
+ (*me->actions->_free)(me->target);
+ FREE(me);
+ }
+
+ PRIVATE void CacheThru_abort ARGS2(
+ HTStream *, me,
+ HTError, e)
+ {
+ if (me->fp)
+ LYCloseTempFP(me->fp);
+ (*me->actions->_abort)(me->target, e);
+ FREE(me);
+ }
+
+ PRIVATE void CacheThru_put_character ARGS2(
+ HTStream *, me,
+ char, c_in)
+ {
+ if (me->fp)
+ fputc(c_in, me->fp);
+ else
+ HTChunkPutc(me->chunk, c_in);
+ (*me->actions->put_character)(me->target, c_in);
+ }
+
+ PRIVATE void CacheThru_put_string ARGS2(
+ HTStream *, me,
+ CONST char *, str)
+ {
+ if (me->fp)
+ fputs(str, me->fp);
+ else
+ HTChunkPuts(me->chunk, str);
+ (*me->actions->put_string)(me->target, str);
+ }
+
+ PRIVATE void CacheThru_write ARGS3(
+ HTStream *, me,
+ CONST char *, str,
+ int, l)
+ {
+ if (me->fp)
+ fwrite(str, 1, l, me->fp);
+ else
+ HTChunkPutb(me->chunk, str, l);
+ (*me->actions->put_block)(me->target, str, l);
+ }
+
+ PRIVATE CONST HTStreamClass PassThruCache =
+ {
+ "PassThruCache",
+ CacheThru_free,
+ CacheThru_abort,
+ CacheThru_put_character,
+ CacheThru_put_string,
+ CacheThru_write
+ };
+
+ PRIVATE HTStream* CacheThru_new ARGS2(
+ HTParentAnchor *, anchor,
+ HTStream *, target)
+ {
+ char filename[LY_MAXPATH];
+ HTStream *stream = NULL;
+ HTProtocol *p = (HTProtocol *)anchor->protocol;
+
+ /*
+ * Neatly and transparently vanish if source caching is disabled.
+ */
+ if (LYCacheSource == SOURCE_CACHE_NONE)
+ return target;
+
+ if (strcmp(p->name, "http") != 0) {
+ CTRACE(tfp, "Protocol is \"%s\"; not caching\n", p->name);
+ return target;
+ }
+
+ stream = (HTStream *) malloc(sizeof(*stream));
+ if (!stream)
+ outofmem(__FILE__, "CacheThru_new");
+
+ stream->isa = &PassThruCache;
+ stream->fp = NULL;
+ stream->chunk = NULL;
+ stream->target = target;
+ stream->actions = target->isa;
+
+ if (LYCacheSource == SOURCE_CACHE_FILE) {
+ if (source_cache_filename) {
+ CTRACE(tfp, "Reusing source cache file %s\n",
+ source_cache_filename);
+ FREE(stream);
+ return target;
+ }
+
+ if (!(stream->fp = LYOpenTemp(filename, HTML_SUFFIX, "w"))) {
+ CTRACE(tfp, "Cannot get source cache file for URL %s\n",
+ HTAnchor_address((HTAnchor *)anchor));
+ FREE(stream);
+ return target;
+ }
+
+ /*
+ * Yes, this is a Gross And Disgusting Hack(TM), I know...
+ */
+ StrAllocCopy(source_cache_filename, filename);
+
+ CTRACE(tfp, "Caching source for URL %s in file %s\n",
+ HTAnchor_address((HTAnchor *)anchor), filename);
+ }
+
+ if (LYCacheSource == SOURCE_CACHE_MEMORY) {
+ if (source_cache_chunk) {
+ CTRACE(tfp, "Reusing source memory cache %p\n",
+ (void *)source_cache_chunk);
+ FREE(stream);
+ return target;
+ }
+
+ /* I think this is right... */
+ source_cache_chunk = stream->chunk = HTChunkCreate(128);
+ CTRACE(tfp, "Caching source for URL %s in memory cache %p\n",
+ HTAnchor_address((HTAnchor *)anchor), (void *)stream->chunk);
+
+ }
+
+ return stream;
+ }
+ #endif
+
/* HTConverter for HTML to plain text
** ----------------------------------
**
***************
*** 7313,7319 ****
--- 7464,7476 ----
HTParentAnchor *, anchor,
HTStream *, sink)
{
+ #ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTML_new(anchor, pres->rep_out, sink)));
+ #else
return SGML_new(&HTML_dtd, anchor, HTML_new(anchor, pres->rep_out, sink));
+ #endif
}
/* HTConverter for HTML source to plain text
***************
*** 7372,7378 ****
--- 7529,7541 ----
}
if (!intermediate)
return NULL;
+ #ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTMLGenerator(intermediate)));
+ #else
return SGML_new(&HTML_dtd, anchor, HTMLGenerator(intermediate));
+ #endif
}
/* HTConverter for HTML to C code
***************
*** 7397,7403 ****
--- 7560,7571 ----
html->comment_start = "/* ";
html->comment_end = " */\n"; /* Must start in col 1 for cpp */
/* HTML_put_string(html,html->comment_start); */
+ #ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor, html));
+ #else
return SGML_new(&HTML_dtd, anchor, html);
+ #endif
}
/* Presenter for HTML
***************
*** 7414,7420 ****
--- 7582,7594 ----
HTParentAnchor *, anchor,
HTStream *, sink GCC_UNUSED)
{
+ #ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTML_new(anchor, WWW_PRESENT, NULL)));
+ #else
return SGML_new(&HTML_dtd, anchor, HTML_new(anchor, WWW_PRESENT, NULL));
+ #endif
}
#endif /* !GUI */
*** ./src/GridText.h.orig Tue Mar 30 12:10:37 1999
--- ./src/GridText.h Sat Apr 10 19:24:50 1999
***************
*** 166,171 ****
--- 166,175 ----
char * target));
extern int HTisDocumentSource NOPARAMS;
extern void HTuncache_current_document NOPARAMS;
+ #ifdef SOURCE_CACHE
+ extern BOOLEAN HTreparse_document NOPARAMS;
+ extern BOOLEAN HTdocument_settings_changed NOPARAMS;
+ #endif
extern int HText_getTopOfScreen NOPARAMS;
extern int HText_getLines PARAMS((HText * text));
extern int HText_getNumOfLines NOPARAMS;
*** ./src/LYMainLoop.c.orig Tue Mar 30 12:10:37 1999
--- ./src/LYMainLoop.c Sun Apr 11 20:58:43 1999
***************
*** 1237,1242 ****
--- 1237,1262 ----
}
}
+ #ifdef SOURCE_CACHE
+ /*
+ * If the parse settings have changed since this HText was
+ * generated, we need to reparse and redraw it.
+ */
+ if (HTdocument_settings_changed()) {
+ HTUserMsg(gettext("Reparsing document under current settings..."));
+ if (HTreparse_document())
+ refresh_screen = TRUE;
+ else {
+ /*
+ * Urk. I have no idea how to recover from a failure here.
+ * At a guess, I'll try reloading.
+ */
+ cmd = LYK_RELOAD;
+ goto new_cmd;
+ }
+ }
+ #endif
+
/*
* If the curdoc.line is different than Newline then there must
* have been a change since last update. Run HText_pageDisplay()
***************
*** 2049,2054 ****
--- 2069,2080 ----
LYUCPushAssumed(HTMainAnchor);
HTOutputFormat = WWW_SOURCE;
}
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ #endif
LYforce_no_cache = TRUE;
FREE(curdoc.address); /* so it doesn't get pushed */
break;
***************
*** 2125,2135 ****
--- 2151,2163 ----
0, 0) == FALSE) {
HTInfoMsg(WILL_NOT_RELOAD_DOC);
} else {
+ #ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
newdoc.line = curdoc.line;
newdoc.link = curdoc.link;
+ #endif
}
if (historical_comments)
historical_comments = FALSE;
***************
*** 2142,2147 ****
--- 2170,2186 ----
HTAlert(historical_comments ?
HISTORICAL_ON_VALID_OFF : HISTORICAL_OFF_VALID_ON);
}
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ newdoc.line = curdoc.line;
+ newdoc.link = curdoc.link;
+ #endif
break;
case LYK_MINIMAL: /* toggle 'minimal' comments parsing */
***************
*** 2157,2167 ****
--- 2196,2208 ----
0, 0) == FALSE) {
HTInfoMsg(WILL_NOT_RELOAD_DOC);
} else {
+ #ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
newdoc.line = curdoc.line;
newdoc.link = curdoc.link;
+ #endif
}
}
if (minimal_comments)
***************
*** 2175,2180 ****
--- 2216,2232 ----
HTAlert(minimal_comments ?
MINIMAL_ON_BUT_HISTORICAL : MINIMAL_OFF_HISTORICAL_ON);
}
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ newdoc.line = curdoc.line;
+ newdoc.link = curdoc.link;
+ #endif
break;
case LYK_SOFT_DQUOTES:
***************
*** 2189,2199 ****
--- 2241,2253 ----
1, 1) == FALSE) {
HTInfoMsg(WILL_NOT_RELOAD_DOC);
} else {
+ #ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
newdoc.line = curdoc.line;
newdoc.link = curdoc.link;
+ #endif
}
if (soft_dquotes)
soft_dquotes = FALSE;
***************
*** 2201,2206 ****
--- 2255,2271 ----
soft_dquotes = TRUE;
HTUserMsg(soft_dquotes ?
SOFT_DOUBLE_QUOTE_ON : SOFT_DOUBLE_QUOTE_OFF);
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ newdoc.line = curdoc.line;
+ newdoc.link = curdoc.link;
+ #endif
break;
case LYK_SWITCH_DTD:
***************
*** 2223,2231 ****
--- 2288,2298 ----
if (HTisDocumentSource() && LYPreparsedSource) {
HTOutputFormat = WWW_SOURCE;
}
+ #ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
+ #endif
}
#ifdef NO_ASSUME_SAME_DOC
newdoc.line = 1;
***************
*** 2237,2242 ****
--- 2304,2318 ----
Old_DTD = !Old_DTD;
HTSwitchDTD(!Old_DTD);
HTUserMsg(Old_DTD ? USING_DTD_0 : USING_DTD_1);
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ #endif
break;
#ifdef NOT_DONE_YET
***************
*** 5447,5452 ****
--- 5523,5534 ----
HTUserMsg(clickable_images ?
CLICKABLE_IMAGES_ON : CLICKABLE_IMAGES_OFF);
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ #endif
cmd = LYK_RELOAD;
goto new_cmd;
***************
*** 5458,5463 ****
--- 5540,5551 ----
HTUserMsg(pseudo_inline_alts ?
PSEUDO_INLINE_ALTS_ON : PSEUDO_INLINE_ALTS_OFF);
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ #endif
cmd = LYK_RELOAD;
goto new_cmd;
***************
*** 5470,5475 ****
--- 5558,5569 ----
HTUserMsg(LYRawMode ? RAWMODE_OFF : RAWMODE_ON);
HTMLSetCharacterHandling(current_char_set);
LYRawMode_flag = LYRawMode;
+ #ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ #endif
cmd = LYK_RELOAD;
goto new_cmd;
}
*** ./src/LYReadCFG.c.orig Tue Mar 30 12:10:37 1999
--- ./src/LYReadCFG.c Sun Apr 11 19:44:41 1999
***************
*** 763,768 ****
--- 763,783 ----
return 0;
}
+ #ifdef SOURCE_CACHE
+ static int source_cache_fun ARGS1(
+ char *, value)
+ {
+ if (!strncasecomp(value, "FILE", 4))
+ LYCacheSource = SOURCE_CACHE_FILE;
+ else if (!strncasecomp(value, "MEM", 3))
+ LYCacheSource = SOURCE_CACHE_MEMORY;
+ else if (!strncasecomp(value, "NONE", 4))
+ LYCacheSource = SOURCE_CACHE_NONE;
+
+ return 0;
+ }
+ #endif
+
static int suffix_fun ARGS1(
char *, value)
{
***************
*** 999,1004 ****
--- 1014,1022 ----
PARSE_ENV("snewspost_proxy", CONF_ENV, 0 ),
PARSE_ENV("snewsreply_proxy", CONF_ENV, 0 ),
PARSE_SET("soft_dquotes", CONF_BOOL, soft_dquotes),
+ #ifdef SOURCE_CACHE
+ PARSE_SET("source_cache", CONF_FUN, source_cache_fun),
+ #endif
PARSE_STR("startfile", CONF_STR, startfile),
PARSE_SET("strip_dotdot_urls", CONF_BOOL, LYStripDotDotURLs),
PARSE_SET("substitute_underscores", CONF_BOOL, use_underscore),
*** ./src/LYMain.c.orig Tue Mar 30 12:10:37 1999
--- ./src/LYMain.c Sun Apr 11 20:54:19 1999
***************
*** 1556,1561 ****
--- 1556,1569 ----
no_multibook = TRUE;
}
+ #ifdef SOURCE_CACHE
+ /*
+ * Disable source caching if not interactive.
+ */
+ if (dump_output_immediately)
+ LYCacheSource = SOURCE_CACHE_NONE;
+ #endif
+
#ifdef VMS
set_vms_keys();
#endif /* VMS */
*** ./src/LYGlobalDefs.h.orig Thu Mar 4 05:39:45 1999
--- ./src/LYGlobalDefs.h Sun Apr 11 22:24:41 1999
***************
*** 27,32 ****
--- 27,36 ----
#define VISITED_LINKS_HELP "keystrokes/visited_help.html"
#endif /* LYHELP_H */
+ #ifdef SOURCE_CACHE
+ #include <HTChunk.h>
+ #endif
+
#ifdef SOCKS
extern BOOLEAN socks_flag;
#endif /* SOCKS */
***************
*** 245,250 ****
--- 249,262 ----
extern BOOLEAN historical_comments;
extern BOOLEAN minimal_comments;
extern BOOLEAN soft_dquotes;
+ #ifdef SOURCE_CACHE
+ extern char * source_cache_filename;
+ extern HTChunk * source_cache_chunk;
+ extern int LYCacheSource;
+ #define SOURCE_CACHE_NONE 0
+ #define SOURCE_CACHE_FILE 1
+ #define SOURCE_CACHE_MEMORY 2
+ #endif
extern BOOLEAN LYCancelDownload;
extern BOOLEAN LYRestricted;
extern BOOLEAN LYValidate;
*** ./configure.in.orig Tue Mar 30 12:10:37 1999
--- ./configure.in Sat Apr 10 00:27:33 1999
***************
*** 567,572 ****
--- 567,579 ----
AC_MSG_RESULT($use_alt_bindings)
test $use_alt_bindings != no && AC_DEFINE(EXP_ALT_BINDINGS)
+ AC_MSG_CHECKING(if source caching should be used)
+ CF_ARG_ENABLE(source-cache,
+ [ --enable-source-cache cache HTML source for parse mode changes],
+ [use_source_cache=$enableval],
+ [use_source_cache=no]
+ test $use_source_cache != no && AC_DEFINE(SOURCE_CACHE)
+
AC_MSG_CHECKING(if color-style code should be used)
CF_ARG_ENABLE(color-style,
[ --enable-color-style use optional/experimental color style],
*** ./config.hin.orig Tue Mar 30 12:10:37 1999
--- ./config.hin Sat Apr 10 00:27:33 1999
***************
*** 28,33 ****
--- 28,34 ----
#undef EXEC_SCRIPTS /* CF_ARG_ENABLE(exec-scripts) */
#undef EXP_ADDRLIST_PAGE /* CF_ARG_ENABLE(addrlist-page) */
#undef EXP_ALT_BINDINGS /* CF_ARG_ENABLE(alt-bindings) */
+ #undef SOURCE_CACHE /* CF_ARG_ENABLE(source-cache) */
#undef EXP_CHARTRANS_AUTOSWITCH /* CF_ARG_ENABLE(font-switch) */
#undef EXP_KEYBOARD_LAYOUT /* CF_ARG_ENABLE(kbd-layout) */
#undef EXP_LIBJS /* CF_ARG_ENABLE(libjs) */
*** ./lynx.cfg.orig Wed Mar 17 22:17:11 1999
--- ./lynx.cfg Sun Apr 11 23:07:34 1999
***************
*** 513,518 ****
--- 513,532 ----
#DEFAULT_CACHE_SIZE:10
#DEFAULT_VIRTUAL_MEMORY_SIZE:512000
+ # SOURCE_CACHE sets the source caching behavior for Lynx:
+ # FILE causes Lynx to keep a temporary file for each cached document
+ # containing the HTML source of the document, which it uses to regenerate
+ # the document when certain settings are changed (for instance,
+ # historical vs. minimal vs. valid comment parsing) instead of reloading
+ # the source from the network.
+ # MEMORY is like FILE, except the document source is kept in memory. You
+ # may wish to adjust DEFAULT_CACHE_SIZE and DEFAULT_VIRTUAL_MEMORY_SIZE
+ # accordingly.
+ # NONE is the default; the document source is not cached, and is reloaded
+ # from the network when needed.
+ #
+ #SOURCE_CACHE:NONE
+
# If ALWAYS_RESUBMIT_POSTS is set TRUE, Lynx always will resubmit forms
# with method POST, dumping any cache from a previous submission of the
# form, including when the document returned by that form is sought with
- Re: lynx-dev PATCH [dev21]: source caching, take 2, Scott Bigham, 1999/04/11
- Re: lynx-dev PATCH [dev21]: source caching, take 2, dickey, 1999/04/12
- Re: lynx-dev PATCH [dev21]: source caching, take 2, dickey, 1999/04/12
- Re: lynx-dev PATCH [dev21]: source caching, take 2,
Scott Bigham <=
- Re: lynx-dev PATCH [dev21]: source caching, take 2, dickey, 1999/04/12
- Re: lynx-dev PATCH [dev21]: source caching, take 2, dickey, 1999/04/12