[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] sort: EOL included in final field
From: |
Herbert Xu |
Subject: |
[PATCH] sort: EOL included in final field |
Date: |
Sun, 10 Jun 2001 15:25:30 +1000 |
User-agent: |
Mutt/1.3.18i |
The final newline is included in the final field when fields are specified
through -k. Here is a test case:
$ sort -c -k 1,1 <<eof
> a
> a b
> eof
sort: -:2: disorder: a b
The changelog says:
1999-11-03 Paul Eggert <address@hidden>
* NEWS, doc/textutils.texi:
Do not consider newline to be part of a line when comparing lines
in `sort' and `comm'. POSIX.2 requires that we consider newline,
but this is a bug in the spec and the bug will likely be fixed.
* src/comm.c (compare_files): Likewise.
* src/sort.c (begfield, limfield, findlines, keycompare, compare):
Likewise.
1999-05-20 Paul Eggert <address@hidden>
* src/sort.c: Treat the trailing newline as part of the line,
as required by POSIX.2.
The only copy of POSIX.2 I have access to is the September 1991 draft
version 11.2. Neither it, SuSv2, or the Austin Draft Issue 6 contain
any references to the requirement of the trailing newline to be considered
either as part of the last resort comparison or when constructing fields.
In fact, all three documents contain this in their
Rationale/Application Usage section:
The default value for -t, <blank>, has different properties than, for
example, -t "<space>". If a line contains:
<space><space>foo
the following treatment would occur with default separation versus
specifically selecting a <space>:
Field Default -t "<space>"
_____ _________________ ____________
1 <space><space>foo empty
2 empty empty 1
3 empty foo 1
So it is clear the the intention is to not consider the new line when
delimiting fields.
The following patch removes the final newline from consideration when
delimiting fields.
--
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <address@hidden>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
p
Description: Text document
- [PATCH] sort: EOL included in final field,
Herbert Xu <=