Skip to content
Snippets Groups Projects
Commit 8d6199be authored by Recolic Keghart's avatar Recolic Keghart
Browse files

tiny bug fix

parent 01fb2ba5
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,7 @@ namespace rlib {
if(required && pos == args.cend())
throw std::invalid_argument("Required argument '{}' not provided."_format(argName));
if(pos == args.cend())
return std::move(def);
return def;
rlib_defer(([&, pos]{if(!useEqualSym) args.erase(pos+1); args.erase(pos);}));
if(useEqualSym)
return pos->substr(argName.size() + 1);
......@@ -91,7 +91,7 @@ namespace rlib {
else
return def;
}
return std::move(value);
return value;
}
rlib::string getValueArg(const std::string &longName, const char *shortName)
......
......@@ -131,7 +131,7 @@ namespace rlib {
inline char *_format_string_c_helper(const char *fmt, ...)
{
int n;
int size = std::strlen(fmt);
size_t size = std::strlen(fmt);
char *p, *np;
va_list ap;
......@@ -186,10 +186,10 @@ namespace rlib {
return this->c_str();
}
std::string as(as_helper<std::string>) const {
return std::move(*this);
return *this;
}
rlib::string as(as_helper<rlib::string>) const {
return std::move(*this);
return *this;
}
char as(as_helper<char>) const {
if(size() > 1)
......
......@@ -7,12 +7,16 @@
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
namespace rlib {
using ssize_t = int;
}
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
// Include winsock2.h before windows.h
......@@ -501,6 +505,11 @@ namespace rlib {
currvptr = (char *)vptr + current / 2;
}
}
static void close_ex(sockfd_t fd) {
if (closesocket(fd) == SOCKET_ERROR) {
throw std::runtime_error("closeSocket failed. error code: " + std::to_string(WSAGetLastError()));
}
}
#else
// POSIX sockIO
public:
......@@ -586,6 +595,11 @@ namespace rlib {
currvptr = (char *)vptr + current / 2;
}
}
static void close_ex(sockfd_t fd) {
if (close(fd) == -1) {
throw std::runtime_error("close failed. error code: " + std::to_string(errno));
}
}
#endif
#ifndef MSG_NOSIGNAL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment