Skip to content

Commit 904c4df

Browse files
committed
refactor code, resize things to allow for 64 bit sizes... NativeUint
1 parent 24a711c commit 904c4df

File tree

8 files changed

+299
-296
lines changed

8 files changed

+299
-296
lines changed

MYOBJ.PAS

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Implementation
1818
End;
1919

2020
Begin
21-
End.
21+
End.

STACKS.PAS

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ Implementation
131131

132132

133133
begin
134-
end.
134+
end.

TECO.INI

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ See TECO.DOC for complete usage information
1818
*****************************************************************************
1919
Welcome to TECO/2
2020
(Half TECO)
21-
Version 1.07 Alpha
21+
Version 1.08 Alpha
2222

23-
Copyright (C) 1989-2021 Michael A. Warot all rights reserved.
23+
Copyright (C) 1989-2024 Michael A. Warot all rights reserved.
2424
*****************************************************************************
2525

2626
This message brought to you by TECO.INI

TECO.PAS

+35-125
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,7 @@
11
Program Teco;
2-
{
3-
The Last remake of TECO, a nice editor....
4-
5-
Copyright (C) 1989-2021 Michael Warot, all rights reserved.
6-
7-
Disclaimer: The author makes no warantee, expressed or implied.
8-
Use this software strickly at your own risk.
9-
10-
"Back when I was 25, we didn't have any fancy windows and mice...
11-
AND WE LIKED IT THAT WAY!", yeah, SSSSSUUUURRRRREEEEE....
12-
13-
Rev
14-
4 - Add command input routine, begin implementing a simple
15-
command interpreter
16-
5 - Implement string parameters
17-
6 - Implement number parameters and a small (10) stack
18-
7 - Implement a simple form of numeric expressions
19-
8 - Procedure Execute added, to allow commands to come from multiple
20-
sources, and allow the "current" buffer to be one of many.
21-
Add LineOriented()
22-
9 - Move TBuffer and Tstack out to separate units
23-
Add ExecStr()
24-
10 - More debugging....
25-
11 - File oriented I/O, buffers, etc.
26-
12 - Remove ExecStr()
27-
Make all q-registers general purpose.... (You're right, Ken)
28-
procedures use pointers instead of VAR parameters
29-
13 - Add search and replace. (Pattern matching supported, but slow).
30-
31-
1/21/91 - MAW
32-
14 - Write first draft of TECO.DOC, revise code to more closely match
33-
definitions in DEC's manual.
34-
35-
1/21/91 - MAW - Big problem, because of the interpretive nature of the
36-
current implementation, conditional branching looks to be
37-
a real problem. Considering "compiling" commands, which
38-
would eliminate most semantic ambiguities, in addition
39-
to increasing the speed of operations.
40-
41-
42-
Varsion 100 - experimental, compiling version. (NOT COMPILING!)
43-
44-
Notes: Flag "C" and 1 is the Case Sensitive flag, default off (0)
45-
Flag "T" and 8 is the NO ECHO flags, default off (echo keys)
46-
47-
7/17/91 - Replace all tbuffer references with tbuf, to allow for file I/O.
48-
A simple search/replace command actually works now!
49-
First release to the public
50-
51-
7/22/91 - Correct bug in GetConstant which pushed junk on the stack
52-
- Correct logic fault, never allow GetStringParam to be inside
53-
a conditional if an argument is REQUIRED, if the procedure isn't
54-
called, the argument becomes part of the command, not just
55-
another parameter! Append is the one exception to this rule.
56-
7/23/91 - Fix bug in Search, wouldn't find a match at the current cursor
57-
position.
58-
59-
7/25/91 - Fix bug (feature?) which caused EX in a .INI file to be ignored
60-
- Add StringSearch, a MUCH faster engine for searching through
61-
the buffer. Supports most of the "String Build" characters
62-
63-
1.03á--- release?
64-
65-
12/03/91 - Modify code to use Release(QStack.Pop,Done) to eliminate bug
66-
which eats memory. Old version didn't properly page text...
67-
68-
Modify ExitLoop to pass F> in a command
69-
70-
01/03/2021 - Modify code to work in Windows 10, 64 Bit,
71-
on a machine with with more Disk and RAM than MS-DOS could even access.
72-
73-
}
742
Uses
753
Stacks,
76-
Buff,
4+
TextBuffers,
775
DOS,CRT;
786
Const
797
ESC = #27;
@@ -104,24 +32,6 @@ begin
10432
GetKey := x;
10533
end;
10634

107-
(*
108-
Function GetKey : Word; Assembler;
109-
Asm
110-
xor ax,ax { Keyboard int, get key }
111-
int $16
112-
End;
113-
114-
Function KeyPressed : Boolean; Assembler;
115-
Asm
116-
mov ax,1
117-
int $16 { Keyboard int, get status }
118-
mov ax,0 { Zero flag set = no key }
119-
jz @@1
120-
inc ax
121-
@@1: { 1 if key ready, 0 if not }
122-
End;
123-
*)
124-
12535
Function Qnum(X : Char):Byte;
12636
Const
12737
Qxlat : Array[0..127] of Byte =
@@ -146,11 +56,11 @@ Var
14656
QStack : OStack;
14757
Done : Boolean;
14858
Flags : Array[0..37] of Longint;
149-
Qregs : Array[0..37] of PBuf; { Q registers }
59+
Qregs : Array[0..37] of PTextFileBuffer; { Q registers }
15060
Qnums : Array[0..37] of Longint; { Q registers, numeric part }
15161
BitMask : Array[0..255] of Longint; { Used in StringSearch }
15262

153-
function CmdChar(cmd : pbuf):Char;
63+
function CmdChar(cmd : PTextFileBuffer):Char;
15464
var
15565
c : char;
15666
begin
@@ -169,15 +79,15 @@ Function StringCompare(P1,P2 : Pointer):Longint;
16979
}
17080
Var
17181
Data,
172-
Pattern : pbuf;
82+
Pattern : PTextFileBuffer;
17383
Old1,Old2 : TextPtr;
17484
CaseSensitive : Boolean;
17585
c : char;
17686
Match : Boolean;
17787
Size : Longint;
17888
Begin
179-
Pattern := pbuf(P1);
180-
Data := pbuf(P2);
89+
Pattern := PTextFileBuffer(P1);
90+
Data := PTextFileBuffer(P2);
18191
CaseSensitive := (Flags[13] AND 1) <> 0;
18292
Match := True;
18393
Old1 := Pattern^.WhereAt;
@@ -216,7 +126,7 @@ End;
216126

217127

218128

219-
Function StringSearch(Pattern,Data : PBuf):Longint;
129+
Function StringSearch(Pattern,Data : PTextFileBuffer):Longint;
220130
{
221131
A new, faster search engine.
222132
ONLY GOES 31 characters!
@@ -364,13 +274,13 @@ Begin
364274
end;
365275
End;
366276

367-
Procedure Compile_And_Execute(Var Cmd, Data : pbuf);
277+
Procedure Compile_And_Execute(Var Cmd, Data : PTextFileBuffer);
368278
Begin
369279
End;
370280

371281

372282

373-
Procedure Execute(Var Cmd, Data : pbuf);
283+
Procedure Execute(Var Cmd, Data : PTextFileBuffer);
374284
Var
375285
Delim : Char; { #0 if '@' prefix used }
376286
ColonPrefix : Boolean;
@@ -415,7 +325,7 @@ Var
415325
GetConstant := T;
416326
End;
417327

418-
Function ValidNumber(Var B : pbuf) : Boolean;
328+
Function ValidNumber(Var B : PTextFileBuffer) : Boolean;
419329
var
420330
ok : boolean;
421331
t : longint;
@@ -479,9 +389,9 @@ Var
479389

480390
(******** String parameter routines **********)
481391

482-
Function GetStringParam(Var B : pbuf;
392+
Function GetStringParam(Var B : PTextFileBuffer;
483393
Var P : Pointer;
484-
Var S : Word ) : Boolean;
394+
Var Size : NativeUint ) : Boolean;
485395
Var
486396
Ok : Boolean;
487397
Begin
@@ -491,12 +401,12 @@ Var
491401
cmd^.Move(+1);
492402
end;
493403
P := cmd^.ThisCharP; { Pointer to buffer }
494-
S := cmd^.WhereAt; { Current char # }
404+
Size := cmd^.WhereAt; { Current char # }
495405
While (NOT Cmd^.AtEnd) AND (cmd^.ThisChar <> Delim) do
496406
cmd^.Move(+1);
497407
If cmd^.ThisChar = Delim then
498408
begin
499-
S := (cmd^.WhereAt - S);
409+
Size := (cmd^.WhereAt - Size);
500410
Ok := True;
501411
cmd^.Move(+1);
502412
end
@@ -523,11 +433,11 @@ Var
523433
end;
524434
end; { LineOriented }
525435

526-
procedure InsertMacro(Var Dest : pbuf);
436+
procedure InsertMacro(Var Dest : PTextFileBuffer);
527437
var
528438
x : char;
529439
p1 : pointer;
530-
s1 : word;
440+
s1 : NativeUint;
531441
begin
532442
If ColonPrefix then { Append }
533443
Dest^.JumpTo(Dest^.EndPtr);
@@ -543,12 +453,12 @@ Var
543453
end;
544454
end;
545455

546-
function Qregister: pbuf;
456+
function Qregister: PTextFileBuffer;
547457
var
548458
c : integer;
549459
begin
550460
c := Qnum(cmd^.ThisChar); cmd^.Move(+1);
551-
if qregs[c] = nil then qregs[c] := new(PBuf,Init(DefaultSize));
461+
if qregs[c] = nil then qregs[c] := new(PTextFileBuffer,Init(DefaultSize));
552462
Qregister := Qregs[c];
553463
end;
554464

@@ -567,7 +477,7 @@ Var
567477
end;
568478

569479
if cmd^.thischar <> '>' then
570-
error('loop missing ending ">"!')
480+
ReportError('loop missing ending ">"!')
571481
else
572482
if xout then cmd^.move(+1); { Mod for skip to > }
573483
end;
@@ -577,7 +487,7 @@ Var
577487
begin
578488
If LoopStack.Empty then
579489
begin
580-
Error('not in a loop!');
490+
ReportError('not in a loop!');
581491
inloop := false;
582492
end
583493
else
@@ -598,7 +508,7 @@ Var
598508
end;
599509

600510
if (cmd^.thischar <> '|') AND (cmd^.thischar <> '''') then
601-
error('loop missing ending ">"!')
511+
ReportError('loop missing ending ">"!')
602512
else
603513
cmd^.move(+1);
604514
end;
@@ -616,7 +526,7 @@ Var
616526
end;
617527

618528
if cmd^.thischar <> '''' then
619-
error('loop missing ending "''"!')
529+
ReportError('loop missing ending "''"!')
620530
else
621531
cmd^.move(+1);
622532
end;
@@ -625,9 +535,9 @@ Var
625535
C,X : Char;
626536
I,J,K : Longint;
627537
P1,P2 : Pointer;
628-
S1,S2 : Word;
538+
S1,S2 : NativeUint;
629539
S : String;
630-
Q : pbuf;
540+
Q : PTextFileBuffer;
631541
kludge : integer;
632542
begin
633543
cmd^.JumpTo(0);
@@ -702,8 +612,8 @@ begin
702612
else k := Stack.Pop;
703613
If GetStringParam(Cmd,P1,S1) then
704614
begin
705-
QStack.Push(New(pbuffer,Cpy(P1,S1)));
706-
Stack.Push( StringSearch(Pbuf(Qstack.Top),Data) );
615+
QStack.Push(New(PTextBuffer,Cpy(P1,S1)));
616+
Stack.Push( StringSearch(PTextFileBuffer(Qstack.Top),Data) );
707617
Dispose(QStack.Pop,Done);
708618
end;
709619
end;
@@ -714,15 +624,15 @@ begin
714624
else k := Stack.Pop;
715625
If GetStringParam(Cmd,P1,S1) then
716626
begin
717-
QStack.Push(New(pbuffer,Cpy(P1,S1)));
627+
QStack.Push(New(PTextBuffer,Cpy(P1,S1)));
718628

719629
While (k > 0) AND (Not Data^.AtEnd) do
720630
begin
721631
i := StringCompare(QStack.Top,Data);
722632
if (i <> 0) then
723633
begin
724634
dec(k);
725-
Data^.Move(pbuf(QStack.Top)^.EndPtr); {AFTER match}
635+
Data^.Move(PTextFileBuffer(QStack.Top)^.EndPtr); {AFTER match}
726636
end
727637
else
728638
Data^.Move(+1);
@@ -735,7 +645,7 @@ begin
735645
if k <> 0 then
736646
Data^.Move(-1)
737647
else
738-
Data^.Move(pbuf(QStack.Top)^.EndPtr); {AFTER match}
648+
Data^.Move(PTextFileBuffer(QStack.Top)^.EndPtr); {AFTER match}
739649
end;
740650

741651
Dispose(QStack.Pop,Done);
@@ -798,7 +708,7 @@ begin
798708
end;
799709
'C' : begin { close the current buffer }
800710
Data^.Done;
801-
Data := New(PBuf,Init(DefaultSize));
711+
Data := New(PTextFileBuffer,Init(DefaultSize));
802712
end;
803713

804714
'Q' : begin
@@ -1009,7 +919,7 @@ begin
1009919
{ Not Zero } 'N' : If I = 0 then
1010920
GotoElse;
1011921
else
1012-
Error('Undefined Conditional!');
922+
ReportError('Undefined Conditional!');
1013923
End;
1014924
end;
1015925

@@ -1029,7 +939,7 @@ begin
1029939
end;
1030940
end; { Execute() }
1031941

1032-
procedure GetCommand(var cmd : pbuf);
942+
procedure GetCommand(var cmd : PTextFileBuffer);
1033943
var
1034944
C,X,Last : KeyStroke;
1035945
begin
@@ -1109,10 +1019,10 @@ Begin
11091019
LoopStack.Init;
11101020
QStack.Init;
11111021

1112-
Qregs[11] := PBuf(New(PBuffer,Cpy(@CommandP[1],Length(CommandP)) ) );
1022+
Qregs[11] := PTextFileBuffer(New(PTextBuffer,Cpy(@CommandP[1],Length(CommandP)) ) );
11131023

1114-
Qregs[37] := New(PBuf,Load(INIname));
1115-
Qregs[Current] := New(PBuf,Init(DefaultSize));
1024+
Qregs[37] := New(PTextFileBuffer,Load(INIname));
1025+
Qregs[Current] := New(PTextFileBuffer,Init(DefaultSize));
11161026

11171027
Done := False;
11181028

0 commit comments

Comments
 (0)