#!/usr/bin/tclsh
#
# This script splits the sqlite3.c amalgamated source code files into
# several smaller files such that no single files is more than a fixed
# number of lines in length (32k or 64k). Each of the split out files
# is #include-ed by the master file.
#
# Splitting files up this way allows them to be used with older compilers
# that cannot handle really long source files.
#
set MAX 32768 ;# Maximum number of lines per file.
set BEGIN
set END
set in
set out1
fconfigure $out1 -translation lf
# Copy the header from sqlite3.c into sqlite3-all.c
#
while
# Gather the complete content of a file into memory. Store the
# content in $bufout. Store the number of lines is $nout
#
# Write a big chunk of text in to an auxiliary file "sqlite3-NNN.c".
# Also add an appropriate #include to sqlite3-all.c
#
set filecnt 0
# Continue reading input. Store chunks in separate files and add
# the #includes to the main sqlite3-all.c file as necessary to reference
# the extra chunks.
#
set all
set N 0
while
if
close $out1
close $in