bgetd.c (411B)
1 #include "lib9.h" 2 3 #include <bio.h> 4 5 struct bgetd { 6 Biobuf* b; 7 int eof; 8 }; 9 10 static int 11 Bgetdf(void* vp) { 12 int c; 13 struct bgetd* bg = vp; 14 15 c = Bgetc(bg->b); 16 if (c == Beof) 17 bg->eof = 1; 18 return c; 19 } 20 21 int Bgetd(Biobuf* bp, double* dp) { 22 double d; 23 struct bgetd b; 24 25 b.b = bp; 26 b.eof = 0; 27 d = fmtcharstod(Bgetdf, &b); 28 if (b.eof) 29 return -1; 30 Bungetc(bp); 31 *dp = d; 32 return 1; 33 }