date and time created 83/08/11 20:49:31 by sam
[unix-history] / usr / src / old / as.vax / asscan2.c
index 197024f..11fe47e 100644 (file)
@@ -2,37 +2,39 @@
  *     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[] = "@(#)asscan2.c 4.9 %G%";
+static char sccsid[] = "@(#)asscan2.c 4.14 %G%";
 #endif not lint
 
 #include "asscanl.h"
 
 static inttoktype      oval = NL;
 #endif not lint
 
 #include "asscanl.h"
 
 static inttoktype      oval = NL;
-
+#define        ASINBUFSIZ      4096
 char   inbufunget[8];
 char   inbuffer[ASINBUFSIZ];
 char   *Ginbufptr = inbuffer;
 int    Ginbufcnt = 0;
 char   inbufunget[8];
 char   inbuffer[ASINBUFSIZ];
 char   *Ginbufptr = inbuffer;
 int    Ginbufcnt = 0;
+int    scannerhadeof;
 
 fillinbuffer()
 {
                int     nread;
 
 fillinbuffer()
 {
                int     nread;
-       static  int     hadeof;
                int     goal;
                int     got;
 
        nread = 0;
                int     goal;
                int     got;
 
        nread = 0;
-       if (hadeof == 0){
+       if (scannerhadeof == 0){
                goal = sizeof(inbuffer);
                do {
                        got = read(stdin->_file, inbuffer + nread, goal);
                        if (got == 0)
                goal = sizeof(inbuffer);
                do {
                        got = read(stdin->_file, inbuffer + nread, goal);
                        if (got == 0)
-                               hadeof = 1;
+                               scannerhadeof = 1;
                        if (got <= 0)
                                break;
                        nread += got;
                        goal -= got;
                } while (goal);
                        if (got <= 0)
                                break;
                        nread += got;
                        goal -= got;
                } while (goal);
+       } else {
+               scannerhadeof = 0;
        }
        /*
         *      getchar assumes that Ginbufcnt and Ginbufptr
        }
        /*
         *      getchar assumes that Ginbufcnt and Ginbufptr
@@ -47,16 +49,6 @@ fillinbuffer()
        Ginbufptr = inbuffer + 1;
 }
 
        Ginbufptr = inbuffer + 1;
 }
 
-#ifndef FLEXNAMES
-char   strtext[NCPString + 1];
-#else FLEXNAMES
-# if NCPName < NCPString
-char   strtext[NCPString + 1];
-# else
-#define        strtext yytext
-# endif
-#endif FLEXNAMES
-
 scan_dot_s(bufferbox)
        struct tokbufdesc *bufferbox;
 {
 scan_dot_s(bufferbox)
        struct tokbufdesc *bufferbox;
 {
@@ -73,10 +65,10 @@ scan_dot_s(bufferbox)
                ptrall  lgbackpatch;    /* where to stuff a string length */
        reg     ptrall  bufptr;         /* where to stuff tokens */
                ptrall  bufub;          /* where not to stuff tokens */
                ptrall  lgbackpatch;    /* where to stuff a string length */
        reg     ptrall  bufptr;         /* where to stuff tokens */
                ptrall  bufub;          /* where not to stuff tokens */
-       reg     int     maxstrlg;       /* how long a string can be */
                long    intval;         /* value of int */
                int     linescrossed;   /* when doing strings and comments */
                struct  Opcode          opstruct;
                long    intval;         /* value of int */
                int     linescrossed;   /* when doing strings and comments */
                struct  Opcode          opstruct;
+       reg     int     strlg;          /* the length of a string */
 
        (bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]); 
        (bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
 
        (bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]); 
        (bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
@@ -84,7 +76,7 @@ scan_dot_s(bufferbox)
        MEMTOREGBUF;
        if (newfflag){
                newfflag = 0;
        MEMTOREGBUF;
        if (newfflag){
                newfflag = 0;
-               ryylval = (int)savestr(newfname, strlen(newfname) + 1);
+               ryylval = (int)savestr(newfname, strlen(newfname)+1, STR_BOTH);
 
                ptoken(bufptr, IFILE);
                ptoken(bufptr, STRING);
 
                ptoken(bufptr, IFILE);
                ptoken(bufptr, STRING);
@@ -253,7 +245,7 @@ scan_dot_s(bufferbox)
                case 0:
                case LABELID:
                        /*
                case 0:
                case LABELID:
                        /*
-                        *      Its a name... (Labels are subsets ofname)
+                        *      Its a name... (Labels are subsets of name)
                         */
                        ryylval = (int)op;
                        val = NAME;
                         */
                        ryylval = (int)op;
                        val = NAME;
@@ -316,13 +308,13 @@ scan_dot_s(bufferbox)
        case DQ:
           eatstr:
                linescrossed = 0;
        case DQ:
           eatstr:
                linescrossed = 0;
-               for(rcp = strtext, maxstrlg = NCPString; maxstrlg > 0; --maxstrlg){
+               for (strlg = 0; /*VOID*/; strlg++){
                    switch(ch = getchar()){
                    case '"':
                        goto tailDQ;
                    default:
                    stuff:
                    switch(ch = getchar()){
                    case '"':
                        goto tailDQ;
                    default:
                    stuff:
-                       pchar(rcp, ch);
+                       putc(ch, strfile);
                        break;
                    case '\n':
                        yywarning("New line in a string constant");
                        break;
                    case '\n':
                        yywarning("New line in a string constant");
@@ -331,7 +323,7 @@ scan_dot_s(bufferbox)
                        ch = getchar();
                        switch(ch){
                        case EOFCHAR:
                        ch = getchar();
                        switch(ch){
                        case EOFCHAR:
-                               pchar(rcp, '\n');
+                               putc('\n', strfile);
                                ungetc(EOFCHAR);
                                goto tailDQ;
                        default:
                                ungetc(EOFCHAR);
                                goto tailDQ;
                        default:
@@ -376,20 +368,15 @@ scan_dot_s(bufferbox)
                        pint(bufptr, linescrossed);
                }
                /*
                        pint(bufptr, linescrossed);
                }
                /*
-                *      put the string in strtext into the string pool
-                *
-                *      The value in ryylval points to the string;
-                *      the previous 2 bytes is the length of the string
-                *
                 *      Cheat: append a trailing null to the string
                 *      and then adjust the string length to ignore
                 *      the trailing null.  If any STRING client requires
                 *      the trailing null, the client can just change STRLEN
                 */
                 *      Cheat: append a trailing null to the string
                 *      and then adjust the string length to ignore
                 *      the trailing null.  If any STRING client requires
                 *      the trailing null, the client can just change STRLEN
                 */
+               putc(0, strfile);
+               ryylval = (int)savestr((char *)0, strlg + 1, STR_FILE);
                val = STRING;
                val = STRING;
-               *rcp++ = 0;
-               ryylval = (int)savestr(strtext, rcp - strtext);
-               STRLEN(((char *)ryylval)) -= 1;
+               ((struct strdesc *)ryylval)->sd_strlen -= 1;
                goto ret;
 
        case BADCHAR:
                goto ret;
 
        case BADCHAR: