Module Name: src
Committed By: dsl
Date: Sat Aug 22 21:50:32 UTC 2009
Modified Files:
src/usr.bin/sort: init.c
Log Message:
<space> and <tab> at the start of key fields are supposed to be sorted
as if part of the data.
This is a bit fubar since we need a value than sorts before any byte value
as a key field separator - so need 257 byte values (since radixsort() doesn't
take a length for each record).
For now map '\t' to 0x01 and hope no one will notice!
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/sort/init.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/sort/init.c
diff -u src/usr.bin/sort/init.c:1.20 src/usr.bin/sort/init.c:1.21
--- src/usr.bin/sort/init.c:1.20 Sat Aug 22 10:53:28 2009
+++ src/usr.bin/sort/init.c Sat Aug 22 21:50:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.20 2009/08/22 10:53:28 dsl Exp $ */
+/* $NetBSD: init.c,v 1.21 2009/08/22 21:50:32 dsl Exp $ */
/*-
* Copyright (c) 2000-2003 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
#include "sort.h"
#ifndef lint
-__RCSID("$NetBSD: init.c,v 1.20 2009/08/22 10:53:28 dsl Exp $");
+__RCSID("$NetBSD: init.c,v 1.21 2009/08/22 21:50:32 dsl Exp $");
__SCCSID("@(#)init.c 8.1 (Berkeley) 6/6/93");
#endif /* not lint */
@@ -338,20 +338,16 @@
int i;
int next_weight = SINGL_FLD ? 1 : 2;
int rev_weight = SINGL_FLD ? 255 : 254;
- int had_field_sep = 0;
+ int had_field_sep = SINGL_FLD;
for (i = 0; i < 256; i++) {
unweighted[i] = i;
if (d_mask[i] & REC_D_F)
continue;
- if (d_mask[i] & FLD_D && !SINGL_FLD) {
+ if (!had_field_sep && d_mask[i] & FLD_D) {
+ /* First/only separator sorts before any data */
ascii[i] = 1;
Rascii[i] = 255;
- if (had_field_sep) {
- /* avoid confusion in key dumps */
- next_weight++;
- rev_weight--;
- }
had_field_sep = 1;
continue;
}