Trailing-Edge
-
PDP-10 Archives
-
bb-r775e-bm_tops20_ks_upd_5
-
sources/edt/ufstring.bli
There are 10 other files named ufstring.bli in the archive. Click here to see a list.
%TITLE 'UFSTRING - line-mode string search'
MODULE UFSTRING ( ! Line-mode string search
IDENT = '3-001' ! File: UFSTRING.BLI Edit: CJG3001
) =
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:
!
! Line-mode string search.
!
! ENVIRONMENT: Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: February 7, 1978
!
! MODIFIED BY:
!
! 1-001 - Original. DJS 19-FEB-1981. This module was created by
! extracting routine U_F_STRING from module UTIL.
! 1-002 - Regularize headers and remove control C checking. JBS 11-Mar-1981
! 1-003 - Worry about string truncation. JBS 05-May-1982
! 1-004 - Put in check for control C. STS 15-Jun-1982
! 1-005 - Remove EDT$$A_STR_CMP. JBS 16-Jul-1982
! 3-001 - Fix string pointer in call to string compare. CJG 24-Mar-1983
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
FORWARD ROUTINE
EDT$$FND_STR;
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
! NONE
!
! EQUATED SYMBOLS:
!
! NONE
!
! OWN STORAGE:
!
! NONE
!
! EXTERNAL REFERENCES:
!
! In the routine
%SBTTL 'EDT$$FND_STR - line-mode string search'
GLOBAL ROUTINE EDT$$FND_STR ( ! Line-mode string search
STRING, ! Pointer to model string
LEN, ! Length of model string
DIR ! Direction of search
) =
!++
! FUNCTIONAL DESCRIPTION:
!
! Line mode string search routine. Set-up the string which is passed in
! as the current search string, then work our way through the buffer in
! the specified direction looking for the string. If the string is found
! the buffer position is left at the string, otherwise it will be at the
! beginning or end depeneding on the direction.
!
! FORMAL PARAMETERS:
!
! STRING Pointer to the search string.
!
! LEN Length of the search string.
!
! DIR Direction of search: 0 = backward, 1 = forward.
!
! IMPLICIT INPUTS:
!
! CUR_BUF
! SEA_STR
! SEA_STRLEN
! WK_LN
! EXCT_MATCH
!
! IMPLICIT OUTPUTS:
!
! CC_DONE
! CUR_BUF
!
! ROUTINE VALUE
!
! 0 = string not found
! 1 = string found
! 2 = string invalid
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
EXTERNAL ROUTINE
EDT$$CHK_CC,
EDT$$SET_SEASTR,
EDT$$RD_NXTLN,
EDT$$STR_CMP, ! Match strings of equal length
EDT$$RD_PRVLN;
EXTERNAL
CUR_BUF : REF TBCB_BLOCK, ! Pointer to current buffer TBCB
CC_DONE, ! control C seen flag
SEA_STR : BLOCK [CH$ALLOCATION (64, BYTE_SIZE)], ! Last search string.
SEA_STRLEN, ! Length of above.
WK_LN : REF LIN_BLOCK, ! Pointer to the current line
EXCT_MATCH; ! The type of string matching
LOCAL
CONTROL_C : INITIAL (0),
SC,
SOURCE;
!+
! Set up the new search string.
!-
IF EDT$$SET_SEASTR (.STRING, .LEN)
THEN
BEGIN
WHILE NOT .CONTROL_C DO
BEGIN
CONTROL_C = EDT$$CHK_CC ();
!+
! If seaching backward, then go back a line.
!-
IF ( NOT .DIR)
THEN
IF ( NOT EDT$$RD_PRVLN ()) THEN RETURN (0);
!+
! Get a pointer to the line.
!-
SOURCE = WK_LN [LIN_TEXT];
!+
! Compare at each character in the line.
!-
INCR I FROM .CUR_BUF [TBCB_CHAR_POS] TO !
(.WK_LN [LIN_LENGTH] - .SEA_STRLEN) DO
IF EDT$$STR_CMP (CH$PTR (.SOURCE, .I, BYTE_SIZE),
CH$PTR (SEA_STR,, BYTE_SIZE),
.SEA_STRLEN, .EXCT_MATCH)
THEN
BEGIN
CUR_BUF [TBCB_CHAR_POS] = .I + .SEA_STRLEN;
RETURN (1);
END;
!+
! If the direction is forward, then move forward a line.
!-
IF .DIR
THEN
IF ( NOT EDT$$RD_NXTLN ()) THEN RETURN (0);
END;
CC_DONE = 1;
RETURN (0);
END;
RETURN (2);
END; ! of routine EDT$$FND_STR
END
ELUDOM