//	Zinc Application Framework - Z_PRNTF1.CPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#include <z_fdata.hpp>
#include <z_stdarg.hpp>
#include <z_string.hpp>

#include <stdio.h>

static int zvsprintf(ZafIChar *dst, const ZafIChar *format, va_list *args);

int ZafStandardArg::vsprintf(ZafIChar *dst, const ZafIChar *format, va_list *args)
{
#if defined(ZAF_REARRANGEARGS)
	ZafIChar *newFormat = new ZafIChar[ZAF_MAXPARAMLEN];
	char buff[ZAF_MAXPARAMLEN];	// Borland expects this in the stack.
	va_list newArgs;
	ZafStandardArg::RearrangeArgs(false, buff, format, args, newFormat, &newArgs);
	int i = zvsprintf(dst, newFormat, newArgs);
//	int i = ZafFormatData::_vsprintf(dst, newFormat, newArgs);
	delete []newFormat;
#else
	int i = zvsprintf(dst, format, args);
//	int i = ZafFormatData::_vsprintf(dst, format, args);
#endif
	return (i);
}

static int zvsprintf(ZafIChar *dst, const ZafIChar *format, va_list *args)
{
#if defined(ZAF_UNICODE)
	return (ZafStandardArg::_vsprintf(dst, format, args));
#else
#	if defined(_SUNOS4)
	return (vsprintf(dst, format, *args) ? 1 : 0);
#	else
	return (vsprintf(dst, format, *args));
#	endif
#endif
}
