chromatic <[EMAIL PROTECTED]> wrote:
On Tuesday 18 July 2006 19:43, Matt Diephouse wrote:

> I know I'm a little late to the game here, but in the future it would
> be useful to mention this sort of info in a comment in the source. :-)
> And a comment might be a nice addition even now.
>
> (You mentioned being more clear in the svn log, but a comment would
> really be the most useful.)

Something like this?

This is what I ended up applying (inlined because it's already ci'd).
I wanted to get more into why having -o means that we can't tell what
the user forgot to pass. (And having not written any of the code, I
could tell what wasn't immediately clear :-)

--
matt diephouse
http://matt.diephouse.com


--- compilers/imcc/main.c       (revision 13376)
+++ compilers/imcc/main.c       (working copy)
@@ -368,8 +368,17 @@
        usage(stderr);
        exit(EX_USAGE);
    }
-    /* reached the end of the option list and consumed all of argv */
+    /* if we reached the end of the option list and consumed all of argv,
+     * we don't have the name of a program to run */
    if (*argc == opt.opt_index ) {
+
+        /* If the user passed the -o flag -- the only flag that must take a
+         * parameter -- then we can't be sure that the user forgot the name of
+         * the program. it could be that the user forgot to give the argument
+         * for -o and the rest of argv got slurped up as flags. (If -o appeared
+         * with no argument, the getopt check would have complained earlier.)
+         *
+         * Given that, this was the best error message we could come up with */
        if (interp->output_file) {
            fprintf(stderr, "Missing program name or argument for -o\n");
        }

Reply via email to