aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.c
diff options
context:
space:
mode:
authorK. Handa2014-12-28 22:18:39 +0900
committerK. Handa2014-12-28 22:18:39 +0900
commitc2f9c07aa02d1c8cba4efdd503463642a910cd6b (patch)
tree8e25338f25fe6d71a72cddff77f4c368192379ef /src/doc.c
parent5979af512bf5d6a28acea24299b67c7939d9e703 (diff)
parente092accb6bb8aea08dab1796d707b3adce55a38c (diff)
downloademacs-c2f9c07aa02d1c8cba4efdd503463642a910cd6b.tar.gz
emacs-c2f9c07aa02d1c8cba4efdd503463642a910cd6b.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src/doc.c')
-rw-r--r--src/doc.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/doc.c b/src/doc.c
index 1b87c23e949..1d9c330d12c 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -42,6 +42,8 @@ static ptrdiff_t get_doc_string_buffer_size;
42 42
43static unsigned char *read_bytecode_pointer; 43static unsigned char *read_bytecode_pointer;
44 44
45static char const sibling_etc[] = "../etc/";
46
45/* `readchar' in lread.c calls back here to fetch the next byte. 47/* `readchar' in lread.c calls back here to fetch the next byte.
46 If UNREADFLAG is 1, we unread a byte. */ 48 If UNREADFLAG is 1, we unread a byte. */
47 49
@@ -80,7 +82,6 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
80{ 82{
81 char *from, *to, *name, *p, *p1; 83 char *from, *to, *name, *p, *p1;
82 int fd; 84 int fd;
83 ptrdiff_t minsize;
84 int offset; 85 int offset;
85 EMACS_INT position; 86 EMACS_INT position;
86 Lisp_Object file, tem, pos; 87 Lisp_Object file, tem, pos;
@@ -113,21 +114,14 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
113 114
114 tem = Ffile_name_absolute_p (file); 115 tem = Ffile_name_absolute_p (file);
115 file = ENCODE_FILE (file); 116 file = ENCODE_FILE (file);
116 if (NILP (tem)) 117 Lisp_Object docdir
117 { 118 = NILP (tem) ? ENCODE_FILE (Vdoc_directory) : empty_unibyte_string;
118 Lisp_Object docdir = ENCODE_FILE (Vdoc_directory); 119 ptrdiff_t docdir_sizemax = SBYTES (docdir) + 1;
119 minsize = SCHARS (docdir); 120#ifndef CANNOT_DUMP
120 /* sizeof ("../etc/") == 8 */ 121 docdir_sizemax = max (docdir_sizemax, sizeof sibling_etc);
121 if (minsize < 8) 122#endif
122 minsize = 8; 123 name = SAFE_ALLOCA (docdir_sizemax + SBYTES (file));
123 name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); 124 lispstpcpy (lispstpcpy (name, docdir), file);
124 char *z = lispstpcpy (name, docdir);
125 strcpy (z, SSDATA (file));
126 }
127 else
128 {
129 name = SSDATA (file);
130 }
131 125
132 fd = emacs_open (name, O_RDONLY, 0); 126 fd = emacs_open (name, O_RDONLY, 0);
133 if (fd < 0) 127 if (fd < 0)
@@ -137,8 +131,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
137 { 131 {
138 /* Preparing to dump; DOC file is probably not installed. 132 /* Preparing to dump; DOC file is probably not installed.
139 So check in ../etc. */ 133 So check in ../etc. */
140 strcpy (name, "../etc/"); 134 lispstpcpy (stpcpy (name, sibling_etc), file);
141 strcat (name, SSDATA (file));
142 135
143 fd = emacs_open (name, O_RDONLY, 0); 136 fd = emacs_open (name, O_RDONLY, 0);
144 } 137 }
@@ -580,7 +573,6 @@ the same file name is found in the `doc-directory'. */)
580 (0) 573 (0)
581#endif /* CANNOT_DUMP */ 574#endif /* CANNOT_DUMP */
582 { 575 {
583 static char const sibling_etc[] = "../etc/";
584 dirname = sibling_etc; 576 dirname = sibling_etc;
585 dirlen = sizeof sibling_etc - 1; 577 dirlen = sizeof sibling_etc - 1;
586 } 578 }
@@ -594,8 +586,7 @@ the same file name is found in the `doc-directory'. */)
594 count = SPECPDL_INDEX (); 586 count = SPECPDL_INDEX ();
595 USE_SAFE_ALLOCA; 587 USE_SAFE_ALLOCA;
596 name = SAFE_ALLOCA (dirlen + SBYTES (filename) + 1); 588 name = SAFE_ALLOCA (dirlen + SBYTES (filename) + 1);
597 strcpy (name, dirname); 589 lispstpcpy (stpcpy (name, dirname), filename); /*** Add this line ***/
598 strcat (name, SSDATA (filename)); /*** Add this line ***/
599 590
600 /* Vbuild_files is nil when temacs is run, and non-nil after that. */ 591 /* Vbuild_files is nil when temacs is run, and non-nil after that. */
601 if (NILP (Vbuild_files)) 592 if (NILP (Vbuild_files))