Re: pgsql: to_char(): have format 'OF' only show the leading negative sign

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
Date: 2015-04-29 21:04:04
Message-ID: 20150429210404.GO31727@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Wed, Apr 29, 2015 at 10:11:02AM -0400, Stephen Frost wrote:
> Bruce,
>
> * Bruce Momjian (bruce(at)momjian(dot)us) wrote:
> > to_char(): have format 'OF' only show the leading negative sign
> >
> > Previously both hours and minutes displayed as negative.
> >
> > Report by David Pozsar
>
> This is causing the following error for me:
>
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c: In function ‘DCH_to_char’:
> /home/sfrost/git/pg/dev/postgresql/src/backend/utils/adt/formatting.c:2510:6: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
> sprintf(s, ":%02ld", abs(tm->tm_gmtoff % SECS_PER_HOUR) / SECS_PER_MINUTE);
> ^
>
> Since abs() is declared to return just an int. I don't see it anywhere
> in our tree and I'm not sure how portable it actually is, but labs() is
> supposedly in C89, so perhaps that should be used here instead?

OK, I have switched to labs() and will keep an eye on the buildfarm;
patch attached. (There is already an uncomfortable amount of red
there.)

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
to_char.diff text/x-diff 713 bytes

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2015-04-29 21:05:24 Re: Re: pgsql: to_char(): have format 'OF' only show the leading negative sign
Previous Message Robert Haas 2015-04-29 19:53:28 pgsql: Update .gitignore for new rmgr, changed paths.