ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/expandarg.c
(Generate patch)

Comparing ray/src/common/expandarg.c (file contents):
Revision 2.2 by greg, Sun Nov 8 16:23:17 1992 UTC vs.
Revision 2.11 by greg, Sat Dec 28 18:05:13 2019 UTC

# Line 1 | Line 1
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 < #define MAXARGEXP       512             /* maximum argument expansion */
12 > #include <errno.h>
13  
14 + #include "rtio.h"
15 + #include "rtmisc.h"
16 +
17 +
18 + #define MAXARGEXP       4096            /* 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 < expandarg(acp, avp, n)          /* expand list at argument n */
26 < int     *acp;
27 < register char   ***avp;
28 < int     n;
25 > int
26 > expandarg(              /* expand list at argument n */
27 >        int     *acp,
28 >        char    ***avp,
29 >        int     n
30 > )
31   {
32          int     ace;
33          char    *ave[MAXARGEXP];
# Line 30 | Line 37 | int    n;
37                  return(0);
38          errno = 0;      
39          if ((*avp)[n][0] == filexpchr) {                /* file name */
40 <                ace = wordfile(ave, (*avp)[n]+1);
40 >                ace = wordfile(ave, MAXARGEXP, (*avp)[n]+1);
41                  if (ace < 0)
42                          return(-1);     /* no such file */
43          } else if ((*avp)[n][0] == envexpchr) {         /* env. variable */
44 <                ace = wordstring(ave, getenv((*avp)[n]+1));
44 >                ace = wordstring(ave, MAXARGEXP, getenv((*avp)[n]+1));
45                  if (ace < 0)
46                          return(-1);     /* no such variable */
47          } else                                          /* regular argument */
# Line 44 | Line 51 | int    n;
51          if (newav == NULL)
52                  return(-1);
53                                          /* copy preceeding arguments */
54 <        bcopy((char *)*avp, (char *)newav, n*sizeof(char *));
54 >        memcpy((void *)newav, (void *)*avp, n*sizeof(char *));
55                                          /* copy expanded argument */
56 <        bcopy((char *)ave, (char *)(newav+n), ace*sizeof(char *));
56 >        memcpy((void *)(newav+n), (void *)ave, ace*sizeof(char *));
57                                          /* copy trailing arguments + NULL */
58 <        bcopy((char *)(*avp+n+1), (char *)(newav+n+ace), (*acp-n)*sizeof(char *));
58 >        memcpy((void *)(newav+n+ace), (void *)(*avp+n+1), (*acp-n)*sizeof(char *));
59                                          /* free old list */
60          bfree((char *)*avp, (*acp+1)*sizeof(char *));
61                                          /* assign new list */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines