summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2005-05-27 15:15:31 +0000
committerBruce Momjian2005-05-27 15:15:31 +0000
commit0c081eda743f2ce0185275381b89745cb75e1d99 (patch)
tree87c1f696ac4891ea82cc568622fc07889ff88763
parent8d6b8c0119ae144c0c9090d67125bc03925a14ee (diff)
Fix compile of entab to use stdarg.h. Clean up includes.
Marko Kreen
-rw-r--r--src/backend/utils/adt/datetime.c9
-rw-r--r--src/interfaces/ecpg/pgtypeslib/interval.c2
-rw-r--r--src/test/regress/expected/horology.out40
-rw-r--r--src/tools/entab/entab.c11
-rw-r--r--src/tools/entab/halt.c8
5 files changed, 34 insertions, 36 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 6028d0d487..be473b316f 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -3461,12 +3461,9 @@ EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str)
#ifdef HAVE_INT64_TIMESTAMP
sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec);
#else
- sprintf(str + strlen(str), ":%013.10f", tm->tm_sec + fsec);
+ sprintf(str + strlen(str), ":%012.9f", tm->tm_sec + fsec);
#endif
- /* chop off trailing pairs of zeros... */
- while (strcmp((str + strlen(str) - 2), "00") == 0 &&
- *(str + strlen(str) - 3) != '.')
- *(str + strlen(str) - 2) = '\0';
+ TrimTrailingZeros(str);
}
else
sprintf(str + strlen(str), ":%02d", tm->tm_sec);
@@ -3804,7 +3801,7 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
sprintf(cp, ".%06d", Abs(fsec));
#else
fsec += tm->tm_sec;
- sprintf(cp, ":%013.10f", fabs(fsec));
+ sprintf(cp, ":%012.9f", fabs(fsec));
#endif
TrimTrailingZeros(cp);
cp += strlen(cp);
diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c
index f5b2b2573f..a5e9673b10 100644
--- a/src/interfaces/ecpg/pgtypeslib/interval.c
+++ b/src/interfaces/ecpg/pgtypeslib/interval.c
@@ -511,7 +511,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
sprintf(cp, ".%06d", Abs(fsec));
#else
fsec += tm->tm_sec;
- sprintf(cp, ":%013.10f", fabs(fsec));
+ sprintf(cp, ":%012.9f", fabs(fsec));
#endif
TrimTrailingZeros(cp);
cp += strlen(cp);
diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out
index ca8bc3d0e5..c0a7f6e5b8 100644
--- a/src/test/regress/expected/horology.out
+++ b/src/test/regress/expected/horology.out
@@ -205,62 +205,62 @@ SET DateStyle = 'ISO';
-- As of 7.4, allow time without time zone having a time zone specified
SELECT time without time zone '040506.789+08';
time
----------------
- 04:05:06.7890
+--------------
+ 04:05:06.789
(1 row)
SELECT time without time zone '040506.789-08';
time
----------------
- 04:05:06.7890
+--------------
+ 04:05:06.789
(1 row)
SELECT time without time zone 'T040506.789+08';
time
----------------
- 04:05:06.7890
+--------------
+ 04:05:06.789
(1 row)
SELECT time without time zone 'T040506.789-08';
time
----------------
- 04:05:06.7890
+--------------
+ 04:05:06.789
(1 row)
SELECT time with time zone '040506.789+08';
timetz
-------------------
- 04:05:06.7890+08
+-----------------
+ 04:05:06.789+08
(1 row)
SELECT time with time zone '040506.789-08';
timetz
-------------------
- 04:05:06.7890-08
+-----------------
+ 04:05:06.789-08
(1 row)
SELECT time with time zone 'T040506.789+08';
timetz
-------------------
- 04:05:06.7890+08
+-----------------
+ 04:05:06.789+08
(1 row)
SELECT time with time zone 'T040506.789-08';
timetz
-------------------
- 04:05:06.7890-08
+-----------------
+ 04:05:06.789-08
(1 row)
SELECT time with time zone 'T040506.789 +08';
timetz
-------------------
- 04:05:06.7890+08
+-----------------
+ 04:05:06.789+08
(1 row)
SELECT time with time zone 'T040506.789 -08';
timetz
-------------------
- 04:05:06.7890-08
+-----------------
+ 04:05:06.789-08
(1 row)
SET DateStyle = 'Postgres, MDY';
diff --git a/src/tools/entab/entab.c b/src/tools/entab/entab.c
index 7f8e40f705..2e91bdb488 100644
--- a/src/tools/entab/entab.c
+++ b/src/tools/entab/entab.c
@@ -11,8 +11,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
-#include "../../include/c.h"
+#if defined(WIN32) || defined(__CYGWIN__)
+#define PG_BINARY_R "rb"
+#else
+#define PG_BINARY_R "r"
+#endif
#define NUL '\0'
@@ -29,9 +34,7 @@ extern char *optarg;
extern int optind;
int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
int tab_size = 8,
min_spaces = 2,
diff --git a/src/tools/entab/halt.c b/src/tools/entab/halt.c
index d204d28678..dda2f23791 100644
--- a/src/tools/entab/halt.c
+++ b/src/tools/entab/halt.c
@@ -19,15 +19,13 @@
/*VARARGS*/
void
-halt(const char *path, ...)
+halt(const char *format, ...)
{
va_list arg_ptr;
- char *format,
- *pstr;
+ const char *pstr;
void (*sig_func) ();
- va_start(arg_ptr, path);
- format = va_arg(arg_ptr, char *);
+ va_start(arg_ptr, format);
if (strncmp(format, "PERROR", 6) != 0)
vfprintf(stderr, format, arg_ptr);
else