72 lines
1.8 KiB
Diff
72 lines
1.8 KiB
Diff
|
--- lib/readline/display.c
|
||
|
+++ lib/readline/display.c 2012-07-18 08:04:36.456009352 +0000
|
||
|
@@ -176,7 +176,8 @@ int _rl_vis_botlin = 0;
|
||
|
static int last_lmargin;
|
||
|
|
||
|
/* A buffer for `modeline' messages. */
|
||
|
-static char msg_buf[128];
|
||
|
+static char *msg_buf;
|
||
|
+static size_t msg_buf_sz = 128;
|
||
|
|
||
|
/* Non-zero forces the redisplay even if we thought it was unnecessary. */
|
||
|
static int forced_display;
|
||
|
@@ -2139,6 +2140,32 @@ rl_message (va_alist)
|
||
|
#if defined (PREFER_VARARGS)
|
||
|
char *format;
|
||
|
#endif
|
||
|
+#if defined (HAVE_VSNPRINTF)
|
||
|
+ int vsnprbytes;
|
||
|
+#endif
|
||
|
+
|
||
|
+ if (!msg_buf)
|
||
|
+ msg_buf = xmalloc(msg_buf_sz);
|
||
|
+
|
||
|
+#if defined (HAVE_VSNPRINTF)
|
||
|
+ do
|
||
|
+ {
|
||
|
+ va_end (args);
|
||
|
+#if defined (PREFER_STDARG)
|
||
|
+ va_start (args, format);
|
||
|
+#else
|
||
|
+ va_start (args);
|
||
|
+ format = va_arg (args, char *);
|
||
|
+#endif
|
||
|
+ vsnprbytes = vsnprintf (msg_buf, msg_buf_sz - 1, format, args);
|
||
|
+ if (vsnprbytes < msg_buf_sz - 1)
|
||
|
+ break;
|
||
|
+
|
||
|
+ msg_buf_sz += 64;
|
||
|
+ msg_buf = xrealloc (msg_buf, msg_buf_sz);
|
||
|
+ }
|
||
|
+ while (1);
|
||
|
+#else
|
||
|
|
||
|
#if defined (PREFER_STDARG)
|
||
|
va_start (args, format);
|
||
|
@@ -2147,11 +2174,8 @@ rl_message (va_alist)
|
||
|
format = va_arg (args, char *);
|
||
|
#endif
|
||
|
|
||
|
-#if defined (HAVE_VSNPRINTF)
|
||
|
- vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args);
|
||
|
-#else
|
||
|
vsprintf (msg_buf, format, args);
|
||
|
- msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
|
||
|
+ msg_buf[msg_buf_sz - 1] = '\0'; /* overflow? */
|
||
|
#endif
|
||
|
va_end (args);
|
||
|
|
||
|
@@ -2176,8 +2200,11 @@ int
|
||
|
rl_message (format, arg1, arg2)
|
||
|
char *format;
|
||
|
{
|
||
|
+ if (!msg_buf)
|
||
|
+ msg_buf = xmalloc(msg_buf_sz);
|
||
|
+
|
||
|
sprintf (msg_buf, format, arg1, arg2);
|
||
|
- msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
|
||
|
+ msg_buf[msg_buf_sz - 1] = '\0'; /* overflow? */
|
||
|
|
||
|
rl_display_prompt = msg_buf;
|
||
|
if (saved_local_prompt == 0)
|