From 8fffb693819323722cd6f8cd94135546bfc39bca Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 20 Jan 2016 14:21:55 +0100 Subject: Various formatting cleanups. --- source/fitz/ftoa.c | 18 +++--- source/fitz/jmemcust.c | 151 ++++++++++++++++++++++---------------------- source/fitz/jmemcust.h | 79 +++++++++++------------ source/gprf/gprf-doc.c | 8 +-- source/html/html-layout.c | 2 +- source/pdf/pdf-appearance.c | 6 +- source/pdf/pdf-form.c | 3 +- source/pdf/pdf-interpret.c | 2 +- source/pdf/pdf-write.c | 2 +- source/pdf/pdf-xref.c | 4 +- source/tools/pdfposter.c | 2 +- 11 files changed, 134 insertions(+), 143 deletions(-) diff --git a/source/fitz/ftoa.c b/source/fitz/ftoa.c index db2b87bb..9f2d8b9f 100644 --- a/source/fitz/ftoa.c +++ b/source/fitz/ftoa.c @@ -83,7 +83,7 @@ multiply(diy_fp_t x, diy_fp_t y) c = y.f >> half; d = y.f & mask; ac = a * c; bc = b * c; ad = a * d; bd = b * d; tmp = (bd >> half) + (ad & mask) + (bc & mask); - tmp += ((uint64_t)1U) << (half - 1); /* Round. */ + tmp += ((uint64_t)1U) << (half - 1); /* Round. */ r.f = ac + (ad >> half) + (bc >> half) + (tmp >> half); r.e = x.e + y.e + half * 2; return r; @@ -96,7 +96,7 @@ multiply(diy_fp_t x, diy_fp_t y) #define SP_SIGNIFICAND_MASK 0x7fffff #define SP_HIDDEN_BIT 0x800000 /* 2^23 */ -/* Does not normalize the result. */ +/* Does not normalize the result. */ static diy_fp_t float2diy_fp(float d) { @@ -122,13 +122,13 @@ static diy_fp_t normalize_boundary(diy_fp_t in) { diy_fp_t res = in; - /* The original number could have been a denormal. */ + /* The original number could have been a denormal. */ while (! (res.f & (SP_HIDDEN_BIT << 1))) { res.f <<= 1; res.e--; } - /* Do the final shifts in one go. */ + /* Do the final shifts in one go. */ res.f <<= (DIY_SIGNIFICAND_SIZE - SP_SIGNIFICAND_SIZE - 2); res.e = res.e - (DIY_SIGNIFICAND_SIZE - SP_SIGNIFICAND_SIZE - 2); return res; @@ -141,7 +141,7 @@ normalized_boundaries(float f, diy_fp_t* lower_ptr, diy_fp_t* upper_ptr) diy_fp_t upper, lower; int significand_is_zero = v.f == SP_HIDDEN_BIT; - upper.f = (v.f << 1) + 1; upper.e = v.e - 1; + upper.f = (v.f << 1) + 1; upper.e = v.e - 1; upper = normalize_boundary(upper); if (significand_is_zero) { @@ -156,8 +156,7 @@ normalized_boundaries(float f, diy_fp_t* lower_ptr, diy_fp_t* upper_ptr) lower.f <<= lower.e - upper.e; lower.e = upper.e; - /* Adjust to double boundaries, so that we can also read the numbers - with '(float) strtod'. */ + /* Adjust to double boundaries, so that we can also read the numbers with '(float) strtod'. */ upper.f -= 1 << 10; lower.f += 1 << 10; @@ -171,14 +170,13 @@ k_comp(int n) /* Avoid ceil and floating point multiplication for better * performace and portability. Instead use the approximation * log10(2) ~ 1233/(2^12). Tests show that this gives the correct - * result for all values of n in the range -500..500. */ + * result for all values of n in the range -500..500. */ int tmp = n + DIY_SIGNIFICAND_SIZE - 1; int k = (tmp * 1233) / (1 << 12); return tmp > 0 ? k + 1 : k; } -/* Cached powers of ten from 10**-37..10**46. - Produced using GNU MPFR's mpfr_pow_si. */ +/* Cached powers of ten from 10**-37..10**46. Produced using GNU MPFR's mpfr_pow_si. */ /* Significands. */ static uint64_t powers_ten[84] = { diff --git a/source/fitz/jmemcust.c b/source/fitz/jmemcust.c index b0dd4ff6..7cbd3bcc 100644 --- a/source/fitz/jmemcust.c +++ b/source/fitz/jmemcust.c @@ -1,17 +1,18 @@ -/* Copyright (C) 2001-2014 Artifex Software, Inc. - All Rights Reserved. - - This software is provided AS-IS with no warranty, either express or - implied. - - This software is distributed under license and may not be copied, - modified or distributed except as expressly authorized under the terms - of the license contained in the file LICENSE in this distribution. - - Refer to licensing information at http://www.artifex.com or contact - Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, - CA 94903, U.S.A., +1(415)492-9861, for further information. -*/ +/* + * Copyright (C) 2001-2014 Artifex Software, Inc. + * All Rights Reserved. + * + * This software is provided AS-IS with no warranty, either express or + * implied. + * + * This software is distributed under license and may not be copied, + * modified or distributed except as expressly authorized under the terms + * of the license contained in the file LICENSE in this distribution. + * + * Refer to licensing information at http://www.artifex.com or contact + * Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, + * CA 94903, U.S.A., +1(415)492-9861, for further information. + */ #if !defined(SHARE_JPEG) || SHARE_JPEG==0 @@ -24,17 +25,17 @@ GLOBAL(void *) jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - return (void *) (cmem->j_mem_get_small)(cinfo, sizeofobject); + return (void *) (cmem->j_mem_get_small)(cinfo, sizeofobject); } GLOBAL(void) jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - (cmem->j_mem_free_small)(cinfo, object, sizeofobject); + (cmem->j_mem_free_small)(cinfo, object, sizeofobject); } /* @@ -47,17 +48,17 @@ jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) GLOBAL(void FAR *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - return (void *) (cmem->j_mem_get_large)(cinfo, sizeofobject); + return (void *) (cmem->j_mem_get_large)(cinfo, sizeofobject); } GLOBAL(void) jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - (cmem->j_mem_free_large)(cinfo, object, sizeofobject); + (cmem->j_mem_free_large)(cinfo, object, sizeofobject); } /* @@ -67,15 +68,15 @@ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) GLOBAL(long) jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) + long max_bytes_needed, long already_allocated) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - long ret = max_bytes_needed; + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + long ret = max_bytes_needed; - if (cmem->j_mem_avail) - ret = (cmem->j_mem_avail)(cinfo); + if (cmem->j_mem_avail) + ret = (cmem->j_mem_avail)(cinfo); - return ret; + return ret; } /* @@ -86,82 +87,82 @@ jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, GLOBAL(void) jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) + long total_bytes_needed) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - if (cmem->j_mem_open_backing_store) { - (cmem->j_mem_open_backing_store)(cinfo, info, total_bytes_needed); - } - else - ERREXIT(cinfo, JERR_NO_BACKING_STORE); + if (cmem->j_mem_open_backing_store) { + (cmem->j_mem_open_backing_store)(cinfo, info, total_bytes_needed); + } + else + ERREXIT(cinfo, JERR_NO_BACKING_STORE); } /* * These routines take care of any system-dependent initialization and - * cleanup required. Here, there isn't any. + * cleanup required. Here, there isn't any. */ GLOBAL(long) jpeg_mem_init (j_common_ptr cinfo) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - long ret = 0; + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + long ret = 0; - if (cmem->j_mem_init) - ret = (cmem->j_mem_init)(cinfo); + if (cmem->j_mem_init) + ret = (cmem->j_mem_init)(cinfo); - return ret; + return ret; } GLOBAL(void) jpeg_mem_term (j_common_ptr cinfo) { - jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); + jpeg_cust_mem_data *cmem = GET_CUST_MEM_DATA(cinfo); - if (cmem->j_mem_term) - (cmem->j_mem_term)(cinfo); + if (cmem->j_mem_term) + (cmem->j_mem_term)(cinfo); } GLOBAL(jpeg_cust_mem_data *) jpeg_cust_mem_init(jpeg_cust_mem_data *custm, void *priv, - j_custmem_init_ptr init, - j_custmem_term_ptr term, - j_custmem_avail_ptr avail, - j_custmem_get_small_ptr get_small, - j_custmem_free_small_ptr free_small, - j_cust_mem_get_large_ptr get_large, - j_custmem_free_large_ptr free_large, - j_custmem_open_backing_store_ptr open_backing_store) + j_custmem_init_ptr init, + j_custmem_term_ptr term, + j_custmem_avail_ptr avail, + j_custmem_get_small_ptr get_small, + j_custmem_free_small_ptr free_small, + j_cust_mem_get_large_ptr get_large, + j_custmem_free_large_ptr free_large, + j_custmem_open_backing_store_ptr open_backing_store) { - jpeg_cust_mem_data *lcustm = NULL; - - /* We need at least the following for a viable memory manager */ - if (get_small && free_small && get_large && free_large) - { - lcustm = custm; - - lcustm->priv = priv; - lcustm->j_mem_init = init; - lcustm->j_mem_term = term; - lcustm->j_mem_avail = avail; - lcustm->j_mem_get_small = get_small; - lcustm->j_mem_free_small = free_small; - lcustm->j_mem_get_large = get_large; - lcustm->j_mem_free_large = free_large; - lcustm->j_mem_open_backing_store = open_backing_store; - } - return lcustm; + jpeg_cust_mem_data *lcustm = NULL; + + /* We need at least the following for a viable memory manager */ + if (get_small && free_small && get_large && free_large) + { + lcustm = custm; + + lcustm->priv = priv; + lcustm->j_mem_init = init; + lcustm->j_mem_term = term; + lcustm->j_mem_avail = avail; + lcustm->j_mem_get_small = get_small; + lcustm->j_mem_free_small = free_small; + lcustm->j_mem_get_large = get_large; + lcustm->j_mem_free_large = free_large; + lcustm->j_mem_open_backing_store = open_backing_store; + } + 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; + 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 6371113e..13879fca 100644 --- a/source/fitz/jmemcust.h +++ b/source/fitz/jmemcust.h @@ -1,56 +1,51 @@ /* Copyright (C) 2001-2014 Artifex Software, Inc. - All Rights Reserved. - - This software is provided AS-IS with no warranty, either express or - implied. - - This software is distributed under license and may not be copied, - modified or distributed except as expressly authorized under the terms - of the license contained in the file LICENSE in this distribution. - - Refer to licensing information at http://www.artifex.com or contact - Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, - CA 94903, U.S.A., +1(415)492-9861, for further information. -*/ + * All Rights Reserved. + * + * This software is provided AS-IS with no warranty, either express or + * implied. + * + * This software is distributed under license and may not be copied, + * modified or distributed except as expressly authorized under the terms + * of the license contained in the file LICENSE in this distribution. + * + * Refer to licensing information at http://www.artifex.com or contact + * Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, + * CA 94903, U.S.A., +1(415)492-9861, for further information. + */ typedef JMETHOD(long, j_custmem_init_ptr, (j_common_ptr cinfo)); typedef JMETHOD(void, j_custmem_term_ptr, (j_common_ptr cinfo)); typedef JMETHOD(long, j_custmem_avail_ptr, (j_common_ptr cinfo)); -typedef JMETHOD(void *, j_custmem_get_small_ptr, - (j_common_ptr cinfo, size_t size)); -typedef JMETHOD(void, j_custmem_free_small_ptr, - (j_common_ptr cinfo, void *object, size_t size)); -typedef JMETHOD(void *, j_cust_mem_get_large_ptr, - (j_common_ptr cinfo, size_t size)); -typedef JMETHOD(void, j_custmem_free_large_ptr, - (j_common_ptr cinfo, void *object, size_t size)); -typedef JMETHOD(void, j_custmem_open_backing_store_ptr, - (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)); +typedef JMETHOD(void *, j_custmem_get_small_ptr, (j_common_ptr cinfo, size_t size)); +typedef JMETHOD(void, j_custmem_free_small_ptr, (j_common_ptr cinfo, void *object, size_t size)); +typedef JMETHOD(void *, j_cust_mem_get_large_ptr, (j_common_ptr cinfo, size_t size)); +typedef JMETHOD(void, j_custmem_free_large_ptr, (j_common_ptr cinfo, void *object, size_t size)); +typedef JMETHOD(void, j_custmem_open_backing_store_ptr, (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)); typedef struct { - j_custmem_init_ptr j_mem_init; - j_custmem_term_ptr j_mem_term; - j_custmem_avail_ptr j_mem_avail; - j_custmem_get_small_ptr j_mem_get_small; - j_custmem_free_small_ptr j_mem_free_small; - j_cust_mem_get_large_ptr j_mem_get_large; - j_custmem_free_large_ptr j_mem_free_large; - j_custmem_open_backing_store_ptr j_mem_open_backing_store; - void *priv; + j_custmem_init_ptr j_mem_init; + j_custmem_term_ptr j_mem_term; + j_custmem_avail_ptr j_mem_avail; + j_custmem_get_small_ptr j_mem_get_small; + j_custmem_free_small_ptr j_mem_free_small; + j_cust_mem_get_large_ptr j_mem_get_large; + j_custmem_free_large_ptr j_mem_free_large; + j_custmem_open_backing_store_ptr j_mem_open_backing_store; + void *priv; } jpeg_cust_mem_data; #define GET_CUST_MEM_DATA(c) ((jpeg_cust_mem_data *)c->client_data) GLOBAL(jpeg_cust_mem_data *) -jpeg_cust_mem_init(jpeg_cust_mem_data *custm, void *priv, - j_custmem_init_ptr init, - j_custmem_term_ptr term, - j_custmem_avail_ptr avail, - j_custmem_get_small_ptr get_small, - j_custmem_free_small_ptr free_small, - j_cust_mem_get_large_ptr get_large, - j_custmem_free_large_ptr free_large, - j_custmem_open_backing_store_ptr open_backing_store); + jpeg_cust_mem_init(jpeg_cust_mem_data *custm, void *priv, + j_custmem_init_ptr init, + j_custmem_term_ptr term, + j_custmem_avail_ptr avail, + j_custmem_get_small_ptr get_small, + j_custmem_free_small_ptr free_small, + 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); + jpeg_cust_mem_set_private(jpeg_cust_mem_data *custm, void *priv); diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c index 55d88e17..98e273ee 100644 --- a/source/gprf/gprf-doc.c +++ b/source/gprf/gprf-doc.c @@ -173,14 +173,14 @@ static inline unsigned char *cmyk_to_rgba(unsigned char *out, uint32_t c, uint32 uint32_t c1m1y, c1m1y1, c1my, c1my1, cm1y, cm1y1, cmy, cmy1; /* We use some tricks here: - * x + (x>>15) + * x + (x >> 15) * converts x from 0..65535 to 0..65536 - * (A * B)>>16 + * (A * B) >> 16 * multiplies A (0..65535) and B (0..65536) to give a 0...65535 result. * (This relies on A and B being unsigned). * * We also rely on the fact that if: - * C = (A * B)>> 16 + * C = (A * B) >> 16 * for A (0..65535) and B (0..65536) then A - C is also in (0..65535) * as C cannot possibly be any larger than A. */ @@ -864,7 +864,7 @@ gprf_open_document_with_stream(fz_context *ctx, fz_stream *file) val = fz_read_int32_le(ctx, file); if (val != 0x4f525047) fz_throw(ctx, FZ_ERROR_GENERIC, "Invalid file signature in gproof file"); - val = fz_read_byte(ctx, file); + val = fz_read_byte(ctx, file); val |= fz_read_byte(ctx, file)<<8; if (val != 1) fz_throw(ctx, FZ_ERROR_GENERIC, "Invalid version in gproof file"); diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 96cb6453..1d9885b6 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -1286,7 +1286,7 @@ fz_draw_html(fz_context *ctx, fz_html *box, float page_top, float page_bot, fz_d static char *concat_text(fz_context *ctx, fz_xml *root) { - fz_xml *node; + fz_xml *node; int i = 0, n = 1; char *s; for (node = fz_xml_down(root); node; node = fz_xml_next(node)) diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index ec40dfd8..466978b5 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1233,8 +1233,7 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj * } } - /* If ANY of the entries are not an array then just use the opts not - the vals. */ + /* If ANY of the entries are not an array then just use the opts not the vals. */ if (val_opt_ok) pos = vals; else @@ -1323,8 +1322,7 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj * info.font_rec.da_rec.font_size = fontsize; lineheight = ascent - descent; - /* Check if all items will fit. If not, then place the "selected" item - at the top of our widget rect. */ + /* Check if all items will fit. If not, then place the "selected" item at the top of our widget rect. */ items_height = n * fontsize * lineheight; if (items_height <= height || !num_sel) fz_translate(&tm, clip_rect.x0, clip_rect.y1 - lineheight * fontsize); diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 1f101007..78adf542 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -1294,8 +1294,7 @@ int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw for (i = 0; i < n; i++) { m = pdf_array_len(ctx, pdf_array_get(ctx, optarr, i)); - /* If it is a two element array, the second item is the one that we want - if we want the listing value */ + /* If it is a two element array, the second item is the one that we want if we want the listing value. */ if (m == 2) if (exportval) opts[i] = pdf_to_str_buf(ctx, pdf_array_get(ctx, pdf_array_get(ctx, optarr, i), 0)); diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c index f876925a..b1adc576 100644 --- a/source/pdf/pdf-interpret.c +++ b/source/pdf/pdf-interpret.c @@ -1175,7 +1175,7 @@ pdf_process_stream(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, fz_stream } else { - cookie->errors++; + cookie->errors++; } if (!ignoring_errors) { diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 5d05e496..d785f332 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -2022,7 +2022,7 @@ static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_state index = pdf_new_array(ctx, doc, 2); pdf_dict_put_drop(ctx, dict, PDF_NAME_Index, index); - /* opts->gen_list[num] is already initialized by fz_calloc. */ + /* opts->gen_list[num] is already initialized by fz_calloc. */ opts->use_list[num] = 1; opts->ofs_list[num] = opts->first_xref_entry_offset; diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 50642ab4..3bcf5d79 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -717,7 +717,7 @@ pdf_xref_find_subsection(fz_context *ctx, pdf_document *doc, fz_off_t ofs, int l /* Different cases here. Case 1) We might be asking for a * subsection (or a subset of a subsection) that we already - * have - Just return it. Case 2) We might be asking for a + * have - Just return it. Case 2) We might be asking for a * completely new subsection - Create it and return it. * Case 3) We might have an overlapping one - Create a 'solid' * subsection and return that. */ @@ -2759,7 +2759,7 @@ pdf_document *pdf_create_document(fz_context *ctx) pdf_dict_put_drop(ctx, pages, PDF_NAME_Type, PDF_NAME_Pages); pdf_dict_put_drop(ctx, pages, PDF_NAME_Count, pdf_new_int(ctx, doc, 0)); pdf_dict_put_drop(ctx, pages, PDF_NAME_Kids, pdf_new_array(ctx, doc, 1)); - /* Set the trailer of the final xref section. */ + /* Set the trailer of the final xref section. */ doc->xref_sections[0].trailer = trailer; } fz_catch(ctx) diff --git a/source/tools/pdfposter.c b/source/tools/pdfposter.c index 5a5a5948..8989e2c9 100644 --- a/source/tools/pdfposter.c +++ b/source/tools/pdfposter.c @@ -22,7 +22,7 @@ intersect_box(fz_context *ctx, pdf_document *doc, pdf_obj *page, pdf_obj *box_na { pdf_obj *box = pdf_dict_get(ctx, page, box_name); pdf_obj *newbox; - fz_rect old_rect; + fz_rect old_rect; if (box == NULL) return; -- cgit v1.2.3