2 import structs
/ArrayList
3 import text
/StringTokenizer
7 charok
:= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890[]{}():\0"
8 charOk?
: func(c
:Char
) -> Bool
{ charok contains?
(c
) }
9 debugbuf
: func(b
:Buffer
) {
11 for (i in
0 .. b size
) ob
append("\\x" + numberToString(b
[i
] as UInt64
, 16, 2, true
))
12 "ptr: %p, size: %d, buf: %s" format(b
, b size
, ob data
) println()
16 main
: func( args
: ArrayList
<String
>) {
17 opts
:= Opts
new(args
)
18 oldchars
:= Buffer
new()
19 newchars
:= Buffer
new()
20 if(!opts set?
("new")) {
21 assert(oldchars
fromFile("oldchars"))
22 assert(newchars
fromFile("newchars"))
25 if (opts args size
< 2 ) exit(1)
27 x
fromFile(opts args
get(0))
28 org
:= x
toString() split('
\n'
)
30 y
fromFile(opts args
get(1))
31 dfg
:= y
toString() split('
\n'
)
32 for (lineno in
0..org size
) {
33 orgline
:= org
get(lineno
)
34 dfgline
:= dfg
get(lineno
)
36 for (i in
0..orgline size
) {
37 if (orgline
[i
] != dfgline
[i
]) {
38 if (!charOk?
(orgline
[i
])) {
39 if (!oldchars contains?
(orgline
[i
])) {
40 oldchars
append(orgline
[i
])
41 newchars
append(dfgline
[i
])
43 // s
:= numberToString(orgline
[i
] as UInt64
,16,2) + '
='
+ numberToString(dfgline
[i
] as UInt64
,16,2)
50 // if (found
) orgline
println()
51 // if (found
) dfgline
println()
54 ("oldchars: " + oldchars
toString()) println()
55 ("newchars: " + newchars
toString()) println()
56 if (newchars contains?
('\
0'
)) "something went wrong" println()
59 assert(oldchars
toFile("oldchars"))
60 assert(newchars
toFile("newchars"))