1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Get additional command arguments from file or environment. |
6 |
+ |
* |
7 |
+ |
* External symbols declared in rtio.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include "standard.h" |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
+ |
#include "rtio.h" |
13 |
+ |
|
14 |
+ |
#include "rtmisc.h" |
15 |
+ |
|
16 |
+ |
#include <errno.h> |
17 |
+ |
|
18 |
|
#define MAXARGEXP 512 /* maximum argument expansion */ |
19 |
|
|
20 |
|
/* set the following to suit, -1 to disable */ |
21 |
|
int envexpchr = '$'; /* environment expansion character */ |
22 |
< |
int filexpchr = '^'; /* file expansion character */ |
22 |
> |
int filexpchr = '@'; /* file expansion character */ |
23 |
|
|
24 |
|
|
25 |
+ |
int |
26 |
|
expandarg(acp, avp, n) /* expand list at argument n */ |
27 |
|
int *acp; |
28 |
|
register char ***avp; |
32 |
|
char *ave[MAXARGEXP]; |
33 |
|
char **newav; |
34 |
|
/* check argument */ |
35 |
+ |
if (n >= *acp) |
36 |
+ |
return(0); |
37 |
|
errno = 0; |
38 |
|
if ((*avp)[n][0] == filexpchr) { /* file name */ |
39 |
|
ace = wordfile(ave, (*avp)[n]+1); |
50 |
|
if (newav == NULL) |
51 |
|
return(-1); |
52 |
|
/* copy preceeding arguments */ |
53 |
< |
bcopy((char *)*avp, (char *)newav, n*sizeof(char *)); |
53 |
> |
bcopy((void *)*avp, (void *)newav, n*sizeof(char *)); |
54 |
|
/* copy expanded argument */ |
55 |
< |
bcopy((char *)ave, (char *)(newav+n), ace*sizeof(char *)); |
55 |
> |
bcopy((void *)ave, (void *)(newav+n), ace*sizeof(char *)); |
56 |
|
/* copy trailing arguments + NULL */ |
57 |
< |
bcopy((char *)(*avp+n+1), (char *)(newav+n+ace), (*acp-n)*sizeof(char *)); |
57 |
> |
bcopy((void *)(*avp+n+1), (void *)(newav+n+ace), (*acp-n)*sizeof(char *)); |
58 |
|
/* free old list */ |
59 |
|
bfree((char *)*avp, (*acp+1)*sizeof(char *)); |
60 |
|
/* assign new list */ |