fix inverted windows detection logic and typo

pull/2045/head
Rachel Powers 2023-03-25 19:13:27 -07:00
parent 549d8ffea1
commit c7e5767a11
7 changed files with 16 additions and 18 deletions

View File

@ -81,7 +81,7 @@ int BufferedFile::onClose()
int rv = 0;
if (fp_) {
fflush(fp_);
#if defined(__MINGW32__)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
fsync(fileno(fp_));
#else // __MINGW32__
_commit(fileno(fp_));

View File

@ -303,20 +303,20 @@ void ConsoleStatCalc::calculateStat(const DownloadEngine* e)
unsigned short int cols = 79;
if (isTTY_) {
#if efined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
# ifdef HAVE_TERMIOS_H
struct winsize size;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
cols = std::max(0, (int)size.ws_col - 1);
}
# endif // HAVE_TERMIOS_H
#else // __MINGW32__
#else // __MINGW32__ || _MSC_VER
CONSOLE_SCREEN_BUFFER_INFO info;
if (::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE),
&info)) {
cols = std::max(0, info.dwSize.X - 2);
}
#endif // !__MINGW32__
#endif // !__MINGW32__ && !_MSC_VER
std::string line(cols, ' ');
global::cout()->printf("\r%s\r", line.c_str());
}

View File

@ -262,13 +262,13 @@ void SelectEventPoll::updateFdSet()
for (auto& i : socketEntries_) {
auto& e = i.second;
sock_t fd = e.getSocket();
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
if (fd < 0 || FD_SETSIZE <= fd) {
A2_LOG_WARN("Detected file descriptor >= FD_SETSIZE or < 0. "
"Download may slow down or fail.");
continue;
}
#endif // !__MINGW32__
#endif // !__MINGW32__ && !_MSC_VER
int events = e.getEvents();
if (events & EventPoll::EVENT_READ) {
#if defined(__MINGW32__) || defined(_MSC_VER)

View File

@ -38,8 +38,6 @@
#ifndef NO_UNIX
# include <unistd.h>
#endif
# include <unistd.h>
#endif
#include <cstdlib>
#include <cassert>
#include <cstring>

View File

@ -70,7 +70,7 @@
namespace aria2 {
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
# define SOCKET_ERRNO (errno)
#else
# define SOCKET_ERRNO (WSAGetLastError())
@ -104,7 +104,7 @@ namespace aria2 {
namespace {
std::string errorMsg(int errNum)
{
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
return util::safeStrerror(errNum);
#else
auto msg = util::formatLastError(errNum);
@ -656,7 +656,7 @@ void SocketCore::closeConnection()
}
}
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
# define CHECK_FD(fd) \
if (fd < 0 || FD_SETSIZE <= fd) { \
logger_->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
@ -683,7 +683,7 @@ bool SocketCore::isWritable(time_t timeout)
}
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_WRITABLE, errorMsg(errNum).c_str()));
#else // !HAVE_POLL
# ifn defined(__MINGW32__) || defined(_MSC_VER)
# if !defined(__MINGW32__) && !defined(_MSC_VER)
CHECK_FD(sockfd_);
# endif // !__MINGW32__
fd_set fds;
@ -728,7 +728,7 @@ bool SocketCore::isReadable(time_t timeout)
}
throw DL_RETRY_EX(fmt(EX_SOCKET_CHECK_READABLE, errorMsg(errNum).c_str()));
#else // !HAVE_POLL
# ifn defined(__MINGW32__) || defined(_MSC_VER)
# if !defined(__MINGW32__) && !defined(_MSC_VER)
CHECK_FD(sockfd_);
# endif // !__MINGW32__
fd_set fds;

View File

@ -1742,7 +1742,7 @@ void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
#endif // HAVE_SIGACTION
}
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
std::string getHomeDir()
{
const char* p = getenv("HOME");
@ -1789,7 +1789,7 @@ std::string getXDGDir(const std::string& environmentVariable,
std::string filename;
const char* p = getenv(environmentVariable.c_str());
if (p &&
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
p[0] == '/'
#else // __MINGW32__
p[0] && p[1] == ':'
@ -2234,7 +2234,7 @@ void executeHook(const std::string& command, a2_gid_t gid, size_t numFiles,
{
const std::string gidStr = GroupId::toHex(gid);
const std::string numFilesStr = util::uitos(numFiles);
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
A2_LOG_INFO(fmt("Executing user command: %s %s %s %s", command.c_str(),
gidStr.c_str(), numFilesStr.c_str(), firstFilename.c_str()));
pid_t cpid = fork();
@ -2502,7 +2502,7 @@ std::string formatLastError(int errNum)
void make_fd_cloexec(int fd)
{
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
int flags;
// TODO from linux man page, fcntl() with F_GETFD or F_SETFD does

View File

@ -96,7 +96,7 @@ void TimeTest::testToHTTPDate()
{
// This test disabled for MinGW32, because the garbage will be
// displayed and it hides real errors.
#if defined(__MINGW32__) || defined(_MSC_VER)
#if !defined(__MINGW32__) && !defined(_MSC_VER)
Time t(1220714793);
CPPUNIT_ASSERT_EQUAL(std::string("Sat, 06 Sep 2008 15:26:33 GMT"),
t.toHTTPDate());