diff options
| author | Joakim Verona | 2012-05-30 14:08:12 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-05-30 14:08:12 +0200 |
| commit | 70700d8c47a35b19e29607ac5f0ed322bdd78249 (patch) | |
| tree | 4fa00d3fac00025354f0b6e23dcda1b58689a094 /src/doc.c | |
| parent | 44fce8ffe7198991c41c985ff4e67ec7d407907e (diff) | |
| parent | 72cb32cf2f0938dd7dc733eed77b1ed1e497b053 (diff) | |
| download | emacs-70700d8c47a35b19e29607ac5f0ed322bdd78249.tar.gz emacs-70700d8c47a35b19e29607ac5f0ed322bdd78249.zip | |
upstream
Diffstat (limited to 'src/doc.c')
| -rw-r--r-- | src/doc.c | 24 |
1 files changed, 14 insertions, 10 deletions
| @@ -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 | { |
| @@ -124,7 +126,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition) | |||
| 124 | /* sizeof ("../etc/") == 8 */ | 126 | /* sizeof ("../etc/") == 8 */ |
| 125 | if (minsize < 8) | 127 | if (minsize < 8) |
| 126 | minsize = 8; | 128 | minsize = 8; |
| 127 | name = (char *) alloca (minsize + SCHARS (file) + 8); | 129 | SAFE_ALLOCA (name, char *, minsize + SCHARS (file) + 8); |
| 128 | strcpy (name, SSDATA (docdir)); | 130 | strcpy (name, SSDATA (docdir)); |
| 129 | strcat (name, SSDATA (file)); | 131 | strcat (name, SSDATA (file)); |
| 130 | } | 132 | } |
| @@ -155,13 +157,16 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition) | |||
| 155 | /* Make sure we read at least 1024 bytes before `position' | 157 | /* Make sure we read at least 1024 bytes before `position' |
| 156 | so we can check the leading text for consistency. */ | 158 | so we can check the leading text for consistency. */ |
| 157 | offset = min (position, max (1024, position % (8 * 1024))); | 159 | offset = min (position, max (1024, position % (8 * 1024))); |
| 158 | if (0 > lseek (fd, position - offset, 0)) | 160 | if (TYPE_MAXIMUM (off_t) < position |
| 161 | || lseek (fd, position - offset, 0) < 0) | ||
| 159 | { | 162 | { |
| 160 | emacs_close (fd); | 163 | emacs_close (fd); |
| 161 | error ("Position %"pI"d out of range in doc string file \"%s\"", | 164 | error ("Position %"pI"d out of range in doc string file \"%s\"", |
| 162 | position, name); | 165 | position, name); |
| 163 | } | 166 | } |
| 164 | 167 | ||
| 168 | SAFE_FREE (); | ||
| 169 | |||
| 165 | /* Read the doc string into get_doc_string_buffer. | 170 | /* Read the doc string into get_doc_string_buffer. |
| 166 | P points beyond the data just read. */ | 171 | P points beyond the data just read. */ |
| 167 | 172 | ||
| @@ -279,7 +284,7 @@ Invalid data in documentation file -- %c followed by code %03o", | |||
| 279 | else | 284 | else |
| 280 | { | 285 | { |
| 281 | /* The data determines whether the string is multibyte. */ | 286 | /* The data determines whether the string is multibyte. */ |
| 282 | EMACS_INT nchars = | 287 | ptrdiff_t nchars = |
| 283 | multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer | 288 | multibyte_chars_in_text (((unsigned char *) get_doc_string_buffer |
| 284 | + offset), | 289 | + offset), |
| 285 | to - (get_doc_string_buffer + offset)); | 290 | to - (get_doc_string_buffer + offset)); |
| @@ -502,8 +507,7 @@ aren't strings. */) | |||
| 502 | /* Scanning the DOC files and placing docstring offsets into functions. */ | 507 | /* Scanning the DOC files and placing docstring offsets into functions. */ |
| 503 | 508 | ||
| 504 | static void | 509 | static void |
| 505 | store_function_docstring (Lisp_Object obj, EMACS_INT offset) | 510 | store_function_docstring (Lisp_Object obj, ptrdiff_t offset) |
| 506 | /* Use EMACS_INT because we get offset from pointer subtraction. */ | ||
| 507 | { | 511 | { |
| 508 | /* Don't use indirect_function here, or defaliases will apply their | 512 | /* Don't use indirect_function here, or defaliases will apply their |
| 509 | docstrings to the base functions (Bug#2603). */ | 513 | docstrings to the base functions (Bug#2603). */ |
| @@ -560,7 +564,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 560 | { | 564 | { |
| 561 | int fd; | 565 | int fd; |
| 562 | char buf[1024 + 1]; | 566 | char buf[1024 + 1]; |
| 563 | register EMACS_INT filled; | 567 | register int filled; |
| 564 | register EMACS_INT pos; | 568 | register EMACS_INT pos; |
| 565 | register char *p; | 569 | register char *p; |
| 566 | Lisp_Object sym; | 570 | Lisp_Object sym; |
| @@ -595,7 +599,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 595 | 599 | ||
| 596 | for (beg = buildobj; *beg; beg = end) | 600 | for (beg = buildobj; *beg; beg = end) |
| 597 | { | 601 | { |
| 598 | EMACS_INT len; | 602 | ptrdiff_t len; |
| 599 | 603 | ||
| 600 | while (*beg && isspace (*beg)) ++beg; | 604 | while (*beg && isspace (*beg)) ++beg; |
| 601 | 605 | ||
| @@ -643,7 +647,7 @@ the same file name is found in the `doc-directory'. */) | |||
| 643 | if (end - p > 4 && end[-2] == '.' | 647 | if (end - p > 4 && end[-2] == '.' |
| 644 | && (end[-1] == 'o' || end[-1] == 'c')) | 648 | && (end[-1] == 'o' || end[-1] == 'c')) |
| 645 | { | 649 | { |
| 646 | EMACS_INT len = end - p - 2; | 650 | ptrdiff_t len = end - p - 2; |
| 647 | char *fromfile = alloca (len + 1); | 651 | char *fromfile = alloca (len + 1); |
| 648 | strncpy (fromfile, &p[2], len); | 652 | strncpy (fromfile, &p[2], len); |
| 649 | fromfile[len] = 0; | 653 | fromfile[len] = 0; |