Even after "+109 LOConsistency" it was still inconsistent. This one is contentious: makes debugging if/else statments occupying the same line with the condition un-easily-breakpointable (among other things?).
Unified · Split
| @@ -81,11 +81,9 @@ · 80 unmodified lines | ||
| 81 | 81 | #define lprintf(...) |
| 82 | 82 | #endif |
| 83 | 83 | |
| 84 | −#define ARSERT(cond) for (;;) { \ | |
| 85 | − if (!(cond)) { \ | |
| 86 | − errx (1, "%s:%d " #cond, __FILE__, __LINE__); \ | |
| 87 | − } \ | |
| 88 | − break; \ | |
| 84 | +#define ARSERT(cond) for (;;) { \ | |
| 85 | + if (!(cond)) errx (1, "%s:%d " #cond, __FILE__, __LINE__); \ | |
| 86 | + break; \ | |
| 89 | 87 | } (void) 0 |
| 90 | 88 | |
| 91 | 89 | #define ML(d) extern value ml_##d; value ml_##d |
| @@ -204,25 +202,20 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; · 112 unmodified lines | ||
| 204 | 202 | static void lock (const char *cap) |
| 205 | 203 | { |
| 206 | 204 | int ret = pthread_mutex_lock (&mutex); |
| 207 | − if (ret) { | |
| 208 | − errx (1, "%s: pthread_mutex_lock: %s", cap, strerror (ret)); | |
| 209 | − } | |
| 205 | + if (ret) errx (1, "%s: pthread_mutex_lock: %s", cap, strerror (ret)); | |
| 210 | 206 | } |
| 211 | 207 | |
| 212 | 208 | static void unlock (const char *cap) |
| 213 | 209 | { |
| 214 | 210 | int ret = pthread_mutex_unlock (&mutex); |
| 215 | − if (ret) { | |
| 216 | − errx (1, "%s: pthread_mutex_unlock: %s", cap, strerror (ret)); | |
| 217 | − } | |
| 211 | + if (ret) errx (1, "%s: pthread_mutex_unlock: %s", cap, strerror (ret)); | |
| 218 | 212 | } |
| 219 | 213 | |
| 220 | 214 | static int trylock (const char *cap) |
| 221 | 215 | { |
| 222 | 216 | int ret = pthread_mutex_trylock (&mutex); |
| 223 | − if (ret && ret != EBUSY) { | |
| 217 | + if (ret && ret != EBUSY) | |
| 224 | 218 | errx (1, "%s: pthread_mutex_trylock: %s", cap, strerror (ret)); |
| 225 | − } | |
| 226 | 219 | return ret == EBUSY; |
| 227 | 220 | } |
| 228 | 221 | |
| @@ -230,9 +223,7 @@ static int hasdata (void) · 1 unmodified line | ||
| 230 | 223 | { |
| 231 | 224 | int ret, avail; |
| 232 | 225 | ret = ioctl (state.csock, FIONREAD, &avail); |
| 233 | − if (ret) { | |
| 234 | − err (1, "hasdata: FIONREAD error ret=%d", ret); | |
| 235 | − } | |
| 226 | + if (ret) err (1, "hasdata: FIONREAD error ret=%d", ret); | |
| 236 | 227 | return avail > 0; |
| 237 | 228 | } |
| 238 | 229 | |
| @@ -242,9 +233,7 @@ ML (hasdata (value fd_v)) · 3 unmodified lines | ||
| 242 | 233 | int ret, avail; |
| 243 | 234 | |
| 244 | 235 | ret = ioctl (Int_val (fd_v), FIONREAD, &avail); |
| 245 | − if (ret) { | |
| 246 | − uerror ("ioctl (FIONREAD)", Nothing); | |
| 247 | − } | |
| 236 | + if (ret) uerror ("ioctl (FIONREAD)", Nothing); | |
| 248 | 237 | CAMLreturn (Val_bool (avail > 0)); |
| 249 | 238 | } |
| 250 | 239 | |
| @@ -255,12 +244,8 @@ static void readdata (int fd, void *p, int size) · 4 unmodified lines | ||
| 255 | 244 | again: |
| 256 | 245 | n = read (fd, p, size); |
| 257 | 246 | if (n - size) { |
| 258 | − if (n < 0 && errno == EINTR) { | |
| 259 | − goto again; | |
| 260 | − } | |
| 261 | − if (!n) { | |
| 262 | − errx (1, "EOF while reading"); | |
| 263 | − } | |
| 247 | + if (n < 0 && errno == EINTR) goto again; | |
| 248 | + if (!n) errx (1, "EOF while reading"); | |
| 264 | 249 | errx (1, "read (fd %d, req %d, ret %zd)", fd, size, n); |
| 265 | 250 | } |
| 266 | 251 | } |
| @@ -280,9 +265,7 @@ again: · 13 unmodified lines | ||
| 280 | 265 | goto again; |
| 281 | 266 | } |
| 282 | 267 | if (n - size - 4) { |
| 283 | − if (!n) { | |
| 284 | − errx (1, "EOF while writing data"); | |
| 285 | − } | |
| 268 | + if (!n) errx (1, "EOF while writing data"); | |
| 286 | 269 | err (1, "writev (fd %d, req %d, ret %zd)", fd, size + 4, n); |
| 287 | 270 | } |
| 288 | 271 | } |
| @@ -329,21 +312,13 @@ static void GCC_FMT_ATTR (1, 2) printd (const char *fmt, ...) · 40 unmodified lines | ||
| 329 | 312 | writedata (state.csock, buf, len); |
| 330 | 313 | break; |
| 331 | 314 | } |
| 332 | − else { | |
| 333 | − size = len + 5; | |
| 334 | − } | |
| 335 | − } | |
| 336 | − else { | |
| 337 | − err (1, "vsnprintf for `%s' failed", fmt); | |
| 315 | + else size = len + 5; | |
| 338 | 316 | } |
| 317 | + else err (1, "vsnprintf for `%s' failed", fmt); | |
| 339 | 318 | buf = realloc (buf == fbuf ? NULL : buf, size); |
| 340 | − if (!buf) { | |
| 341 | − err (1, "realloc for temp buf (%d bytes) failed", size); | |
| 342 | − } | |
| 343 | − } | |
| 344 | − if (buf != fbuf) { | |
| 345 | − free (buf); | |
| 319 | + if (!buf) err (1, "realloc for temp buf (%d bytes) failed", size); | |
| 346 | 320 | } |
| 321 | + if (buf != fbuf) free (buf); | |
| 347 | 322 | } |
| 348 | 323 | |
| 349 | 324 | static void closedoc (void) |
| @@ -409,14 +384,10 @@ static void docinfo (void) · 59 unmodified lines | ||
| 409 | 384 | again: |
| 410 | 385 | need = fz_lookup_metadata (state.ctx, state.doc, tab[i].tag, buf, len); |
| 411 | 386 | if (need > 0) { |
| 412 | − if (need <= len) { | |
| 413 | − printd ("info %s\t%s", tab[i].name, buf); | |
| 414 | − } | |
| 387 | + if (need <= len) printd ("info %s\t%s", tab[i].name, buf); | |
| 415 | 388 | else { |
| 416 | 389 | buf = realloc (buf, need); |
| 417 | − if (!buf) { | |
| 418 | − err (1, "docinfo realloc %d", need); | |
| 419 | − } | |
| 390 | + if (!buf) err (1, "docinfo realloc %d", need); | |
| 420 | 391 | len = need; |
| 421 | 392 | goto again; |
| 422 | 393 | } |
| @@ -442,15 +413,9 @@ static void unlinktile (struct tile *tile) · 19 unmodified lines | ||
| 442 | 413 | |
| 443 | 414 | static void freepage (struct page *page) |
| 444 | 415 | { |
| 445 | − if (!page) { | |
| 446 | − return; | |
| 447 | − } | |
| 448 | − if (page->text) { | |
| 449 | − fz_drop_stext_page (state.ctx, page->text); | |
| 450 | − } | |
| 451 | − if (page->slinks) { | |
| 452 | − free (page->slinks); | |
| 453 | − } | |
| 416 | + if (!page) return; | |
| 417 | + if (page->text) fz_drop_stext_page (state.ctx, page->text); | |
| 418 | + if (page->slinks) free (page->slinks); | |
| 454 | 419 | fz_drop_display_list (state.ctx, page->dlist); |
| 455 | 420 | fz_drop_page (state.ctx, page->fzpage); |
| 456 | 421 | free (page); |
| @@ -463,9 +428,7 @@ static void freetile (struct tile *tile) · 6 unmodified lines | ||
| 463 | 428 | #if 0 |
| 464 | 429 | fz_drop_pixmap (state.ctx, tile->pixmap); |
| 465 | 430 | #else /* piggyback */ |
| 466 | − if (state.pig) { | |
| 467 | − fz_drop_pixmap (state.ctx, state.pig); | |
| 468 | − } | |
| 431 | + if (state.pig) fz_drop_pixmap (state.ctx, state.pig); | |
| 469 | 432 | state.pig = tile->pixmap; |
| 470 | 433 | #endif |
| 471 | 434 | } |
| @@ -480,9 +443,7 @@ static void trimctm (pdf_page *page, int pindex) · 8 unmodified lines | ||
| 480 | 443 | { |
| 481 | 444 | struct pagedim *pdim = &state.pagedims[pindex]; |
| 482 | 445 | |
| 483 | − if (!page) { | |
| 484 | − return; | |
| 485 | − } | |
| 446 | + if (!page) return; | |
| 486 | 447 | if (!pdim->tctmready) { |
| 487 | 448 | fz_rect realbox, mediabox; |
| 488 | 449 | fz_matrix page_ctm, ctm; |
| @@ -507,10 +468,8 @@ static fz_matrix pagectm1 (fz_page *fzpage, struct pagedim *pdim) · 18 unmodified lines | ||
| 507 | 468 | trimctm (pdf_page_from_fz_page (state.ctx, fzpage), (int) pdimno); |
| 508 | 469 | ctm = fz_concat (pdim->tctm, pdim->ctm); |
| 509 | 470 | } |
| 510 | − else { | |
| 511 | − ctm = fz_concat (fz_translate (-pdim->mediabox.x0, -pdim->mediabox.y0), | |
| 512 | − pdim->ctm); | |
| 513 | − } | |
| 471 | + else ctm = fz_concat (fz_translate (-pdim->mediabox.x0, -pdim->mediabox.y0), | |
| 472 | + pdim->ctm); | |
| 514 | 473 | return ctm; |
| 515 | 474 | } |
| 516 | 475 | |
| @@ -525,9 +484,7 @@ static void *loadpage (int pageno, int pindex) · 8 unmodified lines | ||
| 525 | 484 | struct page *page; |
| 526 | 485 | |
| 527 | 486 | page = calloc (sizeof (struct page), 1); |
| 528 | − if (!page) { | |
| 529 | − err (1, "calloc page %d", pageno); | |
| 530 | − } | |
| 487 | + if (!page) err (1, "calloc page %d", pageno); | |
| 531 | 488 | |
| 532 | 489 | page->dlist = fz_new_display_list (state.ctx, fz_infinite_rect); |
| 533 | 490 | dev = fz_new_list_device (state.ctx, page->dlist); |
| @@ -558,9 +515,7 @@ static struct tile *alloctile (int h) · 24 unmodified lines | ||
| 558 | 515 | slicecount = (h + state.sliceheight - 1) / state.sliceheight; |
| 559 | 516 | tilesize = sizeof (*tile) + ((slicecount - 1) * sizeof (struct slice)); |
| 560 | 517 | tile = calloc (tilesize, 1); |
| 561 | − if (!tile) { | |
| 562 | − err (1, "cannot allocate tile (%zu bytes)", tilesize); | |
| 563 | − } | |
| 518 | + if (!tile) err (1, "cannot allocate tile (%zu bytes)", tilesize); | |
| 564 | 519 | for (int i = 0; i < slicecount; ++i) { |
| 565 | 520 | int sh = fz_mini (h, state.sliceheight); |
| 566 | 521 | tile->slices[i].h = sh; |
| @@ -598,9 +553,7 @@ static struct tile *rendertile (struct page *page, int x, int y, int w, int h, · 31 unmodified lines | ||
| 598 | 553 | tile->pixmap->x = bbox.x0; |
| 599 | 554 | tile->pixmap->y = bbox.y0; |
| 600 | 555 | } |
| 601 | − else { | |
| 602 | − fz_drop_pixmap (state.ctx, state.pig); | |
| 603 | − } | |
| 556 | + else fz_drop_pixmap (state.ctx, state.pig); | |
| 604 | 557 | state.pig = NULL; |
| 605 | 558 | } |
| 606 | 559 | if (!tile->pixmap) { |
| @@ -610,11 +563,8 @@ static struct tile *rendertile (struct page *page, int x, int y, int w, int h, · 3 unmodified lines | ||
| 610 | 563 | bbox, NULL, 1, pbo->ptr); |
| 611 | 564 | tile->pbo = pbo; |
| 612 | 565 | } |
| 613 | − else { | |
| 614 | − tile->pixmap = | |
| 615 | − fz_new_pixmap_with_bbox (state.ctx, state.colorspace, bbox, | |
| 616 | − NULL, 1); | |
| 617 | − } | |
| 566 | + else tile->pixmap = fz_new_pixmap_with_bbox ( | |
| 567 | + state.ctx, state.colorspace, bbox, NULL, 1); | |
| 618 | 568 | } |
| 619 | 569 | |
| 620 | 570 | tile->w = w; |
| @@ -673,9 +623,7 @@ static void initpdims1 (void) · 52 unmodified lines | ||
| 673 | 623 | } |
| 674 | 624 | } |
| 675 | 625 | } |
| 676 | − if (!pageobj) { | |
| 677 | − pageobj = pdf_lookup_page_obj (ctx, pdf, pageno); | |
| 678 | − } | |
| 626 | + if (!pageobj) pageobj = pdf_lookup_page_obj (ctx, pdf, pageno); | |
| 679 | 627 | |
| 680 | 628 | rotate = pdf_to_int (ctx, pdf_dict_gets (ctx, pageobj, "Rotate")); |
| 681 | 629 | |
| @@ -706,9 +654,7 @@ static void initpdims1 (void) · 24 unmodified lines | ||
| 706 | 654 | rect = fz_transform_rect (rect, ctm); |
| 707 | 655 | rect = fz_intersect_rect (rect, mediabox); |
| 708 | 656 | |
| 709 | − if (!fz_is_empty_rect (rect)) { | |
| 710 | − mediabox = rect; | |
| 711 | − } | |
| 657 | + if (!fz_is_empty_rect (rect)) mediabox = rect; | |
| 712 | 658 | |
| 713 | 659 | obj = pdf_new_array (ctx, pdf, 4); |
| 714 | 660 | pdf_array_push_real (ctx, obj, mediabox.x0); |
| @@ -727,11 +673,10 @@ static void initpdims1 (void) · 12 unmodified lines | ||
| 727 | 673 | fz_drop_page (ctx, &page->super); |
| 728 | 674 | show = (pageno + 1 == state.pagecount) |
| 729 | 675 | || (trim ? pageno % 5 == 0 : pageno % 20 == 0); |
| 730 | − if (show) { | |
| 676 | + if (show) | |
| 731 | 677 | printd ("progress %f Trimming %d", |
| 732 | 678 | (double) (pageno + 1) / state.pagecount, |
| 733 | 679 | pageno + 1); |
| 734 | − } | |
| 735 | 680 | } |
| 736 | 681 | fz_catch (ctx) { |
| 737 | 682 | printd ("emsg failed to load page %d", pageno); |
| @@ -760,22 +705,14 @@ static void initpdims1 (void) · 22 unmodified lines | ||
| 760 | 705 | cropbox = |
| 761 | 706 | pdf_to_rect (ctx, pdf_dict_gets (ctx, pageobj, "CropBox")); |
| 762 | 707 | if (!fz_is_empty_rect (cropbox)) { |
| 763 | − if (empty) { | |
| 764 | − mediabox = cropbox; | |
| 765 | − } | |
| 766 | − else { | |
| 767 | − mediabox = fz_intersect_rect (mediabox, cropbox); | |
| 768 | − } | |
| 708 | + if (empty) mediabox = cropbox; | |
| 709 | + else mediabox = fz_intersect_rect (mediabox, cropbox); | |
| 769 | 710 | } |
| 770 | 711 | else { |
| 771 | 712 | if (empty) { |
| 772 | − if (fz_is_empty_rect (rootmediabox)) { | |
| 773 | − printd ("emsg cannot find page size for page %d", | |
| 774 | − pageno); | |
| 775 | − } | |
| 776 | − else { | |
| 777 | − mediabox = rootmediabox; | |
| 778 | − } | |
| 713 | + if (fz_is_empty_rect (rootmediabox)) | |
| 714 | + printd ("emsg cannot find page %d size", pageno); | |
| 715 | + else mediabox = rootmediabox; | |
| 779 | 716 | } |
| 780 | 717 | } |
| 781 | 718 | } |
| @@ -802,9 +739,7 @@ static void initpdims1 (void) · 20 unmodified lines | ||
| 802 | 739 | rect.y1 += state.trimfuzz.y1; |
| 803 | 740 | rect = fz_intersect_rect (rect, mediabox); |
| 804 | 741 | |
| 805 | − if (!fz_is_empty_rect (rect)) { | |
| 806 | − mediabox = rect; | |
| 807 | − } | |
| 742 | + if (!fz_is_empty_rect (rect)) mediabox = rect; | |
| 808 | 743 | } |
| 809 | 744 | fz_drop_page (ctx, page); |
| 810 | 745 | } |
| @@ -819,11 +754,9 @@ static void initpdims1 (void) · 8 unmodified lines | ||
| 819 | 754 | fz_drop_page (ctx, page); |
| 820 | 755 | |
| 821 | 756 | show = !state.trimmargins && pageno % 20 == 0; |
| 822 | − if (show) { | |
| 823 | − printd ("progress %f Gathering dimensions %d", | |
| 824 | − (double) (pageno) / state.pagecount, | |
| 825 | − pageno); | |
| 826 | − } | |
| 757 | + if (show) printd ("progress %f Gathering dimensions %d", | |
| 758 | + (double) (pageno) / state.pagecount, | |
| 759 | + pageno); | |
| 827 | 760 | } |
| 828 | 761 | fz_catch (ctx) { |
| 829 | 762 | printd ("emsg failed to load page %d", pageno); |
| @@ -838,10 +771,8 @@ static void initpdims1 (void) · 8 unmodified lines | ||
| 838 | 771 | |
| 839 | 772 | size = (state.pagedimcount + 1) * sizeof (*state.pagedims); |
| 840 | 773 | state.pagedims = realloc (state.pagedims, size); |
| 841 | − if (!state.pagedims) { | |
| 842 | − err (1, "realloc pagedims to %zu (%d elems)", | |
| 843 | − size, state.pagedimcount + 1); | |
| 844 | − } | |
| 774 | + if (!state.pagedims) err (1, "realloc pagedims to %zu (%d elems)", | |
| 775 | + size, state.pagedimcount + 1); | |
| 845 | 776 | |
| 846 | 777 | p = &state.pagedims[state.pagedimcount++]; |
| 847 | 778 | p->rotate = rotate; |
| @@ -865,17 +796,15 @@ static void initpdims (void) · 17 unmodified lines | ||
| 865 | 796 | } |
| 866 | 797 | size_t size = (state.pagedimcount + 1) * sizeof (*state.pagedims); |
| 867 | 798 | state.pagedims = realloc (state.pagedims, size); |
| 868 | − if (!state.pagedims) { | |
| 799 | + if (!state.pagedims) | |
| 869 | 800 | err (1, "realloc pagedims to %zu (%d elems)", |
| 870 | 801 | size, state.pagedimcount + 1); |
| 871 | − } | |
| 872 | 802 | if (fread (state.pagedims, |
| 873 | 803 | sizeof (*state.pagedims), |
| 874 | 804 | state.pagedimcount+1, |
| 875 | − f) - (state.pagedimcount+1)) { | |
| 805 | + f) - (state.pagedimcount+1)) | |
| 876 | 806 | err (1, "fread pagedim data %zu %d", |
| 877 | 807 | sizeof (*state.pagedims), state.pagedimcount+1); |
| 878 | − } | |
| 879 | 808 | fclose (f); |
| 880 | 809 | } |
| 881 | 810 | |
| @@ -883,20 +812,17 @@ static void initpdims (void) · 1 unmodified line | ||
| 883 | 812 | initpdims1 (); |
| 884 | 813 | if (state.dcf) { |
| 885 | 814 | f = fopen (state.dcf, "wb"); |
| 886 | − if (!f) { | |
| 887 | − err (1, "fopen %s for writing", state.dcf); | |
| 888 | − } | |
| 815 | + if (!f) err (1, "fopen %s for writing", state.dcf); | |
| 889 | 816 | if (fwrite (&state.pagedimcount, |
| 890 | − sizeof (state.pagedimcount), 1, f) - 1) { | |
| 817 | + sizeof (state.pagedimcount), 1, f) - 1) | |
| 891 | 818 | err (1, "fwrite pagedimcunt %zu", sizeof (state.pagedimcount)); |
| 892 | − } | |
| 893 | 819 | if (fwrite (state.pagedims, sizeof (*state.pagedims), |
| 894 | 820 | state.pagedimcount + 1, f) |
| 895 | − - (state.pagedimcount + 1)) { | |
| 821 | + - (state.pagedimcount + 1)) | |
| 896 | 822 | err (1, "fwrite pagedim data %zu %u", |
| 897 | 823 | sizeof (*state.pagedims), state.pagedimcount+1); |
| 898 | − } fclose (f); | |
| 899 | 824 | } |
| 825 | + fclose (f); | |
| 900 | 826 | } |
| 901 | 827 | } |
| 902 | 828 | |
| @@ -908,9 +834,7 @@ static void layout (void) · 5 unmodified lines | ||
| 908 | 834 | struct pagedim *p = NULL; |
| 909 | 835 | float zw, w, maxw = 0.0, zoom = 1.0; |
| 910 | 836 | |
| 911 | − if (state.pagedimcount == 0) { | |
| 912 | − return; | |
| 913 | − } | |
| 837 | + if (state.pagedimcount == 0) return; | |
| 914 | 838 | |
| 915 | 839 | switch (state.fitmodel) { |
| 916 | 840 | case FitProportional: |
| @@ -1019,12 +943,8 @@ static void recurse_outline (fz_outline *outline, int level) · 102 unmodified lines | ||
| 1019 | 943 | printd ("o %d %d %d %d %s", |
| 1020 | 944 | level, outline->page, (int) p.y, h, outline->title); |
| 1021 | 945 | } |
| 1022 | − else { | |
| 1023 | − printd ("on %d %s", level, outline->title); | |
| 1024 | − } | |
| 1025 | − if (outline->down) { | |
| 1026 | − recurse_outline (outline->down, level + 1); | |
| 1027 | − } | |
| 946 | + else printd ("on %d %s", level, outline->title); | |
| 947 | + if (outline->down) recurse_outline (outline->down, level + 1); | |
| 1028 | 948 | outline = outline->next; |
| 1029 | 949 | } |
| 1030 | 950 | } |
| @@ -1033,9 +953,7 @@ static void process_outline (void) · 2 unmodified lines | ||
| 1033 | 953 | { |
| 1034 | 954 | fz_outline *outline; |
| 1035 | 955 | |
| 1036 | − if (!state.needoutline || !state.pagedimcount) { | |
| 1037 | − return; | |
| 1038 | − } | |
| 956 | + if (!state.needoutline || !state.pagedimcount) return; | |
| 1039 | 957 | |
| 1040 | 958 | state.needoutline = 0; |
| 1041 | 959 | outline = fz_load_outline (state.ctx, state.doc); |
| @@ -1053,18 +971,14 @@ static char *strofline (fz_stext_line *line) · 11 unmodified lines | ||
| 1053 | 971 | size_t size = 0, cap = 80; |
| 1054 | 972 | |
| 1055 | 973 | p = malloc (cap + 1); |
| 1056 | − if (!p) { | |
| 1057 | − return NULL; | |
| 1058 | − } | |
| 974 | + if (!p) return NULL; | |
| 1059 | 975 | |
| 1060 | 976 | for (ch = line->first_char; ch; ch = ch->next) { |
| 1061 | 977 | int n = fz_runetochar (utf8, ch->c); |
| 1062 | 978 | if (size + n > cap) { |
| 1063 | 979 | cap *= 2; |
| 1064 | 980 | p = realloc (p, cap + 1); |
| 1065 | − if (!p) { | |
| 1066 | − return NULL; | |
| 1067 | − } | |
| 981 | + if (!p) return NULL; | |
| 1068 | 982 | } |
| 1069 | 983 | |
| 1070 | 984 | memcpy (p + size, utf8, n); |
| @@ -1082,9 +996,7 @@ static int matchline (regex_t *re, fz_stext_line *line, · 11 unmodified lines | ||
| 1082 | 996 | regmatch_t rm; |
| 1083 | 997 | |
| 1084 | 998 | p = strofline (line); |
| 1085 | − if (!p) { | |
| 1086 | − return -1; | |
| 1087 | − } | |
| 999 | + if (!p) return -1; | |
| 1088 | 1000 | |
| 1089 | 1001 | ret = regexec (re, p, 1, &rm, 0); |
| 1090 | 1002 | if (ret) { |
| @@ -1113,9 +1025,7 @@ static int matchline (regex_t *re, fz_stext_line *line, · 22 unmodified lines | ||
| 1113 | 1025 | } |
| 1114 | 1026 | for (;ch; ch = ch->next) { |
| 1115 | 1027 | o += fz_runelen (ch->c); |
| 1116 | − if (o > rm.rm_eo) { | |
| 1117 | − break; | |
| 1118 | − } | |
| 1028 | + if (o > rm.rm_eo) break; | |
| 1119 | 1029 | } |
| 1120 | 1030 | e = ch->quad; |
| 1121 | 1031 | |
| @@ -1131,14 +1041,12 @@ static int matchline (regex_t *re, fz_stext_line *line, · 9 unmodified lines | ||
| 1131 | 1041 | pageno + 1, (int) (rm.rm_eo - rm.rm_so), &p[rm.rm_so], |
| 1132 | 1042 | now () - start); |
| 1133 | 1043 | } |
| 1134 | − else { | |
| 1135 | − printd ("match %d %d %f %f %f %f %f %f %f %f", | |
| 1136 | − pageno, 2, | |
| 1137 | − s.ul.x, s.ul.y, | |
| 1138 | − e.ur.x, s.ul.y, | |
| 1139 | − e.lr.x, e.lr.y, | |
| 1140 | − s.ul.x, e.lr.y); | |
| 1141 | − } | |
| 1044 | + else printd ("match %d %d %f %f %f %f %f %f %f %f", | |
| 1045 | + pageno, 2, | |
| 1046 | + s.ul.x, s.ul.y, | |
| 1047 | + e.ur.x, s.ul.y, | |
| 1048 | + e.lr.x, e.lr.y, | |
| 1049 | + s.ul.x, e.lr.y); | |
| 1142 | 1050 | free (p); |
| 1143 | 1051 | return 1; |
| 1144 | 1052 | } |
| @@ -1164,11 +1072,9 @@ static void search (regex_t *re, int pageno, int y, int forward) · 19 unmodified lines | ||
| 1164 | 1072 | pageno); |
| 1165 | 1073 | stop = 1; |
| 1166 | 1074 | } |
| 1167 | − else { | |
| 1168 | − printd ("progress %f searching in page %d", | |
| 1169 | − (double) (pageno + 1) / state.pagecount, | |
| 1170 | − pageno); | |
| 1171 | − } | |
| 1075 | + else printd ("progress %f searching in page %d", | |
| 1076 | + (double) (pageno + 1) / state.pagecount, | |
| 1077 | + pageno); | |
| 1172 | 1078 | } |
| 1173 | 1079 | pdim = pdimofpageno (pageno); |
| 1174 | 1080 | text = fz_new_stext_page (state.ctx, pdim->mediabox); |
| @@ -1184,13 +1090,10 @@ static void search (regex_t *re, int pageno, int y, int forward) · 9 unmodified lines | ||
| 1184 | 1090 | for (block = text->first_block; block; block = block->next) { |
| 1185 | 1091 | fz_stext_line *line; |
| 1186 | 1092 | |
| 1187 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 1188 | − continue; | |
| 1189 | − } | |
| 1093 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 1094 | + | |
| 1190 | 1095 | for (line = block->u.t.first_line; line; line = line->next) { |
| 1191 | − if (line->bbox.y0 < y + 1) { | |
| 1192 | − continue; | |
| 1193 | − } | |
| 1096 | + if (line->bbox.y0 < y + 1) continue; | |
| 1194 | 1097 | |
| 1195 | 1098 | switch (matchline (re, line, stop, pageno, start)) { |
| 1196 | 1099 | case 0: break; |
| @@ -1204,13 +1107,10 @@ static void search (regex_t *re, int pageno, int y, int forward) · 7 unmodified lines | ||
| 1204 | 1107 | for (block = text->last_block; block; block = block->prev) { |
| 1205 | 1108 | fz_stext_line *line; |
| 1206 | 1109 | |
| 1207 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 1208 | − continue; | |
| 1209 | − } | |
| 1110 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 1111 | + | |
| 1210 | 1112 | for (line = block->u.t.last_line; line; line = line->prev) { |
| 1211 | − if (line->bbox.y0 < y + 1) { | |
| 1212 | − continue; | |
| 1213 | − } | |
| 1113 | + if (line->bbox.y0 < y + 1) continue; | |
| 1214 | 1114 | |
| 1215 | 1115 | switch (matchline (re, line, stop, pageno, start)) { |
| 1216 | 1116 | case 0: break; |
| @@ -1234,9 +1134,7 @@ static void search (regex_t *re, int pageno, int y, int forward) · 17 unmodified lines | ||
| 1234 | 1134 | fz_drop_page (state.ctx, page); |
| 1235 | 1135 | } |
| 1236 | 1136 | end = now (); |
| 1237 | − if (!stop) { | |
| 1238 | − printd ("progress 1 no matches %f sec", end - start); | |
| 1239 | − } | |
| 1137 | + if (!stop) printd ("progress 1 no matches %f sec", end - start); | |
| 1240 | 1138 | printd ("clearrects"); |
| 1241 | 1139 | } |
| 1242 | 1140 | |
| @@ -1264,20 +1162,15 @@ static void realloctexts (int texcount) · 21 unmodified lines | ||
| 1264 | 1162 | { |
| 1265 | 1163 | size_t size; |
| 1266 | 1164 | |
| 1267 | − if (texcount == state.tex.count) { | |
| 1268 | − return; | |
| 1269 | − } | |
| 1165 | + if (texcount == state.tex.count) return; | |
| 1270 | 1166 | |
| 1271 | − if (texcount < state.tex.count) { | |
| 1167 | + if (texcount < state.tex.count) | |
| 1272 | 1168 | glDeleteTextures (state.tex.count - texcount, |
| 1273 | 1169 | state.tex.ids + texcount); |
| 1274 | − } | |
| 1275 | 1170 | |
| 1276 | 1171 | size = texcount * (sizeof (*state.tex.ids) + sizeof (*state.tex.owners)); |
| 1277 | 1172 | state.tex.ids = realloc (state.tex.ids, size); |
| 1278 | − if (!state.tex.ids) { | |
| 1279 | − err (1, "realloc texs %zu", size); | |
| 1280 | − } | |
| 1173 | + if (!state.tex.ids) err (1, "realloc texs %zu", size); | |
| 1281 | 1174 | |
| 1282 | 1175 | state.tex.owners = (void *) (state.tex.ids + texcount); |
| 1283 | 1176 | if (texcount > state.tex.count) { |
| @@ -1298,9 +1191,7 @@ static char *mbtoutf8 (char *s) · 14 unmodified lines | ||
| 1298 | 1191 | wchar_t *tmp; |
| 1299 | 1192 | size_t i, ret, len; |
| 1300 | 1193 | |
| 1301 | − if (state.utf8cs) { | |
| 1302 | − return s; | |
| 1303 | − } | |
| 1194 | + if (state.utf8cs) return s; | |
| 1304 | 1195 | |
| 1305 | 1196 | len = mbstowcs (NULL, s, strlen (s)); |
| 1306 | 1197 | if (len == 0 || len == (size_t) -1) { |
| @@ -1371,15 +1262,11 @@ static void * mainloop (void UNUSED_ATTR *unused) · 64 unmodified lines | ||
| 1371 | 1262 | fz_var (oldlen); |
| 1372 | 1263 | for (;;) { |
| 1373 | 1264 | len = readlen (state.csock); |
| 1374 | − if (len == 0) { | |
| 1375 | − errx (1, "readlen returned 0"); | |
| 1376 | − } | |
| 1265 | + if (len == 0) errx (1, "readlen returned 0"); | |
| 1377 | 1266 | |
| 1378 | 1267 | if (oldlen < len + 1) { |
| 1379 | 1268 | p = realloc (p, len + 1); |
| 1380 | − if (!p) { | |
| 1381 | − err (1, "realloc %d failed", len + 1); | |
| 1382 | − } | |
| 1269 | + if (!p) err (1, "realloc %d failed", len + 1); | |
| 1383 | 1270 | oldlen = len + 1; |
| 1384 | 1271 | } |
| 1385 | 1272 | readdata (state.csock, p, len); |
| @@ -1394,17 +1281,14 @@ static void * mainloop (void UNUSED_ATTR *unused) · 8 unmodified lines | ||
| 1394 | 1281 | |
| 1395 | 1282 | fz_var (ok); |
| 1396 | 1283 | ret = sscanf (p + 5, " %d %d %n", &usedoccss, &layouth, &off); |
| 1397 | − if (ret != 2) { | |
| 1398 | − errx (1, "malformed open `%.*s' ret=%d", len, p, ret); | |
| 1399 | − } | |
| 1284 | + if (ret != 2) errx (1, "malformed open `%.*s' ret=%d", len, p, ret); | |
| 1400 | 1285 | |
| 1401 | 1286 | filename = p + 5 + off; |
| 1402 | 1287 | filenamelen = strlen (filename); |
| 1403 | 1288 | password = filename + filenamelen + 1; |
| 1404 | 1289 | |
| 1405 | − if (password[strlen (password) + 1]) { | |
| 1290 | + if (password[strlen (password) + 1]) | |
| 1406 | 1291 | fz_set_user_css (state.ctx, password + strlen (password) + 1); |
| 1407 | − } | |
| 1408 | 1292 | |
| 1409 | 1293 | lock ("open"); |
| 1410 | 1294 | fz_set_use_document_css (state.ctx, usedoccss); |
| @@ -1415,9 +1299,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 4 unmodified lines | ||
| 1415 | 1299 | utf8filename = mbtoutf8 (filename); |
| 1416 | 1300 | printd ("emsg Error loading %s: %s", |
| 1417 | 1301 | utf8filename, fz_caught_message (state.ctx)); |
| 1418 | − if (utf8filename != filename) { | |
| 1419 | − free (utf8filename); | |
| 1420 | − } | |
| 1302 | + if (utf8filename != filename) free (utf8filename); | |
| 1421 | 1303 | } |
| 1422 | 1304 | if (ok) { |
| 1423 | 1305 | docinfo (); |
| @@ -1430,9 +1312,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 6 unmodified lines | ||
| 1430 | 1312 | int i, colorspace; |
| 1431 | 1313 | |
| 1432 | 1314 | ret = sscanf (p + 2, " %d", &colorspace); |
| 1433 | − if (ret != 1) { | |
| 1434 | − errx (1, "malformed cs `%.*s' ret=%d", len, p, ret); | |
| 1435 | − } | |
| 1315 | + if (ret != 1) errx (1, "malformed cs `%.*s' ret=%d", len, p, ret); | |
| 1436 | 1316 | lock ("cs"); |
| 1437 | 1317 | set_tex_params (colorspace); |
| 1438 | 1318 | for (i = 0; i < state.tex.count; ++i) { |
| @@ -1445,9 +1325,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 6 unmodified lines | ||
| 1445 | 1325 | void *ptr; |
| 1446 | 1326 | |
| 1447 | 1327 | ret = sscanf (p + 8, " %" SCNxPTR, (uintptr_t *) &ptr); |
| 1448 | − if (ret != 1) { | |
| 1328 | + if (ret != 1) | |
| 1449 | 1329 | errx (1, "malformed freepage `%.*s' ret=%d", len, p, ret); |
| 1450 | − } | |
| 1451 | 1330 | lock ("freepage"); |
| 1452 | 1331 | freepage (ptr); |
| 1453 | 1332 | unlock ("freepage"); |
| @@ -1456,9 +1335,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 2 unmodified lines | ||
| 1456 | 1335 | void *ptr; |
| 1457 | 1336 | |
| 1458 | 1337 | ret = sscanf (p + 8, " %" SCNxPTR, (uintptr_t *) &ptr); |
| 1459 | − if (ret != 1) { | |
| 1338 | + if (ret != 1) | |
| 1460 | 1339 | errx (1, "malformed freetile `%.*s' ret=%d", len, p, ret); |
| 1461 | − } | |
| 1462 | 1340 | lock ("freetile"); |
| 1463 | 1341 | freetile (ptr); |
| 1464 | 1342 | unlock ("freetile"); |
| @@ -1470,9 +1348,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 5 unmodified lines | ||
| 1470 | 1348 | |
| 1471 | 1349 | ret = sscanf (p + 6, " %d %d %d %d,%n", |
| 1472 | 1350 | &icase, &pageno, &y, &forward, &len2); |
| 1473 | − if (ret != 4) { | |
| 1474 | − errx (1, "malformed search `%s' ret=%d", p, ret); | |
| 1475 | − } | |
| 1351 | + if (ret != 4) errx (1, "malformed search `%s' ret=%d", p, ret); | |
| 1476 | 1352 | |
| 1477 | 1353 | pattern = p + 6 + len2; |
| 1478 | 1354 | ret = regcomp (&re, pattern, |
| @@ -1496,9 +1372,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 17 unmodified lines | ||
| 1496 | 1372 | |
| 1497 | 1373 | printd ("clear"); |
| 1498 | 1374 | ret = sscanf (p + 8, " %d %d %d", &w, &h, &fitmodel); |
| 1499 | − if (ret != 3) { | |
| 1375 | + if (ret != 3) | |
| 1500 | 1376 | errx (1, "malformed geometry `%.*s' ret=%d", len, p, ret); |
| 1501 | − } | |
| 1502 | 1377 | |
| 1503 | 1378 | lock ("geometry"); |
| 1504 | 1379 | state.h = h; |
| @@ -1525,14 +1400,12 @@ static void * mainloop (void UNUSED_ATTR *unused) · 20 unmodified lines | ||
| 1525 | 1400 | printd ("clear"); |
| 1526 | 1401 | ret = sscanf (p + 9, " %d %d %d %n", |
| 1527 | 1402 | &rotate, &fitmodel, &h, &off); |
| 1528 | − if (ret != 3) { | |
| 1403 | + if (ret != 3) | |
| 1529 | 1404 | errx (1, "bad reqlayout line `%.*s' ret=%d", len, p, ret); |
| 1530 | − } | |
| 1531 | 1405 | lock ("reqlayout"); |
| 1532 | 1406 | pdf = pdf_specifics (state.ctx, state.doc); |
| 1533 | − if (state.rotate != rotate || state.fitmodel != fitmodel) { | |
| 1407 | + if (state.rotate != rotate || state.fitmodel != fitmodel) | |
| 1534 | 1408 | state.gen += 1; |
| 1535 | − } | |
| 1536 | 1409 | state.rotate = rotate; |
| 1537 | 1410 | state.fitmodel = fitmodel; |
| 1538 | 1411 | state.h = h; |
| @@ -1560,9 +1433,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 21 unmodified lines | ||
| 1560 | 1433 | int pageno, pindex; |
| 1561 | 1434 | |
| 1562 | 1435 | ret = sscanf (p + 4, " %d %d", &pageno, &pindex); |
| 1563 | − if (ret != 2) { | |
| 1436 | + if (ret != 2) | |
| 1564 | 1437 | errx (1, "bad page line `%.*s' ret=%d", len, p, ret); |
| 1565 | − } | |
| 1566 | 1438 | |
| 1567 | 1439 | lock ("page"); |
| 1568 | 1440 | a = now (); |
| @@ -1582,9 +1454,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 13 unmodified lines | ||
| 1582 | 1454 | ret = sscanf (p + 4, " %" SCNxPTR " %d %d %d %d %" SCNxPTR, |
| 1583 | 1455 | (uintptr_t *) &page, &x, &y, &w, &h, |
| 1584 | 1456 | (uintptr_t *) &data); |
| 1585 | − if (ret != 6) { | |
| 1586 | − errx (1, "bad tile line `%.*s' ret=%d", len, p, ret); | |
| 1587 | − } | |
| 1457 | + if (ret != 6) errx (1, "bad tile line `%.*s' ret=%d", len, p, ret); | |
| 1588 | 1458 | |
| 1589 | 1459 | lock ("tile"); |
| 1590 | 1460 | a = now (); |
| @@ -1603,9 +1473,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 12 unmodified lines | ||
| 1603 | 1473 | |
| 1604 | 1474 | ret = sscanf (p + 7, " %d %d %d %d %d", |
| 1605 | 1475 | &trimmargins, &fuzz.x0, &fuzz.y0, &fuzz.x1, &fuzz.y1); |
| 1606 | − if (ret != 5) { | |
| 1476 | + if (ret != 5) | |
| 1607 | 1477 | errx (1, "malformed trimset `%.*s' ret=%d", len, p, ret); |
| 1608 | − } | |
| 1609 | 1478 | lock ("trimset"); |
| 1610 | 1479 | state.trimmargins = trimmargins; |
| 1611 | 1480 | if (memcmp (&fuzz, &state.trimfuzz, sizeof (fuzz))) { |
| @@ -1620,9 +1489,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 8 unmodified lines | ||
| 1620 | 1489 | |
| 1621 | 1490 | ret = sscanf (p + 7, " %d %d %d %d %d", |
| 1622 | 1491 | &trimmargins, &fuzz.x0, &fuzz.y0, &fuzz.x1, &fuzz.y1); |
| 1623 | − if (ret != 5) { | |
| 1492 | + if (ret != 5) | |
| 1624 | 1493 | errx (1, "malformed settrim `%.*s' ret=%d", len, p, ret); |
| 1625 | − } | |
| 1626 | 1494 | printd ("clear"); |
| 1627 | 1495 | lock ("settrim"); |
| 1628 | 1496 | state.trimmargins = trimmargins; |
| @@ -1644,9 +1512,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 15 unmodified lines | ||
| 1644 | 1512 | int h; |
| 1645 | 1513 | |
| 1646 | 1514 | ret = sscanf (p + 6, " %d", &h); |
| 1647 | − if (ret != 1) { | |
| 1515 | + if (ret != 1) | |
| 1648 | 1516 | errx (1, "malformed sliceh `%.*s' ret=%d", len, p, ret); |
| 1649 | − } | |
| 1650 | 1517 | if (h != state.sliceheight) { |
| 1651 | 1518 | state.sliceheight = h; |
| 1652 | 1519 | for (int i = 0; i < state.tex.count; ++i) { |
| @@ -1729,9 +1596,7 @@ static void showsel (struct page *page, int ox, int oy) · 76 unmodified lines | ||
| 1729 | 1596 | int seen = 0; |
| 1730 | 1597 | unsigned char selcolor[] = {15,15,15,140}; |
| 1731 | 1598 | |
| 1732 | − if (!page->fmark || !page->lmark) { | |
| 1733 | − return; | |
| 1734 | − } | |
| 1599 | + if (!page->fmark || !page->lmark) return; | |
| 1735 | 1600 | |
| 1736 | 1601 | glEnable (GL_BLEND); |
| 1737 | 1602 | glBlendFunc (GL_SRC_ALPHA, GL_SRC_ALPHA); |
| @@ -1743,22 +1608,16 @@ static void showsel (struct page *page, int ox, int oy) · 5 unmodified lines | ||
| 1743 | 1608 | for (block = page->text->first_block; block; block = block->next) { |
| 1744 | 1609 | fz_stext_line *line; |
| 1745 | 1610 | |
| 1746 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 1747 | − continue; | |
| 1748 | − } | |
| 1611 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 1749 | 1612 | for (line = block->u.t.first_line; line; line = line->next) { |
| 1750 | 1613 | fz_stext_char *ch; |
| 1751 | 1614 | |
| 1752 | 1615 | rect = fz_empty_rect; |
| 1753 | 1616 | for (ch = line->first_char; ch; ch = ch->next) { |
| 1754 | 1617 | fz_rect r; |
| 1755 | − if (ch == page->fmark) { | |
| 1756 | − seen = 1; | |
| 1757 | − } | |
| 1618 | + if (ch == page->fmark) seen = 1; | |
| 1758 | 1619 | r = fz_rect_from_quad (ch->quad); |
| 1759 | − if (seen) { | |
| 1760 | − rect = fz_union_rect (rect, r); | |
| 1761 | − } | |
| 1620 | + if (seen) rect = fz_union_rect (rect, r); | |
| 1762 | 1621 | if (ch == page->lmark) { |
| 1763 | 1622 | bbox = fz_round_rect (rect); |
| 1764 | 1623 | recti (bbox.x0 + ox, bbox.y0 + oy, |
| @@ -1882,12 +1741,8 @@ static void highlightlinks (struct page *page, int xoff, int yoff) · 117 unmodified lines | ||
| 1882 | 1741 | p4.y = link->rect.y1; |
| 1883 | 1742 | |
| 1884 | 1743 | /* TODO: different colours for different schemes */ |
| 1885 | − if (fz_is_external_link (state.ctx, link->uri)) { | |
| 1886 | − glColor3ub (0, 0, 255); | |
| 1887 | − } | |
| 1888 | − else { | |
| 1889 | − glColor3ub (255, 0, 0); | |
| 1890 | − } | |
| 1744 | + if (fz_is_external_link (state.ctx, link->uri)) glColor3ub (0, 0, 255); | |
| 1745 | + else glColor3ub (255, 0, 0); | |
| 1891 | 1746 | |
| 1892 | 1747 | stipplerect (ctm, p1, p2, p3, p4, texcoords, vertices); |
| 1893 | 1748 | } |
| @@ -1920,9 +1775,7 @@ static int compareslinks (const void *l, const void *r) · 26 unmodified lines | ||
| 1920 | 1775 | { |
| 1921 | 1776 | struct slink const *ls = l; |
| 1922 | 1777 | struct slink const *rs = r; |
| 1923 | − if (ls->bbox.y0 == rs->bbox.y0) { | |
| 1924 | − return ls->bbox.x0 - rs->bbox.x0; | |
| 1925 | − } | |
| 1778 | + if (ls->bbox.y0 == rs->bbox.y0) return ls->bbox.x0 - rs->bbox.x0; | |
| 1926 | 1779 | return ls->bbox.y0 - rs->bbox.y0; |
| 1927 | 1780 | } |
| 1928 | 1781 | |
| @@ -1954,18 +1807,14 @@ static void ensureannots (struct page *page) · 25 unmodified lines | ||
| 1954 | 1807 | pdf_page *pdfpage; |
| 1955 | 1808 | |
| 1956 | 1809 | pdf = pdf_specifics (state.ctx, state.doc); |
| 1957 | − if (!pdf) { | |
| 1958 | − return; | |
| 1959 | − } | |
| 1810 | + if (!pdf) return; | |
| 1960 | 1811 | |
| 1961 | 1812 | pdfpage = pdf_page_from_fz_page (state.ctx, page->fzpage); |
| 1962 | 1813 | if (state.gen != page->agen) { |
| 1963 | 1814 | dropannots (page); |
| 1964 | 1815 | page->agen = state.gen; |
| 1965 | 1816 | } |
| 1966 | − if (page->annots) { | |
| 1967 | − return; | |
| 1968 | − } | |
| 1817 | + if (page->annots) return; | |
| 1969 | 1818 | |
| 1970 | 1819 | for (annot = pdf_first_annot (state.ctx, pdfpage); |
| 1971 | 1820 | annot; |
| @@ -1976,9 +1825,7 @@ static void ensureannots (struct page *page) · 4 unmodified lines | ||
| 1976 | 1825 | if (count > 0) { |
| 1977 | 1826 | page->annotcount = count; |
| 1978 | 1827 | page->annots = calloc (count, annotsize); |
| 1979 | − if (!page->annots) { | |
| 1980 | − err (1, "calloc annots %d", count); | |
| 1981 | − } | |
| 1828 | + if (!page->annots) err (1, "calloc annots %d", count); | |
| 1982 | 1829 | |
| 1983 | 1830 | for (annot = pdf_first_annot (state.ctx, pdfpage), i = 0; |
| 1984 | 1831 | annot; |
| @@ -2017,9 +1864,7 @@ static void ensureslinks (struct page *page) · 32 unmodified lines | ||
| 2017 | 1864 | dropslinks (page); |
| 2018 | 1865 | page->sgen = state.gen; |
| 2019 | 1866 | } |
| 2020 | − if (page->slinks) { | |
| 2021 | − return; | |
| 2022 | − } | |
| 1867 | + if (page->slinks) return; | |
| 2023 | 1868 | |
| 2024 | 1869 | ensurelinks (page); |
| 2025 | 1870 | ctm = pagectm (page); |
| @@ -2033,9 +1878,7 @@ static void ensureslinks (struct page *page) · 7 unmodified lines | ||
| 2033 | 1878 | |
| 2034 | 1879 | page->slinkcount = count; |
| 2035 | 1880 | page->slinks = calloc (count, slinksize); |
| 2036 | − if (!page->slinks) { | |
| 2037 | − err (1, "calloc slinks %d", count); | |
| 2038 | − } | |
| 1881 | + if (!page->slinks) err (1, "calloc slinks %d", count); | |
| 2039 | 1882 | |
| 2040 | 1883 | for (i = 0, link = page->links; link; ++i, link = link->next) { |
| 2041 | 1884 | fz_rect rect; |
| @@ -2112,24 +1955,17 @@ static void uploadslice (struct tile *tile, struct slice *slice) · 70 unmodified lines | ||
| 2112 | 1955 | offset += slice1->h * tile->w * tile->pixmap->n; |
| 2113 | 1956 | } |
| 2114 | 1957 | if (slice->texindex != -1 && slice->texindex < state.tex.count |
| 2115 | − && state.tex.owners[slice->texindex].slice == slice) { | |
| 1958 | + && state.tex.owners[slice->texindex].slice == slice) | |
| 2116 | 1959 | glBindTexture (TEXT_TYPE, state.tex.ids[slice->texindex]); |
| 2117 | − } | |
| 2118 | 1960 | else { |
| 2119 | 1961 | int subimage = 0; |
| 2120 | 1962 | int texindex = state.tex.index++ % state.tex.count; |
| 2121 | 1963 | |
| 2122 | 1964 | if (state.tex.owners[texindex].w == tile->w) { |
| 2123 | − if (state.tex.owners[texindex].h >= slice->h) { | |
| 2124 | − subimage = 1; | |
| 2125 | − } | |
| 2126 | − else { | |
| 2127 | − state.tex.owners[texindex].h = slice->h; | |
| 2128 | − } | |
| 2129 | − } | |
| 2130 | − else { | |
| 2131 | − state.tex.owners[texindex].h = slice->h; | |
| 1965 | + if (state.tex.owners[texindex].h >= slice->h) subimage = 1; | |
| 1966 | + else state.tex.owners[texindex].h = slice->h; | |
| 2132 | 1967 | } |
| 1968 | + else state.tex.owners[texindex].h = slice->h; | |
| 2133 | 1969 | |
| 2134 | 1970 | state.tex.owners[texindex].w = tile->w; |
| 2135 | 1971 | state.tex.owners[texindex].slice = slice; |
| @@ -2146,21 +1982,17 @@ static void uploadslice (struct tile *tile, struct slice *slice) · 10 unmodified lines | ||
| 2146 | 1982 | state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, tile->pbo->id); |
| 2147 | 1983 | texdata = 0; |
| 2148 | 1984 | } |
| 2149 | − else { | |
| 2150 | − texdata = tile->pixmap->samples; | |
| 2151 | − } | |
| 2152 | − if (subimage) { | |
| 2153 | − glTexSubImage2D (TEXT_TYPE, | |
| 2154 | − 0, | |
| 2155 | − 0, | |
| 2156 | − 0, | |
| 2157 | − tile->w, | |
| 2158 | − slice->h, | |
| 2159 | − state.tex.form, | |
| 2160 | − state.tex.ty, | |
| 2161 | − texdata+offset | |
| 2162 | − ); | |
| 2163 | − } | |
| 1985 | + else texdata = tile->pixmap->samples; | |
| 1986 | + if (subimage) glTexSubImage2D (TEXT_TYPE, | |
| 1987 | + 0, | |
| 1988 | + 0, | |
| 1989 | + 0, | |
| 1990 | + tile->w, | |
| 1991 | + slice->h, | |
| 1992 | + state.tex.form, | |
| 1993 | + state.tex.ty, | |
| 1994 | + texdata+offset | |
| 1995 | + ); | |
| 2164 | 1996 | else { |
| 2165 | 1997 | glTexImage2D (TEXT_TYPE, |
| 2166 | 1998 | 0, |
| @@ -2173,9 +2005,7 @@ static void uploadslice (struct tile *tile, struct slice *slice) · 6 unmodified lines | ||
| 2173 | 2005 | texdata+offset |
| 2174 | 2006 | ); |
| 2175 | 2007 | } |
| 2176 | − if (tile->pbo) { | |
| 2177 | − state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0); | |
| 2178 | − } | |
| 2008 | + if (tile->pbo) state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0); | |
| 2179 | 2009 | } |
| 2180 | 2010 | } |
| 2181 | 2011 | |
| @@ -2304,17 +2134,13 @@ ML (postprocess (value ptr_v, value hlinks_v, · 122 unmodified lines | ||
| 2304 | 2134 | } |
| 2305 | 2135 | |
| 2306 | 2136 | ensureannots (page); |
| 2307 | − if (hlmask & 1) { | |
| 2308 | − highlightlinks (page, xoff, yoff); | |
| 2309 | − } | |
| 2137 | + if (hlmask & 1) highlightlinks (page, xoff, yoff); | |
| 2310 | 2138 | if (hlmask & 2) { |
| 2311 | 2139 | highlightslinks (page, xoff, yoff, noff, targ, STTI (tlen), |
| 2312 | 2140 | chars, STTI (clen), hfsize); |
| 2313 | 2141 | noff = page->slinkcount; |
| 2314 | 2142 | } |
| 2315 | − if (page->tgen == state.gen) { | |
| 2316 | − showsel (page, xoff, yoff); | |
| 2317 | − } | |
| 2143 | + if (page->tgen == state.gen) showsel (page, xoff, yoff); | |
| 2318 | 2144 | unlock (__func__); |
| 2319 | 2145 | |
| 2320 | 2146 | done: |
| @@ -2339,17 +2165,13 @@ static struct annot *getannot (struct page *page, int x, int y) · 18 unmodified lines | ||
| 2339 | 2165 | const fz_matrix *tctm; |
| 2340 | 2166 | pdf_document *pdf = pdf_specifics (state.ctx, state.doc); |
| 2341 | 2167 | |
| 2342 | − if (!page->annots) { | |
| 2343 | − return NULL; | |
| 2344 | − } | |
| 2168 | + if (!page->annots) return NULL; | |
| 2345 | 2169 | |
| 2346 | 2170 | if (pdf) { |
| 2347 | 2171 | trimctm (pdf_page_from_fz_page (state.ctx, page->fzpage), page->pdimno); |
| 2348 | 2172 | tctm = &state.pagedims[page->pdimno].tctm; |
| 2349 | 2173 | } |
| 2350 | − else { | |
| 2351 | − tctm = &fz_identity; | |
| 2352 | − } | |
| 2174 | + else tctm = &fz_identity; | |
| 2353 | 2175 | |
| 2354 | 2176 | p.x = x; |
| 2355 | 2177 | p.y = y; |
| @@ -2435,9 +2257,7 @@ ML (find_page_with_links (value start_page_v, value dir_v)) · 79 unmodified lines | ||
| 2435 | 2257 | fz_catch (state.ctx) { |
| 2436 | 2258 | found = 0; |
| 2437 | 2259 | } |
| 2438 | − if (page) { | |
| 2439 | − fz_drop_page (state.ctx, &page->super); | |
| 2440 | − } | |
| 2260 | + if (page) fz_drop_page (state.ctx, &page->super); | |
| 2441 | 2261 | } |
| 2442 | 2262 | else { |
| 2443 | 2263 | fz_page *page = fz_load_page (state.ctx, state.doc, i); |
| @@ -2563,9 +2383,7 @@ ML (findlink (value ptr_v, value dir_v)) · 119 unmodified lines | ||
| 2563 | 2383 | break; |
| 2564 | 2384 | |
| 2565 | 2385 | case dir_last: |
| 2566 | − if (page->slinks) { | |
| 2567 | − found = page->slinks + (page->slinkcount - 1); | |
| 2568 | − } | |
| 2386 | + if (page->slinks) found = page->slinks + (page->slinkcount - 1); | |
| 2569 | 2387 | break; |
| 2570 | 2388 | } |
| 2571 | 2389 | } |
| @@ -2694,9 +2512,7 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 122 unmodified lines | ||
| 2694 | 2512 | struct pagedim *pdim; |
| 2695 | 2513 | |
| 2696 | 2514 | ret_v = Val_int (0); |
| 2697 | − if (trylock (__func__)) { | |
| 2698 | − goto done; | |
| 2699 | − } | |
| 2515 | + if (trylock (__func__)) goto done; | |
| 2700 | 2516 | |
| 2701 | 2517 | page = parse_pointer (__func__, ptr); |
| 2702 | 2518 | pdim = &state.pagedims[page->pdimno]; |
| @@ -2740,19 +2556,13 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 37 unmodified lines | ||
| 2740 | 2556 | for (block = page->text->first_block; block; block = block->next) { |
| 2741 | 2557 | fz_stext_line *line; |
| 2742 | 2558 | |
| 2743 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 2744 | − continue; | |
| 2745 | − } | |
| 2746 | − if (!fz_is_point_inside_rect (p, block->bbox)) { | |
| 2747 | − continue; | |
| 2748 | − } | |
| 2559 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 2560 | + if (!fz_is_point_inside_rect (p, block->bbox)) continue; | |
| 2749 | 2561 | |
| 2750 | 2562 | for (line = block->u.t.first_line; line; line = line->next) { |
| 2751 | 2563 | fz_stext_char *ch; |
| 2752 | 2564 | |
| 2753 | − if (!fz_is_point_inside_rect (p, line->bbox)) { | |
| 2754 | − continue; | |
| 2755 | − } | |
| 2565 | + if (!fz_is_point_inside_rect (p, line->bbox)) continue; | |
| 2756 | 2566 | |
| 2757 | 2567 | for (ch = line->first_char; ch; ch = ch->next) { |
| 2758 | 2568 | if (!fz_is_point_inside_quad (p, ch->quad)) { |
| @@ -2760,9 +2570,7 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 1 unmodified line | ||
| 2760 | 2570 | FT_FaceRec *face = fz_font_ft_face (state.ctx, |
| 2761 | 2571 | ch->font); |
| 2762 | 2572 | |
| 2763 | − if (!n2) { | |
| 2764 | − n2 = "<unknown font>"; | |
| 2765 | − } | |
| 2573 | + if (!n2) n2 = "<unknown font>"; | |
| 2766 | 2574 | |
| 2767 | 2575 | if (face && face->family_name) { |
| 2768 | 2576 | char *s; |
| @@ -2781,9 +2589,7 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 12 unmodified lines | ||
| 2781 | 2589 | } |
| 2782 | 2590 | } |
| 2783 | 2591 | } |
| 2784 | − if (str_v == Val_unit) { | |
| 2785 | − str_v = caml_copy_string (n2); | |
| 2786 | − } | |
| 2592 | + if (str_v == Val_unit) str_v = caml_copy_string (n2); | |
| 2787 | 2593 | ret_v = caml_alloc_small (1, utext); |
| 2788 | 2594 | Field (ret_v, 0) = str_v; |
| 2789 | 2595 | goto unlock; |
| @@ -2836,9 +2642,7 @@ ML (markunder (value ptr_v, value x_v, value y_v, value mark_v)) · 46 unmodified lines | ||
| 2836 | 2642 | fz_point p = { .x = Int_val (x_v), .y = Int_val (y_v) }; |
| 2837 | 2643 | |
| 2838 | 2644 | ret_v = Val_bool (0); |
| 2839 | − if (trylock (__func__)) { | |
| 2840 | − goto done; | |
| 2841 | − } | |
| 2645 | + if (trylock (__func__)) goto done; | |
| 2842 | 2646 | |
| 2843 | 2647 | page = parse_pointer (__func__, String_val (ptr_v)); |
| 2844 | 2648 | pdim = &state.pagedims[page->pdimno]; |
| @@ -2856,12 +2660,8 @@ ML (markunder (value ptr_v, value x_v, value y_v, value mark_v)) · 11 unmodified lines | ||
| 2856 | 2660 | p.y += pdim->bounds.y0; |
| 2857 | 2661 | |
| 2858 | 2662 | for (block = page->text->first_block; block; block = block->next) { |
| 2859 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 2860 | − continue; | |
| 2861 | − } | |
| 2862 | − if (!fz_is_point_inside_rect (p, block->bbox)) { | |
| 2863 | − continue; | |
| 2864 | − } | |
| 2663 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 2664 | + if (!fz_is_point_inside_rect (p, block->bbox)) continue; | |
| 2865 | 2665 | |
| 2866 | 2666 | if (mark == mark_block) { |
| 2867 | 2667 | page->fmark = block->u.t.first_line->first_char; |
| @@ -2892,15 +2692,11 @@ ML (markunder (value ptr_v, value x_v, value y_v, value mark_v)) · 24 unmodified lines | ||
| 2892 | 2692 | first = NULL; |
| 2893 | 2693 | } |
| 2894 | 2694 | else { |
| 2895 | − if (!first) { | |
| 2896 | − first = ch2; | |
| 2897 | − } | |
| 2695 | + if (!first) first = ch2; | |
| 2898 | 2696 | } |
| 2899 | 2697 | } |
| 2900 | 2698 | for (ch2 = ch; ch2; ch2 = ch2->next) { |
| 2901 | − if (uninteresting (ch2->c)) { | |
| 2902 | − break; | |
| 2903 | − } | |
| 2699 | + if (uninteresting (ch2->c)) break; | |
| 2904 | 2700 | last = ch2; |
| 2905 | 2701 | } |
| 2906 | 2702 | |
| @@ -2934,9 +2730,7 @@ ML (rectofblock (value ptr_v, value x_v, value y_v)) · 27 unmodified lines | ||
| 2934 | 2730 | fz_point p = { .x = Int_val (x_v), .y = Int_val (y_v) }; |
| 2935 | 2731 | |
| 2936 | 2732 | ret_v = Val_int (0); |
| 2937 | − if (trylock (__func__)) { | |
| 2938 | − goto done; | |
| 2939 | − } | |
| 2733 | + if (trylock (__func__)) goto done; | |
| 2940 | 2734 | |
| 2941 | 2735 | page = parse_pointer (__func__, String_val (ptr_v)); |
| 2942 | 2736 | pdim = &state.pagedims[page->pdimno]; |
| @@ -2959,8 +2753,7 @@ ML (rectofblock (value ptr_v, value x_v, value y_v)) · 16 unmodified lines | ||
| 2959 | 2753 | continue; |
| 2960 | 2754 | } |
| 2961 | 2755 | |
| 2962 | − if (fz_is_point_inside_rect (p, *b)) | |
| 2963 | − break; | |
| 2756 | + if (fz_is_point_inside_rect (p, *b)) break; | |
| 2964 | 2757 | b = NULL; |
| 2965 | 2758 | } |
| 2966 | 2759 | if (b) { |
| @@ -2989,9 +2782,7 @@ ML0 (seltext (value ptr_v, value rect_v)) · 22 unmodified lines | ||
| 2989 | 2782 | fz_stext_block *block; |
| 2990 | 2783 | fz_stext_char *fc, *lc; |
| 2991 | 2784 | |
| 2992 | − if (trylock (__func__)) { | |
| 2993 | − goto done; | |
| 2994 | − } | |
| 2785 | + if (trylock (__func__)) goto done; | |
| 2995 | 2786 | |
| 2996 | 2787 | page = parse_pointer (__func__, String_val (ptr_v)); |
| 2997 | 2788 | ensuretext (page); |
| @@ -3014,18 +2805,13 @@ ML0 (seltext (value ptr_v, value rect_v)) · 16 unmodified lines | ||
| 3014 | 2805 | lc = page->lmark; |
| 3015 | 2806 | |
| 3016 | 2807 | for (block = page->text->first_block; block; block = block->next) { |
| 3017 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 3018 | − continue; | |
| 3019 | − } | |
| 2808 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 2809 | + | |
| 3020 | 2810 | for (line = block->u.t.first_line; line; line = line->next) { |
| 3021 | 2811 | for (ch = line->first_char; ch; ch = ch->next) { |
| 3022 | 2812 | fz_point p0 = { .x = x0, .y = y0 }, p1 = { .x = x1, .y = y1 }; |
| 3023 | − if (fz_is_point_inside_quad (p0, ch->quad)) { | |
| 3024 | − fc = ch; | |
| 3025 | − } | |
| 3026 | − if (fz_is_point_inside_quad (p1, ch->quad)) { | |
| 3027 | − lc = ch; | |
| 3028 | − } | |
| 2813 | + if (fz_is_point_inside_quad (p0, ch->quad)) fc = ch; | |
| 2814 | + if (fz_is_point_inside_quad (p1, ch->quad)) lc = ch; | |
| 3029 | 2815 | } |
| 3030 | 2816 | } |
| 3031 | 2817 | } |
| @@ -3075,9 +2861,8 @@ ML (spawn (value command_v, value fds_v)) · 43 unmodified lines | ||
| 3075 | 2861 | char *argv[] = { "/bin/sh", "-c", NULL, NULL }; |
| 3076 | 2862 | |
| 3077 | 2863 | argv[2] = &Byte (command_v, 0); |
| 3078 | − if ((ret = posix_spawn_file_actions_init (&fa)) != 0) { | |
| 2864 | + if ((ret = posix_spawn_file_actions_init (&fa)) != 0) | |
| 3079 | 2865 | unix_error (ret, "posix_spawn_file_actions_init", Nothing); |
| 3080 | − } | |
| 3081 | 2866 | |
| 3082 | 2867 | if ((ret = posix_spawnattr_init (&attr)) != 0) { |
| 3083 | 2868 | msg = "posix_spawnattr_init"; |
| @@ -3164,9 +2949,7 @@ ML0 (copysel (value fd_v, value ptr_v)) · 80 unmodified lines | ||
| 3164 | 2949 | fz_stext_block *block; |
| 3165 | 2950 | int fd = Int_val (fd_v); |
| 3166 | 2951 | |
| 3167 | − if (trylock (__func__)) { | |
| 3168 | − goto done; | |
| 3169 | − } | |
| 2952 | + if (trylock (__func__)) goto done; | |
| 3170 | 2953 | |
| 3171 | 2954 | page = parse_pointer (__func__, String_val (ptr_v)); |
| 3172 | 2955 | |
| @@ -3183,26 +2966,21 @@ ML0 (copysel (value fd_v, value ptr_v)) · 10 unmodified lines | ||
| 3183 | 2966 | } |
| 3184 | 2967 | |
| 3185 | 2968 | for (block = page->text->first_block; block; block = block->next) { |
| 3186 | − if (block->type != FZ_STEXT_BLOCK_TEXT) { | |
| 3187 | − continue; | |
| 3188 | − } | |
| 2969 | + if (block->type != FZ_STEXT_BLOCK_TEXT) continue; | |
| 2970 | + | |
| 3189 | 2971 | for (line = block->u.t.first_line; line; line = line->next) { |
| 3190 | 2972 | fz_stext_char *ch; |
| 3191 | 2973 | for (ch = line->first_char; ch; ch = ch->next) { |
| 3192 | 2974 | if (seen || ch == page->fmark) { |
| 3193 | 2975 | do { |
| 3194 | 2976 | pipechar (f, ch); |
| 3195 | − if (ch == page->lmark) { | |
| 3196 | − goto close; | |
| 3197 | − } | |
| 2977 | + if (ch == page->lmark) goto close; | |
| 3198 | 2978 | } while ((ch = ch->next)); |
| 3199 | 2979 | seen = 1; |
| 3200 | 2980 | break; |
| 3201 | 2981 | } |
| 3202 | 2982 | } |
| 3203 | − if (seen) { | |
| 3204 | − fputc ('\n', f); | |
| 3205 | − } | |
| 2983 | + if (seen) fputc ('\n', f); | |
| 3206 | 2984 | } |
| 3207 | 2985 | } |
| 3208 | 2986 | close: |
| @@ -3210,10 +2988,9 @@ close: · 1 unmodified line | ||
| 3210 | 2988 | int ret = fclose (f); |
| 3211 | 2989 | fd = -1; |
| 3212 | 2990 | if (ret == -1) { |
| 3213 | − if (errno != ECHILD) { | |
| 2991 | + if (errno != ECHILD) | |
| 3214 | 2992 | printd ("emsg failed to close sel pipe: %d:%s", |
| 3215 | 2993 | errno, strerror (errno)); |
| 3216 | − } | |
| 3217 | 2994 | } |
| 3218 | 2995 | } |
| 3219 | 2996 | unlock: |
| @@ -3221,10 +2998,9 @@ unlock: · 1 unmodified line | ||
| 3221 | 2998 | |
| 3222 | 2999 | done: |
| 3223 | 3000 | if (fd >= 0) { |
| 3224 | − if (close (fd)) { | |
| 3001 | + if (close (fd)) | |
| 3225 | 3002 | printd ("emsg failed to close sel pipe: %d:%s", |
| 3226 | 3003 | errno, strerror (errno)); |
| 3227 | − } | |
| 3228 | 3004 | } |
| 3229 | 3005 | CAMLreturn0; |
| 3230 | 3006 | } |
| @@ -3237,9 +3013,7 @@ ML (getpdimrect (value pagedimno_v)) · 6 unmodified lines | ||
| 3237 | 3013 | fz_rect box; |
| 3238 | 3014 | |
| 3239 | 3015 | ret_v = caml_alloc_small (4 * Double_wosize, Double_array_tag); |
| 3240 | − if (trylock (__func__)) { | |
| 3241 | − box = fz_empty_rect; | |
| 3242 | − } | |
| 3016 | + if (trylock (__func__)) box = fz_empty_rect; | |
| 3243 | 3017 | else { |
| 3244 | 3018 | box = state.pagedims[pagedimno].mediabox; |
| 3245 | 3019 | unlock (__func__); |
| @@ -3267,9 +3041,7 @@ ML (zoom_for_height (value winw_v, value winh_v, value dw_v, value cols_v)) · 21 unmodified lines | ||
| 3267 | 3041 | float cols = Int_val (cols_v); |
| 3268 | 3042 | float pw = 1.0, ph = 1.0; |
| 3269 | 3043 | |
| 3270 | − if (trylock (__func__)) { | |
| 3271 | − goto done; | |
| 3272 | − } | |
| 3044 | + if (trylock (__func__)) goto done; | |
| 3273 | 3045 | |
| 3274 | 3046 | for (i = 0, p = state.pagedims; i < state.pagedimcount; ++i, ++p) { |
| 3275 | 3047 | float w = p->pagebox.x1 / cols; |
| @@ -3277,13 +3049,9 @@ ML (zoom_for_height (value winw_v, value winh_v, value dw_v, value cols_v)) · 1 unmodified line | ||
| 3277 | 3049 | if (h > maxh) { |
| 3278 | 3050 | maxh = h; |
| 3279 | 3051 | ph = h; |
| 3280 | − if (state.fitmodel != FitProportional) { | |
| 3281 | − pw = w; | |
| 3282 | − } | |
| 3283 | − } | |
| 3284 | − if ((state.fitmodel == FitProportional) && w > pw) { | |
| 3285 | − pw = w; | |
| 3052 | + if (state.fitmodel != FitProportional) pw = w; | |
| 3286 | 3053 | } |
| 3054 | + if ((state.fitmodel == FitProportional) && w > pw) pw = w; | |
| 3287 | 3055 | } |
| 3288 | 3056 | |
| 3289 | 3057 | zoom = (((winh / ph) * pw) + dw) / winw; |
| @@ -3301,9 +3069,7 @@ ML (getmaxw (value unit_v)) · 11 unmodified lines | ||
| 3301 | 3069 | float maxw = -1.; |
| 3302 | 3070 | struct pagedim *p; |
| 3303 | 3071 | |
| 3304 | − if (trylock (__func__)) { | |
| 3305 | − goto done; | |
| 3306 | − } | |
| 3072 | + if (trylock (__func__)) goto done; | |
| 3307 | 3073 | |
| 3308 | 3074 | for (i = 0, p = state.pagedims; i < state.pagedimcount; ++i, ++p) { |
| 3309 | 3075 | float w = p->pagebox.x1; |
| @@ -3437,9 +3203,7 @@ ML (platform (value unit_v)) · 127 unmodified lines | ||
| 3437 | 3203 | #elif defined __APPLE__ |
| 3438 | 3204 | platid = pimacos; |
| 3439 | 3205 | #endif |
| 3440 | − if (uname (&buf)) { | |
| 3441 | − err (1, "uname"); | |
| 3442 | − } | |
| 3206 | + if (uname (&buf)) err (1, "uname"); | |
| 3443 | 3207 | |
| 3444 | 3208 | tup_v = caml_alloc_tuple (2); |
| 3445 | 3209 | { |
| @@ -3462,9 +3226,7 @@ ML0 (cloexec (value fd_v)) · 16 unmodified lines | ||
| 3462 | 3226 | CAMLparam1 (fd_v); |
| 3463 | 3227 | int fd = Int_val (fd_v); |
| 3464 | 3228 | |
| 3465 | − if (fcntl (fd, F_SETFD, FD_CLOEXEC, 1)) { | |
| 3466 | − uerror ("fcntl", Nothing); | |
| 3467 | − } | |
| 3229 | + if (fcntl (fd, F_SETFD, FD_CLOEXEC, 1)) uerror ("fcntl", Nothing); | |
| 3468 | 3230 | CAMLreturn0; |
| 3469 | 3231 | } |
| 3470 | 3232 | |
| @@ -3479,9 +3241,7 @@ ML (getpbo (value w_v, value h_v, value cs_v)) · 8 unmodified lines | ||
| 3479 | 3241 | |
| 3480 | 3242 | if (state.bo_usable) { |
| 3481 | 3243 | pbo = calloc (sizeof (*pbo), 1); |
| 3482 | − if (!pbo) { | |
| 3483 | − err (1, "calloc pbo"); | |
| 3484 | − } | |
| 3244 | + if (!pbo) err (1, "calloc pbo"); | |
| 3485 | 3245 | |
| 3486 | 3246 | switch (cs) { |
| 3487 | 3247 | case 0: |
| @@ -3513,24 +3273,18 @@ ML (getpbo (value w_v, value h_v, value cs_v)) · 25 unmodified lines | ||
| 3513 | 3273 | char *s; |
| 3514 | 3274 | |
| 3515 | 3275 | res = snprintf (NULL, 0, "%" PRIxPTR, (uintptr_t) pbo); |
| 3516 | − if (res < 0) { | |
| 3276 | + if (res < 0) | |
| 3517 | 3277 | err (1, "snprintf %" PRIxPTR " failed", (uintptr_t) pbo); |
| 3518 | − } | |
| 3519 | 3278 | s = malloc (res+1); |
| 3520 | − if (!s) { | |
| 3521 | − err (1, "malloc %d bytes failed", res+1); | |
| 3522 | − } | |
| 3279 | + if (!s) err (1, "malloc %d bytes failed", res+1); | |
| 3523 | 3280 | res = sprintf (s, "%" PRIxPTR, (uintptr_t) pbo); |
| 3524 | − if (res < 0) { | |
| 3281 | + if (res < 0) | |
| 3525 | 3282 | err (1, "sprintf %" PRIxPTR " failed", (uintptr_t) pbo); |
| 3526 | − } | |
| 3527 | 3283 | ret_v = caml_copy_string (s); |
| 3528 | 3284 | free (s); |
| 3529 | 3285 | } |
| 3530 | 3286 | } |
| 3531 | − else { | |
| 3532 | − ret_v = caml_copy_string ("0"); | |
| 3533 | − } | |
| 3287 | + else ret_v = caml_copy_string ("0"); | |
| 3534 | 3288 | CAMLreturn (ret_v); |
| 3535 | 3289 | } |
| 3536 | 3290 | |
| @@ -3555,9 +3309,8 @@ ML0 (unmappbo (value ptr_v)) · 18 unmodified lines | ||
| 3555 | 3309 | |
| 3556 | 3310 | if (tile->pbo) { |
| 3557 | 3311 | state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, tile->pbo->id); |
| 3558 | − if (state.glUnmapBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB) == GL_FALSE) { | |
| 3312 | + if (state.glUnmapBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB) == GL_FALSE) | |
| 3559 | 3313 | errx (1, "glUnmapBufferARB failed: %#x\n", glGetError ()); |
| 3560 | − } | |
| 3561 | 3314 | tile->pbo->ptr = NULL; |
| 3562 | 3315 | state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0); |
| 3563 | 3316 | } |
| @@ -3600,9 +3353,7 @@ ML (unproject (value ptr_v, value x_v, value y_v)) · 36 unmodified lines | ||
| 3600 | 3353 | pdim = &state.pagedims[page->pdimno]; |
| 3601 | 3354 | |
| 3602 | 3355 | ret_v = Val_int (0); |
| 3603 | − if (trylock (__func__)) { | |
| 3604 | − goto done; | |
| 3605 | − } | |
| 3356 | + if (trylock (__func__)) goto done; | |
| 3606 | 3357 | |
| 3607 | 3358 | p.x = x + pdim->bounds.x0; |
| 3608 | 3359 | p.y = y + pdim->bounds.y0; |
| @@ -3637,21 +3388,16 @@ ML (project (value ptr_v, value pageno_v, value pdimno_v, value x_v, value y_v)) · 28 unmodified lines | ||
| 3637 | 3388 | ret_v = Val_int (0); |
| 3638 | 3389 | lock (__func__); |
| 3639 | 3390 | |
| 3640 | − if (!*s) { | |
| 3641 | − page = loadpage (pageno, pdimno); | |
| 3642 | − } | |
| 3643 | − else { | |
| 3644 | − page = parse_pointer (__func__, String_val (ptr_v)); | |
| 3645 | − } | |
| 3391 | + if (!*s) page = loadpage (pageno, pdimno); | |
| 3392 | + else page = parse_pointer (__func__, String_val (ptr_v)); | |
| 3646 | 3393 | pdim = &state.pagedims[pdimno]; |
| 3647 | 3394 | |
| 3648 | 3395 | if (pdf_specifics (state.ctx, state.doc)) { |
| 3649 | 3396 | trimctm (pdf_page_from_fz_page (state.ctx, page->fzpage), page->pdimno); |
| 3650 | 3397 | ctm = state.pagedims[page->pdimno].tctm; |
| 3651 | 3398 | } |
| 3652 | − else { | |
| 3653 | − ctm = fz_identity; | |
| 3654 | − } | |
| 3399 | + else ctm = fz_identity; | |
| 3400 | + | |
| 3655 | 3401 | p.x = x + pdim->bounds.x0; |
| 3656 | 3402 | p.y = y + pdim->bounds.y0; |
| 3657 | 3403 | |
| @@ -3662,9 +3408,7 @@ ML (project (value ptr_v, value pageno_v, value pdimno_v, value x_v, value y_v)) · 4 unmodified lines | ||
| 3662 | 3408 | Field (ret_v, 0) = caml_copy_double ((double) p.x); |
| 3663 | 3409 | Field (ret_v, 1) = caml_copy_double ((double) p.y); |
| 3664 | 3410 | |
| 3665 | − if (!*s) { | |
| 3666 | − freepage (page); | |
| 3667 | − } | |
| 3411 | + if (!*s) freepage (page); | |
| 3668 | 3412 | unlock (__func__); |
| 3669 | 3413 | CAMLreturn (ret_v); |
| 3670 | 3414 | } |
| @@ -3743,9 +3487,7 @@ ML0 (savedoc (value path_v)) · 72 unmodified lines | ||
| 3743 | 3487 | CAMLparam1 (path_v); |
| 3744 | 3488 | pdf_document *pdf = pdf_specifics (state.ctx, state.doc); |
| 3745 | 3489 | |
| 3746 | − if (pdf) { | |
| 3747 | − pdf_save_document (state.ctx, pdf, String_val (path_v), NULL); | |
| 3748 | − } | |
| 3490 | + if (pdf) pdf_save_document (state.ctx, pdf, String_val (path_v), NULL); | |
| 3749 | 3491 | CAMLreturn0; |
| 3750 | 3492 | } |
| 3751 | 3493 | |
| @@ -3793,9 +3535,8 @@ static fz_font *lsff (fz_context *ctx,int UNUSED_ATTR script, · 41 unmodified lines | ||
| 3793 | 3535 | |
| 3794 | 3536 | if (!done) { |
| 3795 | 3537 | char *path = getenv ("LLPP_FALLBACK_FONT"); |
| 3796 | − if (path) { | |
| 3538 | + if (path) | |
| 3797 | 3539 | font = fz_new_font_from_file (ctx, NULL, path, 0, 1); |
| 3798 | − } | |
| 3799 | 3540 | done = 1; |
| 3800 | 3541 | } |
| 3801 | 3542 | return font; |
| @@ -3809,9 +3550,7 @@ ML0 (setdcf (value path_v)) · 7 unmodified lines | ||
| 3809 | 3550 | size_t len = caml_string_length (path_v); |
| 3810 | 3551 | if (*p) { |
| 3811 | 3552 | state.dcf = malloc (len + 1); |
| 3812 | − if (!state.dcf) { | |
| 3813 | − err (1, "malloc dimpath %zu", len + 1); | |
| 3814 | − } | |
| 3553 | + if (!state.dcf) err (1, "malloc dimpath %zu", len + 1); | |
| 3815 | 3554 | memcpy (state.dcf, p, len); |
| 3816 | 3555 | state.dcf[len] = 0; |
| 3817 | 3556 | } |
| @@ -3824,14 +3563,10 @@ ML (init (value csock_v, value params_v)) · 6 unmodified lines | ||
| 3824 | 3563 | int ret, texcount, colorspace, mustoresize; |
| 3825 | 3564 | const char *fontpath; |
| 3826 | 3565 | |
| 3827 | − if (pipe (state.pfds)) { | |
| 3828 | − err (1, "pipe"); | |
| 3829 | − } | |
| 3566 | + if (pipe (state.pfds)) err (1, "pipe"); | |
| 3830 | 3567 | for (int ntries = 0; ntries < 1737; ++ntries) { |
| 3831 | 3568 | if (-1 == dup2 (state.pfds[1], 2)) { |
| 3832 | − if (EINTR == errno) { | |
| 3833 | − continue; | |
| 3834 | − } | |
| 3569 | + if (EINTR == errno) continue; | |
| 3835 | 3570 | err (1, "dup2"); |
| 3836 | 3571 | } |
| 3837 | 3572 | break; |
| @@ -3855,9 +3590,7 @@ ML (init (value csock_v, value params_v)) · 17 unmodified lines | ||
| 3855 | 3590 | const char *cset = nl_langinfo (CODESET); |
| 3856 | 3591 | state.utf8cs = !strcmp (cset, "UTF-8"); |
| 3857 | 3592 | } |
| 3858 | − else { | |
| 3859 | − printd ("emsg setlocale: %d:%s", errno, strerror (errno)); | |
| 3860 | − } | |
| 3593 | + else printd ("emsg setlocale: %d:%s", errno, strerror (errno)); | |
| 3861 | 3594 | #endif |
| 3862 | 3595 | |
| 3863 | 3596 | state.ctx = fz_new_context (NULL, NULL, mustoresize); |
| @@ -3875,9 +3608,7 @@ ML (init (value csock_v, value params_v)) · 11 unmodified lines | ||
| 3875 | 3608 | |
| 3876 | 3609 | set_tex_params (colorspace); |
| 3877 | 3610 | |
| 3878 | − if (*fontpath) { | |
| 3879 | − state.face = load_font (fontpath); | |
| 3880 | − } | |
| 3611 | + if (*fontpath) state.face = load_font (fontpath); | |
| 3881 | 3612 | else { |
| 3882 | 3613 | int len; |
| 3883 | 3614 | const unsigned char *data; |
| @@ -3885,18 +3616,14 @@ ML (init (value csock_v, value params_v)) · 1 unmodified line | ||
| 3885 | 3616 | data = pdf_lookup_substitute_font (state.ctx, 0, 0, 0, 0, &len); |
| 3886 | 3617 | state.face = load_builtin_font (data, len); |
| 3887 | 3618 | } |
| 3888 | − if (!state.face) { | |
| 3889 | − _exit (1); | |
| 3890 | − } | |
| 3619 | + if (!state.face) _exit (1); | |
| 3891 | 3620 | |
| 3892 | 3621 | realloctexts (texcount); |
| 3893 | 3622 | setuppbo (); |
| 3894 | 3623 | makestippletex (); |
| 3895 | 3624 | |
| 3896 | 3625 | ret = pthread_create (&state.thread, NULL, mainloop, NULL); |
| 3897 | − if (ret) { | |
| 3898 | − errx (1, "pthread_create: %s", strerror (ret)); | |
| 3899 | − } | |
| 3626 | + if (ret) errx (1, "pthread_create: %s", strerror (ret)); | |
| 3900 | 3627 | |
| 3901 | 3628 | CAMLreturn (Val_int (state.pfds[0])); |
| 3902 | 3629 | } |