diff options
author | jmallett <jmallett@FreeBSD.org> | 2003-01-19 00:22:34 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2003-01-19 00:22:34 +0000 |
commit | 0c8d64a2c4ed9577970bc064bd9354ec7fa78297 (patch) | |
tree | 2986fc8ec7518040f3f7cba46759c64c32ef7920 /bin/ps/keyword.c | |
parent | 6f344674a0af04f9a80844d7e0495643cfd96161 (diff) | |
download | FreeBSD-src-0c8d64a2c4ed9577970bc064bd9354ec7fa78297.zip FreeBSD-src-0c8d64a2c4ed9577970bc064bd9354ec7fa78297.tar.gz |
When inserting a non-user-specified (e.g. not via -o or -O) format, don't dupe
one that is already there. This is consistent with GNU ps(1)'s BSD mode, and
POLA.
Reported by: Andy Farkas <andyf@speednet.com.au>
Tested by: Andy Farkas <andyf@speednet.com.au>
Diffstat (limited to 'bin/ps/keyword.c')
-rw-r--r-- | bin/ps/keyword.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 82a3674..045a7b0 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include "ps.h" -static VAR *findvar(char *); +static VAR *findvar(char *, int); static int vcmp(const void *, const void *); /* Compute offset in common structures. */ @@ -223,7 +223,7 @@ showkey(void) } void -parsefmt(const char *p) +parsefmt(const char *p, int user) { static struct varent *vtail; char *tempstr, *tempstr1; @@ -248,8 +248,18 @@ parsefmt(const char *p) cp = tempstr; tempstr = NULL; } - if (cp == NULL || !(v = findvar(cp))) + if (cp == NULL || !(v = findvar(cp, user))) continue; + if (!user) { + /* + * If the user is NOT adding this field manually, + * get on with our lives if this VAR is already + * represented in the list. + */ + vent = find_varentry(v); + if (vent != NULL) + continue; + } if ((vent = malloc(sizeof(struct varent))) == NULL) errx(1, "malloc failed"); vent->var = malloc(sizeof(*vent->var)); @@ -273,7 +283,7 @@ parsefmt(const char *p) } static VAR * -findvar(char *p) +findvar(char *p, int user) { VAR *v, key; char *hp; @@ -290,7 +300,7 @@ findvar(char *p) warnx("%s: illegal keyword specification", p); eval = 1; } - parsefmt(v->alias); + parsefmt(v->alias, user); return ((VAR *)NULL); } if (!v) { |