From 6aab099baa7bab76d187f21b85e74848e25a8110 Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 4 Feb 2021 22:56:53 +0100 Subject: svg-flatten: Be even smarter locating usvg --- svg-flatten/src/main.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/svg-flatten/src/main.cpp b/svg-flatten/src/main.cpp index 53ce19b..2b996f3 100644 --- a/svg-flatten/src/main.cpp +++ b/svg-flatten/src/main.cpp @@ -340,18 +340,25 @@ int main(int argc, char **argv) { } string dpi_str = to_string(dpi); + const char *homedir; + if ((homedir = getenv("HOME")) == NULL) { + homedir = getpwuid(getuid())->pw_dir; + } + string homedir_s(homedir); + string loc_in_home = homedir_s + "/.cargo/bin/usvg"; + const char *command_line[] = {nullptr, "--keep-named-groups", "--dpi", dpi_str.c_str(), barf.c_str(), frob.c_str(), NULL}; bool found_usvg = false; int usvg_rc=-1; - for (int i=0; i<2; i++) { - const char *homedir; - if ((homedir = getenv("HOME")) == NULL) { - homedir = getpwuid(getuid())->pw_dir; - } - string homedir_s(homedir); - string loc_in_home = homedir_s + "/.cargo/bin/usvg"; - + for (int i=0; i<3; i++) { + const char *usvg_envvar; if (i == 0) { + if ((usvg_envvar = getenv("USVG")) == NULL) { + continue; + } else { + command_line[0] = "usvg"; + } + } else if (i == 1) { command_line[0] = "usvg"; } else { command_line[0] = loc_in_home.c_str(); -- cgit