|
From: <mar...@us...> - 2007-05-15 08:06:10
|
Revision: 2009
http://svn.sourceforge.net/jcl/?rev=2009&view=rev
Author: marquardt
Date: 2007-05-15 01:06:05 -0700 (Tue, 15 May 2007)
Log Message:
-----------
modifications for FPC
Modified Paths:
--------------
trunk/jcl/source/common/JclFileUtils.pas
trunk/jcl/source/common/JclSysInfo.pas
trunk/jcl/source/common/JclWideStrings.pas
Modified: trunk/jcl/source/common/JclFileUtils.pas
===================================================================
--- trunk/jcl/source/common/JclFileUtils.pas 2007-05-15 06:49:51 UTC (rev 2008)
+++ trunk/jcl/source/common/JclFileUtils.pas 2007-05-15 08:06:05 UTC (rev 2009)
@@ -16,10 +16,10 @@
{ Portions created by Marcel van Brakel are Copyright (C) Marcel van Brakel. All rights reserved. }
{ }
{ Contributors: }
-{ Andr\xE9 Snepvangers (asnepvangers) }
+{ Andre Snepvangers (asnepvangers) }
{ Andreas Hausladen (ahuser) }
{ Anthony Steele }
-{ Rik Barker (rikbarker) }
+{ Rik Barker (rikbarker) }
{ Azret Botash }
{ Charlie Calvert }
{ David Hervieux }
@@ -1570,14 +1570,14 @@
while P < FEnd do
begin
case P^ of
- AnsiLineFeed :
+ AnsiLineFeed:
begin
Inc(FLineCount);
Inc(P);
if (P < FEnd) and (P^ = AnsiCarriageReturn) then
Inc(P);
end;
- AnsiCarriageReturn :
+ AnsiCarriageReturn:
begin
Inc(FLineCount);
Inc(P);
@@ -1680,14 +1680,14 @@
while (Result < FEnd) and (LineOffset > 0) do
begin
case Result^ of
- AnsiLineFeed :
+ AnsiLineFeed:
begin
Dec(LineOffset);
Inc(Result);
if (Result < FEnd) and (Result^ = AnsiCarriageReturn) then
Inc(Result);
end;
- AnsiCarriageReturn :
+ AnsiCarriageReturn:
begin
Dec(LineOffset);
Inc(Result);
@@ -1695,7 +1695,7 @@
Inc(Result);
end;
else
- Inc(Result);
+ Inc(Result);
end;
end;
end
@@ -1707,7 +1707,7 @@
begin
Dec(Result);
case Result^ of
- AnsiLineFeed :
+ AnsiLineFeed:
begin
Inc(LineOffset);
if LineOffset >= 1 then
@@ -1716,7 +1716,7 @@
if (Result > FContent) and ((Result-1)^ = AnsiCarriageReturn) then
Dec(Result);
end;
- AnsiCarriageReturn :
+ AnsiCarriageReturn:
begin
Inc(LineOffset);
if LineOffset >= 1 then
@@ -1769,18 +1769,18 @@
if P < FEnd then
begin
case P^ of
- AnsiLineFeed :
+ AnsiLineFeed:
begin
Inc(P);
if (P < FEnd) and (P^ = AnsiCarriageReturn) then
Inc(P);
end;
- AnsiCarriageReturn :
+ AnsiCarriageReturn:
begin
Inc(P);
if (P < FEnd) and (P^ = AnsiLineFeed) then
Inc(P);
- end;
+ end;
end;
end;
StartPos := P;
@@ -2441,7 +2441,7 @@
if realpath(PChar(Path), PChar(FullPath)) = nil then
RaiseLastOSError;
StrResetLength(FullPath);
-
+
FsTypes := TStringList.Create;
try
GetAvailableFileSystems(FsTypes);
@@ -2689,10 +2689,11 @@
List.Add(SearchRec.Name);
Break;
end;
-
+
case FindNext(SearchRec) of
- 0 : ;
- ERROR_NO_MORE_FILES :
+ 0:
+ ;
+ ERROR_NO_MORE_FILES:
Break;
else
Result := False;
@@ -3237,12 +3238,14 @@
{$ENDIF UNIX}
{$ENDIF ~CLR}
+{$IFDEF MSWINDOWS}
{$IFDEF FPC}
{ TODO : Move this over to JclWin32 when JclWin32 gets overhauled. }
function GetTempFileName(lpPathName, lpPrefixString: PChar;
uUnique: UINT; lpTempFileName: PChar): UINT; stdcall;
external kernel32 name 'GetTempFileNameA';
{$ENDIF FPC}
+{$ENDIF MSWINDOWS}
function FileGetTempName(const Prefix: string): string;
{$IFDEF CLR}
@@ -3752,12 +3755,16 @@
begin
L := MAX_PATH + 1;
SetLength(Result, L);
-{$IFDEF MSWINDOWS}
+ {$IFDEF MSWINDOWS}
L := Windows.GetModuleFileName(Module, Pointer(Result), L);
-{$ENDIF MSWINDOWS}
-{$IFDEF UNIX}
+ {$ENDIF MSWINDOWS}
+ {$IFDEF UNIX}
+ {$IFDEF FPC}
+ L := 0; // FIXME
+ {$ELSE}
L := GetModuleFileName(Module, Pointer(Result), L);
-{$ENDIF UNIX}
+ {$ENDIF FPC}
+ {$ENDIF UNIX}
SetLength(Result, L);
end;
{$ENDIF ~CLR}
@@ -5488,7 +5495,11 @@
Priority := tpIdle;
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
+ {$IFDEF FPC}
+ Priority := tpIdle;
+ {$ELSE}
Priority := 0;
+ {$ENDIF FPC}
{$ENDIF UNIX}
{$ENDIF ~CLR}
FreeOnTerminate := True;
@@ -6100,7 +6111,7 @@
for IndexNew := 0 to NewItems.Count - 1 do
begin
Item := NewItems.Strings[IndexNew];
-
+
Duplicate := False;
for IndexList := 0 to StrList.Count - 1 do
if SamePath(Item, StrList.Strings[IndexList]) then
Modified: trunk/jcl/source/common/JclSysInfo.pas
===================================================================
--- trunk/jcl/source/common/JclSysInfo.pas 2007-05-15 06:49:51 UTC (rev 2008)
+++ trunk/jcl/source/common/JclSysInfo.pas 2007-05-15 08:06:05 UTC (rev 2009)
@@ -17,7 +17,7 @@
{ }
{ Contributors: }
{ Alexander Radchenko }
-{ Andr\xE9 Snepvangers (asnepvangers) }
+{ Andre Snepvangers (asnepvangers) }
{ Azret Botash }
{ Bryan Coutch }
{ Carl Clark }
@@ -32,7 +32,7 @@
{ Nick Hodges }
{ Olivier Sannier (obones) }
{ Peter Friese }
-{ Peter Th\xF6rnquist (peter3) }
+{ Peter Thornquist (peter3) }
{ Petr Vones (pvones) }
{ Rik Barker }
{ Robert Marquardt (marquardt) }
@@ -138,7 +138,9 @@
function GetStartmenuFolder: string;
function GetDesktopDirectoryFolder: string;
{$IFNDEF CLR}
+{$IFNDEF FPC}
function GetCommonDocumentsFolder: string;
+{$ENDIF ~FPC}
function GetNethoodFolder: string;
function GetFontsFolder: string;
function GetCommonStartmenuFolder: string;
@@ -418,7 +420,7 @@
LinePerSector: Byte; // for L3 Normal Cache
Entries: Cardinal; // for TLB
I: string;
- end;
+ end;
TFreqInfo = record
RawFreq: Cardinal;
@@ -664,7 +666,7 @@
EINTEL64_BIT_26 = BIT_26; // Reserved, do not count on value
EINTEL64_BIT_27 = BIT_27; // Reserved, do not count on value
EINTEL64_BIT_28 = BIT_28; // Reserved, do not count on value
- EINTEL64_EM64T = BIT_29; // Intel\xAE Extended Memory 64 Technology
+ EINTEL64_EM64T = BIT_29; // Intel Extended Memory 64 Technology
EINTEL64_BIT_30 = BIT_30; // Reserved, do not count on value
EINTEL64_BIT_31 = BIT_31; // Reserved, do not count on value
@@ -1312,7 +1314,9 @@
JclBase, JclFileUtils, JclStrings;
{$IFDEF FPC}
+{$IFDEF MSWINDOWS}
{$I JclSysInfo.fpc}
+{$ENDIF MSWINDOWS}
{$ENDIF FPC}
//=== Environment ============================================================
@@ -1445,13 +1449,13 @@
end;
{$ENDIF UNIX}
-{$IFDEF MSWINDOWS}
-
function GetEnvironmentVars(const Vars: TStrings): Boolean;
begin
Result := GetEnvironmentVars(Vars, True);
end;
+{$IFDEF MSWINDOWS}
+
function GetEnvironmentVars(const Vars: TStrings; Expand: Boolean): Boolean;
{$IFDEF CLR}
var
@@ -1661,7 +1665,11 @@
StrResetLength(Result);
Exit;
end;
+ {$IFDEF FPC}
+ if GetLastOSError <> ERANGE then
+ {$ELSE}
if GetLastError <> ERANGE then
+ {$ENDIF FPC}
RaiseLastOSError;
Size := Size * 2;
end;
@@ -1843,10 +1851,12 @@
end;
{$IFNDEF CLR}
+{$IFNDEF FPC}
function GetCommonDocumentsFolder: string;
begin
Result := GetSpecialFolderLocation(CSIDL_COMMON_DOCUMENTS);
end;
+{$ENDIF ~FPC}
{$ENDIF ~CLR}
{$IFNDEF CLR}
@@ -2171,13 +2181,22 @@
while IfList^.if_index <> 0 do
begin
//copy in the interface name to look up address of
+ {$IFDEF FPC}
+ strncpy(IfReq.ifr_ifrn.ifrn_name, IfList^.if_name, IFNAMSIZ);
+ {$ELSE}
strncpy(IfReq.ifrn_name, IfList^.if_name, IFNAMSIZ);
+ {$ENDIF FPC}
//get the address for this interface
if ioctl(Sock, SIOCGIFADDR, @IfReq) <> 0 then
RaiseLastOSError;
//print out the address
+ {$IFDEF FPC}
+ SockAddrPtr := PSockAddrIn(@IfReq.ifr_ifru.ifru_addr);
+ Results.Add(Format('%s=%s', [IfReq.ifr_ifrn.ifrn_name, inet_ntoa(SockAddrPtr^.sin_addr)]));
+ {$ELSE}
SockAddrPtr := PSockAddrIn(@IfReq.ifru_addr);
Results.Add(Format('%s=%s', [IfReq.ifrn_name, inet_ntoa(SockAddrPtr^.sin_addr)]));
+ {$ENDIF FPC}
Inc(IfList);
end;
finally
@@ -2422,8 +2441,13 @@
if ProcDir <> nil then
begin
PtrDirEnt := nil;
+ {$IFDEF FPC}
+ if readdir_r(ProcDir, @Scratch, @PtrDirEnt) <> 0 then
+ Exit;
+ {$ELSE}
if readdir_r(ProcDir, @Scratch, PtrDirEnt) <> 0 then
Exit;
+ {$ENDIF FPC}
List.BeginUpdate;
try
while PtrDirEnt <> nil do
@@ -2455,8 +2479,13 @@
List.AddObject(FileName, Pointer(ProcID));
end;
+ {$IFDEF FPC}
+ if readdir_r(ProcDir, @Scratch, @PtrDirEnt) <> 0 then
+ Break;
+ {$ELSE}
if readdir_r(ProcDir, @Scratch, PtrDirEnt) <> 0 then
Break;
+ {$ENDIF FPC}
end;
finally
List.EndUpdate;
@@ -2921,7 +2950,7 @@
if GetWindowThreadProcessId(Wnd, @PID) <> 0 then
Result := TerminateApp(PID, Timeout)
else
- Result := taError;
+ Result := taError;
end;
function GetProcessNameFromWnd(Wnd: THandle): string;
@@ -4052,7 +4081,7 @@
POP EDI
end;
end;
-
+
procedure ProcessStandard(var CPUInfo: TCpuInfo; HiVal: Cardinal);
var
VersionInfo, AdditionalInfo, ExFeatures: Cardinal;
@@ -4141,36 +4170,36 @@
if IntelCacheDescription[J].D = CPUInfo.IntelSpecific.CacheDescriptors[I] then
with IntelCacheDescription[J] do
case Family of
- //cfInstructionTLB :
- //cfDataTLB :
- cfL1InstructionCache :
+ //cfInstructionTLB:
+ //cfDataTLB:
+ cfL1InstructionCache:
begin
Inc(CPUInfo.L1InstructionCacheSize,Size);
CPUInfo.L1InstructionCacheLineSize := LineSize;
CPUInfo.L1InstructionCacheAssociativity := WaysOfAssoc;
end;
- cfL1DataCache :
+ cfL1DataCache:
begin
Inc(CPUInfo.L1DataCacheSize,Size);
CPUInfo.L1DataCacheLineSize := LineSize;
CPUInfo.L1DataCacheAssociativity := WaysOfAssoc;
end;
- cfL2Cache :
+ cfL2Cache:
if (CPUInfo.IntelSpecific.L2Cache = 0) then
begin
Inc(CPUInfo.L2CacheSize,Size);
CPUInfo.L2CacheLineSize := LineSize;
CPUInfo.L2CacheAssociativity := WaysOfAssoc;
end;
- cfL3Cache :
+ cfL3Cache:
begin
Inc(CPUInfo.L3CacheSize,Size);
CPUInfo.L3CacheLineSize := LineSize;
CPUInfo.L3CacheAssociativity := WaysOfAssoc;
CPUInfo.L3LinesPerSector := LinePerSector;
end;
- //cfTrace : // no numeric informations
- //cfOther :
+ //cfTrace: // no numeric informations
+ //cfOther:
end;
end;
if not CPUInfo.HasExtendedInfo then
@@ -4402,7 +4431,7 @@
10:
CPUInfo.CpuName := 'AMD Athlon\x99 XP (Model 10)';
else
- StrFmt(CPUInfo.CpuName,PChar(RsUnknownAMDModel),[CPUInfo.Model]);
+ StrFmt(CPUInfo.CpuName, PChar(RsUnknownAMDModel), [CPUInfo.Model]);
end;
8:
@@ -4428,7 +4457,7 @@
CPUInfo.Is64Bits := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_LONG) <> 0);
CPUInfo.DEPCapable := CPUInfo.HasExtendedInfo and ((CPUInfo.AMDSpecific.ExFeatures and EAMD_NX) <> 0);
end;
-
+
procedure ProcessCyrix(var CPUInfo: TCpuInfo; HiVal: Cardinal);
var
ExHiVal, Unused, VersionInfo, AdditionalInfo: Cardinal;
@@ -4546,7 +4575,7 @@
else CPUInfo.SSE := 0;
CPUInfo._3DNow := (CPUInfo.Features and VIA_3DNOW) <> 0;
end;
-
+
procedure ProcessTransmeta(var CPUInfo: TCpuInfo; HiVal: Cardinal);
var
ExHiVal, Unused, VersionInfo: Cardinal;
@@ -4629,14 +4658,14 @@
end;
CPUInfo.MMX := (CPUInfo.Features and TRANSMETA_MMX) <> 0;
end;
-
+
var
HiVal: Cardinal;
begin
FillChar(Result, sizeof(Result), 0);
Result.LogicalCore := 1;
Result.PhysicalCore := 1;
-
+
if HasCPUIDInstruction then
begin
Result.HasInstruction := True;
@@ -4874,7 +4903,11 @@
var
SystemInf: TSysInfo ;
begin
+ {$IFDEF FPC}
+ SysInfo(@SystemInf);
+ {$ELSE}
SysInfo(SystemInf);
+ {$ENDIF FPC}
with SystemInf do
Result := 100 - Round(100 * freeram / totalram);
end;
@@ -4895,7 +4928,11 @@
var
SystemInf: TSysInfo;
begin
+ {$IFDEF FPC}
+ SysInfo(@SystemInf);
+ {$ELSE}
SysInfo(SystemInf);
+ {$ENDIF FPC}
Result := SystemInf.totalswap;
end;
{$ENDIF UNIX}
@@ -4916,7 +4953,11 @@
var
SystemInf: TSysInfo;
begin
+ {$IFDEF FPC}
+ SysInfo(@SystemInf);
+ {$ELSE}
SysInfo(SystemInf);
+ {$ENDIF FPC}
with SystemInf do
Result := 100 - Trunc(100 * FreeSwap / TotalSwap);
end;
@@ -4941,7 +4982,11 @@
var
SystemInf: TSysInfo;
begin
+ {$IFDEF FPC}
+ SysInfo(@SystemInf);
+ {$ELSE}
SysInfo(SystemInf);
+ {$ENDIF FPC}
Result := SystemInf.totalram;
end;
{$ENDIF UNIX}
@@ -4961,7 +5006,11 @@
var
SystemInf: TSysInfo;
begin
+ {$IFDEF FPC}
+ SysInfo(@SystemInf);
+ {$ELSE}
SysInfo(SystemInf);
+ {$ENDIF FPC}
Result := SystemInf.freeram;
end;
{$ENDIF UNIX}
@@ -5078,7 +5127,7 @@
@MyGetFreeSystemResources := GetProcAddress(ResmeterLibHandle, '_MyGetFreeSystemResources32@4');
if not Assigned(MyGetFreeSystemResources) then
UnloadSystemResourcesMeterLib;
- end;
+ end;
end;
begin
Modified: trunk/jcl/source/common/JclWideStrings.pas
===================================================================
--- trunk/jcl/source/common/JclWideStrings.pas 2007-05-15 06:49:51 UTC (rev 2008)
+++ trunk/jcl/source/common/JclWideStrings.pas 2007-05-15 08:06:05 UTC (rev 2009)
@@ -111,7 +111,7 @@
procedure DefineProperties(Filer: TFiler); override;
function ExtractName(const S: WideString): WideString;
function GetP(Index: Integer): PWideString; virtual; abstract;
- function Get(Index: Integer): WideString;
+ function Get(Index: Integer): WideString;
function GetCapacity: Integer; virtual;
function GetCount: Integer; virtual; abstract;
function GetObject(Index: Integer): TObject; virtual;
@@ -288,8 +288,10 @@
function TrimLeftLengthW(const S: WideString): Integer;
function TrimRightLengthW(const S: WideString): Integer;
+{$IFNDEF FPC}
function WideStartsText(const SubStr, S: WideString): Boolean;
function WideStartsStr(const SubStr, S: WideString): Boolean;
+{$ENDIF ~FPC}
{$IFDEF UNITVERSIONING}
const
@@ -995,8 +997,12 @@
Result := CompareStringW(LOCALE_USER_DEFAULT, 0,
PWideChar(S1), Length(S1), PWideChar(S2), Length(S2)) - 2;
{$ELSE ~MSWINDOWS}
- { TODO : Don't cheat here }
- Result := CompareString(S1, S2);
+ {$IFDEF FPC}
+ Result := SysUtils.WideCompareStr(S1, S2);
+ {$ELSE}
+ { TODO : Don't cheat here }
+ Result := CompareString(S1, S2);
+ {$ENDIF FPC}
{$ENDIF ~MSWINDOWS}
end;
@@ -1044,6 +1050,8 @@
Dec(Result);
end;
+{$IFNDEF FPC}
+
function WideStartsText(const SubStr, S: WideString): Boolean;
var
Len: Integer;
@@ -1060,6 +1068,7 @@
Result := (Len <= Length(S)) and (StrLCompW(PWideChar(SubStr), PWideChar(S), Len) = 0);
end;
+{$ENDIF ~FPC}
//=== { TWStrings } ==========================================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2007-05-20 04:45:25
|
Revision: 2011
http://svn.sourceforge.net/jcl/?rev=2011&view=rev
Author: marquardt
Date: 2007-05-19 21:45:22 -0700 (Sat, 19 May 2007)
Log Message:
-----------
minor resourcestring move
Modified Paths:
--------------
trunk/jcl/source/common/JclResources.pas
trunk/jcl/source/common/JclSysInfo.pas
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2007-05-18 20:16:19 UTC (rev 2010)
+++ trunk/jcl/source/common/JclResources.pas 2007-05-20 04:45:22 UTC (rev 2011)
@@ -1749,6 +1749,8 @@
RsIntelCacheDescrF0 = '64-Byte Prefetching';
RsIntelCacheDescrF1 = '128-Byte Prefetching';
+ RsUnknownAMDModel = 'Unknown AMD (Model %d)';
+
RsOSVersionWin95 = 'Windows 95';
RsOSVersionWin95OSR2 = 'Windows 95 OSR2';
RsOSVersionWin98 = 'Windows 98';
Modified: trunk/jcl/source/common/JclSysInfo.pas
===================================================================
--- trunk/jcl/source/common/JclSysInfo.pas 2007-05-18 20:16:19 UTC (rev 2010)
+++ trunk/jcl/source/common/JclSysInfo.pas 2007-05-20 04:45:22 UTC (rev 2011)
@@ -4034,9 +4034,6 @@
end;
{$ENDIF MSWINDOWS}
-resourcestring
- RsUnknownAMDModel = 'Unknown AMD (Model %d)';
-
function CPUID: TCpuInfo;
function HasCPUIDInstruction: Boolean;
const
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2007-06-10 08:39:54
|
Revision: 2033
http://svn.sourceforge.net/jcl/?rev=2033&view=rev
Author: outchy
Date: 2007-06-10 01:39:50 -0700 (Sun, 10 Jun 2007)
Log Message:
-----------
Mantis 4111: LastDayOfWeek returns wrong result.
Moving Date and Time related functions from JclSchedule.pas to JclDateTime.pas.
Modified Paths:
--------------
trunk/jcl/source/common/JclDateTime.pas
trunk/jcl/source/common/JclSchedule.pas
Modified: trunk/jcl/source/common/JclDateTime.pas
===================================================================
--- trunk/jcl/source/common/JclDateTime.pas 2007-06-09 20:52:48 UTC (rev 2032)
+++ trunk/jcl/source/common/JclDateTime.pas 2007-06-10 08:39:50 UTC (rev 2033)
@@ -200,6 +200,28 @@
function UnixTimeToFileTime(const AValue: TJclUnixTime32): TFileTime;
{$ENDIF MSWINDOWS}
+// Time stamps (formerly in JclSchedule)
+function NullStamp: TTimeStamp;
+function CompareTimeStamps(const Stamp1, Stamp2: TTimeStamp): Int64;
+function EqualTimeStamps(const Stamp1, Stamp2: TTimeStamp): Boolean;
+function IsNullTimeStamp(const Stamp: TTimeStamp): Boolean;
+function TimeStampDOW(const Stamp: TTimeStamp): Integer;
+
+// Day of week (formerly in JclSchedule)
+function FirstWeekDay(const Year, Month: Integer; var DOW: Integer): Integer; overload;
+function FirstWeekDay(const Year, Month: Integer): Integer; overload;
+function LastWeekDay(const Year, Month: Integer; var DOW: Integer): Integer; overload;
+function LastWeekDay(const Year, Month: Integer): Integer; overload;
+function IndexedWeekDay(const Year, Month: Integer; Index: Integer): Integer;
+function FirstWeekendDay(const Year, Month: Integer; var DOW: Integer): Integer; overload;
+function FirstWeekendDay(const Year, Month: Integer): Integer; overload;
+function LastWeekendDay(const Year, Month: Integer; var DOW: Integer): Integer; overload;
+function LastWeekendDay(const Year, Month: Integer): Integer; overload;
+function IndexedWeekendDay(const Year, Month: Integer; Index: Integer): Integer;
+function FirstDayOfWeek(const Year, Month, DayOfWeek: Integer): Integer;
+function LastDayOfWeek(const Year, Month, DayOfWeek: Integer): Integer;
+function IndexedDayOfWeek(const Year, Month, DayOfWeek, Index: Integer): Integer;
+
type
EJclDateTimeError = class(EJclError);
@@ -1204,6 +1226,264 @@
{$ENDIF MSWINDOWS}
+// Time stamps utilities
+
+// Utility functions
+function NullStamp: TTimeStamp;
+begin
+ Result.Date := 0;
+ Result.Time := -1;
+end;
+
+function CompareTimeStamps(const Stamp1, Stamp2: TTimeStamp): Int64;
+begin
+ if Stamp1.Date < Stamp2.Date then
+ Result := -1
+ else
+ if Stamp1.Date = Stamp2.Date then
+ begin
+ if Stamp1.Time < Stamp2.Time then
+ Result := -1
+ else
+ if Stamp1.Time = Stamp2.Time then
+ Result := 0
+ else // If Stamp1.Time > Stamp2.Time then
+ Result := 1;
+ end
+ else // if Stamp1.Date > Stamp2.Date then
+ Result := 1;
+// Result := Int64(Stamp1) - Int64(Stamp2);
+end;
+
+function EqualTimeStamps(const Stamp1, Stamp2: TTimeStamp): Boolean;
+begin
+ Result := CompareTimeStamps(Stamp1, Stamp2) = 0;
+end;
+
+function IsNullTimeStamp(const Stamp: TTimeStamp): Boolean;
+begin
+ Result := CompareTimeStamps(NullStamp, Stamp) = 0;
+end;
+
+function TimeStampDOW(const Stamp: TTimeStamp): Integer;
+begin
+ Result := (Stamp.Date - 1) mod 7 + 1
+end;
+
+// day of week utilities
+
+function FirstWeekDay(const Year, Month: Integer; var DOW: Integer): Integer;
+begin
+ DOW := ISODayOfWeek(EncodeDate(Year, Month, 1));
+ if DOW > 5 then
+ begin
+ Result := 9 - DOW;
+ DOW := 1;
+ end
+ else
+ Result := 1;
+end;
+
+function FirstWeekDay(const Year, Month: Integer): Integer;
+var
+ Dummy: Integer;
+begin
+ Result := FirstWeekDay(Year, Month, Dummy);
+end;
+
+function LastWeekDay(const Year, Month: Integer; var DOW: Integer): Integer;
+begin
+ DOW := ISODayOfWeek(EncodeDate(Year, Month, DaysInMonth(EncodeDate(Year, Month, 1))));
+ if DOW > 5 then
+ begin
+ Result := DaysInMonth(EncodeDate(Year, Month, 1)) - (DOW - 5);
+ DOW := 5;
+ end
+ else
+ Result := DaysInMonth(EncodeDate(Year, Month, 1));
+end;
+
+function LastWeekDay(const Year, Month: Integer): Integer;
+var
+ Dummy: Integer;
+begin
+ Result := LastWeekDay(Year, Month, Dummy);
+end;
+
+function IndexedWeekDay(const Year, Month: Integer; Index: Integer): Integer;
+var
+ DOW: Integer;
+begin
+ if Index > 0 then
+ Result := FirstWeekDay(Year, Month, DOW)
+ else
+ if Index < 0 then
+ Result := LastWeekDay(Year, Month, DOW)
+ else
+ Result := 0;
+ if Index > 1 then // n-th weekday from start of month
+ begin
+ Dec(Index);
+ if DOW > 1 then // adjust to first monday
+ begin
+ if Index < (5 - DOW) then
+ begin
+ Inc(Result, Index);
+ Index := 0;
+ end
+ else
+ begin
+ Dec(Index, 6 - DOW);
+ Inc(Result, 8 - DOW);
+ end;
+ end;
+ Result := Result + (7 * (Index div 5)) + (Index mod 5);
+ end
+ else
+ if Index < -1 then // n-th weekday from end of month
+ begin
+ Index := Abs(Index) - 1;
+ if DOW < 5 then // adjust to last friday
+ begin
+ if Index < DOW then
+ begin
+ Dec(Result, Index);
+ Index := 0;
+ end
+ else
+ begin
+ Dec(Index, DOW);
+ Dec(Result, DOW + 2);
+ end;
+ end;
+ Result := Result - (7 * (Index div 5)) - (Index mod 5);
+ end;
+ if (Result < 0) or (Result > DaysInMonth(EncodeDate(Year, Month, 1))) then
+ Result := 0;
+end;
+
+function FirstWeekendDay(const Year, Month: Integer; var DOW: Integer): Integer;
+begin
+ DOW := ISODayOfWeek(EncodeDate(Year, Month, 1));
+ if DOW < 6 then
+ begin
+ Result := 7 - DOW;
+ DOW := 6;
+ end
+ else
+ Result := 1;
+end;
+
+function FirstWeekendDay(const Year, Month: Integer): Integer;
+var
+ Dummy: Integer;
+begin
+ Result := FirstWeekendDay(Year, Month, Dummy);
+end;
+
+function LastWeekendDay(const Year, Month: Integer; var DOW: Integer): Integer;
+begin
+ DOW := ISODayOfWeek(EncodeDate(Year, Month, DaysInMonth(EncodeDate(Year, Month, 1))));
+ if DOW < 6 then
+ begin
+ Result := DaysInMonth(EncodeDate(Year, Month, 1)) - DOW;
+ DOW := 7;
+ end
+ else
+ Result := DaysInMonth(EncodeDate(Year, Month, 1));
+end;
+
+function LastWeekendDay(const Year, Month: Integer): Integer;
+var
+ Dummy: Integer;
+begin
+ Result := LastWeekendDay(Year, Month, Dummy);
+end;
+
+function IndexedWeekendDay(const Year, Month: Integer; Index: Integer): Integer;
+var
+ DOW: Integer;
+begin
+ if Index > 0 then
+ Result := FirstWeekendDay(Year, Month, DOW)
+ else
+ if Index < 0 then
+ Result := LastWeekendDay(Year, Month, DOW)
+ else
+ Result := 0;
+ if Index > 1 then // n-th weekend day from the start of the month
+ begin
+ if (DOW > 6) and not Odd(Index) then // Adjust to first saturday
+ begin
+ Inc(Result, 6);
+ Dec(Index);
+ end;
+ if Index > 1 then
+ begin
+ Dec(Index);
+ Result := Result + (7 * (Index div 2)) + (Index mod 2);
+ end;
+ end
+ else
+ if Index < -1 then // n-th weekend day from the start of the month
+ begin
+ Index := Abs(Index);
+ if (DOW < 7) and not Odd(Index) then // Adjust to last sunday
+ begin
+ Dec(Result, 6);
+ Dec(Index);
+ end;
+ if Index > 1 then
+ begin
+ Dec(Index);
+ Result := Result - (7 * (Index div 2)) - (Index mod 2);
+ end;
+ end;
+ if (Result < 0) or (Result > DaysInMonth(EncodeDate(Year, Month, 1))) then
+ Result := 0;
+end;
+
+function FirstDayOfWeek(const Year, Month, DayOfWeek: Integer): Integer;
+var
+ DOW: Integer;
+begin
+ DOW := ISODayOfWeek(EncodeDate(Year, Month, 1));
+ if DOW > DayOfWeek then
+ Result := 8 + DayOfWeek - DOW
+ else
+ if DOW < DayOfWeek then
+ Result := 1 + DayOfWeek - DOW
+ else
+ Result := 1;
+end;
+
+function LastDayOfWeek(const Year, Month, DayOfWeek: Integer): Integer;
+var
+ DOW: Integer;
+begin
+ DOW := ISODayOfWeek(EncodeDate(Year, Month, DaysInMonth(EncodeDate(Year, Month, 1))));
+ if DOW > DayOfWeek then
+ Result := DaysInMonth(EncodeDate(Year, Month, 1)) - (DOW - DayOfWeek)
+ else
+ if DOW < DayOfWeek then
+ Result := DaysInMonth(EncodeDate(Year, Month, 1)) - (7 - DayOfWeek + DOW)
+ else
+ Result := DaysInMonth(EncodeDate(Year, Month, 1));
+end;
+
+function IndexedDayOfWeek(const Year, Month, DayOfWeek, Index: Integer): Integer;
+begin
+ if Index > 0 then
+ Result := FirstDayOfWeek(Year, Month, DayOfWeek) + 7 * (Index - 1)
+ else
+ if Index < 0 then
+ Result := LastDayOfWeek(Year, Month, DayOfWeek) - 7 * (Abs(Index) - 1)
+ else
+ Result := 0;
+ if (Result < 0) or (Result > DaysInMonth(EncodeDate(Year, Month, 1))) then
+ Result := 0;
+end;
+
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
Modified: trunk/jcl/source/common/JclSchedule.pas
===================================================================
--- trunk/jcl/source/common/JclSchedule.pas 2007-06-09 20:52:48 UTC (rev 2032)
+++ trunk/jcl/source/common/JclSchedule.pas 2007-06-10 08:39:50 UTC (rev 2033)
@@ -174,10 +174,6 @@
end;
function CreateSchedule: IJclSchedule;
-function NullStamp: TTimeStamp;
-function CompareTimeStamps(const Stamp1, Stamp2: TTimeStamp): Int64;
-function EqualTimeStamps(const Stamp1, Stamp2: TTimeStamp): Boolean;
-function IsNullTimeStamp(const Stamp: TTimeStamp): Boolean;
{$IFDEF UNITVERSIONING}
const
@@ -257,265 +253,6 @@
{$ENDIF ~RTL140_UP}
-// Utility functions
-function NullStamp: TTimeStamp;
-begin
- Result.Date := 0;
- Result.Time := -1;
-end;
-
-function CompareTimeStamps(const Stamp1, Stamp2: TTimeStamp): Int64;
-begin
- if Stamp1.Date < Stamp2.Date then
- Result := -1
- else
- if Stamp1.Date = Stamp2.Date then
- begin
- if Stamp1.Time < Stamp2.Time then
- Result := -1
- else
- if Stamp1.Time = Stamp2.Time then
- Result := 0
- else // If Stamp1.Time > Stamp2.Time then
- Result := 1;
- end
- else // if Stamp1.Date > Stamp2.Date then
- Result := 1;
-// Result := Int64(Stamp1) - Int64(Stamp2);
-end;
-
-function EqualTimeStamps(const Stamp1, Stamp2: TTimeStamp): Boolean;
-begin
- Result := CompareTimeStamps(Stamp1, Stamp2) = 0;
-end;
-
-function IsNullTimeStamp(const Stamp: TTimeStamp): Boolean;
-begin
- Result := CompareTimeStamps(NullStamp, Stamp) = 0;
-end;
-
-function TimeStampDOW(const Stamp: TTimeStamp): Integer;
-begin
- Result := (Stamp.Date - 1) mod 7 + 1
-end;
-
-function ISODayOfWeek(DateTime: TDateTime): Integer;
-begin
- Result := (DayOfWeek(DateTime - 2 + 7) mod 7) + 1;
-end;
-
-function FirstWeekDayPrim(const Year, Month: Integer; var DOW: Integer): Integer;
-begin
- DOW := ISODayOfWeek(JclDateTime.EncodeDate(Year, Month, 1));
- if DOW > 5 then
- begin
- Result := 9 - DOW;
- DOW := 1;
- end
- else
- Result := 1;
-end;
-
-function LastWeekDayPrim(const Year, Month: Integer; var DOW: Integer): Integer;
-begin
- DOW := ISODayOfWeek(JclDateTime.EncodeDate(Year, Month, DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1))));
- if DOW > 5 then
- begin
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1)) - (DOW - 5);
- DOW := 5;
- end
- else
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1));
-end;
-
-function FirstWeekendDayPrim(const Year, Month: Integer; var DOW: Integer): Integer;
-begin
- DOW := ISODayOfWeek(JclDateTime.EncodeDate(Year, Month, 1));
- if DOW < 6 then
- begin
- Result := 7 - DOW;
- DOW := 6;
- end
- else
- Result := 1;
-end;
-
-function LastWeekendDayPrim(const Year, Month: Integer; var DOW: Integer): Integer;
-begin
- DOW := ISODayOfWeek(JclDateTime.EncodeDate(Year, Month, DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1))));
- if DOW < 6 then
- begin
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1)) - DOW;
- DOW := 7;
- end
- else
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1));
-end;
-
-function FirstWeekDay(const Year, Month: Integer): Integer;
-var
- Dummy: Integer;
-begin
- Result := FirstWeekDayPrim(Year, Month, Dummy);
-end;
-
-function LastWeekDay(const Year, Month: Integer): Integer;
-var
- Dummy: Integer;
-begin
- Result := LastWeekDayPrim(Year, Month, Dummy);
-end;
-
-function IndexedWeekDay(const Year, Month: Integer; Index: Integer): Integer;
-var
- DOW: Integer;
-begin
- if Index > 0 then
- Result := FirstWeekDayPrim(Year, Month, DOW)
- else
- if Index < 0 then
- Result := LastWeekDayPrim(Year, Month, DOW)
- else
- Result := 0;
- if Index > 1 then // n-th weekday from start of month
- begin
- Dec(Index);
- if DOW > 1 then // adjust to first monday
- begin
- if Index < (5 - DOW) then
- begin
- Inc(Result, Index);
- Index := 0;
- end
- else
- begin
- Dec(Index, 6 - DOW);
- Inc(Result, 8 - DOW);
- end;
- end;
- Result := Result + (7 * (Index div 5)) + (Index mod 5);
- end
- else
- if Index < -1 then // n-th weekday from end of month
- begin
- Index := Abs(Index) - 1;
- if DOW < 5 then // adjust to last friday
- begin
- if Index < DOW then
- begin
- Dec(Result, Index);
- Index := 0;
- end
- else
- begin
- Dec(Index, DOW);
- Dec(Result, DOW + 2);
- end;
- end;
- Result := Result - (7 * (Index div 5)) - (Index mod 5);
- end;
- if (Result < 0) or (Result > DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1))) then
- Result := 0;
-end;
-
-function FirstWeekendDay(const Year, Month: Integer): Integer;
-var
- Dummy: Integer;
-begin
- Result := FirstWeekendDayPrim(Year, Month, Dummy);
-end;
-
-function LastWeekendDay(const Year, Month: Integer): Integer;
-var
- Dummy: Integer;
-begin
- Result := LastWeekendDayPrim(Year, Month, Dummy);
-end;
-
-function IndexedWeekendDay(const Year, Month: Integer; Index: Integer): Integer;
-var
- DOW: Integer;
-begin
- if Index > 0 then
- Result := FirstWeekendDayPrim(Year, Month, DOW)
- else
- if Index < 0 then
- Result := LastWeekendDayPrim(Year, Month, DOW)
- else
- Result := 0;
- if Index > 1 then // n-th weekend day from the start of the month
- begin
- if (DOW > 6) and not Odd(Index) then // Adjust to first saturday
- begin
- Inc(Result, 6);
- Dec(Index);
- end;
- if Index > 1 then
- begin
- Dec(Index);
- Result := Result + (7 * (Index div 2)) + (Index mod 2);
- end;
- end
- else
- if Index < -1 then // n-th weekend day from the start of the month
- begin
- Index := Abs(Index);
- if (DOW < 7) and not Odd(Index) then // Adjust to last sunday
- begin
- Dec(Result, 6);
- Dec(Index);
- end;
- if Index > 1 then
- begin
- Dec(Index);
- Result := Result - (7 * (Index div 2)) - (Index mod 2);
- end;
- end;
- if (Result < 0) or (Result > DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1))) then
- Result := 0;
-end;
-
-function FirstDayOfWeek(const Year, Month, DayOfWeek: Integer): Integer;
-var
- DOW: Integer;
-begin
- DOW := ISODayOfWeek(JclDateTime.EncodeDate(Year, Month, 1));
- if DOW > DayOfWeek then
- Result := 8 + DayOfWeek - DOW
- else
- if DOW < DayOfWeek then
- Result := 1 + DayOfWeek - DOW
- else
- Result := 1;
-end;
-
-function LastDayOfWeek(const Year, Month, DayOfWeek: Integer): Integer;
-var
- DOW: Integer;
-begin
- DOW := ISODayOfWeek(JclDateTime.EncodeDate(Year, Month, DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1))));
- if DOW > DayOfWeek then
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1)) - (DOW - DayOfWeek)
- else
- if DOW < DayOfWeek then
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1)) - (7 + DayOfWeek - DOW)
- else
- Result := DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1));
-end;
-
-function IndexedDayOfWeek(const Year, Month, DayOfWeek, Index: Integer): Integer;
-begin
- if Index > 0 then
- Result := FirstDayOfWeek(Year, Month, DayOfWeek) + 7 * (Index - 1)
- else
- if Index < 0 then
- Result := LastDayOfWeek(Year, Month, DayOfWeek) - 7 * (Abs(Index) - 1)
- else
- Result := 0;
- if (Result < 0) or (Result > DaysInMonth(JclDateTime.EncodeDate(Year, Month, 1))) then
- Result := 0;
-end;
-
//=== { TScheduleAggregate } =================================================
type
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2007-06-10 08:55:33
|
Revision: 2034
http://svn.sourceforge.net/jcl/?rev=2034&view=rev
Author: outchy
Date: 2007-06-10 01:55:31 -0700 (Sun, 10 Jun 2007)
Log Message:
-----------
Eliminating dotnet specific warnings.
Modified Paths:
--------------
trunk/jcl/source/common/JclBase.pas
trunk/jcl/source/common/JclStringLists.pas
Modified: trunk/jcl/source/common/JclBase.pas
===================================================================
--- trunk/jcl/source/common/JclBase.pas 2007-06-10 08:39:50 UTC (rev 2033)
+++ trunk/jcl/source/common/JclBase.pas 2007-06-10 08:55:31 UTC (rev 2034)
@@ -230,7 +230,7 @@
// basic set types
type
- TSetOfChar = set of Char;
+ TSetOfAnsiChar = set of AnsiChar;
{$IFNDEF XPLATFORM_RTL}
procedure RaiseLastOSError;
Modified: trunk/jcl/source/common/JclStringLists.pas
===================================================================
--- trunk/jcl/source/common/JclStringLists.pas 2007-06-10 08:39:50 UTC (rev 2033)
+++ trunk/jcl/source/common/JclStringLists.pas 2007-06-10 08:55:31 UTC (rev 2034)
@@ -166,7 +166,7 @@
function Trim: IJclStringList;
function Join(const ASeparator: string = ''): string;
function Split(const AText, ASeparator: string; AClearBeforeAdd: Boolean = True): IJclStringList;
- function ExtractWords(const AText: string; const ADelims: TSetOfChar = [#0..' ']; AClearBeforeAdd: Boolean = True): IJclStringList;
+ function ExtractWords(const AText: string; const ADelims: TSetOfAnsiChar = [#0..' ']; AClearBeforeAdd: Boolean = True): IJclStringList;
function Last: string;
function First: string;
function LastIndex: Integer;
@@ -344,7 +344,7 @@
function Delimit(const ADelimiter: string): IJclStringList;
function Join(const ASeparator: string = ''): string;
function Split(const AText, ASeparator: string; AClearBeforeAdd: Boolean = True): IJclStringList;
- function ExtractWords(const AText: string; const ADelims: TSetOfChar = [#0..' '];
+ function ExtractWords(const AText: string; const ADelims: TSetOfAnsiChar = [#0..' '];
AClearBeforeAdd: Boolean = True): IJclStringList;
function Last: string;
function First: string;
@@ -507,7 +507,7 @@
Result := FSelfAsInterface;
end;
-function TJclStringListImpl.ExtractWords(const AText: string; const ADelims: TSetOfChar;
+function TJclStringListImpl.ExtractWords(const AText: string; const ADelims: TSetOfAnsiChar;
AClearBeforeAdd: Boolean): IJclStringList;
var
L, I, X: Integer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <usc...@us...> - 2007-06-23 12:42:20
|
Revision: 2052
http://svn.sourceforge.net/jcl/?rev=2052&view=rev
Author: uschuster
Date: 2007-06-23 05:42:17 -0700 (Sat, 23 Jun 2007)
Log Message:
-----------
fixed RAD Studio detection
Modified Paths:
--------------
trunk/jcl/source/common/JclBorlandTools.pas
trunk/jcl/source/common/JclResources.pas
Modified: trunk/jcl/source/common/JclBorlandTools.pas
===================================================================
--- trunk/jcl/source/common/JclBorlandTools.pas 2007-06-22 22:19:09 UTC (rev 2051)
+++ trunk/jcl/source/common/JclBorlandTools.pas 2007-06-23 12:42:17 UTC (rev 2052)
@@ -994,7 +994,7 @@
CLRVersionResId: 9500;
Supported: True),
(
- Name: RsDelphiName;
+ Name: RsRSName;
VersionStr: '2007';
Version: 11;
CoreIdeVersion: '100';
@@ -5004,13 +5004,14 @@
if IDEVersionNumber in [Low(BDSVersions)..High(BDSVersions)] then
begin
Result := BDSVersions[IDEVersionNumber].Name;
- // IDE Version 5 comes in two flavors:
+ // IDE Version 5 comes in three flavors:
// - Delphi only (Spacely)
- // - C++ Builder only (Cogswell)
- // In the second case the product name is "C++ Builder" and not "Delphi"
- // Right now, the name of an installation of Cogswell on top of Spacely
- // is not yet known and a way to detect it will have to be thought of.
- if (IDEVersionNumber = 5) and (bpBCBuilder32 in Personalities) then
+ // - C++Builder only (Cogswell)
+ // - Delphi and C++Builder
+ if (IDEVersionNumber = 5) and (Personalities = [bpDelphi32]) then
+ Result := RsDelphiName
+ else
+ if (IDEVersionNumber = 5) and (Personalities = [bpBCBuilder32]) then
Result := RsBCBName;
end
else
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2007-06-22 22:19:09 UTC (rev 2051)
+++ trunk/jcl/source/common/JclResources.pas 2007-06-23 12:42:17 UTC (rev 2052)
@@ -74,6 +74,7 @@
RsBCBName = 'C++Builder';
RsCSharpName = 'C#Builder';
RsBDSName = 'Borland Developer Studio';
+ RsRSName = 'RAD Studio';
{$IFDEF KYLIX}
RsKylixName = 'Kylix for %s';
RsKylixVersionName = 'Kylix %d for %s';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2007-07-19 19:04:27
|
Revision: 2084
http://svn.sourceforge.net/jcl/?rev=2084&view=rev
Author: outchy
Date: 2007-07-19 12:04:25 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
Minor change: constructors should not be virtual for those classes hardly inheritable
Introducing a new major stream class: TJclSectoredStream: read and write data in sectors
First child classes to be implemented: TJclCRC16Stream and TJclCRC32Stream, protection of data using a cyclic redundancy check, CRC are added after each BufferSize-d block of data. one bit can be corrected in each data block.
Modified Paths:
--------------
trunk/jcl/source/common/JclResources.pas
trunk/jcl/source/common/JclStreams.pas
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2007-07-19 13:35:13 UTC (rev 2083)
+++ trunk/jcl/source/common/JclResources.pas 2007-07-19 19:04:25 UTC (rev 2084)
@@ -1649,6 +1649,7 @@
RsStreamsCreateError = 'Cannot create file %s';
RsStreamsOpenError = 'Cannot open file %s';
RsStreamsSetSizeError = 'Error setting stream size';
+ RsStreamsCRCError = 'Cyclic Redundency Check (CRC) error: data are damaged';
//=== JclStrHashMap ==========================================================
resourcestring
Modified: trunk/jcl/source/common/JclStreams.pas
===================================================================
--- trunk/jcl/source/common/JclStreams.pas 2007-07-19 13:35:13 UTC (rev 2083)
+++ trunk/jcl/source/common/JclStreams.pas 2007-07-19 19:04:25 UTC (rev 2084)
@@ -1,4 +1,4 @@
-{**************************************************************************************************}
+{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
@@ -72,7 +72,7 @@
procedure SetSize(NewSize: Longint); override;
procedure SetSize(const NewSize: Int64); override;
public
- constructor Create(AHandle: THandle); virtual;
+ constructor Create(AHandle: THandle);
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
@@ -81,7 +81,7 @@
TJclFileStream = class(TJclHandleStream)
public
- constructor Create(const FileName: string; Mode: Word; Rights: Cardinal = 0); reintroduce; virtual;
+ constructor Create(const FileName: string; Mode: Word; Rights: Cardinal = 0);
destructor Destroy; override;
end;
@@ -147,7 +147,7 @@
protected
procedure SetSize(const NewSize: Int64); override;
public
- constructor Create; virtual;
+ constructor Create;
destructor Destroy; override;
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
@@ -177,7 +177,7 @@
procedure SetSize(NewSize: Longint); overload; override;
procedure SetSize(const NewSize: Int64); overload; override;
public
- constructor Create(AStream: TStream; AOwnsStream: Boolean = False); virtual;
+ constructor Create(AStream: TStream; AOwnsStream: Boolean = False);
destructor Destroy; override;
function Read(var Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; override;
@@ -190,7 +190,7 @@
end;
TJclBufferedStream = class(TJclStreamDecorator)
- private
+ protected
FBuffer: array of Byte;
FBufferCurrentSize: Longint;
FBufferMaxModifiedPos: Longint;
@@ -198,22 +198,21 @@
FBufferStart: Int64; // position of the first byte of the buffer in stream
FPosition: Int64; // current position in stream
function BufferHit: Boolean;
- function GetCalcedSize: Int64;
- function LoadBuffer: Boolean;
- procedure SetBufferSize(Value: Longint);
+ function GetCalcedSize: Int64; virtual;
+ function LoadBuffer: Boolean; virtual;
function ReadFromBuffer(var Buffer; Count, Start: Longint): Longint;
function WriteToBuffer(const Buffer; Count, Start: Longint): Longint;
protected
procedure DoAfterStreamChange; override;
procedure DoBeforeStreamChange; override;
public
- constructor Create(AStream: TStream; AOwnsStream: Boolean = False); override;
+ constructor Create(AStream: TStream; AOwnsStream: Boolean = False);
destructor Destroy; override;
- procedure Flush;
+ procedure Flush; virtual;
function Read(var Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
function Write(const Buffer; Count: Longint): Longint; override;
- property BufferSize: Longint read FBufferSize write SetBufferSize;
+ property BufferSize: Longint read FBufferSize write FBufferSize;
end;
TStreamNotifyEvent = procedure(Sender: TObject; Position: Int64; Size: Int64) of object;
@@ -229,7 +228,7 @@
procedure SetSize(const NewSize: Int64); overload; override;
public
constructor Create(AStream: TStream; ANotification: TStreamNotifyEvent = nil;
- AOwnsStream: Boolean = False); reintroduce; virtual;
+ AOwnsStream: Boolean = False);
function Read(var Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; override;
function Seek(Offset: Longint; Origin: Word): Longint; overload; override;
@@ -276,7 +275,7 @@
// scopedstream starting at the current position of the ParentStream
// if MaxSize is positive or null, read and write operations cannot overrun this size or the ParentStream limitation
// if MaxSize is negative, read and write operations are unlimited (up to the ParentStream limitation)
- constructor Create(AParentStream: TStream; AMaxSize: Int64 = -1); reintroduce;
+ constructor Create(AParentStream: TStream; AMaxSize: Int64 = -1);
function Read(var Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
function Write(const Buffer; Count: Longint): Longint; override;
@@ -310,6 +309,45 @@
property OnSize: TJclStreamSizeEvent read FOnSize write FOnSize;
end;
+ // ancestor classes for streams with checksums and encrypted streams
+ // data are stored in sectors: each BufferSize-d buffer is followed by FBlockOverHeader bytes
+ // containing the checksum. In case of an encrypted stream, there is no byte
+ // but sector is encrypted
+
+ // reusing some code from TJclBufferedStream
+ TJclSectoredStream = class(TJclBufferedStream)
+ protected
+ FSectorOverHead: Integer;
+ function FlatToSectored(const Position: Int64): Int64;
+ function SectoredToFlat(const Position: Int64): Int64;
+ function GetCalcedSize: Int64; override;
+ function LoadBuffer: Boolean; override;
+ procedure DoAfterStreamChange; override;
+ procedure AfterBlockRead; virtual; // override to check protection
+ procedure BeforeBlockWrite; virtual; // override to compute protection
+ public
+ constructor Create(AStorageStream: TStream; AOwnsStream: Boolean = False;
+ ASectorOverHead: Integer = 0);
+
+ procedure Flush; override;
+ end;
+
+ TJclCRC16Stream = class(TJclSectoredStream)
+ protected
+ procedure AfterBlockRead; override;
+ procedure BeforeBlockWrite; override;
+ public
+ constructor Create(AStorageStream: TStream; AOwnsStream: Boolean = False);
+ end;
+
+ TJclCRC32Stream = class(TJclSectoredStream)
+ protected
+ procedure AfterBlockRead; override;
+ procedure BeforeBlockWrite; override;
+ public
+ constructor Create(AStorageStream: TStream; AOwnsStream: Boolean = False);
+ end;
+
// call TStream.Seek(Int64,TSeekOrigin) if present (TJclStream or COMPILER6_UP)
// otherwize call TStream.Seek(LongInt,Word) with range checking
function StreamSeek(Stream: TStream; const Offset: Int64;
@@ -328,7 +366,7 @@
implementation
uses
- JclResources;
+ JclResources, JclMath;
{$IFDEF KYLIX}
function __open(PathName: PChar; Flags: Integer; Mode: Integer): Integer; cdecl;
@@ -873,7 +911,8 @@
constructor TJclBufferedStream.Create(AStream: TStream; AOwnsStream: Boolean = False);
begin
inherited Create(AStream, AOwnsStream);
- FPosition := Stream.Position;
+ if Stream <> nil then
+ FPosition := Stream.Position;
BufferSize := 4096;
end;
@@ -989,12 +1028,6 @@
Result := NewPos;
end;
-procedure TJclBufferedStream.SetBufferSize(Value: Longint);
-begin
- if FBufferSize <> Value then
- FBufferSize := Value;
-end;
-
function TJclBufferedStream.Write(const Buffer; Count: Longint): Longint;
begin
Result := Count;
@@ -1390,6 +1423,152 @@
Result := -1;
end;
+//=== { TJclSectoredStream } =================================================
+
+procedure TJclSectoredStream.AfterBlockRead;
+begin
+ // override to customize (checks of protection)
+end;
+
+procedure TJclSectoredStream.BeforeBlockWrite;
+begin
+ // override to customize (computation of protection)
+end;
+
+constructor TJclSectoredStream.Create(AStorageStream: TStream;
+ AOwnsStream: Boolean; ASectorOverHead: Integer);
+begin
+ inherited Create(AStorageStream, AOwnsStream);
+ FSectorOverHead := ASectorOverHead;
+ if Stream <> nil then
+ FPosition := SectoredToFlat(Stream.Position);
+end;
+
+procedure TJclSectoredStream.DoAfterStreamChange;
+begin
+ inherited DoAfterStreamChange;
+ if Stream <> nil then
+ FPosition := SectoredToFlat(Stream.Position);
+end;
+
+function TJclSectoredStream.FlatToSectored(const Position: Int64): Int64;
+begin
+ Result := (Position div BufferSize) * (BufferSize + FSectorOverHead) // add overheads of previous buffers
+ + Position mod BufferSize; // offset in sector
+end;
+
+procedure TJclSectoredStream.Flush;
+begin
+ if (Stream <> nil) and (FBufferMaxModifiedPos > 0) then
+ begin
+ BeforeBlockWrite;
+
+ Stream.Position := FlatToSectored(FBufferStart);
+ Stream.WriteBuffer(FBuffer[0], FBufferCurrentSize + FSectorOverHead);
+ FBufferMaxModifiedPos := 0;
+ end;
+end;
+
+function TJclSectoredStream.GetCalcedSize: Int64;
+var
+ VirtualSize: Int64;
+begin
+ if Assigned(Stream) then
+ Result := SectoredToFlat(Stream.Size)
+ else
+ Result := 0;
+ VirtualSize := FBufferMaxModifiedPos + FBufferStart;
+ if Result < VirtualSize then
+ Result := VirtualSize;
+end;
+
+function TJclSectoredStream.LoadBuffer: Boolean;
+var
+ TotalSectorSize: Integer;
+begin
+ Flush;
+ TotalSectorSize := FBufferSize + FSectorOverHead;
+ if Length(FBuffer) <> TotalSectorSize then
+ SetLength(FBuffer, TotalSectorSize);
+ FBufferStart := (FPosition div BufferSize) * BufferSize;
+ if Stream <> nil then
+ begin
+ Stream.Position := FlatToSectored(FBufferStart);
+ FBufferCurrentSize := Stream.Read(FBuffer[0], TotalSectorSize);
+ if FBufferCurrentSize > 0 then
+ begin
+ Dec(FBufferCurrentSize, FSectorOverHead);
+ AfterBlockRead;
+ end;
+ end
+ else
+ FBufferCurrentSize := 0;
+ Result := (FBufferCurrentSize > 0);
+end;
+
+function TJclSectoredStream.SectoredToFlat(const Position: Int64): Int64;
+var
+ TotalSectorSize: Int64;
+begin
+ TotalSectorSize := BufferSize + FSectorOverHead;
+ Result := (Position div TotalSectorSize) * BufferSize // remove previous overheads
+ + Position mod TotalSectorSize; // offset in sector
+end;
+
+//=== { TJclCRC16Stream } ====================================================
+
+procedure TJclCRC16Stream.AfterBlockRead;
+var
+ CRC: Word;
+begin
+ CRC := FBuffer[FBufferCurrentSize] + (FBuffer[FBufferCurrentSize + 1] shl 8);
+ if CheckCrc16(FBuffer, FBufferCurrentSize, CRC) < 0 then
+ raise EJclStreamError.CreateRes(@RsStreamsCRCError);
+end;
+
+procedure TJclCRC16Stream.BeforeBlockWrite;
+var
+ CRC: Word;
+begin
+ CRC := Crc16(FBuffer, FBufferCurrentSize);
+ FBuffer[FBufferCurrentSize] := CRC and $FF;
+ FBuffer[FBufferCurrentSize + 1] := CRC shr 8;
+end;
+
+constructor TJclCRC16Stream.Create(AStorageStream: TStream; AOwnsStream: Boolean);
+begin
+ inherited Create(AStorageStream, AOwnsStream, 2);
+end;
+
+//=== { TJclCRC32Stream } ====================================================
+
+procedure TJclCRC32Stream.AfterBlockRead;
+var
+ CRC: Cardinal;
+begin
+ CRC := FBuffer[FBufferCurrentSize] + (FBuffer[FBufferCurrentSize + 1] shl 8)
+ + (FBuffer[FBufferCurrentSize + 2] shl 16) + (FBuffer[FBufferCurrentSize + 3] shl 24);
+ if CheckCrc32(FBuffer, FBufferCurrentSize, CRC) < 0 then
+ raise EJclStreamError.CreateRes(@RsStreamsCRCError);
+end;
+
+procedure TJclCRC32Stream.BeforeBlockWrite;
+var
+ CRC: Cardinal;
+begin
+ CRC := Crc32(FBuffer, FBufferCurrentSize);
+ FBuffer[FBufferCurrentSize] := CRC and $FF;
+ FBuffer[FBufferCurrentSize + 1] := (CRC shr 8) and $FF;
+ FBuffer[FBufferCurrentSize + 2] := (CRC shr 16) and $FF;
+ FBuffer[FBufferCurrentSize + 3] := (CRC shr 24) and $FF;
+end;
+
+constructor TJclCRC32Stream.Create(AStorageStream: TStream;
+ AOwnsStream: Boolean);
+begin
+ inherited Create(AStorageStream, AOwnsStream, 4);
+end;
+
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2007-08-12 14:33:50
|
Revision: 2120
http://jcl.svn.sourceforge.net/jcl/?rev=2120&view=rev
Author: marquardt
Date: 2007-08-12 07:33:45 -0700 (Sun, 12 Aug 2007)
Log Message:
-----------
style cleaning
Modified Paths:
--------------
trunk/jcl/source/common/JclAnsiStrings.pas
trunk/jcl/source/common/JclBorlandTools.pas
Modified: trunk/jcl/source/common/JclAnsiStrings.pas
===================================================================
--- trunk/jcl/source/common/JclAnsiStrings.pas 2007-08-12 08:49:57 UTC (rev 2119)
+++ trunk/jcl/source/common/JclAnsiStrings.pas 2007-08-12 14:33:45 UTC (rev 2120)
@@ -165,7 +165,7 @@
function StrSame(const S1, S2: AnsiString): Boolean;
// String Transformation Routines
-function StrCenter(const S: AnsiString; L: Integer; C: AnsiChar = ' '): AnsiString;
+function StrCenter(const S: AnsiString; L: Integer; C: AnsiChar = ' '): AnsiString;
function StrCharPosLower(const S: AnsiString; CharPos: Integer): AnsiString;
function StrCharPosUpper(const S: AnsiString; CharPos: Integer): AnsiString;
function StrDoubleQuote(const S: AnsiString): AnsiString;
@@ -517,10 +517,10 @@
if CharIsUpper(CurrChar) then
ReCaseChar := LoCaseChar
else
- if CharIsLower(CurrChar) then
- ReCaseChar := UpCaseChar
- else
- ReCaseChar := CurrChar;
+ if CharIsLower(CurrChar) then
+ ReCaseChar := UpCaseChar
+ else
+ ReCaseChar := CurrChar;
AnsiCaseMap[Ord(CurrChar) + AnsiLoOffset] := LoCaseChar;
AnsiCaseMap[Ord(CurrChar) + AnsiUpOffset] := UpCaseChar;
AnsiCaseMap[Ord(CurrChar) + AnsiReOffset] := ReCaseChar;
@@ -771,7 +771,7 @@
Result := False;
Exit;
end;
- end;
+ end;
end;
function StrContainsChars(const S: AnsiString; Chars: TSysCharSet; CheckAll: Boolean): Boolean;
@@ -865,7 +865,7 @@
//=== String Transformation Routines =========================================
-function StrCenter(const S: AnsiString; L: Integer; C: AnsiChar = ' '): AnsiString;
+function StrCenter(const S: AnsiString; L: Integer; C: AnsiChar = ' '): AnsiString;
begin
if Length(S) < L then
begin
@@ -1128,10 +1128,10 @@
// Check FromIndex
if (FromIndex <= 0) or (FromIndex > Length(Source)) or
- (ToIndex <= 0) or (ToIndex > Length(Dest)) or
- ((FromIndex + Count - 1) > Length(Source)) or ((ToIndex + Count - 1) > Length(Dest)) then
- { TODO : Is failure without notice the proper thing to do here? }
- Exit;
+ (ToIndex <= 0) or (ToIndex > Length(Dest)) or
+ ((FromIndex + Count - 1) > Length(Source)) or ((ToIndex + Count - 1) > Length(Dest)) then
+ { TODO : Is failure without notice the proper thing to do here? }
+ Exit;
// Move
{$IFDEF CLR}
@@ -1228,14 +1228,14 @@
UniqueString(Result);
Source := PAnsiChar(S);
Dest := PAnsiChar(Result);
- for Index := 0 to Len-1 do
+ for Index := 0 to Len - 1 do
begin
if not (Source^ in Chars) then
begin
Dest^ := Source^;
- Inc(Dest,SizeOf(AnsiChar));
+ Inc(Dest, SizeOf(AnsiChar));
end;
- Inc(Source,SizeOf(AnsiChar));
+ Inc(Source, SizeOf(AnsiChar));
end;
SetLength(Result, (Longint(Dest) - Longint(PAnsiChar(Result))) div SizeOf(AnsiChar));
end;
@@ -1266,14 +1266,14 @@
UniqueString(Result);
Source := PAnsiChar(S);
Dest := PAnsiChar(Result);
- for Index := 0 to Len-1 do
+ for Index := 0 to Len - 1 do
begin
if Source^ in Chars then
begin
Dest^ := Source^;
- Inc(Dest,SizeOf(AnsiChar));
+ Inc(Dest, SizeOf(AnsiChar));
end;
- Inc(Source,SizeOf(AnsiChar));
+ Inc(Source, SizeOf(AnsiChar));
end;
SetLength(Result, (Longint(Dest) - Longint(PAnsiChar(Result))) div SizeOf(AnsiChar));
end;
@@ -1983,13 +1983,12 @@
if I > 0 then
Inc(Result);
- while (I > 0) and (Length(S) > I+Length(SubS)) do
+ while (I > 0) and (Length(S) > I + Length(SubS)) do
begin
- I := StrSearch(SubS, S, I+1);
-
+ I := StrSearch(SubS, S, I + 1);
if I > 0 then
Inc(Result);
- end
+ end;
end;
{$IFDEF CLR}
@@ -3365,7 +3364,7 @@
UniqueString(S);
Len := Length(S);
P := PAnsiChar(S);
- for Index := 0 to Len-1 do
+ for Index := 0 to Len - 1 do
begin
if P^ = Search then
begin
@@ -3899,13 +3898,13 @@
if Temp[I] = '-' then
IsNegative := not IsNegative
else
- if not (Temp[I] in [' ', '(', '+']) then
- begin
- // if it appears prior to any digit, it has to be a decimal separator
- SwapSeparators := Temp[I] = ThouSep;
- J := I;
- Break;
- end;
+ if not (Temp[I] in [' ', '(', '+']) then
+ begin
+ // if it appears prior to any digit, it has to be a decimal separator
+ SwapSeparators := Temp[I] = ThouSep;
+ J := I;
+ Break;
+ end;
end;
if not SwapSeparators then
Modified: trunk/jcl/source/common/JclBorlandTools.pas
===================================================================
--- trunk/jcl/source/common/JclBorlandTools.pas 2007-08-12 08:49:57 UTC (rev 2119)
+++ trunk/jcl/source/common/JclBorlandTools.pas 2007-08-12 14:33:45 UTC (rev 2120)
@@ -567,7 +567,8 @@
// compilation functions
function CompileDelphiPackage(const PackageName, BPLPath, DCPPath: string): Boolean; overload; virtual;
- function CompileDelphiPackage(const PackageName, BPLPath, DCPPath, ExtraOptions: string): Boolean; overload; virtual;
+ function CompileDelphiPackage(const PackageName, BPLPath, DCPPath, ExtraOptions: string): Boolean;
+ overload; virtual;
function CompileDelphiProject(const ProjectName, OutputDir, DcpSearchPath: string): Boolean; virtual;
function CompileBCBPackage(const PackageName, BPLPath, DCPPath: string): Boolean; virtual;
function CompileBCBProject(const ProjectName, OutputDir, DcpSearchPath: string): Boolean; virtual;
@@ -654,7 +655,7 @@
function GetCommonProjectsDir: string; virtual;
function RemoveFromDebugDCUPath(const Path: string): Boolean;
function RemoveFromLibrarySearchPath(const Path: string): Boolean;
- function RemoveFromLibraryBrowsingPath(const Path: string): Boolean;
+ function RemoveFromLibraryBrowsingPath(const Path: string): Boolean;
function SubstitutePath(const Path: string): string;
{$IFDEF KEEP_DEPRECATED}
function SupportsBCB: Boolean;
@@ -827,7 +828,8 @@
property CppSearchPath: TJclBorRADToolPath read GetCppSearchPath write SetCppSearchPath;
property CppBrowsingPath: TJclBorRADToolPath read GetCppBrowsingPath write SetCppBrowsingPath;
- property CppLibraryPath: TJclBorRADToolPath read GetCppLibraryPath write SetCppLibraryPath; // Only exists in BDS 5 and upper
+ // Only exists in BDS 5 and upper
+ property CppLibraryPath: TJclBorRADToolPath read GetCppLibraryPath write SetCppLibraryPath;
function RegisterPackage(const BinaryFileName, Description: string): Boolean; override;
function UnregisterPackage(const BinaryFileName: string): Boolean; override;
@@ -845,7 +847,7 @@
end;
{$ENDIF MSWINDOWS}
- TTraverseMethod = function (Installation: TJclBorRADToolInstallation): Boolean of object;
+ TTraverseMethod = function(Installation: TJclBorRADToolInstallation): Boolean of object;
TJclBorRADToolInstallations = class(TObject)
private
@@ -869,9 +871,12 @@
function Iterate(TraverseMethod: TTraverseMethod): Boolean;
property Count: Integer read GetCount;
property Installations[Index: Integer]: TJclBorRADToolInstallation read GetInstallations; default;
- property BCBInstallationFromVersion[VersionNumber: Integer]: TJclBorRADToolInstallation read GetBCBInstallationFromVersion;
- property DelphiInstallationFromVersion[VersionNumber: Integer]: TJclBorRADToolInstallation read GetDelphiInstallationFromVersion;
- property BDSInstallationFromVersion[VersionNumber: Integer]: TJclBorRADToolInstallation read GetBDSInstallationFromVersion;
+ property BCBInstallationFromVersion[VersionNumber: Integer]: TJclBorRADToolInstallation
+ read GetBCBInstallationFromVersion;
+ property DelphiInstallationFromVersion[VersionNumber: Integer]: TJclBorRADToolInstallation
+ read GetDelphiInstallationFromVersion;
+ property BDSInstallationFromVersion[VersionNumber: Integer]: TJclBorRADToolInstallation
+ read GetBDSInstallationFromVersion;
property BCBVersionInstalled[VersionNumber: Integer]: Boolean read GetBCBVersionInstalled;
property DelphiVersionInstalled[VersionNumber: Integer]: Boolean read GetDelphiVersionInstalled;
property BDSVersionInstalled[VersionNumber: Integer]: Boolean read GetBDSVersionInstalled;
@@ -1152,10 +1157,11 @@
if AnsiStartsText(LibraryText, S) and (BinaryExtension = '') then
BinaryExtension := BinaryExtensionLibrary;
if AnsiStartsText(DelphiBinaryExtOption, S) then
- BinaryExtension := StrTrimQuotes(Copy(S, Length(DelphiBinaryExtOption), Length(S) - Length(DelphiBinaryExtOption)));
- if Assigned(LibSuffix) and
- AnsiStartsText(DelphiLibSuffixOption, S) then
- LibSuffix^ := StrTrimQuotes(Copy(S, Length(DelphiLibSuffixOption), Length(S) - Length(DelphiLibSuffixOption)));
+ BinaryExtension :=
+ StrTrimQuotes(Copy(S, Length(DelphiBinaryExtOption), Length(S) - Length(DelphiBinaryExtOption)));
+ if Assigned(LibSuffix) and AnsiStartsText(DelphiLibSuffixOption, S) then
+ LibSuffix^ :=
+ StrTrimQuotes(Copy(S, Length(DelphiLibSuffixOption), Length(S) - Length(DelphiLibSuffixOption)));
end;
finally
DPRFile.Free;
@@ -1220,7 +1226,7 @@
SemiColonPos := Pos(';', SubS2);
if SemiColonPos > 0 then
begin
- SubS3 := Copy(SubS2, SemiColonPos+1, Length(SubS2));
+ SubS3 := Copy(SubS2, SemiColonPos + 1, Length(SubS2));
AmpPos := Pos('&', SubS3);
if (Description <> nil) and (AmpPos > 0) then
Description^ := Copy(SubS3, 1, AmpPos - 1);
@@ -1289,7 +1295,7 @@
LProjectPos := Pos(BCBProjectOption, S);
if Assigned(BinaryFileName) and (LProjectPos > 0) then
begin
- SubS1 := Copy(S,LProjectPos, Length(S));
+ SubS1 := Copy(S, LProjectPos, Length(S));
J := 1;
while (Pos('>', SubS1) = 0) and ((I + J) < BPKFile.Count) do
begin
@@ -1464,7 +1470,8 @@
StrLength := ResData^;
Inc(ResData);
Inc(ResIndex);
- if (StrLength >= MatchLen) and (StrLICompW(PWideChar(lParam^.StartStr), PWideChar(ResData), MatchLen) = 0) then
+ if (StrLength >= MatchLen) and
+ (StrLICompW(PWideChar(lParam^.StartStr), PWideChar(ResData), MatchLen) = 0) then
begin
// we have a match
SetLength(lParam^.MatchStr, StrLength);
@@ -1481,8 +1488,7 @@
end;
// find in specified module "FileName" a resourcestring starting with StartStr
-function FindResStart(const FileName: string;
- const StartStr: WideString): WideString;
+function FindResStart(const FileName: string; const StartStr: WideString): WideString;
var
H: HMODULE;
FindResRec: TFindResStartRec;
@@ -1492,11 +1498,11 @@
H := LoadLibraryEx(PChar(FileName), 0, LOAD_LIBRARY_AS_DATAFILE or DONT_RESOLVE_DLL_REFERENCES);
if H <> 0 then
- try
- EnumResourceNames(H, RT_STRING, @FindResStartCallBack, Integer(@FindResRec));
- finally
- FreeLibrary(H);
- end;
+ try
+ EnumResourceNames(H, RT_STRING, @FindResStartCallBack, Integer(@FindResRec));
+ finally
+ FreeLibrary(H);
+ end;
Result := FindResRec.MatchStr;
end;
@@ -1581,13 +1587,14 @@
for Index := Low(ResEn) to High(ResEn) do
LoadResRec.EnglishStr[Index] := ResEn[Index];
- H := LoadLibraryEx(PChar(ChangeFileExt(BaseBinName, BinaryExtensionPackage)), 0, LOAD_LIBRARY_AS_DATAFILE or DONT_RESOLVE_DLL_REFERENCES);
+ H := LoadLibraryEx(PChar(ChangeFileExt(BaseBinName, BinaryExtensionPackage)), 0,
+ LOAD_LIBRARY_AS_DATAFILE or DONT_RESOLVE_DLL_REFERENCES);
if H <> 0 then
- try
- EnumResourceNames(H, RT_STRING, @LoadResCallBack, Integer(@LoadResRec));
- finally
- FreeLibrary(H);
- end;
+ try
+ EnumResourceNames(H, RT_STRING, @LoadResCallBack, Integer(@LoadResRec));
+ finally
+ FreeLibrary(H);
+ end;
FileName := '';
@@ -1612,15 +1619,16 @@
begin
H := LoadLibraryEx(PChar(FileName), 0, LOAD_LIBRARY_AS_DATAFILE or DONT_RESOLVE_DLL_REFERENCES);
if H <> 0 then
- try
- for Index := 0 to NbRes - 1 do
- begin
- SetLength(Result[Index], 1024);
- SetLength(Result[Index], LoadStringW(H, LoadResRec.ResId[Index], PWideChar(Result[Index]), Length(Result[Index]) - 1));
+ try
+ for Index := 0 to NbRes - 1 do
+ begin
+ SetLength(Result[Index], 1024);
+ SetLength(Result[Index],
+ LoadStringW(H, LoadResRec.ResId[Index], PWideChar(Result[Index]), Length(Result[Index]) - 1));
+ end;
+ finally
+ FreeLibrary(H);
end;
- finally
- FreeLibrary(H);
- end;
end
else
Result := LoadResRec.EnglishStr;
@@ -1814,8 +1822,8 @@
//== { TJclHelp2Manager } ====================================================
const
- Help2BorlandNameSpace = 'Borland.BDS%d';
- Help2DefaultKeyWord = '_DEFAULT';
+ Help2BorlandNameSpace = 'Borland.BDS%d';
+ Help2DefaultKeyWord = '_DEFAULT';
constructor TJclHelp2Manager.Create(AInstallation: TJclBorRADToolInstallation);
begin
@@ -2167,7 +2175,7 @@
FreeAndNil(FKnownPackages);
FreeAndNil(FKnownIDEPackages);
FreeAndNil(FExperts);
- inherited Destroy;
+ inherited Destroy;
end;
function TJclBorRADToolIdePackages.AddPackage(const FileName, Description: string): Boolean;
@@ -2211,7 +2219,7 @@
function TJclBorRADToolIdePackages.GetExpertFileNames(Index: Integer): string;
begin
- Result := PackageEntryToFileName(FExperts.Values[FExperts.Names[Index]]);
+ Result := PackageEntryToFileName(FExperts.Values[FExperts.Names[Index]]);
end;
function TJclBorRADToolIdePackages.GetIDECount: Integer;
@@ -2265,7 +2273,7 @@
end;
begin
- if (Installation.RadToolKind = brBorlandDevStudio) then
+ if Installation.RadToolKind = brBorlandDevStudio then
ReadPackageList(KnownIDEPackagesKeyName, FKnownIDEPackages);
ReadPackageList(KnownPackagesKeyName, FKnownPackages);
ReadPackageList(DisabledPackagesKeyName, FDisabledPackages);
@@ -2419,7 +2427,7 @@
if Assigned(FOutputCallback) then
begin
FOutputCallback(LaunchCommand);
- Result := JclSysUtils.Execute(LaunchCommand, FOutputCallback) = 0
+ Result := JclSysUtils.Execute(LaunchCommand, FOutputCallback) = 0;
end
else
Result := JclSysUtils.Execute(LaunchCommand, FOutput) = 0;
@@ -2509,7 +2517,8 @@
AdditionalOptions := '';
DProjFileName := ChangeFileExt(ProjectFileName, SourceExtensionDProject);
- if FileExists(DProjFileName) and (Installation.IDEVersionNumber >= 5) and (Installation.RadToolKind = brBorlandDevStudio) then
+ if FileExists(DProjFileName) and (Installation.IDEVersionNumber >= 5) and
+ (Installation.RadToolKind = brBorlandDevStudio) then
begin
OptionsXmlFile := TJclSimpleXML.Create;
try
@@ -2535,8 +2544,8 @@
ConditionProperty := PropertyGroupNode.Properties.ItemNamed[DProjConditionValueName];
if Assigned(ConditionProperty) then
begin
- if (ProjectConfiguration <> '') and (ProjectPlatform <> '')
- and (AnsiPos(Format('%s|%s', [ProjectConfiguration, ProjectPlatform]), ConditionProperty.Value) > 0) then
+ if (ProjectConfiguration <> '') and (ProjectPlatform <> '') and
+ (AnsiPos(Format('%s|%s', [ProjectConfiguration, ProjectPlatform]), ConditionProperty.Value) > 0) then
begin
// this is the active configuration, check for overrides
ChildNode := PropertyGroupNode.Items.ItemNamed[DProjUsePackageNodeName];
@@ -2587,18 +2596,18 @@
OptionNode := PersonalityInfoNode.Items.ItemNamed[BDSProjOptionNodeName];
if Assigned(OptionNode) then
for NodeIndex := 0 to OptionNode.Items.Count - 1 do
- begin
- ChildNode := OptionNode.Items.Item[NodeIndex];
- if SameText(ChildNode.Name, BDSProjOptionNodeName) then
begin
- NameProperty := ChildNode.Properties.ItemNamed[BDSProjNameProperty];
- if Assigned(NameProperty) and SameText(NameProperty.Value, BDSProjPersonalityValue) then
+ ChildNode := OptionNode.Items.Item[NodeIndex];
+ if SameText(ChildNode.Name, BDSProjOptionNodeName) then
begin
- PersonalityName := ChildNode.Value;
- Break;
+ NameProperty := ChildNode.Properties.ItemNamed[BDSProjNameProperty];
+ if Assigned(NameProperty) and SameText(NameProperty.Value, BDSProjPersonalityValue) then
+ begin
+ PersonalityName := ChildNode.Value;
+ Break;
+ end;
end;
end;
- end;
end;
if PersonalityName <> '' then
begin
@@ -2608,30 +2617,30 @@
DirectoriesNode := PersonalityNode.Items.ItemNamed[BDSProjDirectoriesNodeName];
if Assigned(DirectoriesNode) then
for NodeIndex := 0 to DirectoriesNode.Items.Count - 1 do
- begin
- ChildNode := DirectoriesNode.Items.Item[NodeIndex];
- if SameText(ChildNode.Name, BDSProjDirectoriesNodeName) then
begin
- NameProperty := ChildNode.Properties.ItemNamed[BDSProjNameProperty];
- if Assigned(NameProperty) then
+ ChildNode := DirectoriesNode.Items.Item[NodeIndex];
+ if SameText(ChildNode.Name, BDSProjDirectoriesNodeName) then
begin
- if SameText(NameProperty.Value, BDSProjUnitOutputDirValue) then
- UnitOutputDir := ChildNode.Value
- else
- if SameText(NameProperty.Value, BDSProjSearchPathValue) then
- SearchPath := ChildNode.Value
- else
- if SameText(NameProperty.Value, BDSProjPackagesValue) then
- DynamicPackages := ChildNode.Value
- else
- if SameText(NameProperty.Value, BDSProjConditionalsValue) then
- Conditionals := ChildNode.Value
- else
- if SameText(NameProperty.Value, BDSProjUsePackagesValue) then
- UsePackages := StrToBoolean(ChildNode.Value);
+ NameProperty := ChildNode.Properties.ItemNamed[BDSProjNameProperty];
+ if Assigned(NameProperty) then
+ begin
+ if SameText(NameProperty.Value, BDSProjUnitOutputDirValue) then
+ UnitOutputDir := ChildNode.Value
+ else
+ if SameText(NameProperty.Value, BDSProjSearchPathValue) then
+ SearchPath := ChildNode.Value
+ else
+ if SameText(NameProperty.Value, BDSProjPackagesValue) then
+ DynamicPackages := ChildNode.Value
+ else
+ if SameText(NameProperty.Value, BDSProjConditionalsValue) then
+ Conditionals := ChildNode.Value
+ else
+ if SameText(NameProperty.Value, BDSProjUsePackagesValue) then
+ UsePackages := StrToBoolean(ChildNode.Value);
+ end;
end;
end;
- end;
end;
end;
finally
@@ -2648,7 +2657,7 @@
SearchPath := OptionsFile.ReadString(DOFDirectoriesSection, DOFSearchPathName, '');
UnitOutputDir := OptionsFile.ReadString(DOFDirectoriesSection, DOFUnitOutputDirKey, '');
Conditionals := OptionsFile.ReadString(DOFDirectoriesSection, DOFConditionals, '');
- UsePackages := OptionsFile.ReadString(DOFCompilerSection,DOFPackageNoLinkKey,'') = '1';
+ UsePackages := OptionsFile.ReadString(DOFCompilerSection, DOFPackageNoLinkKey, '') = '1';
DynamicPackages := OptionsFile.ReadString(DOFLinkerSection, DOFPackagesKey, '');
AdditionalOptions := OptionsFile.ReadString(DOFAdditionalSection, DOFOptionsKey, '');
finally
@@ -2671,7 +2680,7 @@
SearchDcpPath := StrEnsureSuffix(PathSep, DCPPath) + Installation.DCPOutputPath;
AddPathOption('U', StrEnsureSuffix(PathSep, SearchDcpPath) + SearchPath);
if UsePackages and (DynamicPackages <> '') then
- Options.Add(Format('-LU"%s"',[DynamicPackages]));
+ Options.Add(Format('-LU"%s"', [DynamicPackages]));
if AdditionalOptions <> '' then
Options.Add(AdditionalOptions);
end;
@@ -2734,7 +2743,7 @@
if IsPathOption(Option, SwitchLen) then
begin
- StrToStrings(StrTrimQuotes(Copy(Option, SwitchLen+1, Length(Option) - SwitchLen)), PathSep, PathList);
+ StrToStrings(StrTrimQuotes(Copy(Option, SwitchLen + 1, Length(Option) - SwitchLen)), PathSep, PathList);
// change to relative paths to avoid DCC32 126 character path limit
for PathIndex := 0 to PathList.Count - 1 do
PathList.Strings[PathIndex] := PathGetRelativePath(CurrentFolder, ExpandFileName(PathList[PathIndex]));
@@ -2823,7 +2832,7 @@
{$IFDEF MSWINDOWS}
//=== { TJclDCCIL } ==========================================================
-
+
function TJclDCCIL.GetExeName: string;
begin
Result := DCCILExeName;
@@ -3270,10 +3279,8 @@
try
MakeFileName := StrTrimQuotes(ChangeFileExt(PackageName, '.mak'));
if clProj2Mak in CommandLineTools then // let bpr2mak generate make file from .bpk
- begin
// Kylix bpr2mak doesn't like full file names
Result := Bpr2Mak.Execute(StringsToStr(Bpr2Mak.Options, ' ') + ' ' + ExtractFileName(PackageName))
- end
else
// If make file exists (and doesn't need to be created by bpr2mak)
Result := FileExists(MakeFileName);
@@ -3282,7 +3289,7 @@
Make.Options.Add('-DMAPFLAGS=-s');
GetBPKFileInfo(PackageName, RunOnly, @BinaryFileName);
-
+
Result := Result and
Make.Execute(Format('%s -f%s', [StringsToStr(Make.Options, ' '), StrDoubleQuote(MakeFileName)])) and
ProcessMapFile(PathAddSeparator(BPLPath) + BinaryFileName);
@@ -3404,7 +3411,7 @@
PackageExtension: string;
begin
PackageExtension := ExtractFileExt(PackageName);
- if SameText(PackageExtension,SourceExtensionBCBPackage) then
+ if SameText(PackageExtension, SourceExtensionBCBPackage) then
Result := CompileBCBPackage(PackageName, BPLPath, DCPPath)
else
if SameText(PackageExtension, SourceExtensionDelphiPackage) then
@@ -3419,7 +3426,7 @@
ProjectExtension: string;
begin
ProjectExtension := ExtractFileExt(ProjectName);
- if SameText(ProjectExtension,SourceExtensionBCBProject) then
+ if SameText(ProjectExtension, SourceExtensionBCBProject) then
Result := CompileBCBProject(ProjectName, OutputDir, DcpSearchPath)
else
if SameText(ProjectExtension, SourceExtensionDelphiProject) then
@@ -3794,7 +3801,7 @@
raise EJclBorRadException.CreateResFmt(@RsECannotInstallRunOnly, [PackageName]);
BPLFileName := PathAddSeparator(BPLPath) + PathExtractFileNameNoExt(PackageName) +
LibSuffix + BinaryExtensionPackage;
-
+
Result := CompileDelphiPackage(PackageName, BPLPath, DCPPath) and
RegisterIdePackage(BPLFileName, Description);
@@ -3813,7 +3820,7 @@
raise EJclBorRadException.CreateResFmt(@RsECannotInstallRunOnly, [PackageName]);
BPLFileName := PathAddSeparator(BPLPath) + PathExtractFileNameNoExt(PackageName) +
LibSuffix + BinaryExtensionPackage;
-
+
Result := CompileDelphiPackage(PackageName, BPLPath, DCPPath) and
RegisterPackage(BPLFileName, Description);
@@ -3976,6 +3983,19 @@
end;
procedure TJclBorRADToolInstallation.ReadInformation;
+const
+ {$IFDEF KYLIX}
+ BinDir = 'bin/';
+ {$ELSE ~KYLIX}
+ BinDir = 'bin\';
+ {$ENDIF ~KYLIX}
+ UpdateKeyName = 'Update #';
+ BDSUpdateKeyName = 'UpdatePackInstalled';
+var
+ KeyLen, I: Integer;
+ Key: string;
+ Ed: TJclBorRADToolEdition;
+
function FormatVersionNumber(const Num: Integer): string;
begin
Result := '';
@@ -3993,25 +4013,14 @@
{$ENDIF ~KYLIX}
brBorlandDevStudio:
case Num of
- 1 :
+ 1:
Result := 'cs1';
else
Result := Format('d%d', [Num + 6]); // BDS 2 goes to D8
end;
end;
end;
-const
- {$IFDEF KYLIX}
- BinDir = 'bin/';
- {$ELSE ~KYLIX}
- BinDir = 'bin\';
- {$ENDIF ~KYLIX}
- UpdateKeyName = 'Update #';
- BDSUpdateKeyName = 'UpdatePackInstalled';
-var
- KeyLen, I: Integer;
- Key: string;
- Ed: TJclBorRADToolEdition;
+
begin
Key := ConfigData.FileName;
{$IFDEF KYLIX}
@@ -4072,13 +4081,13 @@
if RadToolKind = brBorlandDevStudio then
FInstalledUpdatePack := StrToIntDef(Globals.Values[BDSUpdateKeyName], 0)
else
- for I := 0 to Globals.Count - 1 do
- begin
- Key := Globals.Names[I];
- KeyLen := Length(UpdateKeyName);
- if (Pos(UpdateKeyName, Key) = 1) and (Length(Key) > KeyLen) and StrIsDigit(Key[KeyLen + 1]) then
- FInstalledUpdatePack := Max(FInstalledUpdatePack, Integer(Ord(Key[KeyLen + 1]) - 48));
- end;
+ for I := 0 to Globals.Count - 1 do
+ begin
+ Key := Globals.Names[I];
+ KeyLen := Length(UpdateKeyName);
+ if (Pos(UpdateKeyName, Key) = 1) and (Length(Key) > KeyLen) and StrIsDigit(Key[KeyLen + 1]) then
+ FInstalledUpdatePack := Max(FInstalledUpdatePack, Integer(Ord(Key[KeyLen + 1]) - 48));
+ end;
end;
function TJclBorRADToolInstallation.RegisterExpert(const BinaryFileName, Description: string): Boolean;
@@ -4256,8 +4265,8 @@
{$IFDEF KYLIX}
Result := False;
{$ELSE ~KYLIX}
- Result := (RadToolKind = brBorlandDevStudio) or (VersionNumber >= 6)
- and (FileExists(LibFolderName + VclDcp) or FileExists(ObjFolderName + VclDcp));
+ Result := (RadToolKind = brBorlandDevStudio) or (VersionNumber >= 6) and
+ (FileExists(LibFolderName + VclDcp) or FileExists(ObjFolderName + VclDcp));
{$ENDIF ~KYLIX}
end;
@@ -4268,8 +4277,8 @@
{$IFDEF KYLIX}
Result := True;
{$ELSE}
- Result := (Edition <> deSTD) and (VersionNumber in [6, 7]) and (RadToolKind <> brBorlandDevStudio)
- and (FileExists(LibFolderName + VisualClxDcp) or FileExists(ObjFolderName + VisualClxDcp));
+ Result := (Edition <> deSTD) and (VersionNumber in [6, 7]) and (RadToolKind <> brBorlandDevStudio) and
+ (FileExists(LibFolderName + VisualClxDcp) or FileExists(ObjFolderName + VisualClxDcp));
{$ENDIF KYLIX}
end;
@@ -4344,10 +4353,10 @@
RunOnly: Boolean;
begin
OutputString(Format(RsPackageUninstallationStarted, [PackageName]));
-
+
if not IsBCBPackage(PackageName) then
raise EJclBorRADException.CreateResFmt(@RsENotABCBPackage, [PackageName]);
-
+
GetBPKFileInfo(PackageName, RunOnly, @BinaryFileName);
BPLFileName := PathAddSeparator(BPLPath) + BinaryFileName;
@@ -4360,7 +4369,7 @@
if Result then
begin
OutputFileDelete(BPLFileName);
-
+
BPIFileName := PathAddSeparator(DCPPath) + PathExtractFileNameNoExt(PackageName) + CompilerExtensionBPI;
OutputFileDelete(BPIFileName);
@@ -4411,7 +4420,7 @@
RunOnly: Boolean;
begin
OutputString(Format(RsIdePackageUninstallationStarted, [PackageName]));
-
+
if not IsDelphiPackage(PackageName) then
raise EJclBorRADException.CreateResFmt(@RsENotADelphiPackage, [PackageName]);
@@ -4441,13 +4450,12 @@
function TJclBorRADToolInstallation.UninstallDelphiPackage(const PackageName, BPLPath, DCPPath: string): Boolean;
var
- MAPFileName,
- BPLFileName, DCPFileName: string;
+ MAPFileName, BPLFileName, DCPFileName: string;
BaseName, LibSuffix: string;
RunOnly: Boolean;
begin
OutputString(Format(RsPackageUninstallationStarted, [PackageName]));
-
+
if not IsDelphiPackage(PackageName) then
raise EJclBorRADException.CreateResFmt(@RsENotADelphiPackage, [PackageName]);
@@ -4480,7 +4488,7 @@
ProjectExtension: string;
begin
ProjectExtension := ExtractFileExt(ProjectName);
- if SameText(ProjectExtension,SourceExtensionBCBProject) then
+ if SameText(ProjectExtension, SourceExtensionBCBProject) then
Result := UninstallBCBExpert(ProjectName, OutputDir)
else
if SameText(ProjectExtension, SourceExtensionDelphiProject) then
@@ -4494,7 +4502,7 @@
PackageExtension: string;
begin
PackageExtension := ExtractFileExt(PackageName);
- if SameText(PackageExtension,SourceExtensionBCBPackage) then
+ if SameText(PackageExtension, SourceExtensionBCBPackage) then
Result := UninstallBCBIdePackage(PackageName, BPLPath, DCPPath)
else
if SameText(PackageExtension, SourceExtensionDelphiPackage) then
@@ -4508,7 +4516,7 @@
PackageExtension: string;
begin
PackageExtension := ExtractFileExt(PackageName);
- if SameText(PackageExtension,SourceExtensionBCBPackage) then
+ if SameText(PackageExtension, SourceExtensionBCBPackage) then
Result := UninstallBCBPackage(PackageName, BPLPath, DCPPath)
else
if SameText(PackageExtension, SourceExtensionDelphiPackage) then
@@ -4908,7 +4916,8 @@
Result := GetCommonProjectsDirectory(RootDir, IDEVersionNumber);
end;
-class function TJclBDSInstallation.GetCommonProjectsDirectory(const RootDir: string; IDEVersionNumber: Integer): string;
+class function TJclBDSInstallation.GetCommonProjectsDirectory(const RootDir: string;
+ IDEVersionNumber: Integer): string;
var
RsVarsOutput, ComSpec: string;
Lines: TStrings;
@@ -4933,7 +4942,8 @@
Result := LoadResStrings(RootDir + '\Bin\coreide' + BDSVersions[IDEVersionNumber].CoreIdeVersion + '.',
['RAD Studio'])[0];
- Result := Format('%s%s%d.0', [PathAddSeparator(GetCommonDocumentsFolder), PathAddSeparator(Result), IDEVersionNumber]);
+ Result := Format('%s%s%d.0',
+ [PathAddSeparator(GetCommonDocumentsFolder), PathAddSeparator(Result), IDEVersionNumber]);
end;
end
else
@@ -4994,7 +5004,8 @@
Result := GetDefaultProjectsDirectory(RootDir, IDEVersionNumber);
end;
-class function TJclBDSInstallation.GetDefaultProjectsDirectory(const RootDir: string; IDEVersionNumber: In...
[truncated message content] |
|
From: <ou...@us...> - 2007-09-16 08:25:15
|
Revision: 2169
http://jcl.svn.sourceforge.net/jcl/?rev=2169&view=rev
Author: outchy
Date: 2007-09-16 01:25:13 -0700 (Sun, 16 Sep 2007)
Log Message:
-----------
Donation from Andreas Schmidt: StringToFile to append data to the end.
Modified Paths:
--------------
trunk/jcl/source/common/JclAnsiStrings.pas
trunk/jcl/source/common/JclStrings.pas
Modified: trunk/jcl/source/common/JclAnsiStrings.pas
===================================================================
--- trunk/jcl/source/common/JclAnsiStrings.pas 2007-09-15 18:31:36 UTC (rev 2168)
+++ trunk/jcl/source/common/JclAnsiStrings.pas 2007-09-16 08:25:13 UTC (rev 2169)
@@ -38,6 +38,7 @@
{ Robert Lee }
{ Robert Marquardt (marquardt) }
{ Robert Rossmair (rrossmair) }
+{ Andreas Schmidt }
{ }
{**************************************************************************************************}
{ }
@@ -339,7 +340,7 @@
function BooleanToStr(B: Boolean): AnsiString;
{$ENDIF KEEP_DEPRECATED}
function FileToString(const FileName: AnsiString): AnsiString;
-procedure StringToFile(const FileName, Contents: AnsiString);
+procedure StringToFile(const FileName, Contents: AnsiString; Append: Boolean = False);
function StrToken(var S: AnsiString; Separator: AnsiChar): AnsiString;
{$IFNDEF CLR}
procedure StrTokens(const S: AnsiString; const List: TStrings);
@@ -377,7 +378,7 @@
{$IFDEF HAS_UNIT_LIBC}
Libc,
{$ENDIF HAS_UNIT_LIBC}
- JclLogic, JclResources;
+ JclLogic, JclResources, JclStreams;
//=== Internal ===============================================================
@@ -3746,13 +3747,18 @@
end;
end;
-procedure StringToFile(const FileName: AnsiString; const Contents: AnsiString);
+procedure StringToFile(const FileName: AnsiString; const Contents: AnsiString; Append: Boolean);
var
FS: TFileStream;
Len: Integer;
begin
- FS := TFileStream.Create(FileName, fmCreate);
+ if Append and FileExists(filename) then
+ FS := TFileStream.Create(FileName, fmOpenReadWrite or fmShareDenyWrite)
+ else
+ FS := TFileStream.Create(FileName, fmCreate);
try
+ if Append then
+ StreamSeek(FS, 0, soEnd); // faster than .Position := .Size
Len := Length(Contents);
if Len > 0 then
{$IFDEF CLR}
Modified: trunk/jcl/source/common/JclStrings.pas
===================================================================
--- trunk/jcl/source/common/JclStrings.pas 2007-09-15 18:31:36 UTC (rev 2168)
+++ trunk/jcl/source/common/JclStrings.pas 2007-09-16 08:25:13 UTC (rev 2169)
@@ -39,6 +39,7 @@
{ Robert Lee }
{ Robert Marquardt (marquardt) }
{ Robert Rossmair (rrossmair) }
+{ Andreas Schmidt }
{ }
{**************************************************************************************************}
{ }
@@ -350,7 +351,7 @@
function BooleanToStr(B: Boolean): string;
{$ENDIF KEEP_DEPRECATED}
function FileToString(const FileName: string): AnsiString;
-procedure StringToFile(const FileName: string; const Contents: AnsiString);
+procedure StringToFile(const FileName: string; const Contents: AnsiString; Append: Boolean = False);
function StrToken(var S: string; Separator: Char): string;
procedure StrTokens(const S: string; const List: TStrings);
procedure StrTokenToStrings(S: string; Separator: Char; const List: TStrings);
@@ -499,7 +500,7 @@
{$IFDEF HAS_UNIT_LIBC}
Libc,
{$ENDIF HAS_UNIT_LIBC}
- JclLogic, JclResources;
+ JclLogic, JclResources, JclStreams;
//=== Internal ===============================================================
@@ -3975,25 +3976,29 @@
end;
end;
-procedure StringToFile(const FileName: string; const Contents: AnsiString);
+procedure StringToFile(const FileName: string; const Contents: AnsiString; Append: Boolean);
var
- fs: TFileStream;
+ FS: TFileStream;
Len: Integer;
begin
- fs := TFileStream.Create(FileName, fmCreate);
+ if Append and FileExists(filename) then
+ FS := TFileStream.Create(FileName, fmOpenReadWrite or fmShareDenyWrite)
+ else
+ FS := TFileStream.Create(FileName, fmCreate);
try
+ if Append then
+ StreamSeek(FS, 0, soEnd); // faster than .Position := .Size
Len := Length(Contents);
if Len > 0 then
{$IFDEF CLR}
- fs.WriteBuffer(BytesOf(Contents), Len);
+ FS.WriteBuffer(BytesOf(Contents), Len);
{$ELSE}
- fs.WriteBuffer(Contents[1], Len);
+ FS.WriteBuffer(Contents[1], Len);
{$ENDIF CLR}
finally
- fs.Free;
+ FS.Free;
end;
end;
-
function StrToken(var S: string; Separator: Char): string;
var
I: Integer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mo...@us...> - 2007-11-26 22:05:11
|
Revision: 2234
http://jcl.svn.sourceforge.net/jcl/?rev=2234&view=rev
Author: morrac
Date: 2007-11-26 14:05:06 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
- Improve FPC support.
- Fix an error in TJclFileStream.Create (FPC and Kylix only).
Modified Paths:
--------------
trunk/jcl/source/common/JclBase.pas
trunk/jcl/source/common/JclStreams.pas
trunk/jcl/source/common/JclStringLists.pas
trunk/jcl/source/common/JclSysInfo.pas
trunk/jcl/source/common/JclSysUtils.pas
trunk/jcl/source/common/JclUnitVersioning.pas
Modified: trunk/jcl/source/common/JclBase.pas
===================================================================
--- trunk/jcl/source/common/JclBase.pas 2007-11-26 21:30:16 UTC (rev 2233)
+++ trunk/jcl/source/common/JclBase.pas 2007-11-26 22:05:06 UTC (rev 2234)
@@ -347,12 +347,16 @@
procedure MoveArray(var List: TDynFloatArray; FromIndex, ToIndex, Count: Integer); overload;
procedure MoveArray(var List: TDynPointerArray; FromIndex, ToIndex, Count: Integer); overload;
{$ENDIF ~CLR}
+{$IFNDEF FPC}
procedure MoveArray(var List: TDynAnsiStringArray; FromIndex, ToIndex, Count: Integer); overload;
+{$ENDIF}
procedure MoveArray(var List: TDynWideStringArray; FromIndex, ToIndex, Count: Integer); overload;
procedure MoveArray(var List: TDynObjectArray; FromIndex, ToIndex, Count: Integer); overload;
procedure MoveArray(var List: TDynSingleArray; FromIndex, ToIndex, Count: Integer); overload;
procedure MoveArray(var List: TDynDoubleArray; FromIndex, ToIndex, Count: Integer); overload;
+{$IFNDEF FPC}
procedure MoveArray(var List: TDynExtendedArray; FromIndex, ToIndex, Count: Integer); overload;
+{$ENDIF}
procedure MoveArray(var List: TDynIntegerArray; FromIndex, ToIndex, Count: Integer); overload;
procedure MoveArray(var List: TDynCardinalArray; FromIndex, ToIndex, Count: Integer); overload;
procedure MoveArray(var List: TDynInt64Array; FromIndex, ToIndex, Count: Integer); overload;
@@ -579,6 +583,7 @@
end;
{$ENDIF ~CLR}
+{$IFNDEF FPC}
procedure MoveArray(var List: TDynAnsiStringArray; FromIndex, ToIndex, Count: Integer); overload;
{$IFDEF CLR}
var
@@ -636,6 +641,7 @@
end;
end;
{$ENDIF CLR}
+{$ENDIF FPC}
procedure MoveArray(var List: TDynWideStringArray; FromIndex, ToIndex, Count: Integer); overload;
{$IFDEF CLR}
@@ -869,6 +875,7 @@
end;
{$ENDIF CLR}
+{$IFNDEF FPC}
procedure MoveArray(var List: TDynExtendedArray; FromIndex, ToIndex, Count: Integer); overload;
{$IFDEF CLR}
var
@@ -926,6 +933,7 @@
end;
end;
{$ENDIF CLR}
+{$ENDIF FPC}
procedure MoveArray(var List: TDynIntegerArray; FromIndex, ToIndex, Count: Integer); overload;
{$IFDEF CLR}
Modified: trunk/jcl/source/common/JclStreams.pas
===================================================================
--- trunk/jcl/source/common/JclStreams.pas 2007-11-26 21:30:16 UTC (rev 2233)
+++ trunk/jcl/source/common/JclStreams.pas 2007-11-26 22:05:06 UTC (rev 2234)
@@ -660,7 +660,11 @@
const
SeekOrigins: array [TSeekOrigin] of Cardinal = ( SEEK_SET {soBeginning}, SEEK_CUR {soCurrent}, SEEK_END {soEnd} );
begin
+{$IFDEF KYLIX}
Result := __lseek(Handle, Offset, SeekOrigins[Origin]);
+{$ELSE}
+ Result := lseek(Handle, Offset, SeekOrigins[Origin]);
+{$ENDIF}
end;
{$ENDIF LINUX}
@@ -682,21 +686,24 @@
constructor TJclFileStream.Create(const FileName: string; Mode: Word; Rights: Cardinal);
var
H: THandle;
-{$IFDEF KYLIX}
+{$IFDEF LINUX}
const
- INVALID_HANDLE_VALUE = 0;
-{$ENDIF KYLIX}
+ INVALID_HANDLE_VALUE = -1;
+{$ENDIF LINUX}
begin
if Mode = fmCreate then
begin
+ {$IFDEF LINUX}
{$IFDEF KYLIX}
H := __open(PChar(FileName), O_CREAT or O_RDWR, FileAccessRights);
- inherited Create(H);
{$ELSE ~KYLIX}
+ H := open(PChar(FileName), O_CREAT or O_RDWR, $666);
+ {$ENDIF}
+ {$ELSE ~LINUX}
H := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE,
0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+ {$ENDIF ~LINUX}
inherited Create(H);
- {$ENDIF ~KYLIX}
if Handle = INVALID_HANDLE_VALUE then
{$IFDEF CLR}
raise EJclStreamError.CreateFmt(RsStreamsCreateError, [FileName]);
Modified: trunk/jcl/source/common/JclStringLists.pas
===================================================================
--- trunk/jcl/source/common/JclStringLists.pas 2007-11-26 21:30:16 UTC (rev 2233)
+++ trunk/jcl/source/common/JclStringLists.pas 2007-11-26 22:05:06 UTC (rev 2234)
@@ -355,9 +355,9 @@
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
{$ENDIF CLR}
- {$IFDEF COMPILER5}
+ {$IF defined(COMPILER5) OR defined(FPC)}
function CompareStrings(const S1, S2: string): Integer; virtual;
- {$ENDIF COMPILER5}
+ {$IFEND}
public
constructor Create;
destructor Destroy; override;
@@ -1126,12 +1126,12 @@
Result := FSelfAsInterface;
end;
-{$IFDEF COMPILER5}
+{$IF defined(COMPILER5) OR defined(FPC)}
function TJclStringListImpl.CompareStrings(const S1, S2: string): Integer;
begin
Result := AnsiCompareText(S1, S2);
end;
-{$ENDIF COMPILER5}
+{$IFEND}
function TJclStringListImpl.SortByName: IJclStringList;
Modified: trunk/jcl/source/common/JclSysInfo.pas
===================================================================
--- trunk/jcl/source/common/JclSysInfo.pas 2007-11-26 21:30:16 UTC (rev 2233)
+++ trunk/jcl/source/common/JclSysInfo.pas 2007-11-26 22:05:06 UTC (rev 2234)
@@ -1434,7 +1434,7 @@
{$ENDIF MSWINDOWS}
-{$IFDEF KYLIX}
+{$IFDEF LINUX}
function GetEnvironmentVars(const Vars: TStrings): Boolean;
var
P: PPChar;
@@ -1458,7 +1458,7 @@
begin
Result := GetEnvironmentVars(Vars); // Expand is there just for x-platform compatibility
end;
-{$ENDIF KYLIX}
+{$ENDIF LINUX}
{$IFDEF MSWINDOWS}
function GetEnvironmentVars(const Vars: TStrings): Boolean;
Modified: trunk/jcl/source/common/JclSysUtils.pas
===================================================================
--- trunk/jcl/source/common/JclSysUtils.pas 2007-11-26 21:30:16 UTC (rev 2233)
+++ trunk/jcl/source/common/JclSysUtils.pas 2007-11-26 22:05:06 UTC (rev 2234)
@@ -132,7 +132,7 @@
{ SharedFreeMem releases the shared memory if it was the last reference. }
function SharedFreeMem(var p{: Pointer}): Boolean;
-// Functions for the shared memory user
+// Functions for the shared memory user
{ SharedOpenMem returns True if the shared memory was already allocated by
SharedGetMem or SharedAllocMem. Otherwise it returns False.
@@ -951,7 +951,7 @@
{$IFDEF THREADSAFE}
HandleListAccess := GetAccessToHandleList;
{$ENDIF THREADSAFE}
-
+
// search for same name
Iterate := MMFHandleList;
while Iterate <> nil do
@@ -972,7 +972,7 @@
begin
if Size = 0 then
raise ESharedMemError.CreateResFmt(@RsInvalidMMFEmpty, [Name]);
-
+
Protect := PAGE_READWRITE;
if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
(DesiredAccess = FILE_MAP_COPY) then
@@ -1626,7 +1626,8 @@
begin
PatchAddress := Pointer(Integer(AClass) + Offset);
if not WriteProtectedMemory(PatchAddress, @Value, SizeOf(Value), WrittenBytes) then
- raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, [SysErrorMessage(GetLastError)]);
+ raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError,
+ [SysErrorMessage({$IFDEF FPC}GetLastOSError{$ELSE}GetLastError{$ENDIF})]);
if WrittenBytes <> SizeOf(Pointer) then
raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, [IntToStr(WrittenBytes)]);
@@ -1782,7 +1783,8 @@
begin
PatchAddress := PPointer(Integer(AClass) + vmtParent)^;
if not WriteProtectedMemory(PatchAddress, @NewClassParent, SizeOf(Pointer), WrittenBytes) then
- raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, [SysErrorMessage(GetLastError)]);
+ raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError,
+ [SysErrorMessage({$IFDEF FPC}GetLastOSError{$ELSE}GetLastError{$ENDIF})]);
if WrittenBytes <> SizeOf(Pointer) then
raise EJclVMTError.CreateResFmt(@RsVMTMemoryWriteError, [IntToStr(WrittenBytes)]);
// make sure that everything keeps working in a dual processor setting
@@ -2244,7 +2246,7 @@
end;
FirstDigitPos := I + 1;
-
+
if HasSign then
Result[I] := SignChar(Value)
else
Modified: trunk/jcl/source/common/JclUnitVersioning.pas
===================================================================
--- trunk/jcl/source/common/JclUnitVersioning.pas 2007-11-26 21:30:16 UTC (rev 2233)
+++ trunk/jcl/source/common/JclUnitVersioning.pas 2007-11-26 22:05:06 UTC (rev 2234)
@@ -480,7 +480,11 @@
for I := FModules.Count - 1 downto 0 do
begin
SetLength(Buffer, 1024);
+ {$IFDEF FPC}
+ if dlsym(Pointer(Modules[I].Instance), '_init') = nil then
+ {$ELSE}
if GetModuleFileName(Modules[I].Instance, PChar(Buffer), 1024) = 0 then
+ {$ENDIF}
// This module is no more in memory but has not unregistered itself so
// unregister it here.
UnregisterModule(Modules[I]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2007-11-30 19:28:53
|
Revision: 2243
http://jcl.svn.sourceforge.net/jcl/?rev=2243&view=rev
Author: outchy
Date: 2007-11-30 11:28:51 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
Removing lots of CLR excluded code, refactoring EDI exception constructors.
Modified Paths:
--------------
trunk/jcl/source/common/JclEDI.pas
trunk/jcl/source/common/JclEDIXML.pas
trunk/jcl/source/common/JclEDI_UNEDIFACT.pas
trunk/jcl/source/common/JclEDI_UNEDIFACT_Ext.pas
trunk/jcl/source/common/JclResources.pas
Modified: trunk/jcl/source/common/JclEDI.pas
===================================================================
--- trunk/jcl/source/common/JclEDI.pas 2007-11-30 19:24:18 UTC (rev 2242)
+++ trunk/jcl/source/common/JclEDI.pas 2007-11-30 19:28:51 UTC (rev 2243)
@@ -89,7 +89,11 @@
TEDIObject = class(TObject); // Base EDI Object
TEDIObjectArray = array of TEDIObject;
- EJclEDIError = EJclError;
+ EJclEDIError = class(EJclError)
+ public
+ constructor CreateID(ID: Integer);
+ constructor CreateIDFmt(ID: Integer; const Args: array of const);
+ end;
// EDI Forward Class Declarations
TEDIDataObject = class;
@@ -531,6 +535,26 @@
end;
end;
+//=== { EJclEDIError } =======================================================
+
+constructor EJclEDIError.CreateID(ID: Integer);
+begin
+ {$IFDEF CLR}
+ Create(RsEDIErrors[ID]);
+ {$ELSE ~CLR}
+ CreateRes(RsEDIErrors[ID]);
+ {$ENDIF ~CLR}
+end;
+
+constructor EJclEDIError.CreateIDFmt(ID: Integer; const Args: array of const);
+begin
+ {$IFDEF CLR}
+ Create(Format(RsEDIErrors[ID], Args));
+ {$ELSE ~CLR}
+ CreateResFmt(RsEDIErrors[ID], Args);
+ {$ENDIF ~CLR}
+end;
+
//=== { TEDIDelimiters } =====================================================
constructor TEDIDelimiters.Create;
Modified: trunk/jcl/source/common/JclEDIXML.pas
===================================================================
--- trunk/jcl/source/common/JclEDIXML.pas 2007-11-30 19:24:18 UTC (rev 2242)
+++ trunk/jcl/source/common/JclEDIXML.pas 2007-11-30 19:28:51 UTC (rev 2243)
@@ -721,7 +721,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError047);
+ raise EJclEDIError.CreateID(47);
end;
OriginalData := FData;
@@ -760,7 +760,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError046);
+ raise EJclEDIError.CreateID(46);
end;
// Set next start positon
StartPos := 1;
@@ -773,7 +773,7 @@
FAttributes.ParseAttributes(XMLStartTag);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError048);
+ raise EJclEDIError.CreateID(48);
// Set data start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Check for CData tag
@@ -797,10 +797,10 @@
FData := Copy(FData, StartPos, (EndPos - StartPos));
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError050);
+ raise EJclEDIError.CreateID(50);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError049);
+ raise EJclEDIError.CreateID(49);
// Handle Entity Reference Characters
StrReplace(FData, EDIXML_HTMLLessThanSign, EDIXML_LessThanSign, [rfReplaceAll]);
StrReplace(FData, EDIXML_HTMLGreaterThanSign, EDIXML_GreaterThanSign, [rfReplaceAll]);
@@ -920,7 +920,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError042);
+ raise EJclEDIError.CreateID(42);
end;
AttributeString := FAttributes.CombineAttributes;
@@ -970,7 +970,7 @@
SetLength(FElements, High(FElements));
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError058, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(58, [IntToStr(Index)]);
end;
procedure TEDIXMLSegment.DeleteElements;
@@ -1003,7 +1003,7 @@
SetLength(FElements, Length(FElements) - Count);
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError058, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(58, [IntToStr(Index)]);
end;
procedure TEDIXMLSegment.Disassemble;
@@ -1017,7 +1017,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError041);
+ raise EJclEDIError.CreateID(41);
end;
// Set next start positon
StartPos := 1;
@@ -1031,7 +1031,7 @@
FAttributes.ParseAttributes(XMLStartTag);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError043);
+ raise EJclEDIError.CreateID(43);
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for element
@@ -1051,10 +1051,10 @@
FElements[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError050);
+ raise EJclEDIError.CreateID(50);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError049);
+ raise EJclEDIError.CreateID(49);
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for element
@@ -1072,15 +1072,15 @@
if Index <= High(FElements) then
begin
if not Assigned(FElements[Index]) then
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError057, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(57, [IntToStr(Index)]);
Result := FElements[Index];
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError056, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(56, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError055, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(55, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError054, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(54, [IntToStr(Index)]);
end;
function TEDIXMLSegment.GetIndexPositionFromParent: Integer;
@@ -1249,11 +1249,11 @@
FElements[Index] := Element;
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError053, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(53, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError052, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(52, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError051, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(51, [IntToStr(Index)]);
end;
//=== { TEDIXMLTransactionSetSegment } =======================================
@@ -1398,7 +1398,7 @@
SetLength(FEDIDataObjects, High(FEDIDataObjects));
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError040);
+ raise EJclEDIError.CreateID(40);
end;
procedure TEDIXMLDataObjectGroup.DeleteEDIDataObjects;
@@ -1418,15 +1418,15 @@
if Index <= High(FEDIDataObjects) then
begin
if not Assigned(FEDIDataObjects[Index]) then
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError039, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(39, [IntToStr(Index)]);
Result := FEDIDataObjects[Index];
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError038, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(38, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError037, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(37, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError036, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(36, [IntToStr(Index)]);
end;
function TEDIXMLDataObjectGroup.InsertEDIDataObject(InsertIndex: Integer;
@@ -1509,11 +1509,11 @@
FEDIDataObjects[Index] := EDIDataObject;
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError035, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(35, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError034, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(34, [IntToStr(Index)])
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError033, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(33, [IntToStr(Index)]);
end;
//=== { TEDIXMLTransactionSetLoop } ==========================================
@@ -1549,7 +1549,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError030);
+ raise EJclEDIError.CreateID(30);
end;
AttributeString := FAttributes.CombineAttributes;
@@ -1584,7 +1584,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError029);
+ raise EJclEDIError.CreateID(29);
end;
// Set next start positon
StartPos := 1;
@@ -1598,7 +1598,7 @@
FAttributes.ParseAttributes(XMLStartTag);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError031);
+ raise EJclEDIError.CreateID(31);
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Determine the nearest tag to search for
@@ -1631,10 +1631,10 @@
EDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError045);
+ raise EJclEDIError.CreateID(45);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError044);
+ raise EJclEDIError.CreateID(44);
end
else
begin
@@ -1669,10 +1669,10 @@
EDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError032);
+ raise EJclEDIError.CreateID(32);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError031);
+ raise EJclEDIError.CreateID(31);
end;
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
@@ -1730,7 +1730,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError026);
+ raise EJclEDIError.CreateID(26);
end;
AttributeString := FAttributes.CombineAttributes;
@@ -1765,7 +1765,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError025);
+ raise EJclEDIError.CreateID(25);
end;
// Set next start positon
StartPos := 1;
@@ -1795,10 +1795,10 @@
EDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError045);
+ raise EJclEDIError.CreateID(45);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError044);
+ raise EJclEDIError.CreateID(44);
end
else
begin
@@ -1833,10 +1833,10 @@
EDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError032);
+ raise EJclEDIError.CreateID(32);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError031);
+ raise EJclEDIError.CreateID(31);
end;
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
@@ -1870,7 +1870,7 @@
else
begin
FSTSegment := nil;
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError059);
+ raise EJclEDIError.CreateID(59);
end;
if FSESegment.Attributes.GetAttributeValue(XMLAttribute_Id) = XMLTag_TSTSegmentId then
@@ -1887,14 +1887,14 @@
else
begin
FSESegment := nil;
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError060);
+ raise EJclEDIError.CreateID(60);
end;
end
else
begin
FSTSegment := nil;
FSESegment := nil;
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError061);
+ raise EJclEDIError.CreateID(61);
end;
FData := '';
//
@@ -1944,7 +1944,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError016);
+ raise EJclEDIError.CreateID(16);
end;
AttributeString := FAttributes.CombineAttributes;
@@ -1977,7 +1977,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError015);
+ raise EJclEDIError.CreateID(15);
end;
// Search for Functional Group Header
StartPos := 1;
@@ -1998,13 +1998,13 @@
FGSSegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError021);
+ raise EJclEDIError.CreateID(21);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError020);
+ raise EJclEDIError.CreateID(20);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError019);
+ raise EJclEDIError.CreateID(19);
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for Transaction Set
@@ -2024,10 +2024,10 @@
EDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError028);
+ raise EJclEDIError.CreateID(28);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError027);
+ raise EJclEDIError.CreateID(27);
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for Transaction Set
@@ -2051,13 +2051,13 @@
FGESegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError024);
+ raise EJclEDIError.CreateID(24);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError023);
+ raise EJclEDIError.CreateID(23);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError022);
+ raise EJclEDIError.CreateID(22);
FData := '';
//
FState := ediDisassembled;
@@ -2104,7 +2104,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError005);
+ raise EJclEDIError.CreateID(5);
end;
AttributeString := FAttributes.CombineAttributes;
@@ -2137,7 +2137,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError006);
+ raise EJclEDIError.CreateID(6);
end;
// Search for Interchange Control Header
StartPos := 1;
@@ -2158,13 +2158,13 @@
FISASegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError011);
+ raise EJclEDIError.CreateID(11);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError010);
+ raise EJclEDIError.CreateID(10);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError009);
+ raise EJclEDIError.CreateID(9);
// Set next start position. Move past the delimiter
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for Functional Group
@@ -2184,10 +2184,10 @@
EDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError018);
+ raise EJclEDIError.CreateID(18);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError017);
+ raise EJclEDIError.CreateID(17);
// Set next start positon
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for Functional Group
@@ -2211,13 +2211,13 @@
FIEASegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError014);
+ raise EJclEDIError.CreateID(14);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError013);
+ raise EJclEDIError.CreateID(13);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError012);
+ raise EJclEDIError.CreateID(12);
FData := '';
//
FState := ediDisassembled;
@@ -2261,7 +2261,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError004);
+ raise EJclEDIError.CreateID(4);
end;
FData := FEDIXMLFileHeader.OutputXMLHeader;
@@ -2297,7 +2297,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError003);
+ raise EJclEDIError.CreateID(3);
end;
// Search for XML file heaer
StartPos := 1;
@@ -2342,10 +2342,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError008);
+ raise EJclEDIError.CreateID(8);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError007);
+ raise EJclEDIError.CreateID(7);
// Set next start position. Move past the delimiter
StartPos := SearchResult + FDelimiters.ETDLength;
// Search for Interchange
@@ -2387,7 +2387,7 @@
FData := StringReplace(FData, AnsiCrLf, '', [rfReplaceAll, rfIgnoreCase]);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError001);
+ raise EJclEDIError.CreateID(1);
end;
procedure TEDIXMLFile.LoadFromFile(const FileName: string);
@@ -2420,7 +2420,7 @@
end;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError002);
+ raise EJclEDIError.CreateID(2);
end;
procedure TEDIXMLFile.SaveToFile;
@@ -2441,7 +2441,7 @@
end;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}EDIXMLError002);
+ raise EJclEDIError.CreateID(2);
end;
//=== { TEDIXMLFileHeader } ==================================================
@@ -2573,7 +2573,7 @@
ConvertTransactionSetLoopToEDI(Result, XMLLoop);
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError062, [XMLTransactionSet[I].ClassName]);
+ raise EJclEDIError.CreateIDFmt(62, [XMLTransactionSet[I].ClassName]);
end;
end;
@@ -2670,7 +2670,7 @@
ConvertTransactionSetLoopToEDI(EDITransactionSet, nXMLLoop);
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError062, [XMLLoop[I].ClassName]);
+ raise EJclEDIError.CreateIDFmt(62, [XMLLoop[I].ClassName]);
end;
end;
@@ -2701,7 +2701,7 @@
ConvertTransactionSetLoopToXML(nEDILoop, nXMLLoop);
end
else
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}EDIXMLError062, [EDILoop[I].ClassName]);
+ raise EJclEDIError.CreateIDFmt(62, [EDILoop[I].ClassName]);
end;
end;
Modified: trunk/jcl/source/common/JclEDI_UNEDIFACT.pas
===================================================================
--- trunk/jcl/source/common/JclEDI_UNEDIFACT.pas 2007-11-30 19:24:18 UTC (rev 2242)
+++ trunk/jcl/source/common/JclEDI_UNEDIFACT.pas 2007-11-30 19:28:51 UTC (rev 2243)
@@ -575,7 +575,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError036);
+ raise EJclEDIError.CreateID(36);
end;
FData := FSegmentID;
@@ -629,7 +629,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError035);
+ raise EJclEDIError.CreateID(35);
end;
// Continue
StartPos := 1;
@@ -905,7 +905,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError031);
+ raise EJclEDIError.CreateID(31);
end;
FData := FUNHSegment.Assemble;
@@ -962,7 +962,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError030);
+ raise EJclEDIError.CreateID(30);
end;
// Find the first segment
StartPos := 1;
@@ -1135,7 +1135,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError020);
+ raise EJclEDIError.CreateID(20);
end;
FData := FUNGSegment.Assemble;
FUNGSegment.Data := '';
@@ -1190,7 +1190,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError019);
+ raise EJclEDIError.CreateID(19);
end;
// Find Functional Group Header Segment
StartPos := 1;
@@ -1205,14 +1205,14 @@
FUNGSegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError021);
+ raise EJclEDIError.CreateID(21);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError022);
+ raise EJclEDIError.CreateID(22);
// Search for Message Header
SearchResult := StrSearch(FDelimiters.SD + UNHSegmentId + FDelimiters.ED, FData, StartPos);
if SearchResult <= 0 then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError032);
+ raise EJclEDIError.CreateID(32);
// Set next start position
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Continue
@@ -1234,10 +1234,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError033);
+ raise EJclEDIError.CreateID(33);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError034);
+ raise EJclEDIError.CreateID(34);
// Set the next start position
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
//
@@ -1260,10 +1260,10 @@
FUNESegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError023);
+ raise EJclEDIError.CreateID(23);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError024);
+ raise EJclEDIError.CreateID(24);
FData := '';
FState := ediDisassembled;
end;
@@ -1397,7 +1397,7 @@
Result := '';
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError013);
+ raise EJclEDIError.CreateID(13);
FData := FUNBSegment.Assemble;
FUNBSegment.Data := '';
@@ -1429,7 +1429,7 @@
DeleteEDIDataObjects;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError012);
+ raise EJclEDIError.CreateID(12);
StartPos := 1;
// Search for Interchange Control Header
@@ -1442,10 +1442,10 @@
FUNBSegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError014);
+ raise EJclEDIError.CreateID(14);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError015);
+ raise EJclEDIError.CreateID(15);
// Search for Functional Group Header
SearchResult := StrSearch(FDelimiters.SD + UNGSegmentId + FDelimiters.ED, FData, StartPos);
if SearchResult > 0 then
@@ -1471,10 +1471,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError023);
+ raise EJclEDIError.CreateID(23);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError024);
+ raise EJclEDIError.CreateID(24);
// Set next start positon
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Verify the next record is a Functional Group Header
@@ -1488,7 +1488,7 @@
// Search for Message Header
SearchResult := StrSearch(FDelimiters.SD + UNHSegmentId + FDelimiters.ED, FData, StartPos);
if SearchResult <= 0 then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError032);
+ raise EJclEDIError.CreateID(32);
// Set next start position
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Continue
@@ -1510,10 +1510,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError033);
+ raise EJclEDIError.CreateID(33);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError034);
+ raise EJclEDIError.CreateID(34);
// Set the next start position
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Verify the next record is a Message Header
@@ -1534,10 +1534,10 @@
FUNZSegment.Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError016);
+ raise EJclEDIError.CreateID(16);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError017);
+ raise EJclEDIError.CreateID(17);
FData := '';
FState := ediDisassembled;
@@ -1796,7 +1796,7 @@
InternalAlternateDelimitersDetection(StartPos);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError015);
+ raise EJclEDIError.CreateID(15);
// Continue
while (StartPos + Length(UNBSegmentId)) < Length(FData) do
@@ -1820,10 +1820,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError016);
+ raise EJclEDIError.CreateID(16);
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError017);
+ raise EJclEDIError.CreateID(17);
// Set next start position, Move past the delimiter
StartPos := SearchResult + FDelimiters.SDLen;
//
@@ -1847,7 +1847,7 @@
if foIgnoreGarbageAtEndOfFile in FEDIFileOptions then
Break
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError018);
+ raise EJclEDIError.CreateID(18);
end;
end;
FData := '';
@@ -1901,7 +1901,7 @@
end;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError001);
+ raise EJclEDIError.CreateID(1);
end;
procedure TEDIFile.LoadFromFile(const FileName: string);
@@ -1934,7 +1934,7 @@
end;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError002);
+ raise EJclEDIError.CreateID(2);
end;
procedure TEDIFile.SaveToFile;
@@ -1955,7 +1955,7 @@
end;
end
else
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError002);
+ raise EJclEDIError.CreateID(2);
end;
procedure TEDIFile.SetInterchangeControl(Index: Integer; Interchange: TEDIInterchangeControl);
@@ -1991,8 +1991,8 @@
for I := SearchResult downto 1 do
begin
Delimiter := Copy(FData, I, 1);
- if not (Delimiter[1] in
- AnsiLetters + AnsiDecDigits + [FDelimiters.ED[1], FDelimiters.SD[1]]) then
+ if not (AnsiChar(Delimiter[1]) in
+ AnsiLetters + AnsiDecDigits + [AnsiChar(FDelimiters.ED[1]), AnsiChar(FDelimiters.SD[1])]) then
begin
FDelimiters.SS := Copy(FData, I, 1);
Break;
@@ -2068,7 +2068,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError038);
+ raise EJclEDIError.CreateID(38);
end;
if GetCount > 0 then
@@ -2123,7 +2123,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- raise EJclEDIError.CreateRes({$IFNDEF CLR}@{$ENDIF}RsEDIError037);
+ raise EJclEDIError.CreateID(37);
end;
StartPos := 1;
SearchResult := StrSearch(FDelimiters.SS, FData, StartPos);
Modified: trunk/jcl/source/common/JclEDI_UNEDIFACT_Ext.pas
===================================================================
--- trunk/jcl/source/common/JclEDI_UNEDIFACT_Ext.pas 2007-11-30 19:24:18 UTC (rev 2242)
+++ trunk/jcl/source/common/JclEDI_UNEDIFACT_Ext.pas 2007-11-30 19:28:51 UTC (rev 2243)
@@ -226,9 +226,8 @@
for I := 0 to DataSegment.ElementCount - 1 do
begin
if I > J then
- raise EJclEDIError.CreateResFmt({$IFNDEF CLR}@{$ENDIF}RsEDIError058,
- [IntToStr(I), DataSegment.SegmentId,
- IntToStr(DataSegment.GetIndexPositionFromParent)]);
+ raise EJclEDIError.CreateIDFmt(58, [IntToStr(I), DataSegment.SegmentId,
+ IntToStr(DataSegment.GetIndexPositionFromParent)]);
DataSegment.EDIDataObject[I].SpecPointer := SpecSegment.Elements[I];
// ToDo: Assign SubElement Specs
end;
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2007-11-30 19:24:18 UTC (rev 2242)
+++ trunk/jcl/source/common/JclResources.pas 2007-11-30 19:28:51 UTC (rev 2243)
@@ -918,6 +918,32 @@
RsUnknownAttribute = 'Unknown Attribute';
+
+const
+ {$IFDEF CLR}
+ RsEDIErrors: array [1..58] of string =
+ ( RsEDIError001, RsEDIError002, RsEDIError003, RsEDIError004, RsEDIError005, RsEDIError006, RsEDIError007,
+ RsEDIError008, RsEDIError009, RsEDIError010, RsEDIError011, RsEDIError012, RsEDIError013, RsEDIError014,
+ RsEDIError015, RsEDIError016, RsEDIError017, RsEDIError018, RsEDIError019, RsEDIError020, RsEDIError021,
+ RsEDIError022, RsEDIError023, R...
[truncated message content] |
|
From: <ou...@us...> - 2007-11-30 20:33:15
|
Revision: 2247
http://jcl.svn.sourceforge.net/jcl/?rev=2247&view=rev
Author: outchy
Date: 2007-11-30 12:33:13 -0800 (Fri, 30 Nov 2007)
Log Message:
-----------
fixed C++ Header failure (duplicate constructor(int) )
removing other IFDEF CLR in EJclEDIError constructions
Modified Paths:
--------------
trunk/jcl/source/common/JclEDI.pas
trunk/jcl/source/common/JclEDISEF.pas
trunk/jcl/source/common/JclEDI_ANSIX12.pas
trunk/jcl/source/common/JclEDI_ANSIX12_Ext.pas
Modified: trunk/jcl/source/common/JclEDI.pas
===================================================================
--- trunk/jcl/source/common/JclEDI.pas 2007-11-30 19:33:03 UTC (rev 2246)
+++ trunk/jcl/source/common/JclEDI.pas 2007-11-30 20:33:13 UTC (rev 2247)
@@ -91,8 +91,8 @@
EJclEDIError = class(EJclError)
public
- constructor CreateID(ID: Integer);
- constructor CreateIDFmt(ID: Integer; const Args: array of const);
+ constructor CreateID(ID: Cardinal);
+ constructor CreateIDFmt(ID: Cardinal; const Args: array of const);
end;
// EDI Forward Class Declarations
@@ -537,7 +537,7 @@
//=== { EJclEDIError } =======================================================
-constructor EJclEDIError.CreateID(ID: Integer);
+constructor EJclEDIError.CreateID(ID: Cardinal);
begin
{$IFDEF CLR}
Create(RsEDIErrors[ID]);
@@ -546,7 +546,7 @@
{$ENDIF ~CLR}
end;
-constructor EJclEDIError.CreateIDFmt(ID: Integer; const Args: array of const);
+constructor EJclEDIError.CreateIDFmt(ID: Cardinal; const Args: array of const);
begin
{$IFDEF CLR}
Create(Format(RsEDIErrors[ID], Args));
@@ -700,11 +700,7 @@
if IndexIsValid(Index) then
FEDIDataObjects.Delete(Index)
else
- {$IFNDEF CLR}
- raise EJclEDIError.CreateResFmt(@RsEDIError010, [Self.ClassName, IntToStr(Index)]);
- {$ELSE}
- raise EJclEDIError.CreateFmt(RsEDIError010, [Self.ClassName, IntToStr(Index)]);
- {$ENDIF ~CLR}
+ raise EJclEDIError.CreateIDFmt(10, [Self.ClassName, IntToStr(Index)]);
end;
procedure TEDIDataObjectGroup.DeleteEDIDataObjects;
@@ -727,11 +723,7 @@
end;
end
else
- {$IFNDEF CLR}
- raise EJclEDIError.CreateResFmt(@RsEDIError011, [IntToStr(Index)]);
- {$ELSE}
- raise EJclEDIError.CreateFmt(RsEDIError011, [IntToStr(Index)]);
- {$ENDIF ~CLR}
+ raise EJclEDIError.CreateIDFmt(11, [IntToStr(Index)]);
end;
destructor TEDIDataObjectGroup.Destroy;
@@ -748,15 +740,15 @@
if Index <= FEDIDataObjects.Count - 1 then
begin
if not Assigned(FEDIDataObjects[Index]) then
- raise EJclEDIError.CreateFmt(RsEDIError006, [Self.ClassName, IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(6, [Self.ClassName, IntToStr(Index)]);
Result := FEDIDataObjects[Index];
end
else
- raise EJclEDIError.CreateFmt(RsEDIError005, [Self.ClassName, IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(5, [Self.ClassName, IntToStr(Index)])
else
- raise EJclEDIError.CreateFmt(RsEDIError004, [Self.ClassName, IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(4, [Self.ClassName, IntToStr(Index)])
else
- raise EJclEDIError.CreateFmt(RsEDIError003, [Self.ClassName, IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(3, [Self.ClassName, IntToStr(Index)]);
end;
function TEDIDataObjectGroup.IndexIsValid(Index: Integer): Boolean;
@@ -832,11 +824,11 @@
FEDIDataObjects[Index].Parent := Self;
end
else
- raise EJclEDIError.CreateFmt(RsEDIError009, [Self.ClassName, IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(9, [Self.ClassName, IntToStr(Index)])
else
- raise EJclEDIError.CreateFmt(RsEDIError008, [Self.ClassName, IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(8, [Self.ClassName, IntToStr(Index)])
else
- raise EJclEDIError.CreateFmt(RsEDIError007, [Self.ClassName, IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(7, [Self.ClassName, IntToStr(Index)]);
end;
function TEDIDataObjectGroup.GetIndexPositionFromParent: Integer;
@@ -1513,11 +1505,7 @@
Result := Low(FStack);
end
else
- {$IFNDEF CLR}
- raise EJclEDIError.CreateResFmt(@RsEDIError057, [IntToStr(Index)]);
- {$ELSE}
- raise EJclEDIError.CreateFmt(RsEDIError057, [IntToStr(Index)]);
- {$ENDIF ~CLR}
+ raise EJclEDIError.CreateIDFmt(57, [IntToStr(Index)]);
end;
function TEDILoopStack.GetSize: Integer;
@@ -1537,11 +1525,11 @@
if Index <= High(FStack) then
Result := FStack[Index]
else
- raise EJclEDIError.CreateFmt(RsEDIError054, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(54, [IntToStr(Index)])
else
- raise EJclEDIError.CreateFmt(RsEDIError055, [IntToStr(Index)])
+ raise EJclEDIError.CreateIDFmt(55, [IntToStr(Index)])
else
- raise EJclEDIError.CreateFmt(RsEDIError056, [IntToStr(Index)]);
+ raise EJclEDIError.CreateIDFmt(56, [IntToStr(Index)]);
end;
procedure TEDILoopStack.Pop(Index: Integer);
Modified: trunk/jcl/source/common/JclEDISEF.pas
===================================================================
--- trunk/jcl/source/common/JclEDISEF.pas 2007-11-30 19:33:03 UTC (rev 2246)
+++ trunk/jcl/source/common/JclEDISEF.pas 2007-11-30 20:33:13 UTC (rev 2247)
@@ -4079,11 +4079,7 @@
end;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError001);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError001);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(1);
end;
procedure TEDISEFFile.ParseTextSets;
@@ -4368,11 +4364,7 @@
end;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError002);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError002);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(2);
end;
procedure TEDISEFTable.Disassemble;
Modified: trunk/jcl/source/common/JclEDI_ANSIX12.pas
===================================================================
--- trunk/jcl/source/common/JclEDI_ANSIX12.pas 2007-11-30 19:33:03 UTC (rev 2246)
+++ trunk/jcl/source/common/JclEDI_ANSIX12.pas 2007-11-30 20:33:13 UTC (rev 2247)
@@ -748,11 +748,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError036);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError036);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(36);
end;
FData := FSegmentId;
@@ -805,11 +801,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError035);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError035);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(35);
end;
// Continue
StartPos := 1;
@@ -1047,11 +1039,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError026);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError026);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(26);
end;
FData := FSTSegment.Assemble;
@@ -1108,11 +1096,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError025);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError025);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(25);
end;
// Find the first segment
StartPos := 1;
@@ -1312,11 +1296,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError020);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError020);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(20);
end;
FData := FGSSegment.Assemble;
FGSSegment.Data := '';
@@ -1371,11 +1351,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError019);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError019);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(19);
end;
// Find Functional Group Header Segment
StartPos := 1;
@@ -1390,26 +1366,14 @@
FGSSegment.Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError021);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError021);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(21);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError022);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError022);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(22);
// Search for Transaction Set Header
SearchResult := StrSearch(FDelimiters.SD + TSHSegmentId + FDelimiters.ED, FData, StartPos);
if SearchResult <= 0 then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError027);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError027);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(27);
// Set next start position
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Continue
@@ -1431,18 +1395,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError028);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError028);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(28);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError029);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError029);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(29);
// Set the next start position
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
//
@@ -1465,18 +1421,10 @@
FGESegment.Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError023);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError023);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(23);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError024);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError024);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(24);
FData := '';
FState := ediDisassembled;
end;
@@ -1632,11 +1580,7 @@
Result := '';
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError013);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError013);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(13);
FData := FISASegment.Assemble;
FISASegment.Data := '';
@@ -1687,11 +1631,7 @@
DeleteFunctionalGroups;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError012);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError012);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(12);
StartPos := 1;
// Search for Interchange Control Header
@@ -1704,18 +1644,10 @@
FISASegment.Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError014);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError014);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(14);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError015);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError015);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(15);
// Search for Functional Group Header
SearchResult := StrSearch(FDelimiters.SD + FGHSegmentId + FDelimiters.ED, FData, StartPos);
// Check for TA1 Segment
@@ -1726,11 +1658,7 @@
SearchResult := I;
end;
if (SearchResult <= 0) and (not ProcessTA1) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError022);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError022);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(22);
// Set next start positon
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Continue
@@ -1754,18 +1682,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError023);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError023);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(23);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError024);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError024);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(24);
// Set next start positon
StartPos := SearchResult + FDelimiters.SDLen; // Move past the delimiter
// Verify the next record is a Functional Group Header
@@ -1812,18 +1732,10 @@
FIEASegment.Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError016);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError016);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(16);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError017);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError017);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(17);
FData := '';
FState := ediDisassembled;
end;
@@ -2042,11 +1954,7 @@
InternalDelimitersDetection(StartPos);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError015);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError015);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(15);
// Continue
while (StartPos + Length(ICHSegmentId)) < Length(FData) do
begin
@@ -2067,18 +1975,10 @@
FEDIDataObjects[I].Disassemble;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError016);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError016);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(16);
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError017);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError017);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(17);
// Set next start position, Move past the delimiter
StartPos := SearchResult + FDelimiters.SDLen;
// Verify the next record is an Interchange Control Header
@@ -2096,11 +1996,7 @@
if foIgnoreGarbageAtEndOfFile in FEDIFileOptions then
Break
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError018);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError018);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(18);
end;
end;
FData := '';
@@ -2171,11 +2067,7 @@
end;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError001);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError001);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(1);
end;
procedure TEDIFile.LoadFromFile(const FileName: string);
@@ -2209,11 +2101,7 @@
end;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError002);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError002);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(2);
end;
procedure TEDIFile.SaveToFile;
@@ -2234,11 +2122,7 @@
end;
end
else
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError002);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError002);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(2);
end;
procedure TEDIFile.SetInterchangeControl(Index: Integer; Interchange: TEDIInterchangeControl);
@@ -2723,11 +2607,7 @@
begin
FDelimiters := InternalAssignDelimiters;
if not Assigned(FDelimiters) then
- {$IFDEF CLR}
- raise EJclEDIError.Create(RsEDIError035);
- {$ELSE}
- raise EJclEDIError.CreateRes(@RsEDIError035);
- {$ENDIF CLR}
+ raise EJclEDIError.CreateID(35);
end;
SearchResult := StrSearch(FDelimiters.ED + FDelimiters.SS, FData, 1);
if SearchResult <> 0 then
@@ -3237,12 +3117,7 @@
for I := 0 to DataSegment.ElementCount - 1 do
begin
if I > J then
- {$IFDEF CLR}
- raise EJclEDIError.CreateFmt(RsEDIError002,
- {$ELSE}
- raise EJclEDIError.CreateResFmt(@RsEDIError058,
- {$ENDIF CLR}
- [IntToStr(I), DataSegment.SegmentID,
+ raise EJclEDIError.CreateIDFmt(58, [IntToStr(I), DataSegment.SegmentID,
IntToStr(DataSegment.GetIndexPositionFromParent)]);
DataSegment.Element[I].SpecPointer := SpecSegment.Element[I];
end;
Modified: trunk/jcl/source/common/JclEDI_ANSIX12_Ext.pas
===================================================================
--- trunk/jcl/source/common/JclEDI_ANSIX12_Ext.pas 2007-11-30 19:33:03 UTC (rev 2246)
+++ trunk/jcl/source/common/JclEDI_ANSIX12_Ext.pas 2007-11-30 20:33:13 UTC (rev 2247)
@@ -222,12 +222,7 @@
for I := 0 to DataSegment.ElementCount - 1 do
begin
if I > J then
- {$IFDEF CLR}
- raise EJclEDIError.CreateFmt(RsEDIError058,
- {$ELSE}
- raise EJclEDIError.CreateResFmt(@RsEDIError058,
- {$ENDIF CLR}
- [IntToStr(I), DataSegment.SegmentId,
+ raise EJclEDIError.CreateIDFmt(58, [IntToStr(I), DataSegment.SegmentId,
IntToStr(DataSegment.GetIndexPositionFromParent)]);
DataSegment.Element[I].SpecPointer := SpecSegment.Elements[I];
end;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jed...@us...> - 2007-12-01 15:51:15
|
Revision: 2257
http://jcl.svn.sourceforge.net/jcl/?rev=2257&view=rev
Author: jedi_mbe
Date: 2007-12-01 07:51:06 -0800 (Sat, 01 Dec 2007)
Log Message:
-----------
Added TJclTabSet and support routines
Modified Paths:
--------------
trunk/jcl/source/common/JclResources.pas
trunk/jcl/source/common/JclStrings.pas
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2007-12-01 13:28:55 UTC (rev 2256)
+++ trunk/jcl/source/common/JclResources.pas 2007-12-01 15:51:06 UTC (rev 2257)
@@ -1700,6 +1700,14 @@
RsArgumentIsNull = 'Argument %d is null';
RsDotNetFormatArgumentNotSupported = 'Argument type of %d is not supported';
RsArgumentOutOfRange = 'Argument out of range';
+ RsTabs_DuplicatesNotAllowed = 'Duplicate tab stops are not allowed.';
+ RsTabs_StopExpected = 'A tab stop was expected but not found.';
+ RsTabs_CloseBracketExpected = 'Closing bracket expected.';
+ RsTabs_TabWidthExpected = 'Tab width expected.';
+{$IFNDEF CLR}
+ // Default text for the NullReferenceException in .NET
+ RsArg_NullReferenceException = 'Object reference not set to an instance of an object.';
+{$ENDIF ~CLR}
//=== JclStructStorage =======================================================
resourcestring
Modified: trunk/jcl/source/common/JclStrings.pas
===================================================================
--- trunk/jcl/source/common/JclStrings.pas 2007-12-01 13:28:55 UTC (rev 2256)
+++ trunk/jcl/source/common/JclStrings.pas 2007-12-01 15:51:06 UTC (rev 2257)
@@ -26,6 +26,7 @@
{ Jean-Fabien Connault (cycocrew) }
{ John C Molyneux }
{ Leonard Wennekers }
+{ Martin Bestebroer }
{ Martin Kimmings }
{ Martin Kubecka }
{ Massimo Maria Ghisalberti }
@@ -482,6 +483,97 @@
{$ENDIF CLR}
+// TJclTabSet
+type
+ TJclTabSet = class {$IFNDEF CLR}(TInterfacedObject, IToString){$ENDIF}
+ private
+ FStops: TDynIntegerArray;
+ FRealWidth: Integer;
+ FWidth: Integer;
+ FZeroBased: Boolean;
+ procedure CalcRealWidth;
+ function GetCount: Integer;
+ function GetStops(Index: Integer): Integer;
+ function GetTabWidth: Integer;
+ function GetZeroBased: Boolean;
+ procedure SetStops(Index, Value: Integer);
+ procedure SetTabWidth(Value: Integer);
+ procedure SetZeroBased(Value: Boolean);
+ protected
+ function FindStop(Column: Integer): Integer;
+ function InternalTabStops: TDynIntegerArray;
+ function InternalTabWidth: Integer;
+ procedure RemoveAt(Index: Integer);
+ public
+ constructor Create; overload;
+ constructor Create(TabWidth: Integer); overload;
+ constructor Create(Tabstops: array of Integer; ZeroBased: Boolean); overload;
+ constructor Create(Tabstops: array of Integer; ZeroBased: Boolean; TabWidth: Integer); overload;
+
+ // Tab stops manipulation
+ function Add(Column: Integer): Integer;
+ function Delete(Column: Integer): Integer;
+
+ // Usage
+ function Expand(S: string): string; overload;
+ function Expand(S: string; Column: Integer): string; overload;
+ procedure OptimalFillInfo(StartColumn, TargetColumn: Integer; out TabsNeeded, SpacesNeeded: Integer);
+ function Optimize(S: string): string; overload;
+ function Optimize(S: string; Column: Integer): string; overload;
+ function StartColumn: Integer;
+ function TabFrom(Column: Integer): Integer;
+ function UpdatePosition(S: string): Integer; overload;
+ function UpdatePosition(S: string; Column: Integer): Integer; overload;
+ function UpdatePosition(S: string; var Column, Line: Integer): Integer; overload;
+
+ // Conversions
+ class function FromString(S: string): TJclTabSet; {$IFDEF SUPPORTS_STATIC}static; {$ENDIF}
+ function ToString: string; {$IFDEF CLR}override; {$ENDIF}overload;
+ function ToString(FormattingOptions: Integer): string; overload;
+
+ // Properties
+ property ActualTabWidth: Integer read InternalTabWidth;
+ property Count: Integer read GetCount;
+ property TabStops[&Index: Integer]: Integer read GetStops write SetStops; default;
+ property TabWidth: Integer read GetTabWidth write SetTabWidth;
+ property ZeroBased: Boolean read GetZeroBased write SetZeroBased;
+ end;
+
+// Formatting constants
+const
+ TabSetFormatting_SurroundStopsWithBrackets = 1;
+ TabSetFormatting_EmptyBracketsIfNoStops = 2;
+ TabSetFormatting_NoTabStops = 4;
+ TabSetFormatting_NoTabWidth = 8;
+ TabSetFormatting_AutoTabWidth = 16;
+ // common combinations
+ TabSetFormatting_Default = 0;
+ TabSetFormatting_AlwaysUseBrackets = TabSetFormatting_SurroundStopsWithBrackets or
+ TabSetFormatting_EmptyBracketsIfNoStops;
+ TabSetFormatting_Full = TabSetFormatting_AlwaysUseBrackets or TabSetFormatting_AutoTabWidth;
+ // aliases
+ TabSetFormatting_StopsOnly = TabSetFormatting_NoTabWidth;
+ TabSetFormatting_TabWidthOnly = TabSetFormatting_NoTabStops;
+ TabSetFormatting_StopsWithoutBracketsAndTabWidth = TabSetFormatting_Default;
+
+// Tab expansion routines
+function StrExpandTabs(S: string): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF}overload;
+function StrExpandTabs(S: string; TabWidth: Integer): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF}overload;
+function StrExpandTabs(S: string; TabSet: TJclTabSet): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF}overload;
+// Tab optimization routines
+function StrOptimizeTabs(S: string): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF}overload;
+function StrOptimizeTabs(S: string; TabWidth: Integer): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF}overload;
+function StrOptimizeTabs(S: string; TabSet: TJclTabSet): string; {$IFDEF SUPPORTS_INLINE}inline; {$ENDIF}overload;
+
+{$IFNDEF CLR}
+// move to JclBase?
+type
+ NullReferenceException = class (EJclError)
+ public
+ constructor Create; overload;
+ end;
+{$ENDIF ~CLR}
+
// Exceptions
type
EJclStringError = EJclError;
@@ -5023,6 +5115,728 @@
end;
{$ENDIF CLR}
+function StrExpandTabs(S: string): string;
+begin
+ // use an empty tab set, which will default to a tab width of 2
+ Result := TJclTabSet(nil).Expand(s);
+end;
+
+function StrExpandTabs(S: string; TabWidth: Integer): string;
+var
+ TabSet: TJclTabSet;
+begin
+ // create a tab set with no tab stops and the given tab width
+ TabSet := TJclTabSet.Create(TabWidth);
+ try
+ Result := TabSet.Expand(S);
+ finally
+ TabSet.Free;
+ end;
+end;
+
+function StrExpandTabs(S: string; TabSet: TJclTabSet): string;
+begin
+ // use the provided tab set to perform the expansion
+ Result := TabSet.Expand(S);
+end;
+
+function StrOptimizeTabs(S: string): string;
+begin
+ // use an empty tab set, which will default to a tab width of 2
+ Result := TJclTabSet(nil).Optimize(s);
+end;
+
+function StrOptimizeTabs(S: string; TabWidth: Integer): string;
+var
+ TabSet: TJclTabSet;
+begin
+ // create a tab set with no tab stops and the given tab width
+ TabSet := TJclTabSet.Create(TabWidth);
+ try
+ Result := TabSet.Optimize(S);
+ finally
+ TabSet.Free;
+ end;
+end;
+
+function StrOptimizeTabs(S: string; TabSet: TJclTabSet): string;
+begin
+ // use the provided tab set to perform the optimization
+ Result := TabSet.Optimize(S);
+end;
+
+//=== { TJclTabSet } =====================================================
+
+constructor TJclTabSet.Create;
+begin
+ // no tab stops, tab width set to auto
+ Create([], True, 0);
+end;
+
+constructor TJclTabSet.Create(TabWidth: Integer);
+begin
+ // no tab stops, specified tab width
+ Create([], True, TabWidth);
+end;
+
+constructor TJclTabSet.Create(Tabstops: array of Integer; ZeroBased: Boolean);
+begin
+ // specified tab stops, tab width equal to distance between last two tab stops
+ Create(Tabstops, ZeroBased, 0);
+end;
+
+constructor TJclTabSet.Create(Tabstops: array of Integer; ZeroBased: Boolean; TabWidth: Integer);
+var
+ idx: Integer;
+begin
+ inherited Create;
+ for idx := 0 to High(Tabstops) do
+ Add(Tabstops[idx]);
+ FWidth := TabWidth;
+ FZeroBased := ZeroBased;
+ CalcRealWidth;
+end;
+
+function TJclTabSet.Add(Column: Integer): Integer;
+begin
+ if Self = nil then
+ raise NullReferenceException.Create;
+ if Column < StartColumn then
+ raise ArgumentOutOfRangeException.Create('Column');
+ Result := FindStop(Column);
+ if Result < 0 then
+ begin
+ // the column doesn't exist; invert the result of FindStop to get the correct index position
+ Result := not Result;
+ // increase the tab stop array
+ SetLength(FStops, Length(FStops) + 1);
+ // make room at the insert position
+ MoveArray(FStops, Result, Result + 1, High(FStops) - Result);
+ // add the tab stop at the correct location
+ FStops[Result] := Column;
+ CalcRealWidth;
+ end
+ else
+ begin
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsTabs_DuplicatesNotAllowed);
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsTabs_DuplicatesNotAllowed);
+ {$ENDIF}
+ end;
+end;
+
+procedure TJclTabSet.CalcRealWidth;
+begin
+ if FWidth < 1 then
+ begin
+ if Length(FStops) > 1 then
+ FRealWidth := FStops[High(FStops)] - FStops[Pred(High(FStops))]
+ else
+ if Length(FStops) = 1 then
+ FRealWidth := FStops[0]
+ else
+ FRealWidth := 2;
+ end
+ else
+ FRealWidth := FWidth;
+end;
+
+function TJclTabSet.Delete(Column: Integer): Integer;
+begin
+ Result := FindStop(Column);
+ if Result >= 0 then
+ RemoveAt(Result);
+end;
+
+function TJclTabSet.Expand(S: string): string;
+begin
+ Result := Expand(s, StartColumn);
+end;
+
+function TJclTabSet.Expand(S: string; Column: Integer): string;
+var
+ sb: TStringBuilder;
+ head: PChar;
+ cur: PChar;
+begin
+ if Column < StartColumn then
+ raise ArgumentOutOfRangeException.Create('Column');
+ sb := TStringBuilder.Create(Length(S));
+ try
+ cur := PChar(S);
+ while cur^ <> #0 do
+ begin
+ head := cur;
+ while (cur^<> #0) and (cur^ <> #9) do
+ begin
+ if cur^ in [#10, #13] then
+ Column := StartColumn
+ else
+ Inc(Column);
+ Inc(cur);
+ end;
+ if cur > head then
+ sb.Append(head, 0, cur - head);
+ if cur^ = #9 then
+ begin
+ sb.Append(' ', TabFrom(Column) - Column);
+ Column := TabFrom(Column);
+ Inc(cur);
+ end;
+ end;
+ Result := sb.ToString;
+ finally
+ sb.Free;
+ end;
+end;
+
+function TJclTabSet.FindStop(Column: Integer): Integer;
+begin
+ if Self <> nil then
+ begin
+ Result := High(FStops);
+ while (Result >= 0) and (FStops[Result] > Column) do
+ Dec(Result);
+ if (Result >= 0) and (FStops[Result] <> Column) then
+ Result := not Succ(Result);
+ end
+ else
+ Result := -1;
+end;
+
+class function TJclTabSet.FromString(S: string): TJclTabSet;
+var
+ cur: PChar;
+
+ procedure SkipWhiteSpace;
+ begin
+ while CharIsWhiteSpace(cur^) do
+ Inc(cur);
+ end;
+
+ function ParseNumber: Integer;
+ var
+ head: PChar;
+ begin
+ SkipWhiteSpace;
+ head := cur;
+ while cur^ in ['0'..'9'] do
+ Inc(cur);
+ if (cur <= head) or not TryStrToInt(Copy(head, 1, cur - head), Result) then
+ Result := -1;
+ end;
+
+ procedure ParseStops;
+ var
+ openBracket: Boolean;
+ num: Integer;
+ hadComma: Boolean;
+ begin
+ SkipWhiteSpace;
+ openBracket := cur^ = '[';
+ hadComma := False;
+ if openBracket then
+ Inc(cur);
+ repeat
+ num := ParseNumber;
+ if (num < 0) and hadComma then
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsTabs_StopExpected)
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsTabs_StopExpected)
+ {$ENDIF}
+ else
+ if num >= 0 then
+ Result.Add(num);
+ SkipWhiteSpace;
+ hadComma := cur^ = ',';
+ if hadComma then
+ Inc(cur);
+ until (cur^ in [#0, '+', ']']);
+ if hadComma then
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsTabs_StopExpected)
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsTabs_StopExpected)
+ {$ENDIF}
+ else
+ if openBracket and (cur^ <> ']') then
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsTabs_CloseBracketExpected)
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsTabs_CloseBracketExpected)
+ {$ENDIF}
+ end;
+
+ procedure ParseTabWidth;
+ var
+ num: Integer;
+ begin
+ SkipWhiteSpace;
+ if cur^ = '+' then
+ begin
+ Inc(cur);
+ SkipWhiteSpace;
+ num := ParseNumber;
+ if (num < 0) then
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsTabs_TabWidthExpected)
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsTabs_TabWidthExpected)
+ {$ENDIF}
+ else
+ Result.TabWidth := num;
+ end;
+ end;
+
+ procedure ParseZeroBasedFlag;
+ begin
+ SkipWhiteSpace;
+ if cur^ = '0' then
+ begin
+ Inc(cur);
+ if CharIsWhiteSpace(cur^) or (cur^ in [#0, '[']) then
+ begin
+ Result.ZeroBased := True;
+ SkipWhiteSpace;
+ end
+ else
+ Dec(cur);
+ end;
+ end;
+
+begin
+ Result := TJclTabSet.Create;
+ try
+ Result.ZeroBased := False;
+ cur := PChar(S);
+ ParseZeroBasedFlag;
+ ParseStops;
+ ParseTabWidth;
+ except
+ // clean up the partially complete instance (to avoid memory leaks)...
+ Result.Free;
+ // ... and re-raise the exception
+ raise;
+ end;
+end;
+
+function TJclTabSet.GetCount: Integer;
+begin
+ if Self <> nil then
+ Result := Length(FStops)
+ else
+ Result := 0;
+end;
+
+function TJclTabSet.GetStops(Index: Integer): Integer;
+begin
+ if Self <> nil then
+ begin
+ if (Index < 0) or (Index >= Length(FStops)) then
+ begin
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsArgumentOutOfRange);
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsArgumentOutOfRange);
+ {$ENDIF CLR}
+ end
+ else
+ Result := FStops[Index]
+ end
+ else
+ begin
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsArgumentOutOfRange);
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsArgumentOutOfRange);
+ {$ENDIF CLR}
+ end;
+end;
+
+function TJclTabSet.GetTabWidth: Integer;
+begin
+ if Self <> nil then
+ Result := FWidth
+ else
+ Result := 0;
+end;
+
+function TJclTabSet.GetZeroBased: Boolean;
+begin
+ Result := (Self = nil) or FZeroBased;
+end;
+
+procedure TJclTabSet.OptimalFillInfo(StartColumn, TargetColumn: Integer; out TabsNeeded, SpacesNeeded: Integer);
+var
+ nextTab: Integer;
+begin
+ if StartColumn < Self.StartColumn then // starting column less than 1 or 0 (depending on ZeroBased state)
+ raise ArgumentOutOfRangeException.Create('StartColumn');
+ if (TargetColumn < StartColumn) then // target lies before the starting column
+ raise ArgumentOutOfRangeException.Create('TargetColumn');
+ TabsNeeded := 0;
+ repeat
+ nextTab := TabFrom(StartColumn);
+ if nextTab <= TargetColumn then
+ begin
+ Inc(TabsNeeded);
+ StartColumn := nextTab;
+ end;
+ until nextTab > TargetColumn;
+ SpacesNeeded := TargetColumn - StartColumn;
+end;
+
+function TJclTabSet.Optimize(S: string): string;
+begin
+ Result := Optimize(S, StartColumn);
+end;
+
+function TJclTabSet.Optimize(S: string; Column: Integer): string;
+var
+ sb: TStringBuilder;
+ head: PChar;
+ cur: PChar;
+ tgt: Integer;
+
+ procedure AppendOptimalWhiteSpace(Target: Integer);
+ var
+ tabCount: Integer;
+ spaceCount: Integer;
+ begin
+ if cur > head then
+ begin
+ OptimalFillInfo(Column, Target, tabCount, spaceCount);
+ if tabCount > 0 then
+ sb.Append(#9, tabCount);
+ if spaceCount > 0 then
+ sb.Append(' ', spaceCount);
+ end;
+ end;
+
+begin
+ if Column < StartColumn then
+ raise ArgumentOutOfRangeException.Create('Column');
+ sb := TStringBuilder.Create(Length(S));
+ try
+ cur := PChar(s);
+ while cur^<> #0 do
+ begin
+ // locate first whitespace character
+ head := cur;
+ while (cur^ <> #0) and not CharIsWhiteSpace(cur^) do
+ Inc(cur);
+ // output non whitespace characters
+ if cur > head then
+ sb.Append(head, 0, cur - head);
+ // advance column
+ Inc(Column, cur - head);
+ // initialize target column indexer
+ tgt := Column;
+ // locate end of whitespace sequence
+ while CharIsWhiteSpace(cur^) do
+ begin
+ if cur^ in [AnsiLineFeed, AnsiCarriageReturn] then
+ begin
+ // append optimized whitespace sequence...
+ AppendOptimalWhiteSpace(tgt);
+ // ...set the column back to the start of the line...
+ Column := StartColumn;
+ // ...reset target column indexer...
+ tgt := Column;
+ // ...add the line break character...
+ sb.Append(cur^);
+ end
+ else
+ if cur^ = #9 then
+ tgt := TabFrom(tgt) // expand the tab
+ else
+ Inc(tgt); // a normal whitespace; taking up 1 column
+ Inc(cur);
+ end;
+ AppendOptimalWhiteSpace(tgt); // append optimized whitespace sequence...
+ Column := tgt; // ...and memorize the column for the next iteration
+ end;
+ Result := sb.ToString; // convert result to a string
+ finally
+ sb.Free;
+ end;
+end;
+
+procedure TJclTabSet.RemoveAt(Index: Integer);
+begin
+ if Self <> nil then
+ begin
+ MoveArray(FStops, Succ(Index), Index, High(FStops) - Index);
+ SetLength(FStops, High(FStops));
+ CalcRealWidth;
+ end
+ else
+ raise NullReferenceException.Create;
+end;
+
+procedure TJclTabSet.SetStops(Index, Value: Integer);
+var
+ temp: Integer;
+begin
+ if Self <> nil then
+ begin
+ if (Index < 0) or (Index >= Length(FStops)) then
+ begin
+ {$IFDEF CLR}
+ raise ArgumentOutOfRangeException.Create;
+ {$ELSE}
+ raise ArgumentOutOfRangeException.CreateRes(@RsArgumentOutOfRange);
+ {$ENDIF CLR}
+ end
+ else
+ begin
+ temp := FindStop(Value);
+ if temp < 0 then
+ begin
+ // remove existing tab stop...
+ RemoveAt(Index);
+ // now add the new tab stop
+ Add(Value);
+ end
+ else
+ if temp <> Index then
+ begin
+ // new tab stop already present at another index
+ {$IFDEF CLR}
+ raise EJclStringError.Create(RsTabs_DuplicatesNotAllowed);
+ {$ELSE}
+ raise EJclStringError.CreateRes(@RsTabs_DuplicatesNotAllowed);
+ {$ENDIF}
+ end;
+ end;
+ end
+ else
+ raise NullReferenceException.Create;
+end;
+
+procedure TJclTabSet.SetTabWidth(Value: Integer);
+begin
+ if Self <> nil then
+ begin
+ FWidth := Value;
+ CalcRealWidth;
+ end
+ else
+ raise NullReferenceException.Create;
+end;
+
+procedure TJclTabSet.SetZeroBased(Value: Boolean);
+var
+ shift: Integer;
+ idx: Integer;
+begin
+ if Self <> nil then
+ begin
+ if Value <> FZeroBased then
+ begin
+ FZeroBased := Value;
+ if Value then
+ shift := -1
+ else
+ shift := 1;
+ for idx := 0 to High(FStops) do
+ FStops[idx] := FStops[idx] + shift;
+ end;
+ end
+ else
+ raise NullReferenceException.Create;
+end;
+
+function TJclTabSet.InternalTabStops: TDynIntegerArray;
+begin
+ if Self <> nil then
+ Result := FStops
+ else
+ Result := nil;
+end;
+
+function TJclTabSet.InternalTabWidth: Integer;
+begin
+ if Self <> nil then
+ Result := FRealWidth
+ else
+ Result := 2;
+end;
+
+function TJclTabSet.StartColumn: Integer;
+begin
+ if GetZeroBased then
+ Result := 0
+ else
+ Result := 1;
+end;
+
+function TJclTabSet.TabFrom(Column: Integer): Integer;
+begin
+ if Column < StartColumn then
+ raise ArgumentOutOfRangeException.Create('Column');
+ Result := FindStop(Column);
+ if Result < 0 then
+ Result := not Result
+ else
+ Inc(Result);
+ if Result >= GetCount then
+ begin
+ if GetCount > 0 then
+ Result := FStops[High(FStops)]
+ else
+ Result := StartColumn;
+ while Result <= Column do
+ Inc(Result, ActualTabWidth);
+ end
+ else
+ Result := FStops[Result];
+end;
+
+function TJclTabSet.ToString: string;
+begin
+ Result := ToString(TabSetFormatting_Full);
+end;
+
+function TJclTabSet.ToString(FormattingOptions: Integer): string;
+var
+ sb: TStringBuilder;
+ idx: Integer;
+
+ function WantBrackets: Boolean;
+ begin
+ Result := (TabSetFormatting_SurroundStopsWithBrackets and FormattingOptions) <> 0;
+ end;
+
+ function EmptyBrackets: Boolean;
+ begin
+ Result := (TabSetFormatting_EmptyBracketsIfNoStops and FormattingOptions) <> 0;
+ end;
+
+ function IncludeAutoWidth: Boolean;
+ begin
+ Result := (TabSetFormatting_AutoTabWidth and FormattingOptions) <> 0;
+ end;
+
+ function IncludeTabWidth: Boolean;
+ begin
+ Result := (TabSetFormatting_NoTabWidth and FormattingOptions) = 0;
+ end;
+
+ function IncludeStops: Boolean;
+ begin
+ Result := (TabSetFormatting_NoTabStops and FormattingOptions) = 0;
+ end;
+
+begin
+ sb := TStringBuilder.Create;
+ try
+ // output the fixed tabulation positions if requested...
+ if IncludeStops then
+ begin
+ // output each individual tabulation position
+ for idx := 0 to GetCount - 1 do
+ begin
+ sb.Append(TabStops[idx]);
+ sb.Append(',');
+ end;
+ // remove the final comma if any tabulation positions where outputted
+ if sb.Length <> 0 then
+ sb.Remove(sb.Length - 1, 1);
+ // bracket the tabulation positions if requested
+ if WantBrackets and (EmptyBrackets or (sb.Length > 0)) then
+ begin
+ sb.Insert(0, '[');
+ sb.Append(']');
+ end;
+ end;
+ // output the tab width if requested....
+ if IncludeTabWidth and (IncludeAutoWidth or (TabWidth > 0)) then
+ begin
+ // separate the tab width from any outputted tabulation positions with a whitespace
+ if sb.Length > 0 then
+ sb.Append(' ');
+ // flag tab width
+ sb.Append('+');
+ // finally, output the tab width
+ sb.Append(ActualTabWidth);
+ end;
+ // flag zero-based tabset by outputting a 0 (zero) as the first character.
+ if ZeroBased then
+ sb.Insert(0, '0 ');
+ Result := StrTrimCharRight(sb.ToString, ' ');
+ finally
+ sb.Free;
+ end;
+end;
+
+function TJclTabSet.UpdatePosition(S: string): Integer;
+var
+ lines: Integer;
+begin
+ Result := StartColumn;
+ UpdatePosition(S, Result, lines);
+end;
+
+function TJclTabSet.UpdatePosition(S: string; Column: Integer): Integer;
+var
+ lines: Integer;
+begin
+ if Column < StartColumn then
+ raise ArgumentOutOfRangeException.Create('Column');
+ Result := Column;
+ UpdatePosition(S, Result, lines);
+end;
+
+function TJclTabSet.UpdatePosition(S: string; var Column, Line: Integer): Integer;
+var
+ prevChar: Char;
+ cur: PChar;
+begin
+ if Column < StartColumn then
+ raise ArgumentOutOfRangeException.Create('Column');
+ // initialize loop
+ cur := PChar(S);
+ // iterate until end of string (the Null-character)
+ while cur^ <> #0 do
+ begin
+ // check for line-breaking characters
+ if cur^ in [#10, #13] then
+ begin
+ // Column moves back all the way to the left
+ Column := StartColumn;
+ // If this is the first line-break character or the same line-break character, increment the Line parameter
+ Inc(Line);
+ // check if it's the first of a two-character line-break
+ prevChar := cur^;
+ Inc(cur);
+ // if it isn't a two-character line-break, undo the previous advancement
+ if not (cur^ in [#10, #13]) or (cur^ = prevChar) then
+ Dec(cur);
+ end
+ else // check for tab character and expand it
+ if cur^ = #9 then
+ Column := TabFrom(Column)
+ else // a normal character; increment column
+ Inc(Column);
+ // advance pointer
+ Inc(cur);
+ end;
+ // set the result to the newly calculated column
+ Result := Column;
+end;
+
+{$IFNDEF CLR}
+{ NullReferenceException }
+
+constructor NullReferenceException.Create;
+begin
+ CreateRes(@RsArg_NullReferenceException);
+end;
+{$ENDIF ~CLR}
+
{$IFDEF CLR}
{$IFDEF UNITVERSIONING}
initialization
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2008-01-17 21:11:13
|
Revision: 2311
http://jcl.svn.sourceforge.net/jcl/?rev=2311&view=rev
Author: outchy
Date: 2008-01-17 13:11:10 -0800 (Thu, 17 Jan 2008)
Log Message:
-----------
updated to latest specifications.
Modified Paths:
--------------
trunk/jcl/source/common/JclResources.pas
trunk/jcl/source/common/JclSysInfo.pas
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2008-01-15 22:40:58 UTC (rev 2310)
+++ trunk/jcl/source/common/JclResources.pas 2008-01-17 21:11:10 UTC (rev 2311)
@@ -1798,6 +1798,7 @@
RsIntelCacheDescr86 = '2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size';
RsIntelCacheDescr87 = '2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size';
RsIntelCacheDescrB0 = 'Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries';
+ RsIntelCacheDescrB1 = 'Instruction TLB: 2 MByte pages, 4-way, 8 entries or 4 MByte pages, 4-way, 4 entries';
RsIntelCacheDescrB3 = 'Data TLB: 4 KByte pages, 4-way set associative, 128 entries';
RsIntelCacheDescrB4 = 'Data TLB1: 4 KByte pages, 4-way set associative, 256 entries';
RsIntelCacheDescrF0 = '64-Byte Prefetching';
Modified: trunk/jcl/source/common/JclSysInfo.pas
===================================================================
--- trunk/jcl/source/common/JclSysInfo.pas 2008-01-15 22:40:58 UTC (rev 2310)
+++ trunk/jcl/source/common/JclSysInfo.pas 2008-01-17 21:11:10 UTC (rev 2311)
@@ -617,7 +617,7 @@
EINTEL_MONITOR = BIT_3; // Monitor/MWAIT
EINTEL_DSCPL = BIT_4; // CPL Qualified debug Store
EINTEL_VMX = BIT_5; // Virtual Machine Technology
- EINTEL_BIT_6 = BIT_6; // Reserved, do not count on value
+ EINTEL_SMX = BIT_6; // Safer Mode Extensions
EINTEL_EST = BIT_7; // Enhanced Intel Speedstep technology
EINTEL_TM2 = BIT_8; // Thermal monitor 2
EINTEL_SSSE3 = BIT_9; // SSSE 3 extensions
@@ -629,7 +629,7 @@
EINTEL_PDCM = BIT_15; // Perf/Debug Capability MSR
EINTEL_BIT_16 = BIT_16; // Reserved, do not count on value
EINTEL_BIT_17 = BIT_17; // Reserved, do not count on value
- EINTEL_BIT_18 = BIT_18; // Reserved, do not count on value
+ EINTEL_DCA = BIT_18; // Direct Cache Access
EINTEL_SSE4_1 = BIT_19; // Streaming SIMD Extensions 4.1
EINTEL_SSE4_2 = BIT_20; // Streaming SIMD Extensions 4.2
EINTEL_BIT_21 = BIT_21; // Reserved, do not count on value
@@ -1155,7 +1155,7 @@
MXCSR_FZ = BIT_15; // Flush to Zero
const
- IntelCacheDescription: array [0..63] of TCacheInfo = (
+ IntelCacheDescription: array [0..64] of TCacheInfo = (
(D: $00; Family: cfOther; I: RsIntelCacheDescr00),
(D: $01; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 4; Entries: 32; I: RsIntelCacheDescr01),
(D: $02; Family: cfInstructionTLB; Size: 4096; WaysOfAssoc: 4; Entries: 2; I: RsIntelCacheDescr02),
@@ -1216,6 +1216,7 @@
(D: $86; Family: cfL2Cache; Size: 512; WaysOfAssoc: 4; LineSize: 64; I: RsIntelCacheDescr86),
(D: $87; Family: cfL2Cache; Size: 1024; WaysOfAssoc: 8; LineSize: 64; I: RsIntelCacheDescr87),
(D: $B0; Family: cfInstructionTLB; Size: 4; WaysOfAssoc: 4; Entries: 128; I: RsIntelCacheDescrB0),
+ (D: $B1; Family: cfInstructionTLB; Size: 2048; WaysOfAssoc: 4; Entries: 8; I: RsIntelCacheDescrB1),
(D: $B3; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; Entries: 128; I: RsIntelCacheDescrB3),
(D: $B4; Family: cfDataTLB; Size: 4; WaysOfAssoc: 4; Entries: 256; I: RsIntelCacheDescrB4),
(D: $F0; Family: cfOther; I: RsIntelCacheDescrF0),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2008-02-03 19:03:07
|
Revision: 2340
http://jcl.svn.sourceforge.net/jcl/?rev=2340&view=rev
Author: outchy
Date: 2008-02-03 11:03:05 -0800 (Sun, 03 Feb 2008)
Log Message:
-----------
Ensure 7z.dll is loaded (when dynamically linked) before calling Sevenzip.CreateObject, otherwise a null access violation will happen.
Modified Paths:
--------------
trunk/jcl/source/common/JclCompression.pas
trunk/jcl/source/common/JclResources.pas
Modified: trunk/jcl/source/common/JclCompression.pas
===================================================================
--- trunk/jcl/source/common/JclCompression.pas 2008-02-03 19:00:42 UTC (rev 2339)
+++ trunk/jcl/source/common/JclCompression.pas 2008-02-03 19:03:05 UTC (rev 2340)
@@ -4504,6 +4504,8 @@
begin
SevenzipCLSID := GetCLSID;
InterfaceID := Sevenzip.IOutArchive;
+ if (not Is7ZipLoaded) and (not Load7Zip) then
+ raise EJclCompressionError.CreateRes(@RsCompression7zLoadError);
if (Sevenzip.CreateObject(@SevenzipCLSID, @InterfaceID, FOutArchive) <> ERROR_SUCCESS)
or not Assigned(FOutArchive) then
raise EJclCompressionError.CreateResFmt(@RsCompression7zOutArchiveError, [GUIDToString(SevenzipCLSID)]);
@@ -4911,6 +4913,8 @@
begin
SevenzipCLSID := GetCLSID;
InterfaceID := Sevenzip.IInArchive;
+ if (not Is7ZipLoaded) and (not Load7Zip) then
+ raise EJclCompressionError.CreateRes(@RsCompression7zLoadError);
if (Sevenzip.CreateObject(@SevenzipCLSID, @InterfaceID, FInArchive) <> ERROR_SUCCESS)
or not Assigned(FInArchive) then
raise EJclCompressionError.CreateResFmt(@RsCompression7zInArchiveError, [GUIDToString(SevenzipCLSID)]);
@@ -5491,6 +5495,8 @@
begin
SevenzipCLSID := GetCLSID;
InterfaceID := Sevenzip.IInArchive;
+ if (not Is7ZipLoaded) and (not Load7Zip) then
+ raise EJclCompressionError.CreateRes(@RsCompression7zLoadError);
if (Sevenzip.CreateObject(@SevenzipCLSID, @InterfaceID, FInArchive) <> ERROR_SUCCESS)
or not Assigned(FInArchive) then
raise EJclCompressionError.CreateResFmt(@RsCompression7zInArchiveError, [GUIDToString(SevenzipCLSID)]);
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2008-02-03 19:00:42 UTC (rev 2339)
+++ trunk/jcl/source/common/JclResources.pas 2008-02-03 19:03:05 UTC (rev 2340)
@@ -811,6 +811,7 @@
RsCompressionDataError = 'Data error';
RsCompressionCRCError = 'CRC error';
RsCompressionUnknownError = 'Unknown error';
+ RsCompression7zLoadError = 'Sevenzip: Failed to load 7z.dll';
RsCompression7zReturnError = 'Sevenzip: Error result (%.8x) "%s"';
RsCompression7zUnassignedStream = 'Sevenzip: Stream object is not assigned';
RsCompression7zOutArchiveError = 'Sevenzip: Failed to get out archive interface for class %s';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ah...@us...> - 2008-03-29 23:09:15
|
Revision: 2364
http://jcl.svn.sourceforge.net/jcl/?rev=2364&view=rev
Author: ahuser
Date: 2008-03-29 16:09:11 -0700 (Sat, 29 Mar 2008)
Log Message:
-----------
Fixed possible unicode bugs
Modified Paths:
--------------
trunk/jcl/source/common/JclAnsiStrings.pas
trunk/jcl/source/common/JclStrings.pas
Modified: trunk/jcl/source/common/JclAnsiStrings.pas
===================================================================
--- trunk/jcl/source/common/JclAnsiStrings.pas 2008-03-24 17:22:45 UTC (rev 2363)
+++ trunk/jcl/source/common/JclAnsiStrings.pas 2008-03-29 23:09:11 UTC (rev 2364)
@@ -1239,11 +1239,11 @@
if not (Source^ in Chars) then
begin
Dest^ := Source^;
- Inc(Dest, SizeOf(AnsiChar));
+ Inc(Dest);
end;
- Inc(Source, SizeOf(AnsiChar));
+ Inc(Source);
end;
- SetLength(Result, (Longint(Dest) - Longint(PAnsiChar(Result))) div SizeOf(AnsiChar));
+ SetLength(Result, Dest - PAnsiChar(Result));
end;
{$ENDIF CLR}
@@ -1277,11 +1277,11 @@
if Source^ in Chars then
begin
Dest^ := Source^;
- Inc(Dest, SizeOf(AnsiChar));
+ Inc(Dest);
end;
- Inc(Source, SizeOf(AnsiChar));
+ Inc(Source);
end;
- SetLength(Result, (Longint(Dest) - Longint(PAnsiChar(Result))) div SizeOf(AnsiChar));
+ SetLength(Result, Dest - PAnsiChar(Result));
end;
{$ENDIF CLR}
@@ -1392,6 +1392,7 @@
IgnoreCase: Boolean;
begin
if Search = '' then
+ begin
if S = '' then
begin
S := Replace;
@@ -1399,6 +1400,7 @@
end
else
raise EJclStringError.CreateRes(@RsBlankSearchString);
+ end;
if S <> '' then
begin
Modified: trunk/jcl/source/common/JclStrings.pas
===================================================================
--- trunk/jcl/source/common/JclStrings.pas 2008-03-24 17:22:45 UTC (rev 2363)
+++ trunk/jcl/source/common/JclStrings.pas 2008-03-29 23:09:11 UTC (rev 2364)
@@ -742,13 +742,21 @@
Len: Integer;
RetValue: string;
begin
- Len := Length(Str);
- SetLength(RetValue, Len);
case Offset of
StrUpOffset:
- LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, PChar(Str), Len, PChar(RetValue), Len);
+ begin
+ Len := LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, PChar(Str), Length(Str), nil, 0);
+ SetLength(RetValue, Len);
+ if Len > 0 then
+ LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, PChar(Str), Length(Str), PChar(RetValue), Len);
+ end;
StrLoOffset:
- LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, PChar(Str), Len, PChar(RetValue), Len);
+ begin
+ Len := LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, PChar(Str), Length(Str), nil, 0);
+ SetLength(RetValue, Len);
+ if Len > 0 then
+ LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, PChar(Str), Length(Str), PChar(RetValue), Len);
+ end
else
Assert(False, 'StrReOffset not supported');
end;
@@ -858,18 +866,28 @@
procedure StrCaseBuff(S: PChar; const Offset: Integer);
{$IFDEF SUPPORTS_UNICODE}
var
- Len: Integer;
+ Len, SLen: Integer;
RetValue: string;
begin
if S <> nil then
begin
- Len := StrLen(S);
- SetLength(RetValue, Len);
+ Len := 0;
+ SLen := StrLen(S);
case Offset of
StrUpOffset:
- LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, S, Len, PChar(RetValue), Len);
+ begin
+ Len := LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, S, SLen, nil, 0);
+ SetLength(RetValue, Len);
+ if Len > 0 then
+ LCMapString(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, S, SLen, PChar(RetValue), Len);
+ end;
StrLoOffset:
- LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, S, Len, PChar(RetValue), Len);
+ begin
+ Len := LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, S, SLen, nil, 0);
+ SetLength(RetValue, Len);
+ if Len > 0 then
+ LCMapString(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, S, SLen, PChar(RetValue), Len);
+ end
else
Assert(False, 'StrReOffset not supported');
end;
@@ -1456,16 +1474,16 @@
UniqueString(Result);
Source := PChar(S);
Dest := PChar(Result);
- for Index := 0 to Len-1 do
+ for Index := 0 to Len - 1 do
begin
if not (Source^ in Chars) then
begin
Dest^ := Source^;
- Inc(Dest,SizeOf(Char));
+ Inc(Dest);
end;
- Inc(Source,SizeOf(Char));
+ Inc(Source);
end;
- SetLength(Result, (Longint(Dest) - Longint(PChar(Result))) div SizeOf(Char));
+ SetLength(Result, Dest - PChar(Result));
end;
{$ENDIF CLR}
@@ -1496,11 +1514,11 @@
if Source^ in Chars then
begin
Dest^ := Source^;
- Inc(Dest,SizeOf(Char));
+ Inc(Dest);
end;
- Inc(Source,SizeOf(Char));
+ Inc(Source);
end;
- SetLength(Result, (Longint(Dest) - Longint(PChar(Result))) div SizeOf(Char));
+ SetLength(Result, Dest - PChar(Result));
end;
{$ENDIF CLR}
@@ -1532,10 +1550,10 @@
Source := PChar(S);
if Dest <> nil then
for Index := 0 to Count - 1 do
- begin
- Move(Source^, Dest^, Len * SizeOf(Char));
- Inc(Dest,Len*SizeOf(Char));
- end;
+ begin
+ Move(Source^, Dest^, Len * SizeOf(Char));
+ Inc(Dest, Len);
+ end;
end;
{$ENDIF CLR}
@@ -1579,9 +1597,9 @@
Dest := PChar(Result);
while (L > 0) do
begin
- Move(S[1], Dest^, Min(L, Len) *SizeOf(Char));
- Inc(Dest,Len);
- Dec(L,Len);
+ Move(S[1], Dest^, Min(L, Len) * SizeOf(Char));
+ Inc(Dest, Len);
+ Dec(L, Len);
end;
end;
end;
@@ -1609,6 +1627,7 @@
IgnoreCase: Boolean;
begin
if Search = '' then
+ begin
if S = '' then
begin
S := Replace;
@@ -1616,6 +1635,7 @@
end
else
raise EJclStringError.CreateRes(@RsBlankSearchString);
+ end;
if S <> '' then
begin
@@ -1787,6 +1807,7 @@
end;
procedure StrReverseInPlace(var S: string);
+{ TODO -oahuser : Warning: This is dangerous for unicode surrogates }
{$IFDEF CLR}
var
I, LenS: Integer;
@@ -2933,7 +2954,7 @@
end;
end;
if Last <> nil then
- Result := Abs((Longint(PChar(S)) - Longint(Last)) div SizeOf(Char)) + 1;
+ Result := Abs(PChar(S) - Last) + 1;
end;
{$ENDIF CLR}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ou...@us...> - 2008-06-15 20:50:50
|
Revision: 2384
http://jcl.svn.sourceforge.net/jcl/?rev=2384&view=rev
Author: outchy
Date: 2008-06-15 13:50:45 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
TAR archives don't have properties, an exception was raised while compressing this archive.
Modified Paths:
--------------
trunk/jcl/source/common/JclCompression.pas
trunk/jcl/source/common/JclResources.pas
Modified: trunk/jcl/source/common/JclCompression.pas
===================================================================
--- trunk/jcl/source/common/JclCompression.pas 2008-06-11 18:34:22 UTC (rev 2383)
+++ trunk/jcl/source/common/JclCompression.pas 2008-06-15 20:50:45 UTC (rev 2384)
@@ -4756,9 +4756,7 @@
if Supports(AJclArchive, IJclArchiveAlgorithm, Algorithm) and Assigned(Algorithm) then
AddCardinalProperty('A', Algorithm.Algorithm);
end;
- end
- else
- raise EJclCompressionError.CreateRes(@RsCompression7zNoProperties);
+ end;
end;
//=== { TJclSevenzipOutputCallback } =========================================
Modified: trunk/jcl/source/common/JclResources.pas
===================================================================
--- trunk/jcl/source/common/JclResources.pas 2008-06-11 18:34:22 UTC (rev 2383)
+++ trunk/jcl/source/common/JclResources.pas 2008-06-15 20:50:45 UTC (rev 2384)
@@ -36,7 +36,7 @@
{ }
{**************************************************************************************************}
{ }
-{ Last modified: $Date:: $ }
+{ Last modified: $Date:: $ }
{ Revision: $Rev:: $ }
{ Author: $Author:: $ }
{ }
@@ -816,7 +816,6 @@
RsCompression7zUnassignedStream = 'Sevenzip: Stream object is not assigned';
RsCompression7zOutArchiveError = 'Sevenzip: Failed to get out archive interface for class %s';
RsCompression7zInArchiveError = 'Sevenzip: Failed to get in archive interface for class %s';
- RsCompression7zNoProperties = 'Sevenzip: Failed to get property setter interface';
RsCompression7zUnknownValueType = 'Sevenzip: Unknown value type (%d) for property ID %d';
RsCompression7zOnlyCurrentFile = 'Sevenzip: Only properties for current file can be retreived';
RsCompression7zWindows = 'Windows';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|