1 Star 0 Fork 38

sugarfillet/bash

forked from src-openEuler/bash 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bash-5.0-patch1.patch 3.58 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:32 . Package init
diff --git a/bashline.c b/bashline.c
index 2846aab..75e79f1 100644
--- a/bashline.c
+++ b/bashline.c
@@ -231,6 +231,7 @@ static int bash_possible_variable_completions __P((int, int));
static int bash_complete_command __P((int, int));
static int bash_possible_command_completions __P((int, int));
+static int completion_glob_pattern __P((char *));
static char *glob_complete_word __P((const char *, int));
static int bash_glob_completion_internal __P((int));
static int bash_glob_complete_word __P((int, int));
@@ -1741,7 +1742,7 @@ bash_default_completion (text, start, end, qc, compflags)
/* This could be a globbing pattern, so try to expand it using pathname
expansion. */
- if (!matches && glob_pattern_p (text))
+ if (!matches && completion_glob_pattern ((char *)text))
{
matches = rl_completion_matches (text, glob_complete_word);
/* A glob expression that matches more than one filename is problematic.
@@ -1850,7 +1851,7 @@ command_word_completion_function (hint_text, state)
glob_matches = (char **)NULL;
}
- globpat = glob_pattern_p (hint_text);
+ globpat = completion_glob_pattern ((char *)hint_text);
/* If this is an absolute program name, do not check it against
aliases, reserved words, functions or builtins. We must check
@@ -3713,6 +3714,61 @@ bash_complete_command_internal (what_to_do)
return bash_specific_completion (what_to_do, command_word_completion_function);
}
+static int
+completion_glob_pattern (string)
+ char *string;
+{
+ register int c;
+ char *send;
+ int open;
+
+ DECLARE_MBSTATE;
+
+ open = 0;
+ send = string + strlen (string);
+
+ while (c = *string++)
+ {
+ switch (c)
+ {
+ case '?':
+ case '*':
+ return (1);
+
+ case '[':
+ open++;
+ continue;
+
+ case ']':
+ if (open)
+ return (1);
+ continue;
+
+ case '+':
+ case '@':
+ case '!':
+ if (*string == '(') /*)*/
+ return (1);
+ continue;
+
+ case '\\':
+ if (*string == 0)
+ return (0);
+ }
+
+ /* Advance one fewer byte than an entire multibyte character to
+ account for the auto-increment in the loop above. */
+#ifdef HANDLE_MULTIBYTE
+ string--;
+ ADVANCE_CHAR_P (string, send - string);
+ string++;
+#else
+ ADVANCE_CHAR_P (string, send - string);
+#endif
+ }
+ return (0);
+}
+
static char *globtext;
static char *globorig;
@@ -3877,7 +3933,7 @@ bash_vi_complete (count, key)
t = substring (rl_line_buffer, p, rl_point);
}
- if (t && glob_pattern_p (t) == 0)
+ if (t && completion_glob_pattern (t) == 0)
rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */
FREE (t);
diff --git a/lib/glob/glob_loop.c b/lib/glob/glob_loop.c
index 5f319cc..7d6ae21 100644
--- a/lib/glob/glob_loop.c
+++ b/lib/glob/glob_loop.c
@@ -54,17 +54,11 @@ INTERNAL_GLOB_PATTERN_P (pattern)
continue;
case L('\\'):
-#if 0
/* Don't let the pattern end in a backslash (GMATCH returns no match
if the pattern ends in a backslash anyway), but otherwise return 1,
since the matching engine uses backslash as an escape character
and it can be removed. */
return (*p != L('\0'));
-#else
- /* The pattern may not end with a backslash. */
- if (*p++ == L('\0'))
- return 0;
-#endif
}
return 0;
diff --git a/patchlevel.h b/patchlevel.h
index 1cd7c96..40db1a3 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 0
+#define PATCHLEVEL 1
#endif /* _PATCHLEVEL_H_ */
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sugarfillet/bash.git
[email protected]:sugarfillet/bash.git
sugarfillet
bash
bash
master

搜索帮助