Skip to content

Commit

Permalink
refactor: minor xpd_tools_constr changes, may fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
slimit75 committed Apr 10, 2024
1 parent b104416 commit 9c43ccd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD 17)

# CMake Settings
set(CMAKE_CXX_FLAGS "-O3 -fPIC -pedantic")
set(CMAKE_C_FLAGS "-O3 -fPIC -pedantic")
set(CMAKE_CXX_FLAGS "-O3 -fPIC -pedantic -Wall")
set(CMAKE_C_FLAGS "-O3 -fPIC -pedantic -Wall")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")

Expand Down
8 changes: 8 additions & 0 deletions src/tools.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#include "xpdraw/tools.h"

#include <string.h>
#include <string>
#include <XPLMPlugin.h>
#include <XPLMUtilities.h>

int xpVersion = -1;
char xpPath[512];
char pluginPath[512];
char str3[512];

char *xpd_tools_constr(const char *str1, const char *str2) {
strcpy(str3, str1);
strncat(str3, str2, sizeof(str3) - strlen(str3) - 1);
return str3;
}

char *xpd_tools_plugin_fp() {
XPLMEnableFeature("XPLM_USE_NATIVE_PATHS", 1);
Expand Down
8 changes: 1 addition & 7 deletions src/xpdraw/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,14 @@
extern "C" {
#endif

#include <string.h>

/**
* @brief Concentrate two C strings into one
*
* @param str1
* @param str2
* @return char*
*/
inline char *xpd_tools_constr(const char *str1, const char *str2) {
char str3[256];
strcpy(str3, str1);
return strncat(str3, str2, sizeof(str3) - strlen(str3) - 1);
}
char *xpd_tools_constr(const char *str1, const char *str2);

/**
* @brief Returns the plugin's current path. Forces XPLM_USE_NATIVE_PATHS to true!
Expand Down

0 comments on commit 9c43ccd

Please sign in to comment.