Re: [dev] [st] possibly redundant check in techo

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu, 14 Aug 2014 23:55:39 +0200

On Thu, Aug 14, 2014 at 04:38:24PM -0500, Steven Degutis wrote:
> Convenience link to the line: http://git.suckless.org/st/tree/st.c#n2315
>
> Here, techo is calling ISCONTROL(c) where c is a 'char'. But
> ISCONTROLC1 is always going to return false for a char.

This is not true, char can be signed or unsigned, it is
implementation defined.

> Perhaps it should test against ISCONTROLC0 instead? Or is this line
> intended to use ISCONTROL for some reason?

No, it must check that the character written is a control code,
and it means check if the code is a C0 or C1 code.

> For the record, I came across this while porting st to OS X using
> native APIs (NSWindow, NSView, CoreText, etc).

What processador do you use in your port? intel or ibm?

There was a discussion in this list sometime ago about this
topic, and I think this was the best solution (if someone can
find the messages ...), but I agree that if char is signed then
we have a problem. It is clear that c must be char, because
tputc expects a char pointer and buf is also a char pointer.

Maybe we should change the line to:

                if(ISCONTROL((uchar) c)) { /* control code */

Regards,


-- 
Roberto E. Vargas Caballero
Received on Thu Aug 14 2014 - 23:55:39 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 15 2014 - 00:00:21 CEST