Skip to content

Commit

Permalink
mandb: improve extraction and cache for each locale
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 20, 2021
1 parent 18bb2d5 commit 3588158
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
42 changes: 23 additions & 19 deletions lib/core-complete.sh
Expand Up @@ -2660,39 +2660,43 @@ function ble/complete/mandb/.generate-cache {
(*) ble/bin/cat "$path" ;;
esac | ble/bin/awk -v type="$_ble_complete_mandb_convert_type" '
BEGIN {
g_key = "";
g_keys_count = 0;
g_desc = "";
if (type == "man") {
print ".TH __ble_ignore__ 1 __ble_ignore__ __ble_ignore__";
print ".ll 9999"
}
}
function flush_topic() {
if (g_key == "") return;
print "__ble_key__";
if (type == "man") print ".TP";
print g_key;
print "";
print "__ble_desc__";
print "";
print g_desc;
print "";
g_key = "";
function flush_topic(_, i) {
if (g_keys_count == 0) return;
for (i = 0; i < g_keys_count; i++) {
print "__ble_key__";
if (type == "man") print ".TP";
print g_keys[i];
print "";
print "__ble_desc__";
print "";
print g_desc;
print "";
}
g_keys_count = 0;
g_desc = "";
}
type == "man" && /^\.TP([^_[:alnum:]]|$)/ {
flush_topic(); mode = "key"; next;
if (g_keys_count && g_desc != "") flush_topic();
mode = "key"; next;
}
type == "mdoc" && /^\.It Fl([^_[:alnum:]]|$)/ {
flush_topic(); mode = "key";
if (g_keys_count && g_desc != "") flush_topic();
mode = "key";
sub(/^\.It Fl/, ".Fl");
}
/^\.(S[Ss]|S[Hh]|P[Pp])([^_[:alnum:]]|$)/ { flush_topic(); next; }
/^\.PD([^_[:alnum:]]|$)/ { next; }
mode == "key" {
g_key = $0;
g_keys[g_keys_count++] = $0;
g_desc = "";
mode = "desc";
next;
Expand Down Expand Up @@ -2778,10 +2782,10 @@ function ble/complete/mandb/.generate-cache {
}
function ble/complete/mandb/load-cache {
local command=${1##*/}
local fcache=$_ble_base_cache/man/$command
local lc_messages=${LC_ALL:-${LC_MESSAGES:-${LANG:-C}}}
local fcache=$_ble_base_cache/man/$lc_messages/$command
if ! [[ -s $fcache && $fcache -nt $_ble_base/lib/core-complete.sh ]]; then
[[ -d $_ble_base_cache/man ]] ||
ble/bin/mkdir -p "$_ble_base_cache/man"
[[ -d ${fcache%/*} ]] || ble/bin/mkdir -p "${fcache%/*}"
ble/complete/mandb/.generate-cache "$command" >| "$fcache" &&
[[ -s $fcache ]] ||
return 1
Expand Down
3 changes: 2 additions & 1 deletion memo/ChangeLog.md
Expand Up @@ -51,7 +51,8 @@
- global:work around bash-4.2 bug of `declare -gA` (reported by 0xC0ncord) `#D1470` 8856a04
- global: fix declaration of associative arrays for `ble-reload` (reported by 0xC0ncord) `#D1471` 3cae6e4
- bind: work around broken `cmd_xmap` after switching the editing mode `#D1478` 8d354c1
- edit: clear graphic rendition on newlines and external commands `#D1479` 0000000
- edit: clear graphic rendition on newlines and external commands `#D1479` 18bb2d5
- mandb: improve extraction and cache for each locale `#D1480` 0000000

## Internal changes and fixes

Expand Down
9 changes: 9 additions & 0 deletions note.txt
Expand Up @@ -3730,6 +3730,15 @@ bash_tips

2021-02-20

* complete/mabdb: man awk の内容を抽出しきれていない [#D1480]

先ず .PD という行が挿入されている事が原因の様である。
.PD という行は皆無視しても良い様な気がしたので無視する。
更に、複数のオプションに対して一つの説明がなされている場合に対応した。

キャッシュファイルは LANG 毎に別にするべき気がする。特に LC_MESSAGES に従って
設定するべき。

* edit: "echo " の状態で \C-x\C-v するとバージョン情報が灰色 [#D1479]

これは外部コマンドを実行する時に sgr0 をちゃんとしていないのが原因。何処で
Expand Down

0 comments on commit 3588158

Please sign in to comment.