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