author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2015年04月09日 06:53:29 +0300 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019年10月03日 16:36:00 -0600 |
commit | 5321cf5e8d2c9c840595f0bf715c4101ee32059e (patch) | |
tree | 3cbc30988c17211d00822f3441b88f904c86a67f /src | |
parent | 3e2d6642b63dd03911fdbc6343142ac5b1936edc (diff) | |
download | src-highlite-5321cf5e8d2c9c840595f0bf715c4101ee32059e.tar.gz |
-rw-r--r-- | src/source-highlight.cc | 41 |
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 |