[Toybox] [CLEANUP][watch.c]
Rob Landley
rob at landley.net
Tue Aug 21 15:17:12 PDT 2018
On 08/20/2018 02:43 PM, enh wrote:
> (less importantly, i wondered if the \e escapes in interestingtimes.c are your
> plan for the future and will replace \033, or should be \e for consistency.
> personally, i find \e less unreadable -- i even prefer \x1b to \033 -- but \e is
> not actually in the standard.)
\e is a gcc extension, but I try not to rely on those (same reason I've avoided
"a ?: b" despite it being REALLY CONVENIENT).
I've mostly been using \033 but it's disgusting (octal's a relic of the PDP 7
being a 6 bit machine), and \x1b isn't more intelligible. (Why doesn't C have a
decimal escape?)
I did tty_esc() in hopes of avoiding this entirely, but real world usage hasn't
shown it to be a net positive (batches of multiple escapes are smaller as a
single printf), and I may go back and rip it out again. :(
Looks like I'm only using it in two files, and "clear" doing an xwrite() with a
fixed size for the string is annoying (back when I was still micro-optimizing
for size, so a standalone build of "clear" doesn't pull in printf. I probably
don't care about that these days, it's a libc issue.)
Technically this doesn't need the x version because when you xexit() or return
from command_main() the cleanup code does the flush and ferror() check for every
command. (I should add that to the toybox walkthrough video script I keep
meaning to do...)
Rob
More information about the Toybox
mailing list