Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: macOS fixes #323

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ cmake_install.cmake
Project.sln
CMakeCache.txt

# Build files on macOS
Makefile

# Test folders
tests_tmp_dll/
tests_tmp_app/
Expand Down
11 changes: 10 additions & 1 deletion src/asar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ option(ASAR_GEN_EXE "Build Asar standalone application" ON)
option(ASAR_GEN_DLL "Build Asar shared library" ON)
option(ASAR_GEN_LIB "Build Asar static library" ON)
option(ASAR_COVERAGE "Build Asar with coverage tracking support" OFF)
option(ASAR_USE_THREADS "Run Asar in a new thread to alleviate stack usage problems" ON)
if (MSVC)
message(STATUS "In MSVC you can override MSVC_LIB_TYPE, valid values are D for dynamic and T for static")
endif()

# Determine default value based on the operating system
if(APPLE)
set(ASAR_USE_THREADS_DEFAULT OFF)
else()
set(ASAR_USE_THREADS_DEFAULT ON)
endif()

# Define the option with the determined default value
option(ASAR_USE_THREADS "Run Asar in a new thread to alleviate stack usage problems" ${ASAR_USE_THREADS_DEFAULT})


set (CMAKE_CXX_STANDARD 17)

Expand Down
3 changes: 3 additions & 0 deletions src/asar/interface-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ int main(int argc, const char * argv[])
}
if (!openrom(romname, false))
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-security"
asar_throw_error(pass, error_type_null, openromerror);
#pragma GCC diagnostic pop
pause(err);
return 1;
}
Expand Down
16 changes: 8 additions & 8 deletions src/asar/libstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,24 +347,24 @@ inline string hex(unsigned int value)
{
char buffer[64];
if(0);
else if (value<=0x000000FF) sprintf(buffer, "%.2X", value);
else if (value<=0x0000FFFF) sprintf(buffer, "%.4X", value);
else if (value<=0x00FFFFFF) sprintf(buffer, "%.6X", value);
else sprintf(buffer, "%.8X", value);
else if (value<=0x000000FF) snprintf(buffer, sizeof(buffer), "%.2X", value);
else if (value<=0x0000FFFF) snprintf(buffer, sizeof(buffer), "%.4X", value);
else if (value<=0x00FFFFFF) snprintf(buffer, sizeof(buffer), "%.6X", value);
else snprintf(buffer, sizeof(buffer), "%.8X", value);
return buffer;
}

inline string hex(unsigned int value, int width)
{
char buffer[64];
sprintf(buffer, "%.*X", width, value);
snprintf(buffer, sizeof(buffer), "%.*X", width, value);
return buffer;
}

inline string dec(int value)
{
char buffer[64];
sprintf(buffer, "%i", value);
snprintf(buffer, sizeof(buffer), "%i", value);
return buffer;
}

Expand All @@ -375,7 +375,7 @@ inline string ftostr(double value)
char rval[512];
// RPG Hacker: Ridiculously high precision, I know, but we're working with doubles
// here and can afford it, so no need to waste any precision
sprintf(rval, "%.100f", value);
snprintf(rval, sizeof(rval), "%.100f", value);
if (strchr(rval, '.'))//nuke useless zeroes
{
char * end=strrchr(rval, '\0')-1;
Expand All @@ -398,7 +398,7 @@ inline string ftostrvar(double value, int precision)

// see above
char rval[512];
sprintf(rval, "%.*f", clampedprecision, (double)value);
snprintf(rval, sizeof(rval), "%.*f", clampedprecision, (double)value);
if (strchr(rval, '.'))//nuke useless zeroes
{
char * end = strrchr(rval, '\0') - 1;
Expand Down