1 Star 0 Fork 44

src-oepkgs-oE-rv/less

forked from src-openEuler/less 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Make-histpattern-return-negative-value-to-indicate-e.patch 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
From 9b718ada456d49c795278328ed9d4d6f7f19686d Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Wed, 13 Jan 2021 14:25:21 -0800
Subject: [PATCH] Make histpattern return negative value to indicate error.
Avoid "Pattern not found" message after "Invalid pattern".
---
search.c | 13 ++++++++++++---------
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/search.c b/search.c
index 43b90a5..1165ba3 100644
--- a/search.c
+++ b/search.c
@@ -1413,7 +1413,7 @@ hist_pattern(search_type)
return (0);
if (set_pattern(&search_info, pattern, search_type) < 0)
- return (0);
+ return (-1);
#if HILITE_SEARCH
if (hilite_search == OPT_ONPLUS && !hide_hilite)
@@ -1446,7 +1446,7 @@ chg_caseless(VOID_PARAM)
* Regenerate the pattern using the new state.
*/
clear_pattern(&search_info);
- hist_pattern(search_info.search_type);
+ (void) hist_pattern(search_info.search_type);
}
}
@@ -1474,10 +1474,13 @@ search(search_type, pattern, n)
* A null pattern means use the previously compiled pattern.
*/
search_type |= SRCH_AFTER_TARGET;
- if (!prev_pattern(&search_info) && !hist_pattern(search_type))
+ if (!prev_pattern(&search_info))
{
- error("No previous regular expression", NULL_PARG);
- return (-1);
+ int r = hist_pattern(search_type);
+ if (r == 0)
+ error("No previous regular expression", NULL_PARG);
+ if (r <= 0)
+ return (-1);
}
if ((search_type & SRCH_NO_REGEX) !=
(search_info.search_type & SRCH_NO_REGEX))
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-oepkgs-oe-rv/less.git
git@gitee.com:src-oepkgs-oe-rv/less.git
src-oepkgs-oe-rv
less
less
master

搜索帮助