source: git/ntl/src/newnames.c @ 2cfffe

spielwiese
Last change on this file since 2cfffe was 2cfffe, checked in by Hans Schönemann <hannes@…>, 21 years ago
This commit was generated by cvs2svn to compensate for changes in r6316, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6317 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.1 KB
Line 
1
2/************************************************************************
3
4This program can be compiled under either C or C++.
5It copies its input to its output, substituting all old
6NTL macro names by new NTL macro names.
7This is intended to automate the transition from NTL 3.1 to 3.5.
8
9Each maximal length alphanumeric substring in the input
10is looked up in a table, and if there is a match, the substring
11is replaced.
12
13*************************************************************************/
14
15
16#include <stdio.h>
17#include <string.h>
18
19#define NumNames (79)
20
21const char *names[NumNames][2] = {
22{ "BB_HALF_MUL_CODE", "NTL_BB_HALF_MUL_CODE" },
23{ "BB_MUL_CODE", "NTL_BB_MUL_CODE" },
24{ "BB_REV_CODE", "NTL_BB_REV_CODE" },
25{ "BB_SQR_CODE", "NTL_BB_SQR_CODE" },
26{ "FFTFudge", "NTL_FFTFudge" },
27{ "FFTMaxRoot", "NTL_FFTMaxRoot" },
28{ "FFTMaxRootBnd", "NTL_FFTMaxRootBnd" },
29{ "QUAD_FLOAT_SPLIT", "NTL_QUAD_FLOAT_SPLIT" },
30{ "WV_NTL_RANGE_CHECK_CODE", "NTL_WV_RANGE_CHECK_CODE" },
31{ "WordVectorExpansionRatio", "NTL_WordVectorExpansionRatio" },
32{ "WordVectorInputBlock", "NTL_WordVectorInputBlock" },
33{ "WordVectorMinAlloc", "NTL_WordVectorMinAlloc" },
34{ "XD_BOUND", "NTL_XD_BOUND" },
35{ "XD_BOUND_INV", "NTL_XD_BOUND_INV" },
36{ "XD_HBOUND", "NTL_XD_HBOUND" },
37{ "XD_HBOUND_INV", "NTL_XD_HBOUND_INV" },
38{ "ZZ_ARITH_RIGHT_SHIFT", "NTL_ARITH_RIGHT_SHIFT" },
39{ "ZZ_BITS_PER_INT", "NTL_BITS_PER_INT" },
40{ "ZZ_BITS_PER_LONG", "NTL_BITS_PER_LONG" },
41{ "ZZ_DOUBLES_LOW_HIGH", "NTL_DOUBLES_LOW_HIGH" },
42{ "ZZ_DOUBLE_PRECISION", "NTL_DOUBLE_PRECISION" },
43{ "ZZ_EXT_DOUBLE", "NTL_EXT_DOUBLE" },
44{ "ZZ_FDOUBLE_PRECISION", "NTL_FDOUBLE_PRECISION" },
45{ "ZZ_FRADIX", "NTL_FRADIX" },
46{ "ZZ_FRADIX_INV", "NTL_FRADIX_INV" },
47{ "ZZ_FetchHiLo", "NTL_FetchHiLo" },
48{ "ZZ_FetchLo", "NTL_FetchLo" },
49{ "ZZ_HI_WD", "NTL_HI_WD" },
50{ "ZZ_LO_WD", "NTL_LO_WD" },
51{ "ZZ_MAX_INT", "NTL_MAX_INT" },
52{ "ZZ_MAX_LONG", "NTL_MAX_LONG" },
53{ "ZZ_MIN_INT", "NTL_MIN_INT" },
54{ "ZZ_MIN_LONG", "NTL_MIN_LONG" },
55{ "ZZ_NBITS", "NTL_NBITS" },
56{ "ZZ_NBITSH", "NTL_NBITSH" },
57{ "ZZ_NBITS_MAX", "NTL_NBITS_MAX" },
58{ "ZZ_NTL_SINGLE_MUL_OK", "NTL_SINGLE_MUL_OK" },
59{ "ZZ_PRIME_BND", "NTL_PRIME_BND" },
60{ "ZZ_RADIX", "NTL_RADIX" },
61{ "ZZ_RADIXM", "NTL_RADIXM" },
62{ "ZZ_RADIXROOT", "NTL_RADIXROOT" },
63{ "ZZ_RADIXROOTM", "NTL_RADIXROOTM" },
64{ "ZZ_pRegister", "NTL_ZZ_pRegister" },
65{ "ZZ_pX_BERMASS_CROSSOVER", "NTL_ZZ_pX_BERMASS_CROSSOVER" },
66{ "ZZ_pX_DIV_CROSSOVER", "NTL_ZZ_pX_DIV_CROSSOVER" },
67{ "ZZ_pX_FFT_CROSSOVER", "NTL_ZZ_pX_FFT_CROSSOVER" },
68{ "ZZ_pX_GCD_CROSSOVER", "NTL_ZZ_pX_GCD_CROSSOVER" },
69{ "ZZ_pX_HalfGCD_CROSSOVER", "NTL_ZZ_pX_HalfGCD_CROSSOVER" },
70{ "ZZ_pX_NEWTON_CROSSOVER", "NTL_ZZ_pX_NEWTON_CROSSOVER" },
71{ "ZZ_pX_TRACE_CROSSOVER", "NTL_ZZ_pX_TRACE_CROSSOVER" },
72{ "ntl_eq_matrix_decl", "NTL_eq_matrix_decl" },
73{ "ntl_eq_matrix_impl", "NTL_eq_matrix_impl" },
74{ "ntl_eq_vector_decl", "NTL_eq_vector_decl" },
75{ "ntl_eq_vector_impl", "NTL_eq_vector_impl" },
76{ "ntl_io_matrix_decl", "NTL_io_matrix_decl" },
77{ "ntl_io_matrix_impl", "NTL_io_matrix_impl" },
78{ "ntl_io_vector_decl", "NTL_io_vector_decl" },
79{ "ntl_io_vector_impl", "NTL_io_vector_impl" },
80{ "ntl_matrix_decl", "NTL_matrix_decl" },
81{ "ntl_matrix_impl", "NTL_matrix_impl" },
82{ "ntl_pair_decl", "NTL_pair_decl" },
83{ "ntl_pair_eq_decl", "NTL_pair_eq_decl" },
84{ "ntl_pair_eq_impl", "NTL_pair_eq_impl" },
85{ "ntl_pair_impl", "NTL_pair_impl" },
86{ "ntl_pair_io_decl", "NTL_pair_io_decl" },
87{ "ntl_pair_io_impl", "NTL_pair_io_impl" },
88{ "ntl_vector_decl", "NTL_vector_decl" },
89{ "ntl_vector_default", "NTL_vector_default" },
90{ "ntl_vector_impl", "NTL_vector_impl" },
91{ "ntl_vector_impl_plain", "NTL_vector_impl_plain" },
92{ "zz_pRegister", "NTL_zz_pRegister" },
93{ "zz_pX_BERMASS_CROSSOVER", "NTL_zz_pX_BERMASS_CROSSOVER" },
94{ "zz_pX_DIV_CROSSOVER", "NTL_zz_pX_DIV_CROSSOVER" },
95{ "zz_pX_GCD_CROSSOVER", "NTL_zz_pX_GCD_CROSSOVER" },
96{ "zz_pX_HalfGCD_CROSSOVER", "NTL_zz_pX_HalfGCD_CROSSOVER" },
97{ "zz_pX_MOD_CROSSOVER", "NTL_zz_pX_MOD_CROSSOVER" },
98{ "zz_pX_MUL_CROSSOVER", "NTL_zz_pX_MUL_CROSSOVER" },
99{ "zz_pX_NEWTON_CROSSOVER", "NTL_zz_pX_NEWTON_CROSSOVER" },
100{ "zz_pX_TRACE_CROSSOVER", "NTL_zz_pX_TRACE_CROSSOVER" },
101};
102
103
104void PrintName(const char *name)
105{
106   int i;
107
108   i = 0;
109   while (i < NumNames && strcmp(name, names[i][0]))
110      i++;
111
112   if (i >= NumNames)
113      printf("%s", name);
114   else
115      printf("%s", names[i][1]);
116}
117
118
119int IsAlphaNum(int c)
120{
121   return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
122           (c == '_') || (c >= '0' && c <= '9'));
123}
124
125char buf[10000];
126
127
128int main()
129{
130   int c;
131   int state;
132   int len;
133
134   state = 0;
135   len = 0;
136
137
138   do {
139      c = getchar();
140
141      switch (state) {
142      case 0:
143         if (IsAlphaNum(c)) {
144            buf[len] = c;
145            len++;
146            state = 1;
147         }
148         else {
149            if (c != EOF) putchar(c);
150         }
151
152         break;
153
154      case 1:
155         if (IsAlphaNum(c)) {
156            buf[len] = c;
157            len++;
158         }
159         else {
160            buf[len] = '\0';
161            PrintName(buf);
162            len = 0;
163
164            if (c != EOF) putchar(c);
165            state = 0;
166         }
167
168         break;
169      }
170   } while (c != EOF);
171   
172   return 0;
173}
Note: See TracBrowser for help on using the repository browser.