add "scan helper getc" and rework strtod, etc. to use it
[musl] / src / internal / shgetc.h
1 #include "stdio_impl.h"
2
3 void __shlim(FILE *, off_t);
4 int __shgetc(FILE *);
5
6 static inline off_t shcnt(FILE *f)
7 {
8         return f->shcnt + (f->rpos - f->rend);
9 }
10
11 static inline void shlim(FILE *f, off_t lim)
12 {
13         __shlim(f, lim);
14 }
15
16 static inline int shgetc(FILE *f)
17 {
18         if (f->rpos < f->shend) return *f->rpos++;
19         return __shgetc(f);
20 }
21
22 static inline void shunget(FILE *f)
23 {
24         if (f->rend) f->rpos--;
25 }