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.3 by greg, Wed Oct 23 13:43:19 1991 UTC vs.
Revision 2.5 by greg, Wed Sep 8 09:12:36 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();
20 > #ifndef  MEMHOG
21 > #define  bmalloc        malloc
22 > #endif
23 >
24 > #ifdef  DCL_ATOF
25   extern double  atof();
26 + #endif
27 +
28 + extern char  *bmalloc(), *savestr(), *fgetword();
29   extern int  atoi();
30   extern long  atol();
31  
23 #ifdef  MEMHOG
24 extern char  *bmalloc();
25 #else
26 #define  bmalloc        malloc
27 #endif
32  
29
33   readfargs(fa, fp)               /* read function arguments from stream */
34   register FUNARGS  *fa;
35   FILE  *fp;
36   {
37 < #define getstr()        (fgetword(sbuf,MAXSTR,fp)!=NULL)
38 < #define getint()        (getstr() && isint(sbuf))
39 < #define getflt()        (getstr() && isflt(sbuf))
37 > #define getstr(s)       (fgetword(s,sizeof(s),fp)!=NULL)
38 > #define getint(s)       (getstr(s) && isint(s))
39 > #define getflt(s)       (getstr(s) && isflt(s))
40          char  sbuf[MAXSTR];
41          register int  n, i;
42  
43 <        if (!getint() || (n = atoi(sbuf)) < 0)
43 >        if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
44                  return(0);
45          if (fa->nsargs = n) {
46                  fa->sarg = (char **)bmalloc(n*sizeof(char *));
47                  if (fa->sarg == NULL)
48                          return(-1);
49                  for (i = 0; i < fa->nsargs; i++) {
50 <                        if (!getstr())
50 >                        if (!getstr(sbuf))
51                                  return(0);
52                          fa->sarg[i] = savestr(sbuf);
53                  }
54          } else
55                  fa->sarg = NULL;
56 <        if (!getint() || (n = atoi(sbuf)) < 0)
56 >        if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
57                  return(0);
58   #ifdef  IARGS
59          if (fa->niargs = n) {
# Line 58 | Line 61 | FILE  *fp;
61                  if (fa->iarg == NULL)
62                          return(-1);
63                  for (i = 0; i < n; i++) {
64 <                        if (!getint())
64 >                        if (!getint(sbuf))
65                                  return(0);
66                          fa->iarg[i] = atol(sbuf);
67                  }
# Line 68 | Line 71 | FILE  *fp;
71          if (n != 0)
72                  return(0);
73   #endif
74 <        if (!getint() || (n = atoi(sbuf)) < 0)
74 >        if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
75                  return(0);
76          if (fa->nfargs = n) {
77                  fa->farg = (FLOAT *)bmalloc(n*sizeof(FLOAT));
78                  if (fa->farg == NULL)
79                          return(-1);
80                  for (i = 0; i < n; i++) {
81 <                        if (!getflt())
81 >                        if (!getflt(sbuf))
82                                  return(0);
83                          fa->farg[i] = atof(sbuf);
84                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines