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

RCS_ID='$Id: nsq-n2r,v 0.9 1998/03/09 21:28:06 carlos Exp $'

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., 675 Mass Ave., Cambridge, MA 02139, USA.
			----------------------

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

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