summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2010-08-12 05:02:53 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2010-08-12 05:02:53 +0000
commite6c2e2c930ae1c183b1a0264f6d6f9506aa603f5 (patch)
treebb8707f14793dfb7ff8a3c8ca3b0a16d6e9a3692
parent1aaf50897d81f5b99f77d31367a589268e39b5aa (diff)
make fgetln fixups look like the man page. correct a pair of brances and
some other style tweaks
-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