In the midst of working on system file stuff, I noticed that
width_to_bytes in src/data/variable.c is more complex than
needed.  I'd like to check in the following change to make its
operation clearer.  Comments?

Index: variable.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/variable.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 variable.c
--- variable.c  8 Jul 2006 03:05:51 -0000       1.9
+++ variable.c  21 Sep 2006 02:42:18 -0000
@@ -356,30 +358,19 @@ dict_class_to_name (enum dict_class dict
 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); 
+    }
 }
 
 


-- 
Ben Pfaff 
email: [EMAIL PROTECTED]
web: http://benpfaff.org


_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to