Uninitialized vector entry?
[minix3.git] / lib / ack / libp / rdr.c
bloba9ea1c8f310bf54c110911d95b16c562d29adbe6
1 /* $Header$ */
2 /*
3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
5 * This product is part of the Amsterdam Compiler Kit.
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
19 /* Author: J.W. Stevenson */
21 #include <pc_file.h>
23 #define BIG 1e17
25 extern _rf();
26 extern _incpt();
27 extern _skipsp();
28 extern int _getsig();
29 extern int _getint();
30 extern int _fstdig();
31 extern int _nxtdig();
33 static double r;
34 static int pow10;
36 static dig(ch) int ch; {
38 if (r>BIG)
39 pow10++;
40 else
41 r = r*10.0 + ch;
44 double _rdr(f) struct file *f; {
45 int i; double e; int is_signed,ch;
47 r = 0;
48 pow10 = 0;
49 _rf(f);
50 _skipsp(f);
51 is_signed = _getsig(f);
52 ch = _fstdig(f);
54 dig(ch);
55 while ((ch = _nxtdig(f)) >= 0);
56 if (*f->ptr == '.') {
57 _incpt(f);
58 ch = _fstdig(f);
59 do {
60 dig(ch);
61 pow10--;
62 } while ((ch = _nxtdig(f)) >= 0);
64 if ((*f->ptr == 'e') || (*f->ptr == 'E')) {
65 _incpt(f);
66 pow10 += _getint(f);
68 if ((i = pow10) < 0)
69 i = -i;
70 e = 1.0;
71 while (--i >= 0)
72 e *= 10.0;
73 if (pow10<0)
74 r /= e;
75 else
76 r *= e;
77 return(is_signed? -r : r);