From: Bruno Haible Date: Wed, 27 Mar 2019 20:38:14 +0000 (+0100) Subject: libtextstyle: Make the SIGCONT handler work more reliably. X-Git-Tag: v0.20~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b25d79f323d1e5c6cfe51922acb76e82e6a5e737;p=thirdparty%2Fgettext.git libtextstyle: Make the SIGCONT handler work more reliably. * gnulib-local/lib/term-ostream.oo.c (out_attr_change): Modify active_attr before emitting the escape sequences, not afterwards. * libtextstyle/NEWS: Mention the fix. --- diff --git a/gnulib-local/lib/term-ostream.oo.c b/gnulib-local/lib/term-ostream.oo.c index 3e8700d06..4e2d184e6 100644 --- a/gnulib-local/lib/term-ostream.oo.c +++ b/gnulib-local/lib/term-ostream.oo.c @@ -1339,6 +1339,11 @@ out_attr_change (term_ostream_t stream, attributes_t new_attr) attributes_t old_attr = stream->active_attr; bool cleared_attributes; + /* Keep track of the active attributes. Do this *before* emitting the + escape sequences, otherwise async_set_attributes_from_default will not + do its job correctly. */ + stream->active_attr = new_attr; + /* For out_char to work. */ out_stream = stream; out_fd = stream->fd; @@ -1438,9 +1443,6 @@ out_attr_change (term_ostream_t stream, attributes_t new_attr) { out_underline_change (stream, new_attr.underline, false); } - - /* Keep track of the active attributes. */ - stream->active_attr = new_attr; } static void diff --git a/libtextstyle/NEWS b/libtextstyle/NEWS index dae693e65..43e702115 100644 --- a/libtextstyle/NEWS +++ b/libtextstyle/NEWS @@ -2,6 +2,8 @@ New in 0.8: * Fixed a couple of reliability bugs: - When a program exits while the terminal was in non-default state, the library left the terminal with ECHO off. + - The SIGCONT signal handler would fail to restore the proper styling, + with a low probability. - The SIGTSTP and SIGCONT signal handlers could clobber errno. New in 0.7: