From 3896f2877313b79bcdaa6b38e8d6d681f2c6a4e4 Mon Sep 17 00:00:00 2001
From: Humdinger <humdingerb@gmail.com>
Date: Fri, 20 Jan 2017 19:56:14 +0100
Subject: undef PAGESIZE on HAIKU

Update patch by Jerome Duval to new release.

diff --git a/src/testpattern/testpattern.c b/src/testpattern/testpattern.c
index 2474d69..3a6f00d 100644
--- a/src/testpattern/testpattern.c
+++ b/src/testpattern/testpattern.c
@@ -36,6 +36,9 @@
 #include <stdio.h>
 #include <math.h>
 #include <string.h>
+#ifdef __HAIKU__
+#undef PAGESIZE
+#endif
 #include "testpattern.h"
 #include <gutenprint/gutenprint-intl.h>
 #include <errno.h>
diff --git a/src/testpattern/testpatternl.c b/src/testpattern/testpatternl.c
index 048a31b..7c85598 100644
--- a/src/testpattern/testpatternl.c
+++ b/src/testpattern/testpatternl.c
@@ -20,6 +20,9 @@
 #include <string.h>
 #include <errno.h>
 #include <stdlib.h>
+#ifdef __HAIKU__
+#undef PAGESIZE
+#endif
 
 /* end standard C headers. */
 
diff --git a/src/testpattern/testpatternl.l b/src/testpattern/testpatternl.l
index 31d6197..27d0998 100644
--- a/src/testpattern/testpatternl.l
+++ b/src/testpattern/testpatternl.l
@@ -27,6 +27,9 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef __HAIKU__
+#undef PAGESIZE
+#endif
 #include "testpattern.h"
 
 #pragma GCC diagnostic ignored "-Wredundant-decls"
diff --git a/src/testpattern/testpatterny.c b/src/testpattern/testpatterny.c
index 2344ffb..7c0c08b 100644
--- a/src/testpattern/testpatterny.c
+++ b/src/testpattern/testpatterny.c
@@ -73,6 +73,9 @@
 #include <strings.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef __HAIKU__
+#undef PAGESIZE
+#endif
 #include "testpattern.h"
 
 extern int mylineno;
diff --git a/src/testpattern/testpatterny.y b/src/testpattern/testpatterny.y
index 4678949..d2ab025 100644
--- a/src/testpattern/testpatterny.y
+++ b/src/testpattern/testpatterny.y
@@ -28,6 +28,9 @@
 #include <strings.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef __HAIKU__
+#undef PAGESIZE
+#endif
 #include "testpattern.h"
 
 extern int mylineno;
-- 
2.30.2


From 7cf3fc9a3aeb3e2c9e2950e13f0df1558529d5be Mon Sep 17 00:00:00 2001
From: Humdinger <humdingerb@gmail.com>
Date: Fri, 20 Jan 2017 19:58:12 +0100
Subject: strings.h fixes

Update patch by Jerome Duval to new release.

diff --git a/src/main/curve.c b/src/main/curve.c
index 2aeb15e..83efd76 100644
--- a/src/main/curve.c
+++ b/src/main/curve.c
@@ -30,6 +30,7 @@
 #include <ieeefp.h>
 #endif
 #include <string.h>
+#include <strings.h>
 #include <stdlib.h>
 #include <limits.h>
 #include <unistd.h>
diff --git a/src/main/escp2-papers.c b/src/main/escp2-papers.c
index 19d1b98..3580842 100644
--- a/src/main/escp2-papers.c
+++ b/src/main/escp2-papers.c
@@ -22,6 +22,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include <strings.h>
 #include <gutenprint/gutenprint.h>
 #include "gutenprint-internal.h"
 #include <gutenprint/gutenprint-intl-internal.h>
diff --git a/src/main/print-ps.c b/src/main/print-ps.c
index 751424d..2838983 100644
--- a/src/main/print-ps.c
+++ b/src/main/print-ps.c
@@ -32,6 +32,7 @@
 #include "gutenprint-internal.h"
 #include <time.h>
 #include <string.h>
+#include <strings.h>
 #include <math.h>
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
-- 
2.30.2


From 0a0eaed03dc51f3552d1f38f4db65055721c4d02 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 1 Apr 2017 15:24:54 +0200
Subject: Make gcc2 happy.


diff --git a/src/main/print-canon.c b/src/main/print-canon.c
index 6ba401a..51fc7ab 100644
--- a/src/main/print-canon.c
+++ b/src/main/print-canon.c
@@ -3832,7 +3832,6 @@ canon_init_setPageMargins2(const stp_vars_t *v, canon_privdata_t *init)
      rather than calculated.
   */
   unsigned char arg_ESCP_1 = (init->pt) ? canon_size_type(v,init->caps) : 0x03; /* default size A4 */
-  stp_dprintf(STP_DBG_CANON, v,"setPageMargins2: arg_ESCP_1 = '%x'\n",arg_ESCP_1);
 
   /* TOFIX: what exactly is to be sent?
    * Is it the printable length or the bottom border?
@@ -3846,6 +3845,7 @@ canon_init_setPageMargins2(const stp_vars_t *v, canon_privdata_t *init)
   const char* input_slot = stp_get_string_parameter(v, "InputSlot");
   int print_cd = (input_slot && (!strcmp(input_slot, "CD")));
 
+  stp_dprintf(STP_DBG_CANON, v,"setPageMargins2: arg_ESCP_1 = '%x'\n",arg_ESCP_1);
   stp_dprintf(STP_DBG_CANON, v,"setPageMargins2: print_cd = %d\n",print_cd);
 
   test_cd = 1;
-- 
2.30.2


From f0a3d8af46c568e225f1f2b162a928c4844769e7 Mon Sep 17 00:00:00 2001
From: Schrijvers Luc <Begasus@users.noreply.github.com>
Date: Mon, 21 May 2018 07:42:56 +0200
Subject: Make gcc2 happy, suite.


diff --git a/src/main/channel.c b/src/main/channel.c
index 6cd4ca9..a19d6a7 100644
--- a/src/main/channel.c
+++ b/src/main/channel.c
@@ -1201,6 +1201,7 @@ stp_channel_get_output_8bit(const stp_vars_t *v)
   if (! cg->output_data_8bit)
     cg->output_data_8bit = stp_malloc(sizeof(unsigned char) *
 				      cg->total_channels * cg->width);
+  {
   int i;
   (void) memset(cg->output_data_8bit, 0, sizeof(unsigned char) *
 		cg->total_channels * cg->width);
@@ -1208,4 +1209,5 @@ stp_channel_get_output_8bit(const stp_vars_t *v)
     cg->output_data_8bit[i] = cg->output_data[i] / (unsigned short) 257;
   cg->valid_8bit = 1;
   return cg->output_data_8bit;
+  }
 }
-- 
2.30.2


From 524794614025b5b57bb959b2e3464b58395c470f Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sun, 14 Apr 2019 20:56:21 +0200
Subject: gcc2 patch for 5.3.1


diff --git a/src/main/color-conversions.c b/src/main/color-conversions.c
index e5a31a8..bc24618 100644
--- a/src/main/color-conversions.c
+++ b/src/main/color-conversions.c
@@ -380,6 +380,9 @@ color_##bits##_to_color(const stp_vars_t *vars, const unsigned char *in, \
   int bright_color_adjustment = 0;					\
   int hue_only_color_adjustment = 0;					\
   int do_user_adjustment = 0;						\
+  const double *hue_map;							\
+  const double *lum_map;							\
+  const double *sat_map;							\
   if (lut->color_correction->correction == COLOR_CORRECTION_BRIGHT)	\
     bright_color_adjustment = 1;					\
   if (lut->color_correction->correction == COLOR_CORRECTION_HUE)	\
@@ -408,9 +411,9 @@ color_##bits##_to_color(const stp_vars_t *vars, const unsigned char *in, \
   (void) stp_curve_cache_get_double_data(&(lut->hue_map));		\
   (void) stp_curve_cache_get_double_data(&(lut->lum_map));		\
   (void) stp_curve_cache_get_double_data(&(lut->sat_map));		\
-  const double *hue_map = CURVE_CACHE_FAST_DOUBLE(&(lut->hue_map));	\
-  const double *lum_map = CURVE_CACHE_FAST_DOUBLE(&(lut->lum_map));	\
-  const double *sat_map = CURVE_CACHE_FAST_DOUBLE(&(lut->sat_map));	\
+  hue_map = CURVE_CACHE_FAST_DOUBLE(&(lut->hue_map));	\
+  lum_map = CURVE_CACHE_FAST_DOUBLE(&(lut->lum_map));	\
+  sat_map = CURVE_CACHE_FAST_DOUBLE(&(lut->sat_map));	\
 									\
   if (split_saturation)							\
     ssat = sqrt(ssat);							\
@@ -485,6 +488,9 @@ color_##bits##_to_kcmy(const stp_vars_t *vars, const unsigned char *in,	\
   int bright_color_adjustment = 0;					\
   int hue_only_color_adjustment = 0;					\
   int do_user_adjustment = 0;						\
+  const double *hue_map;							\
+  const double *lum_map;							\
+  const double *sat_map;							\
   if (lut->color_correction->correction == COLOR_CORRECTION_BRIGHT)	\
     bright_color_adjustment = 1;					\
   if (lut->color_correction->correction == COLOR_CORRECTION_HUE)	\
@@ -514,9 +520,9 @@ color_##bits##_to_kcmy(const stp_vars_t *vars, const unsigned char *in,	\
   (void) stp_curve_cache_get_double_data(&(lut->hue_map));		\
   (void) stp_curve_cache_get_double_data(&(lut->lum_map));		\
   (void) stp_curve_cache_get_double_data(&(lut->sat_map));		\
-  const double *hue_map = CURVE_CACHE_FAST_DOUBLE(&(lut->hue_map));	\
-  const double *lum_map = CURVE_CACHE_FAST_DOUBLE(&(lut->lum_map));	\
-  const double *sat_map = CURVE_CACHE_FAST_DOUBLE(&(lut->sat_map));	\
+  hue_map = CURVE_CACHE_FAST_DOUBLE(&(lut->hue_map));	\
+  lum_map = CURVE_CACHE_FAST_DOUBLE(&(lut->lum_map));	\
+  sat_map = CURVE_CACHE_FAST_DOUBLE(&(lut->sat_map));	\
 									\
   if (split_saturation)							\
     ssat = sqrt(ssat);							\
diff --git a/src/main/escp2-channels.c b/src/main/escp2-channels.c
index 9e3b4e7..30b3c5f 100644
--- a/src/main/escp2-channels.c
+++ b/src/main/escp2-channels.c
@@ -408,9 +408,9 @@ load_inkgroup(const char *name)
       stp_mxml_node_t *node =
 	stp_xml_parse_file_from_path_uncached_safe(name, "escp2InkGroup", NULL);
       stp_mxml_node_t *child = node->child;
+      size_t count = 0;
       igl = stp_zalloc(sizeof(inkgroup_t));
       stp_refcache_add_item("escpInkgroup", name, igl);
-      size_t count = 0;
       while (child)
 	{
 	  if (child->type == STP_MXML_ELEMENT &&
diff --git a/src/main/escp2-resolutions.c b/src/main/escp2-resolutions.c
index f099907..33c2547 100644
--- a/src/main/escp2-resolutions.c
+++ b/src/main/escp2-resolutions.c
@@ -178,13 +178,15 @@ int
 stpi_escp2_load_resolutions(const stp_vars_t *v, const char *name,
 			    stp_mxml_node_t *node)
 {
+  static const char *res_cache = "escp2Resolutions";
+  stpi_escp2_printer_t *printdef;
+  resolution_list_t *pr;
+  int found = 0;
   stp_dprintf(STP_DBG_ESCP2_XML, v,
 	      ">>>Loading resolutions from %s (%p)...", name, (void *) node);
-  static const char *res_cache = "escp2Resolutions";
-  stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
-  resolution_list_t *pr =
+  printdef = stpi_escp2_get_printer(v);
+  pr =
     (resolution_list_t *) stp_refcache_find_item(res_cache, name);
-  int found = 0;
   if (pr)
     stp_dprintf(STP_DBG_ESCP2_XML, v, "cached!");
   if(! pr)
@@ -287,11 +289,13 @@ stpi_escp2_load_quality_presets_from_xml(stp_mxml_node_t *node)
 int
 stpi_escp2_load_quality_presets(const stp_vars_t *v, const char *name)
 {
+  static const char *quality_cache = "escp2QualityPresets";
+  stpi_escp2_printer_t *printdef;
+  quality_list_t *qpw;
   stp_dprintf(STP_DBG_ESCP2_XML, v,
 	      ">>>Loading quality presets from %s...", name);
-  static const char *quality_cache = "escp2QualityPresets";
-  stpi_escp2_printer_t *printdef = stpi_escp2_get_printer(v);
-  quality_list_t *qpw =
+  printdef = stpi_escp2_get_printer(v);
+  qpw =
     (quality_list_t *) stp_refcache_find_item(quality_cache, name);
   if (qpw)
     stp_dprintf(STP_DBG_ESCP2_XML, v, "cached!");
diff --git a/src/main/print-dyesub.c b/src/main/print-dyesub.c
index 70fcc39..1b931ae 100644
--- a/src/main/print-dyesub.c
+++ b/src/main/print-dyesub.c
@@ -2811,9 +2811,10 @@ mitsu_p95d_load_parameters(const stp_vars_t *v, const char *name,
 
     if (strcmp(name, "P95Gamma") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p95d_gamma_list;
+      mlist = &mitsu_p95d_gamma_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -2823,9 +2824,10 @@ mitsu_p95d_load_parameters(const stp_vars_t *v, const char *name,
       description->deflt.str = stp_string_list_param(description->bounds.str, 0)->name;
       description->is_active = 1;
     } else if (strcmp(name, "Buzzer") == 0) {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p95d_buzzer_list;
+      mlist = &mitsu_p95d_buzzer_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -2835,9 +2837,10 @@ mitsu_p95d_load_parameters(const stp_vars_t *v, const char *name,
       description->deflt.str = stp_string_list_param(description->bounds.str, 2)->name;
       description->is_active = 1;
     } else if (strcmp(name, "MediaCut") == 0) {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p95d_cutter_list;
+      mlist = &mitsu_p95d_cutter_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -2847,9 +2850,10 @@ mitsu_p95d_load_parameters(const stp_vars_t *v, const char *name,
       description->deflt.str = stp_string_list_param(description->bounds.str, 2)->name;
       description->is_active = 1;
     } else if (strcmp(name, "Comment") == 0) {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p95d_comment_list;
+      mlist = &mitsu_p95d_comment_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -3217,9 +3221,10 @@ mitsu_p93d_load_parameters(const stp_vars_t *v, const char *name,
 
     if (strcmp(name, "P93Gamma") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p93d_gamma_list;
+      mlist = &mitsu_p93d_gamma_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -3229,9 +3234,10 @@ mitsu_p93d_load_parameters(const stp_vars_t *v, const char *name,
       description->deflt.str = stp_string_list_param(description->bounds.str, 0)->name;
       description->is_active = 1;
     } else if (strcmp(name, "Buzzer") == 0) {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p95d_buzzer_list;
+      mlist = &mitsu_p95d_buzzer_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -3244,9 +3250,10 @@ mitsu_p93d_load_parameters(const stp_vars_t *v, const char *name,
       description->deflt.boolean = 0;
       description->is_active = 1;
     } else if (strcmp(name, "Comment") == 0) {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_p95d_comment_list;
+      mlist = &mitsu_p95d_comment_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -3782,9 +3789,10 @@ mitsu9500_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "CP9500Contrast") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu9500_contrast_list;
+      mlist = &mitsu9500_contrast_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -3894,9 +3902,10 @@ mitsu9550_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu9550_quality_list;
+      mlist = &mitsu9550_quality_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -4209,9 +4218,10 @@ mitsu98xx_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu9810_quality_list;
+      mlist = &mitsu9810_quality_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -4492,9 +4502,10 @@ mitsu70x_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu70x_quality_list;
+      mlist = &mitsu70x_quality_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -4543,9 +4554,10 @@ mitsu707_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu70x_quality_list;
+      mlist = &mitsu70x_quality_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -4569,9 +4581,10 @@ mitsu707_load_parameters(const stp_vars_t *v, const char *name,
     }
   else if (strcmp(name, "Deck") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu707_deck_list;
+      mlist = &mitsu707_deck_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -4784,9 +4797,10 @@ mitsu_k60_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_k60_quality_list;
+      mlist = &mitsu_k60_quality_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -4968,9 +4982,10 @@ mitsu_d90_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &mitsu_d90_quality_list;
+      mlist = &mitsu_d90_quality_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -5511,9 +5526,10 @@ shinko_chcs1245_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "DustRemoval") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &shinko_chcs1245_dust_list;
+      mlist = &shinko_chcs1245_dust_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -6863,9 +6879,10 @@ ds820_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "PrintSpeed") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &dnpds820_printspeeds_list;
+      mlist = &dnpds820_printspeeds_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -7314,9 +7331,10 @@ magicard_load_parameters(const stp_vars_t *v, const char *name,
 
   if (strcmp(name, "BlackType") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &magicard_black_types_list;
+      mlist = &magicard_black_types_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -7387,9 +7405,10 @@ magicard_load_parameters(const stp_vars_t *v, const char *name,
     }
   else if (strcmp(name, "Holokote") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &magicard_holokotes_list;
+      mlist = &magicard_holokotes_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -7413,9 +7432,10 @@ magicard_load_parameters(const stp_vars_t *v, const char *name,
     }
   else if (strcmp(name, "OvercoatHole") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &magicard_overcoat_holes_list;
+      mlist = &magicard_overcoat_holes_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -7427,9 +7447,10 @@ magicard_load_parameters(const stp_vars_t *v, const char *name,
     }
   else if (strcmp(name, "OvercoatHoleDuplex") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &magicard_overcoat_holes_list;
+      mlist = &magicard_overcoat_holes_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
@@ -7465,9 +7486,10 @@ magicard_load_parameters(const stp_vars_t *v, const char *name,
     }
   else if (strcmp(name, "MagCoer") == 0)
     {
+      const dyesub_stringlist_t *mlist;
       description->bounds.str = stp_string_list_create();
 
-      const dyesub_stringlist_t *mlist = &magicard_mag_coer_list;
+      mlist = &magicard_mag_coer_list;
       for (i = 0; i < mlist->n_items; i++)
         {
 	  const dyesub_stringitem_t *m = &(mlist->item[i]);
diff --git a/src/main/print-escp2-data.c b/src/main/print-escp2-data.c
index 267855d..5734b8f 100644
--- a/src/main/print-escp2-data.c
+++ b/src/main/print-escp2-data.c
@@ -405,9 +405,10 @@ void
 stpi_escp2_load_model(const stp_vars_t *v, int model)
 {
   char buf[MAXPATHLEN+1];
+  int model_id_from_file;
   stp_xml_init();
   snprintf(buf, MAXPATHLEN, "escp2/model/model_%d.xml", model);
-  int model_id_from_file = load_model_from_file(v, buf, 0);
+  model_id_from_file = load_model_from_file(v, buf, 0);
   stp_xml_exit();
   STPI_ASSERT(model_id_from_file == model, v);
 }
diff --git a/src/main/print-escp2.c b/src/main/print-escp2.c
index 6fe807a..1b1c9b2 100644
--- a/src/main/print-escp2.c
+++ b/src/main/print-escp2.c
@@ -2232,8 +2232,9 @@ escp2_parameters(const stp_vars_t *v, const char *name,
 		 stp_parameter_t *description)
 {
   int		i;
+  int found;
   description->p_type = STP_PARAMETER_TYPE_INVALID;
-  int found = 0;
+  found = 0;
   if (name == NULL)
     return;
 
@@ -4474,6 +4475,7 @@ escp2_do_print(stp_vars_t *v, stp_image_t *image, int print_op)
   int i;
 
   escp2_privdata_t *pd;
+  int page_number;
 
   if (strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") == 0 &&
       (stp_get_string_parameter(v, "InkType") &&
@@ -4500,7 +4502,7 @@ escp2_do_print(stp_vars_t *v, stp_image_t *image, int print_op)
   if (strcmp(stp_get_string_parameter(v, "InputImageType"), "Raw") == 0 &&
       !set_raw_ink_type(v))
     return 0;
-  int page_number = stp_get_int_parameter(v, "PageNumber");
+  page_number = stp_get_int_parameter(v, "PageNumber");
 
   pd = (escp2_privdata_t *) stp_zalloc(sizeof(escp2_privdata_t));
 
diff --git a/src/main/print-papers.c b/src/main/print-papers.c
index c457295..737c023 100644
--- a/src/main/print-papers.c
+++ b/src/main/print-papers.c
@@ -468,6 +468,8 @@ stpi_get_papersize_list_named(const char *name, const char *file)
   else
     {
       char buf[MAXPATHLEN+1];
+      stp_mxml_node_t *node;
+      const char *stmp;
       stp_deprintf(STP_DBG_PAPER, "Loading paper list %s from %s\n",
 		   name, file ? file : "(null)");
       if (! file)
@@ -476,9 +478,9 @@ stpi_get_papersize_list_named(const char *name, const char *file)
 	(void) snprintf(buf, MAXPATHLEN, "papers/%s.xml", name);
       else
 	strncpy(buf, file, MAXPATHLEN);
-      stp_mxml_node_t *node =
+      node =
 	stp_xml_parse_file_from_path_safe(buf, "paperdef", NULL);
-      const char *stmp = stp_mxmlElementGetAttr(node, "name");
+      stmp = stp_mxmlElementGetAttr(node, "name");
       STPI_ASSERT(stmp && !strcmp(name, stmp), NULL);
       impl = stp_malloc(sizeof(papersize_list_impl_t));
       impl->name = stp_strdup(name);
diff --git a/src/main/print-util.c b/src/main/print-util.c
index 1119484..56171b4 100644
--- a/src/main/print-util.c
+++ b/src/main/print-util.c
@@ -338,10 +338,11 @@ void
 stp_eprintf(const stp_vars_t *v, const char *format, ...)
 {
   int bytes;
+  void * errdata;
   stp_outfunc_t errfunc = stp_get_errfunc(v);
   if (! errfunc)
     errfunc = global_errfunc;
-  void * errdata = stp_get_errdata(v);
+  errdata = stp_get_errdata(v);
   if (! errdata)
     errdata = global_errdata;
   if (errfunc)
@@ -424,6 +425,7 @@ stp_dprintf(unsigned long level, const stp_vars_t *v, const char *format, ...)
   stpi_init_debug();
   if (level & stpi_debug_level)
     {
+      void *dbgdata;
       stp_outfunc_t dbgfunc = stp_get_dbgfunc(v);
       if (! dbgfunc)
 	dbgfunc = global_dbgfunc;
@@ -431,7 +433,7 @@ stp_dprintf(unsigned long level, const stp_vars_t *v, const char *format, ...)
 	dbgfunc = stp_get_errfunc(v);
       if (! dbgfunc)
 	dbgfunc = global_errfunc;
-      void *dbgdata = stp_get_dbgdata(v);
+      dbgdata = stp_get_dbgdata(v);
       if (! dbgdata)
 	dbgdata = global_dbgdata;
       if (! dbgdata)
diff --git a/src/main/printers.c b/src/main/printers.c
index 58787fa..3636cbe 100644
--- a/src/main/printers.c
+++ b/src/main/printers.c
@@ -494,12 +494,14 @@ stp_describe_output(const stp_vars_t *v)
 int
 stp_verify(stp_vars_t *v)
 {
+  const stp_printfuncs_t *printfuncs;
+  stp_vars_t *nv;
+  int status;
   if (stp_get_verified(v))
     return 1;
-  const stp_printfuncs_t *printfuncs =
+  printfuncs =
     stpi_get_printfuncs(stp_get_printer(v));
-  stp_vars_t *nv = stp_vars_create_copy(v);
-  int status;
+  nv = stp_vars_create_copy(v);
   stp_prune_inactive_options(nv);
   status = (printfuncs->verify)(nv);
   stp_set_verified(v, stp_get_verified(nv));
diff --git a/src/main/refcache.c b/src/main/refcache.c
index 9664528..0cdc0d1 100644
--- a/src/main/refcache.c
+++ b/src/main/refcache.c
@@ -113,8 +113,9 @@ stp_refcache_create(const char *name)
 static stp_refcache_t *
 find_cache_named(const char *cache)
 {
+  stp_list_item_t *item;
   check_stp_cache();
-  stp_list_item_t *item = stp_list_get_item_by_name(global_cache_list, cache);
+  item = stp_list_get_item_by_name(global_cache_list, cache);
   if (item)
     return (stp_refcache_t *) stp_list_item_get_data(item);
   else
@@ -124,8 +125,9 @@ find_cache_named(const char *cache)
 static stp_refcache_t *
 find_or_create_cache_named(const char *cache)
 {
+  stp_list_item_t *item;
   check_stp_cache();
-  stp_list_item_t *item = stp_list_get_item_by_name(global_cache_list, cache);
+  item = stp_list_get_item_by_name(global_cache_list, cache);
   if (!item)
     {
       stp_refcache_create(cache);
@@ -207,8 +209,9 @@ stp_refcache_replace_item(const char *cache, const char *item, void *data)
 void
 stp_refcache_destroy(const char *cache)
 {
+  stp_list_item_t *item;
   check_stp_cache();
-  stp_list_item_t *item = stp_list_get_item_by_name(global_cache_list, cache);
+  item = stp_list_get_item_by_name(global_cache_list, cache);
   if (item)
     {
       stp_list_item_destroy(global_cache_list, item);
diff --git a/src/main/sequence.c b/src/main/sequence.c
index 8be0911..482c4cb 100644
--- a/src/main/sequence.c
+++ b/src/main/sequence.c
@@ -383,13 +383,14 @@ stp_sequence_create_from_xmltree(stp_mxml_node_t *da)
 	  if (child->type == STP_MXML_TEXT)
 	    {
 	      char *endptr;
+	      double tmpval;
 	      /*
 	       * Explicitly documented that callers to strtod should clear
 	       * errno before calling it if they want to check the return
 	       * status.
 	       */
 	      errno = 0;
-	      double tmpval = strtod(child->value.text.string, &endptr);
+	      tmpval = strtod(child->value.text.string, &endptr);
 	      if (endptr == child->value.text.string)
 		{
 		  stp_erprintf
diff --git a/src/main/xml.c b/src/main/xml.c
index 5587a12..1755131 100644
--- a/src/main/xml.c
+++ b/src/main/xml.c
@@ -308,8 +308,9 @@ xml_try_parse_file_1(const char *pathname, const char *topnodename)
 static stp_mxml_node_t *
 xml_try_parse_file(const char *pathname, const char *topnodename)
 {
+  stp_mxml_node_t *answer;
   stp_xml_init();
-  stp_mxml_node_t *answer = xml_try_parse_file_1(pathname, topnodename);
+  answer = xml_try_parse_file_1(pathname, topnodename);
   stp_xml_exit();
   return answer;
 }
@@ -423,11 +424,12 @@ void
 stp_xml_free_parsed_file(stp_mxml_node_t *node)
 {
   char *addr_string;
+  stp_param_string_t *cache_entry;
   /* free(NULL) is legal and a no-op. */
   if (! node)
     return;
   stp_asprintf(&addr_string, "%p", (void *) node);
-  stp_param_string_t *cache_entry =
+  cache_entry =
     stp_string_list_find(cached_xml_files, addr_string);
   if (! cache_entry)
     {
diff --git a/src/testpattern/testpattern.c b/src/testpattern/testpattern.c
index 3a6f00d..84e6375 100644
--- a/src/testpattern/testpattern.c
+++ b/src/testpattern/testpattern.c
@@ -613,12 +613,12 @@ fill_channels_##bits(unsigned char *data, size_t len, size_t scount)	\
 {									\
   int i;								\
   int c;								\
-  scount = global_channel_depth;					\
   T *s_data = (T *) data;						\
   unsigned black_val = global_ink_limit * ((1 << bits) - 1);		\
-  unsigned blocksize = len / scount;					\
-  unsigned blocks = blocksize * scount;					\
+  unsigned blocksize = len / global_channel_depth;					\
+  unsigned blocks = blocksize * global_channel_depth;					\
   unsigned extra = len - blocks;					\
+  scount = global_channel_depth;					\
   memset(s_data, 0, sizeof(T) * len * scount);				\
   for (c = 0; c < scount; c++)						\
     {									\
-- 
2.30.2

