summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-10-05 11:05:26 +0200
committerTor Andersson <tor@ghostscript.com>2004-10-05 11:05:26 +0200
commit7edeed5a4fae0199a65dc724c2c131d4d120bf28 (patch)
treec27e90705a7c083643913a82a4deb2d74b385e57 /base
parent98e44466052e654c6b34a685fe7dbc433632aecc (diff)
downloadmupdf-7edeed5a4fae0199a65dc724c2c131d4d120bf28.tar.xz
strip out c99-isms for msvc
Diffstat (limited to 'base')
-rw-r--r--base/error.c21
-rw-r--r--base/matrix.c31
-rw-r--r--base/memory.c10
-rw-r--r--base/rect.c11
4 files changed, 61 insertions, 12 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;