1 Star 0 Fork 78

zhoushuiqing/rpm

forked from src-openEuler/rpm 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-support-for-POSIX-getopt-behaviour.patch 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
renxichen 提交于 2023-02-28 20:00 . bugfix with upstream patches about fifo
From 1f47b1cc0eddbb1921d81249a4bd604089c71495 Mon Sep 17 00:00:00 2001
From: "(GalaxyMaster)" <galaxy4public@users.noreply.github.com>
Date: Tue, 31 Jan 2023 18:24:55 +1100
Subject: [PATCH] support for POSIX getopt() behaviour
[POSIX defines optarg only for options with arguments](https://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html) and callback() is expecting optarg to be NULL for options without arguments, however, at least on musl optarg will carry a pointer to the argument of the previous option with argument. This commit makes the behaviour deterministic and expected.
---
rpmio/rgetopt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rpmio/rgetopt.c b/rpmio/rgetopt.c
index f789fa8fe..b14366a8a 100644
--- a/rpmio/rgetopt.c
+++ b/rpmio/rgetopt.c
@@ -28,6 +28,7 @@ int rgetopt(int argc, char * const argv[], const char *opts,
optind = 0;
#else
optind = 1;
+ optarg = NULL;
#endif
while ((c = getopt(argc, argv, opts)) != -1) {
@@ -39,6 +40,7 @@ int rgetopt(int argc, char * const argv[], const char *opts,
rc = -1;
break;
}
+ optarg = NULL;
}
return (rc < 0) ? -optopt : optind;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ZhouShuiQing/rpm.git
git@gitee.com:ZhouShuiQing/rpm.git
ZhouShuiQing
rpm
rpm
master

搜索帮助