aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/doc.c b/src/doc.c
index 83e943c42b8..9fbeb0b5ed5 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -86,9 +86,11 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
86 register int fd; 86 register int fd;
87 register char *name; 87 register char *name;
88 register char *p, *p1; 88 register char *p, *p1;
89 EMACS_INT minsize; 89 ptrdiff_t minsize;
90 EMACS_INT offset, position; 90 int offset;
91 EMACS_INT position;
91 Lisp_Object file, tem; 92 Lisp_Object file, tem;
93 USE_SAFE_ALLOCA;
92 94
93 if (INTEGERP (filepos)) 95 if (INTEGERP (filepos))
94 { 96 {
@@ -122,7 +124,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
122 /* sizeof ("../etc/") == 8 */ 124 /* sizeof ("../etc/") == 8 */
123 if (minsize < 8) 125 if (minsize < 8)
124 minsize = 8; 126 minsize = 8;
125 name = (char *) alloca (minsize + SCHARS (file) + 8); 127 SAFE_ALLOCA (name, char *, minsize + SCHARS (file) + 8);
126 strcpy (name, SSDATA (Vdoc_directory)); 128 strcpy (name, SSDATA (Vdoc_directory));
127 strcat (name, SSDATA (file)); 129 strcat (name, SSDATA (file));
128 } 130 }
@@ -153,13 +155,16 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
153 /* Make sure we read at least 1024 bytes before `position' 155 /* Make sure we read at least 1024 bytes before `position'
154 so we can check the leading text for consistency. */ 156 so we can check the leading text for consistency. */
155 offset = min (position, max (1024, position % (8 * 1024))); 157 offset = min (position, max (1024, position % (8 * 1024)));
156 if (0 > lseek (fd, position - offset, 0)) 158 if (TYPE_MAXIMUM (off_t) < position
159 || lseek (fd, position - offset, 0) < 0)
157 { 160 {
158 emacs_close (fd); 161 emacs_close (fd);
159 error ("Position %"pI"d out of range in doc string file \"%s\"", 162 error ("Position %"pI"d out of range in doc string file \"%s\"",
160 position, name); 163 position, name);
161 } 164 }
162 165
166 SAFE_FREE ();
167
163 /* Read the doc string into get_doc_string_buffer. 168 /* Read the doc string into get_doc_string_buffer.
164 P points beyond the data just read. */ 169 P points beyond the data just read. */
165 170
@@ -277,7 +282,7 @@ Invalid data in documentation file -- %c followed by code %03o",
277 else 282 else
278 { 283 {
279 /* The data determines whether the string is multibyte. */ 284 /* The data determines whether the string is multibyte. */
280 EMACS_INT nchars = 285 ptrdiff_t nchars =
281 multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer 286 multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer
282 + offset), 287 + offset),
283 to - (get_doc_string_buffer + offset)); 288 to - (get_doc_string_buffer + offset));
@@ -500,8 +505,7 @@ aren't strings. */)
500/* Scanning the DOC files and placing docstring offsets into functions. */ 505/* Scanning the DOC files and placing docstring offsets into functions. */
501 506
502static void 507static void
503store_function_docstring (Lisp_Object fun, EMACS_INT offset) 508store_function_docstring (Lisp_Object fun, ptrdiff_t offset)
504/* Use EMACS_INT because we get offset from pointer subtraction. */
505{ 509{
506 fun = indirect_function (fun); 510 fun = indirect_function (fun);
507 511
@@ -556,7 +560,7 @@ the same file name is found in the `doc-directory'. */)
556{ 560{
557 int fd; 561 int fd;
558 char buf[1024 + 1]; 562 char buf[1024 + 1];
559 register EMACS_INT filled; 563 register int filled;
560 register EMACS_INT pos; 564 register EMACS_INT pos;
561 register char *p; 565 register char *p;
562 Lisp_Object sym; 566 Lisp_Object sym;
@@ -591,7 +595,7 @@ the same file name is found in the `doc-directory'. */)
591 595
592 for (beg = buildobj; *beg; beg = end) 596 for (beg = buildobj; *beg; beg = end)
593 { 597 {
594 EMACS_INT len; 598 ptrdiff_t len;
595 599
596 while (*beg && isspace (*beg)) ++beg; 600 while (*beg && isspace (*beg)) ++beg;
597 601
@@ -639,7 +643,7 @@ the same file name is found in the `doc-directory'. */)
639 if (end - p > 4 && end[-2] == '.' 643 if (end - p > 4 && end[-2] == '.'
640 && (end[-1] == 'o' || end[-1] == 'c')) 644 && (end[-1] == 'o' || end[-1] == 'c'))
641 { 645 {
642 EMACS_INT len = end - p - 2; 646 ptrdiff_t len = end - p - 2;
643 char *fromfile = alloca (len + 1); 647 char *fromfile = alloca (len + 1);
644 strncpy (fromfile, &p[2], len); 648 strncpy (fromfile, &p[2], len);
645 fromfile[len] = 0; 649 fromfile[len] = 0;