[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Regression test suite
From: |
Gaius Mulley |
Subject: |
Re: [Groff] Regression test suite |
Date: |
Sun, 18 Aug 2002 09:12:42 +0100 |
> P.S. Anyone take a look at the second bug I found (another html backend
> endless loop ?)
Hi Mark,
yes here is a patch which fixes these two endless loops. However
grohtml is still making a mess of these manual pages, I've not had
time to analyse why this is the case.
Also thank you for undertaking the regression tests. You might find
the \O escape useful in generating specific tests (as Colin
mentioned). The new \O escape allows you to enable/disable output,
although movement is preserved. Hence they might allow you to throw
away text you don't wish to test for etc.
Gaius
--- groff-cvs/src/devices/grohtml/post-html.cc Wed Aug 7 16:01:32 2002
+++ groff-html/src/devices/grohtml/post-html.cc Sun Aug 18 08:44:01 2002
@@ -254,16 +254,25 @@
struct char_block {
enum { SIZE = 256 };
- char buffer[SIZE];
+ char *buffer;
int used;
char_block *next;
char_block();
+ char_block::char_block(int length);
};
char_block::char_block()
+ : used(0), next(0), buffer(NULL)
+{
+}
+
+char_block::char_block(int length)
: used(0), next(0)
{
+ buffer = (char *)malloc(max(length, char_block::SIZE));
+ if (buffer == NULL)
+ fatal("out of memory error");
}
class char_buffer {
@@ -300,18 +309,14 @@
return NULL;
if (tail == 0) {
- tail = new char_block;
+ tail = new char_block(length+1);
head = tail;
} else {
if (tail->used + length+1 > char_block::SIZE) {
- tail->next = new char_block;
- tail = tail->next;
+ tail->next = new char_block(length+1);
+ tail = tail->next;
}
}
- // at this point we have a tail which is ready for the string.
- if (tail->used + length+1 > char_block::SIZE) {
- fatal("need to increase char_block::SIZE");
- }
old_used = tail->used;
do {
@@ -1071,6 +1076,7 @@
element_list *t = new element_list(in, ptr->lineno, ptr->minv, ptr->minh,
ptr->maxv, ptr->maxh);
if (ptr == tail)
tail = t;
+ ptr->right->left = t;
t->right = ptr->right;
ptr->right = t;
t->left = ptr;
@@ -1299,6 +1305,7 @@
glyphs.move_to(old_pos);
printf("\ndebugging end\n\n");
printf("\n-->\n");
+ fflush(stdout);
#endif
}
@@ -1529,7 +1536,7 @@
font *make_bold (font *f);
int overstrike (int index, const char *name, const
environment *env, int w);
void do_body (void);
- int next_horiz_pos (int nf);
+ int next_horiz_pos (text_glob *g, int nf);
void lookahead_for_tables (void);
void insert_tab_te (void);
text_glob *insert_tab_ts (text_glob *where);
@@ -2439,10 +2446,12 @@
int html_printer::calc_nf (text_glob *g, int nf)
{
- if (g->is_fi())
- return FALSE;
- if (g->is_nf())
- return TRUE;
+ if (g != NULL) {
+ if (g->is_fi())
+ return FALSE;
+ if (g->is_nf())
+ return TRUE;
+ }
return nf;
}
@@ -2471,16 +2480,19 @@
* -1 is returned if it doesn't exist.
*/
-int html_printer::next_horiz_pos (int nf)
+int html_printer::next_horiz_pos (text_glob *g, int nf)
{
int next = -1;
- text_glob *g = page_contents->glyphs.get_data();
- if (g->is_br() || (nf && g->is_eol()))
+ if ((g != NULL) && (g->is_br() || (nf && g->is_eol())))
if (! page_contents->glyphs.is_empty()) {
- page_contents->glyphs.move_right();
- next = g->minh;
- page_contents->glyphs.move_left();
+ page_contents->glyphs.move_right_get_data();
+ if (g == NULL)
+ page_contents->glyphs.start_from_head();
+ else {
+ next = g->minh;
+ page_contents->glyphs.move_left();
+ }
}
return next;
}
@@ -2674,7 +2686,11 @@
page_contents->glyphs.start_from_head();
g = page_contents->glyphs.get_data();
do {
-#if 0
+#if defined(DEBUG_TABLES)
+ fprintf(stderr, " [") ;
+ fprintf(stderr, g->text_string) ;
+ fprintf(stderr, "] ") ;
+ fflush(stderr);
if (strcmp(g->text_string, "XXXXXXX") == 0)
stop();
#endif
@@ -2796,29 +2812,28 @@
/*
* move onto next glob, check whether we are starting a new line
*/
- page_contents->glyphs.move_right();
- g = page_contents->glyphs.get_data();
+ g = page_contents->glyphs.move_right_get_data();
-#if defined(DEBUG_TABLES)
- if (g->is_in() && (!seen_text))
- html.simple_comment("IGNORE .in");
- else
-#endif
- if (g->is_br_ni() || (nf && g->is_eol())) {
+ if (g != NULL && (g->is_br_ni() || (nf && g->is_eol()))) {
do {
- page_contents->glyphs.move_right();
- g = page_contents->glyphs.get_data();
+ g = page_contents->glyphs.move_right_get_data();
nf = calc_nf(g, nf);
- } while (g->is_br_ni() || (nf && g->is_eol()));
+ } while ((g != NULL) && (g->is_br_ni() || (nf && g->is_eol())));
start_of_line = g;
seen_text = FALSE;
ncol = 0;
- left = next_horiz_pos(nf);
+ left = next_horiz_pos(g, nf);
if (found_col)
last = g;
found_col = FALSE;
}
- } while (! page_contents->glyphs.is_equal_to_head());
+ } while ((g != NULL) && (! page_contents->glyphs.is_equal_to_head()));
+
+#if defined(DEBUG_TABLES)
+ fprintf(stderr, "finished scanning for tables\n");
+#endif
+
+ page_contents->glyphs.start_from_head();
if (start_of_table != NULL) {
if (last != NULL)
while (last != page_contents->glyphs.get_data())