nemiver r895 - in trunk: . src/common src/persp/dbgperspective
- From: dodji svn gnome org
- To: svn-commits-list gnome org
- Subject: nemiver r895 - in trunk: . src/common src/persp/dbgperspective
- Date: Sat, 26 Jul 2008 23:54:47 +0000 (UTC)
Author: dodji
Date: Sat Jul 26 23:54:47 2008
New Revision: 895
URL: http://svn.gnome.org/viewvc/nemiver?rev=895&view=rev
Log:
Second attempt at fixing #543797
* src/common/nmv-env.cc,h:
(build_path_to_executable): new helper to build an absolute path
to an executable by searching in the $PATH env variable.
* src/persp/dbgperspective/nmv-dbg-perspective.cc:
(DBGPerspective::execute_program): don't forget to lookup
executables - that have relative paths - in directories pointed
to by the $PATH environment variable.
Modified:
trunk/ChangeLog
trunk/src/common/nmv-env.cc
trunk/src/common/nmv-env.h
trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
Modified: trunk/src/common/nmv-env.cc
==============================================================================
--- trunk/src/common/nmv-env.cc (original)
+++ trunk/src/common/nmv-env.cc Sat Jul 26 23:54:47 2008
@@ -358,6 +358,18 @@
return result;
}
+
+bool
+build_path_to_executable (const UString &a_exe_name,
+ UString &a_path_to_exe)
+{
+ UString path = Glib::find_program_in_path (a_exe_name);
+ if (path.empty ())
+ return false;
+ a_path_to_exe = path;
+ return true;
+}
+
NEMIVER_END_NAMESPACE (env)
NEMIVER_END_NAMESPACE (common)
NEMIVER_END_NAMESPACE (nemiver)
Modified: trunk/src/common/nmv-env.h
==============================================================================
--- trunk/src/common/nmv-env.h (original)
+++ trunk/src/common/nmv-env.h Sat Jul 26 23:54:47 2008
@@ -1,7 +1,7 @@
/* -*- Mode: C++; indent-tabs-mode:nil; c-basic-offset:4; -*- */
-/*Copyright (c) 2005-2006 Dodji Seketeli
- *
+// Author: Dodji Seketeli
+/*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
@@ -78,6 +78,9 @@
NEMIVER_API UString build_path_to_help_file (const UString &a_file_name);
+NEMIVER_API bool build_path_to_executable (const UString &a_exe_name,
+ UString &a_exe_path);
+
NEMIVER_END_NAMESPACE (env)
NEMIVER_END_NAMESPACE (common)
NEMIVER_END_NAMESPACE (nemiver)
Modified: trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc (original)
+++ trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc Sat Jul 26 23:54:47 2008
@@ -4672,12 +4672,25 @@
<< IDebugger::state_to_string (dbg_engine->get_state ())
<< "'") ;
- // first of all, make sure the program we want to debug exists.
- if (!Glib::file_test (a_prog, Glib::FILE_TEST_IS_REGULAR)) {
- UString msg;
- msg.printf (_("Could not find file %s"), a_prog.c_str ());
- ui_utils::display_error (msg);
- return;
+ UString prog = a_prog;
+ // First of all, make sure the program we want to debug exists.
+ // Note that Nemiver can be invoked like 'nemiver fooprog'
+ // or 'nemiver /absolute/path/to/fooprog'.
+ // In the former form, nemiver will look for the program
+ // in the $PATH environment variable and use the resulting absolute
+ // path.
+ // In the later form, nemiver will just use the absolute path.
+ if (!Glib::file_test (prog, Glib::FILE_TEST_IS_REGULAR)) {
+ // We didn't find prog. If the path to prog is not absolute,
+ // look it up in the directories pointed to by the
+ // $PATH environment variable.
+ if (Glib::path_is_absolute (prog.raw ())
+ || !env::build_path_to_executable (prog, prog)) {
+ UString msg;
+ msg.printf (_("Could not find file %s"), prog.c_str ());
+ ui_utils::display_error (msg);
+ return;
+ }
}
// if the engine is running, stop it.
@@ -4687,12 +4700,12 @@
}
// close old file that might be open
- if (a_close_opened_files && a_prog != m_priv->prog_path && get_n_pages ()) {
+ if (a_close_opened_files && prog != m_priv->prog_path && get_n_pages ()) {
close_opened_files () ;
}
vector<UString> args = a_args.split (" ") ;
- args.insert (args.begin (), a_prog) ;
+ args.insert (args.begin (), prog) ;
vector<UString> source_search_dirs = a_cwd.split (" ") ;
// delete old breakpoints, if any.
@@ -4739,7 +4752,7 @@
attached_to_target_signal ().emit (true) ;
- m_priv->prog_path = a_prog ;
+ m_priv->prog_path = prog ;
m_priv->prog_args = a_args ;
m_priv->prog_cwd = a_cwd ;
m_priv->env_variables = a_env ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]