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