Skip to content

Commit

Permalink
Printf work
Browse files Browse the repository at this point in the history
  • Loading branch information
floam committed Sep 6, 2016
1 parent ce9bd95 commit 7ee5b51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/builtin_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include <sys/types.h>
#include <wchar.h>
#include <wctype.h>
#include <stddef.h>
#include <inttypes.h>

#include "builtin.h"
#include "common.h"
Expand Down Expand Up @@ -254,18 +256,18 @@ static T raw_string_to_scalar_type(const wchar_t *s, wchar_t **end);
// #626
template <>
intmax_t raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) {
return wcstoll(s, end, 0);
return wcstoimax(s, end, 0);
}

template <>
uintmax_t raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) {
return wcstoull(s, end, 0);
return wcstoumax(s, end, 0);
}

template <>
long double raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) {
double val = wcstod(s, end);
if (**end == L'\0') return val;
if (**end == L'\0' && *s != L'\0') return val;

// The conversion using the user's locale failed. That may be due to the string not being a
// valid floating point value. It could also be due to the locale using different separator
Expand Down

0 comments on commit 7ee5b51

Please sign in to comment.