changeset 10278:4a278982c0fe

use gnulib progname module
author John W. Eaton <jwe@octave.org>
date Mon, 08 Feb 2010 17:30:23 -0500
parents 703038d648f1
children 323c9cbbd02a
files ChangeLog bootstrap.conf liboctave/ChangeLog liboctave/oct-env.cc liboctave/oct-env.h
diffstat 5 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-08  John W. Eaton  <jwe@octave.org>
+
+	* bootstrap.conf (gnulib_modules): Include progname in the list.
+
 2010-02-08  Jaroslav Hajek  <highegg@gmail.com>
 
 	* NEWS: Update.
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -34,6 +34,7 @@
   sleep
   nanosleep
   pathmax
+  progname
   readlink
   rename
   rmdir
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,11 @@
+2010-02-08  John W. Eaton  <jwe@octave.org>
+
+	* oct-env.cc (octave_env::prog_invocation_name): Rename from
+	program_invocation_name.  Change all uses.
+	(octave_env::prog_name): Rename from program_name.  Change all uses.
+	(octave_env::do_set_program_name): Call ::set_program_name
+	function from gnulib.
+
 2010-02-08  Jaroslav Hajek  <highegg@gmail.com>
 
 	* idx-vector.h (idx_vector::idx_base_rep::sort_idx): New pure virtual
--- a/liboctave/oct-env.cc
+++ b/liboctave/oct-env.cc
@@ -50,6 +50,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "progname.h"
+
 #include "file-ops.h"
 #include "lo-error.h"
 #include "lo-sysdep.h"
@@ -60,7 +62,7 @@
 
 octave_env::octave_env (void)
   : follow_symbolic_links (true), verbatim_pwd (true),
-    current_directory (), program_name (), program_invocation_name (),
+    current_directory (), prog_name (), prog_invocation_name (),
     user_name (), host_name ()
 {
   // Get a real value for the current directory.
@@ -146,14 +148,14 @@
 octave_env::get_program_name (void)
 {
   return (instance_ok ())
-    ? instance->program_name : std::string ();
+    ? instance->prog_name : std::string ();
 }
 
 std::string
 octave_env::get_program_invocation_name (void)
 {
   return (instance_ok ())
-    ? instance->program_invocation_name : std::string ();
+    ? instance->prog_invocation_name : std::string ();
 }
 
 void
@@ -212,13 +214,18 @@
 void
 octave_env::do_set_program_name (const std::string& s) const
 {
-  program_invocation_name = s;
+  // For gnulib.
+  ::set_program_name (s.c_str ());
+
+  // Let gnulib strip off things like the "lt-" prefix from libtool.
+  prog_invocation_name = program_name;
 
   size_t pos
-    = program_invocation_name.find_last_of (file_ops::dir_sep_chars ());
+    = prog_invocation_name.find_last_of (file_ops::dir_sep_chars ());
 
-  program_name = (pos == std::string::npos)
-    ? program_invocation_name : program_invocation_name.substr (pos+1);
+  // Also keep a shortened version of the program name.
+  prog_name = (pos == std::string::npos)
+    ? prog_invocation_name : prog_invocation_name.substr (pos+1);
 }
 
 // Return a pretty pathname.  If the first part of the pathname is the
--- a/liboctave/oct-env.h
+++ b/liboctave/oct-env.h
@@ -127,9 +127,9 @@
   mutable std::string current_directory;
 
   // Etc.
-  mutable std::string program_name;
+  mutable std::string prog_name;
 
-  mutable std::string program_invocation_name;
+  mutable std::string prog_invocation_name;
 
   mutable std::string user_name;