1 #include <u.h> 2 #include <libc.h> 3 4 static int 5 strtodf(void *vp) 6 { 7 return *(*((char**)vp))++; 8 } 9 10 double 11 strtod(char *s, char **end) 12 { 13 double d; 14 char *ss; 15 int c; 16 17 ss = s; 18 d = charstod(strtodf, &s); 19 /* 20 * Fix cases like 2.3e+ , which charstod will consume 21 */ 22 if(end){ 23 *end = --s; 24 while(s > ss){ 25 c = *--s; 26 if(c!='-' && c!='+' && c!='e' && c!='E') 27 break; 28 (*end)--; 29 } 30 } 31 return d; 32 } 33