diff --git a/packages/fcl-res/src/coffwriter.pp b/packages/fcl-res/src/coffwriter.pp index 9d62bbed6a..53b471324e 100644 --- a/packages/fcl-res/src/coffwriter.pp +++ b/packages/fcl-res/src/coffwriter.pp @@ -150,6 +150,7 @@ uses coffconsts; constructor TCoffStringTable.Create; begin + inherited create; fSize:=4; Duplicates:=dupIgnore; end; diff --git a/packages/fcl-xml/src/xmlconf.pp b/packages/fcl-xml/src/xmlconf.pp index 3e84cd0227..31b2f2fead 100644 --- a/packages/fcl-xml/src/xmlconf.pp +++ b/packages/fcl-xml/src/xmlconf.pp @@ -166,6 +166,7 @@ Var begin F:=TFileStream.Create(AFileName,fmOpenread or fmShareDenyWrite); try + FFileName := ''; ReadXMLFile(Doc, AFilename); FFileName:=AFileName; finally @@ -398,11 +399,14 @@ procedure TXMLConfig.DoSetFilename(const AFilename: String; ForceReload: Boolean begin if (not ForceReload) and (FFilename = AFilename) then exit; - + Flush; FreeAndNil(Doc); if csLoading in ComponentState then + begin + FFilename := AFilename; exit; + end; if FileExists(AFilename) and not FStartEmpty then LoadFromFile(AFilename) else if not Assigned(Doc) then @@ -425,6 +429,8 @@ begin if AValue <> FRootName then begin FRootName := AValue; + if not (ComponentState * [csLoading,csDesigning] = []) then + Exit; Root := Doc.DocumentElement; Cfg := Doc.CreateElement(AValue); while Assigned(Root.FirstChild) do @@ -475,7 +481,7 @@ var begin for I := Length(FPathStack)-1 downto 0 do FPathStack[I] := ''; - FElement := nil; + FElement := nil; FPathDirty := False; FPathCount := 0; end; diff --git a/packages/openssl/src/openssl.pas b/packages/openssl/src/openssl.pas index 30d9c3ef20..e59fbc2c15 100644 --- a/packages/openssl/src/openssl.pas +++ b/packages/openssl/src/openssl.pas @@ -1282,7 +1282,7 @@ var function PEM_write_bio_PUBKEY(bp: pBIO; x: pEVP_PKEY): integer; function PEM_read_bio_X509(bp: PBIO; x: PPX509; cb: ppem_password_cb; u: pointer): PX509; function PEM_write_bio_X509(bp: pBIO; x: px509): integer; - + function PEM_write_bio_PKCS7(bp : PBIO; x : PPKCS7) : cint; // BIO Functions - bio.h function BioNew(b: PBIO_METHOD): PBIO; procedure BioFreeAll(b: PBIO); @@ -1728,6 +1728,7 @@ type TPEM_write_bio_PUBKEY = function(bp: pBIO; x: pEVP_PKEY): integer; cdecl; TPEM_read_bio_X509 = function(bp: pBIO; x: PPX509; cb: Ppem_password_cb; u: pointer): px509; cdecl; TPEM_write_bio_X509 = function(bp: pBIO; x: PX509): integer; cdecl; + TPEM_write_bio_PKCS7 = function(bp: pBIO; x: PPKCS7): integer; cdecl; // BIO Functions @@ -1963,6 +1964,7 @@ var _PEM_write_bio_PUBKEY: TPEM_write_bio_PUBKEY = nil; _PEM_read_bio_X509: TPEM_read_bio_X509 = nil; _PEM_write_bio_X509: TPEM_write_bio_X509 = nil; + _PEM_write_bio_PKCS7 : TPEM_write_bio_PKCS7 = Nil; // BIO Functions _BIO_ctrl: TBIO_ctrl = nil; @@ -3677,6 +3679,15 @@ begin Result := 0; end; +function PEM_write_bio_PKCS7(bp : PBIO; x : PPKCS7) : cint; + +begin + if InitSSLInterface and Assigned(_PEM_write_bio_PKCS7) then + Result := _PEM_write_bio_PKCS7(bp, x) + else + Result := 0; +end; + // BIO Functions @@ -4869,7 +4880,7 @@ begin _PEM_write_bio_PUBKEY := GetProcAddr(SSLUtilHandle, 'PEM_write_bio_PUBKEY'); _PEM_read_bio_X509 := GetProcAddr(SSLUtilHandle, 'PEM_read_bio_X509'); _PEM_write_bio_X509 := GetProcAddr(SSLUtilHandle,'PEM_write_bio_X509'); - + _PEM_write_bio_PKCS7 := GetProcAddr(SSLUtilHandle,'PEM_write_bio_PKCS7'); // BIO _BIO_ctrl := GetProcAddr(SSLUtilHandle, 'BIO_ctrl'); _BIO_s_file := GetProcAddr(SSLUtilHandle, 'BIO_s_file'); @@ -5333,6 +5344,7 @@ begin _PEM_write_bio_PrivateKey := nil; _PEM_read_bio_X509 := nil; _PEM_write_bio_X509 := nil; + _PEM_write_bio_PKCS7 := nil; // BIO diff --git a/packages/rtl-objpas/src/inc/strutils.pp b/packages/rtl-objpas/src/inc/strutils.pp index f099520c86..aff3a01c9e 100644 --- a/packages/rtl-objpas/src/inc/strutils.pp +++ b/packages/rtl-objpas/src/inc/strutils.pp @@ -20,7 +20,7 @@ unit StrUtils; interface uses - SysUtils{, Types}; + SysUtils, Types; { --------------------------------------------------------------------- Case insensitive search/replace @@ -36,6 +36,11 @@ Function AnsiIndexText(const AText: string; const AValues: array of string): Int Function StartsText(const ASubText, AText: string): Boolean; inline; Function EndsText(const ASubText, AText: string): Boolean; inline; +function ResemblesText(const AText, AOther: string): Boolean; inline; +function ContainsText(const AText, ASubText: string): Boolean; inline; +function MatchText(const AText: string; const AValues: array of string): Boolean; inline; +function IndexText(const AText: string; const AValues: array of string): Integer; inline; + { --------------------------------------------------------------------- Case sensitive search/replace ---------------------------------------------------------------------} @@ -54,6 +59,11 @@ Function IndexStr(const AText: UnicodeString; const AValues: array of UnicodeStr Function IndexText(const AText: UnicodeString; const AValues: array of UnicodeString): Integer; Operator in (const AText: string; const AValues: array of string):Boolean;inline; Operator in (const AText: UnicodeString; const AValues: array of UnicodeString):Boolean;inline; + +function ContainsStr(const AText, ASubText: string): Boolean; inline; +function MatchStr(const AText: string; const AValues: array of string): Boolean; inline; +function IndexStr(const AText: string; const AValues: array of string): Integer; inline; + { --------------------------------------------------------------------- Miscellaneous ---------------------------------------------------------------------} @@ -67,6 +77,8 @@ Function IfThen(AValue: Boolean; const ATrue: string; const AFalse: string = '') function NaturalCompareText (const S1 , S2 : string ): Integer ; function NaturalCompareText(const Str1, Str2: string; const ADecSeparator, AThousandSeparator: Char): Integer; +function SplitString(const S, Delimiters: string): TStringDynArray; + { --------------------------------------------------------------------- VB emulations. ---------------------------------------------------------------------} @@ -146,6 +158,7 @@ type Const AnsiResemblesProc: TCompareTextProc = @SoundexProc; + ResemblesProc: TCompareTextProc = @SoundexProc; { --------------------------------------------------------------------- Other functions, based on RxStrUtils. @@ -927,19 +940,54 @@ begin Result := AnsiEndsText(ASubText, AText); end; +function ResemblesText(const AText, AOther: string): Boolean; +begin + if Assigned(ResemblesProc) then + Result := ResemblesProc(AText, AOther) + else + Result := False; +end; + +function ContainsText(const AText, ASubText: string): Boolean; +begin + Result := AnsiContainsText(AText, ASubText); +end; + +function MatchText(const AText: string; const AValues: array of string): Boolean; +begin + Result := AnsiMatchText(AText, AValues); +end; + +function IndexText(const AText: string; const AValues: array of string): Integer; +begin + Result := AnsiIndexText(AText, AValues); +end; + +function ContainsStr(const AText, ASubText: string): Boolean; +begin + Result := AnsiContainsStr(AText, ASubText); +end; + +function MatchStr(const AText: string; const AValues: array of string): Boolean; +begin + Result := AnsiMatchStr(AText, AValues); +end; + +function IndexStr(const AText: string; const AValues: array of string): Integer; +begin + Result := AnsiIndexStr(AText, AValues); +end; function AnsiReplaceText(const AText, AFromText, AToText: string): string; begin Result := StringReplace(AText,AFromText,AToText,[rfReplaceAll,rfIgnoreCase]); end; - function AnsiMatchText(const AText: string; const AValues: array of string): Boolean; begin Result:=(AnsiIndexText(AText,AValues)<>-1) end; - function AnsiIndexText(const AText: string; const AValues: array of string): Integer; begin for Result := Low(AValues) to High(AValues) do @@ -1292,6 +1340,11 @@ begin end; end; +function SplitString(const S, Delimiters: string): TStringDynArray; +begin + Result := S.Split(Delimiters); +end; + function NaturalCompareText (const S1 , S2 : string ): Integer ; begin Result := NaturalCompareText(S1, S2, diff --git a/rtl/inc/getopts.pp b/rtl/inc/getopts.pp index 8447630f4c..5a655b1f1f 100644 --- a/rtl/inc/getopts.pp +++ b/rtl/inc/getopts.pp @@ -47,27 +47,24 @@ Function GetLongOpts (ShortOpts : String;LongOpts : POption;var Longind : Longin Implementation -{$IFNDEF FPC} - {$ifdef TP} - uses strings; - {$else } - uses SysUtils; - type PtrInt = Integer; - {$endif} -{$ENDIF FPC} +{$IFNDEF FPC} {*************************************************************************** Create an ArgV ***************************************************************************} -{$IF not Declared(argv)} //{$ifdef TP} +uses SysUtils; + + type PtrInt = Integer; type ppchar = ^pchar; apchar = array[0..127] of pchar; + var argc : longint; argv : apchar; + const CHAR_SIZE = SizeOf(Char); @@ -139,7 +136,7 @@ begin move(argsbuf,argv,count shl 2); end; -{$IFEND} //{$endif TP} +{$ENDIF} {*************************************************************************** Real Getopts @@ -167,7 +164,7 @@ begin if (top-middle>middle-bottom) then begin len:=middle-bottom; - for i:=1 to len-1 do + for i:=0 to len-1 do begin temp:=argv[bottom+i]; argv[bottom+i]:=argv[top-(middle-bottom)+i]; @@ -496,17 +493,8 @@ begin getlongopts:=internal_getopt(shortopts,longopts,@longind,true); end; -{$ifdef FPC} - initialization -{$endif} -{$ifndef FPC} - {$ifdef TP} - begin - {$else} - initialization - {$endif} -{$endif} -{ create argv if running under TP } +initialization +{ create argv if not running under FPC } {$ifndef FPC} setup_arguments; {$endif} diff --git a/rtl/objpas/classes/parser.inc b/rtl/objpas/classes/parser.inc index 0671456d0c..29e5e3a9fc 100644 --- a/rtl/objpas/classes/parser.inc +++ b/rtl/objpas/classes/parser.inc @@ -361,8 +361,16 @@ begin end; destructor TParser.Destroy; + +Var + aCount : Integer; + begin - fStream.Position:=SourcePos; + if fToken=toWString then + aCount:=Length(fLastTokenWStr)*2 + else + aCount:=Length(fLastTokenStr); + fStream.Position:=SourcePos-aCount; FreeMem(fBuf); end; diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index cf56ccb110..7aaabbada2 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/rtl/objpas/sysutils/sysstr.inc @@ -850,6 +850,17 @@ begin System.Str(Value, result); end ; +function UIntToStr(Value: QWord): string; + +begin + result:=IntTostr(Value); +end; + +function UIntToStr(Value: Cardinal): string; + +begin + System.Str(Value, result); +end; { IntToHex returns a string representing the hexadecimal value of Value } diff --git a/rtl/objpas/sysutils/sysstrh.inc b/rtl/objpas/sysutils/sysstrh.inc index 383579d234..51c7f507a9 100644 --- a/rtl/objpas/sysutils/sysstrh.inc +++ b/rtl/objpas/sysutils/sysstrh.inc @@ -115,6 +115,8 @@ function IsValidIdent(const Ident: string; AllowDots: Boolean = False; StrictDot function IntToStr(Value: Longint): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} function IntToStr(Value: Int64): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} function IntToStr(Value: QWord): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} +function UIntToStr(Value: QWord): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} +function UIntToStr(Value: Cardinal): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} function IntToHex(Value: Longint; Digits: integer): string; function IntToHex(Value: Int64; Digits: integer): string; function IntToHex(Value: QWord; Digits: integer): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} diff --git a/rtl/objpas/sysutils/syswide.inc b/rtl/objpas/sysutils/syswide.inc index 6135ece8e9..0b60f3a3a0 100644 --- a/rtl/objpas/sysutils/syswide.inc +++ b/rtl/objpas/sysutils/syswide.inc @@ -11,6 +11,11 @@ ********************************************************************* } +function IsLeadChar(Ch: WideChar): Boolean; +begin + Result := (Ch >= #$D800) and (Ch <= #$DFFF); +end; + function Trim(const S: widestring): widestring; var Ofs, Len: sizeint; @@ -180,6 +185,7 @@ begin result:=(Ch<=#$FF) and (ansichar(byte(ch)) in CSet); end; + {$macro on} {$define INWIDESTRINGREPLACE} {$define SRString:=WideString} diff --git a/rtl/objpas/sysutils/syswideh.inc b/rtl/objpas/sysutils/syswideh.inc index eff1af4690..2ad6ce00a0 100644 --- a/rtl/objpas/sysutils/syswideh.inc +++ b/rtl/objpas/sysutils/syswideh.inc @@ -35,3 +35,6 @@ function StrCopy(Dest, Source: PWideChar): PWideChar; overload; function StrLCopy(Dest,Source: PWideChar; MaxLen: SizeInt): PWideChar; overload; Function CharInSet(Ch:WideChar;Const CSet : TSysCharSet) : Boolean; function WideStringReplace(const S, OldPattern, NewPattern: WideString; Flags: TReplaceFlags): WideString; + +function IsLeadChar(Ch: WideChar): Boolean; inline; overload; + diff --git a/rtl/unix/unix.pp b/rtl/unix/unix.pp index 6bce71f18f..f41b1a1b18 100644 --- a/rtl/unix/unix.pp +++ b/rtl/unix/unix.pp @@ -914,6 +914,8 @@ var pl : ^cint; begin AssignStream:=-1; + if fpAccess(prog,X_OK)<>0 then + exit(-1); if AssignPipe(streamin,pipo)=-1 Then exit(-1); if AssignPipe(pipi,streamout)=-1 Then @@ -985,7 +987,8 @@ var pl: ^cint; begin AssignStream := -1; - + if fpAccess(prog,X_OK)<>0 then + exit(-1); // Assign pipes if AssignPipe(StreamIn, PipeOut)=-1 Then Exit(-1); diff --git a/utils/ptopu.pp b/utils/ptopu.pp index 047a3749bd..213c78a7b0 100644 --- a/utils/ptopu.pp +++ b/utils/ptopu.pp @@ -72,7 +72,7 @@ TYPE notsym,nilsym,orsym,setsym,tosym,virtualsym,usessym, casevarsym,ofobjectsym, { other symbols } - becomes,delphicomment,dopencomment,dclosecomment,opencomment,closecomment,semicolon,colon,equals, + becomes,notequal,lessorequal,greaterorequal,delphicomment,dopencomment,dclosecomment,opencomment,closecomment,semicolon,colon,equals, openparen,closeparen,period,endoffile,othersym); { Formatting options } @@ -252,7 +252,7 @@ CONST 'and','arr','div','down','file','goto', 'in','mod','not','nil','or','set','to','virtual','uses', 'casevar','ofobject', - 'becomes','delphicomment','dopencomment','dclosecomment', + 'becomes','notequal','lessorequal','greaterorequal','delphicomment','dopencomment','dclosecomment', 'opencomment','closecomment','semicolon', 'colon','equals', 'openparen','closeparen','period','endoffile','other'); @@ -265,7 +265,7 @@ CONST DblChar : DblCharTable = - ( ':=', '//','(*','*)' ); + ( ':=', '<>', '<=', '>=', '//','(*','*)' ); SglChar : SglCharTable = ('{', '}', ';', ':', '=', '(', ')', '.' ); @@ -1411,5 +1411,5 @@ End; Begin - dblch := [becomes, opencomment]; + dblch := [becomes, notequal, lessorequal, greaterorequal, opencomment]; end.