From 2de8bafb5c02a0ebc1a5a087c9728f45bf0b5ac9 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 27 Jan 2007 05:36:11 +0000 Subject: [PATCH] Fix padding of x when literal is sized and unsigned. --- lexor.lex | 8 ++++---- pform.cc | 7 +++++-- verinum.cc | 11 ++++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lexor.lex b/lexor.lex index 38604c0a6..9a8228d1b 100644 --- a/lexor.lex +++ b/lexor.lex @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: lexor.lex,v 1.92 2006/07/31 03:50:17 steve Exp $" +#ident "$Id: lexor.lex,v 1.93 2007/01/27 05:36:11 steve Exp $" #endif # include "config.h" @@ -460,7 +460,7 @@ static verinum*make_unsized_binary(const char*txt) ptr += 1; } - verinum*out = new verinum(bits, size); + verinum*out = new verinum(bits, size, false); out->has_sign(sign_flag); delete[]bits; return out; @@ -520,7 +520,7 @@ static verinum*make_unsized_octal(const char*txt) ptr += 1; } - verinum*out = new verinum(bits, size); + verinum*out = new verinum(bits, size, false); out->has_sign(sign_flag); delete[]bits; return out; @@ -590,7 +590,7 @@ static verinum*make_unsized_hex(const char*txt) ptr += 1; } - verinum*out = new verinum(bits, size); + verinum*out = new verinum(bits, size, false); out->has_sign(sign_flag); delete[]bits; return out; diff --git a/pform.cc b/pform.cc index c515c1893..9658c084f 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.cc,v 1.138 2007/01/16 05:44:15 steve Exp $" +#ident "$Id: pform.cc,v 1.139 2007/01/27 05:36:11 steve Exp $" #endif # include "config.h" @@ -199,7 +199,7 @@ verinum* pform_verinum_with_size(verinum*siz, verinum*val, break; } - verinum*res = new verinum(pad, size); + verinum*res = new verinum(pad, size, true); unsigned copy = val->len(); if (res->len() < copy) @@ -1744,6 +1744,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.139 2007/01/27 05:36:11 steve + * Fix padding of x when literal is sized and unsigned. + * * Revision 1.138 2007/01/16 05:44:15 steve * Major rework of array handling. Memories are replaced with the * more general concept of arrays. The NetMemory and NetEMemory diff --git a/verinum.cc b/verinum.cc index 8e223c723..4ed2c95b5 100644 --- a/verinum.cc +++ b/verinum.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: verinum.cc,v 1.50 2007/01/19 05:42:04 steve Exp $" +#ident "$Id: verinum.cc,v 1.51 2007/01/27 05:36:11 steve Exp $" #endif # include "config.h" @@ -352,6 +352,12 @@ verinum pad_to_width(const verinum&that, unsigned width) verinum::V pad = that[that.len()-1]; if (pad==verinum::V1 && !that.has_sign()) pad = verinum::V0; + if (that.has_len()) { + if (pad==verinum::Vx) + pad = verinum::V0; + if (pad==verinum::Vz) + pad = verinum::V0; + } verinum val(pad, width, that.has_len()); @@ -1056,6 +1062,9 @@ verinum::V operator ^ (verinum::V l, verinum::V r) /* * $Log: verinum.cc,v $ + * Revision 1.51 2007/01/27 05:36:11 steve + * Fix padding of x when literal is sized and unsigned. + * * Revision 1.50 2007/01/19 05:42:04 steve * Fix calculation of verinum pow operation. *