summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2009-03-11 22:02:49 +0100
committerTor Andersson <tor@ghostscript.com>2009-03-11 22:02:49 +0100
commit9f6a77c2d17128a44bf2fc9fead449a05354def5 (patch)
tree905d3c56580a906b77b1ca2660cb6f3fd123b945
parent31733cfd3ba1a920542da3792f2591cf7ba5f62a (diff)
downloadmupdf-9f6a77c2d17128a44bf2fc9fead449a05354def5.tar.xz
Rename and prune some files and functions.
-rw-r--r--Jamrules6
-rw-r--r--fitz/Jamfile3
-rw-r--r--fitz/base_cleanname.c52
-rw-r--r--fitz/base_memory.c66
-rw-r--r--fitz/base_unicode.c (renamed from fitz/base_rune.c)0
-rw-r--r--fitz/filt_flate.c14
-rw-r--r--fitz/fitz_base.h22
-rw-r--r--fitzdraw/pathscan.c6
8 files changed, 33 insertions, 136 deletions
diff --git a/Jamrules b/Jamrules
index 99ddf6fb..f8632436 100644
--- a/Jamrules
+++ b/Jamrules
@@ -16,7 +16,7 @@
# libraries are in c:/local/include and c:/local/lib.
#
# MacOS X builds assume that you have third party libraries installed
-# from MacPorts in /opt/local.
+# in /usr/local or some other system known location.
#
# Linux builds assume that you have freetype-config to find the paths
# to the freetype library.
@@ -81,8 +81,8 @@ if $(OS) = MACOSX
BUILD_X11APP = true ;
- THIRDPARTYINC ?= -I/opt/local/include -I/opt/local/include/freetype2 -I/usr/X11R6/include ;
- THIRDPARTYLIB ?= -L/opt/local/lib -L/usr/X11R6/lib ;
+ THIRDPARTYINC ?= -I/usr/X11/include ;
+ THIRDPARTYLIB ?= -L/usr/X11/lib ;
CCFLAGS = -Wall -std=c99 $(THIRDPARTYINC) ;
LINKFLAGS = $(THIRDPARTYLIB) ;
diff --git a/fitz/Jamfile b/fitz/Jamfile
index 61f2583d..c0d0fb2d 100644
--- a/fitz/Jamfile
+++ b/fitz/Jamfile
@@ -16,9 +16,8 @@ Library libfitz :
base_matrix.c
base_memory.c
base_rect.c
- base_rune.c
base_string.c
- base_cleanname.c
+ base_unicode.c
;
if $(NEED_GETOPT) { Library libfitz : util_getopt.c ; }
diff --git a/fitz/base_cleanname.c b/fitz/base_cleanname.c
deleted file mode 100644
index 54764630..00000000
--- a/fitz/base_cleanname.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * In place, rewrite name to compress multiple /, eliminate ., and process ..
- */
-
-#define SEP(x) ((x)=='/' || (x) == 0)
-
-char *
-cleanname(char *name)
-{
- char *p, *q, *dotdot;
- int rooted;
-
- rooted = name[0] == '/';
-
- /*
- * invariants:
- * p points at beginning of path element we're considering.
- * q points just past the last path element we wrote (no slash).
- * dotdot points just past the point where .. cannot backtrack
- * any further (no slash).
- */
- p = q = dotdot = name+rooted;
- while(*p) {
- if(p[0] == '/') /* null element */
- p++;
- else if(p[0] == '.' && SEP(p[1]))
- p += 1; /* don't count the separator in case it is nul */
- else if(p[0] == '.' && p[1] == '.' && SEP(p[2])) {
- p += 2;
- if(q > dotdot) { /* can backtrack */
- while(--q > dotdot && *q != '/')
- ;
- } else if(!rooted) { /* /.. is / but ./../ is .. */
- if(q != name)
- *q++ = '/';
- *q++ = '.';
- *q++ = '.';
- dotdot = q;
- }
- } else { /* real path element */
- if(q != name+rooted)
- *q++ = '/';
- while((*q = *p) != '/' && *q != 0)
- p++, q++;
- }
- }
- if(q == name) /* empty string is really ``.'' */
- *q++ = '.';
- *q = '\0';
- return name;
-}
-
diff --git a/fitz/base_memory.c b/fitz/base_memory.c
index cd6de8cb..21effdc1 100644
--- a/fitz/base_memory.c
+++ b/fitz/base_memory.c
@@ -1,71 +1,31 @@
#include "fitz_base.h"
-/* Make this thread local storage if you wish. */
-
-static void *stdmalloc(fz_memorycontext *mem, int n)
-{
- return malloc(n);
-}
-
-static void *stdrealloc(fz_memorycontext *mem, void *p, int n)
-{
- return realloc(p, n);
-}
-
-static void stdfree(fz_memorycontext *mem, void *p)
-{
- free(p);
-}
-
-static fz_memorycontext defmem = { stdmalloc, stdrealloc, stdfree };
-static fz_memorycontext *curmem = &defmem;
-
-fz_memorycontext *
-fz_currentmemorycontext()
-{
- return curmem;
-}
-
-void
-fz_setmemorycontext(fz_memorycontext *mem)
-{
- curmem = mem;
-}
-
-void *
-fz_malloc(int n)
+void * fz_malloc(int n)
{
- fz_memorycontext *mem = fz_currentmemorycontext();
- void *p = mem->malloc(mem, n);
+ void *p = malloc(n);
if (!p)
- fz_warn("cannot malloc %d bytes", n);
+ fz_throw("cannot malloc %d bytes", n);
return p;
}
-void *
-fz_realloc(void *p, int n)
+void * fz_realloc(void *p, int n)
{
- fz_memorycontext *mem = fz_currentmemorycontext();
- void *np = mem->realloc(mem, p, n);
+ void *np = realloc(p, n);
if (np == nil)
- fz_warn("cannot realloc %d bytes", n);
+ fz_throw("cannot realloc %d bytes", n);
return np;
}
-void
-fz_free(void *p)
+void fz_free(void *p)
{
- fz_memorycontext *mem = fz_currentmemorycontext();
- mem->free(mem, p);
+ free(p);
}
-char *
-fz_strdup(char *s)
+char * fz_strdup(char *s)
{
- int len = strlen(s);
- char *ns = fz_malloc(len + 1);
- if (ns)
- strcpy(ns, s);
- return ns;
+ char *ns = strdup(s);
+ if (!ns)
+ fz_throw("cannot strdup %d bytes", strlen(s) + 1);
+ return ns;
}
diff --git a/fitz/base_rune.c b/fitz/base_unicode.c
index 32168792..32168792 100644
--- a/fitz/base_rune.c
+++ b/fitz/base_unicode.c
diff --git a/fitz/filt_flate.c b/fitz/filt_flate.c
index 73105800..65a84711 100644
--- a/fitz/filt_flate.c
+++ b/fitz/filt_flate.c
@@ -17,6 +17,12 @@ zmalloc(void *opaque, unsigned int items, unsigned int size)
return fz_malloc(items * size);
}
+static void
+zfree(void *opaque, void *ptr)
+{
+ fz_free(ptr);
+}
+
fz_error
fz_newflated(fz_filter **fp, fz_obj *params)
{
@@ -28,8 +34,8 @@ fz_newflated(fz_filter **fp, fz_obj *params)
FZ_NEWFILTER(fz_flate, f, flated);
f->z.zalloc = zmalloc;
- f->z.zfree = (void(*)(void*,void*))fz_currentmemorycontext()->free;
- f->z.opaque = fz_currentmemorycontext();
+ f->z.zfree = zfree;
+ f->z.opaque = nil;
f->z.next_in = nil;
f->z.avail_in = 0;
@@ -133,8 +139,8 @@ fz_newflatee(fz_filter **fp, fz_obj *params)
}
f->z.zalloc = zmalloc;
- f->z.zfree = (void(*)(void*,void*))fz_currentmemorycontext()->free;
- f->z.opaque = fz_currentmemorycontext();
+ f->z.zfree = zfree;
+ f->z.opaque = nil;
f->z.next_in = nil;
f->z.avail_in = 0;
diff --git a/fitz/fitz_base.h b/fitz/fitz_base.h
index 211ed8dc..6bee3ecb 100644
--- a/fitz/fitz_base.h
+++ b/fitz/fitz_base.h
@@ -173,12 +173,9 @@ int runetochar(char *str, int *rune);
int runelen(long c);
int runenlen(int *r, int nrune);
int fullrune(char *str, int n);
-char *cleanname(char *name);
typedef int fz_error;
-#define fz_outofmem ((fz_error)-1)
-
#define fz_throw(...) fz_throwimp(__func__, __FILE__, __LINE__, __VA_ARGS__)
#define fz_rethrow(cause, ...) fz_rethrowimp(cause, __func__, __FILE__, __LINE__, __VA_ARGS__)
#define fz_catch(cause, ...) fz_catchimp(cause, __func__, __FILE__, __LINE__, __VA_ARGS__)
@@ -189,22 +186,9 @@ fz_error fz_throwimp(const char *func, const char *file, int line, char *fmt, ..
fz_error fz_rethrowimp(fz_error cause, const char *func, const char *file, int line, char *fmt, ...) __printflike(5, 6);
fz_error fz_catchimp(fz_error cause, const char *func, const char *file, int line, char *fmt, ...) __printflike(5, 6);
-typedef struct fz_memorycontext_s fz_memorycontext;
-
-struct fz_memorycontext_s
-{
- void * (*malloc)(fz_memorycontext *, int);
- void * (*realloc)(fz_memorycontext *, void *, int);
- void (*free)(fz_memorycontext *, void *);
-};
-
-fz_memorycontext *fz_currentmemorycontext(void);
-void fz_setmemorycontext(fz_memorycontext *memorycontext);
-
void *fz_malloc(int n);
void *fz_realloc(void *p, int n);
void fz_free(void *p);
-
char *fz_strdup(char *s);
/*
@@ -232,12 +216,6 @@ void *fz_hashgetval(fz_hashtable *table, int idx);
#define fz_floor(x) floor(x)
#define fz_ceil(x) ceil(x)
-/* divide and floor towards -inf */
-static inline int fz_idiv(int a, int b)
-{
- return a < 0 ? (a - b + 1) / b : a / b;
-}
-
typedef struct fz_matrix_s fz_matrix;
typedef struct fz_point_s fz_point;
typedef struct fz_rect_s fz_rect;
diff --git a/fitzdraw/pathscan.c b/fitzdraw/pathscan.c
index dec7c73f..2ab7d5b6 100644
--- a/fitzdraw/pathscan.c
+++ b/fitzdraw/pathscan.c
@@ -2,6 +2,12 @@
#include "fitz_tree.h"
#include "fitz_draw.h"
+/* divide and floor towards -inf */
+static inline int fz_idiv(int a, int b)
+{
+ return a < 0 ? (a - b + 1) / b : a / b;
+}
+
enum { HSCALE = 17, VSCALE = 15, SF = 1 };
/*