BSD 4_3 release
[unix-history] / usr / src / bin / as / asparse.c
index af04c44..f97c112 100644 (file)
@@ -1,8 +1,11 @@
 /*
 /*
- *     Copyright (c) 1982 Regents of the University of California
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
  */
  */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)asparse.c 4.17 7/1/83";
+static char sccsid[] = "@(#)asparse.c  5.2 (Berkeley) 6/19/85";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -137,27 +140,20 @@ yyparse()
                        }
 restlab:
                        shift;
                        }
 restlab:
                        shift;
-                       flushfield(NBPW/4);
+                       flushfield(NBWD/4);
                        if ((np->s_type&XTYPE)!=XUNDEF) {
                        if ((np->s_type&XTYPE)!=XUNDEF) {
-                               if(  (np->s_type&XTYPE)!=dotp->e_xtype 
-                                  || np->s_value!=dotp->e_xvalue
-                                  || (  (passno==1)
-                                      &&(np->s_index != dotp->e_xloc)
-                                     )
-                                 ){
-#ifndef DEBUG
-                                       if (FETCHNAME(np)[0] != 'L')
-#endif not DEBUG
-                                       {
-                                               if (passno == 1)
-                                                 yyerror("%s redefined",
+                               if (  (np->s_type&XTYPE) != dotp->e_xtype 
+                                  || np->s_value != dotp->e_xvalue
+                                  || (   passno == 1
+                                      && np->s_index != dotp->e_xloc) ) {
+                                       if (passno == 1)
+                                               yyerror("%s redefined",
                                                        FETCHNAME(np));
                                                        FETCHNAME(np));
-                                               else
-                                                 yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
+                                       else
+                                               yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
                                                        FETCHNAME(np),
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                                        FETCHNAME(np),
                                                        np->s_value,
                                                        dotp->e_xvalue);
-                                       }
                                }
                        }
                        np->s_type &= ~(XTYPE|XFORW);
                                }
                        }
                        np->s_type &= ~(XTYPE|XFORW);
@@ -171,7 +167,7 @@ restlab:
                                np->s_tag = LABELID;
                        }
                }       /*end of this being a label*/
                                np->s_tag = LABELID;
                        }
                }       /*end of this being a label*/
-       }       /*end of to consuming all labels, NLs and SEMIS */ 
+       }       /*end of consuming all labels, NLs and SEMIS */ 
 
        xp = explist;
        ap = arglist;
 
        xp = explist;
        ap = arglist;
@@ -282,7 +278,7 @@ restlab:
        }
        if (seg_type == IDATA)
                seg_number += NLOC;
        }
        if (seg_type == IDATA)
                seg_number += NLOC;
-       flushfield(NBPW/4);
+       flushfield(NBWD/4);
        dotp = &usedot[seg_number];
        if (passno==2) {        /* go salt away in pass 2*/
                txtfil = usefile[seg_number];
        dotp = &usedot[seg_number];
        if (passno==2) {        /* go salt away in pass 2*/
                txtfil = usefile[seg_number];
@@ -298,10 +294,10 @@ restlab:
         *      exprlist:  empty | exprlist outexpr
         *      outexpr:   <expr> | <expr> : <expr>
         */
         *      exprlist:  empty | exprlist outexpr
         *      outexpr:   <expr> | <expr> : <expr>
         */
-   case IBYTE: curlen = NBPW/4; goto elist;
-   case IWORD: curlen = NBPW/2; goto elist;
-   case IINT:  curlen = NBPW;   goto elist;
-   case ILONG: curlen = NBPW;   goto elist;
+   case IBYTE: curlen = NBWD/4; goto elist;
+   case IWORD: curlen = NBWD/2; goto elist;
+   case IINT:  curlen = NBWD;   goto elist;
+   case ILONG: curlen = NBWD;   goto elist;
 
    elist:
        seg_type = val;
 
    elist:
        seg_type = val;
@@ -342,9 +338,9 @@ restlab:
                        if (bitoff)
                                yyerror("Illegal relocation in field");
                        switch(curlen){
                        if (bitoff)
                                yyerror("Illegal relocation in field");
                        switch(curlen){
-                               case NBPW/4:    reloc_how = TYPB; break;
-                               case NBPW/2:    reloc_how = TYPW; break;
-                               case NBPW:      reloc_how = TYPL; break;
+                               case NBWD/4:    reloc_how = TYPB; break;
+                               case NBWD/2:    reloc_how = TYPW; break;
+                               case NBWD:      reloc_how = TYPL; break;
                        }
                        if (passno == 1){
                                dotp->e_xvalue += ty_nbyte[reloc_how];
                        }
                        if (passno == 1){
                                dotp->e_xvalue += ty_nbyte[reloc_how];
@@ -376,7 +372,7 @@ restlab:
        }       /* there existed an expression at all */
 
        flushfield(curlen);
        }       /* there existed an expression at all */
 
        flushfield(curlen);
-       if ( ( curlen == NBPW/4) && bitoff)
+       if ( ( curlen == NBWD/4) && bitoff)
                dotp->e_xvalue ++;
        break;
        /*end of case IBYTE, IWORD, ILONG, IINT*/
                dotp->e_xvalue ++;
        break;
        /*end of case IBYTE, IWORD, ILONG, IINT*/
@@ -388,7 +384,7 @@ restlab:
                yyerror("Space size not absolute");
        space_value = locxp->e_xvalue;
   ospace:
                yyerror("Space size not absolute");
        space_value = locxp->e_xvalue;
   ospace:
-       flushfield(NBPW/4);
+       flushfield(NBWD/4);
        {
                static char spacebuf[128];
                while (space_value > sizeof(spacebuf)){
        {
                static char spacebuf[128];
                while (space_value > sizeof(spacebuf)){
@@ -421,10 +417,9 @@ restlab:
        expr(locxp, val);
        if (passno == 2 && (locxp->e_xtype & XTYPE) != XABS)    /* tekmdp */
                yyerror("Fill value not absolute");
        expr(locxp, val);
        if (passno == 2 && (locxp->e_xtype & XTYPE) != XABS)    /* tekmdp */
                yyerror("Fill value not absolute");
-       flushfield(NBPW/4);
-       if (passno == 1) {
-               dotp->e_xvalue += fill_rep * fill_size;
-       } else {
+       flushfield(NBWD/4);
+       dotp->e_xvalue += fill_rep * fill_size;
+       if (passno == 2) {
                while(fill_rep-- > 0)
                        bwrite((char *)&locxp->e_xvalue, fill_size, txtfil);
        }
                while(fill_rep-- > 0)
                        bwrite((char *)&locxp->e_xvalue, fill_size, txtfil);
        }
@@ -441,7 +436,7 @@ restlab:
         */
        while (val == STRING){
                int     mystrlen;
         */
        while (val == STRING){
                int     mystrlen;
-               flushfield(NBPW/4);
+               flushfield(NBWD/4);
                if (bitoff)
                        dotp->e_xvalue++;
                stringp = (struct strdesc *)yylval;
                if (bitoff)
                        dotp->e_xvalue++;
                stringp = (struct strdesc *)yylval;
@@ -543,6 +538,7 @@ restlab:
                stpt->s_value = locxp->e_xvalue;
                stpt->s_index = dotp - usedot;
                if (exprisname){
                stpt->s_value = locxp->e_xvalue;
                stpt->s_index = dotp - usedot;
                if (exprisname){
+                       stpt->s_type = locxp->e_xtype;
                        switch(stpt->s_ptype){
                                case N_GSYM:
                                case N_FNAME:
                        switch(stpt->s_ptype){
                                case N_GSYM:
                                case N_FNAME: