diff options
| author | Karl Heuer | 1994-02-10 20:50:54 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-02-10 20:50:54 +0000 |
| commit | 671fbc4df13660f0b7cb366e2cbe8ee4198ebe78 (patch) | |
| tree | cda5e1f0e334278752288b3344847b07eeacbf6c /src | |
| parent | 3a179e58d72c311d1745a1f11a21c2093a8ed48b (diff) | |
| download | emacs-671fbc4df13660f0b7cb366e2cbe8ee4198ebe78.tar.gz emacs-671fbc4df13660f0b7cb366e2cbe8ee4198ebe78.zip | |
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/editfns.c b/src/editfns.c index e6fcbfdf35d..aa97aee21c1 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1366,6 +1366,12 @@ use `save-excursion' outermost:\n\ | |||
| 1366 | return unbind_to (count, val); | 1366 | return unbind_to (count, val); |
| 1367 | } | 1367 | } |
| 1368 | 1368 | ||
| 1369 | /* Buffer for the most recent text displayed by Fmessage. */ | ||
| 1370 | static char *message_text; | ||
| 1371 | |||
| 1372 | /* Allocated length of that buffer. */ | ||
| 1373 | static int message_length; | ||
| 1374 | |||
| 1369 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, | 1375 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, |
| 1370 | "Print a one-line message at the bottom of the screen.\n\ | 1376 | "Print a one-line message at the bottom of the screen.\n\ |
| 1371 | The first argument is a control string.\n\ | 1377 | The first argument is a control string.\n\ |
| @@ -1389,7 +1395,19 @@ minibuffer contents show.") | |||
| 1389 | { | 1395 | { |
| 1390 | register Lisp_Object val; | 1396 | register Lisp_Object val; |
| 1391 | val = Fformat (nargs, args); | 1397 | val = Fformat (nargs, args); |
| 1392 | message2 (XSTRING (val)->data, XSTRING (val)->size); | 1398 | /* Copy the data so that it won't move when we GC. */ |
| 1399 | if (! message_text) | ||
| 1400 | { | ||
| 1401 | message_text = (char *)xmalloc (80); | ||
| 1402 | message_length = 80; | ||
| 1403 | } | ||
| 1404 | if (XSTRING (val)->size > message_length) | ||
| 1405 | { | ||
| 1406 | message_length = XSTRING (val)->size; | ||
| 1407 | message_text = (char *)xrealloc (message_text, message_length); | ||
| 1408 | } | ||
| 1409 | bcopy (XSTRING (val)->data, message_text, XSTRING (val)->size); | ||
| 1410 | message2 (message_text, XSTRING (val)->size); | ||
| 1393 | return val; | 1411 | return val; |
| 1394 | } | 1412 | } |
| 1395 | } | 1413 | } |