1 Star 0 Fork 98

yu_boyun/grub2

forked from src-openEuler/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0186-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
hanzj0122_admin 提交于 2020-07-29 20:47 . update to 2.04
From c8a79b3f43d083a70688067f095edea1a3dffb7b Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <[email protected]>
Date: Mon, 4 Nov 2019 17:33:30 +0100
Subject: [PATCH 186/220] blscfg: Add support for sorting the plus ('+') higher
than base version
Handle plus separator. Concept is the same as tilde, except that if one of
the strings ends (base version), the other is considered as higher version.
A plus character is used for example by the Linux kernel build system to
denote that is the base version plus some changes on top of it.
Currently for example rpmvercmp("5.3.0", "5.3.0+") will return 0 even when
the two versions are not the same.
Resolves: rhbz#1767395
Signed-off-by: Javier Martinez Canillas <[email protected]>
---
grub-core/commands/blscfg.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index d78cff7..83b33c1 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -163,8 +163,8 @@ static int vercmp(const char * a, const char * b)
/* loop through each version segment of str1 and str2 and compare them */
while (*one || *two) {
- while (*one && !grub_isalnum(*one) && *one != '~') one++;
- while (*two && !grub_isalnum(*two) && *two != '~') two++;
+ while (*one && !grub_isalnum(*one) && *one != '~' && *one != '+') one++;
+ while (*two && !grub_isalnum(*two) && *two != '~' && *two != '+') two++;
/* handle the tilde separator, it sorts before everything else */
if (*one == '~' || *two == '~') {
@@ -175,6 +175,21 @@ static int vercmp(const char * a, const char * b)
continue;
}
+ /*
+ * Handle plus separator. Concept is the same as tilde,
+ * except that if one of the strings ends (base version),
+ * the other is considered as higher version.
+ */
+ if (*one == '+' || *two == '+') {
+ if (!*one) return -1;
+ if (!*two) return 1;
+ if (*one != '+') goto_return (1);
+ if (*two != '+') goto_return (-1);
+ one++;
+ two++;
+ continue;
+ }
+
/* If we ran to the end of either, we are finished with the loop */
if (!(*one && *two)) break;
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yu_boyun/grub2.git
[email protected]:yu_boyun/grub2.git
yu_boyun
grub2
grub2
master

搜索帮助