1 | /****************************************************************
|
---|
2 |
|
---|
3 | The author of this software is David M. Gay.
|
---|
4 |
|
---|
5 | Copyright (C) 1998, 2001 by Lucent Technologies
|
---|
6 | All Rights Reserved
|
---|
7 |
|
---|
8 | Permission to use, copy, modify, and distribute this software and
|
---|
9 | its documentation for any purpose and without fee is hereby
|
---|
10 | granted, provided that the above copyright notice appear in all
|
---|
11 | copies and that both that the copyright notice and this
|
---|
12 | permission notice and warranty disclaimer appear in supporting
|
---|
13 | documentation, and that the name of Lucent or any of its entities
|
---|
14 | not be used in advertising or publicity pertaining to
|
---|
15 | distribution of the software without specific, written prior
|
---|
16 | permission.
|
---|
17 |
|
---|
18 | LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
---|
19 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
---|
20 | IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
|
---|
21 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
22 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
---|
23 | IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
24 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
---|
25 | THIS SOFTWARE.
|
---|
26 |
|
---|
27 | ****************************************************************/
|
---|
28 |
|
---|
29 | /* Please send bug reports to
|
---|
30 | David M. Gay
|
---|
31 | Bell Laboratories, Room 2C-463
|
---|
32 | 600 Mountain Avenue
|
---|
33 | Murray Hill, NJ 07974-0636
|
---|
34 | U.S.A.
|
---|
35 | dmg@bell-labs.com
|
---|
36 | */
|
---|
37 |
|
---|
38 | #include "gdtoaimp.h"
|
---|
39 | #include <stdio.h>
|
---|
40 | #include <stdlib.h>
|
---|
41 |
|
---|
42 | static char ibuf[2048];
|
---|
43 |
|
---|
44 | #define U (unsigned long)
|
---|
45 |
|
---|
46 | static void
|
---|
47 | #ifdef KR_headers
|
---|
48 | dshow(what, d) char *what; double d;
|
---|
49 | #else
|
---|
50 | dshow(char *what, double d)
|
---|
51 | #endif
|
---|
52 | {
|
---|
53 | char buf[32];
|
---|
54 | g_dfmt(buf, &d, 0, sizeof(buf));
|
---|
55 | printf("%s = #%lx %lx = %s\n", what,
|
---|
56 | U ((ULong*)&d)[_0], U ((ULong*)&d)[_1], buf);
|
---|
57 | }
|
---|
58 |
|
---|
59 | int
|
---|
60 | main(Void)
|
---|
61 | {
|
---|
62 | /* Input: one number per line */
|
---|
63 |
|
---|
64 | char *s, *se, *se1;
|
---|
65 | int i, j;
|
---|
66 | double dd[2], dd1, dd2;
|
---|
67 | static char cfmt[] = "%s consumes %d bytes and returns %d\n";
|
---|
68 |
|
---|
69 | while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
|
---|
70 | while(*s <= ' ')
|
---|
71 | if (!*s++)
|
---|
72 | continue;
|
---|
73 | printf("\nInput: %s", ibuf);
|
---|
74 | i = strtodI(ibuf, &se, dd);
|
---|
75 | printf(cfmt, "strtodI", (int)(se-ibuf), i);
|
---|
76 | dshow("dd[0]", dd[0]);
|
---|
77 | dshow("dd[1]", dd[1]);
|
---|
78 | printf("\n");
|
---|
79 | j = strtoId(ibuf, &se1, &dd1, &dd2);
|
---|
80 | if (j != i || se != se1
|
---|
81 | || dd[0] != dd1 || dd[1] != dd2) {
|
---|
82 | printf(cfmt, "**** strtoId", (int)(se-ibuf), j);
|
---|
83 | dshow("dd1", dd1);
|
---|
84 | dshow("dd2", dd2);
|
---|
85 | }
|
---|
86 | }
|
---|
87 | return 0;
|
---|
88 | }
|
---|