StrIterPeek
Description
Read the current character into *out without advancing. Propagating alias for IterPeekAt(mi, 0, out); see IterPeekAt for the full contract.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:822:
char fc = 0;
while (StrIterPeek(&fsi, &fc)) {
if (fc != '{') {
LOG_FATAL("buf_read_fmt: stray '{c}' in binary fmt; only {{<Nr}} / {{>Nr}} allowed", (u32)(u8)fc);- In
Io.c:830:
Zstr spec_start = (Zstr)StrIterPos(&fsi);
char sc = 0;
while (StrIterPeek(&fsi, &sc) && sc != '}') {
StrIterMustNext(&fsi);
}- In
Io.c:1005:
StrIter fsi = StrIterFromZstr(fmtstr);
char fc = 0;
while (StrIterPeek(&fsi, &fc)) {
if (fc != '{') {
LOG_FATAL("buf_*_fmt: stray '{c}' in binary fmt; only {{<Nr}} / {{>Nr}} allowed", (u32)(u8)fc);- In
Io.c:1013:
Zstr spec_start = (Zstr)StrIterPos(&fsi);
char sc = 0;
while (StrIterPeek(&fsi, &sc) && sc != '}') {
StrIterMustNext(&fsi);
}- In
Io.c:2524:
char c = 0;
while (StrIterPeek(&si, &c) && IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:2542:
StrIter saved = si;
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
while (StrIterPeek(&si, &c) && !IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:2564:
bool has_decimal = false;
while (StrIterPeek(&si, &c)) {
// A second '.' ends the number; the parser proper rejects
// multi-dot mantissas, so stopping here keeps the rejected tail
- In
Io.c:2580:
StrIterMustNext(&si);
if (StrIterPeek(&si, &c) && (c == '+' || c == '-')) {
StrIterMustNext(&si);
}- In
Io.c:2584:
}
if (!StrIterPeek(&si, &c) || !IS_DIGIT(c)) {
StrIterMustPrev(&si);
break;- In
Io.c:2589:
}
while (StrIterPeek(&si, &c) && IS_DIGIT(c)) {
StrIterMustNext(&si);
}- In
Io.c:2637:
char c = 0;
while (StrIterPeek(&si, &c) && IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:2655:
StrIter saved = si;
while (StrIterPeek(&si, &c)) {
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), false)) {
break;- In
Io.c:2756:
char c = 0; \
\
while (StrIterPeek(&si, &c) && IS_SPACE(c)) { \
StrIterMustNext(&si); \
} \
- In
Io.c:2767:
\
StrIter saved = si; \
while (StrIterPeek(&si, &c)) { \
if (!is_valid_number_char(c, StrIterIndex(&si) == StrIterIndex(&saved), false)) { \
break; \
- In
Io.c:3054:
char c = 0;
while (StrIterPeek(&si, &c) && IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:3077:
StrIter hex_saved = si;
while (StrIterPeek(&si, &c) && IS_XDIGIT(c)) {
StrIterMustNext(&si);
}- In
Io.c:3118:
StrIter oct_saved = si;
while (StrIterPeek(&si, &c) && c >= '0' && c <= '7') {
StrIterMustNext(&si);
}- In
Io.c:3152:
StrIter bin_saved = si;
while (StrIterPeek(&si, &c) && (c == '0' || c == '1')) {
StrIterMustNext(&si);
}- In
Io.c:3190:
char c = 0;
while (StrIterPeek(&si, &c) && IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:3205:
char d0 = 0;
(void)StrIterPeek(&si, &d0);
if (d0 == '+') {
StrIterMustNext(&si);- In
Io.c:3229:
}
while (StrIterPeek(&si, &c) && int_fmt_digit_matches_radix(c, radix)) {
StrIterMustNext(&si);
}- In
Io.c:3239:
char trailing = 0;
if (StrIterPeek(&si, &trailing) && trailing == '_') {
LOG_ERROR("Int reads do not accept digit separators");
return start;- In
Io.c:3287:
char c = 0;
while (StrIterPeek(&si, &c) && IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:3343:
char c = 0;
while (StrIterPeek(&si, &c) && IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:3361:
StrIter saved = si;
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
while (StrIterPeek(&si, &c) && !IS_SPACE(c)) {
StrIterMustNext(&si);
}- In
Io.c:3385:
bool has_decimal = false;
while (StrIterPeek(&si, &c)) {
if (c == '.') {
if (has_decimal)- In
Io.c:3398:
StrIterMustNext(&si);
if (StrIterPeek(&si, &c) && (c == '+' || c == '-')) {
StrIterMustNext(&si);
}- In
Io.c:3402:
}
if (!StrIterPeek(&si, &c) || !IS_DIGIT(c)) {
StrIterMustPrev(&si);
break;- In
Io.c:3407:
}
while (StrIterPeek(&si, &c) && IS_DIGIT(c)) {
StrIterMustNext(&si);
}- In
ArgParse.c:83:
u64 v = 0;
char c;
while (StrIterPeek(&si, &c) && c >= '0' && c <= '9') {
u64 d = (u64)(c - '0');
if (v > (~(u64)0 - d) / 10)- In
ProcMaps.c:50:
int consumed = 0;
char c;
while (StrIterPeek(si, &c)) {
int d = hex_digit_value(c);
if (d < 0)- In
ProcMaps.c:66:
static bool expect_char(StrIter *si, char want) {
char c;
if (!StrIterPeek(si, &c) || c != want)
return false;
StrIterMustNext(si);- In
ProcMaps.c:74:
static void skip_ws(StrIter *si) {
char c;
while (StrIterPeek(si, &c) && (c == ' ' || c == '\t')) {
StrIterMustNext(si);
}- In
ProcMaps.c:82:
static void skip_token(StrIter *si) {
char c;
while (StrIterPeek(si, &c) && c != ' ' && c != '\t' && c != '\n') {
StrIterMustNext(si);
}- In
ProcMaps.c:143:
size path_start_pos = StrIterIndex(si);
char c;
while (StrIterPeek(si, &c) && c != '\n') {
StrIterMustNext(si);
}- In
ProcMaps.c:223:
// Skip past whatever line we couldn't parse.
char c;
while (StrIterPeek(&si, &c) && c != '\n') {
StrIterMustNext(&si);
}- In
Dns.c:137:
static void skip_hspace_iter(StrIter *si) {
char c;
while (StrIterPeek(si, &c) && is_hspace(c)) {
StrIterMustNext(si);
}- In
Dns.c:146:
static void skip_to_eol_iter(StrIter *si) {
char c;
while (StrIterPeek(si, &c) && c != '\n') {
StrIterMustNext(si);
}- In
Dns.c:167:
// Comment / blank line -> eat the whole line.
if (!StrIterPeek(&si, &c) || c == '#' || c == '\n' || c == '\r') {
skip_to_eol_iter(&si);
continue;- In
Dns.c:174:
// First token: IP literal.
size ip_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n') {
StrIterMustNext(&si);
}- In
Dns.c:202:
// Subsequent tokens: name + aliases.
while (StrIterPeek(&si, &c) && c != '\n') {
skip_hspace_iter(&si);
if (!StrIterPeek(&si, &c) || c == '\n' || c == '#') {- In
Dns.c:204:
while (StrIterPeek(&si, &c) && c != '\n') {
skip_hspace_iter(&si);
if (!StrIterPeek(&si, &c) || c == '\n' || c == '#') {
break;
}- In
Dns.c:208:
}
size nm_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n' && c != '#') {
StrIterMustNext(&si);
}- In
Dns.c:264:
skip_hspace_iter(&si);
if (!StrIterPeek(&si, &c) || c == '#' || c == ';' || c == '\n' || c == '\r') {
skip_to_eol_iter(&si);
continue;- In
Dns.c:280:
size ip_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && !is_hspace(c) && c != '\n' && c != '#') {
StrIterMustNext(&si);
}- In
KvConfig.c:81:
static StrIter kvconfig_consume_line_end(StrIter si) {
char c;
if (StrIterPeek(&si, &c) && c == '\r') {
StrIterMustNext(&si);
}- In
KvConfig.c:84:
StrIterMustNext(&si);
}
if (StrIterPeek(&si, &c) && c == '\n') {
StrIterMustNext(&si);
}- In
KvConfig.c:92:
StrIter KvConfigSkipWhitespace(StrIter si) {
char c;
while (StrIterPeek(&si, &c) && kvconfig_is_space(c)) {
StrIterMustNext(&si);
}- In
KvConfig.c:100:
StrIter KvConfigSkipLine(StrIter si) {
char c;
while (StrIterPeek(&si, &c) && c != '\n') {
StrIterMustNext(&si);
}- In
KvConfig.c:116:
char c;
while (StrIterPeek(&si, &c)) {
if (c == '=' || c == ':' || kvconfig_is_space(c) || c == '\n' || kvconfig_is_comment_start(c)) {
break;- In
KvConfig.c:144:
char c;
if (!StrIterPeek(&si, &c) || c == '\n' || kvconfig_is_comment_start(c)) {
return si;
}- In
KvConfig.c:152:
StrIterMustNext(&si);
while (StrIterPeek(&si, &c)) {
if (c == quote) {
StrIterMustNext(&si);- In
KvConfig.c:160:
if (c == '\\') {
StrIterMustNext(&si);
if (!StrIterPeek(&si, &c)) {
LOG_ERROR("Unexpected end of quoted config value");
StrClear(value);- In
KvConfig.c:195:
}
while (StrIterPeek(&si, &c) && c != '\n') {
if (kvconfig_is_comment_start(c) && StrLen(value) > 0 &&
kvconfig_is_space(StrCharAt(value, StrLen(value) - 1))) {- In
KvConfig.c:237:
char c;
if (!StrIterPeek(&si, &c) || (c != '=' && c != ':')) {
LOG_ERROR("Expected '=' or ':' after config key");
StrClear(key);- In
KvConfig.c:254:
si = KvConfigSkipWhitespace(si);
if (!StrIterPeek(&si, &c)) {
// EOF after value is fine - last line without newline.
return si;- In
KvConfig.c:282:
char c;
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));- In
KvConfig.c:287:
StrIter read_si;
while (StrIterPeek(&si, &c)) {
if (c == '\n') {
StrIterMustNext(&si);- In
KvConfig.c:296:
si = KvConfigSkipWhitespace(si);
char c2;
if (!StrIterPeek(&si, &c2) || c2 == '\n') {
si = kvconfig_consume_line_end(si);
continue;- In
KvConfig.c:305:
}
if (!StrIterPeek(&si, &c)) {
StrDeinit(&key);
StrDeinit(&value);- In
JSON.c:22:
// starting of an object
char c;
if (!StrIterPeek(&si, &c) || c != '{') {
LOG_ERROR("Invalid object start. Expected '{'.");
return saved_si;- In
JSON.c:40:
// while not at the end of object.
while (StrIterPeek(&si, &c) && c != '}') {
if (expect_comma) {
if (c != ',') {- In
JSON.c:67:
si = JSkipWhitespace(si);
if (!StrIterPeek(&si, &c) || c != ':') {
LOG_ERROR("Expected ':' after key string. Failed to read JSON");
StrDeinit(&key);- In
JSON.c:97:
}
if (!StrIterPeek(&si, &c) || c != '}') {
LOG_ERROR("Expected end of object '}' but found '{c}'", c);
DefaultAllocatorDeinit(&scratch);- In
JSON.c:117:
char c;
if (!StrIterPeek(&si, &c) || c != '[') {
LOG_ERROR("Invalid array start. Expected '['.");
return saved_si;- In
JSON.c:128:
// while not at the end of array.
while (StrIterPeek(&si, &c) && c != ']') {
if (expect_comma) {
if (c != ',') {- In
JSON.c:155:
// end of array
if (!StrIterPeek(&si, &c) || c != ']') {
LOG_ERROR("Invalid end of array. Expected ']'.");
return saved_si;- In
JSON.c:166:
StrIter JSkipWhitespace(StrIter si) {
char c;
while (StrIterPeek(&si, &c)) {
switch (c) {
case ' ' :- In
JSON.c:195:
// string start
char c;
if (StrIterPeek(&si, &c) && c == '"') {
StrIterMustNext(&si);- In
JSON.c:199:
// while a printable character
while (StrIterPeek(&si, &c)) {
// three cases
// - end of string (return)
- In
JSON.c:213:
case '\\' :
StrIterMustNext(&si);
if (!StrIterPeek(&si, &c)) {
LOG_ERROR("Unexpected end of string.");
StrClear(str);- In
JSON.c:318:
bool is_neg = false;
char c;
if (StrIterPeek(&si, &c) && c == '-') {
is_neg = true;
StrIterMustNext(&si);- In
JSON.c:328:
bool is_parsing = true;
while (is_parsing && StrIterPeek(&si, &c)) {
switch (c) {
case 'E' :- In
JSON.c:513:
char c;
if (StrIterRemainingLength(&si) >= 4) {
if (StrIterPeek(&si, &c) && c == 't') {
Zstr pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "true", 4) == 0) {- In
JSON.c:525:
if (StrIterRemainingLength(&si) >= 5) {
if (StrIterPeek(&si, &c) && c == 'f') {
Zstr pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "false", 5) == 0) {- In
JSON.c:563:
char c;
if (StrIterRemainingLength(&si) >= 4) {
if (StrIterPeek(&si, &c) && c == 'n') {
Zstr pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "null", 4) == 0) {- In
JSON.c:593:
char c;
if (!StrIterPeek(&si, &c)) {
LOG_ERROR("Failed to read value. Invalid JSON");
return si;- In
Dns.c:29:
u64 total_bytes = 0;
char c;
while (StrIterPeek(&si, &c)) {
// Find next dot or end-of-string.
size seg_start = StrIterIndex(&si);- In
Dns.c:32:
// Find next dot or end-of-string.
size seg_start = StrIterIndex(&si);
while (StrIterPeek(&si, &c) && c != '.') {
StrIterMustNext(&si);
}- In
Dns.c:57:
return false;
}
if (StrIterPeek(&si, &c) && c == '.') {
StrIterMustNext(&si);
} si = JSkipWhitespace(si); \
char UNPL(jr_c); \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') { \
LOG_ERROR("Invalid object start. Expected '{'."); \
si = UNPL(saved_si); \
bool UNPL(expect_comma) = false; \
bool UNPL(failed) = false; \
while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') { \
if (UNPL(expect_comma)) { \
if (UNPL(jr_c) != ',') { \
si = UNPL(read_si); \
si = JSkipWhitespace(si); \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') { \
LOG_ERROR("Expected ':' after key string. Failed to read JSON"); \
StrDeinit(&key); \
} \
if (!UNPL(failed)) { \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') { \
LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c)); \
UNPL(failed) = true; \
char c = '\0';
if (!StrIterPeek(&si, &c) || c != '{') {
WriteFmt("[DEBUG] Peek check failed: expected '{', got '{c}'\n", c);
success = false;- In
JSON.h:448:
/* starting of an array */ \
char UNPL(jr_c); \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '[') { \
LOG_ERROR("Invalid array start. Expected '['."); \
si = UNPL(saved_si); \
- In
JSON.h:460:
\
/* while not at the end of array. */ \
while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != ']') { \
if (UNPL(expect_comma)) { \
if (UNPL(jr_c) != ',') { \
- In
JSON.h:498:
/* end of array */ \
if (!UNPL(failed)) { \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ']') { \
LOG_ERROR("Invalid end of array. Expected ']'."); \
UNPL(failed) = true; \
- In
JSON.h:544:
/* starting of an object */ \
char UNPL(jr_c); \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') { \
LOG_ERROR("Invalid object start. Expected '{'."); \
si = UNPL(saved_si); \
- In
JSON.h:557:
\
/* while not at the end of object. */ \
while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') { \
if (UNPL(expect_comma)) { \
if (UNPL(jr_c) != ',') { \
- In
JSON.h:586:
\
\
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') { \
LOG_ERROR("Expected ':' after key string. Failed to read JSON"); \
StrDeinit(&key); \
- In
JSON.h:628:
\
if (!UNPL(failed)) { \
if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') { \
LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c)); \
UNPL(failed) = true; \
Last updated on