summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-10-08 16:16:14 +0100
committerRobin Watts <robin.watts@artifex.com>2012-10-08 16:57:44 +0100
commitdd4f6ffd475b0e769ba6231cf24b050bcdc97814 (patch)
tree96afc56cb815e26c39e8d95e0e906c165d82fe66 /pdf
parentd66ff690beb8c49e39311c9f6208fd4ac1fc1e1f (diff)
downloadmupdf-dd4f6ffd475b0e769ba6231cf24b050bcdc97814.tar.xz
Bug 693350: Add some dreaded 'const's for string keys.
On the whole we avoid using const within MuPDF, but bug 693350 highlights cases where this can cause a problem with C++. In C, if you do: foo("bar"); then "bar" has type char *. In C++, if you do foo("bar"); then "bar" has type const char *. This means that any calls to the MuPDF library from C++ that take strings give warnings. The fix is simple, so it seems to be worthwhile adding a few consts. None of our internal data structures are affected in any way by this change. Thanks to Franz Fellner for pointing out this issue.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/mupdf.h18
-rw-r--r--pdf/pdf_object.c20
2 files changed, 19 insertions, 19 deletions
diff --git a/pdf/mupdf.h b/pdf/mupdf.h
index b1f3da81..82f9bd6e 100644
--- a/pdf/mupdf.h
+++ b/pdf/mupdf.h
@@ -17,8 +17,8 @@ pdf_obj *pdf_new_null(fz_context *ctx);
pdf_obj *pdf_new_bool(fz_context *ctx, int b);
pdf_obj *pdf_new_int(fz_context *ctx, int i);
pdf_obj *pdf_new_real(fz_context *ctx, float f);
-pdf_obj *pdf_new_name(fz_context *ctx, char *str);
-pdf_obj *pdf_new_string(fz_context *ctx, char *str, int len);
+pdf_obj *pdf_new_name(fz_context *ctx, const char *str);
+pdf_obj *pdf_new_string(fz_context *ctx, const char *str, int len);
pdf_obj *pdf_new_indirect(fz_context *ctx, int num, int gen, void *doc);
pdf_obj *pdf_new_array(fz_context *ctx, int initialcap);
pdf_obj *pdf_new_dict(fz_context *ctx, int initialcap);
@@ -71,15 +71,15 @@ int pdf_dict_len(pdf_obj *dict);
pdf_obj *pdf_dict_get_key(pdf_obj *dict, int idx);
pdf_obj *pdf_dict_get_val(pdf_obj *dict, int idx);
pdf_obj *pdf_dict_get(pdf_obj *dict, pdf_obj *key);
-pdf_obj *pdf_dict_gets(pdf_obj *dict, char *key);
-pdf_obj *pdf_dict_getp(pdf_obj *dict, char *key);
-pdf_obj *pdf_dict_getsa(pdf_obj *dict, char *key, char *abbrev);
+pdf_obj *pdf_dict_gets(pdf_obj *dict, const char *key);
+pdf_obj *pdf_dict_getp(pdf_obj *dict, const char *key);
+pdf_obj *pdf_dict_getsa(pdf_obj *dict, const char *key, const char *abbrev);
void pdf_dict_put(pdf_obj *dict, pdf_obj *key, pdf_obj *val);
-void pdf_dict_puts(pdf_obj *dict, char *key, pdf_obj *val);
-void pdf_dict_puts_drop(pdf_obj *dict, char *key, pdf_obj *val);
-void pdf_dict_putp(pdf_obj *dict, char *key, pdf_obj *val);
+void pdf_dict_puts(pdf_obj *dict, const char *key, pdf_obj *val);
+void pdf_dict_puts_drop(pdf_obj *dict, const char *key, pdf_obj *val);
+void pdf_dict_putp(pdf_obj *dict, const char *key, pdf_obj *val);
void pdf_dict_del(pdf_obj *dict, pdf_obj *key);
-void pdf_dict_dels(pdf_obj *dict, char *key);
+void pdf_dict_dels(pdf_obj *dict, const char *key);
void pdf_sort_dict(pdf_obj *dict);
int pdf_fprint_obj(FILE *fp, pdf_obj *obj, int tight);
diff --git a/pdf/pdf_object.c b/pdf/pdf_object.c
index 1225a145..77e1da74 100644
--- a/pdf/pdf_object.c
+++ b/pdf/pdf_object.c
@@ -103,7 +103,7 @@ pdf_new_real(fz_context *ctx, float f)
}
pdf_obj *
-pdf_new_string(fz_context *ctx, char *str, int len)
+pdf_new_string(fz_context *ctx, const char *str, int len)
{
pdf_obj *obj;
obj = Memento_label(fz_malloc(ctx, offsetof(pdf_obj, u.s.buf) + len + 1), "pdf_obj(string)");
@@ -117,7 +117,7 @@ pdf_new_string(fz_context *ctx, char *str, int len)
}
pdf_obj *
-pdf_new_name(fz_context *ctx, char *str)
+pdf_new_name(fz_context *ctx, const char *str)
{
pdf_obj *obj;
obj = Memento_label(fz_malloc(ctx, offsetof(pdf_obj, u.n) + strlen(str) + 1), "pdf_obj(name)");
@@ -774,7 +774,7 @@ pdf_dict_get_val(pdf_obj *obj, int i)
}
static int
-pdf_dict_finds(pdf_obj *obj, char *key, int *location)
+pdf_dict_finds(pdf_obj *obj, const char *key, int *location)
{
if (obj->u.d.sorted && obj->u.d.len > 0)
{
@@ -819,7 +819,7 @@ pdf_dict_finds(pdf_obj *obj, char *key, int *location)
}
pdf_obj *
-pdf_dict_gets(pdf_obj *obj, char *key)
+pdf_dict_gets(pdf_obj *obj, const char *key)
{
int i;
@@ -835,7 +835,7 @@ pdf_dict_gets(pdf_obj *obj, char *key)
}
pdf_obj *
-pdf_dict_getp(pdf_obj *obj, char *keys)
+pdf_dict_getp(pdf_obj *obj, const char *keys)
{
char buf[256];
char *k, *e;
@@ -873,7 +873,7 @@ pdf_dict_get(pdf_obj *obj, pdf_obj *key)
}
pdf_obj *
-pdf_dict_getsa(pdf_obj *obj, char *key, char *abbrev)
+pdf_dict_getsa(pdf_obj *obj, const char *key, const char *abbrev)
{
pdf_obj *v;
v = pdf_dict_gets(obj, key);
@@ -943,7 +943,7 @@ pdf_dict_put(pdf_obj *obj, pdf_obj *key, pdf_obj *val)
}
void
-pdf_dict_puts(pdf_obj *obj, char *key, pdf_obj *val)
+pdf_dict_puts(pdf_obj *obj, const char *key, pdf_obj *val)
{
fz_context *ctx = obj->ctx;
pdf_obj *keyobj = pdf_new_name(ctx, key);
@@ -963,7 +963,7 @@ pdf_dict_puts(pdf_obj *obj, char *key, pdf_obj *val)
}
void
-pdf_dict_puts_drop(pdf_obj *obj, char *key, pdf_obj *val)
+pdf_dict_puts_drop(pdf_obj *obj, const char *key, pdf_obj *val)
{
fz_context *ctx = obj->ctx;
pdf_obj *keyobj = NULL;
@@ -987,7 +987,7 @@ pdf_dict_puts_drop(pdf_obj *obj, char *key, pdf_obj *val)
}
void
-pdf_dict_putp(pdf_obj *obj, char *keys, pdf_obj *val)
+pdf_dict_putp(pdf_obj *obj, const char *keys, pdf_obj *val)
{
fz_context *ctx = obj->ctx;
char buf[256];
@@ -1044,7 +1044,7 @@ pdf_dict_putp(pdf_obj *obj, char *keys, pdf_obj *val)
}
void
-pdf_dict_dels(pdf_obj *obj, char *key)
+pdf_dict_dels(pdf_obj *obj, const char *key)
{
RESOLVE(obj);