From 6108f235c54fb039e92f7aebce75a774c9255e24 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 20 Nov 2012 13:44:27 +0100 Subject: Obsess about whitespace. --- apps/jstest_main.c | 2 +- apps/mudraw.c | 2 +- draw/draw_device.c | 5 ++-- draw/draw_mesh.c | 4 +-- draw/draw_simple_scale.c | 6 ++-- fitz/crypt_sha2.c | 14 ++++----- fitz/filt_faxd.c | 2 +- fitz/fitz.h | 12 ++++---- fitz/image_tiff.c | 2 +- fitz/res_colorspace.c | 70 +++++++++++++++++++++---------------------- fitz/res_font.c | 4 +-- pdf/pdf_cmap.c | 4 +-- pdf/pdf_form.c | 19 ++++++------ pdf/pdf_interpret.c | 2 +- pdf/pdf_js.c | 24 +++++++-------- pdf/pdf_object.c | 3 +- pdf/pdf_write.c | 77 ++++++++++++++++++++++++++---------------------- xps/xps_util.c | 2 +- 18 files changed, 129 insertions(+), 125 deletions(-) diff --git a/apps/jstest_main.c b/apps/jstest_main.c index 9ea7ee26..ff7f9497 100644 --- a/apps/jstest_main.c +++ b/apps/jstest_main.c @@ -164,7 +164,7 @@ usage(void) fprintf(stderr, "\nSyntax: mujstest -o [ -p ] [-v] \n"); fprintf(stderr, "\n should sensibly be of the form file-%%d.png\n"); fprintf(stderr, "\n is a path prefix to apply to filenames within the script\n"); - fprintf(stderr, "\n-v verbose\n"); + fprintf(stderr, "\n-v\tverbose\n"); fprintf(stderr, "\nscriptfile contains a list of commands:\n"); fprintf(stderr, "\tPASSWORD \tSet the password\n"); fprintf(stderr, "\tOPEN \tOpen a file\n"); diff --git a/apps/mudraw.c b/apps/mudraw.c index 33203749..0573f477 100644 --- a/apps/mudraw.c +++ b/apps/mudraw.c @@ -209,7 +209,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) { fz_interactive *inter = fz_interact(doc); fz_widget *widget = NULL; - + if (inter) widget = fz_first_widget(inter, page); diff --git a/draw/draw_device.c b/draw/draw_device.c index 25ebdaab..8d2c4d8b 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -1694,9 +1694,8 @@ fz_draw_free_user(fz_device *devp) fz_drop_pixmap(ctx, state[1].shape); } /* We never free the dest/mask/shape at level 0, as: - * 1) dest is passed in and ownership remains with the - * caller. - * 2) shape and mask are NULL at level 0. + * 1) dest is passed in and ownership remains with the caller. + * 2) shape and mask are NULL at level 0. */ if (dev->stack != &dev->init_stack[0]) fz_free(ctx, dev->stack); diff --git a/draw/draw_mesh.c b/draw/draw_mesh.c index 8a181235..14470da6 100644 --- a/draw/draw_mesh.c +++ b/draw/draw_mesh.c @@ -245,9 +245,9 @@ fz_paint_triangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbo for (i = 0; i < len; i++) { gel[i][0] = floorf(poly[i][0] + 0.5f) * 65536; /* trunc and fix */ - gel[i][1] = floorf(poly[i][1] + 0.5f); /* y is not fixpoint */ + gel[i][1] = floorf(poly[i][1] + 0.5f); /* y is not fixpoint */ for (k = 2; k < n; k++) - gel[i][k] = poly[i][k] * 65536; /* fix with precision */ + gel[i][k] = poly[i][k] * 65536; /* fix with precision */ } top = bot = 0; diff --git a/draw/draw_simple_scale.c b/draw/draw_simple_scale.c index 8c438783..90fd75e0 100644 --- a/draw/draw_simple_scale.c +++ b/draw/draw_simple_scale.c @@ -611,8 +611,8 @@ scale_row_to_temp1(unsigned char *dst, unsigned char *src, fz_weights *weights) "subs r9, r9, #1 @ len-- \n" "blt 3f @ while (len >= 0) \n" "2: @ { \n" - "ldrgt r6, [r2], #4 @ r6 = *contrib++ \n" - "ldrgtb r7, [r4], #1 @ r7 = *min++ \n" + "ldrgt r6, [r2], #4 @ r6 = *contrib++ \n" + "ldrgtb r7, [r4], #1 @ r7 = *min++ \n" "ldr r12,[r2], #4 @ r12 = *contrib++ \n" "ldrb r14,[r4], #1 @ r14 = *min++ \n" "mlagt r5, r6, r7, r5 @ g += r6 * r7 \n" @@ -818,7 +818,7 @@ scale_row_from_temp(unsigned char *dst, unsigned char *src, fz_weights *weights, "blt 4f @ while (x >= 0) { \n" #ifndef ARCH_ARM_CAN_LOAD_UNALIGNED "tst r3, #3 @ if ((r3 & 3) \n" - "tsteq r1, #3 @ || (r1 & 3)) \n" + "tsteq r1, #3 @ || (r1 & 3)) \n" "bne 4f @ can't do fast code \n" #endif "ldr r9, =0x00FF00FF @ r9 = 0x00FF00FF \n" diff --git a/fitz/crypt_sha2.c b/fitz/crypt_sha2.c index 1a91fdda..dee0ccf7 100644 --- a/fitz/crypt_sha2.c +++ b/fitz/crypt_sha2.c @@ -34,13 +34,13 @@ static inline uint64_t bswap64(uint64_t num) if (!isbigendian()) { return ( (((num) << 56)) - | (((num) << 40) & 0x00FF000000000000ULL) - | (((num) << 24) & 0x0000FF0000000000ULL) - | (((num) << 8) & 0x000000FF00000000ULL) - | (((num) >> 8) & 0x00000000FF000000ULL) - | (((num) >> 24) & 0x0000000000FF0000ULL) - | (((num) >> 40) & 0x000000000000FF00ULL) - | (((num) >> 56)) ); + | (((num) << 40) & 0x00FF000000000000ULL) + | (((num) << 24) & 0x0000FF0000000000ULL) + | (((num) << 8) & 0x000000FF00000000ULL) + | (((num) >> 8) & 0x00000000FF000000ULL) + | (((num) >> 24) & 0x0000000000FF0000ULL) + | (((num) >> 40) & 0x000000000000FF00ULL) + | (((num) >> 56)) ); } return num; } diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c index a23e6319..1de6b970 100644 --- a/fitz/filt_faxd.c +++ b/fitz/filt_faxd.c @@ -31,7 +31,7 @@ enum cfd_white_initial_bits = 8, cfd_black_initial_bits = 7, cfd_2d_initial_bits = 7, - cfd_uncompressed_initial_bits = 6 /* must be 6 */ + cfd_uncompressed_initial_bits = 6 /* must be 6 */ }; /* non-run codes in tables */ diff --git a/fitz/fitz.h b/fitz/fitz.h index f058df50..77e690e7 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -2549,7 +2549,7 @@ typedef struct fz_ui_event_s { struct { - int ptype; + int ptype; fz_point pt; } pointer; } event; @@ -2881,14 +2881,14 @@ typedef struct fz_write_options_s fz_write_options; */ struct fz_write_options_s { - int do_ascii; /* If non-zero then attempt (where possible) to - make the output ascii. */ - int do_expand; /* Bitflags; each non zero bit indicates an aspect + int do_ascii; /* If non-zero then attempt (where possible) to make + the output ascii. */ + int do_expand; /* Bitflags; each non zero bit indicates an aspect of the file that should be 'expanded' on writing. */ - int do_garbage; /* If non-zero then attempt (where possible) to + int do_garbage; /* If non-zero then attempt (where possible) to garbage collect the file before writing. */ - int do_linear; /* If non-zero then write linearised. */ + int do_linear; /* If non-zero then write linearised. */ }; /* An enumeration of bitflags to use in the above 'do_expand' field of diff --git a/fitz/image_tiff.c b/fitz/image_tiff.c index f79e8672..2176062c 100644 --- a/fitz/image_tiff.c +++ b/fitz/image_tiff.c @@ -47,7 +47,7 @@ struct tiff unsigned ycbcrsubsamp[2]; - unsigned char *jpegtables; /* point into "file" buffer */ + unsigned char *jpegtables; /* point into "file" buffer */ unsigned jpegtableslen; unsigned char *profile; diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c index edda776d..50c0a8f7 100644 --- a/fitz/res_colorspace.c +++ b/fitz/res_colorspace.c @@ -86,13 +86,13 @@ static void cmyk_to_rgb(fz_context *ctx, fz_colorspace *cs, float *cmyk, float * float c1m = m - cm; float cm1 = c - cm; float c1m1 = 1 - m - cm1; - float c1m1y = c1m1 * y; + float c1m1y = c1m1 * y; float c1m1y1 = c1m1 - c1m1y; - float c1my = c1m * y; + float c1my = c1m * y; float c1my1 = c1m - c1my; - float cm1y = cm1 * y; + float cm1y = cm1 * y; float cm1y1 = cm1 - cm1y; - float cmy = cm * y; + float cmy = cm * y; float cmy1 = cm - cmy; /* this is a matrix multiplication, unrolled for performance */ @@ -389,13 +389,13 @@ static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src) c1m = (m<<8) - cm; cm1 = (c<<8) - cm; c1m1 = ((256 - m)<<8) - cm1; - c1m1y = c1m1 * y; + c1m1y = c1m1 * y; c1m1y1 = (c1m1<<7) - c1m1y; - c1my = c1m * y; + c1my = c1m * y; c1my1 = (c1m<<7) - c1my; - cm1y = cm1 * y; + cm1y = cm1 * y; cm1y1 = (cm1<<7) - cm1y; - cmy = cm * y; + cmy = cm * y; cmy1 = (cm<<7) - cmy; /* this is a matrix multiplication, unrolled for performance */ @@ -403,67 +403,67 @@ static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src) x0 = (c1m1y1<<8) - x1; /* 0 0 0 0 */ x1 = x1>>8; /* From 23 fractional bits to 15 */ r = g = b = x0; - r += 35 * x1; /* 0.1373 */ - g += 31 * x1; /* 0.1216 */ - b += 32 * x1; /* 0.1255 */ + r += 35 * x1; /* 0.1373 */ + g += 31 * x1; /* 0.1216 */ + b += 32 * x1; /* 0.1255 */ x1 = c1m1y * k; /* 0 0 1 1 */ x0 = (c1m1y<<8) - x1; /* 0 0 1 0 */ x1 >>= 8; /* From 23 fractional bits to 15 */ - r += 28 * x1; /* 0.1098 */ - g += 26 * x1; /* 0.1020 */ + r += 28 * x1; /* 0.1098 */ + g += 26 * x1; /* 0.1020 */ r += x0; x0 >>= 8; /* From 23 fractional bits to 15 */ - g += 243 * x0; /* 0.9490 */ + g += 243 * x0; /* 0.9490 */ x1 = c1my1 * k; /* 0 1 0 1 */ x0 = (c1my1<<8) - x1; /* 0 1 0 0 */ x1 >>= 8; /* From 23 fractional bits to 15 */ x0 >>= 8; /* From 23 fractional bits to 15 */ - r += 36 * x1; /* 0.1412 */ - r += 237 * x0; /* 0.9255 */ - b += 141 * x0; /* 0.5490 */ + r += 36 * x1; /* 0.1412 */ + r += 237 * x0; /* 0.9255 */ + b += 141 * x0; /* 0.5490 */ x1 = c1my * k; /* 0 1 1 1 */ x0 = (c1my<<8) - x1; /* 0 1 1 0 */ x1 >>= 8; /* From 23 fractional bits to 15 */ x0 >>= 8; /* From 23 fractional bits to 15 */ - r += 34 * x1; /* 0.1333 */ - r += 238 * x0; /* 0.9294 */ - g += 28 * x0; /* 0.1098 */ - b += 36 * x0; /* 0.1412 */ + r += 34 * x1; /* 0.1333 */ + r += 238 * x0; /* 0.9294 */ + g += 28 * x0; /* 0.1098 */ + b += 36 * x0; /* 0.1412 */ x1 = cm1y1 * k; /* 1 0 0 1 */ x0 = (cm1y1<<8) - x1; /* 1 0 0 0 */ x1 >>= 8; /* From 23 fractional bits to 15 */ x0 >>= 8; /* From 23 fractional bits to 15 */ - g += 15 * x1; /* 0.0588 */ - b += 36 * x1; /* 0.1412 */ - g += 174 * x0; /* 0.6784 */ - b += 240 * x0; /* 0.9373 */ + g += 15 * x1; /* 0.0588 */ + b += 36 * x1; /* 0.1412 */ + g += 174 * x0; /* 0.6784 */ + b += 240 * x0; /* 0.9373 */ x1 = cm1y * k; /* 1 0 1 1 */ x0 = (cm1y<<8) - x1; /* 1 0 1 0 */ x1 >>= 8; /* From 23 fractional bits to 15 */ x0 >>= 8; /* From 23 fractional bits to 15 */ - g += 19 * x1; /* 0.0745 */ - g += 167 * x0; /* 0.6510 */ - b += 80 * x0; /* 0.3137 */ + g += 19 * x1; /* 0.0745 */ + g += 167 * x0; /* 0.6510 */ + b += 80 * x0; /* 0.3137 */ x1 = cmy1 * k; /* 1 1 0 1 */ x0 = (cmy1<<8) - x1; /* 1 1 0 0 */ x1 >>= 8; /* From 23 fractional bits to 15 */ x0 >>= 8; /* From 23 fractional bits to 15 */ - b += 2 * x1; /* 0.0078 */ - r += 46 * x0; /* 0.1804 */ - g += 49 * x0; /* 0.1922 */ - b += 147 * x0; /* 0.5725 */ + b += 2 * x1; /* 0.0078 */ + r += 46 * x0; /* 0.1804 */ + g += 49 * x0; /* 0.1922 */ + b += 147 * x0; /* 0.5725 */ x0 = cmy * (256-k); /* 1 1 1 0 */ x0 >>= 8; /* From 23 fractional bits to 15 */ - r += 54 * x0; /* 0.2118 */ - g += 54 * x0; /* 0.2119 */ - b += 57 * x0; /* 0.2235 */ + r += 54 * x0; /* 0.2118 */ + g += 54 * x0; /* 0.2119 */ + b += 57 * x0; /* 0.2235 */ r -= (r>>8); g -= (g>>8); diff --git a/fitz/res_font.c b/fitz/res_font.c index 77cae676..b7304e55 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -142,9 +142,9 @@ struct fz_font_context_s { }; #undef __FTERRORS_H__ -#define FT_ERRORDEF(e, v, s) { (e), (s) }, +#define FT_ERRORDEF(e, v, s) { (e), (s) }, #define FT_ERROR_START_LIST -#define FT_ERROR_END_LIST { 0, NULL } +#define FT_ERROR_END_LIST { 0, NULL } struct ft_error { diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c index d6cb3103..67626b31 100644 --- a/pdf/pdf_cmap.c +++ b/pdf/pdf_cmap.c @@ -306,8 +306,8 @@ static int cmprange(const void *va, const void *vb) void pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap) { - pdf_range *a; /* last written range on output */ - pdf_range *b; /* current range examined on input */ + pdf_range *a; /* last written range on output */ + pdf_range *b; /* current range examined on input */ if (cmap->rlen == 0) return; diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index 0d08c215..872e02ad 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -56,8 +56,8 @@ enum enum { - Q_Left = 0, - Q_Cent = 1, + Q_Left = 0, + Q_Cent = 1, Q_Right = 2 }; @@ -203,7 +203,7 @@ static int get_field_flags(pdf_document *doc, pdf_obj *obj) int pdf_field_type(pdf_document *doc, pdf_obj *obj) { char *type = get_field_type_name(doc, obj); - int flags = get_field_flags(doc, obj); + int flags = get_field_flags(doc, obj); if (!strcmp(type, "Btn")) { @@ -514,8 +514,7 @@ static fz_buffer *create_aligned_text_buffer(pdf_document *doc, fz_rect *clip, t { fz_rect rect = measure_text(doc, &info->font_rec, tm, text); - atm.e -= info->q == Q_Right ? rect.x1 - : (rect.x1 - rect.x0) / 2; + atm.e -= info->q == Q_Right ? rect.x1 : (rect.x1 - rect.x0) / 2; } return create_text_buffer(ctx, clip, info, &atm, text); @@ -793,7 +792,7 @@ static fz_buffer *create_text_appearance(pdf_document *doc, fz_rect *bbox, fz_ma fz_var(fztmp); fz_try(ctx) { - float ascent, descent; + float ascent, descent; fz_matrix tm; variable = (info->font_rec.da_rec.font_size == 0); @@ -941,7 +940,7 @@ static void update_marked_content(pdf_document *doc, pdf_xobject *form, fz_buffe fz_stream *str_outer = NULL; fz_stream *str_inner = NULL; unsigned char *buf; - int len; + int len; fz_buffer *newbuf = NULL; pdf_lexbuf_init(ctx, &lbuf, PDF_LEXBUF_SMALL); @@ -1546,7 +1545,7 @@ void pdf_field_reset(pdf_document *doc, pdf_obj *field) * FIXME: we assume for now that V has not been set unequal * to DV higher in the hierarchy than "field". * - * At the bottom of the hierarchy we may find widget annotations + * At the bottom of the hierarchy we may find widget annotations * that aren't also fields, but DV and V will not be present in their * dictionaries, and attempts to remove V will be harmless. */ pdf_obj *dv = pdf_dict_gets(field, "DV"); @@ -1943,7 +1942,7 @@ static void toggle_check_box(pdf_document *doc, pdf_obj *obj) } else { - pdf_obj *n, *key = NULL; + pdf_obj *n, *key = NULL; int len, i; n = pdf_dict_getp(obj, "AP/N"); @@ -2020,7 +2019,7 @@ int pdf_pass_event(pdf_document *doc, pdf_page *page, fz_ui_event *ui_event) { pdf_annot *annot; pdf_hotspot *hp = &doc->hotspot; - fz_point *pt = &(ui_event->event.pointer.pt); + fz_point *pt = &(ui_event->event.pointer.pt); int changed = 0; for (annot = page->annots; annot; annot = annot->next) diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index b4593126..1acef7df 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -264,7 +264,7 @@ pdf_is_hidden_ocg(pdf_obj *ocg, pdf_csi *csi, pdf_obj *rdb) { combine = 3; } - else /* Assume it's the default (AnyOn) */ + else /* Assume it's the default (AnyOn) */ { combine = 0; } diff --git a/pdf/pdf_js.c b/pdf/pdf_js.c index 6d72121c..6e71f528 100644 --- a/pdf/pdf_js.c +++ b/pdf/pdf_js.c @@ -15,7 +15,7 @@ struct pdf_js_s static pdf_jsimp_obj *app_alert(void *jsctx, void *obj, int argc, pdf_jsimp_obj *args[]) { - pdf_js *js = (pdf_js *)jsctx; + pdf_js *js = (pdf_js *)jsctx; fz_context *ctx = js->doc->ctx; pdf_jsimp_obj *cMsg_obj = NULL; pdf_jsimp_obj *nIcon_obj = NULL; @@ -186,9 +186,9 @@ static pdf_obj *load_color(fz_context *ctx, pdf_jsimp *imp, pdf_jsimp_obj *val) static pdf_jsimp_obj *field_buttonSetCaption(void *jsctx, void *obj, int argc, pdf_jsimp_obj *args[]) { - pdf_js *js = (pdf_js *)jsctx; + pdf_js *js = (pdf_js *)jsctx; pdf_obj *field = (pdf_obj *)obj; - char *name; + char *name; if (argc != 1) return NULL; @@ -448,7 +448,7 @@ static char *utf8_to_pdf(fz_context *ctx, char *utf8) static pdf_jsimp_obj *doc_getField(void *jsctx, void *obj, int argc, pdf_jsimp_obj *args[]) { - pdf_js *js = (pdf_js *)jsctx; + pdf_js *js = (pdf_js *)jsctx; fz_context *ctx = js->doc->ctx; pdf_obj *dict = NULL; char *utf8; @@ -513,7 +513,7 @@ static void reset_field(pdf_js *js, pdf_jsimp_obj *item) static pdf_jsimp_obj *doc_resetForm(void *jsctx, void *obj, int argc, pdf_jsimp_obj *args[]) { - pdf_js *js = (pdf_js *)jsctx; + pdf_js *js = (pdf_js *)jsctx; fz_context *ctx = js->doc->ctx; pdf_jsimp_obj *arr = NULL; pdf_jsimp_obj *elem = NULL; @@ -581,7 +581,7 @@ static pdf_jsimp_obj *doc_resetForm(void *jsctx, void *obj, int argc, pdf_jsimp_ static pdf_jsimp_obj *doc_print(void *jsctx, void *obj, int argc, pdf_jsimp_obj *args[]) { - pdf_js *js = (pdf_js *)jsctx; + pdf_js *js = (pdf_js *)jsctx; pdf_event_issue_print(js->doc); @@ -590,7 +590,7 @@ static pdf_jsimp_obj *doc_print(void *jsctx, void *obj, int argc, pdf_jsimp_obj static pdf_jsimp_obj *doc_mailDoc(void *jsctx, void *obj, int argc, pdf_jsimp_obj *args[]) { - pdf_js *js = (pdf_js *)jsctx; + pdf_js *js = (pdf_js *)jsctx; fz_context *ctx = js->doc->ctx; pdf_jsimp_obj *bUI_obj = NULL; pdf_jsimp_obj *cTo_obj = NULL; @@ -689,8 +689,8 @@ static pdf_jsimp_obj *doc_mailDoc(void *jsctx, void *obj, int argc, pdf_jsimp_ob } static void declare_dom(pdf_js *js) -{ - pdf_jsimp *imp = js->imp; + + pdf_jsimp *imp = js->imp; /* Create the document type */ js->doctype = pdf_jsimp_new_type(imp, NULL); @@ -748,7 +748,7 @@ static void preload_helpers(pdf_js *js) pdf_js *pdf_new_js(pdf_document *doc) { fz_context *ctx = doc->ctx; - pdf_js *js = NULL; + pdf_js *js = NULL; fz_var(js); fz_try(ctx) @@ -784,7 +784,7 @@ void pdf_js_load_document_level(pdf_js *js) { pdf_document *doc = js->doc; fz_context *ctx = doc->ctx; - pdf_obj *javascript = NULL; + pdf_obj *javascript = NULL; char *codebuf = NULL; fz_var(javascript); @@ -896,4 +896,4 @@ void pdf_js_execute_count(pdf_js *js, char *code, int count) int pdf_js_supported() { return 1; -} \ No newline at end of file +} diff --git a/pdf/pdf_object.c b/pdf/pdf_object.c index a28743d1..ab6968c6 100644 --- a/pdf/pdf_object.c +++ b/pdf/pdf_object.c @@ -1193,7 +1193,8 @@ static inline int iswhite(int ch) static inline int isdelim(int ch) { - return ch == '(' || ch == ')' || + return + ch == '(' || ch == ')' || ch == '<' || ch == '>' || ch == '[' || ch == ']' || ch == '{' || ch == '}' || diff --git a/pdf/pdf_write.c b/pdf/pdf_write.c index d00e154a..a674db9c 100644 --- a/pdf/pdf_write.c +++ b/pdf/pdf_write.c @@ -8,23 +8,25 @@ typedef struct pdf_write_options_s pdf_write_options; -/* As part of linearization, we need to keep a list of what objects are used - * by what page. We do this by recording the objects used in a given page - * in a page_objects structure. We have a list of these structures (one per - * page) in the page_objects_list structure. - * - * The page_objects structure maintains a heap in the object array, so - * insertion takes log n time, and we can heapsort and dedupe at the end for - * a total worse case n log n time. - * - * The magic heap invariant is that: - * entry[n] >= entry[(n+1)*2-1] & entry[n] >= entry[(n+1)*2] - * or equivalently: - * entry[(n-1)>>1] >= entry[n] - * - * For a discussion of the heap data structure (and heapsort) see Kingston, - * "Algorithms and Data Structures". - */ +/* + As part of linearization, we need to keep a list of what objects are used + by what page. We do this by recording the objects used in a given page + in a page_objects structure. We have a list of these structures (one per + page) in the page_objects_list structure. + + The page_objects structure maintains a heap in the object array, so + insertion takes log n time, and we can heapsort and dedupe at the end for + a total worse case n log n time. + + The magic heap invariant is that: + entry[n] >= entry[(n+1)*2-1] & entry[n] >= entry[(n+1)*2] + or equivalently: + entry[(n-1)>>1] >= entry[n] + + For a discussion of the heap data structure (and heapsort) see Kingston, + "Algorithms and Data Structures". +*/ + typedef struct { int num_shared; int page_object_number; @@ -249,23 +251,26 @@ page_objects_sort(fz_context *ctx, page_objects *po) static int order_ge(int ui, int uj) { - /* For linearization, we need to order the sections as follows: - * Remaining pages - * Shared objects - * Objects not associated with any page - * (Linearization params) - * Catalogue (and other document level objects) - * First page - * (Primary Hint stream) (*) - * Any free objects - * Note, this is NOT the same order they appear in - * the final file! - * - * The PDF reference gives us the option of putting the hint stream - * after the first page, and we take it, for simplicity. - */ - /* If the 2 objects are in the same section, then page object comes - * first. */ + /* + For linearization, we need to order the sections as follows: + + Remaining pages + Shared objects + Objects not associated with any page + (Linearization params) + Catalogue (and other document level objects) + First page + (Primary Hint stream) (*) + Any free objects + + Note, this is NOT the same order they appear in + the final file! + + The PDF reference gives us the option of putting the hint stream + after the first page, and we take it, for simplicity. + */ + + /* If the 2 objects are in the same section, then page object comes first. */ if (((ui ^ uj) & ~USE_PAGE_OBJECT) == 0) return ((ui & USE_PAGE_OBJECT) == 0); /* Put unused objects last */ @@ -463,7 +468,7 @@ page_objects_dump(pdf_write_options *opts) for (j = 0; j < p->len; j++) { int o = p->object[j]; - fprintf(stderr, " Object %d: use=%x\n", o, opts->use_list[o]); + fprintf(stderr, "\tObject %d: use=%x\n", o, opts->use_list[o]); } fprintf(stderr, "Byte range=%d->%d\n", p->min_ofs, p->max_ofs); fprintf(stderr, "Number of objects=%d, Number of shared objects=%d\n", p->num_objects, p->num_shared); @@ -1536,7 +1541,7 @@ static void expandstream(pdf_document *xref, pdf_write_options *opts, pdf_obj *o static int is_image_filter(char *s) { - if ( !strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF") || + if (!strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF") || !strcmp(s, "DCTDecode") || !strcmp(s, "DCT") || !strcmp(s, "RunLengthDecode") || !strcmp(s, "RL") || !strcmp(s, "JBIG2Decode") || diff --git a/xps/xps_util.c b/xps/xps_util.c index cb84ba71..167171cc 100644 --- a/xps/xps_util.c +++ b/xps/xps_util.c @@ -78,7 +78,7 @@ skip_authority(char *path) return p; } -#define SEP(x) ((x)=='/' || (x) == 0) +#define SEP(x) ((x)=='/' || (x) == 0) static char * xps_clean_path(char *name) -- cgit v1.2.3