Mercurial > emacs
comparison src/doc.c @ 9133:48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
store_function_docstring, Fsnarf_documentation): Use type test macros.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 27 Sep 1994 03:06:52 +0000 |
parents | e3c272c7f4d2 |
children | 1fbc46670cb0 |
comparison
equal
deleted
inserted
replaced
9132:b2ca75d3a5cb | 9133:48820d57a24c |
---|---|
77 register char *p, *p1; | 77 register char *p, *p1; |
78 register int count; | 78 register int count; |
79 int minsize; | 79 int minsize; |
80 extern char *index (); | 80 extern char *index (); |
81 | 81 |
82 if (XTYPE (Vdoc_directory) != Lisp_String | 82 if (!STRINGP (Vdoc_directory) || !STRINGP (Vdoc_file_name)) |
83 || XTYPE (Vdoc_file_name) != Lisp_String) | |
84 return Qnil; | 83 return Qnil; |
85 | 84 |
86 minsize = XSTRING (Vdoc_directory)->size; | 85 minsize = XSTRING (Vdoc_directory)->size; |
87 /* sizeof ("../etc/") == 8 */ | 86 /* sizeof ("../etc/") == 8 */ |
88 if (minsize < 8) | 87 if (minsize < 8) |
163 | 162 |
164 case Lisp_Compiled: | 163 case Lisp_Compiled: |
165 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING) | 164 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING) |
166 return Qnil; | 165 return Qnil; |
167 tem = XVECTOR (fun)->contents[COMPILED_DOC_STRING]; | 166 tem = XVECTOR (fun)->contents[COMPILED_DOC_STRING]; |
168 if (XTYPE (tem) == Lisp_String) | 167 if (STRINGP (tem)) |
169 doc = tem; | 168 doc = tem; |
170 else if (XTYPE (tem) == Lisp_Int && XINT (tem) >= 0) | 169 else if (INTEGERP (tem) && XINT (tem) >= 0) |
171 doc = get_doc_string (XFASTINT (tem)); | 170 doc = get_doc_string (XFASTINT (tem)); |
172 else | 171 else |
173 return Qnil; | 172 return Qnil; |
174 break; | 173 break; |
175 | 174 |
177 case Lisp_Vector: | 176 case Lisp_Vector: |
178 return build_string ("Keyboard macro."); | 177 return build_string ("Keyboard macro."); |
179 | 178 |
180 case Lisp_Cons: | 179 case Lisp_Cons: |
181 funcar = Fcar (fun); | 180 funcar = Fcar (fun); |
182 if (XTYPE (funcar) != Lisp_Symbol) | 181 if (!SYMBOLP (funcar)) |
183 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 182 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
184 else if (EQ (funcar, Qkeymap)) | 183 else if (EQ (funcar, Qkeymap)) |
185 return build_string ("Prefix command (definition is a keymap associating keystrokes with\n\ | 184 return build_string ("Prefix command (definition is a keymap associating keystrokes with\n\ |
186 subcommands.)"); | 185 subcommands.)"); |
187 else if (EQ (funcar, Qlambda) | 186 else if (EQ (funcar, Qlambda) |
188 || EQ (funcar, Qautoload)) | 187 || EQ (funcar, Qautoload)) |
189 { | 188 { |
190 tem = Fcar (Fcdr (Fcdr (fun))); | 189 tem = Fcar (Fcdr (Fcdr (fun))); |
191 if (XTYPE (tem) == Lisp_String) | 190 if (STRINGP (tem)) |
192 doc = tem; | 191 doc = tem; |
193 else if (XTYPE (tem) == Lisp_Int && XINT (tem) >= 0) | 192 else if (INTEGERP (tem) && XINT (tem) >= 0) |
194 doc = get_doc_string (XFASTINT (tem)); | 193 doc = get_doc_string (XFASTINT (tem)); |
195 else | 194 else |
196 return Qnil; | 195 return Qnil; |
197 | 196 |
198 break; | 197 break; |
229 Lisp_Object sym, prop, raw; | 228 Lisp_Object sym, prop, raw; |
230 { | 229 { |
231 register Lisp_Object tem; | 230 register Lisp_Object tem; |
232 | 231 |
233 tem = Fget (sym, prop); | 232 tem = Fget (sym, prop); |
234 if (XTYPE (tem) == Lisp_Int) | 233 if (INTEGERP (tem)) |
235 tem = get_doc_string (XINT (tem) > 0 ? XINT (tem) : - XINT (tem)); | 234 tem = get_doc_string (XINT (tem) > 0 ? XINT (tem) : - XINT (tem)); |
236 if (NILP (raw) && XTYPE (tem) == Lisp_String) | 235 if (NILP (raw) && STRINGP (tem)) |
237 return Fsubstitute_command_keys (tem); | 236 return Fsubstitute_command_keys (tem); |
238 return tem; | 237 return tem; |
239 } | 238 } |
240 | 239 |
241 /* Scanning the DOC files and placing docstring offsets into functions. */ | 240 /* Scanning the DOC files and placing docstring offsets into functions. */ |
248 fun = indirect_function (fun); | 247 fun = indirect_function (fun); |
249 | 248 |
250 /* The type determines where the docstring is stored. */ | 249 /* The type determines where the docstring is stored. */ |
251 | 250 |
252 /* Lisp_Subrs have a slot for it. */ | 251 /* Lisp_Subrs have a slot for it. */ |
253 if (XTYPE (fun) == Lisp_Subr) | 252 if (SUBRP (fun)) |
254 XSUBR (fun)->doc = (char *) - offset; | 253 XSUBR (fun)->doc = (char *) - offset; |
255 | 254 |
256 /* If it's a lisp form, stick it in the form. */ | 255 /* If it's a lisp form, stick it in the form. */ |
257 else if (CONSP (fun)) | 256 else if (CONSP (fun)) |
258 { | 257 { |
260 | 259 |
261 tem = XCONS (fun)->car; | 260 tem = XCONS (fun)->car; |
262 if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) | 261 if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) |
263 { | 262 { |
264 tem = Fcdr (Fcdr (fun)); | 263 tem = Fcdr (Fcdr (fun)); |
265 if (CONSP (tem) && | 264 if (CONSP (tem) && INTEGERP (XCONS (tem)->car)) |
266 XTYPE (XCONS (tem)->car) == Lisp_Int) | |
267 XFASTINT (XCONS (tem)->car) = offset; | 265 XFASTINT (XCONS (tem)->car) = offset; |
268 } | 266 } |
269 else if (EQ (tem, Qmacro)) | 267 else if (EQ (tem, Qmacro)) |
270 store_function_docstring (XCONS (fun)->cdr, offset); | 268 store_function_docstring (XCONS (fun)->cdr, offset); |
271 } | 269 } |
272 | 270 |
273 /* Bytecode objects sometimes have slots for it. */ | 271 /* Bytecode objects sometimes have slots for it. */ |
274 else if (XTYPE (fun) == Lisp_Compiled) | 272 else if (COMPILEDP (fun)) |
275 { | 273 { |
276 /* This bytecode object must have a slot for the | 274 /* This bytecode object must have a slot for the |
277 docstring, since we've found a docstring for it. */ | 275 docstring, since we've found a docstring for it. */ |
278 if (XVECTOR (fun)->size > COMPILED_DOC_STRING) | 276 if (XVECTOR (fun)->size > COMPILED_DOC_STRING) |
279 XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) = offset; | 277 XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) = offset; |
356 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ | 354 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ |
357 if (p != end) | 355 if (p != end) |
358 { | 356 { |
359 end = index (p, '\n'); | 357 end = index (p, '\n'); |
360 sym = oblookup (Vobarray, p + 2, end - p - 2); | 358 sym = oblookup (Vobarray, p + 2, end - p - 2); |
361 if (XTYPE (sym) == Lisp_Symbol) | 359 if (SYMBOLP (sym)) |
362 { | 360 { |
363 /* Attach a docstring to a variable? */ | 361 /* Attach a docstring to a variable? */ |
364 if (p[1] == 'V') | 362 if (p[1] == 'V') |
365 { | 363 { |
366 /* Install file-position as variable-documentation property | 364 /* Install file-position as variable-documentation property |