Listing: 1 IMPLEMENTATION MODULE ScanUtils; 2 (* 3 * REPERTOIRE 4 * Release 1.6 5 * By Charles Bradford and Cole Brecheen 6 * (c) Copyright 1985-1992 PMI 7 * Green Bay, Wisconsin 8 * All rights reserved 9 * (414) 468-6040 10 * 11 * $Header: D:/logfiles/mods/scanutil.mov 1.2 17 Mar 1991 17:56:48 coleb $ 12 * 13 *) 14 15 16 17 IMPORT LowLevel; 18 IMPORT M2Strings; 19 IMPORT Numbers; 20 IMPORT StrEdit; 21 IMPORT SYSTEM; 22 23 VAR 24 Initialized : BOOLEAN; 25 26 PROCEDURE Init(); 27 BEGIN 28 IF Initialized THEN 29 RETURN; 30 ELSE 31 Initialized := TRUE; 32 END; 33 LowLevel.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 34 M2Strings.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 35 Numbers.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 36 StrEdit.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 37 END Init; ***** ^ not supported yet 38 39 40 CONST 41 space = ' '; 42 tab = CHAR(9); ***** ^ not supported yet 43 44 45 PROCEDURE ScanForByte(size : INTEGER; lookfor : SYSTEM.BYTE; ***** ^ not supported yet 46 start : SYSTEM.ADDRESS; caseMatters: CaseSensitivity ) : INTEGER; ***** ^ not supported yet ***** ^ undeclared identifier 47 VAR 48 cnt: INTEGER; 49 tmpAdr: LowLevel.Address8086; ***** ^ not supported yet 50 BEGIN 51 tmpAdr.x := start; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 52 IF size < 0 THEN 53 FOR cnt := 0 TO ABS(size + 1) DO ***** ^ undeclared identifier ***** ^ not supported yet 54 IF caseMatters = CaseInsens THEN ***** ^ not supported yet ***** ^ undeclared identifier 55 IF CAP(CHAR(lookfor)) = CAP(tmpAdr.b^) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 56 RETURN cnt; 57 END; 58 ELSE 59 IF CHAR(lookfor) = tmpAdr.b^ THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 60 RETURN cnt; 61 END; 62 END; 63 DEC(tmpAdr.off); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 64 END; 65 ELSIF size > 0 THEN 66 FOR cnt := 0 TO (size - 1) DO 67 IF caseMatters = CaseInsens THEN ***** ^ not supported yet ***** ^ undeclared identifier 68 IF CAP(CHAR(lookfor)) = CAP(tmpAdr.b^) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 69 RETURN cnt; 70 END; 71 ELSE 72 IF CHAR(lookfor) = tmpAdr.b^ THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 73 RETURN cnt; 74 END; 75 END; 76 INC(tmpAdr.off); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 77 END; 78 END; 79 RETURN size; 80 END ScanForByte; ***** ^ not supported yet 81 82 83 PROCEDURE BreakPoint(VAR thestr : ARRAY OF CHAR; maxlength : CARDINAL; ***** ^ not supported yet 84 breakchars : ARRAY OF CHAR) : CARDINAL; ***** ^ not supported yet 85 VAR 86 cnt : CARDINAL; 87 BEGIN 88 cnt := maxlength-1; 89 WHILE (cnt>0) AND 90 (Pos(thestr[cnt], breakchars, CaseSens) > HIGH(breakchars)) DO ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 91 DEC(cnt); ***** ^ undeclared identifier ***** ^ not supported yet 92 END; 93 IF (cnt=0) AND 94 (Pos(thestr[0], breakchars, CaseSens) > HIGH(breakchars)) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 95 RETURN (maxlength); 96 ELSE 97 RETURN (cnt); 98 END; 99 END BreakPoint; ***** ^ not supported yet 100 101 102 PROCEDURE BreakPtAdr( TheAdr: SYSTEM.ADDRESS; TheSize: CARDINAL; ***** ^ not supported yet 103 maxlength : CARDINAL; breakchars : ARRAY OF CHAR) : ***** ^ not supported yet 104 CARDINAL; 105 VAR 106 cnt : CARDINAL; 107 tmp : LowLevel.Address8086; ***** ^ not supported yet 108 BEGIN 109 cnt := maxlength-1; 110 tmp.a := TheAdr; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 111 INC( tmp.off, cnt ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 112 WHILE (cnt>0) AND (NOT Present(tmp.b^, breakchars, CaseSens)) DO ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 113 DEC( tmp.off ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 114 DEC(cnt); ***** ^ undeclared identifier ***** ^ not supported yet 115 END; 116 IF (cnt=0) AND (NOT Present(tmp.b^, breakchars, CaseSens)) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 117 RETURN maxlength; 118 ELSE 119 RETURN cnt; 120 END; 121 END BreakPtAdr; ***** ^ not supported yet 122 123 124 PROCEDURE ByteCount( size: CARDINAL; lookfor: CHAR; start: 125 SYSTEM.ADDRESS): CARDINAL; ***** ^ not supported yet 126 VAR 127 cnt, offset, skipped: CARDINAL; 128 BEGIN 129 cnt := 0; 130 offset := 0; 131 WHILE offset < size DO 132 skipped := LowLevel.ScanEQ( size - offset, lookfor, ***** ^ not supported yet ***** ^ not supported yet 133 LowLevel.AddAddr(start, offset) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 134 IF skipped < (size - offset) THEN 135 INC( cnt ); ***** ^ undeclared identifier ***** ^ not supported yet 136 INC( offset, skipped + 1 ); ***** ^ undeclared identifier ***** ^ not supported yet 137 ELSE 138 RETURN cnt; 139 END; 140 END; 141 RETURN cnt; 142 END ByteCount; ***** ^ not supported yet 143 144 145 PROCEDURE Equal( str1, str2: ARRAY OF CHAR; ***** ^ not supported yet 146 caseMatters: CaseSensitivity ): BOOLEAN; ***** ^ undeclared identifier 147 BEGIN 148 IF caseMatters = CaseInsens THEN ***** ^ not supported yet ***** ^ undeclared identifier 149 StrEdit.CAPstr(str1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 150 StrEdit.CAPstr(str2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 151 END; 152 RETURN M2Strings.CompareStr(str1, str2) = 0; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 153 END Equal; ***** ^ not supported yet 154 155 156 PROCEDURE FindNthPattern(pattern: ARRAY OF CHAR; which: CARDINAL; ***** ^ not supported yet 157 searchIn: ARRAY OF CHAR; caseMatters: CaseSensitivity ): CARDINAL; ***** ^ not supported yet ***** ^ undeclared identifier 158 VAR 159 cnt, lastSpot, inLngth: CARDINAL; 160 found : BOOLEAN; 161 BEGIN 162 found := FALSE; 163 lastSpot := 0; 164 cnt := 0; 165 inLngth := M2Strings.Length(searchIn); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 166 REPEAT 167 lastSpot := Positn(pattern, searchIn, lastSpot, caseMatters); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 168 IF lastSpot >= inLngth THEN 169 cnt := which + 1; 170 ELSE 171 INC(cnt); ***** ^ undeclared identifier ***** ^ not supported yet 172 END; 173 IF cnt = which THEN 174 found := TRUE; 175 END; 176 UNTIL found OR (cnt > which); 177 IF cnt > which THEN 178 RETURN(65535); 179 ELSE 180 RETURN(lastSpot); 181 END; 182 END FindNthPattern; ***** ^ not supported yet 183 184 185 PROCEDURE FirstNonMatching(TheChar : CHAR; VAR TheStr : ARRAY OF CHAR) : ***** ^ not supported yet 186 CHAR; 187 (* Returns the first character in TheStr that does not match 188 TheChar. If none found, returns TheChar. *) 189 VAR 190 spot, leng : CARDINAL; 191 BEGIN 192 leng := M2Strings.Length(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 193 IF leng = 0 THEN 194 RETURN TheChar; 195 END; 196 spot := LowLevel.ScanNE( leng, TheChar, SYSTEM.ADR(TheStr) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 197 IF spot < leng THEN 198 RETURN TheStr[spot]; ***** ^ not supported yet ***** ^ not supported yet 199 ELSE 200 RETURN TheChar; 201 END; 202 END FirstNonMatching; ***** ^ not supported yet 203 204 205 PROCEDURE IsAlphaChar( TheChar: CHAR ): BOOLEAN; 206 BEGIN 207 RETURN ((TheChar >= 'a') AND (TheChar <= 'z')) OR ((TheChar 208 >= 'A') AND (TheChar <= 'Z')); 209 END IsAlphaChar; ***** ^ not supported yet 210 211 212 PROCEDURE IsBlank(TheStr : ARRAY OF CHAR) : BOOLEAN; ***** ^ not supported yet 213 (*TRUE if thestr is all blanks *) 214 VAR 215 answer, leng : CARDINAL; 216 BEGIN 217 leng := M2Strings.Length(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 218 IF leng=0 THEN 219 RETURN TRUE; 220 END; 221 answer := LowLevel.ScanNE(leng,space,SYSTEM.ADR(TheStr)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 222 RETURN (answer>=leng); 223 END IsBlank; ***** ^ not supported yet 224 225 226 PROCEDURE IsNextPattern( Pattern: ARRAY OF CHAR; VAR TheStr: ***** ^ not supported yet 227 ARRAY OF CHAR; StartingSpot: CARDINAL; ***** ^ not supported yet 228 caseMatters: CaseSensitivity ): BOOLEAN; ***** ^ undeclared identifier 229 VAR 230 tmp, cnt: CARDINAL; 231 lngth: INTEGER; 232 tmpadr: LowLevel.Address8086; ***** ^ not supported yet 233 result: BOOLEAN; 234 BEGIN 235 lngth := INTEGER(M2Strings.Length(TheStr)) - INTEGER(StartingSpot); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 236 (* Don't bother looking if the StartingSpot is greater than the 237 length of the string. *) 238 IF lngth < 0 THEN 239 RETURN FALSE; 240 END; 241 tmp := PosAdr( Pattern, LowLevel.AddAddr( SYSTEM.ADR(TheStr), ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 242 StartingSpot), CARDINAL(lngth), caseMatters ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 243 (* Figure out where Pattern appears, if at all. *) 244 IF tmp = CARDINAL(lngth) THEN ***** ^ not supported yet 245 (* If it doesn't appear at all, return FALSE. *) 246 RETURN FALSE; 247 END; 248 (* tmp now represents the offset beyond StartingSpot at which 249 Pattern appears. We want to know if that's the same offset 250 as the first nonblank character beyond StartingSpot. *) 251 result := TRUE; 252 cnt := StartingSpot; 253 WHILE ((cnt < tmp) AND result) DO 254 IF (TheStr[cnt] # space) AND (TheStr[cnt] # tab) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 255 result := FALSE; 256 END; 257 INC(cnt); ***** ^ undeclared identifier ***** ^ not supported yet 258 END; 259 RETURN result; 260 END IsNextPattern; ***** ^ not supported yet 261 262 263 PROCEDURE IsNumber( TheStr: ARRAY OF CHAR; StartingSpot: ***** ^ not supported yet 264 CARDINAL ): BOOLEAN; 265 VAR 266 AllNumbers, PointFound, AtLeastOneFound : BOOLEAN; 267 EndStr, index : CARDINAL; 268 bufch : CHAR; 269 BEGIN 270 M2Strings.Delete( TheStr, 0, StartingSpot ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 271 StrEdit.CrunchBlanks( TheStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 272 EndStr := M2Strings.Length(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 273 IF (EndStr = 0) OR Present( space, TheStr, CaseSens ) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier 274 RETURN FALSE; 275 END; 276 DEC( EndStr ); ***** ^ undeclared identifier ***** ^ not supported yet 277 index := 0; 278 AtLeastOneFound := FALSE; 279 PointFound := FALSE; 280 AllNumbers := TRUE; 281 REPEAT 282 bufch := TheStr[index]; ***** ^ not supported yet ***** ^ not supported yet 283 IF IsNumericChar( bufch ) THEN ***** ^ undeclared identifier ***** ^ not supported yet 284 AtLeastOneFound := TRUE; 285 ELSIF (bufch = '-') OR (bufch = '+') THEN 286 IF NOT (index = 0) THEN 287 AllNumbers := FALSE; 288 END; 289 ELSIF bufch = '.' THEN 290 IF PointFound THEN 291 AllNumbers := FALSE; 292 ELSE 293 PointFound := TRUE; 294 END; 295 ELSE 296 AllNumbers := FALSE; 297 END; 298 INC( index ); ***** ^ undeclared identifier ***** ^ not supported yet 299 UNTIL (NOT AllNumbers) OR (index > EndStr); 300 RETURN AtLeastOneFound AND AllNumbers; 301 END IsNumber; ***** ^ not supported yet 302 303 304 PROCEDURE IsNumericChar( TheChar: CHAR ): BOOLEAN; 305 BEGIN 306 RETURN (TheChar >= '0') AND (TheChar <= '9'); 307 END IsNumericChar; ***** ^ not supported yet 308 309 310 PROCEDURE IsWhiteSpace( TheChar: CHAR ): BOOLEAN; 311 BEGIN 312 RETURN (TheChar = space) OR (TheChar = tab); 313 END IsWhiteSpace; ***** ^ not supported yet 314 315 316 PROCEDURE LastNonMatching(TheChar : CHAR; VAR TheStr 317 : ARRAY OF CHAR) : CHAR; ***** ^ not supported yet 318 (* Starts at the end of TheStr and searches backward for a 319 character that does not match TheChar. If none found, 320 returns TheChar. *) 321 VAR 322 spot: INTEGER; 323 BEGIN 324 spot := M2Strings.Length(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 325 IF spot = 0 THEN 326 RETURN TheChar; 327 ELSE 328 DEC( spot ); ***** ^ undeclared identifier ***** ^ not supported yet 329 END; 330 WHILE (TheStr[spot] = TheChar) AND (spot > 0) DO ***** ^ not supported yet ***** ^ not supported yet 331 DEC( spot ); ***** ^ undeclared identifier ***** ^ not supported yet 332 END; 333 IF spot > 0 THEN 334 RETURN TheStr[spot]; ***** ^ not supported yet ***** ^ not supported yet 335 ELSE 336 RETURN TheChar; 337 END; 338 END LastNonMatching; ***** ^ not supported yet 339 340 341 PROCEDURE MatchingPos( spot: CARDINAL; TheStr: ARRAY 342 OF CHAR ): CARDINAL; ***** ^ not supported yet 343 (*Returns the position of the ending character that matches 344 the beginning character at position spot within TheStr. If 345 TheStr does not have a valid beginning character at spot, 346 or if spot is not inside the present length of TheStr, or 347 if no matching ending character is found, MatchingPos 348 returns spot.*) 349 VAR 350 TmpSpot, StackCount, lngth : CARDINAL; 351 Opener, Closer, bufch: CHAR; 352 Openers, Closers: ARRAY [0..3] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 353 BEGIN 354 StrEdit.AssignStr( '[{(<', Openers ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 355 StrEdit.AssignStr( ']})>', Closers ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 356 lngth := M2Strings.Length( TheStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 357 IF spot >= lngth THEN 358 RETURN spot; 359 END; 360 bufch := TheStr[spot]; ***** ^ not supported yet ***** ^ not supported yet 361 TmpSpot := LowLevel.ScanEQ(SYSTEM.SIZE(Openers), bufch, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 362 SYSTEM.ADR(Openers) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 363 IF TmpSpot <= HIGH( Openers ) THEN ***** ^ undeclared identifier ***** ^ not supported yet 364 Opener := bufch; 365 Closer := Closers[ TmpSpot ]; ***** ^ not supported yet ***** ^ not supported yet 366 TmpSpot := spot + 1; 367 StackCount := 0; 368 WHILE TmpSpot < lngth DO 369 IF TheStr[ TmpSpot ] = Opener THEN ***** ^ not supported yet ***** ^ not supported yet 370 INC( StackCount ); ***** ^ undeclared identifier ***** ^ not supported yet 371 ELSIF TheStr[ TmpSpot ] = Closer THEN ***** ^ not supported yet ***** ^ not supported yet 372 IF StackCount = 0 THEN 373 RETURN TmpSpot; 374 ELSE 375 DEC( StackCount ); ***** ^ undeclared identifier ***** ^ not supported yet 376 END; 377 END; 378 INC( TmpSpot ); ***** ^ undeclared identifier ***** ^ not supported yet 379 END; 380 END; 381 RETURN spot; 382 END MatchingPos; ***** ^ not supported yet 383 384 385 PROCEDURE PatternScan( PatternAdr: SYSTEM.ADDRESS; ***** ^ not supported yet 386 PatternSize: CARDINAL; ScanAreaAdr: SYSTEM.ADDRESS; ***** ^ not supported yet 387 ScanAreaSize: CARDINAL; caseMatters: CaseSensitivity ): CARDINAL; ***** ^ undeclared identifier 388 VAR 389 BytesSkipped, ThisScan, cnt, PossibleStartSpots : CARDINAL; 390 MaxScan: INTEGER; 391 PatAdr, AreaAdr: LowLevel.Address8086; ***** ^ not supported yet 392 BEGIN 393 PatAdr.a := PatternAdr; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 394 AreaAdr.a := ScanAreaAdr; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 395 IF (ScanAreaSize >= PatternSize) AND (PatternSize#0) THEN 396 PossibleStartSpots := ScanAreaSize - PatternSize + 1; 397 IF PossibleStartSpots > 32766 THEN 398 MaxScan := 32766; 399 ELSE 400 MaxScan := PossibleStartSpots; 401 END; 402 BytesSkipped := ScanForByte( MaxScan, PatAdr.b^, ScanAreaAdr, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 403 caseMatters ); ***** ^ not supported yet 404 ThisScan := BytesSkipped; 405 INC( AreaAdr.off, ThisScan ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 406 WHILE (BytesSkipped < PossibleStartSpots) DO 407 IF ThisScan < CARDINAL(MaxScan) THEN ***** ^ not supported yet 408 cnt := 0; 409 LOOP 410 (* as long as following elements equal do:*) 411 INC( cnt ); ***** ^ undeclared identifier ***** ^ not supported yet 412 IF cnt >= PatternSize THEN 413 (*if at end of pattern, we've found a match*) 414 RETURN BytesSkipped; 415 END; 416 INC( PatAdr.off ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 417 INC( AreaAdr.off ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 418 IF caseMatters = CaseInsens THEN ***** ^ not supported yet ***** ^ undeclared identifier 419 IF CAP(AreaAdr.b^) # CAP(PatAdr.b^) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 420 (*if next element # object, stop comparing*) 421 EXIT; 422 END; 423 ELSE 424 IF AreaAdr.b^ # PatAdr.b^ THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 425 (*if next element # object, stop comparing*) 426 EXIT; 427 END; 428 END; 429 END; 430 END; 431 INC( BytesSkipped ); ***** ^ undeclared identifier ***** ^ not supported yet 432 IF BytesSkipped > PossibleStartSpots THEN 433 RETURN ScanAreaSize; 434 (* Pattern not found. *) 435 ELSIF (PossibleStartSpots - BytesSkipped) > 32766 THEN 436 MaxScan := 32766; 437 ELSE 438 MaxScan := PossibleStartSpots - BytesSkipped; 439 END; 440 PatAdr.a := PatternAdr; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 441 AreaAdr.a := ScanAreaAdr; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 442 INC( AreaAdr.off, BytesSkipped ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 443 ThisScan := ScanForByte( MaxScan, ***** ^ not supported yet 444 PatAdr.b^, AreaAdr.a, caseMatters ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 445 INC( BytesSkipped, ThisScan ); ***** ^ undeclared identifier ***** ^ not supported yet 446 INC( AreaAdr.off, ThisScan ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 447 END; 448 END; 449 RETURN ScanAreaSize; 450 (* Pattern not found. *) 451 END PatternScan; ***** ^ not supported yet 452 453 454 PROCEDURE PosAdr(VAR s2 : ARRAY OF CHAR; s : SYSTEM.ADDRESS; ***** ^ not supported yet ***** ^ not supported yet 455 size: CARDINAL; caseMatters: CaseSensitivity ) : CARDINAL; ***** ^ undeclared identifier 456 BEGIN 457 RETURN PatternScan( SYSTEM.ADR(s2), M2Strings.Length(s2), s, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 458 size, caseMatters ); ***** ^ not supported yet 459 END PosAdr; ***** ^ not supported yet 460 461 462 PROCEDURE Pos(s2 : ARRAY OF CHAR; s : ARRAY OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 463 caseMatters: CaseSensitivity ) : CARDINAL; ***** ^ undeclared identifier 464 (* Return the index in s of the first occurence of the substring s2, 465 or High(s)+1 if there are no occurences of s2.*) 466 VAR 467 i, j, n, n2, len : CARDINAL; 468 BEGIN 469 n := M2Strings.Length(s); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 470 (*length of string to search in*) 471 n2 := M2Strings.Length(s2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 472 (*length of string to search for*) 473 IF (n >= n2) AND (n2 # 0) THEN 474 (*only search if target bigger than object; object non-null*) 475 len := n-n2+1; 476 (* number of possible starting positions *) 477 i := ScanForByte(len, s2[0], SYSTEM.ADR(s[0]), caseMatters); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 478 (*changed; start at first occurence of s2[0]*) 479 WHILE (i= n2 THEN 485 (*if at end of object, finished*) 486 RETURN i; 487 END; 488 IF caseMatters = CaseInsens THEN ***** ^ not supported yet ***** ^ undeclared identifier 489 IF CAP(s[i+j]) # CAP(s2[0+j]) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 490 (*if next element # to object, stop comparing*) 491 EXIT; 492 END; 493 ELSE 494 IF s[i+j] # s2[0+j] THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 495 (*if next element # to object, stop comparing*) 496 EXIT; 497 END; 498 END; 499 INC(j); ***** ^ undeclared identifier ***** ^ not supported yet 500 END; 501 i := i + 1 + CARDINAL( 502 ScanForByte( len-1-i, s2[0], SYSTEM.ADR(s[i+1]), caseMatters)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 503 (*changed: try next possible starting position *) 504 END; 505 END; 506 RETURN (HIGH(s)+1); ***** ^ undeclared identifier ***** ^ not supported yet 507 (* String not found. *) 508 END Pos; ***** ^ not supported yet 509 510 511 PROCEDURE PosDelimited(VAR pattern, obj, delimiters : ARRAY OF 512 CHAR; caseMatters: CaseSensitivity ) : CARDINAL; ***** ^ not supported yet ***** ^ undeclared identifier 513 (*These are VAR parameters just for purposes of efficiency. 514 Neither is actually changed.*) 515 VAR 516 spot1, spot2 : CARDINAL; 517 BEGIN 518 (*PosDelimited*) 519 IF PresentPos( pattern, obj, spot1, caseMatters ) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 520 spot2 := spot1 + M2Strings.Length(pattern); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 521 (*spot2 should now point to the character after the 522 pattern*) 523 IF (spot1=0) 524 OR 525 Present(obj[spot1-1], delimiters, caseMatters) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 526 (*Now we know everything to the left of the pattern 527 is okay.*) 528 IF (spot2>=M2Strings.Length(obj)) OR Present(obj[spot2], ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 529 delimiters, caseMatters) THEN ***** ^ not supported yet ***** ^ not supported yet 530 (*And now we know everything is okay to the right.*) 531 RETURN (spot1); 532 END; 533 END; 534 END; 535 RETURN (HIGH(obj)+1); ***** ^ undeclared identifier ***** ^ not supported yet 536 END PosDelimited; ***** ^ not supported yet 537 538 539 PROCEDURE Positn(s2 : ARRAY OF CHAR; s : ARRAY OF CHAR; i : CARDINAL; ***** ^ not supported yet ***** ^ not supported yet 540 caseMatters: CaseSensitivity ) : CARDINAL; ***** ^ undeclared identifier 541 (* Return the index in s of the first occurence of the substring s2, 542 at or after index i, or HIGH(s)+1 if there are no occurences of s2.*) 543 VAR 544 len, PosAdrResult: CARDINAL; 545 BEGIN 546 len := M2Strings.Length( s ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 547 IF len > i THEN 548 PosAdrResult := PosAdr( s2, SYSTEM.ADR(s[i]), len - i, caseMatters ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 549 IF PosAdrResult < (len - i) THEN 550 RETURN i + PosAdrResult; 551 END; 552 END; 553 RETURN (HIGH(s)+1); ***** ^ undeclared identifier ***** ^ not supported yet 554 (* String not found.*) 555 END Positn; ***** ^ not supported yet 556 557 558 PROCEDURE Present(str1, str2 : ARRAY OF CHAR; ***** ^ not supported yet 559 caseMatters: CaseSensitivity ) : BOOLEAN; ***** ^ undeclared identifier 560 BEGIN 561 IF Pos( str1, str2, caseMatters ) <= HIGH(str2) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 562 RETURN (TRUE); 563 ELSE 564 RETURN (FALSE); 565 END; 566 END Present; ***** ^ not supported yet 567 568 569 PROCEDURE PresentPos(str1, str2 : ARRAY OF CHAR; VAR spot: ***** ^ not supported yet 570 CARDINAL; caseMatters: CaseSensitivity ) : BOOLEAN; ***** ^ undeclared identifier 571 VAR 572 size: CARDINAL; 573 BEGIN 574 size := M2Strings.Length(str2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 575 spot := PosAdr( str1, SYSTEM.ADR(str2), size, caseMatters ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 576 IF spot < size THEN 577 RETURN (TRUE); 578 ELSE 579 spot := HIGH(str2) + 1; ***** ^ undeclared identifier ***** ^ not supported yet 580 RETURN (FALSE); 581 END; 582 END PresentPos; ***** ^ not supported yet 583 584 585 PROCEDURE SubStrMatch( str1: ARRAY OF CHAR; StartingAt1, ***** ^ not supported yet 586 EndingAt1: CARDINAL; VAR str2: ARRAY OF CHAR; StartingAt2, ***** ^ not supported yet 587 EndingAt2: CARDINAL; caseMatters: CaseSensitivity ): BOOLEAN; ***** ^ undeclared identifier 588 VAR 589 size1, size2, tmpc: CARDINAL; 590 BEGIN 591 size1 := M2Strings.Length(str1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 592 size2 := M2Strings.Length(str2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 593 IF (size1 <= StartingAt1) OR (size2 <= StartingAt2) OR 594 (StartingAt1 > EndingAt1) OR (StartingAt2 > EndingAt2) THEN 595 RETURN FALSE; 596 END; 597 size1 := Numbers.Min( EndingAt1 + 1, size1) - StartingAt1; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 598 size2 := Numbers.Min( EndingAt2 + 1, size2) - StartingAt2; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 599 tmpc := PatternScan( SYSTEM.ADR(str1[StartingAt1]), size1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 600 SYSTEM.ADR(str2[StartingAt2]), size2, caseMatters ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 601 RETURN tmpc = 0; 602 END SubStrMatch; ***** ^ not supported yet 603 604 605 BEGIN 606 Initialized := FALSE; 607 Init(); ***** ^ not supported yet ***** ^ not supported yet 608 END ScanUtils. ***** ^ not supported yet 474 errors