Skip to content

Add files via upload - #15

Open
joyfaker wants to merge 1 commit into
developfrom
joyfaker-patch-7
Open

Add files via upload#15
joyfaker wants to merge 1 commit into
developfrom
joyfaker-patch-7

Conversation

@joyfaker

Copy link
Copy Markdown
Owner

[Describe your pull request here. Please read the text below the line and make sure you follow the checklist.]

  • The changes are described in detail, both the what and why.
  • If applicable, an existing issue is referenced.
  • The Code coverage remained at 100%. A test case for every new line of code.
  • If applicable, the documentation is updated.
  • The source code is amalgamated by running make amalgamate.

Read the Contribution Guidelines for detailed information.

Signed-off-by: joyfaker <joyfakerauth@gmail.com>
@xytestapp

xytestapp Bot commented Jul 28, 2026

Copy link
Copy Markdown

AI代码审查报告

变更概览

本次 PR 涉及 16 个文件,新增 +998 行,删除 -54 行。

功能变更摘要

本 PR 为 Vim 引入了持久化撤销(Persistent Undo)功能,允许将撤销历史保存到磁盘并在重新打开文件时恢复。通过新增特性宏、:wundo/:rundo 命令以及 undofile/undodir 选项,实现了撤销树的序列化与反序列化。同时重构了 SHA256 模块以支持文件内容哈希校验,并在文件读写流程中集成自动加载与保存逻辑,确保撤销历史与文件内容的一致性。

变更记录 (Changes)

模块 / 文件 (Cohort / File(s)) 摘要 (Summary)
特性开关与选项配置
src/feature.h, src/eval.c, src/option.c, src/option.h
定义持久化撤销编译宏,新增 undofile 与 undodir 全局及缓冲区选项,并在 has() 函数中注册特性标识,为功能提供完整的配置与检测基础。
撤销命令与执行层
src/ex_cmds.h, src/ex_docmd.c
在命令表中注册 :wundo 和 :rundo 命令,实现对应的命令解析与执行函数,通过调用底层撤销树读写接口完成撤销历史的显式保存与加载。
文件 I/O 与哈希集成
src/fileio.c, src/sha256.c
重构 SHA256 模块导出核心哈希函数,在文件读取流程中实时计算内容哈希,并根据选项配置自动定位、校验并加载对应的持久化撤销文件。
代码规范与底层工具
src/buffer.c, src/memline.c, src/os_mac.h
统一多处注释排版与宏定义缩进,将符号链接解析函数改为非静态以适配原型声明,提升代码可维护性并为后续文件路径处理提供支持。
其他变更
src/spell.c, src/structs.h, src/undo.c, src/version.c, src/vim.h
上述模块之外的其他文件变更。

问题严重级别分布

级别 数量 占比
🟡 中危 10 100%

代表性问题(至多 10 条,按严重级别优先)

  1. 🟡 中危 softwareSafe/vim/src/ex_docmd.c L8464: 全局符号污染,若其他模块定义了同名函数会导致链接错误;且不符合 Vim 内部函数的封装惯例。
  2. 🟡 中危 softwareSafe/vim/src/fileio.c L2586: 在文件读取部分失败但未正确清理上下文的极端路径下,可能导致基于不完整数据的哈希校验,进而加载错误的撤销历史或导致内存异常。
  3. 🟡 中危 src/ex_docmd.c L8464: line 306 处将 ex_wundoex_rundo 声明为 static,但 line 8464 和 8474 处的函数定义缺少 static 关键字。C 语言标准规定,若…
  4. 🟡 中危 src/fileio.c L1189: 当缓冲区没有有效文件名时,可能导致哈希计算基于错误的数据源,进而使撤销文件校验失败或加载错误的撤销历史。
  5. 🟡 中危 src/fileio.c L2586: line 2586 处仅检查 read_undo_file 标志即调用 sha256_finishu_read_undo,但未验证文件读取是否成功(error 变量)。当 lin…
  6. 🟡 中危 src/undo.c L874: > 【nuwa 静态扫描】 本条经 nuwa MCP 静态分析命中。

line 874 处调用 fread 读取哈希值未检查返回值 → line 876 处 memcmp 比较可能未完全初始…
7. 🟡 中危 src/undo.c L970: > 【cppcheck 静态扫描】 本条经 cppcheck 静态分析命中。

line 969 处分配 uep 后,line 970 处立即调用 vim_memset 初始化,但 line …
8. 🟡 中危 src/undo.c L978: line 978 处为 array 分配内存后未检查返回值,line 980 处直接进入循环使用 array[i]。当 uep->ue_size 较大导致分配失败时,array 为 NULL,循环内写…
9. 🟡 中危 src/undo.c L1140: line 1140 处调用 alloc 分配 entry_lens 数组后未检查返回值,line 1150 处循环直接写入 entry_lens[i]。内存不足时 alloc 返回 NULL,导致空指…
10. 🟡 中危 src/undo.c L1274: line 1274 处调用 vim_read 读取 2 字节魔数未检查返回值,line 1276 处直接使用 buf[0] 和 buf[1] 进行魔数校验。若文件为空或读取失败,buf 保持未初始化状…

Powered by: qwen3.6-plus


CodeHawk 提供支持 · nuwa


分析任务ID: BOT-PR-TASK-GITHUB-e49a10dd-bd859710-8a33-11f1-8b0d-bcc56923e636🦅

@joyfaker

Copy link
Copy Markdown
Owner Author

@xytestapp /pr-review

Comment thread c_security_test.c
@@ -0,0 +1,25 @@

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 AI 代码审查发现问题

📋 问题概述

line 306 处将 ex_wundoex_rundo 声明为 static,但 line 8464 和 8474 处的函数定义缺少 static 关键字。C 语言标准规定,若函数先被声明为静态链接,后续定义也必须为静态,否则构成约束违规(constraint violation),将直接导致编译失败。

📍 问题详情

🟡 问题 1 | 严重程度: MEDIUM | 行号: 1

💬 详细说明:

  • line 306 处将 ex_wundoex_rundo 声明为 static,但 line 8464 和 8474 处的函数定义缺少 static 关键字。C 语言标准规定,若函数先被声明为静态链接,后续定义也必须为静态,否则构成约束违规(constraint violation),将直接导致编译失败。

📝 问题代码:

void

💡 修复建议:

在 line 8464 和 8474 的函数定义前添加 static 关键字,使其与 line 306-307 的声明保持一致。这符合 Vim 中命令处理函数通常为内部静态函数的惯例。

✅ 修复示例:

    #ifdef FEAT_PERSISTENT_UNDO
    static void
ex_wundo(eap)
    exarg_T *eap;
{
    char_u hash[UNDO_HASH_SIZE];

    u_compute_hash(hash);
    u_write_undo(eap->arg, eap->forceit, curbuf, hash);
}

🔗 参考链接

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xytestapp 你还在不

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在


分析任务ID: BOT-CHAT-TASK-GITHUB-e49a10dd-2952ef00-8bf7-11f1-976a-95e04ab80475🦅

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xytestapp 你还在不2

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xytestapp 你还在不3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joyfaker,可以收到消息。我在这里;直接 @coderabbit 并说明需要我检查、解释或处理的内容即可。

You are interacting with an AI system.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xytestapp 你还在不 尊嘟假的1

@xytestapp xytestapp Bot Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joyfaker

AI代码审查完成,发现 10 个问题(行评 10 条)

关联评论:

@xytestapp 你还在不 尊嘟假的1


分析任务ID: BOT-CHAT-TASK-GITHUB-e49a10dd-ca8a65d0-8c86-11f1-9cc7-913a8d6bcaf1🦅

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xytestapp hello~

@xytestapp xytestapp Bot Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joyfaker,AI代码审查完成,发现 10 个问题(行评 10 条)

@xytestapp hello~

分析任务ID: BOT-CHAT-TASK-GITHUB-e49a10dd-ec0a07f0-8c87-11f1-830e-f78a926c79cf

🦅

@joyfaker

Copy link
Copy Markdown
Owner Author

@xytestapp are u ok?

@xytestapp

xytestapp Bot commented Jul 28, 2026

Copy link
Copy Markdown

🚀 任务已启动(CodeHawk)

分析任务已启动,正在进行处理。

无需额外操作,任务完成后系统将自动反馈:

  • 分析结论
  • 风险与问题说明(如有)
  • 修复建议或后续行动建议

请稍候,结果生成后将自动同步。


任务 ID: BOT-CHAT-TASK-GITHUB-e49a10dd-425ed640-8a34-11f1-8677-b2dfbe56bfd6

reply_to_comment_id: 5099584874

@joyfaker

Copy link
Copy Markdown
Owner Author

@xytestapp 你还在不

@xytestapp

xytestapp Bot commented Jul 30, 2026

Copy link
Copy Markdown

我在


分析任务ID: BOT-CHAT-TASK-GITHUB-e49a10dd-be1ec7e0-8bf6-11f1-9ece-0d929bb649e3🦅

reply_to_comment_id: 5128840192

@joyfaker

Copy link
Copy Markdown
Owner Author

reply_to_comment_id

@joyfaker joyfaker closed this Jul 30, 2026
@joyfaker joyfaker reopened this Jul 30, 2026
@joyfaker

Copy link
Copy Markdown
Owner Author

@xytestapp 外面你还在不2

@joyfaker

Copy link
Copy Markdown
Owner Author

@xytestapp 外面你还在不3

@joyfaker

Copy link
Copy Markdown
Owner Author

@xytestapp 外面你还在不4

@xytestapp

xytestapp Bot commented Jul 30, 2026

Copy link
Copy Markdown

我在


分析任务ID: BOT-CHAT-TASK-GITHUB-e49a10dd-3e092e70-8bfa-11f1-9c3c-cef06f85e364🦅

@joyfaker

Copy link
Copy Markdown
Owner Author

@CodeRabbit 可以收到消息吗?

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@joyfaker 可以收到,我在。请告诉我需要我检查、审查或处理什么。

You are interacting with an AI system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant