From commits-return-2826-apmail-stdcxx-commits-archive=stdcxx.apache.org@stdcxx.apache.org Thu Apr 24 23:40:41 2008 Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 98408 invoked from network); 24 Apr 2008 23:40:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Apr 2008 23:40:41 -0000 Received: (qmail 46949 invoked by uid 500); 24 Apr 2008 23:40:42 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 46921 invoked by uid 500); 24 Apr 2008 23:40:42 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 46910 invoked by uid 99); 24 Apr 2008 23:40:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 16:40:42 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 23:39:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DFD451A9832; Thu, 24 Apr 2008 16:40:16 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r651459 - in /stdcxx/trunk: include/rw/_config-acc.h include/rw/_config-gcc.h include/rw/_defs.h tests/src/printf.cpp Date: Thu, 24 Apr 2008 23:40:15 -0000 To: commits@stdcxx.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080424234016.DFD451A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebor Date: Thu Apr 24 16:40:13 2008 New Revision: 651459 URL: http://svn.apache.org/viewvc?rev=651459&view=rev Log: 2008-04-24 Martin Sebor Merged revs 650742 and 650710 from branches/4.2.x. 2008-04-22 Martin Sebor STDCXX-890 * include/rw/_defs.h (_RWSTD_ATTRIBUTE_NORETURN): Defined macro to be empty when not yet #defined. (__rw_assert_fail): Replaced _RWSTD_GNUC_ATTRIBUTE ((noreturn)) with _RWSTD_ATTRIBUTE_NORETURN. * include/rw/_config-acc.h [aCC 6] (_RWSTD_ATTRIBUTE_NORETURN): Defined macro to __attribute__((noreturn)) for HP aCC 6 and better. * include/rw/_config-gcc.h (_RWSTD_ATTRIBUTE_NORETURN): Defined macro to __attribute__((noreturn)) for all versions of gcc. 2008-04-22 Martin Sebor STDCXX-756 * tests/src/printf.cpp (_rw_fmtexpr): Handled malloc(() failure to silence HP aCC 6 warning 20200: Potential null pointer dereference. (_rw_pvasnprintf, rw_sprintf, rw_snprintf): Cast operand to a wider type before adding to it to silence HP aCC remark 4298: addition result could be truncated before cast to bigger sized type. (_rw_fmtstr): Commented out redundant extern keyword to silence the annoying HP aCC 6 remark 4244: extern storage class used with a function definition. (_rw_quotechar): Made use of the new _RWSTD_UWCHAR_INT_T type to silence HP aCC 6 remark 4248: comparison of unsigned integer with a signed integer. (_rw_fmtfloating): Replaced a for loop with an equivalent call to strlen() to silence another useless HP aCC remark, 4315: for loop without body, did you insert an extra ';'? Modified: stdcxx/trunk/include/rw/_config-acc.h stdcxx/trunk/include/rw/_config-gcc.h stdcxx/trunk/include/rw/_defs.h stdcxx/trunk/tests/src/printf.cpp Modified: stdcxx/trunk/include/rw/_config-acc.h URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_config-acc.h?rev=651459&r1=651458&r2=651459&view=diff ============================================================================== --- stdcxx/trunk/include/rw/_config-acc.h (original) +++ stdcxx/trunk/include/rw/_config-acc.h Thu Apr 24 16:40:13 2008 @@ -25,7 +25,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. * **************************************************************************/ @@ -97,4 +97,10 @@ # define _RWSTD_NO_EXCEPTIONS # endif // _RWSTD_NO_EXCEPTIONS #endif // __HPACC_NOEH + +#if 6 <= _RWSTD_HP_aCC_MAJOR + // aCC 6 attribute((noreturn)) to indicate that a function + // doesn't return (it may exit by throwing an exception) +# define _RWSTD_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) +#endif // aCC >= 6 Modified: stdcxx/trunk/include/rw/_config-gcc.h URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_config-gcc.h?rev=651459&r1=651458&r2=651459&view=diff ============================================================================== --- stdcxx/trunk/include/rw/_config-gcc.h (original) +++ stdcxx/trunk/include/rw/_config-gcc.h Thu Apr 24 16:40:13 2008 @@ -25,7 +25,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. * **************************************************************************/ @@ -83,6 +83,10 @@ #endif //__GNUG__ <= 2 && __GNUC_MINOR__ < 97 && _RWSTD_NO_HONOR_STD #define _RWSTD_GNUC_ATTRIBUTE(attr) __attribute__ (attr) + +// gcc attribute((noreturn)) to indicate that a function doesn't return +// (it may still exit by throwing an exception or by calling longjmp) +#define _RWSTD_ATTRIBUTE_NORETURN _RWSTD_GNUC_ATTRIBUTE ((noreturn)) #ifdef _RWSTD_OS_LINUX Modified: stdcxx/trunk/include/rw/_defs.h URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_defs.h?rev=651459&r1=651458&r2=651459&view=diff ============================================================================== --- stdcxx/trunk/include/rw/_defs.h (original) +++ stdcxx/trunk/include/rw/_defs.h Thu Apr 24 16:40:13 2008 @@ -25,7 +25,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. * **************************************************************************/ @@ -1128,6 +1128,12 @@ # define _RWSTD_ASSUME(expr) _RWSTD_ASSERT (expr) #endif // _RWSTD_ASSUME +#ifndef _RWSTD_ATTRIBUTE_NORETURN + // gcc (and others) __attribute__ ((noreturn)) +# define _RWSTD_ATTRIBUTE_NORETURN /* empty */ +#endif // _RWSTD_ATTR_NORETURN + + // compile-time assertion - asserts constant expressions during // compilation with no runtime overhead; failed assertions are reported // as compilation errors @@ -1149,7 +1155,7 @@ // called for failed assertions void _RWSTD_EXPORT __rw_assert_fail (const char*, const char*, int, const char*) - _RWSTD_GNUC_ATTRIBUTE ((noreturn)); + _RWSTD_ATTRIBUTE_NORETURN; } // extern "C++" Modified: stdcxx/trunk/tests/src/printf.cpp URL: http://svn.apache.org/viewvc/stdcxx/trunk/tests/src/printf.cpp?rev=651459&r1=651458&r2=651459&view=diff ============================================================================== --- stdcxx/trunk/tests/src/printf.cpp (original) +++ stdcxx/trunk/tests/src/printf.cpp Thu Apr 24 16:40:13 2008 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2005-2006 Rogue Wave Software. + * Copyright 2005-2008 Rogue Wave Software, Inc. * **************************************************************************/ @@ -815,7 +815,7 @@ RW_ASSERT (size_t (len) <= *buf.pbufsize); RW_ASSERT (buf.endoff <= *buf.pbufsize); - const size_t offinx = size_t (nextoff - 1); + const size_t offinx = size_t (nextoff) - 1; if (pspec [paramno].cond_end && pspec [paramno].cond_begin) { // change from an if to an else clause @@ -1444,11 +1444,11 @@ *pf++ = 't'; else if (spec.mod == spec.mod_L) { strcpy (pf, _RWSTD_LDBL_PRINTF_PREFIX); - for ( ; *pf; ++pf); + pf += strlen (pf); } else if (spec.mod == spec.mod_ext_A && _RWSTD_LDBL_SIZE == spec.width) { strcpy (pf, _RWSTD_LDBL_PRINTF_PREFIX); - for ( ; *pf; ++pf); + pf += strlen (pf); } if (spec.mod != spec.mod_ext_A && 0 <= spec.width) { @@ -1801,27 +1801,12 @@ template int _rw_quotechar (char *buf, charT wc, int noesc) { -#if _RWSTD_WCHAR_MIN < 0 - // wchar_t is signed, convert its value to unsigned long // without widening (i.e., treat it as an unsigned type) + const _RWSTD_UWCHAR_INT_T wi = + _RWSTD_STATIC_CAST (_RWSTD_UWCHAR_INT_T, wc); -# if _RWSTD_WCHAR_MIN == _RWSTD_SHRT_MIN - const ULong wi = UShrt (wc); -# elif _RWSTD_WCHAR_MIN ==_RWSTD_INT_MIN - const ULong wi = UInt (wc); -# elif _RWSTD_WCHAR_MIN == _RWSTD_LONG_MIN - const ULong wi = ULong (wc); -# endif - -#else // if _RWSTD_WCHAR_MIN >= 0 - - // wchar_t is unsigned - const ULong wi = ULong (wc); - -#endif // _RWSTD_WCHAR_MIN < 0 - - if ((1 == sizeof wc || wi < 0x100) && noesc) { + if ((1 == sizeof wc || wi < 0x100U) && noesc) { buf [0] = char (wc); buf [1] = '\0'; return 1; @@ -2323,8 +2308,11 @@ } /********************************************************************/ +// extern so it can be used in other translation units of the driver +// although it's not mneant to be called directly except by the +// implementation of rw_printf() and friends -extern int +/* extern */ int _rw_fmtstr (const FmtSpec &spec, Buffer &buf, const char *str, size_t len) { if (spec.fl_pound) @@ -3107,8 +3095,11 @@ char *pbuf = varbuf; const size_t varlen = strlen (param) + strlen (val) + 2; - if (sizeof varbuf < varlen) + if (sizeof varbuf < varlen) { pbuf = (char*)malloc (varlen); + if (0 == pbuf) + return -1; + } strcpy (pbuf, param); strcat (pbuf, "="); @@ -3303,7 +3294,7 @@ va_end (va); if (-1 < nchars) - memcpy (buf, tmpbuf, size_t (nchars + 1 /* NUL */)); + memcpy (buf, tmpbuf, size_t (nchars) + 1 /* NUL */); free (tmpbuf); @@ -3327,7 +3318,7 @@ va_end (va); if (size_t (nchars) < bufsize) { - memcpy (buf, tmpbuf, size_t (nchars + 1 /* NUL */)); + memcpy (buf, tmpbuf, size_t (nchars) + 1 /* NUL */); } else { // buffer isn't big enough