From 6c5884853f2d9f8dfd012083ef37b8456924a208 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 12 Jun 2015 07:28:44 -0400 Subject: [PATCH] Fix string-to-int space conversion, bug931. --- Changes | 2 ++ include/verilated.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 79aff6914..5611ec91e 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix .c files to be treated as .cpp, bug930. [Jonathon Donaldson] +**** Fix string-to-int space conversion, bug931. [Fabrizio Ferrandi] + * Verilator 3.874 2015-06-06 diff --git a/include/verilated.cpp b/include/verilated.cpp index 37699000b..7c44c6a90 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -708,8 +708,8 @@ void _VL_VINT_TO_STRING(int obits, char* destoutp, WDataInP sourcep) { start = false; // Drop leading 0s } } - *destp++ = '\0'; // Terminate - while (isspace(*(destp-1)) && destp>destoutp) *--destp = '\0'; // Drop trailing spaces + *destp = '\0'; // Terminate + if (!start) while (isspace(*(destp-1)) && destp>destoutp) *--destp = '\0'; // Drop trailing spaces } void _VL_STRING_TO_VINT(int obits, void* destp, int srclen, const char* srcp) {