Google
 

Trailing-Edge - PDP-10 Archives - BB-R775C-BM - sources/maccal.bli
There are 10 other files named maccal.bli in the archive. Click here to see a list.
 %TITLE 'MACCAL - macro call'
MODULE MACCAL (				! Macro call
		IDENT = '3-003'			! File: MACCAL.BLI Edit: GB3003
		) =
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:
!
!	Macro call
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: 6-AUG-1979
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 18-FEB-1981.  This module was created by
!	extracting routine EDT$$MAC_CALL  from module EDTCTR.
! 1-002	- Regularize headers and fix file and module name.  JBS 04-Mar-1981
! 1-003	- Remove L_LINE.  JBS 01-Oct-1981
! 1-004 - Replace L_LINE. TMV 7-Dec-81
! 1-005	- Add an entry point so that EDT$$EXE_CMD_NOOVERLAY can
!	   get this mdoule back into memory after a macro has been executed.  JBS 10-Mar-1982
! 1-006	- Save and restore the command line over a macro call, so another
!	   command can be after the macro name.  JBS 03-Jun-1982
! 1-005	- Add an entry point so that EDT$$EXE_CMD_NOOVERLAY cat
!	   get this mdoule back into memory after a macro has been executed.  JBS 10-Mar-1982
! 1-006	- Save and restore the command line over a macro call, so another
!	   command can be after the macro name.  JBS 03-Jun-1982
! 1-007 - See if a control C was found and reset command buffer. STS 16-Jul-1982
! 3-001 - Make a proper string ptr to CMD_TEXT.  GB 3-Mar-1983
! 3-002 - Don't need overlay code. CJG 17-Apr-1983
! 3-003 - Add updates from V3 sources. GB 03-May-1983
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$MAC_CALL : NOVALUE;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$MAC_CALL  - macro call'

GLOBAL ROUTINE EDT$$MAC_CALL (			! Macro call
    MAC						! Address of the macro
    ) : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Call a macro.  A macro is a buffer which contains line-mode
!	commands.
!
! FORMAL PARAMETERS:
!
!  MAC			Address of the macro
!
! IMPLICIT INPUTS:
!
!	CUR_BUF
!	MAC_BUF
!	CMD_BUF
!	CMD_LEN
!	CMD_PTR
!	CMD_END
!
! IMPLICIT OUTPUTS:
!
!	CUR_BUF
!	MAC_BUF
!	CMD_BUF
!	CMD_END
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	Saves and restores the command line.
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$EXE_CMD,
	EDT$$RD_CURLN : NOVALUE,
	EDT$$TOP_BUF : NOVALUE,
	EDT$$ALO_HEAP,				! Allocate heap storage
	EDT$$DEA_HEAP : NOVALUE,		! Deallocate heap storage
	EDT$$FMT_MSG : NOVALUE;			! Format a message

    EXTERNAL
    	CC_DONE,
	CUR_BUF,				! Current tbcb
	CMD_LEN,
	CMD_BUF,
	MAC_BUF,				! Current macro buffer pointer
	CMD_PTR,				! Pointer to the current command
	CMD_END;				! End of the current command

    LOCAL
    	STATUS,
	SAVE_TBCB,
	SAVE_MACRO,
	SAVE_CMD_BUF,
	SAVE_CMD_END,
	CMD_TEXT : REF VECTOR,
	CMD_LENGTH;

    MESSAGES ((INSMEM));
!+
! Save the current command line.
!-
    SAVE_CMD_BUF = .CMD_PTR;
    SAVE_CMD_END = .CMD_END;
    CMD_LENGTH = CH$DIFF (CH$PLUS (.SAVE_CMD_END, 1), .SAVE_CMD_BUF);

    IF (.CMD_LENGTH GTR 0)
    THEN
	BEGIN

	IF EDT$$ALO_HEAP (CMD_LENGTH, CMD_TEXT)
	THEN
	    CH$MOVE (.CMD_LENGTH, .SAVE_CMD_BUF, CH$PTR (.CMD_TEXT,, BYTE_SIZE))
	ELSE
	    BEGIN
	    EDT$$FMT_MSG (EDT$_INSMEM);
	    RETURN;
	    END;

	END;

!+
! Point the command processor to the macro without destorying
! the current buffer or the current macro.
!-
    SAVE_TBCB = .CUR_BUF;
    CUR_BUF = .MAC;
    EDT$$TOP_BUF ();
    CUR_BUF = .SAVE_TBCB;
    EDT$$RD_CURLN ();
    SAVE_MACRO = .MAC_BUF;
    MAC_BUF = .MAC;
!+
! Execute the commands in the specified buffer.
!-
    STATUS = EDT$$EXE_CMD (INP_MACRO);
!+
! Restore the former macro.
!-
    MAC_BUF = .SAVE_MACRO;
!+
! Restore the former command line contents, if any.
!-
    CMD_BUF = .SAVE_CMD_BUF;
    CMD_END = .SAVE_CMD_END;

    IF (.CMD_LENGTH GTR 0)
    THEN

	BEGIN
	CH$MOVE (.CMD_LENGTH, CH$PTR (.CMD_TEXT,, BYTE_SIZE), .SAVE_CMD_BUF);
	EDT$$DEA_HEAP (CMD_LENGTH, CMD_TEXT);
	END;

    IF (.STATUS EQL 2)				! if we saw a control C
    THEN
    	BEGIN
    	IF (CH$PTR_NEQ (.CMD_END, .CMD_PTR))
    	THEN
    	    CC_DONE = 1;
	CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
	CMD_END = .CMD_PTR;
	END;
    END;					! of routine EDT$MAC_CALL

END						! of module EDT$MACCAL

ELUDOM