//-----------------------------------------------------------------------------
// Copyright © 2004 - Philip Howard - All rights reserved
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
// GNU General Public License for more details.
//
// 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.
//-----------------------------------------------------------------------------
// package	libh/string
// homepage	http://libh.slashusr.org/
//-----------------------------------------------------------------------------
// author	Philip Howard
// email	libh at ipal dot org
// homepage	http://phil.ipal.org/
//-----------------------------------------------------------------------------
// This file is best viewed using a fixed spaced font such as Courier
// and in a display at least 120 columns wide.
//-----------------------------------------------------------------------------

#include "string_lib.h"

__PROTO_BEGIN__
//-----------------------------------------------------------------------------
// function	split_sep_find_sptab
//
// purpose	Find the start and end of the next separator and update the
//		split state for the new position.
//
//		The separator is a sequence of one or more spaces and/or tabs.
//
// argument	1 (split_p) pointer to split state
//
// returns	(int) -1 : error
//		(int)  0 : separator found
//		(int)  1 : end of string, not found
//-----------------------------------------------------------------------------
int
split_sep_find_sptab (
    split_p		arg_split
    )
__PROTO_END__
{
    char *	ptr		;
    char *	end		;


    ptr = arg_split->next_ptr;
    end = arg_split->data_end;

    //-- Find start of separator.
    while ( ptr < end &&
	    * ptr != ' ' &&
	    * ptr != '\t' ) ++ ptr;

    //-- The separator or end of string is the end of this part.
    arg_split->part_end = ptr;

    //-- If end of string, return not found
    if ( ptr >= end ) {
	arg_split->next_ptr = NULL;
	return 1;
    }

    //-- Find end of separator.
    while ( * ptr == ' ' ||
	    * ptr == '\t' ) ++ ptr;
    arg_split->next_ptr = ptr;

    //-- Return success.
    return 0;
}

