Fix #86 by requiring '-' (e.g. "yasm -") to read from stdin, and reporting

an error if no files are specified (instead of defaulting to stdin).
While the old behavior mimiced GNU AS, the new behavior is far more common
amongst typical compilers (e.g. GCC), including NASM.

While I'm here, add support for '--' (e.g. "yasm -- -f").

svn path=/trunk/yasm/; revision=1659
0.6.0
Peter Johnson 18 years ago
parent 6ab452816c
commit d754e57ba7
  1. 14
      frontends/yasm/yasm-options.c
  2. 9
      frontends/yasm/yasm.c
  3. 2
      out_test.sh

@ -58,6 +58,16 @@ parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts,
if (argv[0][0] == '-') { /* opt */
got_it = 0;
if (argv[0][1] == '-') { /* lopt */
if (argv[0][2] == '\0') { /* --, end of options */
/* Handle rest of args as non-options */
while (--argc) {
argv++;
if (not_an_option_handler(argv[0]))
errors++;
}
return errors;
}
for (i = 0; i < nopts; i++) {
if (options[i].lopt &&
strncmp(&argv[0][2], options[i].lopt,
@ -92,8 +102,10 @@ parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts,
argv[0]);
warnings++;
}
} else if (argv[0][1] == '\0') { /* just -, is non-option */
if (not_an_option_handler(argv[0]))
errors++;
} else { /* sopt */
for (i = 0; i < nopts; i++) {
if (argv[0][1] == options[i].sopt) {
char *cmd = &argv[0][1];

@ -263,7 +263,10 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
if (in_filename && strcmp(in_filename, "-") != 0) {
if (!in_filename) {
print_error(_("No input files specified"));
return EXIT_FAILURE;
} else if (strcmp(in_filename, "-") != 0) {
/* Open the input file (if not standard input) */
in = fopen(in_filename, "rt");
if (!in) {
@ -275,10 +278,8 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
} else {
/* If no files were specified or filename was "-", read stdin */
/* Filename was "-", read stdin */
in = stdin;
if (!in_filename)
in_filename = yasm__xstrdup("-");
}
/* Initialize intnum and floatnum */

@ -31,7 +31,7 @@ do
fi
# Run within a subshell to prevent signal messages from displaying.
sh -c "cat ${asm} | ./yasm $4 -o results/${o} 2>results/${e}" >/dev/null 2>/dev/null
sh -c "cat ${asm} | ./yasm $4 -o results/${o} - 2>results/${e}" >/dev/null 2>/dev/null
status=$?
if test $status -gt 128; then
# We should never get a coredump!

Loading…
Cancel
Save