Cleanup wposix header and source

Remove stale NAN and INFINITY, both have equivalents since C++11 and
cleanup headers in wposix source file.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2026-06-04 21:15:23 +02:00
parent 62fcb7e042
commit 6fc47e2997
No known key found for this signature in database
3 changed files with 12 additions and 21 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -25,21 +25,25 @@
*/
#include "precompiled.h"
#include "lib/sysdep/os/win/wposix/wposix.h"
#include "lib/sysdep/os/win/wposix/wposix_internal.h"
#include "lib/bits.h"
#include "wposix.h"
#include "lib/sysdep/os/win/win.h"
#include <cerrno>
#include <cstdlib>
#include <cstring>
int setenv(const char* envname, const char* envval, int overwrite)
{
if(!envname || envname[0] == '\0' || strchr(envname, '='))
if(!envname || envname[0] == '\0' || std::strchr(envname, '='))
{
errno = EINVAL;
return -1;
}
if(overwrite || !getenv(envname))
if(overwrite || !std::getenv(envname))
SetEnvironmentVariableA(envname, envval);
return 0;

View file

@ -54,17 +54,4 @@
int setenv(const char* envname, const char* envval, int overwrite);
//
// <math.h>
//
// (missing on MSVC)
#ifndef INFINITY
#define INFINITY (std::numeric_limits<float>::infinity())
#endif
#ifndef NAN
#define NAN (std::numeric_limits<float>::quiet_NaN())
#endif
#endif // #ifndef INCLUDED_WPOSIX

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -213,7 +213,7 @@ public:
float f = 0;
JS::RootedValue testNANVal(rq.cx);
Script::ToJSVal(rq, &testNANVal, NAN);
Script::ToJSVal(rq, &testNANVal, std::numeric_limits<float>::quiet_NaN());
TS_ASSERT(Script::FromJSVal(rq, testNANVal, f));
TS_ASSERT(std::isnan(f));
}