○[NetBSD] debugging wcurses その2
昨日の続き、src/lib/libcurses/refresh.cのdoupdate()あたり。
- W: 0: 0x41604
+ W: 0: 0x3f437c4
これは
508 __CTRACE(__CTRACE_REFRESH, "W: %d:", i);
509 __CTRACE(__CTRACE_REFRESH, " 0x%x \n",
510 win->lines[i]->hash);
でハッシュ値の表示なのでどうもよさげ。
- 0x1 A
+ 0x1 \xa2\xa2
ja_JP.eucJPの場合は何か変な
汁値出てるね、こいつはここか。
513 for (j = 0; j < win->maxx; j++)
514 __CTRACE(__CTRACE_REFRESH, "%c",
515 win->lines[i]->line[j].ch);
src/lib/libcurses/curses_private.hを見ると
96 struct __ldata {
97 wchar_t ch; /* Character */
98 attr_t attr; /* Attributes */
wchar_tなので"%c"じゃなくて"%lc"だよな。
ctrace.cはただのvfprintf(3)のwrapperなので修正しとく。
W: 0: 0x5f231c4
0x1 ああ
カラム0と1にそれぞれ「あ」が入ってる状態すか、にゃるほど。
お次は各セルのattributeのダンプか。
517 __CTRACE(__CTRACE_REFRESH, " attr:");
518 for (j = 0; j < win->maxx; j++)
519 __CTRACE(__CTRACE_REFRESH, " %x",
520 win->lines[i]->line[j].attr);
の出力。
- attr: 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000
4000000
+ attr: 8000000 fc000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 4000000 400000
0 4000000
C localeの場合、カラム0(=A)のattrは4000000、すなわちwcwidth=1でおk。
ja_JP.eucJPの場合、カラム0(=あ)のattrは800000、すなわちwcwidth=2でこれも問題なし。
カラム1の値のfc000000は、これcurses_private.hに定義されてる__WCWIDTHの値。
そんでsrc/lib/libcurses/addbytes.cにある
536 /* Mark as "continuation" cell */
537 tp->attr |= __WCWIDTH;
継続セルの為のマーカーちゅーコメントと一致するので問題なし。
現時点での可能性としては
- move(0, 1)することでline dataにある「ああ」の後の「あ」が処理対象に
- attributeをちゃんと見ておらず、カラム0と1が継続セルとは認識されない
- よって先頭の「あ」のwcwidth=2分が余計なカーソル移動量として計算される
あたりだとガッテンガッテンなのだが、hjklで移動する時は問題発生しないのよな。
なかなか尻尾掴めんの。
デバックは健康の為に1日10分まで、続く。
○[NetBSD] debugging wcurses その3
さっきの続き。
src/lib/libcurses/refresh.cのmakech()あたり。
makech: csp is on curscr:(0,0)
makech: nsp is at __virtscr:(0,0)
makech: wx=0,lch=79
- makech: nsp=(41,4000000,20,0,0x0)
+ makech: nsp=(a4a2,8000000,20,0,0x0)
makech: csp=(20,4000000,20,0,0x0)
domvcur: (0,0)=>(0,0)
__unsetattr: checkms = 1, ms = TRUE, wattr = 00000000
makech: 1: wx = 0, ly= 0, lx = 0, newy = 0, newx = 0
makech: have attr 00000000, need attr 00000000
- __cputwchar: 0x41
- makech:(0,0) putwchar(41)
+ __cputwchar: 0xa4a2
+ makech:(0,0) putwchar(a4a2)
makech: 2: wx = 1, lx = 0
- makech: 3: wx = 1, lx = 1
- makech: wx=1,lch=79
+ makech: have attr 00000000, need attr 00000000
+ makech: 2: wx = 2, lx = 0
+ makech: 3: wx = 2, lx = 2
+ makech: wx=2,lch=79
makech: nsp=(20,4000000,20,0,0x0)
makech: csp=(20,4000000,20,0,0x0)
makech-after: curscr(0xbb87d200)-__virtscr(0xbb87d300)
- [0,0](41,4000000,20,0,0x0)-(41,4000000,20,0,0x0)
- [0,1](20,4000000,20,0,0x0)-(20,4000000,20,0,0x0)
+ [0,0](a4a2,8000000,20,0,0x0)-(a4a2,8000000,20,0,0x0)
+ [0,1](a4a2,fc000000,20,0,0x0)-(a4a2,fc000000,20,0,0x0)
[0,2](20,4000000,20,0,0x0)-(20,4000000,20,0,0x0)
[0,3](20,4000000,20,0,0x0)-(20,4000000,20,0,0x0)
[0,4](20,4000000,20,0,0x0)-(20,4000000,20,0,0x0)
とくに問題無いね。
wcwidth=1ならwx=1, lx=1でwcwidth=2ならwx=2, lx=2で
画面サイズは80なのでlch=79までスペースで埋めてるだけぽ。
makech: wx=0,lch=79
makech: nsp=(7e,4000000,20,0,0x0)
makech: csp=(20,4000000,20,0,0x0)
- domvcur: (0,1)=>(1,0)
+ domvcur: (0,2)=>(1,0)
__unsetattr: checkms = 1, ms = TRUE, wattr = 00000000
- mvcur: moving cursor from (0, 1) to (1, 0)
+ mvcur: moving cursor from (0, 2) to (1, 0)
fgoto: in_refresh=1
fgoto: cgp=;1H
plod: cnt=6, in_refresh=1
これもwcwidth=1の場合なら(0,1)から次の行へ
wcwidth=2の場合なら(0,2)以下略、よって問題なさげ。
__cputchar: H
__cputchar: ^J
plod: returns 0
- makech: 1: wx = 0, ly= 0, lx = 1, newy = 1, newx = 0
+ makech: 1: wx = 0, ly= 0, lx = 2, newy = 1, newx = 0
makech: have attr 00000000, need attr 00000000
__cputwchar: 0x7e
makech:(1,0) putwchar(7e)
以下同文。
その次、 src/lib/libcurses/cr_put.cのplod()あたり。
doupdate: line 32 notdirty
80 0
doupdate: ly=31, lx=1
- domvcur: (1f,1)=>(0,0)
+ domvcur: (1f,1)=>(0,1)
__unsetattr: checkms = 1, ms = TRUE, wattr = 00000000
- mvcur: moving cursor from (31, 1) to (0, 0)
+ mvcur: moving cursor from (31, 1) to (0, 1)
fgoto: in_refresh=1
- fgoto: cgp=;1H
+ fgoto: cgp=;2H
plod: cnt=6, in_refresh=1
- plod: returns 3
+ plod: returns 2
plod: cnt=0, in_refresh=1
__cputchar: ^[
__cputchar: [
__cputchar: H
+ __cputwchar: 0xa4a2
+ plod: (0,0)WCOL(2), putwchar(a4a2)
plod: returns 0
__unsetattr: checkms = 0, ms = TRUE, wattr = 00000000
***********after*****************
stdscr(0xbb87d280)-curscr(0xbb87d200)-__virtscr(0xbb87d300)
- [0,0](41,4000000,0x0)-(41,4000000,0x0)
- [0,1](20,4000000,0x0)-(20,4000000,0x0)
+ [0,0](a4a2,8000000,0x0)-(a4a2,8000000,0x0)
+ [0,1](a4a2,fc000000,0x0)-(a4a2,fc000000,0x0)
[0,2](20,4000000,0x0)-(20,4000000,0x0)
[0,3](20,4000000,0x0)-(20,4000000,0x0)
[0,4](20,4000000,0x0)-(20,4000000,0x0)
うーむ、C localeの時は__cputwchar()は呼ばれないのに
ja_JP.eucJP localeだと呼ばれるはなじぇ?
しかもこの後のログを見ていくと都合3回呼ばれてる。
+ __cputwchar: 0xa4a2
+ plod: (0,0)WCOL(2), putwchar(a4a2)
...
+ __cputwchar: 0xa4a2
+ plod: (0,0)WCOL(2), putwchar(a4a2)
...
+ __cputwchar: 0x7e
+ plod: (0,0)WCOL(1), putwchar(7e)
怪しいなぁ。
ソースを読んでみる。
412 if ((curscr->lines[outline]->line[outcol].attr
413 & WA_ATTRIBUTES)
414 == curscr->wattr ) {
現在のスクリーンのattriuteとセルのattributeが一致した場合、__cputwchar()を
呼ぶみたい、attrの値が初期化されてないとか壊れるとかだろーか。
それかこのif文中でやってる処理自体が間違いとか。
そのうち続く。