Update awk and libm.

This commit is contained in:
Serge
2022-05-26 00:23:40 -07:00
parent 8458c9e3c4
commit 716151b46f
23 changed files with 175 additions and 112 deletions

2
include/inttypes.h Normal file
View File

@@ -0,0 +1,2 @@
#include <stdint.h>
#include <stddef.h>

View File

@@ -68,7 +68,7 @@ typedef struct {
cell *optr;
} obj;
#define BOTCH 1
#define BOTCH 0
struct nd {
char ntype;
char subtype;
@@ -127,9 +127,23 @@ extern int pairstack[], paircnt;
#define istemp(n) (n.otype == OCELL && n.osub == CTEMP)
#define isfld(n) (!donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval==EMPTY)
#define isrec(n) (donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval!=EMPTY)
obj nullproc();
obj relop();
obj nullproc(void);
obj relop(node **a, int n);
#define MAXSYM 50
#define HAT 0177 /* matches ^ in regular expr */
/* watch out for mach dep */
struct fa;
void yyerror(char *s);
void error(int f, char *s, ...);
void syminit(void);
int freeze(char *s);
int thaw(char *s);
void run(void);
void recbld(void);
int isnumber(char *s);
int getrec(void);
int member(char c, char *s);
void fldbld(void);
void freesymtab(cell *ap);
int match(struct fa *pfa, char *p);

View File

@@ -1,4 +1,8 @@
/* awk.g.y 4.1 82/05/07 */
%code requires {
#define YYSTYPE node *
#define YYSTYPE_IS_DECLARED 1
}
%token FIRSTTOKEN /*must be first*/
%token FINAL FATAL
@@ -37,14 +41,22 @@
#ifndef DEBUG
# define PUTS(x)
#endif
#define YYSTYPE node *
int yylex(void);
void yyerror(char *s);
node *valtonode(cell *a, int b);
node *stat1(int a, node *b);
node *stat2(int a, node *b, node *c);
node *stat3(int a, node *b, node *c, node *d);
node *stat4(int a, node *b, node *c, node *d, node *e);
node *op1(int a, node *b);
node *op2(int a, node *b, node *c);
node *op3(int a, node *b, node *c, node *d);
node *genprint(void);
node *pa2stat(node *a, node *b, node *c);
node *linkum(node *a, node *b);
struct fa *makedfa(node *p);
char *cclenter(char *p);
node *exptostat(node *a);
void startreg(void);
%}
%%
@@ -91,7 +103,7 @@ else:
;
field:
FIELD { PUTS("field"); $$ = valtonode($1, CFLD); }
FIELD { PUTS("field"); $$ = valtonode((cell *) $1, CFLD); }
| INDIRECT term { PUTS("ind field"); $$ = op1(INDIRECT, $2); }
;
@@ -100,14 +112,14 @@ if:
;
lex_expr:
expr MATCHOP regular_expr { PUTS("expr~re"); $$ = op2($2, $1, makedfa($3)); }
expr MATCHOP regular_expr { PUTS("expr~re"); $$ = op2((int) $2, $1, (node *) makedfa($3)); }
| '(' lex_expr ')' { PUTS("(lex_expr)"); $$ = $2; }
;
var:
NUMBER {PUTS("number"); $$ = valtonode($1, CCON); }
| STRING { PUTS("string"); $$ = valtonode($1, CCON); }
| VAR { PUTS("var"); $$ = valtonode($1, CVAR); }
NUMBER {PUTS("number"); $$ = valtonode((cell *) $1, CCON); }
| STRING { PUTS("string"); $$ = valtonode((cell *) $1, CCON); }
| VAR { PUTS("var"); $$ = valtonode((cell *) $1, CVAR); }
| VAR '[' expr ']' { PUTS("array[]"); $$ = op2(ARRAY, $1, $3); }
| field
;
@@ -121,7 +133,7 @@ term:
$$ = op2(FNCN, $1, valtonode(lookup("$record", symtab, 0), CFLD));
}
| FNCN '(' expr ')' { PUTS("func(expr)"); $$ = op2(FNCN, $1, $3); }
| SPRINTF print_list { PUTS("sprintf"); $$ = op1($1, $2); }
| SPRINTF print_list { PUTS("sprintf"); $$ = op1((int) $1, $2); }
| SUBSTR '(' expr ',' expr ',' expr ')'
{ PUTS("substr(e,e,e)"); $$ = op3(SUBSTR, $3, $5, $7); }
| SUBSTR '(' expr ',' expr ')'
@@ -149,7 +161,7 @@ term:
expr:
term { PUTS("term"); }
| expr term { PUTS("expr term"); $$ = op2(CAT, $1, $2); }
| var ASGNOP expr { PUTS("var=expr"); $$ = stat2($2, $1, $3); }
| var ASGNOP expr { PUTS("var=expr"); $$ = stat2((int) $2, $1, $3); }
;
optNL:
@@ -174,7 +186,7 @@ pa_stats:
pattern:
regular_expr { PUTS("regex");
$$ = op2(MATCH, valtonode(lookup("$record", symtab, 0), CFLD), makedfa($1));
$$ = op2(MATCH, valtonode(lookup("$record", symtab, 0), CFLD), (node *) makedfa($1));
}
| rel_expr { PUTS("relexpr"); }
| lex_expr { PUTS("lexexpr"); }
@@ -207,10 +219,10 @@ regular_expr:
r:
CHAR { PUTS("regex CHAR"); $$ = op2(CHAR, (node *) 0, $1); }
| DOT { PUTS("regex DOT"); $$ = op2(DOT, (node *) 0, (node *) 0); }
| CCL { PUTS("regex CCL"); $$ = op2(CCL, (node *) 0, cclenter($1)); }
| NCCL { PUTS("regex NCCL"); $$ = op2(NCCL, (node *) 0, cclenter($1)); }
| '^' { PUTS("regex ^"); $$ = op2(CHAR, (node *) 0, HAT); }
| '$' { PUTS("regex $"); $$ = op2(CHAR, (node *) 0 ,(node *) 0); }
| CCL { PUTS("regex CCL"); $$ = op2(CCL, (node *) 0, (node *) cclenter((char*)$1)); }
| NCCL { PUTS("regex NCCL"); $$ = op2(NCCL, (node *) 0, (node *) cclenter((char*)$1)); }
| '^' { PUTS("regex ^"); $$ = op2(CHAR, (node *) 0, (node *) HAT); }
| '$' { PUTS("regex $"); $$ = op2(CHAR, (node *) 0, (node *) 0); }
| r OR r { PUTS("regex OR"); $$ = op2(OR, $1, $3); }
| r r %prec CAT
{ PUTS("regex CAT"); $$ = op2(CAT, $1, $2); }
@@ -222,7 +234,7 @@ r:
rel_expr:
expr RELOP expr
{ PUTS("expr relop expr"); $$ = op2($2, $1, $3); }
{ PUTS("expr relop expr"); $$ = op2((int) $2, $1, $3); }
| '(' rel_expr ')'
{ PUTS("(relexpr)"); $$ = $2; }
;
@@ -234,13 +246,13 @@ st:
simple_stat:
PRINT print_list redir expr
{ PUTS("print>stat"); $$ = stat3($1, $2, $3, $4); }
{ PUTS("print>stat"); $$ = stat3((int) $1, $2, $3, $4); }
| PRINT print_list
{ PUTS("print list"); $$ = stat3($1, $2, nullstat, nullstat); }
{ PUTS("print list"); $$ = stat3((int) $1, $2, nullstat, nullstat); }
| PRINTF print_list redir expr
{ PUTS("printf>stat"); $$ = stat3($1, $2, $3, $4); }
{ PUTS("printf>stat"); $$ = stat3((int) $1, $2, $3, $4); }
| PRINTF print_list
{ PUTS("printf list"); $$ = stat3($1, $2, nullstat, nullstat); }
{ PUTS("printf list"); $$ = stat3((int) $1, $2, nullstat, nullstat); }
| expr { PUTS("expr"); $$ = exptostat($1); }
| { PUTS("null simple statement"); $$ = nullstat; }
| error { yyclearin; yyerror("illegal statement"); }

View File

@@ -3,17 +3,18 @@
%Start A str chc sc reg comment
%{
#include "awk.h"
#include "awk.def.h"
#include "awk.h"
#define YY_NO_INPUT /* defeat lex */
extern int yylval;
extern int mustfld;
int lineno = 1;
#define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long", cbuf); BEGIN A;}
#define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long"); BEGIN A;}
#define CBUFLEN 150
char cbuf[CBUFLEN];
int clen, cflag;
cell *fieldadr(int n);
%}
A [a-zA-Z_]
@@ -42,36 +43,36 @@ WS [ \t]
<A>PROGEND return(EOF);
<A>"&&" return(AND);
<A>"!" return(NOT);
<A>"!=" { yylval = NE; return(RELOP); }
<A>"~" { yylval = MATCH; return(MATCHOP); }
<A>"!~" { yylval = NOTMATCH; return(MATCHOP); }
<A>"<" { yylval = LT; return(RELOP); }
<A>"<=" { yylval = LE; return(RELOP); }
<A>"==" { yylval = EQ; return(RELOP); }
<A>">=" { yylval = GE; return(RELOP); }
<A>">" { yylval = GT; return(RELOP); }
<A>">>" { yylval = APPEND; return(RELOP); }
<A>"++" { yylval = INCR; return(INCR); }
<A>"--" { yylval = DECR; return(DECR); }
<A>"+=" { yylval = ADDEQ; return(ASGNOP); }
<A>"-=" { yylval = SUBEQ; return(ASGNOP); }
<A>"*=" { yylval = MULTEQ; return(ASGNOP); }
<A>"/=" { yylval = DIVEQ; return(ASGNOP); }
<A>"%=" { yylval = MODEQ; return(ASGNOP); }
<A>"=" { yylval = ASSIGN; return(ASGNOP); }
<A>"!=" { yylval = (node *) NE; return(RELOP); }
<A>"~" { yylval = (node *) MATCH; return(MATCHOP); }
<A>"!~" { yylval = (node *) NOTMATCH; return(MATCHOP); }
<A>"<" { yylval = (node *) LT; return(RELOP); }
<A>"<=" { yylval = (node *) LE; return(RELOP); }
<A>"==" { yylval = (node *) EQ; return(RELOP); }
<A>">=" { yylval = (node *) GE; return(RELOP); }
<A>">" { yylval = (node *) GT; return(RELOP); }
<A>">>" { yylval = (node *) APPEND; return(RELOP); }
<A>"++" { yylval = (node *) INCR; return(INCR); }
<A>"--" { yylval = (node *) DECR; return(DECR); }
<A>"+=" { yylval = (node *) ADDEQ; return(ASGNOP); }
<A>"-=" { yylval = (node *) SUBEQ; return(ASGNOP); }
<A>"*=" { yylval = (node *) MULTEQ; return(ASGNOP); }
<A>"/=" { yylval = (node *) DIVEQ; return(ASGNOP); }
<A>"%=" { yylval = (node *) MODEQ; return(ASGNOP); }
<A>"=" { yylval = (node *) ASSIGN; return(ASGNOP); }
<A>"$"{D}+ { if (atoi(yytext+1)==0) {
yylval = (hack)lookup("$record", symtab, 0);
yylval = (node *) lookup("$record", symtab, 0);
return(STRING);
} else {
yylval = fieldadr(atoi(yytext+1));
yylval = (node *) fieldadr(atoi(yytext+1));
return(FIELD);
}
}
<A>"$"{WS}* { return(INDIRECT); }
<A>NF { mustfld=1; yylval = (hack)setsymtab(yytext, EMPTY, 0.0, NUM, symtab); return(VAR); }
<A>NF { mustfld=1; yylval = (node *) setsymtab(yytext, EMPTY, 0.0, NUM, symtab); return(VAR); }
<A>({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)? {
yylval = (hack)setsymtab(yytext, EMPTY, atof(yytext), CON|NUM, symtab); return(NUMBER); }
yylval = (node *) setsymtab(yytext, EMPTY, atof(yytext), CON|NUM, symtab); return(NUMBER); }
<A>"}"{WS}*\n { BEGIN sc; lineno++; return(';'); }
<A>"}" { BEGIN sc; return(';'); }
<A>;\n { lineno++; return(';'); }
@@ -84,27 +85,27 @@ WS [ \t]
<A>exit return(EXIT);
<A>break return(BREAK);
<A>continue return(CONTINUE);
<A>print { yylval = PRINT; return(PRINT); }
<A>printf { yylval = PRINTF; return(PRINTF); }
<A>sprintf { yylval = SPRINTF; return(SPRINTF); }
<A>split { yylval = SPLIT; return(SPLIT); }
<A>print { yylval = (node *) PRINT; return(PRINT); }
<A>printf { yylval = (node *) PRINTF; return(PRINTF); }
<A>sprintf { yylval = (node *) SPRINTF; return(SPRINTF); }
<A>split { yylval = (node *) SPLIT; return(SPLIT); }
<A>substr return(SUBSTR);
<A>index return(INDEX);
<A>in return(IN);
<A>getline return(GETLINE);
<A>length { yylval = FLENGTH; return(FNCN); }
<A>log { yylval = FLOG; return(FNCN); }
<A>int { yylval = FINT; return(FNCN); }
<A>exp { yylval = FEXP; return(FNCN); }
<A>sqrt { yylval = FSQRT; return(FNCN); }
<A>{A}{B}* { yylval = (hack)setsymtab(yytext, tostring(""), 0.0, STR|NUM, symtab); return(VAR); }
<A>length { yylval = (node *) FLENGTH; return(FNCN); }
<A>log { yylval = (node *) FLOG; return(FNCN); }
<A>int { yylval = (node *) FINT; return(FNCN); }
<A>exp { yylval = (node *) FEXP; return(FNCN); }
<A>sqrt { yylval = (node *) FSQRT; return(FNCN); }
<A>{A}{B}* { yylval = (node *) setsymtab(yytext, tostring(""), 0.0, STR|NUM, symtab); return(VAR); }
<A>\" { BEGIN str; clen=0; }
<A># { BEGIN comment; }
<comment>\n { BEGIN A; lineno++; return(NL); }
<comment>. ;
<A>. { yylval = yytext[0]; return(yytext[0]); }
<A>. { yylval = (node *) (int) yytext[0]; return(yytext[0]); }
<reg>"[" { BEGIN chc; clen=0; cflag=0; }
<reg>"[^" { BEGIN chc; clen=0; cflag=1; }
@@ -118,19 +119,19 @@ WS [ \t]
<reg>")" return(')');
<reg>"^" return('^');
<reg>"$" return('$');
<reg>\\{D}{D}{D} { sscanf(yytext+1, "%o", &yylval); return(CHAR); }
<reg>\\. { if (yytext[1]=='n') yylval = '\n';
else if (yytext[1] == 't') yylval = '\t';
else yylval = yytext[1];
<reg>\\{D}{D}{D} { sscanf(yytext+1, "%o", (int *) &yylval); return(CHAR); }
<reg>\\. { if (yytext[1]=='n') yylval = (node *) '\n';
else if (yytext[1] == 't') yylval = (node *) '\t';
else yylval = (node *) (int) yytext[1];
return(CHAR);
}
<reg>"/" { BEGIN A; unput('/'); }
<reg>\n { yyerror("newline in regular expression"); lineno++; BEGIN A; }
<reg>. { yylval = yytext[0]; return(CHAR); }
<reg>. { yylval = (node *) (int) yytext[0]; return(CHAR); }
<str>\" { char *s; BEGIN A; cbuf[clen]=0; s = tostring(cbuf);
cbuf[clen] = ' '; cbuf[++clen] = 0;
yylval = (hack)setsymtab(cbuf, s, 0.0, CON|STR, symtab); return(STRING); }
yylval = (node *) setsymtab(cbuf, s, 0.0, CON|STR, symtab); return(STRING); }
<str>\n { yyerror("newline in string"); lineno++; BEGIN A; }
<str>"\\\"" { cbuf[clen++]='"'; }
<str,chc>"\\"n { cbuf[clen++]='\n'; }
@@ -139,7 +140,7 @@ WS [ \t]
<str>. { CADD; }
<chc>"\\""]" { cbuf[clen++]=']'; }
<chc>"]" { BEGIN reg; cbuf[clen]=0; yylval = (hack)tostring(cbuf);
<chc>"]" { BEGIN reg; cbuf[clen]=0; yylval = (node *) tostring(cbuf);
if (cflag==0) { return(CCL); }
else { return(NCCL); } }
<chc>\n { yyerror("newline in character class"); lineno++; BEGIN A; }
@@ -147,9 +148,10 @@ WS [ \t]
%%
int
input()
{
register c;
int c;
extern char *lexprog;
if (yyin == NULL)
@@ -163,6 +165,7 @@ input()
return(c);
}
void
startreg()
{
BEGIN reg;

View File

@@ -38,6 +38,12 @@ node *point[MAXLIN];
int setcnt;
int line;
void follow(node *v);
int notin(int **array, int n, int *prev);
void cfoll(node *v);
void overflo(void);
void freetr(node *p);
void penter(node *p);
struct fa *makedfa(p) /* returns dfa for tree pointed to by p */
node *p;
@@ -58,6 +64,7 @@ node *p;
return(fap);
}
void
penter(p) /* set up parent pointers and leaf indices */
node *p;
{
@@ -83,6 +90,7 @@ node *p;
}
}
void
freetr(p) /* free parse tree and follow sets */
node *p;
{
@@ -109,7 +117,7 @@ node *p;
char *cclenter(p)
register char *p;
{
register i, c;
int i, c;
char *op;
op = p;
@@ -137,15 +145,17 @@ register char *p;
return(tostring(chars));
}
void
overflo()
{
error(FATAL, "regular expression too long\n");
}
void
cfoll(v) /* enter follow set of each leaf of vertex v into foll[leaf] */
register node *v;
{
register i;
int i;
int prev;
int *add();
@@ -174,10 +184,11 @@ register node *v;
}
}
int
first(p) /* collects initially active leaves of p into setvec */
register node *p; /* returns 0 or 1 depending on whether p matches empty string */
{
register b;
int b;
switch(type(p)) {
LEAF
@@ -208,6 +219,7 @@ register node *p; /* returns 0 or 1 depending on whether p matches empty string
return(-1);
}
void
follow(v)
node *v; /* collects leaves that can follow v into setvec */
{
@@ -243,8 +255,8 @@ node *v; /* collects leaves that can follow v into setvec */
}
}
member(c, s) /* is c in s? */
register char c, *s;
int
member(char c, char *s) /* is c in s? */
{
while (*s)
if (c == *s++)
@@ -252,10 +264,11 @@ register char c, *s;
return(0);
}
int
notin(array, n, prev) /* is setvec in array[0] thru array[n]? */
int **array;
int *prev; {
register i, j;
int i, j;
int *ptr;
for (i=0; i<=n; i++) {
ptr = array[i];
@@ -272,7 +285,7 @@ int *prev; {
int *add(n) { /* remember setvec */
int *ptr, *p;
register i;
int i;
if ((p = ptr = (int *) malloc((n+1)*sizeof(int))) == NULL)
overflo();
*ptr = n;
@@ -288,8 +301,8 @@ int *add(n) { /* remember setvec */
struct fa *cgotofn()
{
register i, k;
register int *ptr;
int i, k;
int *ptr;
char c;
char *p;
node *cp;
@@ -505,11 +518,12 @@ struct fa *cgotofn()
return(where[0]);
}
int
match(pfa, p)
register struct fa *pfa;
register char *p;
{
register count;
int count;
char c;
if (p == 0) return(0);
if (pfa->cch == 1) { /* fast test for first character, if possible */

View File

@@ -1,12 +1,15 @@
#include "stdio.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int
freeze(s)
char *s;
{
int fd;
unsigned int *len;
size_t len;
len = (unsigned int *)sbrk(0);
len = (size_t) sbrk(0);
if((fd = creat(s, 0666)) < 0) {
perror(s);
return(1);
@@ -17,6 +20,7 @@ freeze(s)
return(0);
}
int
thaw(s)
char *s;
{

View File

@@ -30,6 +30,8 @@ cell fldtab[MAXFLD] = { /*room for fields */
};
int maxfld = 0; /* last used field */
void setclvar(char *s);
void
error(int f, char *s, ...)
{
@@ -46,12 +48,13 @@ error(int f, char *s, ...)
exit(2);
}
int
getrec()
{
register char *rr;
extern int svargc;
extern char **svargv;
register c, sep;
int c, sep;
dprintf("**RS=%o, **FS=%o\n", **RS, **FS, NULL);
donefld = 0;
@@ -108,6 +111,7 @@ getrec()
return(0); /* true end of file */
}
void
setclvar(s) /* set var=value from s */
char *s;
{
@@ -122,6 +126,7 @@ char *s;
dprintf("command line set %s to |%s|\n", s, p, NULL);
}
void
fldbld()
{
register char *r, *fr, sep;
@@ -183,6 +188,7 @@ fldbld()
printf("field %d: |%s|\n", i, fldtab[i].sval);
}
void
recbld()
{
int i;
@@ -193,7 +199,7 @@ recbld()
r = record;
for (i = 1; i <= *NF; i++) {
p = getsval(&fldtab[i]);
while (*r++ = *p++)
while ((*r++ = *p++))
;
*(r-1) = **OFS;
}
@@ -223,6 +229,7 @@ yyerror(s)
errorflag = 2;
}
void
PUTS(s)
char *s;
{
@@ -231,10 +238,11 @@ PUTS(s)
#define MAXEXPON 38 /* maximum exponenet for fp number */
int
isnumber(s)
register char *s;
{
register d1, d2;
int d1, d2;
int point;
char *es;

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "awk.def.h"
#include "awk.h"
@@ -13,12 +14,12 @@ int svargc;
char **svargv, **xargv;
extern FILE *yyin; /* lex input file */
char *lexprog; /* points to program argument if it exists */
extern errorflag; /* non-zero if any syntax errors; set by yyerror */
int filefd, symnum, ansfd;
char *filelist;
extern int maxsym, errno;
extern int maxsym;
int
main(argc, argv)
int argc;
char *argv[];
@@ -29,10 +30,10 @@ main(argc, argv)
while (argc > 1) {
argc--;
argv++;
/* this nonsense is because gcos argument handling */
/* folds -F into -f. accordingly, one checks the next
/* character after f to see if it's -f file or -Fx.
*/
/* this nonsense is because gcos argument handling
* folds -F into -f. accordingly, one checks the next
* character after f to see if it's -f file or -Fx.
*/
if (argv[0][0] == '-' && TOLOWER(argv[0][1]) == 'f' && argv[0][2] == '\0') {
yyin = fopen(argv[1], "r");
if (yyin == NULL)
@@ -92,6 +93,7 @@ main(argc, argv)
exit(errorflag);
}
int
yywrap()
{
return(1);

View File

@@ -119,7 +119,7 @@ node *stat4(a,b,c,d,e) node *b, *c, *d, *e;
node *valtonode(a, b) cell *a;
{
register node *x;
x = node0(a);
x = node0((int) a);
x->ntype = NVALUE;
x->subtype = b;
return(x);

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "awk.def.h"
#include "awk.h"
struct tok

View File

@@ -31,6 +31,10 @@ static cell nullval = { EMPTY, EMPTY, 0.0, NUM, 0 };
obj true = { OBOOL, BTRUE, 0 };
obj false = { OBOOL, BFALSE, 0 };
void redirprint(char *s, int a, node *b);
void tempfree(obj a);
void
run()
{
register int i;
@@ -40,7 +44,7 @@ run()
/* Wait for children to complete if output to a pipe. */
for (i=0; i<FILENUM; i++)
if (files[i].fp && files[i].type == '|')
pclose(files[i].fp);
fclose(files[i].fp);
}
obj execute(u) node *u;
@@ -152,7 +156,7 @@ obj matchop(a,n) node **a;
if (isstr(x)) s = x.optr->sval;
else s = getsval(x.optr);
tempfree(x);
i = match(a[1], s);
i = match((struct fa*) a[1], s);
if (n==MATCH && i==1 || n==NOTMATCH && i==0)
return(true);
else
@@ -224,6 +228,7 @@ obj relop(a,n) node **a;
}
}
void
tempfree(a) obj a;
{
if (!istemp(a)) return;
@@ -397,7 +402,7 @@ char *format(s,a) char *s; node *a;
return(buf);
}
obj asprintf(a,n) node **a;
obj asprintf1(a,n) node **a;
{
obj x;
node *y;
@@ -592,7 +597,7 @@ obj aprintf(a,n) node **a;
{
obj x;
x = asprintf(a,n);
x = asprintf1(a,n);
if (a[1]==NULL) {
printf("%s", x.optr->sval);
tempfree(x);
@@ -840,7 +845,11 @@ obj print(a,n) node **a;
return(false);
}
obj nullproc() {}
obj nullproc()
{
static const obj zero;
return zero;
}
obj nodetoobj(a) node *a;
{
@@ -853,6 +862,7 @@ obj nodetoobj(a) node *a;
return(x);
}
void
redirprint(s, a, b) char *s; node *b;
{
register int i;

View File

@@ -1,5 +1,6 @@
e y.tab.h
1,$g!/#define /d
1,$g/YYSTYPE/d
1,$s/# *define *//
1,$s/^/{"/
1,$s/ /", /

View File

@@ -19,6 +19,10 @@ cell *recloc; /* location of record */
cell *nrloc; /* NR */
cell *nfloc; /* NF */
void checkval(cell *vp);
int hash(char *s);
void
syminit()
{
setsymtab("0", tostring("0"), 0.0, NUM|STR|CON|FLD, symtab);
@@ -51,6 +55,7 @@ cell **makesymtab()
return(cp);
}
void
freesymtab(ap) /* free symbol table */
cell *ap;
{
@@ -76,7 +81,7 @@ awkfloat f;
unsigned t;
cell **tab;
{
register h;
int h;
register cell *p;
cell *lookup();
@@ -101,13 +106,14 @@ cell **tab;
return(p);
}
int
hash(s) /* form hash value for string s */
register unsigned char *s;
char *s;
{
register int hashval;
for (hashval = 0; *s != '\0'; )
hashval += *s++;
hashval += (unsigned char) *s++;
return(hashval % MAXSYM);
}
@@ -206,6 +212,7 @@ register cell *vp;
return(vp->sval);
}
void
checkval(vp)
register cell *vp;
{

View File

@@ -7,8 +7,6 @@
#include <errno.h>
#include <math.h>
int errno;
static double pio2 = 1.570796326794896619;
double

View File

@@ -19,11 +19,11 @@
* Coefficients for large x are #5667 from Hart & Cheney (18.72D).
*/
#include <math.h>
#include <errno.h>
#define M 7
#define N 9
int errno;
static double torp = 1.1283791670955125738961589031;
static double p1[] = {
0.804373630960840172832162e5,

View File

@@ -8,7 +8,6 @@
#include <errno.h>
#include <math.h>
int errno;
static double p0 = .2080384346694663001443843411e7;
static double p1 = .3028697169744036299076048876e5;
static double p2 = .6061485330061080841615584556e2;

View File

@@ -39,7 +39,6 @@
#include <math.h>
#include <errno.h>
int errno;
static double pzero, qzero;
static double tpi = .6366197723675813430755350535e0;
static double pio4 = .7853981633974483096156608458e0;

View File

@@ -39,7 +39,6 @@
#include <math.h>
#include <errno.h>
int errno;
static double pzero, qzero;
static double tpi = .6366197723675813430755350535e0;
static double pio4 = .7853981633974483096156608458e0;

View File

@@ -29,8 +29,6 @@
#include <math.h>
#include <errno.h>
int errno;
double
jn(n,x) int n; double x;{
int i;

View File

@@ -9,8 +9,6 @@
#include <errno.h>
#include <math.h>
int errno;
static double _log2 = 0.693147180559945309e0;
static double ln10 = 2.302585092994045684;
static double sqrto2 = 0.707106781186547524e0;

View File

@@ -5,8 +5,6 @@
#include <errno.h>
#include <math.h>
int errno;
double
pow(arg1,arg2)
double arg1, arg2;

View File

@@ -7,8 +7,6 @@
#include <errno.h>
#include <math.h>
int errno;
double
sqrt(arg)
double arg;

View File

@@ -7,8 +7,6 @@
#include <errno.h>
#include <math.h>
int errno;
static double invpi = 1.27323954473516268;
static double p0 = -0.1306820264754825668269611177e+5;
static double p1 = 0.1055970901714953193602353981e+4;