Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
sftable.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include <limits.h>
12#include <sfio/sfhdr.h>
13#include <stddef.h>
14#include <util/gv_ctype.h>
15
16/* Dealing with $ argument addressing stuffs.
17**
18** Written by Kiem-Phong Vo.
19*/
20
21static char *sffmtint(const char *str, int *v)
22{
23 for (*v = 0; gv_isdigit(*str); ++str)
24 *v = *v * 10 + (*str - '0');
25 *v -= 1;
26 return (char *) str;
27}
28
29/* table for floating point and integer conversions */
31 .sf_pos10 = {1e1, 1e2, 1e4, 1e8, 1e16, 1e32},
32 .sf_neg10 = {1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32},
33
34 .sf_dec =
35 {'0', '0', '0', '1', '0', '2', '0', '3', '0', '4',
36 '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
37 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4',
38 '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
39 '2', '0', '2', '1', '2', '2', '2', '3', '2', '4',
40 '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
41 '3', '0', '3', '1', '3', '2', '3', '3', '3', '4',
42 '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
43 '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',
44 '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
45 '5', '0', '5', '1', '5', '2', '5', '3', '5', '4',
46 '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
47 '6', '0', '6', '1', '6', '2', '6', '3', '6', '4',
48 '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
49 '7', '0', '7', '1', '7', '2', '7', '3', '7', '4',
50 '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
51 '8', '0', '8', '1', '8', '2', '8', '3', '8', '4',
52 '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
53 '9', '0', '9', '1', '9', '2', '9', '3', '9', '4',
54 '9', '5', '9', '6', '9', '7', '9', '8', '9', '9',
55 },
56
57 .sf_digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_",
58
59 .sf_fmtintf = sffmtint,
60 .sf_cv36 =
61 {
70 0, 1, 2, 3, 4, 5,
71 6, 7, 8, 9, SF_RADIX, SF_RADIX,
73 11, 12, 13, 14, 15, 16,
74 17, 18, 19, 20, 21, 22,
75 23, 24, 25, 26, 27, 28,
76 29, 30, 31, 32, 33, 34,
78 SF_RADIX, 10, 11, 12, 13, 14,
79 15, 16, 17, 18, 19, 20,
80 21, 22, 23, 24, 25, 26,
81 27, 28, 29, 30, 31, 32,
82 33, 34, 35, SF_RADIX, SF_RADIX, SF_RADIX,
105 },
106 .sf_cv64 =
107 {
116 0, 1, 2, 3, 4, 5,
117 6, 7, 8, 9, SF_RADIX, SF_RADIX,
119 37, 38, 39, 40, 41, 42,
120 43, 44, 45, 46, 47, 48,
121 49, 50, 51, 52, 53, 54,
122 55, 56, 57, 58, 59, 60,
124 SF_RADIX, 10, 11, 12, 13, 14,
125 15, 16, 17, 18, 19, 20,
126 21, 22, 23, 24, 25, 26,
127 27, 28, 29, 30, 31, 32,
128 33, 34, 35, SF_RADIX, SF_RADIX, SF_RADIX,
151 },
152 .sf_type = {
153 ['d'] = SFFMT_INT,
154 ['i'] = SFFMT_INT,
155 ['u'] = SFFMT_UINT,
156 ['o'] = SFFMT_UINT,
157 ['x'] = SFFMT_UINT,
158 ['X'] = SFFMT_UINT,
159 ['e'] = SFFMT_FLOAT,
160 ['E'] = SFFMT_FLOAT,
161 ['g'] = SFFMT_FLOAT,
162 ['G'] = SFFMT_FLOAT,
163 ['f'] = SFFMT_FLOAT,
164 ['s'] = SFFMT_POINTER,
165 ['n'] = SFFMT_POINTER,
166 ['p'] = SFFMT_POINTER,
167 ['!'] = SFFMT_POINTER,
168 ['c'] = SFFMT_BYTE,
169 ['['] = SFFMT_CLASS,
170 }
171};
replacements for ctype.h functions
static bool gv_isdigit(int c)
Definition gv_ctype.h:41
textitem scanner parser str
Definition htmlparse.y:224
#define SFFMT_CLASS
Definition sfhdr.h:117
#define SFFMT_POINTER
Definition sfhdr.h:116
#define SFFMT_BYTE
Definition sfhdr.h:115
#define SF_RADIX
Definition sfhdr.h:119
#define SFFMT_INT
Definition sfhdr.h:112
#define SFFMT_UINT
Definition sfhdr.h:113
#define SFFMT_FLOAT
Definition sfhdr.h:114
Sftab_t _Sftable
Definition sftable.c:30
static char * sffmtint(const char *str, int *v)
Definition sftable.c:21
long double sf_pos10[SF_MAXEXP10]
positive powers of 10
Definition sfhdr.h:138