Google
 

Trailing-Edge - PDP-10 Archives - bb-r775e-bm_tops20_ks_upd_5 - sources/edt/wfreseq.bli
There are 10 other files named wfreseq.bli in the archive. Click here to see a list.
 %TITLE 'WFRESEQ - resequence a range of lines'
MODULE WFRESEQ (				! Resequence a range of lines
		IDENT = '3-001'			! File: WFRESEQ.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:
!
!	Resequence a range of lines.
!
! 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 EDT$$RSEQ  from module EDTWF.
! 1-002	- Regularize headers.  JBS 19-Mar-1981
! 1-003 - Add return value and line_too_large error check.  SMB 4-Feb-1982
! 1-004 - Change count to 48-bits.  SMB 07-Feb-1982
! 1-005 - Only copy cur_buf once. STS 18-Mar-1982
! 1-006	- Fix subtitle and local symbol name.  JBS 14-Sep-1982
! 1-007 - Put edt$$tst_eob in line. STS 22-Sep-1982
! 1-008	- Declare EDT$$Z_EOB_LN.  JBS 23-Sep-1982
! 1-009	- Remove declaration of EDT$$TST_EOB, no longer used.  JBS 24-Sep-1982
! 3-001 - Add updates from V3 sources.  GB 09-may-1983
!--

%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$RSEQ;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$WF_RESEQUENCE - resequence a range of lines'

GLOBAL ROUTINE EDT$$RSEQ (			! Resequence a range of lines
	COUNT, 					! Number of lines
	START, 					! Initial line number
	INC					! Increment
    ) =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine resequences a range of lines.  The current line is
!	the first to be resequenced.  The line following the last line
!	resequenced becomes the current line.  This routine works by assigning
!	the number START to the first line and adding INC to get the next line
!	number.  If when we have finished, the number of the following line is
!	less than the last one resequenced, then we continue resequencing until
!	this is no longer true.
!
! FORMAL PARAMETERS:
!
!  COUNT 		the number of lines to be resequenced
!
!  START 		the initial line number
!
!  INC 			the line number increment.
!
! IMPLICIT INPUTS:
!
!	CUR_BUF
!	WK_LN
!
! IMPLICIT OUTPUTS:
!
!	CUR_BUF
!	WK_MODFD
!
! ROUTINE VALUE:
!
!	0 = unable to resequence some of the lines
!	1 = successful resequence
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$FMT_MSG,
	EDT$$CMP_LNO,
	EDT$$RD_CURLN : NOVALUE,
	EDT$$RD_NXTLN;

    EXTERNAL
	WK_RESCNT : LN_BLOCK,		! Actual # lines resequenced
	LNO0 : LN_BLOCK,
	LNO_ZERO : LN_BLOCK,
	LNO_BIG,				! Maximum line number
	CUR_BUF : REF TBCB_BLOCK,	! Current text buffer control block
	WK_LN : REF LIN_BLOCK,		! Pointer to current line
	EOB_LN : REF LIN_BLOCK,		! Location of special end-of-buffer line
	WK_MODFD;			! Flag indicating bucket was modified

    MESSAGES ((MAXLINNUM));

    LOCAL
	COPY_FLAG,
	EOF,
	MAX,
	LINE_TOO_LARGE,				! 1 or more lines will have max line number
	EDT$$SAV_BUFPOS : POS_BLOCK,
	LINE_CNT : LN_BLOCK,			! Temporary holds res count
	NEXT_LINE_NUMBER : LN_BLOCK,
	PREV_NUM : LN_BLOCK;

    MOVELINE (.COUNT, LINE_CNT);
    MOVELINE (.COUNT, WK_RESCNT);
    COPY_FLAG = 0;

    IF (EDT$$CMP_LNO(LINE_CNT, LNO_ZERO) EQL 0) THEN RETURN (0);
    EOF = 0;

    MOVELINE (.START, NEXT_LINE_NUMBER);
    MOVELINE (.START, PREV_NUM);
    LINE_TOO_LARGE = 0;

    WHILE ( NOT .EOF) DO
	BEGIN

!+
! Determine if there are more lines to resequence than what was specified
! in COUNT.  If so, increase the "actual resequence count".
!-
	IF (EDT$$CMP_LNO(LINE_CNT, LNO_ZERO) EQL 0)
	THEN
	    IF (EDT$$CMP_LNO (WK_LN [LIN_NUM], PREV_NUM) GTR 0) 
	    THEN 
		EXITLOOP
	    ELSE
		ADDLINE (WK_RESCNT, LNO0, WK_RESCNT)
	ELSE
	    SUBLINE (LNO0, LINE_CNT, LINE_CNT);

	MOVELINE (NEXT_LINE_NUMBER, WK_LN [LIN_NUM]);
	WK_MODFD = 1;
	EDT$$RD_NXTLN ();

	IF (EDT$$CMP_LNO(LINE_CNT, LNO_ZERO) EQL 0) 
	THEN 
	    IF NOT .COPY_FLAG THEN
	    BEGIN
	    EDT$$CPY_MEM (POS_SIZE, .CUR_BUF, EDT$$SAV_BUFPOS);
	    COPY_FLAG = 1;
	    END;

	MOVELINE (NEXT_LINE_NUMBER, PREV_NUM);
	IF (.WK_LN NEQA EOB_LN)
	THEN
	    BEGIN
	    MAX = ADDLINE (.INC, NEXT_LINE_NUMBER, NEXT_LINE_NUMBER);
	    IF ((EDT$$CMP_LNO(NEXT_LINE_NUMBER, LNO_BIG) GTR 0)
	     OR (.MAX NEQ 0))
	    THEN
	    	BEGIN
	    	LINE_TOO_LARGE = 1;
	    	MOVELINE (LNO_BIG, NEXT_LINE_NUMBER)
	    	END;
	    END
	 ELSE
	    EOF = 1;
	END;

    EDT$$CPY_MEM (POS_SIZE, EDT$$SAV_BUFPOS, .CUR_BUF);
    EDT$$RD_CURLN ();
    IF (.LINE_TOO_LARGE NEQ 0)
    THEN
	BEGIN
	EDT$$FMT_MSG (EDT$_MAXLINNUM);
	RETURN (0)
	END
    ELSE
	RETURN (1)
    END;


END
ELUDOM