Author: sebor
Date: Mon Feb 6 14:21:40 2006
New Revision: 375398
URL: http://svn.apache.org/viewcvs?rev=375398&view=rev
Log:
2006-02-06 Martin Sebor <[EMAIL PROTECTED]>
* include/printf.h: Renamed...
* include/rw_printf.h: ...to this.
* src/alg_test.cpp (<rw_printf.h>): Included instead of <printf.h>.
* containers/23.deque.modifiers.cpp: Same.
* src/any.cpp: Same.
* strings/21.cwchar.cpp: Same.
* self/0.printf.cpp: Same.
* src/printf.cpp: Same.
(_rw_fmtlong, _rw_fmtllong): Used _RWSTD_INTERNAL to conditionally
declared the helper functions to have internal linkage in order to
work around a Sun C++ bug.
* src/system.cpp (<rw_printf.h>): Included instead of <printf.h>.
(_rw_vsystem): Avoided declaring const a variable used as an argument
to the WIFXXX() macros in order to prevent bogus gcc warning on Linux:
cast from `const int*' to `int*' discards qualifiers from pointer
target type: see http://sourceware.org/bugzilla/show_bug.cgi?id=1392
* src/driver.cpp (<rw_printf.h>): Included instead of <printf.h>.
Used rw_fprintf(rw_stderr) instead of fprintf to make sure all output
is flushed even when the program abends.
Added:
incubator/stdcxx/trunk/tests/include/rw_printf.h
- copied unchanged from r368440,
incubator/stdcxx/trunk/tests/include/printf.h
Removed:
incubator/stdcxx/trunk/tests/include/printf.h
Modified:
incubator/stdcxx/trunk/tests/containers/23.deque.modifiers.cpp
incubator/stdcxx/trunk/tests/self/0.printf.cpp
incubator/stdcxx/trunk/tests/src/alg_test.cpp
incubator/stdcxx/trunk/tests/src/any.cpp
incubator/stdcxx/trunk/tests/src/driver.cpp
incubator/stdcxx/trunk/tests/src/printf.cpp
incubator/stdcxx/trunk/tests/src/system.cpp
incubator/stdcxx/trunk/tests/strings/21.cwchar.cpp
Modified: incubator/stdcxx/trunk/tests/containers/23.deque.modifiers.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/containers/23.deque.modifiers.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/containers/23.deque.modifiers.cpp (original)
+++ incubator/stdcxx/trunk/tests/containers/23.deque.modifiers.cpp Mon Feb 6
14:21:40 2006
@@ -41,7 +41,7 @@
#include <alg_test.h> // for X
#include <driver.h> // for rw_test(), ...
-#include <snprintfa.h> // for rw_asnprintf
+#include <rw_printf.h> // for rw_asnprintf
/**************************************************************************/
Modified: incubator/stdcxx/trunk/tests/self/0.printf.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/self/0.printf.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/self/0.printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/self/0.printf.cpp Mon Feb 6 14:21:40 2006
@@ -1,6 +1,6 @@
/************************************************************************
*
- * 0.printf.cpp - test exercising the rw_printf family of functions
+ * 0.printf.cpp - test exercising the rw_snprintfa() utility functions
*
* $Id$
*
@@ -19,7 +19,7 @@
*
**************************************************************************/
-#include <printf.h>
+#include <rw_printf.h>
#include <ctype.h> // for isdigit()
#include <errno.h> // for EXXX, errno
Modified: incubator/stdcxx/trunk/tests/src/alg_test.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/alg_test.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/alg_test.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/alg_test.cpp Mon Feb 6 14:21:40 2006
@@ -27,8 +27,9 @@
#include <stdlib.h> // for rand(), strtol()
#include <string.h> // for size_t, strlen()
+
#include <alg_test.h>
-#include <printf.h> // for rw_asnprintf()
+#include <rw_printf.h>
/* static */ size_t X::count_;
Modified: incubator/stdcxx/trunk/tests/src/any.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/any.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/any.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/any.cpp Mon Feb 6 14:21:40 2006
@@ -24,7 +24,7 @@
#include <any.h>
-#include <printf.h> // for rw_sprintfa()
+#include <rw_printf.h> // for rw_sprintfa()
#include <stdlib.h> // for free()
#include <string.h> // for memset()
Modified: incubator/stdcxx/trunk/tests/src/driver.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/driver.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/driver.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/driver.cpp Mon Feb 6 14:21:40 2006
@@ -16,7 +16,7 @@
* CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under
* the License.
- *
+ *
**************************************************************************/
// expand _TEST_EXPORT macros
@@ -28,12 +28,12 @@
#include "opt_types.h"
#include <cmdopt.h> // for rw_setopts()
-#include <printf.h> // for rw_snprintfa()
+#include <rw_printf.h> // for rw_snprintfa()
#include <assert.h> // for assert
#include <setjmp.h> // for longjmp, setjmp, ...
#include <stdarg.h> // for va_list
-#include <stdio.h> // for fileno, fprintf
+#include <stdio.h> // for fileno
#include <stdlib.h> // for free
#include <string.h> // for strchr, strcpy
@@ -47,7 +47,7 @@
} // extern "C"
-#else
+#else // if Windows
// no isatty on Windoze
# define _RWSTD_NO_ISATTY
#endif // _WIN{32,64}
@@ -315,15 +315,21 @@
static int
ndiags [N_DIAG_TYPES][2] /* = { { total, active }, ... }*/;
-static FILE *ftestout;
+static rw_file *_rw_ftestout = rw_stdout;
static jmp_buf test_env;
+#ifdef _RWSTD_USE_CONFIG
// set to 1 after the driver has been initialized
-static int driver_initialized = 0;
+static int _rw_driver_init = 0;
+#else // if !defined (_RWSTD_USE_CONFIG)
+// FIXME: remove this as soon as all tests have been ported
+// from RWTest to this driver
+_TEST_EXPORT int _rw_driver_init = 0;
+#endif // _RWSTD_USE_CONFIG
// set to 1 after the driver has finished running
-static int driver_finished = 0;
+static int _rw_driver_done = 0;
#if 0 // disabled
// %S: severity
@@ -350,23 +356,32 @@
#define CHECK_INIT(init, func) _rw_check_init (init, __LINE__, func)
static inline void
-_rw_check_init (bool init, int line, const char *func)
+_rw_check_init (int expect_init, int line, const char *func)
{
- if (init && !driver_initialized) {
- fprintf (stderr, "%s:%d: %s: test driver already initialized\n",
- __FILE__, line, func);
- abort ();
+ if (expect_init) {
+ // driver is expected to be initialized
+ if (!_rw_driver_init) {
+ rw_fprintf (rw_stderr,
+ "%s:%d: %s: test driver not initialized yet\n",
+ __FILE__, line, func);
+
+ abort ();
+ }
}
+ else if (_rw_driver_init) {
+ // driver is NOT expected to be initialized
+ rw_fprintf (rw_stderr,
+ "%s:%d: %s: test driver already initialized\n",
+ __FILE__, line, func);
- if (!init && driver_initialized) {
- fprintf (stderr, "%s:%d: %s: test driver not initialized yet\n",
- __FILE__, line, func);
abort ();
}
- if (driver_finished) {
- fprintf (stderr, "%s:%d: %s: test finished, cannot call\n",
- __FILE__, line, func);
+ if (_rw_driver_done) {
+ // driver is NOT expected to be done at this point
+ rw_fprintf (rw_stderr,
+ "%s:%d: %s: test finished, cannot call\n",
+ __FILE__, line, func);
}
}
@@ -580,15 +595,15 @@
FILE* const f = fopen (file_name, "w");
if (f) {
- if (ftestout && ftestout != stderr)
- fclose (ftestout);
+ if (_rw_ftestout && _rw_ftestout != rw_stdout)
+ fclose ((FILE*)(void*)_rw_ftestout);
- ftestout = f;
+ _rw_ftestout = (rw_file*)(void*)f;
}
}
// return 0 on success, any non-zero value on failure
- return !(ftestout != 0);
+ return !(_rw_ftestout != 0);
}
/************************************************************************/
@@ -605,7 +620,8 @@
// is output sent to a terminal?
// if so, assume a vt100 compatible terminal for now
- static const int tty = isatty (fileno (ftestout));
+ static const int tty = _rw_ftestout ?
+ isatty (fileno ((FILE*)(void*)_rw_ftestout)) : 0;
#else // if defined (_RWSTD_NO_ISATTY)
@@ -630,10 +646,11 @@
{
CHECK_INIT (false, "rw_vtest()");
- driver_initialized = 1;
+ _rw_driver_init = 1;
if (optstr && 0 > rw_vsetopts (optstr, va)) {
- fprintf (stderr, "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
+ rw_fprintf (rw_stderr,
+ "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
return 1;
}
@@ -661,7 +678,8 @@
0);
if (3 > nopts) {
- fprintf (stderr, "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
+ rw_fprintf (rw_stderr,
+ "%s:%d: rw_setopts() failed\n", __FILE__, __LINE__);
abort ();
return 1;
}
@@ -685,7 +703,7 @@
if (status)
return status;
- if (0 == ftestout) {
+ if (rw_stdout == _rw_ftestout) {
if (_rw_opt_no_stdout (0, 0) && file_name) {
char fname [256];
@@ -699,10 +717,10 @@
else
strcat (fname, ".out");
- ftestout = fopen (fname, "w");
+ _rw_ftestout = (rw_file*)(void*)fopen (fname, "w");
}
else
- ftestout = stdout;
+ _rw_ftestout = rw_stdout;
}
if (clause)
@@ -737,16 +755,16 @@
// fatal test error (via a call to rw_fatal())
}
- driver_finished = 1;
+ _rw_driver_done = 1;
static const char tblrow[] =
"+-----------------------+--------+--------+--------+";
- fprintf (ftestout,
- "# %s\n"
- "# | DIAGNOSTIC | ACTIVE | TOTAL |INACTIVE|\n"
- "# %s\n",
- tblrow, tblrow);
+ rw_fprintf (_rw_ftestout,
+ "# %s\n"
+ "# | DIAGNOSTIC | ACTIVE | TOTAL |INACTIVE|\n"
+ "# %s\n",
+ tblrow, tblrow);
int nlines = 0;
@@ -774,17 +792,18 @@
sfx = ndiags [i][1] ? diag_msgs [i].esc_sfx : "";
}
- fprintf (ftestout,
- "# | (S%d) %-*s |%s %6d %s| %6d | %5ld%% |\n",
- i, int (sizeof diag_msgs [i].code), diag_msgs [i].code,
- pfx, ndiags [i][1], sfx, ndiags [i][0], pct);
+ rw_fprintf (_rw_ftestout,
+ "# | (S%d) %-*s |%s %6d %s| %6d | %5ld%% |\n",
+ i, int (sizeof diag_msgs [i].code),
+ diag_msgs [i].code,
+ pfx, ndiags [i][1], sfx, ndiags [i][0], pct);
}
}
if (0 == nlines)
- fprintf (ftestout, "# no diagnostics\n");
+ rw_fprintf (_rw_ftestout, "# no diagnostics\n");
- fprintf (ftestout, "# %s\n", tblrow);
+ rw_fprintf (_rw_ftestout, "# %s\n", tblrow);
if (_rw_opt_compat (0, 0)) {
@@ -792,18 +811,20 @@
// RWTest compatibility format
- fprintf (ftestout,
- "######################################################\n"
- "## Warnings = %d\n"
- "## Assertions = %d\n"
- "## FailedAssertions = %d\n",
- ndiags [diag_warn][1] + ndiags [diag_xwarn][1],
- ndiags [diag_assert][0],
- ndiags [diag_assert][1] + ndiags [diag_xassert][1]);
+ rw_fprintf (_rw_ftestout,
+ "######################################################\n"
+ "## Warnings = %d\n"
+ "## Assertions = %d\n"
+ "## FailedAssertions = %d\n",
+ ndiags [diag_warn][1] + ndiags [diag_xwarn][1],
+ ndiags [diag_assert][0],
+ ndiags [diag_assert][1] + ndiags [diag_xassert][1]);
}
- fclose (ftestout);
- ftestout = 0;
+ if (_rw_ftestout != rw_stdout) {
+ fclose ((FILE*)(void*)_rw_ftestout);
+ _rw_ftestout = 0;
+ }
return status;
}
@@ -1051,7 +1072,7 @@
}
#endif // 0/1
- fprintf (ftestout, "%s\n", mybuf);
+ rw_fprintf (_rw_ftestout, "%s\n", mybuf);
if (mybuf != fmterr)
free (mybuf);
Modified: incubator/stdcxx/trunk/tests/src/printf.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/printf.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/printf.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/printf.cpp Mon Feb 6 14:21:40 2006
@@ -1,6 +1,6 @@
/************************************************************************
*
- * printf.cpp - definitions of the rw_printf family of functions
+ * snprintfa.cpp - definitions of the snprintfa family of functions
*
* $Id$
*
@@ -22,7 +22,7 @@
// expand _TEST_EXPORT macros
#define _RWSTD_TEST_SRC
#include <testdefs.h>
-#include <printf.h>
+#include <rw_printf.h>
#include <ctype.h> // for isalpha(), ...
#include <errno.h> // for errno, errno constants
@@ -80,12 +80,12 @@
struct FmtSpec;
-static int
+_RWSTD_INTERNAL int
_rw_fmtlong (const FmtSpec&, char**, size_t*, long);
#ifdef _RWSTD_LONG_LONG
-static int
+_RWSTD_INTERNAL int
_rw_fmtllong (const FmtSpec&, char**, size_t*, _RWSTD_LONG_LONG);
#endif // _RWSTD_LONG_LONG
@@ -1089,7 +1089,7 @@
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
};
-static int
+_RWSTD_INTERNAL int
_rw_fmtlong (const FmtSpec &spec, char **pbuf, size_t *pbufsize, long val)
{
char buffer [130]; // big enough for a 128-bit long in base 2
@@ -1180,7 +1180,7 @@
#ifdef _RWSTD_LONG_LONG
-static int
+_RWSTD_INTERNAL int
_rw_fmtllong (const FmtSpec &spec,
char **pbuf, size_t *pbufsize, _RWSTD_LONG_LONG val)
{
@@ -1275,12 +1275,12 @@
typedef _RWSTD_LONG_LONG LLong;
const int len = sizeof (val) <= sizeof (long) ?
- _rw_fmtlong (spec, pbuf, pbufsize, long (val))
- : _rw_fmtllong (spec, pbuf, pbufsize, LLong (val));
+ ::_rw_fmtlong (spec, pbuf, pbufsize, long (val))
+ : ::_rw_fmtllong (spec, pbuf, pbufsize, LLong (val));
#else // if !defined (_RWSTD_LONG_LONG)
- const int len = _rw_fmtlong (spec, pbuf, pbufsize, long (val));
+ const int len = ::_rw_fmtlong (spec, pbuf, pbufsize, long (val));
#endif // _RWSTD_LONG_LONG
@@ -2675,8 +2675,11 @@
{
RW_ASSERT (0 != pbuf);
- if (0 == array || 0 > _RW::__rw_memattr (array, _RWSTD_SIZE_MAX, 0))
- return _rw_fmtbadaddr (spec, pbuf, pbufsize, array);
+ if (0 == array || 0 > _RW::__rw_memattr (array, _RWSTD_SIZE_MAX, 0)) {
+ // qualify the name of the static function in order to
+ // allow it to be found when referenced from a template
+ return ::_rw_fmtbadaddr (spec, pbuf, pbufsize, array);
+ }
if (_RWSTD_SIZE_MAX == nelems) {
// compute the length of the NUL-terminate string
Modified: incubator/stdcxx/trunk/tests/src/system.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/system.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/system.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/system.cpp Mon Feb 6 14:21:40 2006
@@ -25,7 +25,7 @@
#include <system.h>
#include <driver.h>
-#include <printf.h>
+#include <rw_printf.h>
#include <stdarg.h> // for va_copy, va_list, ...
#include <stdlib.h> // for system
@@ -54,10 +54,13 @@
rw_vasnprintf (&buf, &bufsize, cmd, va);
- rw_note (0, __FILE__, __LINE__,
- "executing \"%s\"", buf);
+ rw_note (0, "file:" __FILE__, __LINE__, "executing \"%s\"", buf);
- const int ret = system (buf);
+ // avoid using const in order to prevent gcc warning on Linux
+ // issued for WIFSIGNALED() et al: cast from `const int*' to
+ // `int*' discards qualifiers from pointer target type:
+ // see http://sourceware.org/bugzilla/show_bug.cgi?id=1392
+ /* const */ int ret = system (buf);
if (ret) {
Modified: incubator/stdcxx/trunk/tests/strings/21.cwchar.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.cwchar.cpp?rev=375398&r1=375397&r2=375398&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.cwchar.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.cwchar.cpp Mon Feb 6 14:21:40 2006
@@ -956,7 +956,7 @@
// included here to avoid namespace pollution
#include <cstdarg> // for va_list
#include <cstdio> // for FILE
-#include <printf.h> // for rw_stdout
+#include <rw_printf.h> // for rw_stdout
namespace std {