From be65971e975c6034601dc1d5eb1bbaa25e2e50f3 Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Sat, 30 Jul 2022 17:41:17 +0100 Subject: [PATCH] Added pcre support and changes to compile with clib2, although it is not 100% working now --- Makefile.os4 | 17 +++++++++++------ cli/filelister.cpp | 2 +- cli/main.cpp | 5 +++++ externals/picojson/picojson.h | 3 ++- lib/cppcheck.cpp | 1 + lib/mathlib.cpp | 10 +++++++++- lib/platform.h | 4 ++-- 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Makefile.os4 b/Makefile.os4 index bd884f3e8..3b3cfc1bc 100644 --- a/Makefile.os4 +++ b/Makefile.os4 @@ -77,7 +77,7 @@ else # !WINNT endif # !CPPCHK_GLIBCXX_DEBUG endif # GNU/kFreeBSD - LDFLAGS=-lpthread -athread=native -gstabs + LDFLAGS=-lpthread endif # WINNT @@ -101,8 +101,12 @@ ifndef CXXFLAGS CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar $(CPPCHK_GLIBCXX_DEBUG) -g endif -override CXXFLAGS += -mcrt=newlib -athread=native -DNO_UNIX_SIGNAL_HANDLING -DUSE_THREADS -gstabs -# CXXFLAGS=-mcrt=newlib -athread=native -std=c++0x -O2 -DNDEBUG -DNO_UNIX_SIGNAL_HANDLING -DUSE_THREADS -Wall -Wno-sign-compare +MCRT := -mcrt=newlib +ifeq ($(USE_CLIB2), yes) +MCRT := -mcrt=clib2 +endif + +override CXXFLAGS +=$(MCRT) -O2 -athread=native -DNO_UNIX_SIGNAL_HANDLING -DUSE_THREADS ifeq (g++, $(findstring g++,$(CXX))) override CXXFLAGS += -std=gnu++0x @@ -115,11 +119,12 @@ else ifeq ($(CXX), c++) endif ifeq ($(HAVE_RULES),yes) - override CXXFLAGS += -DHAVE_RULES -DTIXML_USE_STL $(shell pcre-config --cflags) + override CXXFLAGS += -DHAVE_RULES -DTIXML_USE_STL + # $(shell pcre-config --cflags) ifdef LIBS - LIBS += $(shell pcre-config --libs) + LIBS += -lpcre else - LIBS=$(shell pcre-config --libs) + LIBS=-lpcre endif endif diff --git a/cli/filelister.cpp b/cli/filelister.cpp index 5ee7e853b..cf30b6e99 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -174,7 +174,7 @@ bool FileLister::fileExists(const std::string &path) #endif #endif -#if defined(__amigaos4__) +#if defined(__amigaos4__) && !defined(__CLIB2__) static int readdir_r(DIR *dir, struct dirent *buf, struct dirent **result) { struct dirent *de; diff --git a/cli/main.cpp b/cli/main.cpp index d7ba1bc79..9132fe842 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -80,6 +80,10 @@ static char exename[1024] = {0}; static char exename[1024] = {0}; #endif +#if defined(__amigaos4__) +static const char *stack __attribute__((used)) = "$STACK:102400"; +static const char *version __attribute__((used)) = "\0$VER: cppcheck 2.9 (28.07.2022)"; +#endif /** * Main function of cppcheck * @@ -121,3 +125,4 @@ int main(int argc, char* argv[]) #endif // *INDENT-ON* } + diff --git a/externals/picojson/picojson.h b/externals/picojson/picojson.h index 48bb64e67..cdde72ba9 100644 --- a/externals/picojson/picojson.h +++ b/externals/picojson/picojson.h @@ -196,7 +196,7 @@ namespace picojson { if ( #ifdef _MSC_VER ! _finite(n) -#elif __cplusplus>=201103L || !(defined(isnan) && defined(isinf)) +#elif (__cplusplus>=201103L || !(defined(isnan) && defined(isinf))) && !defined(__CLIB2__) std::isnan(n) || std::isinf(n) #else isnan(n) || isinf(n) @@ -1008,3 +1008,4 @@ inline std::ostream& operator<<(std::ostream& os, const picojson::value& x) #endif #endif + diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index d221c72e4..7a1e09320 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1757,3 +1757,4 @@ bool CppCheck::isUnusedFunctionCheckEnabled() const { return (mSettings.jobs == 1 && mSettings.checks.isEnabled(Checks::unusedFunction)); } + diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index bf6c5fb83..0e7d9b558 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -73,11 +73,18 @@ std::string MathLib::value::str() const { std::ostringstream ostr; if (mType == MathLib::value::Type::FLOAT) { + #if defined(__amigaos4__) && defined(__CLIB2__) + if (isnan(mDoubleValue)) + return "nan.0"; + if (isinf(mDoubleValue)) + return (mDoubleValue > 0) ? "inf.0" : "-inf.0"; + #else if (std::isnan(mDoubleValue)) return "nan.0"; if (std::isinf(mDoubleValue)) return (mDoubleValue > 0) ? "inf.0" : "-inf.0"; - + #endif + ostr.precision(9); ostr << std::fixed << mDoubleValue; @@ -1298,3 +1305,4 @@ MathLib::value operator>>(const MathLib::value &v1, const MathLib::value &v2) { return v1.shiftRight(v2); } + diff --git a/lib/platform.h b/lib/platform.h index 017412769..e218b3ed3 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -23,9 +23,9 @@ #include "config.h" -#if defined(__amigaos4__) +#if defined(__amigaos4__) && !defined(__CLIB2__) #define stricmp strcasecmp -#endif +#endif /* amigaos4 */ #include #include