--- ray/src/common/expandarg.c 1992/11/08 16:23:17 2.2 +++ ray/src/common/expandarg.c 2016/03/21 19:06:08 2.10 @@ -1,26 +1,34 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: expandarg.c,v 2.10 2016/03/21 19:06:08 greg Exp $"; #endif - /* * Get additional command arguments from file or environment. + * + * External symbols declared in rtio.h */ -#include "standard.h" +#include "copyright.h" -#define MAXARGEXP 512 /* maximum argument expansion */ +#include +#include +#include "rtio.h" +#include "rtmisc.h" + + +#define MAXARGEXP 4096 /* maximum argument expansion */ + /* set the following to suit, -1 to disable */ int envexpchr = '$'; /* environment expansion character */ -int filexpchr = '^'; /* file expansion character */ +int filexpchr = '@'; /* file expansion character */ -expandarg(acp, avp, n) /* expand list at argument n */ -int *acp; -register char ***avp; -int n; +int +expandarg( /* expand list at argument n */ + int *acp, + char ***avp, + int n +) { int ace; char *ave[MAXARGEXP]; @@ -30,11 +38,11 @@ int n; return(0); errno = 0; if ((*avp)[n][0] == filexpchr) { /* file name */ - ace = wordfile(ave, (*avp)[n]+1); + ace = wordfile(ave, MAXARGEXP, (*avp)[n]+1); if (ace < 0) return(-1); /* no such file */ } else if ((*avp)[n][0] == envexpchr) { /* env. variable */ - ace = wordstring(ave, getenv((*avp)[n]+1)); + ace = wordstring(ave, MAXARGEXP, getenv((*avp)[n]+1)); if (ace < 0) return(-1); /* no such variable */ } else /* regular argument */ @@ -44,11 +52,11 @@ int n; if (newav == NULL) return(-1); /* copy preceeding arguments */ - bcopy((char *)*avp, (char *)newav, n*sizeof(char *)); + memcpy((void *)newav, (void *)*avp, n*sizeof(char *)); /* copy expanded argument */ - bcopy((char *)ave, (char *)(newav+n), ace*sizeof(char *)); + memcpy((void *)(newav+n), (void *)ave, ace*sizeof(char *)); /* copy trailing arguments + NULL */ - bcopy((char *)(*avp+n+1), (char *)(newav+n+ace), (*acp-n)*sizeof(char *)); + memcpy((void *)(newav+n+ace), (void *)(*avp+n+1), (*acp-n)*sizeof(char *)); /* free old list */ bfree((char *)*avp, (*acp+1)*sizeof(char *)); /* assign new list */