Fix the case where the user specifies an alternate heading for some
output-format keyword, and the keyword they picked is an alias to some other keyword. E.g.: ps -o stat=Zustand $$ ('stat' is defined as an alias for 'state') PR: bin/57833 MFC after: 3 weeks
This commit is contained in:
parent
67bcd64670
commit
ec71648737
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=156423
@ -295,8 +295,9 @@ parsefmt(const char *p, int user)
|
||||
static VAR *
|
||||
findvar(char *p, int user, char **header)
|
||||
{
|
||||
size_t rflen;
|
||||
VAR *v, key;
|
||||
char *hp;
|
||||
char *hp, *realfmt;
|
||||
|
||||
hp = strchr(p, '=');
|
||||
if (hp)
|
||||
@ -306,11 +307,17 @@ findvar(char *p, int user, char **header)
|
||||
v = bsearch(&key, var, sizeof(var)/sizeof(VAR) - 1, sizeof(VAR), vcmp);
|
||||
|
||||
if (v && v->alias) {
|
||||
if (hp) {
|
||||
warnx("%s: illegal keyword specification", p);
|
||||
eval = 1;
|
||||
}
|
||||
parsefmt(v->alias, user);
|
||||
/*
|
||||
* XXX - This processing will not be correct for any alias
|
||||
* which expands into a list of format keywords. Presently
|
||||
* there are no aliases which do that.
|
||||
*/
|
||||
rflen = strlen(v->alias) + strlen(hp) + 2;
|
||||
realfmt = malloc(rflen);
|
||||
strlcpy(realfmt, v->alias, rflen);
|
||||
strlcat(realfmt, "=", rflen);
|
||||
strlcat(realfmt, hp, rflen);
|
||||
parsefmt(realfmt, user);
|
||||
return ((VAR *)NULL);
|
||||
}
|
||||
if (!v) {
|
||||
|
Loading…
Reference in New Issue
Block a user