diff options
| author | Thomas E. Dickey <dickey@invisible-island.net> | 2013-10-24 00:21:20 -0400 |
|---|---|---|
| committer | Thomas E. Dickey <dickey@invisible-island.net> | 2013-10-24 00:21:20 -0400 |
| commit | 44b428bb55ea5ccb0739bcca2131934a676b6344 (patch) | |
| tree | efc9743290c05ee951fcd67a995e000d1fa14ff7 /src | |
| parent | 663ccb75029b218a6426112cfaa17d798c03bc03 (diff) | |
| download | lynx-snapshots-44b428bb55ea5ccb0739bcca2131934a676b6344.tar.gz | |
snapshot of project "lynx", label v2-8-8dev_16w
Diffstat (limited to 'src')
| -rw-r--r-- | src/LYOptions.c | 26 | ||||
| -rw-r--r-- | src/LYReadCFG.c | 15 | ||||
| -rw-r--r-- | src/LYStyle.c | 95 | ||||
| -rw-r--r-- | src/LYUtils.c | 18 | ||||
| -rw-r--r-- | src/LYUtils.h | 40 |
5 files changed, 132 insertions, 62 deletions
diff --git a/src/LYOptions.c b/src/LYOptions.c index afaab4c7..d725f0d2 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -1,4 +1,4 @@ -/* $LynxId: LYOptions.c,v 1.161 2013/10/22 08:10:03 tom Exp $ */ +/* $LynxId: LYOptions.c,v 1.163 2013/10/24 00:08:39 tom Exp $ */ #include <HTUtils.h> #include <HTFTP.h> #include <HTTP.h> /* 'reloading' flag */ @@ -2522,6 +2522,10 @@ void build_lss_enum(HTList *list) color_style_list = list; } +/* + * Find the current lss-file in the list, to get the default value for the + * form. + */ static int get_color_style_value(void) { int result = 0; @@ -2543,7 +2547,25 @@ static int get_color_style_value(void) } return result; } + +/* + * Return the pathname found in the given list-item. + */ +static char *get_color_style_config(int code) +{ + char *result = 0; + + if (LYuse_color_style) { + LSS_NAMES *obj; + + if ((obj = HTList_objectAt(color_style_list, code - 1)) != 0) { + result = obj->actual; + } + } + 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. @@ -2963,7 +2985,7 @@ int postoptions(DocInfo *newdoc) && GetOptValues(color_style_values, data[i].value, &code)) { if (code) { LYuse_color_style = TRUE; - StrAllocCopy(lynx_lss_file, color_style_values[code].LongName); + StrAllocCopy(lynx_lss_file, get_color_style_config(code)); reinit_color_styles(); } else { LYuse_color_style = FALSE; diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 419fd833..4adbd664 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYReadCFG.c,v 1.177 2013/10/21 23:13:30 tom Exp $ + * $LynxId: LYReadCFG.c,v 1.178 2013/10/23 21:26:29 tom Exp $ */ #ifndef NO_RULES #include <HTRules.h> @@ -648,6 +648,12 @@ static int color_fun(char *value) parse_color(value); return 0; } + +static int lynx_lss_file_fun(char *value) +{ + add_to_lss_list(value, NULL); + return 0; +} #endif #ifdef USE_DEFAULT_COLORS @@ -673,13 +679,6 @@ 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) { diff --git a/src/LYStyle.c b/src/LYStyle.c index 277a7e0b..669620dd 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYStyle.c,v 1.85 2013/10/23 09:23:57 tom Exp $ + * $LynxId: LYStyle.c,v 1.87 2013/10/23 23:58:52 tom Exp $ * * character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) @@ -817,53 +817,81 @@ void update_color_style(void) static char *find_lss_file(const char *nominal) { + const char *dftfile = default_lss_file; char *result = 0; + char *path = 0; + char *head = 0; + char *leaf; + char *item; if (non_empty(nominal)) { StrAllocCopy(result, nominal); + /* - * Look for it in the home directory - if there is a tilde to expand. + * Look for it in as-is - first expanding any tilde. */ LYTildeExpand(&result, TRUE); if (!LYCanReadFile(result)) { - char *dftfile = default_lss_file; - char *leaf; + const char *cfg_path; + char *list = 0; + BOOLEAN found = FALSE; /* - * If not, try finding it in the same directory as the compiled-in - * location of the default lss-file. + * Now try in the config-path. */ - if (strcmp(nominal, dftfile) && - (leaf = LYPathLeaf(dftfile)) != dftfile) { - char *head = 0; + if ((cfg_path = LYGetEnv("LYNX_CFG_PATH")) == NULL) + cfg_path = LYNX_CFG_PATH; + + StrAllocCopy(list, cfg_path); + path = list; + while ((item = LYstrsep(&path, PATH_SEPARATOR)) != 0) { + if (isEmpty(item)) + continue; + HTSprintf0(&result, "%s%s%s", item, FILE_SEPARATOR, nominal); + LYTildeExpand(&result, TRUE); + if (LYCanReadFile(result)) { + found = TRUE; + break; + } + } + FREE(list); + if (!found) { + /* + * If not, try finding it in the same directory as the + * compiled-in location of the default file. + */ StrAllocCopy(head, dftfile); - head[leaf - dftfile] = '\0'; - StrAllocCopy(result, head); - StrAllocCat(result, nominal); - FREE(head); + if (strcmp(nominal, dftfile) && + (leaf = LYPathLeaf(head)) != head) { + + head[leaf - head] = '\0'; + StrAllocCopy(result, head); + StrAllocCat(result, nominal); - if (!LYCanReadFile(result)) { - FREE(result); + 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); + 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 + } } } + FREE(head); return result; } @@ -919,11 +947,16 @@ void init_color_styles(char **from_cmdline, const char *default_styles) */ if (list_of_lss_files == 0) { char *source = 0; + char *config; StrAllocCopy(source, default_styles); - while ((cp = strtok(source, ";")) != 0) { - add_to_lss_list(cp, NULL); - source = 0; + config = source; + while ((cp = LYstrsep(&config, ";")) != 0) { + char *target; + + target = find_lss_file(LYPathLeaf(cp)); + if (target != 0) + add_to_lss_list(cp, target); } FREE(source); } @@ -980,7 +1013,7 @@ void reinit_color_styles(void) } } for (cs = 0; cs < HTL_num_lexemes; ++cs) { - html_src_clean_item(cs); + html_src_clean_item((HTlexeme) cs); } free_colorstylestuff(); style_readFromFile(lynx_lss_file); diff --git a/src/LYUtils.c b/src/LYUtils.c index cdb68d56..f2aa60cf 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.256 2013/10/23 09:12:22 tom Exp $ + * $LynxId: LYUtils.c,v 1.257 2013/10/23 22:14:03 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -5132,11 +5132,11 @@ static char *HomeEnv(void) if (result == 0) { /* Windows Vista/7 */ if ((head = LYGetEnv("USERPROFILE")) != 0) { - HTSprintf0(&temp, "%s%sDocuments", head, PATHSEP_STR); + HTSprintf0(&temp, "%s%sDocuments", head, FILE_SEPARATOR); result = CheckDir(temp); if (result == 0) { /* Windows 2000 */ - HTSprintf0(&temp, "%s%sMy Documents", head, PATHSEP_STR); + HTSprintf0(&temp, "%s%sMy Documents", head, FILE_SEPARATOR); result = CheckDir(temp); } } @@ -5145,7 +5145,7 @@ static char *HomeEnv(void) if (result == 0) { if ((head = LYGetEnv("HOMEDRIVE")) != 0) { if ((leaf = LYGetEnv("HOMEPATH")) != 0) { - HTSprintf0(&temp, "%s%s%s", head, PATHSEP_STR, leaf); + HTSprintf0(&temp, "%s%s%s", head, FILE_SEPARATOR, leaf); result = CheckDir(temp); } } @@ -5161,12 +5161,12 @@ static char *HomeEnv(void) result = CheckDir(LYGetEnv("TMP")); if (result == 0) { if ((head = LYGetEnv("SystemDrive")) != 0) { - HTSprintf0(&temp, "%s%s", head, PATHSEP_STR); + HTSprintf0(&temp, "%s%s", head, FILE_SEPARATOR); result = CheckDir(temp); } } if (result == 0) - result = CheckDir("C:" PATHSEP_STR); + result = CheckDir("C:" FILE_SEPARATOR); } #endif @@ -5787,7 +5787,7 @@ static BOOL IsOurSymlink(const char *name) if (cutoff != 0) { HTSprintf0(&clone, "%.*s%s%s", (int) (cutoff - name), - name, PATHSEP_STR, buffer); + name, FILE_SEPARATOR, buffer); FREE(buffer); buffer = clone; } @@ -6950,7 +6950,7 @@ void LYAddPathSep(char **path) && ((temp = *path) != 0) && (len = strlen(temp)) != 0 && !LYIsPathSep(temp[len - 1])) { - StrAllocCat(*path, PATHSEP_STR); + StrAllocCat(*path, FILE_SEPARATOR); } } @@ -6966,7 +6966,7 @@ void LYAddPathSep0(char *path) && (len = strlen(path)) != 0 && (len < LY_MAXPATH - 2) && !LYIsPathSep(path[len - 1])) { - strcat(path, PATHSEP_STR); + strcat(path, FILE_SEPARATOR); } } diff --git a/src/LYUtils.h b/src/LYUtils.h index 3545b6f8..ac6609bb 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -1,4 +1,4 @@ -/* $LynxId: LYUtils.h,v 1.92 2013/10/19 00:55:45 tom Exp $ */ +/* $LynxId: LYUtils.h,v 1.94 2013/10/23 22:14:03 tom Exp $ */ #ifndef LYUTILS_H #define LYUTILS_H @@ -29,24 +29,31 @@ #ifdef __cplusplus extern "C" { #endif + #ifdef VMS #define HTSYS_name(path) HTVMS_name("", path) #define HTSYS_purge(path) HTVMS_purge(path) #define HTSYS_remove(path) HTVMS_remove(path) #endif /* VMS */ + #if defined(USE_DOS_DRIVES) #define HTSYS_name(path) HTDOS_name(path) #endif + #ifndef HTSYS_name #define HTSYS_name(path) path #endif + #ifndef HTSYS_purge #define HTSYS_purge(path) /* nothing */ #endif + #ifndef HTSYS_remove #define HTSYS_remove(path) remove(path) #endif + #define LYIsPipeCommand(s) ((s)[0] == '|') + #ifdef VMS #define TTY_DEVICE "tt:" #define NUL_DEVICE "nl:" @@ -76,23 +83,30 @@ extern "C" { #endif /* __CYGWIN__ */ #endif /* DOSPATH */ #endif /* VMS */ + /* See definitions in src/LYCharVals.h. The hardcoded values... This prohibits binding C-c and C-g. Maybe it is better to remove this? */ #define LYCharIsINTERRUPT_HARD(ch) \ ((ch) == LYCharINTERRUPT1 || ch == LYCharINTERRUPT2) + #define LYCharIsINTERRUPT(ch) \ (LYCharIsINTERRUPT_HARD(ch) || LKC_TO_LAC(keymap,ch) == LYK_INTERRUPT) + #define LYCharIsINTERRUPT_NO_letter(ch) \ (LYCharIsINTERRUPT(ch) && !isprint(ch)) + #if defined(USE_DOS_DRIVES) -#define PATHSEP_STR "\\" +#define PATH_SEPARATOR ";" +#define FILE_SEPARATOR "\\" #define LYIsPathSep(ch) ((ch) == '/' || (ch) == '\\') #define LYIsDosDrive(s) (isalpha(UCH((s)[0])) && (s)[1] == ':') #else -#define PATHSEP_STR "/" +#define PATH_SEPARATOR ":" +#define FILE_SEPARATOR "/" #define LYIsPathSep(ch) ((ch) == '/') #define LYIsDosDrive(s) FALSE /* really nothing */ #endif + #ifdef USE_ADDRLIST_PAGE #define LYIsListpageTitle(name) \ (!strcmp((name), LIST_PAGE_TITLE) || \ @@ -101,10 +115,12 @@ extern "C" { #define LYIsListpageTitle(name) \ (!strcmp((name), LIST_PAGE_TITLE)) #endif + #define LYIsTilde(ch) ((ch) == '~') #define LYIsHtmlSep(ch) ((ch) == '/') #define findPoundSelector(address) strchr(address, '#') #define restorePoundSelector(pound) if ((pound) != NULL) *(pound) = '#' + extern BOOL strn_dash_equ(const char *p1, const char *p2, int len); extern BOOLEAN LYAddSchemeForURL(char **AllocatedString, const char *default_scheme); extern BOOLEAN LYCachedTemp(char *result, char **cached); @@ -227,7 +243,7 @@ extern "C" { extern int xsystem(char *cmd); #endif -/* Keeping track of User Interface Pages: */ + /* Keeping track of User Interface Pages: */ typedef enum { UIP_UNKNOWN = -1 ,UIP_HISTORY = 0 @@ -302,18 +318,18 @@ extern "C" { extern int win32_check_interrupt(void); #endif -/* - * Whether or not the status line must be shown. - */ + /* + * Whether or not the status line must be shown. + */ extern BOOLEAN mustshow; #define _statusline(msg) mustshow = TRUE, statusline(msg) -/* - * For is_url(). - * - * Universal document id types (see LYCheckForProxyURL) - */ + /* + * For is_url(). + * + * Universal document id types (see LYCheckForProxyURL) + */ typedef enum { NOT_A_URL_TYPE = 0, UNKNOWN_URL_TYPE = 1, /* must be nonzero */ |