diff options
author | June McEnroe <june@causal.agency> | 2020-07-18 15:04:59 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-07-18 15:05:23 -0400 |
commit | 3837b47913ecddaa92d0c27a468d21dfa8fe2446 (patch) | |
tree | 627c3de73d649f33441bd316b70db47b90f3bf43 | |
parent | Actually fix nvim and doas presence tests (diff) | |
download | src-3837b47913ecddaa92d0c27a468d21dfa8fe2446.tar.gz src-3837b47913ecddaa92d0c27a468d21dfa8fe2446.zip |
Read from stdin in order
-rw-r--r-- | bin/man1/order.1 | 9 | ||||
-rw-r--r-- | bin/order.y | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/bin/man1/order.1 b/bin/man1/order.1 index f042102f..8e0f9661 100644 --- a/bin/man1/order.1 +++ b/bin/man1/order.1 @@ -1,4 +1,4 @@ -.Dd May 18, 2019 +.Dd July 18, 2020 .Dt ORDER 1 .Os . @@ -8,7 +8,7 @@ . .Sh SYNOPSIS .Nm -.Ar expr ... +.Op Ar expr ... . .Sh DESCRIPTION .Nm @@ -16,6 +16,11 @@ parses C expressions and prints them with parentheses according to the precedence rules in .Xr operator 7 . +If no +.Ar expr +are given, +each line of standard input +is parsed and printed. . .Sh EXAMPLES .Bd -literal diff --git a/bin/order.y b/bin/order.y index 2de1b531..95f1036e 100644 --- a/bin/order.y +++ b/bin/order.y @@ -183,4 +183,11 @@ int main(int argc, char *argv[]) { input = argv[i]; yyparse(); } + if (argc > 1) return EX_OK; + size_t cap = 0; + char *buf = NULL; + while (0 < getline(&buf, &cap, stdin)) { + input = buf; + yyparse(); + } } |