]> granicus.if.org Git - sudo/commitdiff
now do an freopen() of the stmp file so that yyin will always point
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 29 Mar 1995 22:22:20 +0000 (22:22 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 29 Mar 1995 22:22:20 +0000 (22:22 +0000)
to the same thing.  This is important for flex since we are
doing a YY_NEWFILE

visudo.c

index 88d2d6710caa32d9b0c29369961a9cfc9331daf9..15a73aa05dc2f45f83aad96123d1716a375a6c83 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -271,7 +271,10 @@ int main(argc, argv)
             * for parse errors.
             */
            yyout = stdout;
-           yyin = fopen(stmp, "r");
+           if (parse_error)
+               yyin = freopen(stmp, "r", yyin);
+           else
+               yyin = fopen(stmp, "r");
            if (yyin == NULL) {
                (void) fprintf(stderr,
                    "%s: Can't re-open temporary file (%s), %s unchanged.\n",
@@ -291,8 +294,6 @@ int main(argc, argv)
                    Argv[0], stmp, sudoers);
                Exit(1);
            }
-
-           (void) fclose(yyin);
        } else {
            (void) fprintf(stderr, "%s: Editor (%s) failed, %s unchanged.\n",
                Argv[0], Editor, sudoers);