summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/util.c b/util.c
index 6e8c1d4..008792c 100644
--- a/util.c
+++ b/util.c
@@ -57,13 +57,41 @@ extern Widget scratch;
extern Widget vpanes[2], labels[3], texts[3], forms[3];
extern XawTextWrapMode wrapmodes[3];
+#ifndef va_copy
+# ifdef __va_copy
+# define va_copy __va_copy
+# else
+# error "no working va_copy was found"
+# endif
+#endif
+
/*
* Implementation
*/
void
-XeditPrintf(char *str)
+XeditPrintf(const char *format, ...)
{
- XawTextBlock text;
+ char *str;
+ size_t size;
+ va_list va,
+ va2;
+ XawTextBlock text;
+
+ va_start(va, format);
+
+ va_copy(va2, va);
+ size = vsnprintf(NULL, 0, format, va2);
+ va_end(va2);
+
+ str = (char *)malloc(size + 1);
+ if (str == NULL)
+ return;
+
+ vsnprintf(str, size + 1, format, va);
+ str[size] = 0;
+
+ va_end(va);
+
XawTextPosition pos = XawTextSourceScan(XawTextGetSource(messwidget),
0, XawstAll, XawsdRight, 1, True);
@@ -75,6 +103,8 @@ XeditPrintf(char *str)
XawTextReplace(messwidget, pos, pos, &text);
XawTextSetInsertionPoint(messwidget, pos + text.length);
+
+ free(str);
}
Widget