diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-10-12 08:37:25 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-10-12 08:37:25 +0200 |
commit | 4ee01bbc747ce85b5ccfeed3e934dfb76fb14482 (patch) | |
tree | cde2ab7ff286056127ca4d7929ece9dc0b0216ca | |
parent | 358811630686460d6b0a96021a1bcb4c3124fb03 (diff) | |
download | mupdf-4ee01bbc747ce85b5ccfeed3e934dfb76fb14482.tar.xz |
merged seokgyos win32 fixes
-rw-r--r-- | base/error.c | 3 | ||||
-rw-r--r-- | filter/filec.c | 6 | ||||
-rw-r--r-- | filter/filer.c | 8 | ||||
-rw-r--r-- | filter/jbig2d.c | 14 | ||||
-rw-r--r-- | include/fitz/base.h | 5 | ||||
-rw-r--r-- | include/fitz/sysdep.h | 36 | ||||
-rw-r--r-- | mupdf/open.c | 6 |
7 files changed, 58 insertions, 20 deletions
diff --git a/base/error.c b/base/error.c index 33954e07..b00157e3 100644 --- a/base/error.c +++ b/base/error.c @@ -50,6 +50,9 @@ fz_throw0(const char *func, const char *file, int line, char *fmt, ...) eo->msg[sizeof(eo->msg) - 1] = '\0'; va_end(ap); + if (getenv("BOMB")) + fz_abort(eo); + return eo; } diff --git a/filter/filec.c b/filter/filec.c index 0c4d034a..34db4d12 100644 --- a/filter/filec.c +++ b/filter/filec.c @@ -21,11 +21,11 @@ fz_openfile(fz_file **filep, char *path, int mode) realmode = 0; if (mode == FZ_READ) - realmode = O_RDONLY; + realmode = O_BINARY | O_RDONLY; if (mode == FZ_WRITE) - realmode = O_WRONLY | O_CREAT | O_TRUNC; + realmode = O_BINARY | O_WRONLY | O_CREAT | O_TRUNC; if (mode == FZ_APPEND) - realmode = O_WRONLY; + realmode = O_BINARY | O_WRONLY; fd = open(path, realmode, 0644); if (fd == -1) diff --git a/filter/filer.c b/filter/filer.c index ead97bdc..29e04558 100644 --- a/filter/filer.c +++ b/filter/filer.c @@ -11,7 +11,7 @@ static int doread(fz_buffer *b, int fd) return n; } -static int producedata(fz_file *f) +int fz_producedata(fz_file *f) { fz_error *reason; int produced; @@ -99,7 +99,7 @@ fz_peekbyte(fz_file *f) if (f->out->rp == f->out->wp) { if (f->out->eof) return EOF; - if (producedata(f)) return EOF; + if (fz_producedata(f)) return EOF; } if (f->out->rp < f->out->wp) @@ -114,7 +114,7 @@ fz_readbyte(fz_file *f) if (f->out->rp == f->out->wp) { if (f->out->eof) return EOF; - if (producedata(f)) return EOF; + if (fz_producedata(f)) return EOF; } if (f->out->rp < f->out->wp) @@ -136,7 +136,7 @@ fz_read(fz_file *f, char *buf, int n) if (f->out->rp == f->out->wp) { if (f->out->eof) return i; - if (producedata(f) < 0) return -1; + if (fz_producedata(f) < 0) return -1; } } diff --git a/filter/jbig2d.c b/filter/jbig2d.c index e58a5e49..3d191e65 100644 --- a/filter/jbig2d.c +++ b/filter/jbig2d.c @@ -12,7 +12,21 @@ +create the per-page ctx */ +#ifdef WIN32 /* Microsoft Visual C+*/ + +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef __int64 int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; + +#else #include <inttypes.h> +#endif + #include <jbig2.h> typedef struct fz_jbig2d_s fz_jbig2d; diff --git a/include/fitz/base.h b/include/fitz/base.h index 26a23be5..06a644b3 100644 --- a/include/fitz/base.h +++ b/include/fitz/base.h @@ -36,12 +36,11 @@ struct fz_error_s extern fz_error fz_koutofmem; #ifdef WIN32 -#define fz_throw fz_throwMS -fz_error *fz_throwMS(char *fmt, ...); +#define fz_throw(...) fz_throw0(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) #else #define fz_throw(fmt, ...) fz_throw0(__func__, __FILE__, __LINE__, fmt, ## __VA_ARGS__) -fz_error *fz_throw0(const char *func, const char *file, int line, char *fmt, ...); #endif +fz_error *fz_throw0(const char *func, const char *file, int line, char *fmt, ...); void fz_warn(char *fmt, ...); void fz_abort(fz_error *eo); diff --git a/include/fitz/sysdep.h b/include/fitz/sysdep.h index f3125601..7f7ddbca 100644 --- a/include/fitz/sysdep.h +++ b/include/fitz/sysdep.h @@ -11,28 +11,50 @@ #include <float.h> /* DBL_EPSILON */ #include <math.h> +#include <errno.h> +#include <fcntl.h> /* O_RDONLY & co */ + #ifdef WIN32 + #define NEED_STRLCPY #define NEED_STRSEP #define NEED_GETOPT + +#define M_E 2.71828182845904523536 +#define M_LOG2E 1.44269504088896340736 +#define M_LOG10E 0.434294481903251827651 +#define M_LN2 0.693147180559945309417 +#define M_LN10 2.30258509299404568402 #define M_PI 3.14159265358979323846 +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.785398163397448309616 +#define M_1_PI 0.318309886183790671538 +#define M_2_PI 0.636619772367581343076 +#define M_1_SQRTPI 0.564189583547756286948 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT_2 0.707106781186547524401 + +#define va_copy(a,b) (a) = (b) #define inline __inline #define vsnprintf _vsnprintf -#endif -#include <errno.h> -#ifndef WIN32 +#include <io.h> + +#else + +#define O_BINARY 0 #include <unistd.h> -#endif -#include <fcntl.h> /* O_RDONLY & co */ -/* not supposed to be here, but printf debugging sorta needs it */ -#include <stdio.h> +#endif /* * Extras! Extras! Get them while they're hot! */ +/* not supposed to be here, but printf debugging sorta needs it */ +#include <stdio.h> + #ifdef NEED_STRLCPY extern int strlcpy(char *dst, const char *src, int n); extern int strlcat(char *dst, const char *src, int n); diff --git a/mupdf/open.c b/mupdf/open.c index 7fa94268..529872a8 100644 --- a/mupdf/open.c +++ b/mupdf/open.c @@ -176,9 +176,9 @@ readoldxref(fz_obj **trailerp, pdf_xref *xref, unsigned char *buf, int cap) if (!xref->table[ofs + i].type) { s = buf; - xref->table[ofs + i].ofs = atoi(strsep(&s, " ")); - xref->table[ofs + i].gen = atoi(strsep(&s, " ")); - xref->table[ofs + i].type = strsep(&s, " ")[0]; + xref->table[ofs + i].ofs = atoi(s); + xref->table[ofs + i].gen = atoi(s + 11); + xref->table[ofs + i].type = s[17]; } } } |