File: isconst.c

package info (click to toggle)
wcalc 2.4-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,916 kB
  • sloc: ansic: 7,089; objc: 2,002; sh: 890; lex: 816; yacc: 641; makefile: 103
file content (144 lines) | stat: -rw-r--r-- 3,041 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <string.h>
#include <stdio.h>
#include "isconst.h"
#ifdef MEMWATCH
#include "memwatch.h"
#endif

#warning this is all in utf8... should probably use iconv

const constdef consts[] = {
    {W_e,"e"},
    {W_pi,"pi"},
    {W_pi,"pI"},
    {W_pi,"Pi"},
    {W_pi,"PI"},
    {W_pi,"\317\200"},
    {W_random,"random"},
    {W_Na,"Na"},
    {W_Na,"NA"},
    {W_k,"k"},
    {W_Cc,"Cc"},
    {W_ec,"ec"},
    {W_R,"R"},
    {W_G,"G"},
    {W_g,"g"},
    {W_Me,"Me"},
    {W_Mp,"Mp"},
    {W_Mn,"Mn"},
    {W_Md,"Md"},
    {W_u,"u"},
    {W_u,"amu"},
    {W_c,"c"},
    {W_h,"h"},
    {W_mu0, "mu0"},
    {W_mu0, "muzero"},
    {W_mu0, "muZERO"},
    {W_mu0, "\302\2650"},
    {W_mu0, "\302\265zero"},
    {W_mu0, "\302\265ZERO"},
    {W_mu0, "\316\2740"},
    {W_mu0, "\316\274zero"},
    {W_mu0, "\316\274ZERO"},
    {W_epsilon0, "epsilonzero"},
    {W_epsilon0, "epsilonZERO"},
    {W_epsilon0, "epsilon0"},
    {W_epsilon0, "EPSILONzero"},
    {W_epsilon0, "EPSILONZERO"},
    {W_epsilon0, "EPSILON0"},
    {W_epsilon0, "\316\265zero"},
    {W_epsilon0, "\316\265ZERO"},
    {W_epsilon0, "\316\2650"},
    {W_muB, "\302\265B"},
    {W_muB, "\316\274B"},
    {W_muB, "muB"},
    {W_muN, "\302\265N"},
    {W_muN, "\316\274N"},
    {W_muN, "muN"},
    {W_b, "b"},
    {W_a0, "a0"},
    {W_F, "F"},
    {W_Vm, "Vm"},
    {W_Vm, "NAk"},
    {W_eV, "eV"},
    {W_sigma, "sigma"},
    {W_sigma, "\317\203"},
    {W_alpha, "alpha"},
    {W_alpha, "\316\261"},
    {W_gamma, "gamma"},
    {W_gamma, "GAMMA"},
    {W_gamma, "\316\263"},
    {W_re, "re"},
    {W_Kj, "Kj"},
    {W_Rk, "Rk"},
    {W_Rinf, "Rinf"},
    {W_Rinf, "R\342\210\236"},
    {W_Eh, "Eh"},
    {W_Gf, "Gf"},
    {W_Mmu, "Mmu"},
    {W_Mmu, "M\302\265"},
    {W_Mmu, "M\316\274"},
    {W_Mt, "Mt"},
    {W_Mt, "Mtau"},
    {W_Mt, "M\317\204"},
    {W_Mh, "Mh"},
    {W_Malpha, "Malpha"},
    {W_Malpha, "M\316\261"},
    {W_n0, "n0"},
    {W_n0, "nzero"},
    {W_n0, "nZERO"},
    {W_c1, "c1"},
    {W_c2, "c2"},
    {W_G0, "G0"},
    {W_G0, "Gzero"},
    {W_G0, "GZERO"},
    {W_Z0, "Z0"},
    {W_Z0, "Zzero"},
    {W_Z0, "ZZERO"},
    {W_Phi0, "Phi0"},
    {W_Phi0, "Phizero"},
    {W_Phi0, "PhiZERO"},
    {W_Phi0, "\316\2460"},
    {W_Phi0, "\316\246zero"},
    {W_Phi0, "\316\246ZERO"},
    {W_quarter, "\302\274"},
    {W_half, "\302\275"},
    {W_threequarters, "\302\276"},
    {W_K, "K"},
    {W_NaN, "@NaN@"},
    {W_Inf, "@Inf@"},
    {W_notaconstant,0}
};

consttype isconst(const char *str)
{
    int i;

    for (i=0; consts[i].label; i++) {
	if (strcmp(consts[i].label, str) == 0) {
	    return consts[i].type;
	}
    }
    return W_notaconstant;
}

void printconsts()
{
    size_t i;
    size_t linelen = 0;

    for (i=0; consts[i].label; i++) {
	if (linelen + strlen(consts[i].label) + 2 > 70) {
	    printf(",\n");
	    linelen = 0;
	}
	if (linelen == 0) {
	    printf("%s", consts[i].label);
	    linelen = strlen(consts[i].label);
	} else {
	    printf(", %s", consts[i].label);
	    linelen += strlen(consts[i].label) + 2;
	}
    }
    printf("\n");
}