9 |
|
|
10 |
|
#include <stdio.h> |
11 |
|
#include <stdlib.h> |
12 |
+ |
#include <string.h> |
13 |
|
#include <math.h> |
14 |
|
#include <ctype.h> |
15 |
+ |
#include <sys/types.h> |
16 |
|
|
17 |
+ |
#include "rtprocess.h" /* getpid() */ |
18 |
+ |
#include "rtmath.h" |
19 |
+ |
#include "rtio.h" |
20 |
+ |
|
21 |
|
#define isdelim(c) (isspace(c) || (c)==',') |
22 |
|
|
23 |
|
#define MAXTAB 1024 /* maximum number of data rows */ |
24 |
|
#define MAXLINE 4096 /* maximum line width (characters) */ |
19 |
– |
#define FLOAT float /* real type (precision) */ |
25 |
|
#define OUTFMT "%.7g" /* output format conversion string */ |
26 |
|
|
27 |
|
int interpolate = 0; |
29 |
|
char **func; |
30 |
|
int nfuncs; |
31 |
|
|
32 |
< |
FLOAT abscissa[MAXTAB]; /* independent values (first column) */ |
33 |
< |
FLOAT (*ordinate)[MAXTAB]; /* dependent values (other columns) */ |
32 |
> |
RREAL abscissa[MAXTAB]; /* independent values (first column) */ |
33 |
> |
RREAL (*ordinate)[MAXTAB]; /* dependent values (other columns) */ |
34 |
|
int tabsize = 0; /* final table size (number of rows) */ |
35 |
|
char locID[16]; /* local identifier (for uniqueness) */ |
36 |
|
|
37 |
< |
extern char *fgets(), *fskip(), *absc_exp(); |
37 |
> |
/*extern char *fgets(), *fskip(), *absc_exp();*/ |
38 |
|
|
39 |
+ |
static void load_data(FILE *fp); |
40 |
+ |
static void print_funcs(char *xe); |
41 |
+ |
static void putlist(register RREAL *av, int al, register int pos); |
42 |
+ |
static char * absc_exp(void); |
43 |
|
|
44 |
< |
main(argc, argv) |
45 |
< |
int argc; |
46 |
< |
char **argv; |
44 |
> |
int |
45 |
> |
main( |
46 |
> |
int argc, |
47 |
> |
char **argv |
48 |
> |
) |
49 |
|
{ |
50 |
|
progname = argv[0]; |
51 |
|
argv++; |
63 |
|
} |
64 |
|
func = argv; |
65 |
|
nfuncs = argc; |
66 |
< |
ordinate = (FLOAT (*)[MAXTAB])malloc(nfuncs*MAXTAB*sizeof(FLOAT)); |
66 |
> |
ordinate = (RREAL (*)[MAXTAB])malloc(nfuncs*MAXTAB*sizeof(RREAL)); |
67 |
|
if (ordinate == NULL) { |
68 |
|
fprintf(stderr, "%s: not enough memory\n", progname); |
69 |
|
exit(1); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
< |
load_data(fp) /* load tabular data from fp */ |
79 |
< |
FILE *fp; |
78 |
> |
static void |
79 |
> |
load_data( /* load tabular data from fp */ |
80 |
> |
FILE *fp |
81 |
> |
) |
82 |
|
{ |
83 |
|
int lineno; |
84 |
|
char *err; |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
< |
char * |
127 |
< |
absc_exp() /* produce expression for abscissa */ |
126 |
> |
static char * |
127 |
> |
absc_exp(void) /* produce expression for abscissa */ |
128 |
|
{ |
129 |
|
static char ourexp[64]; |
130 |
|
double step, eps; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
< |
print_funcs(xe) /* print functions */ |
181 |
< |
char *xe; |
180 |
> |
static void |
181 |
> |
print_funcs( /* print functions */ |
182 |
> |
char *xe |
183 |
> |
) |
184 |
|
{ |
185 |
|
int xelen; |
186 |
|
register int i; |
187 |
|
|
188 |
|
xelen = strlen(xe); |
189 |
|
for (i = 0; i < nfuncs; i++) { |
190 |
< |
if (func[i][0] == '\0' | func[i][0] == '0') |
190 |
> |
if ((func[i][0] == '\0') | (func[i][0] == '0')) |
191 |
|
continue; |
192 |
|
if (interpolate) { |
193 |
|
printf("%s`%s(i):select(i,", func[i], locID); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
< |
putlist(av, al, pos) /* put out array of values */ |
209 |
< |
register FLOAT *av; |
210 |
< |
int al; |
211 |
< |
register int pos; |
208 |
> |
static void |
209 |
> |
putlist( /* put out array of values */ |
210 |
> |
register RREAL *av, |
211 |
> |
int al, |
212 |
> |
register int pos |
213 |
> |
) |
214 |
|
{ |
215 |
|
char obuf[32]; |
216 |
|
int len; |