Eskil

Check-in [de8aecb181]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added binary plugin
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: de8aecb181c920f921d12da95e93657ca1c59d17
User & Date: peter 2015-11-20 23:49:00.023
Context
2015-11-21
02:13
Adapted test to compressed pdf check-in: b86ab111b4 user: peter tags: trunk
2015-11-20
23:49
Added binary plugin check-in: de8aecb181 user: peter tags: trunk
2015-11-17
23:44
Compress printed PDF check-in: 04edfdfee9 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Changes.



1
2
3
4
5
6
7



2015-11-17
 Compress printed PDF.

2015-10-14
 Page break between files when printing in patch mode.

2015-10-12
>
>
>







1
2
3
4
5
6
7
8
9
10
2015-11-19
 Added binary plugin.

2015-11-17
 Compress printed PDF.

2015-10-14
 Page break between files when printing in patch mode.

2015-10-12
Added plugins/binary.tcl.








































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
##Eskil Plugin : Compare binary files, in hex

# Example file for a plugin.
# A plugin must start exactly like this one.
# The text after : is the summary you can get at the command line

# This plugin converts files to hex to be able to compare binary files.
# A set of chars can be defined to be used as "newline". Default "0 10 13".
# Example usage:
# eskil -plugin binary -plugininfo "0 10 13 32" f1 f2

# A plugin must define this procedure to do the job.
# side: left or right
# chi:  An input channel for reading the original file.
# cho:  An output channel for writing the processed file.
proc PreProcess {side chi cho} {
    if {[catch {llength $::Info}]} {
        puts $cho "Binary plugin needs -plugininfo parameter to be a list"
        return 1
    }
    if {[llength $::Info] > 0} {
        set delimitL $::Info
    } else {
        set delimitL [list 0 10 13]
    }

    # Build an RE that matches the given chars
    set REm "\["
    set REi "\[^"
    foreach code $delimitL {
        set c [format %c $code]
        if {[string is wordchar $c]} {
            append REm $c
            append REi $c
        } else {
            # Just in case it is a special char for RE
            append REm \\ $c
            append REi \\ $c
        }
    }
    append REm "\]"
    append REi "\]"

    set RE $REi*$REm*

    fconfigure $chi -translation binary
    # Assume small enough for memory.
    # A file too large to read would be virtually impossible to display anyway.
    set data [read $chi]
    foreach line [regexp -all -inline $RE $data] {
        puts $cho [strToHex $line]
    }

    # Signal that the file after processing should be used both
    # for comparison and for displaying.
    return 1
}

# Note: With 8.6 there is "binary encode hex" that might be faster

# Build a string to hex mapper for speed
set ::hexCharMap {}
for {set i 0} {$i < 256} {incr i} {
    lappend ::hexCharMap [format %c $i] [format "%02X " $i]
}
proc strToHex {str} {
    string map $::hexCharMap $str
}