Changeset 54256 in webkit


Ignore:
Timestamp:
Feb 2, 2010 2:50:41 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-02 Kwang Yul Seo <skyul@company100.net>

Reviewed by Eric Seidel.

Use WTF::getLocalTime instead of localtime_r in FTPDirectoryDocument
https://bugs.webkit.org/show_bug.cgi?id=34409

Platform guards for localtime_r are not needed because we already have
WTF::getLocalTime which does the same thing.

  • loader/FTPDirectoryDocument.cpp: (WebCore::processFileDateString):
  • loader/FTPDirectoryParser.cpp: (WebCore::gmtimeQt):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54250 r54256  
     12010-02-02  Kwang Yul Seo  <skyul@company100.net>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Use WTF::getLocalTime instead of localtime_r in FTPDirectoryDocument
     6        https://bugs.webkit.org/show_bug.cgi?id=34409
     7
     8        Platform guards for localtime_r are not needed because we already have
     9        WTF::getLocalTime which does the same thing.
     10
     11        * loader/FTPDirectoryDocument.cpp:
     12        (WebCore::processFileDateString):
     13        * loader/FTPDirectoryParser.cpp:
     14        (WebCore::gmtimeQt):
     15
    1162010-02-02  Adam Roben  <aroben@apple.com>
    217
  • trunk/WebCore/loader/FTPDirectoryDocument.cpp

    r52791 r54256  
    3939#include "SharedBuffer.h"
    4040#include "Text.h"
     41
     42#include <wtf/CurrentTime.h>
    4143#include <wtf/StdLibExtras.h>
    42 
    43 #if PLATFORM(QT)
    44 #include <QDateTime>
    45 // On Windows, use the threadsafe *_r functions provided by pthread.
    46 #elif OS(WINDOWS) && (USE(PTHREADS) || HAVE(PTHREAD_H))
    47 #include <pthread.h>
    48 #endif
    4944
    5045using namespace std;
     
    201196}
    202197
    203 #if PLATFORM(QT)
    204 
    205 /*!
    206  Replacement for localtime_r() which is not available on MinGW.
    207 
    208  We use this on all of Qt's platforms for portability.
    209  */
    210 struct tm gmtimeQt(const QDateTime &input)
    211 {
    212     tm result;
    213 
    214     const QDate date(input.date());
    215     result.tm_year = date.year() - 1900;
    216     result.tm_mon = date.month();
    217     result.tm_mday = date.day();
    218     result.tm_wday = date.dayOfWeek();
    219     result.tm_yday = date.dayOfYear();
    220 
    221     const QTime time(input.time());
    222     result.tm_sec = time.second();
    223     result.tm_min = time.minute();
    224     result.tm_hour = time.hour();
    225 
    226     return result;
    227 }
    228 
    229 static struct tm *localTimeQt(const time_t *const timep, struct tm *result)
    230 {
    231     const QDateTime dt(QDateTime::fromTime_t(*timep));
    232     *result = WebCore::gmtimeQt(dt.toLocalTime());
    233     return result;
    234 }
    235 
    236 #define localtime_r(x, y) localTimeQt(x, y)
    237 #elif OS(WINDOWS) && !defined(localtime_r)
    238 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
    239 #define localtime_r(x, y) localtime_s((y), (x))
    240 #else /* !_MSC_VER */
    241 #define localtime_r(x,y) (localtime(x)?(*(y)=*localtime(x),(y)):0)
    242 #endif
    243 #endif
    244 
    245198static String processFileDateString(const FTPTime& fileTime)
    246199{
     
    268221    struct tm now;
    269222    time_t now_t = time(NULL);
    270     localtime_r(&now_t, &now);
     223    getLocalTime(&now_t, &now);
    271224   
    272225    // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
  • trunk/WebCore/loader/FTPDirectoryParser.cpp

    r53809 r54256  
    3939namespace WebCore {
    4040#if PLATFORM(QT) && defined(Q_WS_WIN32)
    41 // Defined in FTPDirectoryDocument.cpp.
    42 struct tm gmtimeQt(const QDateTime &input);
     41
     42// Replacement for gmtime_r() which is not available on MinGW.
     43// We use this on Win32 Qt platform for portability.
     44struct tm gmtimeQt(const QDateTime& input)
     45{
     46    tm result;
     47
     48    QDate date(input.date());
     49    result.tm_year = date.year() - 1900;
     50    result.tm_mon = date.month();
     51    result.tm_mday = date.day();
     52    result.tm_wday = date.dayOfWeek();
     53    result.tm_yday = date.dayOfYear();
     54
     55    QTime time(input.time());
     56    result.tm_sec = time.second();
     57    result.tm_min = time.minute();
     58    result.tm_hour = time.hour();
     59
     60    return result;
     61}
    4362
    4463static struct tm *gmtimeQt(const time_t *const timep, struct tm *result)
Note: See TracChangeset for help on using the changeset viewer.