changeset 14648:45d13c154bb4

(get_doc_string): Move static vars outside the function, and rename to get_doc_string_buffer and get_doc_string_buffer_size.
author Richard M. Stallman <rms@gnu.org>
date Thu, 22 Feb 1996 18:21:03 +0000
parents b1a88c3a6912
children 2925c3f0d038
files src/doc.c
diffstat 1 files changed, 22 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/doc.c	Thu Feb 22 13:07:58 1996 +0000
+++ b/src/doc.c	Thu Feb 22 18:21:03 1996 +0000
@@ -70,6 +70,10 @@
 #endif /* VMS */
 }
 
+/* Buffer used for reading from documentation file.  */
+static char *get_doc_string_buffer;
+static int get_doc_string_buffer_size;
+
 /* Extract a doc string from a file.  FILEPOS says where to get it.
    If it is an integer, use that position in the standard DOC-... file.
    If it is (FILE . INTEGER), use FILE as the file name
@@ -82,9 +86,6 @@
 get_doc_string (filepos)
      Lisp_Object filepos;
 {
-  static char *buffer;
-  static int buffer_size;
-
   char *from, *to;
   register int fd;
   register char *name;
@@ -162,23 +163,27 @@
 	     position, name);
     }
 
-  /* Read the doc string into a buffer.
-     p points beyond the data just read.  */
+  /* Read the doc string into get_doc_string_buffer.
+     P points beyond the data just read.  */
 
-  p = buffer;
+  p = get_doc_string_buffer;
   while (1)
     {
-      int space_left = buffer_size - (p - buffer);
+      int space_left = (get_doc_string_buffer_size
+			- (p - get_doc_string_buffer));
       int nread;
 
       /* Allocate or grow the buffer if we need to.  */
       if (space_left == 0)
 	{
-	  int in_buffer = p - buffer;
-	  buffer_size += 16 * 1024;
-	  buffer = (char *) xrealloc (buffer, buffer_size + 1);
-	  p = buffer + in_buffer;
-	  space_left = buffer_size - (p - buffer);
+	  int in_buffer = p - get_doc_string_buffer;
+	  get_doc_string_buffer_size += 16 * 1024;
+	  get_doc_string_buffer
+	    = (char *) xrealloc (get_doc_string_buffer,
+				 get_doc_string_buffer_size + 1);
+	  p = get_doc_string_buffer + in_buffer;
+	  space_left = (get_doc_string_buffer_size
+			- (p - get_doc_string_buffer));
 	}
 
       /* Read a disk block at a time.
@@ -194,7 +199,7 @@
       p[nread] = 0;
       if (!nread)
 	break;
-      if (p == buffer)
+      if (p == get_doc_string_buffer)
 	p1 = index (p + offset, '\037');
       else
 	p1 = index (p, '\037');
@@ -210,8 +215,8 @@
 
   /* Scan the text and perform quoting with ^A (char code 1).
      ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_.  */
-  from = buffer + offset;
-  to = buffer + offset;
+  from = get_doc_string_buffer + offset;
+  to = get_doc_string_buffer + offset;
   while (from != p)
     {
       if (*from == 1)
@@ -233,7 +238,8 @@
 	*to++ = *from++;
     }
 
-  return make_string (buffer + offset, to - (buffer + offset));
+  return make_string (get_doc_string_buffer + offset,
+		      to - (get_doc_string_buffer + offset));
 }
 
 /* Get a string from position FILEPOS and pass it through the Lisp reader.