. service tells you which device it couldn't stat
[minix3.git] / lib / ack / libp / wrr.c
blob5c2df66e704c6e187781c0e347ab5696f5bf89b8
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_err.h>
22 #include <pc_file.h>
24 extern _wstrin();
25 extern char *_ecvt();
27 #define PREC_DIG 80 /* maximum digits produced by _ecvt() */
29 _wsr(w,r,f) int w; double r; struct file *f; {
30 char *p,*b; int s,d,i; char buf[PREC_DIG+7];
32 if (w < 0) _trp(EWIDTH);
33 p = buf;
34 if ((i = w-6) < 2)
35 i = 2;
36 b = _ecvt(r,i,&d,&s);
37 *p++ = s? '-' : ' ';
38 if (*b == '0')
39 d++;
40 *p++ = *b++;
41 *p++ = '.';
42 while (--i > 0)
43 *p++ = *b++;
44 *p++ = 'e';
45 d--;
46 if (d < 0) {
47 d = -d;
48 *p++ = '-';
49 } else
50 *p++ = '+';
52 if (d >= 1000) {
53 *p++ = '*';
54 *p++ = '*';
55 *p++ = '*';
57 else {
58 *p++ = '0' + d/100;
59 *p++ = '0' + (d/10) % 10;
60 *p++ = '0' + d%10;
62 _wstrin(w,(int)(p-buf),buf,f);
65 _wrr(r,f) double r; struct file *f; {
66 _wsr(13,r,f);