Trailing-Edge
-
PDP-10 Archives
-
tops20-v7-ft-dist1-clock
-
7-sources/rannext.bli
There are 10 other files named rannext.bli in the archive. Click here to see a list.
%TITLE 'RANNEXT - next line in a range'
MODULE RANNEXT ( ! Next line in a range
IDENT = '3-002' ! File: RANNEXT.BLI Edit: CJG3002
) =
BEGIN
!COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1981, 1988. 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 THAT IS NOT SUPPLIED BY DIGITAL.
!
!
!++
! FACILITY: EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
! Get the next line in a range.
!
! ENVIRONMENT: Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: February 3, 1978
!
! MODIFIED BY:
!
! 1-001 - Original. DJS 19-FEB-1981. This module was created by
! extracting routine EDT$$NXT_LNRNG from module RANGE.
! 1-003 - Use the ASSERT macro. JBS 01-Jun-1981
! 1-004 - If this is an ALL range, it must have a search string.
! JBS 31-Oct-1981
! 1-005 - Use the new PREV_RANGE field to find the ALL string. JBS 02-Nov-1981
! 1-006 - Modify the next range find for AND ranges. SMB 15-Feb-1982
! 1-007 - Type .,-,- now works at the [EOB]. TMV 18-FEB-1982
! 1-008 - Regularize format. JBS 04-May-1982
! 1-009 - Remove EDT$$A_STR_CMP. JBS 16-Jul-1982
! 1-010 - Put calls to edt$$rng_nxtln in line. STS 17-Sep-1982
! 1-011 - Put edt$$tst_eob in line. STS 22-Sep-1982
! 1-012 - Remove reference to edt$$rng_posfrst. STS 11-Oct-1982
! 3-001 - Add updates from V3 sources. GB 03-May-1983
! 3-002 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
FORWARD ROUTINE
EDT$$NXT_LNRNG;
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
! NONE
!
! EQUATED SYMBOLS:
!
! NONE
!
! OWN STORAGE:
!
! NONE
!
! EXTERNAL REFERENCES:
!
! In the routine
%SBTTL 'EDT$$NXT_LNRNG - next line in a range'
GLOBAL ROUTINE EDT$$NXT_LNRNG ( ! Get the next line in a range
DELETED ! 1 = last line was deleted
) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine returns the next line in a range. The position
! routine must have been called first if this routine is to
! work properly.
!
! FORMAL PARAMETERS:
!
! DELETED Indicate whether the last line was deleted.
!
! IMPLICIT INPUTS:
!
! RNG_CURRNG
! RNG_EOL
! RNG_MORELN
! RNG_NOOFLN
! SEA_STRLEN
! WK_LN
! EXCT_MATCH
!
! IMPLICIT OUTPUTS:
!
! RNG_FRSTLN
!
! ROUTINE VALUE:
!
! 0 = No more lines exist in this range
! 1 = A line was sucessfully located
!
!
! SIDE EFFECTS:
!
! The current text buffer is re-positioned.
!
!--
BEGIN
EXTERNAL ROUTINE
EDT$$RNG_REPOS,
EDT$$CMP_LNO,
EDT$$RD_NXTLN,
EDT$$STR_CMP; ! Compare two strings of equal length
EXTERNAL
RNG_CURRNG : REF NODE_BLOCK, ! The current range node
RNG_EOL : LN_BLOCK, ! The line number at which this range ends
RNG_MORELN, ! Used by EDT$$NXT_LNRNG to indicate more lines.
RNG_FRSTLN, ! Indicates first line in a range.
RNG_NOOFLN, ! Count of number of lines in a range.
SEA_STRLEN, ! Length of search string.
EOB_LN,
EXCT_MATCH, ! The type of string matching
WK_LN : REF LIN_BLOCK; ! The current line pointer.
LABEL
LOOP;
LOCAL
DEL_FLAG;
!+
! Get a local copy of the delete flag, since if this is an ALL range,
! we will loop, and the delete flag will be turned off after the first
! time though.
!-
DEL_FLAG = .DELETED;
!+
! Loop until we find a line which contains the ALL string. If no all
! string, we will get out the first time through.
!-
LOOP :
BEGIN
WHILE 1 DO
BEGIN
!+
! If we are at the end of the buffer, or the RNG_MORELN flag is zero,
! then there are no more lines. Exit with a 0.
!-
IF .RNG_MORELN EQL 0 THEN RETURN (0);
!+
! Case on the range type.
!-
CASE .RNG_CURRNG [RAN_TYPE] FROM RAN_NULL TO NUM_RAN OF
SET
!+
! For all the single line ranges, if RNG_FRSTLN is on, then return
! success and turn it off. If it is not then check to see if it
! was part of an AND list; if so, position to the next line in
! the list.
!-
[RAN_NUMBER, RAN_DOT, RAN_STR, RAN_BEGIN, RAN_LAST, RAN_END, RAN_MINUS, RAN_PLUS, RAN_NULL,
RAN_MINSTR, RAN_ORIG] :
BEGIN
IF .RNG_FRSTLN !
THEN
RNG_FRSTLN = 0
ELSE
IF (.RNG_CURRNG [NEXT_RANGE] EQL 0)
THEN
RETURN (0)
ELSE
IF EDT$$RNG_REPOS (.RNG_CURRNG [NEXT_RANGE])
THEN
RNG_FRSTLN = 0
ELSE
RETURN (0);
END;
!+
! For WHOLE or REST, just move to the next line.
!-
[RAN_WHOLE, RAN_REST] :
BEGIN
IF (.WK_LN EQLA EOB_LN) THEN RETURN (0);
IF NOT .DEL_FLAG
THEN
IF (NOT .RNG_FRSTLN)
THEN
EDT$$RD_NXTLN()
ELSE
RNG_FRSTLN = 0;
END;
!+
! For FOR and SELECT, the range block contains the number of lines
! to include. Count it down, returning failure if it becomes negative.
!-
[RAN_FOR, RAN_SELECT] :
BEGIN
IF (.WK_LN EQLA EOB_LN) THEN RETURN (0);
RNG_CURRNG [RAN_VAL] = .RNG_CURRNG [RAN_VAL] - 1;
IF (.RNG_CURRNG [RAN_VAL] LSS 0)
THEN
RETURN (0)
ELSE
IF NOT .DEL_FLAG
THEN
IF NOT .RNG_FRSTLN
THEN
EDT$$RD_NXTLN()
ELSE
RNG_FRSTLN = 0;
END;
!+
! The THRU and BEFORE ranges have saved away the last line to be
! included. Move to the next line in the range, then compare it
! to the last line number. If it is greater, return failure.
!-
[RAN_THRU, RAN_BEFORE] :
BEGIN
IF (.WK_LN EQLA EOB_LN) THEN RETURN (0);
IF NOT .DEL_FLAG
THEN
IF NOT .RNG_FRSTLN
THEN
EDT$$RD_NXTLN()
ELSE
RNG_FRSTLN = 0;
IF (EDT$$CMP_LNO (WK_LN [LIN_NUM], RNG_EOL) GTR 0) THEN RETURN (0);
END;
[INRANGE] :
; ! some ranges (such as ALL) can never get here.
[OUTRANGE] :
ASSERT (19, 0);
TES;
!+
! If there was an ALL, insure that the string exists in the line.
! If it does not, continue through the loop again looking either
! for one that does contain the string or the end of the range.
!-
BEGIN
BIND
ALL_RAN = .RNG_CURRNG [PREV_RANGE] : NODE_BLOCK;
LOCAL
CH_POINT;
IF (ALL_RAN EQLA 0) THEN LEAVE LOOP;
IF ((ALL_RAN NEQA 0) AND (.WK_LN EQLA EOB_LN)) THEN RETURN (0);
IF (.ALL_RAN [RAN_TYPE] NEQ RAN_ALL) THEN LEAVE LOOP;
!+
! An ALL range must have a string.
!-
ASSERT (19, .ALL_RAN [STR_PNT] NEQA 0);
CH_POINT = CH$PTR (WK_LN [LIN_TEXT],, BYTE_SIZE);
DECR I FROM .WK_LN [LIN_LENGTH] - .SEA_STRLEN TO 0 DO
IF EDT$$STR_CMP (.CH_POINT, .ALL_RAN [STR_PNT], .ALL_RAN [RAN_VAL], .EXCT_MATCH)
THEN
LEAVE LOOP ! This line has the string
ELSE
CH_POINT = CH$PLUS (.CH_POINT, 1); ! Keep looking
DEL_FLAG = 0;
END;
END;
END;
!+
! Count one more line found in the range.
!-
RNG_NOOFLN = .RNG_NOOFLN + 1;
RETURN (1);
END; ! of routine EDT$$NXT_LNRNG
END
ELUDOM