On Tue, Feb 7, 2023 at 2:39 PM Hiltjo Posthuma <hil...@codemadness.org> wrote: > > On Tue, Feb 07, 2023 at 11:20:36AM -0500, Adam Price wrote: > > On Tue, Feb 7, 2023 at 11:17 AM Roberto E. Vargas Caballero > > <k...@shike2.com> wrote: > > > > > > On Tue, Feb 07, 2023 at 10:54:57AM -0500, Adam Price wrote: > > > > On Mon, Feb 6, 2023 at 12:06 PM Roberto E. Vargas Caballero > > > > <k...@shike2.com> wrote: > > > > > > > > > > Hi, > > > > > > > > > > On Mon, Feb 06, 2023 at 08:45:27AM +0200, Santtu Lakkala wrote: > > > > > > > tsetattr(csiescseq.arg, csiescseq.narg); > > > > > > > break; > > > > > > > - case 'n': /* DSR – Device Status Report (cursor position) */ > > > > > > > - if (csiescseq.arg[0] == 6) { > > > > > > > + case 'n': /* DSR – Device Status Report */ > > > > > > > + switch (csiescseq.arg[0]) { > > > > > > > + case 5: /* Status Report "OK" `0n` */ > > > > > > > + ttywrite("\033[0n", sizeof("\033[0n"), 0); > > > > > > > > > > > > This will write a NUL byte to the tty, which doesn't seem > > > > > > intentional. > > > > > > > > > > Indeed, but it should not have any difference because '\0' is a > > > > > control > > > > > character that in this situation is ignored by the terminal. Anyway it > > > > > should be avoided. > > > > > > > > Ah right, of course. Thank you to you two for pointing that out. I > > > > should use > > > > strlen() instead of sizeof(). > > > > > > > > I will send an updated patch here shortly. > > > > > > > > > > No, sizeof()-1. There is no reason to call strlen when you know the size. > > > > In this particular case, strlen() and sizeof() - 1 give the same result, no? > > > > In a nutshell (discarding more pedantics :)): > > strlen() is done at run-time, it counts until a NUL byte. > sizeof() is done at compile time and counts the size of the data structure. > > Otherwise the result is the same here. > strlen() would most probably be optimized by the modern compiler too. > > I agree with Roberto that the best code pattern in this case is using > sizeof()-1. > > I hope this helps, > > -- > Kind regards, > Hiltjo >
It does. I appreciate the help and the explanation.