Adopt use of gnulib for portability.
[pspp] / src / devind.c
index 8432ea8e4d9f362dcedbfe3cdae129d3988f7468..39f0550e5aba217565f5b0daeeb80b2a7e6ab32b 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. */
 
 /* Device-independent output format.  Eventually I intend for all
    PSPP output to work this way, but adding it as an available
@@ -88,7 +88,7 @@
 
 #include <config.h>
 #include "devind.h"
-#include <assert.h>
+#include "error.h"
 #include <errno.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include "alloc.h"
 #include "error.h"
 #include "filename.h"
-#include "getline.h"
+#include "getl.h"
 #include "output.h"
 #include "som.h"
 #include "tab.h"
 #include "version.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 /* Device-independent output driver extension record. */
 struct devind_driver_ext
   {
@@ -116,13 +119,13 @@ struct devind_driver_ext
   };
 
 static int
-devind_open_global (struct outp_class *this unused)
+devind_open_global (struct outp_class *this UNUSED)
 {
   return 1;
 }
 
 static int
-devind_close_global (struct outp_class *this unused)
+devind_close_global (struct outp_class *this UNUSED)
 {
   return 1;
 }
@@ -220,7 +223,7 @@ devind_option (struct outp_driver *this, const char *key, const struct string *v
       break;
     case 1:
       free (x->file.filename);
-      x->file.filename = xstrdup (ds_value (val));
+      x->file.filename = xstrdup (ds_c_str (val));
       break;
     default:
       assert (0);
@@ -260,7 +263,7 @@ devind_close_page (struct outp_driver *this)
 static void output_tab_table (struct outp_driver *, struct tab_table *);
 
 static void
-devind_submit (struct outp_driver *this, struct som_table *s)
+devind_submit (struct outp_driver *this, struct som_entity *s)
 {
   extern struct som_table_class tab_table_class;
   struct devind_driver_ext *x = this->ext;
@@ -272,10 +275,10 @@ devind_submit (struct outp_driver *this, struct som_table *s)
       return;
     }
 
-  if (s->class == &tab_table_class)
+  assert (s->class == &tab_table_class);
+
+  if ( s->type == SOM_TABLE ) 
     output_tab_table (this, s->ext);
-  else
-    assert (0);
 }
 
 /* Write string S of length LEN to file F, escaping characters as
@@ -320,7 +323,7 @@ output_tab_table (struct outp_driver *this, struct tab_table *t)
   if (t->nr == 1 && t->nc == 1)
     {
       fputs ("p:", x->file.file);
-      escape_string (x->file.file, ls_value (t->cc), ls_length (t->cc));
+      escape_string (x->file.file, ls_c_str (t->cc), ls_length (t->cc));
       putc ('\n', x->file.file);
       
       return;
@@ -347,7 +350,7 @@ output_tab_table (struct outp_driver *this, struct tab_table *t)
   if (!ls_empty_p (&t->title))
     {
       putc ('T', x->file.file);
-      escape_string (x->file.file, ls_value (&t->title),
+      escape_string (x->file.file, ls_c_str (&t->title),
                     ls_length (&t->title));
       putc ('\n', x->file.file);
     }
@@ -367,7 +370,7 @@ output_tab_table (struct outp_driver *this, struct tab_table *t)
        
        for (c = 0; c < t->nc; c++, ct++)
          {
-            struct len_string *cc;
+            struct fixed_string *cc;
             struct tab_joined_cell *j;
 
             if (*ct == TAB_EMPTY)
@@ -376,7 +379,7 @@ output_tab_table (struct outp_driver *this, struct tab_table *t)
             cc = t->cc + c + r * t->nc;
            if (*ct & TAB_JOIN) 
               {
-                j = (struct tab_joined_cell *) ls_value (cc);
+                j = (struct tab_joined_cell *) ls_c_str (cc);
                 cc = &j->contents;
                 if (c != j->x1 || r != j->y1)
                   continue;
@@ -399,7 +402,7 @@ output_tab_table (struct outp_driver *this, struct tab_table *t)
             else
               putc ('c', x->file.file);
             putc ('t', x->file.file);
-            escape_string (x->file.file, ls_value (cc), ls_length (cc));
+            escape_string (x->file.file, ls_c_str (cc), ls_length (cc));
             putc ('\n', x->file.file);
           }
       }
@@ -474,4 +477,7 @@ struct outp_class devind_class =
   NULL,
   NULL,
   NULL,
+
+  NULL,
+  NULL,
 };