From 992e1d005974235247ac41ab89a05a05e885575d Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Mon, 20 Feb 2017 18:43:13 -0800 Subject: [PATCH] use a consistent ERANGE message The previous change neglected to consider that numbers too large for the long long datatype will result in calling strerror(ERANGE) whose return value can vary depending on the platform. Which breaks the unit test. --- src/builtin_printf.cpp | 6 +++++- tests/printf.err | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/builtin_printf.cpp b/src/builtin_printf.cpp index 3ec49dd8b..2d6a48b39 100644 --- a/src/builtin_printf.cpp +++ b/src/builtin_printf.cpp @@ -240,7 +240,11 @@ 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) { - this->fatal_error(L"%ls: %s", s, strerror(errcode)); + if (errcode == ERANGE) { + this->fatal_error(L"%ls: %ls", s, _(L"Number out of range")); + } else { + this->fatal_error(L"%ls: %s", s, strerror(errcode)); + } } else if (*end) { if (s == end) this->fatal_error(_(L"%ls: expected a numeric value"), s); diff --git a/tests/printf.err b/tests/printf.err index e04bd0f0f..40686c8f9 100644 --- a/tests/printf.err +++ b/tests/printf.err @@ -1,2 +1,2 @@ 2,34: value not completely converted -0xABCDEF12345678901: Result too large +0xABCDEF12345678901: Number out of range