aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-05-19 17:52:48 +0200
committerDuncaen <mail@duncano.de>2017-05-19 17:53:16 +0200
commit7f46b539fefd9fe591f281fcdebd60e7fd82b774 (patch)
treebc88e6f7c1b879d18e1cbafe0a42a1e7494d2c60
parentd46b0d0ee8d95bb378598499cf7cac76fa5bca50 (diff)
downloadlobase-7f46b539fefd9fe591f281fcdebd60e7fd82b774.tar.gz
usr.bin/wc: update to OPENBSD_6_1
-rw-r--r--usr.bin/wc/wc.110
-rw-r--r--usr.bin/wc/wc.c48
2 files changed, 28 insertions, 30 deletions
diff --git a/usr.bin/wc/wc.1 b/usr.bin/wc/wc.1
index afd78b0..dcbb3b6 100644
--- a/usr.bin/wc/wc.1
+++ b/usr.bin/wc/wc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: wc.1,v 1.26 2015/12/08 01:00:44 schwarze Exp $
+.\" $OpenBSD: wc.1,v 1.27 2016/10/24 13:46:58 schwarze Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" from: @(#)wc.1 8.2 (Berkeley) 4/19/94
.\"
-.Dd $Mdocdate: December 8 2015 $
+.Dd $Mdocdate: October 24 2016 $
.Dt WC 1
.Os
.Sh NAME
@@ -106,9 +106,9 @@ are integers separated by spaces.
.Sh ENVIRONMENT
.Bl -tag -width LC_CTYPE
.It Ev LC_CTYPE
-The character set
-.Xr locale 1 ,
-defining which byte sequences form characters.
+The character encoding
+.Xr locale 1 .
+It decides which byte sequences form characters.
If unset or set to
.Qq C ,
.Qq POSIX ,
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index 9011c72..e92a9fc 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wc.c,v 1.20 2015/12/08 01:00:45 schwarze Exp $ */
+/* $OpenBSD: wc.c,v 1.21 2016/09/16 09:25:23 fcambus Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
@@ -32,10 +32,8 @@
#include <sys/param.h> /* MAXBSIZE */
#include <sys/stat.h>
#include <sys/file.h>
-#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <locale.h>
#include <ctype.h>
#include <err.h>
@@ -46,12 +44,12 @@
int64_t tlinect, twordct, tcharct;
int doline, doword, dochar, humanchar, multibyte;
-int rval;
+int rval;
extern char *__progname;
-void print_counts(int64_t, int64_t, int64_t, char *);
-void format_and_print(long long);
-void cnt(char *);
+static void print_counts(int64_t, int64_t, int64_t, char *);
+static void format_and_print(int64_t);
+static void cnt(char *);
int
main(int argc, char *argv[])
@@ -83,10 +81,10 @@ main(int argc, char *argv[])
break;
case '?':
default:
- (void)fprintf(stderr,
+ fprintf(stderr,
"usage: %s [-c | -m] [-hlw] [file ...]\n",
__progname);
- exit(1);
+ return 1;
}
argv += optind;
argc -= optind;
@@ -100,7 +98,7 @@ main(int argc, char *argv[])
doline = doword = dochar = 1;
if (!*argv) {
- cnt((char *)NULL);
+ cnt(NULL);
} else {
int dototal = (argc > 1);
@@ -112,14 +110,14 @@ main(int argc, char *argv[])
print_counts(tlinect, twordct, tcharct, "total");
}
- exit(rval);
+ return rval;
}
-void
+static void
cnt(char *file)
{
static char *buf;
- static ssize_t bufsz;
+ static size_t bufsz;
FILE *stream;
char *C;
@@ -214,7 +212,7 @@ cnt(char *file)
++charct;
len = mbtowc(&wc, C, MB_CUR_MAX);
if (len == -1) {
- (void)mbtowc(NULL, NULL,
+ mbtowc(NULL, NULL,
MB_CUR_MAX);
len = 1;
wc = L' ';
@@ -264,31 +262,31 @@ cnt(char *file)
}
}
-void
-format_and_print(long long v)
+static void
+format_and_print(int64_t v)
{
if (humanchar) {
char result[FMT_SCALED_STRSIZE];
- (void)fmt_scaled(v, result);
- (void)printf("%7s", result);
+ fmt_scaled((long long)v, result);
+ printf("%7s", result);
} else {
- (void)printf(" %7lld", v);
+ printf(" %7lld", v);
}
}
-void
+static void
print_counts(int64_t lines, int64_t words, int64_t chars, char *name)
{
if (doline)
- format_and_print((long long)lines);
+ format_and_print(lines);
if (doword)
- format_and_print((long long)words);
+ format_and_print(words);
if (dochar)
- format_and_print((long long)chars);
+ format_and_print(chars);
if (name)
- (void)printf(" %s\n", name);
+ printf(" %s\n", name);
else
- (void)printf("\n");
+ printf("\n");
}