Prevent ps(1) from doing idiotic munging of things in a -ofmt= string.

God I hate the backwards compatability crap here.
This commit is contained in:
Juli Mallett 2002-09-03 05:44:00 +00:00
parent b331ec93c0
commit daed3ad661
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102886

View File

@ -591,9 +591,16 @@ pscomp(const void *a, const void *b)
static char *
kludge_oldps_options(char *s)
{
int have_fmt;
size_t len;
char *newopts, *ns, *cp;
/*
* If we have an 'o' option, then note it, since we don't want to do
* some types of munging.
*/
have_fmt = index(s, 'o') != NULL;
len = strlen(s);
if ((newopts = ns = malloc(len + 2)) == NULL)
errx(1, "malloc failed");
@ -634,7 +641,7 @@ kludge_oldps_options(char *s)
*/
if (isdigit(*cp) &&
(cp == s || (cp[-1] != 't' && cp[-1] != 'p')) &&
(cp - 1 == s || cp[-2] != 't'))
(cp - 1 == s || cp[-2] != 't') && !have_fmt)
*ns++ = 'p';
(void)strcpy(ns, cp); /* and append the number */