Google
 

Trailing-Edge - PDP-10 Archives - BB-AE97C-BM - sources/findpara.bli
There are 10 other files named findpara.bli in the archive. Click here to see a list.
 %TITLE 'FINDPARA - isolate wps paragraph entity'
MODULE FINDPARA (				! isolate wps paragraph entity
		IDENT = '3-001'			! File: FINDPARA.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 isolate the WPS paragraph entity
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Shelly T. Solomon  CREATION DATE: October 26, 1981
!
! MODIFIED BY:
!
! 1-001	- Original.  STS 26-Oct-1981.
! 1-002 - Take out reference to EDT$$G_LN_NO.  SMB 14-Sep-1982
! 1-003 - Take out reference to EDT$$TST_EOB. STS 22-Sep-1982
! 1-004 - Move over the delimiter when found. STS 21-Dec-1982
! 3-001 - Add updates from V3 updates.  GB 27-Apr-1983
!++
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$FND_WPARA;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$FND_WPARA  - isolate wps paragraph entity'

GLOBAL ROUTINE EDT$$FND_WPARA (			! isolate wps paragraph entity
    DIR
    ) =

!++
! FUNCTIONAL DESCRIPTION:
!
! This routine is used to isolate the WPS paragraph entity.  It is found by looking
! for a string of consecutive carriage returns > 2.
!
! FORMAL PARAMETERS:
!
!    DIR		Direction of movement
!
! IMPLICIT INPUTS:
!
! IMPLICIT OUTPUTS:
!
!    NONE
!
! ROUTINE VALUE:
!
!	1 = success, 0 = couldn't find
!
! SIDE EFFECTS:
!
!    NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$CS_BOTBUF,				! Move to bottom of buffer
	EDT$$CS_LEFT,				! Move left a character
	EDT$$CS_RIGHT,				! Move right a character
	EDT$$STR_SEACMD,			! Search for a specific string
	EDT$$CS_TOP;				! Move to top of buffer

    EXTERNAL
	US_ENT : VECTOR,			! Pointers to user defined entities
 	WK_LN : REF LIN_BLOCK,
	EOB_LN,
	LN_BUF,				! Current line buffer
	LN_PTR;				! Current character pointer

!+
! this routine is used to isolate the paragraph entity.  It is found by looking
! for a string of consecutive carriage lines > 2
!-

LOCAL
    L_DIF,
    C;
    
!+
! Remember where we are now
!-
    C = 0;

    IF .DIR EQL DIR_FORWARD
    THEN
	BEGIN
	IF (.WK_LN EQLA EOB_LN) THEN RETURN 0;

!+
! skip all delimiters now
!-

	WHILE (CH$RCHAR (.LN_PTR) EQL ASC_K_CR) AND
		CH$PTR_EQL (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE))
	DO
	    BEGIN
	    C = .C + 1;
	    IF NOT EDT$$CS_RIGHT() THEN EXITLOOP;
	    END;
	IF .C GEQ 1 THEN RETURN 1;
	C = EDT$$STR_SEACMD(.(.US_ENT[2] + 1), ..US_ENT[2], 0, DIR_FORWARD);
	IF .C
	THEN

!+
! We found the delimiter, now skip all of the delimiters
!-

	    BEGIN
    	    INCR I FROM 1 TO CH$RCHAR (CH$PTR (.(.US_ENT[2] + 1),, BYTE_SIZE))
    	    DO
	        EDT$$CS_RIGHT();

	    WHILE CH$RCHAR (.LN_PTR) EQL ASC_K_CR AND
			CH$PTR_EQL (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE))
	    DO
	        IF NOT EDT$$CS_RIGHT() THEN EXITLOOP;
	    RETURN 1;
	    END
	ELSE
	    BEGIN
	    C = EDT$$CS_RIGHT();
	    EDT$$CS_BOTBUF();
	    RETURN .C;
	    END;
	END
    ELSE
	BEGIN

!+
! Move back one character to handle being on the first character
! of the paragraph
!-

    	INCR I FROM 0 TO CH$RCHAR (CH$PTR (.(.US_ENT[2] + 1),, BYTE_SIZE))
        DO
	    EDT$$CS_LEFT();
    
	WHILE CH$RCHAR (.LN_PTR) EQL ASC_K_CR AND
		    CH$PTR_EQL (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE))
	DO
	    IF NOT EDT$$CS_LEFT() THEN EXITLOOP;

	C = EDT$$STR_SEACMD(.(.US_ENT[2] + 1), ..US_ENT[2], 1, DIR_BACKWARD);
	IF .C
	THEN

!+
! We found the delimiter, now move past them
!-

	    BEGIN
	    INCR I FROM 1 TO ..US_ENT[2]
	    DO
	        EDT$$CS_RIGHT();
	    RETURN 1;
	    END
	ELSE
	    BEGIN
	    C = EDT$$CS_LEFT();
	    EDT$$CS_TOP();
	    RETURN .C;
	    END;
	END;
    END;


END
ELUDOM