122 |
static short *order = NULL; |
static short *order = NULL; |
123 |
static short *base = NULL; |
static short *base = NULL; |
124 |
static short *pos = NULL; |
static short *pos = NULL; |
125 |
|
|
126 |
|
/* TABLE_SIZE is the allocated size of both TABLE and CHECK. |
127 |
|
We start with the original hard-coded value: SHRT_MAX |
128 |
|
(yes, not USHRT_MAX). */ |
129 |
|
static size_t table_size = SHRT_MAX; |
130 |
static short *table = NULL; |
static short *table = NULL; |
131 |
static short *check = NULL; |
static short *check = NULL; |
132 |
static int lowzero; |
static int lowzero; |
138 |
int error_verbose = 0; |
int error_verbose = 0; |
139 |
|
|
140 |
|
|
141 |
|
/*----------------------------------------------------------------. |
142 |
|
| If TABLE (and CHECK) appear to be small to be addressed at | |
143 |
|
| DESIRED, grow them. Note that TABLE[DESIRED] is to be used, so | |
144 |
|
| the desired size is at least DESIRED + 1. | |
145 |
|
`----------------------------------------------------------------*/ |
146 |
|
|
147 |
|
static void |
148 |
|
table_grow (size_t desired) |
149 |
|
{ |
150 |
|
size_t old_size = table_size; |
151 |
|
|
152 |
|
while (table_size <= desired) |
153 |
|
table_size *= 2; |
154 |
|
|
155 |
|
if (trace_flag) |
156 |
|
fprintf (stderr, "growing table and check from: %d to %d\n", |
157 |
|
old_size, table_size); |
158 |
|
|
159 |
|
table = XREALLOC (table, short, table_size); |
160 |
|
check = XREALLOC (check, short, table_size); |
161 |
|
|
162 |
|
for (/* Nothing. */; old_size < table_size; ++old_size) |
163 |
|
{ |
164 |
|
table[old_size] = 0; |
165 |
|
check[old_size] = -1; |
166 |
|
} |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
/*------------------------------------------------------------------. |
/*------------------------------------------------------------------. |
171 |
| Create a function NAME which Format the FIRST and then | |
| Create a function NAME which Format the FIRST and then | |
172 |
| TABLE_DATA[BEGIN..END[ (of TYPE) into OOUT, and return the number | |
| TABLE_DATA[BEGIN..END[ (of TYPE) into OOUT, and return the number | |
802 |
return -1; |
return -1; |
803 |
} |
} |
804 |
|
|
|
/* FIXME: For the time being, best approximation... */ |
|
|
#define MAXTABLE SHRT_MAX |
|
805 |
|
|
806 |
static int |
static int |
807 |
pack_vector (int vector) |
pack_vector (int vector) |
815 |
|
|
816 |
assert (t); |
assert (t); |
817 |
|
|
818 |
for (j = lowzero - from[0]; j < MAXTABLE; j++) |
for (j = lowzero - from[0]; j < (int) table_size; j++) |
819 |
{ |
{ |
820 |
int k; |
int k; |
821 |
int ok = 1; |
int ok = 1; |
823 |
for (k = 0; ok && k < t; k++) |
for (k = 0; ok && k < t; k++) |
824 |
{ |
{ |
825 |
loc = j + from[k]; |
loc = j + from[k]; |
826 |
if (loc > MAXTABLE) |
if (loc > (int) table_size) |
827 |
fatal (_("maximum table size (%d) exceeded"), MAXTABLE); |
table_grow (loc); |
828 |
|
|
829 |
if (table[loc] != 0) |
if (table[loc] != 0) |
830 |
ok = 0; |
ok = 0; |
867 |
|
|
868 |
base = XCALLOC (short, nvectors); |
base = XCALLOC (short, nvectors); |
869 |
pos = XCALLOC (short, nentries); |
pos = XCALLOC (short, nentries); |
870 |
table = XCALLOC (short, MAXTABLE); |
table = XCALLOC (short, table_size); |
871 |
check = XCALLOC (short, MAXTABLE); |
check = XCALLOC (short, table_size); |
872 |
|
|
873 |
lowzero = 0; |
lowzero = 0; |
874 |
high = 0; |
high = 0; |
876 |
for (i = 0; i < nvectors; i++) |
for (i = 0; i < nvectors; i++) |
877 |
base[i] = SHRT_MIN; |
base[i] = SHRT_MIN; |
878 |
|
|
879 |
for (i = 0; i < MAXTABLE; i++) |
for (i = 0; i < (int) table_size; i++) |
880 |
check[i] = -1; |
check[i] = -1; |
881 |
|
|
882 |
for (i = 0; i < nentries; i++) |
for (i = 0; i < nentries; i++) |