Parcourir la source

--- Merging r16482 into '.':
U rtl/objpas/sysutils/sysinth.inc
--- Merging r16744 into '.':
U rtl/objpas/dateutil.inc
U rtl/objpas/sysutils/sysstr.inc
U rtl/objpas/sysutils/dati.inc
U rtl/objpas/cvarutil.inc
U rtl/objpas/fmtbcd.pp
--- Merging r16951 into '.':
G rtl/objpas/fmtbcd.pp
--- Merging r16952 into '.':
G rtl/objpas/fmtbcd.pp

# revisions: 16482,16744,16951,16952
------------------------------------------------------------------------
r16482 | marco | 2010-11-30 10:49:19 +0100 (Tue, 30 Nov 2010) | 4 lines
Changed paths:
M /trunk/rtl/objpas/sysutils/sysinth.inc

* Delphi XE (2010?) compatible alias for defaultformatsettings.
* deprecated separate globals (Delphi XE). Causes some deprecated
warnings in dati.inc that still have to be fixed.

------------------------------------------------------------------------
------------------------------------------------------------------------
r16744 | sergei | 2011-01-09 16:27:05 +0100 (Sun, 09 Jan 2011) | 2 lines
Changed paths:
M /trunk/rtl/objpas/cvarutil.inc
M /trunk/rtl/objpas/dateutil.inc
M /trunk/rtl/objpas/fmtbcd.pp
M /trunk/rtl/objpas/sysutils/dati.inc
M /trunk/rtl/objpas/sysutils/sysstr.inc

* RTL: Replaced deprecated formatting symbols with their up-to-date counterparts, reduces compiler noise.
* Also removed some unused variables.
------------------------------------------------------------------------
------------------------------------------------------------------------
r16951 | joost | 2011-02-20 18:53:18 +0100 (Sun, 20 Feb 2011) | 1 line
Changed paths:
M /trunk/rtl/objpas/fmtbcd.pp

* TryStrToBcd now returns true when it succeeds, and false when it fails, not the other way around
------------------------------------------------------------------------
------------------------------------------------------------------------
r16952 | joost | 2011-02-20 18:59:12 +0100 (Sun, 20 Feb 2011) | 1 line
Changed paths:
M /trunk/rtl/objpas/fmtbcd.pp

* Fixed BCDToStr for values between -1 and 0
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@17586 -

marco il y a 14 ans
Parent
commit
c61d37e616

+ 2 - 2
rtl/objpas/cvarutil.inc

@@ -386,8 +386,8 @@ var
 begin
 begin
   j := 1;
   j := 1;
   for i := 1 to Length(s) do
   for i := 1 to Length(s) do
-    if s[i] <> ThousandSeparator then begin
-      if s[i] = DecimalSeparator then
+    if s[i] <> DefaultFormatSettings.ThousandSeparator then begin
+      if s[i] = DefaultFormatSettings.DecimalSeparator then
         s[j] := '.'
         s[j] := '.'
       else
       else
         s[j] := s[i];
         s[j] := s[i];

+ 5 - 5
rtl/objpas/dateutil.inc

@@ -1946,12 +1946,12 @@ Var
 begin
 begin
   DecodeDateTime(ABasedate,Y,M,D,H,N,S,MS);
   DecodeDateTime(ABasedate,Y,M,D,H,N,S,MS);
   Msg:=DoField(AYear,Y,'????');
   Msg:=DoField(AYear,Y,'????');
-  Msg:=Msg+DateSeparator+DoField(AMonth,M,'??');
-  Msg:=Msg+DateSeparator+DoField(ADay,D,'??');
+  Msg:=Msg+DefaultFormatSettings.DateSeparator+DoField(AMonth,M,'??');
+  Msg:=Msg+DefaultFormatSettings.DateSeparator+DoField(ADay,D,'??');
   Msg:=Msg+' '+DoField(AHour,H,'??');
   Msg:=Msg+' '+DoField(AHour,H,'??');
-  Msg:=Msg+TimeSeparator+DoField(AMinute,N,'??');
-  Msg:=Msg+TimeSeparator+Dofield(ASecond,S,'??');
-  Msg:=Msg+DecimalSeparator+DoField(AMilliSecond,MS,'???');
+  Msg:=Msg+DefaultFormatSettings.TimeSeparator+DoField(AMinute,N,'??');
+  Msg:=Msg+DefaultFormatSettings.TimeSeparator+Dofield(ASecond,S,'??');
+  Msg:=Msg+DefaultFormatSettings.DecimalSeparator+DoField(AMilliSecond,MS,'???');
   Raise EConvertError.CreateFmt(SErrInvalidTimeStamp,[Msg]);
   Raise EConvertError.CreateFmt(SErrInvalidTimeStamp,[Msg]);
 end;
 end;
 
 

+ 22 - 19
rtl/objpas/fmtbcd.pp

@@ -1216,8 +1216,8 @@ IMPLEMENTATION
                                 end;
                                 end;
 { find out language-specific ? }
 { find out language-specific ? }
         DecimalPoint_is_System: begin
         DecimalPoint_is_System: begin
-                                 dp := DecimalSeparator;
-                                 dc := ThousandSeparator;
+                                 dp := DefaultFormatSettings.DecimalSeparator;
+                                 dc := DefaultFormatSettings.ThousandSeparator;
                                 end;
                                 end;
        end;
        end;
      end;
      end;
@@ -1417,7 +1417,7 @@ IMPLEMENTATION
                end;
                end;
 
 
     begin
     begin
-      result := False;
+      result := True;
       FillChar ( lvars, SizeOf ( lvars ), #0 );
       FillChar ( lvars, SizeOf ( lvars ), #0 );
       BCD := NullBCD;
       BCD := NullBCD;
       lav := Length ( aValue );
       lav := Length ( aValue );
@@ -1468,31 +1468,31 @@ IMPLEMENTATION
                         '.': if ch = dp
                         '.': if ch = dp
                                then begin
                                then begin
                                  if inife <> inint
                                  if inife <> inint
-                                   then result := True
+                                   then result := False
                                    else inife := infrac;
                                    else inife := infrac;
                                 end;
                                 end;
                         'e',
                         'e',
                         'E': if inife = inexp
                         'E': if inife = inexp
-                               then result := True
+                               then result := False
                                else inife := inexp;
                                else inife := inexp;
                         '+',
                         '+',
                         '-': if ( inife = inexp ) AND ( fp[inexp] = 0 )
                         '-': if ( inife = inexp ) AND ( fp[inexp] = 0 )
                                then pse := i
                                then pse := i
-                               else result := True;
+                               else result := False;
                         else begin
                         else begin
-                          result := True;
+                          result := False;
                           errp := i;
                           errp := i;
                          end;
                          end;
                        end;
                        end;
                      end;
                      end;
-                  if result
+                  if not result
                     then begin
                     then begin
-                      result := False;
+                      result := True;
                       for i := errp TO lav do
                       for i := errp TO lav do
                         if aValue[i] <> ' '
                         if aValue[i] <> ' '
-                          then result := True;
+                          then result := False;
                      end;
                      end;
-                  if result
+                  if not result
                     then EXIT;
                     then EXIT;
 
 
                   if ps <> 0
                   if ps <> 0
@@ -1503,15 +1503,15 @@ IMPLEMENTATION
                     then begin
                     then begin
                       exp := 0;
                       exp := 0;
                       for i := fp[inexp] TO lp[inexp] do
                       for i := fp[inexp] TO lp[inexp] do
-                        if NOT result
+                        if result
                           then
                           then
                             if aValue[i] <> dc
                             if aValue[i] <> dc
                               then begin
                               then begin
                                 exp := exp * 10 + ( Ord ( aValue[i] ) - Ord ( '0' ) );
                                 exp := exp * 10 + ( Ord ( aValue[i] ) - Ord ( '0' ) );
                                 if exp > 999
                                 if exp > 999
-                                  then result := True;
+                                  then result := False;
                                end;
                                end;
-                      if result
+                      if not result
                         then EXIT;
                         then EXIT;
 
 
                       if pse <> 0
                       if pse <> 0
@@ -1545,16 +1545,16 @@ IMPLEMENTATION
                                 Dec ( p );
                                 Dec ( p );
                                 Singles[p] := Ord ( aValue[i] ) - Ord ( '0' );
                                 Singles[p] := Ord ( aValue[i] ) - Ord ( '0' );
                                end
                                end
-                              else result := True;
+                              else result := False;
                            end;
                            end;
-                  if result
+                  if not result
                     then EXIT;
                     then EXIT;
 
 
                   FDig := p;
                   FDig := p;
                   if LDig < 0
                   if LDig < 0
                     then LDig := 0;
                     then LDig := 0;
                   Plac := LDig;
                   Plac := LDig;
-                  result := NOT pack_BCD ( bh, BCD );
+                  result := pack_BCD ( bh, BCD );
                  end;
                  end;
              end;
              end;
      end;
      end;
@@ -1565,7 +1565,7 @@ IMPLEMENTATION
       BCD : tBCD;
       BCD : tBCD;
 
 
     begin
     begin
-      if TryStrToBCD ( aValue, BCD )
+      if not TryStrToBCD ( aValue, BCD )
         then begin
         then begin
           RAISE eBCDOverflowException.create ( 'in StrToBCD' );
           RAISE eBCDOverflowException.create ( 'in StrToBCD' );
          end
          end
@@ -1727,7 +1727,10 @@ IMPLEMENTATION
             then begin
             then begin
 {$ifndef use_ansistring}
 {$ifndef use_ansistring}
               Inc ( l );
               Inc ( l );
-              result[1] := '0';
+              if Neg then
+                result[2] := '0'
+              else
+                result[1] := '0'
 {$else}
 {$else}
               result := result + '0';
               result := result + '0';
 {$endif}
 {$endif}

+ 10 - 10
rtl/objpas/sysutils/dati.inc

@@ -510,22 +510,22 @@ end;
 
 
 function StrToDate(const S: ShortString; separator : char): TDateTime;
 function StrToDate(const S: ShortString; separator : char): TDateTime;
 begin
 begin
-    result := StrToDate(@S[1],Length(s),ShortDateFormat,separator)
+    result := StrToDate(@S[1],Length(s),DefaultFormatSettings.ShortDateFormat,separator)
 end;
 end;
 
 
 function StrToDate(const S: ShortString): TDateTime;
 function StrToDate(const S: ShortString): TDateTime;
 begin
 begin
-    result := StrToDate(@S[1],Length(s),ShortDateFormat,#0);
+    result := StrToDate(@S[1],Length(s),DefaultFormatSettings.ShortDateFormat,#0);
 end;
 end;
 
 
 function StrToDate(const S: AnsiString; separator : char): TDateTime;
 function StrToDate(const S: AnsiString; separator : char): TDateTime;
 begin
 begin
-    result := StrToDate(@S[1],Length(s),ShortDateFormat,separator)
+    result := StrToDate(@S[1],Length(s),DefaultFormatSettings.ShortDateFormat,separator)
 end;
 end;
 
 
 function StrToDate(const S: AnsiString): TDateTime;
 function StrToDate(const S: AnsiString): TDateTime;
 begin
 begin
-    result := StrToDate(@S[1],Length(s),ShortDateFormat,#0);
+    result := StrToDate(@S[1],Length(s),DefaultFormatSettings.ShortDateFormat,#0);
 end;
 end;
 
 
 {   StrToTime converts the string S to a TDateTime value
 {   StrToTime converts the string S to a TDateTime value
@@ -736,7 +736,7 @@ function StrToDateTime(const s: string): TDateTime;
 var
 var
   I: integer;
   I: integer;
 begin
 begin
-  I:=Pos(TimeSeparator,S);
+  I:=Pos(DefaultFormatSettings.TimeSeparator,S);
   If (I>0) then
   If (I>0) then
     begin
     begin
     While (I>0) and (S[I]<>' ') do
     While (I>0) and (S[I]<>' ') do
@@ -754,7 +754,7 @@ function StrToDateTime(const s: AnsiString; const UseFormat : TFormatSettings):
 var
 var
   I: integer;
   I: integer;
 begin
 begin
-  I:=Pos(TimeSeparator,S);
+  I:=Pos(UseFormat.TimeSeparator,S);
   If (I>0) then
   If (I>0) then
     begin
     begin
     While (I>0) and (S[I]<>' ') do
     While (I>0) and (S[I]<>' ') do
@@ -773,7 +773,7 @@ function StrToDateTime(const s: ShortString; const UseFormat : TFormatSettings):
 var
 var
   I: integer;
   I: integer;
 begin
 begin
-  I:=Pos(TimeSeparator,S);
+  I:=Pos(UseFormat.TimeSeparator,S);
   If (I>0) then
   If (I>0) then
     begin
     begin
     While (I>0) and (S[I]<>' ') do
     While (I>0) and (S[I]<>' ') do
@@ -1196,19 +1196,19 @@ end;
 
 
 function TryStrToDate(const S: ShortString; out Value: TDateTime; separator : char): Boolean;
 function TryStrToDate(const S: ShortString; out Value: TDateTime; separator : char): Boolean;
 begin
 begin
-  Result:=TryStrToDate(S,Value,ShortDateFormat,Separator);
+  Result:=TryStrToDate(S,Value,DefaultFormatSettings.ShortDateFormat,Separator);
 end;
 end;
 
 
 
 
 function TryStrToDate(const S: AnsiString; out Value: TDateTime): Boolean;
 function TryStrToDate(const S: AnsiString; out Value: TDateTime): Boolean;
 begin
 begin
-  Result:=TryStrToDate(S,Value,ShortDateFormat,#0);
+  Result:=TryStrToDate(S,Value,DefaultFormatSettings.ShortDateFormat,#0);
 end;
 end;
 
 
 function TryStrToDate(const S: AnsiString; out Value: TDateTime; separator : char): Boolean;
 function TryStrToDate(const S: AnsiString; out Value: TDateTime; separator : char): Boolean;
 
 
 begin
 begin
-  Result:=TryStrToDate(S,Value,ShortDateFormat,Separator);
+  Result:=TryStrToDate(S,Value,DefaultFormatSettings.ShortDateFormat,Separator);
 end;
 end;
 
 
 function TryStrToDate(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean;
 function TryStrToDate(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean;

+ 21 - 19
rtl/objpas/sysutils/sysinth.inc

@@ -78,6 +78,8 @@ var
     LongDayNames:  ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
     LongDayNames:  ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
     TwoDigitYearCenturyWindow: 50;
     TwoDigitYearCenturyWindow: 50;
   );
   );
+
+  FormatSettings : TFormatSettings absolute DefaultFormatSettings;
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
     Date formatting settings
     Date formatting settings
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
@@ -85,41 +87,41 @@ var
 Var
 Var
 
 
    { Character to be put between date, month and year }
    { Character to be put between date, month and year }
-   DateSeparator: char absolute DefaultFormatSettings.DateSeparator;
+   DateSeparator: char absolute DefaultFormatSettings.DateSeparator deprecated;
 
 
    { Format used for short date notation }
    { Format used for short date notation }
-   ShortDateFormat: string absolute DefaultFormatSettings.ShortDateFormat;
+   ShortDateFormat: string absolute DefaultFormatSettings.ShortDateFormat deprecated;
 
 
    { Format used for long date notation }
    { Format used for long date notation }
-   LongDateFormat: string absolute DefaultFormatSettings.LongDateFormat;
+   LongDateFormat: string absolute DefaultFormatSettings.LongDateFormat deprecated;
 
 
 
 
    { Short names of months. }
    { Short names of months. }
-   ShortMonthNames: TMonthNameArray absolute DefaultFormatSettings.ShortMonthNames;
+   ShortMonthNames: TMonthNameArray absolute DefaultFormatSettings.ShortMonthNames deprecated;
 
 
    { Long names of months. }
    { Long names of months. }
-   LongMonthNames: TMonthNameArray absolute DefaultFormatSettings.LongMonthNames;
+   LongMonthNames: TMonthNameArray absolute DefaultFormatSettings.LongMonthNames deprecated;
 
 
    { Short names of days }
    { Short names of days }
-   ShortDayNames: TWeekNameArray absolute DefaultFormatSettings.ShortDayNames;
+   ShortDayNames: TWeekNameArray absolute DefaultFormatSettings.ShortDayNames deprecated;
 
 
    { Full names of days }
    { Full names of days }
-   LongDayNames: TWeekNameArray absolute DefaultFormatSettings.LongDayNames;
+   LongDayNames: TWeekNameArray absolute DefaultFormatSettings.LongDayNames deprecated;
 
 
    { Format used for short time notation }
    { Format used for short time notation }
-   ShortTimeFormat: string absolute DefaultFormatSettings.ShortTimeFormat;
+   ShortTimeFormat: string absolute DefaultFormatSettings.ShortTimeFormat deprecated;
 
 
    { Format used for long time notation }
    { Format used for long time notation }
-   LongTimeFormat: string absolute DefaultFormatSettings.LongTimeFormat;
+   LongTimeFormat: string absolute DefaultFormatSettings.LongTimeFormat deprecated;
 
 
    { Character to be put between hours and minutes }
    { Character to be put between hours and minutes }
-   TimeSeparator: char absolute DefaultFormatSettings.TimeSeparator;
+   TimeSeparator: char absolute DefaultFormatSettings.TimeSeparator deprecated;
 
 
    { String to indicate AM time when using 12 hour clock. }
    { String to indicate AM time when using 12 hour clock. }
-   TimeAMString: string absolute DefaultFormatSettings.TimeAMString;
+   TimeAMString: string absolute DefaultFormatSettings.TimeAMString deprecated;
 
 
    { String to indicate PM time when using 12 hour clock. }
    { String to indicate PM time when using 12 hour clock. }
-   TimePMString: string absolute DefaultFormatSettings.TimePMString;
+   TimePMString: string absolute DefaultFormatSettings.TimePMString deprecated;
 
 
 
 
 
 
@@ -129,13 +131,13 @@ Var
 
 
 
 
   { Character that comes between integer and fractional part of a number }
   { Character that comes between integer and fractional part of a number }
-  DecimalSeparator : Char absolute DefaultFormatSettings.DecimalSeparator; 
+  DecimalSeparator : Char absolute DefaultFormatSettings.DecimalSeparator deprecated;
 
 
   { Character that is put every 3 numbers in a currency }
   { Character that is put every 3 numbers in a currency }
-  ThousandSeparator : Char absolute DefaultFormatSettings.ThousandSeparator;
+  ThousandSeparator : Char absolute DefaultFormatSettings.ThousandSeparator deprecated;
 
 
   { Number of decimals to use when formatting a currency.  }
   { Number of decimals to use when formatting a currency.  }
-  CurrencyDecimals : Byte absolute DefaultFormatSettings.CurrencyDecimals;
+  CurrencyDecimals : Byte absolute DefaultFormatSettings.CurrencyDecimals deprecated;
 
 
   { Format to use when formatting currency :
   { Format to use when formatting currency :
     0 = $1
     0 = $1
@@ -144,7 +146,7 @@ Var
     3 = 1 $
     3 = 1 $
     4 = Currency string replaces decimal indicator. e.g. 1$50
     4 = Currency string replaces decimal indicator. e.g. 1$50
    }
    }
-  CurrencyFormat : Byte absolute DefaultFormatSettings.CurrencyFormat;
+  CurrencyFormat : Byte absolute DefaultFormatSettings.CurrencyFormat deprecated;
 
 
   { Same as above, only for negative currencies:
   { Same as above, only for negative currencies:
     0 = ($1)
     0 = ($1)
@@ -159,12 +161,12 @@ Var
     9 = -$ 1
     9 = -$ 1
     10 = $ 1-
     10 = $ 1-
    }
    }
-  NegCurrFormat : Byte absolute DefaultFormatSettings.NegCurrFormat;
+  NegCurrFormat : Byte absolute DefaultFormatSettings.NegCurrFormat deprecated;
 
 
   { Currency notation. Default is $ for dollars. }
   { Currency notation. Default is $ for dollars. }
-  CurrencyString : String absolute DefaultFormatSettings.CurrencyString;
+  CurrencyString : String absolute DefaultFormatSettings.CurrencyString deprecated;
 
 
-  ListSeparator: Char absolute DefaultFormatSettings.ListSeparator;
+  ListSeparator: Char absolute DefaultFormatSettings.ListSeparator deprecated;
 
 
 type
 type
   TSysLocale = record
   TSysLocale = record

+ 2 - 5
rtl/objpas/sysutils/sysstr.inc

@@ -1169,9 +1169,7 @@ Var
   // removes negative sign in case when result is zero eg. -0.00
   // removes negative sign in case when result is zero eg. -0.00
   var
   var
     i: PtrInt;
     i: PtrInt;
-    S: String;
     TS: Char;
     TS: Char;
-    B: Boolean;
     StartPos: PtrInt;
     StartPos: PtrInt;
   begin
   begin
     Result := False;
     Result := False;
@@ -1180,7 +1178,6 @@ Var
     else
     else
       StartPos := 2;
       StartPos := 2;
     TS := FormatSettings.ThousandSeparator;
     TS := FormatSettings.ThousandSeparator;
-    S := '';
     for i := StartPos to length(AValue) do
     for i := StartPos to length(AValue) do
     begin
     begin
       Result := (AValue[i] in ['0', DS, 'E', '+', TS]);
       Result := (AValue[i] in ['0', DS, 'E', '+', TS]);
@@ -1430,7 +1427,7 @@ Begin
         End
         End
         Else
         Else
         Begin
         Begin
-          Case NegCurrFormat Of
+          Case FormatSettings.NegCurrFormat Of
             0: Result := '(' + FormatSettings.CurrencyString + Result + ')';
             0: Result := '(' + FormatSettings.CurrencyString + Result + ')';
             1: Result := '-' + FormatSettings.CurrencyString + Result;
             1: Result := '-' + FormatSettings.CurrencyString + Result;
             2: Result := FormatSettings.CurrencyString + '-' + Result;
             2: Result := FormatSettings.CurrencyString + '-' + Result;
@@ -2899,7 +2896,7 @@ function sscanf(const s: string; const fmt : string;const Pointers : array of Po
       while (Length(s) > n) and (s[n] = ' ')  do
       while (Length(s) > n) and (s[n] = ' ')  do
         inc(n);
         inc(n);
       while (Length(s) >= n) and
       while (Length(s) >= n) and
-            (s[n] in ['0'..'9', '+', '-', DecimalSeparator, 'e', 'E']) do
+            (s[n] in ['0'..'9', '+', '-', FormatSettings.DecimalSeparator, 'e', 'E']) do
         begin
         begin
           s1 := s1+s[n];
           s1 := s1+s[n];
           inc(n);
           inc(n);