Adopt use of gnulib for portability.
[pspp-builds.git] / src / output.c
index c0c4e0b022339f4e1f1a978b611dca96d00925ad..59bccb8045324f707f792d3be6be4f2feabc1ec3 100644 (file)
@@ -14,8 +14,8 @@
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA. */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
 
 #include <config.h>
 #include "output.h"
@@ -34,6 +34,9 @@
 #include "settings.h"
 #include "str.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 /* FIXME? Should the output configuration format be changed to
    drivername:classname:devicetype:options, where devicetype is zero
    or more of screen, printer, listing? */
@@ -288,12 +291,12 @@ outp_read_devices (void)
   where.line_number = 0;
   err_push_file_locator (&where);
 
-  ds_init (NULL, &line, 128);
+  ds_init (&line, 128);
 
   if (init_fn == NULL)
     {
-      msg (IE, _("Cannot find output initialization file.  Use `-vv' to view "
-          "search path."));
+      msg (IE, _("Cannot find output initialization file.  "
+                 "Use `-vvvv' to view search path."));
       goto exit;
     }
 
@@ -315,7 +318,7 @@ outp_read_devices (void)
            msg (ME, _("Reading %s: %s."), init_fn, strerror (errno));
          break;
        }
-      for (cp = ds_value (&line); isspace ((unsigned char) *cp); cp++);
+      for (cp = ds_c_str (&line); isspace ((unsigned char) *cp); cp++);
       if (!strncmp ("define", cp, 6) && isspace ((unsigned char) cp[6]))
        outp_configure_macro (&cp[7]);
       else if (*cp)
@@ -442,12 +445,27 @@ destroy_list (struct outp_driver ** dl)
 int
 outp_done (void)
 {
+  struct outp_driver_class_list *n = outp_class_list ; 
 #if GLOBAL_DEBUGGING
   if (iterating_driver_list)
     reentrancy ();
 #endif
   destroy_list (&outp_driver_list);
 
+  while (n) 
+    {
+      struct outp_driver_class_list *next = n->next;
+      free(n);
+      n = next;
+    }
+  outp_class_list = NULL;
+
+  free (outp_title);
+  outp_title = NULL;
+  
+  free (outp_subtitle);
+  outp_subtitle = NULL;
+
   return 1;
 }
 
@@ -511,7 +529,7 @@ tokener (void)
          while (*prog && *prog != quote)
            {
              if (*prog != '\\')
-               ds_putchar (&op_tokstr, *prog++);
+               ds_putc (&op_tokstr, *prog++);
              else
                {
                  int c;
@@ -590,14 +608,14 @@ tokener (void)
                      msg (IS, _("Syntax error in string constant."));
                       continue;
                    }
-                 ds_putchar (&op_tokstr, (unsigned char) c);
+                 ds_putc (&op_tokstr, (unsigned char) c);
                }
            }
          prog++;
        }
       else
        while (*prog && !isspace ((unsigned char) *prog) && *prog != '=')
-         ds_putchar (&op_tokstr, *prog++);
+         ds_putc (&op_tokstr, *prog++);
       op_token = 'a';
     }
 
@@ -612,7 +630,7 @@ parse_options (char *s, struct outp_driver * d)
   prog = s;
   op_token = -1;
 
-  ds_init (NULL, &op_tokstr, 64);
+  ds_init (&op_tokstr, 64);
   while (tokener ())
     {
       char key[65];
@@ -624,7 +642,7 @@ parse_options (char *s, struct outp_driver * d)
        }
 
       ds_truncate (&op_tokstr, 64);
-      strcpy (key, ds_value (&op_tokstr));
+      strcpy (key, ds_c_str (&op_tokstr));
 
       tokener ();
       if (op_token != '=')
@@ -1150,7 +1168,7 @@ outp_get_paper_size (char *size, int *h, int *v)
   where.filename = pprsz_fn;
   where.line_number = 0;
   err_push_file_locator (&where);
-  ds_init (NULL, &line, 128);
+  ds_init (&line, 128);
 
   if (pprsz_fn == NULL)
     {
@@ -1176,7 +1194,7 @@ outp_get_paper_size (char *size, int *h, int *v)
            msg (ME, _("Reading %s: %s."), pprsz_fn, strerror (errno));
          break;
        }
-      for (cp = ds_value (&line); isspace ((unsigned char) *cp); cp++);
+      for (cp = ds_c_str (&line); isspace ((unsigned char) *cp); cp++);
       if (*cp == 0)
        continue;
       if (*cp != '"')