diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2012-08-13 01:05:48 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2012-08-13 01:05:48 -0400 |
commit | 4fe78157f9d08e4bf8de41f47ee117b4b9383814 (patch) | |
tree | 65865010d184a4f91a9685c84ef4cee17421a41a /src | |
parent | e95e8bb0ca158527eebbde0ca503552bfeda77c8 (diff) | |
download | lynx-snapshots-4fe78157f9d08e4bf8de41f47ee117b4b9383814.tar.gz |
snapshot of project "lynx", label v2-8-8dev_12l
Diffstat (limited to 'src')
-rw-r--r-- | src/LYReadCFG.c | 8 | ||||
-rw-r--r-- | src/LYReadCFG.h | 4 | ||||
-rw-r--r-- | src/LYStrings.c | 12 | ||||
-rw-r--r-- | src/LYrcFile.c | 206 | ||||
-rw-r--r-- | src/LYrcFile.h | 3 | ||||
-rw-r--r-- | src/chrtrans/makefile.in | 3 | ||||
-rw-r--r-- | src/makefile.in | 3 |
7 files changed, 133 insertions, 106 deletions
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 26d8ebc6..ea6845d3 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.c,v 1.167 2012/02/10 01:10:22 tom Exp $ + * $LynxId: LYReadCFG.c,v 1.168 2012/08/13 00:09:29 tom Exp $ */ #ifndef NO_RULES #include <HTRules.h> @@ -1904,9 +1904,10 @@ typedef BOOL (optidx_set_t)[NOPTS_]; * For simple (boolean, string, integer, time) values, set the corresponding * configuration variable. */ -void LYSetConfigValue(const char *name, +BOOL LYSetConfigValue(const char *name, const char *param) { + BOOL changed = TRUE; char *value = NULL; Config_Type *tbl = lookup_config(name); ParseUnionPtr q = ParseUnionOf(tbl); @@ -2012,9 +2013,12 @@ void LYSetConfigValue(const char *name, break; default: + changed = FALSE; break; } FREE(value); + + return changed; } /* diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h index ff95d13a..94928e80 100644 --- a/src/LYReadCFG.h +++ b/src/LYReadCFG.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.h,v 1.26 2011/06/06 00:08:21 tom Exp $ + * $LynxId: LYReadCFG.h,v 1.27 2012/08/13 00:09:50 tom Exp $ */ #ifndef LYREADCFG_H #define LYREADCFG_H @@ -64,7 +64,7 @@ extern "C" { list_ptr, char *number); extern void reload_read_cfg(void); /* implemented in LYMain.c */ - extern void LYSetConfigValue(const char *name, const char *value); + extern BOOL LYSetConfigValue(const char *name, const char *value); extern void LYSetTextDomain(void); #ifdef __cplusplus diff --git a/src/LYStrings.c b/src/LYStrings.c index 615c2fc8..47570b33 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.205 2012/02/13 00:33:02 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.206 2012/08/13 00:18:00 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -37,6 +37,7 @@ #ifdef USE_CMD_LOGGING #include <LYReadCFG.h> +#include <LYrcFile.h> #endif #include <LYShowInfo.h> @@ -6182,8 +6183,13 @@ int LYReadCmdKey(int mode) *tmp++ = '\0'; tmp = LYSkipBlanks(tmp); } - CTRACE((tfp, "LYSetConfigValue(%s, %s)\n", src, tmp)); - LYSetConfigValue(src, tmp); + if (LYSetConfigValue(src, tmp)) { + CTRACE((tfp, "LYSetConfigValue(%s, %s)\n", src, tmp)); + } else if (LYsetRcValue(src, tmp)) { + CTRACE((tfp, "LYsetRcValue(%s, %s)\n", src, tmp)); + } else { + CTRACE((tfp, "?? set ignored %s\n", src)); + } } break; } diff --git a/src/LYrcFile.c b/src/LYrcFile.c index 5b909053..db361455 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -1,4 +1,4 @@ -/* $LynxId: LYrcFile.c,v 1.88 2010/12/11 14:20:53 tom Exp $ */ +/* $LynxId: LYrcFile.c,v 1.89 2012/08/13 00:30:44 tom Exp $ */ #include <HTUtils.h> #include <HTFTP.h> #include <LYUtils.h> @@ -650,6 +650,113 @@ static Config_Type *lookup_config(const char *name) return tbl; } +BOOL LYsetRcValue(const char *name, const char *param) +{ + char MBM_line[256]; + char *notes; + int n; + Config_Type *tbl; + ParseUnionPtr q; + BOOL changed = TRUE; + char *value = NULL; + + StrAllocCopy(value, param); + value = LYSkipBlanks(value); + CTRACE2(TRACE_CFG, (tfp, "LYrcFile %s:%s\n", name, value)); + + tbl = lookup_config(name); + if (tbl->name == 0) { + const char *special = RC_MULTI_BOOKMARK; + + if (!strncasecomp(name, special, (int) strlen(special))) { + tbl = lookup_config(special); + } + /* + * lynx ignores unknown keywords. + * This includes known keywords where there is no ENABLE_LYNXRC. + */ + if (tbl->name == 0) { + CTRACE((tfp, "LYrcFile: ignored %s=%s\n", name, value)); + return FALSE; + } + } + + q = ParseUnionOf(tbl); + switch (tbl->type) { + case CONF_BOOL: + if (q->set_value != 0) + *(q->set_value) = getBool(value); + break; + + case CONF_FUN: + if (q->fun_value != 0) + (*(q->fun_value)) (value); + break; + + case CONF_ARRAY: + for (n = 0; tbl->strings[n] != 0; ++n) { + if (!strcasecomp(value, tbl->strings[n])) { + *(q->int_value) = n; + break; + } + } + break; + + case CONF_ENUM: + if (tbl->table != 0) + LYgetEnum(tbl->table, value, q->int_value); + break; + + case CONF_INT: + if (q->int_value != 0) { + int ival; + + if (1 == sscanf(value, "%d", &ival)) + *(q->int_value) = ival; + } + break; + + case CONF_LIS: + if (q->str_value != 0) { + if (*(q->str_value) != NULL) + StrAllocCat(*(q->str_value), ","); + StrAllocCat(*(q->str_value), value); + } + break; + + case CONF_MBM: + for (n = 1; n <= MBM_V_MAXFILES; n++) { + sprintf(MBM_line, "multi_bookmark%c", LYindex2MBM(n)); + + if (!strcasecomp(name, MBM_line)) { + if ((notes = strchr(value, ',')) != 0) { + *notes++ = '\0'; + LYTrimTrailing(value); + notes = LYSkipBlanks(notes); + } else { + notes = value + strlen(value); + } + StrAllocCopy(MBM_A_subbookmark[n], value); + StrAllocCopy(MBM_A_subdescript[n], notes); + break; + } + } + break; + + case CONF_STR: + if (q->str_value != 0) + StrAllocCopy(*(q->str_value), value); + break; + + default: + changed = FALSE; + break; + } + FREE(value); + + return changed; +} + /* Read and process user options. If the passed-in fp is NULL, open the * regular user defaults file for reading, otherwise use fp which has to be a * file open for reading. - kw @@ -658,8 +765,6 @@ void read_rc(FILE *fp) { char *buffer = NULL; char rcfile[LY_MAXPATH]; - char MBM_line[256]; - int n; if (!fp) { /* @@ -678,9 +783,7 @@ void read_rc(FILE *fp) * Process the entries. */ while (LYSafeGets(&buffer, fp) != NULL) { - char *name, *value, *notes; - Config_Type *tbl; - ParseUnionPtr q; + char *name, *value; /* Most lines in the config file are comment lines. Weed them out * now. Also, leading whitespace is ok, so trim it. @@ -699,96 +802,7 @@ void read_rc(FILE *fp) } *value++ = '\0'; LYTrimTrailing(name); - value = LYSkipBlanks(value); - CTRACE2(TRACE_CFG, (tfp, "LYrcFile %s:%s\n", name, value)); - - tbl = lookup_config(name); - if (tbl->name == 0) { - const char *special = RC_MULTI_BOOKMARK; - - if (!strncasecomp(name, special, (int) strlen(special))) { - tbl = lookup_config(special); - } - /* - * lynx ignores unknown keywords. - * This includes known keywords where there is no ENABLE_LYNXRC. - */ - if (tbl->name == 0) { - CTRACE((tfp, "LYrcFile: ignored %s=%s\n", name, value)); - continue; - } - } - - q = ParseUnionOf(tbl); - switch (tbl->type) { - case CONF_BOOL: - if (q->set_value != 0) - *(q->set_value) = getBool(value); - break; - - case CONF_FUN: - if (q->fun_value != 0) - (*(q->fun_value)) (value); - break; - - case CONF_ARRAY: - for (n = 0; tbl->strings[n] != 0; ++n) { - if (!strcasecomp(value, tbl->strings[n])) { - *(q->int_value) = n; - break; - } - } - break; - - case CONF_ENUM: - if (tbl->table != 0) - LYgetEnum(tbl->table, value, q->int_value); - break; - - case CONF_INT: - if (q->int_value != 0) { - int ival; - - if (1 == sscanf(value, "%d", &ival)) - *(q->int_value) = ival; - } - break; - - case CONF_LIS: - if (q->str_value != 0) { - if (*(q->str_value) != NULL) - StrAllocCat(*(q->str_value), ","); - StrAllocCat(*(q->str_value), value); - } - break; - - case CONF_MBM: - for (n = 1; n <= MBM_V_MAXFILES; n++) { - sprintf(MBM_line, "multi_bookmark%c", LYindex2MBM(n)); - - if (!strcasecomp(name, MBM_line)) { - if ((notes = strchr(value, ',')) != 0) { - *notes++ = '\0'; - LYTrimTrailing(value); - notes = LYSkipBlanks(notes); - } else { - notes = value + strlen(value); - } - StrAllocCopy(MBM_A_subbookmark[n], value); - StrAllocCopy(MBM_A_subdescript[n], notes); - break; - } - } - break; - - case CONF_STR: - if (q->str_value != 0) - StrAllocCopy(*(q->str_value), value); - break; - - case CONF_NIL: - break; - } + LYsetRcValue(name, value); } LYCloseInput(fp); diff --git a/src/LYrcFile.h b/src/LYrcFile.h index ab82f576..c84ab3d5 100644 --- a/src/LYrcFile.h +++ b/src/LYrcFile.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYrcFile.h,v 1.42 2011/06/12 00:30:05 tom Exp $ + * $LynxId: LYrcFile.h,v 1.43 2012/08/13 00:16:53 tom Exp $ */ #ifndef LYRCFILE_H #define LYRCFILE_H @@ -283,6 +283,7 @@ extern Config_Enum tbl_transfer_rate[]; extern Config_Enum tbl_user_mode[]; extern BOOL LYgetEnum(Config_Enum * table, const char *name, int *result); +extern BOOL LYsetRcValue(const char *name, const char *param); extern BOOL will_save_rc(const char *name); extern const char *LYputEnum(Config_Enum * table, int value); extern int enable_lynxrc(char *value); diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in index f6dd49c4..1b7c2416 100644 --- a/src/chrtrans/makefile.in +++ b/src/chrtrans/makefile.in @@ -1,4 +1,4 @@ -# $LynxId: makefile.in,v 1.37 2010/09/19 19:30:58 tom Exp $ +# $LynxId: makefile.in,v 1.38 2012/08/12 23:54:57 tom Exp $ # # Makefile for the makeuctb and unicode tables. # @@ -9,6 +9,7 @@ SHELL = @CONFIG_SHELL@ prefix = @prefix@ exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = $(srcdir) diff --git a/src/makefile.in b/src/makefile.in index 79860e46..a18b6537 100644 --- a/src/makefile.in +++ b/src/makefile.in @@ -1,4 +1,4 @@ -# $LynxId: makefile.in,v 1.68 2012/08/04 13:15:18 tom Exp $ +# $LynxId: makefile.in,v 1.69 2012/08/12 23:54:35 tom Exp $ # template-makefile for Lynx src directory SHELL = @CONFIG_SHELL@ @@ -6,6 +6,7 @@ CDPATH = . @SET_MAKE@ prefix = @prefix@ +datarootdir = @datarootdir@ exec_prefix = @exec_prefix@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ |