Comment 1 for bug 2004463

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote (last edit ):

The reason is in iocsh.cpp line 363:
        if (quote != EOF) {

Here, quote is 0xff but EOF is -1.

quote is initialized in line 265:
        char quote = EOF;

The problem is the usage of EOF in function split().

On any architecture, where char is unsigned (e.g. VxWorks on PPC), the initialization
        char quote = EOF;
sets quote to (char)-1 = 255.

Later, the comparison (quote != EOF) compares an unsigned char with the signed int literal -1. Thus the unsigned char gets promoted to a signed int with the same value 255 which is then then compared to -1. That is of course not equal.

The possible fixes are:
1. use signed char quote
2. use int quote
3. use 0 instead of EOF

I prefer solution 3. The attached patch has been created with commit 60128ee but can be applied to the current HEAD (bc54524) as well.