Skip to content

Commit

Permalink
decode: move "{keymap/*. => lib/core-decode.*-}rlfunc.txt" and clean …
Browse files Browse the repository at this point in the history
…up files
  • Loading branch information
akinomyoga committed Feb 22, 2021
1 parent e130619 commit f7323b4
Show file tree
Hide file tree
Showing 19 changed files with 265 additions and 15 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -6,8 +6,9 @@

# edit files
/COMMIT
/[a-zA-Z].txt
/[a-zA-Z].sh
/[a-zA-Z0-9].txt
/[a-zA-Z0-9].sh
/\*scratch\*

# test
/test
Expand Down
8 changes: 6 additions & 2 deletions .srcoption
@@ -1,2 +1,6 @@
-x md:bash --exclude=./out --exclude=./dist --exclude=./a.sh --exclude=./test/install --exclude=./ble.sh ble-syntax-ctx.def keymap/*.rlfunc.txt ble.pp blerc

-x md:bash --exclude=./out --exclude=./dist --exclude=./a.sh --exclude=./test/install --exclude=./ble.sh
GNUmakefile
ble.pp
blerc
lib/core-syntax-ctx.def
lib/core-decode.*-rlfunc.txt
8 changes: 3 additions & 5 deletions GNUmakefile
Expand Up @@ -47,13 +47,8 @@ $(OUTDIR)/ble.sh: ble.pp GNUmakefile | $(OUTDIR)
outdirs += $(OUTDIR)/keymap
outfiles += $(OUTDIR)/keymap/emacs.sh
outfiles += $(OUTDIR)/keymap/vi.sh $(OUTDIR)/keymap/vi_digraph.sh $(OUTDIR)/keymap/vi_digraph.txt $(OUTDIR)/keymap/vi_test.sh
outfiles += $(OUTDIR)/keymap/emacs.rlfunc.txt
outfiles += $(OUTDIR)/keymap/vi_imap.rlfunc.txt
outfiles += $(OUTDIR)/keymap/vi_nmap.rlfunc.txt
$(OUTDIR)/keymap/%.sh: keymap/%.sh | $(OUTDIR)/keymap
cp -p $< $@
$(OUTDIR)/keymap/%.txt: keymap/%.txt | $(OUTDIR)/keymap
cp -p $< $@

#------------------------------------------------------------------------------
# lib
Expand All @@ -67,6 +62,9 @@ outfiles += $(OUTDIR)/lib/core-complete.sh
outfiles += $(OUTDIR)/lib/core-syntax.sh
outfiles += $(OUTDIR)/lib/core-test.sh
outfiles += $(OUTDIR)/lib/core-edit.ignoreeof-messages.txt
outfiles += $(OUTDIR)/lib/core-decode.emacs-rlfunc.txt
outfiles += $(OUTDIR)/lib/core-decode.vi_imap-rlfunc.txt
outfiles += $(OUTDIR)/lib/core-decode.vi_nmap-rlfunc.txt
outfiles += $(OUTDIR)/lib/vim-surround.sh
outfiles += $(OUTDIR)/lib/vim-arpeggio.sh
outfiles += $(OUTDIR)/lib/test-main.sh
Expand Down
1 change: 1 addition & 0 deletions ble.pp
Expand Up @@ -932,6 +932,7 @@ function ble/base/process-blesh-arguments {
ble/util/print "ble.sh ($arg): an option argument is missing." >&2
fi ;;
(--noinputrc)
_ble_builtin_bind_user_settings_loaded=noinputrc
_ble_builtin_bind_inputrc_done=noinputrc ;;
(--rcfile=*|--init-file=*|--rcfile|--init-file)
if [[ $arg != *=* ]]; then
Expand Down
2 changes: 1 addition & 1 deletion keymap/vi.sh
Expand Up @@ -5860,7 +5860,7 @@ function ble-decode/keymap:vi_nmap/define {
# ble-bind -f '_' 'vi-rlfunc/yank-arg'
}

# vi_nmap.rlfunc.txt 用
# lib/core-decode.vi_nmap-rlfunc.txt 用

# d or D
function ble/widget/vi-rlfunc/delete-to {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion make_command.sh
Expand Up @@ -632,7 +632,7 @@ function sub:check-readline-bindable {
[[ $bash == bash-[12]* ]] && continue
"$bash" -c 'bind -l' 2>/dev/null
done | sort -u
) <(sort keymap/emacs.rlfunc.txt)
) <(sort lib/core-decode.emacs-rlfunc.txt)
}

#------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -75,6 +75,7 @@
- benchmark (`ble-measure`): support `-T TIME` and `-B TIME` option `#D1460` 1aa471b
- util, color (`bleopt`, `blehook`, `ble-color-setface`): support `--color` and fix `sgr0` contamination in non-color output `#D1466` 69248ff
- global: fix status check for read timeout `#D1467` e886883
- decode: move `{keymap/*. => lib/core-decode.*-}rlfunc.txt` and clean up files `#D1486` e130619

<!---------------------------------------------------------------------------->
# ble-0.4.0-devel2
Expand Down
12 changes: 12 additions & 0 deletions memo/D1478.fix-rebind-C-x-test1.sh
@@ -0,0 +1,12 @@
#!/bin/bash

# unbind all "C-x ?"
for second in e g {A..Z} '\C-'{e,g,r,u,v,x,'?'} '!' '$' '(' ')' '*' '/' '@' '~'; do
bind -r '\C-x'"$second"
done

bind -x '"\C-x\C-x":echo XX'
bind -r '\C-x\C-x'

bind -x '"\C-x":echo X'
bind -x '"\C-b":echo B'
12 changes: 12 additions & 0 deletions memo/D1478.fix-rebind-C-x-test2.sh
@@ -0,0 +1,12 @@
#!/bin/bash

# unbind all "C-x ?"
for second in e g {A..Z} '\C-'{e,g,r,u,v,x,'?'} '!' '$' '(' ')' '*' '/' '@' '~'; do
bind -r '\C-x'"$second"
done

# bash-4.2 以下で以下の様にすると vi で C-x を受信できなくなってしまう。
bind -x '"\C-x\C-x":echo XX'
bind -r '\C-x\C-x'
set -o vi
bind -x '"\C-x":echo X'
19 changes: 19 additions & 0 deletions memo/D1483.check-rlfunc-decode-error.sh
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

echo "----------"
echo "locale"
locale

echo "----------"
echo "test regex (default locale)"

rex='^"([^\"]|\\.)*$'
[[ $'"\x9B": self-insert' =~ $rex ]]
echo "$? (${BASH_REMATCH[*]@Q})"

echo "----------"
echo "test regex (locale C)"

LC_ALL=C
[[ $'"\x9B": self-insert' =~ $rex ]]
echo "$? (${BASH_REMATCH[*]@Q})"
86 changes: 86 additions & 0 deletions memo/T0003.debug-trap.sh
@@ -0,0 +1,86 @@
#!/bin/bash

bash44_traverse=1

function user-debug-handler {
local caller=${FUNCNAME[1]}
[[ $caller == ble-debug-handler ]] &&
caller=${FUNCNAME[2]}
echo "trap($*):$caller: $BASH_COMMAND"
}

# * 4.4 以降では最初に DEBUG を設定した関数呼び出しレベルを書き換える?
# 否、関数終了時に上書きする様にしたら良いという事の気がする。
# * 関数を一つ上がったら trap handler を削除
# * trap handler が全てなくなったら解除
# ? yes: 内側の関数で活性化した時に外側の関数でもちゃんと DEBUG trap が発動
# するのだろうか。

_debug_trap_handlers=()
function ble/trap-debug {
local depth=$((${#FUNCNAME[@]}-2))
if [[ $1 != - ]]; then
_debug_trap_handlers[depth]=$1

# 再活性化 (extdebug/functrace が設定されていなければ、
# 設定を行った関数呼び出しレベルでしか DEBUG trap は発生しない)。
builtin trap ble-debug-handler DEBUG
else
unset '_debug_trap_handlers[depth]'
fi
}
function ble-debug-handler {
local depth=$((${#FUNCNAME[@]}-1))
[[ $_ble_trap_suppress || ${FUNCNAME[1]} == trap ]] && return 0
#echo "ble-debug-handler"
for ((;depth>=0;depth--)); do
local handler=${_debug_trap_handlers[depth]-}
[[ $handler ]] || continue
eval "$handler"
return "$?"
done
}
function ble-return-handler {
#echo "ble-return-handler"
local _ble_trap_suppress=1
local depth=$((${#FUNCNAME[@]}-1))
((depth)) || return 0
if [[ $bash44_traverse && ${_debug_trap_handlers[depth]+set} ]]; then
_debug_trap_handlers[depth-1]=${_debug_trap_handlers[depth]}
fi
}

#------------------------------------------------------------------------------

function f3 {
builtin trap '_ble_trap_suppress=1 ble-return-handler' RETURN
trap 'user-debug-handler f3' DEBUG
echo f3
}
function f2 {
builtin trap '_ble_trap_suppress=1 ble-return-handler' RETURN
echo f2:1
f3
echo f2:2
trap - DEBUG
}
function f1 {
builtin trap '_ble_trap_suppress=1 ble-return-handler' RETURN
trap 'user-debug-handler f1' DEBUG
echo f1:1
f2
echo f1:3
trap - DEBUG
}

#------------------------------------------------------------------------------

#trap ble-debug-handler DEBUG

# 通常
f1

echo ----------
trap ble-return-handler RETURN
function trap { local _ble_trap_suppress=1; ble/trap-debug "$1"; }
f1
12 changes: 12 additions & 0 deletions memo/T0005.source-arguments-in-func.bashrc
@@ -0,0 +1,12 @@
# bashrc -*- mode: sh-bash; -*-

sub=T0005.source-arguments-in-func.source.sh

function sourcer1 { source "$sub"; }
function sourcer2 { source "$sub" x; }

sourcer1 A B C
sourcer2 A B C
shopt -s extdebug
sourcer1 A B C
sourcer2 A B C
17 changes: 17 additions & 0 deletions memo/T0005.source-arguments-in-func.source.sh
@@ -0,0 +1,17 @@
# -*- mode: sh; mode: sh-bash -*-

args=("$0" "$@")
declare -p args
declare -p FUNCNAME
declare -p BASH_LINENO
declare -p BASH_SOURCE
declare -p BASH_ARGC
declare -p BASH_ARGV

# 呼び出しを行った後で extdebug を実行しても意味ない
# shopt -s extdebug
# declare -p BASH_ARGC
# declare -p BASH_ARGV
# shopt -u extdebug
echo ----------------------------------------

77 changes: 77 additions & 0 deletions memo/benchmark/array-access.sh
@@ -0,0 +1,77 @@
#!/bin/bash

if [[ ! $_ble_bash ]]; then
echo 'benchmark: Please source from a ble session.' >&2
return 1
fi

function measure-array.1 {
local N=$1
eval "local -a a=({1..$N})"
ble-measure "$2"
}
function measure-array {
measure-array.1 10 "$1 10 "
measure-array.1 100 "$1 100 "
measure-array.1 1000 "$1 1000 "
measure-array.1 10000 "$1 10000 "
measure-array.1 100000 "$1 100000"
}
function sum-forward { local s=0; for ((i=0;i<N;i++)); do ((s+=a[i])); done ; }
function sum-backward { local s=0; for ((i=N;--i>=0;)); do ((s+=a[i])); done ; }
function sum-random { local s=0; for ((i=0;i<N;i++)); do ((s+=a[RANDOM%N])); done; }

measure-array sum-forward
measure-array sum-backward
measure-array sum-random

# bash-dev
# 38.371 usec/eval: sum-forward 10 (x5000)
# 311.913 usec/eval: sum-forward 100 (x500)
# 3046.322 usec/eval: sum-forward 1000 (x50)
# 30699.500 usec/eval: sum-forward 10000 (x5)
# 309013.300 usec/eval: sum-forward 100000 (x1)
# 33.804 usec/eval: sum-backward 10 (x5000)
# 269.811 usec/eval: sum-backward 100 (x500)
# 2645.302 usec/eval: sum-backward 1000 (x50)
# 26564.500 usec/eval: sum-backward 10000 (x5)
# 266084.300 usec/eval: sum-backward 100000 (x1)
# 45.826 usec/eval: sum-random 10 (x5000)
# 399.209 usec/eval: sum-random 100 (x500)
# 4580.182 usec/eval: sum-random 1000 (x50)
# 135904.300 usec/eval: sum-random 10000 (x1)
# 3693072.300 usec/eval: sum-random 100000 (x1)

# bash-5.0
# 38.723 usec/eval: sum-forward 10 (x5000)
# 322.861 usec/eval: sum-forward 100 (x500)
# 3188.720 usec/eval: sum-forward 1000 (x50)
# 31446.200 usec/eval: sum-forward 10000 (x5)
# 317422.600 usec/eval: sum-forward 100000 (x1)
# 34.875 usec/eval: sum-backward 10 (x5000)
# 286.639 usec/eval: sum-backward 100 (x500)
# 2826.220 usec/eval: sum-backward 1000 (x50)
# 27921.600 usec/eval: sum-backward 10000 (x5)
# 283819.600 usec/eval: sum-backward 100000 (x1)
# 46.838 usec/eval: sum-random 10 (x2000)
# 414.663 usec/eval: sum-random 100 (x500)
# 5517.050 usec/eval: sum-random 1000 (x20)
# 123421.600 usec/eval: sum-random 10000 (x1)
# 4942400.600 usec/eval: sum-random 100000 (x1)

# bash-4.4
# 41.660 usec/eval: sum-forward 10 (x5000)
# 354.000 usec/eval: sum-forward 100 (x500)
# 3416.000 usec/eval: sum-forward 1000 (x50)
# 34200.000 usec/eval: sum-forward 10000 (x5)
# 347000.000 usec/eval: sum-forward 100000 (x1)
# 37.060 usec/eval: sum-backward 10 (x5000)
# 316.000 usec/eval: sum-backward 100 (x500)
# 5095.000 usec/eval: sum-backward 1000 (x20)
# 242000.000 usec/eval: sum-backward 10000 (x1)
# 19999000.000 usec/eval: sum-backward 100000 (x1)
# 51.050 usec/eval: sum-random 10 (x2000)
# 454.000 usec/eval: sum-random 100 (x500)
# 5895.000 usec/eval: sum-random 1000 (x20)
# 172000.000 usec/eval: sum-random 10000 (x1)
# 4577000.000 usec/eval: sum-random 100000 (x1)
8 changes: 8 additions & 0 deletions note.txt
Expand Up @@ -3742,6 +3742,14 @@ bash_tips

2021-02-22

* decode: rlfunc.txt ファイルを移動する [#D1486]

* .srcoption の中身も更新した。
* GNUmakefile も書き換えた。
* decode.sh も書き換えた。
* 他に make_command.sh と vi.sh の中で言及していたファイル名を書き換えた。
* 序でに散らばっていたテスト用のファイルをリポジトリに追加しておく。

* term: screen で attach した時に時々 _ble_term_* が壊れる現象 [#D1485]

screen で attach すると何故か色々壊れる現象があったが、どうも contra からの
Expand Down
10 changes: 6 additions & 4 deletions src/decode.sh
Expand Up @@ -3071,9 +3071,11 @@ function ble/decode/read-inputrc/test {
if ((_ble_bash<40400)); then
((lhs_major=2+_ble_bash/10000,
lhs_minor=_ble_bash/100%100))
elif ((_ble_bash<50000)); then
((lhs_major=7,lhs_minor=0))
else
((lhs_major=3+_ble_bash/10000,
lhs_minor=0))
lhs_minor=_ble_bash/100%100))
fi

local rhs_major rhs_minor
Expand Down Expand Up @@ -3347,11 +3349,11 @@ function ble/builtin/bind/rlfunc2widget {

local rlfunc_file= rlfunc_dict=
case $kmap in
(emacs) rlfunc_file=$_ble_base/keymap/emacs.rlfunc.txt
(emacs) rlfunc_file=$_ble_base/lib/core-decode.emacs-rlfunc.txt
rlfunc_dict=_ble_decode_rlfunc2widget_emacs ;;
(vi_imap) rlfunc_file=$_ble_base/keymap/vi_imap.rlfunc.txt
(vi_imap) rlfunc_file=$_ble_base/lib/core-decode.vi_imap-rlfunc.txt
rlfunc_dict=_ble_decode_rlfunc2widget_vi_imap ;;
(vi_nmap) rlfunc_file=$_ble_base/keymap/vi_nmap.rlfunc.txt
(vi_nmap) rlfunc_file=$_ble_base/lib/core-decode.vi_nmap-rlfunc.txt
rlfunc_dict=_ble_decode_rlfunc2widget_vi_nmap ;;
esac

Expand Down

0 comments on commit f7323b4

Please sign in to comment.