From fe267b43d5fe5740a0307f63f8e93672c90a355f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 10 Feb 2009 14:47:07 +0000 Subject: [PATCH] 2009-02-10 Tatsuhiro Tsujikawa Don't use Time::parse(buf, "%Y%m%d%H%M%S") because Mac OS X and included strptime doesn't parse data for this format. * src/FtpConnection.cc * test/FtpConnectionTest.cc --- ChangeLog | 7 +++++++ src/FtpConnection.cc | 6 ++---- test/FtpConnectionTest.cc | 7 +++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c50046a..f84e7a4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-02-10 Tatsuhiro Tsujikawa + + Don't use Time::parse(buf, "%Y%m%d%H%M%S") because Mac OS X and + included strptime doesn't parse data for this format. + * src/FtpConnection.cc + * test/FtpConnectionTest.cc + 2009-02-10 Tatsuhiro Tsujikawa Removed tests giving -1 for unsigned argument. diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 49d8a15a..b3f004d4 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -367,9 +367,8 @@ unsigned int FtpConnection::receiveMdtmResponse(Time& time) char buf[15]; // YYYYMMDDhhmmss+\0, milli second part is dropped. sscanf(response.second.c_str(), "%*u %14s", buf); if(strlen(buf) == 14) { -#ifdef HAVE_STRPTIME - time = Time::parse(buf, "%Y%m%d%H%M%S"); -#else // !HAVE_STRPTIME + // We don't use Time::parse(buf,"%Y%m%d%H%M%S") here because Mac OS X + // and included strptime doesn't parse data for this format. struct tm tm; memset(&tm, 0, sizeof(tm)); tm.tm_sec = Util::parseInt(&buf[12]); @@ -384,7 +383,6 @@ unsigned int FtpConnection::receiveMdtmResponse(Time& time) buf[4] = '\0'; tm.tm_year = Util::parseInt(&buf[0])-1900; time = Time(timegm(&tm)); -#endif // !HAVE_STRPTIME } else { time = Time::null(); } diff --git a/test/FtpConnectionTest.cc b/test/FtpConnectionTest.cc index d11158b7..b636a335 100644 --- a/test/FtpConnectionTest.cc +++ b/test/FtpConnectionTest.cc @@ -172,14 +172,13 @@ void FtpConnectionTest::testReceiveMdtmResponse() CPPUNIT_ASSERT(t.bad()); } { -#ifdef HAVE_STRPTIME - // invalid month: 19 + // invalid month: 19, we don't care about invalid month.. Time t; _serverSocket->writeData("213 20081908124312\r\n"); waitRead(_clientSocket); CPPUNIT_ASSERT_EQUAL((unsigned int)213, _ftp->receiveMdtmResponse(t)); - CPPUNIT_ASSERT(t.bad()); -#endif + // Wed Jul 8 12:43:12 2009 + CPPUNIT_ASSERT_EQUAL((time_t)1247056992, t.getTime()); } { Time t;