Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sort <space> and <tab> at the start of key fields ar...
details: https://anonhg.NetBSD.org/src/rev/e05f92c412ca
branches: trunk
changeset: 746895:e05f92c412ca
user: dsl <dsl%NetBSD.org@localhost>
date: Sat Aug 22 21:50:32 2009 +0000
description:
<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!
diffstat:
usr.bin/sort/init.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diffs (42 lines):
diff -r 76e2ed063400 -r e05f92c412ca usr.bin/sort/init.c
--- a/usr.bin/sort/init.c Sat Aug 22 21:43:53 2009 +0000
+++ b/usr.bin/sort/init.c Sat Aug 22 21:50:32 2009 +0000
@@ -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;
}
Home |
Main Index |
Thread Index |
Old Index