diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2018-03-09 01:45:26 +0000 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2018-03-09 01:45:26 +0000 |
commit | 82107ab8e0468191d32dfc0eb2b9e105c1a6aaff (patch) | |
tree | 28a2cb178d5f194de74d13d630238293b427849a /src/LYStyle.c | |
parent | 9b7b3896381522f1b70c8e7d803db8103cccd7a1 (diff) | |
download | lynx-snapshots-82107ab8e0468191d32dfc0eb2b9e105c1a6aaff.tar.gz |
snapshot of project "lynx", label v2-8-9dev_16p
Diffstat (limited to 'src/LYStyle.c')
-rw-r--r-- | src/LYStyle.c | 68 |
1 files changed, 35 insertions, 33 deletions
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); } |