From 484bdb086aa2ea3b4dd665991239ee43c816e893 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Sat, 17 Sep 2022 21:04:40 -0700 Subject: [PATCH] :gear: Restore support for GCC-4.8 (#246) * Create workflow for targeting specific platforms/compilers starts with a GCC-4.8 CentOS base * make sure to install dev tools * Update targets.yml * Update targets.yml * Update targets.yml * Update targets.yml * install CMake by hand * try ubuntu with gcc 4.8 * fix action * actions/checkout@v3 * latest cmake + set compiler for CMake * install g++ * fix compiler passed to cmake * try to run in docker container * in container we are root * try an update * assume yes * revert to using gh runner image * permissions * replace `codecvt` when required * pass locale * fix linter * linter * revert changes to actions (min for pr) --- .github/workflows/targets.yml | 35 +++++++++++++++++++++++++++++++++++ include/jwt-cpp/jwt.h | 12 +++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/targets.yml diff --git a/.github/workflows/targets.yml b/.github/workflows/targets.yml new file mode 100644 index 0000000..1484ea1 --- /dev/null +++ b/.github/workflows/targets.yml @@ -0,0 +1,35 @@ +name: Specific Targets CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + paths: + - "CMakeLists.txt" + - "cmake/**" + - "include/jwt-cpp/**" + - "tests/cmake/**" + - ".github/actions/**" + - ".github/workflows/targets.yml" + +jobs: + gcc-4-8: + name: GCC 4.8 + runs-on: ubuntu-18.04 + steps: + - run: sudo apt-get install g++-4.8 + - uses: lukka/get-cmake@latest + - uses: actions/checkout@v3 + + - name: setup + run: | + mkdir build + cd build + CC=gcc-4.8 CXX=g++-4.8 cmake .. + sudo cmake --install . + - name: test + working-directory: tests/cmake + run: | + CC=gcc-4.8 CXX=g++-4.8 cmake . -DTEST:STRING="defaults-enabled" + cmake --build . diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index 428163b..4dd77ff 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,10 @@ #include #include +#if __cplusplus > 201103L +#include +#endif + #if __cplusplus >= 201402L #ifdef __has_include #if __has_include() @@ -3125,11 +3128,18 @@ namespace jwt { } static std::string to_lower_unicode(const std::string& str, const std::locale& loc) { +#if __cplusplus > 201103L std::wstring_convert, wchar_t> conv; auto wide = conv.from_bytes(str); auto& f = std::use_facet>(loc); f.tolower(&wide[0], &wide[0] + wide.size()); return conv.to_bytes(wide); +#else + std::string result; + std::transform(str.begin(), str.end(), std::back_inserter(result), + [&loc](unsigned char c) { return std::tolower(c, loc); }); + return result; +#endif } }; } // namespace verify_ops