Browse Source

Fixed interface of querying character positions in strings

git-svn-id: https://svn-dept.inf.ethz.ch/svn/lecturers/a2/trunk@8749 8c9fc860-2736-0410-a75d-ab315db34111
negelef 6 years ago
parent
commit
8fda7536e4

+ 1 - 1
source/Codecs.Mod

@@ -640,7 +640,7 @@ BEGIN
 END GetAnimationDecoder;
 
 PROCEDURE SplitName*(CONST  name : ARRAY OF CHAR; VAR protocol, filename : ARRAY OF CHAR);
-VAR pos, i : LONGINT;
+VAR pos, i : SIZE;
 BEGIN
 	pos := Strings.Pos("://", name);
 	IF pos >= 0 THEN

+ 1 - 1
source/CompilerInterface.Mod

@@ -102,7 +102,7 @@ END GetCompilerByName;
 	if the file extension the compiler requires is part of the filename, e.g. Module.Mod.Bak for the file extension .Mod
 	Returns NIL if no appropriate compiler found *)
 PROCEDURE GetCompilerByFilename*(filename : ARRAY OF CHAR) : Compiler;
-VAR c : Compiler; pos : LONGINT;
+VAR c : Compiler; pos : SIZE;
 BEGIN {EXCLUSIVE}
 	Strings.UpperCase(filename);
 	c := compilers;

+ 4 - 4
source/CyberbitNetInstall.Mod

@@ -19,8 +19,8 @@ TYPE
 		PROCEDURE &New*;
 		VAR res : WORD; temp : ARRAY 16 OF CHAR;
 			r : Streams.Reader; w : Files.Writer;
-			buf: ARRAY BufSize OF CHAR; len : LONGINT;
-			msg, s : ARRAY 256 OF CHAR; i, j : LONGINT;
+			buf: ARRAY BufSize OF CHAR; len, size : LONGINT;
+			msg, s : ARRAY 256 OF CHAR; i, j : SIZE;
 			ftpConnection : FTPClient.FTPClient;
 			errorStr : ARRAY 512 OF CHAR;
 			f : Files.File;
@@ -60,7 +60,7 @@ TYPE
 				INC(j)
 			END;
 			temp[j] := 0X;
-			Strings.StrToInt(temp, i);
+			Strings.StrToInt(temp, size);
 			(* open the local file *)
 			res := -1;
 			IF (Files.Old(file) = NIL) OR (WMDialogs.Confirmation("Confirm overwriting", file) = WMDialogs.ResYes) THEN
@@ -74,7 +74,7 @@ TYPE
 			END;
 			(* create the status window *)
 			NEW(status);
-			status.fileSize := i;
+			status.fileSize := size;
 			status.nofFiles := 1;
 			(* transfer the bytes and update the statuswindow *)
 			IF res = 0 THEN

+ 1 - 1
source/Decoder.Mod

@@ -1718,7 +1718,7 @@ TYPE
 			msg : ARRAY 256 OF CHAR;
 			module : Modules.Module;
 			header: ObjHeader;
-			res: WORD; extPos : LONGINT;
+			res: WORD; extPos : SIZE;
 		BEGIN
 			vc := CreateForm();
 			Init(vc.bounds.GetWidth(), vc.bounds.GetHeight(), FALSE);

+ 2 - 2
source/ExerciseGroups.Mod

@@ -1513,7 +1513,7 @@ TYPE
 
 		PROCEDURE UpdateList(request: HTTPSupport.HTTPRequest; params: DynamicWebpage.ParameterList);
 		VAR tempStr, personOidStr, exerciseNoStr: Strings.String;
-			i, length, sepIdx, personOid, exerciseNo, newGrade: LONGINT; par: DynamicWebpage.Parameter;
+			i, length, sepIdx: SIZE; personOid, exerciseNo, newGrade: LONGINT; par: DynamicWebpage.Parameter;
 			(* params: the grades for all group members *)
 		BEGIN
 			(* if this event handler is manually invoked on this active element such that the active element was not previously
@@ -1701,4 +1701,4 @@ TYPE
 BEGIN
 	NEW(personDesc, ThisModuleNameStr, "Person", GetNewPerson);
 	NEW(groupDesc, ThisModuleNameStr, "Group", GetNewGroup)
-END ExerciseGroups.
+END ExerciseGroups.

+ 1 - 1
source/FSTools.Mod

@@ -357,7 +357,7 @@ VAR
 
 	PROCEDURE PrepareContext(context : Commands.Context; CONST currentFile, arguments : ARRAY OF CHAR);
 	CONST PlaceHolder = "<#filename#>";
-	VAR thisArguments : Strings.String; position : LONGINT;
+	VAR thisArguments : Strings.String; position : SIZE;
 	BEGIN
 		NEW(thisArguments, Strings.Length(arguments) + 1024);
 		COPY(arguments, thisArguments^);

+ 1 - 2
source/FTPClient.Mod

@@ -612,7 +612,7 @@ TYPE
 		END AddFTPEntryToListing;
 
 		PROCEDURE GetCurrentDir*(VAR dir : ARRAY OF CHAR; VAR res : WORD);
-		VAR p : LONGINT;
+		VAR p : SIZE;
 		BEGIN
 			IF ~open OR busy THEN res := -2; RETURN END;
 			w.String("PWD"); w.Ln; w.Update;
@@ -673,4 +673,3 @@ Permanent Comment
 Assertion
 Debug
 
-

+ 1 - 1
source/FoxBasic.Mod

@@ -2146,7 +2146,7 @@ VAR
 	END InstallWriterFactory;
 
 	PROCEDURE Replace(VAR in: ARRAY OF CHAR; CONST this, by: ARRAY OF CHAR);
-	VAR pos: LONGINT;
+	VAR pos: SIZE;
 	BEGIN
 		pos := Strings.Pos(this,in);
 		IF pos >= 0 THEN

+ 1 - 1
source/FoxProgTools.Mod

@@ -491,7 +491,7 @@ TYPE
 			END Add;
 
 			PROCEDURE Do(VAR src: ARRAY OF CHAR);
-			VAR pos: LONGINT; r: Replacement;
+			VAR pos: SIZE; r: Replacement;
 			BEGIN
 				r := first;
 				WHILE r # NIL DO

+ 1 - 2
source/GZip.Mod

@@ -320,7 +320,7 @@ BEGIN
 END GZip;
 
 PROCEDURE UnGZip*(context:Commands.Context);
-VAR filename: Files.FileName; from,to: Files.File; pos:LONGINT;
+VAR filename: Files.FileName; from,to: Files.File; pos: SIZE;
 BEGIN
 	IF context.arg.GetString(filename) THEN
 		pos:=Strings.Pos(".gz", filename);
@@ -345,4 +345,3 @@ END GZip.
 GZip.GZip "../httproot/raphael-min.js" ~
 GZip.UnGZip "../httproot/raphael-min2.js.gz" ~
 
-

+ 1 - 1
source/HTMLTransformer.Mod

@@ -2973,7 +2973,7 @@ END MapBaselineShift;
 PROCEDURE GetExistingFontName(f : String) : String;
 VAR
 	fonts, temp : String;
-	pos : LONGINT;
+	pos : SIZE;
 	font : ARRAY 32 OF CHAR;
 
 	PROCEDURE Get(f : ARRAY OF CHAR; alternatives : BOOLEAN) : String;

+ 2 - 3
source/HTTPSupport.Mod

@@ -20,7 +20,7 @@ TYPE
 			variables*: TFClasses.List; (** List of HTTPVariable *)
 
 		PROCEDURE &Init*(VAR requestHeader: WebHTTP.RequestHeader; bodyReader: Streams.Reader);
-			VAR pos: LONGINT; restLength: LONGINT; uriReader : Streams.StringReader; uriRest : Strings.String;
+			VAR pos, restLength: SIZE; uriReader : Streams.StringReader; uriRest : Strings.String;
 				contentType: ARRAY 40 OF CHAR;
 		BEGIN
 			NEW(variables);
@@ -154,7 +154,7 @@ TYPE
 	END HTTPRequest;
 
 	PROCEDURE RemoveVariablesFromURI*(olduri: ARRAY OF CHAR; VAR newuri: ARRAY OF CHAR);
-	VAR pos: LONGINT;
+	VAR pos: SIZE;
 	BEGIN
 		pos := Strings.Pos("?", olduri);
 		IF (pos > 0) THEN
@@ -261,4 +261,3 @@ version             = "version" EQUAL version-value
 version-value       = 1*DIGIT
 sts-uri             = "sts-uri" EQUAL DQUOTE absoluteURI DQUOTE
 
-

+ 1 - 1
source/ModuleTrees.Mod

@@ -268,7 +268,7 @@ TYPE
 
 			PROCEDURE Expand(path : ARRAY OF CHAR);
 			VAR node, tnode : WMTrees.TreeNode;
-				pos : LONGINT;
+				pos : SIZE;
 				found : BOOLEAN;
 				ident : ARRAY 64 OF CHAR;
 				string : Strings.String;

+ 1 - 1
source/OdVCSBase.Mod

@@ -368,7 +368,7 @@ END ApplyDelta;
 
 PROCEDURE NameToDelta(name: TFileName; VAR df: TFileName);
 VAR
-	i, ofs: LONGINT;
+	i, ofs: SIZE;
 BEGIN
 	i := Strings.Pos(":", name);
 	IF i = -1 THEN (* Add BaseDir *)

+ 3 - 3
source/OdXml.Mod

@@ -619,7 +619,7 @@ END AbsXmlName;
 
 (** Expand an xmlns. *)
 PROCEDURE AbsName * (CONST rawName: ARRAY OF CHAR):OdUtil.Line;
-VAR absName, absSpace, nameSpace, name: OdUtil.Line; colonPos: LONGINT;
+VAR absName, absSpace, nameSpace, name: OdUtil.Line; colonPos: SIZE;
 BEGIN
 	colonPos := Strings.Pos(":", rawName);
 	IF colonPos  > -1 THEN
@@ -761,7 +761,7 @@ END VersionTreeReq;
 PROCEDURE ProppatchReq*(CONST modeName: ARRAY OF CHAR; props: WebHTTP.AdditionalField): XML.Document;
 VAR doc: XML.Document; pu(*propertyupdate*), prop, mode, e : XML.Element;
 	ac: XML.ArrayChars; modePropName, key, attrKey, attrVal: ARRAY 128 OF CHAR;
-	pos: LONGINT; nameVal: StringSplitter;
+	pos: SIZE; nameVal: StringSplitter;
 BEGIN
 	NEW(doc); doc.AddContent(xmlDecl);
 	(* propertyupdate *)
@@ -1054,4 +1054,4 @@ END ArrayChars;
 
 BEGIN
 	xmlDecl := XmlDecl("1.0", "UTF-8"); (* Standard header *)
-END OdXml.
+END OdXml.

+ 1 - 1
source/PETTrees.Mod

@@ -223,7 +223,7 @@ TYPE
 
 			PROCEDURE Expand(path : ARRAY OF CHAR);
 			VAR node, tnode : WMTrees.TreeNode;
-				pos : LONGINT;
+				pos : SIZE;
 				found : BOOLEAN;
 				ident : ARRAY 64 OF CHAR;
 				string : Strings.String;

+ 7 - 17
source/Strings.Mod

@@ -82,9 +82,6 @@ TYPE
 
 	END Buffer;
 
-
-
-
 	OPERATOR "+"*( a: String; CONST b: ARRAY OF CHAR ): String;
 	VAR str: String;
 	BEGIN
@@ -131,7 +128,6 @@ TYPE
 		RETURN str
 	END "+";
 
-
 (** string handling *)
 
 (** returns the length of a string *)
@@ -169,11 +165,11 @@ END Truncate;
  * Returns the position of the first occurrence of pattern in the string or -1 if no occurrence is found.
  * Rabin-Karp algorithm, adopted from Sedgewick.
  *)
-PROCEDURE Pos*(CONST pattern, string: ARRAY OF CHAR): LONGINT;
+PROCEDURE Pos*(CONST pattern, string: ARRAY OF CHAR): SIZE;
 CONST
 	q = 8204957;	(* prime number, {(d+1) * q <= MAX(LONGINT)} *)
 	d = 256;			(* number of different characters *)
-VAR h1, h2, dM, i, j, m, n: LONGINT; found : BOOLEAN;
+VAR h1, h2, dM: LONGINT; i, j, m, n: SIZE; found : BOOLEAN;
 BEGIN
 	m := Length(pattern); n := Length(string);
 	IF (m > n) THEN RETURN -1 END;
@@ -215,11 +211,11 @@ END Pos;
 (** More generic version of Pos. Basically the same search algorithm, but can also perform case-insensitive searching and/or
  * backwards directed searching.
  * Returns the position of the first character of the first occurence of 'pattern' in 'text'  in search direction or -1 if pattern not found *)
-PROCEDURE GenericPos*(CONST pattern: ARRAY OF CHAR; from : LONGINT; CONST string: ARRAY OF CHAR; ignoreCase, backwards : BOOLEAN): LONGINT;
+PROCEDURE GenericPos*(CONST pattern: ARRAY OF CHAR; from : SIZE; CONST string: ARRAY OF CHAR; ignoreCase, backwards : BOOLEAN): SIZE;
 CONST
 	q = 8204957;	(* prime number, {(d+1) * q <= MAX(LONGINT)} *)
 	d = 256;			(* number of different characters *)
-VAR ch, chp : CHAR; h1, h2, dM, i, j, patternLength, stringLength: LONGINT; found : BOOLEAN;
+VAR ch, chp : CHAR; h1, h2, dM: LONGINT; i, j, patternLength, stringLength: SIZE; found : BOOLEAN;
 BEGIN
 	patternLength := Length(pattern); stringLength := Length(string);
 
@@ -392,7 +388,6 @@ PROCEDURE Append* (VAR s: ARRAY OF CHAR; CONST appendix: ARRAY OF CHAR);
 BEGIN Concat (s, appendix, s)
 END Append;
 
-
 (** appends appendix to s: s := s || appendix. The resulting string is truncated to the length of s if necessary *)
 PROCEDURE AppendX* (VAR s: ARRAY OF CHAR; CONST appendix: ARRAY OF CHAR);
 BEGIN ConcatX (s, appendix, s)
@@ -405,7 +400,6 @@ BEGIN
 	IntToStr(num,number); Append(s,number);
 END AppendInt;
 
-
 (** appends a character to a string s := s || char *)
 PROCEDURE AppendChar*(VAR s: ARRAY OF CHAR; ch: CHAR);
 VAR cs: ARRAY 2 OF CHAR;
@@ -413,7 +407,6 @@ BEGIN
 	cs[0] := ch; cs[1] := 0X; Append(s,cs);
 END AppendChar;
 
-
 (** copies src[index ... index + len-1] to dst *)
 PROCEDURE Copy* (CONST src: ARRAY OF CHAR; index, len: SIZE; VAR dst: ARRAY OF CHAR);
 BEGIN
@@ -468,8 +461,8 @@ END Trim;
 (**
  * Splits 'string' into multiple strings separated by 'separator'.
  * Result properties:
- *	separator = 0X: 	LEN(StringArray) = 1
- *	separator # 0X: 	LEN(StringArray) = 1 + <Number of occurences of 'ch' in 'string'>
+ *	separator = 0X:	LEN(StringArray) = 1
+ *	separator # 0X:	LEN(StringArray) = 1 + <Number of occurences of 'ch' in 'string'>
  *	StringArray[i] # NIL (0 <= i <= LEN(StringArray)-1)
  *)
 PROCEDURE Split*(CONST string : ARRAY OF CHAR; separator : CHAR) : StringArray;
@@ -559,7 +552,6 @@ BEGIN
 	RETURN (ch>=20X) & (ch<=7EX)
 END IsPrintable;
 
-
 (** conversion functions *)
 
 (** converts a boolean value to a string *)
@@ -803,7 +795,7 @@ END StrToDate;
 	www	->  clear-text week-day, e.g. Mon
 
 	hh		->	two-digit hour, e.g. 08
-	h		-> 	hour, e.g. 8
+	h		->	hour, e.g. 8
 	nn		-> two-digit minute, e.g. 03
 	n		-> minute, e.g. 3
 	ss		-> two-digit second, e.g. 00
@@ -891,7 +883,6 @@ BEGIN
 	COPY(str, s^);
 END SetAOC;
 
-
 (* Gets extension of the given name, returns file (without extension) and ext *)
 PROCEDURE GetExtension* (CONST name : ARRAY OF CHAR; VAR file, ext: ARRAY OF CHAR);
 VAR len, index: SIZE;
@@ -1079,4 +1070,3 @@ BEGIN
 END Strings.
 
 System.Free Utilities ~
-

+ 1 - 1
source/TFModuleTrees.Mod

@@ -338,7 +338,7 @@ TYPE
 		END SetEditor;
 
 		PROCEDURE BrowseToDefinition*(sender, data : ANY);
-		VAR pos : LONGINT;
+		VAR pos : SIZE;
 			no : TS.NamedObject;
 			scope : TS.Scope;
 			ident : ARRAY 64 OF CHAR;

+ 1 - 1
source/TFSMTPServer.Mod

@@ -159,7 +159,7 @@ TYPE
 			message : Message;
 
 		PROCEDURE AddRecipient(VAR x : ARRAY OF CHAR);
-		VAR l, p : LONGINT; s : String; line : Line;
+		VAR l, p : SIZE; s : String; line : Line;
 		BEGIN
 			p := Strings.Pos("<", x); IF p >= 0 THEN Strings.Delete(x, 0, p + 1) END; Strings.TrimRight(x, ">");
 			l := Strings.Length(x) + 1 ; IF l = 1 THEN RETURN END;

+ 1 - 1
source/TestFiles.Mod

@@ -513,7 +513,7 @@ TYPE
 			arg : Streams.StringReader;
 			commandStr : ARRAY 128 OF CHAR; parameterStr : Strings.String;
 			msg : ARRAY 128 OF CHAR;
-			pos  : LONGINT; res : WORD;
+			pos : SIZE; res : WORD;
 		BEGIN
 			NEW(parameterStr, 4096); Strings.Truncate(parameterStr^, 0);
 			r.SkipWhitespace; r.String(commandStr);

+ 3 - 3
source/WMArchives.Mod

@@ -432,7 +432,7 @@ TYPE
 
 		(* recursive method insert a new node at the right place *)
 		PROCEDURE InsertTreeNode(parent : WMTrees.TreeNode; name : Strings.String; data : EntryInfo);
-		VAR posOfSlash : LONGINT;
+		VAR posOfSlash : SIZE;
 			subnode : WMTrees.TreeNode;
 			dirName, tail : Strings.String;
 		BEGIN
@@ -1057,7 +1057,7 @@ VAR
 (* ----- helpers ------------------------------------------------------- *)
 
 (* copy the head of string to head and the tail of string to tail *)
-PROCEDURE SplitString(string : Strings.String;  VAR head, tail : Strings.String; index : LONGINT);
+PROCEDURE SplitString(string : Strings.String;  VAR head, tail : Strings.String; index : SIZE);
 VAR i : LONGINT;
 BEGIN
 	NEW(head, index+1);
@@ -1183,4 +1183,4 @@ END WMArchives.
 
 WMArchives.Open ~
 WMArchives.Open traditional.skin ~
-System.Free WMArchives ~
+System.Free WMArchives ~

+ 1 - 1
source/WMSystemComponents.Mod

@@ -443,7 +443,7 @@ TYPE
 			w : SelectionWrapper;
 			filename : Files.FileName;
 			command : ARRAY 1024 OF CHAR;
-			position: LONGINT; res: WORD;
+			position: SIZE; res: WORD;
 			msg : ARRAY 256 OF CHAR;
 		BEGIN
 			IF (data # NIL) & (data IS SelectionWrapper) THEN

+ 1 - 1
source/WebBrowser.Mod

@@ -156,7 +156,7 @@ TYPE
 		VAR
 			urlNode : URLNode;
 			urlAOC : ARRAY 1024 OF CHAR;
-			i: LONGINT;
+			i: SIZE;
 		BEGIN
 			IF ~IsCallFromSequencer() THEN sequencer.ScheduleEvent(SELF.Go, sender, data)
 			ELSE

+ 1 - 1
source/WebBrowserComponents.Mod

@@ -475,7 +475,7 @@ VAR
 
 PROCEDURE GetResourceConnection*(url : String) : ResourceConnection;
 VAR
-	pos : LONGINT;
+	pos : SIZE;
 	protocol : String;
 	filename : String;
 	connection : ResourceConnection;

+ 1 - 1
source/WebBrowserPanel.Mod

@@ -735,7 +735,7 @@ END GetContent;
 PROCEDURE DecodeLinkData*(data : ANY; VAR link : String; VAR target : String);
 VAR
 	linkValue : String;
-	urlPos, len : LONGINT;
+	urlPos, len : SIZE;
 BEGIN
 	linkValue := data(WMTextView.LinkWrapper).link;
 	IF Strings.StartsWith2("#", linkValue^) THEN

+ 1 - 1
source/WebFTPServer.Mod

@@ -848,7 +848,7 @@ END Code;
 
 PROCEDURE ComposeDirectory(path, name: ARRAY OF CHAR; VAR res: ARRAY OF CHAR);
 VAR
-	prefix: Files.Prefix; tmp: ARRAY dirLen OF CHAR; p: LONGINT;
+	prefix: Files.Prefix; tmp: ARRAY dirLen OF CHAR; p: SIZE;
 	absolute : BOOLEAN;
 BEGIN
 	COPY(path, res); absolute :=  PathDelimiter = name[0];