forked from pool/cpprest
Accepting request 860195 from devel:libraries:c_c++
OBS-URL: https://build.opensuse.org/request/show/860195 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cpprest?expand=0&rev=20
This commit is contained in:
158
base64.patch
Normal file
158
base64.patch
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
Index: cpprestsdk-2.10.16/Release/src/utilities/base64.cpp
|
||||||
|
===================================================================
|
||||||
|
--- cpprestsdk-2.10.16.orig/Release/src/utilities/base64.cpp
|
||||||
|
+++ cpprestsdk-2.10.16/Release/src/utilities/base64.cpp
|
||||||
|
@@ -43,30 +43,6 @@ const std::array<unsigned char, 128> _ba
|
||||||
|
23, 24, 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
|
||||||
|
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255}};
|
||||||
|
|
||||||
|
-struct _triple_byte
|
||||||
|
-{
|
||||||
|
- unsigned char _1_1 : 2;
|
||||||
|
- unsigned char _0 : 6;
|
||||||
|
- unsigned char _2_1 : 4;
|
||||||
|
- unsigned char _1_2 : 4;
|
||||||
|
- unsigned char _3 : 6;
|
||||||
|
- unsigned char _2_2 : 2;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-struct _double_byte
|
||||||
|
-{
|
||||||
|
- unsigned char _1_1 : 2;
|
||||||
|
- unsigned char _0 : 6;
|
||||||
|
- unsigned char _2_1 : 4;
|
||||||
|
- unsigned char _1_2 : 4;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-struct _single_byte
|
||||||
|
-{
|
||||||
|
- unsigned char _1_1 : 2;
|
||||||
|
- unsigned char _0 : 6;
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
//
|
||||||
|
// A note on the implementation of BASE64 encoding and decoding:
|
||||||
|
//
|
||||||
|
@@ -134,26 +110,14 @@ std::vector<unsigned char> _from_base64(
|
||||||
|
size_t idx = 0;
|
||||||
|
for (; size > 4; ++idx)
|
||||||
|
{
|
||||||
|
- unsigned char target[3];
|
||||||
|
- memset(target, 0, sizeof(target));
|
||||||
|
- _triple_byte* record = reinterpret_cast<_triple_byte*>(target);
|
||||||
|
-
|
||||||
|
unsigned char val0 = _base64_dectbl[ptr[0]];
|
||||||
|
unsigned char val1 = _base64_dectbl[ptr[1]];
|
||||||
|
unsigned char val2 = _base64_dectbl[ptr[2]];
|
||||||
|
unsigned char val3 = _base64_dectbl[ptr[3]];
|
||||||
|
|
||||||
|
- record->_0 = val0;
|
||||||
|
- record->_1_1 = val1 >> 4;
|
||||||
|
- result[idx] = target[0];
|
||||||
|
-
|
||||||
|
- record->_1_2 = val1 & 0xF;
|
||||||
|
- record->_2_1 = val2 >> 2;
|
||||||
|
- result[++idx] = target[1];
|
||||||
|
-
|
||||||
|
- record->_2_2 = val2 & 0x3;
|
||||||
|
- record->_3 = val3 & 0x3F;
|
||||||
|
- result[++idx] = target[2];
|
||||||
|
+ result[idx] = (val0 << 2) | (val1 >> 4);
|
||||||
|
+ result[++idx] = ((val1 & 0xF) << 4) | (val2 >> 2);
|
||||||
|
+ result[++idx] = ((val2 & 0x3) << 6) | (val3 & 0x3F);
|
||||||
|
|
||||||
|
ptr += 4;
|
||||||
|
size -= 4;
|
||||||
|
@@ -163,45 +127,35 @@ std::vector<unsigned char> _from_base64(
|
||||||
|
// in all the iterations (a performance issue).
|
||||||
|
|
||||||
|
{
|
||||||
|
- unsigned char target[3];
|
||||||
|
- memset(target, 0, sizeof(target));
|
||||||
|
- _triple_byte* record = reinterpret_cast<_triple_byte*>(target);
|
||||||
|
-
|
||||||
|
unsigned char val0 = _base64_dectbl[ptr[0]];
|
||||||
|
unsigned char val1 = _base64_dectbl[ptr[1]];
|
||||||
|
unsigned char val2 = _base64_dectbl[ptr[2]];
|
||||||
|
unsigned char val3 = _base64_dectbl[ptr[3]];
|
||||||
|
|
||||||
|
- record->_0 = val0;
|
||||||
|
- record->_1_1 = val1 >> 4;
|
||||||
|
- result[idx] = target[0];
|
||||||
|
+ result[idx] = (val0 << 2) | (val1 >> 4);
|
||||||
|
|
||||||
|
- record->_1_2 = val1 & 0xF;
|
||||||
|
if (val2 != 254)
|
||||||
|
{
|
||||||
|
- record->_2_1 = val2 >> 2;
|
||||||
|
- result[++idx] = target[1];
|
||||||
|
+ result[++idx] = ((val1 & 0xF) << 4) | (val2 >> 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// There shouldn't be any information (ones) in the unused bits,
|
||||||
|
- if (record->_1_2 != 0)
|
||||||
|
+ if ((val1 & 0xF) != 0)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Invalid end of base64 string");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- record->_2_2 = val2 & 0x3;
|
||||||
|
if (val3 != 254)
|
||||||
|
{
|
||||||
|
- record->_3 = val3 & 0x3F;
|
||||||
|
- result[++idx] = target[2];
|
||||||
|
+ result[++idx] = ((val2 & 0x3) << 6) | (val3 & 0x3F);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// There shouldn't be any information (ones) in the unused bits.
|
||||||
|
- if (record->_2_2 != 0)
|
||||||
|
+ if ((val2 & 0x3) != 0)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Invalid end of base64 string");
|
||||||
|
}
|
||||||
|
@@ -218,11 +172,10 @@ utility::string_t _to_base64(const unsig
|
||||||
|
|
||||||
|
for (; size >= 3;)
|
||||||
|
{
|
||||||
|
- const _triple_byte* record = reinterpret_cast<const _triple_byte*>(ptr);
|
||||||
|
- unsigned char idx0 = record->_0;
|
||||||
|
- unsigned char idx1 = (record->_1_1 << 4) | record->_1_2;
|
||||||
|
- unsigned char idx2 = (record->_2_1 << 2) | record->_2_2;
|
||||||
|
- unsigned char idx3 = record->_3;
|
||||||
|
+ unsigned char idx0 = ptr[0] >> 2;
|
||||||
|
+ unsigned char idx1 = ((ptr[0] & 0x3) << 4) | (ptr[1] >> 4);
|
||||||
|
+ unsigned char idx2 = ((ptr[1] & 0xF) << 2) | (ptr[2] >> 6);
|
||||||
|
+ unsigned char idx3 = ptr[2] & 0x3F;
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx0]));
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx1]));
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx2]));
|
||||||
|
@@ -234,9 +187,8 @@ utility::string_t _to_base64(const unsig
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
- const _single_byte* record = reinterpret_cast<const _single_byte*>(ptr);
|
||||||
|
- unsigned char idx0 = record->_0;
|
||||||
|
- unsigned char idx1 = (record->_1_1 << 4);
|
||||||
|
+ unsigned char idx0 = ptr[0] >> 2;
|
||||||
|
+ unsigned char idx1 = ((ptr[0] & 0x3) << 4);
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx0]));
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx1]));
|
||||||
|
result.push_back('=');
|
||||||
|
@@ -245,10 +197,9 @@ utility::string_t _to_base64(const unsig
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
- const _double_byte* record = reinterpret_cast<const _double_byte*>(ptr);
|
||||||
|
- unsigned char idx0 = record->_0;
|
||||||
|
- unsigned char idx1 = (record->_1_1 << 4) | record->_1_2;
|
||||||
|
- unsigned char idx2 = (record->_2_1 << 2);
|
||||||
|
+ unsigned char idx0 = ptr[0] >> 2;
|
||||||
|
+ unsigned char idx1 = ((ptr[0] & 0x3) << 4) | (ptr[1] >> 4);
|
||||||
|
+ unsigned char idx2 = ((ptr[1] & 0xF) << 2);
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx0]));
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx1]));
|
||||||
|
result.push_back(char_t(_base64_enctbl[idx2]));
|
||||||
@@ -1,20 +1,13 @@
|
|||||||
diff --git a/Release/tests/functional/streams/istream_tests.cpp b/Release/tests/functional/streams/istream_tests.cpp
|
Index: cpprestsdk-2.10.16/Release/tests/functional/streams/istream_tests.cpp
|
||||||
index d1018e31..66b3f801 100644
|
===================================================================
|
||||||
--- a/Release/tests/functional/streams/istream_tests.cpp
|
--- cpprestsdk-2.10.16.orig/Release/tests/functional/streams/istream_tests.cpp
|
||||||
+++ b/Release/tests/functional/streams/istream_tests.cpp
|
+++ cpprestsdk-2.10.16/Release/tests/functional/streams/istream_tests.cpp
|
||||||
@@ -1297,6 +1297,7 @@ SUITE(istream_tests)
|
@@ -1305,7 +1305,7 @@ SUITE(istream_tests)
|
||||||
void compare_double(double expected, double actual) { compare_floating(expected, actual, DBL_EPSILON); }
|
test_string.append(" 6E+4.5"); // two numbers merged in exponent
|
||||||
void compare_float(float expected, float actual) { compare_floating(expected, actual, FLT_EPSILON); }
|
test_string.append(" 6E-4.5"); // two numbers merged in exponent
|
||||||
|
test_string.append(" 3.14 -10 +42.0 -1234.567 .01 +0 -0");
|
||||||
+/*
|
-#ifndef __APPLE__
|
||||||
TEST(extract_floating_point)
|
+#if FLT_EVAL_METHOD > 1
|
||||||
{
|
test_string.append(" 12345678901234567890123456789012345678901234567890"); // a big number
|
||||||
std::string test_string;
|
#endif
|
||||||
@@ -1343,6 +1344,7 @@ SUITE(istream_tests)
|
test_string.append(" 9.81E05 6.0221413e+23 1.6e-14"); // numbers with exponent
|
||||||
if (expected == 0) VERIFY_ARE_EQUAL(1 / expected, 1 / actual);
|
|
||||||
} while (!std_istream.eof());
|
|
||||||
}
|
|
||||||
+*/
|
|
||||||
|
|
||||||
TEST(extract_floating_point_with_exceptions)
|
|
||||||
{
|
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Jan 4 11:02:30 UTC 2021 - Andreas Schwab <schwab@suse.de>
|
||||||
|
|
||||||
|
- cpprest-2.10.9-disable-test-extract_floating_point.patch: Only disable
|
||||||
|
the problematic test
|
||||||
|
- base64.patch: Portable base64
|
||||||
|
- filestream.patch: Fix type mismatch in basic_file_buffer
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue May 12 16:39:14 UTC 2020 - Guillaume GARDET <guillaume.gardet@opensuse.org>
|
Tue May 12 16:39:14 UTC 2020 - Guillaume GARDET <guillaume.gardet@opensuse.org>
|
||||||
|
|
||||||
|
|||||||
10
cpprest.spec
10
cpprest.spec
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package cpprest
|
# spec file for package cpprest
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2021 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -22,17 +22,19 @@ Name: cpprest
|
|||||||
Version: 2.10.16
|
Version: 2.10.16
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: C++ REST library
|
Summary: C++ REST library
|
||||||
|
License: MIT AND BSD-3-Clause AND Zlib
|
||||||
# main: MIT (license.txt)
|
# main: MIT (license.txt)
|
||||||
# Websocket++: BSD-3-Clause (ThirdPartyNotices.txt)
|
# Websocket++: BSD-3-Clause (ThirdPartyNotices.txt)
|
||||||
# base64/base64.hpp: Zlib (ThirdPartyNotices.txt)
|
# base64/base64.hpp: Zlib (ThirdPartyNotices.txt)
|
||||||
# sha1/sha1.hpp: BSD-3-Clause (ThirdPartyNotices.txt)
|
# sha1/sha1.hpp: BSD-3-Clause (ThirdPartyNotices.txt)
|
||||||
# common/md5.hpp: Zlib (ThirdPartyNotices.txt)
|
# common/md5.hpp: Zlib (ThirdPartyNotices.txt)
|
||||||
# utf8_validation.hpp: MIT (ThirdPartyNotices.txt)
|
# utf8_validation.hpp: MIT (ThirdPartyNotices.txt)
|
||||||
License: MIT AND BSD-3-Clause AND Zlib
|
|
||||||
URL: https://github.com/Microsoft/cpprestsdk
|
URL: https://github.com/Microsoft/cpprestsdk
|
||||||
Source: https://github.com/Microsoft/cpprestsdk/archive/v%{version}/cpprestsdk-%{version}.tar.gz
|
Source: https://github.com/Microsoft/cpprestsdk/archive/v%{version}/cpprestsdk-%{version}.tar.gz
|
||||||
# https://github.com/Microsoft/cpprestsdk/issues/576
|
# https://github.com/Microsoft/cpprestsdk/issues/576
|
||||||
Patch1: cpprest-2.10.9-disable-test-extract_floating_point.patch
|
Patch1: cpprest-2.10.9-disable-test-extract_floating_point.patch
|
||||||
|
Patch2: base64.patch
|
||||||
|
Patch3: filestream.patch
|
||||||
BuildRequires: cmake >= 3.0
|
BuildRequires: cmake >= 3.0
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
BuildRequires: pkgconfig
|
BuildRequires: pkgconfig
|
||||||
@@ -78,9 +80,9 @@ Development files.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n cpprestsdk-%{version}
|
%setup -q -n cpprestsdk-%{version}
|
||||||
%ifarch aarch64 ppc64 ppc64le
|
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
%endif
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%cmake \
|
%cmake \
|
||||||
|
|||||||
40
filestream.patch
Normal file
40
filestream.patch
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
Index: cpprestsdk-2.10.16/Release/include/cpprest/filestream.h
|
||||||
|
===================================================================
|
||||||
|
--- cpprestsdk-2.10.16.orig/Release/include/cpprest/filestream.h
|
||||||
|
+++ cpprestsdk-2.10.16/Release/include/cpprest/filestream.h
|
||||||
|
@@ -399,7 +399,7 @@ protected:
|
||||||
|
{
|
||||||
|
pplx::extensibility::scoped_recursive_lock_t lck(m_info->m_lock);
|
||||||
|
m_info->m_rdpos += 1;
|
||||||
|
- _CharType ch1 = (_CharType)callback->m_ch;
|
||||||
|
+ _CharType ch1 = callback->m_ch;
|
||||||
|
delete callback;
|
||||||
|
return pplx::task_from_result<int_type>(ch1);
|
||||||
|
}
|
||||||
|
@@ -453,7 +453,7 @@ protected:
|
||||||
|
if (ch == sizeof(_CharType))
|
||||||
|
{
|
||||||
|
pplx::extensibility::scoped_recursive_lock_t lck(m_info->m_lock);
|
||||||
|
- _CharType ch1 = (_CharType)callback->m_ch;
|
||||||
|
+ _CharType ch1 = callback->m_ch;
|
||||||
|
delete callback;
|
||||||
|
return pplx::task_from_result<int_type>(ch1);
|
||||||
|
}
|
||||||
|
@@ -889,7 +889,7 @@ private:
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
- int_type m_ch;
|
||||||
|
+ _CharType m_ch;
|
||||||
|
|
||||||
|
private:
|
||||||
|
_file_info* m_info;
|
||||||
|
@@ -917,7 +917,7 @@ private:
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
- int_type m_ch;
|
||||||
|
+ _CharType m_ch;
|
||||||
|
|
||||||
|
virtual void on_error(const std::exception_ptr& e)
|
||||||
|
{
|
||||||
Reference in New Issue
Block a user