Skip to content

Commit

Permalink
Merge pull request #220 from biojppm/fix/unsignedchar
Browse files Browse the repository at this point in the history
[fix] char constants may be unsigned
  • Loading branch information
biojppm authored Feb 23, 2022
2 parents 40e5607 + 3de2af6 commit f1b0dc7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 34 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ jobs:
fail-fast: false
matrix:
include:
- {std: 11, cxx: g++-10, bt: Debug , os: ubuntu-18.04 , bitlinks: static64 static32}
- {std: 11, cxx: g++-10, bt: Release, os: ubuntu-18.04 , bitlinks: static64 static32}
- {std: 17, cxx: g++-10, bt: Debug , os: ubuntu-18.04 , bitlinks: static64 static32}
- {std: 17, cxx: g++-10, bt: Release, os: ubuntu-18.04 , bitlinks: static64 static32}
- {std: 20, cxx: g++-10, bt: Debug , os: ubuntu-18.04 , bitlinks: static64 static32}
- {std: 20, cxx: g++-10, bt: Release, os: ubuntu-18.04 , bitlinks: static64 static32}
- {std: 11, cxx: vs2019, bt: Debug , os: windows-latest, bitlinks: static64 static32}
- {std: 11, cxx: vs2019, bt: Release, os: windows-latest, bitlinks: static64 static32}
- {std: 17, cxx: vs2019, bt: Debug , os: windows-latest, bitlinks: static64 static32}
- {std: 17, cxx: vs2019, bt: Release, os: windows-latest, bitlinks: static64 static32}
- {std: 20, cxx: vs2019, bt: Debug , os: windows-latest, bitlinks: static64 static32}
- {std: 20, cxx: vs2019, bt: Release, os: windows-latest, bitlinks: static64 static32}
- {std: 11, cxx: g++-10, bt: Debug , os: ubuntu-18.04, bitlinks: static64 static32}
- {std: 11, cxx: g++-10, bt: Release, os: ubuntu-18.04, bitlinks: static64 static32}
- {std: 17, cxx: g++-10, bt: Debug , os: ubuntu-18.04, bitlinks: static64 static32}
- {std: 17, cxx: g++-10, bt: Release, os: ubuntu-18.04, bitlinks: static64 static32}
- {std: 20, cxx: g++-10, bt: Debug , os: ubuntu-18.04, bitlinks: static64 static32}
- {std: 20, cxx: g++-10, bt: Release, os: ubuntu-18.04, bitlinks: static64 static32}
- {std: 11, cxx: vs2019, bt: Debug , os: windows-2019, bitlinks: static64 static32}
- {std: 11, cxx: vs2019, bt: Release, os: windows-2019, bitlinks: static64 static32}
- {std: 17, cxx: vs2019, bt: Debug , os: windows-2019, bitlinks: static64 static32}
- {std: 17, cxx: vs2019, bt: Release, os: windows-2019, bitlinks: static64 static32}
- {std: 20, cxx: vs2019, bt: Debug , os: windows-2019, bitlinks: static64 static32}
- {std: 20, cxx: vs2019, bt: Release, os: windows-2019, bitlinks: static64 static32}
env: {BM: ON, STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
steps:
# use fetch-depth to ensure all tags are fetched
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ small C++ utilities multiplatform library.
ryml is written in C++11, and compiles cleanly with:
* Visual Studio 2015 and later
* clang++ 3.9 and later
* g++ 5 and later (4.8 under work)
* g++ 4.8 and later
* Intel Compiler

ryml is [extensively unit-tested in Linux, Windows and
Expand Down
1 change: 1 addition & 0 deletions changelog/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ As part of the [new feature to track source locations](https://github.com/biojpp
- Ensure error is emitted on unclosed flow sequence characters eg `[[[` ([PR#210](https://github.com/biojppm/rapidyaml/pulls/210)). Same thing for `[]]`.
- Refactor error message building and parser debug logging to use the new dump facilities in c4core ([PR#212](https://github.com/biojppm/rapidyaml/pulls/212)).
- Parse: fix read-after-free when duplicating a parser state node, when pushing to the stack requires a stack buffer resize ([PR#210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Add support for legacy gcc 4.8 ([PR#217](https://github.com/biojppm/rapidyaml/pulls/217)).


### Improvements
Expand Down
2 changes: 1 addition & 1 deletion ext/c4core
Submodule c4core updated 1 files
+2 −1 changelog/current.md
12 changes: 12 additions & 0 deletions src/c4/yml/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ do \
} while(0)



namespace detail {
template<int8_t signedval, uint8_t unsignedval>
struct _charconstant_t
: public std::conditional<std::is_signed<char>::value,
std::integral_constant<int8_t, signedval>,
std::integral_constant<uint8_t, unsignedval>>::type
{};
#define _RYML_CHCONST(signedval, unsignedval) ::c4::yml::detail::_charconstant_t<INT8_C(signedval), UINT8_C(unsignedval)>::value
} // namespace detail


namespace detail {
struct _SubstrWriter
{
Expand Down
20 changes: 10 additions & 10 deletions src/c4/yml/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4576,31 +4576,31 @@ csubstr Parser::_filter_dquot_scalar(substr s)
else if(next == '_') // unicode non breaking space \u00a0
{
// https://www.compart.com/en/unicode/U+00a0
m_filter_arena.str[pos++] = -0x3e; // = UINT8_C(0xc2);
m_filter_arena.str[pos++] = -0x60; // = UINT8_C(0xa0);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x3e, 0xc2);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x60, 0xa0);
++i;
}
else if(next == 'N') // unicode next line \u0085
{
// https://www.compart.com/en/unicode/U+0085
m_filter_arena.str[pos++] = -0x3e; // UINT8_C(0xc2);
m_filter_arena.str[pos++] = -0x7b; // UINT8_C(0x85);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x3e, 0xc2);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x7b, 0x85);
++i;
}
else if(next == 'L') // unicode line separator \u2028
{
// https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=1024&names=-&utf8=0x&unicodeinhtml=hex
m_filter_arena.str[pos++] = -0x1e; // = UINT8_C(0xe2);
m_filter_arena.str[pos++] = -0x80; // = UINT8_C(0x80);
m_filter_arena.str[pos++] = -0x58; // = UINT8_C(0xa8);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x1e, 0xe2);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x80, 0x80);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x58, 0xa8);
++i;
}
else if(next == 'P') // unicode paragraph separator \u2029
{
// https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=1024&names=-&utf8=0x&unicodeinhtml=hex
m_filter_arena.str[pos++] = -0x1e; // = UINT8_C(0xe2);
m_filter_arena.str[pos++] = -0x80; // = UINT8_C(0x80);
m_filter_arena.str[pos++] = -0x57; // = UINT8_C(0xa9);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x1e, 0xe2);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x80, 0x80);
m_filter_arena.str[pos++] = _RYML_CHCONST(-0x57, 0xa9);
++i;
}
_c4dbgfdq("[{}]: backslash...sofar=[{}]~~~{}~~~", i, pos, m_filter_arena.first(pos));
Expand Down
21 changes: 11 additions & 10 deletions test/test_double_quoted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ TEST(double_quoted, escaped_chars)
expected += INT8_C(0x1b); // \e
//
// wrap explicitly to avoid overflow
expected += INT8_C(-0x3e); // UINT8_C(0xc2) \_ (1)
expected += INT8_C(-0x60); // UINT8_C(0xa0) \_ (2)
expected += _RYML_CHCONST(-0x3e, 0xc2); // \_ (1)
expected += _RYML_CHCONST(-0x60, 0xa0); // \_ (2)
//
expected += INT8_C(-0x3e); // UINT8_C(0xc2) \N (1)
expected += INT8_C(-0x7b); // UINT8_C(0x85) \N (2)
expected += _RYML_CHCONST(-0x3e, 0xc2); // \N (1)
expected += _RYML_CHCONST(-0x7b, 0x85); // \N (2)
//
expected += INT8_C(-0x1e); // UINT8_C(0xe2) \L (1)
expected += INT8_C(-0x80); // UINT8_C(0x80) \L (2)
expected += INT8_C(-0x58); // UINT8_C(0xa8) \L (3)
expected += _RYML_CHCONST(-0x1e, 0xe2); // \L (1)
expected += _RYML_CHCONST(-0x80, 0x80); // \L (2)
expected += _RYML_CHCONST(-0x58, 0xa8); // \L (3)
//
expected += _RYML_CHCONST(-0x1e, 0xe2); // \P (1)
expected += _RYML_CHCONST(-0x80, 0x80); // \P (2)
expected += _RYML_CHCONST(-0x57, 0xa9); // \P (3)
//
expected += INT8_C(-0x1e); // UINT8_C(0xe2) \P (1)
expected += INT8_C(-0x80); // UINT8_C(0x80) \P (2)
expected += INT8_C(-0x57); // UINT8_C(0xa9) \P (3)
Tree t = parse_in_arena(yaml);
csubstr v = t.rootref().val();
std::string actual = {v.str, v.len};
Expand Down

0 comments on commit f1b0dc7

Please sign in to comment.