summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-03-14 03:20:23 +0000
committerMiles Bader <miles@gnu.org>1995-03-14 03:20:23 +0000
commit057ea6822f70ebab7d4949c8d8fb831af45ebc02 (patch)
tree2021c1fd20491574ec8622fdee6b38872e2ae02f
parentbf919d11aedc8b4c52edbdfe02be9853d485f895 (diff)
Copy the correct number of fields when squashing.
Correctly skip prefix-only fields.
-rw-r--r--libps/fmt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libps/fmt.c b/libps/fmt.c
index 3422107e..e45509d3 100644
--- a/libps/fmt.c
+++ b/libps/fmt.c
@@ -334,7 +334,8 @@ ps_fmt_squash(ps_fmt_t fmt, int flags)
/* Shift down all following fields over this one. */
if (nfields > 0)
- bcopy(field + 1, field, nfields * sizeof *field);
+ bcopy(field + 1, field,
+ (nfields - (field - fields)) * sizeof *field);
if (field == fields)
/* This is the first field, so move its prefix to the
@@ -378,6 +379,8 @@ ps_fmt_squash(ps_fmt_t fmt, int flags)
/* don't squash this field, just move to the next one */
field++;
}
+ else
+ field++;
}
fmt->needs &= ~flags; /* we don't need any of them anymore */