Skip to content

Commit

Permalink
complete: work around "mawk <= 1.3.4-20200525" type-inference bug
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 11, 2024
1 parent aa396f6 commit 546499b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
- mandb: process less formatting sequences in parsing `--help` `#D2244` 60d36ba5
- mandb: hook into bash-completion's `_comp_command_offset` `#D2255` cbcce625
- canvas: update tables for Unicode 16.0.0 `#D2283` 5b43ca3f 25a10a6f
- complete: work around `mawk <= 1.3.4-20200525` type-inference bug (reported by KaKi87) `#D2295` xxxxxxxx

## Contrib

Expand Down
15 changes: 6 additions & 9 deletions lib/core-complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3941,8 +3941,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
}
}
function mandb_process_items(items, _, i, n, items_count, item, name, entry, record, desc, option, optarg, suffix) {
n = length(items);
function mandb_process_items(items, n, _, i, items_count, item, name, entry, record, desc, option, optarg, suffix) {
items_count = 0;
mandb_count = 0;
for (i = 1; i <= n; i++) {
Expand Down Expand Up @@ -3989,8 +3988,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
# filters
# uniq, remove empty
function uniq_items(items, _, n, m, i, item, uniq) {
n = length(items);
function uniq_items(items, n, _, m, i, item, uniq) {
m = 0;
for (i = 1; i <= n; i++) {
item = items[i];
Expand All @@ -4003,8 +4001,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
}
# filter by regex, restore if nothing matches
function filter_items_by_regex(items, rex_filter, _, n, m, i, item) {
n = length(items);
function filter_items_by_regex(items, n, rex_filter, _, m, i, item) {
m = 0;
for (i = 1; i <= item_count; i++) {
item = items[i];
Expand Down Expand Up @@ -4049,7 +4046,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
}
# 1. uniq
item_count = uniq_items(items);
item_count = uniq_items(items, item_count);
# 2. rtrim
if (c_enable_rtrim) {
Expand All @@ -4059,7 +4056,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
# 3. filter-by-prefix
if (c_enable_filter) {
item_count = filter_items_by_regex(items, c_rex_filter);
item_count = filter_items_by_regex(items, item_count, c_rex_filter);
}
# 4. sort
Expand All @@ -4073,7 +4070,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
# 5. mandb
has_mandb = 0;
if (c_enable_mandb) {
item_count = mandb_process_items(items);
item_count = mandb_process_items(items, item_count);
has_mandb = mandb_count != 0;
}
Expand Down
7 changes: 7 additions & 0 deletions memo/D2295.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# bashrc

source ~/.opt/bash-completion/2.11/share/bash-completion/bash_completion
source ~/.mwg/src/ble.sh/out/ble.sh --norc
#ble/bin/awk() { mawk-1.3.4-20230525 -v AWKTYPE=mawk "$@"; }
ble/bin/awk() { mawk-1.3.4-20200120 -v AWKTYPE=mawk "$@"; }
unset -f ble/bin/gawk
18 changes: 17 additions & 1 deletion note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7700,6 +7700,21 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2024-12-11

* complete: mawk-1.3.4-20230525 以前でプログラム補完が全く効かない (reported by KaKi87) [#D2295]
https://github.com/akinomyoga/ble.sh/issues/535

どうも mawk-1.3.4-20230525 以前では関数引数が配列の時に a[] よりも前に
length(a) があると、勝手にその引数はスカラー文字列と判定してコンパイルを実
行する様である。そしてこの振る舞いはずっと昔からだった様である。これまで報
告を受けなかったのは、gawk が入っているシステムでは mawk よりも gawk を優先
してこの部分の処理で使っていたため。git clone してビルドする方式だと何れに
しても gawk が要求されるので、殆どのユーザーは gawk をいれていたのだった。
一方で、報告者は nightly version を使っていた。

取り敢えず修正した。動作確認もした。

2024-11-28

* README: README 及び wiki によく行う説明をまとめる [#D2294]
Expand Down Expand Up @@ -7781,7 +7796,8 @@ bash_tips
と思ったがやはりこれは関係ない事の気がするし、いつの間にかに他の人が色々
別の話をしているので気にしない事にする。

* 返信 https://www.reddit.com/r/bash/comments/1gzn6gu/blesh_performance_tune_help/?show=original
* done; 返信 https://www.reddit.com/r/bash/comments/1gzn6gu/blesh_performance_tune_help/?show=original
* done: 返信 https://github.com/akinomyoga/ble.sh/discussions/525

* done: profiler の使い方等についても記述するべきではないか。というか、そ
もそも performance を改善する為にできることはないかと質問しているのは、
Expand Down

0 comments on commit 546499b

Please sign in to comment.