parent
eeefc4ba3b
commit
e1082f64bc
@ -2461,15 +2461,20 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
|
||||
constvalue *enumroot,int *errorfound)
|
||||
{
|
||||
cell dsize,totalsize;
|
||||
int idx,abortparse;
|
||||
int idx,numvectors,abortparse,ellips;
|
||||
const char *initptr,*prev_initptr;
|
||||
|
||||
assert(cur>=0 && cur<numdim);
|
||||
assert(startlit>=0);
|
||||
assert(cur+2<=numdim);/* there must be 2 dimensions or more to do */
|
||||
assert(cur+2<=numdim); /* there must be 2 dimensions or more to do */
|
||||
assert(errorfound!=NULL && *errorfound==FALSE);
|
||||
idx=0;
|
||||
prev_initptr=NULL;
|
||||
totalsize=0;
|
||||
abortparse=FALSE;
|
||||
needtoken('{');
|
||||
for (idx=0,abortparse=FALSE; !abortparse; idx++) {
|
||||
do {
|
||||
int ellips=FALSE;
|
||||
/* In case the major dimension is zero, we need to store the offset
|
||||
* to the newly detected sub-array into the indirection table; i.e.
|
||||
* this table needs to be expanded and updated.
|
||||
@ -2481,24 +2486,40 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
|
||||
if (dim[cur]==0) {
|
||||
litinsert(0,startlit);
|
||||
} else if (idx>=dim[cur]) {
|
||||
error(18); /* initialization data exceeds array size */
|
||||
error(18); /* initialization data exceeds array size */
|
||||
break;
|
||||
} /* if */
|
||||
if (cur+2<numdim) {
|
||||
if (cur<numdim-2) {
|
||||
dsize=initarray(ident,tag,dim,numdim,cur+1,startlit,counteddim,
|
||||
lastdim,enumroot,errorfound);
|
||||
} else {
|
||||
dsize=initvector(ident,tag,dim[cur+1],TRUE,enumroot,errorfound);
|
||||
/* The final dimension may be variable length. We need to save the
|
||||
* lengths of the final dimensions in order to set the indirection
|
||||
* vectors for the next-to-last dimension.
|
||||
*/
|
||||
append_constval(lastdim,itoh(idx),dsize,0);
|
||||
initptr=lptr;
|
||||
numvectors=idx+1;
|
||||
if ((ellips=matchtoken(tELLIPS))!=0)
|
||||
numvectors=dim[cur];
|
||||
dsize=0;
|
||||
while (idx<numvectors) {
|
||||
if (ellips && prev_initptr!=NULL)
|
||||
lptr=prev_initptr; /* go back to array initializer */
|
||||
dsize+=initvector(ident,tag,dim[cur+1],TRUE,enumroot,errorfound);
|
||||
if (*errorfound)
|
||||
break;
|
||||
/* The final dimension may be variable length. We need to save the
|
||||
* lengths of the final dimensions in order to set the indirection
|
||||
* vectors for the next-to-last dimension.
|
||||
*/
|
||||
append_constval(lastdim,itoh(idx++),dsize,0);
|
||||
} /* for */
|
||||
if (ellips) {
|
||||
needtoken(',');
|
||||
needtoken(tELLIPS);
|
||||
} /* if */
|
||||
prev_initptr=initptr;
|
||||
} /* if */
|
||||
totalsize+=dsize;
|
||||
if (*errorfound || !matchtoken(','))
|
||||
abortparse=TRUE;
|
||||
} /* for */
|
||||
} while (!abortparse);
|
||||
needtoken('}');
|
||||
assert(counteddim!=NULL);
|
||||
if (counteddim[cur]>0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user