int bb[TABLE_N_AXES][2],
int clip[TABLE_N_AXES][2]);
+static void
+reallocate_lines (struct ascii_driver *a)
+{
+ if (a->length > a->allocated_lines)
+ {
+ int i;
+ a->lines = xnrealloc (a->lines, a->length, sizeof *a->lines);
+ for (i = a->allocated_lines; i < a->length; i++)
+ {
+ struct ascii_line *line = &a->lines[i];
+ ds_init_empty (&line->s);
+ line->width = 0;
+ }
+ a->allocated_lines = a->length;
+ }
+}
+
+
static struct ascii_driver *
ascii_driver_cast (struct output_driver *driver)
{
return false;
}
+ reallocate_lines (a);
+
return true;
}
a->subtitle = xstrdup (text);
break;
+ case TEXT_ITEM_COMMAND_OPEN:
case TEXT_ITEM_COMMAND_CLOSE:
break;
static char *
ascii_reserve (struct ascii_driver *a, int y, int x0, int x1, int n)
{
- struct ascii_line *line = &a->lines[y];
+ struct ascii_line *line;
+ assert (y < a->allocated_lines);
+ line = &a->lines[y];
if (x0 >= line->width)
{
if (length == 0)
return;
- text = cell->contents;
breaks = xmalloc (length + 1);
u8_possible_linebreaks (CHAR_CAST (const uint8_t *, text), length,
"UTF-8", breaks);
a->file = fn_open (a->file_name, a->append ? "a" : "w");
if (a->file != NULL)
{
-#if HAVE_DECL_SIGWINCH
if ( isatty (fileno (a->file)))
{
+#if HAVE_DECL_SIGWINCH
struct sigaction action;
sigemptyset (&action.sa_mask);
action.sa_flags = 0;
action.sa_handler = winch_handler;
the_driver = a;
+ sigaction (SIGWINCH, &action, NULL);
+#endif
a->auto_width = true;
a->auto_length = true;
- sigaction (SIGWINCH, &action, NULL);
}
-#endif
}
else
{
a->page_number++;
- if (a->length > a->allocated_lines)
- {
- a->lines = xnrealloc (a->lines, a->length, sizeof *a->lines);
- for (i = a->allocated_lines; i < a->length; i++)
- {
- struct ascii_line *line = &a->lines[i];
- ds_init_empty (&line->s);
- line->width = 0;
- }
- a->allocated_lines = a->length;
- }
+ reallocate_lines (a);
for (i = 0; i < a->length; i++)
{