Modified: stdcxx/branches/4.2.x/tests/src/printf.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/printf.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/src/printf.cpp (original) +++ stdcxx/branches/4.2.x/tests/src/printf.cpp Wed Apr 16 10:01:56 2008 @@ -53,14 +53,11 @@ # include <wctype.h> // for iswalpha(), ... #endif // _RWSTD_NO_WCTYPE_H -#if defined (_WIN32) || defined (_WIN64) - // define macros to enable Win98 + WinNT support in <windows.h> -# define _WIN32_WINNT 0x0410 -# define WINVER 0x400 -# include <windows.h> // for GetLastError(), IsDebuggerPresent() +#if defined (_WIN32) +# include <windows.h> // for GetLastError(), OutputDebugString() #else # include <dlfcn.h> -#endif // _WIN{32,64} +#endif // _WIN32 #include <ios> #include <iostream> @@ -451,28 +448,28 @@ // for guard block static const char guard[] = "\xde\xad\xbe\xef"; - size_t guardsize = sizeof guard - 1; - - size_t newbufsize = *buf.pbufsize * 2 + guardsize; + const size_t guardsize = sizeof guard - 1; - if (newbufsize <= buflen + len + guardsize) - newbufsize = 2 * (buflen + len + 1) + guardsize; + size_t newbufsize = *buf.pbufsize * 2; + if (newbufsize < 16) + newbufsize = 16; + + const size_t requiredsize = buflen + len + 1; + if (newbufsize < requiredsize) + newbufsize = requiredsize * 2; // prevent buffer size from exceeding the maximum if (buf.maxsize < newbufsize) newbufsize = buf.maxsize; - if (newbufsize < buflen + len + guardsize) - guardsize = 0; - - if (newbufsize < buflen + len + guardsize) { + if (newbufsize < requiredsize) { #ifdef ENOMEM errno = ENOMEM; #endif // ENOMEM return 0; } - char* const newbuf = (char*)malloc (newbufsize); + char* const newbuf = (char*)malloc (newbufsize + guardsize); // return 0 on failure to allocate, let caller deal with it if (0 == newbuf) @@ -481,17 +478,19 @@ memcpy (newbuf, *buf.pbuf, buflen); // append a guard block to the end of the buffer - memcpy (newbuf + newbufsize - guardsize, guard, guardsize); + memcpy (newbuf + newbufsize, guard, guardsize); if (*buf.pbuf) { - // verify that we didn't write past the end of the buffer + // verify that we didn't write past the end of the buffer and + // that the user didn't pass a local or static buffer without + // a maxsize format specifier. RW_ASSERT (0 == memcmp (*buf.pbuf + *buf.pbufsize, guard, guardsize)); free (*buf.pbuf); } *buf.pbuf = newbuf; - *buf.pbufsize = newbufsize - guardsize; + *buf.pbufsize = newbufsize; } if (0 != str) { @@ -625,7 +624,7 @@ RW_ASSERT (0 != *buf.pbuf); // len = int (strlen (*buf.pbuf)); - len = buf.endoff; + len = int (buf.endoff); spec.param.ptr_ = PARAM (ptr_, pva); @@ -977,6 +976,7 @@ // over it fmt += 4; buf.endoff = *buf.pbuf ? strlen (*buf.pbuf) : 0; + RW_ASSERT (buf.endoff < *buf.pbufsize || !*buf.pbuf); } else if (*buf.pbuf) **buf.pbuf = '\0'; @@ -1056,73 +1056,51 @@ char buffer [130]; // big enough for a 128-bit long in base 2 char *end = buffer; - long upoff = 0; - const char *pfx = 0; + // 7.19.6.1 of ISO/IEC 9899:1999: + // The result of converting a zero value with a precision + // of zero is no characters. + if (spec.prec || val) { + const long upoff = 'X' == spec.cvtspec ? 36 : 0; + const int base = 1 < spec.base && spec.base < 37 ? spec.base : 10; + const bool is_signed = 'd' == spec.cvtspec || 'i' == spec.cvtspec; + const bool neg = 0 > val && is_signed; + + ULong uval = ULong (neg ? -val : val); + + do { + *end++ = _rw_digits [upoff + uval % base]; + } while (uval /= base); - if ('X' == spec.cvtspec) - upoff = 36; - - if (spec.fl_pound) { - if (16 == spec.base) - pfx = upoff ? "0X" : "0x"; - else if (8 == spec.base && val) - pfx = "0"; - } - - const int base = 1 < spec.base && spec.base < 37 ? spec.base : 10; - - ULong uval; - - bool neg; - - if (val < 0) { - neg = 'd' == spec.cvtspec || 'i' == spec.cvtspec; - uval = ULong (neg ? -val : val); - } - else { - neg = false; - uval = ULong (val); - } - - do { - *end++ = _rw_digits [upoff + uval % base]; - } while (uval /= base); - - int size = int (end - buffer); - - // insert as many zeros as specified by precision - if (-1 < spec.prec && size < spec.prec) { + // insert as many zeros as specified by precision // FIXME: prevent buffer overrun - for (int i = size; i != spec.prec; ++i) + for (int i = int (end - buffer); i < spec.prec; ++i) *end++ = '0'; - } - // insert octal or hex prefix for non-zero values - if (pfx && val) { - if (pfx [1]) - *end++ = pfx [1]; - *end++ = pfx [0]; - } - - if (neg) - *end++ = '-'; - else if (spec.fl_plus && ('d' == spec.cvtspec || 'i' == spec.cvtspec)) - *end++ = '+'; - - if (0 == spec.prec && 0 == val) { - // 7.19.6.1 of ISO/IEC 9899:1999: - // The result of converting a zero value with a precision - // of zero is no characters. - end = buffer; + // insert octal or hex prefix for non-zero values + if (spec.fl_pound && val) { + switch (spec.base) { + case 16: + *end++ = upoff ? 'X' : 'x'; + // fall through + case 8: + *end++ = '0'; + break; + } + } + + if (neg) + *end++ = '-'; + else if (spec.fl_plus && is_signed) + *end++ = '+'; } // not NUL-terminated RW_ASSERT (buffer <= end); - size = int (end - buffer); + const size_t size = size_t (end - buffer); - for (char *pc = buffer; pc < end; ++pc) { + for (char *pc = buffer; pc < --end; ++pc) { const char tmp = *pc; - *pc = *--end; + *pc = *end; *end = tmp; } @@ -1132,7 +1110,7 @@ newspec.prec = -1; // handle justification by formatting the resulting string - return _rw_fmtstr (newspec, buf, buffer, size_t (size)); + return _rw_fmtstr (newspec, buf, buffer, size); } /********************************************************************/ @@ -1145,79 +1123,62 @@ char buffer [130]; // big enough for a 128-bit long long in base 2 char *end = buffer; - long upoff = 0; - const char *pfx = 0; + // 7.19.6.1 of ISO/IEC 9899:1999: + // The result of converting a zero value with a precision + // of zero is no characters. + if (spec.prec || val) { + const long upoff = 'X' == spec.cvtspec ? 36 : 0; + const int base = 1 < spec.base && spec.base < 37 ? spec.base : 10; + const bool is_signed = 'd' == spec.cvtspec || 'i' == spec.cvtspec; + const bool neg = 0 > val && is_signed; + + typedef unsigned _RWSTD_LONG_LONG ULLong; + ULLong uval = ULLong (neg ? -val : val); + + do { + *end++ = _rw_digits [upoff + uval % base]; + } while (uval /= base); - if ('X' == spec.cvtspec) - upoff = 36; - - if (spec.fl_pound) { - if (16 == spec.base) - pfx = upoff ? "0X" : "0x"; - else if (8 == spec.base && val) - pfx = "0"; - } - - const int base = 1 < spec.base && spec.base < 37 ? spec.base : 10; - - typedef unsigned _RWSTD_LONG_LONG ULLong; - - ULLong uval; - - bool neg; - - if (val < 0) { - neg = 'd' == spec.cvtspec || 'i' == spec.cvtspec; - uval = ULLong (neg ? -val : val); - } - else { - neg = false; - uval = ULLong (val); - } - - do { - *end++ = _rw_digits [upoff + uval % base]; - } while (uval /= base); - - if (pfx) { - if (pfx [1]) - *end++ = pfx [1]; - *end++ = pfx [0]; - } - - char sign; - - if (neg) - sign = '-'; - else if (spec.fl_plus && ('d' == spec.cvtspec || 'i' == spec.cvtspec)) - sign= '+'; - else - sign = '\0'; + // insert as many zeros as specified by precision + // FIXME: prevent buffer overrun + for (int i = int (end - buffer); i < spec.prec; ++i) + *end++ = '0'; - RW_ASSERT (buffer < end); - size_t size = size_t (end - buffer); + // insert octal or hex prefix for non-zero values + if (spec.fl_pound && val) { + switch (spec.base) { + case 16: + *end++ = upoff ? 'X' : 'x'; + // fall through + case 8: + *end++ = '0'; + break; + } + } - // FIXME: prevent buffer overrun - if (0 < spec.prec && size < size_t (spec.prec)) { - for (size_t i = size; i != size_t (spec.prec); ++i) - *end++ = '0'; + if (neg) + *end++ = '-'; + else if (spec.fl_plus && is_signed) + *end++ = '+'; } - if (sign) - *end++ = sign; - // not NUL-terminated - RW_ASSERT (buffer < end); - size = size_t (end - buffer); + RW_ASSERT (buffer <= end); + const size_t size = size_t (end - buffer); - for (char *pc = buffer; pc < end; ++pc) { + for (char *pc = buffer; pc < --end; ++pc) { const char tmp = *pc; - *pc = *--end; + *pc = *end; *end = tmp; } + // reset precision to -1 (already handled above) + FmtSpec newspec (spec); + newspec.fl_pound = 0; + newspec.prec = -1; + // handle justification by formatting the resulting string - return _rw_fmtstr (spec, buf, buffer, size); + return _rw_fmtstr (newspec, buf, buffer, size); } #endif // _RWSTD_LONG_LONG @@ -1569,11 +1530,6 @@ // set the number of digits newspec.prec = _RWSTD_LONG_SIZE * 2; - const union { - const void *ptr; - const ULong *lptr; - } uptr = { pptr }; - int len = 0; if (newspec.fl_pound) { @@ -1587,23 +1543,17 @@ newspec.fl_pound = 0; } - for (size_t i = 0; i != nelems; ++i) { - const size_t inx = _rw_big_endian ? nelems - i - 1 : i; - - len += _rw_fmtlong (newspec, buf, uptr.lptr [inx]); + const union { + const void *ptr; + const ULong *lptr; + } uptr = { pptr }; - if (len < 0) { - break; - } + for (size_t i = 0; i != nelems; ++i) { + const size_t inx = _rw_big_endian ? i : nelems - i - 1; - // separate pointer components with colons - int n = 0; - if (i + 1 < nelems) { - if (0 == _rw_bufcat (buf, ":", size_t (n = 1))) { - len = -1; - break; - } - } + int n = _rw_fmtlong (newspec, buf, uptr.lptr [inx]); + if (n < 0) + return -1; len += n; } @@ -1649,7 +1599,7 @@ if (0 == _rw_bufcat (buf, ")", 1)) return -1; - return buf.endoff - off; + return int (buf.endoff - off); } /********************************************************************/ @@ -2030,7 +1980,7 @@ // repeated occurrences of the element to conserve // space and make the string more readable - const long repeat = pelem - last; + const long repeat = long (pelem - last); if (flags & (A_CHAR | A_WCHAR)) { // format element into elemstr as a character @@ -3376,8 +3326,15 @@ va_end (va); - if (size_t (nchars) <= bufsize) - memcpy (buf, tmpbuf, size_t (nchars)); + if (size_t (nchars) < bufsize) { + memcpy (buf, tmpbuf, size_t (nchars + 1 /* NUL */)); + } + else { + // buffer isn't big enough + memcpy (buf, tmpbuf, bufsize); + if (bufsize) + buf [bufsize - 1] = '\0'; + } free (tmpbuf); @@ -3422,25 +3379,17 @@ // for async-signal safety FILE* const stdio_file = _RWSTD_REINTERPRET_CAST (FILE*, file); - nwrote = fwrite (buf, 1, size_t (nchars), stdio_file); + nwrote = int (fwrite (buf, 1, size_t (nchars), stdio_file)); // flush in case stderr isn't line-buffered (e.g., when // it's determined not to refer to a terminal device, // for example after it has been redirected to a file) fflush (stdio_file); -#ifdef _MSC_VER - - // IsDebuggerPresent() depends on the macros _WIN32_WINNT - // and WINVER being appropriately #defined prior to the - // #inclusion of <windows.h> - if (IsDebuggerPresent ()) { - - // write string to the attached debugger (if any) - OutputDebugString (buf); - } - -#endif // _MSC_VER +#ifdef _WIN32 + // write string to the attached debugger (if any) + OutputDebugString (buf); +#endif // _WIN32 } }
Modified: stdcxx/branches/4.2.x/tests/src/process.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/process.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/src/process.cpp (original) +++ stdcxx/branches/4.2.x/tests/src/process.cpp Wed Apr 16 10:01:56 2008 @@ -269,12 +269,9 @@ { RW_ASSERT (0 != cmd); - char buffer [256]; - char *buf = buffer; + char *buf = 0; - size_t bufsize = sizeof buffer; - - rw_vasnprintf (&buf, &bufsize, cmd, va); + rw_vasnprintf (&buf, 0, cmd, va); rw_note (0, "file:" __FILE__, __LINE__, "executing \"%s\"", buf); @@ -321,8 +318,7 @@ } - if (buf != buffer) - free (buf); + free (buf); return ret; } @@ -348,12 +344,9 @@ { RW_ASSERT (0 != cmd); - char buffer [256]; - char *buf = buffer; - - size_t bufsize = sizeof (buffer); + char *buf = 0; - rw_vasnprintf (&buf, &bufsize, cmd, va); + rw_vasnprintf (&buf, 0, cmd, va); rw_pid_t ret = -1; @@ -392,8 +385,7 @@ #endif // _WIN32 - if (buf != buffer) - free (buf); + free (buf); return ret; } @@ -695,11 +687,11 @@ } // wait for process termination - int ret = rw_waitpid (pid, 0, timeout); - if (pid == ret) + rw_pid_t res = rw_waitpid (pid, 0, timeout); + if (pid == res) return 0; - if (-1 == ret) + if (-1 == res) rw_error (0, __FILE__, __LINE__, "rw_waitpid (%{P}, 0, %i) failed: errno = %{#m} (%{m})", pid, timeout); @@ -733,11 +725,11 @@ } // wait for process termination - ret = rw_waitpid (pid, 0, timeout); - if (pid == ret) + rw_pid_t res = rw_waitpid (pid, 0, timeout); + if (pid == res) return 0; - if (-1 == ret) + if (-1 == res) rw_error (0, __FILE__, __LINE__, "rw_waitpid (%{P}, 0, %i) failed: errno = %{#m} (%{m})", pid, timeout); Modified: stdcxx/branches/4.2.x/tests/src/rand.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/rand.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/src/rand.cpp (original) +++ stdcxx/branches/4.2.x/tests/src/rand.cpp Wed Apr 16 10:01:56 2008 @@ -48,18 +48,17 @@ table32 [TABLE_SIZE - 1] = seed; - _RWSTD_SIZE_T i; - _RWSTD_SIZE_T k = 1; + _RWSTD_UINT32_T k = 1; - for (i = 0; i != TABLE_SIZE - 1U; ++i) { + for (_RWSTD_SIZE_T i = 0; i != TABLE_SIZE - 1U; ++i) { const _RWSTD_SIZE_T ii = 21U * i % TABLE_SIZE; table32 [ii] = k; k = seed - k; - seed = _RWSTD_STATIC_CAST (_RWSTD_SIZE_T, table32 [ii]); + seed = table32 [ii]; } - for (i = 0; i != 4U; ++i) { + for (_RWSTD_SIZE_T i = 0; i != 4U; ++i) { for (_RWSTD_SIZE_T ii = 0; ii != TABLE_SIZE; ++ii) table32 [i] = table32 [i] - table32 [(i + 31U) % TABLE_SIZE]; } @@ -99,18 +98,17 @@ table64 [TABLE_SIZE - 1] = seed; - _RWSTD_SIZE_T i; - _RWSTD_SIZE_T k = 1; + _RWSTD_UINT64_T k = 1; - for (i = 0; i != TABLE_SIZE - 1U; ++i) { + for (_RWSTD_SIZE_T i = 0; i != TABLE_SIZE - 1U; ++i) { const _RWSTD_SIZE_T ii = 21U * i % TABLE_SIZE; table64 [ii] = k; k = seed - k; - seed = _RWSTD_STATIC_CAST (_RWSTD_SIZE_T, table64 [ii]); + seed = table64 [ii]; } - for (i = 0; i != 4U; ++i) { + for (_RWSTD_SIZE_T i = 0; i != 4U; ++i) { for (_RWSTD_SIZE_T ii = 0; ii != TABLE_SIZE; ++ii) table64 [i] = table64 [i] - table64 [(i + 31U) % TABLE_SIZE]; } Modified: stdcxx/branches/4.2.x/tests/strings/21.cwctype.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/strings/21.cwctype.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/strings/21.cwctype.cpp (original) +++ stdcxx/branches/4.2.x/tests/strings/21.cwctype.cpp Wed Apr 16 10:01:56 2008 @@ -763,7 +763,6 @@ { rw_info (0, 0, 0, "behavior of <cwctype> functions in the \"C\" locale"); - char extra_str [80]; char missing_str [80]; for (int i = 0; i != 256; ++i) { @@ -794,17 +793,13 @@ SET_MASK_BIT (upper); SET_MASK_BIT (xdigit); - const int extra_bits = mask & ~char_mask [i]; + // C99 standard (7.25.2.1 p2) implicitly allows + // defining the extra bits in iswxxx() const int missing_bits = ~mask & char_mask [i]; - rw_assert (mask == char_mask [i], 0, 0, - "%#c mask%{?} missing bits %s (%#x)%{;}" - "%{?} extra bits %s (%#x)%{;}", - i, - missing_bits, - get_bitmask (missing_bits, missing_str), missing_bits, - extra_bits, - get_bitmask (extra_bits, extra_str), extra_bits); + rw_assert (0 == missing_bits, 0, 0, + "%#c mask missing bits %s (%#x)", + i, get_bitmask (missing_bits, missing_str), missing_bits); } } @@ -815,14 +810,20 @@ static int run_test (int, char**) { +#ifdef _RWSTD_STRICT_ANSI +# define RW_DIAG rw_assert +#else +# define RW_DIAG rw_warn +#endif + ////////////////////////////////////////////////////////////////// rw_info (0, 0, 0, "checking for the absence of masking macros"); // verify the shadow macros are not #defined (explicitly // disallowed by 17.4.1.2, p6 and Footnote 159 of C++ '03) for (unsigned i = 0; cwctype_macros [i]; ++i) { - rw_assert ('\0' == cwctype_macros [i][0], 0, 0, - "macro %s unexpectedly #defined", cwctype_macros [i]); + RW_DIAG ('\0' == cwctype_macros [i][0], 0, 0, + "macro %s unexpectedly #defined", cwctype_macros [i]); } ////////////////////////////////////////////////////////////////// @@ -845,9 +846,9 @@ rw_info (0, 0, 0, "%s::%s (%s::wint_t) definition", \ std_name, #function, std_name); \ const int result = std::function (test_wint_t ('a')); \ - rw_assert (-1 != result && !(missing_set & bit_ ## function), \ - 0, __LINE__, "%s::%s (%s::wint_t) not defined", \ - std_name, #function, std_name); \ + RW_DIAG (-1 != result && !(missing_set & bit_ ## function), \ + 0, __LINE__, "%s::%s (%s::wint_t) not defined", \ + std_name, #function, std_name); \ } while (0) TEST (iswalnum); @@ -870,8 +871,8 @@ int result = std::wctype (""); - rw_assert (-1 != result && !(missing_set & bit_wctype), 0, __LINE__, - "%s::wctype (const char*) not defined", std_name); + RW_DIAG (-1 != result && !(missing_set & bit_wctype), 0, __LINE__, + "%s::wctype (const char*) not defined", std_name); // exercise std::iswctype(std::wint_t, std::wctype_t) @@ -884,9 +885,9 @@ result = std::iswctype (wc, desc); - rw_assert (-1 != result && !(missing_set & bit_iswctype), 0, __LINE__, - "%s::iswctype (%1$s::wint_t, %1$s::wctype_t) not defined", - std_name); + RW_DIAG (-1 != result && !(missing_set & bit_iswctype), 0, __LINE__, + "%s::iswctype (%1$s::wint_t, %1$s::wctype_t) not defined", + std_name); // exercise std::wctrans(const char*) rw_info (0, 0, 0, @@ -896,8 +897,8 @@ // such as in GNU glibc result = (int)(_RWSTD_PTRDIFF_T)std::wctrans (""); - rw_assert (-1 != result && !(missing_set & bit_wctrans), 0, __LINE__, - "%s::wctrans (const char*) not defined", std_name); + RW_DIAG (-1 != result && !(missing_set & bit_wctrans), 0, __LINE__, + "%s::wctrans (const char*) not defined", std_name); // exercise std::towctrans(wint_t, wctrans_t) rw_info (0, 0, 0, @@ -906,8 +907,8 @@ const test_wctrans_t category = 0; result = std::towctrans (wc, category); - rw_assert (-1 != result && !(missing_set & bit_towctrans), 0, __LINE__, - "%s::towctrans(wint_t, wctrans_t) not defined", std_name); + RW_DIAG (-1 != result && !(missing_set & bit_towctrans), 0, __LINE__, + "%s::towctrans(wint_t, wctrans_t) not defined", std_name); ////////////////////////////////////////////////////////////////// if (rw_opt_no_behavior) Modified: stdcxx/branches/4.2.x/tests/strings/21.string.access.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/strings/21.string.access.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/strings/21.string.access.cpp (original) +++ stdcxx/branches/4.2.x/tests/strings/21.string.access.cpp Wed Apr 16 10:01:56 2008 @@ -272,7 +272,6 @@ }; const bool success = 1 == rw_match (exp_res, pres, 1); - rw_assert (success, 0, tcase.line, "line %d. %{$FUNCALL} == %{#c}, got %{#c}", __LINE__, tcase.nres, *pres); Modified: stdcxx/branches/4.2.x/tests/strings/21.string.cons.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/strings/21.string.cons.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/strings/21.string.cons.cpp (original) +++ stdcxx/branches/4.2.x/tests/strings/21.string.cons.cpp Wed Apr 16 10:01:56 2008 @@ -53,6 +53,8 @@ static const StringTestCase void_test_cases [] = { +#define alloc_test_cases void_test_cases + #undef TEST #define TEST(dummy) { \ __LINE__, -1, -1, -1, -1, -1, \ @@ -75,6 +77,8 @@ static const StringTestCase cptr_test_cases [] = { +#define cptr_alloc_test_cases cptr_test_cases + #undef TEST #define TEST(arg, res) { \ __LINE__, -1, -1, -1, -1, -1, \ @@ -166,6 +170,8 @@ static const StringTestCase cptr_size_test_cases [] = { +#define cptr_size_alloc_test_cases cptr_size_test_cases + #undef TEST #define TEST(arg, size, res) { \ __LINE__, -1, size, -1, -1, -1, \ @@ -278,7 +284,9 @@ static const StringTestCase cstr_size_size_test_cases [] = { -#define range_test_cases cstr_size_size_test_cases +#define range_test_cases cstr_size_size_test_cases +#define cstr_size_size_alloc_test_cases cstr_size_size_test_cases +#define range_alloc_test_cases cstr_size_size_test_cases #undef TEST #define TEST(arg, off, size, res, bthrow) { \ @@ -335,6 +343,8 @@ static const StringTestCase size_val_test_cases [] = { +#define size_val_alloc_test_cases size_val_test_cases + #undef TEST #define TEST(size, val, res) { \ __LINE__, -1, size, -1, -1, val, \ @@ -1112,13 +1122,19 @@ } TEST (void), + TEST (alloc), TEST (cptr), + TEST (cptr_alloc), TEST (cstr), TEST (cptr_size), + TEST (cptr_size_alloc), TEST (cstr_size), TEST (cstr_size_size), + TEST (cstr_size_size_alloc), TEST (size_val), + TEST (size_val_alloc), TEST (range), + TEST (range_alloc), #undef TEST #define TEST(sig) { \ Modified: stdcxx/branches/4.2.x/tests/strings/21.string.cons.mt.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/strings/21.string.cons.mt.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/strings/21.string.cons.mt.cpp (original) +++ stdcxx/branches/4.2.x/tests/strings/21.string.cons.mt.cpp Wed Apr 16 10:01:56 2008 @@ -189,7 +189,7 @@ { rw_info (0, 0, 0, "testing std::string with %d thread%{?}s%{;}, " - "%zu iteration%{?}s%{;} each", + "%d iteration%{?}s%{;} each", rw_opt_nthreads, 1 != rw_opt_nthreads, rw_opt_nloops, 1 != rw_opt_nloops); @@ -217,7 +217,7 @@ rw_info (0, 0, 0, "testing std::wstring with %d thread%{?}s%{;}, " - "%zu iteration%{?}s%{;} each", + "%d iteration%{?}s%{;} each", rw_opt_nthreads, 1 != rw_opt_nthreads, rw_opt_nloops, 1 != rw_opt_nloops); Modified: stdcxx/branches/4.2.x/tests/strings/21.string.iterators.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/strings/21.string.iterators.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/strings/21.string.iterators.cpp (original) +++ stdcxx/branches/4.2.x/tests/strings/21.string.iterators.cpp Wed Apr 16 10:01:56 2008 @@ -371,36 +371,38 @@ "line %d. %{$FUNCALL} expected non null, got null", __LINE__); - // 21.3.6.1 - // if size() is nonzero, the member returns a pointer to the - // initial element of an array whose first size() elements - // equal the corresponding elements of the string controlled - // by *this - // 21.3.6.3 - // if size() is nonzero, the member returns a pointer to the - // initial element of an array whose first size() elements - // equal the corresponding elements of the string controlled - // by *this - const std::size_t match = - rw_match (tcase.res, ret_ptr, tdata.reslen_); + if (ret_ptr) { + // 21.3.6.1 + // if size() is nonzero, the member returns a pointer to the + // initial element of an array whose first size() elements + // equal the corresponding elements of the string controlled + // by *this + // 21.3.6.3 + // if size() is nonzero, the member returns a pointer to the + // initial element of an array whose first size() elements + // equal the corresponding elements of the string controlled + // by *this + const std::size_t match = + rw_match (tcase.res, ret_ptr, tdata.reslen_); - rw_assert (match == tdata.reslen_, 0, tcase.line, - "line %d. %{$FUNCALL} expected %{#*s}, " - "got %{/*.*Gs}, differ at pos %zu", - __LINE__, int (tdata.reslen_), tdata.res_, - cwidth, int (s_size), ret_ptr, match); + rw_assert (match == tdata.reslen_, 0, tcase.line, + "line %d. %{$FUNCALL} expected %{#*s}, " + "got %{/*.*Gs}, differ at pos %zu", + __LINE__, int (tdata.reslen_), tdata.res_, + cwidth, int (s_size), ret_ptr, match); - if (func.which_ == StringIds::c_str_void) { + if (func.which_ == StringIds::c_str_void) { - // check the last element is equal to char () - const char null = char (); - const bool success = - (1 == rw_match (&null, &ret_ptr[s_size], 1)); + // check the last element is equal to char () + const char null = char (); + const bool success = + (1 == rw_match (&null, &ret_ptr[s_size], 1)); - rw_assert(success, 0, tcase.line, - "line %d. %{$FUNCALL} expected last element " - "is a null character %{#c}, got %{#c}", - __LINE__, null, ret_ptr[s_size]); + rw_assert(success, 0, tcase.line, + "line %d. %{$FUNCALL} expected last element " + "is a null character %{#c}, got %{#c}", + __LINE__, null, ret_ptr[s_size]); + } } } Modified: stdcxx/branches/4.2.x/tests/strings/21.string.push_back.mt.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/strings/21.string.push_back.mt.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/strings/21.string.push_back.mt.cpp (original) +++ stdcxx/branches/4.2.x/tests/strings/21.string.push_back.mt.cpp Wed Apr 16 10:01:56 2008 @@ -110,7 +110,7 @@ static int run_test (int, char**) { - rw_info (0, 0, 0, "running %d thread%{?}s%{;}, %zu iteration%{?}s%{;} each", + rw_info (0, 0, 0, "running %d thread%{?}s%{;}, %d iteration%{?}s%{;} each", rw_opt_nthreads, 1 != rw_opt_nthreads, rw_opt_nloops, 1 != rw_opt_nloops); Modified: stdcxx/branches/4.2.x/tests/tr1.util/2.smartptr.shared.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/tr1.util/2.smartptr.shared.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/tr1.util/2.smartptr.shared.cpp (original) +++ stdcxx/branches/4.2.x/tests/tr1.util/2.smartptr.shared.cpp Wed Apr 16 10:01:56 2008 @@ -23,7 +23,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 1994-2006 Rogue Wave Software. + * Copyright 1994-2008 Rogue Wave Software, Inc. * **************************************************************************/ @@ -322,13 +322,35 @@ #endif // ILL_FORMED + { // template <class U> shared_ptr(const shared_ptr<U>&) Derived<int>* const pd = new Derived<int>; - std::tr1::shared_ptr<volatile Derived<int> > ptr_d (pd); - std::tr1::shared_ptr<volatile Base_0<int> > ptr_0 (ptr_d); - std::tr1::shared_ptr<volatile Base_1<int> > ptr_1 (ptr_d); - std::tr1::shared_ptr<volatile Base<int> > ptr_b (ptr_d); +#if !defined (_RWSTD_HP_aCC_MAJOR) || 6 <= _RWSTD_HP_aCC_MAJOR \ + || 3 == _RWSTD_HP_aCC_MAJOR && __hpxstd98 + + typedef volatile Derived<int> v_Derived_i; + typedef volatile Base_0<int> v_Base_0_i; + typedef volatile Base_1<int> v_Base_1_i; + typedef volatile Base<int> v_Base_i; + +#else // HP aCC + + // volatile disabled for HP aCC 3 without the +hpxstd98 + // option available starting with aCC 3.74 to work around + // a compiler bug (see STDCXX-615) + + typedef /* volatile */ Derived<int> v_Derived_i; + typedef /* volatile */ Base_0<int> v_Base_0_i; + typedef /* volatile */ Base_1<int> v_Base_1_i; + typedef /* volatile */ Base<int> v_Base_i; + +#endif // HP aCC + + std::tr1::shared_ptr<v_Derived_i> ptr_d (pd); + std::tr1::shared_ptr<v_Base_0_i> ptr_0 (ptr_d); + std::tr1::shared_ptr<v_Base_1_i> ptr_1 (ptr_d); + std::tr1::shared_ptr<v_Base_i> ptr_b (ptr_d); rw_assert (pd == ptr_d.get (), 0, __LINE__, "shared_ptr<Derived>(Derived* = %#p).get() == %#p, got %#p", @@ -338,19 +360,19 @@ "shared_ptr<Base_0>(const shared_ptr<Derived>(%#p))" ".get() == %#p, got %#p", ptr_d.get (), - (volatile Base_0<int>*)ptr_d.get (), ptr_0.get ()); + (v_Base_0_i*)ptr_d.get (), ptr_0.get ()); rw_assert (ptr_d.get () == ptr_1.get (), 0, __LINE__, "shared_ptr<Base_1>(const shared_ptr<Derived>(%#p))" ".get() == %#p, got %#p", ptr_d.get (), - (volatile Base_1<int>*)ptr_d.get (), ptr_1.get ()); + (v_Base_1_i*)ptr_d.get (), ptr_1.get ()); rw_assert (ptr_d.get () == ptr_b.get (), 0, __LINE__, "shared_ptr<Base>(const shared_ptr<Derived>(%#p))" ".get() == %#p, got %#p", ptr_d.get (), - (volatile Base<int>*)ptr_d.get (), ptr_b.get ()); + (v_Base_i*)ptr_d.get (), ptr_b.get ()); rw_assert (4 == ptr_d.use_count (), 0, __LINE__, ""); rw_assert (ptr_d.use_count () == ptr_0.use_count (), 0, __LINE__, ""); Modified: stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.cpp (original) +++ stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.cpp Wed Apr 16 10:01:56 2008 @@ -39,6 +39,7 @@ #endif #include <rw_new.h> +#include <rw_printf.h> #include <driver.h> #ifndef _RWSTD_NO_SETRLIMIT @@ -245,7 +246,7 @@ { if (0 == tname) { static char buf [40]; - std::sprintf (buf, "char[%u]", unsigned (sizeof (T))); + rw_sprintf (buf, "char[%zu]", sizeof (T)); tname = buf; } @@ -264,13 +265,13 @@ "got { %#p, %td }", tname, nelems, pa.first, pa.second); - for (std::size_t i = 2; i < sizeof (T); i <<= 1) { + for (std::size_t i = 2; i && i < sizeof (T); i <<= 1) { // exercise arithmetic overflow (not to be confused // with the out-of-memory tests below) // attempts to allocate space for an array of elements // with a total size that exceeds SIZE_MAX must fail - nelems = _RWSTD_PTRDIFF_MAX / i + 1; + nelems = (_RWSTD_PTRDIFF_MAX / i) + 1; pa = std::get_temporary_buffer<T>(nelems); Modified: stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.mt.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.mt.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.mt.cpp (original) +++ stdcxx/branches/4.2.x/tests/utilities/20.temp.buffer.mt.cpp Wed Apr 16 10:01:56 2008 @@ -126,7 +126,7 @@ { thr_args* const targs = (thr_args*)arg; - std::printf ("thread %d starting...\n", targs->threadno_); + std::printf ("thread %ld starting...\n", targs->threadno_); #ifndef _RWSTD_INT64_T Modified: stdcxx/branches/4.2.x/util/aliases.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/aliases.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/aliases.cpp (original) +++ stdcxx/branches/4.2.x/util/aliases.cpp Wed Apr 16 10:01:56 2008 @@ -22,10 +22,19 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2007 Rogue Wave Software, Inc. + * Copyright 2001-2008 Rogue Wave Software, Inc. * **************************************************************************/ +#include <rw/_defs.h> + +#ifdef _RWSTD_EDG_ECCP + // disable error #450-D: the type "long long" is nonstandard + // issued for uses of the type in Linux system headers (e.g., + // pthreadtypes.h) +# pragma diag_suppress 450 +#endif // vanilla EDG eccp demo + #ifdef __linux__ // on Linux define _XOPEN_SOURCE to get CODESET defined in <langinfo.h> # define _XOPEN_SOURCE 500 /* SUS conformance */ @@ -34,8 +43,6 @@ #include "diagnostic.h" -#include <rw/_defs.h> - #include <cassert> // for assert() #include <cerrno> // for errno #include <cstdlib> @@ -536,12 +543,12 @@ { static char* slocname = 0; - static int size = 0; // the number of elements in the array - static int total_size = 5120; // the size of the array + static std::size_t size = 0; // number of elements in array + static std::size_t total_size = 5120; // the size of the array // allocate first time through if (!slocname) { - slocname = (char*)std::malloc (16384); + slocname = new char [16384]; *slocname = '\0'; } @@ -594,8 +601,8 @@ const int ret = std::system (cmd); if (ret) - issue_diag (W_NOTSUP, false, 0, "call to system(\"%s\") failed: %s\n", - cmd, std::strerror (errno)); + issue_diag (W_NOTSUP, false, 0, "call to system(\"%s\") failed: %s\n", + cmd, std::strerror (errno)); // open file containing the list of installed locales std::FILE *f = std::fopen (fname, "r"); Modified: stdcxx/branches/4.2.x/util/collate.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/collate.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/collate.cpp (original) +++ stdcxx/branches/4.2.x/util/collate.cpp Wed Apr 16 10:01:56 2008 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2008 Rogue Wave Software, Inc. * **************************************************************************/ @@ -1560,7 +1560,7 @@ { int nesting_level = 0; - while (true) { + do { // fetch next token next = scanner_.next_token(); @@ -1680,8 +1680,9 @@ break; } } - + while (Scanner::tok_end_tokens != next.token); } + // The task of preprocess_order is to parse and model the content of the // order sections in the input files Modified: stdcxx/branches/4.2.x/util/ctype.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/ctype.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/ctype.cpp (original) +++ stdcxx/branches/4.2.x/util/ctype.cpp Wed Apr 16 10:01:56 2008 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2008 Rogue Wave Software, Inc. * **************************************************************************/ @@ -252,7 +252,7 @@ num++; } else { - len = std::sprintf (next_num, "%ld", num++); + len = std::sprintf (next_num, "%lu", num++); } sym_name = begin; Modified: stdcxx/branches/4.2.x/util/def.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/def.h?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/def.h (original) +++ stdcxx/branches/4.2.x/util/def.h Wed Apr 16 10:01:56 2008 @@ -92,12 +92,12 @@ // was the content of the locale definition file scanned ahead bool scan_ahead_; - typedef Scanner::token_t token_t; + typedef Scanner::token_t token_t; typedef std::pair<token_t,token_t> token_pair_t; - typedef std::list<token_t> token_list_t; + typedef std::list<token_t> token_list_t; typedef std::pair<token_t,token_list_t> collate_entry_t; typedef std::pair<token_t,token_list_t> collate_elem_t; - typedef std::list<collate_entry_t> collate_entry_list_t; + typedef std::list<collate_entry_t> collate_entry_list_t; struct collate_section_t; struct collate_section_t { @@ -401,9 +401,9 @@ typedef std::map<wchar_t,std::list<std::string> > xlit_map_t; typedef std::map<wchar_t, unsigned int> xlit_data_offset_map_t; typedef std::map<unsigned int,xlit_offset_table_t> xlit_table_map_t; - xlit_map_t xlit_map_; - xlit_data_offset_map_t xlit_data_offset_map_; - xlit_table_map_t xlit_table_map_; + xlit_map_t xlit_map_; + xlit_data_offset_map_t xlit_data_offset_map_; + xlit_table_map_t xlit_table_map_; // the collate_info_t struct contains information concerning the collation // of each character Modified: stdcxx/branches/4.2.x/util/display.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/display.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/display.cpp (original) +++ stdcxx/branches/4.2.x/util/display.cpp Wed Apr 16 10:01:56 2008 @@ -118,8 +118,8 @@ { (void)&argv; - puts ("NAME STATUS WARN ASSERTS FAILED PERCNT" - " USER SYS REAL"); + puts ("NAME STATUS WARN ASSERTS " + "FAILED PERCNT USER SYS REAL"); } @@ -144,7 +144,7 @@ assert (0 == defaults->verbose); - printf ("%-30.30s ", target_name); + printf ("%-40.40s ", target_name); /* flush to prevent killing a signal from not displaying the text */ fflush (stdout); Modified: stdcxx/branches/4.2.x/util/locale.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/locale.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/locale.cpp (original) +++ stdcxx/branches/4.2.x/util/locale.cpp Wed Apr 16 10:01:56 2008 @@ -22,16 +22,24 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2008 Rogue Wave Software, Inc. * **************************************************************************/ +#include <rw/_defs.h> + #if defined (__linux__) && !defined (_XOPEN_SOURCE) // on Linux define _XOPEN_SOURCE to get CODESET defined in <langinfo.h> # define _XOPEN_SOURCE 500 /* Single UNIX conformance */ #endif // __linux__ -#include <rw/_defs.h> +#ifdef _RWSTD_EDG_ECCP + // disable error #450-D: the type "long long" is nonstandard + // issued for uses of the type in Linux system headers (e.g., + // pthreadtypes.h) +# pragma diag_suppress 450 +#endif // vanilla EDG eccp demo + #include _RWSTD_SYS_TYPES_H #if _RWSTD_PATH_SEP == '/' @@ -922,7 +930,7 @@ // sym is sized at 13 because there will never be more then // 99,999 collating elements char sym [13]; - std::sprintf (sym, "<RW_CE_%d>", ce_num++); + std::sprintf (sym, "<RW_CE_%u>", ce_num++); ce_map.insert (std::make_pair (sym, elem)); std::cout << "collating-element " << sym << " from \""; @@ -2610,7 +2618,7 @@ print_ellipsis (mbchar, last_byte, last_ucs4, last_wchar); // process subsequent maps - for (std::size_t i = 0; i != UCHAR_MAX + 1U; ++i) { + for (unsigned i = 0; i != UCHAR_MAX + 1U; ++i) { if (UINT_MAX == tab [i]) { // invalid multibyte sequence (i.e., unused slot) Modified: stdcxx/branches/4.2.x/util/locale_stub.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/locale_stub.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/locale_stub.cpp (original) +++ stdcxx/branches/4.2.x/util/locale_stub.cpp Wed Apr 16 10:01:56 2008 @@ -59,7 +59,10 @@ slash = std::strrchr (cmdline, '\\'); } - std::strcpy (slash ? slash + 1 : cmdline, localedef); + if (slash) + std::strcpy (slash + 1, localedef); + else + std::strcpy (cmdline, localedef); std::strcat (cmdline, " "); std::strcat (cmdline, argv_1); Modified: stdcxx/branches/4.2.x/util/memchk.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/memchk.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/memchk.cpp (original) +++ stdcxx/branches/4.2.x/util/memchk.cpp Wed Apr 16 10:01:56 2008 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2008 Rogue Wave Software, Inc. * **************************************************************************/ @@ -66,6 +66,17 @@ # define P_tmpdir _P_tmpdir # endif #endif // P_tmpdir + + +#if defined (_RWSTD_EDG_ECCP) && !defined (_WIN32) + +extern "C" { + +int getpagesize (); + +} // extern "C" + +#endif // vanilla EDG eccp demo on UNIX static int page_size () Modified: stdcxx/branches/4.2.x/util/path.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/path.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/path.cpp (original) +++ stdcxx/branches/4.2.x/util/path.cpp Wed Apr 16 10:01:56 2008 @@ -26,17 +26,6 @@ * **************************************************************************/ -#include "path.h" - -#include "diagnostic.h" // for issue_diag() - -#include <cassert> // for assert() -#include <cerrno> // for ERANGE -#include <cstdlib> // for getenv() -#include <cstring> // for strerror() -#include <string> // for string - - #ifndef _MSC_VER # ifdef __linux__ // for symlink() @@ -57,6 +46,17 @@ # include <sys/types.h> # include <sys/stat.h> // for struct stat, stat() #endif // _MSC_VER + + +#include "path.h" + +#include "diagnostic.h" // for issue_diag() + +#include <cassert> // for assert() +#include <cerrno> // for ERANGE +#include <cstdlib> // for getenv() +#include <cstring> // for strerror() +#include <string> // for string static char* get_cwd (char* s, std::size_t l) Modified: stdcxx/branches/4.2.x/util/scanner.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/scanner.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/scanner.cpp (original) +++ stdcxx/branches/4.2.x/util/scanner.cpp Wed Apr 16 10:01:56 2008 @@ -45,8 +45,8 @@ { ScannerContext (const char*, char = '#', char = '\\'); - std::ifstream file; // file stream object - std::string filename; // filename + std::ifstream file; // file stream object + std::string filename; // filename // comment and escape for current file char comment_char; Modified: stdcxx/branches/4.2.x/util/scanner.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/scanner.h?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/scanner.h (original) +++ stdcxx/branches/4.2.x/util/scanner.h Wed Apr 16 10:01:56 2008 @@ -191,7 +191,7 @@ virtual ~Scanner(); // public interface - token_t next_token (); + token_t next_token (); void open (std::string, char = '#', char = '\\'); Modified: stdcxx/branches/4.2.x/util/time.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/util/time.cpp?rev=648752&r1=648751&r2=648752&view=diff ============================================================================== --- stdcxx/branches/4.2.x/util/time.cpp (original) +++ stdcxx/branches/4.2.x/util/time.cpp Wed Apr 16 10:01:56 2008 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2008 Rogue Wave Software, Inc. * **************************************************************************/ @@ -67,12 +67,24 @@ // now get the offset tokp = std::strtok (0, ":"); + if (0 == tokp) + issue_diag (E_SYNTAX, true, &tok, + "expected ':' in era definition\n"); + + assert (0 != tokp); + std::sscanf (tokp, "%d", &tmp_era.era_out.offset); if (direction == '-') tmp_era.era_out.offset *= -1; // now get the start date tokp = std::strtok (0, ":"); + if (0 == tokp) + issue_diag (E_SYNTAX, true, &tok, + "expected ':' in era definition\n"); + + assert (0 != tokp); + unsigned int tmp_mon, tmp_day; std::sscanf (tokp, "%d/%u/%u", &tmp_era.era_out.year[0], &tmp_mon, &tmp_day); @@ -83,6 +95,12 @@ // now get the end date (this may be the beginning or end of time tokp = std::strtok (0, ":"); + if (0 == tokp) + issue_diag (E_SYNTAX, true, &tok, + "expected ':' in era definition\n"); + + assert (0 != tokp); + if (std::strcmp (tokp, "-*") == 0) { tmp_era.era_out.year[1] = _RWSTD_INT_MIN; tmp_era.era_out.month[1] = _RWSTD_CHAR_MIN;
