Mercurial > hg > index.cgi
diff lwasm/input.c @ 554:7627d2b3b81f
Allow using - to refer to standard input for file names
While POSIX-y systems will work with something like /dev/fd/0 to open the
standard input, allowing - as a placeholder for standard input is more
consistent with historical precedent and should be somewhat useful.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 23 Jul 2023 16:42:29 -0600 |
parents | d791d47afc48 |
children |
line wrap: on
line diff
--- a/lwasm/input.c Thu Jul 06 12:06:22 2023 -0600 +++ b/lwasm/input.c Sun Jul 23 16:42:29 2023 -0600 @@ -297,7 +297,10 @@ case input_type_file: debug_message(as, 1, "Opening (reg): %s\n", s); - IS -> data = fopen(s, "rb"); + if (s[0] == '-' && s[1] == '\0') + IS -> data = stdin; + else + IS -> data = fopen(s, "rb"); if (!IS -> data) {