| @@ -1,17 +1,20 @@ | | | @@ -1,17 +1,20 @@ |
1 | $NetBSD: patch-scn2k_scn2k__cmd.cc,v 1.2 2020/03/26 02:33:34 joerg Exp $ | | 1 | $NetBSD: patch-scn2k_scn2k__cmd.cc,v 1.3 2021/12/27 05:11:34 dholland Exp $ |
2 | | | 2 | |
3 | - don't assume signed char for arm and powerpc | | 3 | - don't assume signed char for arm and powerpc |
4 | - fix wrong casts | | 4 | - fix wrong casts |
| | | 5 | - silence const warning |
| | | 6 | - remove chunk of text in #if 0 that doesn't necessarily tokenize |
| | | 7 | (depending apparently on character set settings) |
5 | | | 8 | |
6 | --- scn2k/scn2k_cmd.cc.orig 2008-08-31 09:52:12.000000000 +0000 | | 9 | --- scn2k/scn2k_cmd.cc.orig 2008-08-31 09:52:12.000000000 +0000 |
7 | +++ scn2k/scn2k_cmd.cc | | 10 | +++ scn2k/scn2k_cmd.cc |
8 | @@ -261,9 +261,9 @@ void Flags::Load(const char* save) { | | 11 | @@ -261,9 +261,9 @@ void Flags::Load(const char* save) { |
9 | char buf[1024]; | | 12 | char buf[1024]; |
10 | int n; | | 13 | int n; |
11 | if (sscanf(save, "V<C>[%04d]=",&n) == 1) { | | 14 | if (sscanf(save, "V<C>[%04d]=",&n) == 1) { |
12 | - char* s = strchr(save, '='); | | 15 | - char* s = strchr(save, '='); |
13 | + const char* s = strchr(save, '='); | | 16 | + const char* s = strchr(save, '='); |
14 | s++; | | 17 | s++; |
15 | - char* send = strchr(s, '\n'); | | 18 | - char* send = strchr(s, '\n'); |
16 | + const char* send = strchr(s, '\n'); | | 19 | + const char* send = strchr(s, '\n'); |
17 | int slen = send - s; | | 20 | int slen = send - s; |
| @@ -57,46 +60,115 @@ $NetBSD: patch-scn2k_scn2k__cmd.cc,v 1.2 | | | @@ -57,46 +60,115 @@ $NetBSD: patch-scn2k_scn2k__cmd.cc,v 1.2 |
57 | + if ((s[offset_end] & 0x80) != 0 && s[offset_end]+1 != 0) offset_end += 2; | | 60 | + if ((s[offset_end] & 0x80) != 0 && s[offset_end]+1 != 0) offset_end += 2; |
58 | else offset_end += 1; | | 61 | else offset_end += 1; |
59 | } | | 62 | } |
60 | string result(s, offset_top, offset_end-offset_top); | | 63 | string result(s, offset_top, offset_end-offset_top); |
61 | @@ -456,7 +456,7 @@ bool Flags::Exec(Cmd& cmd) { | | 64 | @@ -456,7 +456,7 @@ bool Flags::Exec(Cmd& cmd) { |
62 | case 7: {// strlen w/ kanji | | 65 | case 7: {// strlen w/ kanji |
63 | const char* s = cmd.Str(cmd.args[0]); int i; | | 66 | const char* s = cmd.Str(cmd.args[0]); int i; |
64 | for (i=0; *s != 0; i++) { | | 67 | for (i=0; *s != 0; i++) { |
65 | - if (*s < 0 && s[1] != 0) s += 2; | | 68 | - if (*s < 0 && s[1] != 0) s += 2; |
66 | + if ((*s & 0x80) != 0 && s[1] != 0) s += 2; | | 69 | + if ((*s & 0x80) != 0 && s[1] != 0) s += 2; |
67 | else s++; | | 70 | else s++; |
68 | } | | 71 | } |
69 | SetSys(i); | | 72 | SetSys(i); |
70 | @@ -682,8 +682,8 @@ int Cmd::GetLeftToken(const char*& d, Va | | 73 | @@ -533,59 +533,6 @@ bool Flags::Exec(Cmd& cmd) { |
| | | 74 | cmd.cmd4 = 0; |
| | | 75 | } |
| | | 76 | |
| | | 77 | -#if 0 |
| | | 78 | -@@@ |
| | | 79 | -save 27 |
| | | 80 | -ともよメガネのところ |
| | | 81 | -- オブジェクト関連:seen9061:0 呼び出しで黒い背景画をかさねるところ、変になる |
| | | 82 | -@@@ |
| | | 83 | -%Xで置換する名前の設定。0x51e で読みだし。セーブファイルごとに保存されるはずなので実装を考えること |
| | | 84 | -%は0-3 (4 以降は使ってない)で、渚、秋生、渚、伊吹先生、など |
| | | 85 | -StrVar を拡張して代入すること |
| | | 86 | -初期値はこの辺 |
| | | 87 | -Text側に納め、セーブファイルでも同じようにすべきだろうなあ |
| | | 88 | - args:0,"渚" |
| | | 89 | - args:1,"秋生" |
| | | 90 | - args:2,"渚" |
| | | 91 | - args:3,"伊吹先生" |
| | | 92 | - args:4,"朋也くん" |
| | | 93 | - args:5,"岡崎さん" |
| | | 94 | - |
| | | 95 | - |
| | | 96 | -106737 : 0x23 - cmd 01-04:051f:00[ 2] |
| | | 97 | - args:0,"古河" |
| | | 98 | -106758 : line 1712 |
| | | 99 | -106761 : 0x23 - cmd 01-04:051f:00[ 2] |
| | | 100 | - args:2,"古河" |
| | | 101 | -106782 : line 1713 |
| | | 102 | -106785 : 0x23 - cmd 01-04:051f:00[ 2] |
| | | 103 | - args:4,"岡崎さん" |
| | | 104 | - |
| | | 105 | -47382 : 0x23 - cmd 01-04:051e:00[ 2] |
| | | 106 | - args:4,V<18>[0](=0) |
| | | 107 | - |
| | | 108 | -47408 : 0x23 - cmd 01-0a:0004:00[ 2] |
| | | 109 | - args:V<18>[0](=0),"岡崎さん" |
| | | 110 | -47437 : expr: V<0>[1000](=0)=V<sys> |
| | | 111 | -47451 : 0x23 - cmd 01-0a:0004:00[ 2] |
| | | 112 | - args:V<18>[0](=0),"朋也くん" |
| | | 113 | -47480 : expr: V<0>[1001](=0)=V<sys> |
| | | 114 | -47494 : V<0>[1000](=0)==0(=true)-> 47589 |
| | | 115 | -47526 : 0x23 - cmd 01-04:0514:00[ 2] |
| | | 116 | - args:0,V<18>[0](=0) /* NAME.A を帰す */ |
| | | 117 | -47552 : 0x23 - cmd 01-0a:0002:00[ 2] |
| | | 118 | - args:V<18>[0](=0),"さん" |
| | | 119 | -47577 : jmp -> 47672 |
| | | 120 | -47589 : V<0>[1001](=0)==0(=true)-> 47672 |
| | | 121 | -47621 : 0x23 - cmd 01-04:0514:00[ 2] |
| | | 122 | - args:1,V<18>[0](=0) /* NAME.B を帰す */ |
| | | 123 | -47647 : 0x23 - cmd 01-0a:0002:00[ 2] |
| | | 124 | - args:V<18>[0](=0),"くん" |
| | | 125 | -47672 : pos. 279 |
| | | 126 | -47675 : 0x23 - cmd 01-0a:0064:00[ 1] |
| | | 127 | - args:V<18>[0](=0) |
| | | 128 | - |
| | | 129 | -#endif |
| | | 130 | cmd.cmd_type = CMD_TEXT; |
| | | 131 | break; |
| | | 132 | } |
| | | 133 | @@ -682,8 +629,8 @@ int Cmd::GetLeftToken(const char*& d, Va |
71 | d += 2; | | 134 | d += 2; |
72 | var_flag = false; | | 135 | var_flag = false; |
73 | } | | 136 | } |
74 | - if (d[0] == 0x24 && ((unsigned const char*)d)[1] == 0xff) { | | 137 | - if (d[0] == 0x24 && ((unsigned const char*)d)[1] == 0xff) { |
75 | - // if ( (d[0] == 0x30 || d[0] == 0x31) && d[1] == 0x24 && ((unsigned const char*)d)[2] == 0xff) /* @@@ not supported; selection 内で、0x30|0x31 が付随することがある */ | | 138 | - // if ( (d[0] == 0x30 || d[0] == 0x31) && d[1] == 0x24 && ((unsigned const char*)d)[2] == 0xff) /* @@@ not supported; selection 内で、0x30|0x31 が付随することがある */ |
76 | + if (d[0] == 0x24 && (unsigned char)d[1] == 0xff) { | | 139 | + if (d[0] == 0x24 && (unsigned char)d[1] == 0xff) { |
77 | + // if ( (d[0] == 0x30 || d[0] == 0x31) && d[1] == 0x24 && (unsigned const char)d[2] == 0xff) /* @@@ not supported; selection 内で、0x30|0x31 が付随することがある */ | | 140 | + // if ( (d[0] == 0x30 || d[0] == 0x31) && d[1] == 0x24 && (unsigned const char)d[2] == 0xff) /* @@@ not supported; selection 内で、0x30|0x31 が付随することがある */ |
78 | // numerical atom | | 141 | // numerical atom |
79 | d += 6; | | 142 | d += 6; |
80 | value = read_little_endian_int(d-4); | | 143 | value = read_little_endian_int(d-4); |
81 | @@ -1001,7 +1001,7 @@ dprintf("enum.<"); | | 144 | @@ -1001,7 +948,7 @@ dprintf("enum.<"); |
82 | int count = GetArgs(d); | | 145 | int count = GetArgs(d); |
83 | args[pt] = VarInfo(count); | | 146 | args[pt] = VarInfo(count); |
84 | dprintf(">"); | | 147 | dprintf(">"); |
85 | - } else if (*d == 0x61 && (d[1] >= 0x00 && d[1] <= 0x04) && d[2] == 0x28 ) { | | 148 | - } else if (*d == 0x61 && (d[1] >= 0x00 && d[1] <= 0x04) && d[2] == 0x28 ) { |
86 | + } else if (*d == 0x61 && ((d[1] & 0x80) == 0 && d[1] <= 0x04) && d[2] == 0x28 ) { | | 149 | + } else if (*d == 0x61 && ((d[1] & 0x80) == 0 && d[1] <= 0x04) && d[2] == 0x28 ) { |
87 | /* 使われるコマンドは 01-21:004b, 01-28:0064 のいずれか(R,C,PB,LO) | | 150 | /* 使われるコマンドは 01-21:004b, 01-28:0064 のいずれか(R,C,PB,LO) |
88 | ** それらのコマンドは | | 151 | ** それらのコマンドは |
89 | ** arg1: 画像ファイル名 | | 152 | ** arg1: 画像ファイル名 |
90 | @@ -1714,10 +1714,10 @@ int main(int argc, char** argv) { | | 153 | @@ -1220,7 +1167,7 @@ void Cmd::GetSelection(const char*& d) { |
| | | 154 | return; |
| | | 155 | } |
| | | 156 | |
| | | 157 | -static char* op_str3[11] = { "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "="}; |
| | | 158 | +static const char* op_str3[11] = { "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "="}; |
| | | 159 | void Cmd::GetCmd(Flags& flags_orig, const char*& d ) { |
| | | 160 | if (d == 0) { SetError(); return;} |
| | | 161 | if (cmd_type != CMD_NOP) return; |
| | | 162 | @@ -1714,10 +1661,10 @@ int main(int argc, char** argv) { |
91 | Cmd cmd(flags, system_version); cmd.ClearError(); | | 163 | Cmd cmd(flags, system_version); cmd.ClearError(); |
92 | | | 164 | |
93 | /* end? */ | | 165 | /* end? */ |
94 | - if (*dcur == -1) { | | 166 | - if (*dcur == -1) { |
95 | + if ((unsigned char)*dcur == 0xff) { | | 167 | + if ((unsigned char)*dcur == 0xff) { |
96 | /* 0xff x 32byte + 0x00 : end sign */ | | 168 | /* 0xff x 32byte + 0x00 : end sign */ |
97 | int i; for (i=0; i<0x20; i++) | | 169 | int i; for (i=0; i<0x20; i++) |
98 | - if (dcur[i] != -1) break; | | 170 | - if (dcur[i] != -1) break; |
99 | + if ((unsigned char)dcur[i] != 0xff) break; | | 171 | + if ((unsigned char)dcur[i] != 0xff) break; |
100 | if (i == 0x20 && dcur[i] == 0) break; | | 172 | if (i == 0x20 && dcur[i] == 0) break; |
101 | } | | 173 | } |
102 | dprintf("%d : ",dcur-dstart); | | 174 | dprintf("%d : ",dcur-dstart); |