benilla-re systems structs docs

_ungetc_lk

function · crt · primitive

Address
0x741c1b · 110 bytes, up to 0x741c88
Signature
int32_t __cdecl (int32_t c, void *stream)
Meaning
Pushes a byte back and returns it, or EOF; a string stream takes it only if the byte before the pointer equals it
Confidence
verified, proof one
Finding
crt/scanf#the-string-stream
Test
crt::crt_sscanf_fixed_difftest, crt::crt_sscanf_random_difftest

Finding: The string stream in crt: formatted input

sscanf(s, fmt, ...) (0x73fb5d) builds a stack FILE with _ptr and _base at s, _cnt its length and _flag 0x49 (read, string, own buffer), and answers __input(stream, fmt, args) (0x744e21). _inc (0x74587d) takes the next byte, unsigned, while --_cnt is not negative; past the end __filbuf (0x745946) answers EOF, −1, and the count keeps falling. __un_inc (0x745897) ignores EOF; _ungetc_lk (0x741c1b) keeps its step back and raises _cnt only when the byte there is the one pushed, so a pushback never changes the string, and at the start with _cnt other than 0 it refuses. __whiteout (0x7458ae) counts and reads until a byte is not a space.

The derivation is in the doc.

Callers 2

Callees 1

Calls and jumps by a bare address, from tables/calls.tsv.