From: Ben Pfaff Date: Thu, 17 Sep 2009 03:19:34 +0000 (-0700) Subject: Don't pad variable labels written to system files. X-Git-Tag: build40^2~1 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46a7a7b189e2df740043496c16d9f7c665b7a828;p=pspp-builds.git Don't pad variable labels written to system files. Previously, the code to write variable labels to system files accidentally padded out the variable labels on the right with spaces to a multiple of 4 bytes in length. With this commit, variable labels will no longer be padded. This fixes a genuine bug for variable labels longer than 252 bytes, which previously were padded out to 256 bytes. Variable labels are limited to a maximum of 255 bytes, so PSPP refused to read such files. Reported-by: Robert Westlund --- diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 7804e591..001b78f1 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -436,8 +436,9 @@ write_variable (struct sfm_writer *w, const struct variable *v) if (var_has_label (v)) { const char *label = var_get_label (v); - size_t padded_len = ROUND_UP (MIN (strlen (label), 255), 4); - write_int (w, padded_len); + size_t label_len = MIN (strlen (label), 255); + size_t padded_len = ROUND_UP (label_len, 4); + write_int (w, label_len); write_string (w, label, padded_len); }