X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8414a40c52191d4c7cfeea74df22d9d64cbec415..63e1921d0be4956ab729735189ccf637773a7e27:/src/tiff/tools/fax2ps.c diff --git a/src/tiff/tools/fax2ps.c b/src/tiff/tools/fax2ps.c index 1c9f72e6a1..36deb7fd3b 100644 --- a/src/tiff/tools/fax2ps.c +++ b/src/tiff/tools/fax2ps.c @@ -35,10 +35,18 @@ # include #endif +#ifdef HAVE_FCNTL_H +# include +#endif + #ifdef HAVE_IO_H # include #endif +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" float defxres = 204.; /* default x resolution (pixels/inch) */ @@ -269,9 +277,9 @@ findPage(TIFF* tif, uint16 pageNumber) uint16 pn = (uint16) -1; uint16 ptotal = (uint16) -1; if (GetPageNumber(tif)) { - while (pn != pageNumber && TIFFReadDirectory(tif) && GetPageNumber(tif)) + while (pn != (pageNumber-1) && TIFFReadDirectory(tif) && GetPageNumber(tif)) ; - return (pn == pageNumber); + return (pn == (pageNumber-1)); } else return (TIFFSetDirectory(tif, (tdir_t)(pageNumber-1))); } @@ -376,10 +384,12 @@ main(int argc, char** argv) fd = tmpfile(); if (fd == NULL) { - fprintf(stderr, "Could not create temporary file, exiting.\n"); - fclose(fd); + fprintf(stderr, "Could not obtain temporary file.\n"); exit(-2); } +#if defined(HAVE_SETMODE) && defined(O_BINARY) + setmode(fileno(stdin), O_BINARY); +#endif while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0) write(fileno(fd), buf, n); lseek(fileno(fd), 0, SEEK_SET); @@ -430,3 +440,10 @@ usage(int code) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */