Google
 

Trailing-Edge - PDP-10 Archives - bb-r775e-bm_tops20_ks_upd_5 - sources/edt/lsubsn.bli
There are 10 other files named lsubsn.bli in the archive. Click here to see a list.
 %TITLE 'LSUBSN - SUBSTITUTE NEXT line-mode command'
MODULE LSUBSN (				! SUBSTITUTE NEXT line-mode command
		IDENT = '3-001'			! File: LSUBSN.BLI Edit: GB3001
		) =
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 SUBSTITUTE NEXT 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$$SUB_NXTCMD  from the module EXEC.BLI.
! 1-002	- Regularize headers.  JBS 20-Mar-1981
! 1-003	- Change SUBSTITUTE to EDT$$SUB_NXT .  JBS 27-Mar-1981
! 1-004	- Worry about string truncation.  JBS 05-May-1982
! 1-005	- Refresh the screen if this command is executed under EXT.  JBS 07-Jul-1982
! 1-006 - Put edt$$tst_eob in line. STS 22-Sep-1982
! 1-007	- Remove EDT$$G_SCR_CHGD, not needed by new screen logic.  JBS 09-Oct-1982
! 3-001 - Add updates from V3 sources.  GB 29-Apr-1983
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$SUB_NXTCMD : NOVALUE;			! Process the SUBSTITUTE NEXT command

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$SUB_NXTCMD  - SUBSTITUTE NEXT line-mode command'

GLOBAL ROUTINE EDT$$SUB_NXTCMD 			! SUBSTITUTE NEXT line-mode command
    : NOVALUE =

!++
! FUNCTIONAL SPECIFICATION:
!
!	Command processing routine for SUBSTITUTE NEXT.  This command keeps
!	trying to do a substitution until it succeeds.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	CUR_BUF
!	EXE_CURCMD
!	WK_LN
!
! IMPLICIT OUTPUTS:
!
!	EXE_SUBCNT
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$SET_STR,
	EDT$$SUB_NXT : NOVALUE,
	EDT$$RD_CURLN,
	EDT$$RD_NXTLN,
	EDT$$FMT_MSG : NOVALUE;

    EXTERNAL
	CUR_BUF : REF TBCB_BLOCK,
	WK_LN : REF LIN_BLOCK,
	EOB_LN,
	EXE_CURCMD : REF NODE_BLOCK,	! Pointer to the current command.
	EXE_SUBCNT;			! No. of substitutions done.

    LOCAL
	STRINGS_OK;

    MESSAGES ((INVSTR));
    STRINGS_OK = 1;
!+
! Check to see if new search and replace strings were specified and, if
! they were, set them up.
!-

    IF (.EXE_CURCMD [STR_PNT] NEQ 0) THEN STRINGS_OK = EDT$$SET_STR ();

!+
! Zero the substitute count.
!-
    EXE_SUBCNT = 0;
!+
! Make sure we are correctly positioned at the current line.
!-
    EDT$$RD_CURLN ();
!+
! Loop until a substitution is done or the end of buffer is encountered.
!-

    WHILE ((.WK_LN NEQA EOB_LN) AND (.EXE_SUBCNT EQL 0) AND .STRINGS_OK) DO
	BEGIN
!+
! Attempt a single substition on this line starting at the cursor
! position.
!-
	EDT$$SUB_NXT (1, .CUR_BUF [TBCB_CHAR_POS]);
!+
! If no substitutions were performed, try again on the next line.
!-

	IF (.EXE_SUBCNT EQL 0) THEN EDT$$RD_NXTLN ();

	END;

    IF ( NOT .STRINGS_OK) THEN EDT$$FMT_MSG (EDT$_INVSTR);

    END;					! of routine EDT$$SUB_NXTCMD


END
ELUDOM