diff -rubB t1lib.orig/lib/type1/t1io.c t1lib/lib/type1/t1io.c --- t1lib.orig/lib/type1/t1io.c Thu Apr 19 01:23:16 2001 +++ t1lib/lib/type1/t1io.c Thu May 31 21:38:13 2001 @@ -53,6 +53,24 @@ #include "t1stdio.h" #include "t1hdigit.h" +/* Introduce KPATHSEA debugging macros to be able to do FOPEN tracing. + There are name conflicts so we don't include debug.h from kpathsea + - janl 31/5/2001 */ + +/* Test if a bit is on. */ +#define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit))) +/* fopen/fclose calls */ +#define KPSE_DEBUG_FOPEN 2 +/* Bit vector defining what we should trace. */ +extern unsigned kpathsea_debug; +/* A printf for the debugging. */ +#define DEBUGF_START() do { fputs ("kdebug:", stderr) +#define DEBUGF_END() fflush (stderr); } while (0) +#define DEBUGF2(str, e1, e2) \ + DEBUGF_START (); fprintf (stderr, str, e1, e2); DEBUGF_END () +#define DEBUGF3(str, e1, e2, e3) \ + DEBUGF_START (); fprintf (stderr, str, e1, e2, e3); DEBUGF_END () + /* we define this to switch to decrypt-debugging mode. The stream of decrypted bytes will be written to stdout! This contains binary charstring data */ @@ -96,7 +114,6 @@ F_FILE *of = &TheFile; char c; - Decrypt = 0; eexec_startOK=0; eexec_endOK=0; @@ -104,11 +121,15 @@ /* We know we are only reading */ /* cygwin32 also needs the binary flag to be set */ #if defined(MSDOS) | defined(_WIN32) | defined (__EMX__) - if ((of->fd=open(fn, O_RDONLY | O_BINARY)) < 0) return NULL; + of->fd=open(fn, O_RDONLY | O_BINARY); #else - if ((of->fd=open(fn, O_RDONLY)) < 0) return NULL; + of->fd=open(fn, O_RDONLY); #endif + if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN)) + DEBUGF3 ("open(%s, %s) => 0x%x\n", fn, mode, (int) of->fd); + if (of->fd == -1) return NULL; + /* We check for pfa/pfb file */ if (read( of->fd, &c, 1)!=1) { close( of->fd); @@ -373,9 +394,16 @@ int T1Close(f) /* Close the file */ F_FILE *f; /* Stream descriptor */ { + int c; + if (f->b_base == NULL) return 0; /* already closed */ f->b_base = NULL; /* no valid stream */ - return close(f->fd); + c = close(f->fd); + + if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN)) + DEBUGF2 ("close(0x%x) => %d\n", f, c); + + return c; } /* end Close */