changeset 14153:06aa17228706 stable

use gnulib::fopen * oct-md5.cc (oct_md5_file): Use gnulib::fopen. * kpse.cc: Don't play #define tricks with fopen. (fopen): Delete. (xfopen): Use gnulib::fopen. * oct-parse.yy (get_help_from_file): Use gnulib::fopen.
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2012 09:41:16 -0500
parents 933bf1b4ab29
children f15007a6c642
files liboctave/kpse.cc liboctave/oct-md5.cc src/oct-parse.yy
diffstat 3 files changed, 7 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/kpse.cc	Fri Jan 06 08:29:11 2012 -0500
+++ b/liboctave/kpse.cc	Fri Jan 06 09:41:16 2012 -0500
@@ -225,10 +225,6 @@
 #define DEBUGF4(str, e1, e2, e3, e4)                                    \
   DEBUGF_START (); gnulib::fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
 
-#undef fopen
-#define fopen kpse_fopen_trace
-static FILE *fopen (const char *filename, const char *mode);
-
 #endif /* not NO_DEBUG */
 
 #ifdef KPSE_DEBUG
@@ -362,11 +358,15 @@
 
   assert (! filename.empty () && mode);
 
-  f = fopen (filename.c_str (), mode);
+  f = gnulib::fopen (filename.c_str (), mode);
 
   if (! f)
     FATAL_PERROR (filename.c_str ());
 
+  if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
+    DEBUGF3 ("fopen (%s, %s) => 0x%lx\n", filename.c_str (), mode,
+             reinterpret_cast<unsigned long> (f));
+
   return f;
 }
 
@@ -2446,28 +2446,6 @@
 }
 #endif
 
-/* Help the user discover what's going on.  */
-
-#ifdef KPSE_DEBUG
-
-/* If the real definitions of fopen or fclose are macros, we lose -- the
-   #undef won't restore them. */
-
-static FILE *
-fopen (const char *filename, const char *mode)
-{
-#undef fopen
-  FILE *ret = fopen (filename, mode);
-
-  if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
-    DEBUGF3 ("fopen (%s, %s) => 0x%lx\n", filename, mode,
-             reinterpret_cast<unsigned long> (ret));
-
-  return ret;
-}
-
-#endif
-
 /* Implementation of a linked list of strings.  */
 
 /* Add the new string STR to the end of the list L.  */
--- a/liboctave/oct-md5.cc	Fri Jan 06 08:29:11 2012 -0500
+++ b/liboctave/oct-md5.cc	Fri Jan 06 09:41:16 2012 -0500
@@ -62,7 +62,7 @@
 {
   std::string retval;
 
-  FILE *ifile = fopen (file.c_str (), "rb");
+  FILE *ifile = gnulib::fopen (file.c_str (), "rb");
 
   if (ifile)
     {
--- a/src/oct-parse.yy	Fri Jan 06 08:29:11 2012 -0500
+++ b/src/oct-parse.yy	Fri Jan 06 09:41:16 2012 -0500
@@ -3612,7 +3612,7 @@
     {
       symbol_found = true;
 
-      FILE *fptr = fopen (file.c_str (), "r");
+      FILE *fptr = gnulib::fopen (file.c_str (), "r");
 
       if (fptr)
         {