changeset 30125:8dd5da409418

maint: use "m_" prefix for member variables in file c-file-ptr-stream.h. * c-file-ptr-stream.cc, c-file-ptr-stream.h, oct-procbuf.cc: Use "m_" prefix for member variables in classes c_file_ptr_buf, c_file_ptr_stream, c_zfile_ptr_buf.
author Rik <rik@octave.org>
date Mon, 06 Sep 2021 11:40:04 -0700
parents 041dbcd1f93b
children bb9da37c0a8b
files libinterp/corefcn/c-file-ptr-stream.cc libinterp/corefcn/c-file-ptr-stream.h libinterp/corefcn/oct-procbuf.cc
diffstat 3 files changed, 86 insertions(+), 84 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/c-file-ptr-stream.cc	Mon Sep 06 11:30:45 2021 -0700
+++ b/libinterp/corefcn/c-file-ptr-stream.cc	Mon Sep 06 11:40:04 2021 -0700
@@ -57,8 +57,8 @@
 c_file_ptr_buf::int_type
 c_file_ptr_buf::overflow (int_type c)
 {
-  if (f)
-    return (c != traits_type::eof ()) ? std::fputc (c, f) : flush ();
+  if (m_f)
+    return (c != traits_type::eof ()) ? std::fputc (c, m_f) : flush ();
   else
     return traits_type::not_eof (c);
 }
@@ -66,12 +66,12 @@
 c_file_ptr_buf::int_type
 c_file_ptr_buf::underflow_common (bool bump)
 {
-  if (f)
+  if (m_f)
     {
-      int_type c = std::fgetc (f);
+      int_type c = std::fgetc (m_f);
 
       if (! bump && c != traits_type::eof ())
-        ungetc (c, f);
+        ungetc (c, m_f);
 
       return c;
     }
@@ -82,15 +82,15 @@
 c_file_ptr_buf::int_type
 c_file_ptr_buf::pbackfail (int_type c)
 {
-  return ((c != traits_type::eof () && f)
-          ? ungetc (c, f) : traits_type::not_eof (c));
+  return ((c != traits_type::eof () && m_f)
+          ? ungetc (c, m_f) : traits_type::not_eof (c));
 }
 
 std::streamsize
 c_file_ptr_buf::xsputn (const char *s, std::streamsize n)
 {
-  if (f)
-    return std::fwrite (s, 1, n, f);
+  if (m_f)
+    return std::fwrite (s, 1, n, m_f);
   else
     return 0;
 }
@@ -98,8 +98,8 @@
 std::streamsize
 c_file_ptr_buf::xsgetn (char *s, std::streamsize n)
 {
-  if (f)
-    return std::fread (s, 1, n, f);
+  if (m_f)
+    return std::fread (s, 1, n, m_f);
   else
     return 0;
 }
@@ -118,11 +118,11 @@
                          std::ios::seekdir dir,
                          std::ios::openmode)
 {
-  if (f)
+  if (m_f)
     {
-      octave_fseeko_wrapper (f, offset, seekdir_to_whence (dir));
+      octave_fseeko_wrapper (m_f, offset, seekdir_to_whence (dir));
 
-      return octave_ftello_wrapper (f);
+      return octave_ftello_wrapper (m_f);
     }
   else
     return 0;
@@ -131,11 +131,11 @@
 std::streampos
 c_file_ptr_buf::seekpos (std::streampos offset, std::ios::openmode)
 {
-  if (f)
+  if (m_f)
     {
-      octave_fseeko_wrapper (f, offset, SEEK_SET);
+      octave_fseeko_wrapper (m_f, offset, SEEK_SET);
 
-      return octave_ftello_wrapper (f);
+      return octave_ftello_wrapper (m_f);
     }
   else
     return 0;
@@ -152,7 +152,7 @@
 int
 c_file_ptr_buf::flush (void)
 {
-  return f ? std::fflush (f) : traits_type::eof ();
+  return m_f ? std::fflush (m_f) : traits_type::eof ();
 }
 
 int
@@ -162,10 +162,10 @@
 
   flush ();
 
-  if (f)
+  if (m_f)
     {
-      retval = cf (f);
-      f = nullptr;
+      retval = m_cf (m_f);
+      m_f = nullptr;
     }
 
   return retval;
@@ -174,19 +174,19 @@
 int
 c_file_ptr_buf::seek (off_t offset, int origin)
 {
-  return f ? octave_fseeko_wrapper (f, offset, origin) : -1;
+  return m_f ? octave_fseeko_wrapper (m_f, offset, origin) : -1;
 }
 
 off_t
 c_file_ptr_buf::tell (void)
 {
-  return f ? octave_ftello_wrapper (f) : -1;
+  return m_f ? octave_ftello_wrapper (m_f) : -1;
 }
 
 int
-c_file_ptr_buf::file_close (FILE *f)
+c_file_ptr_buf::file_close (FILE *m_f)
 {
-  return std::fclose (f);
+  return std::fclose (m_f);
 }
 
 #if defined (HAVE_ZLIB)
@@ -201,8 +201,8 @@
 c_zfile_ptr_buf::int_type
 c_zfile_ptr_buf::overflow (int_type c)
 {
-  if (f)
-    return (c != traits_type::eof ()) ? gzputc (f, c) : flush ();
+  if (m_f)
+    return (c != traits_type::eof ()) ? gzputc (m_f, c) : flush ();
   else
     return traits_type::not_eof (c);
 }
@@ -210,12 +210,12 @@
 c_zfile_ptr_buf::int_type
 c_zfile_ptr_buf::underflow_common (bool bump)
 {
-  if (f)
+  if (m_f)
     {
-      int_type c = gzgetc (f);
+      int_type c = gzgetc (m_f);
 
       if (! bump && c != traits_type::eof ())
-        gzungetc (c, f);
+        gzungetc (c, m_f);
 
       return c;
     }
@@ -226,15 +226,15 @@
 c_zfile_ptr_buf::int_type
 c_zfile_ptr_buf::pbackfail (int_type c)
 {
-  return ((c != traits_type::eof () && f)
-          ? gzungetc (c, f) : traits_type::not_eof (c));
+  return ((c != traits_type::eof () && m_f)
+          ? gzungetc (c, m_f) : traits_type::not_eof (c));
 }
 
 std::streamsize
 c_zfile_ptr_buf::xsputn (const char *s, std::streamsize n)
 {
-  if (f)
-    return gzwrite (f, s, n);
+  if (m_f)
+    return gzwrite (m_f, s, n);
   else
     return 0;
 }
@@ -242,8 +242,8 @@
 std::streamsize
 c_zfile_ptr_buf::xsgetn (char *s, std::streamsize n)
 {
-  if (f)
-    return gzread (f, s, n);
+  if (m_f)
+    return gzread (m_f, s, n);
   else
     return 0;
 }
@@ -255,11 +255,11 @@
 {
   // FIXME
 #if 0
-  if (f)
+  if (m_f)
     {
-      gzseek (f, offset, seekdir_to_whence (dir));
+      gzseek (m_f, offset, seekdir_to_whence (dir));
 
-      return gztell (f);
+      return gztell (m_f);
     }
   else
     return 0;
@@ -272,11 +272,11 @@
 {
   // FIXME
 #if 0
-  if (f)
+  if (m_f)
     {
-      gzseek (f, offset, SEEK_SET);
+      gzseek (m_f, offset, SEEK_SET);
 
-      return gztell (f);
+      return gztell (m_f);
     }
   else
     return 0;
@@ -299,7 +299,7 @@
   // something other than 0 for the second argument to gzflush and
   // checking the return value, etc.?
 
-  return f ? gzflush (f, 0) : traits_type::eof ();
+  return m_f ? gzflush (m_f, 0) : traits_type::eof ();
 }
 
 int
@@ -309,10 +309,10 @@
 
   flush ();
 
-  if (f)
+  if (m_f)
     {
-      retval = cf (f);
-      f = nullptr;
+      retval = m_cf (m_f);
+      m_f = nullptr;
     }
 
   return retval;
--- a/libinterp/corefcn/c-file-ptr-stream.h	Mon Sep 06 11:30:45 2021 -0700
+++ b/libinterp/corefcn/c-file-ptr-stream.h	Mon Sep 06 11:40:04 2021 -0700
@@ -46,10 +46,10 @@
 
   typedef int (*close_fcn) (FILE *);
 
-  FILE *stdiofile (void) { return f; }
+  FILE *stdiofile (void) { return m_f; }
 
-  c_file_ptr_buf (FILE *f_arg, close_fcn cf_arg = file_close)
-    : std::streambuf (), f (f_arg), cf (cf_arg)
+  c_file_ptr_buf (FILE *f, close_fcn cf = file_close)
+    : std::streambuf (), m_f (f), m_cf (cf)
   { }
 
   // No copying!
@@ -84,21 +84,21 @@
 
   int buf_close (void);
 
-  int file_number () const { return f ? fileno (f) : -1; }
+  int file_number () const { return m_f ? fileno (m_f) : -1; }
 
   int seek (off_t offset, int origin);
 
   off_t tell (void);
 
-  void clear (void) { if (f) clearerr (f); }
+  void clear (void) { if (m_f) clearerr (m_f); }
 
-  static int file_close (FILE *f);
+  static int file_close (FILE *m_f);
 
 protected:
 
-  FILE *f;
+  FILE *m_f;
 
-  close_fcn cf;
+  close_fcn m_cf;
 
 private:
 
@@ -113,8 +113,10 @@
 {
 public:
 
-  c_file_ptr_stream (FILE_T f, typename BUF_T::close_fcn cf = BUF_T::file_close)
-    : STREAM_T (nullptr), buf (new BUF_T (f, cf)) { STREAM_T::init (buf); }
+  c_file_ptr_stream (FILE_T m_f,
+                     typename BUF_T::close_fcn m_cf = BUF_T::file_close)
+    : STREAM_T (nullptr), m_buf (new BUF_T (m_f, m_cf))
+  { STREAM_T::init (m_buf); }
 
   // No copying!
 
@@ -122,22 +124,22 @@
 
   c_file_ptr_stream& operator = (const c_file_ptr_stream&) = delete;
 
-  ~c_file_ptr_stream (void) { delete buf; buf = nullptr; }
+  ~c_file_ptr_stream (void) { delete m_buf; m_buf = nullptr; }
 
-  BUF_T * rdbuf (void) { return buf; }
+  BUF_T * rdbuf (void) { return m_buf; }
 
-  void stream_close (void) { if (buf) buf->buf_close (); }
+  void stream_close (void) { if (m_buf) m_buf->buf_close (); }
 
   int seek (off_t offset, int origin)
-  { return buf ? buf->seek (offset, origin) : -1; }
+  { return m_buf ? m_buf->seek (offset, origin) : -1; }
 
-  off_t tell (void) { return buf ? buf->tell () : -1; }
+  off_t tell (void) { return m_buf ? m_buf->tell () : -1; }
 
-  void clear (void) { if (buf) buf->clear (); STREAM_T::clear (); }
+  void clear (void) { if (m_buf) m_buf->clear (); STREAM_T::clear (); }
 
 private:
 
-  BUF_T *buf;
+  BUF_T *m_buf;
 };
 
 typedef c_file_ptr_stream<std::istream, FILE *, c_file_ptr_buf>
@@ -159,10 +161,10 @@
 
   typedef int (*close_fcn) (gzFile);
 
-  gzFile stdiofile (void) { return f; }
+  gzFile stdiofile (void) { return m_f; }
 
-  c_zfile_ptr_buf (gzFile f_arg, close_fcn cf_arg = file_close)
-    : std::streambuf (), f (f_arg), cf (cf_arg)
+  c_zfile_ptr_buf (gzFile f, close_fcn cf = file_close)
+    : std::streambuf (), m_f (f), m_cf (cf)
   { }
 
   // No copying!
@@ -200,19 +202,19 @@
   int file_number () const { return -1; }
 
   int seek (off_t offset, int origin)
-  { return f ? gzseek (f, offset, origin) >= 0 : -1; }
+  { return m_f ? gzseek (m_f, offset, origin) >= 0 : -1; }
 
-  off_t tell (void) { return f ? gztell (f) : -1; }
+  off_t tell (void) { return m_f ? gztell (m_f) : -1; }
 
-  void clear (void) { if (f) gzclearerr (f); }
+  void clear (void) { if (m_f) gzclearerr (m_f); }
 
-  static int file_close (gzFile f) { return ::gzclose (f); }
+  static int file_close (gzFile m_f) { return ::gzclose (m_f); }
 
 protected:
 
-  gzFile f;
+  gzFile m_f;
 
-  close_fcn cf;
+  close_fcn m_cf;
 
 private:
 
--- a/libinterp/corefcn/oct-procbuf.cc	Mon Sep 06 11:30:45 2021 -0700
+++ b/libinterp/corefcn/oct-procbuf.cc	Mon Sep 06 11:40:04 2021 -0700
@@ -83,9 +83,9 @@
   if (is_open ())
     return 0;
 
-  f = (octave::popen (command, (mode & std::ios::in) ? "r" : "w"));
+  m_f = (octave::popen (command, (mode & std::ios::in) ? "r" : "w"));
 
-  if (! f)
+  if (! m_f)
     return 0;
 
   // Oops... popen doesn't return the associated pid, so fake it for now
@@ -95,7 +95,7 @@
   m_open_p = true;
 
   if (mode & std::ios::out)
-    ::setvbuf (f, nullptr, _IOLBF, BUFSIZ);
+    ::setvbuf (m_f, nullptr, _IOLBF, BUFSIZ);
 
   return this;
 
@@ -138,7 +138,7 @@
 
       while (procbuf_list)
         {
-          FILE *fp = procbuf_list->f;
+          FILE *fp = procbuf_list->m_f;
 
           if (fp)
             {
@@ -162,10 +162,10 @@
       return nullptr;
     }
 
-  f = (::fdopen (parent_end, (mode & std::ios::in) ? "r" : "w"));
+  m_f = (::fdopen (parent_end, (mode & std::ios::in) ? "r" : "w"));
 
   if (mode & std::ios::out)
-    ::setvbuf (f, nullptr, _IOLBF, BUFSIZ);
+    ::setvbuf (m_f, nullptr, _IOLBF, BUFSIZ);
 
   m_open_p = true;
 
@@ -186,10 +186,10 @@
 {
 #if defined (__CYGWIN__) || defined (__MINGW32__) || defined (_MSC_VER)
 
-  if (f)
+  if (m_f)
     {
-      m_wstatus = octave::pclose (f);
-      f = 0;
+      m_wstatus = octave::pclose (m_f);
+      m_f = 0;
     }
 
   m_open_p = false;
@@ -198,7 +198,7 @@
 
 #elif defined (HAVE_UNISTD_H)
 
-  if (f)
+  if (m_f)
     {
       pid_t wait_pid;
 
@@ -216,7 +216,7 @@
             }
         }
 
-      if (status == 0 && std::fclose (f) == 0)
+      if (status == 0 && std::fclose (m_f) == 0)
         {
           using namespace std;
 
@@ -227,7 +227,7 @@
           while (wait_pid == -1 && errno == EINTR);
         }
 
-      f = nullptr;
+      m_f = nullptr;
     }
 
   m_open_p = false;