about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CHANGES7
-rw-r--r--lynx.cfg21
-rw-r--r--src/LYCurses.h5
-rw-r--r--src/LYMain.c54
-rw-r--r--src/LYOptions.c69
-rw-r--r--src/LYOptions.h6
-rw-r--r--src/LYReadCFG.c11
-rw-r--r--src/LYStyle.c247
-rw-r--r--src/LYStyle.h58
-rw-r--r--src/LYUtils.c8
10 files changed, 360 insertions, 126 deletions
diff --git a/CHANGES b/CHANGES
index 8e09aa0f..583eac7e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,12 @@
--- $LynxId: CHANGES,v 1.692 2013/10/20 21:59:40 tom Exp $
+-- $LynxId: CHANGES,v 1.694 2013/10/23 09:13:01 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
-2013-10-20 (2.8.8dev.17)
+2013-10-23 (2.8.8dev.17)
+* modify configuration of COLOR_STYLE value in lynx.cfg, allowing multiple
+  filenames to be specified and providing those as choices in the O'ptions
+  menu (Debian #404893) -TD
 * updates for lynx_help_main.html -TD
 * update URLs in about_lynx.html -TD
 * add internal URL "LYNXEDITMAP:", which is (like "LYNXKEYMAP:") generated,
diff --git a/lynx.cfg b/lynx.cfg
index ec54e985..93e4df3f 100644
--- a/lynx.cfg
+++ b/lynx.cfg
@@ -1,4 +1,4 @@
-# $LynxId: lynx.cfg,v 1.228 2013/10/15 08:58:09 tom Exp $
+# $LynxId: lynx.cfg,v 1.229 2013/10/21 09:11:04 tom Exp $
 # lynx.cfg file.
 # The default placement for this file is /usr/local/lib/lynx.cfg (Unix)
 #                                     or Lynx_Dir:lynx.cfg (VMS)
@@ -2411,10 +2411,10 @@ MINIMAL_COMMENTS:TRUE
 # the default mapping unless you change that files manually,
 # so you are responsible for possible deviations
 # when you are changing any KEYMAP below).
-.nf
+#
 # Lynx accepts special keys either by name, or by lynx-specific codes.  These
 # names and codes are listed below, with a brief description:
-#
+.nf
 #         UPARROW: 0x100 (Up Arrow)
 #         DNARROW: 0x101 (Down Arrow)
 #         RTARROW: 0x102 (Right Arrow)
@@ -2443,7 +2443,6 @@ MINIMAL_COMMENTS:TRUE
 #             F11: 0x119 (VT220 Function-key 11)
 #             F12: 0x11A (VT220 Function-key 12)
 #           MOUSE: 0x11D (reserved for internal use with -use_mouse)
-#
 .fi
 # Other codes not listed above may be available for additional keys,
 # depending on operating system and libraries used to compile Lynx.
@@ -2457,8 +2456,8 @@ MINIMAL_COMMENTS:TRUE
 # mappings done here: KEYMAP maps the result of that step (which still
 # represents a key) to a function (which represents an action that Lynx
 # should perform).
-#
 .nf
+#
 #KEYMAP:0x5C:SOURCE		# Toggle source viewing mode (show HTML source)
 #KEYMAP:^R:RELOAD		# Reload the current document and redisplay
 #KEYMAP:^U:NEXT_DOC		# Undo PREV_DOC)
@@ -2537,7 +2536,6 @@ MINIMAL_COMMENTS:TRUE
 #KEYMAP:}:SHIFT_RIGHT		# shift the screen right
 #KEYMAP:|:LINEWRAP_TOGGLE	# toggle linewrap on/off, for shift-commands
 #KEYMAP:~:NESTED_TABLES		# toggle nested-tables parsing on/off
-#
 .fi
 # In addition to the bindings available by default, the following functions
 # are not directly mapped to any keys by default, although some of them may
@@ -2978,9 +2976,18 @@ COLOR:6:brightred:black
 #
 # If neither the command-line "-lss" or this COLOR_STYLE setting are given,
 # lynx tries the environment variables "LYNX_LSS" and "lynx_lss".  If neither
-# is set, lynx uses the compiled-in value (which as noted, may be empty).
+# is set, lynx uses the first compiled-in value (which as noted, may be empty).
+#
+# At startup, lynx remembers the name of the color-style file which was used,
+# and together with each file specified, provides those as choices in the
+# O)ptions menu.
 #
 #COLOR_STYLE: lynx.lss
+#COLOR_STYLE: blue-background.lss
+#COLOR_STYLE: bright-blue.lss
+#COLOR_STYLE: midnight.lss
+#COLOR_STYLE: mild-colors.lss
+#COLOR_STYLE: opaque.lss
 
 .h2 NESTED_TABLES
 # This is an experimental feature for improving table layout.
diff --git a/src/LYCurses.h b/src/LYCurses.h
index f9858eeb..b597ed2c 100644
--- a/src/LYCurses.h
+++ b/src/LYCurses.h
@@ -1,4 +1,4 @@
-/* $LynxId: LYCurses.h,v 1.91 2013/10/10 23:28:33 tom Exp $ */
+/* $LynxId: LYCurses.h,v 1.94 2013/10/22 08:10:43 tom Exp $ */
 #ifndef LYCURSES_H
 #define LYCURSES_H
 
@@ -500,9 +500,12 @@ extern "C" {
 #endif				/* VMS */
 
 #if defined(USE_COLOR_STYLE)
+    extern void add_to_lss_list(const char *source, const char *resolved);
     extern void curses_css(char *name, int dir);
     extern void curses_style(int style, int dir);
     extern void curses_w_style(WINDOW * win, int style, int dir);
+    extern void init_color_styles(char **from_cmdline, const char *default_styles);
+    extern void reinit_color_styles(void);
     extern void setHashStyle(int style, int color, int cattr, int mono, const char *element);
     extern void setStyle(int style, int color, int cattr, int mono);
     extern void update_color_style(void);
diff --git a/src/LYMain.c b/src/LYMain.c
index ee7c77e2..90be6c39 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMain.c,v 1.249 2013/10/20 20:35:23 tom Exp $
+ * $LynxId: LYMain.c,v 1.250 2013/10/21 20:25:19 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTP.h>
@@ -689,6 +689,14 @@ static void FatalProblem(int sig);
 int LYuse_color_style = TRUE;
 char *lynx_lss_file = NULL;	/* from config-file, etc. */
 static char *lynx_lss_file2 = NULL;	/* from command-line options */
+const char *default_color_styles = "\
+lynx.lss;\
+blue-background.lss;\
+bright-blue.lss;\
+midnight.lss;\
+mild-colors.lss;\
+opaque.lss\
+";
 #endif
 
 #ifdef USE_DEFAULT_COLORS
@@ -1572,49 +1580,7 @@ int main(int argc,
 
 #if defined(USE_COLOR_STYLE)
     if (!dump_output_immediately) {
-	/*
-	 * A command-line "-lss" always overrides the config-file, even if it is
-	 * an empty string such as -lss="".
-	 */
-	if (lynx_lss_file2 != 0) {
-	    FREE(lynx_lss_file);
-	    lynx_lss_file = lynx_lss_file2;
-	    lynx_lss_file2 = 0;
-	}
-
-	/*
-	 * If no alternate lynx-style file was specified on the command line, see
-	 * if it's in the environment.
-	 */
-	if (!lynx_lss_file) {
-	    if (((cp = LYGetEnv("LYNX_LSS")) != NULL) ||
-		(cp = LYGetEnv("lynx_lss")) != NULL)
-		StrAllocCopy(lynx_lss_file, cp);
-	}
-
-	/*
-	 * If we still don't have a lynx-style file, use the userdefs.h definition.
-	 */
-	if (!lynx_lss_file)
-	    StrAllocCopy(lynx_lss_file, LYNX_LSS_FILE);
-
-	LYTildeExpand(&lynx_lss_file, TRUE);
-#ifdef USE_PROGRAM_DIR
-	if (!isEmpty(lynx_lss_file) && !LYCanReadFile(lynx_lss_file)) {
-	    HTSprintf0(&lynx_lss_file, "%s\\lynx.lss", program_dir);
-	}
-#endif
-
-	/*
-	 * If the lynx-style file is not available, inform the user and exit.
-	 */
-	if (non_empty(lynx_lss_file) && !LYCanReadFile(lynx_lss_file)) {
-	    fprintf(stderr, gettext("\nLynx file \"%s\" is not available.\n\n"),
-		    lynx_lss_file);
-	    exit_immediately(EXIT_FAILURE);
-	} else {
-	    style_readFromFile(lynx_lss_file);
-	}
+	init_color_styles(&lynx_lss_file2, default_color_styles);
     }
 #endif /* USE_COLOR_STYLE */
 
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 2b0e81f8..afaab4c7 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYOptions.c,v 1.157 2013/10/12 14:51:18 tom Exp $ */
+/* $LynxId: LYOptions.c,v 1.161 2013/10/22 08:10:03 tom Exp $ */
 #include <HTUtils.h>
 #include <HTFTP.h>
 #include <HTTP.h>		/* 'reloading' flag */
@@ -25,6 +25,10 @@
 #include <HTFile.h>
 #include <LYCharUtils.h>
 
+#ifdef USE_COLOR_STYLE
+#include <LYStyle.h>
+#endif
+
 #include <LYLeaks.h>
 
 BOOLEAN term_options;
@@ -2206,6 +2210,8 @@ static OptValues show_color_values[] =
 
 #ifdef USE_COLOR_STYLE
 static const char *color_style_string = RC_COLOR_STYLE;
+static OptValues *color_style_values;
+static HTList *color_style_list;
 #endif
 
 #ifdef USE_DEFAULT_COLORS
@@ -2490,6 +2496,54 @@ static BOOLEAN GetOptValues(OptValues * table, char *value,
     return FALSE;
 }
 
+#ifdef USE_COLOR_STYLE
+void build_lss_enum(HTList *list)
+{
+    int count = HTList_count(list);
+
+    FREE(color_style_values);
+    if (count != 0) {
+	LSS_NAMES *obj;
+	int position = 0;
+
+	color_style_values = typecallocn(OptValues, count + 2);
+
+	if (color_style_values == NULL)
+	    outofmem(__FILE__, "build_lss_enum");
+
+	color_style_values[position++] = bool_values[0];
+	while ((obj = HTList_objectAt(list, position - 1)) != 0) {
+	    color_style_values[position].value = position;
+	    color_style_values[position].LongName = obj->given;
+	    color_style_values[position].HtmlName = obj->given;
+	    position++;
+	}
+    }
+    color_style_list = list;
+}
+
+static int get_color_style_value(void)
+{
+    int result = 0;
+
+    if (LYuse_color_style && non_empty(lynx_lss_file)) {
+	LSS_NAMES *obj;
+	int position = 1;
+
+	while ((obj = HTList_objectAt(color_style_list, position - 1)) != 0) {
+	    if (obj->actual != 0 && !strcmp(obj->actual, lynx_lss_file)) {
+		result = position;
+		break;
+	    } else if (!strcmp(obj->given, lynx_lss_file)) {
+		result = position;
+		break;
+	    }
+	    ++position;
+	}
+    }
+    return result;
+}
+#endif
 /*
  * Break cgi line into array of pairs of pointers.  Don't bother trying to
  * be efficient.  We're not called all that often.
@@ -2906,8 +2960,14 @@ int postoptions(DocInfo *newdoc)
 #ifdef USE_COLOR_STYLE
 	/* Color Style: ON/OFF */
 	if (!strcmp(data[i].tag, color_style_string)
-	    && GetOptValues(bool_values, data[i].value, &code)) {
-	    LYuse_color_style = (BOOLEAN) code;
+	    && GetOptValues(color_style_values, data[i].value, &code)) {
+	    if (code) {
+		LYuse_color_style = TRUE;
+		StrAllocCopy(lynx_lss_file, color_style_values[code].LongName);
+		reinit_color_styles();
+	    } else {
+		LYuse_color_style = FALSE;
+	    }
 	    update_color_style();
 	    lynx_force_repaint();
 	}
@@ -3805,7 +3865,7 @@ static int gen_options(char **newfile)
     /* Color style: ON/OFF */
     PutLabel(fp0, gettext("Color style"), color_style_string);
     BeginSelect(fp0, color_style_string);
-    PutOptValues(fp0, LYuse_color_style, bool_values);
+    PutOptValues(fp0, get_color_style_value(), color_style_values);
     EndSelect(fp0);
 #endif
 
@@ -4093,4 +4153,5 @@ static int gen_options(char **newfile)
     LYCloseTempFP(fp0);
     return (NORMAL);
 }
+
 #endif /* !NO_OPTION_FORMS */
diff --git a/src/LYOptions.h b/src/LYOptions.h
index 3d22e43d..0c5f5f2a 100644
--- a/src/LYOptions.h
+++ b/src/LYOptions.h
@@ -1,4 +1,4 @@
-/* $LynxId: LYOptions.h,v 1.30 2012/02/10 18:39:49 tom Exp $ */
+/* $LynxId: LYOptions.h,v 1.31 2013/10/22 00:37:32 tom Exp $ */
 #ifndef LYOPTIONS_H
 #define LYOPTIONS_H
 
@@ -32,6 +32,10 @@ extern "C" {
     extern void LYoptions(void);
 #endif				/* !NO_OPTION_MENU */
 
+#ifdef USE_COLOR_STYLE
+    extern void build_lss_enum(HTList *);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 21a39b3b..419fd833 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYReadCFG.c,v 1.176 2013/05/30 23:16:56 tom Exp $
+ * $LynxId: LYReadCFG.c,v 1.177 2013/10/21 23:13:30 tom Exp $
  */
 #ifndef NO_RULES
 #include <HTRules.h>
@@ -673,6 +673,13 @@ void update_default_colors(void)
 #endif
     }
 }
+#ifdef USE_COLOR_STYLE
+static int lynx_lss_file_fun(char *value)
+{
+    add_to_lss_list(value, NULL);
+    return 0;
+}
+#endif
 
 static int default_colors_fun(char *value)
 {
@@ -1463,7 +1470,7 @@ static Config_Type Config_Table [] =
      PARSE_FUN(RC_COLOR,                color_fun),
 #endif
 #ifdef USE_COLOR_STYLE
-     PARSE_STR(RC_COLOR_STYLE,          lynx_lss_file),
+     PARSE_FUN(RC_COLOR_STYLE,          lynx_lss_file_fun),
 #endif
      PARSE_PRG(RC_COMPRESS_PATH,        ppCOMPRESS),
      PARSE_PRG(RC_COPY_PATH,            ppCOPY),
diff --git a/src/LYStyle.c b/src/LYStyle.c
index 1f4263be..277a7e0b 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYStyle.c,v 1.76 2013/10/03 18:44:56 tom Exp $
+ * $LynxId: LYStyle.c,v 1.85 2013/10/23 09:23:57 tom Exp $
  *
  * character level styles for Lynx
  * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
@@ -21,6 +21,9 @@
 #include <LYHash.h>
 #include <LYStyle.h>
 
+#include <LYOptions.h>
+#include <LYPrettySrc.h>
+
 #include <LYexit.h>
 #include <LYLeaks.h>
 #include <LYStrings.h>
@@ -30,7 +33,8 @@
 
 #ifdef USE_COLOR_STYLE
 
-static void style_initialiseHashTable(void);
+static HTList *list_of_lss_files;
+static char default_lss_file[] = LYNX_LSS_FILE;
 
 /* because curses isn't started when we parse the config file, we
  * need to remember the STYLE: lines we encounter and parse them
@@ -408,6 +412,40 @@ static void style_deleteStyleList(void)
     lss_styles = NULL;
 }
 
+/* Set all the buckets in the hash table to be empty */
+static void style_initialiseHashTable(void)
+{
+    int i;
+    static int firsttime = 1;
+
+    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;
+    }
+    if (firsttime) {
+	firsttime = 0;
+#ifdef LY_FIND_LEAKS
+	atexit(free_colorstylestuff);
+#endif
+    }
+    s_alink = hash_code("alink");
+    s_a = hash_code("a");
+    s_status = hash_code("status");
+    s_alert = hash_code("alert");
+    s_title = hash_code("title");
+#ifdef USE_SCROLLBAR
+    s_sb_bar = hash_code("scroll.bar");
+    s_sb_bg = hash_code("scroll.back");
+    s_sb_aa = hash_code("scroll.arrow");
+    s_sb_naa = hash_code("scroll.noarrow");
+#endif
+}
+
 static void free_colorstylestuff(void)
 {
     style_initialiseHashTable();
@@ -518,40 +556,6 @@ static void initialise_default_stylesheet(void)
     FREE(strong);
 }
 
-/* Set all the buckets in the hash table to be empty */
-static void style_initialiseHashTable(void)
-{
-    int i;
-    static int firsttime = 1;
-
-    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;
-    }
-    if (firsttime) {
-	firsttime = 0;
-#ifdef LY_FIND_LEAKS
-	atexit(free_colorstylestuff);
-#endif
-    }
-    s_alink = hash_code("alink");
-    s_a = hash_code("a");
-    s_status = hash_code("status");
-    s_alert = hash_code("alert");
-    s_title = hash_code("title");
-#ifdef USE_SCROLLBAR
-    s_sb_bar = hash_code("scroll.bar");
-    s_sb_bg = hash_code("scroll.back");
-    s_sb_aa = hash_code("scroll.arrow");
-    s_sb_naa = hash_code("scroll.noarrow");
-#endif
-}
-
 void parse_userstyles(void)
 {
     char *name;
@@ -811,4 +815,175 @@ void update_color_style(void)
     parse_userstyles();
 }
 
+static char *find_lss_file(const char *nominal)
+{
+    char *result = 0;
+
+    if (non_empty(nominal)) {
+	StrAllocCopy(result, nominal);
+	/*
+	 * Look for it in the home directory - if there is a tilde to expand.
+	 */
+	LYTildeExpand(&result, TRUE);
+	if (!LYCanReadFile(result)) {
+	    char *dftfile = default_lss_file;
+	    char *leaf;
+
+	    /*
+	     * If not, try finding it in the same directory as the compiled-in
+	     * location of the default lss-file.
+	     */
+	    if (strcmp(nominal, dftfile) &&
+		(leaf = LYPathLeaf(dftfile)) != dftfile) {
+		char *head = 0;
+
+		StrAllocCopy(head, dftfile);
+		head[leaf - dftfile] = '\0';
+		StrAllocCopy(result, head);
+		StrAllocCat(result, nominal);
+		FREE(head);
+
+		if (!LYCanReadFile(result)) {
+		    FREE(result);
+		}
+	    }
+#ifdef USE_PROGRAM_DIR
+	    else {
+		/*
+		 * Finally, try in the same directory as the executable.
+		 */
+		StrAllocCopy(result, program_dir);
+		LYAddPathSep(&result);
+		StrAllocCat(result, nominal);
+		LYTildeExpand(&result, TRUE);
+		if (!LYCanReadFile(result)) {
+		    FREE(result);
+		}
+	    }
+#endif
+	}
+
+    }
+    return result;
+}
+
+/*
+ * Add an entry to the lss-list, and cache the resolved filename if known.
+ */
+void add_to_lss_list(const char *source, const char *resolved)
+{
+    LSS_NAMES *obj;
+    LSS_NAMES *chk;
+    BOOLEAN found = FALSE;
+    int position = 0;
+
+    CTRACE((tfp, "add_to_lss_list(\"%s\", \"%s\")\n",
+	    NonNull(source),
+	    NonNull(resolved)));
+
+    obj = typecalloc(LSS_NAMES);
+    if (obj == NULL)
+	outofmem(__FILE__, "add_to_lss_list");
+
+    StrAllocCopy(obj->given, source);
+    StrAllocCopy(obj->actual, resolved);
+    if (list_of_lss_files == 0) {
+	list_of_lss_files = HTList_new();
+    }
+
+    while ((chk = HTList_objectAt(list_of_lss_files, position++)) != 0) {
+	if (!strcmp(source, chk->given)) {
+	    found = TRUE;
+	    if (resolved && !chk->actual) {
+		StrAllocCopy(chk->actual, resolved);
+	    }
+	    break;
+	}
+    }
+
+    if (!found) {
+	HTList_appendObject(list_of_lss_files, obj);
+    }
+}
+
+/*
+ * This is called after reading lynx.cfg, to set the initial value for the
+ * lss-file, and read its data.
+ */
+void init_color_styles(char **from_cmdline, const char *default_styles)
+{
+    char *cp;
+
+    /*
+     * If we read no COLOR_STYLE data from lynx.cfg, build a default list now.
+     */
+    if (list_of_lss_files == 0) {
+	char *source = 0;
+
+	StrAllocCopy(source, default_styles);
+	while ((cp = strtok(source, ";")) != 0) {
+	    add_to_lss_list(cp, NULL);
+	    source = 0;
+	}
+	FREE(source);
+    }
+
+    /*
+     * A command-line "-lss" always overrides the config-file, even if it is
+     * an empty string such as -lss="".
+     */
+    if (*from_cmdline != 0) {
+	FREE(lynx_lss_file);
+	lynx_lss_file = find_lss_file(cp = *from_cmdline);
+	*from_cmdline = 0;
+    } else if (((cp = LYGetEnv("LYNX_LSS")) != NULL) ||
+	       (cp = LYGetEnv("lynx_lss")) != NULL) {
+	lynx_lss_file = find_lss_file(cp);
+    } else {
+	lynx_lss_file = find_lss_file(cp = default_lss_file);
+    }
+    CTRACE1((tfp, "init_color_styles(%s)\n", NonNull(lynx_lss_file)));
+
+    /*
+     * If the lynx-style file is not available, inform the user and exit.
+     */
+    if (isEmpty(lynx_lss_file) || !LYCanReadFile(lynx_lss_file)) {
+	fprintf(stderr, gettext("\nLynx file \"%s\" is not available.\n\n"),
+		NonNull(cp));
+	exit_immediately(EXIT_FAILURE);
+    }
+
+    /*
+     * Otherwise, load the initial lss-file and add it to the list for the
+     * options menu.
+     */
+    style_readFromFile(lynx_lss_file);
+    add_to_lss_list(LYPathLeaf(lynx_lss_file), lynx_lss_file);
+    build_lss_enum(list_of_lss_files);
+}
+
+void reinit_color_styles(void)
+{
+    int cs;
+
+    for (cs = 0; cs < CSHASHSIZE; ++cs) {
+	bucket *style = &hashStyles[cs];
+
+	while (style != 0) {
+	    bucket *next = style->next;
+
+	    if (next != 0) {
+		hashStyles[cs] = *next;
+		free(next);
+	    }
+	    style = hashStyles[cs].next;
+	}
+    }
+    for (cs = 0; cs < HTL_num_lexemes; ++cs) {
+	html_src_clean_item(cs);
+    }
+    free_colorstylestuff();
+    style_readFromFile(lynx_lss_file);
+}
+
 #endif /* USE_COLOR_STYLE */
diff --git a/src/LYStyle.h b/src/LYStyle.h
index 93ff1193..3246b2c5 100644
--- a/src/LYStyle.h
+++ b/src/LYStyle.h
@@ -1,4 +1,4 @@
-/* $LynxId: LYStyle.h,v 1.16 2009/01/01 23:06:08 tom Exp $ */
+/* $LynxId: LYStyle.h,v 1.19 2013/10/22 00:42:18 tom Exp $ */
 #ifndef LYSTYLE_H
 #define LYSTYLE_H
 
@@ -12,12 +12,18 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-/* list of elements */ extern const SGML_dtd HTML_dtd;
 
-/* array of currently set styles */
+    typedef struct {
+	char *given;
+	char *actual;
+    } LSS_NAMES;
+
+    /* list of elements */ extern const SGML_dtd HTML_dtd;
+
+    /* array of currently set styles */
     extern HTCharStyle displayStyles[DSTYLE_ELEMENTS];
 
-/* Set all the buckets in the hash table to be empty */
+    /* Set all the buckets in the hash table to be empty */
     extern void parse_userstyles(void);
 
     extern void style_defaultStyleSheet(void);
@@ -28,45 +34,45 @@ extern "C" {
 			       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
- */
+    /* 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.  A value of -1 means that the 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.
- */
+    /* 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;
 
-/* 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.
- */
+    /* 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.
+     */
     extern char *forced_classname;
 
-/* This is called each time lss styles are read.  It will fill each elt of
- * 'cached_tag_styles' -HV
- */
+    /* This is called each time lss styles are read.  It will fill each element
+     * of 'cached_tag_styles' -HV
+     */
     extern void cache_tag_styles(void);
 
-/* this is global var - it can be used for reading the end of string found
- * during last invokation of TrimColorClass.
- */
+    /* use this for reading the end of string found during last invokation of
+     * TrimColorClass.
+     */
     extern void FastTrimColorClass(const char *tag_name,
 				   unsigned name_len,
 				   char *stylename,
 				   char **pstylename_end,
 				   int *hcode);
 
-/*
- * Functions for cached-styles
- */
+    /*
+     * Functions for cached-styles
+     */
     extern BOOL ValidCachedStyle(int y, int x);
     extern unsigned GetCachedStyle(int y, int x);
     extern void FreeCachedStyles(void);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 6aedd0e3..cdb68d56 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.254 2013/10/19 00:59:45 tom Exp $
+ * $LynxId: LYUtils.c,v 1.256 2013/10/23 09:12:22 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -2816,13 +2816,14 @@ BOOLEAN LYCanWriteFile(const char *filename)
 BOOLEAN LYCanReadFile(const char *filename)
 {
     FILE *fp;
+    BOOLEAN result = FALSE;
 
     if (non_empty(filename)) {
 	if ((fp = fopen(filename, "r")) != 0) {
-	    return LYCloseInput(fp);
+	    result = LYCloseInput(fp);
 	}
     }
-    return FALSE;
+    return result;
 }
 
 /*
@@ -7414,6 +7415,7 @@ void LYsetXDisplay(char *new_display)
 #else
 	static char *display_putenv_command;
 
+	display_putenv_command = NULL;	/* yes, this is a leak - cannot fix */
 	HTSprintf0(&display_putenv_command, "DISPLAY=%s", new_display);
 	putenv(display_putenv_command);
 #endif /* VMS */