Skip to content

Commit 484bdb0

Browse files
⚙️ 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)
1 parent 25377cb commit 484bdb0

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

.github/workflows/targets.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Specific Targets CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
paths:
9+
- "CMakeLists.txt"
10+
- "cmake/**"
11+
- "include/jwt-cpp/**"
12+
- "tests/cmake/**"
13+
- ".github/actions/**"
14+
- ".github/workflows/targets.yml"
15+
16+
jobs:
17+
gcc-4-8:
18+
name: GCC 4.8
19+
runs-on: ubuntu-18.04
20+
steps:
21+
- run: sudo apt-get install g++-4.8
22+
- uses: lukka/get-cmake@latest
23+
- uses: actions/checkout@v3
24+
25+
- name: setup
26+
run: |
27+
mkdir build
28+
cd build
29+
CC=gcc-4.8 CXX=g++-4.8 cmake ..
30+
sudo cmake --install .
31+
- name: test
32+
working-directory: tests/cmake
33+
run: |
34+
CC=gcc-4.8 CXX=g++-4.8 cmake . -DTEST:STRING="defaults-enabled"
35+
cmake --build .

include/jwt-cpp/jwt.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <algorithm>
2525
#include <chrono>
2626
#include <cmath>
27-
#include <codecvt>
2827
#include <functional>
2928
#include <iterator>
3029
#include <locale>
@@ -36,6 +35,10 @@
3635
#include <utility>
3736
#include <vector>
3837

38+
#if __cplusplus > 201103L
39+
#include <codecvt>
40+
#endif
41+
3942
#if __cplusplus >= 201402L
4043
#ifdef __has_include
4144
#if __has_include(<experimental/type_traits>)
@@ -3125,11 +3128,18 @@ namespace jwt {
31253128
}
31263129

31273130
static std::string to_lower_unicode(const std::string& str, const std::locale& loc) {
3131+
#if __cplusplus > 201103L
31283132
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> conv;
31293133
auto wide = conv.from_bytes(str);
31303134
auto& f = std::use_facet<std::ctype<wchar_t>>(loc);
31313135
f.tolower(&wide[0], &wide[0] + wide.size());
31323136
return conv.to_bytes(wide);
3137+
#else
3138+
std::string result;
3139+
std::transform(str.begin(), str.end(), std::back_inserter(result),
3140+
[&loc](unsigned char c) { return std::tolower(c, loc); });
3141+
return result;
3142+
#endif
31333143
}
31343144
};
31353145
} // namespace verify_ops

0 commit comments

Comments
 (0)