Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Fixed warnings, mostly.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/152813

Fixed warnings, mostly.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/152813
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/unit_tests/test_time_parse.cpp'
--- src/unit_tests/test_time_parse.cpp	2013-03-11 15:00:50 +0000
+++ src/unit_tests/test_time_parse.cpp	2013-03-12 03:36:23 +0000
@@ -105,7 +105,7 @@
   iso639_1::type lang = iso639_1::unknown;
   iso3166_1::type country = iso3166_1::unknown;
   ztm tm;
-  char const *bp;
+  char const *bp = nullptr;
 
   ::memset( &tm, 0, sizeof( tm ) );
   ASSERT_NO_EXCEPTION( bp = time::parse( buf, fmt, lang, country, &tm ) );
@@ -127,7 +127,7 @@
   ztm tm;
 
   for ( int i = 0; i < limit; ++i ) {
-    char const *bp;
+    char const *bp = nullptr;
     {
       zstring const buf = (*locale_fn)( i, lang, country );
       ::memset( &tm, 0, sizeof( tm ) );
@@ -187,7 +187,7 @@
   for ( int i = low; i <= high; ++i ) {
     ascii::itoa( i, buf );
     size_t const len = ::strlen( buf );
-    char const *bp;
+    char const *bp = nullptr;
     ::memset( &tm, 0, sizeof( tm ) );
     ASSERT_NO_EXCEPTION( bp = time::parse( buf, conv, lang, country, &tm ) )
     ASSERT_TRUE( bp == buf + len );
@@ -241,7 +241,7 @@
     { "%j %F",  "33 2013-02-01" },      // day is 32
     { "%j %F",  "60 2012-03-01" },      // day is 61
     { "%j %F",  "62 2012-03-01" },      // day is 61
-    0
+    { 0, 0 }
   };
   iso639_1::type lang = iso639_1::unknown;
   iso3166_1::type country = iso3166_1::unknown;
@@ -260,7 +260,7 @@
   iso639_1::type lang = iso639_1::unknown;
   iso3166_1::type country = iso3166_1::unknown;
   ztm tm;
-  char const *bp;
+  char const *bp = nullptr;
 
   ::memset( &tm, 0, sizeof( tm ) );
   ASSERT_NO_EXCEPTION( bp = time::parse( buf, "%D", lang, country, &tm ) )
@@ -275,7 +275,7 @@
   iso639_1::type lang = iso639_1::unknown;
   iso3166_1::type country = iso3166_1::unknown;
   ztm tm;
-  char const *bp;
+  char const *bp = nullptr;
 
   ::memset( &tm, 0, sizeof( tm ) );
   ASSERT_NO_EXCEPTION( bp = time::parse( buf, "%F", lang, country, &tm ) )
@@ -302,7 +302,7 @@
   }
 }
 
-static void test_j() {                  // dat of year: 001-366
+static void test_j() {                  // day of year: 001-366
   char const *const buf = "2012-1-2";
   iso639_1::type lang = iso639_1::unknown;
   iso3166_1::type country = iso3166_1::unknown;
@@ -310,7 +310,7 @@
   char const *bp;
 
   ::memset( &tm, 0, sizeof( tm ) );
-  ASSERT_NO_EXCEPTION( bp = time::parse( buf, "%F", lang, country, &tm ) )
+  ASSERT_NO_EXCEPTION( bp = time::parse( buf, "%j", lang, country, &tm ) )
   ASSERT_TRUE( bp == buf + ::strlen( buf ) );
   ASSERT_TRUE( tm.tm_yday == 0 );
 }
@@ -354,7 +354,7 @@
   ztm tm;
 
   for ( gmt_test const *p = gmt_tests; p->s_off; ++p ) {
-    char const *bp;
+    char const *bp = nullptr;
     ::memset( &tm, 0, sizeof( tm ) );
     ASSERT_NO_EXCEPTION(
       bp = time::parse( p->s_off, "%z", lang, country, &tm )
@@ -408,6 +408,7 @@
   test_D();
   test_F();
   test_invalid_specification();
+  test_j();
   test_literals();
   test_zZ();
 

=== modified file 'src/util/ascii_util.cpp'
--- src/util/ascii_util.cpp	2013-03-11 15:00:50 +0000
+++ src/util/ascii_util.cpp	2013-03-12 03:36:23 +0000
@@ -16,6 +16,7 @@
 #include "stdafx.h"
 
 // standard
+#include <algorithm>
 #include <cstring>
 #include <iomanip>
 
@@ -51,27 +52,20 @@
 
   if ( n_prev < 0 ) *s++ = '-';
   *s = '\0';
-
-  for ( char *t = buf; t < s; ++t ) {
-    char const c = *--s; *s = *t; *t = c;
-  }
+  std::reverse( buf, s );
   return buf;
 }
 
 char* itoa( unsigned long long n, char *buf ) {
   char *s = buf;
-  unsigned long long n_prev;
   do { 
-    n_prev = n;
+    unsigned long long const n_prev = n;
     n /= 10; 
     *s++ = "0123456789" [ n_prev - n * 10 ];
   } while ( n );
 
   *s = '\0';
-
-  for ( char *t = buf; t < s; ++t ) {
-    char const c = *--s; *s = *t; *t = c;
-  }
+  std::reverse( buf, s );
   return buf;
 }
 

=== modified file 'src/util/ascii_util.h'
--- src/util/ascii_util.h	2013-03-11 15:00:50 +0000
+++ src/util/ascii_util.h	2013-03-12 03:36:23 +0000
@@ -665,9 +665,9 @@
 
 /**
  * A type that can hold the largest possible C string equivalent of the largest
- * possible integral value.
+ * possible integral value (assuming 8 bytes for a <code>long long</code>).
  */
-typedef char itoa_buf_type[48];
+typedef char itoa_buf_type[ 20 + 1 /* for null */ ];
 
 /**
  * Converts a <code>long long</code> to a C string.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to