代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/grep 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From ad6de316cca655cd8b0b20b3e9dd18e7e98e443a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 21 Aug 2021 10:44:17 -0700
Subject: [PATCH] =?UTF-8?q?grep:=20avoid=20sticky=20problem=20with?=
=?UTF-8?q?=20=E2=80=98-f=20-=20-f=20-=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Inspired by bug#50129 even though this is a different bug.
* src/grep.c (main): For ‘-f -’, use clearerr (stdin) after
reading, so that ‘grep -f - -f -’ reads stdin twice even
when stdin is a tty. Also, for ‘-f FILE’, report any
I/O error when closing FILE.
---
src/grep.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/grep.c b/src/grep.c
index 7a33686..b2a0566 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2477,7 +2477,6 @@ main (int argc, char **argv)
int matcher = -1;
int opt;
int prev_optind, last_recursive;
- int fread_errno;
intmax_t default_context;
FILE *fp;
exit_failure = EXIT_TROUBLE;
@@ -2648,11 +2647,17 @@ main (int argc, char **argv)
if (cc == 0)
break;
}
- fread_errno = errno;
- if (ferror (fp))
- die (EXIT_TROUBLE, fread_errno, "%s", optarg);
- if (fp != stdin)
- fclose (fp);
+ int err = errno;
+ if (!ferror (fp))
+ {
+ err = 0;
+ if (fp == stdin)
+ clearerr (fp);
+ else if (fclose (fp) != 0)
+ err = errno;
+ }
+ if (err)
+ die (EXIT_TROUBLE, err, "%s", optarg);
/* Append final newline if file ended in non-newline. */
if (newkeycc != keycc && keys[newkeycc - 1] != '\n')
keys[newkeycc++] = '\n';
--
1.8.3.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。