Browse Source

* iso conformant writing of floats (using e instead of E) in iso mode

git-svn-id: trunk@15684 -
florian 15 years ago
parent
commit
c506913e9b
4 changed files with 29 additions and 0 deletions
  1. 5 0
      compiler/ninl.pas
  2. 1 0
      rtl/inc/compproc.inc
  3. 12 0
      rtl/inc/real2str.inc
  4. 11 0
      rtl/inc/text.inc

+ 5 - 0
compiler/ninl.pas

@@ -446,6 +446,11 @@ implementation
                 else
                 else
                   begin
                   begin
                     name := procprefixes[do_read]+'float';
                     name := procprefixes[do_read]+'float';
+
+                    { iso pascal needs a different handler due to upper/lower E differences }
+                    if (m_iso in current_settings.modeswitches) and not(do_read) then
+                       name:=name+'_iso';
+
                     readfunctype:=pbestrealtype^;
                     readfunctype:=pbestrealtype^;
                   end;
                   end;
               end;
               end;

+ 1 - 0
rtl/inc/compproc.inc

@@ -479,6 +479,7 @@ procedure fpc_write_text_int64(len : longint;var t : text;i : int64); compilerpr
 {$endif CPU64}
 {$endif CPU64}
 {$ifndef FPUNONE}
 {$ifndef FPUNONE}
 Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); compilerproc;
 Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); compilerproc;
+Procedure fpc_Write_Text_Float_Iso(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); compilerproc;
 {$endif}
 {$endif}
 procedure fpc_write_text_enum(typinfo,ord2strindex:pointer;len:sizeint;var t:text;ordinal:longint); compilerproc;
 procedure fpc_write_text_enum(typinfo,ord2strindex:pointer;len:sizeint;var t:text;ordinal:longint); compilerproc;
 {$ifdef FPC_HAS_STR_CURRENCY}
 {$ifdef FPC_HAS_STR_CURRENCY}

+ 12 - 0
rtl/inc/real2str.inc

@@ -454,3 +454,15 @@ begin
     else s:=temp;
     else s:=temp;
 end;
 end;
 
 
+
+Procedure str_real_iso (len,f : longint; d : ValReal; real_type :treal_type; out s : string);
+  var
+   i : Integer;
+  begin
+    str_real(len,f,d,real_type,s);
+    for i:=1 to Length(s) do
+      if s[i]='E' then
+        s[i]:='e';
+  end;
+
+

+ 11 - 0
rtl/inc/text.inc

@@ -728,6 +728,17 @@ Begin
   Str_real(Len,fixkomma,r,treal_type(rt),s);
   Str_real(Len,fixkomma,r,treal_type(rt),s);
   Write_Str(Len,t,s);
   Write_Str(Len,t,s);
 End;
 End;
+
+
+Procedure fpc_Write_Text_Float_iso(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); iocheck; compilerproc;
+var
+  s : String;
+Begin
+  If (InOutRes<>0) then
+   exit;
+  Str_real_iso(Len,fixkomma,r,treal_type(rt),s);
+  Write_Str(Len,t,s);
+End;
 {$endif}
 {$endif}
 
 
 procedure fpc_write_text_enum(typinfo,ord2strindex:pointer;len:sizeint;var t:text;ordinal:longint); iocheck; compilerproc;
 procedure fpc_write_text_enum(typinfo,ord2strindex:pointer;len:sizeint;var t:text;ordinal:longint); iocheck; compilerproc;