# Files that most or all ecpg preprocessor test outputs depend on
ECPG_TEST_DEPENDENCIES = ../../preproc/ecpg$(X) \
$(srcdir)/../regression.h \
+ $(srcdir)/../printf_hack.h \
$(srcdir)/../../include/sqlca.h \
$(srcdir)/../../include/sqlda.h \
$(srcdir)/../../include/sqltypes.h \
exec sql include ../regression;
-
-/*
-
-NOTE: This file has a different expect file for regression tests on MinGW32
-
-*/
-
-
+exec sql include ../printf_hack;
/*
/* this is a libc problem since we only call strtod() */
r = dectodbl(dec, &dbl);
if (r) check_errno();
- printf("dec[%d,10]: %g (r: %d)\n", i, r?0.0:dbl, r);
+ printf("dec[%d,10]: ", i);
+ print_double(r ? 0.0 : dbl);
+ printf(" (r: %d)\n", r);
}
PGTYPESdecimal_free(din);
+#line 1 "printf_hack.h"
/*
+ * 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;
-NOTE: This file has a different expect file for regression tests on MinGW32
+ 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
+}
+#line 10 "dec_test.pgc"
/* this is a libc problem since we only call strtod() */
r = dectodbl(dec, &dbl);
if (r) check_errno();
- printf("dec[%d,10]: %g (r: %d)\n", i, r?0.0:dbl, r);
+ printf("dec[%d,10]: ", i);
+ print_double(r ? 0.0 : dbl);
+ printf(" (r: %d)\n", r);
}
PGTYPESdecimal_free(din);
+#line 1 "printf_hack.h"
/*
+ * 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
+}
-NOTE: This file has a different expect file for regression tests on MinGW32
+#line 8 "num_test.pgc"
-*/
int
/* = {0, 0, 0, 0, 0, NULL, NULL} ; */
-#line 22 "num_test.pgc"
+#line 17 "num_test.pgc"
numeric * des ;
/* exec sql end declare section */
-#line 24 "num_test.pgc"
+#line 19 "num_test.pgc"
double d;
long l1, l2;
ECPGdebug(1, stderr);
/* exec sql whenever sqlerror do sqlprint ( ) ; */
-#line 30 "num_test.pgc"
+#line 25 "num_test.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
-#line 32 "num_test.pgc"
+#line 27 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 32 "num_test.pgc"
+#line 27 "num_test.pgc"
{ ECPGsetcommit(__LINE__, "off", NULL);
-#line 34 "num_test.pgc"
+#line 29 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 34 "num_test.pgc"
+#line 29 "num_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) )", ECPGt_EOIT, ECPGt_EORT);
-#line 35 "num_test.pgc"
+#line 30 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 35 "num_test.pgc"
+#line 30 "num_test.pgc"
value1 = PGTYPESnumeric_new();
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( text , num ) values ( 'test' , $1 )",
ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 60 "num_test.pgc"
+#line 55 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 60 "num_test.pgc"
+#line 55 "num_test.pgc"
value2 = PGTYPESnumeric_from_asc("2369.7", NULL);
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select num from test where text = 'test'", ECPGt_EOIT,
ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 66 "num_test.pgc"
+#line 61 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 66 "num_test.pgc"
+#line 61 "num_test.pgc"
PGTYPESnumeric_mul(res, des, res);
PGTYPESnumeric_div(res, value2, res);
text = PGTYPESnumeric_to_asc(res, -1);
PGTYPESnumeric_to_double(res, &d);
- printf("div = %s %e\n", text, d);
+ printf("div = %s ", text);
+ print_double(d);
+ printf("\n");
PGTYPESnumeric_free(value1);
PGTYPESnumeric_free(value2);
PGTYPESnumeric_free(res);
{ ECPGtrans(__LINE__, NULL, "rollback");
-#line 93 "num_test.pgc"
+#line 90 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 93 "num_test.pgc"
+#line 90 "num_test.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 94 "num_test.pgc"
+#line 91 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 94 "num_test.pgc"
+#line 91 "num_test.pgc"
return 0;
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGsetcommit on line 34: action "off"; connection "ecpg1_regression"
+[NO_PID]: ECPGsetcommit on line 29: action "off"; connection "ecpg1_regression"
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 35: query: create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 30: query: create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ); with 0 parameter(s) on connection ecpg1_regression
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 35: using PQexec
+[NO_PID]: ecpg_execute on line 30: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 35: OK: CREATE TABLE
+[NO_PID]: ecpg_process_output on line 30: OK: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 60: query: insert into test ( text , num ) values ( 'test' , $1 ); with 1 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 55: query: insert into test ( text , num ) values ( 'test' , $1 ); with 1 parameter(s) on connection ecpg1_regression
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 60: using PQexecParams
+[NO_PID]: ecpg_execute on line 55: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_free_params on line 60: parameter 1 = 2369.7
+[NO_PID]: ecpg_free_params on line 55: parameter 1 = 2369.7
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 60: OK: INSERT 0 1
+[NO_PID]: ecpg_process_output on line 55: OK: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 66: query: select num from test where text = 'test'; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: ecpg_execute on line 61: query: select num from test where text = 'test'; with 0 parameter(s) on connection ecpg1_regression
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 66: using PQexec
+[NO_PID]: ecpg_execute on line 61: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 66: correctly got 1 tuples with 1 fields
+[NO_PID]: ecpg_process_output on line 61: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 66: RESULT: 2369.7000000 offset: -1; array: no
+[NO_PID]: ecpg_get_data on line 61: RESULT: 2369.7000000 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans on line 93: action "rollback"; connection "ecpg1_regression"
+[NO_PID]: ECPGtrans on line 90: action "rollback"; connection "ecpg1_regression"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection ecpg1_regression closed
[NO_PID]: sqlca: code: 0, state: 00000
add = 2379.7
sub = 2369.7
mul = 13306998429.873000000
-div = 1330699.84298730000 1.330700e+06
+div = 1330699.84298730000 1.3307e+06
to long(0) = 20000000 14
+#line 1 "printf_hack.h"
/*
+ * 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
+}
-NOTE: This file has a different expect file for regression tests on MinGW32
+#line 9 "num_test2.pgc"
-*/
char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
r = PGTYPESnumeric_to_double(num, &d);
if (r) check_errno();
- printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
+ printf("num[%d,10]: ", i);
+ print_double(r ? 0.0 : d);
+ printf(" (r: %d)\n", r);
}
/* do not test double to numeric because
exec sql include ../regression;
-
-/*
-
-NOTE: This file has a different expect file for regression tests on MinGW32
-
-*/
+exec sql include ../printf_hack;
int
PGTYPESnumeric_div(res, value2, res);
text = PGTYPESnumeric_to_asc(res, -1);
PGTYPESnumeric_to_double(res, &d);
- printf("div = %s %e\n", text, d);
+ printf("div = %s ", text);
+ print_double(d);
+ printf("\n");
PGTYPESnumeric_free(value1);
PGTYPESnumeric_free(value2);
exec sql include ../regression;
-
-/*
-
-NOTE: This file has a different expect file for regression tests on MinGW32
-
-*/
+exec sql include ../printf_hack;
char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
r = PGTYPESnumeric_to_double(num, &d);
if (r) check_errno();
- printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
+ printf("num[%d,10]: ", i);
+ print_double(r ? 0.0 : d);
+ printf(" (r: %d)\n", r);
}
/* do not test double to numeric because
--- /dev/null
+/*
+ * 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
+}