+ Made output linesize variable

This commit is contained in:
michael 1999-07-08 21:17:10 +00:00
parent 6a6ff18554
commit b83d255d85
2 changed files with 20 additions and 5 deletions

View File

@ -22,7 +22,7 @@ Uses PtoPu,Objects,getopts;
Var Var
Infilename,OutFileName,ConfigFile : String; Infilename,OutFileName,ConfigFile : String;
BeVerbose : Boolean; BeVerbose : Boolean;
TheIndent,TheBufSize : Integer; TheIndent,TheBufSize,TheLineSize : Integer;
Function StrToInt(Const S : String) : Integer; Function StrToInt(Const S : String) : Integer;
@ -37,10 +37,11 @@ Procedure Usage;
begin begin
Writeln ('ptop : Usage : '); Writeln ('ptop : Usage : ');
Writeln ('ptop [-v] [-i indent] [-b bufsize ][-c optsfile] infile outfile'); Writeln ('ptop [-v] [-i indent] [-b bufsize ][-c optsfile][-l linesize] infile outfile');
Writeln (' converts infile to outfile.'); Writeln (' converts infile to outfile.');
Writeln (' -c : read options from optsfile'); Writeln (' -c : read options from optsfile');
Writeln (' -i : Set number of indent spaces.'); Writeln (' -i : Set number of indent spaces.');
Writeln (' -l : Set maximum output linesize.');
Writeln (' -b : Use buffers of size bufsize'); Writeln (' -b : Use buffers of size bufsize');
Writeln (' -v : be verbose'); Writeln (' -v : be verbose');
writeln ('ptop -g ofile'); writeln ('ptop -g ofile');
@ -71,6 +72,7 @@ begin
ConfigFile:=''; ConfigFile:='';
TheIndent:=2; TheIndent:=2;
TheBufSize:=255; TheBufSize:=255;
TheLineSize:=MaxLineSize;
BeVerbose:=False; BeVerbose:=False;
Repeat Repeat
c:=getopt('i:c:g:b:hv'); c:=getopt('i:c:g:b:hv');
@ -84,6 +86,10 @@ begin
If TheBufSize=0 then TheBufSize:=255; If TheBufSize=0 then TheBufSize:=255;
end; end;
'c' : ConfigFile:=OptArg; 'c' : ConfigFile:=OptArg;
'l' : begin
TheLineSize:=StrToInt(OptArg);
If TheLineSIze=0 Then TheLineSize:=MaxLineSize;
end;
'g' : begin 'g' : begin
ConfigFIle:=OptArg; ConfigFIle:=OptArg;
GenOpts; GenOpts;
@ -125,6 +131,7 @@ begin
CfgS:=Nil; CfgS:=Nil;
PPrinter.Create; PPrinter.Create;
PPrinter.Indent:=TheIndent; PPrinter.Indent:=TheIndent;
PPrinter.LineSize:=TheLineSize;
PPrinter.Ins:=Ins; PPrinter.Ins:=Ins;
PPrinter.outS:=OutS; PPrinter.outS:=OutS;
PPrinter.cfgS:=CfgS; PPrinter.cfgS:=CfgS;
@ -149,7 +156,10 @@ end.
{ {
$Log$ $Log$
Revision 1.1 1999-05-12 16:11:39 peter Revision 1.2 1999-07-08 21:17:10 michael
+ Made output linesize variable
Revision 1.1 1999/05/12 16:11:39 peter
* moved * moved
Revision 1.3 1999/03/25 16:52:29 michael Revision 1.3 1999/03/25 16:52:29 michael

View File

@ -173,6 +173,7 @@ Type
Procedure RShift(currmsym: keysymbol); Procedure RShift(currmsym: keysymbol);
Function ReadConfigFile: Boolean; Function ReadConfigFile: Boolean;
Public Public
LineSize : longint;
Indent : Integer; { How many characters to indent ? } Indent : Integer; { How many characters to indent ? }
InS, InS,
OutS, OutS,
@ -848,7 +849,7 @@ Procedure TprettyPrinter.LShift;
Procedure TPrettyPrinter.InsertSpace(VAR symbol: symbolinfo); Procedure TPrettyPrinter.InsertSpace(VAR symbol: symbolinfo);
{ Insert space if room on line } { Insert space if room on line }
BEGIN BEGIN
IF currlinepos < MAXLINESIZE THEN BEGIN IF currlinepos < LineSize THEN BEGIN
WriteString(OutS, Blank); WriteString(OutS, Blank);
Inc(currlinepos); Inc(currlinepos);
IF (symbol^.crsbefore = 0) AND (symbol^.spacesbefore > 0) IF (symbol^.crsbefore = 0) AND (symbol^.spacesbefore > 0)
@ -1168,6 +1169,7 @@ end;
Constructor TPrettyPrinter.Create; Constructor TPrettyPrinter.Create;
Begin Begin
LineSize:=MaxLineSize;
CreateOptions (Option); CreateOptions (Option);
SetTerminators(Option); SetTerminators(Option);
DiagS:=Nil; DiagS:=Nil;
@ -1188,7 +1190,10 @@ end.
{ {
$Log$ $Log$
Revision 1.2 1999-05-31 10:08:36 michael Revision 1.3 1999-07-08 21:17:11 michael
+ Made output linesize variable
Revision 1.2 1999/05/31 10:08:36 michael
* Fix by Marco van de Voort to enable #13#10 * Fix by Marco van de Voort to enable #13#10
Revision 1.1 1999/05/12 16:11:39 peter Revision 1.1 1999/05/12 16:11:39 peter