"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: tog: fix display of lines ending in \r\n
To:
gameoftrees@openbsd.org
Date:
Thu, 10 Dec 2020 21:30:39 +0100

Download raw body.

Thread
Stefan Sperling:

> The "problem" is that this log message contains \r\n line endings.
> Quick and simple fix below. OK?
> 
> diff 9a2d6ca19c544d6f55347ccb18c566434f6f8d4c ac7edcfb7479cb3379bc90df5540e8d9565ea7bf
> blob - 457fcc6885530f6eb53c478998fd277562f91f45
> blob + ee044a71602208bed395a517f0354d580be3407f
> --- tog/tog.c
> +++ tog/tog.c
> @@ -1164,6 +1164,15 @@ format_line(wchar_t **wlinep, int *widthp, const char 
>  	if (err)
>  		return err;
>  
> +	if (wlen > 0 && wline[wlen - 1] == L'\n') {
> +		wline[wlen - 1] = L'\0';
> +		wlen--;
> +	}

Where would trailing newlines come from?
Not from a log message, since fparseln will split them up.

> +	if (wlen > 0 && wline[wlen - 1] == L'\r') {
> +		wline[wlen - 1] = L'\0';
> +		wlen--;
> +	}
> +

That makes sense, I guess.

It made me curious how got & tog deal with terminal control sequences
in commit messages and blobs.
* got log just passes them through to the terminal--as does git.
* tog escapes them (where??), but gets confused about the line length.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de