Browse Source

Fix issues by adding support for floating point values in va_list

Jeremy Soller 7 years ago
parent
commit
a95a034219
3 changed files with 3 additions and 3 deletions
  1. 1 1
      src/stdio/src/printf.rs
  2. 1 1
      tests/atof.c
  3. 1 1
      va_list

+ 1 - 1
src/stdio/src/printf.rs

@@ -36,7 +36,7 @@ pub unsafe fn printf<W: fmt::Write>(mut w: W, format: *const c_char, mut ap: VaL
                     found_percent = false;
                 }
                 'f' | 'F' => {
-                    let a: f64 = mem::transmute(ap.get::<u64>());
+                    let a = ap.get::<f64>();
 
                     w.write_fmt(format_args!("{}", a));
 

+ 1 - 1
tests/atof.c

@@ -2,7 +2,7 @@
 #include <stdio.h>
 
 int main(int argc, char* argv[]) {
-    double d = atof("1.0");
+    double d = atof("-3.14");
     printf("%f\n", d);
     return 0;
 }

+ 1 - 1
va_list

@@ -1 +1 @@
-Subproject commit 4762a184501beedbb58ea218f0c84fea85685c35
+Subproject commit 1945668b2fc6e96c498003dce700ebaf95108fac