changeset 30050:0a8c6cafd7cc

maint: use "m_" prefix for member variables in oct-env.h. * oct-env.cc, oct-env.h: use "m_" prefix for member variables class env.
author Rik <rik@octave.org>
date Wed, 25 Aug 2021 20:16:05 -0700
parents bffdbda91d28
children 997cf870a963
files liboctave/system/oct-env.cc liboctave/system/oct-env.h
diffstat 2 files changed, 54 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/system/oct-env.cc	Wed Aug 25 17:28:52 2021 -0700
+++ b/liboctave/system/oct-env.cc	Wed Aug 25 20:16:05 2021 -0700
@@ -70,9 +70,9 @@
   namespace sys
   {
     env::env (void)
-      : follow_symbolic_links (true), verbatim_pwd (true),
-        current_directory (), prog_name (), prog_invocation_name (),
-        user_name (), host_name ()
+      : m_follow_symbolic_links (true), m_verbatim_pwd (true),
+        m_current_directory (), m_prog_name (), m_prog_invocation_name (),
+        m_user_name (), m_host_name ()
     {
       // Get a real value for the current directory.
       do_getcwd ();
@@ -83,16 +83,16 @@
       do_get_host_name ();
     }
 
-    env *env::instance = nullptr;
+    env *env::m_instance = nullptr;
 
     bool
     env::instance_ok (void)
     {
       bool retval = true;
 
-      if (! instance)
+      if (! m_instance)
         {
-          instance = new env ();
+          m_instance = new env ();
           singleton_cleanup_list::add (cleanup_instance);
         }
 
@@ -103,105 +103,105 @@
     env::polite_directory_format (const std::string& name)
     {
       return (instance_ok ())
-        ? instance->do_polite_directory_format (name) : "";
+        ? m_instance->do_polite_directory_format (name) : "";
     }
 
     bool
     env::absolute_pathname (const std::string& s)
     {
       return (instance_ok ())
-        ? instance->do_absolute_pathname (s) : false;
+        ? m_instance->do_absolute_pathname (s) : false;
     }
 
     bool
     env::rooted_relative_pathname (const std::string& s)
     {
       return (instance_ok ())
-        ? instance->do_rooted_relative_pathname (s) : false;
+        ? m_instance->do_rooted_relative_pathname (s) : false;
     }
 
     std::string
     env::base_pathname (const std::string& s)
     {
       return (instance_ok ())
-        ? instance->do_base_pathname (s) : "";
+        ? m_instance->do_base_pathname (s) : "";
     }
 
     std::string
     env::make_absolute (const std::string& s, const std::string& dot_path)
     {
       return (instance_ok ())
-        ? instance->do_make_absolute (s, dot_path) : "";
+        ? m_instance->do_make_absolute (s, dot_path) : "";
     }
 
     std::string
     env::get_current_directory ()
     {
       return (instance_ok ())
-        ? instance->do_getcwd () : "";
+        ? m_instance->do_getcwd () : "";
     }
 
     std::string
     env::get_home_directory ()
     {
       return (instance_ok ())
-        ? instance->do_get_home_directory () : "";
+        ? m_instance->do_get_home_directory () : "";
     }
 
     std::string
     env::get_temp_directory ()
     {
       return (instance_ok ())
-        ? instance->do_get_temp_directory () : "";
+        ? m_instance->do_get_temp_directory () : "";
     }
 
     std::string
     env::get_user_config_directory ()
     {
       return (instance_ok ())
-        ? instance->do_get_user_config_directory () : "";
+        ? m_instance->do_get_user_config_directory () : "";
     }
 
     std::string
     env::get_user_data_directory ()
     {
       return (instance_ok ())
-        ? instance->do_get_user_data_directory () : "";
+        ? m_instance->do_get_user_data_directory () : "";
     }
 
     std::string
     env::get_program_name (void)
     {
       return (instance_ok ())
-        ? instance->prog_name : "";
+        ? m_instance->m_prog_name : "";
     }
 
     std::string
     env::get_program_invocation_name (void)
     {
       return (instance_ok ())
-        ? instance->prog_invocation_name : "";
+        ? m_instance->m_prog_invocation_name : "";
     }
 
     void
     env::set_program_name (const std::string& s)
     {
       if (instance_ok ())
-        instance->do_set_program_name (s);
+        m_instance->do_set_program_name (s);
     }
 
     std::string
     env::get_user_name (void)
     {
       return (instance_ok ())
-        ? instance->do_get_user_name () : "";
+        ? m_instance->do_get_user_name () : "";
     }
 
     std::string
     env::get_host_name (void)
     {
       return (instance_ok ())
-        ? instance->do_get_host_name () : "";
+        ? m_instance->do_get_host_name () : "";
     }
 
     std::string
@@ -294,7 +294,7 @@
     env::getenv (const std::string& name)
     {
       return (instance_ok ())
-        ? instance->do_getenv (name) : "";
+        ? m_instance->do_getenv (name) : "";
     }
 
     void
@@ -315,7 +315,7 @@
     env::chdir (const std::string& newdir)
     {
       return (instance_ok ())
-        ? instance->do_chdir (newdir) : false;
+        ? m_instance->do_chdir (newdir) : false;
     }
 
     void
@@ -334,16 +334,16 @@
           // instead of passing S.c_str () which only exists as long as the
           // string object S.
 
-          prog_invocation_name
+          m_prog_invocation_name
             = octave_set_program_name_wrapper (strsave (s.c_str ()));
 
           std::size_t pos
-            = prog_invocation_name.find_last_of (sys::file_ops::dir_sep_chars ());
+            = m_prog_invocation_name.find_last_of (sys::file_ops::dir_sep_chars ());
 
           // Also keep a shortened version of the program name.
-          prog_name = (pos == std::string::npos
-                       ? prog_invocation_name
-                       : prog_invocation_name.substr (pos+1));
+          m_prog_name = (pos == std::string::npos
+                         ? m_prog_invocation_name
+                         : m_prog_invocation_name.substr (pos+1));
 
           initialized = true;
         }
@@ -518,13 +518,13 @@
     std::string
     env::do_getcwd () const
     {
-      if (! follow_symbolic_links)
-        current_directory = "";
+      if (! m_follow_symbolic_links)
+        m_current_directory = "";
 
-      if (verbatim_pwd || current_directory.empty ())
-        current_directory = sys::getcwd ();
+      if (m_verbatim_pwd || m_current_directory.empty ())
+        m_current_directory = sys::getcwd ();
 
-      return current_directory;
+      return m_current_directory;
     }
 
     // This value is not cached because it can change while Octave is
@@ -560,29 +560,29 @@
     std::string
     env::do_get_user_name (void) const
     {
-      if (user_name.empty ())
+      if (m_user_name.empty ())
         {
           sys::password pw = sys::password::getpwuid (sys::getuid ());
 
-          user_name = (pw ? pw.name () : "unknown");
+          m_user_name = (pw ? pw.name () : "unknown");
         }
 
-      return user_name;
+      return m_user_name;
     }
 
     std::string
     env::do_get_host_name (void) const
     {
-      if (host_name.empty ())
+      if (m_host_name.empty ())
         {
           char hostname[1024];
 
           int status = octave_gethostname_wrapper (hostname, 1023);
 
-          host_name = (status < 0) ? "unknown" : hostname;
+          m_host_name = (status < 0) ? "unknown" : hostname;
         }
 
-      return host_name;
+      return m_host_name;
     }
 
     std::string
@@ -601,15 +601,15 @@
 
       std::string tmp;
 
-      if (follow_symbolic_links)
+      if (m_follow_symbolic_links)
         {
-          if (current_directory.empty ())
+          if (m_current_directory.empty ())
             do_getcwd ();
 
-          if (current_directory.empty ())
+          if (m_current_directory.empty ())
             tmp = newdir;
           else
-            tmp = do_make_absolute (newdir, current_directory);
+            tmp = do_make_absolute (newdir, m_current_directory);
 
           // Get rid of trailing directory separator.
           if (tmp.length () > 1 && sys::file_ops::is_dir_sep (tmp.back ()))
@@ -617,7 +617,7 @@
 
           if (! sys::chdir (tmp))
             {
-              current_directory = tmp;
+              m_current_directory = tmp;
               retval = true;
             }
         }
--- a/liboctave/system/oct-env.h	Wed Aug 25 17:28:52 2021 -0700
+++ b/liboctave/system/oct-env.h	Wed Aug 25 20:16:05 2021 -0700
@@ -134,29 +134,30 @@
       void error (const std::string&) const;
 
       // The real thing.
-      static env *instance;
+      static env *m_instance;
 
-      static void cleanup_instance (void) { delete instance; instance = nullptr; }
+      static void cleanup_instance (void)
+      { delete m_instance; m_instance = nullptr; }
 
       // TRUE means follow symbolic links that point to directories just
       // as if they are real directories.
-      bool follow_symbolic_links;
+      bool m_follow_symbolic_links;
 
       // TRUE means that pwd always give verbatim directory, regardless
       // of symbolic link following.
-      bool verbatim_pwd;
+      bool m_verbatim_pwd;
 
       // Where are we?
-      mutable std::string current_directory;
+      mutable std::string m_current_directory;
 
       // Etc.
-      mutable std::string prog_name;
+      mutable std::string m_prog_name;
 
-      mutable std::string prog_invocation_name;
+      mutable std::string m_prog_invocation_name;
 
-      mutable std::string user_name;
+      mutable std::string m_user_name;
 
-      mutable std::string host_name;
+      mutable std::string m_host_name;
     };
   }
 }