Browse Source

# revisions: 33059,33060,33153,33209,33238

git-svn-id: branches/fixes_3_0@33838 -
marco 9 years ago
parent
commit
38a19f9f32

+ 4 - 1
rtl/objpas/sysutils/syshelp.inc

@@ -1193,7 +1193,7 @@ begin
     LastSep:=Sep+1;
     LastSep:=Sep+1;
     Sep:=NextSep(LastSep);
     Sep:=NextSep(LastSep);
     end;
     end;
-  if (LastSep<Length-1) and ((ACount=0) or (Len<ACount)) then
+  if (LastSep<Length) and ((ACount=0) or (Len<ACount)) then
     begin
     begin
     T:=SubString(LastSep);
     T:=SubString(LastSep);
 //    Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
 //    Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
@@ -1481,6 +1481,7 @@ end;
 {$IFDEF FPC_HAS_TYPE_SINGLE}
 {$IFDEF FPC_HAS_TYPE_SINGLE}
 {$define TFLOATHELPER:=TSingleHelper}
 {$define TFLOATHELPER:=TSingleHelper}
 {$define FLOATTYPE:=Single}
 {$define FLOATTYPE:=Single}
+{$define TFloatRec:=TSingleRec}
 {$i syshelpf.inc}
 {$i syshelpf.inc}
 {$ENDIF FPC_HAS_TYPE_SINGLE}
 {$ENDIF FPC_HAS_TYPE_SINGLE}
 
 
@@ -1490,6 +1491,7 @@ end;
 {$IFDEF FPC_HAS_TYPE_DOUBLE}
 {$IFDEF FPC_HAS_TYPE_DOUBLE}
 {$define TFLOATHELPER:=TDoubleHelper}
 {$define TFLOATHELPER:=TDoubleHelper}
 {$define FLOATTYPE:=Double}
 {$define FLOATTYPE:=Double}
+{$define TFloatRec:=TDoubleRec}
 {$i syshelpf.inc}
 {$i syshelpf.inc}
 {$ENDIF FPC_HAS_TYPE_DOUBLE}
 {$ENDIF FPC_HAS_TYPE_DOUBLE}
 
 
@@ -1500,6 +1502,7 @@ end;
 {$ifdef FPC_HAS_TYPE_EXTENDED}
 {$ifdef FPC_HAS_TYPE_EXTENDED}
 {$define TFLOATHELPER:=TExtendedHelper}
 {$define TFLOATHELPER:=TExtendedHelper}
 {$define FLOATTYPE:=Extended}
 {$define FLOATTYPE:=Extended}
+{$define TFloatRec:=TExtended80Rec}
 {$i syshelpf.inc}
 {$i syshelpf.inc}
 {$ENDIF FPC_HAS_TYPE_EXTENDED}
 {$ENDIF FPC_HAS_TYPE_EXTENDED}
 
 

+ 9 - 14
rtl/objpas/sysutils/syshelpf.inc

@@ -98,19 +98,19 @@ end;
 Function TFLOATHELPER.GetE: QWord; inline;
 Function TFLOATHELPER.GetE: QWord; inline;
 
 
 begin
 begin
-  runerror(219);
+  Result:=TFloatRec(Self).Exp;
 end;
 end;
 
 
 Function TFLOATHELPER.GetF: QWord; inline;
 Function TFLOATHELPER.GetF: QWord; inline;
 
 
 begin
 begin
-  runerror(219);
+  Result:=TFloatRec(Self).Frac;
 end;
 end;
 
 
 Function TFLOATHELPER.GetS: Boolean; inline;
 Function TFLOATHELPER.GetS: Boolean; inline;
 
 
 begin
 begin
- runerror(219)
+  Result:=TFloatRec(Self).Sign;
 end;
 end;
 
 
 procedure TFLOATHELPER.SetB(AIndex: Cardinal; const AValue: Byte);
 procedure TFLOATHELPER.SetB(AIndex: Cardinal; const AValue: Byte);
@@ -132,19 +132,19 @@ end;
 procedure TFLOATHELPER.SetE(AValue: QWord);
 procedure TFLOATHELPER.SetE(AValue: QWord);
 
 
 begin
 begin
-  runerror(219);
+  TFloatRec(Self).Exp:=AValue;
 end;
 end;
 
 
 procedure TFLOATHELPER.SetF(AValue: QWord);
 procedure TFLOATHELPER.SetF(AValue: QWord);
 
 
 begin
 begin
-  runerror(219);
+  TFloatRec(Self).Frac:=AValue;
 end;
 end;
 
 
 procedure TFLOATHELPER.SetS(AValue: Boolean);
 procedure TFLOATHELPER.SetS(AValue: Boolean);
 
 
 begin
 begin
-  runerror(219);
+  TFloatRec(Self).Sign:=AValue;
 end;
 end;
 
 
 
 
@@ -174,7 +174,7 @@ end;
 Function TFLOATHELPER.Fraction: Extended;
 Function TFLOATHELPER.Fraction: Extended;
 
 
 begin
 begin
-  runerror(219);
+  Result:=TFloatRec(Self).Fraction;
 end;
 end;
 
 
 Function TFLOATHELPER.IsInfinity: Boolean; overload; inline;
 Function TFLOATHELPER.IsInfinity: Boolean; overload; inline;
@@ -204,18 +204,13 @@ end;
 Function TFLOATHELPER.Mantissa: QWord;
 Function TFLOATHELPER.Mantissa: QWord;
 
 
 begin
 begin
-  runerror(219);
+  Result:=TFLoatRec(Self).Mantissa;
 end;
 end;
 
 
 Function TFLOATHELPER.SpecialType: TFloatSpecial;
 Function TFLOATHELPER.SpecialType: TFloatSpecial;
 
 
 begin
 begin
-  if IsNan then
-    Result:=fsNan
-  else if IsNegativeInfinity then
-    Result:=fsNInf
-  else if IsPositiveInfinity then
-    Result:=fsInf
+  Result:=TFLoatRec(Self).SpecialType;
 end;
 end;
 
 
 Function TFLOATHELPER.ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
 Function TFLOATHELPER.ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;

+ 29 - 0
rtl/objpas/sysutils/sysstr.inc

@@ -218,6 +218,12 @@ begin
  Result:=CompareText(S1,S2)=0;
  Result:=CompareText(S1,S2)=0;
 end;
 end;
 
 
+function SameStr(const s1,s2:String):Boolean;
+
+begin
+ Result:=CompareStr(S1,S2)=0;
+end;
+
 {$ifndef FPC_NOGENERICANSIROUTINES}
 {$ifndef FPC_NOGENERICANSIROUTINES}
 {==============================================================================}
 {==============================================================================}
 {   Ansi string functions                                                      }
 {   Ansi string functions                                                      }
@@ -845,6 +851,19 @@ begin
   if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
   if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
 end;
 end;
 
 
+function StrToDWord(const s: string): DWord;
+var Error: word;
+begin
+  Val(S, result, Error);
+  if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
+end;
+
+function TryStrToDWord(const s: string; Out D: DWord): boolean;
+var Error : word;
+begin
+  Val(s, D, Error);
+  TryStrToDWord:=Error=0
+end;
 
 
 function TryStrToQWord(const s: string; Out Q: QWord): boolean;
 function TryStrToQWord(const s: string; Out Q: QWord): boolean;
 var Error : word;
 var Error : word;
@@ -863,6 +882,16 @@ begin
   if Error <> 0 then result := Default;
   if Error <> 0 then result := Default;
 end ;
 end ;
 
 
+{   StrToDWordDef converts the string S to an DWord value,
+    Default is returned in case S does not represent a valid DWord value  }
+
+function StrToDWordDef(const S: string; Default: DWord): DWord;
+var Error: word;
+begin
+  Val(S, result, Error);
+  if Error <> 0 then result := Default;
+end;
+
 {   StrToInt64Def converts the string S to an int64 value,
 {   StrToInt64Def converts the string S to an int64 value,
     Default is returned in case S does not represent a valid int64 value  }
     Default is returned in case S does not represent a valid int64 value  }
 
 

+ 6 - 2
rtl/objpas/sysutils/sysstrh.inc

@@ -78,6 +78,7 @@ function CompareMemRange(P1, P2: Pointer; Length: PtrUInt): integer;{$ifdef SYSU
 function CompareMem(P1, P2: Pointer; Length: PtrUInt): Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
 function CompareMem(P1, P2: Pointer; Length: PtrUInt): Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
 function CompareText(const S1, S2: string): integer;
 function CompareText(const S1, S2: string): integer;
 function SameText(const s1,s2:String):Boolean;
 function SameText(const s1,s2:String):Boolean;
+function SameStr(const s1,s2:String):Boolean;
 
 
 function AnsiUpperCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}
 function AnsiUpperCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}
 function AnsiLowerCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}
 function AnsiLowerCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}
@@ -111,12 +112,15 @@ function IntToHex(Value: Longint; Digits: integer): string;
 function IntToHex(Value: Int64; Digits: integer): string;
 function IntToHex(Value: Int64; Digits: integer): string;
 function IntToHex(Value: QWord; Digits: integer): string;
 function IntToHex(Value: QWord; Digits: integer): string;
 function StrToInt(const s: string): Longint;
 function StrToInt(const s: string): Longint;
-function TryStrToInt(const s: string; Out i : Longint) : boolean;
+function StrToDWord(const s: string): DWord;
 function StrToInt64(const s: string): int64;
 function StrToInt64(const s: string): int64;
-function TryStrToInt64(const s: string; Out i : int64) : boolean;
 function StrToQWord(const s: string): QWord;
 function StrToQWord(const s: string): QWord;
+function TryStrToInt(const s: string; Out i : Longint) : boolean;
+function TryStrToDWord(const s: string; Out D : DWord) : boolean;
+function TryStrToInt64(const s: string; Out i : int64) : boolean;
 function TryStrToQWord(const s: string; Out Q : QWord) : boolean;
 function TryStrToQWord(const s: string; Out Q : QWord) : boolean;
 function StrToIntDef(const S: string; Default: Longint): Longint;
 function StrToIntDef(const S: string; Default: Longint): Longint;
+function StrToDWordDef(const S: string; Default: DWord): DWord;
 function StrToInt64Def(const S: string; Default: int64): int64;
 function StrToInt64Def(const S: string; Default: int64): int64;
 function StrToQWordDef(const S: string; Default: QWord): QWord;
 function StrToQWordDef(const S: string; Default: QWord): QWord;
 function LoadStr(Ident: integer): string;
 function LoadStr(Ident: integer): string;