CVS: winex/dlls/ntdll debugtools.c, 1.25, 1.26 ntdll.spec, 1.50, 1.51

[email protected] 12 Sep 2007 12:14:48 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/ntdll debugtools.c,1.25,1.26 ntdll.spec,1.50,1.51Update of /var/lib/cvsd/cvsroot/winex/dlls/ntdll
In directory agravaine:/tmp/cvs-serv6441/dlls/ntdll

Modified Files:
	debugtools.c ntdll.spec 
Log Message:

- added the wine_dbg_sprintf() function.  WineHQ's dbghelp library makes use of it.



Index: debugtools.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/debugtools.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- debugtools.c	12 Sep 2007 12:12:42 -0000	1.25
+++ debugtools.c	12 Sep 2007 12:14:45 -0000	1.26
@@ -490,6 +490,53 @@
 }
 
 /***********************************************************************
+ *		wine_dbg_sprintf (NTDLL.@)
+ */
+const char *wine_dbg_sprintf( const char *format, ... )
+{
+    const int           bufSize = 256;
+    struct debug_info * info;
+    char *              str;
+    int                 ret;
+    va_list             args;
+
+
+    if (!traceEnabled)
+        return "";
+
+
+    info = get_info();
+
+
+    va_start(args, format);
+    
+    /* allocate a buffer to write to.  String length + 2 seems to be pretty
+        standard for all other similar functions here. */
+    str = (char *)gimme1(bufSize);
+
+    /* print the string */
+    ret = vsnprintf( str, bufSize - 1, format, args );
+
+    va_end(args);
+
+
+    /* the buffer was too small => truncate the string */
+    if (ret == -1 || ret >= bufSize){
+        str[bufSize - 2] = '@';
+        str[bufSize - 1] = 0;
+    }
+
+    /* only a part of the buffer was used => release the extra space back to the string pool */
+    else{
+        str[ret] = 0;
+        info->str_pos -= (bufSize - ret - 1);
+    }
+
+
+    return str;
+}
+
+/***********************************************************************
  *		wine_dbg_switch_trace (NTDLL.@)
  * get/set debug trace state
  *  init = TRUE: init feature

Index: ntdll.spec
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/ntdll.spec,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- ntdll.spec	12 Sep 2007 12:11:35 -0000	1.50
+++ ntdll.spec	12 Sep 2007 12:14:45 -0000	1.51
@@ -1060,6 +1060,7 @@
 @ cdecl -norelay wine_dbg_vprintf(str ptr) wine_dbg_vprintf
 @ cdecl -norelay wine_dbgstack(long) wine_dbgstack
 @ varargs wine_dbg_printf(str) wine_dbg_printf
+@ varargs wine_dbg_sprintf(str) wine_dbg_sprintf
 @ varargs wine_dbg_log(long str str str) wine_dbg_log
 @ cdecl -norelay wine_start_memwatch(long ptr long) wine_start_memwatch
 @ cdecl -norelay wine_stop_memwatch(long) wine_stop_memwatch