From dc17190f4d67c9f307903d00114695023125c48b Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 13 Jan 2011 19:33:02 -0800 Subject: [PATCH] Keep nulls in a verinum and keep as string when padding is mod 8. For diagnostics and to know what is really going on in the compiler we need to keep any NULL that is in a verinum string or when displayed as/converted to a string. When padding a verinum string if the padding is in multiples of eight then keep the string property. --- verinum.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/verinum.cc b/verinum.cc index 712098b3d..5c79077dc 100644 --- a/verinum.cc +++ b/verinum.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -496,7 +496,6 @@ string verinum::as_string() const return ""; string res; - bool leading_nuls = true; for (unsigned idx = nbits_ ; idx > 0 ; idx -= 8) { char char_val = 0; V*bp = bits_+idx; @@ -509,8 +508,6 @@ string verinum::as_string() const if (*(--bp) == V1) char_val |= 0x04; if (*(--bp) == V1) char_val |= 0x02; if (*(--bp) == V1) char_val |= 0x01; - if (char_val == 0 && leading_nuls) - continue; if (char_val == '"' || char_val == '\\') { char tmp[5]; @@ -588,6 +585,9 @@ verinum pad_to_width(const verinum&that, unsigned width) val.set(idx, that[idx]); val.has_sign(that.has_sign()); + if (that.is_string() && (width % 8) == 0) { + val = verinum(val.as_string()); + } return val; }