X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fascii.c;h=06bd190633f8e5d95c3994fe3b6c743edc180192;hb=687c1acdbeecd7d0d7fdc4143d444e8b1563b532;hp=c9f96b21b58cbd287d2d41152e572ee6a658bd7d;hpb=49c02dd0d35698fd43528c4422b3b5202b481a11;p=pspp-builds.git diff --git a/src/output/ascii.c b/src/output/ascii.c index c9f96b21..06bd1906 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "data/file-name.h" #include "data/settings.h" @@ -786,6 +788,17 @@ ascii_layout_cell (struct ascii_driver *a, const struct table_cell *cell, /* ascii_close_page () and support routines. */ + +#if HAVE_DECL_SIGWINCH +static struct ascii_driver *the_driver; + +static void +winch_handler (int signum UNUSED) +{ + update_page_size (the_driver, false); +} +#endif + static bool ascii_open_page (struct ascii_driver *a) { @@ -799,6 +812,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))) + { + struct sigaction action; + sigemptyset (&action.sa_mask); + action.sa_flags = 0; + action.sa_handler = winch_handler; + the_driver = a; + a->auto_width = true; + a->auto_length = true; + sigaction (SIGWINCH, &action, NULL); + } +#endif if (a->init != NULL) fputs (a->init, a->file); } @@ -875,7 +901,7 @@ static void output_title_line (FILE *out, int width, const char *left, const char *right) { struct string s = DS_EMPTY_INITIALIZER; - ds_put_char_multiple (&s, ' ', width); + ds_put_byte_multiple (&s, ' ', width); if (left != NULL) { size_t length = MIN (strlen (left), width); @@ -886,7 +912,7 @@ output_title_line (FILE *out, int width, const char *left, const char *right) size_t length = MIN (strlen (right), width); memcpy (ds_end (&s) - length, right, length); } - ds_put_char (&s, '\n'); + ds_put_byte (&s, '\n'); fputs (ds_cstr (&s), out); ds_destroy (&s); }