Re: [PATCH v2 3/4] sideband: append suffix for message whose CR in next pktline
- From
Nicolas Pitre <nico@fluxnic.net>
- Date
- Jun 15, 2021, 03:26 UTC
- Message-ID
- <r8ss67nn-31s4-o429-828p-s787sr2481@syhkavp.arg>
- In-Reply-To
- <CANYiYbFsqj9j_UT9-mF+BSOAHU4=On+BUxCU4w6rXhhMaeo=zg@mail.gmail.com>
On Tue, 15 Jun 2021, Jiang Xin wrote:
Show 7 quoted lines
> The issue this patch try to fix is like the following example: > > PKTLINE(\2 "<progress-1>" CR "<progress-2>") > PKTLINE(\2 CR "<message-3>" LF) > > The message "<progress-2>" is displayed without a proper clear-to-eol > suffix, because it's eol (CR) is in another pktline.
I'd fix this issue with the following logic:
bool pending_clear_to_eol;
my_putchar(c) {
switch (c) {
case '\r':
case '\n':
pending_clear_to_eol = true;
break;
default:
if (pending_clear_to_eol) {
clear_to_eol();
pending_clear_to_eol = false;
}
break;
}
putchar(c);
}In other words, you clear the line after printing "remote:" but only if there is a non \n or \r coming next.
Nicolas