1 Star 0 Fork 12

src-oepkgs-oE-rv/python-pyinstaller

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Reimplement-pyi-search-path-using-strtok.patch 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
hht8 提交于 2020-06-29 09:47 . Package init
From a95fbb0f497680cce0a097aa3a143e84943b903f Mon Sep 17 00:00:00 2001
From: Hartmut Goebel <h.goebel@crazy-compilers.com>
Date: Sun, 3 May 2020 15:26:43 +0200
Subject: [PATCH] Bootloader: Reimplement pyi_search_path using strtok().
This avoids some places where we need to cope with strncpy(= and related. Also
the implementation becomes much simpler.
---
bootloader/src/pyi_path.c | 34 +++++++---------------------------
1 file changed, 7 insertions(+), 27 deletions(-)
diff --git a/bootloader/src/pyi_path.c b/bootloader/src/pyi_path.c
index 8736de8cc5..fb417e9269 100644
--- a/bootloader/src/pyi_path.c
+++ b/bootloader/src/pyi_path.c
@@ -205,40 +205,20 @@ pyi_path_exists(char * path)
int
pyi_search_path(char * result, const char * appname)
{
- char * path = pyi_getenv("PATH");
- char dirname[PATH_MAX + 1];
- char filename[PATH_MAX + 1];
+ char *path = pyi_getenv("PATH"); // returns a copy
+ char *dirname;
if (NULL == path) {
return -1;
}
- while (1) {
- char *delim = strchr(path, PYI_PATHSEP);
-
- if (delim) {
- size_t len = delim - path;
-
- if (len > PATH_MAX) {
- len = PATH_MAX;
- }
- strncpy(dirname, path, len);
- *(dirname + len) = '\0';
- }
- else { /* last $PATH element */
- strncpy(dirname, path, PATH_MAX);
- }
- pyi_path_join(filename, dirname, appname);
-
- if (pyi_path_exists(filename)) {
- strncpy(result, filename, PATH_MAX);
+ dirname = strtok(path, PYI_PATHSEPSTR);
+ while (dirname != NULL) {
+ pyi_path_join(result, dirname, appname);
+ if (pyi_path_exists(result)) {
return 0;
}
-
- if (!delim) {
- break;
- }
- path = delim + 1;
+ dirname = strtok(NULL, PYI_PATHSEPSTR);
}
return -1;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-oepkgs-oe-rv/python-pyinstaller.git
git@gitee.com:src-oepkgs-oe-rv/python-pyinstaller.git
src-oepkgs-oe-rv
python-pyinstaller
python-pyinstaller
master

搜索帮助