X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fascii.c;h=9614e6aef899d88353142f7f1827a7a9ad5462d1;hb=319a66b560b7ca7144b88ced1982ba5e490e6e57;hp=7804ade3f475d9e0cc08fa281be5a2d5ed6677d5;hpb=94a8e93c4397e1140dd6de5db19d054df546419e;p=pspp diff --git a/src/output/ascii.c b/src/output/ascii.c index 7804ade3f4..9614e6aef8 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -202,6 +202,24 @@ static void ascii_draw_cell (void *, const struct table_cell *, 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) { @@ -340,6 +358,8 @@ update_page_size (struct ascii_driver *a, bool issue_error) return false; } + reallocate_lines (a); + return true; } @@ -573,9 +593,9 @@ ascii_submit (struct output_driver *driver, } const struct output_driver_factory txt_driver_factory = - { "txt", ascii_create }; + { "txt", "-", ascii_create }; const struct output_driver_factory list_driver_factory = - { "list", ascii_create }; + { "list", "-", ascii_create }; static const struct output_driver_class ascii_driver_class = { @@ -955,7 +975,6 @@ ascii_layout_cell (struct ascii_driver *a, const struct table_cell *cell, if (length == 0) return; - text = cell->contents; breaks = xmalloc (length + 1); u8_possible_linebreaks (CHAR_CAST (const uint8_t *, text), length, "UTF-8", breaks); @@ -1085,19 +1104,19 @@ ascii_open_page (struct ascii_driver *a) 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 { @@ -1110,17 +1129,7 @@ ascii_open_page (struct ascii_driver *a) 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++) {