consolidate character buffer length definitions (manifest constants)
authorRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Thu, 30 Jun 1983 22:59:21 +0000 (14:59 -0800)
committerRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Thu, 30 Jun 1983 22:59:21 +0000 (14:59 -0800)
into one place, with documentation

SCCS-vsn: old/as.vax/asparse.c 4.13
SCCS-vsn: old/as.vax/assyms.c 4.10
SCCS-vsn: old/as.vax/assyms.h 4.5
SCCS-vsn: old/as.vax/as.h 4.13
SCCS-vsn: old/as.vax/asscan2.c 4.8

usr/src/old/as.vax/as.h
usr/src/old/as.vax/asparse.c
usr/src/old/as.vax/asscan2.c
usr/src/old/as.vax/assyms.c
usr/src/old/as.vax/assyms.h

index 5c9f2f8..725bdeb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *     Copyright (c) 1982 Regents of the University of California
 /*
  *     Copyright (c) 1982 Regents of the University of California
- *     @(#)as.h 4.12 %G%
+ *     @(#)as.h 4.13 %G%
  */
 #ifdef VMS
 # define       vax     1
  */
 #ifdef VMS
 # define       vax     1
 #define        NHASH           1103    /* hash table is dynamically extended */
 #define        TNAMESIZE       32      /* maximum length of temporary file names */
 #define        NLOC            4       /* number of location ctrs */
 #define        NHASH           1103    /* hash table is dynamically extended */
 #define        TNAMESIZE       32      /* maximum length of temporary file names */
 #define        NLOC            4       /* number of location ctrs */
-
+/*
+ *     Sizes for character buffers.
+ *     what                    size #define name       comments
+ *
+ *     source file reads       ASINBUFSIZ              integral of BUFSIZ
+ *     string assembly         NCPString               large for .stabs
+ *     name assembly           NCPName                 depends on FLEXNAMES
+ *     string save             STRPOOLDALLOP   
+ *
+ *
+ *     -source file reads should be integral of BUFSIZ for efficient reads
+ *     -string saving is a simple first fit
+ */
+#ifndef ASINBUFSIZ
+#      define  ASINBUFSIZ      4096
+#endif not ASINBUFSIZ
+#ifndef STRPOOLDALLOP
+#      define STRPOOLDALLOP    8192
+#endif not STRPOOLDALLOP
+#ifndef NCPString
+#      define  NCPString       4080
+#endif not NCPString
+
+#define        NCPName NCPS
 #ifdef UNIX
 #ifdef UNIX
-# ifndef       FLEXNAMES
-#      ifndef  NCPS
-#              define  NCPS    8       /* number of characters per symbol*/
-#      endif
-# else
-#      ifdef NCPS
-#              undef   NCPS
-#      endif
-#      define  NCPS    4096    /* needed to allocate yytext */
-# endif
+# ifndef FLEXNAMES
+#      ifndef NCPS
+#              undef   NCPName
+#              define  NCPName 8
+#      endif not NCPS
+# else FLEXNAMES
+#      ifndef NCPS
+#              undef   NCPName
+#              define  NCPName 4096
+#      endif not NCPS
+# endif FLEXNAMES
 # endif UNIX
 
 # ifdef VMS
 # endif UNIX
 
 # ifdef VMS
-# ifdef NCPS
-#      undef   NCPS
-# endif NCPS
-#      define  NCPS    15
+#      define  NCPName 15
 # endif VMS
 
 # endif VMS
 
+/*
+ *     Check sizes, and compiler error if sizes botch
+ */
+#if ((ASINBUFSIZ < NCPString) || (ASINBUFSIZ < NCPName) || (STRPOOLDALLOP < NCPString) || (STRPOOLDALLOP < NCPName))
+       $$$botch with definition sizes
+#endif test botches
 /*
  * Symbol types
  */
 /*
  * Symbol types
  */
@@ -299,7 +326,7 @@ struct      Instab{
 #ifdef FLEXNAMES
        char    *I_name;
 #else not FLEXNAMES
 #ifdef FLEXNAMES
        char    *I_name;
 #else not FLEXNAMES
-       char    I_name[NCPS];
+       char    I_name[NCPName];
 #endif
        u_char  I_popcode;              /* basic op code */
        char    I_nargs;
 #endif
        u_char  I_popcode;              /* basic op code */
        char    I_nargs;
@@ -406,7 +433,7 @@ struct      exp {
         *      The lexical analyzer builds up symbols in yytext.  Lookup
         *      expects its argument in this buffer
         */
         *      The lexical analyzer builds up symbols in yytext.  Lookup
         *      expects its argument in this buffer
         */
-       extern  char    yytext[NCPS+2];         /* text buffer for lexical */
+       extern  char    yytext[NCPName+2];      /* text buffer for lexical */
        /*
         *      Variables to manage the input assembler source file
         */
        /*
         *      Variables to manage the input assembler source file
         */
index ad3d804..7ad5b1b 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.12 %G%";
+static char sccsid[] = "@(#)asparse.c 4.13 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -29,7 +29,7 @@ int   droppedLP;              /*one is analyzing an expression beginning with*/
                                /*a left parenthesis, which has already been*/
                                /*shifted. (Used to parse (<expr>)(rn)*/
 
                                /*a left parenthesis, which has already been*/
                                /*shifted. (Used to parse (<expr>)(rn)*/
 
-char   yytext[NCPS+2];         /*the lexical image*/
+char   yytext[NCPName+2];      /*the lexical image*/
 int    yylval;                 /*the lexical value; sloppy typing*/
 struct Opcode          yyopcode;       /* lexical value for an opcode */
 Bignum yybignum;               /* lexical value for a big number */
 int    yylval;                 /*the lexical value; sloppy typing*/
 struct Opcode          yyopcode;       /* lexical value for an opcode */
 Bignum yybignum;               /* lexical value for a big number */
@@ -135,7 +135,7 @@ yyparse()
                                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",
                                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",
-                                       NCPS,
+                                       NCPName,
 #endif not FLEXNAMES
                                        np->s_name);
                                goto  errorfix;
 #endif not FLEXNAMES
                                        np->s_name);
                                goto  errorfix;
@@ -159,7 +159,7 @@ restlab:
                                                  yyerror("%s redefined",
 #else not FLEXNAMES
                                                  yyerror("%.*s redefined",
                                                  yyerror("%s redefined",
 #else not FLEXNAMES
                                                  yyerror("%.*s redefined",
-                                                       NCPS,
+                                                       NCPName,
 #endif not FLEXNAMES 
                                                        np->s_name);
                                                else
 #endif not FLEXNAMES 
                                                        np->s_name);
                                                else
@@ -167,7 +167,7 @@ restlab:
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
 #else not 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",
-                                                       NCPS,
+                                                       NCPName,
 #endif not FLEXNAMES
                                                        np->s_name,
                                                        np->s_value,
 #endif not FLEXNAMES
                                                        np->s_name,
                                                        np->s_value,
@@ -259,7 +259,7 @@ restlab:
 #ifdef FLEXNAMES
                stpt->s_name = np->s_name;
 #else
 #ifdef FLEXNAMES
                stpt->s_name = np->s_name;
 #else
-               movestr(stpt->s_name, np->s_name, NCPS);
+               movestr(stpt->s_name, np->s_name, NCPName);
 #endif
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
 #endif
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
@@ -560,7 +560,7 @@ restlab:
  *             final expression is taken to be  the current
  *             location counter, and is patched by the 2nd pass
  *
  *             final expression is taken to be  the current
  *             location counter, and is patched by the 2nd pass
  *
- *     .stab{<expr>,}*NCPS,<expr>, <expr>, <expr>, <expr>
+ *     .stab{<expr>,}*NCPName,<expr>, <expr>, <expr>, <expr>
  *     .stabn           <expr>, <expr>, <expr>, <expr>
  *     .stabs   STRING, <expr>, <expr>, <expr>, <expr>
  *     .stabd           <expr>, <expr>, <expr> # . 
  *     .stabn           <expr>, <expr>, <expr>, <expr>
  *     .stabs   STRING, <expr>, <expr>, <expr>, <expr>
  *     .stabd           <expr>, <expr>, <expr> # . 
@@ -579,7 +579,7 @@ restlab:
        (char *)stabstart -= sizeof(struct symtab *);
        (char *)stabstart -= sizeof(bytetoktype);
        shift;
        (char *)stabstart -= sizeof(struct symtab *);
        (char *)stabstart -= sizeof(bytetoktype);
        shift;
-       for (argcnt = 0; argcnt < NCPS; argcnt++){
+       for (argcnt = 0; argcnt < NCPName; argcnt++){
                expr(locxp, val);
                stpt->s_name[argcnt] = locxp->e_xvalue;
                xp = explist;
                expr(locxp, val);
                stpt->s_name[argcnt] = locxp->e_xvalue;
                xp = explist;
@@ -727,7 +727,7 @@ restlab:
                stringp = (char *)yylval;
                shiftover(STRING);
 #ifndef FLEXNAMES
                stringp = (char *)yylval;
                shiftover(STRING);
 #ifndef FLEXNAMES
-               movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPS));
+               movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPName));
 #else
                stpt->s_name = stringp;
                /*
 #else
                stpt->s_name = stringp;
                /*
@@ -740,8 +740,8 @@ restlab:
                shiftover(CM);
        } else {
 #ifndef FLEXNAMES
                shiftover(CM);
        } else {
 #ifndef FLEXNAMES
-               static char nullstr[NCPS];
-               movestr(stpt->s_name, nullstr, NCPS);
+               static char nullstr[NCPName];
+               movestr(stpt->s_name, nullstr, NCPName);
 #else
                static char nullstr[1];
                stpt->s_name = savestr(nullstr, 1);
 #else
                static char nullstr[1];
                stpt->s_name = savestr(nullstr, 1);
@@ -766,7 +766,7 @@ restlab:
                yyerror("Redefinition of %s",
 #else not FLEXNAMES
                yyerror("Redefinition of %.*s",
                yyerror("Redefinition of %s",
 #else not FLEXNAMES
                yyerror("Redefinition of %.*s",
-                       NCPS,
+                       NCPName,
 #endif not FLEXNAMES
                        np->s_name);
        if (passno==1) {
 #endif not FLEXNAMES
                        np->s_name);
        if (passno==1) {
index eea306b..b635a53 100644 (file)
@@ -2,13 +2,12 @@
  *     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.7 %G%";
+static char sccsid[] = "@(#)asscan2.c 4.8 %G%";
 #endif not lint
 
 #include "asscanl.h"
 static inttoktype      oval = NL;
 
 #endif not lint
 
 #include "asscanl.h"
 static inttoktype      oval = NL;
 
-#define ASINBUFSIZ 4096
 #define        NINBUFFERS      2
 #define        INBUFLG         NINBUFFERS*ASINBUFSIZ + 2
        /*
 #define        NINBUFFERS      2
 #define        INBUFLG         NINBUFFERS*ASINBUFSIZ + 2
        /*
@@ -20,6 +19,16 @@ static       inttoktype      oval = NL;
 static char    inbuffer[INBUFLG];
 static char    *InBufPtr = 0;
 
 static char    inbuffer[INBUFLG];
 static char    *InBufPtr = 0;
 
+#ifndef FLEXNAMES
+char   strtext[NCPString + 1];
+#else FLEXNAMES
+# if NCPName < NCPString
+char   strtext[NCPString + 1];
+# else
+#define        strtext yytext
+# endif
+#endif FLEXNAMES
+
 /*
  *     fill the inbuffer from the standard input.
  *     Assert: there are always n COMPLETE! lines in the buffer area.
 /*
  *     fill the inbuffer from the standard input.
  *     Assert: there are always n COMPLETE! lines in the buffer area.
@@ -308,7 +317,7 @@ scan_dot_s(bufferbox)
                }
                rcp = yytext;
                do {
                }
                rcp = yytext;
                do {
-                       if (rcp < &yytext[NCPS])
+                       if (rcp < &yytext[NCPName])
                                *rcp++ = ch;
                } while (INCHARSET ( (ch = getchar()), ALPHA | DIGIT));
                *rcp = '\0';
                                *rcp++ = ch;
                } while (INCHARSET ( (ch = getchar()), ALPHA | DIGIT));
                *rcp = '\0';
@@ -383,7 +392,7 @@ scan_dot_s(bufferbox)
        case DQ:
           eatstr:
                linescrossed = 0;
        case DQ:
           eatstr:
                linescrossed = 0;
-               for(rcp = yytext, maxstrlg = NCPS; maxstrlg > 0; --maxstrlg){
+               for(rcp = strtext, maxstrlg = NCPString; maxstrlg > 0; --maxstrlg){
                    switch(ch = getchar()){
                    case '"':
                        goto tailDQ;
                    switch(ch = getchar()){
                    case '"':
                        goto tailDQ;
@@ -449,7 +458,7 @@ scan_dot_s(bufferbox)
                        pint(bufptr, linescrossed);
                }
                /*
                        pint(bufptr, linescrossed);
                }
                /*
-                *      put the string in yytext into the string pool
+                *      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
                 *
                 *      The value in ryylval points to the string;
                 *      the previous 2 bytes is the length of the string
@@ -461,7 +470,7 @@ scan_dot_s(bufferbox)
                 */
                val = STRING;
                *rcp++ = 0;
                 */
                val = STRING;
                *rcp++ = 0;
-               ryylval = (int)savestr(yytext, rcp - yytext);
+               ryylval = (int)savestr(strtext, rcp - strtext);
                STRLEN(((char *)ryylval)) -= 1;
                goto ret;
 
                STRLEN(((char *)ryylval)) -= 1;
                goto ret;
 
index 1a89322..d45cf70 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[] = "@(#)assyms.c 4.9 %G%";
+static char sccsid[] = "@(#)assyms.c 4.10 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -42,10 +42,6 @@ int  nlabels;        /* number of label entries */
 
 /*
  *     Managers of the symbol literal storage.
 
 /*
  *     Managers of the symbol literal storage.
- *     If we have flexible names, then we allocate BUFSIZ long
- *     string, and pack strings into that.  Otherwise, we allocate
- *     symbol storage in fixed hunks NCPS long when we allocate space
- *     for other symbol attributes.
  */
 struct strpool         *strplhead = 0;
 
  */
 struct strpool         *strplhead = 0;
 
@@ -333,7 +329,7 @@ dumpsymtab()
                                tagstring(sp->s_tag));
 #else not FLEXNAMES
                        printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
                                tagstring(sp->s_tag));
 #else not FLEXNAMES
                        printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
-                               segno, NCPS, NCPS, sp->s_name,
+                               segno, NCPName, NCPName, sp->s_name,
                                sp->s_value, sp->s_index,
                                tagstring(sp->s_tag));
 #endif not FLEXNAMES
                                sp->s_value, sp->s_index,
                                tagstring(sp->s_tag));
 #endif not FLEXNAMES
@@ -432,10 +428,10 @@ struct symtab **lookup(instflg)
                        from = yytext;
                        to = (*hp)->s_name;
 #ifndef FLEXNAMES
                        from = yytext;
                        to = (*hp)->s_name;
 #ifndef FLEXNAMES
-                       for (len = 0; (len<NCPS) && *from; len++)
+                       for (len = 0; (len<NCPName) && *from; len++)
                                if (*from++ != *to++)
                                        goto nextprobe;
                                if (*from++ != *to++)
                                        goto nextprobe;
-                       if (len >= NCPS)        /*both are maximal length*/
+                       if (len >= NCPName)     /*both are maximal length*/
                                return(hp);
                        if (*to == 0)           /*assert *from == 0*/
                                return(hp);
                                return(hp);
                        if (*to == 0)           /*assert *from == 0*/
                                return(hp);
@@ -467,7 +463,7 @@ struct symtab **lookup(instflg)
                *hp = symalloc();
                hdallop->h_nused++;
 #ifndef FLEXNAMES
                *hp = symalloc();
                hdallop->h_nused++;
 #ifndef FLEXNAMES
-               strncpy((*hp)->s_name, yytext, NCPS);
+               strncpy((*hp)->s_name, yytext, NCPName);
 #else FLEXNAMES
                for (from = yytext, len = 0; *from++; len++)
                        continue;
 #else FLEXNAMES
                for (from = yytext, len = 0; *from++; len++)
                        continue;
index a2b738e..f66aeb8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *     Copyright (c) 1982 Regents of the University of California
 /*
  *     Copyright (c) 1982 Regents of the University of California
- *     @(#)assyms.h 4.4 %G%
+ *     @(#)assyms.h 4.5 %G%
  */
 /*
  *     To speed up walks through symbols defined in a particular
  */
 /*
  *     To speed up walks through symbols defined in a particular
@@ -32,10 +32,7 @@ extern       int     hshused;                /*how many hash slots used*/
            walkpointer = * ++ copointer)
 /*
  *     Symbols are allocated in non contiguous chunks by extending
            walkpointer = * ++ copointer)
 /*
  *     Symbols are allocated in non contiguous chunks by extending
- *     the data area.  This way, it is extremely easy to
- *     allow virtual memory temporary files, change the length
- *     of NCPS, and allows for a much more flexible storage
- *     allocation
+ *     the data area.
  */
 
 #define SYMDALLOP      200
  */
 
 #define SYMDALLOP      200
@@ -45,10 +42,8 @@ struct       allocbox{
 };
 
 /*
 };
 
 /*
- *     Names are allocated in a string pool.  String pools are linked
- *     together and are allocated dynamically by Calloc.
+ *     Names are allocated in a dynamically extensible string pool.
  */
  */
-#define        STRPOOLDALLOP   NCPS
 struct strpool{
        struct  strpool *str_next;
        int             str_nalloc;
 struct strpool{
        struct  strpool *str_next;
        int             str_nalloc;