Trailing-Edge
-
PDP-10 Archives
-
bb-lw55a-bm
-
language-sources/string.b36
There are 22 other files named string.b36 in the archive. Click here to see a list.
MODULE STRING( ! General-purpose string-handling functions
IDENT='1',
ENTRY(MOVEAZ, FSUBAZ)
) =
BEGIN
! COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1982, 1986.
! 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: RMS
!
! ABSTRACT:
! ASCIZ string manipulation
!
! ENVIRONMENT: Transportable
!
! AUTHOR: Andrew Nourse
!
! Table of Contents
!
FORWARD ROUTINE
MOVEAZ,
FSUBAZ;
GLOBAL ROUTINE MOVEAZ(SPTR,DPTR)=
!Copy an ASCIZ string
!SPTR: ADDRESS OF source byte pointer (returned untouched)
!DPTR: ADDRESS OF destination byte pointer (returned updated)
!Returns length of string
BEGIN
LOCAL SP;
LOCAL C; !Character we just read
SP=..SPTR; !Make a copy of source pointer
INCR LEN FROM 0 BY 1 DO
BEGIN
IF (C=CH$RCHAR_A(SP)) EQL 0 THEN
(CH$WCHAR(0,..DPTR); RETURN .LEN);
!Make ASCIZ string of dest, but don't bump DPTR past null byte
CH$WCHAR_A(.C,.DPTR)
END;
END; !MOVEAZ
GLOBAL ROUTINE FSUBAZ(TARGET,PATTERN)=
BEGIN
LOCAL
F, ! FIRST PATTERN CHARACTER
TPATTERN; ! CURRENT PATTERN POINTER
TPATTERN=.PATTERN;
F=CH$RCHAR_A(TPATTERN);
DO BEGIN
SELECT CH$RCHAR(.TARGET) OF
SET
[.F]: BEGIN
LOCAL TTPATTERN; ! Current Pattern pointer
LOCAL TTARGET, ! Current Target pointer
P; ! Current Pattern character
TTPATTERN=.TPATTERN; !
TTARGET=.TARGET;
CH$RCHAR_A(TTARGET);
WHILE (P=CH$RCHAR_A(TTPATTERN)) EQL CH$RCHAR_A(TTARGET)
DO (IF .P EQL 0 THEN EXITLOOP);
IF .P EQL 0 THEN RETURN .TARGET; ! End of Pattern -- MATCH
TTPATTERN=.TPATTERN; ! Reset to start of pattern
END;
[0]: RETURN 0; ! No match
TES;
CH$RCHAR_A(TARGET); ! Not yet
END WHILE 1;
END;
END ELUDOM