From 58c9a4b908c79c0b6183951e7dd68dc69cbf4415 Mon Sep 17 00:00:00 2001 From: Kiyoshi Aman Date: Wed, 5 Jun 2019 06:21:58 -0500 Subject: usr.bin/sort: make buildable with libbsd --- usr.bin/sort/sort.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'usr.bin/sort/sort.c') diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index ee5ffdb..1dd772a 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -60,12 +60,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1993\ - The Regents of the University of California. All rights reserved."); -#endif /* not lint */ -__RCSID("$NetBSD: sort.c,v 1.64 2017/01/10 21:13:45 christos Exp $"); /* Sort sorts a file using an optional user-defined key. * Sort uses radix sort for internal sorting, and allows @@ -81,23 +75,23 @@ __RCSID("$NetBSD: sort.c,v 1.64 2017/01/10 21:13:45 christos Exp $"); #include #include #include +#include #include #include -#include #include "sort.h" #include "fsort.h" #include "pathnames.h" int REC_D = '\n'; -u_char d_mask[NBINS]; /* flags for rec_d, field_d, */ +unsigned char d_mask[NBINS]; /* flags for rec_d, field_d, */ /* * weight tables. Gweights is one of ascii, Rascii.. * modified to weight rec_d = 0 (or 255) */ -u_char *const weight_tables[4] = { ascii, Rascii, Ftable, RFtable }; -u_char ascii[NBINS], Rascii[NBINS], RFtable[NBINS], Ftable[NBINS]; +unsigned char *const weight_tables[4] = { ascii, Rascii, Ftable, RFtable }; +unsigned char ascii[NBINS], Rascii[NBINS], RFtable[NBINS], Ftable[NBINS]; int SINGL_FLD = 0, SEP_FLAG = 0, UNIQUE = 0; int REVERSE = 0; @@ -111,7 +105,7 @@ const char *tmpdir; /* where temporary files should be put */ static void cleanup(void); static void onsignal(int); -__dead static void usage(const char *); +static void usage(const char *); int main(int argc, char *argv[]) @@ -142,7 +136,7 @@ main(int argc, char *argv[]) /* fldtab[0] is the global options. */ fldtab_sz = 3; fld_cnt = 0; - fldtab = emalloc(fldtab_sz * sizeof(*fldtab)); + fldtab = malloc(fldtab_sz * sizeof(*fldtab)); memset(fldtab, 0, fldtab_sz * sizeof(*fldtab)); #define SORT_OPTS "bcCdD:fHik:lmno:rR:sSt:T:u" @@ -175,7 +169,7 @@ main(int argc, char *argv[]) /* That is now the default. */ break; case 'k': - fldtab = erealloc(fldtab, (fldtab_sz + 1) * sizeof(*fldtab)); + fldtab = realloc(fldtab, (fldtab_sz + 1) * sizeof(*fldtab)); memset(&fldtab[fldtab_sz], 0, sizeof(fldtab[0])); fldtab_sz++; @@ -234,8 +228,8 @@ main(int argc, char *argv[]) d_mask[' '] &= ~FLD_D; d_mask['\t'] &= ~FLD_D; d_mask['\n'] &= ~FLD_D; - d_mask[(u_char)*optarg] |= FLD_D; - if (d_mask[(u_char)*optarg] & REC_D_F) + d_mask[(unsigned char)*optarg] |= FLD_D; + if (d_mask[(unsigned char)*optarg] & REC_D_F) errx(2, "record/field delimiter clash"); break; case 'T': @@ -415,5 +409,5 @@ RECHEADER * allocrec(RECHEADER *rec, size_t size) { - return (erealloc(rec, size + sizeof(long) - 1)); + return (realloc(rec, size + sizeof(long) - 1)); } -- cgit v1.2.3-60-g2f50