Author: greatlrd
Date: Wed May 24 22:56:29 2006
New Revision: 22012
URL:
http://svn.reactos.ru/svn/reactos?rev=22012&view=rev
Log:
import cprintf from wine cvs 2006-05-23 as bug 1529 suggested, I was looking for this bug
before it was reported.
it make most of msvcrt string test work, only one fail left to fix.
Modified:
trunk/reactos/lib/crt/conio/cprintf.c
Modified: trunk/reactos/lib/crt/conio/cprintf.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/crt/conio/cprintf.c?rev…
==============================================================================
--- trunk/reactos/lib/crt/conio/cprintf.c (original)
+++ trunk/reactos/lib/crt/conio/cprintf.c Wed May 24 22:56:29 2006
@@ -1,27 +1,51 @@
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
+ * COPYRIGHT: Winehq
+ * PROJECT: wine
* FILE: msvcrt/conio/cprintf.c
* PURPOSE: C Runtime
- * PROGRAMMER: Eric Kohl (Imported from DJGPP)
+ * PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
*/
#include <precomp.h>
/*
- * @unimplemented
+ * @implemented
*/
int
_cprintf(const char *fmt, ...)
{
- int cnt;
- char buf[ 2048 ]; /* this is buggy, because buffer might be too small. */
+ char buf[2048], *mem = buf;
+ int written, resize = sizeof(buf), retval;
+ va_list valist;
+
+ while ((written = vsnprintf( mem, resize, fmt, valist )) == -1 ||
+ written > resize)
+ {
+ resize = (written == -1 ? resize * 2 : written + 1);
+ if (mem != buf)
+ free (mem);
+ if (!(mem = (char *)malloc(resize)))
+ return EOF;
+ va_start( valist, fmt );
+ }
+ va_end(valist);
+ retval = _cputs( mem );
+ if (mem != buf)
+ free (mem);
+ return retval;
+
+
+/*
va_list ap;
- va_start(ap, fmt);
- cnt = vsprintf(buf, fmt, ap);
+ va_start(ap, fmt);
+ while (vsprintf(buf, fmt, ap)==-1)
+ {
+ if (cnt < 0)
+
va_end(ap);
_cputs(buf);
return cnt;
+ */
}