[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Don't pad variable labels written to system files.
From: |
Ben Pfaff |
Subject: |
Re: [PATCH] Don't pad variable labels written to system files. |
Date: |
Wed, 16 Sep 2009 20:24:21 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
It turned out that did fix a real problem that Robert Westlund
reported, so I pushed it out to the stable branch.
Ben Pfaff <address@hidden> writes:
> I swear I've sent this patch out before, but Google couldn't find
> it. Comments?
>
> ----------------------------------------------------------------------
>
> 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.
>
> This commit fixes the issue: variable labels will no longer be
> padded.
>
> (This is a cosmetic problem only and should not cause any system
> files written by PSPP to be rejected by a reader.)
> ---
> src/data/sys-file-writer.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c
> index 393be4e..d16eaa1 100644
> --- a/src/data/sys-file-writer.c
> +++ b/src/data/sys-file-writer.c
> @@ -447,8 +447,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);
> }
--
"Premature optimization is the root of all evil."
--D. E. Knuth, "Structured Programming with go to Statements"