/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* POSIX 1003.2 wordexp implementation
*/
#include <ast.h>
#include <wordexp.h>
#include <stak.h>
struct list
{
};
/*
* elimnates shell quoting as inserted with sh_fmtq
* result relaces <string>
* length of resulting string is returned.
*/
{
register int c;
while((c= *sp) && c!='\'')
sp++;
if(c==0)
{
/* copy all but trailing ' */
while(--n>0)
}
else
{
while((c= *++sp) && c!='\'')
*dp++ = c;
}
*dp=0;
}
{
int offset;
savebase = stakfreeze(0);
if(flags&WRDE_REUSE)
else if(!(flags&WRDE_APPEND))
{
}
if(flags&WRDE_UNDEF)
if(!(flags&WRDE_SHOWERR))
if(*cp=='#')
stakputc('\\');
while(c = *cp++)
{
if(c=='\'' && !quoted)
else if(!literal)
{
{
stakputc('\\');
if(c= *cp)
cp++;
else
c = '\\';
}
else if(c=='"')
{
if(flags&WRDE_NOCMD)
{
c=WRDE_CMDSUB;
goto err;
}
/* only the shell can parse the rest */
break;
}
{
c=WRDE_BADCHAR;
goto err;
}
else if(c=='(') /* allow | and & inside pattern */
ac=2;
}
stakputc(c);
}
stakputc(0);
{
c = WRDE_NOSHELL;
goto err;
}
stakseek(0);
ac = 0;
{
if(c=='\'')
{
ac++;
c = 0;
}
stakputc(c);
}
{
c=WRDE_SYNTAX;
else
c=WRDE_BADVAL;
goto err;
}
c = ac+2;
if(flags&WRDE_DOOFFS)
if(flags&WRDE_APPEND)
{
if(flags&WRDE_DOOFFS)
else
av[0] = 0;
}
if(!av)
return(WRDE_NOSPACE);
c = staktell();
{
c=WRDE_NOSPACE;
goto err;
}
cp += sizeof(char*);
if(flags&WRDE_APPEND)
if(flags&WRDE_DOOFFS)
while(ac-- > 0)
{
sh_unquote(cp);
while(c= *cp++);
}
*av = 0;
c=0;
err:
if(offset)
else
stakseek(0);
return(c);
}
/*
* free fields in <wdarg>
*/
{
{
{
}
}
return(0);
}