Google
 

Trailing-Edge - PDP-10 Archives - BB-AE97C-BM - sources/lincl.bli
There are 10 other files named lincl.bli in the archive. Click here to see a list.
 %TITLE 'LINCL - INCLUDE line-mode command'
MODULE LINCL (				! Line-mode INCLUDE command
		IDENT = '3-004'			! File: LINCL.BLI Edit: CJG3004
		) =
BEGIN
!
!			  COPYRIGHT (c) 1981, 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 module executes the line mode INCLUDE command.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: February 3, 1978
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 30-JAN-1981.  This module was created by
!	extracting the routine EDT$$INCL_CMD  from the module EXEC.BLI.
! 1-002	- Change from IO_STS and IO_FNF to IOFI_NFND .
!	   JBS 19-Feb-1981
! 1-003	- Fix module name.  JBS 20-Mar-1981
! 1-004	- Use new message codes.  JBS 04-Aug-1981
! 1-005 - Change I/O calls to use EDT$FILEIO. STS 26-Dec-1981
! 1-006 - Change call to fileio to callfio. STS 06-Jan-1982
! 1-007 - Fix DSC$A_POINTER macro. STS 14-Jan-1982
! 1-008 - Add rhb descr. definitions. STS 22-Jan-1982
! 1-009 - Add a return value for line insertion success.  SMB 3-Feb-1982
! 1-010 - Deallocate dynamic descriptors. STS 10-Feb-1982
! 1-011 - Pass filename to edt$$fiopn_err. STS 25-Feb-1982
! 1-012 - Add literals for callable parameters. STS 08-Mar-1982
! 1-013	- File I/O routines return a status.  JBS 26-Mar-1982
! 1-014	- Correct a typo in edit 1-013.  JBS 29-Mar-1982
! 1-015	- Print a message on a CLOSE error.  JBS 12-Apr-1982
! 1-016 - Change PDP-11 filenames to uppercase.  SMB 19-Apr-1982
! 1-017 - Add error message for no filename.  SMB 21-Apr-1982
! 1-018	- Check for record too long.  JBS 02-Jun-1982
! 1-019	- Pass default name in RHB parameter.  JBS 15-Jun-1982
! 1-020 - Add control C checking.  SMB 30-Jun-1982
! 1-021 - Stop processing on bad select range.  SMB 01-Jul-1982
! 1-022	- Set SCR_CHGD if the screen is changed.  JBS 07-Jul-1982
! 1-023 - Change names of include file messages.  SMB 13-Jul-1982
! 1-024 - Print out error messages on GETs. STS 20-Jul-1982
! 1-025 - Don't check RMS status on 11's since error message has
!	   already been printed. STS 22-Jul-1982
! 1-026	- Don't set EDT$$G_SCR_CHGD, new screen logic doesn't need it.  JBS 09-Oct-1982
! 1-027 - Put edt$$rng_posfrst in line. STS 11-Oct-1982
! 3-001 - Don't need RHB code on TOPS20. CJG 19-Apr-1983
! 3-002 - Remove call to EDT$$CALLFIO. CJG 10-Jun-1983
! 3-003 - Change the way that filespecs are handled. CJG 23-Jun-1983
! 3-004 - Fix loss of filespec length. CJG 8-Jul-1983
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$INCL_CMD : NOVALUE;			! Process the INCLUDE command

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!
! EQUATED SYMBOLS:
!
!	NONE
!
! LITERALS
!

EXTERNAL LITERAL
    EDT$K_OPEN_INPUT,
    EDT$K_CLOSE,
    EDT$K_GET,
    EDT$K_INCLUDE_FILE;

!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$INCL_CMD  - Line mode INCLUDE command'

GLOBAL ROUTINE EDT$$INCL_CMD 			! Line mode INCLUDE command
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Command processing routing for the INCLUDE command.  Attempt to open the file.
!	If it succeeds then position as indicated by the range and read the file
!	into the buffer in front of that line.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	EXE_CURCMD
!
! IMPLICIT OUTPUTS:
!
!	TXT_ONSCR
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	Reads a text file into the work file system, or prints an error message.
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$FILEIO,
	EDT$$STOP_WKINGMSG,
	EDT$$CHK_CC,
	EDT$$FMT_MSG,
	EDT$$RNG_REPOS,
	EDT$$END_INS,
	EDT$$INS_LN,
	EDT$$START_INS,
	EDT$$FIOPN_ERR;

    EXTERNAL
    	RNG_FRSTLN,
    	CUR_BUF : REF TBCB_BLOCK,
    	RNG_ORIGPOS : POS_BLOCK,
	IO_FNAM,
	INC_NAM : BLOCK,		! Include file descriptor block
	CC_DONE,			! CNTRL/C aborted the command
	IOFI_NFND,			! File not found flag
	EXE_CURCMD : REF NODE_BLOCK,	! Pointer to the current command.
	TXT_ONSCR;			! Force "press return to continue" if under EXT

    MESSAGES ((INCFILNEX, ERRINPFIL, INCFILOPN, INCFILCLO, NOFILSPC, RECTOOBIG));

    LOCAL
	FILE_DESC : BLOCK [1],
	GET,
	STATUS,
	RECORD_TOO_BIG;


    RECORD_TOO_BIG = 0;
!+
! File specification must be given for INCLUDE
!-

    IF (.EXE_CURCMD [FSPCLEN] EQL 0)
    THEN
	BEGIN
	EDT$$FMT_MSG (EDT$_NOFILSPC);
	RETURN (0);
	END;
!+
! Open the file.
!-

    INC_NAM [DSC$A_POINTER] = .EXE_CURCMD [FILSPEC];
    INC_NAM [DSC$W_LENGTH]  = .EXE_CURCMD [FSPCLEN];
    STATUS = EDT$FILEIO (EDT$K_OPEN_INPUT, EDT$K_INCLUDE_FILE, INC_NAM);

    IF .STATUS
    THEN
	BEGIN
!+
! File was opened.  Position to start of the range.
!-

    	RNG_FRSTLN = 1;
    	EDT$$CPY_MEM( POS_SIZE, .CUR_BUF, RNG_ORIGPOS);
	IF ( NOT EDT$$RNG_REPOS (.EXE_CURCMD [RANGE1])) THEN RETURN (0);

!+
! Insert all the lines from the file at the current position.
!-
	EDT$$START_INS ();
	STATUS = 1;

	WHILE (.STATUS NEQ 0) DO
	    BEGIN
	    GET = EDT$FILEIO (EDT$K_GET, EDT$K_INCLUDE_FILE, FILE_DESC);

	    IF ( NOT .GET) THEN EXITLOOP;

	    IF (EDT$$CHK_CC ())
	    THEN
		BEGIN
		STATUS = EDT$FILEIO (EDT$K_CLOSE, EDT$K_INCLUDE_FILE, 0);

		IF ( NOT .STATUS) THEN EDT$$FIOPN_ERR (EDT$_INCFILCLO, INC_NAM);

		CC_DONE = 1;
		RETURN (0);
		END;

	    IF (.FILE_DESC [DSC$W_LENGTH] GTR 255) THEN RECORD_TOO_BIG = 1;

	    STATUS = EDT$$INS_LN (CH$PTR (.FILE_DESC [DSC$A_POINTER],, BYTE_SIZE),
		 MIN (.FILE_DESC [DSC$W_LENGTH], 255));
	    END;

	EDT$$END_INS ();
!+
! And close the file.
!-
	EDT$$STOP_WKINGMSG ();
	STATUS = EDT$FILEIO (EDT$K_CLOSE, EDT$K_INCLUDE_FILE, 0);

	IF ( NOT .STATUS) THEN EDT$$FIOPN_ERR (EDT$_INCFILCLO, INC_NAM);

	END
    ELSE
	BEGIN
!+
! The open failed, put out an error message.
!-
	EDT$$FIOPN_ERR (

	    IF .IOFI_NFND THEN EDT$_INCFILNEX ELSE EDT$_INCFILOPN, INC_NAM);

	END;

!+
! If we print the message "record too big" then force "press return to continue",
! since the message would otherwise be lost in the update of the screen that we
! must do.
!-

    IF .RECORD_TOO_BIG
    THEN
	BEGIN
	EDT$$FMT_MSG (EDT$_RECTOOBIG);
	TXT_ONSCR = 1;
	END;


    END;					! of routine EDT$$INCL_CMD


END
ELUDOM