MCPcopy Create free account
hub / github.com/chen3feng/toft / ParseScanSet

Function ParseScanSet

base/string/format/specification.cpp:94–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94static int ParseScanSet(const char* format, char (*cs)[32])
95{
96 const char* f = format;
97 bool is_neg = *f == '^';
98 if (is_neg) {
99 memset(cs, 0xFF, sizeof(*cs));
100 ++f;
101 } else {
102 memset(cs, 0, sizeof(*cs));
103 }
104
105 while (*f != ']') {
106 if (f - format > 256) {
107 LOG(DFATAL) << "Invalid scanset, too long to see the ending ']'";
108 return 0;
109 }
110 if (*f == '\0') {
111 LOG(DFATAL) << "Invalid scanset, unexpected end before ']'";
112 return 0;
113 }
114
115 if (f[1] == '-' && f[2] != '\0' && f[2] != ']') {
116 // Process char range
117 ScanSetSetCharRange(cs, f[0], f[2], !is_neg);
118 f += 3;
119 } else {
120 // Single char
121 ScanSetSetChar(cs, *f, !is_neg);
122 f += 1;
123 }
124 }
125 ++f;
126
127 return f - format;
128}
129
130static int ParseSpecifier(const char* format, char* specifier)
131{

Callers 1

ParseScanSpecifierFunction · 0.85

Calls 2

ScanSetSetCharRangeFunction · 0.85
ScanSetSetCharFunction · 0.85

Tested by

no test coverage detected