diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-10-05 11:05:26 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-10-05 11:05:26 +0200 |
commit | 7edeed5a4fae0199a65dc724c2c131d4d120bf28 (patch) | |
tree | c27e90705a7c083643913a82a4deb2d74b385e57 | |
parent | 98e44466052e654c6b34a685fe7dbc433632aecc (diff) | |
download | mupdf-7edeed5a4fae0199a65dc724c2c131d4d120bf28.tar.xz |
strip out c99-isms for msvc
-rw-r--r-- | base/error.c | 21 | ||||
-rw-r--r-- | base/matrix.c | 31 | ||||
-rw-r--r-- | base/memory.c | 10 | ||||
-rw-r--r-- | base/rect.c | 11 | ||||
-rw-r--r-- | include/fitz/base.h | 6 | ||||
-rw-r--r-- | include/fitz/geometry.h | 2 | ||||
-rw-r--r-- | include/fitz/sysdep.h | 6 | ||||
-rw-r--r-- | tree/node1.c | 2 | ||||
-rw-r--r-- | tree/node2.c | 10 | ||||
-rw-r--r-- | tree/path.c | 2 | ||||
-rw-r--r-- | tree/text.c | 2 | ||||
-rw-r--r-- | tree/tree.c | 2 |
12 files changed, 83 insertions, 22 deletions
diff --git a/base/error.c b/base/error.c index bbba9ac3..33954e07 100644 --- a/base/error.c +++ b/base/error.c @@ -12,6 +12,27 @@ fz_warn(char *fmt, ...) } fz_error * +fz_throwMS(char *fmt, ...) +{ + va_list ap; + fz_error *eo; + + eo = fz_malloc(sizeof(fz_error)); + if (!eo) return fz_outofmem; + + strlcpy(eo->func, "unknown", sizeof eo->func); + strlcpy(eo->file, "unknown", sizeof eo->file); + eo->line = -1; + + va_start(ap, fmt); + vsnprintf(eo->msg, sizeof eo->msg, fmt, ap); + eo->msg[sizeof(eo->msg) - 1] = '\0'; + va_end(ap); + + return eo; +} + +fz_error * fz_throw0(const char *func, const char *file, int line, char *fmt, ...) { va_list ap; diff --git a/base/matrix.c b/base/matrix.c index 70193427..659193f5 100644 --- a/base/matrix.c +++ b/base/matrix.c @@ -16,27 +16,43 @@ fz_concat(fz_matrix one, fz_matrix two) fz_matrix fz_identity(void) { - return (fz_matrix) { 1, 0, 0, 1, 0, 0 }; + fz_matrix m; + m.a = 1; m.b = 0; + m.c = 0; m.d = 1; + m.e = 0; m.f = 0; + return m; } fz_matrix fz_scale(float sx, float sy) { - return (fz_matrix) { sx, 0, 0, sy, 0, 0 }; + fz_matrix m; + m.a = sx; m.b = 0; + m.c = 0; m.d = sy; + m.e = 0; m.f = 0; + return m; } fz_matrix fz_rotate(float theta) { + fz_matrix m; float s = sin(theta * M_PI / 180.0); float c = cos(theta * M_PI / 180.0); - return (fz_matrix) { c, s, -s, c, 0 ,0 }; + m.a = c; m.b = s; + m.c = -s; m.d = c; + m.e = 0; m.f = 0; + return m; } fz_matrix fz_translate(float tx, float ty) { - return (fz_matrix) { 1, 0, 0, 1, tx, ty }; + fz_matrix m; + m.a = 1; m.b = 0; + m.c = 0; m.d = 1; + m.e = tx; m.f = ty; + return m; } fz_matrix @@ -63,8 +79,9 @@ fz_isrectilinear(fz_matrix m) fz_point fz_transformpoint(fz_matrix m, fz_point p) { - float x = p.x * m.a + p.y * m.c + m.e; - float y = p.x * m.b + p.y * m.d + m.f; - return (fz_point) { x, y }; + fz_point t; + t.x = p.x * m.a + p.y * m.c + m.e; + t.y = p.x * m.b + p.y * m.d + m.f; + return t; } diff --git a/base/memory.c b/base/memory.c index 88102d00..b0858383 100644 --- a/base/memory.c +++ b/base/memory.c @@ -39,11 +39,11 @@ static fz_memorycontext defmem = { stdmalloc, stdrealloc, stdfree }; static fz_memorycontext *curmem = &defmem; fz_error fz_koutofmem = { - .msg = {"out of memory"}, - .func = {"<malloc>"}, - .file = {"memory.c"}, - .line = 0, - .frozen = 1 + {"out of memory"}, + {"<malloc>"}, + {"memory.c"}, + 0, + 1 }; fz_memorycontext * diff --git a/base/rect.c b/base/rect.c index cb15d434..cc8d0a76 100644 --- a/base/rect.c +++ b/base/rect.c @@ -1,6 +1,17 @@ #include <fitz.h> fz_rect +fz_infiniterect(void) +{ + fz_rect r; + r.min.x = 1; + r.min.y = 1; + r.max.x = -1; + r.max.y = -1; + return r; +} + +fz_rect fz_intersectrects(fz_rect a, fz_rect b) { fz_rect r; diff --git a/include/fitz/base.h b/include/fitz/base.h index 36fe0aeb..c255efe9 100644 --- a/include/fitz/base.h +++ b/include/fitz/base.h @@ -35,8 +35,14 @@ struct fz_error_s #define fz_outofmem (&fz_koutofmem) extern fz_error fz_koutofmem; +#ifdef __WIN32__ +#define fz_throw fz_throwMS +fz_error *fz_throwMS(char *fmt, ...); +#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 + void fz_warn(char *fmt, ...); void fz_abort(fz_error *eo); void fz_freeerror(fz_error *eo); diff --git a/include/fitz/geometry.h b/include/fitz/geometry.h index 588aa562..29a6b522 100644 --- a/include/fitz/geometry.h +++ b/include/fitz/geometry.h @@ -36,7 +36,7 @@ struct fz_irect_s fz_ipoint max; }; -#define FZ_INFRECT (fz_rect){{1,1},{-1,-1}} +fz_rect fz_infiniterect(void); fz_matrix fz_concat(fz_matrix one, fz_matrix two); fz_matrix fz_identity(void); diff --git a/include/fitz/sysdep.h b/include/fitz/sysdep.h index bb78521f..39221272 100644 --- a/include/fitz/sysdep.h +++ b/include/fitz/sysdep.h @@ -31,6 +31,12 @@ typedef signed long long fz_s64; * Extras! Extras! Get them while they're hot! */ +#ifdef __WIN32__ +#define NEED_STRLCPY +#define NEED_STRSEP +#define NEED_GETOPT +#endif + #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/tree/node1.c b/tree/node1.c index c24b974a..26ce614f 100644 --- a/tree/node1.c +++ b/tree/node1.c @@ -94,7 +94,7 @@ fz_boundnode(fz_node *node, fz_matrix ctm) case FZ_NMETA: return fz_boundmetanode((fz_metanode *) node, ctm); } - return FZ_INFRECT; + return fz_infiniterect(); } int diff --git a/tree/node2.c b/tree/node2.c index dc82265d..0e173dbf 100644 --- a/tree/node2.c +++ b/tree/node2.c @@ -25,7 +25,7 @@ fz_boundovernode(fz_overnode *node, fz_matrix ctm) fz_rect bbox; fz_rect r; - bbox = FZ_INFRECT; + bbox = fz_infiniterect(); for (child = node->super.child; child; child = child->next) { @@ -67,7 +67,7 @@ fz_boundmasknode(fz_masknode *node, fz_matrix ctm) fz_rect bbox; fz_rect r; - bbox = FZ_INFRECT; + bbox = fz_infiniterect(); for (child = node->super.child; child; child = child->next) { @@ -113,7 +113,7 @@ fz_boundblendnode(fz_blendnode *node, fz_matrix ctm) fz_rect bbox; fz_rect r; - bbox = FZ_INFRECT; + bbox = fz_infiniterect(); for (child = node->super.child; child; child = child->next) { @@ -154,7 +154,7 @@ fz_rect fz_boundtransformnode(fz_transformnode *node, fz_matrix ctm) { if (!node->super.child) - return FZ_INFRECT; + return fz_infiniterect(); return fz_boundnode(node->super.child, fz_concat(node->m, ctm)); } @@ -189,7 +189,7 @@ fz_rect fz_boundmetanode(fz_metanode *node, fz_matrix ctm) { if (!node->super.child) - return FZ_INFRECT; + return fz_infiniterect(); return fz_boundnode(node->super.child, ctm); } diff --git a/tree/path.c b/tree/path.c index bab84401..268e5dae 100644 --- a/tree/path.c +++ b/tree/path.c @@ -187,7 +187,7 @@ fz_rect fz_boundpathnode(fz_pathnode *path, fz_matrix ctm) { fz_point p; - fz_rect r = FZ_INFRECT; + fz_rect r = fz_infiniterect(); int i = 0; while (i < path->len) diff --git a/tree/text.c b/tree/text.c index f1992ade..b36fe59d 100644 --- a/tree/text.c +++ b/tree/text.c @@ -31,7 +31,7 @@ fz_boundtextnode(fz_textnode *text, fz_matrix ctm) { // FIXME convolve font bbox to all glyph x,y pairs /* fz_rect bounds = fz_boundglyph(text->font, text->els[0], ctm); */ - return FZ_INFRECT; + return fz_infiniterect(); } static fz_error * diff --git a/tree/tree.c b/tree/tree.c index 7de88e11..12bbc822 100644 --- a/tree/tree.c +++ b/tree/tree.c @@ -41,7 +41,7 @@ fz_boundtree(fz_tree *tree, fz_matrix ctm) { if (tree->root) return fz_boundnode(tree->root, ctm); - return FZ_INFRECT; + return fz_infiniterect(); } void |