Skip to content

Commit

Permalink
util, canvas: fix leak variables
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed May 28, 2021
1 parent bb53271 commit 5967d6c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions make_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ function sub:scan {
\Zble/util/print "trap -- '\''\$\{h//\$Q/\$q}'\'' \$nZd
\Zline = "bind"Zd
\Zlocal trap_command="trap -- Zd
\Zlocal trap$Zd
g'

sub:scan/a.txt
Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
- global: use `_ble_term_IFS` `#D1557` d23ad3c
- global: work around `localvar_inherit` for varname-list init `#D1566` 5c2edfc
- util: fix `ble/util/dense-array#fill-range` a46fdaf
- util: fix leak variables `buff`, `trap`, `{x,y}{1,2}` `#D1572` 0000000

<!---------------------------------------------------------------------------->
# ble-0.4.0-devel2
Expand Down
12 changes: 12 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4655,6 +4655,18 @@ bash_tips

2021-05-27

* canvas: 変数リークしている (buff, trap, {x,y}{1,2}) [#D1572]

buff, trap は直ぐに見つかったが x1,x2,y1,y2 は使っている所が多いと思われる
ので探すのは面倒である。とは言え特にプロンプト関係が怪しいと思われる。

結局 x1,x2,y1,y2 は trace 自体が駄目だった。justify の初期化位置よりも後で
local x1 x2 y1 y2 が宣言されていたのだった。然し、この justify の初期化位置
は此処でなければならなかったのか。そういう理由があった様な気もするがこれに
ついてはテストで確認する必要がある様に感じている。contra によるテストを設定
して確認する必要がある。contra でテストを実行してみた所、特に問題なくテスト
が通った。なのでこの部分の順序変更については気にしなくて良いだろう。

* 新しい ble-face, blehook, bleopt で問題が起こっている [#D1571]

* fixed: blehook で新しい hook を作成できなくなっている。何故だろうか。これ
Expand Down
14 changes: 7 additions & 7 deletions src/canvas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ function ble/canvas/trace/.justify/next-field {
## @fn ble/canvas/trace/.justify/unpack packed_data
## @var[out] sep wmin xI yI xF yF x1 y1 x2 y2 esc
function ble/canvas/trace/.justify/unpack {
local data=$1
local data=$1 buff
sep=${data::1}; data=${data:2}
wmin=${data%%:*}; data=${data#*:}
ble/string#split buff , "${data%%:*}"; data=${data#*:}
Expand Down Expand Up @@ -1392,12 +1392,6 @@ function ble/canvas/trace/.impl {
local lc=32 lg=0
fi

local flag_justify=
if [[ $trace_flags == *J* ]]; then
flag_justify=1
ble/canvas/trace/.justify/begin-line
fi

# prepare measure
local flag_bbox= flag_gbox=
if [[ $trace_flags == *[BJ]* ]]; then
Expand Down Expand Up @@ -1425,6 +1419,12 @@ function ble/canvas/trace/.impl {
local xlimit=$cols
[[ $opt_relative || $trace_flags == *J* ]] && xenl=1 xlimit=$((cols-1))

local flag_justify=
if [[ $trace_flags == *J* ]]; then
flag_justify=1
ble/canvas/trace/.justify/begin-line
fi

local i=0 iN=${#text}
while ((i<iN)); do
local tail=${text:i}
Expand Down
7 changes: 4 additions & 3 deletions src/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ function ble/debug/print {
## ```
## eval "${_ble_debug_check_leak_variable//@var/ret}"
## ...codes1...
## ble/util/.check-leak-variable ret tag1
## ble/debug/.check-leak-variable ret tag1
## ...codes2...
## ble/util/.check-leak-variable ret tag2
## ble/debug/.check-leak-variable ret tag2
## ...codes3...
## ble/util/.check-leak-variable ret tag3
## ble/debug/.check-leak-variable ret tag3
## ```
_ble_debug_check_leak_variable='local @var=__t1wJltaP9nmow__'
function ble/debug/.check-leak-variable {
Expand Down Expand Up @@ -1933,6 +1933,7 @@ function ble/builtin/trap/install-hook {
# - INT は bind -x 内だと改めて設定しないと有効にならない(?)様なの
# で既に登録されていても、builtin trap は省略できない。
#
local trap
ble/util/assign trap "builtin trap -p $name"
[[ $trap_command == "$trap" ]] && return 0
fi
Expand Down

0 comments on commit 5967d6c

Please sign in to comment.