Merge pull request #6132 from haon4/fix_build
Make sure to include zlib.BUILD in our distribution
diff --git a/conformance/failure_list_ruby_mac.txt b/conformance/failure_list_ruby_mac.txt
index 3114cba..876184d 100644
--- a/conformance/failure_list_ruby_mac.txt
+++ b/conformance/failure_list_ruby_mac.txt
@@ -51,11 +51,6 @@
Required.Proto3.JsonInput.RepeatedUint64Wrapper.JsonOutput
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput
-Required.Proto3.JsonInput.TimestampJsonInputTooSmall
-Required.Proto3.JsonInput.TimestampMinValue.JsonOutput
-Required.Proto3.JsonInput.TimestampMinValue.ProtobufOutput
-Required.Proto3.JsonInput.TimestampRepeatedValue.JsonOutput
-Required.Proto3.JsonInput.TimestampRepeatedValue.ProtobufOutput
Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c
index 233c2a2..1d97743 100644
--- a/php/ext/google/protobuf/upb.c
+++ b/php/ext/google/protobuf/upb.c
@@ -10460,6 +10460,48 @@
capture_begin(p, ptr);
}
+#define EPOCH_YEAR 1970
+#define TM_YEAR_BASE 1900
+
+static bool isleap(int year) {
+ return (year % 4) == 0 && (year % 100 != 0 || (year % 400) == 0);
+}
+
+const unsigned short int __mon_yday[2][13] = {
+ /* Normal years. */
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ /* Leap years. */
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+};
+
+int64_t epoch(int year, int yday, int hour, int min, int sec) {
+ int64_t years = year - EPOCH_YEAR;
+
+ int64_t leap_days = years / 4 - years / 100 + years / 400;
+
+ int64_t days = years * 365 + yday + leap_days;
+ int64_t hours = days * 24 + hour;
+ int64_t mins = hours * 60 + min;
+ int64_t secs = mins * 60 + sec;
+ return secs;
+}
+
+
+static int64_t upb_mktime(const struct tm *tp) {
+ int sec = tp->tm_sec;
+ int min = tp->tm_min;
+ int hour = tp->tm_hour;
+ int mday = tp->tm_mday;
+ int mon = tp->tm_mon;
+ int year = tp->tm_year + TM_YEAR_BASE;
+
+ /* Calculate day of year from year, month, and day of month. */
+ int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1);
+ int yday = mon_yday + mday;
+
+ return epoch(year, yday, hour, min, sec);
+}
+
static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
size_t len;
const char *buf;
@@ -10487,7 +10529,7 @@
}
/* Normalize tm */
- seconds = mktime(&p->tm);
+ seconds = upb_mktime(&p->tm);
/* Check timestamp boundary */
if (seconds < -62135596800) {
diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c
index 28bba7f..3d96c5c 100644
--- a/ruby/ext/google/protobuf_c/upb.c
+++ b/ruby/ext/google/protobuf_c/upb.c
@@ -14299,6 +14299,47 @@
capture_begin(p, ptr);
}
+#define EPOCH_YEAR 1970
+#define TM_YEAR_BASE 1900
+
+static bool isleap(int year) {
+ return (year % 4) == 0 && (year % 100 != 0 || (year % 400) == 0);
+}
+
+const unsigned short int __mon_yday[2][13] = {
+ /* Normal years. */
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ /* Leap years. */
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+};
+
+int64_t epoch(int year, int yday, int hour, int min, int sec) {
+ int64_t years = year - EPOCH_YEAR;
+
+ int64_t leap_days = years / 4 - years / 100 + years / 400;
+
+ int64_t days = years * 365 + yday + leap_days;
+ int64_t hours = days * 24 + hour;
+ int64_t mins = hours * 60 + min;
+ int64_t secs = mins * 60 + sec;
+ return secs;
+}
+
+static int64_t upb_mktime(const struct tm *tp) {
+ int sec = tp->tm_sec;
+ int min = tp->tm_min;
+ int hour = tp->tm_hour;
+ int mday = tp->tm_mday;
+ int mon = tp->tm_mon;
+ int year = tp->tm_year + TM_YEAR_BASE;
+
+ /* Calculate day of year from year, month, and day of month. */
+ int mon_yday = ((__mon_yday[isleap(year)][mon]) - 1);
+ int yday = mon_yday + mday;
+
+ return epoch(year, yday, hour, min, sec);
+}
+
static bool end_timestamp_zone(upb_json_parser *p, const char *ptr) {
size_t len;
const char *buf;
@@ -14325,7 +14366,7 @@
}
/* Normalize tm */
- seconds = mktime(&p->tm) - timezone;
+ seconds = upb_mktime(&p->tm);
seconds += 3600 * hours;
/* Check timestamp boundary */
diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec
index 2b095f4..0f7cc0a 100644
--- a/ruby/google-protobuf.gemspec
+++ b/ruby/google-protobuf.gemspec
@@ -20,6 +20,7 @@
s.test_files = ["tests/basic.rb",
"tests/stress.rb",
"tests/generated_code_test.rb"]
+ s.required_ruby_version = '>= 2.3'
s.add_development_dependency "rake-compiler", "~> 0.9.5"
s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9'
s.add_development_dependency "rubygems-tasks", "~> 0.2.4"
diff --git a/update_version.py b/update_version.py
index ab203d6..dfa53f7 100755
--- a/update_version.py
+++ b/update_version.py
@@ -155,13 +155,13 @@
RewriteXml('csharp/src/Google.Protobuf/Google.Protobuf.csproj',
lambda document : ReplaceText(
Find(Find(document.documentElement, 'PropertyGroup'), 'VersionPrefix'),
- GetFullVersion(rc_suffix = '-rc.')),
+ GetFullVersion(rc_suffix = '-rc')),
add_xml_prefix=False)
RewriteXml('csharp/Google.Protobuf.Tools.nuspec',
lambda document : ReplaceText(
Find(Find(document.documentElement, 'metadata'), 'version'),
- GetFullVersion(rc_suffix = '-rc.')))
+ GetFullVersion(rc_suffix = '-rc')))
def UpdateJava():