Trailing-Edge
-
PDP-10 Archives
-
BB-H138F-BM_1988
-
7-sources/wfsplbkt.bli
There are 10 other files named wfsplbkt.bli in the archive. Click here to see a list.
%TITLE 'WFSPLBKT - split the current bucket'
MODULE WFSPLBKT ( ! Split the current bucket
IDENT = '3-003' ! File: WFSPLBKT.BLI Edit: CJG3003
) =
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:
!
! Split the current bucket.
!
! ENVIRONMENT: Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: October 16, 1978
!
! MODIFIED BY:
!
! 1-001 - Original. DJS 23-Feb-1981. This module was created by
! extracting routine SPLIT_BUKT from module EDTWF.
! 1-002 - Regularize headers. JBS 19-Mar-1981
! 1-003 - Modify to use EDT$WORKIO. STS 15-Feb-1982
! 1-004 - Copy entire old bucket before split. STS 18-Feb-1982
! 1-005 - Don't copy on 11's since it uses too much stack. STS 01-Mar-1982
! 1-006 - Change stack storage to heap storage. STS 05-Mar-1982
! 1-007 - Add literals for callable EDT. STS 10-Mar-1982
! 1-008 - Give an error return if heap storage is exhausted. JBS 09-Jun-1982
! 1-009 - Put code for edt$$wf_nxt_buf in line. STS 11-oct-1982
! 3-001 - Change arguments to EDT$$CPY_MEM - it nows copys words. GB 21-Feb-1983
! 3-002 - Add updates from V3 sources. GB 09-May-1983
! 3-003 - Remove call to EDT$$CALLWIO. CJG 13-Jun-1983
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
FORWARD ROUTINE
EDT$$WF_SPLTBUK;
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
! NONE
!
! EQUATED SYMBOLS:
!
! NONE
!
! OWN STORAGE:
!
! NONE
!
! EXTERNAL REFERENCES:
!
! In the routine
%SBTTL 'EDT$$WF_SPLTBUK - split the current bucket'
GLOBAL ROUTINE EDT$$WF_SPLTBUK ! Split the current bucket
=
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine splits the current bucket at the current position into
! two buckets. In the special case that we are at the end of the bucket
! this is done simply by appending a new bucket, otherwise, we must allocate
! a new bucket and copy all the text from the current line to the end of the
! bucket into the new bucket.
!
! FORMAL PARAMETERS:
!
! NONE
!
! IMPLICIT INPUTS:
!
! CUR_BUF
! WF_DESC
! WK_BUK
! WK_CURBUK
!
! IMPLICIT OUTPUTS:
!
! WK_MODFD
! WK_BUK
!
! ROUTINE VALUE:
!
! 1 = OK
! 0 = heap storage exhausted
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
EXTERNAL ROUTINE
EDT$$ALO_HEAP, ! allocate heap storage
EDT$$DEA_HEAP : NOVALUE, ! deallocate heap storage
EDT$$WF_WR : NOVALUE, ! Write to the work file
EDT$$WF_NEWBUK : NOVALUE,
EDT$$WF_ALOBUF : NOVALUE,
EDT$$WF_MAKECUR : NOVALUE;
EXTERNAL
WF_DESC : BLOCK, ! descriptor for the workfile record
WK_AVAIL,
WK_GRTSTBUK,
CUR_BUF : REF TBCB_BLOCK, ! Current text buffer control block
WK_BUK : ! Pointer to current bucket
REF BLOCK [WF_BUKT_SIZE] FIELD (WFB_FIELDS),
WK_CURBUK, ! Number of the current bucket
WK_MODFD; ! Flag indicating bucket was modified
LOCAL
OLD_NEXT,
LEN,
ORIG_BUKT;
!+
! Remember the next bucket number, and the original one
!-
OLD_NEXT = .WK_BUK [WFB_NEXT_BUKT];
ORIG_BUKT = .WK_CURBUK;
!+
! First check to see if we are at the end of a bucket.
!-
IF (.CUR_BUF [TBCB_LINE_ADDR] EQL .WK_BUK [WFB_END])
THEN
!+
! We are at the end, just link a new bucket to this one
!-
BEGIN
IF .WK_AVAIL NEQ 0
THEN
WK_BUK [WFB_NEXT_BUKT] = .WK_AVAIL
ELSE
WK_BUK [WFB_NEXT_BUKT] = .WK_GRTSTBUK;
WK_MODFD = 1;
EDT$$WF_NEWBUK (.OLD_NEXT, .ORIG_BUKT)
END
ELSE
BEGIN
!+
! Split the bucket into two, at the beginning of the current line.
!-
LOCAL
OLD_BUKT,
NEW_BUKT;
LEN = .WK_BUK [WFB_END] - .CUR_BUF [TBCB_LINE_ADDR];
WK_BUK [WFB_END] = .CUR_BUF [TBCB_LINE_ADDR];
IF .WK_AVAIL NEQ 0
THEN
WK_BUK [WFB_NEXT_BUKT] = NEW_BUKT = .WK_AVAIL
ELSE
WK_BUK [WFB_NEXT_BUKT] = NEW_BUKT = .WK_GRTSTBUK;
EDT$$WF_WR (.WK_CURBUK, WF_DESC);
!+
! Save out the bucket so that later we can extract a portion
!-
IF ( NOT EDT$$ALO_HEAP (%REF (WF_BUKT_SIZE * BYTES_PER_WORD), OLD_BUKT)) THEN RETURN (0);
EDT$$CPY_MEM (WF_BUKT_SIZE, .WK_BUK, .OLD_BUKT);
!+
! Now get a fresh buffer
!-
EDT$$WF_ALOBUF ();
WK_BUK [WFB_NEXT_BUKT] = .OLD_NEXT;
WK_BUK [WFB_PREV_BUKT] = .ORIG_BUKT;
!+
! Copy a portion of the old buffer into the new buffer
!-
EDT$$CPY_MEM (.LEN, .OLD_BUKT + .CUR_BUF [TBCB_LINE_ADDR], !
.WK_BUK + WFB_FIXED_SIZE);
EDT$$DEA_HEAP (%REF (WF_BUKT_SIZE * BYTES_PER_WORD), OLD_BUKT);
WK_BUK [WFB_END] = .LEN + WFB_FIXED_SIZE;
WK_MODFD = 1;
IF (.OLD_NEXT EQL 0)
THEN
BEGIN
IF (.ORIG_BUKT EQL .CUR_BUF [TBCB_LAST_BUKT])
THEN
CUR_BUF [TBCB_LAST_BUKT] = .NEW_BUKT;
END
ELSE
BEGIN
EDT$$WF_MAKECUR (.OLD_NEXT);
WK_BUK [WFB_PREV_BUKT] = .NEW_BUKT;
WK_MODFD = 1;
END;
EDT$$WF_MAKECUR (.ORIG_BUKT)
END;
RETURN (1);
END; ! of routine EDT$$WF_SPLTBUK
END
ELUDOM