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