Mercurial > emacs
comparison src/editfns.c @ 5884:d02095ea13a5
(Fmessage): Copy the text to be displayed into a malloc'd buffer.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 10 Feb 1994 20:50:54 +0000 |
parents | 319a7fcb7609 |
children | 5fdb226fe9a4 |
comparison
equal
deleted
inserted
replaced
5883:13cb3226cb41 | 5884:d02095ea13a5 |
---|---|
1364 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | 1364 record_unwind_protect (save_restriction_restore, save_restriction_save ()); |
1365 val = Fprogn (body); | 1365 val = Fprogn (body); |
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\ |
1372 It may contain %s or %d or %c to print successive following arguments.\n\ | 1378 It may contain %s or %d or %c to print successive following arguments.\n\ |
1373 %s means print an argument as a string, %d means print as number in decimal,\n\ | 1379 %s means print an argument as a string, %d means print as number in decimal,\n\ |
1387 } | 1393 } |
1388 else | 1394 else |
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 } |
1396 | 1414 |
1397 DEFUN ("format", Fformat, Sformat, 1, MANY, 0, | 1415 DEFUN ("format", Fformat, Sformat, 1, MANY, 0, |