summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorBruce Korb <bkorb@gnu.org>2008-08-14 06:24:59 -0700
committerJim Meyering <meyering@redhat.com>2008-08-15 09:52:06 +0200
commit4c9fae4e97d95a9f89d1399a8aeb03051f0fec96 (patch)
tree5df98709704785a5158f841f38c816472263f1bf /tests/misc
parenta01c4720d6bd05798168654534c70a31a39e4828 (diff)
downloadcoreutils-4c9fae4e97d95a9f89d1399a8aeb03051f0fec96.tar.xz
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.
Diffstat (limited to 'tests/misc')
-rw-r--r--tests/misc/sort-version65
1 files changed, 65 insertions, 0 deletions
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