comparison liboctave/kpse.cc @ 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 a31c926fb0d5
children 583d3d6f6fde
comparison
equal deleted inserted replaced
14152:933bf1b4ab29 14153:06aa17228706
223 #define DEBUGF3(str, e1, e2, e3) \ 223 #define DEBUGF3(str, e1, e2, e3) \
224 DEBUGF_START (); gnulib::fprintf (stderr, str, e1, e2, e3); DEBUGF_END () 224 DEBUGF_START (); gnulib::fprintf (stderr, str, e1, e2, e3); DEBUGF_END ()
225 #define DEBUGF4(str, e1, e2, e3, e4) \ 225 #define DEBUGF4(str, e1, e2, e3, e4) \
226 DEBUGF_START (); gnulib::fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END () 226 DEBUGF_START (); gnulib::fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
227 227
228 #undef fopen
229 #define fopen kpse_fopen_trace
230 static FILE *fopen (const char *filename, const char *mode);
231
232 #endif /* not NO_DEBUG */ 228 #endif /* not NO_DEBUG */
233 229
234 #ifdef KPSE_DEBUG 230 #ifdef KPSE_DEBUG
235 static unsigned int kpathsea_debug = 0; 231 static unsigned int kpathsea_debug = 0;
236 #endif 232 #endif
360 { 356 {
361 FILE *f; 357 FILE *f;
362 358
363 assert (! filename.empty () && mode); 359 assert (! filename.empty () && mode);
364 360
365 f = fopen (filename.c_str (), mode); 361 f = gnulib::fopen (filename.c_str (), mode);
366 362
367 if (! f) 363 if (! f)
368 FATAL_PERROR (filename.c_str ()); 364 FATAL_PERROR (filename.c_str ());
365
366 if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
367 DEBUGF3 ("fopen (%s, %s) => 0x%lx\n", filename.c_str (), mode,
368 reinterpret_cast<unsigned long> (f));
369 369
370 return f; 370 return f;
371 } 371 }
372 372
373 /* A single (key,value) pair. */ 373 /* A single (key,value) pair. */
2442 int ret = gnulib::closedir (d); 2442 int ret = gnulib::closedir (d);
2443 2443
2444 if (ret != 0) 2444 if (ret != 0)
2445 FATAL ("closedir failed"); 2445 FATAL ("closedir failed");
2446 } 2446 }
2447 #endif
2448
2449 /* Help the user discover what's going on. */
2450
2451 #ifdef KPSE_DEBUG
2452
2453 /* If the real definitions of fopen or fclose are macros, we lose -- the
2454 #undef won't restore them. */
2455
2456 static FILE *
2457 fopen (const char *filename, const char *mode)
2458 {
2459 #undef fopen
2460 FILE *ret = fopen (filename, mode);
2461
2462 if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
2463 DEBUGF3 ("fopen (%s, %s) => 0x%lx\n", filename, mode,
2464 reinterpret_cast<unsigned long> (ret));
2465
2466 return ret;
2467 }
2468
2469 #endif 2447 #endif
2470 2448
2471 /* Implementation of a linked list of strings. */ 2449 /* Implementation of a linked list of strings. */
2472 2450
2473 /* Add the new string STR to the end of the list L. */ 2451 /* Add the new string STR to the end of the list L. */