bye bye fixed names (eg, FLEXNAMES is not set)
[unix-history] / usr / src / old / as.vax / asparse.c
index 7ad5b1b..a9d57ef 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)asparse.c 4.13 %G%";
+static char sccsid[] = "@(#)asparse.c 4.16 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -44,7 +44,7 @@ struct        arg     arglist[NARG];  /*building up operands in instructions*/
  */
 char   tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
 
  */
 char   tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
 
-static char    UDotsname[32];  /*name of the assembly source*/
+static char    UDotsname[64];  /*name of the assembly source*/
 
 yyparse()
 {
 
 yyparse()
 {
@@ -68,7 +68,7 @@ yyparse()
        reg     struct  symtab  *p;
        reg     struct  symtab  *stpt;
 
        reg     struct  symtab  *p;
        reg     struct  symtab  *stpt;
 
-               char    *stringp;       /*handles string lists*/
+               struct  strdesc *stringp;       /*handles string lists*/
 
                int     regno;          /*handles arguments*/
                int     *ptrregno = &regno;
 
                int     regno;          /*handles arguments*/
                int     *ptrregno = &regno;
@@ -131,13 +131,8 @@ yyparse()
                        np = (struct symtab *)yylval;
                        shiftover(NAME);
                        if (val != COLON) {
                        np = (struct symtab *)yylval;
                        shiftover(NAME);
                        if (val != COLON) {
-#ifdef FLEXNAMES
                                yyerror("\"%s\" is not followed by a ':' for a label definition",
                                yyerror("\"%s\" is not followed by a ':' for a label definition",
-#else not FLEXNAMES
-                               yyerror("\"%.*s\" is not followed by a ':' for a label definition",
-                                       NCPName,
-#endif not FLEXNAMES
-                                       np->s_name);
+                                       FETCHNAME(np));
                                goto  errorfix;
                        }
 restlab:
                                goto  errorfix;
                        }
 restlab:
@@ -151,25 +146,15 @@ restlab:
                                      )
                                  ){
 #ifndef DEBUG
                                      )
                                  ){
 #ifndef DEBUG
-                                       if (np->s_name[0] != 'L')
+                                       if (FETCHNAME(np)[0] != 'L')
 #endif not DEBUG
                                        {
                                                if (passno == 1)
 #endif not DEBUG
                                        {
                                                if (passno == 1)
-#ifdef FLEXNAMES
                                                  yyerror("%s redefined",
                                                  yyerror("%s redefined",
-#else not FLEXNAMES
-                                                 yyerror("%.*s redefined",
-                                                       NCPName,
-#endif not FLEXNAMES 
-                                                       np->s_name);
+                                                       FETCHNAME(np));
                                                else
                                                else
-#ifdef FLEXNAMES
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
-#else not FLEXNAMES
-                                                 yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
-                                                       NCPName,
-#endif not FLEXNAMES
-                                                       np->s_name,
+                                                       FETCHNAME(np),
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                        }
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                        }
@@ -180,7 +165,7 @@ restlab:
                        np->s_value = dotp->e_xvalue;
                        if (passno == 1){
                                np->s_index = dotp-usedot;
                        np->s_value = dotp->e_xvalue;
                        if (passno == 1){
                                np->s_index = dotp-usedot;
-                               if (np->s_name[0] == 'L'){
+                               if (FETCHNAME(np)[0] == 'L'){
                                        nlabels++;
                                }
                                np->s_tag = LABELID;
                                        nlabels++;
                                }
                                np->s_tag = LABELID;
@@ -214,10 +199,11 @@ restlab:
 
    case IFILE:
        shift;
 
    case IFILE:
        shift;
-       stringp = (char *)yylval;
+       stringp = (struct strdesc *)yylval;
        shiftover(STRING);
        dotsname = &UDotsname[0];
        shiftover(STRING);
        dotsname = &UDotsname[0];
-       movestr(dotsname, stringp, min(STRLEN(stringp), sizeof(dotsname)));
+       movestr(dotsname, stringp->sd_string,
+               min(stringp->sd_strlen, sizeof(UDotsname)));
        break;
 
    case ILINENO:
        break;
 
    case ILINENO:
@@ -256,11 +242,7 @@ restlab:
         */
        if (passno == 1){
                stpt = (struct symtab *)symalloc();
         */
        if (passno == 1){
                stpt = (struct symtab *)symalloc();
-#ifdef FLEXNAMES
                stpt->s_name = np->s_name;
                stpt->s_name = np->s_name;
-#else
-               movestr(stpt->s_name, np->s_name, NCPName);
-#endif
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
                np = stpt;
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
                np = stpt;
@@ -302,24 +284,10 @@ restlab:
                seg_number += NLOC;
        flushfield(NBPW/4);
        dotp = &usedot[seg_number];
                seg_number += NLOC;
        flushfield(NBPW/4);
        dotp = &usedot[seg_number];
-#ifdef UNIX
        if (passno==2) {        /* go salt away in pass 2*/
                txtfil = usefile[seg_number];
                relfil = rusefile[seg_number];
        }
        if (passno==2) {        /* go salt away in pass 2*/
                txtfil = usefile[seg_number];
                relfil = rusefile[seg_number];
        }
-#endif UNIX
-#ifdef VMS
-       if (passno==2) {
-               puchar(vms_obj_ptr,6);          /*  setpl  */
-               puchar(vms_obj_ptr,seg_number); /* psect # */
-               plong(vms_obj_ptr,dotp->e_xvalue);/*  offset */
-               puchar(vms_obj_ptr,80);         /*  setrb  */
-               if((vms_obj_ptr-sobuf) > 400){
-                       write(objfil,sobuf,vms_obj_ptr-sobuf);
-                       vms_obj_ptr=sobuf+1;    /*flush buf*/
-               }
-       }
-#endif VMS
        break;
 
        /*
        break;
 
        /*
@@ -421,7 +389,6 @@ restlab:
        space_value = locxp->e_xvalue;
   ospace:
        flushfield(NBPW/4);
        space_value = locxp->e_xvalue;
   ospace:
        flushfield(NBPW/4);
-#ifdef UNIX
        {
                static char spacebuf[128];
                while (space_value > sizeof(spacebuf)){
        {
                static char spacebuf[128];
                while (space_value > sizeof(spacebuf)){
@@ -430,21 +397,8 @@ restlab:
                }
                outs(spacebuf, space_value);
        }
                }
                outs(spacebuf, space_value);
        }
-#endif UNIX
-#ifdef VMS
-       dotp->e_xvalue += space_value;          /*bump pc*/
-       if (passno==2){
-         puchar(vms_obj_ptr,81);               /* AUGR  */
-         pulong(vms_obj_ptr,space_value);/* incr  */
-         if ((vms_obj_ptr-sobuf) > 400) {
-               write(objfil,sobuf,vms_obj_ptr-sobuf);
-               vms_obj_ptr=sobuf+1;            /*pur buf*/
-         }
-       }
-#endif VMS
        break;
 
        break;
 
-#ifdef UNIX
        /*
         *      .fill rep, size, value
         *      repeat rep times: fill size bytes with (truncated) value
        /*
         *      .fill rep, size, value
         *      repeat rep times: fill size bytes with (truncated) value
@@ -475,7 +429,6 @@ restlab:
                        bwrite((char *)&locxp->e_xvalue, fill_size, txtfil);
        }
        break;
                        bwrite((char *)&locxp->e_xvalue, fill_size, txtfil);
        }
        break;
-#endif UNIX
 
    case IASCII:                /* .ascii [ <stringlist> ] */
    case IASCIZ:        /* .asciz [ <stringlist> ] */
 
    case IASCII:                /* .ascii [ <stringlist> ] */
    case IASCIZ:        /* .asciz [ <stringlist> ] */
@@ -487,35 +440,35 @@ restlab:
         *      stringlist: empty | STRING | stringlist STRING
         */
        while (val == STRING){
         *      stringlist: empty | STRING | stringlist STRING
         */
        while (val == STRING){
+               int     mystrlen;
                flushfield(NBPW/4);
                if (bitoff)
                        dotp->e_xvalue++;
                flushfield(NBPW/4);
                if (bitoff)
                        dotp->e_xvalue++;
-               stringp = (char *)yylval;
+               stringp = (struct strdesc *)yylval;
                /*
                /*
-                *      utilize the string scanner cheat,
-                *      where it appended a null byte on the string,
-                *      but didn't charge it to STRLEN
+                *      utilize the string scanner cheat;
+                *      the scanner appended a null byte on the string,
+                *      but didn't charge it to sd_strlen
                 */
                 */
-               STRLEN(stringp) += (auxval == IASCIZ) ? 1 : 0;
-#ifdef UNIX
-               outs(stringp, STRLEN(stringp));
-#endif UNIX
-#ifdef VMS
-               {
-                       reg int i;
-                       for (i=0; i < stringp->str_lg; i++){
-                         dotp->e_xvalue += 1;
-                           if (passno==2){
-                               puchar(vms_obj_ptr,-1);
-                               puchar(vms_obj_ptr,stringp->str[i]);
-                               if (vms_obj_ptr-sobuf > 400) {
-                                 write(objfil,sobuf,vms_obj_ptr-sobuf);
-                                 vms_obj_ptr = sobuf + 1;
-                               }
-                           }
+               mystrlen = stringp->sd_strlen;
+               mystrlen += (auxval == IASCIZ) ? 1 : 0;
+               if (passno == 2){
+                       if (stringp->sd_place & STR_CORE){
+                               outs(stringp->sd_string, mystrlen);
+                       } else {
+                               int     i, nread;
+                               fseek(strfile, stringp->sd_stroff, 0);
+                               for (i = 0; i < mystrlen;/*VOID*/){
+                                       nread = fread(yytext, 1,
+                                               min(mystrlen - i,
+                                                 sizeof(yytext)), strfile);
+                                       outs(yytext, nread);
+                                       i += nread;
+                               }
                        }
                        }
+               } else {
+                       dotp->e_xvalue += mystrlen;
                }
                }
-#endif VMS
                shift;          /*over the STRING*/
                if (val == CM)  /*could be a split string*/
                        shift;
                shift;          /*over the STRING*/
                if (val == CM)  /*could be a split string*/
                        shift;
@@ -566,30 +519,8 @@ restlab:
  *     .stabd           <expr>, <expr>, <expr> # . 
  */
    case ISTAB: 
  *     .stabd           <expr>, <expr>, <expr> # . 
  */
    case ISTAB: 
-#ifndef FLEXNAMES
-       stabname = ".stab";
-       if (passno == 2)        goto errorfix;
-       stpt = (struct symtab *)yylval;
-       /*
-        *      Make a pointer to the .stab slot.
-        *      There is a pointer in the way (stpt), and
-        *      tokptr points to the next token.
-        */
-       stabstart = tokptr;
-       (char *)stabstart -= sizeof(struct symtab *);
-       (char *)stabstart -= sizeof(bytetoktype);
-       shift;
-       for (argcnt = 0; argcnt < NCPName; argcnt++){
-               expr(locxp, val);
-               stpt->s_name[argcnt] = locxp->e_xvalue;
-               xp = explist;
-               shiftover(CM);
-       }
-       goto tailstab;
-#else  FLEXNAMES
-       yyerror(".stab directive not supported in; report this compiler bug to system administrator");
+       yyerror(".stab directive no longer supported");
        goto errorfix;
        goto errorfix;
-#endif FLEXNAMES
 
   tailstab:
        expr(locxp, val);
 
   tailstab:
        expr(locxp, val);
@@ -724,28 +655,23 @@ restlab:
        (bytetoktype *)stabstart -= sizeof(bytetoktype);
        shift;
        if (auxval == ISTABSTR){
        (bytetoktype *)stabstart -= sizeof(bytetoktype);
        shift;
        if (auxval == ISTABSTR){
-               stringp = (char *)yylval;
+               stringp = (struct strdesc *)yylval;
                shiftover(STRING);
                shiftover(STRING);
-#ifndef FLEXNAMES
-               movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPName));
-#else
-               stpt->s_name = stringp;
+               stpt->s_name = (char *)stringp;
                /*
                 *      We want the trailing null included in this string.
                 *      We utilize the cheat the string scanner used,
                 *      and merely increment the string length
                 */
                /*
                 *      We want the trailing null included in this string.
                 *      We utilize the cheat the string scanner used,
                 *      and merely increment the string length
                 */
-               STRLEN(stringp) += 1;
-#endif
+               stringp->sd_strlen += 1;
                shiftover(CM);
        } else {
                shiftover(CM);
        } else {
-#ifndef FLEXNAMES
-               static char nullstr[NCPName];
-               movestr(stpt->s_name, nullstr, NCPName);
-#else
                static char nullstr[1];
                static char nullstr[1];
-               stpt->s_name = savestr(nullstr, 1);
-#endif
+               static  struct  strdesc strdp;
+               strdp.sd_stroff = strfilepos;
+               strdp.sd_strlen = 0;
+               strdp.sd_place = STR_BOTH;
+               stpt->s_name = (char *)savestr(nullstr, &strdp);
        }
        goto tailstab;
        break;
        }
        goto tailstab;
        break;
@@ -762,13 +688,7 @@ restlab:
        if ( (locxp->e_xtype & XTYPE) != XABS)  /* tekmdp */
                yyerror("comm size not absolute");
        if (passno == 1 && (np->s_type&XTYPE) != XUNDEF)
        if ( (locxp->e_xtype & XTYPE) != XABS)  /* tekmdp */
                yyerror("comm size not absolute");
        if (passno == 1 && (np->s_type&XTYPE) != XUNDEF)
-#ifdef FLEXNAMES
-               yyerror("Redefinition of %s",
-#else not FLEXNAMES
-               yyerror("Redefinition of %.*s",
-                       NCPName,
-#endif not FLEXNAMES
-                       np->s_name);
+               yyerror("Redefinition of %s", FETCHNAME(np));
        if (passno==1) {
                np->s_value = locxp->e_xvalue;
                if (auxval == ICOMM)
        if (passno==1) {
                np->s_value = locxp->e_xvalue;
                if (auxval == ICOMM)