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