1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-03 09:13:20 +03:00
Files
postgres/src/interfaces/ecpg/test/printf_hack.h
Tom Lane 10a53cae99 Un-break ecpg tests for Windows.
Declaring a function "inline" still doesn't work with Windows compilers
(C99? what's that?), unless the macro provided by pg_config.h is
in-scope, which it is not in our ECPG test programs.  So the workaround
I tried to use in commit 7640f9312 doesn't work for Windows.  Revert
the change in printf_hack.h, and instead just blacklist that file
in cpluspluscheck --- since it's a not-installed test file, we don't
really need to verify its C++ cleanliness anyway.
2019-06-02 11:07:54 -04:00

30 lines
617 B
C

/*
* print_double(x) has the same effect as printf("%g", x), but is intended
* to produce the same formatting across all platforms.
*/
static void
print_double(double x)
{
#ifdef WIN32
/* Change Windows' 3-digit exponents to look like everyone else's */
char convert[128];
int vallen;
sprintf(convert, "%g", x);
vallen = strlen(convert);
if (vallen >= 6 &&
convert[vallen - 5] == 'e' &&
convert[vallen - 3] == '0')
{
convert[vallen - 3] = convert[vallen - 2];
convert[vallen - 2] = convert[vallen - 1];
convert[vallen - 1] = '\0';
}
printf("%s", convert);
#else
printf("%g", x);
#endif
}