Debian Codegraph @

memo/D1588.stub-LC_COLLATE-1.patch

raw
1 From 7c28903712ecc6c2709f78f94743a2049f5edb8e Mon Sep 17 00:00:00 2001
2 From: Koichi Murase <[email protected]>
3 Date: Sat, 5 Jun 2021 06:44:52 +0900
4 Subject: [PATCH] stub: work around LC_COLLATE (1)
5
6 ---
7 lib/core-syntax.sh | 39 ++++++++++++++++++++++-----------------
8 make_command.sh | 9 +++++++++
9 2 files changed, 31 insertions(+), 17 deletions(-)
10
11 diff --git a/lib/core-syntax.sh b/lib/core-syntax.sh
12 index e6c5167..4ac774b 100644
13 --- a/lib/core-syntax.sh
14 +++ b/lib/core-syntax.sh
15 @@ -2057,8 +2057,8 @@ function ble/syntax:bash/check-quotes {
16 ((_ble_syntax_attr[i]=aqdel,i+=2))
17 local t=${BASH_REMATCH[1]} rematch4=${BASH_REMATCH[4]}
18
19 - local rex='\\[abefnrtvE"'\''\?]|\\[0-7]{1,3}|\\c.|\\x[0-9a-fA-F]{1,2}'
20 - ((_ble_bash>=40200)) && rex=$rex'|\\u[0-9a-fA-F]{1,4}|\\U[0-9a-fA-F]{1,8}'
21 + local rex='\\[abefnrtvE"'\''\?]|\\[0-7]{1,3}|\\c.|\\x[0-9a-fA-F]{1,2}' # #D1588 WA LC_COLLATE ok
22 + ((_ble_bash>=40200)) && rex=$rex'|\\u[0-9a-fA-F]{1,4}|\\U[0-9a-fA-F]{1,8}' # #D1588 WA LC_COLLATE ok
23 local rex='^([^'\''\]*)('$rex'|(\\.))'
24 while [[ $t =~ $rex ]]; do
25 local m1=${BASH_REMATCH[1]} m2=${BASH_REMATCH[2]}
26 @@ -2801,10 +2801,10 @@ function ble/syntax:bash/ctx-expr {
27 local ret; ble/syntax/highlight/vartype "$BASH_REMATCH" readvar:expr
28 ((_ble_syntax_attr[i]=ret,i+=${#rematch}))
29 return 0
30 - elif rex='^0[xX][0-9a-fA-F]*|^[0-9]+(#[0-9a-zA-Z@_]*)?'; [[ $tail =~ $rex ]]; then
31 + elif rex='^0[xX][0-9a-fA-F]*|^[0-9]+(#[0-9a-zA-Z@_]*)?'; [[ $tail =~ $rex ]]; then # #D1588 WA LC_COLLATE
32 ((_ble_syntax_attr[i]=ATTR_VAR_NUMBER,i+=${#BASH_REMATCH}))
33 return 0
34 - elif ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[ctx]}a-zA-Z_0-9]+" 1; then
35 + elif ble/syntax:bash/check-plain-with-escape "[^${_ble_syntax_bash_chars[ctx]}a-zA-Z_0-9]+" 1; then # #D1588 WA LC_COLLATE
36 return 0
37 elif [[ $tail == ['][()}']* ]]; then
38 local char=${tail::1} ntype
39 @@ -2856,7 +2856,7 @@ function ble/syntax:bash/ctx-expr {
40 function ble/syntax:bash/check-brace-expansion {
41 [[ $tail == '{'* ]] || return 1
42
43 - local rex='^\{[-+0-9a-zA-Z.]*(\}?)'
44 + local rex='^\{[-+0-9a-zA-Z.]*(\}?)' # #D1588 WA LC_COLLATE
45 [[ $tail =~ $rex ]]
46 local str=$BASH_REMATCH
47
48 @@ -2897,7 +2897,7 @@ function ble/syntax:bash/check-brace-expansion {
49 ctx=${_ble_syntax_bash_command_IsAssign[ctx]}
50
51 # {a..b..c} の形式のブレース展開
52 - if rex='^\{(([-+]?[0-9]+)\.\.[-+]?[0-9]+|[a-zA-Z]\.\.[a-zA-Z])(\.\.[-+]?[0-9]+)?\}$'; [[ $str =~ $rex ]]; then
53 + if rex='^\{(([-+]?[0-9]+)\.\.[-+]?[0-9]+|[a-zA-Z]\.\.[a-zA-Z])(\.\.[-+]?[0-9]+)?\}$'; [[ $str =~ $rex ]]; then # #D1588 WA LC_COLLATE
54 if [[ $force_attr ]]; then
55 ((_ble_syntax_attr[i]=force_attr,i+=${#str}))
56 else
57 @@ -3139,7 +3139,7 @@ function ble/syntax:bash/check-variable-assignment {
58 else
59 suffix="$suffix|\["
60 fi
61 - local rex_assign="^([a-zA-Z_][a-zA-Z_0-9]*)($suffix)"
62 + local rex_assign="^([a-zA-Z_][a-zA-Z_0-9]*)($suffix)" # #D1588 WA LC_COLLATE
63 [[ $tail =~ $rex_assign ]] || return 1
64 local rematch=$BASH_REMATCH
65 local rematch1=${BASH_REMATCH[1]} # for bash-3.1 ${#arr[n]} bug
66 @@ -3333,7 +3333,7 @@ function ble/syntax:bash/ctx-coproc/.is-next-compound {
67 local is_compound=
68 if [[ $tail == '('* ]]; then
69 is_compound=1
70 - elif rex='^[a-z]+|^\[\[?|^[{}!]'; [[ $tail =~ $rex ]]; then
71 + elif rex='^[a-z]+|^\[\[?|^[{}!]'; [[ $tail =~ $rex ]]; then # #D1588 WA LC_COLLATE
72 local rematch=$BASH_REMATCH
73
74 ((p+=${#rematch}))
75 @@ -3367,7 +3367,7 @@ function ble/syntax:bash/ctx-coproc/check-word-end {
76 local word=${text:wbegin:wlen}
77 local wt=$wtype
78
79 - if local rex='^[_a-zA-Z0-9]+$'; [[ $word =~ $rex ]]; then
80 + if local rex='^[_a-zA-Z0-9]+$'; [[ $word =~ $rex ]]; then # #D1588 WA LC_COLLATE
81 if ble/syntax:bash/ctx-coproc/.is-next-compound; then
82 # Note: [_a-zA-Z0-9]+ は一回の読み取りの筈なので、
83 # 此処で遡って代入しても問題ない筈。
84 @@ -3911,7 +3911,7 @@ function ble/syntax:bash/ctx-command {
85 local attr=$ctx
86 if ((attr==CTX_FARGI1)); then
87 # for var in ... の var の部分は変数名をチェックして着色
88 - if rex='^[a-zA-Z_][a-zA-Z_0-9]*'; ((i==wbegin)) && [[ $rematch =~ $rex ]]; then
89 + if rex='^[a-zA-Z_][a-zA-Z_0-9]*'; ((i==wbegin)) && [[ $rematch =~ $rex ]]; then # #D1588 WA LC_COLLATE
90 local ret; ble/syntax/highlight/vartype "$BASH_REMATCH"; attr=$ret
91 else
92 attr=$ATTR_ERR
93 @@ -4653,11 +4653,11 @@ function ble/syntax:bash/find-rhs {
94
95 local rex=
96 if ((wtype==ATTR_VAR)); then
97 - rex='^[a-zA-Z0-9_]+(\+?=|\[)'
98 + rex='^[a-zA-Z0-9_]+(\+?=|\[)' # #D1588 WA LC_COLLATE
99 elif ((wtype==CTX_VALI)); then
100 if [[ :$opts: == *:element-assignment:* ]]; then
101 # 配列要素に対しても変数代入の形式を許す
102 - rex='^[a-zA-Z0-9_]+(\+?=|\[)|^(\[)'
103 + rex='^[a-zA-Z0-9_]+(\+?=|\[)|^(\[)' # #D1588 WA LC_COLLATE
104 else
105 rex='^(\[)'
106 fi
107 @@ -4985,6 +4985,7 @@ function ble/syntax/parse {
108 ((end==beg&&end0==beg&&_ble_syntax_dbeg<0)) && return 0
109
110 local IFS=$_ble_term_IFS
111 + local LC_ALL= LC_COLLATE=C 2>/dev/null # #D1588 WA regex range expression
112
113 local shift=$((end-end0))
114 #%if !release
115 @@ -5116,6 +5117,8 @@ function ble/syntax/parse {
116 '((${#_ble_syntax_stat[@]}==iN+1))' \
117 "unexpected array length #arr=${#_ble_syntax_stat[@]} (expected to be $iN), #proto=${#_ble_array_prototype[@]} should be >= $iN"
118 #%end
119 +
120 + ble/util/unlocal LC_ALL LC_COLLATE 2>/dev/null # #D1588 WA regex range expression
121 }
122
123 ## @fn ble/syntax/highlight text [lang]
124 @@ -5199,7 +5202,7 @@ function ble/syntax/completion-context/.add {
125 ## @fn ble/syntax/completion-context/.check/parameter-expansion
126 ## @var[in] text istat index ctx
127 function ble/syntax/completion-context/.check/parameter-expansion {
128 - local rex_paramx='^(\$(\{[!#]?)?)([a-zA-Z_][a-zA-Z_0-9]*)?$'
129 + local rex_paramx='^(\$(\{[!#]?)?)([a-zA-Z_][a-zA-Z_0-9]*)?$' # #D1588 WA LC_COLLATE
130 if [[ ${text:istat:index-istat} =~ $rex_paramx ]]; then
131 local rematch1=${BASH_REMATCH[1]}
132 local source=variable
133 @@ -5314,7 +5317,7 @@ function ble/syntax/completion-context/.check-prefix/ctx:next-command {
134 ble/syntax/completion-context/.add command "$istat"
135
136 # 変数・代入のチェック
137 - if local rex='^[a-zA-Z_][a-zA-Z_0-9]*(\+?=)?$' && [[ $word =~ $rex ]]; then
138 + if local rex='^[a-zA-Z_][a-zA-Z_0-9]*(\+?=)?$' && [[ $word =~ $rex ]]; then # #D1588 WA LC_COLLATE
139 if [[ $word == *= ]]; then
140 if ((_ble_bash>=30100)) || [[ $word != *+= ]]; then
141 # VAR=<argument>: 現在位置から argument 候補を生成する
142 @@ -5515,7 +5518,7 @@ function ble/syntax/completion-context/.check-prefix/ctx:rhs {
143 ble/syntax/completion-context/.check/parameter-expansion
144 if ((wlen>=0)); then
145 local p=$wbeg
146 - local rex='^[a-zA-Z0-9_]+(\+?=|\[)'
147 + local rex='^[a-zA-Z0-9_]+(\+?=|\[)' # #D1588 WA LC_COLLATE
148 ((ctx==CTX_VALR)) && rex='^(\[)'
149 if [[ ${text:p:index-p} =~ $rex ]]; then
150 if [[ ${BASH_REMATCH[1]} == '[' ]]; then
151 @@ -5568,7 +5571,7 @@ function ble/syntax/completion-context/.check-prefix/ctx:param {
152 ## 数式中の変数名を補完する文脈
153 _ble_syntax_bash_complete_check_prefix[CTX_EXPR]=expr
154 function ble/syntax/completion-context/.check-prefix/ctx:expr {
155 - local tail=${text:istat:index-istat} rex='[a-zA-Z_]+$'
156 + local tail=${text:istat:index-istat} rex='[a-zA-Z_]+$' # #D1588 WA LC_COLLATE
157 if [[ $tail =~ $rex ]]; then
158 local p=$((index-${#BASH_REMATCH}))
159 ble/syntax/completion-context/.add variable:a "$p"
160 @@ -5649,7 +5652,7 @@ function ble/syntax/completion-context/.search-last-istat {
161 ## @var[in] index
162 ## @var[out] sources
163 function ble/syntax/completion-context/.check-prefix {
164 - local rex_param='^[a-zA-Z_][a-zA-Z_0-9]*$'
165 + local rex_param='^[a-zA-Z_][a-zA-Z_0-9]*$' # #D1588 WA LC_COLLATE
166 local from=${1:-$((index-1))}
167
168 local ret
169 @@ -5737,8 +5740,10 @@ function ble/syntax/completion-context/generate {
170 sources=()
171 ((index<0&&(index=0)))
172
173 + local LC_ALL= LC_COLLATE=C 2>/dev/null # #D1588 WA regex-ranges
174 ble/syntax/completion-context/.check-prefix
175 ble/syntax/completion-context/.check-here
176 + ble/util/unlocal LC_ALL LC_COLLATE 2>/dev/null # #D1588 WA regex-ranges
177 }
178
179 #------------------------------------------------------------------------------
180 diff --git a/make_command.sh b/make_command.sh
181 index 1a1a629..75828f3 100755
182 --- a/make_command.sh
183 +++ b/make_command.sh
184 @@ -366,6 +366,14 @@ function sub:scan/mistake-_ble_bash {
185 grc '\(\(.*\b_ble_base\b.*\)\)'
186 }
187
188 +function sub:scan/WA-regex-range {
189 + echo "--- $FUNCNAME ---"
190 + grc --color -i 'a-fA-F|a-zA-Z' --exclude=ext |
191 + sed -E 'h;s/'"$esc"'//g;s/^[^:]*:[0-9]+:[[:space:]]*//
192 + \Z#D1588Zd
193 + g'
194 +}
195 +
196 function sub:scan {
197 if ! type grc >/dev/null; then
198 echo 'blesh check: grc not found. grc can be found in github.com:akinomyoga/mshex.git/' >&2
199 @@ -447,6 +455,7 @@ function sub:scan {
200 sub:scan/eval-literal
201 sub:scan/WA-localvar_inherit
202 sub:scan/mistake-_ble_bash
203 + sub:scan/WA-regex-range
204
205 sub:scan/memo-numbering
206 }
207 --
208 2.21.3
209