nvtree.c revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Knowledge Ventures *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* code for tree nodes and name walking
*
* David Korn
* AT&T Labs
*
*/
#include "defs.h"
#include "name.h"
#include "argnod.h"
struct nvdir
{
int len;
int offset;
char data[1];
};
{
{
{
return(np);
}
}
}
{
0,
0,
0,
};
{
register char *cp;
if(*str=='.')
str++;
if(*str =='[')
{
}
else
}
{
return(0);
{
return(fp);
}
return(0);
}
void *nv_diropen(const char *name)
{
if(!dp)
return(0);
len -= 1;
if(*name)
{
}
else
{
c = *next;
*next = 0;
*next = c;
{
return(0);
if(nv_istable(np))
else
else
if(nfp)
{
}
else
}
else
break;
}
return((void*)dp);
}
{
return(0);
}
char *nv_dirnext(void *dir)
{
register char *cp;
while(1)
{
{
continue;
{
{
if(nv_istable(np))
else
/* check for recursive walk */
{
break;
}
if(save)
continue;
return(0);
{
}
else
}
return(cp);
}
}
break;
#if 0
#endif
}
return(0);
}
void nv_dirclose(void *dir)
{
}
{
char *type=0;
{
{
break;
}
}
type = "-T";
else if(!prefix)
type = "type";
if(type)
}
/*
* print the attributes of name value pair give by <np>
*/
{
register char *cp;
register unsigned val;
register unsigned mask;
register unsigned attr;
{
break;
}
#if 0
{
return;
}
#else
return;
#endif
{
attr &= ~NV_NOPRINT;
return;
if(prefix)
{
break;
/*
* the following test is needed to prevent variables
* with E attribute from being given the F
* attribute as well
*/
continue;
if(val&NV_INTEGER)
{
{
if(array_assoc(ap))
{
continue;
}
continue;
#if 0
cp = "associative";
else
cp = "indexed";
if(!prefix)
else if(*cp=='i')
tp++;
#endif
}
if(prefix)
{
}
else
}
{
{
cp = "precision";
else
cp = "base";
if(!prefix)
}
break;
}
}
if(fp)
if(noname)
return;
}
}
struct Walk
{
int noscope;
int indent;
};
{
return;
special = 1;
{
{
}
return;
}
return;
{
isarray=1;
isarray=2;
else
}
{
return;
}
return;
if(special)
{
associative = 1;
}
else
{
if(isarray)
{
if(isarray==2)
return;
}
}
while(1)
{
if(isarray && associative)
{
break;
}
fmtq = "";
{
{
}
}
else
if(!nv_nextsub(np))
break;
}
{
}
}
/*
* format initialization list given a list of assignments <argp>
*/
{
register int m,r;
if(n==0)
else
m++;
if(outfile)
{
}
{
continue;
if(n && cp[m-1]==0)
break;
{
cp +=m;
r = 0;
if(*cp=='.')
cp++,r++;
{
if(outfile)
{
}
if(outfile)
if(*argv)
continue;
break;
}
{
if(!np)
continue;
}
{
}
else
}
else
break;
}
if(outfile)
{
int c = prefix[m-1];
if(c=='.')
cp[m-1] = 0;
if(c=='.')
cp[m-1] = c;
}
return(--argv);
}
/*
* walk the virtual tree and print or delete name-value pairs
*/
{
char *savptr = stakfreeze(0);
char *subscript=0;
void *dir;
{
stakputc('[');
stakputc(']');
stakputc('.');
}
if(subscript)
{
n++;
}
argv += n;
*argv = 0;
if(dlete&1)
outfile = 0;
else
if(!outfile)
return((char*)0);
}
/*
* get discipline for compound initializations
*/
{
}
/*
* put discipline for compound initializations
*/
{
int nleft = 0;
return;
if(nleft==0)
{
{
}
}
}
/*
* Insert discipline to cause $x to print current tree
*/
{
return;
}