comparison 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
comparison
equal deleted inserted replaced
553:3a173cefc814 554:7627d2b3b81f
295 lw_error("Cannot open include file '%s': %s\n", s, strerror(errno)); 295 lw_error("Cannot open include file '%s': %s\n", s, strerror(errno));
296 break; 296 break;
297 297
298 case input_type_file: 298 case input_type_file:
299 debug_message(as, 1, "Opening (reg): %s\n", s); 299 debug_message(as, 1, "Opening (reg): %s\n", s);
300 IS -> data = fopen(s, "rb"); 300 if (s[0] == '-' && s[1] == '\0')
301 IS -> data = stdin;
302 else
303 IS -> data = fopen(s, "rb");
301 304
302 if (!IS -> data) 305 if (!IS -> data)
303 { 306 {
304 lw_error("Cannot open file '%s': %s\n", s, strerror(errno)); 307 lw_error("Cannot open file '%s': %s\n", s, strerror(errno));
305 } 308 }