From caa77bc0733c3c14646fde39b722b0cd7802ad43 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Wed, 15 Dec 2021 10:08:57 +0900 Subject: [PATCH] mandb: fix small issues of man-page analysis --- docs/ChangeLog.md | 22 ++++++++++++---------- lib/core-complete.sh | 9 ++++++--- note.txt | 29 +++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 00a27148..1ec1836d 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -80,9 +80,9 @@ - blerc: fix the name of the option `bleopt canvas_winch_action` (reported by Knusper) b1be640 - menu (menu-style:desc): improve descriptions (motivated by Shahabaz-Bagwan) `#D1685` 4de1b45 - menu (menu-style:desc): support multicolumns (motivated by Shahabaz-Bagwan) `#D1686` 231dc39 -- term: let DECSCUSR pass through terminal multiplexers (motivated by cmplstofB) `#D1697` 0000000 -- complete: requote for more compact representations on full completions `#D1700` 0000000 -- complete: improve support for `declare` and `[[ ... ]]` `#D1701` 0000000 +- term: let DECSCUSR pass through terminal multiplexers (motivated by cmplstofB) `#D1697` a3349e4 +- complete: requote for more compact representations on full completions `#D1700` a1859b6 +- complete: improve support for `declare` and `[[ ... ]]` `#D1701` da38404 - syntax: fix completion and highlighting of `declare` with assignment arguments `#D1704` `#D1705` 0000000 - cmdspec: refactor `{mandb => cmdspec}_opts` `#D1706` `#D1707` 0000000 @@ -125,9 +125,9 @@ - main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 0525528 88e2df5 - mandb: integrate `mandb` with `bash-completion` (motivated by Shahabaz-Bagwan, bbyfacekiller and EmilySeville7cfg) `#D1688` c1cd666 - syntax: do not start argument completions immediately after previous word (reported by EmilySeville7cfg) `#D1690` 371a5a4 - - syntax: revert 371a5a4 and generate empty completion source on syntax error `#D1609` 0000000 + - syntax: revert 371a5a4 and generate empty completion source on syntax error `#D1609` e09fcab - syntax: strictly check variable names of `for`-statements `#D1692` d056547 -- widget `self-insert`: untranslate control chars and insert the last character `#D1696` 0000000 +- widget `self-insert`: untranslate control chars and insert the last character `#D1696` 5ff3021 ## Fixes @@ -143,8 +143,10 @@ - mandb: use `manpath` and `man -w`, and read `/etc/man_db.conf` and `~/.manpath` `#D1637` 2365e09 - mandb: support the formats of the man pages of `awk` and `sed` (reported by bbyfacekiller) `#D1687` 6932018 - mandb: generate completions of options also for the empty word `#D1689` b90ac78 - - mandb: support the man-page formats of `wget`, `fish`, and `ping` (reported by bbyfacekiller) `#D1687` 0000000 - - mandb: carry optarg for e.g. `-a, --accept=LIST` `#D1687` 0000000 + - mandb: support the man-page formats of `wget`, `fish`, and `ping` (reported by bbyfacekiller) `#D1687` a79280e + - mandb: carry optarg for e.g. `-a, --accept=LIST` `#D1687` 23d5657 + - mandb: parse `--help` for specified commands `#D1693` e1ad2f1 + - mandb: fix small issues of man-page analysis `#D1708` 0000000 - edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` bc4735e - edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` 8379d4a - global: suppress missing locale errors (reported by 3ximus) `#D1440` 4d3c595 @@ -205,7 +207,7 @@ - blerc: add all the missing options `#D1667` 0228d76 - blerc: add missing faces `argument_option` and `cmdinfo_cd_cdpath` (reported by Prikalel) `#D1675` 26aaf87 -- README: describe how to invoke multiple widgets with a keybinding (motivated by michaelmob) `#D1699` 0000000 +- README: describe how to invoke multiple widgets with a keybinding (motivated by michaelmob) `#D1699` 6123551 ## Optimization @@ -253,8 +255,8 @@ - decode: work around the overwritten builtin `set` (reported by eadmaster) `#D1680` a6b4e2c - complete: work around the variable leaks by `virsh` completion from `libvirt` (reported by telometto) `#D1682` f985b9a - stty: do not remove keydefs for C-u, C-v, C-w, and C-? (reported by laoshaw) `#D1683` 82f74f0 -- builtin: print usages of emulated builtins on option errors `#D1694` 0000000 -- decode (`ble/builtin/bind`): improve compatibility of the deprecated form `bind key:rlfunc` (motivated by cmplstofB) `#D1698` 0000000 +- builtin: print usages of emulated builtins on option errors `#D1694` 6f74021 +- decode (`ble/builtin/bind`): improve compatibility of the deprecated form `bind key:rlfunc` (motivated by cmplstofB) `#D1698` b6fc4f0 ## Internal changes and fixes diff --git a/lib/core-complete.sh b/lib/core-complete.sh index 2d0b5a9f..a2d3d3d3 100644 --- a/lib/core-complete.sh +++ b/lib/core-complete.sh @@ -3527,7 +3527,7 @@ function ble/complete/mandb/.generate-cache-from-man { { sub(/[[:space:]]+$/, ""); - REQ = match($0, /^\.[_[:alnum:]]+/) ? substr($0, 2, RLENGTH) : ""; + REQ = match($0, /^\.[_[:alnum:]]+/) ? substr($0, 2, RLENGTH - 1) : ""; } REQ ~ /^(S[Ss]|S[Hh]|Pp)$/ { flush_topic(); next; } @@ -3611,7 +3611,9 @@ function ble/complete/mandb/.generate-cache-from-man { # Format #4: [[.IP "key" 4 \n .IX Item "..."]+ \n .PD \n desc] # This format is used by "wget". /^\.IP[[:space:]]+".*"([[:space:]]+[0-9]+)?$/ && fmt3_state != "key" { - if (!(g_keys_count && g_desc == "")) flush_topic(); + if (mode != "fmt4_desc") + if (!(g_keys_count && g_desc == "")) flush_topic(); + gsub(/^\.IP[[:space:]]+"|"([[:space:]]+[0-9]+)?$/, ""); register_key($0); mode = "fmt4_desc"; @@ -3714,7 +3716,7 @@ function ble/complete/mandb/.generate-cache-from-man { prev_optarg = ""; for (i = n; i > 0; i--) { spec = specs[i]; - sub(/,[[:space:]]*$/, "", spec); + sub(/,[[:space:]]+$/, "", spec); # Exclude non-options. # Exclude FS (\034) because it is used for separators in the cache format. @@ -4123,6 +4125,7 @@ function ble/complete/mandb/generate-cache { if [[ $update ]]; then local fs=$_ble_term_FS ble/bin/awk -F "$_ble_term_FS" ' + BEGIN { plus_count = 0; nodesc_count = 0; } $4 == "" { if ($1 ~ /^\+/) { plus_name[plus_count] = $1; diff --git a/note.txt b/note.txt index 2f1fcd09..6baec2f7 100644 --- a/note.txt +++ b/note.txt @@ -1678,10 +1678,6 @@ bash_tips * cmdspec: cd 関連の cmdinfo は core-cmdspec ではなくて contrib/cmdspec/* 辺 りに移動する? - * [BUG} mandb: declare で空の completion が生成されている。 - - * [BUG] wget の man page 抽出で short option の desc が空になっている。 - * PROMPT_COMMAND / trap DEBUG で問題が起こる? (found by rashad-moves) https://github.com/rashad-moves/HomeConfigurationFiles/commit/efbac4153fd5021f1bc00d42c618fd9d6f4090b9 @@ -5664,6 +5660,31 @@ bash_tips 2021-12-15 + * mandb: オプション候補生成で変な動作が幾つかある [#D1708] + + * ...] という謎の項目が生成されている at man.d/man + + どうやら以下の項目から生成されている様子だ。 + + | -m system[,...], --systems=system[,...] + | + | man を含めます。このオプションは $SYSTEM 環境変数を上書きします。 + + うーん。オプションを分割する時に /,\s*/ ではなくて /,\s+/ で分割する事に + した。スペース無しで記述するという事は考えにくいだろう。或いは + --arg=(hello, world) みたいになっている可能性もなくはないが面倒なので考え + ない。OK + + * fixed: declare で空の completion が生成されている。 + + 空の候補については集約の際に混入している様だ → これは修正した。 + nodesc のオプションを集める時に name[count++] としていたのを name[count]; + count++に分けた所、count を初期化していなかったので空文字列の添字に格納さ + れる様になってしまっていたのが原因だった。 + + * fixed: wget の man page 抽出で short option の desc が空になっている。 + これは man.d/man 由来である → 修正した。 + * progcolor: mandb_opts をキャッシュする様にする [#D1707] progcolor_optctx と同様に。これは declare のより詳細な実装で mandb_opts を