1
Vote

Use RealToStrInvar instead of RealToStr in IlasmUtil.cp

description

There is a problem (at least) with the generation of ilasm files.
 
This test program won't compile with option /ilasm :
 
C:\prj_cp>type Numbers.cp
MODULE Numbers;
 
CONST
e* = 2.78129;
VAR
pi : REAL;
BEGIN
pi := 3.141;
END Numbers.
 
All is well with option /perwapi :
 
C:\prj_cp>gpcp /perwapi Numbers.cp

gpcp: Emitted Numbers.DLL

gpcp: <Numbers> No errors

 
but look:

C:\prj_cp>gpcp /ilasm Numbers.cp
1 MODULE Numbers;
**** -------^ ILASM failed to assemble IL file

gpcp: <Numbers> There was one error

 
C:\prj_cp>ilasm Numbers.il
 
Microsoft (R) .NET Framework IL Assembler. Version 2.0.50727.3053
Copyright (c) Microsoft Corporation. All rights reserved.
Assembling 'Numbers.il' to EXE --> 'Numbers.exe'
Source file is ANSI
 
Numbers.cp(8) : error : syntax error at token ',' in: ldc.r8 3,141
 
***** FAILURE *****
 
 
The problem lies in procedure CodeR in ILASMUTIL.CP :
 
Problem in IlasmUtil.cp :
 
PROCEDURE (os : IlasmFile)CodeR*(code : INTEGER; real : REAL);
VAR nam : ARRAY 64 OF CHAR;
BEGIN
os.Prefix(code);
RTS.RealToStr(real, nam); <----- This Line is wrong!
os.Tstring(nam$);
os.Suffix(code);
END CodeR;
 
Here must be used:
 
RTS.RealToStrInvar(real, nam);
 
because otherwise the local culture is used, in my case "de-DE", and
RTS.RealToStr writes then real numbers with comma (This is correct in Germany.)
instead of a dot to the il file. The ilasm language needs a dot in floating point numbers!
 
I found four places coming in question:
 
---------- BROWSE.CP
RTS.RealToStr(f.fltVal,str);
---------- EXPRDESC.CP
RTS.RealToStr(s.value.real(), name);
---------- ILASMUTIL.CP
RTS.RealToStr(real, nam);
---------- JSMNUTIL.CP
RTS.RealToStr(real, nam);
 
I beliebe, we have to use RTS.RealToStrInvar at least in ILASMUTIL.CP and JSMNUTIL.CP
and also in BROWSE.CP, because:
 
C:\prj_cp>browse Numbers
MODULE Numbers;
 
IMPORT
RTS := "[RTS]";
 
CONST
e* = 2,78129; <----- This Line is wrong!
 
END Numbers.
 
Tom

comments