On Thu, 30 Sep 2021 22:15:39 +0200, Christian Weisgerber wrote:

> E.g. like this?

Yes, that looks correct.

However, this is a bit ugly:

        if (pushback_index < MAXPUSHBACK-1)
                return (unsigned char)(pushback_buffer[pushback_index++] = c);
        else
                return (EOF);

Maybe it would be clearer to do:

        if (pushback_index < MAXPUSHBACK-1) {
                pushback_buffer[pushback_index++] = c;
                return (c);
        }
        return (EOF);

There's no need for an else clause.  You could even turn it around like:

        if (pushback_index + 1 >= MAXPUSHBACK)
                return (EOF);
        pushback_buffer[pushback_index++] = c;
        return (c);

 - todd

Reply via email to