aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-12-19 09:16:27 -0600
committerRob Landley <rob@landley.net>2012-12-19 09:16:27 -0600
commit93504e6d26987a061484b6bfe86c6affe4019ae2 (patch)
tree018095a3cdb715d96d1dcee183bbd6eac086aa3a /toys
parentfadbd6078081afe62cf120f9346b1d69aa79d486 (diff)
downloadtoybox-93504e6d26987a061484b6bfe86c6affe4019ae2.tar.gz
Minor cleanups.
Diffstat (limited to 'toys')
-rw-r--r--toys/other/rev.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/toys/other/rev.c b/toys/other/rev.c
index a95d6615..8cad7da3 100644
--- a/toys/other/rev.c
+++ b/toys/other/rev.c
@@ -10,7 +10,7 @@ config REV
help
usage: rev [FILE...]
- Output lines reversed, when no files are given stdin is used.
+ Output each line reversed, when no files are given stdin is used.
*/
#include "toys.h"
@@ -20,15 +20,13 @@ void do_rev(int fd, char *name)
char *c;
for (;;) {
- int len;
- int i;
+ int len, i;
+
if (!(c = get_line(fd))) break;
len = strlen(c) - 1;
- i = 0;
- while ( i <= len/2)
- {
- char tmp;
- tmp = c[i];
+ for (i = 0; i <= len/2; i++) {
+ char tmp = c[i];
+
c[i] = c[len-i];
c[len-i] = tmp;
i++;