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.3 by greg, Fri Jul 16 12:40:37 1993 UTC vs.
Revision 2.10 by greg, Mon Mar 21 19:06:08 2016 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 > #include <string.h>
14  
15 + #include "rtio.h"
16 + #include "rtmisc.h"
17 +
18 +
19 + #define MAXARGEXP       4096            /* maximum argument expansion */
20 +
21                          /* set the following to suit, -1 to disable */
22   int     envexpchr = '$';                /* environment expansion character */
23   int     filexpchr = '@';                /* file expansion character */
24  
25  
26 < expandarg(acp, avp, n)          /* expand list at argument n */
27 < int     *acp;
28 < register char   ***avp;
29 < int     n;
26 > int
27 > expandarg(              /* expand list at argument n */
28 >        int     *acp,
29 >        char    ***avp,
30 >        int     n
31 > )
32   {
33          int     ace;
34          char    *ave[MAXARGEXP];
# Line 30 | Line 38 | int    n;
38                  return(0);
39          errno = 0;      
40          if ((*avp)[n][0] == filexpchr) {                /* file name */
41 <                ace = wordfile(ave, (*avp)[n]+1);
41 >                ace = wordfile(ave, MAXARGEXP, (*avp)[n]+1);
42                  if (ace < 0)
43                          return(-1);     /* no such file */
44          } else if ((*avp)[n][0] == envexpchr) {         /* env. variable */
45 <                ace = wordstring(ave, getenv((*avp)[n]+1));
45 >                ace = wordstring(ave, MAXARGEXP, getenv((*avp)[n]+1));
46                  if (ace < 0)
47                          return(-1);     /* no such variable */
48          } else                                          /* regular argument */
# Line 44 | Line 52 | int    n;
52          if (newav == NULL)
53                  return(-1);
54                                          /* copy preceeding arguments */
55 <        bcopy((char *)*avp, (char *)newav, n*sizeof(char *));
55 >        memcpy((void *)newav, (void *)*avp, n*sizeof(char *));
56                                          /* copy expanded argument */
57 <        bcopy((char *)ave, (char *)(newav+n), ace*sizeof(char *));
57 >        memcpy((void *)(newav+n), (void *)ave, ace*sizeof(char *));
58                                          /* copy trailing arguments + NULL */
59 <        bcopy((char *)(*avp+n+1), (char *)(newav+n+ace), (*acp-n)*sizeof(char *));
59 >        memcpy((void *)(newav+n+ace), (void *)(*avp+n+1), (*acp-n)*sizeof(char *));
60                                          /* free old list */
61          bfree((char *)*avp, (*acp+1)*sizeof(char *));
62                                          /* assign new list */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines