BSD 3 development
[unix-history] / usr / src / cmd / mip / scan.c
index 9d51ffd..d174c87 100644 (file)
@@ -1,4 +1,5 @@
 # include "mfile1"
 # include "mfile1"
+#include <a.out.h>
 # include <ctype.h>
        /* temporarily */
 
 # include <ctype.h>
        /* temporarily */
 
 char yytext[LXTSZ];
 char * lxgcp;
 
 char yytext[LXTSZ];
 char * lxgcp;
 
+int proflg;
+int gdebug;
+#ifndef LINT
+extern int lastloc;
+#endif
 
        /* ARGSUSED */
 mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
 
        register i;
        register char *cp;
 
        /* ARGSUSED */
 mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
 
        register i;
        register char *cp;
-       extern int idebug, bdebug, tdebug, edebug, ddebug, xdebug;
+       extern int idebug, bdebug, tdebug, edebug, ddebug, xdebug, gdebug;
+       int fdef = 0;
 
        for( i=1; i<argc; ++i ){
                if( *(cp=argv[i]) == '-' && *++cp == 'X' ){
 
        for( i=1; i<argc; ++i ){
                if( *(cp=argv[i]) == '-' && *++cp == 'X' ){
@@ -79,9 +86,29 @@ mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
                                case 'x':
                                        ++xdebug;
                                        break;
                                case 'x':
                                        ++xdebug;
                                        break;
+                               case 'P':       /* profiling */
+                                       ++proflg;
+                                       break;
+                               case 'g':
+                                       ++gdebug;
+                                       break;
                                        }
                                }
                        }
                                        }
                                }
                        }
+                       else {
+                       if( *(argv[i]) != '-' ) switch( fdef++ ) {
+                               case 0:
+                               case 1:
+                                       if( freopen(argv[i], fdef==1 ? "r" : "w", fdef==1 ? stdin : stdout) == NULL) {
+                                               fprintf(stderr, "ccom:can't open %s\n", argv[i]);
+                                               exit(1);
+                                       }
+                                       break;
+
+                               default:
+                                       ;
+                               }
+                       }
                }
 
 # ifdef ONEPASS
                }
 
 # ifdef ONEPASS
@@ -907,15 +934,25 @@ lxres() {
        return( -1 );
        }
 
        return( -1 );
        }
 
+int    labelno;
+
 lxtitle(){
        /* called after a newline; set linenumber and file name */
 
        register c, val;
 lxtitle(){
        /* called after a newline; set linenumber and file name */
 
        register c, val;
-       register char *cp;
+       register char *cp, *cq;
 
        for(;;){  /* might be several such lines in a row */
                if( (c=getchar()) != '#' ){
                        if( c != EOF ) ungetc(c,stdin);
 
        for(;;){  /* might be several such lines in a row */
                if( (c=getchar()) != '#' ){
                        if( c != EOF ) ungetc(c,stdin);
+#ifndef LINT
+                       if ( lastloc != PROG) return;
+                       cp = ftitle;
+                       cq = ititle;
+                       while ( *cp ) if (*cp++ != *cq++) return;
+                       if ( *cq ) return;
+                       psline();
+#endif
                        return;
                        }
 
                        return;
                        }
 
@@ -932,6 +969,22 @@ lxtitle(){
                                *cp = c;
                                }
                        *cp = '\0';
                                *cp = c;
                                }
                        *cp = '\0';
+#ifndef LINT
+                       if (ititle[0] == '\0') {
+                               cp = ftitle;
+                               cq = ititle;
+                               while ( *cp )  
+                                       *cq++ = *cp++;
+                               *cq = '\0';
+                               *--cq = '\0';
+                               for ( cp = ititle+1; *(cp-1); cp += 8 ) {
+                                       pstab(cp, N_SO);
+                                       if (gdebug) printf("0,0,LL%d\n", labelno);
+                                       }
+                               *cq = '"';
+                               printf("LL%d:\n", labelno++);
+                               }
+#endif
                        }
                }
        }
                        }
                }
        }