summaryrefslogtreecommitdiffstats
path: root/usr.bin/paste
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2010-08-12 05:02:52 +0000
committertedu <tedu@openbsd.org>2010-08-12 05:02:52 +0000
commit6e6462b96a940f48cac3b08e87868ec68793e6d1 (patch)
tree549a0d8d502f90ef7d2204531e23fd3effece4db /usr.bin/paste
parentcorrect a format string. not sure who thought size_t would be a good match (diff)
downloadwireguard-openbsd-6e6462b96a940f48cac3b08e87868ec68793e6d1.tar.xz
wireguard-openbsd-6e6462b96a940f48cac3b08e87868ec68793e6d1.zip
make fgetln fixups look like the man page. correct a pair of brances and
some other style tweaks
Diffstat (limited to 'usr.bin/paste')
-rw-r--r--usr.bin/paste/paste.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/paste/paste.c b/usr.bin/paste/paste.c
index a94506f30b6..eeec15d5544 100644
--- a/usr.bin/paste/paste.c
+++ b/usr.bin/paste/paste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paste.c,v 1.17 2009/10/27 23:59:41 deraadt Exp $ */
+/* $OpenBSD: paste.c,v 1.18 2010/08/12 05:02:52 tedu Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -58,8 +58,8 @@ main(int argc, char *argv[])
int ch, seq;
seq = 0;
- while ((ch = getopt(argc, argv, "d:s")) != -1)
- switch(ch) {
+ while ((ch = getopt(argc, argv, "d:s")) != -1) {
+ switch (ch) {
case 'd':
delimcnt = tr(delim = optarg);
break;
@@ -70,6 +70,7 @@ main(int argc, char *argv[])
default:
usage();
}
+ }
argc -= optind;
argv += optind;
@@ -135,8 +136,8 @@ parallel(char **argv)
putchar(ch);
continue;
}
- if (*(buf + len - 1) == '\n')
- *(buf + len - 1) = '\0';
+ if (buf[len - 1] == '\n')
+ buf[len - 1] = '\0';
else {
if ((lbuf = malloc(len + 1)) == NULL)
err(1, "malloc");
@@ -183,8 +184,8 @@ sequential(char **argv)
}
if ((buf = fgetln(fp, &len))) {
for (cnt = 0, dp = delim;;) {
- if (*(buf + len - 1) == '\n')
- *(buf + len - 1) = '\0';
+ if (buf[len - 1] == '\n')
+ buf[len - 1] = '\0';
else {
if ((lbuf = malloc(len + 1)) == NULL)
err(1, "malloc");
@@ -217,9 +218,9 @@ tr(char *arg)
int cnt;
char ch, *p;
- for (p = arg, cnt = 0; (ch = *p++); ++arg, ++cnt)
- if (ch == '\\')
- switch(ch = *p++) {
+ for (p = arg, cnt = 0; (ch = *p++); ++arg, ++cnt) {
+ if (ch == '\\') {
+ switch (ch = *p++) {
case 'n':
*arg = '\n';
break;
@@ -232,12 +233,14 @@ tr(char *arg)
default:
*arg = ch;
break;
+ }
} else
*arg = ch;
+ }
if (!cnt)
errx(1, "no delimiters specified");
- return(cnt);
+ return (cnt);
}
void