D C O M 
 
            Program to compare all files in two libraries to if they 
               are identical 
 
 
 
      str topdir1.80, topdir2.80, dirnames1.120(10000), dirnames2.120(10000) 
      str dircon1.120(1000), dircon2.120(1000), path1.120, path2.120 
      str wk1.120, wk2.120, temp.120 
      str file1.120, file2.120 
      int dir1cnt, dir2cnt 
      int loaddir, readdir
      int i, j, dflag, k 
      int idflag,version 

      idflag = 0 
      putc Program to compare all files in two libraries   
Q0: 
      putc   <return> = fast version 
      putc s <return> = slow version 
      putc x <return> = explanation 

      getc temp 
      temp = trm(temp) 
      if temp = "" 
        version = 0 
        goto Q1 
      end 
      if temp = "s" 
        version = 1 
        goto Q1 
      end 
      if temp = "x" 
        putc The fast version uses a simple disk read to compare files.  This 
        putc method will verify exact matches only.  The comparison will fail 
        putc if records have trailing blanks or if the record terminating   
        putc sequences are different.  (Some files use a simple "line-feed" 
        putc as a terminating sequence rather than the standard 
        putc "line-feed; carriage-return" sequence.  
        putc    
        putc The slow version uses sequencial get-record commands to compare 
        putc files.  This method works only when all of the files to be 
        putc compared are ASCII text files.  
        putc 
      end 
      goto Q0 

Q1:   putc 
      putc First top directory?                 
      getc topdir1 
      topdir1 = trm(topdir1) 
      if topdir1 = "" 
        goto Q1 
      end 

Q1a:  putc 
      putc Second top directory?  
      getc topdir2 
      topdir2 = trm(topdir2) 
      if topdir2 = "" 
        goto Q1 
      end 

      putc 
      putc 

      loaddir = 0 
      readdir = 0 

      perform readdir1 (topdir1) 

      perform readdir2 (topdir2) 

      if topdir1{..} = "/" 
        path1 = topdir1 
      else 
        path1 = topdir1 // "/" 
      end 

      if topdir2{..} = "/" 
        path2 = topdir2 
      else 
        path2 = topdir2 // "/" 
      end 
 
      examine 
 
      loop for i = 1 to dir1cnt 
        k = 0 
        loop for j = 1 to dir2cnt 
          if dircon1(i) = dircon2(j) 
            if dircon1(i){1} = "d" 
              ++loaddir 
              dirnames1(loaddir) = path1 // dircon1(i){3..} 
              dirnames2(loaddir) = path2 // dircon2(j){3..} 
            else 
              file1 = path1 // dircon1(i){3..} 
              file2 = path2 // dircon2(j){3..} 
              if version = 0 
                perform filecom1 (file1, file2) 
              else             
                perform filecom2 (file1, file2) 
              end 
              if dflag = 1 
                putc ~file1  and ~file2  are different   .t95  ...  
                putc 
                idflag = 1 
              end 
            end 
            dircon2(j) = "****2" 
            k = j 
            j = dir2cnt 
          end 
        repeat 
        if k = 0
          temp = path1 // dircon1(i){3..} 
          putc ~temp  is not in ~path2   .t95  ...  
          putc  
          idflag = 1 
        end 
      repeat 
      loop for j = 1 to dir2cnt 
        if dircon2(j) <> "****2" 
          temp = path2 // dircon2(j){3..} 
          putc ~temp  is not in ~path1   .t95  ...  
          putc  
          idflag = 1 
        end 
      repeat 

      readdir = loaddir 
L1: 
      if readdir > 0         
        wk1 = lcs(dirnames1(readdir)) 
        wk2 = lcs(dirnames2(readdir)) 

        wk1 = dirnames1(readdir) 
        wk2 = dirnames2(readdir) 

        perform readdir1 (wk1) 
        perform readdir2 (wk2) 
        path1 = wk1 // "/" 
        path2 = wk2 // "/" 
        --loaddir 

        loop for i = 1 to dir1cnt 
          k = 0 
          loop for j = 1 to dir2cnt 
            if dircon1(i) = dircon2(j) 
              if dircon1(i){1} = "d" 
                ++loaddir 
                dirnames1(loaddir) = path1 // dircon1(i){3..} 
                dirnames2(loaddir) = path2 // dircon2(j){3..} 
              else 
                file1 = path1 // dircon1(i){3..} 
                file2 = path2 // dircon2(j){3..} 
                if version = 0 
                  perform filecom1 (file1, file2) 
                else 
                  perform filecom2 (file1, file2) 
                end 
                if dflag = 1 
                  putc ~file1  and ~file2  are different   .t95  ...  
                  putc 
                  idflag = 1 
                end 
              end 
              dircon2(j) = "****2" 
              k = j 
              j = dir2cnt 
            end 
          repeat 
          if k = 0 
            temp = path1 // dircon1(i){3..} 
            putc ~temp  is not in ~path2   .t95  ...  
            putc  
            idflag = 1 
          end 
        repeat 
        loop for j = 1 to dir2cnt 
          if dircon2(j) <> "****2" 
            temp = path2 // dircon2(j){3..} 
            putc ~temp  is not in ~path1   .t95  ...  
            putc  
            idflag = 1 
          end 
        repeat 

        readdir = loaddir 
        goto L1 
      end 
      putc .t95  ...  
      putc 
      putc .t95  ...  
      putc 
      putc .b27 &a0C.b27 &a-1R...  
      if idflag = 0 
        putc Libraries and all sub-libraries and files therein are identical 
        putc 
      end 
      putc Done!  

      procedure readdir1 (dirname) 
        str dirname.120 
        str line.80, temp1.80, fname.80 

        getvalue dirname 

        dir1cnt = 0 
        open [4,1] dirname 
        loop 
          getf [4] line 

          fname = "" 
          temp1 = line{33..} 
          if line{1,5} = "<dir>" 
            fname = "d-" // temp1 
          else 
            if line{1} = "-" 
              fname = "f-" // temp1 
            end 
          end 
          if fname <> "" 
            ++dir1cnt 
            dircon1(dir1cnt) = fname 
          end 
        repeat 
eof4: 
        close [4] 
      return 

      procedure readdir2 (dirname) 
        str dirname.120 
        str line.80, temp1.80, fname.80 

        getvalue dirname 

        dir2cnt = 0 
        open [5,1] dirname 
        loop 
          getf [5] line 

          fname = "" 
          temp1 = line{33..} 
          if line{1,5} = "<dir>" 
            fname = "d-" // temp1 
          else 
            if line{1} = "-" 
              fname = "f-" // temp1 
            end 
          end 
          if fname <> "" 
            ++dir2cnt 
            dircon2(dir2cnt) = fname 
          end 
        repeat 
eof5: 
        close [5] 
      return 

      procedure filecom1 (f1, f2) 
        int f1z, f2z 
        str f1.120, f2.120 
        str buffer1.100000, buffer2.100000 
        int size,loc 

        getvalue f1, f2 

        putc Comparing files ~f1   .t95  ...  
        putc 
        putc             and ~f2   .t95  ...  
        putc .b27 &a0C.b27 &a-1R...  

        dflag = 0 
        open [1,5] f1 
        f1z = sze 
        open [2,5] f2 
        f2z = sze 

        if f1z <> f2z 
          dflag = 1 
          close [1] 
          close [2] 
          return 
        end 

        size = f1z 
        loc = 1 
        if size = 0 
          close [1] 
          close [2] 
          return 
        end 
RE: 
        if size > 100000 
          len(buffer1) = 100000 
          len(buffer2) = 100000 
        else 
          len(buffer1) = size  
          len(buffer2) = size  
        end 
        read [1,loc] buffer1 
        read [2,loc] buffer2 
        if buffer1 <> buffer2 
          dflag = 1 
          close [1] 
          close [2] 
          return 
        end 
        size -= 100000 
        loc += 100000 
        if size > 0 
          goto RE 
        end 
        close [1] 
        close [2] 
      return 

      procedure filecom2 (f1, f2) 
        str f1.120, f2.120 
        str rec1.500, rec2.500   
        int endflag 

        getvalue f1, f2 

        putc Comparing files ~f1   .t95  ...  
        putc 
        putc             and ~f2   .t95  ...  
        putc .b27 &a0C.b27 &a-1R...  

        dflag = 0 
        open [1,1] f1 
        open [2,1] f2 

        endflag = 0 
GETF1: 
        getf [1] rec1 
GETF2: 
        getf [2] rec2 
        rec1 = trm(rec1) 
        rec2 = trm(rec2) 
        if rec1 <> rec2 
          dflag = 1 
          close [1] 
          close [2] 
          return 
        end 
        goto GETF1 

eof1:   if endflag <> 0 
          dflag = 1 
          close [1] 
          close [2] 
          return 
        end 
        endflag = 1 
        getf [2] rec2 
        dflag = 1 
        close [1] 
        close [2] 
        return 
eof2: 
        if endflag <> 1 
          dflag = 1 
        end 
        close [1] 
        close [2] 
      return 

      run