From 027a73a903af306449710ce12bc09e0e3550c6c9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 4 Aug 2016 10:16:59 -0500 Subject: Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout, add xopenro() that takes one argument and understands "-" means stdin, and switch over lots of users. --- toys/posix/patch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/posix/patch.c') diff --git a/toys/posix/patch.c b/toys/posix/patch.c index 2c73d958..fbad1fb9 100644 --- a/toys/posix/patch.c +++ b/toys/posix/patch.c @@ -265,7 +265,7 @@ void patch_main(void) strip = 0; char *oldname = NULL, *newname = NULL; - if (TT.infile) TT.filepatch = xopen(TT.infile, O_RDONLY); + if (TT.infile) TT.filepatch = xopenro(TT.infile); TT.filein = TT.fileout = -1; if (TT.dir) xchdir(TT.dir); @@ -402,7 +402,7 @@ void patch_main(void) TT.filein = xcreate(name, O_CREAT|O_EXCL|O_RDWR, 0666); } else { printf("patching %s\n", name); - TT.filein = xopen(name, O_RDONLY); + TT.filein = xopenro(name); } if (toys.optflags & FLAG_dry_run) TT.fileout = xopen("/dev/null", O_RDWR); -- cgit v1.2.3