From 5838d4899d4328c5ba320b26d416d1ee32ee1a40 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 3 Jul 1987 16:07:18 +0000 Subject: [PATCH] name changes --- lang/m2/libm2/.distr | 2 +- lang/m2/libm2/LIST | 2 +- lang/m2/libm2/Makefile | 2 +- lang/m2/libm2/PascalIO.def | 120 +++++++++++------------ lang/m2/libm2/PascalIO.mod | 188 ++++++++++++++++++------------------- 5 files changed, 158 insertions(+), 156 deletions(-) diff --git a/lang/m2/libm2/.distr b/lang/m2/libm2/.distr index 1efb87e8d..3ccc63568 100644 --- a/lang/m2/libm2/.distr +++ b/lang/m2/libm2/.distr @@ -4,7 +4,7 @@ ASCII.def Arguments.def Conversion.def EM.def -PascalIo.def +PascalIO.def InOut.def Makefile Mathlib.def diff --git a/lang/m2/libm2/LIST b/lang/m2/libm2/LIST index 30ba3cf83..2a359a1ea 100644 --- a/lang/m2/libm2/LIST +++ b/lang/m2/libm2/LIST @@ -1,5 +1,5 @@ tail_m2.a -PascalIo.mod +PascalIO.mod RealInOut.mod InOut.mod Terminal.mod diff --git a/lang/m2/libm2/Makefile b/lang/m2/libm2/Makefile index 286d4d8bc..445237e26 100644 --- a/lang/m2/libm2/Makefile +++ b/lang/m2/libm2/Makefile @@ -5,7 +5,7 @@ SOURCES = ASCII.def EM.def MathLib0.def Processes.def \ RealInOut.def Storage.def Arguments.def Conversion.def \ random.def Semaphores.def Unix.def RealConver.def \ Strings.def InOut.def Terminal.def TTY.def \ - Mathlib.def PascalIo.def Traps.def + Mathlib.def PascalIO.def Traps.def all: diff --git a/lang/m2/libm2/PascalIO.def b/lang/m2/libm2/PascalIO.def index 87c500762..e45a59cfb 100644 --- a/lang/m2/libm2/PascalIO.def +++ b/lang/m2/libm2/PascalIO.def @@ -1,85 +1,87 @@ -DEFINITION MODULE PascalIo; +DEFINITION MODULE PascalIO; (* This module provides for I/O that is essentially equivalent to the I/O provided by Pascal with "text", or "file of char". However, the user must call a cleanup routine at the end of his program for the output buffers to be flushed. *) - CONST EOS = 0C; (* End of string character *) + CONST Eos = 0C; (* End of string character *) TYPE Text; - VAR input, output: Text; (* standard input and standard output available + VAR Input, Output: Text; (* standard input and standard output available immediately. Standard output is not buffered when connected to a terminal. *) - VAR notext: Text; (* Initialize your Text variables with this *) + VAR Notext: Text; (* Initialize your Text variables with this *) - PROCEDURE Reset(filename: ARRAY OF CHAR; VAR inputtext: Text); - (* When inputtext indicates an open textfile, it is first flushed - and closed. Then, the file indicated by "filename" is opened for reading. - If this fails, a runtime error results. Otherwise, inputtext is + PROCEDURE Reset(Filename: ARRAY OF CHAR; VAR InputText: Text); + (* When InputText indicates an open textfile, it is first flushed + and closed. Then, the file indicated by "Filename" is opened for reading. + If this fails, a runtime error results. Otherwise, InputText is associated with the new input file. *) - PROCEDURE Rewrite(filename: ARRAY OF CHAR; VAR outputtext: Text); - (* When outputtext indicates an open textfile, it is first flushed - and closed. Then, the file indicated by "filename" is opened for writing. - If this fails, a runtime error results. Otherwise, outputtext is + PROCEDURE Rewrite(Filename: ARRAY OF CHAR; VAR OutputText: Text); + (* When OutputText indicates an open textfile, it is first flushed + and closed. Then, the file indicated by "Filename" is opened for writing. + If this fails, a runtime error results. Otherwise, OutputText is associated with the new output file. *) - PROCEDURE PascalIoCleanup(); + PROCEDURE CloseOutput(); (* To be called at the end of the program, to flush all output buffers *) (*************************************************************************** Input routines; All these routines result in a runtime error when not called with either - "input", or a "Text" value obtained by Reset. + "Input", or a "Text" value obtained by Reset. Also, the routines that actually advance the "read pointer", result in a runtime error when end of file is reached prematurely. ****************************************************************************) - PROCEDURE NextCHAR(inputtext: Text): CHAR; - (* Returns the next character of the inputtext, 0C on end of file. + PROCEDURE NextChar(InputText: Text): CHAR; + (* Returns the next character of the InputText, 0C on end of file. Does not advance the "read pointer", so behaves much like "input^" - in Pascal. However, unlike Pascal, if Eoln(inputtext) is true, it + in Pascal. However, unlike Pascal, if Eoln(InputText) is true, it returns the newline character, rather than a space. *) - PROCEDURE Get(inputtext: Text); + PROCEDURE Get(InputText: Text); (* Advances the "read pointer" by one character *) - PROCEDURE Eoln(inputtext: Text): BOOLEAN; - (* Returns TRUE if the next character of the inputtext is a linefeed *) + PROCEDURE Eoln(InputText: Text): BOOLEAN; + (* Returns TRUE if the next character of the InputText is a linefeed *) - PROCEDURE Eof(inputtext: Text): BOOLEAN; - (* Returns TRUE if the end of the inputtext is reached *) + PROCEDURE Eof(InputText: Text): BOOLEAN; + (* Returns TRUE if the end of the InputText is reached *) - PROCEDURE ReadCHAR(inputtext: Text; VAR ch: CHAR); - (* Read a character from the inputtext, and leave result in "ch" *) + PROCEDURE ReadChar(InputText: Text; VAR Char: CHAR); + (* Read a character from the InputText, and leave result in "Char" *) - PROCEDURE ReadLn(inputtext: Text); - (* Skip the rest of the current line of the inputtext, including the linefeed *) + PROCEDURE ReadLn(InputText: Text); + (* Skip the rest of the current line of the InputText, + including the linefeed + *) - PROCEDURE ReadINTEGER(inputtext: Text; VAR int: INTEGER); + PROCEDURE ReadInteger(InputText: Text; VAR Integer: INTEGER); (* Skip leading blanks, read an optionally signed integer from the - inputtext, and leave the result in "int". + InputText, and leave the result in "Integer". If no integer is read, or when overflow occurs, a runtime error results. Input stops at the character following the integer. *) - PROCEDURE ReadCARDINAL(inputtext: Text; VAR card: CARDINAL); - (* Skip leading blanks, read a cardinal from the inputtext, and leave the + PROCEDURE ReadCardinal(InputText: Text; VAR Cardinal: CARDINAL); + (* Skip leading blanks, read a cardinal from the InputText, and leave the result in "card". If no cardinal is read, or when overflow occurs, a runtime error results. Input stops at the character following the integer. *) - PROCEDURE ReadREAL(inputtext: Text; VAR real: REAL); - (* Skip leading blanks, read a real from the inputtext, and leave the - result in "card". + PROCEDURE ReadReal(InputText: Text; VAR Real: REAL); + (* Skip leading blanks, read a real from the InputText, and leave the + result in "Real". Syntax: real --> [(+|-)] digit {digit} [. digit {digit}] [ E [(+|-)] digit {digit} ] @@ -91,48 +93,48 @@ DEFINITION MODULE PascalIo; (*************************************************************************** Output routines; All these routines result in a runtime error when not called with either - "output", or a "Text" value obtained by Rewrite. + "Output", or a "Text" value obtained by Rewrite. ****************************************************************************) - PROCEDURE WriteCHAR(outputtext: Text; ch: CHAR); - (* Writes the character "ch" to the outputtext *) + PROCEDURE WriteChar(OutputText: Text; Char: CHAR); + (* Writes the character "Char" to the OutputText *) - PROCEDURE WriteLn(outputtext: Text); - (* Writes a linefeed to the outputtext *) + PROCEDURE WriteLn(OutputText: Text); + (* Writes a linefeed to the OutputText *) - PROCEDURE Page(outputtext: Text); - (* Writes a form-feed to the outputtext *) + PROCEDURE Page(OutputText: Text); + (* Writes a form-feed to the OutputText *) - PROCEDURE WriteINTEGER(outputtext: Text; int: INTEGER; width: CARDINAL); - (* Write integer "int" to the outputtext, using at least "width" places, + PROCEDURE WriteInteger(OutputText: Text; Integer: INTEGER; Width: CARDINAL); + (* Write integer "Integer" to the OutputText, using at least "Width" places, blank-padding to the left if needed. *) - PROCEDURE WriteCARDINAL(outputtext: Text; card: CARDINAL; width: CARDINAL); - (* Write cardinal "card" to the outputtext, using at least "width" places, - blank-padding to the left if needed. + PROCEDURE WriteCardinal(OutputText: Text; Cardinal, Width: CARDINAL); + (* Write cardinal "Cardinal" to the OutputText, using at least + "Width" places, blank-padding to the left if needed. *) - PROCEDURE WriteBOOLEAN(outputtext: Text; bool: BOOLEAN; width: CARDINAL); - (* Write boolean "bool" to the outputtext, using at least "width" places, + PROCEDURE WriteBoolean(OutputText: Text; Boolean: BOOLEAN; Width: CARDINAL); + (* Write boolean "Boolean" to the OutputText, using at least "Width" places, blank-padding to the left if needed. - Equivalent to WriteSTRING(" TRUE", width), or - WriteSTRING("FALSE", width) + Equivalent to WriteString(" TRUE", Width), or + WriteString("FALSE", Width) *) - PROCEDURE WriteSTRING(outputtext: Text; - str: ARRAY OF CHAR; width: CARDINAL); - (* Write string "str" to the outputtext, using at least "width" places, + PROCEDURE WriteString(OutputText: Text; + String: ARRAY OF CHAR; Width: CARDINAL); + (* Write string "String" to the OutputText, using at least "Width" places, blank-padding to the left if needed. - The string is terminated either by the character EOS, or the upperbound of - the array "str". + The string is terminated either by the character Eos, or the upperbound of + the array "String". *) - PROCEDURE WriteREAL(outputtext: Text; real: REAL; width, nfrac: CARDINAL); - (* Write real "real" to the outputtext. If "nfrac" = 0, use scientific - notation, otherwise use fixed-point notation with "nfrac" digits behind + PROCEDURE WriteReal(OutputText: Text; Real: REAL; Width, Nfrac: CARDINAL); + (* Write real "Real" to the OutputText. If "Nfrac" = 0, use scientific + notation, otherwise use fixed-point notation with "Nfrac" digits behind the dot. - Always use at least "width" places, blank-padding to the left if needed. + Always use at least "Width" places, blank-padding to the left if needed. *) -END PascalIo. +END PascalIO. diff --git a/lang/m2/libm2/PascalIO.mod b/lang/m2/libm2/PascalIO.mod index b59f7313f..aeb851e11 100644 --- a/lang/m2/libm2/PascalIO.mod +++ b/lang/m2/libm2/PascalIO.mod @@ -1,4 +1,4 @@ -IMPLEMENTATION MODULE PascalIo; +IMPLEMENTATION MODULE PascalIO; IMPORT Unix; IMPORT Conversions; @@ -30,13 +30,13 @@ IMPLEMENTATION MODULE PascalIo; VAR ibuf, obuf: IOBuf; head: Text; - PROCEDURE Reset(filename: ARRAY OF CHAR; VAR inputtext: Text); + PROCEDURE Reset(Filename: ARRAY OF CHAR; VAR InputText: Text); BEGIN - doclose(inputtext); - getstruct(inputtext); - WITH inputtext^ DO + doclose(InputText); + getstruct(InputText); + WITH InputText^ DO eof := FALSE; - fildes := Unix.open(ADR(filename), 0); + fildes := Unix.open(ADR(Filename), 0); IF fildes < 0 THEN Traps.Message("could not open input file"); HALT; @@ -48,13 +48,13 @@ IMPLEMENTATION MODULE PascalIo; END; END Reset; - PROCEDURE Rewrite(filename: ARRAY OF CHAR; VAR outputtext: Text); + PROCEDURE Rewrite(Filename: ARRAY OF CHAR; VAR OutputText: Text); BEGIN - doclose(outputtext); - getstruct(outputtext); - WITH outputtext^ DO + doclose(OutputText); + getstruct(OutputText); + WITH OutputText^ DO eof := FALSE; - fildes := Unix.creat(ADR(filename), 666B); + fildes := Unix.creat(ADR(Filename), 666B); IF fildes < 0 THEN Traps.Message("could not open output file"); HALT; @@ -66,7 +66,7 @@ IMPLEMENTATION MODULE PascalIo; END; END Rewrite; - PROCEDURE PascalIoCleanup(); + PROCEDURE CloseOutput(); VAR text: Text; BEGIN text := head; @@ -74,12 +74,12 @@ IMPLEMENTATION MODULE PascalIo; doclose(text); text := text^.next; END; - END PascalIoCleanup; + END CloseOutput; PROCEDURE doclose(text: Text); VAR dummy: INTEGER; BEGIN - IF text # notext THEN + IF text # Notext THEN WITH text^ DO IF type = writing THEN Flush(text); @@ -117,37 +117,37 @@ IMPLEMENTATION MODULE PascalIo; END; END chk; - PROCEDURE ReadCHAR(inputtext: Text; VAR ch : CHAR); + PROCEDURE ReadChar(InputText: Text; VAR ch : CHAR); BEGIN - ch := NextCHAR(inputtext); - Get(inputtext); - END ReadCHAR; + ch := NextChar(InputText); + Get(InputText); + END ReadChar; - PROCEDURE NextCHAR(inputtext: Text): CHAR; + PROCEDURE NextChar(InputText: Text): CHAR; VAR c: CHAR; BEGIN - chk(inputtext, reading); - WITH inputtext^ DO + chk(InputText, reading); + WITH InputText^ DO IF cnt <= maxcnt THEN c := buf[cnt]; ELSE - c := FillBuf(inputtext); + c := FillBuf(InputText); END; END; RETURN c; - END NextCHAR; + END NextChar; - PROCEDURE Get(inputtext: Text); + PROCEDURE Get(InputText: Text); VAR dummy: CHAR; BEGIN - chk(inputtext, reading); - WITH inputtext^ DO + chk(InputText, reading); + WITH InputText^ DO IF eof THEN Traps.Message("unexpected EOF"); HALT; END; IF cnt > maxcnt THEN - dummy := FillBuf(inputtext); + dummy := FillBuf(InputText); END; INC(cnt); END; @@ -170,21 +170,21 @@ IMPLEMENTATION MODULE PascalIo; RETURN c; END FillBuf; - PROCEDURE Eoln(inputtext: Text): BOOLEAN; + PROCEDURE Eoln(InputText: Text): BOOLEAN; BEGIN - RETURN NextCHAR(inputtext) = 12C; + RETURN NextChar(InputText) = 12C; END Eoln; - PROCEDURE Eof(inputtext: Text): BOOLEAN; + PROCEDURE Eof(InputText: Text): BOOLEAN; BEGIN - RETURN (NextCHAR(inputtext) = 0C) AND inputtext^.eof; + RETURN (NextChar(InputText) = 0C) AND InputText^.eof; END Eof; - PROCEDURE ReadLn(inputtext: Text); + PROCEDURE ReadLn(InputText: Text); VAR ch: CHAR; BEGIN REPEAT - ReadCHAR(inputtext, ch) + ReadChar(InputText, ch) UNTIL ch = 12C; END ReadLn; @@ -197,29 +197,29 @@ IMPLEMENTATION MODULE PascalIo; END; END Flush; - PROCEDURE WriteCHAR(outputtext: Text; ch: CHAR); + PROCEDURE WriteChar(OutputText: Text; ch: CHAR); BEGIN - chk(outputtext, writing); - WITH outputtext^ DO + chk(OutputText, writing); + WITH OutputText^ DO INC(cnt); buf[cnt] := ch; IF cnt >= bufferedcount THEN - Flush(outputtext); + Flush(OutputText); END; END; - END WriteCHAR; + END WriteChar; - PROCEDURE WriteLn(outputtext: Text); + PROCEDURE WriteLn(OutputText: Text); BEGIN - WriteCHAR(outputtext, 12C); + WriteChar(OutputText, 12C); END WriteLn; - PROCEDURE Page(outputtext: Text); + PROCEDURE Page(OutputText: Text); BEGIN - WriteCHAR(outputtext, 14C); + WriteChar(OutputText, 14C); END Page; - PROCEDURE ReadINTEGER(inputtext: Text; VAR int : INTEGER); + PROCEDURE ReadInteger(InputText: Text; VAR int : INTEGER); CONST SAFELIMITDIV10 = MAX(INTEGER) DIV 10; SAFELIMITREM10 = MAX(INTEGER) MOD 10; @@ -229,17 +229,17 @@ IMPLEMENTATION MODULE PascalIo; ch: CHAR; chvalue: CARDINAL; BEGIN - WHILE NextCHAR(inputtext) IN spaces DO - Get(inputtext); + WHILE NextChar(InputText) IN spaces DO + Get(InputText); END; - ch := NextCHAR(inputtext); + ch := NextChar(InputText); IF ch = '-' THEN - Get(inputtext); - ch := NextCHAR(inputtext); + Get(InputText); + ch := NextChar(InputText); neg := TRUE; ELSIF ch = '+' THEN - Get(inputtext); - ch := NextCHAR(inputtext); + Get(InputText); + ch := NextChar(InputText); neg := FALSE; ELSE neg := FALSE @@ -258,8 +258,8 @@ IMPLEMENTATION MODULE PascalIo; HALT; ELSE int := 10*int - VAL(INTEGER, chvalue); - Get(inputtext); - ch := NextCHAR(inputtext); + Get(InputText); + ch := NextChar(InputText); END; END; IF NOT neg THEN @@ -269,9 +269,9 @@ IMPLEMENTATION MODULE PascalIo; Traps.Message("integer expected"); HALT; END; - END ReadINTEGER; + END ReadInteger; - PROCEDURE ReadCARDINAL(inputtext: Text; VAR card : CARDINAL); + PROCEDURE ReadCardinal(InputText: Text; VAR card : CARDINAL); CONST SAFELIMITDIV10 = MAX(CARDINAL) DIV 10; SAFELIMITREM10 = MAX(CARDINAL) MOD 10; @@ -281,10 +281,10 @@ IMPLEMENTATION MODULE PascalIo; safedigit: CARDINAL; chvalue: CARDINAL; BEGIN - WHILE NextCHAR(inputtext) IN spaces DO - Get(inputtext); + WHILE NextChar(InputText) IN spaces DO + Get(InputText); END; - ch := NextCHAR(inputtext); + ch := NextChar(InputText); safedigit := SAFELIMITREM10; card := 0; IF (ch >= '0') AND (ch <= '9') THEN @@ -297,17 +297,17 @@ IMPLEMENTATION MODULE PascalIo; HALT; ELSE card := 10*card + chvalue; - Get(inputtext); - ch := NextCHAR(inputtext); + Get(InputText); + ch := NextChar(InputText); END; END; ELSE Traps.Message("cardinal expected"); HALT; END; - END ReadCARDINAL; + END ReadCardinal; - PROCEDURE ReadREAL(inputtext: Text; VAR real: REAL); + PROCEDURE ReadReal(InputText: Text; VAR real: REAL); VAR buf: numbuf; ch: CHAR; @@ -318,17 +318,17 @@ IMPLEMENTATION MODULE PascalIo; BEGIN buf[index] := ch; INC(index); - Get(inputtext); - RETURN NextCHAR(inputtext); + Get(InputText); + RETURN NextChar(InputText); END inch; BEGIN index := 0; ok := TRUE; - WHILE NextCHAR(inputtext) IN spaces DO - Get(inputtext); + WHILE NextChar(InputText) IN spaces DO + Get(InputText); END; - ch := NextCHAR(inputtext); + ch := NextChar(InputText); IF (ch ='+') OR (ch = '-') THEN ch := inch(); END; @@ -370,34 +370,34 @@ IMPLEMENTATION MODULE PascalIo; Traps.Message("Illegal real"); HALT; END; - END ReadREAL; + END ReadReal; - PROCEDURE WriteCARDINAL(outputtext: Text; card: CARDINAL; width: CARDINAL); + PROCEDURE WriteCardinal(OutputText: Text; card: CARDINAL; width: CARDINAL); VAR buf : numbuf; BEGIN Conversions.ConvertCardinal(card, 1, buf); - WriteSTRING(outputtext, buf, width); - END WriteCARDINAL; + WriteString(OutputText, buf, width); + END WriteCardinal; - PROCEDURE WriteINTEGER(outputtext: Text; int: INTEGER; width: CARDINAL); + PROCEDURE WriteInteger(OutputText: Text; int: INTEGER; width: CARDINAL); VAR buf : numbuf; BEGIN Conversions.ConvertInteger(int, 1, buf); - WriteSTRING(outputtext, buf, width); - END WriteINTEGER; + WriteString(OutputText, buf, width); + END WriteInteger; - PROCEDURE WriteBOOLEAN(outputtext: Text; bool: BOOLEAN; width: CARDINAL); + PROCEDURE WriteBoolean(OutputText: Text; bool: BOOLEAN; width: CARDINAL); BEGIN IF bool THEN - WriteSTRING(outputtext, " TRUE", width); + WriteString(OutputText, " TRUE", width); ELSE - WriteSTRING(outputtext, "FALSE", width); + WriteString(OutputText, "FALSE", width); END; - END WriteBOOLEAN; + END WriteBoolean; - PROCEDURE WriteREAL(outputtext: Text; real: REAL; width, nfrac: CARDINAL); + PROCEDURE WriteReal(OutputText: Text; real: REAL; width, nfrac: CARDINAL); VAR buf: numbuf; ok: BOOLEAN; @@ -417,28 +417,28 @@ IMPLEMENTATION MODULE PascalIo; END; RealConversions.RealToString(real, width, digits, buf, ok); END; - WriteSTRING(outputtext, buf, 0); - END WriteREAL; + WriteString(OutputText, buf, 0); + END WriteReal; - PROCEDURE WriteSTRING(outputtext: Text; str: ARRAY OF CHAR; width: CARDINAL); + PROCEDURE WriteString(OutputText: Text; str: ARRAY OF CHAR; width: CARDINAL); VAR index: CARDINAL; BEGIN index := 0; - WHILE (index <= HIGH(str)) AND (str[index] # EOS) DO + WHILE (index <= HIGH(str)) AND (str[index] # Eos) DO INC(index); END; WHILE index < width DO - WriteCHAR(outputtext, " "); + WriteChar(OutputText, " "); INC(index); END; index := 0; - WHILE (index <= HIGH(str)) AND (str[index] # EOS) DO - WriteCHAR(outputtext, str[index]); + WHILE (index <= HIGH(str)) AND (str[index] # Eos) DO + WriteChar(OutputText, str[index]); INC(index); END; - END WriteSTRING; + END WriteString; -BEGIN (* PascalIo initialization *) +BEGIN (* PascalIO initialization *) WITH ibuf DO eof := FALSE; type := reading; @@ -458,10 +458,10 @@ BEGIN (* PascalIo initialization *) END; cnt := 0; END; - notext := NIL; - input := ADR(ibuf); - output := ADR(obuf); - input^.next := output; - output^.next := NIL; - head := input; -END PascalIo. + Notext := NIL; + Input := ADR(ibuf); + Output := ADR(obuf); + Input^.next := Output; + Output^.next := NIL; + head := Input; +END PascalIO. -- 2.34.1