#!/bin/sh

# Convert a tcl script into a literal C string.

# 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. */'

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

# If the source file is empty, we want to emit a null string
# rather than no string.  Force a null string here, since it's
# always harmless to have it.

echo '""'

