changeset 298:8af39c019eb6

MFD
author David Demelier <markand@malikania.fr>
date Thu, 13 Nov 2014 21:10:21 +0100
parents 30a969b658c1 (current diff) 5806c767aec7 (diff)
children 24085fae3162
files
diffstat 7 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/C++/Pack.h	Thu Nov 13 13:55:36 2014 +0100
+++ b/C++/Pack.h	Thu Nov 13 21:10:21 2014 +0100
@@ -366,7 +366,7 @@
 
 template <>
 struct Pack::TypeInfo<uint8_t> : public Pack::Convertible {
-	static constexpr void convert(uint8_t &) noexcept
+	static inline void convert(uint8_t &) noexcept
 	{
 		// uint8_t are endian independent
 	}
@@ -374,7 +374,7 @@
 
 template <>
 struct Pack::TypeInfo<uint16_t> : public Pack::Convertible {
-	static constexpr void convert(uint16_t &v)
+	static inline void convert(uint16_t &v)
 	{
 		v = (((v >> 8) & 0x00FFL) | ((v << 8) & 0xFF00L));
 	}
@@ -382,7 +382,7 @@
 
 template <>
 struct Pack::TypeInfo<uint32_t> : public Pack::Convertible {
-	static constexpr void convert(uint32_t &v)
+	static inline void convert(uint32_t &v)
 	{
 		v = ((((v) >> 24) & 0x000000FFL)
 		    | (((v) >> 8)  & 0x0000FF00L)
@@ -393,7 +393,7 @@
 
 template <>
 struct Pack::TypeInfo<uint64_t> : public Pack::Convertible {
-	static constexpr void convert(uint64_t &v)
+	static inline void convert(uint64_t &v)
 	{
 		v = ((((v) & 0xff00000000000000ull) >> 56)
 			| (((v) & 0x00ff000000000000ull) >> 40)
--- a/C++/Socket.cpp	Thu Nov 13 13:55:36 2014 +0100
+++ b/C++/Socket.cpp	Thu Nov 13 21:10:21 2014 +0100
@@ -196,8 +196,19 @@
 	addrlen = sizeof (sockaddr_storage);
 	handle = ::accept(s.handle(), (sockaddr *)&address, &addrlen);
 
-	if (handle == INVALID_SOCKET)
+	if (handle == INVALID_SOCKET) {
+#if defined(_WIN32)
+		if (WSAGetLastError() == WSAEWOULDBLOCK)
+			throw error::WouldBlock("accept");
+
 		throw error::Failure("accept", Socket::syserror());
+#else
+		if (errno == EAGAIN || errno == EWOULDBLOCK)
+			throw error::WouldBlock("accept");
+
+		throw error::Failure("accept", Socket::syserror());
+#endif
+	}
 
 	// Usually accept works only with SOCK_STREAM
 	info = SocketAddress(address, addrlen);
--- a/C++/Tests/Pack/main.cpp	Thu Nov 13 13:55:36 2014 +0100
+++ b/C++/Tests/Pack/main.cpp	Thu Nov 13 21:10:21 2014 +0100
@@ -28,6 +28,14 @@
 	uint32_t width{};
 	uint32_t height{};
 
+	Point() = default;
+
+	Point(uint32_t width, uint32_t height)
+		: width(width)
+		, height(height)
+	{
+	}
+
 	inline bool operator==(const Point &other) const
 	{
 		return width == other.width && height == other.height;
--- a/C++/Tests/Sockets/main.cpp	Thu Nov 13 13:55:36 2014 +0100
+++ b/C++/Tests/Sockets/main.cpp	Thu Nov 13 21:10:21 2014 +0100
@@ -298,7 +298,6 @@
 					if (tries >= 10)
 						running = false;
 				} catch (const Timeout &) {
-					puts("DEBUG: TIMEOUT");
 				}
 			}
 		} catch (const std::exception &ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C++/Tests/Zip/data/data.txt	Thu Nov 13 21:10:21 2014 +0100
@@ -0,0 +1,1 @@
+abcdef
--- a/C++/ZipArchive.cpp	Thu Nov 13 13:55:36 2014 +0100
+++ b/C++/ZipArchive.cpp	Thu Nov 13 21:10:21 2014 +0100
@@ -39,7 +39,7 @@
 	auto size = m_data.size();
 	auto data = static_cast<char *>(std::malloc(size));
 
-	if (!data)
+	if (data == nullptr)
 		throw std::runtime_error(std::strerror(errno));
 
 	std::memcpy(data, m_data.data(), size);
--- a/C++/ZipArchive.h	Thu Nov 13 13:55:36 2014 +0100
+++ b/C++/ZipArchive.h	Thu Nov 13 21:10:21 2014 +0100
@@ -74,6 +74,7 @@
 
 	ZipFile(const ZipFile &) = delete;
 	ZipFile &operator=(const ZipFile &) = delete;
+
 public:
 	/**
 	 * Create a ZipFile with a zip_file structure.
@@ -142,6 +143,8 @@
 		if (count < 0)
 			return "";
 
+		result.resize(count);
+
 		return result;
 	}
 };