args.c revision 965005c81e0f731867d47892b9fb677030b102df
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1995 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* UNIX shell
*/
#include "defs.h"
static void freedolh(void);
/* Used to save outermost positional parameters */
static unsigned char **globdolv;
static int globdolc;
unsigned char flagadr[16];
unsigned char flagchar[] =
{
'x',
'n',
'v',
't',
'i',
'e',
'r',
'k',
'u',
'h',
'f',
'a',
'm',
'p',
0
};
long flagval[] =
{
0
};
/* ======== option handling ======== */
int
{
unsigned char *cp;
unsigned char *flagc;
unsigned char *flagp;
int len;
{
/*
* if first argument is "--" then options are not
* to be changed. Fix for problems getting
* $1 starting with a "-"
*/
{
argc--;
return(argc);
}
/*
* Step along 'flagchar[]' looking for matches.
* 'sicrp' are not legal with 'set' command.
*/
cp++;
while (*cp) {
len = 1;
}
flagc++;
{
else
{
}
}
{
argp++;
argc--;
}
else
}
argc--;
}
{
cp++;
while (*cp)
{
cp++;
continue;
}
flagc++;
/*
* step through flags
*/
if (wc == 'e')
eflag = 0;
}
}
argc--;
}
/*
* set up $-
*/
if (flags)
{
while (*flagc)
{
flagc++;
}
}
*flagp = 0;
return(argc);
}
/*
* sets up positional parameters
*/
void
{
int argn = 0;
argn++;
/*
* free old ones unless on for loop chain
*/
freedolh();
}
static void
freedolh(void)
{
unsigned char **argp;
{
{
}
}
}
struct dolnod *
{
unsigned char **argp;
int cnt;
{
{
if (cnt == 1)
return(argr);
else
return(argblk);
}
else
{
if (cnt == 0)
{
}
}
}
return(argr);
}
static struct dolnod *
unsigned char *from[];
{
unsigned char **pp;
while (n--)
return(np);
}
struct dolnod *
{
unsigned char **argp;
{
else
{
}
}
return(argr);
}
void
clearup(void)
{
/*
* force `for' $* lists to go away
*/
if(globdolv)
if(globdolc)
if(globdolh)
globdolv = 0;
globdolc = 0;
globdolh = 0;
;
/*
* clean up io files
*/
while (pop())
;
/*
* Clean up pipe file descriptor
* from command substitution
*/
if(savpipe != -1) {
savpipe = -1;
}
/*
* clean up tmp files
*/
while (poptemp())
;
}
/*
* Save positiional parameters before outermost function invocation
* in case we are interrupted.
* Increment use count for current positional parameters so that they aren't thrown
* away.
*/
int funcnt;
{
if (!funcnt) {
}
useargs();
return(dolh);
}
/* After function invocation, free positional parameters,
* restore old positional parameters, and restore
* use count.
*/
{
if(!argfor)
return;
freedolh();
if(dolh)
if(funcnt == 1) {
globdolh = 0;
globdolv = 0;
globdolc = 0;
}
}
struct dolnod *
useargs()
{
if (dolh)
{
{
}
}
return(dolh);
}