Unverified Commit bfa2908d authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #802 from zyearn/third_party_related

remove conflict third party lib
parents fe556250 568dba34
......@@ -111,7 +111,6 @@ BUTIL_SRCS = [
"src/butil/third_party/icu/icu_utf.cc",
"src/butil/third_party/superfasthash/superfasthash.c",
"src/butil/third_party/modp_b64/modp_b64.cc",
"src/butil/third_party/nspr/prtime.cc",
"src/butil/third_party/symbolize/demangle.cc",
"src/butil/third_party/symbolize/symbolize.cc",
"src/butil/third_party/snappy/snappy-sinksource.cc",
......
......@@ -207,7 +207,6 @@ set(BUTIL_SOURCES
${PROJECT_SOURCE_DIR}/src/butil/third_party/icu/icu_utf.cc
${PROJECT_SOURCE_DIR}/src/butil/third_party/superfasthash/superfasthash.c
${PROJECT_SOURCE_DIR}/src/butil/third_party/modp_b64/modp_b64.cc
${PROJECT_SOURCE_DIR}/src/butil/third_party/nspr/prtime.cc
${PROJECT_SOURCE_DIR}/src/butil/third_party/symbolize/demangle.cc
${PROJECT_SOURCE_DIR}/src/butil/third_party/symbolize/symbolize.cc
${PROJECT_SOURCE_DIR}/src/butil/third_party/snappy/snappy-sinksource.cc
......
......@@ -40,7 +40,6 @@ BUTIL_SOURCES = \
src/butil/third_party/icu/icu_utf.cc \
src/butil/third_party/superfasthash/superfasthash.c \
src/butil/third_party/modp_b64/modp_b64.cc \
src/butil/third_party/nspr/prtime.cc \
src/butil/third_party/symbolize/demangle.cc \
src/butil/third_party/symbolize/symbolize.cc \
src/butil/third_party/snappy/snappy-sinksource.cc \
......
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
Name: Netscape Portable Runtime (NSPR)
URL: http://www.mozilla.org/projects/nspr/
License: MPL 1.1/GPL 2.0/LGPL 2.1
This diff is collapsed.
/* Portions are Copyright (C) 2011 Google Inc */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
*---------------------------------------------------------------------------
*
* prtime.h --
*
* NSPR date and time functions
* CVS revision 3.10
* This file contains definitions of NSPR's basic types required by
* prtime.cc. These types have been copied over from the following NSPR
* files prtime.h, prtypes.h(CVS revision 3.35), prlong.h(CVS revision 3.13)
*
*---------------------------------------------------------------------------
*/
#ifndef BUTIL_PRTIME_H__
#define BUTIL_PRTIME_H__
#include <stdint.h>
#include "butil/base_export.h"
typedef int8_t PRInt8;
typedef int16_t PRInt16;
typedef int32_t PRInt32;
typedef int64_t PRInt64;
typedef int PRIntn;
typedef PRIntn PRBool;
#define PR_TRUE 1
#define PR_FALSE 0
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
#define PR_ASSERT DCHECK
#define PR_CALLBACK
#define PR_INT16_MAX 32767
#define NSPR_API(__type) extern __type
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
#define PR_MSEC_PER_SEC 1000UL
#define PR_USEC_PER_SEC 1000000UL
#define PR_NSEC_PER_SEC 1000000000UL
#define PR_USEC_PER_MSEC 1000UL
#define PR_NSEC_PER_MSEC 1000000UL
/*
* PRTime --
*
* NSPR represents basic time as 64-bit signed integers relative
* to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
* (GMT is also known as Coordinated Universal Time, UTC.)
* The units of time are in microseconds. Negative times are allowed
* to represent times prior to the January 1970 epoch. Such values are
* intended to be exported to other systems or converted to human
* readable form.
*
* Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0
* simply uses PRInt64.
*/
typedef PRInt64 PRTime;
/*
* Time zone and daylight saving time corrections applied to GMT to
* obtain the local time of some geographic location
*/
typedef struct PRTimeParameters {
PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */
PRInt32 tp_dst_offset; /* contribution of DST in seconds */
} PRTimeParameters;
/*
* PRExplodedTime --
*
* Time broken down into human-readable components such as year, month,
* day, hour, minute, second, and microsecond. Time zone and daylight
* saving time corrections may be applied. If they are applied, the
* offsets from the GMT must be saved in the 'tm_params' field so that
* all the information is available to reconstruct GMT.
*
* Notes on porting: PRExplodedTime corrresponds to struct tm in
* ANSI C, with the following differences:
* - an additional field tm_usec;
* - replacing tm_isdst by tm_params;
* - the month field is spelled tm_month, not tm_mon;
* - we use absolute year, AD, not the year since 1900.
* The corresponding type in NSPR 1.0 is called PRTime. Below is
* a table of date/time type correspondence in the three APIs:
* API time since epoch time in components
* ANSI C time_t struct tm
* NSPR 1.0 PRInt64 PRTime
* NSPR 2.0 PRTime PRExplodedTime
*/
typedef struct PRExplodedTime {
PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */
PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating
up to two leap seconds) */
PRInt32 tm_min; /* minutes past tm_hour (0-59) */
PRInt32 tm_hour; /* hours past tm_day (0-23) */
PRInt32 tm_mday; /* days past tm_mon (1-31, note that it
starts from 1) */
PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */
PRInt16 tm_year; /* absolute year, AD (note that we do not
count from 1900) */
PRInt8 tm_wday; /* calculated day of the week
(0-6, Sun = 0) */
PRInt16 tm_yday; /* calculated day of the year
(0-365, Jan 1 = 0) */
PRTimeParameters tm_params; /* time parameters used by conversion */
} PRExplodedTime;
/*
* PRTimeParamFn --
*
* A function of PRTimeParamFn type returns the time zone and
* daylight saving time corrections for some geographic location,
* given the current time in GMT. The input argument gmt should
* point to a PRExplodedTime that is in GMT, i.e., whose
* tm_params contains all 0's.
*
* For any time zone other than GMT, the computation is intended to
* consist of two steps:
* - Figure out the time zone correction, tp_gmt_offset. This number
* usually depends on the geographic location only. But it may
* also depend on the current time. For example, all of China
* is one time zone right now. But this situation may change
* in the future.
* - Figure out the daylight saving time correction, tp_dst_offset.
* This number depends on both the geographic location and the
* current time. Most of the DST rules are expressed in local
* current time. If so, one should apply the time zone correction
* to GMT before applying the DST rules.
*/
typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
NSPR_API(PRTime)
PR_ImplodeTime(const PRExplodedTime *exploded);
/*
* Adjust exploded time to normalize field overflows after manipulation.
* Note that the following fields of PRExplodedTime should not be
* manipulated:
* - tm_month and tm_year: because the number of days in a month and
* number of days in a year are not constant, it is ambiguous to
* manipulate the month and year fields, although one may be tempted
* to. For example, what does "a month from January 31st" mean?
* - tm_wday and tm_yday: these fields are calculated by NSPR. Users
* should treat them as "read-only".
*/
NSPR_API(void) PR_NormalizeTime(
PRExplodedTime *exploded, PRTimeParamFn params);
/**********************************************************************/
/*********************** TIME PARAMETER FUNCTIONS *********************/
/**********************************************************************/
/* Time parameters that represent Greenwich Mean Time */
NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt);
/*
* This parses a time/date string into a PRTime
* (microseconds after "1-Jan-1970 00:00:00 GMT").
* It returns PR_SUCCESS on success, and PR_FAILURE
* if the time/date string can't be parsed.
*
* Many formats are handled, including:
*
* 14 Apr 89 03:20:12
* 14 Apr 89 03:20 GMT
* Fri, 17 Mar 89 4:01:33
* Fri, 17 Mar 89 4:01 GMT
* Mon Jan 16 16:12 PDT 1989
* Mon Jan 16 16:12 +0130 1989
* 6 May 1992 16:41-JST (Wednesday)
* 22-AUG-1993 10:59:12.82
* 22-AUG-1993 10:59pm
* 22-AUG-1993 12:59am
* 22-AUG-1993 12:59 PM
* Friday, August 04, 1995 3:54 PM
* 06/21/95 04:24:34 PM
* 20/06/95 21:07
* 95-06-08 19:32:48 EDT
* 1995-06-17T23:11:25.342156Z
*
* If the input string doesn't contain a description of the timezone,
* we consult the `default_to_gmt' to decide whether the string should
* be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE).
* The correct value for this argument depends on what standard specified
* the time string which you are parsing.
*/
/*
* This is the only funtion that should be called from outside base, and only
* from the unit test.
*/
BUTIL_EXPORT PRStatus PR_ParseTimeString (
const char *string,
PRBool default_to_gmt,
PRTime *result);
#endif // BUTIL_PRTIME_H__
......@@ -10,7 +10,6 @@
#include "butil/float_util.h"
#include "butil/lazy_instance.h"
#include "butil/logging.h"
#include "butil/third_party/nspr/prtime.h"
namespace butil {
......@@ -213,21 +212,9 @@ Time Time::LocalMidnight() const {
bool Time::FromStringInternal(const char* time_string,
bool is_local,
Time* parsed_time) {
DCHECK((time_string != NULL) && (parsed_time != NULL));
if (time_string[0] == '\0')
return false;
PRTime result_time = 0;
PRStatus result = PR_ParseTimeString(time_string,
is_local ? PR_FALSE : PR_TRUE,
&result_time);
if (PR_SUCCESS != result)
return false;
result_time += kTimeTToMicrosecondsOffset;
*parsed_time = Time(result_time);
return true;
// TODO(zhujiashun): after removing nspr, this function
// is left unimplemented.
return false;
}
// Local helper class to hold the conversion from Time to TickTime at the
......
......@@ -114,7 +114,6 @@ TEST_BUTIL_SOURCES = [
"thread_local_storage_unittest.cc",
"thread_local_unittest.cc",
"watchdog_unittest.cc",
"pr_time_unittest.cc",
"time_unittest.cc",
"version_unittest.cc",
"logging_unittest.cc",
......
......@@ -127,7 +127,6 @@ SET(TEST_BUTIL_SOURCES
${PROJECT_SOURCE_DIR}/test/thread_local_storage_unittest.cc
${PROJECT_SOURCE_DIR}/test/thread_local_unittest.cc
${PROJECT_SOURCE_DIR}/test/watchdog_unittest.cc
${PROJECT_SOURCE_DIR}/test/pr_time_unittest.cc
${PROJECT_SOURCE_DIR}/test/time_unittest.cc
${PROJECT_SOURCE_DIR}/test/version_unittest.cc
${PROJECT_SOURCE_DIR}/test/logging_unittest.cc
......
......@@ -96,7 +96,6 @@ TEST_BUTIL_SOURCES = \
thread_local_storage_unittest.cc \
thread_local_unittest.cc \
watchdog_unittest.cc \
pr_time_unittest.cc \
time_unittest.cc \
version_unittest.cc \
logging_unittest.cc \
......
......@@ -2128,17 +2128,15 @@ TEST_F(FileUtilTest, TouchFile) {
std::string data("hello");
ASSERT_TRUE(WriteFile(foobar, data.c_str(), data.length()));
Time access_time;
// This timestamp is divisible by one day (in local timezone),
// to make it work on FAT too.
ASSERT_TRUE(Time::FromString("Wed, 16 Nov 1994, 00:00:00",
&access_time));
// 784915200000000 represents the timestamp of "Wed, 16 Nov 1994, 00:00:00".
// This timestamp is divisible by one day (in local timezone), to make it work
// on FAT too.
Time access_time(784915200000000);
Time modification_time;
// 784903526000000 represents the timestamp of "Tue, 15 Nov 1994, 12:45:26 GMT".
// Note that this timestamp is divisible by two (seconds) - FAT stores
// modification times with 2s resolution.
ASSERT_TRUE(Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT",
&modification_time));
Time modification_time(784903526000000);
ASSERT_TRUE(TouchFile(foobar, access_time, modification_time));
File::Info file_info;
......
This diff is collapsed.
......@@ -161,7 +161,10 @@ TEST_F(TimeTest, LocalMidnight) {
EXPECT_EQ(0, exploded.millisecond);
}
TEST_F(TimeTest, ParseTimeTest1) {
// TODO(zhujiashun): Time::FromString is not implemented after removing nspr,
// so all tests using this function is disabled. Enable those tests once
// Time::FromString is implemented.
TEST_F(TimeTest, DISABLED_ParseTimeTest1) {
time_t current_time = 0;
time(&current_time);
......@@ -182,7 +185,7 @@ TEST_F(TimeTest, ParseTimeTest1) {
EXPECT_EQ(current_time, parsed_time.ToTimeT());
}
TEST_F(TimeTest, DayOfWeekSunday) {
TEST_F(TimeTest, DISABLED_DayOfWeekSunday) {
Time time;
EXPECT_TRUE(Time::FromString("Sun, 06 May 2012 12:00:00 GMT", &time));
Time::Exploded exploded;
......@@ -190,7 +193,7 @@ TEST_F(TimeTest, DayOfWeekSunday) {
EXPECT_EQ(0, exploded.day_of_week);
}
TEST_F(TimeTest, DayOfWeekWednesday) {
TEST_F(TimeTest, DISABLED_DayOfWeekWednesday) {
Time time;
EXPECT_TRUE(Time::FromString("Wed, 09 May 2012 12:00:00 GMT", &time));
Time::Exploded exploded;
......@@ -198,7 +201,7 @@ TEST_F(TimeTest, DayOfWeekWednesday) {
EXPECT_EQ(3, exploded.day_of_week);
}
TEST_F(TimeTest, DayOfWeekSaturday) {
TEST_F(TimeTest, DISABLED_DayOfWeekSaturday) {
Time time;
EXPECT_TRUE(Time::FromString("Sat, 12 May 2012 12:00:00 GMT", &time));
Time::Exploded exploded;
......@@ -206,62 +209,62 @@ TEST_F(TimeTest, DayOfWeekSaturday) {
EXPECT_EQ(6, exploded.day_of_week);
}
TEST_F(TimeTest, ParseTimeTest2) {
TEST_F(TimeTest, DISABLED_ParseTimeTest2) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time));
EXPECT_EQ(comparison_time_pdt_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest3) {
TEST_F(TimeTest, DISABLED_ParseTimeTest3) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time));
EXPECT_EQ(comparison_time_local_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest4) {
TEST_F(TimeTest, DISABLED_ParseTimeTest4) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time));
EXPECT_EQ(comparison_time_pdt_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest5) {
TEST_F(TimeTest, DISABLED_ParseTimeTest5) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time));
EXPECT_EQ(comparison_time_pdt_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest6) {
TEST_F(TimeTest, DISABLED_ParseTimeTest6) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time));
EXPECT_EQ(comparison_time_local_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest7) {
TEST_F(TimeTest, DISABLED_ParseTimeTest7) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time));
EXPECT_EQ(comparison_time_local_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest8) {
TEST_F(TimeTest, DISABLED_ParseTimeTest8) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time));
EXPECT_EQ(comparison_time_local_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest9) {
TEST_F(TimeTest, DISABLED_ParseTimeTest9) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time));
EXPECT_EQ(comparison_time_pdt_, parsed_time);
}
TEST_F(TimeTest, ParseTimeTest10) {
TEST_F(TimeTest, DISABLED_ParseTimeTest10) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time));
EXPECT_EQ(parsed_time, comparison_time_local_);
}
// Test some of edge cases around epoch, etc.
TEST_F(TimeTest, ParseTimeTestEpoch0) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch0) {
Time parsed_time;
// time_t == epoch == 0
......@@ -273,7 +276,7 @@ TEST_F(TimeTest, ParseTimeTestEpoch0) {
EXPECT_EQ(0, parsed_time.ToTimeT());
}
TEST_F(TimeTest, ParseTimeTestEpoch1) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch1) {
Time parsed_time;
// time_t == 1 second after epoch == 1
......@@ -285,7 +288,7 @@ TEST_F(TimeTest, ParseTimeTestEpoch1) {
EXPECT_EQ(1, parsed_time.ToTimeT());
}
TEST_F(TimeTest, ParseTimeTestEpoch2) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch2) {
Time parsed_time;
// time_t == 2 seconds after epoch == 2
......@@ -297,7 +300,7 @@ TEST_F(TimeTest, ParseTimeTestEpoch2) {
EXPECT_EQ(2, parsed_time.ToTimeT());
}
TEST_F(TimeTest, ParseTimeTestEpochNeg1) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpochNeg1) {
Time parsed_time;
// time_t == 1 second before epoch == -1
......@@ -312,7 +315,7 @@ TEST_F(TimeTest, ParseTimeTestEpochNeg1) {
// If time_t is 32 bits, a date after year 2038 will overflow time_t and
// cause timegm() to return -1. The parsed time should not be 1 second
// before epoch.
TEST_F(TimeTest, ParseTimeTestEpochNotNeg1) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpochNotNeg1) {
Time parsed_time;
EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100",
......@@ -320,7 +323,7 @@ TEST_F(TimeTest, ParseTimeTestEpochNotNeg1) {
EXPECT_NE(-1, parsed_time.ToTimeT());
}
TEST_F(TimeTest, ParseTimeTestEpochNeg2) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpochNeg2) {
Time parsed_time;
// time_t == 2 seconds before epoch == -2
......@@ -332,7 +335,7 @@ TEST_F(TimeTest, ParseTimeTestEpochNeg2) {
EXPECT_EQ(-2, parsed_time.ToTimeT());
}
TEST_F(TimeTest, ParseTimeTestEpoch1960) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch1960) {
Time parsed_time;
// time_t before Epoch, in 1960
......@@ -347,12 +350,12 @@ TEST_F(TimeTest, ParseTimeTestEpoch1960) {
EXPECT_EQ(-300003599, parsed_time.ToTimeT());
}
TEST_F(TimeTest, ParseTimeTestEmpty) {
TEST_F(TimeTest, DISABLED_ParseTimeTestEmpty) {
Time parsed_time;
EXPECT_FALSE(Time::FromString("", &parsed_time));
}
TEST_F(TimeTest, ParseTimeTestInvalidString) {
TEST_F(TimeTest, DISABLED_ParseTimeTestInvalidString) {
Time parsed_time;
EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment