/*
 * lib/mkargs.c -- Build argc/argv from string just like for main()
 *
 * This file is subject to the terms and conditions of the
 * GNU General Public License. See the file COPYING in the
 * main directory of this archive for more details.
 *
 * Copyright (C) 1995 by Waldorf Electronics,
 * written by Ralf Baechle
 */
int
mkargs(int *argc, char **argv, char *args)
{
    char *p = args;

    *argc = 0;
    while(*p != '\0')
    {
	*argv = p;
	argv++;
	while(*p != '\t' && *p != ' ')
	{
	    if(*p == '\0')
	    {
		goto end;
	    }
	    p++;
	}
	*p = '\0';
	p++;
	while(*p == '\t' || *p == ' ')
	{
	    if(*p == '\0')
	    {
		goto end;
	    }
	    p++;
	}
end:
	(*argc)++;
    }
}
