From 6836cbca31d72c075de04e80d937b704fae20394 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 21 Sep 2006 14:01:09 +0000 Subject: [PATCH] * variable.c: (width_to_bytes) Rephrase code for clarify. --- src/data/ChangeLog | 4 ++++ src/data/variable.c | 29 +++++++++-------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/data/ChangeLog b/src/data/ChangeLog index c9463256..30864442 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,7 @@ +Thu Sep 21 07:00:30 2006 Ben Pfaff + + * variable.c: (width_to_bytes) Rephrase code for clarify. + Sun Jul 16 19:52:03 2006 Ben Pfaff * format.c: (fmt_type_from_string) New function. diff --git a/src/data/variable.c b/src/data/variable.c index 435980e3..7a631a73 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -356,30 +356,19 @@ dict_class_to_name (enum dict_class dict_class) int width_to_bytes(int width) { - const int chunks = width / EFFECTIVE_LONG_STRING_LENGTH ; - const int remainder = width - (chunks * EFFECTIVE_LONG_STRING_LENGTH) ; - int bytes, mod8; - assert (width >= 0); if ( width == 0 ) return MAX_SHORT_STRING ; - - if ( width <= MAX_LONG_STRING) - return MAX_SHORT_STRING * DIV_RND_UP(width, MAX_SHORT_STRING); - - - bytes = remainder + (chunks * (MAX_LONG_STRING + 1) ); - - /* Round up to the nearest 8 */ - mod8 = bytes % MAX_SHORT_STRING; - - if ( mod8 ) - bytes += MAX_SHORT_STRING - mod8; - - assert( bytes % MAX_SHORT_STRING == 0 ); - - return bytes; + else if (width <= MAX_LONG_STRING) + return ROUND_UP (width, MAX_SHORT_STRING); + else + { + int chunks = width / EFFECTIVE_LONG_STRING_LENGTH ; + int remainder = width % EFFECTIVE_LONG_STRING_LENGTH ; + int bytes = remainder + (chunks * (MAX_LONG_STRING + 1) ); + return ROUND_UP (bytes, MAX_SHORT_STRING); + } } -- 2.30.2