[Toybox] [BUG] The sort cmdline fails to sort by 3rd, 4th, etc column when the key_separator is not space

王小建 wangxiaojianffgz at 163.com
Sun Dec 25 00:49:34 PST 2016


Fix a bug for sort.

When the key_separator is not space, the sort commandline tool fails to sort by the 3rd,4th,etc column.
For example:
	when you exec

	  $ sort -t',' -k 3n

	on a file which cotains:

	1,2,3,4
	2,3,4,1
	4,1,2,3
	3,4,1,2

	you got:

	4,1,2,3
	1,2,3,4
	2,3,4,1
	3,4,1,2

	but the expected output should be:

	3,4,1,2
	4,1,2,3
	1,2,3,4
	2,3,4,1

The bug is due to the dependency of "isspace(str[end])" at line 113.
When searching for the non-space key_separator, the search stopped just at the position of first key_separator it met.
The bug can be easily fixed by adding "end++" when the search have found one separator and exit the for loop.









Email:wangxiaojianffgz at 163.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20161225/15ad13be/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-a-bug-for-sort.patch
Type: application/octet-stream
Size: 1469 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20161225/15ad13be/attachment.obj>


More information about the Toybox mailing list