rearrange i_new_hatch_low() in fills.c
authorTony Cook <tony@develop-help.com>
Sat, 2 Feb 2019 01:32:07 +0000 (12:32 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 2 Feb 2019 01:32:07 +0000 (12:32 +1100)
The code used to be a bunch of conditional expressions, which some
Sun C compiler complained about.

Rearrange the code to be a lot more obvious.

Related to CID 185339.

fills.c

diff --git a/fills.c b/fills.c
index 4754e26..b230580 100644 (file)
--- a/fills.c
+++ b/fills.c
@@ -647,25 +647,23 @@ i_new_hatch_low(const i_color *fg, const i_color *bg,
   i_fill_hatch_t *fill = mymalloc(sizeof(i_fill_hatch_t)); /* checked 14jul05 tonyc */
 
   *fill = hatch_fill_proto;
-  /* Some Sun C didn't like the condition expressions that were here.
-     See https://rt.cpan.org/Ticket/Display.html?id=21944
-   */
-  if (fg)
+  if (fg && bg) {
     fill->fg = *fg;
-  else
-    fill->fg = fcolor_to_color(ffg);
-  if (bg)
     fill->bg = *bg;
-  else
+    fill->ffg = color_to_fcolor(fg);
+    fill->fbg = color_to_fcolor(bg);
+  }
+  else if (ffg && fbg) {
+    fill->fg = fcolor_to_color(ffg);
     fill->bg = fcolor_to_color(fbg);
-  if (ffg) 
     fill->ffg = *ffg;
-  else
-    fill->ffg = color_to_fcolor(fg);
-  if (fbg)
     fill->fbg = *fbg;
-  else
-    fill->fbg = color_to_fcolor(bg);
+  }
+  else {
+    assert(0);
+    /* NOTREACHED */
+  }
+  
   if (combine) {
     i_get_combine(combine, &fill->base.combine, &fill->base.combinef);
   }