stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r653285 - /stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp
Date Mon, 05 May 2008 00:09:29 GMT
Author: sebor
Date: Sun May  4 17:09:29 2008
New Revision: 653285

URL: http://svn.apache.org/viewvc?rev=653285&view=rev
Log:
2008-05-04  Martin Sebor  <sebor@roguewave.com>

	* tests/localization/22.locale.time.put.cpp (do_test): Used casts
	to safely convert a plain char argument to the generic charT before
	passing it to the tested function to silence HP aCC remark #4271-D:
	type conversion may lose sign.
	(make_LC_TIME): Handled fopen() failure to silence warning #20200-D:
	Potential null pointer dereference is detected.

Modified:
    stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp?rev=653285&r1=653284&r2=653285&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp Sun May  4 17:09:29 2008
@@ -405,10 +405,15 @@
 
     std::ostreambuf_iterator<charT> it (&sb);
 
+    // convert the narrow fill character to the generic charT
+    // being careful to avoid (potential) sign extension
+    typedef unsigned char UChar;
+    const charT wfill = charT (UChar (fill));
+
     if (patend - pat == 2 && '%' == pat [0]) {
 
         // format character, no modifier
-        *tp.put (it, ios, fill, tmb, char (wpat [1])) = charT ();
+        *tp.put (it, ios, wfill, tmb, char (wpat [1])) = charT ();
 
         const bool success = 0 == rw_strncmp (buf, result);
 
@@ -425,7 +430,7 @@
     else if (patend - pat == 3 && '%' == pat [0]) {
 
         // format character preceded by a format modifier
-        *tp.put (it, ios, fill, tmb, char (wpat [2]), char (wpat [1])) =
+        *tp.put (it, ios, wfill, tmb, char (wpat [2]), char (wpat [1])) =
             charT ();
 
         const bool success = 0 == rw_strncmp (buf, result);
@@ -442,7 +447,7 @@
     sb.pubsetp (buf, buf + sizeof buf / sizeof *buf);
 
     // format string
-    *tp.put (it, ios, fill, tmb, wpat, wpat + (patend - pat)) = charT ();
+    *tp.put (it, ios, wfill, tmb, wpat, wpat + (patend - pat)) = charT ();
 
     const bool success = 0 == rw_strncmp (buf, result);
 
@@ -507,6 +512,8 @@
         return 0;
 
     std::FILE *fout = std::fopen (srcfname, "w");
+    if (0 == fout)
+        return 0;
 
     std::fprintf (fout, "LC_TIME\n");
 
@@ -643,6 +650,9 @@
         return 0;
 
     fout = std::fopen (cmfname, "w");
+    if (0 == fout)
+        return 0;
+
     pcs_write (fout, 0);
 
     std::fclose (fout);



Mime
View raw message