aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2/util.c
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2009-02-21 14:25:19 -0300
committerLeandro A. F. Pereira <leandro@hardinfo.org>2009-02-21 14:25:19 -0300
commit14acc526ad11fdd2d7192a4028828e178d563225 (patch)
tree7241c08bc4102182e9a6f8e752e5bf74cd89deff /hardinfo2/util.c
parent24f42f01ec0d22760af841dfcdbcbbfe5966a8b0 (diff)
If find_program() fails, bail out to g_find_program_in_path() to search the user's path too.
Diffstat (limited to 'hardinfo2/util.c')
-rw-r--r--hardinfo2/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/hardinfo2/util.c b/hardinfo2/util.c
index 2e8facd4..d4ae0971 100644
--- a/hardinfo2/util.c
+++ b/hardinfo2/util.c
@@ -55,11 +55,10 @@ gchar *find_program(gchar *program_name)
"/usr/local/bin", "/usr/local/sbin",
NULL };
+ /* we don't need to call stat() every time: cache the results */
if (!cache) {
cache = g_hash_table_new(g_str_hash, g_str_equal);
- }
-
- if ((temp = g_hash_table_lookup(cache, program_name))) {
+ } else if ((temp = g_hash_table_lookup(cache, program_name))) {
return g_strdup(temp);
}
@@ -74,7 +73,8 @@ gchar *find_program(gchar *program_name)
g_free(temp);
}
- return NULL;
+ /* search has failed; use GLib's search (which uses $PATH env var) */
+ return g_find_program_in_path(program_name);
}
gchar *seconds_to_string(unsigned int seconds)