fix regression in xargs -Px (introduced in r286289) and add regression tests

PR:		202152
Submitted by:	jbeich (original),  Nikolai Lifanov (final)
Reviewed by:	jbeich
Approved by:	bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D3330
This commit is contained in:
allanjude 2015-08-08 18:37:20 +00:00
parent 33c52eed18
commit e6fc39bbd3
6 changed files with 17 additions and 6 deletions

View File

@ -10,13 +10,16 @@ FILES+= regress.0.out
FILES+= regress.0I.out
FILES+= regress.0J.out
FILES+= regress.0L.out
FILES+= regress.0P1.out
FILES+= regress.I.out
FILES+= regress.J.out
FILES+= regress.L.out
FILES+= regress.P1.out
FILES+= regress.R.out
FILES+= regress.in
FILES+= regress.n1.out
FILES+= regress.n2.out
FILES+= regress.n2P0.out
FILES+= regress.n3.out
FILES+= regress.normal.out
FILES+= regress.quotes.in

View File

@ -0,0 +1,4 @@
quick ' brown fox jumped
over "the lazy dog
quick brown fox jumped over the lazy dog

View File

@ -0,0 +1 @@
quick brown fox jumped over the lazy dog

View File

@ -0,0 +1,4 @@
quick brown
fox jumped
over the
lazy dog

View File

@ -1,6 +1,6 @@
# $FreeBSD$
echo 1..13
echo 1..16
REGRESSION_START($1)
@ -8,14 +8,17 @@ REGRESSION_TEST(`normal', `xargs echo The <${SRCDIR}/regress.in')
REGRESSION_TEST(`I', `xargs -I% echo The % % % %% % % <${SRCDIR}/regress.in')
REGRESSION_TEST(`J', `xargs -J% echo The % again. <${SRCDIR}/regress.in')
REGRESSION_TEST(`L', `xargs -L3 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(`P1', `xargs -P1 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(`R', `xargs -I% -R1 echo The % % % %% % % <${SRCDIR}/regress.in')
REGRESSION_TEST(`n1', `xargs -n1 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(`n2', `xargs -n2 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(`n2P0',`xargs -n2 -P0 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(`n3', `xargs -n3 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(`0', `xargs -0 -n1 echo <${SRCDIR}/regress.0.in')
REGRESSION_TEST(`0I', `xargs -0 -I% echo The % %% % <${SRCDIR}/regress.0.in')
REGRESSION_TEST(`0J', `xargs -0 -J% echo The % again. <${SRCDIR}/regress.0.in')
REGRESSION_TEST(`0L', `xargs -0 -L2 echo <${SRCDIR}/regress.0.in')
REGRESSION_TEST(`0P1', `xargs -0 -P1 echo <${SRCDIR}/regress.0.in')
REGRESSION_TEST(`quotes', `xargs -n1 echo <${SRCDIR}/regress.quotes.in')
REGRESSION_END()

View File

@ -166,15 +166,11 @@ main(int argc, char *argv[])
oflag = 1;
break;
case 'P':
maxprocs = strtonum(optarg, 1, INT_MAX, &errstr);
maxprocs = strtonum(optarg, 0, INT_MAX, &errstr);
if (errstr)
errx(1, "-P %s: %s", optarg, errstr);
if (getrlimit(RLIMIT_NPROC, &rl) != 0)
errx(1, "getrlimit failed");
if (*endptr != '\0')
errx(1, "invalid number for -P option");
if (maxprocs < 0)
errx(1, "value for -P option should be >= 0");
if (maxprocs == 0 || maxprocs > rl.rlim_cur)
maxprocs = rl.rlim_cur;
break;