148083Sbostic(*
2*62158Sbostic * Copyright (c) 1980, 1993
3*62158Sbostic *	The Regents of the University of California.  All rights reserved.
448083Sbostic *
548083Sbostic * %sccs.include.redist.c%
648083Sbostic *
7*62158Sbostic *	@(#)pcerror.p	8.1 (Berkeley) 06/06/93
848083Sbostic *)
948083Sbostic
1048083Sbosticprogram errs(input,output,junk,locked);
1148083Sbostic
1248083Sbosticlabel	99;
1348083Sbostic
1448083Sbostictype
1548083Sbosticetype = (ECHR, EHALT, ENILPTR, ECASE, EOUTOFMEM, ECTSNG,
1648083SbosticESTLIM, EARGV, EPACK, EUNPACK, EASRT, ELLIMIT, ETRASHHEAP, EPASTEOF,
1748083SbosticEREFINAF, ENOFILE, ENAMESIZE, EBADINUM, EBADFNUM, ENUMNTFD, ENAMRNG,
1848083SbosticEFMTSIZE, ESEEK, ECREATE, EREMOVE, EOPEN, EREADIT, EWRITEIT, ESQRT,
1948083SbosticELN, ERANGE, ESUBSC, EGOTO, ECLOSE, EWRITE, ECTLWR, ECTUPR, xxx);
2048083Sbosticbiggie = array[1..15000] of integer;
2148083Sbostic
2248083Sbosticvar
2348083Sbosticch :char;
2448083Sbosticchs :alfa;
2548083Sbosticch1 :array[1..10] of char;
2648083Sbosticptr, ptr1 :^char;
2748083Sbosticptr2 :^biggie;
2848083Sbosticjunk, locked, other :file of char;
2948083Sbosticvariant :record
3048083Sbostic	case boolean of
3148083Sbostic	true:(val :1..100);
3248083Sbostic	false:(name :etype)
3348083Sbostic	end;
3448083Sbostics :set of 1..4;
3548083Sbostici :integer;
3648083Sbosticr :real;
3748083Sbosticerr :etype;
3848083Sbostic
3948083Sbosticbegin
4048083Sbosticwriteln('Want a list of error names?');
4148083Sbosticreadln(ch);
4248083Sbosticif ch = 'y' then begin
4348083Sbostic	for err:=ECHR to pred(xxx) do begin
4448083Sbostic		write(err:15);
4548083Sbostic		if ord(err) mod 5 = 4 then
4648083Sbostic			writeln;
4748083Sbostic		end;
4848083Sbostic	writeln;
4948083Sbostic	end;
5048083Sbosticwriteln('enter an error name');
5148083Sbosticreadln(err);
5248083Sbosticif err in [ESEEK, EGOTO, ECLOSE, EWRITE] then begin
5348083Sbostic	writeln(err, ': error cannot be simulated');
5448083Sbostic	goto 99;
5548083Sbostic	end;
5648083Sbosticcase err of
5748083SbosticECHR: ch:=chr(128);
5848083SbosticEHALT: halt;
5948083SbosticENILPTR: ch:=ptr^;
6048083SbosticECASE: case 4 of 1:; end;
6148083SbosticEOUTOFMEM: while true do begin
6248083Sbostic		new(ptr2);
6348083Sbostic		writeln('alloc successful');
6448083Sbostic		end;
6548083SbosticECTLWR: begin
6648083Sbostic	i:=0;
6748083Sbostic	s:=[i..2];
6848083Sbostic	end;
6948083SbosticECTUPR: begin
7048083Sbostic	i:=5;
7148083Sbostic	s:=[1..i];
7248083Sbostic	end;
7348083SbosticECTSNG: begin
7448083Sbostic	i:=0;
7548083Sbostic	s:=[i];
7648083Sbostic	end;
7748083SbosticESTLIM: stlimit(0);
7848083SbosticEARGV: argv(100,chs);
7948083SbosticEPACK: pack(ch1,2,chs);
8048083SbosticEUNPACK: unpack(chs,ch1,2);
8148083SbosticEASRT: assert(false);
8248083SbosticELLIMIT: begin
8348083Sbostic	 linelimit(output,1);
8448083Sbostic	 writeln('This only should print');
8548083Sbostic	 writeln;
8648083Sbostic	 writeln('ERROR');
8748083Sbostic	 end;
8848083SbosticETRASHHEAP: begin
8948083Sbostic	    new(ptr);
9048083Sbostic	    ptr1:=ptr;
9148083Sbostic	    dispose(ptr1);
9248083Sbostic	    dispose(ptr);
9348083Sbostic	    end;
9448083SbosticEPASTEOF: begin
9548083Sbostic	  rewrite(junk);
9648083Sbostic	  reset(junk);
9748083Sbostic	  get(junk);
9848083Sbostic	  get(junk);
9948083Sbostic	  write(junk^);
10048083Sbostic	  end;
10148083SbosticEREFINAF: ch:=junk^;
10248083SbosticENOFILE: ch:=other^;
10348083SbosticENAMESIZE: rewrite(junk,
10448083Sbostic'thisisaverylongandconvolutedfilenamewhichexceedsalllimitsofreasonablenessandgoodtaste');
10548083SbosticEBADINUM: begin
10648083Sbostic	  writeln('Enter a letter');
10748083Sbostic	  read(i);
10848083Sbostic	  end;
10948083SbosticEBADFNUM: begin
11048083Sbostic	  writeln('Enter a letter');
11148083Sbostic	  read(r);
11248083Sbostic	  end;
11348083SbosticENUMNTFD: begin
11448083Sbostic	  writeln('Enter your name');
11548083Sbostic	  read(err);
11648083Sbostic	  end;
11748083SbosticENAMRNG:  begin
11848083Sbostic	  variant.val:=100;
11948083Sbostic	  writeln(variant.name);
12048083Sbostic	  end;
12148083SbosticEFMTSIZE: begin
12248083Sbostic	  i:=-1;
12348083Sbostic	  writeln(1.0:i);
12448083Sbostic	  end;
12548083SbosticECREATE: rewrite(locked);
12648083SbosticEREMOVE: remove('none');
12748083SbosticEOPEN: reset(locked);
12848083SbosticEREADIT: read(output,ch);
12948083SbosticEWRITEIT: write(input,ch);
13048083SbosticESQRT: r:=sqrt(-1.0);
13148083SbosticELN: r:=ln(0);
13248083SbosticERANGE: ch:=succ(chr(127));
13348083SbosticESUBSC: ch:=ch1[127 + 1];
13448083Sbosticend;
13548083Sbosticwriteln('*** ERROR NOT DETECTED ***');
13648083Sbostic99:end.
137