Re: BUG #1671: Long interval string representation rejected - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1671: Long interval string representation rejected
Date
Msg-id 20383.1116944094@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #1671: Long interval string representation rejected  (Neil Conway <neilc@samurai.com>)
Responses Re: BUG #1671: Long interval string representation rejected  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #1671: Long interval string representation rejected  (Neil Conway <neilc@samurai.com>)
List pgsql-bugs
Neil Conway <neilc@samurai.com> writes:
> Attached is a patch that implements this. I'm not especially happy about
> the implementation: defining _two_ local macros (that both
> doubly-evaluate one of their arguments) is pretty ugly, but I didn't see
> a cleaner alternative -- suggestions welcome.

Considering that you're incrementing bufptr inside the macro, it hardly
seems that double-evaluation is a problem: the argument pretty much has
to be a variable.  OTOH there is no reason for the input argument to be
treated that way.  I'd suggest just one macro

#define APPEND_CHAR(bufptr, end, newchar) \
    do \
    { \
        if (((bufptr) + 1) >= (end)) \
            return DTERR_BAD_FORMAT; \
        *(bufptr)++ = (newchar); \
    } while (0);

used as

    APPEND_CHAR(bufp, bufend, *cp++);
    APPEND_CHAR(bufp, bufend, pg_tolower((unsigned char) *cp++));

respectively.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Goar, Saul"
Date:
Subject: Bulletin Board
Next
From: "Haluk GUNCER"
Date:
Subject: BUG #1678: pw_shadow BUS ERROR