Fix the output so it really does dynamically resize the table.
Submitted by: Diane Bruce <db@db.net>
This commit is contained in:
parent
1dce684051
commit
2780cd8718
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=84503
@ -69,6 +69,7 @@ static int pack_vector __P((int));
|
||||
static void save_column __P((int, int));
|
||||
static void sort_actions __P((void));
|
||||
static void token_actions __P((void));
|
||||
static int increase_maxtable __P((int));
|
||||
|
||||
static const char line_format[] = "#line %d \"%s\"\n";
|
||||
static int nvectors;
|
||||
@ -630,7 +631,6 @@ int vector;
|
||||
register int ok;
|
||||
register short *from;
|
||||
register short *to;
|
||||
int newmax;
|
||||
|
||||
i = order[vector];
|
||||
t = tally[i];
|
||||
@ -655,19 +655,7 @@ int vector;
|
||||
{
|
||||
if (loc >= MAXTABLE)
|
||||
fatal("maximum table size exceeded");
|
||||
|
||||
newmax = maxtable;
|
||||
do { newmax += 200; } while (newmax <= loc);
|
||||
table = (short *) REALLOC(table, newmax*sizeof(short));
|
||||
if (table == 0) no_space();
|
||||
check = (short *) REALLOC(check, newmax*sizeof(short));
|
||||
if (check == 0) no_space();
|
||||
for (l = maxtable; l < newmax; ++l)
|
||||
{
|
||||
table[l] = 0;
|
||||
check[l] = -1;
|
||||
}
|
||||
maxtable = newmax;
|
||||
maxtable = increase_maxtable(loc);
|
||||
}
|
||||
|
||||
if (check[loc] != -1)
|
||||
@ -689,7 +677,19 @@ int vector;
|
||||
}
|
||||
|
||||
while (check[lowzero] != -1)
|
||||
{
|
||||
if (lowzero >= maxtable)
|
||||
{
|
||||
if (lowzero >= MAXTABLE)
|
||||
{
|
||||
fatal("maximum table size exceeded in check\n");
|
||||
}
|
||||
|
||||
maxtable = increase_maxtable(loc);
|
||||
}
|
||||
|
||||
++lowzero;
|
||||
}
|
||||
|
||||
return (j);
|
||||
}
|
||||
@ -1313,3 +1313,33 @@ free_reductions()
|
||||
FREE(rp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* increase_maxtable
|
||||
*
|
||||
* inputs - loc location in table
|
||||
* output - size increased to
|
||||
* side effects - table is increase by at least 200 short words
|
||||
*/
|
||||
|
||||
int
|
||||
increase_maxtable(int loc)
|
||||
{
|
||||
int newmax;
|
||||
int l;
|
||||
|
||||
newmax = maxtable;
|
||||
|
||||
do { newmax += 200; } while (newmax <= loc);
|
||||
table = (short *) REALLOC(table, newmax*sizeof(short));
|
||||
if (table == 0) no_space();
|
||||
check = (short *) REALLOC(check, newmax*sizeof(short));
|
||||
if (check == 0) no_space();
|
||||
for (l = maxtable; l < newmax; ++l)
|
||||
{
|
||||
table[l] = 0;
|
||||
check[l] = -1;
|
||||
}
|
||||
|
||||
return(newmax);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user