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 2.1 by greg, Tue Nov 12 16:55:59 1991 UTC vs.
Revision 2.4 by greg, Fri Jun 4 14:28:52 1993 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines