sed: support "-f -" idiom
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 7 Apr 2016 22:20:36 +0000 (00:20 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 7 Apr 2016 22:20:36 +0000 (00:20 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/sed.c

index 4c7f75521f768f8f8b01913aeb324b5cfd873880..9c4c8e1486f78a525b0162c1edf9c2de931318a5 100644 (file)
@@ -1507,12 +1507,12 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
        while (opt_f) { // -f
                char *line;
                FILE *cmdfile;
-               cmdfile = xfopen_for_read(llist_pop(&opt_f));
+               cmdfile = xfopen_stdin(llist_pop(&opt_f));
                while ((line = xmalloc_fgetline(cmdfile)) != NULL) {
                        add_cmd(line);
                        free(line);
                }
-               fclose(cmdfile);
+               fclose_if_not_stdin(cmdfile);
        }
        /* if we didn't get a pattern from -e or -f, use argv[0] */
        if (!(opt & 0x30)) {