1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 /*
23  * generate sfio _Sftable static initializers
24  */
25 
26 #include "FEATURE/common"
27 #include "FEATURE/float"
28 
29 int
main()30 main()
31 {
32 	register int	i;
33 #if _ast_fltmax_double
34 	char*		fs = "";
35 	char*		ds = "";
36 	char*		ls = "";
37 #else
38 	char*		fs = "F";
39 	char*		ds = "";
40 	char*		ls = "L";
41 #endif
42 
43 	printf("\nstatic const float sf_flt_pow10[] =\n{\n");
44 	for (i = 0; i <= FLT_MAX_10_EXP; i++)
45 		printf("\t1E%d%s,\n", i, fs);
46 	printf("};\n");
47 	printf("\nstatic const double sf_dbl_pow10[] =\n{\n");
48 	for (i = 0; i <= DBL_MAX_10_EXP; i++)
49 		printf("\t1E%d%s,\n", i, ds);
50 	printf("};\n");
51 #if !_ast_fltmax_double
52 	printf("\nstatic const _ast_fltmax_t sf_ldbl_pow10[] =\n{\n");
53 	for (i = 0; i <= LDBL_MAX_10_EXP; i++)
54 		printf("\t1E%d%s,\n", i, ls);
55 	printf("};\n");
56 #endif
57 	printf("\nSftab_t _Sftable =\n{\n");
58 	printf("\t{ 1E1%s, 1E2%s, 1E4%s, 1E8%s, 1E16%s, 1E32%s },\n", ls, ls, ls, ls, ls, ls);
59 	printf("\t{ 1E-1%s, 1E-2%s, 1E-4%s, 1E-8%s, 1E-16%s, 1E-32%s },\n", ls, ls, ls, ls, ls, ls);
60 	printf("\t{ '0','0', '0','1', '0','2', '0','3', '0','4',\n");
61 	printf("\t  '0','5', '0','6', '0','7', '0','8', '0','9',\n");
62 	printf("\t  '1','0', '1','1', '1','2', '1','3', '1','4',\n");
63 	printf("\t  '1','5', '1','6', '1','7', '1','8', '1','9',\n");
64 	printf("\t  '2','0', '2','1', '2','2', '2','3', '2','4',\n");
65 	printf("\t  '2','5', '2','6', '2','7', '2','8', '2','9',\n");
66 	printf("\t  '3','0', '3','1', '3','2', '3','3', '3','4',\n");
67 	printf("\t  '3','5', '3','6', '3','7', '3','8', '3','9',\n");
68 	printf("\t  '4','0', '4','1', '4','2', '4','3', '4','4',\n");
69 	printf("\t  '4','5', '4','6', '4','7', '4','8', '4','9',\n");
70 	printf("\t  '5','0', '5','1', '5','2', '5','3', '5','4',\n");
71 	printf("\t  '5','5', '5','6', '5','7', '5','8', '5','9',\n");
72 	printf("\t  '6','0', '6','1', '6','2', '6','3', '6','4',\n");
73 	printf("\t  '6','5', '6','6', '6','7', '6','8', '6','9',\n");
74 	printf("\t  '7','0', '7','1', '7','2', '7','3', '7','4',\n");
75 	printf("\t  '7','5', '7','6', '7','7', '7','8', '7','9',\n");
76 	printf("\t  '8','0', '8','1', '8','2', '8','3', '8','4',\n");
77 	printf("\t  '8','5', '8','6', '8','7', '8','8', '8','9',\n");
78 	printf("\t  '9','0', '9','1', '9','2', '9','3', '9','4',\n");
79 	printf("\t  '9','5', '9','6', '9','7', '9','8', '9','9',\n");
80 	printf("\t},\n");
81 	printf("\t\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_\",\n");
82 	printf("\tsfcvinit, 0,\n");
83 	printf("\tsffmtpos,\n");
84 	printf("\tsffmtint,\n");
85 	printf("\t(float*)&sf_flt_pow10[0],\n");
86 	printf("\t(double*)&sf_dbl_pow10[0],\n");
87 #if _ast_fltmax_double
88 	printf("\t0,\n");
89 #else
90 	printf("\t(_ast_fltmax_t*)&sf_ldbl_pow10[0],\n");
91 #endif
92 	printf("};\n");
93 	return 0;
94 }
95