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.2 by greg, Thu Dec 19 14:45:52 1991 UTC vs.
Revision 2.3 by greg, Tue May 18 09:26:05 1993 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines