perm filename LOWCAS.MAC[SIM,SYS] blob sn#460118 filedate 1979-07-20 generic text, type T, neo UTF8
COMMENT * SIMULA specification;
OPTIONS(/E:QUICK,lowcase);
TEXT PROCEDURE lowcase(t); TEXT t;
COMMENT converts all letters [A-Z] in t to lower case in situ (no copying).
	lowcase:-t;

! IF t=/= NOTEXT THEN
! BEGIN	CHARACTER c;
!	INTEGER shift;
!	shift:= Rank('a') - Rank('A');
!	t.Setpos(1);
!	WHILE	t.More	DO
!	BEGIN	c:= t.Getchar;
!		IF	Letter(c)	THEN
!		BEGIN	IF	c>='A' AND c<='Z'	THEN
!			BEGIN	c:= Char(Rank(c)+shift);
!				t.Setpos(t.Pos-1);
!				t.Putchar(c);
!	END	END	END;
!	lowcase:- t
! END;

COMMENT *;! MACRO-10 code *;!

	TITLE	lowcase
	ENTRY	lowcase
	sall
	search	simmcr,simmac
	macinit
	SUBTTL	SIMULA utility, Lars Enderin Feb 1976

;!*** Copyright 1976 by the Swedish Defence Research Institute. ***
;!*** Copying is allowed.					***


lowcase:PROC
	EXCH	XWAC1,(XTAC)
	JUMPE	XWAC1,L9	;! NOTEXT
	EXCH	XWAC2,1(XTAC)
	STACK	X2
	SETZ	X1,
	LF	X0,ZTVSP(,XWAC1)
	IF	;! Subtext
		JUMPE	X0,FALSE
	THEN	;! Split into word offset, byte offset
		IDIVI	X0,5
	FI
	ADD	X0,ptab(x1)
	ADDI	X0,(XWAC1)
	LF	X2,ZTVLNG(,XWAC1)
	LOOP
		ILDB	X1,X0
		IF	;! Upper case
			CAIG	X1,"Z"
			CAIGE	X1,"A"
			GOTO	FALSE
		THEN	;! Make it lower case
			ADDI	X1,"a"-"A"
			DPB	X1,X0
		FI
	AS
		SOJG	X2,TRUE
	SA
	UNSTK	X2
	EXCH	XWAC2,1(XTAC)
L9():!	EXCH	XWAC1,(XTAC)
	RETURN
	EPROC

ptab:	POINT	7,2,-1
	POINT	7,2,06
	POINT	7,2,13
	POINT	7,2,20
	POINT	7,2,27
	POINT	7,2,35
	LIT
	END;