#****************************************************************************
#  ##   ##         #####   #####  ##     **        NoSQL RDBMS - pad        *
#  ###  ##        ####### ####### ##     **        $Revision: 2.1 $			*
#  #### ##        ###     ##   ## ##     ************************************
#  #######  ####  #####   ##   ## ##     **      Carlo Strozzi (c) 1998     *
#  ####### ######   ##### ## # ## ##     ************************************
#  ## #### ##  ##     ### ##  ### ##     **           Written by            *
#  ##  ### ###### ####### ######  ###### **          Carlo Strozzi          *
#  ##   ##  ####   #####   #### # ###### **     e-mail: carlos@linux.it     *
#****************************************************************************
#   NoSQL RDBMS, Copyright (C) 1998 Carlo Strozzi.                          *
#   This program comes with ABSOLUTELY NO WARRANTY; for details             *
#   refer to the GNU General Public License.                                *
#****************************************************************************
#
#  Add extra spaces to the end of each row of the input table.
#
#  Adding spaces to rows 'makes room' for updating the rows themselves
#  without changing their length and thus not invalidating the table
#  indexes, nor the byte position of the row in the table.
#  Padding gives each record a fixed number of extra spaces to be trimmed
#  as needed.
#
#  This NoSQL operator reads a table from STDIN and writes the padded
#  table to STDOUT.
#
########################################################################

########################################################################
# BEGIN block
########################################################################

BEGIN \
{
  NULL = ""; FS = OFS = "\t";
  blanks = 60
  if ( __nosql_args != NULL )
  {
	if ( ( __nosql_args / 1 ) == __nosql_args ) blanks = __nosql_args
  }
}

########################################################################
# Main loop
########################################################################

NR < 3 { print; next }

{
  tot_len = length( $0 ) + blanks
  j_mode = "%-" tot_len "s\n"
  printf( j_mode, $0 )
}

