-
Notifications
You must be signed in to change notification settings - Fork 52
[201_71] 修复导言区调用未定义的宏导致软件crash问题 #2751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <TMU|<tuple|1.1.0|2026.1.2>> | ||
|
|
||
| <style|<tuple|generic|chinese|table-captions-above|number-europe|preview-ref>> | ||
|
|
||
| <\body> | ||
| <\hide-preamble> | ||
| <assign|theorem|<with|color|<hybrid|backcolor>|>> | ||
| </hide-preamble> | ||
|
|
||
| 1111 | ||
| </body> | ||
|
|
||
| <\initial> | ||
| <\collection> | ||
| <associate|page-medium|paper> | ||
| <associate|page-screen-margin|false> | ||
| </collection> | ||
| </initial> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # [201_71] 修复导言区调用未定义的宏导致软件crash问题 | ||
|
|
||
| ## 如何测试 | ||
| 1. 打开 git/mogan/TeXmacs/tests/tmu/201_71.tmu 文件 | ||
| 2. `Ctrl+Shift+p`进入导言区 | ||
| 3. 鼠标光标移动到`backcolor`后回车应该不会导致软件闪退问题 | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -560,6 +560,7 @@ edit_env_rep::exec (tree t) { | |||||||||||
| return exec_frame_inverse (t); | ||||||||||||
|
|
||||||||||||
| default: | ||||||||||||
| if (L (t) == UNINIT) return t; | ||||||||||||
| if (L (t) < START_EXTENSIONS) { | ||||||||||||
| int i, n= N (t); | ||||||||||||
| // cout << "Executing " << t << "\n"; | ||||||||||||
|
|
@@ -659,7 +660,7 @@ edit_env_rep::exec_with (tree t) { | |||||||||||
| write_update (vars[i], newv[i]); | ||||||||||||
| tree r= exec (t[n - 1]); | ||||||||||||
| for (i= k - 1; i >= 0; i--) | ||||||||||||
| write_update (vars[i], oldv[i]); | ||||||||||||
| if (L (oldv[i]) != UNINIT) write_update (vars[i], oldv[i]); | ||||||||||||
|
|
||||||||||||
| tree u (WITH, n); | ||||||||||||
| for (i= 0; i < k; i++) { | ||||||||||||
|
|
@@ -852,7 +853,11 @@ edit_env_rep::exec_value (tree t) { | |||||||||||
| if (N (t) < 1) return tree (ERROR, "bad value"); | ||||||||||||
| tree r= exec (t[0]); | ||||||||||||
| if (is_compound (r)) return tree (ERROR, "bad value"); | ||||||||||||
| return exec (read (r->label)); | ||||||||||||
| string name= r->label; | ||||||||||||
| if (!provides (name)) return ""; | ||||||||||||
| tree value= read (name); | ||||||||||||
| if (L (value) == UNINIT) return ""; | ||||||||||||
| return exec (value); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| tree | ||||||||||||
|
|
@@ -2667,7 +2672,7 @@ edit_env_rep::exec_until_with (tree t, path p, string var, int level) { | |||||||||||
| return true; | ||||||||||||
| } | ||||||||||||
| for (i= k - 1; i >= 0; i--) | ||||||||||||
| write_update (vars[i], oldv[i]); | ||||||||||||
| if (L (oldv[i]) != UNINIT) write_update (vars[i], oldv[i]); | ||||||||||||
|
||||||||||||
| if (L (oldv[i]) != UNINIT) write_update (vars[i], oldv[i]); | |
| if (L (oldv[i]) != UNINIT) | |
| write_update (vars[i], oldv[i]); | |
| else | |
| reset (vars[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix prevents writing UNINIT values back, which avoids crashes but changes the semantics of the WITH construct. Variables that didn't exist before a WITH block will now persist after the block exits, instead of returning to their undefined state. Consider using env->reset(vars[i]) instead of skipping the write_update when oldv[i] is UNINIT, to properly restore the undefined state.