C+
C NAME:
C	ParseRepair
C PURPOSE:
C	Deconstruct file names into components
C CALLING SEQUENCE:
	subroutine ParseRepair(FileSpec,iDir,iNam)
C INPUTS:
C OUTPUTS:
C CALLS:
C	LocFirst, Str2StrSet, Str2Str
C INCLUDE:
	include 	'filparts.h'
	include		'dirspec.h'
	include		'str2str_inc.h'
C PROCEDURE:
C MODIFICATION HISTORY:
C	JUN-1995, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	FileSpec(FIL__NPARTS)*(FIL__LENGTH)
	    integer	iDir
	    integer	iNam

	integer		Str2Str
	integer		Str2StrSet

	!-------
	! Change `....]' to `[....]'

	if (cOpSys .eq. OS__VMS) then
	    if (iDir .ne. 0 .and. LocFirst(cLead,FileSpec(FIL__DIRECTORY)) .eq. 0) then
		FileSpec(FIL__DIRECTORY) = cLead//FileSpec(FIL__DIRECTORY)
		iDir = iLead+iDir
	    end if

	    !-------
	    ! Change `[....' to `[....]'

	    if (LocFirst(cLead,FileSpec(FIL__NAME)) .eq. 1) then
	        iStr = Str2StrSet(STR__TRIM)
		iDir = 0
		iDir = iDir+Str2Str(FileSpec(FIL__NAME),FileSpec(FIL__DIRECTORY)(iDir+1:))
		iDir = iDir+Str2Str(cTrail,FileSpec(FIL__DIRECTORY)(iDir+1:))
		iStr = Str2StrSet(iStr)
		FileSpec(FIL__NAME) = ' '
		iNam = 0
	    end if

	    !-------
	    ! Remove `]['

	    I = LocFirst(cTrail//cLead,FileSpec(FIL__DIRECTORY))
	    if (I .ne. 0) then
		FileSpec(FIL__DIRECTORY)(I:) = FileSpec(FIL__DIRECTORY)(I+iTrail+iLead:)
		iDir = iDir-iTrail-iLead
	    end if

	end if

	!-------
	! Change `.]' to `]'

	if (iDir .ge. 2 .and. LocFirst(cDivide//cTrail,
     &		FileSpec(FIL__DIRECTORY)) .eq. iDir-iTrail-iDivide+1) then
	    FileSpec(FIL__DIRECTORY)(iDir-iTrail-iDivide+1:) = cTrail
	    iDir = iDir+iDivide
	end if

	if (bNoRoot) then

	    !-------
	    ! Change `[000000.' to `['

	    iR = iLeadRootDivide
	    if (iDir .gt. iLeadRootDivide .and.
     &		FileSpec(FIL__DIRECTORY)(:iLeadRootDivide) .eq. cLeadRootDivide) then
		FileSpec(FIL__DIRECTORY)(iLead+1:) = FileSpec(FIL__DIRECTORY)(iLeadRootDivide+1:)
		iDir = iDir-iRootDivide
	    end if
	end if

	return
	end
