#!/bin/sh

# Convert a tcl script into a C array.

# This is written in sh and sed, on the theory that you have
# to have those to have successfully run configure.

# The downside is sed doesn't support '\t' for tab.  so we
# make a tab char magically appear.  this assumes ascii.
# this won't work with one ancient flavor of 'tr' that
# nobody has anymore.
tab=`echo 'x' | tr -dc 'x' | tr 'x' '\011'`

echo '/* This file is automatically generated.  Do not edit. */'
echo 'static char* tcl_init_script ='

sed -e "s/^[ $tab]*//" -e '
  /^$/d
  /^#/d
  s/\\/\\\\/g
  s/"/\\"/g
  s/^/ "/
  s/$/\\n"/
'

echo ';'
