Make the expression code a little nicer and fix bugs found
[pspp-builds.git] / src / ascii.c
index 60bd1837ce39bc7499ed0f8823f77f4b46e20083..9c0103e0c5e2b044a97f200d5a2acbd1254da62a 100644 (file)
@@ -18,7 +18,7 @@
    02111-1307, USA. */
 
 #include <config.h>
-#include <assert.h>
+#include "error.h"
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
@@ -185,21 +185,21 @@ static int postopen (struct file_ext *);
 static int preclose (struct file_ext *);
 
 static int
-ascii_open_global (struct outp_class *this unused)
+ascii_open_global (struct outp_class *this UNUSED)
 {
   ascii_pool = pool_create ();
   return 1;
 }
 
 static int
-ascii_close_global (struct outp_class *this unused)
+ascii_close_global (struct outp_class *this UNUSED)
 {
   pool_destroy (ascii_pool);
   return 1;
 }
 
 static int *
-ascii_font_sizes (struct outp_class *this unused, int *n_valid_sizes)
+ascii_font_sizes (struct outp_class *this UNUSED, int *n_valid_sizes)
 {
   static int valid_sizes[] = {12, 12, 0, 0};
 
@@ -595,6 +595,7 @@ ascii_option (struct outp_driver *this, const char *key,
            break;
          default:
            assert (0);
+            abort ();
          }
        ls_create (ascii_pool, s, value);
       }
@@ -735,7 +736,7 @@ expand_line (struct ascii_driver_ext *x, int i, int l)
 
 static void
 ascii_line_horz (struct outp_driver *this, const struct rect *r,
-                const struct color *c unused, int style)
+                const struct color *c UNUSED, int style)
 {
   struct ascii_driver_ext *ext = this->ext;
   int x1 = r->x1 / this->horiz;
@@ -769,7 +770,7 @@ ascii_line_horz (struct outp_driver *this, const struct rect *r,
 
 static void
 ascii_line_vert (struct outp_driver *this, const struct rect *r,
-                const struct color *c unused, int style)
+                const struct color *c UNUSED, int style)
 {
   struct ascii_driver_ext *ext = this->ext;
   int x1 = r->x1 / this->horiz;
@@ -804,7 +805,7 @@ ascii_line_vert (struct outp_driver *this, const struct rect *r,
 
 static void
 ascii_line_intersection (struct outp_driver *this, const struct rect *r,
-                        const struct color *c unused,
+                        const struct color *c UNUSED,
                         const struct outp_styles *style)
 {
   struct ascii_driver_ext *ext = this->ext;
@@ -835,25 +836,25 @@ ascii_line_intersection (struct outp_driver *this, const struct rect *r,
 /* FIXME: Later we could set this up so that for certain devices it
    performs shading? */
 static void
-ascii_box (struct outp_driver *this unused, const struct rect *r unused,
-          const struct color *bord unused, const struct color *fill unused)
+ascii_box (struct outp_driver *this UNUSED, const struct rect *r UNUSED,
+          const struct color *bord UNUSED, const struct color *fill UNUSED)
 {
   assert (this->driver_open && this->page_open);
 }
 
 /* Polylines not supported. */
 static void
-ascii_polyline_begin (struct outp_driver *this unused, const struct color *c unused)
+ascii_polyline_begin (struct outp_driver *this UNUSED, const struct color *c UNUSED)
 {
   assert (this->driver_open && this->page_open);
 }
 static void
-ascii_polyline_point (struct outp_driver *this unused, int x unused, int y unused)
+ascii_polyline_point (struct outp_driver *this UNUSED, int x UNUSED, int y UNUSED)
 {
   assert (this->driver_open && this->page_open);
 }
 static void
-ascii_polyline_end (struct outp_driver *this unused)
+ascii_polyline_end (struct outp_driver *this UNUSED)
 {
   assert (this->driver_open && this->page_open);
 }
@@ -888,7 +889,7 @@ ascii_text_set_font_by_position (struct outp_driver *this, int pos)
 }
 
 static void
-ascii_text_set_font_by_family (struct outp_driver *this unused, const char *s unused)
+ascii_text_set_font_by_family (struct outp_driver *this UNUSED, const char *s UNUSED)
 {
   assert (this->driver_open && this->page_open);
 }
@@ -916,7 +917,7 @@ ascii_text_get_font_name (struct outp_driver *this)
 }
 
 static const char *
-ascii_text_get_font_family (struct outp_driver *this unused)
+ascii_text_get_font_family (struct outp_driver *this UNUSED)
 {
   assert (this->driver_open && this->page_open);
   return "";
@@ -1216,6 +1217,7 @@ output_shorts (struct outp_driver *this,
              break;
            default:
              assert (0);
+              abort ();
            }
          if (!on)
            {
@@ -1244,6 +1246,7 @@ output_shorts (struct outp_driver *this,
                    break;
                  default:
                    assert (0);
+                    abort ();
                  }
              else
                {
@@ -1330,6 +1333,7 @@ return_carriage (struct outp_driver *this, int n_chars)
       break;
     default:
       assert (0);
+      abort ();
     }
 }
 
@@ -1403,6 +1407,7 @@ output_lines (struct outp_driver *this, int first, int count)
                  break;
                default:
                  assert (0);
+                  abort ();
                }
              if (off)
                output_string (this, ls_value (off), ls_end (off));
@@ -1427,6 +1432,7 @@ output_lines (struct outp_driver *this, int first, int count)
                  break;
                default:
                  assert (0);
+                  abort ();
                }
              if (on)
                output_string (this, ls_value (on), ls_end (on));
@@ -1461,6 +1467,9 @@ output_lines (struct outp_driver *this, int first, int count)
                  ch = *ep;
                  n_passes = 3;
                  break;
+                default:
+                  assert (0);
+                  abort ();
                }
              output_char (this, 1, ch);
              n_chars += ep - bp + 1;