Google
 

Trailing-Edge - PDP-10 Archives - BB-R775E-BM - sources/edt/edt.bli
There are 11 other files named edt.bli in the archive. Click here to see a list.
%TITLE	'EDT - STARTUP MODULE'
MODULE EDT (
		IDENT = '1-005',		! File: EDT.B36 Edit: GB1005
		MAIN = EDIT$,
		VERSION = '1(34)'		! EDT's version number
		) =
BEGIN
!
!			  COPYRIGHT (c) 1984, 1985 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!		ALL RIGHTS RESERVED.
!
! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
! ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE
! INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER
! COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
! OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
! TRANSFERRED.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE
! AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT
! CORPORATION.
!
! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!

!++
! FACILITY:	EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
!	This is the startup module for EDT
!
! ENVIRONMENT:	Runs on TOPS20
!
! AUTHOR: Chris Gill, CREATION DATE: 13-Jun-1983
!
! MODIFIED BY:
!
! 1-001 - Original. This module was created by combining MAIN and STARTEDT
!	  both modified for TOPS20 operation. CJG 13-Jun-1983
! 1-002 - Move EDT$$PA_CMDLN to INIT to prevent parsed data being lost. CJG 27-Jun-1983
! 1-003 - Deal with the CREATE command (EDT$M_NEWFILE). CJG 12-Jul-1983
! 1-004 - Add EDT$$GET_LOGDIR so that we search the login directory. CJG 7-Oct-1983
! 1-005 - Add a VERSION parameter to the MODULE declaration. GB 19-Jul-1984
!--

%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDIT$;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!

!<BLF/FORMAT>
!
! EQUATED SYMBOLS:
!

EXTERNAL LITERAL
    EDT$M_NOCREATE,
    EDT$M_NOJOURNAL,
    EDT$M_COMMAND,
    EDT$M_NOCOMMAND,
    EDT$M_NEWFILE,
    EDT$K_OPEN_IN_OUT,
    EDT$K_OPEN_INPUT,
    EDT$K_INPUT_FILE,
    EDT$K_JOURNAL_FILE,
    EDT$K_OPEN_OUTPUT_NOSEQ,
    EDT$K_COMMAND_FILE,
    EDT$K_CLOSE;

!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
! Inside the routine.
!-
%SBTTL 'EDIT$ - set up and call EDT'
ROUTINE EDIT$ 				! set up and call EDT
    =

!++
! FUNCTIONAL DESCRIPTION:
!
!	The main entry point for the editor.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	NONE
!
! IMPLICIT OUTPUTS:
!
!	INP_NAM
!	OUT_NAM
!	CMD_NAM
!	COM_NAM
!	JOU_NAM
!	LASTMSG
!	CMD_BUF
!	CMD_END
!
! ROUTINE VALUE:
!
!	Normally 1 or EDT$_EDITORABO
!
! SIDE EFFECTS:
!
!	Performs an edit.
!
! NOTES:
!
!	OPTIONS
!		bit 0 = /RECOVER
!		bit 1 = /COMMAND
!		bit 2 = /NOJOURNAL
!		bit 3 = /NOOUTPUT
!		bit 4 = /NOCOMMAND
! 		bit 5 = /NOCREATE
!		bit 6 = CREATE command
!--

    BEGIN


    EXTERNAL ROUTINE
	EDT$$SYS_EXI,			! Return to system (with status)
	EDT$FILEIO,			! Perform file io
	EDT$$EXE_CMD,			! Execute a command
	EDT$$TERMIN_RCOVMOD : NOVALUE,	! Handle end of journal file during /RECOVER
	EDT$$INIT,			! Do the initial processing
	EDT$$TERMIN,			! Do the final processing
	EDT$$FIOPN_ERR : NOVALUE,	! Print a message about a file error, with file name
	EDT$$TY_CURLN,			! Type out the current line
	EDT$$FMT_MSG : NOVALUE,		! Format and print a message
	EDT$$GET_LOGDIR : NOVALUE,	! Get login directory and device
	EDT$$SET_COMFNAM;		! Open and close command files


    EXTERNAL
	CMD_NAM : BLOCK,		! Command file name
	OUT_NAM : BLOCK,		! Output file name
	INP_NAM : BLOCK,		! input file name
	JOU_NAM : BLOCK,		! Name of journal file
	CMD_NAM_DEF1 : REF BLOCK,	! First default command spec
	CMD_NAM_DEF2 : REF BLOCK,	! Second default command spec
	CMD_DFLT : REF BLOCK,		! Alternative form of CMD_NAM_DEF2
	EXITD,				! Did we exit with the last command?
	RCOV_MOD,			! do a recovery flag
	EDIT_MOD,			! Current editing mode
	EDIT_DFLTMOD,			! Default editing mode
	FNF_MSGFLG,			! File not found message flag
	IOFI_NFND,			! 1 = open failed due to file not found
	OPTIONS : BITVECTOR [36],	! Options bits
	LASTMSG,			! Message for change mode to print
	CMD_PTR,			! Pointer to current location in command buffer
	CMD_BUF,			! Command buffer
	CMD_END,			! Pointer to end of command buffer
	CC_DONE;			! 1 = control C actually aborted something

    MESSAGES ((COMFILNEX, COMFILNOP, COMFILCLO, NOJNLFIL, INPFILNEX,
	ABOBYCC, CTRC__IGN, EDITORABO));

    LOCAL
	STATUS,
	PRIMARY_FILE_CONDITION,
	STRING_LENGTH;

!+
! Do the initial processing.
!-

    PRIMARY_FILE_CONDITION = EDT$$INIT ();

!+
! If initialization failed, abort right now.
!-

    IF (.PRIMARY_FILE_CONDITION EQL 3) THEN EDT$$SYS_EXI (EDT$_EDITORABO);

!+
! If /NOCREATE was specified then exit if file was not found
!-

    IF ((.PRIMARY_FILE_CONDITION EQL 0) AND ((.OPTIONS AND EDT$M_NOCREATE) NEQ 0))
    THEN
	BEGIN
	IF .FNF_MSGFLG THEN EDT$$FMT_MSG (EDT$_INPFILNEX);
	EDT$$SYS_EXI (-1);
	END;

!+
! Open the journal file.  If recovery was specified, open it so we can read
! from it.
!-

    IF .RCOV_MOD
    THEN
	BEGIN
	STATUS = EDT$FILEIO (EDT$K_OPEN_IN_OUT, EDT$K_JOURNAL_FILE, JOU_NAM);

	IF ( NOT .STATUS)
	THEN
	    BEGIN
	    EDT$$FIOPN_ERR (EDT$_NOJNLFIL, JOU_NAM);
	    EDT$$SYS_EXI (EDT$_NOJNLFIL);
	    END;

	END
    ELSE
!+
! We are not in recovery mode; just open the journal file for write.
!-

	IF ((.OPTIONS AND EDT$M_NOJOURNAL) EQL 0)	! NOT /NOJOURNAL
	THEN
	    BEGIN
	    STATUS = EDT$FILEIO (EDT$K_OPEN_OUTPUT_NOSEQ, EDT$K_JOURNAL_FILE, JOU_NAM);
	    END;

!+
! Make sure the journal file was opened.
!-

    IF (( NOT .STATUS) AND (.OPTIONS AND EDT$M_NOJOURNAL) EQL 0)
    THEN
	BEGIN
	EDT$$FIOPN_ERR (EDT$_NOJNLFIL, JOU_NAM);
	EDT$$SYS_EXI (EDT$_NOJNLFIL);
	END;

!+
! Execute the startup file, if one was provided.  The startup file is always executed
! in line mode.
!-
    EDIT_MOD = LINE_MODE;

    IF ((.OPTIONS AND EDT$M_NOCOMMAND) EQL 0)
    THEN
	BEGIN

	IF (.CMD_NAM [DSC$W_LENGTH] EQL 0)
	THEN
	    BEGIN
!+
! No command file name was provided, use the default.  Note that there are
! two default names; if the first is not found we try the second.
!-
	    STATUS = EDT$$SET_COMFNAM (CMD_NAM_DEF1);

	    IF ( NOT .STATUS)
	    THEN
		BEGIN
		STATUS = EDT$$SET_COMFNAM (CMD_NAM_DEF2);

		IF ( NOT .STATUS)
		THEN
		    BEGIN
		    EDT$$GET_LOGDIR (CMD_DFLT, CMD_NAM);
		    STATUS = EDT$$SET_COMFNAM (CMD_NAM);
		    END;
		END;
	    END
	ELSE
	    STATUS = EDT$$SET_COMFNAM (CMD_NAM);

	IF .STATUS
	THEN
	    BEGIN

	    IF (EDT$$EXE_CMD (INP_COMMAND) EQL 2)
	    THEN
		BEGIN
!+
! The startup file was terminated by control C.
!-

		IF .CC_DONE THEN EDT$$FMT_MSG (EDT$_ABOBYCC) ELSE EDT$$FMT_MSG (EDT$_CTRC__IGN);

		CMD_PTR = CH$PTR (CMD_BUF, 0, BYTE_SIZE);
		CMD_END = .CMD_PTR;
!+
! Make sure we stay in line mode so the message is visible.
!-
		EDIT_DFLTMOD = LINE_MODE;
		END;

	    END
	ELSE

	    IF ((.OPTIONS AND EDT$M_COMMAND) NEQ 0)
	    THEN
		BEGIN
		EDT$$FIOPN_ERR (IF .IOFI_NFND
				THEN EDT$_COMFILNEX
				ELSE EDT$_COMFILNOP, CMD_NAM);
		EDT$$SYS_EXI (EDT$_COMFILNOP)
		END;

	END;

!+
! Make sure the command file is closed, and the name is null.
!-
    STATUS = EDT$$SET_COMFNAM (0);		! Close the command file

    IF ( NOT .STATUS) THEN EDT$$SYS_EXI (EDT$_COMFILCLO);

!+
! Use the default mode setting.
!-

    EDIT_MOD = .EDIT_DFLTMOD;

!+
! Give an error message if the primary file was not found or does not have standard format.
! unless we are about to enter change mode, in which case defer the message.
! The message is not needed if the original command was CREATE.
!-

    IF ((.OPTIONS AND EDT$M_NEWFILE) EQL 0)
    THEN
	BEGIN

	CASE .PRIMARY_FILE_CONDITION FROM 0 TO 2 OF
	    SET

	    [0] :

		IF (.EDIT_MOD EQL LINE_MODE)
		THEN
		    BEGIN

		    IF .FNF_MSGFLG THEN EDT$$FMT_MSG (EDT$_INPFILNEX);

		    END
		ELSE

		    IF .FNF_MSGFLG THEN LASTMSG = EDT$_INPFILNEX;

	    [1] :
		BEGIN
		0
		END;

	    [2] :
		BEGIN
		0
		END;

	    TES;

	END;

!+
! If we are in recovery mode, execute the remainder of the journal file.
! (Part of the journal file may have been used to respond to SUBSTITUTE/QUERY
! commands in the startup file.)
!-

    IF (.RCOV_MOD)
    THEN
	BEGIN
	IF (EDT$$EXE_CMD (INP_JOURNAL) EQL 2)
	THEN
	    BEGIN
!+
! The recovery process was interrupted by a control C.  Bail out.
!-

	    IF .CC_DONE THEN RETURN (EDT$_ABOBYCC) ELSE EDT$$SYS_EXI (EDT$_CTRC__IGN);

	    END;

	EDT$$TERMIN_RCOVMOD ();
	END;

!+
! If we are in line mode, then print the current line.
!-

    IF (.EDIT_MOD EQL LINE_MODE)
    THEN
	BEGIN
	EDT$$TY_CURLN ();
	END;

!+
! And execute the main stream of commands.
!-

    EDT$$EXE_CMD (INP_TERM);

!+
! Do the finalization processing.
!-

    EDT$$TERMIN ();

    RETURN (1);
    END;					! of routine EDIT$

END						! of module EDT

ELUDOM