• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

biojppm / rapidyaml / 18640334796

20 Oct 2025 02:34AM UTC coverage: 97.752% (+0.1%) from 97.65%
18640334796

Pull #550

github

web-flow
Merge 138b7f86b into 48acea949
Pull Request #550: Implement FLOW_ML style

823 of 856 new or added lines in 12 files covered. (96.14%)

160 existing lines in 15 files now uncovered.

13784 of 14101 relevant lines covered (97.75%)

543110.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.8
/src/c4/yml/preprocess.cpp
1
#include "c4/yml/preprocess.hpp"
2
#include "c4/yml/error.hpp"
3
#include "c4/yml/detail/dbgprint.hpp"
4

5
/** @file preprocess.hpp Functions for preprocessing YAML prior to parsing. */
6

7
namespace c4 {
8
namespace yml {
9

10
C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH("-Wold-style-cast")
11

12
//-----------------------------------------------------------------------------
13
//-----------------------------------------------------------------------------
14
//-----------------------------------------------------------------------------
15

16
namespace {
17
C4_ALWAYS_INLINE bool _is_idchar(char c)
18
{
19
    return (c >= 'a' && c <= 'z')
132✔
20
        || (c >= 'A' && c <= 'Z')
12✔
21
        || (c >= '0' && c <= '9')
12✔
22
        || (c == '_' || c == '-' || c == '~' || c == '$');
144✔
23
}
24

25
enum _ppstate : int { kReadPending = 0, kKeyPending = 1, kValPending = 2 };
26
C4_ALWAYS_INLINE _ppstate _next(_ppstate s)
27
{
28
    int n = (int)s + 1;
276✔
29
    return (_ppstate)(n <= (int)kValPending ? n : 0);
276✔
30
}
31
} // empty namespace
32

33

34
//-----------------------------------------------------------------------------
35

36
size_t preprocess_rxmap(csubstr s, substr buf)
156✔
37
{
38
    detail::_SubstrWriter writer(buf);
156✔
39
    _ppstate state = kReadPending;
156✔
40
    size_t last = 0;
156✔
41

42
    if(s.begins_with('{'))
156✔
43
    {
44
        _RYML_CHECK_BASIC(s.ends_with('}'));
24✔
45
        s = s.offs(1, 1);
24✔
46
    }
47

48
    writer.append('{');
156✔
49

50
    for(size_t i = 0; i < s.len; ++i)
828✔
51
    {
52
        const char curr = s[i];
672✔
53
        const char next = i+1 < s.len ? s[i+1] : '\0';
1,272✔
54

55
        if(curr == '\'' || curr == '"')
672✔
56
        {
57
            csubstr ss = s.sub(i).pair_range_esc(curr, '\\');
×
58
            i += static_cast<size_t>(ss.end() - (s.str + i));
×
59
            state = _next(state);
×
UNCOV
60
        }
×
61
        else if(state == kReadPending && _is_idchar(curr))
816✔
62
        {
63
            state = _next(state);
132✔
64
        }
65

66
        switch(state)
672✔
67
        {
68
        case kKeyPending:
516✔
69
        {
70
            if(curr == ':' && next == ' ')
516✔
71
            {
72
                state = _next(state);
72✔
73
            }
74
            else if(curr == ',' && next == ' ')
444✔
75
            {
76
                writer.append(s.range(last, i));
48✔
77
                writer.append(": 1, ");
48✔
78
                last = i + 2;
48✔
79
            }
80
            break;
516✔
81
        }
82
        case kValPending:
144✔
83
        {
84
            if(curr == '[' || curr == '{' || curr == '(')
144✔
85
            {
86
                csubstr ss = s.sub(i).pair_range_nested(curr, '\\');
72✔
87
                i += static_cast<size_t>(ss.end() - (s.str + i));
72✔
88
                state = _next(state);
72✔
89
            }
72✔
90
            else if(curr == ',' && next == ' ')
72✔
91
            {
UNCOV
92
                state = _next(state);
×
93
            }
94
            break;
144✔
95
        }
96
        default:
12✔
97
            // nothing to do
98
            break;
12✔
99
        }
100
    }
101

102
    writer.append(s.sub(last));
156✔
103
    if(state == kKeyPending)
156✔
104
        writer.append(": 1");
60✔
105
    writer.append('}');
156✔
106

107
    return writer.pos;
156✔
108
}
109

110
C4_SUPPRESS_WARNING_GCC_CLANG_POP
111

112
} // namespace yml
113
} // namespace c4
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc