10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
|
13 |
+ |
#include "fvect.h" |
14 |
+ |
|
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 |
|
|
21 |
– |
#ifdef MEMHOG |
22 |
– |
extern char *bmalloc(); |
23 |
– |
#else |
24 |
– |
#define bmalloc malloc |
25 |
– |
#endif |
29 |
|
|
27 |
– |
|
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) { |
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 |
|
} |
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 = (double *)bmalloc(n*sizeof(double)); |
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 |
|
} |