Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-2]: src/usr.bin/db Pull up revision 1.13 (requested by seb in tic...
details: https://anonhg.NetBSD.org/src/rev/eb15608e7cb9
branches: netbsd-2
changeset: 563439:eb15608e7cb9
user: riz <riz%NetBSD.org@localhost>
date: Thu May 05 19:31:51 2005 +0000
description:
Pull up revision 1.13 (requested by seb in ticket #1142):
When vis encoding with -S, only remove the trailing NUL if -N isn't used and
the item's size is > 0.
diffstat:
usr.bin/db/db.c | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diffs (64 lines):
diff -r f413db83ae03 -r eb15608e7cb9 usr.bin/db/db.c
--- a/usr.bin/db/db.c Thu May 05 19:21:45 2005 +0000
+++ b/usr.bin/db/db.c Thu May 05 19:31:51 2005 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: db.c,v 1.12 2004/01/05 23:23:34 jmmv Exp $ */
+/* $NetBSD: db.c,v 1.12.4.1 2005/05/05 19:31:51 riz Exp $ */
/*-
- * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 2002-2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef lint
#ifdef __RCSID
-__RCSID("$NetBSD: db.c,v 1.12 2004/01/05 23:23:34 jmmv Exp $");
+__RCSID("$NetBSD: db.c,v 1.12.4.1 2005/05/05 19:31:51 riz Exp $");
#endif /* __RCSID */
#endif /* not lint */
@@ -356,16 +356,17 @@
void
db_print(DBT *key, DBT *val)
{
+ int len;
+ char *data;
- int len;
- char *data;
+#define MINUSNUL(x) ((x) > 0 ? (x) - (flags & F_NO_NUL ? 0 : 1) : 0)
if (flags & F_SHOW_KEY) {
- if (flags & F_ENCODE_KEY)
- len = encode_data(key->size - 1, (char *)key->data,
- &data);
- else {
- len = (int)key->size;
+ if (flags & F_ENCODE_KEY) {
+ len = encode_data(MINUSNUL(key->size),
+ (char *)key->data, &data);
+ } else {
+ len = (int)MINUSNUL(key->size);
data = (char *)key->data;
}
printf("%.*s", len, data);
@@ -373,11 +374,11 @@
if ((flags & F_SHOW_KEY) && (flags & F_SHOW_VALUE))
printf("%s", outputsep);
if (flags & F_SHOW_VALUE) {
- if (flags & F_ENCODE_VAL)
- len = encode_data(val->size - 1, (char *)val->data,
- &data);
- else {
- len = (int)val->size;
+ if (flags & F_ENCODE_VAL) {
+ len = encode_data(MINUSNUL(val->size),
+ (char *)val->data, &data);
+ } else {
+ len = (int)MINUSNUL(val->size);
data = (char *)val->data;
}
printf("%.*s", len, data);
Home |
Main Index |
Thread Index |
Old Index