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

Comparing ray/src/common/readfargs.c (file contents):
Revision 1.2 by greg, Mon Jul 22 11:23:00 1991 UTC vs.
Revision 2.6 by gwlarson, Tue Aug 25 10:20:30 1998 UTC

# Line 8 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   * Allocate, read and free object arguments
9   */
10  
11 < #include <stdio.h>
11 > #include "standard.h"
12  
13   #include "object.h"
14  
15  
16 < extern char  *savestr(), *malloc(), *fgetword();
17 < extern double  atof();
18 < extern int  atoi();
19 < extern long  atol();
20 <
21 < #ifdef  MEMHOG
22 < extern char  *bmalloc();
23 < #else
16 > #ifndef  MEMHOG
17   #define  bmalloc        malloc
18   #endif
19  
20 + extern char  *fgetword();
21 + extern int  atoi();
22 + extern long  atol();
23  
24 +
25   readfargs(fa, fp)               /* read function arguments from stream */
26   register FUNARGS  *fa;
27   FILE  *fp;
28   {
29 < #define getstr()        (fgetword(sbuf,MAXSTR,fp)!=NULL)
30 < #define getint()        (getstr() && isint(sbuf))
31 < #define getflt()        (getstr() && isflt(sbuf))
29 > #define getstr(s)       (fgetword(s,sizeof(s),fp)!=NULL)
30 > #define getint(s)       (getstr(s) && isint(s))
31 > #define getflt(s)       (getstr(s) && isflt(s))
32          char  sbuf[MAXSTR];
33          register int  n, i;
34  
35 <        if (!getint() || (n = atoi(sbuf)) < 0)
35 >        if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
36                  return(0);
37          if (fa->nsargs = n) {
38                  fa->sarg = (char **)bmalloc(n*sizeof(char *));
39                  if (fa->sarg == NULL)
40                          return(-1);
41                  for (i = 0; i < fa->nsargs; i++) {
42 <                        if (!getstr())
42 >                        if (!getstr(sbuf))
43                                  return(0);
44                          fa->sarg[i] = savestr(sbuf);
45                  }
46          } else
47                  fa->sarg = NULL;
48 <        if (!getint() || (n = atoi(sbuf)) < 0)
48 >        if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
49                  return(0);
50   #ifdef  IARGS
51          if (fa->niargs = n) {
# Line 56 | Line 53 | FILE  *fp;
53                  if (fa->iarg == NULL)
54                          return(-1);
55                  for (i = 0; i < n; i++) {
56 <                        if (!getint())
56 >                        if (!getint(sbuf))
57                                  return(0);
58                          fa->iarg[i] = atol(sbuf);
59                  }
# Line 66 | Line 63 | FILE  *fp;
63          if (n != 0)
64                  return(0);
65   #endif
66 <        if (!getint() || (n = atoi(sbuf)) < 0)
66 >        if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
67                  return(0);
68          if (fa->nfargs = n) {
69 <                fa->farg = (double *)bmalloc(n*sizeof(double));
69 >                fa->farg = (FLOAT *)bmalloc(n*sizeof(FLOAT));
70                  if (fa->farg == NULL)
71                          return(-1);
72                  for (i = 0; i < n; i++) {
73 <                        if (!getflt())
73 >                        if (!getflt(sbuf))
74                                  return(0);
75                          fa->farg[i] = atof(sbuf);
76                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines