summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2020-12-02 00:48:45 +0000
committerRobin Watts <Robin.Watts@artifex.com>2020-12-02 01:06:51 +0000
commited946acb20ec03426d35b0d9341c551e7e459184 (patch)
treefdb8042abd81ca2cc573e06407fd18089828d893
parent4633ebbca0c9690003aebc9f4661c232c61cecdd (diff)
downloadghostpdl-ed946acb20ec03426d35b0d9341c551e7e459184.tar.gz
LGTM: Reduce goto use in zsort_continue.
-rw-r--r--psi/zalg.c78
1 files changed, 37 insertions, 41 deletions
diff --git a/psi/zalg.c b/psi/zalg.c
index 88e8e4081..49cbdf520 100644
--- a/psi/zalg.c
+++ b/psi/zalg.c
@@ -124,58 +124,54 @@ zsort_continue(i_ctx_t *i_ctx_p)
status = esp - 8;
Rn = arry.value.refs - 1; /* the -1 compensates for using 1-based indices */
switch (H) {
- case 2:
-H2: if (l > 1) {
- l--;
- ref_assign(&R, &Rn[l]);
- } else {
- ref_assign(&R, &Rn[r]);
- ref_assign_old(&arry, &Rn[r], &Rn[1], ".sort(H2-a)");
- r--;
- if (r <= 1) {
- ref_assign_old(&arry, &Rn[1], &R, ".sort(H2-b)");
- esp -= 9;
- pop(1);
- return o_pop_estack;
- }
+ case 6:
+ /*H6_cont:*/if (!r_has_type(&op[0], t_boolean)) {
+ esp -= 9;
+ return_error(gs_error_typecheck);
}
-/* H3: */ j = l;
-H4: i = j;
- j <<= 1;
- if (j >= r)
- if (j == r)
- goto H6;
- else
- goto H8;
- else {
-/* H5: */ H = 5;
- push(1);
- ref_assign(&op[-1], &Rn[j]);
- ref_assign(&op[0], &Rn[j + 1]);
- break;
+ if (op[0].value.boolval) {
+/* H7: */ ref_assign_old(&arry, &Rn[i], &Rn[j], ".sort(H7)");
+ goto H4;
}
+ do {
+/* H8: */ ref_assign_old(&arry, &Rn[i], &R, ".sort(H8)");
+ /* fallthrough */
+ case 2:
+/* H2: */ if (l > 1) {
+ l--;
+ ref_assign(&R, &Rn[l]);
+ } else {
+ ref_assign(&R, &Rn[r]);
+ ref_assign_old(&arry, &Rn[r], &Rn[1], ".sort(H2-a)");
+ r--;
+ if (r <= 1) {
+ ref_assign_old(&arry, &Rn[1], &R, ".sort(H2-b)");
+ esp -= 9;
+ pop(1);
+ return o_pop_estack;
+ }
+ }
+/* H3: */ j = l;
+H4: i = j;
+ j <<= 1;
+ } while (j > r);
+ if (j == r)
+ goto H6;
+/* H5: */ H = 5;
+ push(1);
+ ref_assign(&op[-1], &Rn[j]);
+ ref_assign(&op[0], &Rn[j + 1]);
+ break;
case 5:
/*H5_cont:*/if (!r_has_type(&op[0], t_boolean))
return_error(gs_error_typecheck);
if (op[0].value.boolval)
j++;
-H6: H = 6;
+H6: H = 6;
push(1);
ref_assign(&op[-1], &R);
ref_assign(&op[0], &Rn[j]);
break;
- case 6:
- /*H6_cont:*/if (!r_has_type(&op[0], t_boolean)) {
- esp -= 9;
- return_error(gs_error_typecheck);
- }
- if (op[0].value.boolval) {
-/* H7: */ ref_assign_old(&arry, &Rn[i], &Rn[j], ".sort(H7)");
- goto H4;
- } else {
-H8: ref_assign_old(&arry, &Rn[i], &R, ".sort(H8)");
- goto H2;
- }
default:
pop(1);
esp -= 9;