diff options
| author | Stefan Boberg <[email protected]> | 2026-02-24 15:02:58 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-02-24 15:02:58 +0100 |
| commit | 2af00d3ff720969fb3b4d471778efcf8c7b3fad4 (patch) | |
| tree | 9193eb3ff8cc9f3fb5e3342d94bde8c193a977ce /thirdparty/ryml/src/c4/yml/preprocess.cpp | |
| parent | added zencore/filesystem.h include (diff) | |
| parent | Various bug fixes (#778) (diff) | |
| download | zen-sb/spdlog-out.tar.xz zen-sb/spdlog-out.zip | |
Merge branch 'main' into sb/spdlog-outsb/spdlog-out
Diffstat (limited to 'thirdparty/ryml/src/c4/yml/preprocess.cpp')
| -rw-r--r-- | thirdparty/ryml/src/c4/yml/preprocess.cpp | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/thirdparty/ryml/src/c4/yml/preprocess.cpp b/thirdparty/ryml/src/c4/yml/preprocess.cpp deleted file mode 100644 index 2e92dce14..000000000 --- a/thirdparty/ryml/src/c4/yml/preprocess.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "c4/yml/preprocess.hpp" -#include "c4/yml/detail/parser_dbg.hpp" - -/** @file preprocess.hpp Functions for preprocessing YAML prior to parsing. */ - -namespace c4 { -namespace yml { - - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -namespace { -C4_ALWAYS_INLINE bool _is_idchar(char c) -{ - return (c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9') - || (c == '_' || c == '-' || c == '~' || c == '$'); -} - -typedef enum { kReadPending = 0, kKeyPending = 1, kValPending = 2 } _ppstate; -C4_ALWAYS_INLINE _ppstate _next(_ppstate s) -{ - int n = (int)s + 1; - return (_ppstate)(n <= (int)kValPending ? n : 0); -} -} // empty namespace - - -//----------------------------------------------------------------------------- - -size_t preprocess_rxmap(csubstr s, substr buf) -{ - detail::_SubstrWriter writer(buf); - _ppstate state = kReadPending; - size_t last = 0; - - if(s.begins_with('{')) - { - RYML_CHECK(s.ends_with('}')); - s = s.offs(1, 1); - } - - writer.append('{'); - - for(size_t i = 0; i < s.len; ++i) - { - const char curr = s[i]; - const char next = i+1 < s.len ? s[i+1] : '\0'; - - if(curr == '\'' || curr == '"') - { - csubstr ss = s.sub(i).pair_range_esc(curr, '\\'); - i += static_cast<size_t>(ss.end() - (s.str + i)); - state = _next(state); - } - else if(state == kReadPending && _is_idchar(curr)) - { - state = _next(state); - } - - switch(state) - { - case kKeyPending: - { - if(curr == ':' && next == ' ') - { - state = _next(state); - } - else if(curr == ',' && next == ' ') - { - writer.append(s.range(last, i)); - writer.append(": 1, "); - last = i + 2; - } - break; - } - case kValPending: - { - if(curr == '[' || curr == '{' || curr == '(') - { - csubstr ss = s.sub(i).pair_range_nested(curr, '\\'); - i += static_cast<size_t>(ss.end() - (s.str + i)); - state = _next(state); - } - else if(curr == ',' && next == ' ') - { - state = _next(state); - } - break; - } - default: - // nothing to do - break; - } - } - - writer.append(s.sub(last)); - if(state == kKeyPending) - writer.append(": 1"); - writer.append('}'); - - return writer.pos; -} - - -} // namespace yml -} // namespace c4 |