Fixed some issues with internationalisation
[pspp] / src / tab.c
index 7fdc37d24c94044a58e0c0e5eff51339b184c161..8dc704ffe665d63eb8c2f4da6a92e4c48ca81feb 100644 (file)
--- a/src/tab.c
+++ b/src/tab.c
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA. */
 
-/* AIX requires this to be the first thing in the file.  */
 #include <config.h>
-#if __GNUC__
-#define alloca __builtin_alloca
-#else
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else
-#ifdef _AIX
-#pragma alloca
-#else
-#ifndef alloca                 /* predefined by HP cc +Olibcalls */
-char *alloca ();
-#endif
-#endif
-#endif
-#endif
-
+#include "tab.h"
 #include <ctype.h>
 #include <assert.h>
 #include <stdarg.h>
@@ -48,22 +32,21 @@ char *alloca ();
 #include "output.h"
 #include "pool.h"
 #include "som.h"
-#include "tab.h"
 #include "var.h"
 
-#undef DEBUGGING
-/*#define DEBUGGING 1 */
 #include "debug-print.h"
 \f
-extern struct som_table_class tab_table_class;
+struct som_table_class tab_table_class;
 
 #if DEBUGGING
 #define DEFFIRST(NAME, LABEL) LABEL,
 #define DEFTAB(NAME, LABEL) LABEL,
+/*
 static const char *tab_names[] =
   {
 #include "tab.def"
   };
+*/
 #undef DEFFIRST
 #undef DEFTAB
 #endif
@@ -132,7 +115,6 @@ tab_destroy (struct tab_table *t)
 {
   assert (t != NULL);
   pool_destroy (t->container);
-  t->container=0;
 }
 
 /* Sets the width and height of a table, in columns and rows,
@@ -820,8 +802,13 @@ tab_output_text (int options, const char *buf, ...)
        {
          if (!d->page_open)
            d->class->open_page (d);
-         
-         d->class->text_set_font_by_name (d, "FIXED");
+
+          if (d->class->text_set_font_by_name != NULL)
+            d->class->text_set_font_by_name (d, "FIXED");
+          else 
+            {
+              /* FIXME */
+            }
        }
     }
 
@@ -838,7 +825,12 @@ tab_output_text (int options, const char *buf, ...)
       struct outp_driver *d;
 
       for (d = outp_drivers (NULL); d; d = outp_drivers (d))
-       d->class->text_set_font_by_name (d, "PROP");
+        if (d->class->text_set_font_by_name != NULL)
+          d->class->text_set_font_by_name (d, "PROP");
+        else 
+          {
+            /* FIXME */
+          }
     }
   
   if (options & TAT_PRINTF)
@@ -1165,50 +1157,47 @@ tabi_title (int x, int y)
 
 static int render_strip (int x, int y, int r, int c1, int c2, int r1, int r2);
 
-/* Execute BODY for each value of X from A to B exclusive. */
-#define UNROLL_LOOP(X, A, B, BODY)             \
-       do                                      \
-         {                                     \
-           for (X = A; X < B; X++)             \
-             {                                 \
-               BODY                            \
-             }                                 \
-         }                                     \
-       while (0)
-
-/* Execute PREP, then BODY for each specified value of X: A1...A2, B1...B2,
-   C1...C2, in each case not including the second value. */
-#define UNROLL_3_LOOPS(X, A1, A2, B1, B2, C1, C2, BODY)        \
-       do                                              \
-         {                                             \
-           UNROLL_LOOP (X, A1, A2, BODY);              \
-           UNROLL_LOOP (X, B1, B2, BODY);              \
-           UNROLL_LOOP (X, C1, C2, BODY);              \
-         }                                             \
-       while (0)
-
 /* Draws the table region in rectangle (X1,Y1)-(X2,Y2), where column
    X2 and row Y2 are not included in the rectangle, at the current
    position on the current output device.  Draws headers as well. */
 static void
 tabi_render (int x1, int y1, int x2, int y2)
 {
-  int y, r;
+  int i, y;
+  int ranges[3][2];
   
   tab_hit++;
+
   y = d->cp_y;
   if (!(t->flags & SOMF_NO_TITLE))
     y += d->font_height;
-  UNROLL_3_LOOPS (r, 0, t->t * 2 + 1, y1 * 2 + 1, y2 * 2,
-                 (t->nr - t->b) * 2, t->nr * 2 + 1,
-
-                 int x = d->cp_x;
-                 x += render_strip (x, y, r, 0, t->l * 2 + 1, y1, y2);
-                 x += render_strip (x, y, r, x1 * 2 + 1, x2 * 2, y1, y2);
-                 x += render_strip (x, y, r, (t->nc - t->r) * 2,
-                                    t->nc * 2 + 1, y1, y2);
-                 y += (r & 1) ? t->h[r / 2] : t->hrh[r / 2];
-                 );
+
+  /* Top headers. */
+  ranges[0][0] = 0;
+  ranges[0][1] = t->t * 2 + 1;
+
+  /* Requested rows. */
+  ranges[1][0] = y1 * 2 + 1;
+  ranges[1][1] = y2 * 2;
+
+  /* Bottom headers. */
+  ranges[2][0] = (t->nr - t->b) * 2;
+  ranges[2][1] = t->nr * 2 + 1;
+
+  for (i = 0; i < 3; i++) 
+    {
+      int r;
+
+      for (r = ranges[i][0]; r < ranges[i][1]; r++) 
+        {
+          int x = d->cp_x;
+          x += render_strip (x, y, r, 0, t->l * 2 + 1, y1, y2);
+          x += render_strip (x, y, r, x1 * 2 + 1, x2 * 2, y1, y2);
+          x += render_strip (x, y, r, (t->nc - t->r) * 2,
+                             t->nc * 2 + 1, y1, y2);
+          y += (r & 1) ? t->h[r / 2] : t->hrh[r / 2]; 
+        }
+    }
 }
 
 struct som_table_class tab_table_class =