fix datadir search - include user settings - src-highlite.git - src-highlite

index : src-highlite.git
src-highlite
summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2015年04月09日 06:53:29 +0300
committerTom Tromey <tom@tromey.com>2019年10月03日 16:36:00 -0600
commit5321cf5e8d2c9c840595f0bf715c4101ee32059e (patch)
tree3cbc30988c17211d00822f3441b88f904c86a67f /src
parent3e2d6642b63dd03911fdbc6343142ac5b1936edc (diff)
downloadsrc-highlite-5321cf5e8d2c9c840595f0bf715c4101ee32059e.tar.gz
fix datadir search - include user settings
at fileutils.cc: - removed redundant logic when searching data files. - now using start_path as fallback data-dir for all cases instead of only for the case where path is not given and input_file_name doesn't have a path. at source-highlight.cc - refined the logic of data-dir search. now it starts with retrieveDataDir(), overridden with --data-dir, and fallback to <bin-dir>../share/source-highlight/ (previously it was effectively never using retrieveDataDir(), so it was ignoring user settings within $HOME, env vars, etc)
Diffstat (limited to 'src')
-rw-r--r--src/source-highlight.cc 41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/source-highlight.cc b/src/source-highlight.cc
index 4f813e6..4feba30 100644
--- a/src/source-highlight.cc
+++ b/src/source-highlight.cc
@@ -203,34 +203,35 @@ int main(int argc, char * argv[]) {
// the default for output format is html
outputFormat = args_info.out_format_arg;
- if (args_info.data_dir_given) {
- dataDir = args_info.data_dir_arg;
- }
-
if (args_info.output_dir_given) {
outputDir = args_info.output_dir_arg;
}
/*
- the starting default path to search for files is computed at
- run-time: it is
- the path of the binary + ".." + RELATIVEDATADIR
- this should make the package relocable (i.e., not stuck
- with a fixed installation directory).
+ The starting default path is from Settings::retrieveDataDir() which
+ does the heavy lifting of finding the data dir by looking at config-time
+ values, environment variables, user settings at $HOME, etc. See settings.h
+
+ From here, invoking with --data-dir=<my-datadir> overrides the above value.
+
+ We also use a fallback dir which is calculated in runtime relative to this
+ executable (by default <executable-dir>/../share/source-highlight/).
+
+ this should make the package relocatable (i.e., not stuck with a fixed
+ installation directory).
Of course, the GNU standards for installation directories
should be followed, but this is not a problem if you use
configure and make install features.
- If no path is specified in the running program we go back to
- the absolute datadir.
- */
- // this is defined in fileutil.cc
- string prefix_dir = get_file_path(argv[0]);
- if (prefix_dir.size())
- start_path = get_file_path(argv[0]) + RELATIVEDATADIR;
- else
- start_path = Settings::retrieveDataDir();
-
- // if datadir is not specified, we rely on start_path?
+ */
+
+ dataDir = Settings::retrieveDataDir();
+ if (args_info.data_dir_given)
+ dataDir = args_info.data_dir_arg;
+
+ // start_path is global fallback for dataDir - used at fileutil.h
+ string executable_dir = get_file_path(argv[0]);
+ if (executable_dir.size())
+ start_path = executable_dir + RELATIVEDATADIR;
try {
// initialize map files
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月28日 00:28:37 +0000

AltStyle によって変換されたページ (->オリジナル) /