Google
 

Trailing-Edge - PDP-10 Archives - BB-H138F-BM_1988 - 7-sources/input.bli
There are 10 other files named input.bli in the archive. Click here to see a list.
 %TITLE 'INPUT - read a line of input'
MODULE INPUT (				! Read a line of input
		IDENT = '3-009'			! File: INPUT.BLI Edit: CJG3009
		) =
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 is called whenever an input line is required for a
!	command or an insert.  This module handles fetching of lines
!	from macros or from the initialization file.
!
! ENVIRONMENT: User mode, sharable
!
! AUTHOR: Bob Kushlis, CREATION DATE: 4-Feb-1979
!
! MODIFIED BY:
!
! Dan Szymanski, 17-NOV-80, 02
!	Change to EDT$$GET_LN  so that a line of input from the terminal
!	which consists of only the two characters ^z or ^Z are not
!	considered to be an end-of-file.
! 2-003	- Regularized headers.  JBS 24-Feb-1981
! 2-004	- Fix module name.  JBS 06-Mar-1981
! 2-005	- Use the ASSERT macro.  JBS 01-Jun-1981
! 2-006	- Remove explicit journaling.  JBS 22-Jun-1981
! 2-007	- Use new journaling interface.  JBS 08-Jul-1981
! 2-008	- Separate reading of the startup file from reading of the journal file.
!	   JBS 16-Aug-1981
! 2-009 - Make command file i/o use EDT$FILEIO.  STS 25-Dec-1981
! 2-010 - Remove DSC$A_POINTER macro  STS 14-Jan-1982
! 2-011 - Convert  reads and writes to use EDT$FILEIO. STS 15-Jan-1981
! 2-012 - Add rhb_descriptor. STS 21-Jan-1982
! 2-013 - Remove reference to sys_cmdrab. STS 10-Feb-1982
! 2-014 - Add literals for callable parameters. STS 08-Mar-1982
! 2-015	- Add JOU_VALID.  JBS 09-Apr-1982
! 2-016 - Make sure an insert line terminated by ^Z gets journalled. STS 24-Jun-1982
! 3-001 - Make all quoted string arguments %C so they are right justified.  GB 09-Feb-1983
! 3-002 - Put the command in the rescan buffer if the parser will be called
!	  next. In terminal mode - don't do anything. CJG Ides of March, 1983
! 3-003 - Don't need RHB code on TPS20. CJG 19-Apr-1983
! 3-004 - Add updates from V3 kit.  GB 27-Apr-1983
! 3-005 - Remove call to EDT$$CALLFIO. CJG 10-Jun-1983
! 3-006 - Modify to use EDT$$TI_BUFSTR for journalling. CJG 15-Jun-1983
! 3-007 - Scan input from command file for nulls and convert to ^_ which the
!         parser can understand. CJG 8-Nov-1983
! 3-008 - Make sure that Control-H works in the main parser. CJG 20-Dec-1983
! 3-009 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$GET_LN;

!
! INCLUDE FILES:
!

REQUIRE 'SYS:JSYS';

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!
! EQUATED SYMBOLS:
!

EXTERNAL LITERAL
    EDT$K_GET,
    EDT$K_COMMAND_FILE;

!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!

EXTERNAL
    CMD_BUF,
    CMD_LEN,
    CMD_END,
    CMD_PTR,
    TEMP_BUFFER,
    SAV_CNT,
    RCOV_MOD,
    INP_SRC,
    MAC_BUF,
    CUR_BUF,
    VFY,
    EOB_LN,
    WK_LN : REF LIN_BLOCK,
    JOU_VALID;				! 1 = journal record is valid


EXTERNAL ROUTINE
    EDT$FILEIO,
    EDT$$RD_JOUTXT,			! Read a text line from the journal file
    EDT$$TI_BUFCH : NOVALUE,		! Put a character in the journal file buffer
    EDT$$TI_BUFSTR : NOVALUE,		! Put a string in the journal file
    EDT$$TI_FLUSHJOUFI : NOVALUE,	! Write out journal file buffer
    EDT$$TI_WRLN,
    EDT$$RD_CMDLN,
    EDT$$RD_CURLN,
    EDT$$RD_NXTLN;

%SBTTL 'EDT$$GET_LN  - return a line'

GLOBAL ROUTINE EDT$$GET_LN (			! Return a line
    PARSE,					! 1=parser will be called next
    PROMPT, 					! Address of the prompt
    PR_LEN					! Length of the prompt
    ) =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine returns a line from the current macro or from the
!	terminal or command file.
!
! FORMAL PARAMETERS:
!
!  PROMPT		The address of a prompt string for terminal input
!
!  PR_LEN		The length of the prompt
!
!
! IMPLICIT INPUTS:
!
!	INP_SRC    - 	tells where the input line will come from.
!	RCOV_MOD
!	WK_LN
!	MAC_BUF
!	VFY
!
! IMPLICIT OUTPUTS:
!
!	CMD_BUF
!	CMD_LEN
!	CUR_BUF
!	CMD_END
!	CMD_PTR
!	JOU_VALID
!
! COMPLETION CODES:
!
!	0	-	No eof occured on this line
!	1	-	An eof did occur
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    LOCAL
	FILE_DESC : BLOCK [1],
	EOF;

    FILE_DESC [DSC$A_POINTER] = 0;
    FILE_DESC [DSC$W_LENGTH] = 0;
    EOF = 0;

    CASE .INP_SRC FROM INP_TERM TO INP_JOURNAL OF
	SET

	[INP_TERM] :
!+
! Input is coming from the terminal (or command procedure)
!-
	    BEGIN
!+
! Since we are about to read from the terminal, make sure the last
! line has been written to the journal file.
!-
	    EDT$$TI_FLUSHJOUFI (%C'T');
	    IF (NOT .PARSE) THEN
		BEGIN
		EOF = EDT$$RD_CMDLN (.PROMPT, .PR_LEN, CMD_BUF, CMD_LEN, 255);
!+
! Put the new line in the journal file buffer.
!-
		EDT$$TI_BUFSTR (CH$PTR (CMD_BUF,, BYTE_SIZE), .CMD_LEN);

		IF .EOF
		THEN
		    BEGIN
		    EDT$$TI_BUFCH (%C'^');
		    EDT$$TI_BUFCH (%C'Z');
		    END;


!+
! Even if we put no characters into the journal record (because the line
! is empty) it is important to output the record next time around, since
! an empty record changes the current line.
!-
		JOU_VALID = 1;
		END;
	    END;

	[INP_JOURNAL] :
!+
! Input is coming from the journal file.
!-
	    BEGIN
	    ASSERT (13, .RCOV_MOD);

	    IF EDT$$RD_JOUTXT (CMD_BUF, CMD_LEN)
	    THEN
		EDT$$TI_WRLN (CMD_BUF, .CMD_LEN)
	    ELSE
		BEGIN
		EOF = 1;
		CMD_LEN = 0;
		END

	    END;

	[INP_COMMAND] :
!+
! Input is coming from the startup file.
!-
	    BEGIN

	    LOCAL
		C,
		P1,
		P2,
		STATUS;

	    STATUS = EDT$FILEIO (EDT$K_GET, EDT$K_COMMAND_FILE, FILE_DESC);

	    IF .STATUS
	    THEN
		BEGIN
		CMD_LEN = .FILE_DESC [DSC$W_LENGTH];
		P1 = CH$PTR (.FILE_DESC [DSC$A_POINTER],, BYTE_SIZE);
		P2 = CH$PTR (CMD_BUF,, BYTE_SIZE);

!+
!Scan through the command line looking for nulls. Convert these to ^_ for
!the parser.
!-
		INCR I FROM 1 TO .CMD_LEN DO
		    BEGIN
		    C = CH$RCHAR_A (P1);
		    IF (.C EQL 0) THEN C = %O'37';
		    CH$WCHAR_A (.C, P2);
		    END;

		END
	    ELSE
		BEGIN
		EOF = 1;
		CMD_LEN = 0;
		END;

	    END;

	[INP_MACRO] :
	    BEGIN

	    LOCAL
		SAVE_TBCB;

	    SAVE_TBCB = .CUR_BUF;
	    CUR_BUF = .MAC_BUF;
	    EDT$$RD_CURLN ();

	    IF (.WK_LN NEQA EOB_LN )
	    THEN
		BEGIN
		CH$MOVE (.WK_LN [LIN_LENGTH], CH$PTR (WK_LN [LIN_TEXT],, BYTE_SIZE),
		    CH$PTR ( CMD_BUF,, BYTE_SIZE));
		CMD_LEN = .WK_LN [LIN_LENGTH];
		EDT$$RD_NXTLN ()
		END
	    ELSE
		BEGIN
		EOF = 1;
		CMD_LEN = 0;
		END;

	    CUR_BUF = .SAVE_TBCB;
	    EDT$$RD_CURLN ();
	    END;

	[INRANGE, OUTRANGE] :
	    ASSERT (9, 0);
	TES;

!+
! If input is coming from a file see if the line ended with ^Z or EOF found.
!-

    IF ((.INP_SRC NEQ INP_TERM) AND ( NOT .EOF)) THEN
	BEGIN

	IF CH$EQL (2, CH$PTR (CMD_BUF, .CMD_LEN - 2, BYTE_SIZE),
		   2, CH$PTR (UPLIT (%STRING('^Z'))))
	THEN
	    BEGIN
	    CMD_LEN = .CMD_LEN - 2;
	    EOF = 1;
	    END;

	IF .VFY THEN EDT$$TI_WRLN (CMD_BUF, .CMD_LEN);

	IF .PARSE THEN
	    BEGIN
	    LOCAL
		PTR;

!+
! If the data is required for the parser, then copy the command to the rescan
! buffer (unless its from the terminal). The string must be terminated by
! <CR><LF><NUL> for this to work.
!-

	    PTR = CH$MOVE (.CMD_LEN, CH$PTR (CMD_BUF,, BYTE_SIZE),
				     CH$PTR (TEMP_BUFFER,, BYTE_SIZE));
	    PTR = CH$MOVE (3, CH$PTR (UPLIT (%STRING (%CHAR (ASC_K_CR, ASC_K_LF, 0)))), .PTR);
	    _RSCAN (CH$PTR (TEMP_BUFFER,, BYTE_SIZE));
	    _RSCAN ($RSINI);
	    END;

	END;


    CMD_END = CH$PTR (CMD_BUF, .CMD_LEN, BYTE_SIZE);
    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);

    RETURN (.EOF);
    END;


END
ELUDOM