summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/destatic.sh16
-rw-r--r--scripts/restatic.sh8
-rw-r--r--source/fitz/draw-mesh.c4
-rw-r--r--source/fitz/filter-dct.c20
-rw-r--r--source/fitz/filter-flate.c8
-rw-r--r--source/fitz/harfbuzz.c16
-rw-r--r--source/fitz/stext-output.c8
-rw-r--r--source/fitz/stext-search.c10
-rw-r--r--source/fitz/string.c4
-rw-r--r--source/fitz/strtod.c6
-rw-r--r--source/fitz/tree.c18
-rw-r--r--source/fitz/xml.c10
-rw-r--r--source/html/css-parse.c2
-rw-r--r--source/pdf/pdf-form.c6
-rw-r--r--source/pdf/pdf-js.c6
m---------thirdparty/mujs0
16 files changed, 83 insertions, 59 deletions
diff --git a/scripts/destatic.sh b/scripts/destatic.sh
new file mode 100644
index 00000000..b6b80701
--- /dev/null
+++ b/scripts/destatic.sh
@@ -0,0 +1,16 @@
+# Simple script to make all static functions in the main source
+# unstatic. This allows backtracing functions (such as that used
+# in Memento, in particular on Android) to pick up symbol names
+# nicely.
+#
+# This script can be reversed using restatic.sh
+
+# Allow for the fact that mujs might not be present
+MUJS_SRC=
+test -d thirdparty/mujs && MUJS_SRC=thirdparty/mujs
+
+# Convert everything
+sed -i '/^static inline/b;/^static const/b;s!^static !/\*static \*/!' $(find source platform/android/viewer platform/java $MUJS_SRC -name '*.c')
+
+# Convert source/tools back again.
+sed -i 's!/\*static \*/!static !' $(find source/tools -name '*.c')
diff --git a/scripts/restatic.sh b/scripts/restatic.sh
new file mode 100644
index 00000000..f3f5b7a4
--- /dev/null
+++ b/scripts/restatic.sh
@@ -0,0 +1,8 @@
+# Simple script to revert the changes made by destatic.sh
+
+# Allow for the fact that mujs might not be present
+MUJS_SRC=
+test -d thirdparty/mujs && MUJS_SRC=thirdparty/mujs
+
+# Convert it all back
+sed -i 's!/\*static \*/!static !' $(find source platform/android/viewer platform/java $MUJS_SRC -name '*.c')
diff --git a/source/fitz/draw-mesh.c b/source/fitz/draw-mesh.c
index 40f16734..d7606f1b 100644
--- a/source/fitz/draw-mesh.c
+++ b/source/fitz/draw-mesh.c
@@ -167,7 +167,7 @@ struct paint_tri_data
};
static void
-prepare_vertex(fz_context *ctx, void *arg, fz_vertex *v, const float *input)
+prepare_mesh_vertex(fz_context *ctx, void *arg, fz_vertex *v, const float *input)
{
struct paint_tri_data *ptd = (struct paint_tri_data *)arg;
const fz_shade *shade = ptd->shade;
@@ -246,7 +246,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap
ptd.bbox = bbox;
fz_init_cached_color_converter(ctx, &ptd.cc, temp->colorspace, shade->colorspace);
- fz_process_mesh(ctx, shade, &local_ctm, &prepare_vertex, &do_paint_tri, &ptd);
+ fz_process_mesh(ctx, shade, &local_ctm, &prepare_mesh_vertex, &do_paint_tri, &ptd);
if (shade->use_function)
{
diff --git a/source/fitz/filter-dct.c b/source/fitz/filter-dct.c
index fee39f69..ebbb48f9 100644
--- a/source/fitz/filter-dct.c
+++ b/source/fitz/filter-dct.c
@@ -86,24 +86,24 @@ fz_dct_mem_term(fz_dctd *state)
#endif /* SHARE_JPEG */
-static void error_exit(j_common_ptr cinfo)
+static void error_exit_dct(j_common_ptr cinfo)
{
fz_dctd *state = JZ_DCT_STATE_FROM_CINFO(cinfo);
cinfo->err->format_message(cinfo, state->msg);
longjmp(state->jb, 1);
}
-static void init_source(j_decompress_ptr cinfo)
+static void init_source_dct(j_decompress_ptr cinfo)
{
/* nothing to do */
}
-static void term_source(j_decompress_ptr cinfo)
+static void term_source_dct(j_decompress_ptr cinfo)
{
/* nothing to do */
}
-static boolean fill_input_buffer(j_decompress_ptr cinfo)
+static boolean fill_input_buffer_dct(j_decompress_ptr cinfo)
{
struct jpeg_source_mgr *src = cinfo->src;
fz_dctd *state = JZ_DCT_STATE_FROM_CINFO(cinfo);
@@ -133,7 +133,7 @@ static boolean fill_input_buffer(j_decompress_ptr cinfo)
return 1;
}
-static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
+static void skip_input_data_dct(j_decompress_ptr cinfo, long num_bytes)
{
struct jpeg_source_mgr *src = cinfo->src;
if (num_bytes > 0)
@@ -173,7 +173,7 @@ next_dctd(fz_context *ctx, fz_stream *stm, size_t max)
cinfo->client_data = state;
cinfo->err = &state->errmgr;
jpeg_std_error(cinfo->err);
- cinfo->err->error_exit = error_exit;
+ cinfo->err->error_exit = error_exit_dct;
fz_dct_mem_init(state);
@@ -185,11 +185,11 @@ next_dctd(fz_context *ctx, fz_stream *stm, size_t max)
(void)fz_read_byte(ctx, state->chain);
cinfo->src = &state->srcmgr;
- cinfo->src->init_source = init_source;
- cinfo->src->fill_input_buffer = fill_input_buffer;
- cinfo->src->skip_input_data = skip_input_data;
+ cinfo->src->init_source = init_source_dct;
+ cinfo->src->fill_input_buffer = fill_input_buffer_dct;
+ cinfo->src->skip_input_data = skip_input_data_dct;
cinfo->src->resync_to_restart = jpeg_resync_to_restart;
- cinfo->src->term_source = term_source;
+ cinfo->src->term_source = term_source_dct;
/* optionally load additional JPEG tables first */
if (state->jpegtables)
diff --git a/source/fitz/filter-flate.c b/source/fitz/filter-flate.c
index 31519066..562c9546 100644
--- a/source/fitz/filter-flate.c
+++ b/source/fitz/filter-flate.c
@@ -11,12 +11,12 @@ struct fz_flate_s
unsigned char buffer[4096];
};
-static void *zalloc(void *opaque, unsigned int items, unsigned int size)
+static void *zalloc_flate(void *opaque, unsigned int items, unsigned int size)
{
return fz_malloc_array_no_throw(opaque, items, size);
}
-static void zfree(void *opaque, void *ptr)
+static void zfree_flate(void *opaque, void *ptr)
{
fz_free(opaque, ptr);
}
@@ -111,8 +111,8 @@ fz_open_flated(fz_context *ctx, fz_stream *chain, int window_bits)
state = fz_malloc_struct(ctx, fz_flate);
state->chain = chain;
- state->z.zalloc = zalloc;
- state->z.zfree = zfree;
+ state->z.zalloc = zalloc_flate;
+ state->z.zfree = zfree_flate;
state->z.opaque = ctx;
state->z.next_in = NULL;
state->z.avail_in = 0;
diff --git a/source/fitz/harfbuzz.c b/source/fitz/harfbuzz.c
index c4a0c5f9..e2b4e834 100644
--- a/source/fitz/harfbuzz.c
+++ b/source/fitz/harfbuzz.c
@@ -64,12 +64,12 @@
static fz_context *hb_secret = NULL;
-static void set_context(fz_context *ctx)
+static void set_hb_context(fz_context *ctx)
{
hb_secret = ctx;
}
-static fz_context *get_context()
+static fz_context *get_hb_context()
{
return hb_secret;
}
@@ -78,19 +78,19 @@ void hb_lock(fz_context *ctx)
{
fz_lock(ctx, FZ_LOCK_FREETYPE);
- set_context(ctx);
+ set_hb_context(ctx);
}
void hb_unlock(fz_context *ctx)
{
- set_context(NULL);
+ set_hb_context(NULL);
fz_unlock(ctx, FZ_LOCK_FREETYPE);
}
void *hb_malloc(size_t size)
{
- fz_context *ctx = get_context();
+ fz_context *ctx = get_hb_context();
assert(ctx != NULL);
@@ -99,7 +99,7 @@ void *hb_malloc(size_t size)
void *hb_calloc(size_t n, size_t size)
{
- fz_context *ctx = get_context();
+ fz_context *ctx = get_hb_context();
assert(ctx != NULL);
@@ -108,7 +108,7 @@ void *hb_calloc(size_t n, size_t size)
void *hb_realloc(void *ptr, size_t size)
{
- fz_context *ctx = get_context();
+ fz_context *ctx = get_hb_context();
assert(ctx != NULL);
@@ -117,7 +117,7 @@ void *hb_realloc(void *ptr, size_t size)
void hb_free(void *ptr)
{
- fz_context *ctx = get_context();
+ fz_context *ctx = get_hb_context();
assert(ctx != NULL);
diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c
index c7090d33..f7ea0c24 100644
--- a/source/fitz/stext-output.c
+++ b/source/fitz/stext-output.c
@@ -73,7 +73,7 @@ fz_print_stext_sheet(fz_context *ctx, fz_output *out, fz_stext_sheet *sheet)
}
static void
-send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
+send_data_base64_stext(fz_context *ctx, fz_output *out, fz_buffer *buffer)
{
size_t i, len;
static const char set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -251,17 +251,17 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
{
case FZ_IMAGE_JPEG:
fz_printf(ctx, out, "image/jpeg;base64,");
- send_data_base64(ctx, out, buffer->buffer);
+ send_data_base64_stext(ctx, out, buffer->buffer);
break;
case FZ_IMAGE_PNG:
fz_printf(ctx, out, "image/png;base64,");
- send_data_base64(ctx, out, buffer->buffer);
+ send_data_base64_stext(ctx, out, buffer->buffer);
break;
default:
{
fz_buffer *buf = fz_new_buffer_from_image_as_png(ctx, image->image);
fz_printf(ctx, out, "image/png;base64,");
- send_data_base64(ctx, out, buf);
+ send_data_base64_stext(ctx, out, buf);
fz_drop_buffer(ctx, buf);
break;
}
diff --git a/source/fitz/stext-search.c b/source/fitz/stext-search.c
index 2246f627..46c9166b 100644
--- a/source/fitz/stext-search.c
+++ b/source/fitz/stext-search.c
@@ -55,7 +55,7 @@ fz_char_and_box *fz_stext_char_at(fz_context *ctx, fz_char_and_box *cab, fz_stex
return cab;
}
-static int charat(fz_context *ctx, fz_stext_page *page, int idx)
+static inline int charat(fz_context *ctx, fz_stext_page *page, int idx)
{
fz_char_and_box cab;
return fz_stext_char_at(ctx, &cab, page, idx)->c;
@@ -69,7 +69,7 @@ static fz_rect *bboxat(fz_context *ctx, fz_stext_page *page, int idx, fz_rect *b
return bbox;
}
-static int textlen(fz_context *ctx, fz_stext_page *page)
+static int textlen_stext(fz_context *ctx, fz_stext_page *page)
{
int len = 0;
int block_num;
@@ -95,7 +95,7 @@ static int textlen(fz_context *ctx, fz_stext_page *page)
return len;
}
-static int match(fz_context *ctx, fz_stext_page *page, const char *s, int n)
+static int match_stext(fz_context *ctx, fz_stext_page *page, const char *s, int n)
{
int orig = n;
int c;
@@ -134,10 +134,10 @@ fz_search_stext_page(fz_context *ctx, fz_stext_page *text, const char *needle, f
return 0;
hit_count = 0;
- len = textlen(ctx, text);
+ len = textlen_stext(ctx, text);
for (pos = 0; pos < len; pos++)
{
- n = match(ctx, text, needle, pos);
+ n = match_stext(ctx, text, needle, pos);
if (n)
{
fz_rect linebox = fz_empty_rect;
diff --git a/source/fitz/string.c b/source/fitz/string.c
index 2eb67d4f..e9d8b086 100644
--- a/source/fitz/string.c
+++ b/source/fitz/string.c
@@ -104,14 +104,14 @@ fz_dirname(char *dir, const char *path, size_t n)
dir[i+1] = 0;
}
-static int ishex(int a)
+static inline int ishex(int a)
{
return (a >= 'A' && a <= 'F') ||
(a >= 'a' && a <= 'f') ||
(a >= '0' && a <= '9');
}
-static int tohex(int c)
+static inline int tohex(int c)
{
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c - 'a' + 0xA;
diff --git a/source/fitz/strtod.c b/source/fitz/strtod.c
index 27489ecd..4f0675fe 100644
--- a/source/fitz/strtod.c
+++ b/source/fitz/strtod.c
@@ -32,7 +32,7 @@
typedef unsigned long ulong;
#endif
-static ulong
+static inline ulong
umuldiv(ulong a, ulong b, ulong c)
{
double d;
@@ -390,7 +390,7 @@ fpcmp(char *a, ulong* f)
}
}
-static void
+static inline void
divby(char *a, int *na, int b)
{
int n, c;
@@ -465,7 +465,7 @@ divascii(char *a, int *na, int *dp, int *bp)
divby(a, na, b);
}
-static void
+static inline void
mulby(char *a, char *p, char *q, int b)
{
int n, c;
diff --git a/source/fitz/tree.c b/source/fitz/tree.c
index 18fb6548..9547dd2f 100644
--- a/source/fitz/tree.c
+++ b/source/fitz/tree.c
@@ -10,14 +10,14 @@ struct fz_tree_s
int level;
};
-static fz_tree sentinel = { "", NULL, &sentinel, &sentinel, 0 };
+static fz_tree tree_sentinel = { "", NULL, &tree_sentinel, &tree_sentinel, 0 };
static fz_tree *fz_tree_new_node(fz_context *ctx, const char *key, void *value)
{
fz_tree *node = fz_malloc_struct(ctx, fz_tree);
node->key = fz_strdup(ctx, key);
node->value = value;
- node->left = node->right = &sentinel;
+ node->left = node->right = &tree_sentinel;
node->level = 1;
return node;
}
@@ -26,7 +26,7 @@ void *fz_tree_lookup(fz_context *ctx, fz_tree *node, const char *key)
{
if (node)
{
- while (node != &sentinel)
+ while (node != &tree_sentinel)
{
int c = strcmp(key, node->key);
if (c == 0)
@@ -72,7 +72,7 @@ static fz_tree *fz_tree_split(fz_tree *node)
fz_tree *fz_tree_insert(fz_context *ctx, fz_tree *node, const char *key, void *value)
{
- if (node && node != &sentinel)
+ if (node && node != &tree_sentinel)
{
int c = strcmp(key, node->key);
if (c < 0)
@@ -93,9 +93,9 @@ void fz_drop_tree(fz_context *ctx, fz_tree *node, void (*dropfunc)(fz_context *c
{
if (node)
{
- if (node->left != &sentinel)
+ if (node->left != &tree_sentinel)
fz_drop_tree(ctx, node->left, dropfunc);
- if (node->right != &sentinel)
+ if (node->right != &tree_sentinel)
fz_drop_tree(ctx, node->right, dropfunc);
fz_free(ctx, node->key);
if (dropfunc)
@@ -106,19 +106,19 @@ void fz_drop_tree(fz_context *ctx, fz_tree *node, void (*dropfunc)(fz_context *c
static void print_tree_imp(fz_context *ctx, fz_tree *node, int level)
{
int i;
- if (node->left != &sentinel)
+ if (node->left != &tree_sentinel)
print_tree_imp(ctx, node->left, level + 1);
for (i = 0; i < level; i++)
putchar(' ');
printf("%s = %p (%d)\n", node->key, node->value, node->level);
- if (node->right != &sentinel)
+ if (node->right != &tree_sentinel)
print_tree_imp(ctx, node->right, level + 1);
}
void fz_debug_tree(fz_context *ctx, fz_tree *root)
{
printf("--- tree dump ---\n");
- if (root && root != &sentinel)
+ if (root && root != &tree_sentinel)
print_tree_imp(ctx, root, 0);
printf("---\n");
}
diff --git a/source/fitz/xml.c b/source/fitz/xml.c
index 1621aed2..47b9461b 100644
--- a/source/fitz/xml.c
+++ b/source/fitz/xml.c
@@ -85,7 +85,7 @@ struct fz_xml_s
fz_xml *up, *down, *tail, *prev, *next;
};
-static void indent(int n)
+static void xml_indent(int n)
{
while (n--) {
putchar(' ');
@@ -99,7 +99,7 @@ void fz_debug_xml(fz_xml *item, int level)
{
char *s = item->text;
int c;
- indent(level);
+ xml_indent(level);
putchar('"');
while ((c = *s++)) {
switch (c) {
@@ -128,16 +128,16 @@ void fz_debug_xml(fz_xml *item, int level)
fz_xml *child;
struct attribute *att;
- indent(level);
+ xml_indent(level);
printf("(%s\n", item->name);
for (att = item->atts; att; att = att->next)
{
- indent(level);
+ xml_indent(level);
printf("=%s %s\n", att->name, att->value);
}
for (child = item->down; child; child = child->next)
fz_debug_xml(child, level + 1);
- indent(level);
+ xml_indent(level);
printf(")%s\n", item->name);
}
}
diff --git a/source/html/css-parse.c b/source/html/css-parse.c
index e395e933..7fd8571a 100644
--- a/source/html/css-parse.c
+++ b/source/html/css-parse.c
@@ -165,7 +165,7 @@ static void css_lex_init(fz_context *ctx, struct lexbuf *buf, const char *s, con
buf->string_len = 0;
}
-static int iswhite(int c)
+static inline int iswhite(int c)
{
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f';
}
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 65090a74..395703a9 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -125,7 +125,7 @@ pdf_obj *pdf_lookup_field(fz_context *ctx, pdf_obj *form, char *name)
return dict;
}
-static void reset_field(fz_context *ctx, pdf_document *doc, pdf_obj *field)
+static void reset_form_field(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
/* Set V to DV wherever DV is present, and delete V where DV is not.
* FIXME: we assume for now that V has not been set unequal
@@ -192,7 +192,7 @@ void pdf_field_reset(fz_context *ctx, pdf_document *doc, pdf_obj *field)
{
pdf_obj *kids = pdf_dict_get(ctx, field, PDF_NAME_Kids);
- reset_field(ctx, doc, field);
+ reset_form_field(ctx, doc, field);
if (kids)
{
@@ -317,7 +317,7 @@ static void reset_form(fz_context *ctx, pdf_document *doc, pdf_obj *fields, int
int i, n = pdf_array_len(ctx, sfields);
for (i = 0; i < n; i++)
- reset_field(ctx, doc, pdf_array_get(ctx, sfields, i));
+ reset_form_field(ctx, doc, pdf_array_get(ctx, sfields, i));
}
fz_always(ctx)
{
diff --git a/source/pdf/pdf-js.c b/source/pdf/pdf-js.c
index 065a11dd..c3e148fe 100644
--- a/source/pdf/pdf-js.c
+++ b/source/pdf/pdf-js.c
@@ -20,7 +20,7 @@ FZ_NORETURN static void rethrow(pdf_js *js)
}
/* Unpack argument object with named arguments into actual parameters. */
-static pdf_js *arguments(js_State *J, ...)
+static pdf_js *unpack_arguments(js_State *J, ...)
{
if (js_isobject(J, 1))
{
@@ -80,7 +80,7 @@ static char *pdf_from_utf8(fz_context *ctx, const char *utf8)
static void app_alert(js_State *J)
{
- pdf_js *js = arguments(J, "cMsg", "nIcon", "nType", "cTitle", 0);
+ pdf_js *js = unpack_arguments(J, "cMsg", "nIcon", "nType", "cTitle", 0);
pdf_alert_event event;
event.message = js_tostring(J, 1);
@@ -461,7 +461,7 @@ static void doc_print(js_State *J)
static void doc_mailDoc(js_State *J)
{
- pdf_js *js = arguments(J, "bUI", "cTo", "cCc", "cBcc", "cSubject", "cMessage", 0);
+ pdf_js *js = unpack_arguments(J, "bUI", "cTo", "cCc", "cBcc", "cSubject", "cMessage", 0);
pdf_mail_doc_event event;
event.ask_user = js_isdefined(J, 1) ? js_toboolean(J, 1) : 1;
diff --git a/thirdparty/mujs b/thirdparty/mujs
-Subproject a4158ae6fff14017f38c425df648c99681b5eb3
+Subproject b3dece5f332316ea0948a3b1ca4ec650515734f