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>
#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
{
assert (t != NULL);
pool_destroy (t->container);
- t->container=0;
+ t=0;
}
/* Sets the width and height of a table, in columns and rows,
int y;
assert (t != NULL);
+ assert (x > 0);
+ assert (x < t->nc);
+ assert (y1 >= 0);
+ assert (y2 >= y1);
+ assert (y2 <= t->nr);
+
#if GLOBAL_DEBUGGING
if (x + t->col_ofs < 0 || x + t->col_ofs > t->nc
|| y1 + t->row_ofs < 0 || y1 + t->row_ofs >= t->nr
int x;
assert (t != NULL);
-#if GLOBAL_DEBUGGING
- if (x1 + t->col_ofs < 0 || x1 + t->col_ofs >= t->nc
- || x2 + t->col_ofs < 0 || x2 + t->col_ofs >= t->nc
- || y + t->row_ofs < 0 || y + t->row_ofs > t->nr)
- {
- printf (_("bad hline: x=(%d+%d=%d,%d+%d=%d) y=%d+%d=%d "
- "in table size (%d,%d)\n"),
- x1, t->col_ofs, x1 + t->col_ofs,
- x2, t->col_ofs, x2 + t->col_ofs,
- y, t->row_ofs, y + t->row_ofs,
- t->nc, t->nr);
- return;
- }
-#endif
+
+ assert (y >= 0);
+ assert (y < t->nr);
+ assert (x2 >= x1 );
+ assert (x1 >= 0 );
+ assert (x2 < t->nc);
x1 += t->col_ofs;
x2 += t->col_ofs;
int x1, int y1, int x2, int y2)
{
assert (t != NULL);
+
+ assert (x2 >= x1);
+ assert (y2 >= y1);
+ assert (x1 >= 0);
+ assert (y1 >= 0);
+ assert (x2 < t->nc);
+ assert (y2 < t->nr);
+
#if GLOBAL_DEBUGGING
if (x1 + t->col_ofs < 0 || x1 + t->col_ofs >= t->nc
|| x2 + t->col_ofs < 0 || x2 + t->col_ofs >= t->nc
va_list args;
assert (table != NULL && text != NULL);
+
+ assert (c >= 0 );
+ assert (r >= 0 );
+ assert (c < table->nc);
+ assert (r < table->nr);
+
+
#if GLOBAL_DEBUGGING
if (c + table->col_ofs < 0 || r + table->row_ofs < 0
|| c + table->col_ofs >= table->nc
struct tab_joined_cell *j;
assert (table != NULL && text != NULL);
+
+ assert (x1 >= 0);
+ assert (y1 >= 0);
+ assert (y2 >= y1);
+ assert (x2 >= x1);
+ assert (y2 < table->nr);
+ assert (x2 < table->nc);
+
#if GLOBAL_DEBUGGING
if (x1 + table->col_ofs < 0 || x1 + table->col_ofs >= table->nc
|| y1 + table->row_ofs < 0 || y1 + table->row_ofs >= table->nr
{
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 */
+ }
}
}
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)
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 =
{
j->hit = tab_hit;
- if (j->x1 == c / 2 && j->y1 == r / 2
- && j->x2 <= c2 && j->y2 <= r2)
+ if (j->x1 == c / 2 && j->y1 == r / 2)
{
struct outp_text text;
int c;
for (c = j->x1, text.h = -t->wrv[j->x2];
- c < j->x2; c++)
- text.h += t->w[c] + t->wrv[c + 1];
+ c < j->x2 && c < c2 / 2; c++)
+ text.h += t->w[c] + t->wrv[c + 1];
}
{
int r;
for (r = j->y1, text.v = -t->hrh[j->y2];
- r < j->y2; r++)
+ r < j->y2 && r < r2 / 2; r++)
text.v += t->h[r] + t->hrh[r + 1];
}
d->class->text_draw (d, &text);