aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--WWW/Library/Implementation/HTAnchor.c28
-rw-r--r--WWW/Library/Implementation/HTAtom.c79
-rw-r--r--WWW/Library/Implementation/HTAtom.h1
-rw-r--r--WWW/Library/Implementation/HTMLGen.c15
-rw-r--r--src/HTML.c16
-rw-r--r--src/LYCurses.c14
-rw-r--r--src/LYHash.c63
-rw-r--r--src/LYHash.h10
-rw-r--r--src/LYMain.c7
-rw-r--r--src/LYPrettySrc.c6
-rw-r--r--src/LYStyle.c68
-rw-r--r--src/LYUtils.c4
13 files changed, 130 insertions, 184 deletions
diff --git a/CHANGES b/CHANGES
index cb183ed1..3dcd969b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,10 @@
--- $LynxId: CHANGES,v 1.942 2018/03/05 22:48:35 tom Exp $
+-- $LynxId: CHANGES,v 1.943 2018/03/09 01:45:26 tom Exp $
===============================================================================
Changes since Lynx 2.8 release
===============================================================================
2018-03-05 (2.8.9dev.17)
+* modify color-style hashing to check for collisions -TD
* add PREFERRED_CONTENT_TYPE defaulting to text/plain and options-menu to
replace an assumption in HTMIMEConvert that everything is text/html.
Since most servers provide a valid Content-Type for HTML, and are more likely
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index b8e17241..d782020b 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: HTAnchor.c,v 1.78 2018/03/02 22:01:24 tom Exp $
+ * $LynxId: HTAnchor.c,v 1.80 2018/03/06 09:34:12 tom Exp $
*
* Hypertext "Anchor" Object HTAnchor.c
* ==========================
@@ -31,29 +31,15 @@
#include <LYUtils.h>
#include <LYLeaks.h>
-#define HASH_TYPE unsigned short
+#define HASH_OF(h, v) ((HASH_TYPE)((h) * 3 + UCH(v)) % HASH_SIZE)
-#ifdef NOT_DEFINED
-/*
- * This is the hashing function used to determine which list in the
- * adult_table a parent anchor should be put in. This is a
- * much simpler function than the original used.
- */
-#define HASH_FUNCTION(cp_address) \
- ( (HASH_TYPE)strlen(cp_address) *\
- (HASH_TYPE)TOUPPER(*cp_address) % HASH_SIZE )
-#endif /* NOT_DEFINED */
-
-/*
- * This is the original function. We'll use it again. - FM
- */
-static HASH_TYPE HASH_FUNCTION(const char *cp_address)
+static HASH_TYPE anchor_hash(const char *cp_address)
{
HASH_TYPE hash;
- const unsigned char *p;
+ const char *p;
- for (p = (const unsigned char *) cp_address, hash = 0; *p; p++)
- hash = (HASH_TYPE) (hash * 3 + (*(const unsigned char *) p)) % HASH_SIZE;
+ for (p = cp_address, hash = 0; *p; p++)
+ hash = HASH_OF(hash, *p);
return (hash);
}
@@ -446,7 +432,7 @@ static HTParentAnchor0 *HTAnchor_findAddress_in_adult_table(const DocAddress *ne
/*
* Select list from hash table,
*/
- hash = HASH_FUNCTION(newdoc->address);
+ hash = anchor_hash(newdoc->address);
adults = &(adult_table[hash]);
/*
diff --git a/WWW/Library/Implementation/HTAtom.c b/WWW/Library/Implementation/HTAtom.c
index 914a7f37..07eca771 100644
--- a/WWW/Library/Implementation/HTAtom.c
+++ b/WWW/Library/Implementation/HTAtom.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: HTAtom.c,v 1.20 2016/11/24 15:29:50 tom Exp $
+ * $LynxId: HTAtom.c,v 1.22 2018/03/06 09:46:58 tom Exp $
*
* Atoms: Names to numbers HTAtom.c
* =======================
@@ -17,15 +17,13 @@
*/
#include <HTUtils.h>
-
-#define HASH_SIZE 101 /* Tunable */
#include <HTAtom.h>
-
#include <HTList.h>
-
#include <LYexit.h>
#include <LYLeaks.h>
+#define HASH_SIZE 101 /* Arbitrary prime. Memory/speed tradeoff */
+
static HTAtom *hash_table[HASH_SIZE];
static BOOL initialised = NO;
@@ -36,9 +34,6 @@ static BOOL initialised = NO;
static void free_atoms(void);
#endif
-/*
- * Alternate hashing function.
- */
#define HASH_FUNCTION(cp_hash) ((strlen(cp_hash) * UCH(*cp_hash)) % HASH_SIZE)
HTAtom *HTAtom_for(const char *string)
@@ -46,38 +41,22 @@ HTAtom *HTAtom_for(const char *string)
size_t hash;
HTAtom *a;
- /* First time around, clear hash table
- */
- /*
- * Memory leak fixed.
- * 05-29-94 Lynx 2-3-1 Garrett Arch Blythe
- */
if (!initialised) {
- int i;
-
- for (i = 0; i < HASH_SIZE; i++)
- hash_table[i] = (HTAtom *) 0;
+ memset(hash_table, 0, sizeof(hash_table));
initialised = YES;
#ifdef LY_FIND_LEAKS
atexit(free_atoms);
#endif
}
- /* Generate hash function
- */
hash = HASH_FUNCTION(string);
- /* Search for the string in the list
- */
for (a = hash_table[hash]; a; a = a->next) {
if (0 == strcasecomp(a->name, string)) {
- /* CTRACE((tfp, "HTAtom: Old atom %p for `%s'\n", a, string)); */
- return a; /* Found: return it */
+ return a;
}
}
- /* Generate a new entry
- */
a = (HTAtom *) malloc(sizeof(*a));
if (a == NULL)
outofmem(__FILE__, "HTAtom_for");
@@ -87,11 +66,8 @@ HTAtom *HTAtom_for(const char *string)
outofmem(__FILE__, "HTAtom_for");
strcpy(a->name, string);
- a->next = hash_table[hash]; /* Put onto the head of list */
+ a->next = hash_table[hash];
hash_table[hash] = a;
-#ifdef NOT_DEFINED
- CTRACE((tfp, "HTAtom: New atom %p for `%s'\n", a, string));
-#endif /* NOT_DEFINED */
return a;
}
@@ -129,46 +105,3 @@ static void free_atoms(void)
}
}
#endif /* LY_FIND_LEAKS */
-
-static BOOL mime_match(const char *name,
- const char *templ)
-{
- if (name && templ) {
- static char *n1 = NULL;
- static char *t1 = NULL;
- char *n2;
- char *t2;
-
- StrAllocCopy(n1, name); /* These also free the ones */
- StrAllocCopy(t1, templ); /* from previous call. */
-
- if (!(n2 = StrChr(n1, '/')) || !(t2 = StrChr(t1, '/')))
- return NO;
-
- *(n2++) = (char) 0;
- *(t2++) = (char) 0;
-
- if ((0 == strcmp(t1, "*") || 0 == strcmp(t1, n1)) &&
- (0 == strcmp(t2, "*") || 0 == strcmp(t2, n2)))
- return YES;
- }
- return NO;
-}
-
-HTList *HTAtom_templateMatches(const char *templ)
-{
- HTList *matches = HTList_new();
-
- if (initialised && templ) {
- int i;
- HTAtom *cur;
-
- for (i = 0; i < HASH_SIZE; i++) {
- for (cur = hash_table[i]; cur; cur = cur->next) {
- if (mime_match(cur->name, templ))
- HTList_addObject(matches, (void *) cur);
- }
- }
- }
- return matches;
-}
diff --git a/WWW/Library/Implementation/HTAtom.h b/WWW/Library/Implementation/HTAtom.h
index 4125d31b..0d787bce 100644
--- a/WWW/Library/Implementation/HTAtom.h
+++ b/WWW/Library/Implementation/HTAtom.h
@@ -34,7 +34,6 @@ extern "C" {
}; /* struct _HTAtom */
extern HTAtom *HTAtom_for(const char *string);
- extern HTList *HTAtom_templateMatches(const char *templ);
#define HTAtom_name(a) ((a)->name)
diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c
index e57de9db..2808a823 100644
--- a/WWW/Library/Implementation/HTMLGen.c
+++ b/WWW/Library/Implementation/HTMLGen.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: HTMLGen.c,v 1.42 2018/03/04 20:04:55 tom Exp $
+ * $LynxId: HTMLGen.c,v 1.44 2018/03/07 10:26:05 tom Exp $
*
* HTML Generator
* ==============
@@ -338,12 +338,12 @@ static int HTMLGen_start_element(HTStructured * me, int element_number,
}
class_string[0] = '\0';
strtolower(myHash);
- hcode = hash_code_1(myHash);
+ hcode = color_style_1(myHash);
strtolower(Style_className);
if (TRACE_STYLE) {
fprintf(tfp, "CSSTRIM:%s -> %d", myHash, hcode);
- if (hashStyles[hcode].code != hcode) {
+ if (!hashStyles[hcode].used) {
char *rp = strrchr(myHash, '.');
fprintf(tfp, " (undefined) %s\n", myHash);
@@ -351,9 +351,9 @@ static int HTMLGen_start_element(HTStructured * me, int element_number,
int hcd;
*rp = '\0'; /* trim the class */
- hcd = hash_code_1(myHash);
+ hcd = color_style_1(myHash);
fprintf(tfp, "CSS:%s -> %d", myHash, hcd);
- if (hashStyles[hcd].code != hcd)
+ if (!hashStyles[hcd].used)
fprintf(tfp, " (undefined) %s\n", myHash);
else
fprintf(tfp, " ca=%d\n", hashStyles[hcd].color);
@@ -409,7 +409,8 @@ static int HTMLGen_start_element(HTStructured * me, int element_number,
(tfp, "CSSTRIM:link=%s\n", title_tmp));
do_cstyle_flush(me);
- HText_characterStyle(me->text, hash_code_1(title_tmp), 1);
+ HText_characterStyle(me->text,
+ color_style_1(title_tmp), 1);
}
}
#endif
@@ -450,7 +451,7 @@ static int HTMLGen_start_element(HTStructured * me, int element_number,
*/
if (title && *title) {
do_cstyle_flush(me);
- HText_characterStyle(me->text, hash_code_1(title_tmp), 0);
+ HText_characterStyle(me->text, color_style_1(title_tmp), 0);
FREE(title_tmp);
}
FREE(title);
diff --git a/src/HTML.c b/src/HTML.c
index 92431d01..8355dd83 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: HTML.c,v 1.186 2018/03/05 00:03:30 tom Exp $
+ * $LynxId: HTML.c,v 1.188 2018/03/07 10:26:46 tom Exp $
*
* Structured stream to Rich hypertext converter
* ============================================
@@ -993,13 +993,13 @@ static int HTML_start_element(HTStructured * me, int element_number,
prefix_string = "";
if (current_tag_style == -1) { /* Append class_name */
- hcode = hash_code_1(HTML_dtd.tags[element_number].name);
+ hcode = color_style_1(HTML_dtd.tags[element_number].name);
if (non_empty(class_name)) {
int ohcode = hcode;
prefix_string = HTML_dtd.tags[element_number].name;
- hcode = hash_code_3(prefix_string, ".", class_name);
- if (!hashStyles[hcode].name) { /* None such -> classless version */
+ hcode = color_style_3(prefix_string, ".", class_name);
+ if (!hashStyles[hcode].used) { /* None such -> classless version */
hcode = ohcode;
prefix_string = "";
CTRACE2(TRACE_STYLE,
@@ -1024,7 +1024,7 @@ static int HTML_start_element(HTStructured * me, int element_number,
class_string[0] = '\0';
}
hcode = current_tag_style;
- if (hcode >= 0 && hashStyles[hcode].name) {
+ if (hcode >= 0 && hashStyles[hcode].used) {
prefix_string = hashStyles[hcode].name;
}
CTRACE2(TRACE_STYLE,
@@ -1040,8 +1040,8 @@ static int HTML_start_element(HTStructured * me, int element_number,
if (present && present[HTML_INPUT_TYPE] && value[HTML_INPUT_TYPE])
type = value[HTML_INPUT_TYPE];
- hcode = hash_code_3(prefix_string, ".type.", type);
- if (!hashStyles[hcode].name) { /* None such -> classless version */
+ hcode = color_style_3(prefix_string, ".type.", type);
+ if (!hashStyles[hcode].used) { /* None such -> classless version */
hcode = ohcode;
CTRACE2(TRACE_STYLE,
(tfp, "STYLE.start_element: type <%s> not configured.\n",
@@ -1450,7 +1450,7 @@ static int HTML_start_element(HTStructured * me, int element_number,
int hcode2;
HTSprintf0(&tmp, "link.%s.%s", value[HTML_LINK_CLASS], title);
- hcode2 = hash_code_1(tmp);
+ hcode2 = color_style_1(tmp);
CTRACE2(TRACE_STYLE,
(tfp, "STYLE.link: using style <%s>\n", tmp));
diff --git a/src/LYCurses.c b/src/LYCurses.c
index 822b8da2..26dd1648 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYCurses.c,v 1.188 2018/03/04 20:00:33 tom Exp $ */
+/* $LynxId: LYCurses.c,v 1.191 2018/03/07 10:02:01 tom Exp $ */
#include <HTUtils.h>
#include <HTAlert.h>
@@ -417,12 +417,10 @@ void setHashStyle(int style,
(tfp, "CSS(SET): <%s> hash=%d, ca=%#x, ma=%#x\n",
element, style, color, mono));
+ ds->used = TRUE;
ds->color = color;
ds->cattr = cattr;
ds->mono = mono;
- ds->code = style;
- FREE(ds->name);
- StrAllocCopy(ds->name, element);
}
/*
@@ -468,16 +466,16 @@ void curses_w_style(WINDOW * win, int style,
break;
}
- if (!ds->name) {
+ if (!ds->used) {
CTRACE2(TRACE_STYLE, (tfp, "CSS.CS:Style %d not configured\n", style));
if (free_ds)
free(ds);
return;
}
- CTRACE2(TRACE_STYLE, (tfp, "CSS.CS:<%s%s> style %d code %#x, color %#x\n",
+ CTRACE2(TRACE_STYLE, (tfp, "CSS.CS:<%s%s> style %d color %#x\n",
(dir ? "" : "/"),
- ds->name, style, ds->code, ds->color));
+ ds->name, style, ds->color));
getyx(win, YP, XP);
@@ -544,7 +542,7 @@ void wcurses_css(WINDOW * win, char *name,
int try_again = 1;
while (try_again) {
- int tmpHash = hash_code_1(name);
+ int tmpHash = color_style_1(name);
CTRACE2(TRACE_STYLE, (tfp, "CSSTRIM:trying to set [%s] style - ", name));
if (tmpHash == NOSTYLE) {
diff --git a/src/LYHash.c b/src/LYHash.c
index 1b8e2c0a..c1410fc7 100644
--- a/src/LYHash.c
+++ b/src/LYHash.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYHash.c,v 1.26 2018/03/04 20:01:27 tom Exp $
+ * $LynxId: LYHash.c,v 1.33 2018/03/07 10:20:10 tom Exp $
*
* A hash table for the (fake) CSS support in Lynx-rp
* (c) 1996 Rob Partington
@@ -12,13 +12,9 @@
#ifdef USE_COLOR_STYLE
-/*
- * This is the same function as the private HASH_FUNCTION() in HTAnchor.c, but
- * with a different value for HASH_SIZE.
- */
-
#define HASH_SIZE CSHASHSIZE
-#define HASH_OF(h, v) ((int)((h) * 3 + UCH(v)) % HASH_SIZE)
+#define HASH_TYPE int
+#define HASH_OF(h, v) ((HASH_TYPE)((h) * 3 + UCH(v)) % HASH_SIZE)
static size_t limit;
static char *buffer;
@@ -35,40 +31,67 @@ static char *get_buffer(size_t need)
return buffer;
}
-static int hash_code(const char *string)
+/*
+ * This is the same algorithm as the private anchor_hash() in HTAnchor.c, but
+ * with a different value for HASH_SIZE.
+ */
+static HASH_TYPE cs_hash(const char *string)
{
- int hash = 0;
+ HASH_TYPE hash = 0;
+ HASH_TYPE best, n;
+ bucket *data;
+ const char *p;
+ int bumped = 0;
- if (string != 0) {
- const char *p;
+ for (p = string; *p; p++)
+ hash = HASH_OF(hash, *p);
- for (p = string; *p; p++)
- hash = HASH_OF(hash, *p);
+ /*
+ * The computed hash-code is only a starting point. Check for collision.
+ */
+ best = hash;
+ for (n = 0; n < HASH_SIZE; n++) {
+ int nn = (n + hash) % HASH_SIZE;
- CTRACE_STYLE((tfp, "hash_code(%s) = %d\n", string, hash));
+ data = &hashStyles[nn];
+ if (data->name == 0 || !strcmp(string, data->name)) {
+ best = nn;
+ hash = nn;
+ break;
+ }
+ ++bumped;
+ }
+ data = &hashStyles[best];
+ if (data->name != 0) {
+ if (strcmp(string, data->name)) {
+ CTRACE_STYLE((tfp, "cs_hash(%s) overwriting %d\n", string, data->name));
+ FREE(data->name);
+ StrAllocCopy(data->name, string);
+ }
} else {
- FREE(buffer);
- limit = 0;
+ StrAllocCopy(data->name, string);
}
+
+ CTRACE_STYLE((tfp, "cs_hash(%s) = %d\n", string, hash));
return hash;
}
-int hash_code_1(const char *string)
+int color_style_1(const char *string)
{
get_buffer(strlen(string));
strcpy(buffer, string);
LYLowerCase(buffer);
- return hash_code(buffer);
+ return cs_hash(buffer);
}
-int hash_code_3(const char *p, const char *q, const char *r)
+int color_style_3(const char *p, const char *q, const char *r)
{
get_buffer(strlen(p) + strlen(q) + strlen(r));
strcpy(buffer, p);
strcat(buffer, q);
strcat(buffer, r);
LYLowerCase(buffer);
- return hash_code(buffer);
+ return cs_hash(buffer);
}
#endif /* USE_COLOR_STYLE */
diff --git a/src/LYHash.h b/src/LYHash.h
index d0c3088c..7d0a1666 100644
--- a/src/LYHash.h
+++ b/src/LYHash.h
@@ -1,4 +1,4 @@
-/* $LynxId: LYHash.h,v 1.34 2018/03/04 20:02:45 tom Exp $ */
+/* $LynxId: LYHash.h,v 1.38 2018/03/06 23:28:12 tom Exp $ */
#ifndef _LYHASH_H_
#define _LYHASH_H_ 1
@@ -11,23 +11,21 @@ extern "C" {
#endif
typedef struct {
char *name; /* name of this item */
- int code; /* code of this item */
+ BOOL used; /* color/attributes have been assigned */
int color; /* color highlighting to be done */
int mono; /* mono highlighting to be done */
int cattr; /* attributes to go with the color */
} bucket;
-#ifndef CSHASHSIZE
#define CSHASHSIZE 9973 /* Arbitrary prime. Memory/speed tradeoff */
-#endif
#define NOSTYLE -1
extern bucket hashStyles[CSHASHSIZE];
extern bucket *nostyle_bucket(void);
- extern int hash_code_1(const char *string);
- extern int hash_code_3(const char *p, const char *q, const char *r);
+ extern int color_style_1(const char *string);
+ extern int color_style_3(const char *p, const char *q, const char *r);
extern int s_a;
extern int s_aedit;
diff --git a/src/LYMain.c b/src/LYMain.c
index 6fc4cd07..97fcf488 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYMain.c,v 1.270 2018/03/05 22:32:14 tom Exp $
+ * $LynxId: LYMain.c,v 1.272 2018/03/07 22:18:43 tom Exp $
*/
#include <HTUtils.h>
#include <HTTP.h>
@@ -757,6 +757,9 @@ static void free_lynx_globals(void)
{
int i;
+#if defined(USE_COLOR_STYLE)
+ clear_lss_list();
+#endif
FREE(ftp_format);
#ifndef VMS
FREE(list_format);
@@ -850,6 +853,8 @@ static void free_lynx_globals(void)
FREE(LYTraceLogPath);
FREE(lynx_cfg_file);
FREE(SSL_cert_file);
+ FREE(SSL_client_cert_file);
+ FREE(SSL_client_key_file);
#if defined(USE_COLOR_STYLE)
FREE(lynx_lss_file2);
FREE(lynx_lss_file);
diff --git a/src/LYPrettySrc.c b/src/LYPrettySrc.c
index ec3c136c..c2ff39e0 100644
--- a/src/LYPrettySrc.c
+++ b/src/LYPrettySrc.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYPrettySrc.c,v 1.34 2018/03/04 19:48:49 tom Exp $
+ * $LynxId: LYPrettySrc.c,v 1.36 2018/03/06 10:27:28 tom Exp $
*
* HTML source syntax highlighting
* by Vlad Harchev <hvv@hippo.ru>
@@ -157,10 +157,10 @@ static void append_open_tag(const char *tagname,
#ifdef USE_COLOR_STYLE
if (non_empty(classname)) {
- hcode = hash_code_3(tagname, ".", classname);
+ hcode = color_style_3(tagname, ".", classname);
StrAllocCopy(subj->class_name, classname);
} else {
- hcode = hash_code_1(tagname);
+ hcode = color_style_1(tagname);
StrAllocCopy(subj->class_name, "");
}
subj->style = hcode;
diff --git a/src/LYStyle.c b/src/LYStyle.c
index a8fd0a46..10044f7b 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYStyle.c,v 1.101 2018/03/04 19:54:30 tom Exp $
+ * $LynxId: LYStyle.c,v 1.105 2018/03/08 21:05:53 tom Exp $
*
* character level styles for Lynx
* (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
@@ -185,7 +185,7 @@ static void parse_attributes(const char *mono,
int fA = default_fg;
int bA = default_bg;
int cA = A_NORMAL;
- int newstyle = hash_code_1(element);
+ int newstyle = color_style_1(element);
int colored_attr;
CTRACE2(TRACE_STYLE, (tfp, "CSS(PA):style d=%d / h=%d, e=%s\n",
@@ -359,8 +359,10 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
}
CTRACE2(TRACE_STYLE, (tfp, "CSSPARSE:%s => %d %s\n",
- element, hash_code_1(element),
- (hashStyles[hash_code_1(element)].name ? "used" : "")));
+ element, color_style_1(element),
+ (hashStyles[color_style_1(element)].used)
+ ? "used"
+ : ""));
/*
* We use some pseudo-elements, so catch these first
@@ -369,7 +371,7 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
if (!strcasecomp(element, table[n].name)) {
parse_attributes(mono, fg, bg, table[n].style, table[n].name);
if (table[n].set_hash != 0)
- *(table[n].set_hash) = hash_code_1(table[n].name);
+ *(table[n].set_hash) = color_style_1(table[n].name);
found = TRUE;
break;
}
@@ -379,7 +381,7 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
if (!strcasecomp(element, "normal")) {
/* added - kw */
parse_attributes(mono, fg, bg, DSTYLE_NORMAL, "html");
- s_normal = hash_code_1("html"); /* rather bizarre... - kw */
+ s_normal = color_style_1("html"); /* rather bizarre... - kw */
LYnormalColor();
}
@@ -412,11 +414,10 @@ static void free_lss_list(void)
LSS_NAMES *obj;
while ((obj = HTList_objectAt(list_of_lss_files, 0)) != 0) {
- if (HTList_unlinkObject(list_of_lss_files, obj)) {
- FREE(obj->given);
- FREE(obj->actual);
- FREE(obj);
- } else {
+ FREE(obj->given);
+ FREE(obj->actual);
+ FREE(obj);
+ if (!HTList_removeObject(list_of_lss_files, obj)) {
break;
}
}
@@ -425,7 +426,12 @@ static void free_lss_list(void)
static void free_colorstylestuff(void)
{
+ int i;
+
style_initialiseHashTable();
+ for (i = 0; i < CSHASHSIZE; i++) {
+ FREE(hashStyles[i].name);
+ }
style_deleteStyleList();
memset(our_pairs, 0, sizeof(our_pairs));
FreeCachedStyles();
@@ -435,34 +441,28 @@ static void free_colorstylestuff(void)
static void style_initialiseHashTable(void)
{
int i;
- static int firsttime = 1;
+ static BOOL firsttime = TRUE;
for (i = 0; i < CSHASHSIZE; i++) {
- if (firsttime)
- hashStyles[i].name = NULL;
- else
- FREE(hashStyles[i].name);
- hashStyles[i].color = 0;
- hashStyles[i].cattr = 0;
- hashStyles[i].mono = 0;
+ hashStyles[i].used = FALSE;
}
if (firsttime) {
- firsttime = 0;
+ firsttime = FALSE;
#ifdef LY_FIND_LEAKS
atexit(free_colorstylestuff);
atexit(free_colorstyle_leaks);
#endif
}
- s_alink = hash_code_1("alink");
- s_a = hash_code_1("a");
- s_status = hash_code_1("status");
- s_alert = hash_code_1("alert");
- s_title = hash_code_1("title");
+ s_alink = color_style_1("alink");
+ s_a = color_style_1("a");
+ s_status = color_style_1("status");
+ s_alert = color_style_1("alert");
+ s_title = color_style_1("title");
#ifdef USE_SCROLLBAR
- s_sb_bar = hash_code_1("scroll.bar");
- s_sb_bg = hash_code_1("scroll.back");
- s_sb_aa = hash_code_1("scroll.arrow");
- s_sb_naa = hash_code_1("scroll.noarrow");
+ s_sb_bar = color_style_1("scroll.bar");
+ s_sb_bg = color_style_1("scroll.back");
+ s_sb_aa = color_style_1("scroll.arrow");
+ s_sb_naa = color_style_1("scroll.noarrow");
#endif
}
@@ -707,7 +707,7 @@ void TrimColorClass(const char *tagname,
if (end)
*end = '\0';
}
- *phcode = hash_code_1(lookfrom && *lookfrom ? lookfrom : &tmp[1]);
+ *phcode = color_style_1(lookfrom && *lookfrom ? lookfrom : &tmp[1]);
}
/* This function is designed as faster analog to TrimColorClass.
@@ -738,7 +738,7 @@ void FastTrimColorClass(const char *tag_name,
*pstylename_end = tag_start;
}
CTRACE2(TRACE_STYLE, (tfp, found ? "success.\n" : "failed.\n"));
- *phcode = hash_code_1(tag_start + 1);
+ *phcode = color_style_1(tag_start + 1);
}
/* This is called each time lss styles are read. It will fill
@@ -749,7 +749,7 @@ void cache_tag_styles(void)
int i;
for (i = 0; i < HTML_ELEMENTS; ++i) {
- cached_tag_styles[i] = hash_code_1(HTML_dtd.tags[i].name);
+ cached_tag_styles[i] = color_style_1(HTML_dtd.tags[i].name);
}
}
@@ -916,8 +916,10 @@ void init_color_styles(char **from_cmdline, const char *default_styles)
char *target;
target = find_lss_file(LYPathLeaf(cp));
- if (target != 0)
+ if (target != 0) {
add_to_lss_list(cp, target);
+ FREE(target);
+ }
}
FREE(source);
}
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 7a12ae66..767ab9b4 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYUtils.c,v 1.280 2018/03/01 22:14:57 Takeshi.Hataguchi Exp $
+ * $LynxId: LYUtils.c,v 1.281 2018/03/07 10:02:51 tom Exp $
*/
#include <HTUtils.h>
#include <HTTCP.h>
@@ -1559,7 +1559,7 @@ void statusline(const char *text)
{
int y, x;
int a = ((StrNCmp(buffer, ALERT_FORMAT, ALERT_PREFIX_LEN)
- || !hashStyles[s_alert].name)
+ || !hashStyles[s_alert].used)
? s_status
: s_alert);