Hi,

I added the missing function targetGenericMisc_formatString() that
somehow got lost.

2006-01-19  Roman Kennke  <[EMAIL PROTECTED]>

        * native/target/generic/target_generic_misc.c:
        (targetGenericMisc_formatString): Added missing method.

/Roman
Index: native/target/generic/target_generic_misc.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/target/generic/target_generic_misc.c,v
retrieving revision 1.2
diff -u -r1.2 target_generic_misc.c
--- native/target/generic/target_generic_misc.c	17 Jan 2006 12:29:40 -0000	1.2
+++ native/target/generic/target_generic_misc.c	19 Jan 2006 20:05:32 -0000
@@ -75,6 +75,39 @@
 
 /***************************** Functions *******************************/
 
+#ifdef TARGET_NATIVE_MISC_FORMAT_STRING_GENERIC
+int targetGenericMisc_formatString(char *buffer, unsigned int bufferSize, const char *format,...)
+{
+  va_list arguments;
+  int     n;
+  char    *tmpBuffer;
+
+  assert(buffer!=NULL);
+  assert(format!=NULL);
+
+  va_start(arguments,format);
+  #ifdef HAVE_VSNPRINTF
+    n=vsnprintf(buffer,bufferSize,format,arguments);
+    if (n==-1) n=bufferSize;
+  #else
+    /* ToDo: how can we implement a safe format function without vsnprintf()
+       which does detect the number of characters formated?
+    */
+    TARGET_NATIVE_MEMORY_ALLOC(tmpBuffer,char*,4096);
+    n=vsprintf(tmpBuffer,format,arguments);
+    assert(n<=4096);
+    if (n<bufferSize)
+    {
+      TARGET_NATIVE_MEMORY_COPY(tmpBuffer,buffer,(n<bufferSize)?n:bufferSize);
+    }
+    TARGET_NATIVE_MEMORY_FREE(tmpBuffer);
+  #endif
+  va_end(arguments);
+
+  return n;
+}
+#endif /* TARGET_NATIVE_MISC_FORMAT_STRING_GENERIC */
+
 /* Put printed (decimal) representation of NUM in a buffer.
    BUFEND marks the end of the buffer, which must be at least 11 chars long.
    Returns the COUNT of chars written.  The result is in
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to