Bugs item #1479316, was opened at 2006-04-30 13:48
Message generated for change (Settings changed) made by dbaelde
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=591456&aid=1479316&group_id=89802
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Xavier Cazin (xaviercazin)
Assigned to: David Baelde (dbaelde)
Summary: Error in operators that expect floats
Initial Comment:
While trying using operators that expect floats as
parameters, like "change volume" and "delay", I get the
following message:
liquidsoap -c /etc/liquidsoap/primo.liq
Line 42, char 22 before "1.2": Unknown error
Fatal error: exception Failure("float_of_string")
here, line 42 is:
change_volume(1.2,foo)
When changed to only "foo", it works. Same issue with
"delay(5.0,foo)" for instance.
----------------------------------------------------------------------
>Comment By: David Baelde (dbaelde)
Date: 2006-05-02 20:04
Message:
Logged In: YES
user_id=640545
Then I commit that modification. Camomile probably does
stuff with locales which ends up setting LC_NUMERIC and
breaks float_of_string.
----------------------------------------------------------------------
Comment By: Xavier Cazin (xaviercazin)
Date: 2006-05-01 19:23
Message:
Logged In: YES
user_id=1513427
I'm sorry, I thought you'd applied the patch in the
revision... Now that I did it myself it does work whatever
the value of LANG is! Thanks :-)
For the record, here is the result you were asking for (not
sure it is useful anymore):
[EMAIL PROTECTED]:~$ ocaml
Objective Caml version 3.09.1
# (float_of_string "4.2");;
- : float = 4.2
#
It also works whatever the value of $LANG.
Thanks a lot!
----------------------------------------------------------------------
Comment By: David Baelde (dbaelde)
Date: 2006-05-01 14:39
Message:
Logged In: YES
user_id=640545
Sorry to bother you but I need more information:
Could you tell us which version of OCaml you use ?
Can you run (float_of_string "4.2") in a Caml toplevel ? If
not you shouldn't be able to run convert "4" either,
considering that my patch didn't work.
Does it work with (float_of_string x) being replaced by
(float_of_int (int_of_string x)) in my patch ? If not I'm
going crazy..
----------------------------------------------------------------------
Comment By: Xavier Cazin (xaviercazin)
Date: 2006-05-01 08:38
Message:
Logged In: YES
user_id=1513427
You did guess right, but the patch doesn't seem to avoid the
need to change the locale. See below (on svn revision 2439).
[EMAIL PROTECTED]:~$ echo $LANG
fr_FR.UTF-8
[EMAIL PROTECTED]:~$ liquidsoap -c /etc/liquidsoap/primo.liq
Line 42, char 22 before "1.2": Unknown error
Fatal error: exception Failure("float_of_string")
[EMAIL PROTECTED]:~$ export LANG=en_GB
[EMAIL PROTECTED]:~$ liquidsoap -c /etc/liquidsoap/primo.liq
[EMAIL PROTECTED]:~$
----------------------------------------------------------------------
Comment By: David Baelde (dbaelde)
Date: 2006-04-30 22:59
Message:
Logged In: YES
user_id=640545
It might be a locale issue, if you're using french for
example. However, I cannot reproduce it at all. If I guessed
right, the following modification might help.
--- tools/lang_lexer.mll (revision 2435)
+++ tools/lang_lexer.mll (working copy)
@@ -58,7 +58,14 @@
| "true" { BOOL true }
| "false" { BOOL false }
| int_literal { INT (int_of_string (Lexing.lexeme lexbuf)) }
- | float_literal { FLOAT (float_of_string (Lexing.lexeme
lexbuf)) }
+ | (['0'-'9']* as ipart) '.' (['0'-'9']* as fpart)
+ { let fpart = if fpart = "" then 0. else
+ (float_of_string fpart) /.
+ (10. ** (float_of_int (String.length fpart)))
+ in
+ let ipart = if ipart = "" then 0. else
float_of_string ipart in
+ Printf.printf "Got %f\n" (ipart +. fpart) ;
+ FLOAT (ipart +. fpart) }
| var { VAR (Lexing.lexeme lexbuf) }
| '\'' (([^'\''] | '\\' '\'')* as s) '\'' {
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=591456&aid=1479316&group_id=89802