mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
Regarding -L, consider a line ending in unescaped white space and the next
non-empty line to form one single line, as required by XPG 4. While here, use isblank(3) to identify white space instead of assuming that only blank and tab are white space characters. Geoff Clare <gwc at opengroup dot org> agrees that the standard for -L should say "A line is considered to end with the first <newline> unless the last character of the line is an *unescaped* <blank>; an *unescaped* trailing <blank> signals continuation to the next non-empty line, inclusive." The word *unescaped* is missing from the standard, but we regard that as a goof in the standard. Bug noticed by, much feedback from, and "should go in now" guenther@
This commit is contained in:
parent
0ff0b821b2
commit
b7f5ef4233
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: xargs.1,v 1.24 2010/02/04 23:12:48 schwarze Exp $
|
||||
.\" $OpenBSD: xargs.1,v 1.25 2010/03/25 01:03:57 schwarze Exp $
|
||||
.\" $FreeBSD: xargs.1,v 1.30 2003/05/21 21:07:28 ru Exp $$
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
.\"
|
||||
.\" @(#)xargs.1 8.1 (Berkeley) 6/6/93
|
||||
.\"
|
||||
.Dd $Mdocdate: February 4 2010 $
|
||||
.Dd $Mdocdate: March 25 2010 $
|
||||
.Dt XARGS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -170,7 +170,9 @@ Call
|
||||
.Ar utility
|
||||
for every
|
||||
.Ar number
|
||||
of lines read.
|
||||
of non-empty lines read.
|
||||
A line ending in unescaped white space and the next non-empty line
|
||||
are considered to form one single line.
|
||||
If EOF is reached and fewer than
|
||||
.Ar number
|
||||
lines have been read then
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: xargs.c,v 1.26 2009/10/27 23:59:50 deraadt Exp $ */
|
||||
/* $OpenBSD: xargs.c,v 1.27 2010/03/25 01:03:57 schwarze Exp $ */
|
||||
/* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */
|
||||
|
||||
/*-
|
||||
@ -38,6 +38,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -239,10 +240,23 @@ main(int argc, char *argv[])
|
||||
static void
|
||||
parse_input(int argc, char *argv[])
|
||||
{
|
||||
int hasblank = 0;
|
||||
static int hadblank = 0;
|
||||
int ch, foundeof = 0;
|
||||
char **avj;
|
||||
|
||||
switch (ch = getchar()) {
|
||||
ch = getchar();
|
||||
if (isblank(ch)) {
|
||||
/* Quotes escape tabs and spaces. */
|
||||
if (insingle || indouble)
|
||||
goto addch;
|
||||
hasblank = 1;
|
||||
if (zflag)
|
||||
goto addch;
|
||||
goto arg2;
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
case EOF:
|
||||
/* No arguments since last exec. */
|
||||
if (p == bbp) {
|
||||
@ -252,18 +266,14 @@ parse_input(int argc, char *argv[])
|
||||
exit(rval);
|
||||
}
|
||||
goto arg1;
|
||||
case ' ':
|
||||
case '\t':
|
||||
/* Quotes escape tabs and spaces. */
|
||||
if (insingle || indouble || zflag)
|
||||
goto addch;
|
||||
goto arg2;
|
||||
case '\0':
|
||||
if (zflag)
|
||||
goto arg2;
|
||||
goto addch;
|
||||
case '\n':
|
||||
count++;
|
||||
hasblank = 1;
|
||||
if (hadblank == 0)
|
||||
count++;
|
||||
if (zflag)
|
||||
goto addch;
|
||||
|
||||
@ -382,6 +392,7 @@ addch: if (p < ebp) {
|
||||
*p++ = ch;
|
||||
break;
|
||||
}
|
||||
hadblank = hasblank;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user