From f4cb197ad36f5ea3ab834abb41d2641daf152622 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 7 May 2018 16:46:16 +0200 Subject: Purge unused functions. --- include/mupdf/fitz/color-management.h | 1 - include/mupdf/fitz/colorspace.h | 1 - include/mupdf/fitz/context.h | 18 ---- include/mupdf/fitz/filter.h | 1 - include/mupdf/fitz/pixmap.h | 6 -- include/mupdf/fitz/separation.h | 6 -- include/mupdf/fitz/string-util.h | 7 -- include/mupdf/fitz/structured-text.h | 3 - include/mupdf/fitz/text.h | 9 -- include/mupdf/pdf/object.h | 3 - platform/java/mupdf_native.c | 41 --------- platform/java/mupdf_native.h | 8 -- platform/java/src/com/artifex/mupdf/fitz/Text.java | 5 -- source/fitz/color-lcms.c | 1 - source/fitz/colorspace-imp.h | 1 - source/fitz/colorspace.c | 20 ----- source/fitz/context.c | 48 ---------- source/fitz/filter-basic.c | 8 -- source/fitz/jmemcust.c | 10 --- source/fitz/jmemcust.h | 3 - source/fitz/memory.c | 10 --- source/fitz/pixmap.c | 25 ------ source/fitz/separation.c | 19 ---- source/fitz/stext-search.c | 53 ----------- source/fitz/strtof.c | 18 +--- source/fitz/text.c | 50 ----------- source/pdf/pdf-parse.c | 100 --------------------- 27 files changed, 3 insertions(+), 472 deletions(-) diff --git a/include/mupdf/fitz/color-management.h b/include/mupdf/fitz/color-management.h index a2f20e9d..85d5e293 100644 --- a/include/mupdf/fitz/color-management.h +++ b/include/mupdf/fitz/color-management.h @@ -77,7 +77,6 @@ struct fz_cmm_engine_s { fz_cmm_fin_link_fn *fin_link; fz_cmm_init_profile_fn *init_profile; fz_cmm_fin_profile_fn *fin_profile; - int avoid_white_fix_flag; }; /* diff --git a/include/mupdf/fitz/colorspace.h b/include/mupdf/fitz/colorspace.h index d5d4e46b..f027ce2e 100644 --- a/include/mupdf/fitz/colorspace.h +++ b/include/mupdf/fitz/colorspace.h @@ -166,7 +166,6 @@ void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace); void fz_drop_colorspace_imp(fz_context *ctx, fz_storable *colorspace); fz_colorspace *fz_colorspace_base(fz_context *ctx, const fz_colorspace *cs); -void fz_set_icc_bgr(fz_context *ctx, fz_colorspace *cs); int fz_colorspace_n(fz_context *ctx, const fz_colorspace *cs); int fz_colorspace_devicen_n(fz_context *ctx, const fz_colorspace *cs); const char *fz_colorspace_name(fz_context *ctx, const fz_colorspace *cs); diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h index 5a05f940..8f72ad99 100644 --- a/include/mupdf/fitz/context.h +++ b/include/mupdf/fitz/context.h @@ -12,7 +12,6 @@ typedef struct fz_alloc_context_s fz_alloc_context; typedef struct fz_error_context_s fz_error_context; typedef struct fz_error_stack_slot_s fz_error_stack_slot; -typedef struct fz_id_context_s fz_id_context; typedef struct fz_warn_context_s fz_warn_context; typedef struct fz_font_context_s fz_font_context; typedef struct fz_colorspace_context_s fz_colorspace_context; @@ -148,7 +147,6 @@ struct fz_context_s void *user; const fz_alloc_context *alloc; fz_locks_context locks; - fz_id_context *id; fz_error_context *error; fz_warn_context *warn; fz_font_context *font; @@ -536,22 +534,6 @@ void *fz_malloc_array_no_throw(fz_context *ctx, size_t count, size_t size); */ void *fz_resize_array_no_throw(fz_context *ctx, void *p, size_t count, size_t size); -/* - fz_strdup_no_throw: Duplicate a C string (with scavenging) - - s: The string to duplicate. - - Returns a pointer to a duplicated string. Returns NULL on failure - to allocate. -*/ -char *fz_strdup_no_throw(fz_context *ctx, const char *s); - -/* - fz_gen_id: Generate an id (guaranteed unique within this family of - contexts). -*/ -int fz_gen_id(fz_context *ctx); - struct fz_warn_context_s { char message[256]; diff --git a/include/mupdf/fitz/filter.h b/include/mupdf/fitz/filter.h index 782c4d80..495b960e 100644 --- a/include/mupdf/fitz/filter.h +++ b/include/mupdf/fitz/filter.h @@ -15,7 +15,6 @@ typedef struct int len; } fz_range; -fz_stream *fz_open_copy(fz_context *ctx, fz_stream *chain); fz_stream *fz_open_null_n(fz_context *ctx, fz_stream *chain, fz_range *ranges, int nranges); fz_stream *fz_open_null(fz_context *ctx, fz_stream *chain, int len, int64_t offset); fz_stream *fz_open_concat(fz_context *ctx, int max, int pad); diff --git a/include/mupdf/fitz/pixmap.h b/include/mupdf/fitz/pixmap.h index fcf9d8b3..b0422033 100644 --- a/include/mupdf/fitz/pixmap.h +++ b/include/mupdf/fitz/pixmap.h @@ -284,12 +284,6 @@ void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, const fz_irect *re */ void fz_gamma_pixmap(fz_context *ctx, fz_pixmap *pix, float gamma); -/* - fz_unmultiply_pixmap: Convert a pixmap from premultiplied to - non-premultiplied format. -*/ -void fz_unmultiply_pixmap(fz_context *ctx, fz_pixmap *pix); - /* fz_convert_pixmap: Convert an existing pixmap to a desired colorspace. Other properties of the pixmap, such as resolution diff --git a/include/mupdf/fitz/separation.h b/include/mupdf/fitz/separation.h index aa66b3ba..584ae7d1 100644 --- a/include/mupdf/fitz/separation.h +++ b/include/mupdf/fitz/separation.h @@ -52,18 +52,12 @@ void fz_set_separation_behavior(fz_context *ctx, fz_separations *sep, int separa /* Test for the current behavior of a separation */ fz_separation_behavior fz_separation_current_behavior(fz_context *ctx, const fz_separations *sep, int separation); -/* Quick test for all separations composite (the common case) */ -int fz_separations_all_composite(fz_context *ctx, const fz_separations *sep); - /* Read separation name */ const char *fz_separation_name(fz_context *ctx, const fz_separations *sep, int separation); /* Count the number of separations */ int fz_count_separations(fz_context *ctx, const fz_separations *sep); -/* Find out if separations are controllable. */ -int fz_separations_controllable(fz_context *ctx, const fz_separations *seps); - /* Return the number of active separations. */ int fz_count_active_separations(fz_context *ctx, const fz_separations *seps); diff --git a/include/mupdf/fitz/string-util.h b/include/mupdf/fitz/string-util.h index 13941d62..fdf47c86 100644 --- a/include/mupdf/fitz/string-util.h +++ b/include/mupdf/fitz/string-util.h @@ -141,13 +141,6 @@ int fz_utflen(const char *s); */ float fz_strtof(const char *s, char **es); -/* - fz_strtof_no_exp: Like fz_strtof, but does not recognize exponent - format. So fz_strtof_no_exp("1.5e20", &tail) will return 1.5 and tail - will point to "e20". -*/ - -float fz_strtof_no_exp(const char *string, char **tailptr); /* fz_grisu: Compute decimal integer m, exp such that: f = m * 10^exp diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h index b062813f..0ad6cd3c 100644 --- a/include/mupdf/fitz/structured-text.h +++ b/include/mupdf/fitz/structured-text.h @@ -103,9 +103,6 @@ struct fz_stext_char_s extern const char *fz_stext_options_usage; -int fz_stext_char_count(fz_context *ctx, fz_stext_page *page); -const fz_stext_char *fz_stext_char_at(fz_context *ctx, fz_stext_page *page, int idx); - /* fz_new_stext_page: Create an empty text page. diff --git a/include/mupdf/fitz/text.h b/include/mupdf/fitz/text.h index d7d7ffb5..d2b9d21f 100644 --- a/include/mupdf/fitz/text.h +++ b/include/mupdf/fitz/text.h @@ -158,15 +158,6 @@ void fz_show_string(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix *tr */ fz_rect *fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r); -/* - fz_clone_text: Clone a text object. - - text: The text object to clone. - - Throws an exception on allocation failure. -*/ -fz_text *fz_clone_text(fz_context *ctx, const fz_text *text); - /* Convert ISO 639 (639-{1,2,3,5}) language specification strings losslessly to a 15 bit fz_text_language code. diff --git a/include/mupdf/pdf/object.h b/include/mupdf/pdf/object.h index dfbaf3b2..677d79d4 100644 --- a/include/mupdf/pdf/object.h +++ b/include/mupdf/pdf/object.h @@ -169,10 +169,7 @@ void pdf_debug_obj(fz_context *ctx, pdf_obj *obj); char *pdf_to_utf8(fz_context *ctx, pdf_obj *src); char *pdf_load_stream_as_utf8(fz_context *ctx, pdf_obj *src); char *pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src); -unsigned short *pdf_to_ucs2(fz_context *ctx, pdf_obj *src); pdf_obj *pdf_to_utf8_name(fz_context *ctx, pdf_obj *src); -char *pdf_from_ucs2(fz_context *ctx, unsigned short *str); -void pdf_to_ucs2_buf(fz_context *ctx, unsigned short *buffer, pdf_obj *src); fz_rect *pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *rect); fz_matrix *pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *mat); diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 592c6c7d..231b3db9 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -4358,26 +4358,6 @@ FUN(Text_finalize)(JNIEnv *env, jobject self) fz_drop_text(ctx, text); } -JNIEXPORT jlong JNICALL -FUN(Text_clone)(JNIEnv *env, jobject self) -{ - fz_context *ctx = get_context(env); - fz_text *old_text = from_Text(env, self); - fz_text *new_text = NULL; - - if (!ctx || !old_text) return 0; - - fz_try(ctx) - new_text = fz_clone_text(ctx, old_text); - fz_catch(ctx) - { - jni_rethrow(env, ctx); - return 0; - } - - return jlong_cast(new_text); -} - JNIEXPORT jlong JNICALL FUN(Text_newNative)(JNIEnv *env, jobject self) { @@ -4397,27 +4377,6 @@ FUN(Text_newNative)(JNIEnv *env, jobject self) return jlong_cast(text); } -JNIEXPORT jlong JNICALL -FUN(Text_cloneNative)(JNIEnv *env, jobject self, jobject jold) -{ - fz_context *ctx = get_context(env); - fz_text *old = from_Text(env, jold); - fz_text *text = NULL; - - if (!ctx) return 0; - if (!old) { jni_throw_arg(env, "old must not be null"); return 0; } - - fz_try(ctx) - text = fz_clone_text(ctx, old); - fz_catch(ctx) - { - jni_rethrow(env, ctx); - return 0; - } - - return jlong_cast(text); -} - JNIEXPORT jobject JNICALL FUN(Text_getBounds)(JNIEnv *env, jobject self, jobject jstroke, jobject jctm) { diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h index 85e68b8f..1813aa18 100644 --- a/platform/java/mupdf_native.h +++ b/platform/java/mupdf_native.h @@ -3274,14 +3274,6 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Text_finalize JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_Text_newNative (JNIEnv *, jobject); -/* - * Class: com_artifex_mupdf_fitz_Text - * Method: cloneNative - * Signature: (Lcom/artifex/mupdf/fitz/Text;)J - */ -JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_Text_cloneNative - (JNIEnv *, jobject, jobject); - /* * Class: com_artifex_mupdf_fitz_Text * Method: showGlyph diff --git a/platform/java/src/com/artifex/mupdf/fitz/Text.java b/platform/java/src/com/artifex/mupdf/fitz/Text.java index 6dbc4845..b5067db2 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/Text.java +++ b/platform/java/src/com/artifex/mupdf/fitz/Text.java @@ -16,16 +16,11 @@ public class Text implements TextWalker } private native long newNative(); - private native long cloneNative(Text old); private Text(long p) { pointer = p; } - public Text(Text old) { - pointer = cloneNative(old); - } - public Text() { pointer = newNative(); } diff --git a/source/fitz/color-lcms.c b/source/fitz/color-lcms.c index 93a5e415..9efbb0b3 100644 --- a/source/fitz/color-lcms.c +++ b/source/fitz/color-lcms.c @@ -356,6 +356,5 @@ fz_cmm_engine fz_cmm_engine_lcms = { fz_lcms_fin_link, fz_lcms_init_profile, fz_lcms_fin_profile, - cmsFLAGS_NOWHITEONWHITEFIXUP }; #endif diff --git a/source/fitz/colorspace-imp.h b/source/fitz/colorspace-imp.h index 5fd1ffd0..8f3b85f6 100644 --- a/source/fitz/colorspace-imp.h +++ b/source/fitz/colorspace-imp.h @@ -12,7 +12,6 @@ #define FZ_ICC_PROFILE_CMYK "DeviceCMYK" #define FZ_ICC_PROFILE_LAB "Lab" -int fz_cmm_avoid_white_fix_flag(fz_context *ctx); void fz_cmm_transform_pixmap(fz_context *ctx, fz_icclink *link, fz_pixmap *dst, fz_pixmap *src); void fz_cmm_transform_color(fz_context *ctx, fz_icclink *link, unsigned short *dst, const unsigned short *src); void fz_cmm_init_link(fz_context *ctx, fz_icclink *link, const fz_iccprofile *dst, int dst_extras, const fz_iccprofile *src, int src_extras, const fz_iccprofile *prf, const fz_color_params *rend, int cmm_flags, int num_bytes, int copy_spots); diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index cb35d54f..5d08b808 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -91,14 +91,6 @@ int fz_colorspace_device_n_has_cmyk(fz_context *ctx, const fz_colorspace *cs) /* CMM module */ -int -fz_cmm_avoid_white_fix_flag(fz_context *ctx) -{ - if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) - return ctx->colorspace->cmm->avoid_white_fix_flag; - return 0; -} - void fz_cmm_transform_pixmap(fz_context *ctx, fz_icclink *link, fz_pixmap *dst, fz_pixmap *src) { @@ -3746,18 +3738,6 @@ clamp_default_icc(const fz_colorspace *cs, const float *src, float *dst) dst[i] = fz_clamp(src[i], 0, 1); } -void fz_set_icc_bgr(fz_context *ctx, fz_colorspace *cs) -{ - fz_iccprofile *profile; - - if (cs == NULL || !fz_colorspace_is_icc(ctx, cs)) - return; - - profile = cs->data; - profile->bgr = 1; - return; -} - fz_colorspace * fz_new_icc_colorspace(fz_context *ctx, const char *name, int num, fz_buffer *buf) { diff --git a/source/fitz/context.c b/source/fitz/context.c index 67fef05b..77b6d18a 100644 --- a/source/fitz/context.c +++ b/source/fitz/context.c @@ -5,37 +5,6 @@ #include #include -struct fz_id_context_s -{ - int refs; - int id; -}; - -static void -fz_drop_id_context(fz_context *ctx) -{ - if (!ctx) - return; - if (fz_drop_imp(ctx, ctx->id, &ctx->id->refs)) - fz_free(ctx, ctx->id); -} - -static void -fz_new_id_context(fz_context *ctx) -{ - ctx->id = fz_malloc_struct(ctx, fz_id_context); - ctx->id->refs = 1; - ctx->id->id = 0; -} - -static fz_id_context * -fz_keep_id_context(fz_context *ctx) -{ - if (!ctx) - return NULL; - return fz_keep_imp(ctx, ctx->id, &ctx->id->refs); -} - struct fz_style_context_s { int refs; @@ -165,7 +134,6 @@ fz_drop_context(fz_context *ctx) fz_drop_colorspace_context(ctx); fz_drop_cmm_context(ctx); fz_drop_font_context(ctx); - fz_drop_id_context(ctx); fz_drop_output_context(ctx); if (ctx->warn) @@ -263,7 +231,6 @@ fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, fz_new_cmm_context(ctx); fz_new_colorspace_context(ctx); fz_new_font_context(ctx); - fz_new_id_context(ctx); fz_new_document_handler_context(ctx); fz_new_style_context(ctx); fz_new_tuning_context(ctx); @@ -318,8 +285,6 @@ fz_clone_context_internal(fz_context *ctx) new_ctx->font = fz_keep_font_context(new_ctx); new_ctx->style = ctx->style; new_ctx->style = fz_keep_style_context(new_ctx); - new_ctx->id = ctx->id; - new_ctx->id = fz_keep_id_context(new_ctx); new_ctx->tuning = ctx->tuning; new_ctx->tuning = fz_keep_tuning_context(new_ctx); memcpy(new_ctx->seed48, ctx->seed48, sizeof ctx->seed48); @@ -329,19 +294,6 @@ fz_clone_context_internal(fz_context *ctx) return new_ctx; } -int -fz_gen_id(fz_context *ctx) -{ - int id; - fz_lock(ctx, FZ_LOCK_ALLOC); - /* We'll never wrap around in normal use, but if we do, then avoid 0. */ - do - id = ++ctx->id->id; - while (id == 0); - fz_unlock(ctx, FZ_LOCK_ALLOC); - return id; -} - void fz_set_user_context(fz_context *ctx, void *user) { if (ctx != NULL) diff --git a/source/fitz/filter-basic.c b/source/fitz/filter-basic.c index f558f43b..5e03a176 100644 --- a/source/fitz/filter-basic.c +++ b/source/fitz/filter-basic.c @@ -2,14 +2,6 @@ #include -/* Pretend we have a filter that just copies data forever */ - -fz_stream * -fz_open_copy(fz_context *ctx, fz_stream *chain) -{ - return fz_keep_stream(ctx, chain); -} - /* Null filter copies a specified amount of data */ struct null_filter diff --git a/source/fitz/jmemcust.c b/source/fitz/jmemcust.c index d5318026..d0cb3048 100644 --- a/source/fitz/jmemcust.c +++ b/source/fitz/jmemcust.c @@ -155,14 +155,4 @@ jpeg_cust_mem_init(jpeg_cust_mem_data *custm, void *priv, return lcustm; } -GLOBAL(jpeg_cust_mem_data *) -jpeg_cust_mem_set_private(jpeg_cust_mem_data *custm, void *priv) -{ - if (custm) - { - custm->priv = priv; - } - return custm; -} - #endif /* !defined(SHARE_JPEG) || SHARE_JPEG==0 */ diff --git a/source/fitz/jmemcust.h b/source/fitz/jmemcust.h index 6e5f6ead..9447fd4d 100644 --- a/source/fitz/jmemcust.h +++ b/source/fitz/jmemcust.h @@ -46,6 +46,3 @@ GLOBAL(jpeg_cust_mem_data *) j_cust_mem_get_large_ptr get_large, j_custmem_free_large_ptr free_large, j_custmem_open_backing_store_ptr open_backing_store); - -GLOBAL(jpeg_cust_mem_data *) - jpeg_cust_mem_set_private(jpeg_cust_mem_data *custm, void *priv); diff --git a/source/fitz/memory.c b/source/fitz/memory.c index ad5b69aa..09df7cda 100644 --- a/source/fitz/memory.c +++ b/source/fitz/memory.c @@ -212,16 +212,6 @@ fz_strdup(fz_context *ctx, const char *s) return ns; } -char * -fz_strdup_no_throw(fz_context *ctx, const char *s) -{ - size_t len = strlen(s) + 1; - char *ns = fz_malloc_no_throw(ctx, len); - if (ns) - memcpy(ns, s, len); - return ns; -} - static void * fz_malloc_default(void *opaque, size_t size) { diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index a0abb5de..9159fea0 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -727,31 +727,6 @@ fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix) } } -void -fz_unmultiply_pixmap(fz_context *ctx, fz_pixmap *pix) -{ - unsigned char *s = pix->samples; - int a, inva; - int k, x, y; - int stride = pix->stride - pix->w * pix->n; - - if (!pix->alpha) - return; - - for (y = 0; y < pix->h; y++) - { - for (x = 0; x < pix->w; x++) - { - a = s[pix->n - 1]; - inva = a ? 255 * 256 / a : 0; - for (k = 0; k < pix->n - 1; k++) - s[k] = (s[k] * inva) >> 8; - s += pix->n; - } - s += stride; - } -} - fz_pixmap * fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray) { diff --git a/source/fitz/separation.c b/source/fitz/separation.c index fe1530a7..c0f01f28 100644 --- a/source/fitz/separation.c +++ b/source/fitz/separation.c @@ -89,11 +89,6 @@ void fz_add_separation_equivalents(fz_context *ctx, fz_separations *sep, uint32_ sep->num_separations++; } -int fz_separations_controllable(fz_context *ctx, const fz_separations *sep) -{ - return (!sep || sep->controllable); -} - void fz_set_separation_behavior(fz_context *ctx, fz_separations *sep, int separation, fz_separation_behavior beh) { int shift; @@ -147,20 +142,6 @@ fz_separation_behavior fz_separation_current_behavior(fz_context *ctx, const fz_ return beh; } -int fz_separations_all_composite(fz_context *ctx, const fz_separations *sep) -{ - int i; - - if (!sep) - return 1; - - for (i = 0; i < (FZ_MAX_SEPARATIONS + 31) / 32; i++) - if (sep_state(sep, i) != FZ_SEPARATION_COMPOSITE) - return 0; - - return 1; -} - const char *fz_separation_name(fz_context *ctx, const fz_separations *sep, int separation) { if (!sep || separation < 0 || separation >= sep->num_separations) diff --git a/source/fitz/stext-search.c b/source/fitz/stext-search.c index 3e2d08df..b73296e3 100644 --- a/source/fitz/stext-search.c +++ b/source/fitz/stext-search.c @@ -4,59 +4,6 @@ #include #include -int fz_stext_char_count(fz_context *ctx, fz_stext_page *page) -{ - fz_stext_block *block; - fz_stext_line *line; - fz_stext_char *ch; - int len = 0; - - for (block = page->first_block; block; block = block->next) - { - if (block->type != FZ_STEXT_BLOCK_TEXT) - continue; - for (line = block->u.t.first_line; line; line = line->next) - { - for (ch = line->first_char; ch; ch = ch->next) - ++len; - ++len; /* pseudo-newline */ - } - } - - return len; -} - -const fz_stext_char *fz_stext_char_at(fz_context *ctx, fz_stext_page *page, int idx) -{ - static const fz_stext_char space = { ' ', {0,0}, {0,0,0,0}, 0, NULL, NULL }; - static const fz_stext_char zero = { '\0', {0,0}, {0,0,0,0}, 0, NULL, NULL }; - fz_stext_block *block; - fz_stext_line *line; - fz_stext_char *ch; - int ofs = 0; - - for (block = page->first_block; block; block = block->next) - { - if (block->type != FZ_STEXT_BLOCK_TEXT) - continue; - for (line = block->u.t.first_line; line; line = line->next) - { - for (ch = line->first_char; ch; ch = ch->next) - { - if (ofs == idx) - return ch; - ++ofs; - } - - /* pseudo-newline */ - if (idx == ofs) - return &space; - ++ofs; - } - } - return &zero; -} - /* Enumerate marked selection */ static float dist2(float a, float b) diff --git a/source/fitz/strtof.c b/source/fitz/strtof.c index 2786a794..83679a75 100644 --- a/source/fitz/strtof.c +++ b/source/fitz/strtof.c @@ -332,8 +332,8 @@ starts_with(const char **s, const char *string) *tailptr = (char *) s; \ while (0) -static float -strtof_internal(const char *string, char **tailptr, int exp_format) +float +fz_strtof(const char *string, char **tailptr) { /* FIXME: error (1/2 + 1/256) ulp */ const char *s; @@ -421,7 +421,7 @@ strtof_internal(const char *string, char **tailptr, int exp_format) } /* Parse exponent. */ - if (exp_format && (*s == 'e' || *s == 'E')) + if (*s == 'e' || *s == 'E') { int exp_negative = 0; int exp = 0; @@ -457,15 +457,3 @@ strtof_internal(const char *string, char **tailptr, int exp_format) SET_TAILPTR(tailptr, s); return scale_integer_to_float(M, N, negative); } - -float -fz_strtof(const char *string, char **tailptr) -{ - return strtof_internal(string, tailptr, 1); -} - -float -fz_strtof_no_exp(const char *string, char **tailptr) -{ - return strtof_internal(string, tailptr, 0); -} diff --git a/source/fitz/text.c b/source/fitz/text.c index 8a01e550..90698125 100644 --- a/source/fitz/text.c +++ b/source/fitz/text.c @@ -171,56 +171,6 @@ fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *strok return bbox; } -fz_text * -fz_clone_text(fz_context *ctx, const fz_text *text) -{ - fz_text *new_text; - fz_text_span *span; - fz_text_span **tail; - - new_text = fz_malloc_struct(ctx, fz_text); - new_text->refs = 1; - span = text->head; - tail = &new_text->head; - - fz_var(span); - - fz_try(ctx) - { - while (span != NULL) - { - fz_text_span *new_span = fz_malloc_struct(ctx, fz_text_span); - *tail = new_span; - tail = &new_span->next; - new_text->tail = new_span; - new_span->font = fz_keep_font(ctx, span->font); - new_span->trm = span->trm; - new_span->wmode = span->wmode; - new_span->len = span->len; - new_span->cap = span->len; - new_span->items = fz_malloc(ctx, span->len * sizeof(*span->items)); - memcpy(new_span->items, span->items, span->len * sizeof(*span->items)); - span = span->next; - } - } - fz_catch(ctx) - { - span = new_text->head; - while (span != NULL) - { - fz_text_span *next = span->next; - fz_drop_font(ctx, span->font); - fz_free(ctx, span->items); - fz_free(ctx, span); - span = next; - } - fz_free(ctx, new_text); - fz_rethrow(ctx); - } - - return new_text; -} - fz_text_language fz_text_language_from_string(const char *str) { fz_text_language lang; diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c index 104b117d..f4075c5a 100644 --- a/source/pdf/pdf-parse.c +++ b/source/pdf/pdf-parse.c @@ -208,106 +208,6 @@ pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src) return pdf_to_utf8(ctx, src); } -/* Convert Unicode/PdfDocEncoding string into ucs-2 */ -unsigned short * -pdf_to_ucs2(fz_context *ctx, pdf_obj *src) -{ - unsigned char *srcptr = (unsigned char *) pdf_to_str_buf(ctx, src); - unsigned short *dstptr, *dst; - int srclen = pdf_to_str_len(ctx, src); - int i; - - if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255) - { - dstptr = dst = fz_malloc_array(ctx, (srclen - 2) / 2 + 1, sizeof(short)); - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] << 8 | srcptr[i+1]; - } - else if (srclen >= 2 && srcptr[0] == 255 && srcptr[1] == 254) - { - dstptr = dst = fz_malloc_array(ctx, (srclen - 2) / 2 + 1, sizeof(short)); - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] | srcptr[i+1] << 8; - } - else - { - dstptr = dst = fz_malloc_array(ctx, srclen + 1, sizeof(short)); - for (i = 0; i < srclen; i++) - *dstptr++ = pdf_doc_encoding[srcptr[i]]; - } - - *dstptr = '\0'; - return dst; -} - -/* allow conversion to UCS-2 without the need for a fz_context */ -/* (buffer must be at least (fz_to_str_len(src) + 1) * 2 bytes in size) */ -void -pdf_to_ucs2_buf(fz_context *ctx, unsigned short *buffer, pdf_obj *src) -{ - unsigned char *srcptr = (unsigned char *) pdf_to_str_buf(ctx, src); - unsigned short *dstptr = buffer; - int srclen = pdf_to_str_len(ctx, src); - int i; - - if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255) - { - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] << 8 | srcptr[i+1]; - } - else if (srclen >= 2 && srcptr[0] == 255 && srcptr[1] == 254) - { - for (i = 2; i + 1 < srclen; i += 2) - *dstptr++ = srcptr[i] | srcptr[i+1] << 8; - } - else - { - for (i = 0; i < srclen; i++) - *dstptr++ = pdf_doc_encoding[srcptr[i]]; - } - - *dstptr = '\0'; -} - -/* Convert UCS-2 string into PdfDocEncoding for authentication */ -char * -pdf_from_ucs2(fz_context *ctx, unsigned short *src) -{ - int i, j, len; - char *docstr; - - len = 0; - while (src[len]) - len++; - - docstr = fz_malloc(ctx, len + 1); - - for (i = 0; i < len; i++) - { - /* shortcut: check if the character has the same code point in both encodings */ - if (0 < src[i] && src[i] < 256 && pdf_doc_encoding[src[i]] == src[i]) { - docstr[i] = src[i]; - continue; - } - - /* search through pdf_docencoding for the character's code point */ - for (j = 0; j < 256; j++) - if (pdf_doc_encoding[j] == src[i]) - break; - docstr[i] = j; - - /* fail, if a character can't be encoded */ - if (!docstr[i]) - { - fz_free(ctx, docstr); - return NULL; - } - } - docstr[len] = '\0'; - - return docstr; -} - pdf_obj * pdf_to_utf8_name(fz_context *ctx, pdf_obj *src) { -- cgit v1.2.3