[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] html backend goes into infinite loop
From: |
Gaius Mulley |
Subject: |
Re: [Groff] html backend goes into infinite loop |
Date: |
Fri, 16 Aug 2002 16:25:53 +0100 |
Hi,
> There is an offending file which causes groff to go into endless loop.
here is a patch which fixes this problem, I've tried it on my `eyeball'
regression suite - it appears ok. Having a mechanical regression suite
would be very useful :-). The patch includes the earlier malloc related one
from the same file.
Gaius
--- groff-cvs/src/devices/grohtml/post-html.cc Wed Aug 7 16:01:32 2002
+++ groff-html/src/devices/grohtml/post-html.cc Fri Aug 16 15:32: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
}
@@ -2675,6 +2682,9 @@
g = page_contents->glyphs.get_data();
do {
#if 0
+ fprintf(stderr, g->text_string) ;
+ fprintf(stderr, " ") ;
+ fflush(stderr);
if (strcmp(g->text_string, "XXXXXXX") == 0)
stop();
#endif
@@ -2796,15 +2806,9 @@
/*
* 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();
@@ -2818,7 +2822,9 @@
last = g;
found_col = FALSE;
}
- } while (! page_contents->glyphs.is_equal_to_head());
+ } while (g != NULL);
+
+ page_contents->glyphs.start_from_head();
if (start_of_table != NULL) {
if (last != NULL)
while (last != page_contents->glyphs.get_data())