declared freopen; apparently it is not declared in stdio.h
authorceriel <none@none>
Tue, 1 Sep 1987 15:24:15 +0000 (15:24 +0000)
committerceriel <none@none>
Tue, 1 Sep 1987 15:24:15 +0000 (15:24 +0000)
on some systems

mach/proto/cg/fillem.c
mach/proto/cg/gencode.c
mach/proto/ncg/codegen.c
mach/proto/ncg/fillem.c
mach/proto/ncg/gencode.c

index 4d1c633..58a25c0 100644 (file)
@@ -61,6 +61,7 @@ long con();
 
 FILE *emfile;
 extern FILE *codefile;
+extern FILE *freopen();
 
 int nextispseu,savetab1;
 int opcode;
index 2f5758b..ee08d43 100644 (file)
@@ -20,6 +20,7 @@ static char rcsid[] = "$Header$";
  */
 
 FILE *codefile;
+extern FILE *freopen();
 
 out_init(filename) char *filename; {
 
index 02336d4..b281153 100644 (file)
@@ -432,10 +432,13 @@ normalfailed:     if (stackpad!=tokpatlen) {
        myfree(besttup);
        break;
     }
+    case DO_TOSTACK:
     case DO_REMOVE: {
        int texpno,nodeno;
        token_p tp;
        struct reginfo *rp;
+       int doremove = (codep[-1] & 037) == DO_REMOVE;
+       extern int allsetno;
 
        DEBUG("REMOVE");
        if (codep[-1]&32) {
@@ -445,6 +448,13 @@ normalfailed:      if (stackpad!=tokpatlen) {
                getint(texpno,codep);
                nodeno=0;
        }
+       if (texpno == allsetno) {
+               totalcost += stackupto(&fakestack[stackheight-tokpatlen-1],ply,toplevel);
+               CHKCOST();
+               if (doremove) for (rp=machregs;rp<machregs+NREGS;rp++)
+                       rp->r_contents.t_token=0;
+               break;
+       }
        for (tp= &fakestack[stackheight-tokpatlen-1];tp>=&fakestack[0];tp--)
                if (match(tp,&machsets[texpno],nodeno)) {
                        /* investigate possible coercion to register */
@@ -452,8 +462,9 @@ normalfailed:       if (stackpad!=tokpatlen) {
                        CHKCOST();
                        break;
                }
-       for (rp=machregs;rp<machregs+NREGS;rp++)
-               if (match(&rp->r_contents,&machsets[texpno],nodeno))
+       if (doremove) for (rp=machregs;rp<machregs+NREGS;rp++)
+               if (rp->r_contents.t_token != 0 &&
+                   match(&rp->r_contents,&machsets[texpno],nodeno))
                        rp->r_contents.t_token=0;
        break;
     }
index e9fc59e..a785f73 100644 (file)
@@ -61,6 +61,7 @@ long con();
 
 FILE *emfile;
 extern FILE *codefile;
+extern FILE *freopen();
 
 int nextispseu,savetab1;
 int opcode;
index a5e7071..c103c88 100644 (file)
@@ -22,6 +22,7 @@ static char rcsid[] = "$Header$";
 string mystrcpy();
 
 FILE *codefile;
+extern FILE *freopen();
 
 out_init(filename) char *filename; {
 
@@ -88,20 +89,20 @@ praddr(ad) addr_t ad; {
        if (ad.ea_str==0 || *(ad.ea_str) == '\0')
                fprintf(codefile,WRD_FMT,ad.ea_off);
        else {
-               fprintf(codefile,"%s",ad.ea_str);
+               fputs(ad.ea_str, codefile);
                if (ad.ea_off<0) {
-                       fputc('-', codefile);
+                       putc('-', codefile);
                        fprintf(codefile,WRD_FMT,-ad.ea_off);           
                }
                else if(ad.ea_off>0) {
-                       fputc('+',codefile);
+                       putc('+',codefile);
                        fprintf(codefile,WRD_FMT,ad.ea_off);
                }
        }
 }
 
 gennl() {
-       fputc('\n',codefile);
+       putc('\n',codefile);
 }
 
 prtoken(tp,leadingchar) token_p tp; {
@@ -109,9 +110,9 @@ prtoken(tp,leadingchar) token_p tp; {
        register char *code;
        register tkdef_p tdp;
 
-       fputc(leadingchar,codefile);
+       putc(leadingchar,codefile);
        if (tp->t_token == -1) {
-               fprintf(codefile,"%s",codestrings[machregs[tp->t_att[0].ar].r_repr]);
+               fputs(codestrings[machregs[tp->t_att[0].ar].r_repr],codefile);
                return;
        }
        tdp = &tokens[tp->t_token];
@@ -119,7 +120,7 @@ prtoken(tp,leadingchar) token_p tp; {
        code = codestrings[tdp->t_format];
        while ((c = *code++) != 0) {
                if (c>=' ' && c<='~')
-                       fputc(c,codefile);
+                       putc(c,codefile);
                else {
                        assert(c>0 && c<=TOKENSIZE);
                        switch(tdp->t_type[c-1]) {
@@ -132,7 +133,7 @@ prtoken(tp,leadingchar) token_p tp; {
                                praddr(tp->t_att[c-1].aa);
                                break;
                        case EV_REG:
-                               fprintf(codefile,"%s",codestrings[machregs[tp->t_att[c-1].ar].r_repr]);
+                               fputs(codestrings[machregs[tp->t_att[c-1].ar].r_repr],codefile);
                                break;
                        }
                }