From 4c9fae4e97d95a9f89d1399a8aeb03051f0fec96 Mon Sep 17 00:00:00 2001 From: Bruce Korb Date: Thu, 14 Aug 2008 06:24:59 -0700 Subject: sort: new option, --sort=version, for version number ordering * src/sort.c [struct keyfield] (version): New member. (usage): Describe --version-sort. (sort_options): Add 'V'. (long_options): Add "version-sort". (CHECK_TABLE, _ct_, SORT_TABLE, _st_): Define new macros. (check_args, sort_args, sort_types): Use these new macros in declarations. (ARGMATCH_VERIFY): Remove use. No longer needed. (compare_version): New function. (key_compare): Add a case. (check_ordering_compatibility): Handle new type. (main): Likewise. Reformat two expressions for readability. * tests/misc/sort-version: new test file * tests/Makefile.am: add it to the list * doc/coreutils.texi (sort invocation): Document it. * NEWS: Mention the new feature. --- tests/misc/sort-version | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/misc/sort-version (limited to 'tests/misc') diff --git a/tests/misc/sort-version b/tests/misc/sort-version new file mode 100644 index 000000000..a4ebd400f --- /dev/null +++ b/tests/misc/sort-version @@ -0,0 +1,65 @@ +#!/usr/bin/echo do-not-run-this-directly.-Use-a-shell +# -*- Mode: shell-script -*- + +if test "$VERBOSE" = yes; then + set -x + sort --version +fi + +. $top_srcdir/tests/test-lib.sh + +s_file=sort-ver-src +g_file=sort-ver-good +r_file=sort-ver-res + +cat > $s_file <<- _EOF_ + string start 5.0.0 end of str + string start 5.00.0 end of str + string start 5.1.0 end of str + string start 5.10.0 end of str + string start 5.2.0 end of str + string start 5.20.0 end of str + string start 5.3.0 end of str + string start 5.30.0 end of str + string start 5.4.0 end of str + string start 5.40.0 end of str + string start 5.5.0 end of str + string start 5.50.0 end of str + string start 5.6.0 end of str + string start 5.60.0 end of str + string start 5.7.0 end of str + string start 5.70.0 end of str + string start 5.8.0 end of str + string start 5.80.0 end of str + string start 5.9.0 end of str + string start 5.90.0 end of str + _EOF_ + + +cat > $g_file <<- _EOF_ + string start 5.00.0 end of str + string start 5.0.0 end of str + string start 5.1.0 end of str + string start 5.2.0 end of str + string start 5.3.0 end of str + string start 5.4.0 end of str + string start 5.5.0 end of str + string start 5.6.0 end of str + string start 5.7.0 end of str + string start 5.8.0 end of str + string start 5.9.0 end of str + string start 5.10.0 end of str + string start 5.20.0 end of str + string start 5.30.0 end of str + string start 5.40.0 end of str + string start 5.50.0 end of str + string start 5.60.0 end of str + string start 5.70.0 end of str + string start 5.80.0 end of str + string start 5.90.0 end of str + _EOF_ + +fail=0 +sort --sort=version -o $r_file $s_file +compare $g_file $r_file >/dev/null 2>&1 || fail=1 +(exit $fail) ; exit $fail -- cgit v1.2.3-70-g09d2