8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
+ |
#include <fcntl.h> |
12 |
|
#include <stdio.h> |
13 |
|
#include <string.h> |
14 |
|
#include <math.h> |
55 |
|
#define savqstr(s) strcpy(emalloc(strlen(s)+1),s) |
56 |
|
#define freqstr(s) efree(s) |
57 |
|
|
58 |
+ |
static int getinputrec(FILE *fp); |
59 |
|
static void scaninp(void), advinp(void), resetinp(void); |
60 |
|
static void putrec(void), putout(void), nbsynch(void); |
61 |
|
static int getrec(void); |
68 |
|
static void chanset(int n, double v); |
69 |
|
static void bchanset(int n, double v); |
70 |
|
static struct strvar* getsvar(char *svname); |
71 |
+ |
static double l_in(char *); |
72 |
|
|
73 |
|
struct field *inpfmt = NULL; /* input record format */ |
74 |
|
struct field *outfmt = NULL; /* output record structure */ |
112 |
|
biggerlib(); |
113 |
|
#endif |
114 |
|
varset("PI", ':', 3.14159265358979323846); |
115 |
+ |
funset("in", 1, '=', &l_in); |
116 |
|
|
117 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
118 |
|
switch (argv[i][1]) { |
219 |
|
execute(argv[i]); |
220 |
|
|
221 |
|
quit(0); |
222 |
+ |
return 0; /* pro forma return */ |
223 |
|
} |
224 |
|
|
225 |
|
|
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
< |
int |
238 |
> |
static int |
239 |
|
getinputrec( /* get next input record */ |
240 |
|
FILE *fp |
241 |
|
) |
302 |
|
fflush(stdout); |
303 |
|
} |
304 |
|
|
305 |
+ |
|
306 |
+ |
static double |
307 |
+ |
l_in(char *funame) /* function call for $channel */ |
308 |
+ |
{ |
309 |
+ |
int n; |
310 |
+ |
register char *cp; |
311 |
+ |
/* get argument as integer */ |
312 |
+ |
n = (int)(argument(1) + .5); |
313 |
+ |
if (n != 0) /* return channel value */ |
314 |
+ |
return(chanvalue(n)); |
315 |
+ |
/* determine number of channels */ |
316 |
+ |
if (noinput || inpfmt != NULL) |
317 |
+ |
return(0); |
318 |
+ |
if (nbicols > 0) |
319 |
+ |
return(nbicols); |
320 |
+ |
if (nbicols < 0) |
321 |
+ |
return(-nbicols); |
322 |
+ |
cp = inpbuf; /* need to count */ |
323 |
+ |
for (n = 0; *cp; ) |
324 |
+ |
if (blnkeq && isspace(sepchar)) { |
325 |
+ |
while (isspace(*cp)) |
326 |
+ |
cp++; |
327 |
+ |
n += *cp != '\0'; |
328 |
+ |
while (*cp && !isspace(*cp)) |
329 |
+ |
cp++; |
330 |
+ |
} else { |
331 |
+ |
n += *cp != '\n'; |
332 |
+ |
while (*cp && *cp++ != sepchar) |
333 |
+ |
; |
334 |
+ |
} |
335 |
+ |
return(n); |
336 |
+ |
} |
337 |
|
|
338 |
|
double |
339 |
|
chanvalue( /* return value for column n */ |