History

Braceless single line

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?).

malc committed 6 years ago

Commit 649d0561 parent 0ae80da1 file · +182 −455Browse files

Unified · Split

link.c+182−455
@@ -81,11 +81,9 @@ · 80 unmodified lines
8181 #define lprintf(...)
8282 #endif
8383
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; \
8987 } (void) 0
9088
9189 #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
204202 static void lock (const char *cap)
205203 {
206204 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));
210206 }
211207
212208 static void unlock (const char *cap)
213209 {
214210 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));
218212 }
219213
220214 static int trylock (const char *cap)
221215 {
222216 int ret = pthread_mutex_trylock (&mutex);
223− if (ret && ret != EBUSY) {
217+ if (ret && ret != EBUSY)
224218 errx (1, "%s: pthread_mutex_trylock: %s", cap, strerror (ret));
225− }
226219 return ret == EBUSY;
227220 }
228221
@@ -230,9 +223,7 @@ static int hasdata (void) · 1 unmodified line
230223 {
231224 int ret, avail;
232225 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);
236227 return avail > 0;
237228 }
238229
@@ -242,9 +233,7 @@ ML (hasdata (value fd_v)) · 3 unmodified lines
242233 int ret, avail;
243234
244235 ret = ioctl (Int_val (fd_v), FIONREAD, &avail);
245− if (ret) {
246− uerror ("ioctl (FIONREAD)", Nothing);
247− }
236+ if (ret) uerror ("ioctl (FIONREAD)", Nothing);
248237 CAMLreturn (Val_bool (avail > 0));
249238 }
250239
@@ -255,12 +244,8 @@ static void readdata (int fd, void *p, int size) · 4 unmodified lines
255244 again:
256245 n = read (fd, p, size);
257246 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");
264249 errx (1, "read (fd %d, req %d, ret %zd)", fd, size, n);
265250 }
266251 }
@@ -280,9 +265,7 @@ again: · 13 unmodified lines
280265 goto again;
281266 }
282267 if (n - size - 4) {
283− if (!n) {
284− errx (1, "EOF while writing data");
285− }
268+ if (!n) errx (1, "EOF while writing data");
286269 err (1, "writev (fd %d, req %d, ret %zd)", fd, size + 4, n);
287270 }
288271 }
@@ -329,21 +312,13 @@ static void GCC_FMT_ATTR (1, 2) printd (const char *fmt, ...) · 40 unmodified lines
329312 writedata (state.csock, buf, len);
330313 break;
331314 }
332− else {
333− size = len + 5;
334− }
335− }
336− else {
337− err (1, "vsnprintf for `%s' failed", fmt);
315+ else size = len + 5;
338316 }
317+ else err (1, "vsnprintf for `%s' failed", fmt);
339318 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);
346320 }
321+ if (buf != fbuf) free (buf);
347322 }
348323
349324 static void closedoc (void)
@@ -409,14 +384,10 @@ static void docinfo (void) · 59 unmodified lines
409384 again:
410385 need = fz_lookup_metadata (state.ctx, state.doc, tab[i].tag, buf, len);
411386 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);
415388 else {
416389 buf = realloc (buf, need);
417− if (!buf) {
418− err (1, "docinfo realloc %d", need);
419− }
390+ if (!buf) err (1, "docinfo realloc %d", need);
420391 len = need;
421392 goto again;
422393 }
@@ -442,15 +413,9 @@ static void unlinktile (struct tile *tile) · 19 unmodified lines
442413
443414 static void freepage (struct page *page)
444415 {
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);
454419 fz_drop_display_list (state.ctx, page->dlist);
455420 fz_drop_page (state.ctx, page->fzpage);
456421 free (page);
@@ -463,9 +428,7 @@ static void freetile (struct tile *tile) · 6 unmodified lines
463428 #if 0
464429 fz_drop_pixmap (state.ctx, tile->pixmap);
465430 #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);
469432 state.pig = tile->pixmap;
470433 #endif
471434 }
@@ -480,9 +443,7 @@ static void trimctm (pdf_page *page, int pindex) · 8 unmodified lines
480443 {
481444 struct pagedim *pdim = &state.pagedims[pindex];
482445
483− if (!page) {
484− return;
485− }
446+ if (!page) return;
486447 if (!pdim->tctmready) {
487448 fz_rect realbox, mediabox;
488449 fz_matrix page_ctm, ctm;
@@ -507,10 +468,8 @@ static fz_matrix pagectm1 (fz_page *fzpage, struct pagedim *pdim) · 18 unmodified lines
507468 trimctm (pdf_page_from_fz_page (state.ctx, fzpage), (int) pdimno);
508469 ctm = fz_concat (pdim->tctm, pdim->ctm);
509470 }
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);
514473 return ctm;
515474 }
516475
@@ -525,9 +484,7 @@ static void *loadpage (int pageno, int pindex) · 8 unmodified lines
525484 struct page *page;
526485
527486 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);
531488
532489 page->dlist = fz_new_display_list (state.ctx, fz_infinite_rect);
533490 dev = fz_new_list_device (state.ctx, page->dlist);
@@ -558,9 +515,7 @@ static struct tile *alloctile (int h) · 24 unmodified lines
558515 slicecount = (h + state.sliceheight - 1) / state.sliceheight;
559516 tilesize = sizeof (*tile) + ((slicecount - 1) * sizeof (struct slice));
560517 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);
564519 for (int i = 0; i < slicecount; ++i) {
565520 int sh = fz_mini (h, state.sliceheight);
566521 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
598553 tile->pixmap->x = bbox.x0;
599554 tile->pixmap->y = bbox.y0;
600555 }
601− else {
602− fz_drop_pixmap (state.ctx, state.pig);
603− }
556+ else fz_drop_pixmap (state.ctx, state.pig);
604557 state.pig = NULL;
605558 }
606559 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
610563 bbox, NULL, 1, pbo->ptr);
611564 tile->pbo = pbo;
612565 }
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);
618568 }
619569
620570 tile->w = w;
@@ -673,9 +623,7 @@ static void initpdims1 (void) · 52 unmodified lines
673623 }
674624 }
675625 }
676− if (!pageobj) {
677− pageobj = pdf_lookup_page_obj (ctx, pdf, pageno);
678− }
626+ if (!pageobj) pageobj = pdf_lookup_page_obj (ctx, pdf, pageno);
679627
680628 rotate = pdf_to_int (ctx, pdf_dict_gets (ctx, pageobj, "Rotate"));
681629
@@ -706,9 +654,7 @@ static void initpdims1 (void) · 24 unmodified lines
706654 rect = fz_transform_rect (rect, ctm);
707655 rect = fz_intersect_rect (rect, mediabox);
708656
709− if (!fz_is_empty_rect (rect)) {
710− mediabox = rect;
711− }
657+ if (!fz_is_empty_rect (rect)) mediabox = rect;
712658
713659 obj = pdf_new_array (ctx, pdf, 4);
714660 pdf_array_push_real (ctx, obj, mediabox.x0);
@@ -727,11 +673,10 @@ static void initpdims1 (void) · 12 unmodified lines
727673 fz_drop_page (ctx, &page->super);
728674 show = (pageno + 1 == state.pagecount)
729675 || (trim ? pageno % 5 == 0 : pageno % 20 == 0);
730− if (show) {
676+ if (show)
731677 printd ("progress %f Trimming %d",
732678 (double) (pageno + 1) / state.pagecount,
733679 pageno + 1);
734− }
735680 }
736681 fz_catch (ctx) {
737682 printd ("emsg failed to load page %d", pageno);
@@ -760,22 +705,14 @@ static void initpdims1 (void) · 22 unmodified lines
760705 cropbox =
761706 pdf_to_rect (ctx, pdf_dict_gets (ctx, pageobj, "CropBox"));
762707 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);
769710 }
770711 else {
771712 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;
779716 }
780717 }
781718 }
@@ -802,9 +739,7 @@ static void initpdims1 (void) · 20 unmodified lines
802739 rect.y1 += state.trimfuzz.y1;
803740 rect = fz_intersect_rect (rect, mediabox);
804741
805− if (!fz_is_empty_rect (rect)) {
806− mediabox = rect;
807− }
742+ if (!fz_is_empty_rect (rect)) mediabox = rect;
808743 }
809744 fz_drop_page (ctx, page);
810745 }
@@ -819,11 +754,9 @@ static void initpdims1 (void) · 8 unmodified lines
819754 fz_drop_page (ctx, page);
820755
821756 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);
827760 }
828761 fz_catch (ctx) {
829762 printd ("emsg failed to load page %d", pageno);
@@ -838,10 +771,8 @@ static void initpdims1 (void) · 8 unmodified lines
838771
839772 size = (state.pagedimcount + 1) * sizeof (*state.pagedims);
840773 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);
845776
846777 p = &state.pagedims[state.pagedimcount++];
847778 p->rotate = rotate;
@@ -865,17 +796,15 @@ static void initpdims (void) · 17 unmodified lines
865796 }
866797 size_t size = (state.pagedimcount + 1) * sizeof (*state.pagedims);
867798 state.pagedims = realloc (state.pagedims, size);
868− if (!state.pagedims) {
799+ if (!state.pagedims)
869800 err (1, "realloc pagedims to %zu (%d elems)",
870801 size, state.pagedimcount + 1);
871− }
872802 if (fread (state.pagedims,
873803 sizeof (*state.pagedims),
874804 state.pagedimcount+1,
875− f) - (state.pagedimcount+1)) {
805+ f) - (state.pagedimcount+1))
876806 err (1, "fread pagedim data %zu %d",
877807 sizeof (*state.pagedims), state.pagedimcount+1);
878− }
879808 fclose (f);
880809 }
881810
@@ -883,20 +812,17 @@ static void initpdims (void) · 1 unmodified line
883812 initpdims1 ();
884813 if (state.dcf) {
885814 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);
889816 if (fwrite (&state.pagedimcount,
890− sizeof (state.pagedimcount), 1, f) - 1) {
817+ sizeof (state.pagedimcount), 1, f) - 1)
891818 err (1, "fwrite pagedimcunt %zu", sizeof (state.pagedimcount));
892− }
893819 if (fwrite (state.pagedims, sizeof (*state.pagedims),
894820 state.pagedimcount + 1, f)
895− - (state.pagedimcount + 1)) {
821+ - (state.pagedimcount + 1))
896822 err (1, "fwrite pagedim data %zu %u",
897823 sizeof (*state.pagedims), state.pagedimcount+1);
898− } fclose (f);
899824 }
825+ fclose (f);
900826 }
901827 }
902828
@@ -908,9 +834,7 @@ static void layout (void) · 5 unmodified lines
908834 struct pagedim *p = NULL;
909835 float zw, w, maxw = 0.0, zoom = 1.0;
910836
911− if (state.pagedimcount == 0) {
912− return;
913− }
837+ if (state.pagedimcount == 0) return;
914838
915839 switch (state.fitmodel) {
916840 case FitProportional:
@@ -1019,12 +943,8 @@ static void recurse_outline (fz_outline *outline, int level) · 102 unmodified lines
1019943 printd ("o %d %d %d %d %s",
1020944 level, outline->page, (int) p.y, h, outline->title);
1021945 }
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);
1028948 outline = outline->next;
1029949 }
1030950 }
@@ -1033,9 +953,7 @@ static void process_outline (void) · 2 unmodified lines
1033953 {
1034954 fz_outline *outline;
1035955
1036− if (!state.needoutline || !state.pagedimcount) {
1037− return;
1038− }
956+ if (!state.needoutline || !state.pagedimcount) return;
1039957
1040958 state.needoutline = 0;
1041959 outline = fz_load_outline (state.ctx, state.doc);
@@ -1053,18 +971,14 @@ static char *strofline (fz_stext_line *line) · 11 unmodified lines
1053971 size_t size = 0, cap = 80;
1054972
1055973 p = malloc (cap + 1);
1056− if (!p) {
1057− return NULL;
1058− }
974+ if (!p) return NULL;
1059975
1060976 for (ch = line->first_char; ch; ch = ch->next) {
1061977 int n = fz_runetochar (utf8, ch->c);
1062978 if (size + n > cap) {
1063979 cap *= 2;
1064980 p = realloc (p, cap + 1);
1065− if (!p) {
1066− return NULL;
1067− }
981+ if (!p) return NULL;
1068982 }
1069983
1070984 memcpy (p + size, utf8, n);
@@ -1082,9 +996,7 @@ static int matchline (regex_t *re, fz_stext_line *line, · 11 unmodified lines
1082996 regmatch_t rm;
1083997
1084998 p = strofline (line);
1085− if (!p) {
1086− return -1;
1087− }
999+ if (!p) return -1;
10881000
10891001 ret = regexec (re, p, 1, &rm, 0);
10901002 if (ret) {
@@ -1113,9 +1025,7 @@ static int matchline (regex_t *re, fz_stext_line *line, · 22 unmodified lines
11131025 }
11141026 for (;ch; ch = ch->next) {
11151027 o += fz_runelen (ch->c);
1116− if (o > rm.rm_eo) {
1117− break;
1118− }
1028+ if (o > rm.rm_eo) break;
11191029 }
11201030 e = ch->quad;
11211031
@@ -1131,14 +1041,12 @@ static int matchline (regex_t *re, fz_stext_line *line, · 9 unmodified lines
11311041 pageno + 1, (int) (rm.rm_eo - rm.rm_so), &p[rm.rm_so],
11321042 now () - start);
11331043 }
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);
11421050 free (p);
11431051 return 1;
11441052 }
@@ -1164,11 +1072,9 @@ static void search (regex_t *re, int pageno, int y, int forward) · 19 unmodified lines
11641072 pageno);
11651073 stop = 1;
11661074 }
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);
11721078 }
11731079 pdim = pdimofpageno (pageno);
11741080 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
11841090 for (block = text->first_block; block; block = block->next) {
11851091 fz_stext_line *line;
11861092
1187− if (block->type != FZ_STEXT_BLOCK_TEXT) {
1188− continue;
1189− }
1093+ if (block->type != FZ_STEXT_BLOCK_TEXT) continue;
1094+
11901095 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;
11941097
11951098 switch (matchline (re, line, stop, pageno, start)) {
11961099 case 0: break;
@@ -1204,13 +1107,10 @@ static void search (regex_t *re, int pageno, int y, int forward) · 7 unmodified lines
12041107 for (block = text->last_block; block; block = block->prev) {
12051108 fz_stext_line *line;
12061109
1207− if (block->type != FZ_STEXT_BLOCK_TEXT) {
1208− continue;
1209− }
1110+ if (block->type != FZ_STEXT_BLOCK_TEXT) continue;
1111+
12101112 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;
12141114
12151115 switch (matchline (re, line, stop, pageno, start)) {
12161116 case 0: break;
@@ -1234,9 +1134,7 @@ static void search (regex_t *re, int pageno, int y, int forward) · 17 unmodified lines
12341134 fz_drop_page (state.ctx, page);
12351135 }
12361136 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);
12401138 printd ("clearrects");
12411139 }
12421140
@@ -1264,20 +1162,15 @@ static void realloctexts (int texcount) · 21 unmodified lines
12641162 {
12651163 size_t size;
12661164
1267− if (texcount == state.tex.count) {
1268− return;
1269− }
1165+ if (texcount == state.tex.count) return;
12701166
1271− if (texcount < state.tex.count) {
1167+ if (texcount < state.tex.count)
12721168 glDeleteTextures (state.tex.count - texcount,
12731169 state.tex.ids + texcount);
1274− }
12751170
12761171 size = texcount * (sizeof (*state.tex.ids) + sizeof (*state.tex.owners));
12771172 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);
12811174
12821175 state.tex.owners = (void *) (state.tex.ids + texcount);
12831176 if (texcount > state.tex.count) {
@@ -1298,9 +1191,7 @@ static char *mbtoutf8 (char *s) · 14 unmodified lines
12981191 wchar_t *tmp;
12991192 size_t i, ret, len;
13001193
1301− if (state.utf8cs) {
1302− return s;
1303− }
1194+ if (state.utf8cs) return s;
13041195
13051196 len = mbstowcs (NULL, s, strlen (s));
13061197 if (len == 0 || len == (size_t) -1) {
@@ -1371,15 +1262,11 @@ static void * mainloop (void UNUSED_ATTR *unused) · 64 unmodified lines
13711262 fz_var (oldlen);
13721263 for (;;) {
13731264 len = readlen (state.csock);
1374− if (len == 0) {
1375− errx (1, "readlen returned 0");
1376− }
1265+ if (len == 0) errx (1, "readlen returned 0");
13771266
13781267 if (oldlen < len + 1) {
13791268 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);
13831270 oldlen = len + 1;
13841271 }
13851272 readdata (state.csock, p, len);
@@ -1394,17 +1281,14 @@ static void * mainloop (void UNUSED_ATTR *unused) · 8 unmodified lines
13941281
13951282 fz_var (ok);
13961283 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);
14001285
14011286 filename = p + 5 + off;
14021287 filenamelen = strlen (filename);
14031288 password = filename + filenamelen + 1;
14041289
1405− if (password[strlen (password) + 1]) {
1290+ if (password[strlen (password) + 1])
14061291 fz_set_user_css (state.ctx, password + strlen (password) + 1);
1407− }
14081292
14091293 lock ("open");
14101294 fz_set_use_document_css (state.ctx, usedoccss);
@@ -1415,9 +1299,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 4 unmodified lines
14151299 utf8filename = mbtoutf8 (filename);
14161300 printd ("emsg Error loading %s: %s",
14171301 utf8filename, fz_caught_message (state.ctx));
1418− if (utf8filename != filename) {
1419− free (utf8filename);
1420− }
1302+ if (utf8filename != filename) free (utf8filename);
14211303 }
14221304 if (ok) {
14231305 docinfo ();
@@ -1430,9 +1312,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 6 unmodified lines
14301312 int i, colorspace;
14311313
14321314 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);
14361316 lock ("cs");
14371317 set_tex_params (colorspace);
14381318 for (i = 0; i < state.tex.count; ++i) {
@@ -1445,9 +1325,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 6 unmodified lines
14451325 void *ptr;
14461326
14471327 ret = sscanf (p + 8, " %" SCNxPTR, (uintptr_t *) &ptr);
1448− if (ret != 1) {
1328+ if (ret != 1)
14491329 errx (1, "malformed freepage `%.*s' ret=%d", len, p, ret);
1450− }
14511330 lock ("freepage");
14521331 freepage (ptr);
14531332 unlock ("freepage");
@@ -1456,9 +1335,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 2 unmodified lines
14561335 void *ptr;
14571336
14581337 ret = sscanf (p + 8, " %" SCNxPTR, (uintptr_t *) &ptr);
1459− if (ret != 1) {
1338+ if (ret != 1)
14601339 errx (1, "malformed freetile `%.*s' ret=%d", len, p, ret);
1461− }
14621340 lock ("freetile");
14631341 freetile (ptr);
14641342 unlock ("freetile");
@@ -1470,9 +1348,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 5 unmodified lines
14701348
14711349 ret = sscanf (p + 6, " %d %d %d %d,%n",
14721350 &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);
14761352
14771353 pattern = p + 6 + len2;
14781354 ret = regcomp (&re, pattern,
@@ -1496,9 +1372,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 17 unmodified lines
14961372
14971373 printd ("clear");
14981374 ret = sscanf (p + 8, " %d %d %d", &w, &h, &fitmodel);
1499− if (ret != 3) {
1375+ if (ret != 3)
15001376 errx (1, "malformed geometry `%.*s' ret=%d", len, p, ret);
1501− }
15021377
15031378 lock ("geometry");
15041379 state.h = h;
@@ -1525,14 +1400,12 @@ static void * mainloop (void UNUSED_ATTR *unused) · 20 unmodified lines
15251400 printd ("clear");
15261401 ret = sscanf (p + 9, " %d %d %d %n",
15271402 &rotate, &fitmodel, &h, &off);
1528− if (ret != 3) {
1403+ if (ret != 3)
15291404 errx (1, "bad reqlayout line `%.*s' ret=%d", len, p, ret);
1530− }
15311405 lock ("reqlayout");
15321406 pdf = pdf_specifics (state.ctx, state.doc);
1533− if (state.rotate != rotate || state.fitmodel != fitmodel) {
1407+ if (state.rotate != rotate || state.fitmodel != fitmodel)
15341408 state.gen += 1;
1535− }
15361409 state.rotate = rotate;
15371410 state.fitmodel = fitmodel;
15381411 state.h = h;
@@ -1560,9 +1433,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 21 unmodified lines
15601433 int pageno, pindex;
15611434
15621435 ret = sscanf (p + 4, " %d %d", &pageno, &pindex);
1563− if (ret != 2) {
1436+ if (ret != 2)
15641437 errx (1, "bad page line `%.*s' ret=%d", len, p, ret);
1565− }
15661438
15671439 lock ("page");
15681440 a = now ();
@@ -1582,9 +1454,7 @@ static void * mainloop (void UNUSED_ATTR *unused) · 13 unmodified lines
15821454 ret = sscanf (p + 4, " %" SCNxPTR " %d %d %d %d %" SCNxPTR,
15831455 (uintptr_t *) &page, &x, &y, &w, &h,
15841456 (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);
15881458
15891459 lock ("tile");
15901460 a = now ();
@@ -1603,9 +1473,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 12 unmodified lines
16031473
16041474 ret = sscanf (p + 7, " %d %d %d %d %d",
16051475 &trimmargins, &fuzz.x0, &fuzz.y0, &fuzz.x1, &fuzz.y1);
1606− if (ret != 5) {
1476+ if (ret != 5)
16071477 errx (1, "malformed trimset `%.*s' ret=%d", len, p, ret);
1608− }
16091478 lock ("trimset");
16101479 state.trimmargins = trimmargins;
16111480 if (memcmp (&fuzz, &state.trimfuzz, sizeof (fuzz))) {
@@ -1620,9 +1489,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 8 unmodified lines
16201489
16211490 ret = sscanf (p + 7, " %d %d %d %d %d",
16221491 &trimmargins, &fuzz.x0, &fuzz.y0, &fuzz.x1, &fuzz.y1);
1623− if (ret != 5) {
1492+ if (ret != 5)
16241493 errx (1, "malformed settrim `%.*s' ret=%d", len, p, ret);
1625− }
16261494 printd ("clear");
16271495 lock ("settrim");
16281496 state.trimmargins = trimmargins;
@@ -1644,9 +1512,8 @@ static void * mainloop (void UNUSED_ATTR *unused) · 15 unmodified lines
16441512 int h;
16451513
16461514 ret = sscanf (p + 6, " %d", &h);
1647− if (ret != 1) {
1515+ if (ret != 1)
16481516 errx (1, "malformed sliceh `%.*s' ret=%d", len, p, ret);
1649− }
16501517 if (h != state.sliceheight) {
16511518 state.sliceheight = h;
16521519 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
17291596 int seen = 0;
17301597 unsigned char selcolor[] = {15,15,15,140};
17311598
1732− if (!page->fmark || !page->lmark) {
1733− return;
1734− }
1599+ if (!page->fmark || !page->lmark) return;
17351600
17361601 glEnable (GL_BLEND);
17371602 glBlendFunc (GL_SRC_ALPHA, GL_SRC_ALPHA);
@@ -1743,22 +1608,16 @@ static void showsel (struct page *page, int ox, int oy) · 5 unmodified lines
17431608 for (block = page->text->first_block; block; block = block->next) {
17441609 fz_stext_line *line;
17451610
1746− if (block->type != FZ_STEXT_BLOCK_TEXT) {
1747− continue;
1748− }
1611+ if (block->type != FZ_STEXT_BLOCK_TEXT) continue;
17491612 for (line = block->u.t.first_line; line; line = line->next) {
17501613 fz_stext_char *ch;
17511614
17521615 rect = fz_empty_rect;
17531616 for (ch = line->first_char; ch; ch = ch->next) {
17541617 fz_rect r;
1755− if (ch == page->fmark) {
1756− seen = 1;
1757− }
1618+ if (ch == page->fmark) seen = 1;
17581619 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);
17621621 if (ch == page->lmark) {
17631622 bbox = fz_round_rect (rect);
17641623 recti (bbox.x0 + ox, bbox.y0 + oy,
@@ -1882,12 +1741,8 @@ static void highlightlinks (struct page *page, int xoff, int yoff) · 117 unmodified lines
18821741 p4.y = link->rect.y1;
18831742
18841743 /* 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);
18911746
18921747 stipplerect (ctm, p1, p2, p3, p4, texcoords, vertices);
18931748 }
@@ -1920,9 +1775,7 @@ static int compareslinks (const void *l, const void *r) · 26 unmodified lines
19201775 {
19211776 struct slink const *ls = l;
19221777 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;
19261779 return ls->bbox.y0 - rs->bbox.y0;
19271780 }
19281781
@@ -1954,18 +1807,14 @@ static void ensureannots (struct page *page) · 25 unmodified lines
19541807 pdf_page *pdfpage;
19551808
19561809 pdf = pdf_specifics (state.ctx, state.doc);
1957− if (!pdf) {
1958− return;
1959− }
1810+ if (!pdf) return;
19601811
19611812 pdfpage = pdf_page_from_fz_page (state.ctx, page->fzpage);
19621813 if (state.gen != page->agen) {
19631814 dropannots (page);
19641815 page->agen = state.gen;
19651816 }
1966− if (page->annots) {
1967− return;
1968− }
1817+ if (page->annots) return;
19691818
19701819 for (annot = pdf_first_annot (state.ctx, pdfpage);
19711820 annot;
@@ -1976,9 +1825,7 @@ static void ensureannots (struct page *page) · 4 unmodified lines
19761825 if (count > 0) {
19771826 page->annotcount = count;
19781827 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);
19821829
19831830 for (annot = pdf_first_annot (state.ctx, pdfpage), i = 0;
19841831 annot;
@@ -2017,9 +1864,7 @@ static void ensureslinks (struct page *page) · 32 unmodified lines
20171864 dropslinks (page);
20181865 page->sgen = state.gen;
20191866 }
2020− if (page->slinks) {
2021− return;
2022− }
1867+ if (page->slinks) return;
20231868
20241869 ensurelinks (page);
20251870 ctm = pagectm (page);
@@ -2033,9 +1878,7 @@ static void ensureslinks (struct page *page) · 7 unmodified lines
20331878
20341879 page->slinkcount = count;
20351880 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);
20391882
20401883 for (i = 0, link = page->links; link; ++i, link = link->next) {
20411884 fz_rect rect;
@@ -2112,24 +1955,17 @@ static void uploadslice (struct tile *tile, struct slice *slice) · 70 unmodified lines
21121955 offset += slice1->h * tile->w * tile->pixmap->n;
21131956 }
21141957 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)
21161959 glBindTexture (TEXT_TYPE, state.tex.ids[slice->texindex]);
2117− }
21181960 else {
21191961 int subimage = 0;
21201962 int texindex = state.tex.index++ % state.tex.count;
21211963
21221964 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;
21321967 }
1968+ else state.tex.owners[texindex].h = slice->h;
21331969
21341970 state.tex.owners[texindex].w = tile->w;
21351971 state.tex.owners[texindex].slice = slice;
@@ -2146,21 +1982,17 @@ static void uploadslice (struct tile *tile, struct slice *slice) · 10 unmodified lines
21461982 state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, tile->pbo->id);
21471983 texdata = 0;
21481984 }
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+ );
21641996 else {
21651997 glTexImage2D (TEXT_TYPE,
21661998 0,
@@ -2173,9 +2005,7 @@ static void uploadslice (struct tile *tile, struct slice *slice) · 6 unmodified lines
21732005 texdata+offset
21742006 );
21752007 }
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);
21792009 }
21802010 }
21812011
@@ -2304,17 +2134,13 @@ ML (postprocess (value ptr_v, value hlinks_v, · 122 unmodified lines
23042134 }
23052135
23062136 ensureannots (page);
2307− if (hlmask & 1) {
2308− highlightlinks (page, xoff, yoff);
2309− }
2137+ if (hlmask & 1) highlightlinks (page, xoff, yoff);
23102138 if (hlmask & 2) {
23112139 highlightslinks (page, xoff, yoff, noff, targ, STTI (tlen),
23122140 chars, STTI (clen), hfsize);
23132141 noff = page->slinkcount;
23142142 }
2315− if (page->tgen == state.gen) {
2316− showsel (page, xoff, yoff);
2317− }
2143+ if (page->tgen == state.gen) showsel (page, xoff, yoff);
23182144 unlock (__func__);
23192145
23202146 done:
@@ -2339,17 +2165,13 @@ static struct annot *getannot (struct page *page, int x, int y) · 18 unmodified lines
23392165 const fz_matrix *tctm;
23402166 pdf_document *pdf = pdf_specifics (state.ctx, state.doc);
23412167
2342− if (!page->annots) {
2343− return NULL;
2344− }
2168+ if (!page->annots) return NULL;
23452169
23462170 if (pdf) {
23472171 trimctm (pdf_page_from_fz_page (state.ctx, page->fzpage), page->pdimno);
23482172 tctm = &state.pagedims[page->pdimno].tctm;
23492173 }
2350− else {
2351− tctm = &fz_identity;
2352− }
2174+ else tctm = &fz_identity;
23532175
23542176 p.x = x;
23552177 p.y = y;
@@ -2435,9 +2257,7 @@ ML (find_page_with_links (value start_page_v, value dir_v)) · 79 unmodified lines
24352257 fz_catch (state.ctx) {
24362258 found = 0;
24372259 }
2438− if (page) {
2439− fz_drop_page (state.ctx, &page->super);
2440− }
2260+ if (page) fz_drop_page (state.ctx, &page->super);
24412261 }
24422262 else {
24432263 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
25632383 break;
25642384
25652385 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);
25692387 break;
25702388 }
25712389 }
@@ -2694,9 +2512,7 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 122 unmodified lines
26942512 struct pagedim *pdim;
26952513
26962514 ret_v = Val_int (0);
2697− if (trylock (__func__)) {
2698− goto done;
2699− }
2515+ if (trylock (__func__)) goto done;
27002516
27012517 page = parse_pointer (__func__, ptr);
27022518 pdim = &state.pagedims[page->pdimno];
@@ -2740,19 +2556,13 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 37 unmodified lines
27402556 for (block = page->text->first_block; block; block = block->next) {
27412557 fz_stext_line *line;
27422558
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;
27492561
27502562 for (line = block->u.t.first_line; line; line = line->next) {
27512563 fz_stext_char *ch;
27522564
2753− if (!fz_is_point_inside_rect (p, line->bbox)) {
2754− continue;
2755− }
2565+ if (!fz_is_point_inside_rect (p, line->bbox)) continue;
27562566
27572567 for (ch = line->first_char; ch; ch = ch->next) {
27582568 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
27602570 FT_FaceRec *face = fz_font_ft_face (state.ctx,
27612571 ch->font);
27622572
2763− if (!n2) {
2764− n2 = "<unknown font>";
2765− }
2573+ if (!n2) n2 = "<unknown font>";
27662574
27672575 if (face && face->family_name) {
27682576 char *s;
@@ -2781,9 +2589,7 @@ ML (whatsunder (value ptr_v, value x_v, value y_v)) · 12 unmodified lines
27812589 }
27822590 }
27832591 }
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);
27872593 ret_v = caml_alloc_small (1, utext);
27882594 Field (ret_v, 0) = str_v;
27892595 goto unlock;
@@ -2836,9 +2642,7 @@ ML (markunder (value ptr_v, value x_v, value y_v, value mark_v)) · 46 unmodified lines
28362642 fz_point p = { .x = Int_val (x_v), .y = Int_val (y_v) };
28372643
28382644 ret_v = Val_bool (0);
2839− if (trylock (__func__)) {
2840− goto done;
2841− }
2645+ if (trylock (__func__)) goto done;
28422646
28432647 page = parse_pointer (__func__, String_val (ptr_v));
28442648 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
28562660 p.y += pdim->bounds.y0;
28572661
28582662 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;
28652665
28662666 if (mark == mark_block) {
28672667 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
28922692 first = NULL;
28932693 }
28942694 else {
2895− if (!first) {
2896− first = ch2;
2897− }
2695+ if (!first) first = ch2;
28982696 }
28992697 }
29002698 for (ch2 = ch; ch2; ch2 = ch2->next) {
2901− if (uninteresting (ch2->c)) {
2902− break;
2903− }
2699+ if (uninteresting (ch2->c)) break;
29042700 last = ch2;
29052701 }
29062702
@@ -2934,9 +2730,7 @@ ML (rectofblock (value ptr_v, value x_v, value y_v)) · 27 unmodified lines
29342730 fz_point p = { .x = Int_val (x_v), .y = Int_val (y_v) };
29352731
29362732 ret_v = Val_int (0);
2937− if (trylock (__func__)) {
2938− goto done;
2939− }
2733+ if (trylock (__func__)) goto done;
29402734
29412735 page = parse_pointer (__func__, String_val (ptr_v));
29422736 pdim = &state.pagedims[page->pdimno];
@@ -2959,8 +2753,7 @@ ML (rectofblock (value ptr_v, value x_v, value y_v)) · 16 unmodified lines
29592753 continue;
29602754 }
29612755
2962− if (fz_is_point_inside_rect (p, *b))
2963− break;
2756+ if (fz_is_point_inside_rect (p, *b)) break;
29642757 b = NULL;
29652758 }
29662759 if (b) {
@@ -2989,9 +2782,7 @@ ML0 (seltext (value ptr_v, value rect_v)) · 22 unmodified lines
29892782 fz_stext_block *block;
29902783 fz_stext_char *fc, *lc;
29912784
2992− if (trylock (__func__)) {
2993− goto done;
2994− }
2785+ if (trylock (__func__)) goto done;
29952786
29962787 page = parse_pointer (__func__, String_val (ptr_v));
29972788 ensuretext (page);
@@ -3014,18 +2805,13 @@ ML0 (seltext (value ptr_v, value rect_v)) · 16 unmodified lines
30142805 lc = page->lmark;
30152806
30162807 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+
30202810 for (line = block->u.t.first_line; line; line = line->next) {
30212811 for (ch = line->first_char; ch; ch = ch->next) {
30222812 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;
30292815 }
30302816 }
30312817 }
@@ -3075,9 +2861,8 @@ ML (spawn (value command_v, value fds_v)) · 43 unmodified lines
30752861 char *argv[] = { "/bin/sh", "-c", NULL, NULL };
30762862
30772863 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)
30792865 unix_error (ret, "posix_spawn_file_actions_init", Nothing);
3080− }
30812866
30822867 if ((ret = posix_spawnattr_init (&attr)) != 0) {
30832868 msg = "posix_spawnattr_init";
@@ -3164,9 +2949,7 @@ ML0 (copysel (value fd_v, value ptr_v)) · 80 unmodified lines
31642949 fz_stext_block *block;
31652950 int fd = Int_val (fd_v);
31662951
3167− if (trylock (__func__)) {
3168− goto done;
3169− }
2952+ if (trylock (__func__)) goto done;
31702953
31712954 page = parse_pointer (__func__, String_val (ptr_v));
31722955
@@ -3183,26 +2966,21 @@ ML0 (copysel (value fd_v, value ptr_v)) · 10 unmodified lines
31832966 }
31842967
31852968 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+
31892971 for (line = block->u.t.first_line; line; line = line->next) {
31902972 fz_stext_char *ch;
31912973 for (ch = line->first_char; ch; ch = ch->next) {
31922974 if (seen || ch == page->fmark) {
31932975 do {
31942976 pipechar (f, ch);
3195− if (ch == page->lmark) {
3196− goto close;
3197− }
2977+ if (ch == page->lmark) goto close;
31982978 } while ((ch = ch->next));
31992979 seen = 1;
32002980 break;
32012981 }
32022982 }
3203− if (seen) {
3204− fputc ('\n', f);
3205− }
2983+ if (seen) fputc ('\n', f);
32062984 }
32072985 }
32082986 close:
@@ -3210,10 +2988,9 @@ close: · 1 unmodified line
32102988 int ret = fclose (f);
32112989 fd = -1;
32122990 if (ret == -1) {
3213− if (errno != ECHILD) {
2991+ if (errno != ECHILD)
32142992 printd ("emsg failed to close sel pipe: %d:%s",
32152993 errno, strerror (errno));
3216− }
32172994 }
32182995 }
32192996 unlock:
@@ -3221,10 +2998,9 @@ unlock: · 1 unmodified line
32212998
32222999 done:
32233000 if (fd >= 0) {
3224− if (close (fd)) {
3001+ if (close (fd))
32253002 printd ("emsg failed to close sel pipe: %d:%s",
32263003 errno, strerror (errno));
3227− }
32283004 }
32293005 CAMLreturn0;
32303006 }
@@ -3237,9 +3013,7 @@ ML (getpdimrect (value pagedimno_v)) · 6 unmodified lines
32373013 fz_rect box;
32383014
32393015 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;
32433017 else {
32443018 box = state.pagedims[pagedimno].mediabox;
32453019 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
32673041 float cols = Int_val (cols_v);
32683042 float pw = 1.0, ph = 1.0;
32693043
3270− if (trylock (__func__)) {
3271− goto done;
3272− }
3044+ if (trylock (__func__)) goto done;
32733045
32743046 for (i = 0, p = state.pagedims; i < state.pagedimcount; ++i, ++p) {
32753047 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
32773049 if (h > maxh) {
32783050 maxh = h;
32793051 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;
32863053 }
3054+ if ((state.fitmodel == FitProportional) && w > pw) pw = w;
32873055 }
32883056
32893057 zoom = (((winh / ph) * pw) + dw) / winw;
@@ -3301,9 +3069,7 @@ ML (getmaxw (value unit_v)) · 11 unmodified lines
33013069 float maxw = -1.;
33023070 struct pagedim *p;
33033071
3304− if (trylock (__func__)) {
3305− goto done;
3306− }
3072+ if (trylock (__func__)) goto done;
33073073
33083074 for (i = 0, p = state.pagedims; i < state.pagedimcount; ++i, ++p) {
33093075 float w = p->pagebox.x1;
@@ -3437,9 +3203,7 @@ ML (platform (value unit_v)) · 127 unmodified lines
34373203 #elif defined __APPLE__
34383204 platid = pimacos;
34393205 #endif
3440− if (uname (&buf)) {
3441− err (1, "uname");
3442− }
3206+ if (uname (&buf)) err (1, "uname");
34433207
34443208 tup_v = caml_alloc_tuple (2);
34453209 {
@@ -3462,9 +3226,7 @@ ML0 (cloexec (value fd_v)) · 16 unmodified lines
34623226 CAMLparam1 (fd_v);
34633227 int fd = Int_val (fd_v);
34643228
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);
34683230 CAMLreturn0;
34693231 }
34703232
@@ -3479,9 +3241,7 @@ ML (getpbo (value w_v, value h_v, value cs_v)) · 8 unmodified lines
34793241
34803242 if (state.bo_usable) {
34813243 pbo = calloc (sizeof (*pbo), 1);
3482− if (!pbo) {
3483− err (1, "calloc pbo");
3484− }
3244+ if (!pbo) err (1, "calloc pbo");
34853245
34863246 switch (cs) {
34873247 case 0:
@@ -3513,24 +3273,18 @@ ML (getpbo (value w_v, value h_v, value cs_v)) · 25 unmodified lines
35133273 char *s;
35143274
35153275 res = snprintf (NULL, 0, "%" PRIxPTR, (uintptr_t) pbo);
3516− if (res < 0) {
3276+ if (res < 0)
35173277 err (1, "snprintf %" PRIxPTR " failed", (uintptr_t) pbo);
3518− }
35193278 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);
35233280 res = sprintf (s, "%" PRIxPTR, (uintptr_t) pbo);
3524− if (res < 0) {
3281+ if (res < 0)
35253282 err (1, "sprintf %" PRIxPTR " failed", (uintptr_t) pbo);
3526− }
35273283 ret_v = caml_copy_string (s);
35283284 free (s);
35293285 }
35303286 }
3531− else {
3532− ret_v = caml_copy_string ("0");
3533− }
3287+ else ret_v = caml_copy_string ("0");
35343288 CAMLreturn (ret_v);
35353289 }
35363290
@@ -3555,9 +3309,8 @@ ML0 (unmappbo (value ptr_v)) · 18 unmodified lines
35553309
35563310 if (tile->pbo) {
35573311 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)
35593313 errx (1, "glUnmapBufferARB failed: %#x\n", glGetError ());
3560− }
35613314 tile->pbo->ptr = NULL;
35623315 state.glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_ARB, 0);
35633316 }
@@ -3600,9 +3353,7 @@ ML (unproject (value ptr_v, value x_v, value y_v)) · 36 unmodified lines
36003353 pdim = &state.pagedims[page->pdimno];
36013354
36023355 ret_v = Val_int (0);
3603− if (trylock (__func__)) {
3604− goto done;
3605− }
3356+ if (trylock (__func__)) goto done;
36063357
36073358 p.x = x + pdim->bounds.x0;
36083359 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
36373388 ret_v = Val_int (0);
36383389 lock (__func__);
36393390
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));
36463393 pdim = &state.pagedims[pdimno];
36473394
36483395 if (pdf_specifics (state.ctx, state.doc)) {
36493396 trimctm (pdf_page_from_fz_page (state.ctx, page->fzpage), page->pdimno);
36503397 ctm = state.pagedims[page->pdimno].tctm;
36513398 }
3652− else {
3653− ctm = fz_identity;
3654− }
3399+ else ctm = fz_identity;
3400+
36553401 p.x = x + pdim->bounds.x0;
36563402 p.y = y + pdim->bounds.y0;
36573403
@@ -3662,9 +3408,7 @@ ML (project (value ptr_v, value pageno_v, value pdimno_v, value x_v, value y_v)) · 4 unmodified lines
36623408 Field (ret_v, 0) = caml_copy_double ((double) p.x);
36633409 Field (ret_v, 1) = caml_copy_double ((double) p.y);
36643410
3665− if (!*s) {
3666− freepage (page);
3667− }
3411+ if (!*s) freepage (page);
36683412 unlock (__func__);
36693413 CAMLreturn (ret_v);
36703414 }
@@ -3743,9 +3487,7 @@ ML0 (savedoc (value path_v)) · 72 unmodified lines
37433487 CAMLparam1 (path_v);
37443488 pdf_document *pdf = pdf_specifics (state.ctx, state.doc);
37453489
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);
37493491 CAMLreturn0;
37503492 }
37513493
@@ -3793,9 +3535,8 @@ static fz_font *lsff (fz_context *ctx,int UNUSED_ATTR script, · 41 unmodified lines
37933535
37943536 if (!done) {
37953537 char *path = getenv ("LLPP_FALLBACK_FONT");
3796− if (path) {
3538+ if (path)
37973539 font = fz_new_font_from_file (ctx, NULL, path, 0, 1);
3798− }
37993540 done = 1;
38003541 }
38013542 return font;
@@ -3809,9 +3550,7 @@ ML0 (setdcf (value path_v)) · 7 unmodified lines
38093550 size_t len = caml_string_length (path_v);
38103551 if (*p) {
38113552 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);
38153554 memcpy (state.dcf, p, len);
38163555 state.dcf[len] = 0;
38173556 }
@@ -3824,14 +3563,10 @@ ML (init (value csock_v, value params_v)) · 6 unmodified lines
38243563 int ret, texcount, colorspace, mustoresize;
38253564 const char *fontpath;
38263565
3827− if (pipe (state.pfds)) {
3828− err (1, "pipe");
3829− }
3566+ if (pipe (state.pfds)) err (1, "pipe");
38303567 for (int ntries = 0; ntries < 1737; ++ntries) {
38313568 if (-1 == dup2 (state.pfds[1], 2)) {
3832− if (EINTR == errno) {
3833− continue;
3834− }
3569+ if (EINTR == errno) continue;
38353570 err (1, "dup2");
38363571 }
38373572 break;
@@ -3855,9 +3590,7 @@ ML (init (value csock_v, value params_v)) · 17 unmodified lines
38553590 const char *cset = nl_langinfo (CODESET);
38563591 state.utf8cs = !strcmp (cset, "UTF-8");
38573592 }
3858− else {
3859− printd ("emsg setlocale: %d:%s", errno, strerror (errno));
3860− }
3593+ else printd ("emsg setlocale: %d:%s", errno, strerror (errno));
38613594 #endif
38623595
38633596 state.ctx = fz_new_context (NULL, NULL, mustoresize);
@@ -3875,9 +3608,7 @@ ML (init (value csock_v, value params_v)) · 11 unmodified lines
38753608
38763609 set_tex_params (colorspace);
38773610
3878− if (*fontpath) {
3879− state.face = load_font (fontpath);
3880− }
3611+ if (*fontpath) state.face = load_font (fontpath);
38813612 else {
38823613 int len;
38833614 const unsigned char *data;
@@ -3885,18 +3616,14 @@ ML (init (value csock_v, value params_v)) · 1 unmodified line
38853616 data = pdf_lookup_substitute_font (state.ctx, 0, 0, 0, 0, &len);
38863617 state.face = load_builtin_font (data, len);
38873618 }
3888− if (!state.face) {
3889− _exit (1);
3890− }
3619+ if (!state.face) _exit (1);
38913620
38923621 realloctexts (texcount);
38933622 setuppbo ();
38943623 makestippletex ();
38953624
38963625 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));
39003627
39013628 CAMLreturn (Val_int (state.pfds[0]));
39023629 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t