From a95a0342197fc20185fbc5ab688ef1619a2b5608 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Thu, 8 Mar 2018 20:54:46 -0700 Subject: [PATCH] Fix issues by adding support for floating point values in va_list --- src/stdio/src/printf.rs | 2 +- tests/atof.c | 2 +- va_list | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stdio/src/printf.rs b/src/stdio/src/printf.rs index ead0a05c..54ce1f76 100644 --- a/src/stdio/src/printf.rs +++ b/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)); diff --git a/tests/atof.c b/tests/atof.c index b6668aab..1bfb9d0e 100644 --- a/tests/atof.c +++ b/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; } diff --git a/va_list b/va_list index 4762a184..1945668b 160000 --- a/va_list +++ b/va_list @@ -1 +1 @@ -Subproject commit 4762a184501beedbb58ea218f0c84fea85685c35 +Subproject commit 1945668b2fc6e96c498003dce700ebaf95108fac -- GitLab