Plugged some memory leaks.
[pspp-builds.git] / src / output / output.c
index e5736b02bedbde68af53a56ab42618e794d93398..5a24d89547a8ea054eb5dd3b5721a7dca761fe0b 100644 (file)
@@ -1,20 +1,18 @@
-/* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+   Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA. */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
 #include "output.h"
@@ -84,7 +82,6 @@ char *outp_subtitle;
 static int disabled_devices;
 
 static void destroy_driver (struct outp_driver *);
-static void configure_driver_line (struct substring);
 static void configure_driver (const struct substring, const struct substring,
                               const struct substring, const struct substring);
 
@@ -152,8 +149,8 @@ add_name (char *bp, char *ep, int source)
   outp_configure_vec = n;
 }
 
-/* Checks that outp_configure_vec is empty, bitches & clears it if it
-   isn't. */
+/* Checks that outp_configure_vec is empty, complains and clears
+   it if it isn't. */
 static void
 check_configure_vec (void)
 {
@@ -320,7 +317,7 @@ outp_read_devices (void)
              struct outp_names *n = search_names (cp, ep);
              if (n)
                {
-                 configure_driver_line (ds_ss (&line));
+                 outp_configure_driver_line (ds_ss (&line));
                  delete_name (n);
                }
            }
@@ -438,6 +435,7 @@ void
 outp_done (void)
 {
   struct outp_driver_class_list *n = outp_class_list ;
+  outp_configure_clear ();
   destroy_list (&outp_driver_list);
 
   while (n)
@@ -564,7 +562,7 @@ get_option_token (struct substring *s, const char *driver_name,
                 case '7':
                   out = c - '0';
                   while (ss_first (*s) >= '0' && ss_first (*s) <= '7')
-                    out = c * 8 + (ss_get_char (s) - '0');
+                    out = out * 8 + (ss_get_char (s) - '0');
                   break;
                 case 'x':
                 case 'X':
@@ -703,7 +701,7 @@ configure_driver (struct substring driver_name, struct substring class_name,
   d->class = c->class;
   d->name = ss_xstrdup (driver_name);
   d->page_open = false;
-  d->device = OUTP_DEV_NONE;
+  d->device = device;
   d->cp_x = d->cp_y = 0;
   d->ext = NULL;
   d->prc = NULL;
@@ -735,8 +733,8 @@ configure_driver (struct substring driver_name, struct substring class_name,
    DRIVERNAME:CLASSNAME:DEVICETYPE:OPTIONS
    Adds a driver to outp_driver_list pursuant to the specification
    provided.  */
-static void
-configure_driver_line (struct substring line_)
+void
+outp_configure_driver_line (struct substring line_)
 {
   struct string line = DS_EMPTY_INITIALIZER;
   struct substring tokens[4];
@@ -1098,10 +1096,10 @@ outp_drivers (struct outp_driver *d)
   return d;
 }
 
-/* Enables (if ENABLE is nonzero) or disables (if ENABLE is zero) the
+/* Enables (if ENABLE is true) or disables (if ENABLE is false) the
    device(s) given in mask DEVICE. */
 void
-outp_enable_device (int enable, int device)
+outp_enable_device (bool enable, int device)
 {
   if (enable)
     disabled_devices &= ~device;
@@ -1145,6 +1143,18 @@ outp_eject_page (struct outp_driver *d)
   outp_open_page (d);
 }
 
+/* Flushes output to screen devices, so that the user can see
+   output that doesn't fill up an entire page. */
+void
+outp_flush (struct outp_driver *d)
+{
+  if (d->device & OUTP_DEV_SCREEN && d->class->flush != NULL)
+    {
+      outp_close_page (d);
+      d->class->flush (d);
+    }
+}
+
 /* Returns the width of string S, in device units, when output on
    device D. */
 int