This file is indexed.

/usr/games/spliteco is in scid 1:4.6.4+dfsg1-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
# \
exec tkscid "$0" "$@"

# spliteco:
#   Takes a Scid-format database and produces a number of smaller
#   databases containing the games grouped according to ECO code.
#   It can produce 5 (A-E), 50 (A0-E9) or 500 (A00-E99) databases.
#   Games with no ECO code are not copied.
#
# Usage:
#   spliteco [-v] <scid-database> 5|50|500
#
# Author: Shane Hudson
# Last updated: May 2002
# Scid website: http://scid.sourceforge.net

set verbose 0

proc main {} {
  global argv verbose
  # Look for optional "-v" argument:
  if {[string range [lindex $argv 0] 0 1] == "-v"} {
    set argv [lrange $argv 1 end]
    set verbose 1
  }
  # Check for two required arguments:
  if {[llength $argv] != 2} { usage }
  set basename [lindex $argv 0]
  set ngroups [lindex $argv 1]
  if {$ngroups != 5  &&  $ngroups != 50  &&  $ngroups != 500} { usage }

  # Strip suffix if necessary:
  set suffix [file extension $basename]
  if {$suffix == ".si3" || $suffix == ".sn3" || $suffix == ".sg3"} {
    set basename [file rootname $basename]
  }
  # Try to open the database:
  if {[catch {sc_base open $basename} frombase]} {
    err "Error opening database \"$basename\": $frombase"
    exit 1
  }
  switch $ngroups {
    5   {split5   $basename $frombase}
    50  {split50  $basename $frombase}
    500 {split500 $basename $frombase}
  }
  sc_base close $frombase
}

proc err {s} {
  puts stderr $s
}

proc log {s} {
  global verbose
  if {$verbose} {
    puts -nonewline stdout $s
    flush stdout
  }
}

proc usage {} {
  err "spliteco:"
  err "  Splits a Scid-format database into 5, 50 or 500 smaller databases"
  err "  grouped by ECO code. Games with no ECO code are not copied."
  err "  For progress feedback, add the \"-v\" (verbose) option."
  err "Usage: spliteco \[-v\] <Scid-database> 5|50|500"
  exit 1
}

proc split5 {basename frombase} {
  foreach major {A B C D E} {
    log "ECO range $major: "
    set ngames [split $frombase ${basename}_$major ${major}00 ${major}99]
    log " copied [format %6d $ngames] games to 1 database\n"
  }
}

proc split50 {basename frombase} {
  foreach major {A B C D E} {
    log "ECO range $major: "
    set ngames 0
    foreach minor {0 1 2 3 4 5 6 7 8 9} {
      set code $major$minor
      incr ngames [split $frombase ${basename}_$code ${code}0 ${code}9]
      log "."
    }
    log " copied [format %6d $ngames] games to 10 databases\n"
  }
}

proc split500 {basename frombase} {
  foreach major {A B C D E} {
    log "ECO range $major: "
    set ngames 0
    foreach minor {0 1 2 3 4 5 6 7 8 9} {
      foreach subcode {0 1 2 3 4 5 6 7 8 9} {
        set code $major$minor$subcode
        incr ngames [split $frombase ${basename}_$code $code $code]
      }
      log "."
    }
    log " copied [format %6d $ngames] games to 100 databases\n"
  }
}

proc split {frombase newbasename startECO endECO} {
  if {[catch {sc_base create $newbasename} tobase]} {
    err "Error creating database \"$newbasename\": $tobase"
    exit 1
  }
  sc_base switch $frombase
  sc_filter set $frombase dbfilter 1
  sc_search header -eco [list $startECO $endECO]
  set ngames [sc_filter count]
  if {[catch {sc_base copygames $frombase dbfilter $tobase} err]} {
    err "Error copying games to \"$newbasename\": $err"
    exit 1
  }
  sc_base close $tobase
  return $ngames
}

main