#!/bin/sh
#
# Converts a NoSQL table to /rdb format.
#
# Author: Carlo Strozzi <carlos@linux.it>

RCS_ID='$Id: nsq-n2r,v 0.9b 1998/03/10 07:35:02 carlos Exp carlos $'

my_name=$(basename $0)

while [ $# -ge 1 ] ; do
    case $1 in
		-h*) cat <<_EOH_

		NoSQL operator: ${my_name}

Usage:  ${my_name}  [options]  < input_table

Options:
	-h	Print this help info.

Converts a NoSQL table to /rdb format. Table header comments are
NOT preserved.

This operator reads an /rdb table via STDIN and produces the NoSQL
version of the same table on STDOUT.

$RCS_ID

			----------------------
NoSQL RDBMS, Copyright (C) 1998 Carlo Strozzi.
This program comes with ABSOLUTELY NO WARRANTY; for details
refer to the GNU General Public License.

You should have received a copy of the GNU General Public License
along with this program;  if not, write to the Free Software
Foundation, Inc., 59 Temple Place Suite 330, Boston, MA 02111-1307
USA.
			----------------------

_EOH_
			exit 0
			;;
		*) break ;;
	esac
done

awk 'BEGIN { headline = 0 }
  $1 ~ /^ *#/ { next }
  { if (++headline == 1) {
      print
	  gsub(/[^\t]/,"-")
      }
    if (headline == 2) next
    print }'
