/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: makestr.c 1.2 89/10/10 $@(#)nlp:lib/lp/makestr.c	1.1"
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */

#include "varargs.h"
#include "string.h"
#include "errno.h"

extern char		*malloc();

/**
 ** makestr() - CONSTRUCT SINGLE STRING FROM SEVERAL
 **/

/*VARARGS0*/
char			*makestr (va_alist)
	va_dcl
{
	register va_list	ap;

	register char		*component,
				*p,
				*q;

	register int		len;

	char			*ret;

	va_start (ap);
	for (len = 0; (component = va_arg(ap, char *)); )
		len += strlen(component);
	va_end (ap);

	if (!len) {
		errno = 0;
		return (0);
	}

	if (!(ret = malloc(len + 1))) {
		errno = ENOMEM;
		return (0);
	}

	va_start (ap);
	for (p = ret; (component = va_arg(ap, char *)); )
		for (q = component; *q; )
			*p++ = *q++;
	*p = 0;
	va_end(ap);

	return (ret);
}
