aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1999-04-13 09:48:41 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1999-04-13 09:48:41 -0400
commitb223937ff728f8242329bedb9c660e81da253e9a (patch)
treebbf056969500f54306deda5db38ff2a6198f3ce9 /src
parent327b7c16889c9d95ec076d695c970da11dc32a2b (diff)
downloadlynx-snapshots-b223937ff728f8242329bedb9c660e81da253e9a.tar.gz
snapshot of project "lynx", label v2-8-2dev_22
Diffstat (limited to 'src')
-rw-r--r--src/DefaultStyle.c2
-rw-r--r--src/GridText.c561
-rw-r--r--src/GridText.h7
-rw-r--r--src/HTAlert.c3
-rw-r--r--src/HTInit.c1
-rw-r--r--src/HTML.c567
-rw-r--r--src/LYBookmark.c1
-rw-r--r--src/LYCgi.c2
-rw-r--r--src/LYCharSets.c1
-rw-r--r--src/LYClean.c1
-rw-r--r--src/LYCookie.c21
-rw-r--r--src/LYCurses.c44
-rw-r--r--src/LYDownload.c2
-rw-r--r--src/LYEdit.c2
-rw-r--r--src/LYForms.c1
-rw-r--r--src/LYGetFile.c30
-rw-r--r--src/LYGlobalDefs.h12
-rw-r--r--src/LYHash.c49
-rw-r--r--src/LYHash.h10
-rw-r--r--src/LYHistory.c7
-rw-r--r--src/LYJump.c1
-rw-r--r--src/LYLeaks.c28
-rw-r--r--src/LYMain.c282
-rw-r--r--src/LYMainLoop.c173
-rw-r--r--src/LYMap.c2
-rw-r--r--src/LYPrettySrc.c301
-rw-r--r--src/LYPrettySrc.h70
-rw-r--r--src/LYPrint.c3
-rw-r--r--src/LYReadCFG.c584
-rw-r--r--src/LYReadCFG.h5
-rw-r--r--src/LYSearch.c1
-rw-r--r--src/LYShowInfo.c51
-rw-r--r--src/LYStrings.c1
-rw-r--r--src/LYStyle.c59
-rw-r--r--src/LYStyle.h34
-rw-r--r--src/LYTraversal.c1
-rw-r--r--src/LYUtils.c7
-rw-r--r--src/LYexit.c4
-rw-r--r--src/UCAuto.c1
-rw-r--r--src/UCdomap.c2
-rw-r--r--src/descrip.mms9
-rw-r--r--src/makefile.dos2
-rw-r--r--src/makefile.dsl2
-rw-r--r--src/makefile.in2
-rw-r--r--src/makefile.wsl2
45 files changed, 2277 insertions, 674 deletions
diff --git a/src/DefaultStyle.c b/src/DefaultStyle.c
index 7a498700..9532c973 100644
--- a/src/DefaultStyle.c
+++ b/src/DefaultStyle.c
@@ -392,7 +392,9 @@ PUBLIC HTStyleSheet * DefaultStyle NOARGS
result = HTStyleSheetNew ();
*result = sheet;
result->styles = 0;
+#ifdef LY_FIND_LEAKS
atexit(FreeDefaultStyle);
+#endif
for (p = sheet.styles; p != 0; p = p->next) {
q = HTStyleNew ();
*q = *p;
diff --git a/src/GridText.c b/src/GridText.c
index b61ca5e1..d637cdb8 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -15,6 +15,7 @@
#include <UCAux.h>
#include <assert.h>
+
#ifndef VMS
#ifdef SYSLOG_REQUESTED_URLS
#include <syslog.h>
@@ -29,7 +30,6 @@
#include <LYGlobalDefs.h>
#include <LYGetFile.h>
#include <LYClean.h>
-#include <LYSignal.h>
#include <LYMail.h>
#include <LYList.h>
#include <LYCharSets.h>
@@ -37,6 +37,7 @@
#include <UCMap.h>
#include <LYEdit.h>
#include <LYPrint.h>
+#include <LYPrettySrc.h>
#ifdef EXP_CHARTRANS_AUTOSWITCH
#include <UCAuto.h>
#endif /* EXP_CHARTRANS_AUTOSWITCH */
@@ -46,6 +47,10 @@
#undef DEBUG_APPCH
+#ifdef SOURCE_CACHE
+#include <HTFile.h>
+#endif
+
#ifdef USE_COLOR_STYLE
#include <AttrList.h>
#include <LYHash.h>
@@ -114,6 +119,12 @@ PUBLIC char * unchecked_radio = "( )";
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,6 +184,23 @@ typedef struct _HTTabID {
*/
struct _HText {
HTParentAnchor * node_anchor;
+#ifdef SOURCE_CACHE
+#undef lines /* FIXME */
+ 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 */
@@ -432,7 +460,9 @@ PUBLIC HText * HText_new ARGS1(
if (!loaded_texts) {
loaded_texts = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(free_all_texts);
+#endif
}
/*
@@ -483,6 +513,34 @@ PUBLIC HText * HText_new ARGS1(
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 = LYUseDefaultRawMode;
+ 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
@@ -503,10 +561,14 @@ PUBLIC HText * HText_new ARGS1(
self->LastChar = '\0';
self->IgnoreExcess = FALSE;
+#ifndef PSRC_TEST
if (HTOutputFormat == WWW_SOURCE)
self->source = YES;
else
self->source = NO;
+#else
+ self->source=( LYpsrc ? psrc_view : HTOutputFormat == WWW_SOURCE);
+#endif
HTAnchor_setDocument(anchor, (HyperDoc *)self);
HTFormNumber = 0; /* no forms started yet */
HTMainText = self;
@@ -729,6 +791,23 @@ PUBLIC void HText_free ARGS1(
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);
}
@@ -2943,24 +3022,20 @@ check_IgnoreExcess:
*/
PUBLIC void _internal_HTC ARGS3(HText *,text, int,style, int,dir)
{
- HTLine* line;
- static int last_style = -1;
- static int last_dir = -1;
+ HTLine* line;
- /* can't change style if we have no text to change style with */
- if (!text) return;
+ /* can't change style if we have no text to change style with */
+ if (text != 0) {
- line = text->last_line;
+ line = text->last_line;
- if ((style != last_style || dir != last_dir) && line->numstyles < MAX_STYLES_ON_LINE)
- {
- line->styles[line->numstyles].horizpos = line->size;
- line->styles[line->numstyles].style = style;
- line->styles[line->numstyles].direction = dir;
- line->numstyles++;
- }
- last_style = style;
- last_dir = dir;
+ if (line->numstyles < MAX_STYLES_ON_LINE) {
+ line->styles[line->numstyles].horizpos = line->size;
+ line->styles[line->numstyles].style = style;
+ line->styles[line->numstyles].direction = dir;
+ line->numstyles++;
+ }
+ }
}
#endif
@@ -5291,7 +5366,9 @@ PUBLIC void HTAddSearchQuery ARGS1(
if (!search_queries) {
search_queries = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(HTSearchQueries_free);
+#endif
HTList_addObject(search_queries, new);
return;
}
@@ -5738,40 +5815,39 @@ PRIVATE void adjust_search_result ARGS3(
}
}
-PUBLIC void www_user_search ARGS3(
+/*
+ John Bley, April 1, 1999 (No joke)
+ www_user_search_internals was spawned from www_user_search to
+ remove a cut-n-paste coding hack: basically, this entire function
+ was duplicated at the two points that www_user_search now calls it.
+ And, because www_user_search has a return value defined as modification
+ of the screen and some global values, and since it used an awkward for(;;)
+ construct, this method has to distinguish between when it's "really"
+ returning and when it's just falling through via a break; in the
+ infinite-for-loop. So, basically, we have a large amount of arguments
+ since this loop used to be directly in www_user_search, and we return
+ 1 to say we're "really" returning and 0 to indicate we fell through.
+ Also, due to exactly one difference between the first pass of this
+ code and the second pass, we have the "firstpass" argument, which is
+ true iff it's the first pass.
+
+ I hate cut-n-paste coding.
+ */
+PRIVATE int www_user_search_internals ARGS8(
+ int, firstpass,
int, start_line,
document *, doc,
- char *, target)
+ char *, target,
+ TextAnchor *, a,
+ HTLine *, line,
+ int *, count,
+ int *, tentative_result)
{
- register HTLine * line;
- register int count;
- int tentative_result = -1;
- TextAnchor *a;
- OptionType *option;
+ OptionType * option;
char *stars = NULL, *cp;
- if (!HTMainText) {
- return;
- }
-
- /*
- * Advance to the start line.
- */
- line = HTMainText->last_line->next;
- for (count = 1; count <= start_line; line = line->next, count++) {
- if (line == HTMainText->last_line) {
- line = HTMainText->last_line->next; /* set to first line */
- count = 1;
- break;
- }
- }
- a = HTMainText->first_anchor;
- while (a && a->line_num < count - 1) {
- a = a->next;
- }
-
for (;;) {
- while ((a != NULL) && a->line_num == (count - 1)) {
+ while ((a != NULL) && a->line_num == (*count - 1)) {
if (a->show_anchor &&
(a->link_type != INPUT_ANCHOR ||
a->input_field->type != F_HIDDEN_TYPE)) {
@@ -5779,15 +5855,15 @@ PUBLIC void www_user_search ARGS3(
LYno_attr_char_strstr(a->hightext, target)) ||
((a->hightext != NULL && case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(a->hightext, target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
if (((a->hightext2 != NULL && case_sensitive == TRUE) &&
LYno_attr_char_strstr(a->hightext2, target)) ||
((a->hightext2 != NULL && case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(a->hightext2, target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
/*
@@ -5807,8 +5883,8 @@ PUBLIC void www_user_search ARGS3(
((case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(a->input_field->value,
target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
StrAllocCopy(stars, a->input_field->value);
for (cp = stars; *cp != '\0'; cp++)
@@ -5818,8 +5894,8 @@ PUBLIC void www_user_search ARGS3(
((case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(stars, target))) {
FREE(stars);
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
FREE(stars);
} else if (a->input_field->type == F_OPTION_LIST_TYPE) {
@@ -5837,8 +5913,8 @@ PUBLIC void www_user_search ARGS3(
case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(option->name,
target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
option = option->next;
}
@@ -5855,8 +5931,8 @@ PUBLIC void www_user_search ARGS3(
LYno_attr_char_strstr(cp, target)) ||
((case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(cp, target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
} else if (a->input_field->type == F_CHECKBOX_TYPE) {
/*
@@ -5872,8 +5948,8 @@ PUBLIC void www_user_search ARGS3(
LYno_attr_char_strstr(cp, target)) ||
((case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(cp, target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
} else {
/*
@@ -5888,191 +5964,89 @@ PUBLIC void www_user_search ARGS3(
((case_sensitive == FALSE) &&
LYno_attr_char_case_strstr(a->input_field->value,
target))) {
- adjust_search_result(doc, count, start_line);
- return;
+ adjust_search_result(doc, *count, start_line);
+ return 1;
}
}
}
}
a = a->next;
}
- if (a != NULL && a->line_num <= (count - 1)) {
+ if (a != NULL && a->line_num <= (*count - 1)) {
a = a->next;
}
if (case_sensitive && LYno_attr_char_strstr(line->data, target)) {
- tentative_result = count;
+ *tentative_result = *count;
break;
} else if (!case_sensitive &&
LYno_attr_char_case_strstr(line->data, target)) {
- tentative_result = count;
+ *tentative_result = *count;
break;
- } else if (line == HTMainText->last_line) { /* next line */
+ /* Note: this is where the two passes differ */
+ } else if (firstpass && line == HTMainText->last_line) {
+ /* next line */
break;
+ } else if (!firstpass && *count > start_line) {
+ HTUserMsg2(STRING_NOT_FOUND, target);
+ return 1; /* end */
} else { /* end */
line = line->next;
- count++;
+ (*count)++;
}
}
- if (tentative_result > 0) {
- adjust_search_result(doc, tentative_result, start_line);
+ /* No, man, we just fell through. You want to call us again. */
+ return 0;
+}
+
+PUBLIC void www_user_search ARGS3(
+ int, start_line,
+ document *, doc,
+ char *, target)
+{
+ HTLine * line;
+ int count;
+ int tentative_result = -1;
+ TextAnchor *a;
+
+ if (!HTMainText) {
return;
}
/*
- * Search from the beginning.
+ * Advance to the start line.
*/
+ line = HTMainText->last_line->next;
+ for (count = 1; count <= start_line; line = line->next, count++) {
+ if (line == HTMainText->last_line) {
+ line = HTMainText->last_line->next; /* set to first line */
+ count = 1;
+ break;
+ }
+ }
+ a = HTMainText->first_anchor;
+ while (a && a->line_num < count - 1) {
+ a = a->next;
+ }
+ if (www_user_search_internals(1, start_line, doc, target,
+ a, line, &count, &tentative_result) == 1) {
+ return; /* Return the www_user_search_internals result */
+ }
+
+ if (tentative_result > 0) {
+ adjust_search_result(doc, tentative_result, start_line);
+ return;
+ }
+ /* That didn't work, search from the beginning instead */
line = HTMainText->last_line->next; /* set to first line */
count = 1;
a = HTMainText->first_anchor;
while (a && a->line_num < count - 1) {
a = a->next;
}
-
- for (;;) {
- while ((a != NULL) && a->line_num == (count - 1)) {
- if (a->show_anchor &&
- (a->link_type != INPUT_ANCHOR ||
- a->input_field->type != F_HIDDEN_TYPE)) {
- if (((a->hightext != NULL && case_sensitive == TRUE) &&
- LYno_attr_char_strstr(a->hightext, target)) ||
- ((a->hightext != NULL && case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(a->hightext, target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
- if (((a->hightext2 != NULL && case_sensitive == TRUE) &&
- LYno_attr_char_strstr(a->hightext2, target)) ||
- ((a->hightext2 != NULL && case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(a->hightext2, target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
-
- /*
- * Search the relevant form fields, taking the
- * case_sensitive setting into account. - FM
- */
- if ((a->input_field != NULL && a->input_field->value != NULL) &&
- a->input_field->type != F_HIDDEN_TYPE) {
- if (a->input_field->type == F_PASSWORD_TYPE) {
- /*
- * Check the actual, hidden password, and then
- * the displayed string. - FM
- */
- if (((case_sensitive == TRUE) &&
- LYno_attr_char_strstr(a->input_field->value,
- target)) ||
- ((case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(a->input_field->value,
- target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
- StrAllocCopy(stars, a->input_field->value);
- for (cp = stars; *cp != '\0'; cp++)
- *cp = '*';
- if (((case_sensitive == TRUE) &&
- LYno_attr_char_strstr(stars, target)) ||
- ((case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(stars, target))) {
- FREE(stars);
- adjust_search_result(doc, count, start_line);
- return;
- }
- FREE(stars);
- } else if (a->input_field->type == F_OPTION_LIST_TYPE) {
- /*
- * Search the option strings that are displayed
- * when the popup is invoked. - FM
- */
- option = a->input_field->select_list;
- while (option != NULL) {
- if (((option->name != NULL &&
- case_sensitive == TRUE) &&
- LYno_attr_char_strstr(option->name,
- target)) ||
- ((option->name != NULL &&
- case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(option->name,
- target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
- option = option->next;
- }
- } else if (a->input_field->type == F_RADIO_TYPE) {
- /*
- * Search for checked or unchecked parens. - FM
- */
- if (a->input_field->num_value) {
- cp = checked_radio;
- } else {
- cp = unchecked_radio;
- }
- if (((case_sensitive == TRUE) &&
- LYno_attr_char_strstr(cp, target)) ||
- ((case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(cp, target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
- } else if (a->input_field->type == F_CHECKBOX_TYPE) {
- /*
- * Search for checked or unchecked
- * square brackets. - FM
- */
- if (a->input_field->num_value) {
- cp = checked_box;
- } else {
- cp = unchecked_box;
- }
- if (((case_sensitive == TRUE) &&
- LYno_attr_char_strstr(cp, target)) ||
- ((case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(cp, target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
- } else {
- /*
- * Check the values intended for display.
- * May have been found already via the
- * hightext search, but make sure here
- * that the entire value is searched. - FM
- */
- if (((case_sensitive == TRUE) &&
- LYno_attr_char_strstr(a->input_field->value,
- target)) ||
- ((case_sensitive == FALSE) &&
- LYno_attr_char_case_strstr(a->input_field->value,
- target))) {
- adjust_search_result(doc, count, start_line);
- return;
- }
- }
- }
- }
- a = a->next;
- }
- if (a != NULL && a->line_num <= (count - 1)) {
- a = a->next;
- }
-
- if (case_sensitive && LYno_attr_char_strstr(line->data, target)) {
- tentative_result = count;
- break;
- } else if (!case_sensitive &&
- LYno_attr_char_case_strstr(line->data, target)) {
- tentative_result = count;
- break;
- } else if (count > start_line) { /* next line */
- HTUserMsg2(STRING_NOT_FOUND, target);
- return; /* end */
- } else {
- line = line->next;
- count++;
- }
+ if (www_user_search_internals(0, start_line, doc, target,
+ a, line, &count, &tentative_result) == 1) {
+ return; /* Return the www_user_search_internals result */
}
if (tentative_result > 0) {
adjust_search_result(doc, tentative_result, start_line);
@@ -6190,6 +6164,148 @@ PUBLIC void HTuncache_current_document NOARGS
}
}
+#ifdef SOURCE_CACHE
+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,
+ LYUseDefaultRawMode);
+ 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 != LYUseDefaultRawMode ||
+ 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
{
return (HTMainText != 0) ? HTMainText->source : FALSE;
@@ -9273,7 +9389,7 @@ PRIVATE int increment_tagged_htline ARGS6(
} else {
valid = FALSE;
break;
- }
+ }
}
/*
@@ -9298,7 +9414,7 @@ PRIVATE int increment_tagged_htline ARGS6(
val = atoi (p);
if ((val == *old_val) || (*old_val == 0)) { /* 0 matches all */
if (*old_val != 0)
- (*old_val)++;
+ (*old_val)++;
val += incr;
sprintf (s, "%d", val);
new_n = strlen (s);
@@ -9328,7 +9444,7 @@ PRIVATE int increment_tagged_htline ARGS6(
*/
if (new_n -= n) {
nxt_anchor = st_anchor;
- while ((nxt_anchor) &&
+ while ((nxt_anchor) &&
(nxt_anchor->line_num == a->line_num)) {
nxt_anchor->line_pos += new_n;
nxt_anchor = nxt_anchor->next;
@@ -9441,7 +9557,7 @@ PRIVATE void insert_new_textarea_anchor ARGS2(
HTLine *l = 0;
int curr_tag = 0; /* 0 ==> match any [tag] number */
- int lx = 0; /* 0 ==> no line crossing [tag]; it's a new line */
+ int lx = 0; /* 0 ==> no line crossing [tag]; it's a new line */
int i;
@@ -9745,8 +9861,6 @@ PUBLIC int HText_ExtEditForm ARGS1(
int len;
- ed_offset[0] = 0; /* pre-ANSI compilers don't initialize aggregates - TD */
-
CTRACE(tfp, "GridText: entered HText_ExtEditForm()\n");
ed_temp = (char *) malloc (LY_MAXPATH);
@@ -9810,6 +9924,7 @@ PUBLIC int HText_ExtEditForm ARGS1(
* 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())
#ifdef VMS
sprintf (ed_offset, "-%d", ((entry_line - start_line) + 1));
@@ -10560,3 +10675,11 @@ PUBLIC void redraw_lines_of_link ARGS1(
#endif
return;
}
+
+#ifdef USE_PSRC
+PUBLIC void HTMark_asSource NOARGS
+{
+ if (HTMainText)
+ HTMainText->source = TRUE;
+}
+#endif
diff --git a/src/GridText.h b/src/GridText.h
index c328202e..3e83a740 100644
--- a/src/GridText.h
+++ b/src/GridText.h
@@ -166,6 +166,10 @@ extern BOOL HText_getFirstTargetInLine PARAMS((
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;
@@ -272,6 +276,9 @@ extern int HText_InsertFile PARAMS((
struct link * form_link));
extern void redraw_lines_of_link PARAMS((int cur));
+
+#ifdef USE_PSRC
extern void HTMark_asSource NOPARAMS;
+#endif
#endif /* LYGRIDTEXT_H */
diff --git a/src/HTAlert.c b/src/HTAlert.c
index c386bb5e..34b828ba 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -16,7 +16,6 @@
#include <LYStrings.h>
#include <LYUtils.h>
#include <LYClean.h>
-#include <LYSignal.h>
#include <GridText.h>
#include <LYCookie.h>
@@ -231,7 +230,7 @@ PUBLIC BOOL HTConfirmDefault ARGS2(CONST char *, Msg, int, Dft)
result = YES;
} else if (TOUPPER(c) == TOUPPER(*msg_no)) {
return(NO);
- } else if (Dft != DFT_CONFIRM && (c == '\r' || c == '\n')) {
+ } else if (Dft != DFT_CONFIRM) {
return(Dft);
}
}
diff --git a/src/HTInit.c b/src/HTInit.c
index c4319235..f6ab32fa 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -24,7 +24,6 @@
#include <LYStrings.h>
#include <LYUtils.h>
#include <LYGlobalDefs.h>
-#include <LYSignal.h>
#include <LYexit.h>
#include <LYLeaks.h>
diff --git a/src/HTML.c b/src/HTML.c
index 7572ad86..40cb1f2d 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -39,7 +39,6 @@
#include <HTForms.h>
#include <HTNestedList.h>
#include <GridText.h>
-#include <LYSignal.h>
#include <LYStrings.h>
#include <LYUtils.h>
#include <LYMap.h>
@@ -51,11 +50,29 @@
#endif /* VMS */
#ifdef USE_COLOR_STYLE
+#include <SGML.h>
#include <AttrList.h>
#include <LYHash.h>
#include <LYStyle.h>
+#include <LYPrettySrc.h>
#undef SELECTED_STYLES
#define pHText_changeStyle(X,Y,Z) {}
+
+#define OPT_SCN 1
+#define OMIT_SCN_KEEPING 0 /* whether to omit keeping of Style_className
+ when lss support is on. 1 to increase performance. The value must
+ correspond to one in LYCurses.c. Should be 0 if OPT_SCN=0 */
+
+#if OMIT_SCN_KEEPING
+# define HCODE_TO_STACK_OFF(x) /*(CSHASHSIZE+1)*/ 88888 /*special value.*/
+#else
+# define HCODE_TO_STACK_OFF(x) x /*pass computed value*/
+#endif
+
+#endif /* USE_COLOR_STYLE */
+
+#ifdef SOURCE_CACHE
+#include <HTAccess.h>
#endif
#include <LYexit.h>
@@ -73,7 +90,14 @@ extern int LYcols;
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 */
@@ -98,6 +122,14 @@ PRIVATE void HTML_end_element PARAMS((HTStructured *me,
int element_number,
char **include));
+PRIVATE void HTML_start_element PARAMS((
+ HTStructured * me,
+ int element_number,
+ CONST BOOL* present,
+ CONST char ** value,
+ int tag_charset,
+ char ** include));
+
/*
* If we have verbose_img set, display labels for images.
*/
@@ -567,7 +599,7 @@ PUBLIC void HTML_write ARGS3(HTStructured *, me, CONST char*, s, int, l)
* In document retrieved from [...]/mypath/mydoc.htm w/ base [...]/otherpath/
* a. HREF="[...]/mypath/mydoc.htm" -> [...]/mypath/mydoc.htm
* b. HREF="[...]/mypath/mydoc.htm#frag" -> [...]/mypath/mydoc.htm#frag
- * c. HREF="mydoc.htm" -> [...]/otherpath/mydoc.htm
+ * c. HREF="mydoc.htm" -> [...]/otherpath/mydoc.htm
* d. HREF="mydoc.htm#frag" -> [...]/otherpath/mydoc.htm#frag
* e. HREF="" -> [...]/mypath/mydoc.htm (marked internal)
* f. HREF="#frag" -> [...]/mypath/mydoc.htm#frag (marked internal)
@@ -605,16 +637,69 @@ PUBLIC void HTML_write ARGS3(HTStructured *, me, CONST char*, s, int, l)
#endif /* DONT_TRACK_INTERNAL_LINKS */
#ifdef USE_COLOR_STYLE
-static char *Style_className = NULL;
+# if !OPT_SCN
+static char* Style_className = NULL;
static char myHash[128];
+# else
+PRIVATE char Style_className[4096];/* i hope it's enough :) HV */
+PRIVATE char* Style_className_end=Style_className;/*this points to the
+ end of string in Style_className (it points to '\0') */
+# endif
static int hcode;
#endif
+
+#ifdef USE_PSRC
+
+PRIVATE void HTMLSRC_apply_markup ARGS4(
+ HTStructured *, context,
+ HTlexem, lexem,
+ BOOL, start,
+ int, tag_charset)
+{
+ HT_tagspec* ts = *( ( start ? lexem_start : lexem_end ) + lexem);
+
+ while (ts) {
+#ifdef USE_COLOR_STYLE
+ if (ts->start) {
+ current_tag_style = ts->style;
+ force_current_tag_style = TRUE;
+ forced_classname = ts->class_name;
+ force_classname = TRUE;
+ }
+#endif
+ CTRACE(tfp,ts->start ? "SRCSTART %d\n" : "SRCSTOP %d\n",(int)lexem);
+ if (ts->start)
+ HTML_start_element(
+ context,
+ ts->element,
+ ts->present,
+ (CONST char **)ts->value,
+ tag_charset,
+ NULL);
+ else
+ HTML_end_element(
+ context,
+ ts->element,
+ NULL);
+ ts = ts->next;
+ }
+}
+# define START TRUE
+# define STOP FALSE
+# define PSRCSTART(x) HTMLSRC_apply_markup(me,HTL_##x,START,tag_charset)
+# define PSRCSTOP(x) HTMLSRC_apply_markup(me,HTL_##x,STOP,tag_charset)
+
+# define PUTC(x) HTML_put_character(me,x)
+# define PUTS(x) HTML_put_string(me,x)
+
+#endif /* USE_PSRC*/
+
/* Start Element
** -------------
*/
PRIVATE void HTML_start_element ARGS6(
- HTStructured *, me,
+ HTStructured *, me,
int, element_number,
CONST BOOL*, present,
CONST char **, value,
@@ -635,11 +720,110 @@ PRIVATE void HTML_start_element ARGS6(
HTParentAnchor *dest = NULL; /* An anchor's destination */
BOOL dest_ismap = FALSE; /* Is dest an image map script? */
BOOL UseBASE = TRUE; /* Resoved vs. BASE if present? */
- HTChildAnchor *ID_A = NULL; /* HTML_foo_ID anchor */
+ HTChildAnchor *ID_A = NULL; /* HTML_foo_ID anchor */
int url_type = 0, i = 0;
char *cp = NULL;
int ElementNumber = element_number;
BOOL intern_flag = FALSE;
+#ifdef USE_COLOR_STYLE
+ char* class_name;
+# if OPT_SCN
+# if !OMIT_SCN_KEEPING
+ char* Style_className_end_was = Style_className_end+1;
+# endif
+ /* assume ';' will be appended*/
+# endif
+#endif
+
+#ifdef USE_PSRC
+ if (psrc_view && !sgml_in_psrc_was_initialized) {
+ if (!psrc_nested_call) {
+ HTTag * tag = &HTML_dtd.tags[element_number];
+ char buf[200];
+ CONST char* p;
+ if (psrc_first_tag) {
+ psrc_first_tag=FALSE;
+ /* perform the special actions on the begining of the document.
+ It's assumed that all lynx modules start generating html
+ from tag (ie not a text) so we are able to trap this moment
+ and initialize.
+ */
+ psrc_nested_call=TRUE;
+ HTML_start_element(me,HTML_BODY, NULL,NULL,tag_charset,NULL);
+ HTML_start_element(me,HTML_PRE, NULL,NULL,tag_charset,NULL);
+ PSRCSTART(entire);
+ psrc_nested_call=FALSE;
+ }
+
+ psrc_nested_call=TRUE;
+ /*write markup for tags and exit*/
+ PSRCSTART(abracket); PUTC('<'); PSRCSTOP(abracket);
+ PSRCSTART(tag);
+ if (tagname_transform!=0)
+ PUTS(tag->name);
+ else {
+ strcpy(buf,tag->name);
+ LYLowerCase(buf);
+ PUTS(buf);
+ }
+ if (present) {
+ for (i = 0; i < tag->number_of_attributes; i++)
+ if (present[i]) {
+ PUTC(' ');
+ PSRCSTART(attrib);
+ if (attrname_transform!=0)
+ PUTS(tag->attributes[i].name);
+ else {
+ strcpy(buf,tag->attributes[i].name);
+ LYLowerCase(buf);
+ PUTS(buf);
+ }
+ if (value[i]) {
+ char q='"';
+ /*0 in dquotes, 1 - in quotes, 2 mixed*/
+ char kind= ( !strchr(value[i], '"') ?
+ 0 :
+ !strchr(value[i], '\'') ?
+ q='\'',1 :
+ 2);
+ PUTC('=');
+ PSRCSTOP(attrib);
+ PSRCSTART(attrval);
+ PUTC(q);
+ /*is it special ? */
+ if (tag->attributes[i].type == HTMLA_ANAME) {
+ HTStartAnchor(me,value[i],NULL);
+ HTML_end_element(me,HTML_A,NULL);
+ } else if (tag->attributes[i].type == HTMLA_HREF) {
+ PSRCSTART(href);
+ HTStartAnchor(me,NULL,value[i]);
+ }
+ if (kind!=2)
+ PUTS(value[i]);
+ else
+ for (p = value[i]; *p; p++)
+ if (*p != '"')
+ PUTC(*p);
+ else
+ PUTS("&#34;");
+ /*is it special ? */
+ if (tag->attributes[i].type == HTMLA_HREF) {
+ HTML_end_element(me,HTML_A,NULL);
+ PSRCSTOP(href);
+ }
+ PUTC(q);
+ PSRCSTOP(attrval);
+ } /* if value */
+ } /* if present[i] */
+ }/* if present*/
+ PSRCSTOP(tag);
+ PSRCSTART(abracket); PUTC('>'); PSRCSTOP(abracket);
+ psrc_nested_call=FALSE;
+ return;
+ } /*if (!psrc_nested_call) */
+ /*fall through*/
+ }
+#endif /* USE_PSRC */
if (LYMapsOnly) {
if (!(ElementNumber == HTML_MAP || ElementNumber == HTML_AREA ||
@@ -664,19 +848,63 @@ PRIVATE void HTML_start_element ARGS6(
/* this should be done differently */
#if defined(USE_COLOR_STYLE)
+
+#if !OPT_SCN
HTSprintf (&Style_className, ";%s", HTML_dtd.tags[element_number].name);
- strcpy (myHash, HTML_dtd.tags[element_number].name);
- if (class_string[0])
- {
- HTSprintf (&Style_className, ".%s", class_string);
- strcat (myHash, ".");
- strcat (myHash, class_string);
+#else
+# if !OMIT_SCN_KEEPING
+ *Style_className_end=';';
+ /*strcpy(Style_className_end+1,HTML_dtd.tags[element_number].name);*/
+ memcpy(Style_className_end+1,
+ HTML_dtd.tags[element_number].name,
+ HTML_dtd.tags[element_number].name_len+1);
+ Style_className_end += HTML_dtd.tags[element_number].name_len+1;
+# endif
+#endif
+ class_name = (force_classname ? forced_classname : class_string);
+ force_classname = FALSE;
+
+ if (force_current_tag_style == FALSE) {
+ current_tag_style = class_name[0]
+ ? -1
+ : cached_tag_styles[element_number];
+ } else {
+ force_current_tag_style = FALSE;
}
- class_string[0] = '\0';
- strtolower(myHash);
- hcode = hash_code(myHash);
- strtolower(Style_className);
+
+ if (current_tag_style == -1) {
+#if !OPT_SCN
+ strcpy (myHash, HTML_dtd.tags[element_number].name);
+#else
+ hcode=hash_code_lowercase_on_fly(HTML_dtd.tags[element_number].name);
+#endif
+ if (class_name[0])
+ {
+#if !OPT_SCN
+ HTSprintf (&Style_className, ".%s", class_name);
+ strcat (myHash, ".");
+ strcat (myHash, class_name);
+#else
+
+# if !OMIT_SCN_KEEPING
+ int l=strlen(class_name);
+ *Style_className_end = '.';
+ memcpy(Style_className_end+1, class_name, l+1 );
+ Style_className_end += l+1;
+# endif
+
+ hcode = hash_code_aggregate_char('.', hcode);
+ hcode = hash_code_aggregate_lower_on_fly(class_name, hcode);
+#endif
+ }
+#if !OPT_SCN
+ strtolower(myHash);
+ hcode = hash_code(myHash);
+#endif
+ class_string[0] = '\0';
+
+#if !OPT_SCN
if (TRACE)
{
fprintf(tfp, "CSSTRIM:%s -> %d", myHash, hcode);
@@ -699,12 +927,46 @@ PRIVATE void HTML_start_element ARGS6(
else
fprintf(tfp, " ca=%d\n", hashStyles[hcode].color);
}
+#endif
- if (displayStyles[element_number + STARTAT].color > -2) /* actually set */
- {
- CTRACE(tfp, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name);
- HText_characterStyle(me->text, hcode, 1);
+ /* seems that this condition is always true - HV */
+ if (displayStyles[element_number + STARTAT].color > -2) /* actually set */
+ {
+ CTRACE(tfp, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name);
+ HText_characterStyle(me->text, hcode, 1);
+ }
+ } else { /* (current_tag_style!=-1) */
+ if (class_name[0]) {
+#if !OPT_SCN
+ HTSprintf (&Style_className, ".%s", class_name);
+ strcat (myHash, ".");
+ strcat (myHash, class_name);
+#else
+# if !OMIT_SCN_KEEPING
+ int l = strlen(class_name);
+ *Style_className_end='.';
+ memcpy(Style_className_end+1,class_name, l+1 );
+ Style_className_end+=l+1;
+# endif
+#endif
+ class_string[0] = '\0';
+ }
+ hcode = current_tag_style;
+ HText_characterStyle(me->text, hcode , 1);
+ current_tag_style = -1;
}
+
+#if !OPT_SCN
+ strtolower(Style_className);
+#else
+# if !OMIT_SCN_KEEPING
+ strtolower(Style_className_end_was);/*only the part that wasn't
+ lowercased yet*/
+# endif
+#endif
+
+
+
#endif /* USE_COLOR_STYLE */
/*
@@ -917,11 +1179,17 @@ PRIVATE void HTML_start_element ARGS6(
/*
* Handle REL links. - FM
*/
+
if (present &&
present[HTML_LINK_REL] && value[HTML_LINK_REL]) {
/*
* Ignore style sheets, for now. - FM
*/
+/* lss and css has different syntax - lynx shouldn't try to
+ parse them now (it tries to parse them as lss, so it exits with
+ error message the 1st non-empty line) - HVV
+*/
+#ifndef USE_COLOR_STYLE
if (!strcasecomp(value[HTML_LINK_REL], "StyleSheet") ||
!strcasecomp(value[HTML_LINK_REL], "Style")) {
CTRACE(tfp, "HTML: StyleSheet link found.\n");
@@ -959,6 +1227,7 @@ PRIVATE void HTML_start_element ARGS6(
FREE(href);
break;
}
+#endif /* ! USE_COLOR_STYLE */
/*
* Ignore anything not registered in the the 28-Mar-95
@@ -2881,7 +3150,7 @@ PRIVATE void HTML_start_element ARGS6(
if ((ID_A = HTAnchor_findChildAndLink(
me->node_anchor, /* Parent */
id_string, /* Tag */
- NULL, /* Addresss */
+ NULL, /* Addresss */
(HTLinkType*)0)) != NULL) { /* Type */
HText_beginAnchor(me->text, me->inUnderline, ID_A);
HText_endAnchor(me->text, 0);
@@ -2930,7 +3199,7 @@ PRIVATE void HTML_start_element ARGS6(
if ((ID_A = HTAnchor_findChildAndLink(
me->node_anchor, /* Parent */
id_string, /* Tag */
- NULL, /* Addresss */
+ NULL, /* Addresss */
(HTLinkType*)0)) != NULL) { /* Type */
HText_beginAnchor(me->text, me->inUnderline, ID_A);
HText_endAnchor(me->text, 0);
@@ -2943,7 +3212,7 @@ PRIVATE void HTML_start_element ARGS6(
if ((ID_A = HTAnchor_findChildAndLink(
me->node_anchor, /* Parent */
id_string, /* Tag */
- NULL, /* Addresss */
+ NULL, /* Addresss */
(HTLinkType*)0)) != NULL) { /* Type */
HText_beginAnchor(me->text, me->inUnderline, ID_A);
HText_endAnchor(me->text, 0);
@@ -2989,7 +3258,7 @@ PRIVATE void HTML_start_element ARGS6(
if ((ID_A = HTAnchor_findChildAndLink(
me->node_anchor, /* Parent */
id_string, /* Tag */
- NULL, /* Addresss */
+ NULL, /* Addresss */
(HTLinkType*)0)) != NULL) { /* Type */
HText_beginAnchor(me->text, me->inUnderline, ID_A);
HText_endAnchor(me->text, 0);
@@ -3094,7 +3363,7 @@ PRIVATE void HTML_start_element ARGS6(
if ((ID_A = HTAnchor_findChildAndLink(
me->node_anchor, /* Parent */
id_string, /* Tag */
- NULL, /* Addresss */
+ NULL, /* Addresss */
(HTLinkType*)0)) != NULL) { /* Type */
HText_beginAnchor(me->text, me->inUnderline, ID_A);
HText_endAnchor(me->text, 0);
@@ -5251,7 +5520,7 @@ PRIVATE void HTML_start_element ARGS6(
}
CTRACE(tfp,"HTML:begin_element[%d]: adding style to stack - %s\n",
- (int) STACKLEVEL(me),
+ (int) STACKLEVEL(me),
me->new_style->name);
(me->sp)--;
me->sp[0].style = me->new_style; /* Stack new style */
@@ -5269,10 +5538,20 @@ PRIVATE void HTML_start_element ARGS6(
#if !defined(USE_HASH)
HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF);
#else
- HText_characterStyle(me->text, hcode, STACK_OFF);
+ HText_characterStyle(me->text, HCODE_TO_STACK_OFF(hcode), STACK_OFF);
#endif /* USE_HASH */
+
+#if !OPT_SCN
TrimColorClass(HTML_dtd.tags[element_number].name,
Style_className, &hcode);
+#else
+# if !OMIT_SCN_KEEPING
+ FastTrimColorClass(HTML_dtd.tags[element_number].name,
+ HTML_dtd.tags[element_number].name_len,
+ Style_className,
+ &Style_className_end, &hcode);
+# endif
+#endif
}
#endif /* USE_COLOR_STYLE */
}
@@ -5292,7 +5571,7 @@ PRIVATE void HTML_start_element ARGS6(
** incoming code errors, not this module.
*/
PRIVATE void HTML_end_element ARGS3(
- HTStructured *, me,
+ HTStructured *, me,
int, element_number,
char **, include)
{
@@ -5300,6 +5579,32 @@ PRIVATE void HTML_end_element ARGS3(
char *temp = NULL, *cp = NULL;
BOOL BreakFlag = FALSE;
+#ifdef USE_PSRC
+ if (psrc_view && !sgml_in_psrc_was_initialized) {
+ if (!psrc_nested_call) {
+ HTTag * tag = &HTML_dtd.tags[element_number];
+ char buf[200];
+ int tag_charset=0;
+
+ psrc_nested_call=TRUE;
+ PSRCSTART(abracket); PUTS("</"); PSRCSTOP(abracket);
+ PSRCSTART(tag);
+ if (tagname_transform!=0)
+ PUTS(tag->name);
+ else {
+ strcpy(buf,tag->name);
+ LYLowerCase(buf);
+ PUTS(buf);
+ }
+ PSRCSTOP(tag);
+ PSRCSTART(abracket); PUTC('>'); PSRCSTOP(abracket);
+ psrc_nested_call=FALSE;
+ return;
+ }
+ /*fall through*/
+ }
+#endif
+
#ifdef CAREFUL /* parser assumed to produce good nesting */
if (element_number != me->sp[0].tag_number &&
HTML_dtd.tags[element_number].contents != SGML_EMPTY) {
@@ -5394,7 +5699,7 @@ PRIVATE void HTML_end_element ARGS3(
} else if (me->sp < (me->stack + MAX_NESTING - 1)) {
(me->sp)++;
CTRACE(tfp, "HTML:end_element[%d]: Popped style off stack - %s\n",
- (int) STACKLEVEL(me),
+ (int) STACKLEVEL(me),
me->sp->style->name);
} else {
CTRACE(tfp,
@@ -6617,8 +6922,17 @@ End_Object:
} /* switch */
#ifdef USE_COLOR_STYLE
+#if !OPT_SCN
TrimColorClass(HTML_dtd.tags[element_number].name,
Style_className, &hcode);
+#else
+# if !OMIT_SCN_KEEPING
+ FastTrimColorClass(HTML_dtd.tags[element_number].name,
+ HTML_dtd.tags[element_number].name_len,
+ Style_className,
+ &Style_className_end, &hcode);
+# endif
+#endif
if (!REALLY_EMPTY(element_number))
{
@@ -6626,7 +6940,7 @@ End_Object:
#if !defined(USE_HASH)
HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF);
#else
- HText_characterStyle(me->text, hcode, STACK_OFF);
+ HText_characterStyle(me->text, HCODE_TO_STACK_OFF(hcode), STACK_OFF);
#endif /* USE_HASH */
}
#endif /* USE_COLOR_STYLE */
@@ -6841,7 +7155,9 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
styles[HTML_PRE]->alignment = HT_LEFT;
}
#ifdef USE_COLOR_STYLE
+# if !OPT_SCN
FREE(Style_className);
+# endif
#endif
FREE(me->base_href);
FREE(me->map_address);
@@ -6930,7 +7246,9 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e)
styles[HTML_PRE]->alignment = HT_LEFT;
}
#ifdef USE_COLOR_STYLE
+# if !OPT_SCN
FREE(Style_className);
+# endif
#endif
FREE(me->base_href);
FREE(me->map_address);
@@ -6995,19 +7313,19 @@ PRIVATE void get_styles NOARGS
styles[HTML_DLC] = HTStyleNamed(styleSheet, "GlossaryCompact");
/* nested list styles */
- styles[HTML_DLC1] = HTStyleNamed(styleSheet, "GlossaryCompact1");
- styles[HTML_DLC2] = HTStyleNamed(styleSheet, "GlossaryCompact2");
- styles[HTML_DLC3] = HTStyleNamed(styleSheet, "GlossaryCompact3");
- styles[HTML_DLC4] = HTStyleNamed(styleSheet, "GlossaryCompact4");
- styles[HTML_DLC5] = HTStyleNamed(styleSheet, "GlossaryCompact5");
- styles[HTML_DLC6] = HTStyleNamed(styleSheet, "GlossaryCompact6");
+ styles[HTML_DLC1] = HTStyleNamed(styleSheet, "GlossaryCompact1");
+ styles[HTML_DLC2] = HTStyleNamed(styleSheet, "GlossaryCompact2");
+ styles[HTML_DLC3] = HTStyleNamed(styleSheet, "GlossaryCompact3");
+ styles[HTML_DLC4] = HTStyleNamed(styleSheet, "GlossaryCompact4");
+ styles[HTML_DLC5] = HTStyleNamed(styleSheet, "GlossaryCompact5");
+ styles[HTML_DLC6] = HTStyleNamed(styleSheet, "GlossaryCompact6");
styles[HTML_ADDRESS] = HTStyleNamed(styleSheet, "Address");
styles[HTML_BANNER] = HTStyleNamed(styleSheet, "Banner");
styles[HTML_BLOCKQUOTE] = HTStyleNamed(styleSheet, "Blockquote");
styles[HTML_BQ] = HTStyleNamed(styleSheet, "Bq");
styles[HTML_FN] = HTStyleNamed(styleSheet, "Footnote");
- styles[HTML_NOTE] = HTStyleNamed(styleSheet, "Note");
+ styles[HTML_NOTE] = HTStyleNamed(styleSheet, "Note");
styles[HTML_PLAINTEXT] =
styles[HTML_XMP] = HTStyleNamed(styleSheet, "Example");
styles[HTML_PRE] = HTStyleNamed(styleSheet, "Preformatted");
@@ -7200,7 +7518,11 @@ PUBLIC HTStructured* HTML_new ARGS3(
me->comment_end = NULL;
#ifdef USE_COLOR_STYLE
+# if !OPT_SCN
FREE(Style_className);
+# else
+ Style_className_end = Style_className;
+# endif
class_string[0] = '\0';
#endif
@@ -7295,11 +7617,157 @@ PUBLIC HTStructured* HTML_new ARGS3(
me->target = stream;
if (stream)
- me->targetClass = *stream->isa; /* Copy pointers */
+ me->targetClass = *stream->isa; /* Copy pointers */
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;
+ }
+
+ /*
+ * We open the temp file in binary mode to make sure that
+ * end-of-line stuff and high-bit Latin-1 (or other) characters
+ * don't get munged; this way, the file should (knock on wood)
+ * contain exactly what came in from the network.
+ */
+ if (!(stream->fp = LYOpenTemp(filename, HTML_SUFFIX, "wb"))) {
+ 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,7 +7781,13 @@ PUBLIC HTStream* HTMLToPlain ARGS3(
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
@@ -7356,7 +7830,7 @@ PUBLIC HTStream* HTMLParsedPresent ARGS3(
intermediate = HTStreamStack(WWW_PLAINTEXT, WWW_PRESENT,
NULL, anchor);
} else {
- /* this too should amount to calling HTPlainPresent: */
+ /* this too should amount to calling HTPlainPresent: */
intermediate = HTStreamStack(WWW_PLAINTEXT, pres->rep_out,
NULL, anchor);
}
@@ -7372,7 +7846,13 @@ PUBLIC HTStream* HTMLParsedPresent ARGS3(
}
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,7 +7877,12 @@ PUBLIC HTStream* HTMLToC ARGS3(
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,7 +7899,13 @@ PUBLIC HTStream* HTMLPresent ARGS3(
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 */
diff --git a/src/LYBookmark.c b/src/LYBookmark.c
index fcad0b4d..752de49d 100644
--- a/src/LYBookmark.c
+++ b/src/LYBookmark.c
@@ -5,7 +5,6 @@
#include <LYBookmark.h>
#include <LYGlobalDefs.h>
#include <LYClean.h>
-#include <LYSignal.h>
#include <LYKeymap.h>
#include <LYCharUtils.h> /* need for META charset */
#include <UCAux.h>
diff --git a/src/LYCgi.c b/src/LYCgi.c
index 2704f6d9..099a514e 100644
--- a/src/LYCgi.c
+++ b/src/LYCgi.c
@@ -91,7 +91,9 @@ PRIVATE void remember_alloced ARGS1(
{
if (!alloced) {
alloced = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(free_alloced_lynxcgi);
+#endif
}
HTList_addObject(alloced, ptr);
}
diff --git a/src/LYCharSets.c b/src/LYCharSets.c
index 87392050..7f43fbe6 100644
--- a/src/LYCharSets.c
+++ b/src/LYCharSets.c
@@ -12,7 +12,6 @@
#include <LYCurses.h>
#include <LYStrings.h>
-#include <LYexit.h>
#include <LYLeaks.h>
extern BOOL HTPassEightBitRaw;
diff --git a/src/LYClean.c b/src/LYClean.c
index 16231871..1b6b5e32 100644
--- a/src/LYClean.c
+++ b/src/LYClean.c
@@ -9,6 +9,7 @@
#include <LYTraversal.h>
#include <LYCookie.h>
#include <UCAuto.h>
+#include <HTAlert.h>
#include <LYexit.h>
#include <LYLeaks.h>
diff --git a/src/LYCookie.c b/src/LYCookie.c
index 3eedd8c2..6c56aa85 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -211,7 +211,7 @@ PRIVATE BOOLEAN host_matches ARGS2(
* The following line will handle both numeric IP addresses and
* FQDNs. Do numeric addresses require special handling?
*/
- if (*B != '.' && !strcmp(A, B))
+ if (*B != '.' && !strcasecomp(A, B))
return YES;
/*
@@ -221,7 +221,7 @@ PRIVATE BOOLEAN host_matches ARGS2(
if (*B == '.' && B[1] != '\0' && B[1] != '.' && *A != '.') {
int diff = (strlen(A) - strlen(B));
if (diff > 0) {
- if (!strcmp((A + diff), B))
+ if (!strcasecomp((A + diff), B))
return YES;
}
}
@@ -280,7 +280,9 @@ PRIVATE void store_cookie ARGS3(
* Ensure that the domain list exists.
*/
if (domain_list == NULL) {
+#ifdef LY_FIND_LEAKS
atexit(LYCookieJar_free);
+#endif
domain_list = HTList_new();
total_cookies = 0;
}
@@ -343,9 +345,9 @@ PRIVATE void store_cookie ARGS3(
}
/*
* The next 4 conditions do NOT apply if the domain is still
- * the default of request-host.
+ * the default of request-host. (domains - case insensitive).
*/
- if (strcmp(co->domain, hostname) != 0) {
+ if (strcasecomp(co->domain, hostname) != 0) {
/*
* The hostname does not contain a dot.
*/
@@ -1074,9 +1076,10 @@ PRIVATE void LYProcessSetCookies ARGS6(
* not an exact match to the hostname, nor
* is a numeric IP address, add a lead dot.
* Otherwise, use the value as is. - FM
+ * (domains - case insensitive).
*/
if (value[0] != '.' && value[0] != '\0' &&
- value[1] != '\0' && strcmp(value, hostname)) {
+ value[1] != '\0' && strcasecomp(value, hostname)) {
char *ptr = strchr(value, '.');
if (ptr != NULL && ptr[1] != '\0') {
ptr = value;
@@ -1575,9 +1578,10 @@ PRIVATE void LYProcessSetCookies ARGS6(
* not an exact match to the hostname, nor
* is a numeric IP address, add a lead dot.
* Otherwise, use the value as is. - FM
+ * (domains - case insensitive).
*/
if (value[0] != '.' && value[0] != '\0' &&
- value[1] != '\0' && strcmp(value, hostname)) {
+ value[1] != '\0' && strcasecomp(value, hostname)) {
char *ptr = strchr(value, '.');
if (ptr != NULL && ptr[1] != '\0') {
ptr = value;
@@ -2121,6 +2125,7 @@ PUBLIC void LYStoreCookies ARGS1 (
CTRACE(tfp, "LYStoreCookies: save cookies to %s on exit\n", cookie_file);
cookie_handle = LYNewTxtFile (cookie_file);
+ if (cookie_handle == NULL) return;
for (dl = domain_list; dl != NULL; dl = dl->next) {
de = dl->object;
if (de == NULL)
@@ -2662,7 +2667,7 @@ PUBLIC void cookie_domain_flag_set ARGS2(
int isexisting = FALSE;
if (str == NULL)
- outofmem(__FILE__, "cookie_set_invcheck");
+ outofmem(__FILE__, "cookie_set_invcheck");
/*
* Is this the first domain we're handling? If so, initialize
@@ -2670,7 +2675,9 @@ PUBLIC void cookie_domain_flag_set ARGS2(
*/
if (domain_list == NULL) {
+#ifdef LY_FIND_LEAKS
atexit(LYCookieJar_free);
+#endif
domain_list = HTList_new();
total_cookies = 0;
}
diff --git a/src/LYCurses.c b/src/LYCurses.c
index b850c895..8433cec5 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -52,6 +52,11 @@ BOOLEAN LYCursesON = FALSE;
PRIVATE int Current_Attr;
#endif
+#define OMIT_SCN_KEEPING 0 /* whether to omit keeping of Style_className
+ in HTML.c when lss support is on. 1 to increase performance. The value
+ must correspond to the value of macro OMIT_SCN_KEEPING defined in HTML.c*/
+
+
#ifdef USE_SLANG
PUBLIC unsigned int Lynx_Color_Flags = 0;
PUBLIC BOOLEAN FullRefresh = FALSE;
@@ -63,6 +68,8 @@ PUBLIC int curscr = 0;
PUBLIC int PHYSICAL_SLtt_Screen_Cols = 10;
#endif /* SLANG_MBCS_HACK */
+
+
PUBLIC void LY_SLrefresh NOARGS
{
if (FullRefresh) {
@@ -311,14 +318,29 @@ PUBLIC void curses_w_style ARGS3(
int, style,
int, dir)
{
+#if OMIT_SCN_KEEPING
+# define SPECIAL_STYLE /*(CSHASHSIZE+1) */ 88888
+ /* if TRACEs are not compiled in, this macro is redundant - we neend't valid
+ 'ds' to stack off. */
+#endif
+
int YP,XP;
- bucket* ds=&hashStyles[style];
+#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]) );
+#endif
+
if (!ds->name)
{
CTRACE(tfp, "CSS.CS:Style %d not configured\n",style);
+#if !OMIT_SCN_KEEPING
return;
+#endif
}
+
CTRACE(tfp, "CSS.CS:<%s%s> (%d)\n",(dir?"":"/"),ds->name,ds->code);
getyx (win, YP, XP);
@@ -352,16 +374,20 @@ PUBLIC void curses_w_style ARGS3(
}
last_styles[last_colorattr_ptr++] = getattrs(stdscr);
/* don't cache style changes for active links */
+#if OMIT_SCN_KEEPING
+ /* since we don't compute the hcode
+ to stack off in HTML.c, we don't know whether this style is
+ configured. So, we shouldn't simply return on stacking on on
+ unconfigured styles, we should push curr attrs on stack. -HV
+ */
+ if (!ds->name) return;
+#endif
if (style != s_alink)
{
CTRACE(tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP);
if (win==stdscr) cached_styles[YP][XP]=style;
- LYAttrset(win, ds->color, ds->mono);
- }
- else
- {
- LYAttrset(win, ds->color, ds->mono);
}
+ LYAttrset(win, ds->color, ds->mono);
return;
case ABS_ON: /* change without remembering the previous style */
@@ -370,12 +396,8 @@ PUBLIC void curses_w_style ARGS3(
{
CTRACE(tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP);
if (win==stdscr) cached_styles[YP][XP]=style;
- LYAttrset(win, ds->color, ds->mono);
- }
- else
- {
- LYAttrset(win, ds->color, ds->mono);
}
+ LYAttrset(win, ds->color, ds->mono);
return;
}
}
diff --git a/src/LYDownload.c b/src/LYDownload.c
index c446e563..15f292d0 100644
--- a/src/LYDownload.c
+++ b/src/LYDownload.c
@@ -5,12 +5,10 @@
#include <LYCurses.h>
#include <LYUtils.h>
#include <LYGlobalDefs.h>
-#include <LYSignal.h>
#include <LYStrings.h>
#include <LYGetFile.h>
#include <LYDownload.h>
-#include <LYexit.h>
#include <LYLeaks.h>
/*
diff --git a/src/LYEdit.c b/src/LYEdit.c
index 7f225041..d7445630 100644
--- a/src/LYEdit.c
+++ b/src/LYEdit.c
@@ -2,9 +2,7 @@
#include <HTParse.h>
#include <HTAlert.h>
#include <LYCurses.h>
-#include <LYSignal.h>
#include <LYUtils.h>
-#include <LYClean.h>
#include <LYGlobalDefs.h>
#include <LYEdit.h>
#include <LYStrings.h>
diff --git a/src/LYForms.c b/src/LYForms.c
index 60150823..399f61df 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -12,7 +12,6 @@
#include <LYGlobalDefs.h>
#include <LYKeymap.h>
#include <LYClean.h>
-#include <LYSignal.h>
#include <LYLeaks.h>
diff --git a/src/LYGetFile.c b/src/LYGetFile.c
index 010c4a92..678bf56b 100644
--- a/src/LYGetFile.c
+++ b/src/LYGetFile.c
@@ -250,33 +250,13 @@ Try_Redirected_URL:
#endif
} else if (url_type == LYNXCFG_URL_TYPE) {
- /* show lynx.cfg settings */
- StrAllocCopy(doc->address, lynx_cfg_infopage());
- WWWDoc.address = doc->address;
- WWWDoc.post_data = doc->post_data;
- WWWDoc.post_content_type = doc->post_content_type;
- WWWDoc.bookmark = doc->bookmark;
- WWWDoc.isHEAD = doc->isHEAD;
- WWWDoc.safe = doc->safe;
+ /* show/change/reload lynx.cfg settings */
+ return(lynx_cfg_infopage(doc));
- if (!HTLoadAbsolute(&WWWDoc))
- return(NOT_FOUND);
- return(NORMAL);
-
-#ifdef HAVE_CFG_DEFS_H
+#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
} else if (url_type == LYNXCOMPILE_OPTS_URL_TYPE) {
/* show compile-time settings */
- StrAllocCopy(doc->address, (char *)lynx_compile_opts());
- WWWDoc.address = doc->address;
- WWWDoc.post_data = doc->post_data;
- WWWDoc.post_content_type = doc->post_content_type;
- WWWDoc.bookmark = doc->bookmark;
- WWWDoc.isHEAD = doc->isHEAD;
- WWWDoc.safe = doc->safe;
-
- if (!HTLoadAbsolute(&WWWDoc))
- return(NOT_FOUND);
- return(NORMAL);
+ return(lynx_compile_opts(doc));
#endif
#ifndef DISABLE_NEWS
@@ -1177,7 +1157,9 @@ PUBLIC void add_trusted ARGS2(
if (!src)
return;
if (first) {
+#ifdef LY_FIND_LEAKS
atexit(LYTrusted_free);
+#endif
first = FALSE;
}
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index 1d467e53..a7ae11e3 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -27,6 +27,10 @@
#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,6 +249,14 @@ extern BOOLEAN nolist;
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;
diff --git a/src/LYHash.c b/src/LYHash.c
index 3410603a..42f9fdac 100644
--- a/src/LYHash.c
+++ b/src/LYHash.c
@@ -3,21 +3,23 @@
*/
#include <LYHash.h>
+#ifdef USE_COLOR_STYLE
+
#ifdef NOT_USED
PUBLIC int hash_table[CSHASHSIZE]; /* 32K should be big enough */
PUBLIC int hash_code_rp ARGS1(char*,string)
{
- char* hash_ptr = string;
- int hash_tmp = 0xC00A | ((*hash_ptr) << 4);
-
- while (*hash_ptr++)
- {
- hash_tmp ^= (((*hash_ptr)<<4) ^ ((*hash_ptr)<<12));
- hash_tmp >>= 1;
- }
- return (hash_tmp % CSHASHSIZE);
+ char* hash_ptr = string;
+ int hash_tmp = 0xC00A | ((*hash_ptr) << 4);
+
+ while (*hash_ptr++)
+ {
+ hash_tmp ^= (((*hash_ptr)<<4) ^ ((*hash_ptr)<<12));
+ hash_tmp >>= 1;
+ }
+ return (hash_tmp % CSHASHSIZE);
}
#endif
@@ -42,3 +44,32 @@ PUBLIC int hash_code ARGS1 (char*, string)
return hash;
}
+
+PUBLIC int hash_code_lowercase_on_fly ARGS1 (char*, string)
+{
+ int hash;
+ unsigned char *p;
+
+ for (p = (unsigned char *)string, hash = 0; *p; p++)
+ hash = (int) (hash * 3 + (unsigned char)tolower(*(char*)p) ) % HASH_SIZE;
+
+ return hash;
+}
+
+PUBLIC int hash_code_aggregate_char ARGS2 (char, c,int,hash)
+{
+ return (int)(hash*3 + (unsigned char)c) % HASH_SIZE;
+}
+
+PUBLIC int hash_code_aggregate_lower_on_fly ARGS2 (char*, string,int,hash_was)
+{
+ int hash;
+ unsigned char *p;
+
+ for (p = (unsigned char *)string, hash = hash_was ; *p; p++)
+ hash = (int) (hash * 3 + (unsigned char)tolower(*(char*)p) ) % HASH_SIZE;
+
+ return hash;
+}
+
+#endif /* USE_COLOR_STYLE */
diff --git a/src/LYHash.h b/src/LYHash.h
index c532a93a..0d562cff 100644
--- a/src/LYHash.h
+++ b/src/LYHash.h
@@ -26,6 +26,16 @@ typedef struct _hashbucket bucket;
extern bucket hashStyles[CSHASHSIZE];
extern int hash_code PARAMS((char* string));
+extern bucket special_bucket;/*it's used when OMIT_SCN_KEEPING is 1 in HTML.c
+ and LYCurses.c. */
+extern bucket nostyle_bucket;/*initialized properly - to be used in CTRACE when
+ NOSTYLE is passed as 'style' to curses_w_style */
+
+extern int hash_code_lowercase_on_fly PARAMS((char* string));
+extern int hash_code_aggregate_char PARAMS((char c,int hash));
+extern int hash_code_aggregate_lower_on_fly PARAMS((char* c,int hash_was));
+
+
#ifdef NOT_USED
extern int hash_table[CSHASHSIZE]; /* 32K should be big enough */
#endif
diff --git a/src/LYHistory.c b/src/LYHistory.c
index b0a2b827..813eedb6 100644
--- a/src/LYHistory.c
+++ b/src/LYHistory.c
@@ -67,6 +67,7 @@ PUBLIC void LYAddVisitedLink ARGS1(
* or list files. - FM
*/
if (doc->post_data || doc->isHEAD || doc->bookmark ||
+ (!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) ||
@@ -82,9 +83,11 @@ PUBLIC void LYAddVisitedLink ARGS1(
!strcmp((doc->title ? doc->title : ""), ADDRLIST_PAGE_TITLE) ||
#endif
!strcmp((doc->title ? doc->title : ""), SHOWINFO_TITLE) ||
+ !strcmp((doc->title ? doc->title : ""), CONFIG_DEF_TITLE) ||
+ !strcmp((doc->title ? doc->title : ""), LYNXCFG_TITLE) ||
!strcmp((doc->title ? doc->title : ""), COOKIE_JAR_TITLE) ||
!strcmp((doc->title ? doc->title : ""), VISITED_LINKS_TITLE) ||
- !strcmp((doc->title ? doc->title : ""), LYNX_TRACELOG_TITLE)) {
+ !strcmp((doc->title ? doc->title : ""), LYNX_TRACELOG_TITLE)))) {
return;
}
@@ -95,7 +98,9 @@ PUBLIC void LYAddVisitedLink ARGS1(
if (!Visited_Links) {
Visited_Links = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(Visited_Links_free);
+#endif
HTList_addObject(Visited_Links, new);
return;
}
diff --git a/src/LYJump.c b/src/LYJump.c
index 534e9c21..5b185d0c 100644
--- a/src/LYJump.c
+++ b/src/LYJump.c
@@ -5,7 +5,6 @@
#include <LYGlobalDefs.h>
#include <LYJump.h>
#include <LYKeymap.h>
-#include <LYSignal.h>
#include <GridText.h>
#include <LYLeaks.h>
diff --git a/src/LYLeaks.c b/src/LYLeaks.c
index 58c4b114..504954a3 100644
--- a/src/LYLeaks.c
+++ b/src/LYLeaks.c
@@ -103,6 +103,7 @@ PUBLIC void LYLeaks NOARGS
}
} else {
size_t i_counter;
+ char *value = (char *)(ALp_head->vp_Alloced);
/*
* Increment the count of total memory lost and
@@ -121,9 +122,8 @@ PUBLIC void LYLeaks NOARGS
i_counter < ALp_head->st_Bytes &&
i_counter < MAX_CONTENT_LENGTH;
i_counter++) {
- if (isprint(((char *)(ALp_head->vp_Alloced))[i_counter])) {
- fprintf(Fp_leakagesink, "%c",
- ((char *)(ALp_head->vp_Alloced))[i_counter]);
+ if (isprint(value[i_counter])) {
+ fprintf(Fp_leakagesink, "%c", value[i_counter]);
} else {
fprintf(Fp_leakagesink, "|");
}
@@ -178,7 +178,7 @@ PUBLIC void LYLeaks NOARGS
** the information in a list.
** Arguments: st_bytes The size of the allocation requested
** in bytes.
-** cp_File The file from which the request for
+** cp_File The file from which the request for
** allocation came from.
** ssi_Line The line number in cp_File where the
** allocation request came from.
@@ -191,7 +191,7 @@ PUBLIC void LYLeaks NOARGS
** 05-26-94 created Lynx 2-3-1 Garrett Arch Blythe
*/
PUBLIC void *LYLeakMalloc ARGS3(
- size_t, st_bytes,
+ size_t, st_bytes,
CONST char *, cp_File,
CONST short, ssi_Line)
{
@@ -238,7 +238,7 @@ PUBLIC void *LYLeakMalloc ARGS3(
** save relevant information in a list.
** Arguments: st_number The number of items to allocate.
** st_bytes The size of each item.
-** cp_File The file which wants to allocation.
+** cp_File The file which wants to allocation.
** ssi_Line The line number in cp_File requesting
** the allocation.
** Return Value: void * The allocated memory, or NULL on failure as
@@ -250,8 +250,8 @@ PUBLIC void *LYLeakMalloc ARGS3(
** 05-26-94 created Lynx 2-3-1 Garrett Arch Blythe
*/
PUBLIC void *LYLeakCalloc ARGS4(
- size_t, st_number,
- size_t, st_bytes,
+ size_t, st_number,
+ size_t, st_bytes,
CONST char *, cp_File,
CONST short, ssi_Line)
{
@@ -303,7 +303,7 @@ PUBLIC void *LYLeakCalloc ARGS4(
** realloc works just like
** malloc.
** st_newBytes The new size of the chunk of memory.
-** cp_File The file containing the realloc.
+** cp_File The file containing the realloc.
** ssi_Line The line containing the realloc in cp_File.
** Return Value: void * The new pointer value (could be the same) or
** NULL if unable to resize (old block
@@ -317,8 +317,8 @@ PUBLIC void *LYLeakCalloc ARGS4(
** 05-26-94 created Lynx 2-3-1 Garrett Arch Blythe
*/
PUBLIC void *LYLeakRealloc ARGS4(
- void *, vp_Alloced,
- size_t, st_newBytes,
+ void *, vp_Alloced,
+ size_t, st_newBytes,
CONST char *, cp_File,
CONST short, ssi_Line)
{
@@ -392,7 +392,7 @@ PUBLIC void *LYLeakRealloc ARGS4(
** Purpose: Capture all requests to free information and also
** remove items from the allocation list.
** Arguments: vp_Alloced The memory to free.
-** cp_File The file calling free.
+** cp_File The file calling free.
** ssi_Line The line of cp_File calling free.
** Return Value: void
** Remarks/Portability/Dependencies/Restrictions:
@@ -404,7 +404,7 @@ PUBLIC void *LYLeakRealloc ARGS4(
** 05-26-94 created Lynx 2-3-1 Garrett Arch Blythe
*/
PUBLIC void LYLeakFree ARGS3(
- void *, vp_Alloced,
+ void *, vp_Alloced,
CONST char *, cp_File,
CONST short, ssi_Line)
{
@@ -556,7 +556,7 @@ PRIVATE void AddToList ARGS1(
** 05-26-94 created Lynx 2-3-1 Garrett Arch Blythe
*/
PRIVATE AllocationList *FindInList ARGS1(
- void *, vp_find)
+ void *, vp_find)
{
AllocationList *ALp_find = ALp_RunTimeAllocations;
diff --git a/src/LYMain.c b/src/LYMain.c
index 9e03d659..43511c64 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -26,9 +26,11 @@
#include <LYMainLoop.h>
#include <LYBookmark.h>
#include <LYCookie.h>
+#include <LYPrettySrc.h>
#ifdef __DJGPP__
#include <dos.h>
+#include <dpmi.h>
#endif /* __DJGPP__ */
#ifdef __EMX__
@@ -360,7 +362,7 @@ PUBLIC char *LYCookieSLooseCheckDomains = NULL; /* check loosely */
PUBLIC char *LYCookieSQueryCheckDomains = NULL; /* check w/a query */
#ifdef EXP_PERSISTENT_COOKIES
BOOLEAN persistent_cookies = TRUE;
-PUBLIC char *LYCookieFile = NULL; /* default cookie file */
+PUBLIC char *LYCookieFile = NULL; /* default cookie file */
#endif /* EXP_PERSISTENT_COOKIES */
PUBLIC char *XLoadImageCommand = NULL; /* Default image viewer for X */
PUBLIC BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? */
@@ -414,6 +416,7 @@ PRIVATE HTList *LYStdinArgs = NULL;
PRIVATE BOOLEAN no_options_further=FALSE; /* set to TRUE after '--' argument */
#endif
+
PRIVATE void parse_arg PARAMS((char **arg, int *i));
PRIVATE void print_help_and_exit PARAMS((int exit_status));
@@ -435,11 +438,10 @@ PRIVATE int LY_set_ctrl_break(int setting)
PRIVATE int LY_get_ctrl_break(void)
{
- typedef union REGS Regs;
- extern Regs regs;
+ __dpmi_regs regs;
regs.h.ah = 0x33;
regs.h.al = 0x00;
- int86(0x21, &regs, &regs);
+ __dpmi_int (0x21, &regs);
return ((int) regs.h.dl);
}
@@ -626,7 +628,7 @@ static void FixCharacters(void)
/* these are used for matching commandline options. */
PRIVATE int argcmp ARGS2(
char*, str,
- char*, what)
+ char*, what)
{
if (str[0] == '-' && str[1] == '-' ) ++str;
return strcmp(str,what);
@@ -634,7 +636,7 @@ PRIVATE int argcmp ARGS2(
PRIVATE int argncmp ARGS2(
char*, str,
- char*, what)
+ char*, what)
{
if (str[0] == '-' && str[1] == '-' ) ++str;
return strncmp(str, what, strlen(what));
@@ -726,11 +728,12 @@ PUBLIC int main ARGS2(
* Will display memory leaks if LY_FIND_LEAKS is defined.
*/
atexit(LYLeaks);
-#endif /* LY_FIND_LEAKS */
/*
* Register the function which will free our allocated globals.
*/
atexit(free_lynx_globals);
+#endif /* LY_FIND_LEAKS */
+
#ifdef LOCALE
/*
@@ -1104,7 +1107,9 @@ PUBLIC int main ARGS2(
if (LYStdinArgs == NULL) {
LYStdinArgs = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(LYStdinArgs_free);
+#endif
}
StrAllocCopy(argument, buf);
HTList_appendObject(LYStdinArgs, argument);
@@ -1329,6 +1334,11 @@ PUBLIC int main ARGS2(
CTRACE(tfp, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", LYNX_SIG_FILE);
}
+#ifdef USE_PSRC
+ /*this is required for checking the tagspecs when parsing cfg file by
+ LYReadCFG.c:parse_html_src_spec -HV */
+ HTSwitchDTD(TRUE);
+#endif
/*
* Process the configuration file.
*/
@@ -1357,15 +1367,15 @@ PUBLIC int main ARGS2(
LYEnsureAbsoluteURL((char **)&LynxHome, "LynxHome");
/*
- * Process any command line arguments not already handled. - FM
+ * Process any command line arguments not already handled. - FM
*/
for (i = 1; i < argc; i++) {
parse_arg(&argv[i], &i);
}
/*
- * Process any stdin-derived arguments for a lone "-" which we've
- * loaded into LYStdinArgs. - FM
+ * Process any stdin-derived arguments for a lone "-" which we've
+ * loaded into LYStdinArgs. - FM
*/
if (LYStdinArgs != NULL) {
char *my_args[2];
@@ -1379,9 +1389,12 @@ PUBLIC int main ARGS2(
}
/*
- * Set the rest of variables when the configuration have read.
+ * Initialize other things based on the configuration read.
*/
+#ifdef USE_PSRC
+ if ( (!Old_DTD) != TRUE ) /* skip if they are already initialized -HV */
+#endif
HTSwitchDTD(!Old_DTD);
/*
@@ -1414,6 +1427,14 @@ PUBLIC int main ARGS2(
#endif
/*
+ * Set up our help and about file base paths. - FM
+ */
+ StrAllocCopy(helpfilepath, helpfile);
+ if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath)
+ *cp = '\0';
+ LYAddHtmlSep(&helpfilepath);
+
+ /*
* Check for a save space path in the environment.
* If one was set in the configuration file, that
* one will be overridden. - FM
@@ -1556,6 +1577,14 @@ PUBLIC int main ARGS2(
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 */
@@ -1637,6 +1666,11 @@ PUBLIC int main ARGS2(
* Done here so that URL guessing in LYEnsureAbsoluteURL() can be
* interruptible (terminal is in raw mode, select() works). -BL
*/
+#ifdef USE_PSRC
+ if (!dump_output_immediately)
+ HTMLSRC_init_caches(); /* do it before terminal is initialized*/
+#endif
+
if (!dump_output_immediately) {
setup(terminal);
}
@@ -1700,14 +1734,6 @@ PUBLIC int main ARGS2(
}
/*
- * Set up our help and about file base paths. - FM
- */
- StrAllocCopy(helpfilepath, helpfile);
- if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath)
- *cp = '\0';
- LYAddHtmlSep(&helpfilepath);
-
- /*
* Make sure our bookmark default strings
* are all allocated and synchronized. - FM
*/
@@ -1766,6 +1792,10 @@ PUBLIC int main ARGS2(
if (x_display != NULL && *x_display != '\0') {
LYisConfiguredForX = TRUE;
}
+#ifdef USE_COLOR_STYLE
+ cache_tag_styles();
+#endif
+
ena_csi((LYlowest_eightbit[current_char_set] > 155));
LYOpenCloset();
status = mainloop();
@@ -1802,6 +1832,58 @@ PUBLIC void LYRegisterLynxProtocols NOARGS
HTRegisterProtocol(&LYLynxCookies);
}
+/*
+ * Some staff to reload lynx.cfg without restarting new lynx session,
+ * also load options menu items and command-line options
+ * to made things consistent. Not implemented yet.
+ * Warning: experimental, more main() reorganization required.
+ *
+ * Called by user of interactive session by LYNXCFG://reload/ link.
+ */
+PUBLIC void reload_read_cfg NOARGS
+{
+ if (!LYRestricted) {
+
+ /* save .lynxrc file in case we change something from Options Menu */
+ if (!save_rc()) return;
+
+ /*
+ * Process the configuration file.
+ */
+ read_cfg(lynx_cfg_file, "main program", 1, (FILE *)0);
+
+ /*
+ * Process the RC file.
+ */
+ read_rc();
+
+
+ /* We are not interested in startfile here */
+ /* but other things may be lost: */
+
+ /*
+ * Process any command line arguments not already handled. - FM
+ */
+ /* Not implemented yet here */
+
+ /*
+ * Process any stdin-derived arguments for a lone "-" which we've
+ * loaded into LYStdinArgs. - FM
+ */
+ /* Not implemented yet here */
+
+ /*
+ * Initialize other things based on the configuration read.
+ */
+ /* Not implemented yet here,
+ * a major problem: file paths
+ * like lynx_temp_space, LYCookieFile etc.
+ */
+
+ }
+}
+
+
/* There are different ways of setting arguments on the command line, and
* there are different types of arguments. These include:
*
@@ -1813,7 +1895,7 @@ PUBLIC void LYRegisterLynxProtocols NOARGS
*/
struct parse_args_type;
-typedef int (*ParseFunc) PARAMS((struct parse_args_type *, char **, char *));
+typedef int (*ParseFunc) PARAMS((char *));
typedef union {
BOOLEAN * set_value;
@@ -1822,8 +1904,6 @@ typedef union {
ParseFunc fun_value;
} ParseUnion;
-#undef PARSE_DEBUG
-
/*
* Storing the four types of data in separate fields costs about 1K of data.
* However, this provides usable type-checking. The initial version of the
@@ -1906,9 +1986,7 @@ static int parse_authentication ARGS2(
}
/* -anonymous */
-static int anonymous_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int anonymous_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
/*
@@ -1923,9 +2001,7 @@ static int anonymous_fun ARGS3(
}
/* -assume_charset */
-static int assume_charset_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int assume_charset_fun ARGS1(
char *, next_arg)
{
UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
@@ -1939,9 +2015,7 @@ static int assume_charset_fun ARGS3(
}
/* -assume_local_charset */
-static int assume_local_charset_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int assume_local_charset_fun ARGS1(
char *, next_arg)
{
UCLYhndl_HTFile_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
@@ -1949,9 +2023,7 @@ static int assume_local_charset_fun ARGS3(
}
/* -assume_unrec_charset */
-static int assume_unrec_charset_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int assume_unrec_charset_fun ARGS1(
char *, next_arg)
{
UCLYhndl_for_unrec = safeUCGetLYhndl_byMIME(next_arg);
@@ -1959,9 +2031,7 @@ static int assume_unrec_charset_fun ARGS3(
}
/* -auth */
-static int auth_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int auth_fun ARGS1(
char *, next_arg)
{
parse_authentication(next_arg, authentication_info);
@@ -1969,9 +2039,7 @@ static int auth_fun ARGS3(
}
/* -base */
-static int base_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int base_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
/*
@@ -1991,9 +2059,7 @@ static int base_fun ARGS3(
#ifdef USE_SLANG
/* -blink */
-static int blink_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int blink_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
Lynx_Color_Flags |= SL_LYNX_USE_BLINK;
@@ -2002,9 +2068,7 @@ static int blink_fun ARGS3(
#endif
/* -cache */
-static int cache_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int cache_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0)
@@ -2018,9 +2082,7 @@ static int cache_fun ARGS3(
}
/* -child */
-static int child_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int child_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
child_lynx = TRUE;
@@ -2030,9 +2092,7 @@ static int child_fun ARGS3(
#ifdef USE_SLANG
/* -color */
-static int color_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int color_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
Lynx_Color_Flags |= SL_LYNX_USE_COLOR;
@@ -2045,9 +2105,7 @@ static int color_fun ARGS3(
#endif
/* -crawl */
-static int crawl_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int crawl_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
crawl = TRUE;
@@ -2056,9 +2114,7 @@ static int crawl_fun ARGS3(
}
/* -display */
-static int display_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int display_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0) {
@@ -2071,9 +2127,7 @@ static int display_fun ARGS3(
}
/* -dump */
-static int dump_output_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int dump_output_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
dump_output_immediately = TRUE;
@@ -2082,9 +2136,7 @@ static int dump_output_fun ARGS3(
}
/* -editor */
-static int editor_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int editor_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0)
@@ -2094,9 +2146,7 @@ static int editor_fun ARGS3(
}
/* -error_file */
-static int error_file_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int error_file_fun ARGS1(
char *, next_arg)
{
/*
@@ -2110,9 +2160,7 @@ static int error_file_fun ARGS3(
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
/* -exec */
-static int exec_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int exec_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
#ifndef NEVER_ALLOW_REMOTE_EXEC
@@ -2125,9 +2173,7 @@ static int exec_fun ARGS3(
#endif
/* -get_data */
-static int get_data_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int get_data_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
/*
@@ -2170,9 +2216,7 @@ static int get_data_fun ARGS3(
}
/* -help */
-static int help_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int help_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
print_help_and_exit (0);
@@ -2180,9 +2224,7 @@ static int help_fun ARGS3(
}
/* -hiddenlinks */
-static int hiddenlinks_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int hiddenlinks_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0) {
@@ -2202,9 +2244,7 @@ static int hiddenlinks_fun ARGS3(
}
/* -homepage */
-static int homepage_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int homepage_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0) {
@@ -2215,9 +2255,7 @@ static int homepage_fun ARGS3(
}
/* -mime_header */
-static int mime_header_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int mime_header_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
/*
@@ -2233,9 +2271,7 @@ static int mime_header_fun ARGS3(
#ifndef DISABLE_NEWS
/* -newschunksize */
-static int newschunksize_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int newschunksize_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0) {
@@ -2251,9 +2287,7 @@ static int newschunksize_fun ARGS3(
}
/* -newsmaxchunk */
-static int newsmaxchunk_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int newsmaxchunk_fun ARGS1(
char *, next_arg)
{
if (next_arg) {
@@ -2270,9 +2304,7 @@ static int newsmaxchunk_fun ARGS3(
#endif /* not DISABLE_NEWS */
/* -nobrowse */
-static int nobrowse_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int nobrowse_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
HTDirAccess = HT_DIR_FORBID;
@@ -2280,9 +2312,7 @@ static int nobrowse_fun ARGS3(
}
/* -nocolor */
-static int nocolor_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int nocolor_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
LYShowColor = SHOW_COLOR_NEVER;
@@ -2294,9 +2324,7 @@ static int nocolor_fun ARGS3(
}
/* -nopause */
-static int nopause_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int nopause_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
InfoSecs = 0;
@@ -2306,9 +2334,7 @@ static int nopause_fun ARGS3(
}
/* -pauth */
-static int pauth_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int pauth_fun ARGS1(
char *, next_arg)
{
parse_authentication(next_arg, proxyauth_info);
@@ -2316,9 +2342,7 @@ static int pauth_fun ARGS3(
}
/* -post_data */
-static int post_data_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int post_data_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
/*
@@ -2359,9 +2383,7 @@ static int post_data_fun ARGS3(
}
/* -restrictions */
-static int restrictions_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int restrictions_fun ARGS1(
char *, next_arg)
{
static CONST char *Usage[] = {
@@ -2456,9 +2478,7 @@ static int restrictions_fun ARGS3(
}
/* -selective */
-static int selective_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int selective_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
HTDirAccess = HT_DIR_SELECTIVE;
@@ -2466,9 +2486,7 @@ static int selective_fun ARGS3(
}
/* -source */
-static int source_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int source_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
dump_output_immediately = TRUE;
@@ -2479,9 +2497,7 @@ static int source_fun ARGS3(
}
/* -traversal */
-static int traversal_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int traversal_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
traversal = TRUE;
@@ -2495,9 +2511,7 @@ static int traversal_fun ARGS3(
}
/* -version */
-static int version_fun ARGS3(
- Parse_Args_Type *, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int version_fun ARGS1(
char *, next_arg GCC_UNUSED)
{
SetOutputMode( O_TEXT );
@@ -2525,9 +2539,7 @@ static int version_fun ARGS3(
}
/* -width */
-static int width_fun ARGS3(
- Parse_Args_Type*, p GCC_UNUSED,
- char **, argv GCC_UNUSED,
+static int width_fun ARGS1(
char *, next_arg)
{
if (next_arg != 0) {
@@ -2850,8 +2862,14 @@ with partial-display logic"
PARSE_SET(
"preparsed", SET_ARG, &LYPreparsedSource,
"show parsed text/html with -source and in source view\n\
- to visualize how lynx behave with invalid HTML"
+ to visualize how lynx behaves with invalid HTML"
),
+#ifdef USE_PSRC
+ PARSE_SET(
+ "prettysrc", SET_ARG, &LYpsrc,
+ "do syntax highlighting and hyperlink handling in source view"
+ ),
+#endif
PARSE_SET(
"print", UNSET_ARG, &no_print,
"enable print functions (DEFAULT)"
@@ -2919,7 +2937,7 @@ treated '>' as a co-terminator for double-quotes and tags"
),
#endif
#endif
- PARSE_FUN(
+ PARSE_SET(
"tagsoup", SET_ARG, &Old_DTD,
"use TagSoup rather than SortaSGML parser"
),
@@ -2988,11 +3006,11 @@ static void print_help_strings ARGS3(
int pad;
int c;
int first;
- int field_width = 21;
+ int field_width = 20;
- pad = field_width - (5 + (int) strlen (name));
+ pad = field_width - (4 + (int) strlen (name));
- fprintf (stdout, " -%s", name);
+ fprintf (stdout, " -%s", name);
if (*help != '=') {
pad--;
@@ -3047,7 +3065,11 @@ in double-quotes (\"-\") on VMS)", NULL);
for (p = Arg_Table; p->name != 0; p++) {
char temp[LINESIZE], *value = temp;
+#ifdef PARSE_DEBUG
+ Parse_Args_Type * q = p;
+#else
ParseUnion *q = (ParseUnion *)(&(p->value));
+#endif
switch (p->type & ARG_TYPE_MASK) {
case TOGGLE_ARG:
case SET_ARG:
@@ -3215,7 +3237,7 @@ PRIVATE void parse_arg ARGS2(
case FUNCTION_ARG:
fun = q->fun_value;
if (0 != fun) {
- if (-1 == (*fun) (p, argv, next_arg)) {
+ if (-1 == (*fun) (next_arg)) {
}
}
break;
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 8b0b824b..55de2ba5 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -36,6 +36,7 @@
#include <LYCharUtils.h>
#include <LYCookie.h>
#include <LYMainLoop.h>
+#include <LYPrettySrc.h>
#ifdef USE_EXTERNALS
#include <LYExtern.h>
@@ -53,6 +54,7 @@
#include <LYexit.h>
#include <LYLeaks.h>
+
PRIVATE BOOL confirm_post_resub PARAMS((
CONST char* address,
CONST char* title,
@@ -316,7 +318,9 @@ int mainloop NOARGS
language : ""));
StrAllocCopy(CurrentNegoCharset, (pref_charset ?
pref_charset : ""));
+#ifdef LY_FIND_LEAKS
atexit(free_mainloop_variables);
+#endif
initialize:
StrAllocCopy(newdoc.address, startfile);
StrAllocCopy(startrealm, startfile);
@@ -562,7 +566,9 @@ try_again:
display_partial = FALSE;
}
#endif /* DISP_PARTIAL */
-
+#ifdef USE_PSRC
+ psrc_first_tag = TRUE;
+#endif
#ifndef DONT_TRACK_INTERNAL_LINKS
if (try_internal) {
if (newdoc.address &&
@@ -1022,7 +1028,13 @@ try_again:
* to Newline, so we get a redraw.
*/
curdoc.line = -1;
-
+#ifdef USE_PSRC
+ if (psrc_view)
+ HTMark_asSource(); /* this flag is not set, since when
+ displaying source, psrc_view is temporary unset when
+ writing the HTML header - and HTMainText is created
+ at that time.*/
+#endif
break;
} /* end switch */
@@ -1052,7 +1064,12 @@ try_again:
* the visited links list. - FM
*/
if (ownerS_address != NULL) {
+#ifndef USE_PSRC
if (HTOutputFormat == WWW_SOURCE && !HText_getOwner())
+#else
+ if ( (LYpsrc ? psrc_view : HTOutputFormat == WWW_SOURCE)
+ && !HText_getOwner() )
+#endif
HText_setMainTextOwner(ownerS_address);
FREE(ownerS_address);
}
@@ -1073,6 +1090,9 @@ try_again:
* the source, we get rendered HTML from now on.
*/
HTOutputFormat = WWW_PRESENT;
+#ifdef USE_PSRC
+ psrc_view = FALSE;
+#endif
/*
* Reset all of the other relevant flags. - FM
@@ -1237,6 +1257,26 @@ try_again:
}
}
+#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()
@@ -1524,6 +1564,8 @@ try_again:
} else {
_statusline(HELP);
}
+ /* turn off cursor since now it's probably on statusline -HV */
+ move((LYlines - 1), (LYcols - 1));
} else {
show_help = FALSE;
}
@@ -2041,6 +2083,8 @@ new_cmd: /*
break;
}
+
+#ifndef USE_PSRC
if (HTisDocumentSource()) {
HTOutputFormat = WWW_PRESENT;
} else {
@@ -2049,8 +2093,28 @@ new_cmd: /*
LYUCPushAssumed(HTMainAnchor);
HTOutputFormat = WWW_SOURCE;
}
- LYforce_no_cache = TRUE;
+#else
+ if (HTisDocumentSource()) {
+ HTOutputFormat = WWW_PRESENT;
+ psrc_view = FALSE;
+ } else {
+ if (HText_getOwner())
+ StrAllocCopy(ownerS_address, HText_getOwner());
+ LYUCPushAssumed(HTMainAnchor);
+ if (LYpsrc)
+ psrc_view = TRUE;
+ else
+ HTOutputFormat = WWW_SOURCE;
+ }
+#endif
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+#endif
FREE(curdoc.address); /* so it doesn't get pushed */
+ LYforce_no_cache = TRUE;
break;
case LYK_RELOAD: /* control-R to reload and refresh */
@@ -2068,9 +2132,18 @@ new_cmd: /*
/*
* Check to see if should reload source, or load html
*/
+
if (HTisDocumentSource()) {
+#ifndef USE_PSRC
HTOutputFormat = WWW_SOURCE;
+#else
+ if (LYpsrc)
+ psrc_view = TRUE;
+ else
+ HTOutputFormat = WWW_SOURCE;
+#endif
}
+
HEAD_request = HTLoadedDocumentIsHEAD();
HTuncache_current_document();
#ifdef NO_ASSUME_SAME_DOC
@@ -2125,11 +2198,13 @@ new_cmd: /*
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,6 +2217,17 @@ new_cmd: /*
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,11 +2243,13 @@ new_cmd: /*
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,6 +2263,17 @@ new_cmd: /*
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,11 +2288,13 @@ new_cmd: /*
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,6 +2302,17 @@ new_cmd: /*
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:
@@ -2220,12 +2332,25 @@ new_cmd: /*
* to the other DTD parsing may show source differences,
* so stay in source view - kw
*/
+
+ /* NOTE: this conditional can be considered incorrect -
+ current behaviour - when viewing source and
+ LYPreparsedSource==TRUE, pressing ^V will toggle parser mode
+ AND switch back from the source view to presentation view.-HV
+ */
if (HTisDocumentSource() && LYPreparsedSource) {
- HTOutputFormat = WWW_SOURCE;
+#ifdef USE_PSRC
+ if (LYpsrc)
+ psrc_view = TRUE;
+ else
+#endif
+ 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,6 +2362,15 @@ new_cmd: /*
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
@@ -3333,6 +3467,10 @@ new_cmd: /*
}
newdoc.link = 0;
force_load = TRUE; /* force MainLoop to reload */
+#ifdef USE_PSRC
+ psrc_view = FALSE; /* we get here if link is not internal */
+#endif
+
#ifdef DIRED_SUPPORT
if (lynx_edit_mode) {
HTuncache_current_document();
@@ -3946,7 +4084,14 @@ if (!LYUseFormsOptions) {
HTAlert(RELOADING_FORM);
}
if (HTisDocumentSource()) {
+#ifndef PSRC_VIEW
HTOutputFormat = WWW_SOURCE;
+#else
+ if (LYpsrc)
+ psrc_view = TRUE;
+ else
+ HTOutputFormat = WWW_SOURCE;
+#endif
}
HEAD_request = HTLoadedDocumentIsHEAD();
HTuncache_current_document();
@@ -5447,6 +5592,12 @@ check_add_bookmark_to_self:
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,6 +5609,12 @@ check_add_bookmark_to_self:
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,6 +5627,12 @@ check_add_bookmark_to_self:
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;
}
@@ -6002,7 +6165,9 @@ PUBLIC void HTAddGotoURL ARGS1(
if (!Goto_URLs) {
Goto_URLs = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(HTGotoURLs_free);
+#endif
HTList_addObject(Goto_URLs, new);
return;
}
diff --git a/src/LYMap.c b/src/LYMap.c
index 56d3f51d..27033d1c 100644
--- a/src/LYMap.c
+++ b/src/LYMap.c
@@ -163,7 +163,9 @@ PUBLIC BOOL LYAddImageMap ARGS3(
{
if (!LynxMaps) {
LynxMaps = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(LYLynxMaps_free);
+#endif
}
theList = LynxMaps;
}
diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c
new file mode 100644
index 00000000..e9c4b76e
--- /dev/null
+++ b/src/LYPrettySrc.c
@@ -0,0 +1,301 @@
+/* HTML source syntax highlighting
+ by Vlad Harchev <hvv@hippo.ru>
+ March 1999
+*/
+#include <HTUtils.h>
+#include <LYHash.h>
+#include <LYPrettySrc.h>
+
+#ifdef USE_PSRC
+
+PUBLIC BOOL psrc_view = FALSE;/* this is read by SGML_put_character - TRUE
+ when viewing pretty source */
+PUBLIC BOOL LYpsrc = FALSE; /* this tells what will be shown on '\':
+ if TRUE, then pretty source, normal source view otherwise. Toggled by
+ -pretty_source commandline option. */
+PUBLIC BOOL sgml_in_psrc_was_initialized;
+PUBLIC BOOL psrc_nested_call;
+PUBLIC BOOL psrc_first_tag;
+
+ /* tagspecs from lynx.cfg are read here. After .lss file is read (is with lss
+ support), the style cache and markup are created before entering the
+ mainloop. */
+PUBLIC char* HTL_tagspecs[HTL_num_lexems] = {
+ /* these values are defaults. They are also listed in comments of distibution's
+ lynx.cfg.*/
+#ifdef USE_COLOR_STYLE
+ "span.htmlsrc_comment:!span",
+ "span.htmlsrc_tag:!span",
+ "span.htmlsrc_attrib:!span",
+ "span.htmlsrc_attrval:!span",
+ "span.htmlsrc_abracket:!span",
+ "span.htmlsrc_entity:!span",
+ "span.htmlsrc_href:!span",
+ "span.htmlsrc_entire:!span",
+ "span.htmlsrc_badseq:!span",
+ "span.htmlsrc_badtag:!span",
+ "span.htmlsrc_badattr:!span",
+ "span.htmlsrc_sgmlspecial:!span"
+#else
+ "b:!b",
+ "b:!b",
+ ":",
+ "!b:b",
+ "b:!b",
+ "b:!b",
+ ":",
+ ":",
+ "b:!b",
+ ":",
+ "!b:b",
+ "b:!b"
+#endif
+};
+
+
+ /* these are pointers since tagspec can be empty (the pointer will be NULL
+ in that case) */
+PUBLIC HT_tagspec* lexem_start[HTL_num_lexems];
+PUBLIC HT_tagspec* lexem_end[HTL_num_lexems];
+
+PUBLIC int tagname_transform = 2;
+PUBLIC int attrname_transform = 2;
+
+
+PRIVATE int html_src_tag_index ARGS1(
+ char*, tagname)
+{
+ HTTag* tag = SGMLFindTag(&HTML_dtd, tagname);
+ return (tag && tag != &HTTag_unrecognized ) ? tag - HTML_dtd.tags : -1;
+}
+
+typedef enum _html_src_check_state
+{
+ HTSRC_CK_normal,
+ HTSRC_CK_seen_excl,
+ HTSRC_CK_after_tagname,
+ HTSRC_CK_seen_dot
+} html_src_check_state;
+
+PRIVATE void append_close_tag ARGS3(
+ char*, tagname,
+ HT_tagspec**, head,
+ HT_tagspec**, tail)
+{
+ int idx, nattr;
+ HTTag* tag;
+ HT_tagspec* subj;
+
+ idx = html_src_tag_index(tagname);
+ tag = HTML_dtd.tags+idx;
+ nattr = tag->number_of_attributes;
+
+ if (idx == -1) {
+ fprintf(stderr,
+ "internal error: previous check didn't find bad HTML tag %s", tagname);
+ exit_immediately(-1);
+ }
+
+ subj = (HT_tagspec*) calloc( sizeof(*subj), 1);
+ subj->element = idx;
+ subj->present = (BOOL*)calloc( nattr*sizeof (BOOL), 1);
+ subj->value = (char**)calloc( nattr*sizeof (char*), 1);
+ subj->start = FALSE;
+
+ if (!*head) {
+ *head = subj; *tail = subj;
+ } else {
+ (*tail)->next = subj; *tail = subj;
+ }
+}
+
+/* this will allocate node, initialize all members, and node
+ append to the list, possibly modifying head and modifying tail */
+PRIVATE void append_open_tag ARGS4(
+ char*, tagname,
+ char*, classname GCC_UNUSED,
+ HT_tagspec**, head,
+ HT_tagspec**, tail)
+{
+ HT_tagspec* subj;
+ HTTag* tag;
+#ifdef USE_COLOR_STYLE
+ int hcode;
+#endif
+
+ append_close_tag(tagname, head, tail); /* initialize common members*/
+ subj = *tail;
+ subj->start = TRUE;
+
+ tag = HTML_dtd.tags+subj->element;
+
+#ifdef USE_COLOR_STYLE
+ hcode = hash_code_lowercase_on_fly(tagname);
+ if (classname && *classname) {
+
+# if 0
+ /*
+ * we don't provide a classname as attribute of that tag, since for plain
+ * formatting tags they are not used directly for anything except style -
+ * and we provide style value directly.
+ */
+ int class_attr_idx = 0;
+ int n = tag->number_of_attributes;
+ attr* attrs = tag->attributes;
+ /*.... */ /* this is not implemented though it's easy */
+# endif
+
+ hcode = hash_code_aggregate_char('.', hcode);
+ hcode = hash_code_aggregate_lower_on_fly(classname, hcode);
+ StrAllocCopy(subj->class_name, classname);
+ } else {
+ subj->class_name = "";
+ }
+ subj->style = hcode;
+#endif
+}
+
+
+/* returns 1 if incorrect */
+PUBLIC int html_src_parse_tagspec ARGS4(
+ char*, ts,
+ HTlexem, lexem,
+ BOOL, checkonly,
+ BOOL, isstart)
+{
+ char *p = ts;
+ char *tagstart = 0;
+ char *tagend = 0;
+ char *classstart;
+ char *classend;
+ char stop = FALSE, after_excl = FALSE;
+ html_src_check_state state = HTSRC_CK_normal;
+ HT_tagspec* head = NULL, *tail = NULL;
+ HT_tagspec** slot = ( isstart ? lexem_start : lexem_end ) +lexem;
+
+ while (!stop) {
+ switch (state) {
+ case HTSRC_CK_normal:
+ case HTSRC_CK_seen_excl:
+ switch (*p) {
+ case '\0': stop = TRUE; break;
+ case ' ': case '\t': break;
+ case '!':
+ if (state == HTSRC_CK_seen_excl)
+ return 1; /*second '!'*/
+ state = HTSRC_CK_seen_excl;
+ after_excl = TRUE;
+ break;
+ default:
+ if (isalpha(*p) || *p == '_') {
+ tagstart = p;
+ while (*p && ( isalpha(*p) || *p == '_') )
+ ++p;
+ tagend = p;
+ state = HTSRC_CK_after_tagname;
+ } else
+ return 1;
+ continue;
+ }
+ break;
+ case HTSRC_CK_after_tagname:
+ switch (*p) {
+ case '\0': stop = TRUE;
+ case ' ':
+ case '\t':
+ {
+ char save = *tagend;
+ *tagend = '\0';
+ classstart = 0;
+ if (checkonly) {
+ int idx = html_src_tag_index(tagstart);
+ *tagend = save;
+ if (idx == -1)
+ return 1;
+ } else {
+ if (after_excl)
+ append_close_tag(tagstart, &head, &tail);
+ else
+ append_open_tag(tagstart, NULL, &head, &tail);
+ }
+ state = HTSRC_CK_normal;
+ after_excl = FALSE;
+ }
+ break;
+ case '.':
+ if (after_excl)
+ return 1;
+ state = HTSRC_CK_seen_dot;
+ break;
+ default:
+ return 1;
+ }
+ break;
+ case HTSRC_CK_seen_dot: {
+ switch (*p) {
+ case ' ':
+ case '\t':
+ break;
+ case '\0':
+ return 1;
+ default: {
+ char save, save1;
+ if ( isalpha(*p) || *p == '_' ) {
+ classstart = p;
+ while (*p && ( isalpha(*p) || *p == '_') ) ++p;
+ classend = p;
+ save = *classend;
+ *classend = '\0';
+ save1 = *tagend;
+ *tagend = '\0';
+ if (checkonly) {
+ int idx = html_src_tag_index(tagstart);
+ *tagend = save1; *classend = save;
+ if (idx == -1)
+ return 1;
+ } else {
+ append_open_tag(tagstart, classstart, &head, &tail);
+ }
+ state = HTSRC_CK_normal;after_excl = FALSE;
+ continue;
+ } else
+ return 1;
+ }
+ }/*of switch(*p)*/
+ break;
+ } /* of case HTSRC_CK_seen_dot: */
+ }/* of switch */
+ ++p;
+ }
+
+ if (!checkonly)
+ *slot = head;
+ return 0;
+}
+
+/*it shouldn't fail anyway - since everything is checked before it's called. */
+PUBLIC void HTMLSRC_init_caches NOARGS
+{
+ int i;
+ char* p;
+ char buf[1000];
+
+ for (i = 0; i < HTL_num_lexems; ++i) {
+ if (HTL_tagspecs[i])
+ strcpy(buf, HTL_tagspecs[i]);
+ else
+ buf[0] = '\0';
+ if ((p = strchr(buf, ':')) != 0)
+ *p = '\0';
+ if (html_src_parse_tagspec(buf, i, FALSE, TRUE) ) {
+ fprintf(stderr, "internal error while caching 1st tagspec of %d lexem", i);
+ exit_immediately(-1);
+ }
+ if (html_src_parse_tagspec( p ? p+1 : NULL , i, FALSE, FALSE) ) {
+ fprintf(stderr, "internal error while caching 2nd tagspec of %d lexem", i);
+ exit_immediately(-1);
+ }
+ }
+}
+
+#endif /* ifdef USE_PSRC */
diff --git a/src/LYPrettySrc.h b/src/LYPrettySrc.h
new file mode 100644
index 00000000..88780bd6
--- /dev/null
+++ b/src/LYPrettySrc.h
@@ -0,0 +1,70 @@
+#ifndef LYPrettySrc_H
+#define LYPrettySrc_H
+
+#ifdef USE_PSRC
+
+#include <HTMLDTD.h>
+
+extern BOOL psrc_view;
+extern BOOL LYpsrc;
+extern BOOL sgml_in_psrc_was_initialized;
+ /*this is used for tracking down whether the SGML engine was initialized
+ ==TRUE if yes. It's value is meaningful if psrc_view = TRUE */
+
+extern BOOL psrc_nested_call;/* this is used when distinguishing whether
+ the current call is nested or not in HTML.c HTML_{start,end}_element.
+ It ==FALSE if psrc_view==FALSE || sgml_in_psrc_was_initialized==TRUE */
+
+extern BOOL psrc_first_tag; /* this is also used in HTML.c to trigger the
+ 1st tag to preform special. */
+
+/* here is a list of lexem codes. */
+typedef enum _HTlexem {
+ HTL_comm=0,
+ HTL_tag,
+ HTL_attrib,
+ HTL_attrval,
+ HTL_abracket,
+ HTL_entity,
+ HTL_href,
+ HTL_entire,
+ HTL_badseq,
+ HTL_badtag,
+ HTL_badattr,
+ HTL_sgmlspecial,
+ HTL_num_lexems
+} HTlexem;
+
+typedef struct _HT_tagspec
+{
+ struct _HT_tagspec* next;/* 0 at the last */
+#ifdef USE_COLOR_STYLE
+ int style;/* precalculated value of the style */
+ char* class_name;
+#endif
+ /* these will be passed to HTML_start_element*/
+ HTMLElement element;
+ BOOL* present;
+ char** value;
+
+ BOOL start; /* if true, then this starts element, otherwise - ends */
+} HT_tagspec;
+
+extern char* HTL_tagspecs[HTL_num_lexems];
+extern HT_tagspec* lexem_start[HTL_num_lexems];
+extern HT_tagspec* lexem_end[HTL_num_lexems];
+
+extern int html_src_parse_tagspec PARAMS((char* ts, HTlexem lexem,
+ BOOL checkonly,BOOL isstart));
+extern void HTMLSRC_init_caches NOPARAMS;
+
+/* these 2 vars tell what kind of transform should be appiled to tag names
+ and attribute names. 0 - lowercase, 1 - as is, 2 uppercase. */
+extern int tagname_transform;
+extern int attrname_transform;
+
+
+#endif /* ifdef USE_PSRC */
+
+
+#endif /* LYPrettySrc_H */
diff --git a/src/LYPrint.c b/src/LYPrint.c
index 5c73a70f..4e4ef9ae 100644
--- a/src/LYPrint.c
+++ b/src/LYPrint.c
@@ -84,10 +84,11 @@ PRIVATE void set_environ ARGS3(
char *envbuffer = 0;
#ifdef VMS
#define SET_ENVIRON(name, value, no_value) set_environ(name, value, no_value)
+ char temp[80];
StrAllocCopy(envbuffer, value);
if (!(envbuffer && *envbuffer))
StrAllocCopy(envbuffer, no_value);
- Define_VMSLogical(names[name], envbuffer);
+ Define_VMSLogical(strcpy(temp, names[name]), envbuffer);
FREE(envbuffer);
#else
#define SET_ENVIRON(name, value, no_value) set_environ(name, value, "")
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 6e6960e1..8a18fb1d 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -22,6 +22,8 @@
#include <LYCookie.h>
#include <LYReadCFG.h>
#include <HTAlert.h>
+#include <LYHistory.h>
+#include <LYPrettySrc.h>
#ifdef DIRED_SUPPORT
#include <LYLocal.h>
@@ -142,7 +144,9 @@ PRIVATE void add_item_to_list ARGS2(
if (cur_item == NULL)
outofmem(__FILE__, "read_cfg");
*list_ptr = cur_item;
+#ifdef LY_FIND_LEAKS
atexit(free_item_list);
+#endif
} else {
/*
* Find the last item.
@@ -240,7 +244,9 @@ PRIVATE void add_printer_to_list ARGS2(
if (cur_item == NULL)
outofmem(__FILE__, "read_cfg");
*list_ptr = cur_item;
+#ifdef LY_FIND_LEAKS
atexit(free_printer_item_list);
+#endif
} else {
/*
* Find the last item.
@@ -450,7 +456,6 @@ typedef union {
long def_value;
} ConfigUnion;
-#undef PARSE_DEBUG
#ifdef PARSE_DEBUG
#define ParseData \
lynx_html_item_type** add_value; \
@@ -460,18 +465,18 @@ typedef union {
ParseFunc fun_value; \
long def_value
#define PARSE_ADD(n,t,v) {n,t, &v, 0, 0, 0, 0, 0}
-#define PARSE_SET(n,t,v) {n,t, 0, &v, 0, 0, 0, 0}
-#define PARSE_INT(n,t,v) {n,t, 0, 0, &v, 0, 0, 0}
-#define PARSE_STR(n,t,v) {n,t, 0, 0, 0, &v, 0, 0}
+#define PARSE_SET(n,t,v) {n,t, 0, v, 0, 0, 0, 0}
+#define PARSE_INT(n,t,v) {n,t, 0, 0, v, 0, 0, 0}
+#define PARSE_STR(n,t,v) {n,t, 0, 0, 0, v, 0, 0}
#define PARSE_ENV(n,t,v) {n,t, 0, 0, 0, v, 0, 0}
#define PARSE_FUN(n,t,v) {n,t, 0, 0, 0, 0, v, 0}
#define PARSE_DEF(n,t,v) {n,t, 0, 0, 0, 0, 0, v}
#else
#define ParseData long value
#define PARSE_ADD(n,t,v) {n,t, (long)&(v)}
-#define PARSE_SET(n,t,v) {n,t, (long)&(v)}
-#define PARSE_INT(n,t,v) {n,t, (long)&(v)}
-#define PARSE_STR(n,t,v) {n,t, (long)&(v)}
+#define PARSE_SET(n,t,v) {n,t, (long) (v)}
+#define PARSE_INT(n,t,v) {n,t, (long) (v)}
+#define PARSE_STR(n,t,v) {n,t, (long) (v)}
#define PARSE_ENV(n,t,v) {n,t, (long) (v)}
#define PARSE_FUN(n,t,v) {n,t, (long) (v)}
#define PARSE_DEF(n,t,v) {n,t, (long) (v)}
@@ -763,6 +768,21 @@ static int printer_fun ARGS1(
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)
{
@@ -841,114 +861,245 @@ static int viewer_fun ARGS1(
return 0;
}
+
+#ifdef USE_PSRC
+
+static void html_src_bad_syntax ARGS2(
+ char*, value,
+ char*, option_name)
+{
+ char buf[100];
+
+ strcpy(buf,"HTMLSRC_");
+ strcat(buf,option_name);
+ LYUpperCase(buf);
+ fprintf(stderr,"Bad syntax in TAGSPEC %s:%s\n",buf,value);
+ exit_immediately(-1);
+}
+
+
+static int parse_html_src_spec ARGS3(
+ HTlexem, lexem_code,
+ char*, value,
+ char*, option_name)
+{
+ /* Now checking the value for being correct. Since HTML_dtd is not
+ * initialized completely (member tags points to non-initiailized data), we
+ * use tags_old. If the syntax is incorrect, then lynx will exit with error
+ * message.
+ */
+ char* ts2;
+ if ( !value || !*value) return 0; /* silently ignoring*/
+
+#define BS() html_src_bad_syntax(value,option_name)
+
+ ts2 = strchr(value,':');
+ if (!ts2)
+ BS();
+ *ts2 = '\0';
+
+ if ( html_src_parse_tagspec(value, lexem_code, TRUE, TRUE)
+ || html_src_parse_tagspec(ts2, lexem_code, TRUE, TRUE) )
+ {
+ *ts2 = ':';
+ BS();
+ }
+
+ *ts2 = ':';
+ HTL_tagspecs[lexem_code] = NULL;
+ StrAllocCopy(HTL_tagspecs[lexem_code],value);
+#undef BS
+ return 0;
+}
+
+#define defHTSRC_parse_fun(x) static int html_src_set_##x ARGS1( char*,str) \
+ { parse_html_src_spec(HTL_##x,str,#x); return 0; }
+
+defHTSRC_parse_fun(comm)
+defHTSRC_parse_fun(tag)
+defHTSRC_parse_fun(attrib)
+defHTSRC_parse_fun(attrval)
+defHTSRC_parse_fun(abracket)
+defHTSRC_parse_fun(entity)
+defHTSRC_parse_fun(href)
+defHTSRC_parse_fun(entire)
+defHTSRC_parse_fun(badseq)
+defHTSRC_parse_fun(badtag)
+defHTSRC_parse_fun(badattr)
+defHTSRC_parse_fun(sgmlspecial)
+
+#undef defHTSRC_parse_fun
+
+static int read_htmlsrc_attrname_xform ARGS1( char*,str)
+{
+ int val;
+ if ( 1 == sscanf(str, "%d", &val) ) {
+ if (val<0 || val >2) {
+ CTRACE(tfp,"bad value for htmlsrc_attrname_xform (ignored - must be one of 0,1,2): %d\n", val);
+ } else
+ attrname_transform = val;
+ } else {
+ CTRACE(tfp,"bad value for htmlsrc_attrname_xform (ignored): %s\n",
+ str);
+ }
+ return 0;
+}
+
+static int read_htmlsrc_tagname_xform ARGS1( char*,str)
+{
+ int val;
+ if ( 1 == sscanf(str,"%d",&val) ) {
+ if (val<0 || val >2) {
+ CTRACE(tfp,"bad value for htmlsrc_tagname_xform (ignored - must be one of 0,1,2): %d\n", val);
+ } else
+ tagname_transform = val;
+ } else {
+ CTRACE(tfp,"bad value for htmlsrc_tagname_xform (ignored): %s\n",
+ str);
+ }
+ return 0;
+}
+
+
+#define defHTSRC_option(x) \
+ PARSE_FUN( "htmlsrc_" #x ,CONF_FUN, html_src_set_##x),
+
+#endif
+
+
/* This table should be sorted alphabetically */
static Config_Type Config_Table [] =
{
- PARSE_SET("accept_all_cookies", CONF_BOOL, LYAcceptAllCookies),
- PARSE_INT("alertsecs", CONF_INT, AlertSecs),
- PARSE_SET("always_resubmit_posts", CONF_BOOL, LYresubmit_posts),
+ PARSE_SET("accept_all_cookies", CONF_BOOL, &LYAcceptAllCookies),
+ PARSE_INT("alertsecs", CONF_INT, &AlertSecs),
+ PARSE_SET("always_resubmit_posts", CONF_BOOL, &LYresubmit_posts),
#ifdef EXEC_LINKS
PARSE_DEF("always_trusted_exec", CONF_ADD_TRUSTED, ALWAYS_EXEC_PATH),
#endif
PARSE_FUN("assume_charset", CONF_FUN, assume_charset_fun),
PARSE_FUN("assume_local_charset", CONF_FUN, assume_local_charset_fun),
PARSE_FUN("assume_unrec_charset", CONF_FUN, assume_unrec_charset_fun),
- PARSE_SET("block_multi_bookmarks", CONF_BOOL, LYMBMBlocked),
- PARSE_SET("bold_h1", CONF_BOOL, bold_H1),
- PARSE_SET("bold_headers", CONF_BOOL, bold_headers),
- PARSE_SET("bold_name_anchors", CONF_BOOL, bold_name_anchors),
- PARSE_SET("case_sensitive_always_on", CONF_BOOL, case_sensitive),
+ PARSE_SET("block_multi_bookmarks", CONF_BOOL, &LYMBMBlocked),
+ PARSE_SET("bold_h1", CONF_BOOL, &bold_H1),
+ PARSE_SET("bold_headers", CONF_BOOL, &bold_headers),
+ PARSE_SET("bold_name_anchors", CONF_BOOL, &bold_name_anchors),
+ PARSE_SET("case_sensitive_always_on", CONF_BOOL, &case_sensitive),
PARSE_FUN("character_set", CONF_FUN, character_set_fun),
- PARSE_SET("checkmail", CONF_BOOL, check_mail),
- PARSE_SET("collapse_br_tags", CONF_BOOL, LYCollapseBRs),
+ PARSE_SET("checkmail", CONF_BOOL, &check_mail),
+ PARSE_SET("collapse_br_tags", CONF_BOOL, &LYCollapseBRs),
#ifdef USE_COLOR_TABLE
PARSE_FUN("color", CONF_FUN, color_fun),
#endif
- PARSE_STR("cookie_accept_domains", CONF_STR, LYCookieSAcceptDomains),
+ PARSE_STR("cookie_accept_domains", CONF_STR, &LYCookieSAcceptDomains),
#ifdef EXP_PERSISTENT_COOKIES
- PARSE_STR("cookie_file", CONF_STR, LYCookieFile),
+ PARSE_STR("cookie_file", CONF_STR, &LYCookieFile),
#endif /* EXP_PERSISTENT_COOKIES */
- PARSE_STR("cookie_loose_invalid_domains", CONF_STR, LYCookieSLooseCheckDomains),
- PARSE_STR("cookie_query_invalid_domains", CONF_STR, LYCookieSQueryCheckDomains),
- PARSE_STR("cookie_reject_domains", CONF_STR, LYCookieSRejectDomains),
- PARSE_STR("cookie_strict_invalid_domains", CONF_STR, LYCookieSStrictCheckDomains),
+ PARSE_STR("cookie_loose_invalid_domains", CONF_STR, &LYCookieSLooseCheckDomains),
+ PARSE_STR("cookie_query_invalid_domains", CONF_STR, &LYCookieSQueryCheckDomains),
+ PARSE_STR("cookie_reject_domains", CONF_STR, &LYCookieSRejectDomains),
+ PARSE_STR("cookie_strict_invalid_domains", CONF_STR, &LYCookieSStrictCheckDomains),
PARSE_ENV("cso_proxy", CONF_ENV, 0 ),
#ifdef VMS
- PARSE_STR("CSWING_PATH", CONF_STR, LYCSwingPath),
+ PARSE_STR("CSWING_PATH", CONF_STR, &LYCSwingPath),
#endif
PARSE_FUN("default_bookmark_file", CONF_FUN, default_bookmark_file_fun),
PARSE_FUN("default_cache_size", CONF_FUN, default_cache_size_fun),
PARSE_FUN("default_editor", CONF_FUN, default_editor_fun),
- PARSE_STR("default_index_file", CONF_STR, indexfile),
+ PARSE_STR("default_index_file", CONF_STR, &indexfile),
PARSE_FUN("default_keypad_mode_is_numbers_as_arrows", CONF_FUN, numbers_as_arrows_fun),
PARSE_FUN("default_user_mode", CONF_FUN, default_user_mode_fun),
#if defined(VMS) && defined(VAXC) && !defined(__DECC)
- PARSE_INT("default_virtual_memory_size", CONF_INT, HTVirtualMemorySize),
+ PARSE_INT("default_virtual_memory_size", CONF_INT, &HTVirtualMemorySize),
#endif
#ifdef DIRED_SUPPORT
PARSE_FUN("dired_menu", CONF_FUN, dired_menu_fun),
#endif
PARSE_ADD("downloader", CONF_ADD_ITEM, downloaders),
- PARSE_SET("emacs_keys_always_on", CONF_BOOL, emacs_keys),
- PARSE_SET("enable_scrollback", CONF_BOOL, enable_scrollback),
+ PARSE_SET("emacs_keys_always_on", CONF_BOOL, &emacs_keys),
+ PARSE_SET("enable_scrollback", CONF_BOOL, &enable_scrollback),
#ifdef USE_EXTERNALS
PARSE_ADD("external", CONF_ADD_ITEM, externals),
#endif
PARSE_ENV("finger_proxy", CONF_ENV, 0 ),
- PARSE_SET("force_8bit_toupper", CONF_BOOL, UCForce8bitTOUPPER),
- PARSE_SET("force_ssl_cookies_secure", CONF_BOOL, LYForceSSLCookiesSecure),
+ PARSE_SET("force_8bit_toupper", CONF_BOOL, &UCForce8bitTOUPPER),
+ PARSE_SET("force_ssl_cookies_secure", CONF_BOOL, &LYForceSSLCookiesSecure),
#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU)
- PARSE_SET("forms_options", CONF_BOOL, LYUseFormsOptions),
+ PARSE_SET("forms_options", CONF_BOOL, &LYUseFormsOptions),
#endif
PARSE_ENV("ftp_proxy", CONF_ENV, 0 ),
- PARSE_STR("global_extension_map", CONF_STR, global_extension_map),
- PARSE_STR("global_mailcap", CONF_STR, global_type_map),
+ PARSE_STR("global_extension_map", CONF_STR, &global_extension_map),
+ PARSE_STR("global_mailcap", CONF_STR, &global_type_map),
PARSE_ENV("gopher_proxy", CONF_ENV, 0 ),
- PARSE_SET("gotobuffer", CONF_BOOL, goto_buffer),
- PARSE_STR("helpfile", CONF_STR, helpfile),
- PARSE_SET("historical_comments", CONF_BOOL, historical_comments),
+ PARSE_SET("gotobuffer", CONF_BOOL, &goto_buffer),
+ PARSE_STR("helpfile", CONF_STR, &helpfile),
+ PARSE_SET("historical_comments", CONF_BOOL, &historical_comments),
+
+#ifdef USE_PSRC
+
+ defHTSRC_option(abracket)
+ defHTSRC_option(attrib)
+
+ PARSE_FUN("htmlsrc_attrname_xform", CONF_FUN, read_htmlsrc_attrname_xform),
+
+ defHTSRC_option(attrval)
+ defHTSRC_option(badattr)
+ defHTSRC_option(badseq)
+ defHTSRC_option(badtag)
+ defHTSRC_option(comm)
+ defHTSRC_option(entire)
+ defHTSRC_option(entity)
+ defHTSRC_option(href)
+ defHTSRC_option(sgmlspecial)
+ defHTSRC_option(tag)
+
+ PARSE_FUN("htmlsrc_tagname_xform", CONF_FUN, read_htmlsrc_tagname_xform),
+
+
+# undef defHTSRC_option
+#endif
+
PARSE_ENV("http_proxy", CONF_ENV, 0 ),
PARSE_ENV("https_proxy", CONF_ENV, 0 ),
PARSE_FUN("include", CONF_INCLUDE, 0),
- PARSE_INT("infosecs", CONF_INT, InfoSecs),
- PARSE_STR("jump_prompt", CONF_STR, jumpprompt),
- PARSE_SET("jumpbuffer", CONF_BOOL, jump_buffer),
+ PARSE_INT("infosecs", CONF_INT, &InfoSecs),
+ PARSE_STR("jump_prompt", CONF_STR, &jumpprompt),
+ PARSE_SET("jumpbuffer", CONF_BOOL, &jump_buffer),
PARSE_FUN("jumpfile", CONF_FUN, jumpfile_fun),
#ifdef EXP_KEYBOARD_LAYOUT
PARSE_FUN("keyboard_layout", CONF_FUN, keyboard_layout_fun),
#endif
PARSE_FUN("keymap", CONF_FUN, keymap_fun),
#ifndef DISABLE_NEWS
- PARSE_SET("list_news_numbers", CONF_BOOL, LYListNewsNumbers),
- PARSE_SET("list_news_dates", CONF_BOOL, LYListNewsDates),
+ PARSE_SET("list_news_numbers", CONF_BOOL, &LYListNewsNumbers),
+ PARSE_SET("list_news_dates", CONF_BOOL, &LYListNewsDates),
#endif
#ifndef VMS
- PARSE_STR("list_format", CONF_STR, list_format),
+ PARSE_STR("list_format", CONF_STR, &list_format),
#endif
PARSE_FUN("localhost_alias", CONF_FUN, localhost_alias_fun),
- PARSE_STR("local_domain", CONF_STR, LYLocalDomain),
+ PARSE_STR("local_domain", CONF_STR, &LYLocalDomain),
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
- PARSE_SET("local_execution_links_always_on", CONF_BOOL, local_exec),
- PARSE_SET("local_execution_links_on_but_not_remote", CONF_BOOL, local_exec_on_local_files),
+ PARSE_SET("local_execution_links_always_on", CONF_BOOL, &local_exec),
+ PARSE_SET("local_execution_links_on_but_not_remote", CONF_BOOL, &local_exec_on_local_files),
#endif
#ifdef LYNXCGI_LINKS
PARSE_FUN("lynxcgi_environment", CONF_FUN, lynxcgi_environment_fun),
#ifndef VMS
- PARSE_STR("lynxcgi_document_root", CONF_STR, LYCgiDocumentRoot),
+ PARSE_STR("lynxcgi_document_root", CONF_STR, &LYCgiDocumentRoot),
#endif
#endif
- PARSE_STR("lynx_host_name", CONF_STR, LYHostName),
+ PARSE_STR("lynx_host_name", CONF_STR, &LYHostName),
PARSE_FUN("lynx_sig_file", CONF_FUN, lynx_sig_file_fun),
- PARSE_SET("mail_system_error_logging", CONF_BOOL, error_logging),
+ PARSE_SET("mail_system_error_logging", CONF_BOOL, &error_logging),
#ifdef VMS
- PARSE_STR("mail_adrs", CONF_STR, mail_adrs),
+ PARSE_STR("mail_adrs", CONF_STR, &mail_adrs),
#endif
- PARSE_SET("make_links_for_all_images", CONF_BOOL, clickable_images),
- PARSE_SET("make_pseudo_alts_for_inlines", CONF_BOOL, pseudo_inline_alts),
- PARSE_INT("messagesecs", CONF_INT, MessageSecs),
- PARSE_SET("minimal_comments", CONF_BOOL, minimal_comments),
- PARSE_INT("multi_bookmark_support", CONF_BOOL, LYMultiBookmarks),
- PARSE_SET("ncr_in_bookmarks", CONF_BOOL, UCSaveBookmarksInUnicode),
+ PARSE_SET("make_links_for_all_images", CONF_BOOL, &clickable_images),
+ PARSE_SET("make_pseudo_alts_for_inlines", CONF_BOOL, &pseudo_inline_alts),
+ PARSE_INT("messagesecs", CONF_INT, &MessageSecs),
+ PARSE_SET("minimal_comments", CONF_BOOL, &minimal_comments),
+ PARSE_SET("multi_bookmark_support", CONF_BOOL, &LYMultiBookmarks),
+ PARSE_SET("ncr_in_bookmarks", CONF_BOOL, &UCSaveBookmarksInUnicode),
#ifndef DISABLE_NEWS
PARSE_FUN("news_chunk_size", CONF_FUN, news_chunk_size_fun),
PARSE_FUN("news_max_chunk", CONF_FUN, news_max_chunk_fun),
@@ -959,83 +1110,84 @@ static Config_Type Config_Table [] =
PARSE_ENV("nntp_proxy", CONF_ENV, 0),
PARSE_ENV("nntpserver", CONF_ENV2, 0), /* actually NNTPSERVER */
#endif
- PARSE_SET("no_dot_files", CONF_BOOL, no_dotfiles),
- PARSE_SET("no_file_referer", CONF_BOOL, no_filereferer),
+ PARSE_SET("no_dot_files", CONF_BOOL, &no_dotfiles),
+ PARSE_SET("no_file_referer", CONF_BOOL, &no_filereferer),
#ifndef VMS
- PARSE_SET("no_forced_core_dump", CONF_BOOL, LYNoCore),
+ PARSE_SET("no_forced_core_dump", CONF_BOOL, &LYNoCore),
#endif
- PARSE_SET("no_from_header", CONF_BOOL, LYNoFromHeader),
- PARSE_SET("no_ismap_if_usemap", CONF_BOOL, LYNoISMAPifUSEMAP),
+ PARSE_SET("no_from_header", CONF_BOOL, &LYNoFromHeader),
+ PARSE_SET("no_ismap_if_usemap", CONF_BOOL, &LYNoISMAPifUSEMAP),
PARSE_ENV("no_proxy", CONF_ENV, 0 ),
- PARSE_SET("no_referer_header", CONF_BOOL, LYNoRefererHeader),
+ PARSE_SET("no_referer_header", CONF_BOOL, &LYNoRefererHeader),
PARSE_FUN("outgoing_mail_charset", CONF_FUN, outgoing_mail_charset_fun),
#ifdef DISP_PARTIAL
- PARSE_SET("partial", CONF_BOOL, display_partial),
- PARSE_INT("partial_thres", CONF_INT, partial_threshold),
+ PARSE_SET("partial", CONF_BOOL, &display_partial),
+ PARSE_INT("partial_thres", CONF_INT, &partial_threshold),
#endif
#ifdef EXP_PERSISTENT_COOKIES
- PARSE_SET("persistent_cookies", CONF_BOOL, persistent_cookies),
+ PARSE_SET("persistent_cookies", CONF_BOOL, &persistent_cookies),
#endif /* EXP_PERSISTENT_COOKIES */
- PARSE_STR("personal_mailcap", CONF_STR, personal_type_map),
- PARSE_STR("personal_extension_map", CONF_STR, personal_extension_map),
- PARSE_STR("preferred_charset", CONF_STR, pref_charset),
- PARSE_STR("preferred_language", CONF_STR, language),
- PARSE_SET("prepend_base_to_source", CONF_BOOL, LYPrependBaseToSource),
- PARSE_SET("prepend_charset_to_source", CONF_BOOL, LYPrependCharsetToSource),
+ PARSE_STR("personal_mailcap", CONF_STR, &personal_type_map),
+ PARSE_STR("personal_extension_map", CONF_STR, &personal_extension_map),
+ PARSE_STR("preferred_charset", CONF_STR, &pref_charset),
+ PARSE_STR("preferred_language", CONF_STR, &language),
+ PARSE_SET("prepend_base_to_source", CONF_BOOL, &LYPrependBaseToSource),
+ PARSE_SET("prepend_charset_to_source", CONF_BOOL, &LYPrependCharsetToSource),
PARSE_FUN("printer", CONF_FUN, printer_fun),
- PARSE_SET("quit_default_yes", CONF_BOOL, LYQuitDefaultYes),
+ PARSE_SET("quit_default_yes", CONF_BOOL, &LYQuitDefaultYes),
#ifndef NO_RULES
PARSE_FUN("rule", CONF_FUN, HTSetConfiguration),
PARSE_FUN("rulesfile", CONF_FUN, cern_rulesfile_fun),
#endif /* NO_RULES */
- PARSE_STR("save_space", CONF_STR, lynx_save_space),
- PARSE_SET("scan_for_buried_news_refs", CONF_BOOL, scan_for_buried_news_references),
- PARSE_SET("seek_frag_area_in_cur", CONF_BOOL, LYSeekFragAREAinCur),
- PARSE_SET("seek_frag_map_in_cur", CONF_BOOL, LYSeekFragMAPinCur),
- PARSE_SET("set_cookies", CONF_BOOL, LYSetCookies),
- PARSE_SET("show_cursor", CONF_BOOL, LYShowCursor),
- PARSE_SET("show_kb_rate", CONF_BOOL, LYshow_kb_rate),
+ PARSE_STR("save_space", CONF_STR, &lynx_save_space),
+ PARSE_SET("scan_for_buried_news_refs", CONF_BOOL, &scan_for_buried_news_references),
+ PARSE_SET("seek_frag_area_in_cur", CONF_BOOL, &LYSeekFragAREAinCur),
+ PARSE_SET("seek_frag_map_in_cur", CONF_BOOL, &LYSeekFragMAPinCur),
+ PARSE_SET("set_cookies", CONF_BOOL, &LYSetCookies),
+ PARSE_SET("show_cursor", CONF_BOOL, &LYShowCursor),
+ PARSE_SET("show_kb_rate", CONF_BOOL, &LYshow_kb_rate),
PARSE_ENV("snews_proxy", CONF_ENV, 0 ),
PARSE_ENV("snewspost_proxy", CONF_ENV, 0 ),
PARSE_ENV("snewsreply_proxy", CONF_ENV, 0 ),
- PARSE_SET("soft_dquotes", CONF_BOOL, soft_dquotes),
- PARSE_STR("startfile", CONF_STR, startfile),
- PARSE_SET("strip_dotdot_urls", CONF_BOOL, LYStripDotDotURLs),
- PARSE_SET("substitute_underscores", CONF_BOOL, use_underscore),
+ 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),
PARSE_FUN("suffix", CONF_FUN, suffix_fun),
PARSE_FUN("system_editor", CONF_FUN, system_editor_fun),
- PARSE_STR("system_mail", CONF_STR, system_mail),
- PARSE_STR("system_mail_flags", CONF_STR, system_mail_flags),
- PARSE_SET("tagsoup", CONF_BOOL, Old_DTD),
+ PARSE_STR("system_mail", CONF_STR, &system_mail),
+ PARSE_STR("system_mail_flags", CONF_STR, &system_mail_flags),
+ PARSE_SET("tagsoup", CONF_BOOL, &Old_DTD),
#ifdef EXEC_LINKS
PARSE_DEF("trusted_exec", CONF_ADD_TRUSTED, EXEC_PATH),
#endif
#ifdef LYNXCGI_LINKS
PARSE_DEF("trusted_lynxcgi", CONF_ADD_TRUSTED, CGI_PATH),
#endif
- PARSE_STR("url_domain_prefixes", CONF_STR, URLDomainPrefixes),
- PARSE_STR("url_domain_suffixes", CONF_STR, URLDomainSuffixes),
+ PARSE_STR("url_domain_prefixes", CONF_STR, &URLDomainPrefixes),
+ PARSE_STR("url_domain_suffixes", CONF_STR, &URLDomainSuffixes),
#ifdef DIRED_SUPPORT
PARSE_ADD("uploader", CONF_ADD_ITEM, uploaders),
#endif
#ifdef VMS
- PARSE_SET("use_fixed_records", CONF_BOOL, UseFixedRecords),
+ PARSE_SET("use_fixed_records", CONF_BOOL, &UseFixedRecords),
#endif
#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE)
- PARSE_SET("use_mouse", CONF_BOOL, LYUseMouse),
+ PARSE_SET("use_mouse", CONF_BOOL, &LYUseMouse),
#endif
- PARSE_SET("use_select_popups", CONF_BOOL, LYSelectPopups),
- PARSE_SET("verbose_images", CONF_BOOL, verbose_img),
- PARSE_SET("vi_keys_always_on", CONF_BOOL, vi_keys),
+ PARSE_SET("use_select_popups", CONF_BOOL, &LYSelectPopups),
+ PARSE_SET("verbose_images", CONF_BOOL, &verbose_img),
+ PARSE_SET("vi_keys_always_on", CONF_BOOL, &vi_keys),
PARSE_FUN("viewer", CONF_FUN, viewer_fun),
PARSE_ENV("wais_proxy", CONF_ENV, 0 ),
- PARSE_STR("xloadimage_command", CONF_STR, XLoadImageCommand),
+ PARSE_STR("xloadimage_command", CONF_STR, &XLoadImageCommand),
{0}
};
-PRIVATE char *local_url = NULL;
-
/*
* Free memory allocated in 'read_cfg()'
*/
@@ -1060,7 +1212,6 @@ PUBLIC void free_lynx_cfg NOARGS
break;
}
}
- FREE(local_url);
}
/*
@@ -1136,8 +1287,8 @@ PUBLIC void read_cfg ARGS4(
/* Significant lines are of the form KEYWORD:WHATEVER */
if ((value = strchr (name, ':')) == 0) {
- /* fprintf (stderr, "Bad line-- no :\n"); */
- continue;
+ /* fprintf (stderr, "Bad line-- no :\n"); */
+ continue;
}
/* skip past colon, but replace ':' with 0 to make name meaningful */
@@ -1238,19 +1389,28 @@ PUBLIC void read_cfg ARGS4(
case CONF_INCLUDE:
/* include another file */
#ifndef NO_CONFIG_INFO
- if (fp0 != 0) {
+ if (fp0 != 0 && !LYRestricted) {
char *url = 0;
+ char *cp1 = NULL;
LYLocalFileToURL(&url, value);
- fprintf(fp0, "%s:<a href=\"%s\">%s</a>\n\n", name, url, value);
- fprintf(fp0, " #&lt;begin %s&gt;\n", value);
+ StrAllocCopy(cp1, value);
+ if (strchr(value, '&') || strchr(value, '<')) {
+ LYEntify(&cp1, TRUE);
+ }
+
+ fprintf(fp0, "%s:<a href=\"%s\">%s</a>\n\n", name, url, cp1);
+ fprintf(fp0, " #&lt;begin %s&gt;\n", cp1);
+
+ read_cfg (value, cfg_filename, nesting_level + 1, fp0);
+
+ fprintf(fp0, " #&lt;end of %s&gt;\n\n", cp1);
FREE(url);
- }
-#endif
+ FREE(cp1);
+ } else
+#endif /* !NO_CONFIG_INFO */
+
read_cfg (value, cfg_filename, nesting_level + 1, fp0);
-#ifndef NO_CONFIG_INFO
- if (fp0 != 0)
- fprintf(fp0, " #&lt;end of %s&gt;\n\n", value);
-#endif
+
break;
case CONF_ADD_ITEM:
@@ -1356,18 +1516,75 @@ PUBLIC void read_cfg ARGS4(
}
/*
- * lynx.cfg infopage, returns local url.
+ * Show rendered lynx.cfg data without comments, LYNXCFG:/ internal page.
+ * Called from getfile() cyrcle:
+ * we create and load the page just in place and return to mainloop().
*/
-PUBLIC char *lynx_cfg_infopage NOARGS
+PUBLIC int lynx_cfg_infopage ARGS1(
+ document *, newdoc)
{
- char tempfile[LY_MAXPATH];
+ static char tempfile[LY_MAXPATH];
+ static char *local_url; /* static! */
+ DocAddress WWWDoc; /* need on exit */
char *temp = 0;
+ char *cp1 = NULL;
FILE *fp0;
+
+#ifndef NO_CONFIG_INFO
+ /*-------------------------------------------------
+ * kludge a link from LYNXCFG:/, the URL was:
+ * " <a href=\"LYNXCFG://reload\">RELOAD THE CHANGES</a>\n"
+ *--------------------------------------------------*/
+
+ if ((strstr(newdoc->address, "LYNXCFG://reload")) && !LYRestricted) {
+ /*
+ * Some staff to reload read_cfg(),
+ * but also load options menu items and command-line options
+ * to made things consistent. Not implemented yet. Dummy.
+ */
+ reload_read_cfg();
+
+ /*
+ * now pop-up and return to updated LYNXCFG:/ page,
+ * remind postoptions() but much simpler:
+ */
+
+ /* the page was pushed, so pop-up. */
+ LYpop(newdoc);
+ WWWDoc.address = newdoc->address;
+ WWWDoc.post_data = newdoc->post_data;
+ WWWDoc.post_content_type = newdoc->post_content_type;
+ WWWDoc.bookmark = newdoc->bookmark;
+ WWWDoc.isHEAD = newdoc->isHEAD;
+ WWWDoc.safe = newdoc->safe;
+ LYforce_no_cache = FALSE; /* ! */
+ LYoverride_no_cache = TRUE; /* ! */
+
+ /*
+ * Working out of getfile() cycle we reset *no_cache manually here so
+ * HTLoadAbsolute() will return "Document already in memory": it was
+ * forced reloading obsolete file again without this (overhead).
+ *
+ * Probably *no_cache was set in a wrong position because of
+ * the internal page...
+ */
+ if (!HTLoadAbsolute(&WWWDoc))
+ return(NOT_FOUND);
+
+
+ /* now set up the flag and fall down to create a new LYNXCFG:/ page */
+ local_url = 0; /* see below */
+ }
+#endif /* !NO_CONFIG_INFO */
+
+
if (local_url == 0) {
+
+ LYRemoveTemp(tempfile);
if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) {
HTAlert(CANNOT_OPEN_TEMP);
- return(0);
+ return(NOT_FOUND);
}
LYLocalFileToURL(&local_url, tempfile);
@@ -1376,40 +1593,54 @@ PUBLIC char *lynx_cfg_infopage NOARGS
BeginInternalPage (fp0, LYNXCFG_TITLE, NULL);
fprintf(fp0, "<pre>\n");
+
#ifndef NO_CONFIG_INFO
+ if (!LYRestricted) {
#if defined(HAVE_CONFIG_H) || defined(VMS)
- if (strcmp(lynx_cfg_file, LYNX_CFG_FILE)) {
- StrAllocCopy(temp, LYNX_CFG_FILE);
- fprintf(fp0, "<em>%s\n%s",
- gettext("This is read from your lynx.cfg file,"),
- gettext("please \"read\" distribution's"));
- fprintf(fp0, " <a href=\"%s\">lynx.cfg</a> ",
- temp);
- FREE(temp);
- fprintf(fp0, "%s</em>\n\n",
- gettext("for more comments."));
- } else
+ if (strcmp(lynx_cfg_file, LYNX_CFG_FILE)) {
+ fprintf(fp0, "<em>%s\n%s",
+ gettext("This is read from your lynx.cfg file,"),
+ gettext("please \"read\" distribution's"));
+ LYLocalFileToURL(&temp, LYNX_CFG_FILE);
+ fprintf(fp0, " <a href=\"%s\">lynx.cfg</a> ",
+ temp);
+ FREE(temp);
+ fprintf(fp0, "%s</em>\n\n",
+ gettext("for more comments."));
+ } else
#endif /* HAVE_CONFIG_H */
- {
- /* no absolute path... for lynx.cfg on DOS/Win32 */
- fprintf(fp0, "<em>%s\n%s",
- gettext("This is read from your lynx.cfg file,"),
- gettext("please \"read\" distribution's"));
- fprintf(fp0, " </em>lynx.cfg<em> ");
- fprintf(fp0, "%s</em>\n\n",
- gettext("for more comments."));
- }
+ {
+ /* no absolute path... for lynx.cfg on DOS/Win32 */
+ fprintf(fp0, "<em>%s\n%s",
+ gettext("This is read from your lynx.cfg file,"),
+ gettext("please \"read\" distribution's"));
+ fprintf(fp0, " </em>lynx.cfg<em> ");
+ fprintf(fp0, "%s</em>\n",
+ gettext("for more comments."));
+ }
- LYLocalFileToURL(&temp, lynx_cfg_file);
- fprintf(fp0, " #<em>%s <a href=\"%s\">%s</a></em>\n",
- gettext("Your primary configuration"),
- temp,
- lynx_cfg_file);
- FREE(temp);
+ /** a new experimental link ... **/
+ if (user_mode == ADVANCED_MODE)
+ fprintf(fp0, " <a href=\"LYNXCFG://reload\">%s</a>\n",
+ gettext("RELOAD THE CHANGES"));
+
+
+ LYLocalFileToURL(&temp, lynx_cfg_file);
+ StrAllocCopy(cp1, lynx_cfg_file);
+ if (strchr(lynx_cfg_file, '&') || strchr(lynx_cfg_file, '<')) {
+ LYEntify(&cp1, TRUE);
+ }
+ fprintf(fp0, "\n #<em>%s <a href=\"%s\">%s</a></em>\n",
+ gettext("Your primary configuration"),
+ temp,
+ cp1);
+ FREE(temp);
+ FREE(cp1);
+
+ } else
+#endif /* !NO_CONFIG_INFO */
-#else
fprintf(fp0, "<em>%s</em>\n\n", gettext("This is read from your lynx.cfg file:"));
-#endif /* NO_CONFIG_INFO */
/*
* Process the configuration file.
@@ -1421,5 +1652,78 @@ PUBLIC char *lynx_cfg_infopage NOARGS
LYCloseTempFP(fp0);
}
- return(local_url);
+ /* return to getfile() cyrcle */
+ StrAllocCopy(newdoc->address, local_url);
+ WWWDoc.address = newdoc->address;
+ WWWDoc.post_data = newdoc->post_data;
+ WWWDoc.post_content_type = newdoc->post_content_type;
+ WWWDoc.bookmark = newdoc->bookmark;
+ WWWDoc.isHEAD = newdoc->isHEAD;
+ WWWDoc.safe = newdoc->safe;
+
+ if (!HTLoadAbsolute(&WWWDoc))
+ return(NOT_FOUND);
+ return(NORMAL);
+}
+
+
+#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
+/*
+ * Compile-time definitions info, LYNXCOMPILEOPTS:/ internal page,
+ * from getfile() cyrcle.
+ */
+PUBLIC int lynx_compile_opts ARGS1(
+ document *, newdoc)
+{
+ char tempfile[LY_MAXPATH];
+#define PutDefs(table, N) fprintf(fp0, "%-35s %s\n", table[N].name, table[N].value)
+#include <cfg_defs.h>
+ unsigned n;
+ static char *info_url; /* static! */
+ DocAddress WWWDoc; /* need on exit */
+ FILE *fp0;
+
+ /* create the page only once - compile-time data will not change... */
+
+ if (info_url == 0) {
+ if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
+ HTAlert(CANNOT_OPEN_TEMP);
+ return(NOT_FOUND);
+ }
+ LYLocalFileToURL(&info_url, tempfile);
+
+ BeginInternalPage (fp0, CONFIG_DEF_TITLE, NULL);
+ fprintf(fp0, "<pre>\n");
+
+ fprintf(fp0, "%s %s<a href=\"LYNXCFG:\"> lynx.cfg</a> %s\n\n",
+ SEE_ALSO,
+ YOUR_SEGMENT,
+ RUNTIME_OPT_SEGMENT);
+
+ fprintf(fp0, "\n%s<br>\n<em>config.cache</em>\n", AUTOCONF_CONFIG_CACHE);
+ for (n = 0; n < TABLESIZE(config_cache); n++) {
+ PutDefs(config_cache, n);
+ }
+ fprintf(fp0, "\n%s<br>\n<em>lynx_cfg.h</em>\n", AUTOCONF_LYNXCFG_H);
+ for (n = 0; n < TABLESIZE(config_defines); n++) {
+ PutDefs(config_defines, n);
+ }
+ fprintf(fp0, "</pre>\n");
+ EndInternalPage(fp0);
+ LYCloseTempFP(fp0);
+ }
+
+ /* exit to getfile() cyrcle */
+ StrAllocCopy(newdoc->address, info_url);
+ WWWDoc.address = newdoc->address;
+ WWWDoc.post_data = newdoc->post_data;
+ WWWDoc.post_content_type = newdoc->post_content_type;
+ WWWDoc.bookmark = newdoc->bookmark;
+ WWWDoc.isHEAD = newdoc->isHEAD;
+ WWWDoc.safe = newdoc->safe;
+
+ if (!HTLoadAbsolute(&WWWDoc))
+ return(NOT_FOUND);
+ return(NORMAL);
}
+#endif /* !NO_CONFIG_INFO */
diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h
index 2526ab17..6f674f3d 100644
--- a/src/LYReadCFG.h
+++ b/src/LYReadCFG.h
@@ -47,7 +47,8 @@ extern void read_cfg PARAMS((char *cfg_filename, char *parent_filename, int nest
extern void free_lynx_cfg NOPARAMS;
extern BOOLEAN have_read_cfg;
-extern char *lynx_cfg_infopage NOPARAMS;
-extern char *lynx_compile_opts NOPARAMS;
+extern int lynx_cfg_infopage PARAMS((document *newdoc));
+extern int lynx_compile_opts PARAMS((document *newdoc));
+extern void reload_read_cfg NOPARAMS; /* not implemented yet, in LYMain.c */
#endif /* LYREADCFG_H */
diff --git a/src/LYSearch.c b/src/LYSearch.c
index dfd359c3..a9cace09 100644
--- a/src/LYSearch.c
+++ b/src/LYSearch.c
@@ -5,7 +5,6 @@
#include <LYSearch.h>
#include <LYGlobalDefs.h>
#include <GridText.h>
-#include <LYSignal.h>
#include <LYLeaks.h>
diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c
index 6f068304..ea97a9e6 100644
--- a/src/LYShowInfo.c
+++ b/src/LYShowInfo.c
@@ -24,55 +24,6 @@
#define ADVANCED_INFO 1 /* to get more info in advanced mode */
-#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
-#define HAVE_CFG_DEFS_H
-
-#define PutDefs(table, N) fprintf(fp0, "%-35s %s\n", table[N].name, table[N].value)
-
-/*
- * Compile-time definitions info, returns local url
- */
-PUBLIC char *lynx_compile_opts NOARGS
-{
- char tempfile[LY_MAXPATH];
-#include <cfg_defs.h>
- unsigned n;
- static char *info_url;
- FILE *fp0;
-
- if (info_url == 0) {
- if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
- HTAlert(CANNOT_OPEN_TEMP);
- return(0);
- }
- LYLocalFileToURL(&info_url, tempfile);
-
- BeginInternalPage (fp0, CONFIG_DEF_TITLE, NULL);
- fprintf(fp0, "<pre>\n");
-
- fprintf(fp0, "%s %s<a href=\"LYNXCFG:\"> lynx.cfg</a> %s\n\n",
- SEE_ALSO,
- YOUR_SEGMENT,
- RUNTIME_OPT_SEGMENT);
-
- fprintf(fp0, "\n%s<br>\n<em>config.cache</em>\n", AUTOCONF_CONFIG_CACHE);
- for (n = 0; n < TABLESIZE(config_cache); n++) {
- PutDefs(config_cache, n);
- }
- fprintf(fp0, "\n%s<br>\n<em>lynx_cfg.h</em>\n", AUTOCONF_LYNXCFG_H);
- for (n = 0; n < TABLESIZE(config_defines); n++) {
- PutDefs(config_defines, n);
- }
- fprintf(fp0, "</pre>\n");
- EndInternalPage(fp0);
- LYCloseTempFP(fp0);
- }
- return info_url;
-}
-#else
-#undef HAVE_CFG_DEFS_H
-#endif /* !NO_CONFIG_INFO */
-
/*
* Showinfo prints a page of info about the current file and the link
* that the cursor is on.
@@ -135,7 +86,7 @@ PUBLIC int showinfo ARGS4(
(LYNX_RELEASE ? REL_VERSION : DEV_VERSION) );
if (!LYRestricted) {
-#ifdef HAVE_CFG_DEFS_H
+#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
fprintf(fp0, " - <a href=\"LYNXCOMPILEOPTS:\">%s</a>\n",
COMPILE_OPT_SEGMENT);
#else
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 4179e5f1..01556b95 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -5,7 +5,6 @@
#include <LYGlobalDefs.h>
#include <GridText.h>
#include <LYKeymap.h>
-#include <LYSignal.h>
#include <LYClean.h>
#include <LYMail.h>
#include <LYNews.h>
diff --git a/src/LYStyle.c b/src/LYStyle.c
index 7de53c65..d74c14d3 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.23 Tue, 30 Mar 1999 10:10:37 -0700 dickey @
+ * @Id: LYStyle.c 1.24 Tue, 13 Apr 1999 03:39:16 -0600 dickey @
*/
#include <HTUtils.h>
#include <HTML.h>
@@ -22,6 +22,7 @@
#include <LYexit.h>
#include <LYLeaks.h>
+#include <LYStrings.h>
#ifdef USE_COLOR_STYLE
@@ -30,6 +31,20 @@ PUBLIC int last_styles[128];
PUBLIC int last_colorattr_ptr=0;
PUBLIC bucket hashStyles[CSHASHSIZE];
+PUBLIC bucket special_bucket =
+{
+ "<special>" /* in order something to be in trace. */
+};
+PUBLIC bucket nostyle_bucket =
+{
+ "<NOSTYLE>" /* in order something to be in trace. */
+};
+
+PUBLIC int cached_tag_styles[HTML_ELEMENTS];
+PUBLIC int current_tag_style;
+PUBLIC BOOL force_current_tag_style=FALSE;
+PUBLIC char* forced_classname;
+PUBLIC BOOL force_classname;
/* definitions for the mono attributes we can use */
static int ncursesMono[7] = {
@@ -309,7 +324,9 @@ PUBLIC void style_initialiseHashTable NOARGS
}
if (firsttime) {
firsttime = 0;
+#ifdef LY_FIND_LEAKS
atexit(free_colorstylestuff);
+#endif
}
s_high = hash_code("high");
s_alink = hash_code("alink");
@@ -457,4 +474,44 @@ PUBLIC void TrimColorClass ARGS3(
(styleclassname ? styleclassname : "<null>"), tmp);
}
+/* This function is desgined as faster analog to TrimColorClass.
+ It assumes that tag_name is presentin stylename! -HV
+*/
+PUBLIC void FastTrimColorClass ARGS5 (
+ CONST char*, tag_name,
+ int, name_len,
+ char*, stylename,
+ char**, pstylename_end,/*will be modified*/
+ int*, phcode) /*will be modified*/
+{
+ char* tag_start = *pstylename_end;
+
+ while (tag_start >= stylename)
+ {
+ for (; tag_start >= stylename && *tag_start!=';' ; --tag_start)
+ ;
+ if ( !strncasecmp(tag_start+1, tag_name, name_len) ) break;
+ --tag_start;
+ }
+ *tag_start = '\0';
+ *pstylename_end = tag_start;
+ *phcode = hash_code(tag_start+1);
+}
+
+ /* This is called each time lss styles are read. It will fill
+ each elt of 'cached_tag_styles' -HV
+ */
+PUBLIC void cache_tag_styles NOARGS
+{
+ char buf[200];
+ int i;
+
+ for (i = 0; i < HTML_ELEMENTS; ++i)
+ {
+ strcpy(buf, HTML_dtd.tags[i].name);
+ LYLowerCase(buf);
+ cached_tag_styles[i] =hash_code(buf);
+ }
+}
+
#endif /* USE_COLOR_STYLE */
diff --git a/src/LYStyle.h b/src/LYStyle.h
index 414c3d7b..6df504cf 100644
--- a/src/LYStyle.h
+++ b/src/LYStyle.h
@@ -4,6 +4,7 @@
#ifdef USE_COLOR_STYLE
#include <AttrList.h>
+#include <HTMLDTD.h>
/* list of elements */
extern CONST SGML_dtd HTML_dtd;
@@ -33,6 +34,39 @@ extern void TrimColorClass PARAMS((
char * styleclassname,
int * phcode));
+
+ /* this is an array of styles for tags that don't specify 'class' - the
+ values from that array will be suggested by SGML.c by setting the
+ following variable. Value of -1 means that style value should be calculated
+ honestly. -HV */
+extern int cached_tag_styles[HTML_ELEMENTS];
+
+ /* the style for current tag is suggested in current_tag_style. If
+ force_current_tag_style =TRUE, then no attempts to calculate the color style
+ for current tag should be made - the value of 'current_tag_style' must
+ be used.
+ */
+extern int current_tag_style;
+extern BOOL force_current_tag_style;
+
+extern BOOL force_classname;
+extern char* forced_classname; /* if force_current_tag_style =TRUE, then here
+ will be the classname (this is done to avoid copying the class name to the
+ buffer class_name. */
+
+ /* This is called each time lss styles are read. It will fill
+ each elt of 'cached_tag_styles' -HV */
+extern void cache_tag_styles NOPARAMS;
+ /* this is global var - it can be used for reading the end of string found
+ during last invokation of TrimColorClass.
+ */
+extern void FastTrimColorClass PARAMS ((
+ CONST char* tag_name,
+ int name_len,
+ char* stylename,
+ char** pstylename_end,
+ int* hcode));
+
#endif /* USE_COLOR_STYLE */
#endif /* LYSTYLE_H */
diff --git a/src/LYTraversal.c b/src/LYTraversal.c
index e83770b0..ed7a1b58 100644
--- a/src/LYTraversal.c
+++ b/src/LYTraversal.c
@@ -1,7 +1,6 @@
#include <HTUtils.h>
#include <LYGlobalDefs.h>
#include <LYUtils.h>
-#include <LYSignal.h>
#include <LYClean.h>
#include <LYCurses.h>
#include <LYTraversal.h>
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 319a4192..301cb1bc 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -2318,6 +2318,7 @@ PUBLIC int HTCheckForInterrupt NOARGS
HText_pageDisplay(Newline_partial, "");
}
#endif /* DISP_PARTIAL */
+ break;
} /* end switch */
/** Other or no keystrokes **/
return((int)FALSE);
@@ -2438,7 +2439,9 @@ PUBLIC void LYAddLocalhostAlias ARGS1(
if (!localhost_aliases) {
localhost_aliases = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(LYLocalhostAliases_free);
+#endif
}
if ((LocalAlias = (char *)calloc(1, (strlen(alias) + 1))) == NULL)
@@ -3064,7 +3067,9 @@ PUBLIC void HTAddSugFilename ARGS1(
if (!sug_filenames) {
sug_filenames = HTList_new();
+#ifdef LY_FIND_LEAKS
atexit(HTSugFilenames_free);
+#endif
HTList_addObject(sug_filenames, new);
return;
}
@@ -4891,7 +4896,9 @@ PUBLIC CONST char * Home_Dir NOARGS
StrAllocCopy(HomeDir, cp);
}
homedir = (CONST char *)HomeDir;
+#ifdef LY_FIND_LEAKS
atexit(LYHomeDir_free);
+#endif
}
return homedir;
}
diff --git a/src/LYexit.c b/src/LYexit.c
index 67549ae4..92cfe6b0 100644
--- a/src/LYexit.c
+++ b/src/LYexit.c
@@ -19,7 +19,6 @@
*/
PUBLIC BOOL LYOutOfMemory = FALSE;
-#ifdef LY_FIND_LEAKS
/*
* Stack of functions to call upon exit.
@@ -78,9 +77,6 @@ PRIVATE void LYCompleteExit NOPARAMS
callstack[topOfStack]();
}
}
-#else
-#define LYCompleteExit() /*nothing*/
-#endif /* LY_FIND_LEAKS */
/*
* Purpose: Terminates program.
diff --git a/src/UCAuto.c b/src/UCAuto.c
index 35775a2a..12e9f1de 100644
--- a/src/UCAuto.c
+++ b/src/UCAuto.c
@@ -22,6 +22,7 @@
#include <UCAuto.h>
#include <LYGlobalDefs.h>
#include <LYClean.h>
+#include <LYLeaks.h>
#ifdef EXP_CHARTRANS_AUTOSWITCH
diff --git a/src/UCdomap.c b/src/UCdomap.c
index e777dcca..f3d6c87c 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -2024,7 +2024,9 @@ PUBLIC void UCInit NOARGS
{
UCreset_allocated_LYCharSets();
+#ifdef LY_FIND_LEAKS
atexit(UCcleanup_mem);
+#endif
UCconsole_map_init();
/*
diff --git a/src/descrip.mms b/src/descrip.mms
index 667f67bb..f4ce9e1a 100644
--- a/src/descrip.mms
+++ b/src/descrip.mms
@@ -160,9 +160,16 @@ CFLAGS = $(TCPFLAGS) $(CFLAGS)/Include=([], [-], [.chrtrans], [-.WWW.Library.Imp
lynx : lynx.exe
@ Continue
-lynx.exe : $(OBJS) $(WWWLIB)
+HDRS = [.chrtrans]iso01_uni.h
+
+lynx.exe : $(HDRS) $(OBJS) $(WWWLIB)
$(LINK) /Executable = Lynx.exe $(OBJS), $(WWWLIB)/lib, $(TOPT)/opt, $(COPT)/opt
+$(HDRS) :
+ set default [.chrtrans]
+ @build-chrtrans
+ set default [-]
+
clean :
- Set Protection = (Owner:RWED) *.*;-1
- Purge /NoLog /NoConfirm
diff --git a/src/makefile.dos b/src/makefile.dos
index a7b30b41..1e05433f 100644
--- a/src/makefile.dos
+++ b/src/makefile.dos
@@ -7,7 +7,7 @@ LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \
HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o
+LYStyle.o LYHash.o LYPrettySrc.o
CFLAGS= $(MCFLAGS) -I. -I.. $(SLANGINC)
diff --git a/src/makefile.dsl b/src/makefile.dsl
index 64c14f1d..acdbfcd4 100644
--- a/src/makefile.dsl
+++ b/src/makefile.dsl
@@ -7,7 +7,7 @@ LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \
HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o
+LYStyle.o LYHash.o LYPrettySrc.o
CFLAGS= $(MCFLAGS) $(INTLFLAGS) -I. -I.. $(SLANGINC)
diff --git a/src/makefile.in b/src/makefile.in
index 978d6d0d..4712a331 100644
--- a/src/makefile.in
+++ b/src/makefile.in
@@ -65,7 +65,7 @@ LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \
HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o $(CHARTRANS_OBJS) @LIBOBJS@
+LYStyle.o LYHash.o LYPrettySrc.o $(CHARTRANS_OBJS) @LIBOBJS@
C_SRC = $(OBJS:.o=.c)
diff --git a/src/makefile.wsl b/src/makefile.wsl
index 1b238170..893746cc 100644
--- a/src/makefile.wsl
+++ b/src/makefile.wsl
@@ -7,7 +7,7 @@ LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \
HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o
+LYStyle.o LYHash.o LYPrettySrc.o
CFLAGS= $(MCFLAGS) -I. -I.. $(SLANGINC)