diff options
| author | Richard M. Stallman | 1996-02-22 18:21:03 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-02-22 18:21:03 +0000 |
| commit | 912e8480b7554aa47d66de5c2463552c8872d70a (patch) | |
| tree | 768f9c937a140aecb23beb81846c77ed9d65f884 /src | |
| parent | a3a3984834d8ea2c9bf4e47360ef56b454a77d95 (diff) | |
| download | emacs-912e8480b7554aa47d66de5c2463552c8872d70a.tar.gz emacs-912e8480b7554aa47d66de5c2463552c8872d70a.zip | |
(get_doc_string): Move static vars outside the function,
and rename to get_doc_string_buffer and get_doc_string_buffer_size.
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc.c | 38 |
1 files changed, 22 insertions, 16 deletions
| @@ -70,6 +70,10 @@ munge_doc_file_name (name) | |||
| 70 | #endif /* VMS */ | 70 | #endif /* VMS */ |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /* Buffer used for reading from documentation file. */ | ||
| 74 | static char *get_doc_string_buffer; | ||
| 75 | static int get_doc_string_buffer_size; | ||
| 76 | |||
| 73 | /* Extract a doc string from a file. FILEPOS says where to get it. | 77 | /* Extract a doc string from a file. FILEPOS says where to get it. |
| 74 | If it is an integer, use that position in the standard DOC-... file. | 78 | If it is an integer, use that position in the standard DOC-... file. |
| 75 | If it is (FILE . INTEGER), use FILE as the file name | 79 | If it is (FILE . INTEGER), use FILE as the file name |
| @@ -82,9 +86,6 @@ static Lisp_Object | |||
| 82 | get_doc_string (filepos) | 86 | get_doc_string (filepos) |
| 83 | Lisp_Object filepos; | 87 | Lisp_Object filepos; |
| 84 | { | 88 | { |
| 85 | static char *buffer; | ||
| 86 | static int buffer_size; | ||
| 87 | |||
| 88 | char *from, *to; | 89 | char *from, *to; |
| 89 | register int fd; | 90 | register int fd; |
| 90 | register char *name; | 91 | register char *name; |
| @@ -162,23 +163,27 @@ get_doc_string (filepos) | |||
| 162 | position, name); | 163 | position, name); |
| 163 | } | 164 | } |
| 164 | 165 | ||
| 165 | /* Read the doc string into a buffer. | 166 | /* Read the doc string into get_doc_string_buffer. |
| 166 | p points beyond the data just read. */ | 167 | P points beyond the data just read. */ |
| 167 | 168 | ||
| 168 | p = buffer; | 169 | p = get_doc_string_buffer; |
| 169 | while (1) | 170 | while (1) |
| 170 | { | 171 | { |
| 171 | int space_left = buffer_size - (p - buffer); | 172 | int space_left = (get_doc_string_buffer_size |
| 173 | - (p - get_doc_string_buffer)); | ||
| 172 | int nread; | 174 | int nread; |
| 173 | 175 | ||
| 174 | /* Allocate or grow the buffer if we need to. */ | 176 | /* Allocate or grow the buffer if we need to. */ |
| 175 | if (space_left == 0) | 177 | if (space_left == 0) |
| 176 | { | 178 | { |
| 177 | int in_buffer = p - buffer; | 179 | int in_buffer = p - get_doc_string_buffer; |
| 178 | buffer_size += 16 * 1024; | 180 | get_doc_string_buffer_size += 16 * 1024; |
| 179 | buffer = (char *) xrealloc (buffer, buffer_size + 1); | 181 | get_doc_string_buffer |
| 180 | p = buffer + in_buffer; | 182 | = (char *) xrealloc (get_doc_string_buffer, |
| 181 | space_left = buffer_size - (p - buffer); | 183 | get_doc_string_buffer_size + 1); |
| 184 | p = get_doc_string_buffer + in_buffer; | ||
| 185 | space_left = (get_doc_string_buffer_size | ||
| 186 | - (p - get_doc_string_buffer)); | ||
| 182 | } | 187 | } |
| 183 | 188 | ||
| 184 | /* Read a disk block at a time. | 189 | /* Read a disk block at a time. |
| @@ -194,7 +199,7 @@ get_doc_string (filepos) | |||
| 194 | p[nread] = 0; | 199 | p[nread] = 0; |
| 195 | if (!nread) | 200 | if (!nread) |
| 196 | break; | 201 | break; |
| 197 | if (p == buffer) | 202 | if (p == get_doc_string_buffer) |
| 198 | p1 = index (p + offset, '\037'); | 203 | p1 = index (p + offset, '\037'); |
| 199 | else | 204 | else |
| 200 | p1 = index (p, '\037'); | 205 | p1 = index (p, '\037'); |
| @@ -210,8 +215,8 @@ get_doc_string (filepos) | |||
| 210 | 215 | ||
| 211 | /* Scan the text and perform quoting with ^A (char code 1). | 216 | /* Scan the text and perform quoting with ^A (char code 1). |
| 212 | ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */ | 217 | ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */ |
| 213 | from = buffer + offset; | 218 | from = get_doc_string_buffer + offset; |
| 214 | to = buffer + offset; | 219 | to = get_doc_string_buffer + offset; |
| 215 | while (from != p) | 220 | while (from != p) |
| 216 | { | 221 | { |
| 217 | if (*from == 1) | 222 | if (*from == 1) |
| @@ -233,7 +238,8 @@ get_doc_string (filepos) | |||
| 233 | *to++ = *from++; | 238 | *to++ = *from++; |
| 234 | } | 239 | } |
| 235 | 240 | ||
| 236 | return make_string (buffer + offset, to - (buffer + offset)); | 241 | return make_string (get_doc_string_buffer + offset, |
| 242 | to - (get_doc_string_buffer + offset)); | ||
| 237 | } | 243 | } |
| 238 | 244 | ||
| 239 | /* Get a string from position FILEPOS and pass it through the Lisp reader. | 245 | /* Get a string from position FILEPOS and pass it through the Lisp reader. |