Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/fixver.mid
There are no other files named fixver.mid in the archive.
TITLE FIXVER
SUBTTL MRC

; Fix versions of files from the date-edit line

.DECSAV

EVEC:	JRST FIXVER
	JRST FIXVER
	.FVERS
EVECL==.-EVEC

A=1 ? B=2 ? C=3 ? D=4 ? P=17

PDLLEN==10.

DEFINE TMSG STRING
 HRROI A,[ASCIZ\STRING\]
 PSOUT%
TERMIN

DEFINE INS ?VALUE,MASK
 <.DPB VALUE,<.BP MASK>> TERMIN

CALL=PUSHJ P,
RET=POPJ P,

FIXVER:	RESET
	MOVE P,[PDL(-PDLLEN)]
	TMSG [Files to process: ]
	MOVSI A,(GJ%OLD\GJ%CFM\GJ%IFG\GJ%FLG\GJ%FNS\GJ%SHT)
	MOVE B,[.PRIIN,,.PRIOU]
	GTJFN%			; get JFN on filespec user wants
	 ERJMP [TMSG [
?]
		CALL ERMSG
		TMSG [
]
		JRST FIXVER]
	MOVEM A,JFN		; save JFN, including flags
	CAIA
LOOP:	 GNJFN%			; get next file in specification
	  ERJMP [TMSG [All done]
		 HALTF%
		 JRST FIXVER]
	HRROI A,FILE		; save its name in a convenient place
	HRRZ B,JFN
	MOVE C,[<INS .JSAOF,JS%DEV>\<INS .JSAOF,JS%DIR>\<INS .JSAOF,JS%NAM>\<INS .JSAOF,JS%TYP>\<INS .JSAOF,JS%GEN>\JS%PAF]
	SETZ D,
	JFNS%
	 ERCAL LOSE
	HRROI A,NFILE		; get the name, without the generation
	HRRZ B,JFN
	MOVE C,[<INS .JSAOF,JS%DEV>\<INS .JSAOF,JS%DIR>\<INS .JSAOF,JS%NAM>\<INS .JSAOF,JS%TYP>\JS%PAF]
	JFNS%
	 ERCAL LOSE
	MOVEM A,GENPNT
	HRROI A,FILE		; show the file name
	PSOUT%
	HRRZ A,JFN		; open up the file
	MOVE B,[<INS 7,OF%BSZ>\OF%RD]
	OPENF%
	 JRST [	TMSG [ cannot be opened - ]
		CALL ERMSG
		JRST NXTFIL]
	BIN%			; get first character of file
	CAIE B,"!
	 CAIN B,";		; expect semicolon
	  CAIA
	   JRST [TMSG [ does not look like a date-edited file]
		 JRST CLZFIL]
	MOVEI D,100.		; this many characters before giving up
				; lots more because of possible host prefix
FNDNAM:	BIN%			; find file name
	CAIE B,">		; found end of directory yet?
	 SOJG D,FNDNAM		; no, keep on searching
	JUMPLE D,[TMSG [ unable to find file name]
		  JRST CLZFIL]
	MOVEI D,80.		; this many filename characters before punting
FNDEXT:	BIN%			; find extension
	CAIE B,".
	 SOJG D,FNDEXT
	JUMPLE D,[TMSG [ unable to find extension]
		  JRST CLZFIL]
	MOVEI D,80.		; this many extension characters before punting
FNDGEN:	BIN%			; find generation
	CAIN B,";		; perhaps this was edited on Tenex...sigh
	 MOVEI B,".
	CAIE B,".
	 SOJG D,FNDGEN
	JUMPLE D,[TMSG [ unable to find generation]
		  JRST CLZFIL]
	IDPB B,GENPNT		; insert delimiter
GENLUP:	BIN%			; get a character of generation
	CAIL B,"0		; numeric?
	 CAILE B,"9
	  JRST GENDUN
	IDPB B,GENPNT		; yes, insert in string
	JRST GENLUP

GENDUN:	CAIE B,^I		; insist upon tab, space, or comma
	 CAIN B,<" >
	  JRST GENOK
	CAIE B,",
	 JRST [	TMSG [ has crufty character "]
		MOVEI A,(B)
		PBOUT%
		TMSG [" in generation number]
		JRST CLZFIL]
GENOK:	SETZ B,			; tie off the name with a null
	IDPB B,GENPNT
	TMSG [ => ]
	HRROI A,NFILE
	PSOUT%
	HRROI A,FILE		; compare two strings
	HRROI B,NFILE
	STCMP%
	JUMPN A,RENFIL		; strings are different, maybe rename
	TMSG [ [Same]]
CLZFIL:	MOVSI A,(CO%NRJ)	; close file, don't release JFN
	HRR A,JFN
	CLOSF%
	 ERCAL LOSE
NXTFIL:	TMSG [
]
	MOVE A,JFN		; get JFN back
	JRST LOOP		; do next file

RENFIL:	TLNN A,(SC%GTR)		; is this to a lower generation?
	 JRST [	TMSG [ [Ok]
]
		JRST RENDO]
	TMSG [ Ok?]
RENFL1:	PBIN%			; get confirmation character
	CAIN A,^M		; ignore CR
	 JRST RENFL1
	CAIN A,^J		; LF means yes too
	 JRST RENDO
	CAIE A,"Y
	 CAIN A,"y
	  CAIA
	   JRST CLZFIL
	TMSG [es
]
RENDO:	MOVSI A,.GFAUT		; get author string
	HRR A,JFN
	HRROI B,AUTHOR
	GFUST%
	 ERCAL LOSE
	MOVSI A,.GFLWR		; get last writer string
	HRR A,JFN
	HRROI B,WRITER
	GFUST%
	 ERCAL LOSE
	MOVSI A,(CO%NRJ)	; close file, don't release JFN
	HRR A,JFN
	CLOSF%
	 ERCAL LOSE
	MOVSI A,(GJ%NEW\GJ%SHT)	; get a JFN on new file
	HRROI B,NFILE
	GTJFN%
	 ERJMP RNMERR
	MOVE A			; remember this JFN
	MOVSI A,(GJ%OLD\GJ%SHT)	; get a second JFN on old file due to RNAMF%
	HRROI B,FILE		; misfeature which releases the JFN
	GTJFN%
	 ERJMP RNMERR
	MOVE B,			; get new JFN back
	RNAMF%			; try to do the rename
	 ERJMP RNMERR
	MOVSI A,.SFAUT		; set author string
	HRR A,
	HRROI B,AUTHOR
	SFUST%
	 ERCAL [TMSG [%Set author failed - ]
		CALL ERMSG
		TMSG [
]
		RET]
	MOVSI A,.SFLWR		; set last writer string
	HRR A,
	HRROI B,WRITER
	SFUST%
	 ERCAL [TMSG [%Set last writer failed - ]
		CALL ERMSG
		TMSG [
]
		RET]
	MOVE A,			; release the new JFN
	RLJFN%
	 ERCAL LOSE
	MOVE A,JFN		; get JFN back
	JRST LOOP		; do next file

RNMERR:	TMSG [%Rename failed - ]
	CALL ERMSG
	TMSG [
]
	MOVE A,JFN		; go to next file
	JRST LOOP

; Here on fatal lossage

LOSE:	TMSG [
?]
	CALL ERMSG
	TMSG [, JSYS at PC=]
	MOVEI A,.PRIOU		; output the PC
	POP P,B
	SUBI B,2		; point PC at actual location of the JSYS
	MOVE C,[NO%MAG\8.]
	NOUT%
	 JRST 4,.-1		; this can't happen
	HALTF%
	JRST FIXVER

ERMSG:	MOVEI A,.PRIOU		; output message for last error
	HRLOI B,.FHSLF
	SETZ C,
	ERSTR%
	 NOP
	 NOP
	RET

	CONSTANTS

JFN:	BLOCK 1			; JFN for files being worked on
AUTHOR:	BLOCK 8.		; author string
WRITER:	BLOCK 8.		; last writer word
FILE:	BLOCK 20.		; name of file being worked on
NFILE:	BLOCK 20.		; new name of the file
GENPNT:	BLOCK 1			; pointer to where generation will go
PDL:	BLOCK PDLLEN		; stack

END EVECL,,EVEC