Trailing-Edge
-
PDP-10 Archives
-
bb-r775d-bm_tops20_ks_upd_4
-
sources/ugbuffer.bli
There are 10 other files named ugbuffer.bli in the archive. Click here to see a list.
%TITLE 'UGBUFFER - get a buffer pointer'
MODULE UGBUFFER ( ! Get a buffer pointer
IDENT = '3-002' ! File: UGBUFFER.BLI Edit: CJG3002
) =
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:
!
! Get a buffer pointer. Create a buffer if necessary.
!
! 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 EDT$$GET_BUFPTR from module UTIL.
! 1-002 - Regularized headers. JBS 25-Feb-1981
! 1-003 - Fix module name. JBS 11-Mar-1981
! 1-004 - Implement virtual memory deallocation TMV 6-Aug-81
! 1-005 - When a buffer is first allocated we are positioned at
! its front. JBS 08-Apr-1982
! 3-001 - Make arguments to CH$EQL into string ptrs for Tops10/20. GB 27-Jan-1983
! 3-002 - NAME is already a pointer - don't make it one again. CJG 24-Mar-83
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
FORWARD ROUTINE
EDT$$GET_BUFPTR;
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
! NONE
!
! EQUATED SYMBOLS:
!
! NONE
!
! OWN STORAGE:
!
! NONE
!
! EXTERNAL REFERENCES:
!
! In the routine
%SBTTL 'EDT$$GET_BUFPTR - get a buffer pointer'
GLOBAL ROUTINE EDT$$GET_BUFPTR ( ! Get a buffer pointer
NAME, ! Pointer to buffer name
LEN, ! Length of that name
BUF_ADDR, ! Place to store buffer address
NEW ! 1 = new buffer created
) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine searches for a buffer with a specified name. If the buffer
! if found, then the address of the TBCB is returned. If the buffer is not
! found, then a buffer by that name is created.
!
! FORMAL PARAMETERS:
!
! NAME Pointer to a string containing the name of the buffer.
!
! LEN Length of the name string.
!
! BUF_ADDR Address of a fullword to receive the TBCB address.
!
! NEW Address of a flag to be set if the buffer was newly created.
!
! IMPLICIT INPUTS:
!
! BUF_LST
!
! IMPLICIT OUTPUTS:
!
! BUF_LST
!
! ROUTINE VALUE:
!
! Returns zero if an attempt to create a new buffer failed, one otherwise.
!
! SIDE EFFECTS:
!
! May create a new buffer and link it onto the buffer list.
!
!--
BEGIN
EXTERNAL ROUTINE
EDT$$ALO_HEAP;
EXTERNAL
BUF_LST : REF TBCB_BLOCK, ! Pointer to first buffer in line.
LNO_ZERO : LN_BLOCK; ! Clear line number
LOCAL
NEW_BUF : REF TBCB_BLOCK;
!+
! Start with the head of the text buffer list.
!-
NEW_BUF = .BUF_LST;
!+
! Now link our way through the list until we either find a matching
! name or hit the end of the list.
!-
WHILE (.NEW_BUF NEQ 0) DO
IF CH$EQL (.LEN, .NAME, .NEW_BUF [TBCB_NAME_LEN],
CH$PTR (NEW_BUF [TBCB_NAME],, BYTE_SIZE))
THEN
EXITLOOP
ELSE
NEW_BUF = .NEW_BUF [TBCB_NEXT_BUF];
IF (.NEW_BUF EQL 0)
THEN
BEGIN
!+
! Well, we didn't find it. Better create a new one.
!-
IF ( NOT EDT$$ALO_HEAP (%REF (TBCB_SIZE*BYTES_PER_WORD + .LEN), NEW_BUF)) THEN RETURN (0);
NEW_BUF [TBCB_NAME_LEN] = .LEN;
!+
! Move the name into the newly created text buffer.
!-
CH$MOVE (.LEN, .NAME, CH$PTR (NEW_BUF [TBCB_NAME],, BYTE_SIZE));
!+
! And append it to the front of the buffer list.
!-
NEW_BUF [TBCB_NEXT_BUF] = .BUF_LST;
NEW_BUF [TBCB_PREV_BUF] = 0;
IF (.BUF_LST NEQ 0) THEN BUF_LST [TBCB_PREV_BUF] = .NEW_BUF;
BUF_LST = .BUF_ADDR = .NEW_BUF;
!+
! Initialize the other fields in the TBCB.
!-
NEW_BUF [TBCB_LINE_ADDR] = 0; ! Pointer to current line.
NEW_BUF [TBCB_CUR_BUKT] = 0; ! Current bucket number.
MOVELINE (LNO_ZERO, NEW_BUF [TBCB_CUR_LIN]); ! Current line number.
NEW_BUF [TBCB_CHAR_POS] = 0; ! The character position within the line
NEW_BUF [TBCB_FIRST_BUKT] = 0; ! First bucket number.
NEW_BUF [TBCB_LAST_BUKT] = 0; ! Last bucket number.
MOVELINE (LNO_ZERO, NEW_BUF [TBCB_INPUT_LINE]); ! Number of last input line.
MOVELINE (LNO_ZERO, NEW_BUF [TBCB_LINE_COUNT]); ! Count of lines in buffer.
NEW_BUF [TBCB_CHAR_COUNT] = 0; ! Count of chars in buffer.
NEW_BUF [TBCB_INPUT_RAB] = 0; ! Pointer to input RAB.
NEW_BUF [TBCB_IS_MAC] = 0;
.NEW = 1;
END
ELSE
.NEW = 0;
.BUF_ADDR = .NEW_BUF;
RETURN (1);
END; ! of routine EDT$$GET_BUFPTR
END
ELUDOM