diff --git a/src/builtins/printf.cpp b/src/builtins/printf.cpp index c733bfb0c..7a09438e2 100644 --- a/src/builtins/printf.cpp +++ b/src/builtins/printf.cpp @@ -53,6 +53,7 @@ #include "printf.h" #include +#include #include #include #include @@ -174,7 +175,7 @@ void builtin_printf_state_t::append_format_output(const wchar_t *fmt, ...) { } void builtin_printf_state_t::verify_numeric(const wchar_t *s, const wchar_t *end, int errcode) { - if (errcode != 0) { + if (errcode != 0 && errcode != EINVAL) { if (errcode == ERANGE) { this->fatal_error(L"%ls: %ls", s, _(L"Number out of range")); } else { @@ -201,16 +202,14 @@ void builtin_printf_state_t::verify_numeric(const wchar_t *s, const wchar_t *end template static T raw_string_to_scalar_type(const wchar_t *s, wchar_t **end); -// we use wcstoll instead of wcstoimax because FreeBSD 8 has busted wcstoumax and wcstoimax - see -// #626 template <> intmax_t raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) { - return std::wcstoll(s, end, 0); + return std::wcstoimax(s, end, 0); } template <> uintmax_t raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) { - return std::wcstoull(s, end, 0); + return std::wcstoumax(s, end, 0); } template <> diff --git a/tests/checks/printf.fish b/tests/checks/printf.fish index cecbbaa12..1c3a15afc 100644 --- a/tests/checks/printf.fish +++ b/tests/checks/printf.fish @@ -1,5 +1,9 @@ # RUN: %fish %s +printf "%d %d\n" 1 2 3 +# CHECK: 1 2 +# CHECK: 3 0 + printf "Hello %d %i %f %F %g %G\n" 1 2 3 4 5 6 # CHECK: Hello 1 2 3.000000 4.000000 5 6