aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-12-08 09:59:52 +0000
committerGerd Moellmann2000-12-08 09:59:52 +0000
commit8d17fe0bb5e300ea1576bd5b9e47ddd63dbe39fa (patch)
treeddceb680da85ab583f2da3499e0c23ae1a830222
parent5d65df0d39324a62140d37219f67dcdb42aafe99 (diff)
downloademacs-8d17fe0bb5e300ea1576bd5b9e47ddd63dbe39fa.tar.gz
emacs-8d17fe0bb5e300ea1576bd5b9e47ddd63dbe39fa.zip
(Fsubstitute_command_keys): Change the way buffers
are reallocated so that it is portable.
-rw-r--r--src/doc.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/doc.c b/src/doc.c
index afa7e9df947..fc86198a212 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -313,6 +313,8 @@ string is passed through `substitute-command-keys'.")
313 Lisp_Object funcar; 313 Lisp_Object funcar;
314 Lisp_Object tem, doc; 314 Lisp_Object tem, doc;
315 315
316 doc = Qnil;
317
316 if (SYMBOLP (function) 318 if (SYMBOLP (function)
317 && (tem = Fget (function, Qfunction_documentation), 319 && (tem = Fget (function, Qfunction_documentation),
318 !NILP (tem))) 320 !NILP (tem)))
@@ -587,7 +589,6 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
587 register unsigned char *bufp; 589 register unsigned char *bufp;
588 int idx; 590 int idx;
589 int bsize; 591 int bsize;
590 unsigned char *new;
591 Lisp_Object tem; 592 Lisp_Object tem;
592 Lisp_Object keymap; 593 Lisp_Object keymap;
593 unsigned char *start; 594 unsigned char *start;
@@ -686,9 +687,9 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
686 687
687 if (NILP (tem)) /* but not on any keys */ 688 if (NILP (tem)) /* but not on any keys */
688 { 689 {
689 new = (unsigned char *) xrealloc (buf, bsize += 4); 690 int offset = bufp - buf;
690 bufp += new - buf; 691 buf = (unsigned char *) xrealloc (buf, bsize += 4);
691 buf = new; 692 bufp = buf + offset;
692 bcopy ("M-x ", bufp, 4); 693 bcopy ("M-x ", bufp, 4);
693 bufp += 4; 694 bufp += 4;
694 nchars += 4; 695 nchars += 4;
@@ -771,14 +772,16 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int
771 length = XSTRING (tem)->size; 772 length = XSTRING (tem)->size;
772 length_byte = STRING_BYTES (XSTRING (tem)); 773 length_byte = STRING_BYTES (XSTRING (tem));
773 subst: 774 subst:
774 new = (unsigned char *) xrealloc (buf, bsize += length_byte); 775 {
775 bufp += new - buf; 776 int offset = bufp - buf;
776 buf = new; 777 buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
777 bcopy (start, bufp, length_byte); 778 bufp = buf + offset;
778 bufp += length_byte; 779 bcopy (start, bufp, length_byte);
779 nchars += length; 780 bufp += length_byte;
780 /* Check STRING again in case gc relocated it. */ 781 nchars += length;
781 strp = (unsigned char *) XSTRING (string)->data + idx; 782 /* Check STRING again in case gc relocated it. */
783 strp = (unsigned char *) XSTRING (string)->data + idx;
784 }
782 } 785 }
783 else if (! multibyte) /* just copy other chars */ 786 else if (! multibyte) /* just copy other chars */
784 *bufp++ = *strp++, nchars++; 787 *bufp++ = *strp++, nchars++;