Typo errors and little improvements inspired by ACBr

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@251 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2022-01-14 14:53:08 +00:00
parent b43d4c2452
commit 948daf7b74
2 changed files with 35 additions and 13 deletions

View File

@ -61,6 +61,13 @@
{$ZEROBASEDSTRINGS OFF}
{$ENDIF}
{$IfDef DELPHI2009_UP}
{$DEFINE HAS_CHARINSET}
{$EndIf}
{$IfDef FPC}
{$DEFINE HAS_CHARINSET}
{$EndIf}
unit synafpc;
interface
@ -118,6 +125,10 @@ function StrLCopy(Dest: PAnsiChar; const Source: PAnsiChar; MaxLen: Cardinal): P
function StrLComp(const Str1, Str2: PANSIChar; MaxLen: Cardinal): Integer;
procedure Sleep(milliseconds: Cardinal);
{$IfNDef HAS_CHARINSET}
function CharInSet(C: AnsiChar; const CharSet: TSysCharSet): Boolean;
{$EndIf}
implementation
@ -162,7 +173,7 @@ begin
{$EndIf}
{$Else}
Result := SysUtils.StrLCopy(Dest, Source, MaxLen);
{$IfEnd}
{$ENDIF}
{$EndIf}
end;
@ -179,7 +190,7 @@ begin
{$EndIf}
{$Else}
Result := SysUtils.StrLComp(Str1, Str2, MaxLen);
{$IfEnd}
{$ENDIF}
{$EndIf}
end;
@ -194,7 +205,13 @@ begin
{$ELSE}
sysutils.sleep(milliseconds);
{$ENDIF}
end;
{$IfNDef HAS_CHARINSET}
function CharInSet(C: AnsiChar; const CharSet: TSysCharSet): Boolean;
begin
result := C in CharSet;
end;
{$EndIf}
end.

View File

@ -59,6 +59,11 @@
{$WARN IMPLICIT_STRING_CAST OFF}
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
{$WARN SUSPICIOUS_TYPECAST OFF}
{$WARN SYMBOL_DEPRECATED OFF}
{$ENDIF}
{$IFDEF NEXTGEN}
{$ZEROBASEDSTRINGS OFF}
{$ENDIF}
unit synautil;
@ -77,7 +82,7 @@ uses
{$ENDIF OS2}
{$ELSE FPC}
{$IFDEF POSIX}
Posix.Base, Posix.Time, Posix.SysTypes, Posix.SysTime, Posix.Stdio,
Posix.Base, Posix.Time, Posix.SysTypes, Posix.SysTime, Posix.Stdio, Posix.Unistd,
{$ELSE}
Libc,
{$ENDIF}
@ -1920,7 +1925,7 @@ end;
procedure SearchForLineBreak(var APtr:PANSIChar; AEtx:PANSIChar; out ABol:PANSIChar; out ALength:integer);
begin
ABol := APtr;
while (APtr<AEtx) and not (APtr^ in [#0,#10,#13]) do
while (APtr<AEtx) and not (Byte(APtr^) in [0, 10, 13]) do
inc(APtr);
ALength := APtr-ABol;
end;
@ -2024,12 +2029,12 @@ begin
// Moving Aptr position forward until boundary will be reached
while (APtr<AEtx) do
begin
if {$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(APtr,#13#10'--',4)=0 then
if SynaFpc.strlcomp(APtr,#13#10'--',4)=0 then
begin
eob := MatchBoundary(APtr,AEtx,ABoundary);
Step := 4;
end
else if {$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(APtr,'--',2)=0 then
else if SynaFpc.strlcomp(APtr,'--',2)=0 then
begin
eob := MatchBoundary(APtr,AEtx,ABoundary);
Step := 2;
@ -2062,17 +2067,17 @@ begin
Lng := length(ABoundary);
if (MatchPos+2+Lng)>AETX then
exit;
if {$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(MatchPos,#13#10,2)=0 then
if SynaFpc.strlcomp(MatchPos,#13#10,2)=0 then
inc(MatchPos,2);
if (MatchPos+2+Lng)>AETX then
exit;
if {$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(MatchPos,'--',2)<>0 then
if SynaFpc.strlcomp(MatchPos,'--',2)<>0 then
exit;
inc(MatchPos,2);
if {$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(MatchPos,PANSIChar(ABoundary),Lng)<>0 then
if SynaFpc.strlcomp(MatchPos,PANSIChar(ABoundary),Lng)<>0 then
exit;
inc(MatchPos,Lng);
if ((MatchPos+2)<=AEtx) and ({$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(MatchPos,#13#10,2)=0) then
if ((MatchPos+2)<=AEtx) and (SynaFpc.strlcomp(MatchPos,#13#10,2)=0) then
inc(MatchPos,2);
Result := MatchPos;
end;
@ -2087,10 +2092,10 @@ begin
MatchPos := MatchBoundary(ABOL,AETX,ABoundary);
if not Assigned(MatchPos) then
exit;
if {$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(MatchPos,'--',2)<>0 then
if SynaFpc.strlcomp(MatchPos,'--',2)<>0 then
exit;
inc(MatchPos,2);
if (MatchPos+2<=AEtx) and ({$IFDEF DELPHIX_SEATTLE_UP} AnsiStrings. {$ENDIF} strlcomp(MatchPos,#13#10,2)=0) then
if (MatchPos+2<=AEtx) and (SynaFpc.strlcomp(MatchPos,#13#10,2)=0) then
inc(MatchPos,2);
Result := MatchPos;
end;