summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-04-06 23:36:14 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-04-06 23:36:14 +0200
commit61c0d90e41d86a2a80e5b0d50f77aa2318e27c19 (patch)
tree9fb95eb2a62827351c47cded1162486fe726844a
parentb8cbc9f85d459d33243c9d564c01439a21b45f0b (diff)
downloadfpGUI-61c0d90e41d86a2a80e5b0d50f77aa2318e27c19.tar.xz
docdump: processing of the INF dictionary
-rw-r--r--docview/src/docdump/docdump.lpi28
-rw-r--r--docview/src/docdump/docdump.lpr3
-rw-r--r--docview/src/docdump/readdictionary.pas61
3 files changed, 84 insertions, 8 deletions
diff --git a/docview/src/docdump/docdump.lpi b/docview/src/docdump/docdump.lpi
index 440c482c..1c61feff 100644
--- a/docview/src/docdump/docdump.lpi
+++ b/docview/src/docdump/docdump.lpi
@@ -1,16 +1,18 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <Version Value="7"/>
+ <Version Value="9"/>
<General>
<SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/>
- <TargetFileExt Value=""/>
<UseAppBundle Value="False"/>
</General>
<VersionInfo>
- <ProjectVersion Value=""/>
+ <StringTable ProductVersion=""/>
</VersionInfo>
+ <BuildModes Count="1">
+ <Item1 Name="default" Default="True"/>
+ </BuildModes>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
@@ -20,10 +22,11 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
+ <CommandLineParams Value="/media/flash16gig/programming/openwatcom/bld/wipfc/ipfcdump/linux386/rtl_test.inf"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
- <Units Count="15">
+ <Units Count="16">
<Unit0>
<Filename Value="docdump.lpr"/>
<IsPartOfProject Value="True"/>
@@ -98,16 +101,27 @@
<IsPartOfProject Value="True"/>
<UnitName Value="u_Tools"/>
</Unit14>
+ <Unit15>
+ <Filename Value="readdictionary.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="readdictionary"/>
+ </Unit15>
</Units>
</ProjectOptions>
<CompilerOptions>
- <Version Value="8"/>
+ <Version Value="9"/>
+ <Target>
+ <Filename Value="infdump"/>
+ </Target>
<SearchPaths>
- <IncludeFiles Value="$(ProjOutDir)/"/>
- <OtherUnitFiles Value="../"/>
+ <IncludeFiles Value="$(ProjOutDir)"/>
+ <OtherUnitFiles Value=".."/>
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Other>
+ <CompilerMessages>
+ <UseMsgFile Value="True"/>
+ </CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
diff --git a/docview/src/docdump/docdump.lpr b/docview/src/docdump/docdump.lpr
index 84077608..a642b0c0 100644
--- a/docview/src/docdump/docdump.lpr
+++ b/docview/src/docdump/docdump.lpr
@@ -11,7 +11,7 @@ uses
{$ENDIF}{$ENDIF}
Classes, SysUtils, IPFFileFormatUnit, IPFEscapeCodes, CustApp, readheader,
filestreamhelper, readextfiles, readstrings, iterator_intf, iterator_impl,
- readnlsdata, readfonts, readcontrols, readtoc, u_Tools;
+ readnlsdata, readfonts, readcontrols, readtoc, u_Tools, readdictionary;
type
@@ -61,6 +61,7 @@ begin
ProcessFonts(FIn, FOut);
ProcessControls(FIn, FOut);
ProcessTOC(FIn, FOut);
+ ProcessDictionary(FIn, FOut);
finally
FIn.Free;
FOut.Free;
diff --git a/docview/src/docdump/readdictionary.pas b/docview/src/docdump/readdictionary.pas
new file mode 100644
index 00000000..18d2970d
--- /dev/null
+++ b/docview/src/docdump/readdictionary.pas
@@ -0,0 +1,61 @@
+{
+ Dump the dictionary data
+}
+unit readdictionary;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, filestreamhelper;
+
+procedure ProcessDictionary(AIn: TFileStream; AOut: TFileTextStream);
+
+
+implementation
+
+uses
+ IPFFileFormatUnit, readheader, u_Tools;
+
+
+{ We read one dictionary string at a time. Not very efficient, but
+ explains the workings of the dictionary in easy terms. }
+function readDictString(AIn: TFileStream; out AText: string): integer;
+var
+ Len: uint8;
+ p: pbyte;
+ c: array[0..255] of char;
+begin
+ // adjust length so we can use as a Pascal string
+ // (file uses length including length byte,
+ // Pascal string have length excluding length byte)
+ FillChar(c, sizeof(c), 0);
+ Len := AIn.ReadByte; // first byte is the length of string + length byte
+ Result := Len;
+ Len := Len-1; // adjust length to exclude the length byte
+ p := GetMem(Len);
+ AIn.Read(p^, Len); // read string of dictionary
+ Move(p^, c, Len); // copy string to char array
+ AText := c; // convert Pchar to String type
+ FreeMem(p);
+end;
+
+procedure ProcessDictionary(AIn: TFileStream; AOut: TFileTextStream);
+var
+ count: integer;
+ t: string;
+ size: integer;
+begin
+ AOut.WriteLn('');
+ AOut.WriteLn('Dictionary (vocabulary list)');
+ AIn.Seek(hdr.dictstart, soBeginning);
+ for count := 0 to hdr.ndict-1 do
+ begin
+ size := readDictString(AIn, t);
+ AOut.WriteLn(Format(' %4.4x (%4.0d): %2.2x (%.2d) [%s]', [count, count, size, size, t]));
+ end;
+end;
+
+end.
+