From 6d34b6cd00bb26603f8acedd3f0ed69a4484e484 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 21 Mar 2004 06:22:20 +0000 Subject: [PATCH] Fix table function assertions to respect offsets. --- src/ChangeLog | 8 ++++++++ src/command.def | 2 +- src/tab.c | 41 +++++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 90df01c4..14de8621 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +Sat Mar 20 22:19:08 2004 Ben Pfaff + + * tab.c: (tab_vline) Fix assertions to respect row_ofs and + col_ofs. + (tab_hline) Ditto. + (tab_box) Ditto. + (tab_joint_text) Ditto. + Sat Mar 20 17:57:23 2004 Ben Pfaff * levene.c: Add #include. diff --git a/src/command.def b/src/command.def index b5a3eda1..beb18c4e 100644 --- a/src/command.def +++ b/src/command.def @@ -114,7 +114,7 @@ DEFCMD ("SAMPLE", ERRO, ERRO, TRAN, TRAN, cmd_sample) DEFCMD ("SAVE", ERRO, ERRO, PROC, PROC, cmd_save) DEFCMD ("SELECT IF", ERRO, ERRO, TRAN, TRAN, cmd_select_if) DEFCMD ("SET", INIT, INPU, TRAN, PROC, cmd_set) -DEFCMD ("SHOW", INIT, INPU, TRAN, PROC, cmd_show) +DEFCMD ("SHOW", INIT, INPU, TRAN, PROC, cmd_show) DEFCMD ("SORT", ERRO, ERRO, PROC, PROC, cmd_sort_cases) DEFCMD ("SORT CASES", ERRO, ERRO, PROC, PROC, cmd_sort_cases) DEFCMD ("SPLIT FILE", ERRO, INPU, TRAN, TRAN, cmd_split_file) diff --git a/src/tab.c b/src/tab.c index fbb292fd..118a77cd 100644 --- a/src/tab.c +++ b/src/tab.c @@ -252,11 +252,6 @@ tab_vline (struct tab_table *t, int style, int x, int y1, int y2) 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 @@ -277,6 +272,12 @@ tab_vline (struct tab_table *t, int style, int x, int y1, int y2) y1 += t->row_ofs; y2 += t->row_ofs; + assert (x > 0); + assert (x < t->nc); + assert (y1 >= 0); + assert (y2 >= y1); + assert (y2 <= t->nr); + if (style != -1) { if ((style & TAL_SPACING) == 0) @@ -295,16 +296,16 @@ tab_hline (struct tab_table * t, int style, int x1, int x2, int y) assert (t != NULL); + x1 += t->col_ofs; + x2 += t->col_ofs; + y += t->row_ofs; + 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; - y += t->row_ofs; - if (style != -1) { if ((style & TAL_SPACING) == 0) @@ -326,13 +327,6 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, { 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 @@ -355,6 +349,13 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, y1 += t->row_ofs; y2 += t->row_ofs; + assert (x2 >= x1); + assert (y2 >= y1); + assert (x1 >= 0); + assert (y1 >= 0); + assert (x2 < t->nc); + assert (y2 < t->nr); + if (f_h != -1) { int x; @@ -689,12 +690,12 @@ tab_joint_text (struct tab_table *table, int x1, int y1, int x2, int y2, assert (table != NULL && text != NULL); - assert (x1 >= 0); - assert (y1 >= 0); + assert (x1 + table->col_ofs >= 0); + assert (y1 + table->row_ofs >= 0); assert (y2 >= y1); assert (x2 >= x1); - assert (y2 < table->nr); - assert (x2 < table->nc); + assert (y2 + table->row_ofs < table->nr); + assert (x2 + table->col_ofs < table->nc); #if GLOBAL_DEBUGGING if (x1 + table->col_ofs < 0 || x1 + table->col_ofs >= table->nc -- 2.30.2