Google
 

Trailing-Edge - PDP-10 Archives - tops20-v7-ft-dist1-clock - 7-sources/lflno.bli
There are 10 other files named lflno.bli in the archive. Click here to see a list.
 %TITLE 'LFLNO - format the current line number'
MODULE LFLNO (				! Format the current line number
		IDENT = '3-003'			! File: LFLNO.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:
!
!	This module formats a line number for printing.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: February 3, 1978
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 02-FEB-1981.  This module was created by
!	extracting the routine EDT$$FILL_LNO  from the module EXEC.BLI.
!
! 1-002.  DJS 11-FEB-1981.  The tab following the editor-supplied line
!	number changed to an equivalent number of spaces so that there
!	is no problem with terminals with settable tab stops.
! 1-003	- Regularize headers.  JBS 19-Mar-1981
! 1-004 - Remove division on line number calculations.  SMB 13-Jan-1982
! 1-005 - Change line number print format depending on size of line#.  SMB 24-Jan-1982
! 1-006 - Change line number division to routine call.  SMB 11-Feb-1982
! 1-007 - Change positioning in format buffer of text. STS 22-Jun-1982
! 1-008 - Change the column position of typed text.  SMB 14-Jul-1982
! 1-009 - Put fsetcol in line. STS 11-Oct-1982
! 1-010 - Modify to use new compare macro. STS 20-Oct-1982
! 1-011	- Maintain cursor position.  JBS 22-Oct-1982
! 3-001 - Make string ptrs into real string ptrs and treat accordingly.  GB 3-Feb-1983
! 3-002 - Add updates from V3 sources.  GB 29-Apr-1983
! 3-003 - Add FMT_FREE to improve speed of format routines. CJG 11-Jan-1984
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$FILL_LNO : NOVALUE;			! Format a line number for printing

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$FILL_LNO  - format the current line number'

GLOBAL ROUTINE EDT$$FILL_LNO 			! Format the current line number
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Format a line number for printing.  The line number of the current
!	line is converted to a decimal number with leading zeros and
!	trailing zeroes after the decimal point suppressed.  The decimal
!	point is suppressed if the number is an integer.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	FMT_CUR
!	FMT_BUF
!	FMT_FREE
!	LNO0
!	thru
!	LNO14
!	WK_LN
!
! IMPLICIT OUTPUTS:
!
!	PRV_COL
!	FMT_LNPOS
!	FMT_CUR
!	FMT_FREE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$CMP_LNO,
	EDT$$LDIV;

    EXTERNAL
	FMT_LNPOS,			! Column number, for formatting
	FMT_CUR,			! Current position in the format buffer
	FMT_FREE,			! Space left in format buffer
	FMT_BUF,			! The format buffer
	LNO0 : LNOVECTOR [14],		! Powers of 10
	WK_LN : REF LIN_BLOCK,		! The current line in the work file
	PRV_COL;			! Cursor column number

    LOCAL
	LNUM_LEN,			! Line number length
	SIGNIF,				! Flag indicating a sig. digit has been seen
	DIGIT,				! The current digit
	LFORMAT,			! Length of line number format
	DIVISOR : LN_BLOCK,		! A power of ten to divide by
	LINNO : LN_BLOCK,		! The line number we are putting out
	T_LINE_NUM;			! Pointer into the output buffer.

!+
! Initialize the pointer to the beginning of the format buffer.
!-

    T_LINE_NUM = .FMT_CUR;

!+
! Get the offset into the format buffer where we are positioned
!-

    LFORMAT = FMT_BUFLEN - .FMT_FREE;

!+
! Fetch the line number into a local
!-

    LINNO [LN_LO] = .WK_LN [LIN_NUM];
    LINNO [LN_MD] = .WK_LN [LIN_NUMM];
    LINNO [LN_HI] = .WK_LN [LIN_NUMH];
    SIGNIF = 0;

!+
! Initialize the line number field to spaces.  Format is nnnnn.nnnnnb if
! line number < 10**5 and nnnnnnnnnn.nnnnnb otherwise.
!-

    IF (EDT$$CMP_LNO (WK_LN [LIN_NUM], LNO0 [10]) GEQ 0)
    THEN
	BEGIN
	CH$MOVE (17, CH$PTR(UPLIT (%STRING ('                  '))), .T_LINE_NUM);
	LNUM_LEN = 17;
	END
    ELSE
	BEGIN
	CH$MOVE (12, CH$PTR(UPLIT (%STRING ('             '))), .T_LINE_NUM);
	LNUM_LEN = 12;
	END;

    LFORMAT = .LFORMAT + .LNUM_LEN;
!+
! Loop once for each possible digit in the number starting with most
! significant
!-

    DECR I FROM 14 TO 0 DO
	BEGIN
	EDT$$LDIV (LINNO, DIGIT, .I);
!+
! Write the digit out if the current digit is non-zero or
! we have seen a previous non zero digit or we are down
! to the units digit.
!-

	IF ((.DIGIT NEQ 0) OR (.SIGNIF NEQ 0) OR (.I EQL 5))
	THEN
	    BEGIN
	    CH$WCHAR (.DIGIT + %C'0', .T_LINE_NUM);
	    SIGNIF = .SIGNIF + 1;
	    END;

!+
! Bump the character pointer.
!-

	IF ((.LNUM_LEN EQL 17) OR ((.LNUM_LEN EQL 12) AND (.I LEQ 9)))
	THEN
	    T_LINE_NUM = CH$PLUS (.T_LINE_NUM, 1);

!+
! If we are into the fractional part and the rest of
! the number is zero, then get out of the loop.
!-

	IF ((.I LEQ 5) AND (.LINNO EQL 0)) THEN EXITLOOP;

!+
! If we are down to the units position, then write out
! the decimal point.
!-

	IF (.I EQL 5) THEN CH$WCHAR_A (%C'.', T_LINE_NUM);

	END;

!+
! Set the format buffer pointer and column number.
!-

    FMT_CUR = CH$PTR (FMT_BUF, .LFORMAT, BYTE_SIZE);
    PRV_COL = .PRV_COL + .LFORMAT - .FMT_LNPOS;
    FMT_FREE = .FMT_FREE - .LNUM_LEN;
    FMT_LNPOS = .LFORMAT;
    END;					! of routine EDT$$FILL_LNO

!<BLF/PAGE>
END						! of module EDT$LFLNO

ELUDOM