]>
Commit | Line | Data |
---|---|---|
eafdeb9c JB |
1 | --- lynx2-8-6/src/LYUtils.c.orig 2006-11-07 02:27:15.000000000 +0100 |
2 | +++ lynx2-8-6/src/LYUtils.c 2007-02-25 21:41:54.554627431 +0100 | |
3 | @@ -5330,7 +5330,9 @@ | |
4 | const char *fname) | |
2bafab09 | 5 | { |
6 | char *home = NULL; | |
eafdeb9c JB |
7 | + char *etc_dir = getenv("ETC_DIR"); |
8 | const char *file = fname; | |
9 | + char *file2 = NULL; | |
2bafab09 | 10 | int len; |
11 | ||
12 | /* | |
eafdeb9c | 13 | @@ -5353,13 +5355,39 @@ |
2bafab09 | 14 | /* |
eafdeb9c | 15 | * Set up home string and length. - FM |
2bafab09 | 16 | */ |
17 | - StrAllocCopy(home, Home_Dir()); | |
18 | - | |
19 | #ifdef VMS | |
20 | #define NO_HOMEPATH "Error:" | |
21 | #else | |
22 | #define NO_HOMEPATH "/error" | |
23 | #endif /* VMS */ | |
24 | + | |
25 | + if (etc_dir) { | |
26 | + StrAllocCopy(home, etc_dir); | |
27 | + if (!non_empty(etc_dir)) | |
28 | + /* | |
29 | + * Home_Dir() has a bug if this ever happens. - FM | |
30 | + */ | |
31 | + StrAllocCopy(etc_dir, NO_HOMEPATH); | |
32 | + | |
33 | + len = fbuffer_size - (strlen(etc_dir) + 1); | |
34 | + if (len <= 0) { | |
35 | + /* | |
36 | + * Buffer is smaller than or only big enough for the home path. | |
37 | + * Load what fits of the home path and return. This will fail, | |
38 | + * but we need something in the buffer. - FM | |
39 | + */ | |
40 | + LYstrncpy(fbuffer, etc_dir, (fbuffer_size - 1)); | |
41 | + return; | |
42 | + } | |
43 | + /* | |
44 | + * Check whether we have a subdirectory path or just a filename. - FM | |
45 | + */ | |
46 | + file2 = (strncmp(file, "./", 2) ? file : file + 2); | |
47 | + sprintf(fbuffer, "%s/%.*s", etc_dir, len, | |
48 | + (strncmp(file2, ".", 1) ? file2 : (file2+1))); | |
49 | + } else { | |
50 | + StrAllocCopy(home, Home_Dir()); | |
51 | + | |
52 | if (!non_empty(home)) | |
53 | /* | |
eafdeb9c JB |
54 | * Home_Dir() has a bug if this ever happens. - FM |
55 | @@ -5416,6 +5444,7 @@ | |
92cdea70 | 56 | (StrNCmp(file, "./", 2) ? file : (file + 2))); |
2bafab09 | 57 | #endif /* VMS */ |
58 | FREE(home); | |
59 | + } | |
60 | } | |
61 | ||
62 | /* |