From f3670781af0119811d742f7b6c9f206996083c7f Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Thu, 8 Aug 2024 17:18:13 -0400 Subject: [PATCH] Use std:: namespace for tanf, tolower, strlen, strrchr --- src/JSystem/JAudio/JASWaveArcLoader.cpp | 4 ---- src/JSystem/JKernel/JKRFileCache.cpp | 2 +- src/JSystem/JKernel/JKRFileLoader.cpp | 8 +------- .../MSL/MSL_C/MSL_Common/Include/ctype.h | 12 ++++++++---- .../MSL/MSL_C/MSL_Common/Include/math.h | 2 +- .../MSL/MSL_C/MSL_Common/Include/string.h | 8 +++++++- src/SSystem/SComponent/c_angle.cpp | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/JSystem/JAudio/JASWaveArcLoader.cpp b/src/JSystem/JAudio/JASWaveArcLoader.cpp index a259f5728..b03096e18 100644 --- a/src/JSystem/JAudio/JASWaveArcLoader.cpp +++ b/src/JSystem/JAudio/JASWaveArcLoader.cpp @@ -32,10 +32,6 @@ JASystem::Kernel::THeap* JASystem::WaveArcLoader::getRootHeap() { char JASystem::WaveArcLoader::sCurrentDir[DIR_MAX] = "/Banks/"; -namespace std { - using ::strlen; -}; - /* 80287C30-80287D24 .text setCurrentDir__Q28JASystem13WaveArcLoaderFPCc */ void JASystem::WaveArcLoader::setCurrentDir(const char* dir) { JUT_ASSERT(60, std::strlen(dir) < DIR_MAX); diff --git a/src/JSystem/JKernel/JKRFileCache.cpp b/src/JSystem/JKernel/JKRFileCache.cpp index 95334515a..a784403bd 100644 --- a/src/JSystem/JKernel/JKRFileCache.cpp +++ b/src/JSystem/JKernel/JKRFileCache.cpp @@ -59,7 +59,7 @@ JKRFileCache::JKRFileCache(const char* path, const char* volume) { const char* volumePath = volume; if (!volume) { - volumePath = strrchr(mRootPath, '/'); + volumePath = std::strrchr(mRootPath, '/'); volumePath++; } diff --git a/src/JSystem/JKernel/JKRFileLoader.cpp b/src/JSystem/JKernel/JKRFileLoader.cpp index 99ed5a936..06ce0204e 100644 --- a/src/JSystem/JKernel/JKRFileLoader.cpp +++ b/src/JSystem/JKernel/JKRFileLoader.cpp @@ -136,13 +136,7 @@ const char* JKRFileLoader::fetchVolumeName(char* buffer, s32 bufferSize, const c path++; while (*path != 0 && *path != '/') { if (1 < bufferSize) { - int lower_char; - int ch = (int)*path; - if (ch == -1) { - lower_char = -1; - } else { - lower_char = __lower_map[ch & 0xFF]; - } + int lower_char = std::tolower(*path); *buffer = lower_char; buffer++; diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h index 067a24b2f..48910f67e 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h @@ -28,19 +28,23 @@ extern unsigned char __upper_map[]; #define __control (__motion_char | __control_char) #define __zero_fill(c) ((int)(unsigned char)(c)) -int tolower(int); +int tolower(int c); inline int isalpha(int c) { return (int)(__ctype_map[(unsigned char)c] & __letter); } inline int isdigit(int c) { return (int)(__ctype_map[(unsigned char)c] & __digit); } inline int isspace(int c) { return (int)(__ctype_map[(unsigned char)c] & __whitespace); } inline int isupper(int c) { return (int)(__ctype_map[(unsigned char)c] & __upper_case); } inline int isxdigit(int c) { return (int)(__ctype_map[(unsigned char)c] & __hex_digit); } -// added underscore to avoid naming conflicts -inline int _tolower(int c) { return (c == -1 ? -1 : (int)__lower_map[(unsigned char)c]); } inline int toupper(int c) { return (c == -1 ? -1 : (int)__upper_map[(unsigned char)c]); } #ifdef __cplusplus -} +}; + +namespace std { +inline int tolower(int c) { return (c == -1 ? -1 : (int)__lower_map[(unsigned char)c]); } +using ::toupper; +}; // namespace std + #endif #endif /* _MSL_COMMON_CTYPE_H */ diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h index 0490f76c3..45bafe4f0 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h @@ -78,6 +78,7 @@ inline float fmodf(float x, float y) { return fmod(x, y); } inline float atan2f(float y, float x) { return (float)atan2(y, x); } inline float sinf(float x) { return sin(x); } inline float cosf(float x) { return cos(x); } +inline float tanf(float x) { return tan(x); } extern inline float sqrtf(float x) { const double _half = .5; @@ -93,7 +94,6 @@ extern inline float sqrtf(float x) { } return x; } - }; // namespace std #endif diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h index 4f93326f8..6721ecd7a 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h @@ -27,7 +27,13 @@ char* strcpy(char* dst, const char* src); size_t strlen(const char* str); #ifdef __cplusplus -} +}; + + +namespace std { +using ::strlen; +using ::strrchr; +}; // namespace std #endif #endif /* _MSL_COMMON_STRING_H */ diff --git a/src/SSystem/SComponent/c_angle.cpp b/src/SSystem/SComponent/c_angle.cpp index c0090c713..a9718b5e5 100644 --- a/src/SSystem/SComponent/c_angle.cpp +++ b/src/SSystem/SComponent/c_angle.cpp @@ -71,17 +71,17 @@ s16 cSAngle::Inv() const { /* 80253D40-80253D68 .text Sin__7cSAngleCFv */ f32 cSAngle::Sin() const { - return sin(Radian()); + return std::sinf(Radian()); } /* 80253D68-80253D90 .text Cos__7cSAngleCFv */ f32 cSAngle::Cos() const { - return cos(Radian()); + return std::cosf(Radian()); } /* 80253D90-80253DB8 .text Tan__7cSAngleCFv */ f32 cSAngle::Tan() const { - return tan(Radian()); + return std::tanf(Radian()); } /* 80253DB8-80253DE4 .text __mi__7cSAngleCFv */