Article 8581 of alt.sources:
Xref: mv alt.sources:8581
Path: mv!news.NH.Destek.Net!news.emi.com!uunet!in3.uu.net!nntp04.primenet.com!nntp.primenet.com!newspump.sol.net!uwm.edu!news.cse.psu.edu!news.math.psu.edu!ra.nrl.navy.mil!mitch.nrl.navy.mil!grunes
From: grunes@news.nrl.navy.mil (Mitchell R Grunes)
Newsgroups: alt.sources
Subject: expndtab: Tab to blank converter and trailing blank kill
Date: 29 Aug 1996 13:26:33 GMT
Organization: AlliedSignal Technical Services Corp.
Lines: 54
Message-ID: <grunes.429.0@news.nrl.navy.mil>
NNTP-Posting-Host: mitch.nrl.navy.mil

Archive-name: expndtab
Submitted-by: grunes@ssdd.nrl.navy.mil (Mitchell R Grunes)

********expndtab: Tab to blank converter and trailing blank kill********

If you like or dislike it, send e-mail.  DON'T POST to alt.sources.
Bug reports must include sample files on which it failed.

CONTENTS:
   expndtab.for     Fortran language source code.
---expndtab.for--------------CUT HERE-----------------------------
c Program by Mitchell R Grunes to expand tabs to spaces.
c It also removes trailing blanks, and trailing blank lines.
c This program was written in FORTRAN, for historic reasons.
        program ExpndTab
        character*80 name
        character*255 a,b
        print*,'Input file name:'
        read(*,'(a80)')name
        print*,name
        open(1,file=name,status='old')
        print*,'Output file name:'
        read(*,'(a80)')name
        print*,name
        open(2,file=name,status='new')
        nBlank=0
1       read(1,'(a255)',end=99)a
        b=' '                                   ! expand tabs
        j=1
        jmax=0
        do i=1,255
          if(a(i:i).eq.char(9))then
            j=(j-1)/8*8+8+1
          else if(j.le.255)then
            b(j:j)=a(i:i)
            if(a(i:i).ne.' ')jmax=j             ! last non-blank
            j=j+1
          end if
        end do
        if(b.eq.' ')then                        ! count blank lines
          nBlank=nBlank+1
        else                                    ! not blank--write
          do i=1,nBlank                         !   prior blank lines
            write(2,'(a1)')
          enddo
          nBlank=0
          write(2,'(255a1)')(b(i:i),i=1,jmax)   !   tab expanded output
        endif
        goto 1
99      end
-----------------------------CUT HERE-----------------------------
-------------------------------------------------------------------------
Mitchell R Grunes, grunes@nrlvax.nrl.navy.mil.  Opinions are mine alone.



