Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/lastlogin Output records in original order
details: https://anonhg.NetBSD.org/src/rev/a9e14dc73bd2
branches: trunk
changeset: 932403:a9e14dc73bd2
user: kim <kim%NetBSD.org@localhost>
date: Wed May 06 19:45:39 2020 +0000
description:
Output records in original order
Append to the list of output records instead of pushing on it, so we
don't reverse the order of records (when not sorting).
diffstat:
usr.sbin/lastlogin/lastlogin.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diffs (78 lines):
diff -r 71bc9073b50b -r a9e14dc73bd2 usr.sbin/lastlogin/lastlogin.c
--- a/usr.sbin/lastlogin/lastlogin.c Wed May 06 19:45:12 2020 +0000
+++ b/usr.sbin/lastlogin/lastlogin.c Wed May 06 19:45:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lastlogin.c,v 1.18 2020/05/06 19:31:32 kim Exp $ */
+/* $NetBSD: lastlogin.c,v 1.19 2020/05/06 19:45:39 kim Exp $ */
/*
* Copyright (c) 1996 John M. Vinopal
* All rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lastlogin.c,v 1.18 2020/05/06 19:31:32 kim Exp $");
+__RCSID("$NetBSD: lastlogin.c,v 1.19 2020/05/06 19:45:39 kim Exp $");
#endif
#include <sys/types.h>
@@ -95,6 +95,7 @@
#define DOSORT(x) ((x) & (SORT_TIME))
static int sortlog = SORT_NONE;
static struct output *outstack = NULL;
+static struct output *outstack_p = NULL;
static int fixed = 0;
#define FIXED_NAMELEN UT_NAMESIZE
@@ -121,7 +122,7 @@
static void process_entryx(struct passwd *, struct lastlogx *);
static void dolastlogx(const char *, int, char *[]);
#endif
-static void push_record(struct output *);
+static void append_record(struct output *);
static void sizecolumns(struct output *);
static void output_stack(struct output *);
static void sort_and_output_stack(struct output *);
@@ -289,7 +290,7 @@
* onto a stack. Otherwise, we can just output it.
*/
if (SIZECOLUMNS || DOSORT(sortlog))
- push_record(&o);
+ append_record(&o);
else
output_record(&o);
}
@@ -417,14 +418,14 @@
* onto a stack. Otherwise, we can just output it.
*/
if (SIZECOLUMNS || DOSORT(sortlog))
- push_record(&o);
+ append_record(&o);
else
output_record(&o);
}
#endif
static void
-push_record(struct output *o)
+append_record(struct output *o)
{
struct output *out;
@@ -434,12 +435,10 @@
(void)memcpy(out, o, sizeof(*out));
out->next = NULL;
- if (outstack) {
- out->next = outstack;
- outstack = out;
- } else {
- outstack = out;
- }
+ if (outstack_p)
+ outstack_p = outstack_p->next = out;
+ else
+ outstack = outstack_p = out;
}
static void
Home |
Main Index |
Thread Index |
Old Index