Added get_variable_message_length: this function determines the buffer size
authortwisti <none@none>
Tue, 29 Mar 2005 22:24:34 +0000 (22:24 +0000)
committertwisti <none@none>
Tue, 29 Mar 2005 22:24:34 +0000 (22:24 +0000)
required by e.g. vnsprintf

src/toolbox/util.c
src/toolbox/util.h

index 8f512f8ec84ed857c1123f7c6887818cbc3f4af3..9cf650a8595d0ebc2071d3d2673257dd5e9007d5 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: util.c 2063 2005-03-23 11:19:11Z twisti $
+   $Id: util.c 2127 2005-03-29 22:24:34Z twisti $
 
 */
 
@@ -79,6 +79,26 @@ char *_Jv_getcwd(void)
 }
 
 
+/* get_variable_message_length *************************************************
+
+   This function simluates the print of a variable message and
+   determines so the message length;
+
+*******************************************************************************/
+
+int get_variable_message_length(const char *fmt, ...)
+{
+       va_list ap;
+       int     len;
+
+       va_start(ap, fmt);
+       len = vsnprintf(NULL, 0, fmt, ap);
+       va_end(ap);
+
+       return len;
+}
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
index 56a19a332f45ad2800ac0561ccc2a5401f10658c..971e611ba092df93416142ababb7c9fa5fe4c672 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: util.h 2063 2005-03-23 11:19:11Z twisti $
+   $Id: util.h 2127 2005-03-29 22:24:34Z twisti $
 
 */
 
@@ -39,6 +39,7 @@
 /* function prototypes ********************************************************/
 
 char *_Jv_getcwd(void);
+int get_variable_message_length(const char *fmt, ...);
 
 #endif /* _UTIL_H */