annotate src/doc.c @ 4952:19a72041c5ed

Mule-izing, various fixes related to char * arguments -------------------- ChangeLog entries follow: -------------------- modules/ChangeLog addition: 2010-01-26 Ben Wing <ben@xemacs.org> * postgresql/postgresql.c: * postgresql/postgresql.c (CHECK_LIVE_CONNECTION): * postgresql/postgresql.c (print_pgresult): * postgresql/postgresql.c (Fpq_conn_defaults): * postgresql/postgresql.c (Fpq_connectdb): * postgresql/postgresql.c (Fpq_connect_start): * postgresql/postgresql.c (Fpq_result_status): * postgresql/postgresql.c (Fpq_res_status): Mule-ize large parts of it. 2010-01-26 Ben Wing <ben@xemacs.org> * ldap/eldap.c (print_ldap): * ldap/eldap.c (allocate_ldap): Use write_ascstring(). src/ChangeLog addition: 2010-01-26 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (build_ascstring): * alloc.c (build_msg_cistring): * alloc.c (staticpro_1): * alloc.c (staticpro_name): * alloc.c (staticpro_nodump_1): * alloc.c (staticpro_nodump_name): * alloc.c (unstaticpro_nodump_1): * alloc.c (mcpro_1): * alloc.c (mcpro_name): * alloc.c (object_memory_usage_stats): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_once_early): * buffer.c (print_buffer): * buffer.c (vars_of_buffer): * buffer.c (common_init_complex_vars_of_buffer): * buffer.c (init_initial_directory): * bytecode.c (invalid_byte_code): * bytecode.c (print_compiled_function): * bytecode.c (mark_compiled_function): * chartab.c (print_table_entry): * chartab.c (print_char_table): * config.h.in: * console-gtk.c: * console-gtk.c (gtk_device_to_console_connection): * console-gtk.c (gtk_semi_canonicalize_console_connection): * console-gtk.c (gtk_canonicalize_console_connection): * console-gtk.c (gtk_semi_canonicalize_device_connection): * console-gtk.c (gtk_canonicalize_device_connection): * console-stream.c (stream_init_frame_1): * console-stream.c (vars_of_console_stream): * console-stream.c (init_console_stream): * console-x.c (x_semi_canonicalize_console_connection): * console-x.c (x_semi_canonicalize_device_connection): * console-x.c (x_canonicalize_device_connection): * console-x.h: * data.c (eq_with_ebola_notice): * data.c (Fsubr_interactive): * data.c (Fnumber_to_string): * data.c (digit_to_number): * device-gtk.c (gtk_init_device): * device-msw.c (print_devmode): * device-x.c (x_event_name): * dialog-msw.c (handle_directory_dialog_box): * dialog-msw.c (handle_file_dialog_box): * dialog-msw.c (vars_of_dialog_mswindows): * doc.c (weird_doc): * doc.c (Fsnarf_documentation): * doc.c (vars_of_doc): * dumper.c (pdump): * dynarr.c: * dynarr.c (Dynarr_realloc): * editfns.c (Fuser_real_login_name): * editfns.c (get_home_directory): * elhash.c (print_hash_table_data): * elhash.c (print_hash_table): * emacs.c (main_1): * emacs.c (vars_of_emacs): * emodules.c: * emodules.c (_emodules_list): * emodules.c (Fload_module): * emodules.c (Funload_module): * emodules.c (Flist_modules): * emodules.c (find_make_module): * emodules.c (attempt_module_delete): * emodules.c (emodules_load): * emodules.c (emodules_doc_subr): * emodules.c (emodules_doc_sym): * emodules.c (syms_of_module): * emodules.c (vars_of_module): * emodules.h: * eval.c (print_subr): * eval.c (signal_call_debugger): * eval.c (build_error_data): * eval.c (signal_error): * eval.c (maybe_signal_error): * eval.c (signal_continuable_error): * eval.c (maybe_signal_continuable_error): * eval.c (signal_error_2): * eval.c (maybe_signal_error_2): * eval.c (signal_continuable_error_2): * eval.c (maybe_signal_continuable_error_2): * eval.c (signal_ferror): * eval.c (maybe_signal_ferror): * eval.c (signal_continuable_ferror): * eval.c (maybe_signal_continuable_ferror): * eval.c (signal_ferror_with_frob): * eval.c (maybe_signal_ferror_with_frob): * eval.c (signal_continuable_ferror_with_frob): * eval.c (maybe_signal_continuable_ferror_with_frob): * eval.c (syntax_error): * eval.c (syntax_error_2): * eval.c (maybe_syntax_error): * eval.c (sferror): * eval.c (sferror_2): * eval.c (maybe_sferror): * eval.c (invalid_argument): * eval.c (invalid_argument_2): * eval.c (maybe_invalid_argument): * eval.c (invalid_constant): * eval.c (invalid_constant_2): * eval.c (maybe_invalid_constant): * eval.c (invalid_operation): * eval.c (invalid_operation_2): * eval.c (maybe_invalid_operation): * eval.c (invalid_change): * eval.c (invalid_change_2): * eval.c (maybe_invalid_change): * eval.c (invalid_state): * eval.c (invalid_state_2): * eval.c (maybe_invalid_state): * eval.c (wtaerror): * eval.c (stack_overflow): * eval.c (out_of_memory): * eval.c (print_multiple_value): * eval.c (issue_call_trapping_problems_warning): * eval.c (backtrace_specials): * eval.c (backtrace_unevalled_args): * eval.c (Fbacktrace): * eval.c (warn_when_safe): * event-Xt.c (modwarn): * event-Xt.c (modbarf): * event-Xt.c (check_modifier): * event-Xt.c (store_modifier): * event-Xt.c (emacs_Xt_format_magic_event): * event-Xt.c (describe_event): * event-gtk.c (dragndrop_data_received): * event-gtk.c (store_modifier): * event-gtk.c (gtk_reset_modifier_mapping): * event-msw.c (dde_eval_string): * event-msw.c (Fdde_alloc_advise_item): * event-msw.c (mswindows_dde_callback): * event-msw.c (FROB): * event-msw.c (emacs_mswindows_format_magic_event): * event-stream.c (external_debugging_print_event): * event-stream.c (execute_help_form): * event-stream.c (vars_of_event_stream): * events.c (print_event_1): * events.c (print_event): * events.c (event_equal): * extents.c (print_extent_1): * extents.c (print_extent): * extents.c (vars_of_extents): * faces.c (print_face): * faces.c (complex_vars_of_faces): * file-coding.c: * file-coding.c (print_coding_system): * file-coding.c (print_coding_system_in_print_method): * file-coding.c (default_query_method): * file-coding.c (find_coding_system): * file-coding.c (make_coding_system_1): * file-coding.c (chain_print): * file-coding.c (undecided_print): * file-coding.c (gzip_print): * file-coding.c (vars_of_file_coding): * file-coding.c (complex_vars_of_file_coding): * fileio.c: * fileio.c (report_file_type_error): * fileio.c (report_error_with_errno): * fileio.c (report_file_error): * fileio.c (barf_or_query_if_file_exists): * fileio.c (vars_of_fileio): * floatfns.c (matherr): * fns.c (print_bit_vector): * fns.c (Fmapconcat): * fns.c (add_suffix_to_symbol): * fns.c (add_prefix_to_symbol): * frame-gtk.c: * frame-gtk.c (Fgtk_window_id): * frame-x.c (def): * frame-x.c (x_cde_transfer_callback): * frame.c: * frame.c (Fmake_frame): * gc.c (show_gc_cursor_and_message): * gc.c (vars_of_gc): * glyphs-eimage.c (png_instantiate): * glyphs-eimage.c (tiff_instantiate): * glyphs-gtk.c (gtk_print_image_instance): * glyphs-msw.c (mswindows_print_image_instance): * glyphs-x.c (x_print_image_instance): * glyphs-x.c (update_widget_face): * glyphs.c (make_string_from_file): * glyphs.c (print_image_instance): * glyphs.c (signal_image_error): * glyphs.c (signal_image_error_2): * glyphs.c (signal_double_image_error): * glyphs.c (signal_double_image_error_2): * glyphs.c (xbm_mask_file_munging): * glyphs.c (pixmap_to_lisp_data): * glyphs.h: * gui.c (gui_item_display_flush_left): * hpplay.c (player_error_internal): * hpplay.c (myHandler): * intl-win32.c: * intl-win32.c (langcode_to_lang): * intl-win32.c (sublangcode_to_lang): * intl-win32.c (Fmswindows_get_locale_info): * intl-win32.c (lcid_to_locale_mule_or_no): * intl-win32.c (mswindows_multibyte_to_unicode_print): * intl-win32.c (complex_vars_of_intl_win32): * keymap.c: * keymap.c (print_keymap): * keymap.c (ensure_meta_prefix_char_keymapp): * keymap.c (Fkey_description): * keymap.c (Ftext_char_description): * lisp.h: * lisp.h (struct): * lisp.h (DECLARE_INLINE_HEADER): * lread.c (Fload_internal): * lread.c (locate_file): * lread.c (read_escape): * lread.c (read_raw_string): * lread.c (read1): * lread.c (read_list): * lread.c (read_compiled_function): * lread.c (init_lread): * lrecord.h: * marker.c (print_marker): * marker.c (marker_equal): * menubar-msw.c (displayable_menu_item): * menubar-x.c (command_builder_operate_menu_accelerator): * menubar.c (vars_of_menubar): * minibuf.c (reinit_complex_vars_of_minibuf): * minibuf.c (complex_vars_of_minibuf): * mule-charset.c (Fmake_charset): * mule-charset.c (complex_vars_of_mule_charset): * mule-coding.c (iso2022_print): * mule-coding.c (fixed_width_query): * number.c (bignum_print): * number.c (ratio_print): * number.c (bigfloat_print): * number.c (bigfloat_finalize): * objects-msw.c: * objects-msw.c (mswindows_color_to_string): * objects-msw.c (mswindows_color_list): * objects-tty.c: * objects-tty.c (tty_font_list): * objects-tty.c (tty_find_charset_font): * objects-xlike-inc.c (xft_find_charset_font): * objects-xlike-inc.c (endif): * print.c: * print.c (write_istring): * print.c (write_ascstring): * print.c (Fterpri): * print.c (Fprint): * print.c (print_error_message): * print.c (print_vector_internal): * print.c (print_cons): * print.c (print_string): * print.c (printing_unreadable_object): * print.c (print_internal): * print.c (print_float): * print.c (print_symbol): * process-nt.c (mswindows_report_winsock_error): * process-nt.c (nt_canonicalize_host_name): * process-unix.c (unix_canonicalize_host_name): * process.c (print_process): * process.c (report_process_error): * process.c (report_network_error): * process.c (make_process_internal): * process.c (Fstart_process_internal): * process.c (status_message): * process.c (putenv_internal): * process.c (vars_of_process): * process.h: * profile.c (vars_of_profile): * rangetab.c (print_range_table): * realpath.c (vars_of_realpath): * redisplay.c (vars_of_redisplay): * search.c (wordify): * search.c (Freplace_match): * sheap.c (sheap_adjust_h): * sound.c (report_sound_error): * sound.c (Fplay_sound_file): * specifier.c (print_specifier): * symbols.c (Fsubr_name): * symbols.c (do_symval_forwarding): * symbols.c (set_default_buffer_slot_variable): * symbols.c (set_default_console_slot_variable): * symbols.c (store_symval_forwarding): * symbols.c (default_value): * symbols.c (defsymbol_massage_name_1): * symbols.c (defsymbol_massage_name_nodump): * symbols.c (defsymbol_massage_name): * symbols.c (defsymbol_massage_multiword_predicate_nodump): * symbols.c (defsymbol_massage_multiword_predicate): * symbols.c (defsymbol_nodump): * symbols.c (defsymbol): * symbols.c (defkeyword): * symbols.c (defkeyword_massage_name): * symbols.c (check_module_subr): * symbols.c (deferror_1): * symbols.c (deferror): * symbols.c (deferror_massage_name): * symbols.c (deferror_massage_name_and_message): * symbols.c (defvar_magic): * symeval.h: * symeval.h (DEFVAR_SYMVAL_FWD): * sysdep.c: * sysdep.c (init_system_name): * sysdll.c: * sysdll.c (MAYBE_PREPEND_UNDERSCORE): * sysdll.c (dll_function): * sysdll.c (dll_variable): * sysdll.c (dll_error): * sysdll.c (dll_open): * sysdll.c (dll_close): * sysdll.c (image_for_address): * sysdll.c (my_find_image): * sysdll.c (search_linked_libs): * sysdll.h: * sysfile.h: * sysfile.h (DEFAULT_DIRECTORY_FALLBACK): * syswindows.h: * tests.c (DFC_CHECK_LENGTH): * tests.c (DFC_CHECK_CONTENT): * tests.c (Ftest_hash_tables): * text.c (vars_of_text): * text.h: * tooltalk.c (tt_opnum_string): * tooltalk.c (tt_message_arg_ival_string): * tooltalk.c (Ftooltalk_default_procid): * tooltalk.c (Ftooltalk_default_session): * tooltalk.c (init_tooltalk): * tooltalk.c (vars_of_tooltalk): * ui-gtk.c (Fdll_load): * ui-gtk.c (type_to_marshaller_type): * ui-gtk.c (Fgtk_import_function_internal): * ui-gtk.c (emacs_gtk_object_printer): * ui-gtk.c (emacs_gtk_boxed_printer): * unicode.c (unicode_to_ichar): * unicode.c (unicode_print): * unicode.c (unicode_query): * unicode.c (vars_of_unicode): * unicode.c (complex_vars_of_unicode): * win32.c: * win32.c (mswindows_report_process_error): * window.c (print_window): * xemacs.def.in.in: BASIC IDEA: Further fixing up uses of char * and CIbyte * to reflect their actual semantics; Mule-izing some code; redoing of the not-yet-working code to handle message translation. Clean up code to handle message-translation (not yet working). Create separate versions of build_msg_string() for working with Ibyte *, CIbyte *, and Ascbyte * arguments. Assert that Ascbyte * arguments are pure-ASCII. Make build_msg_string() be the same as build_msg_ascstring(). Create same three versions of GETTEXT() and DEFER_GETTEXT(). Also create build_defer_string() and variants for the equivalent of DEFER_GETTEXT() when building a string. Remove old CGETTEXT(). Clean up code where GETTEXT(), DEFER_GETTEXT(), build_msg_string(), etc. was being called and introduce some new calls to build_msg_string(), etc. Remove GETTEXT() from calls to weird_doc() -- we assume that the message snarfer knows about weird_doc(). Remove uses of DEFER_GETTEXT() from error messages in sysdep.c and instead use special comments /* @@@begin-snarf@@@ */ and /* @@@end-snarf@@@ */ that the message snarfer presumably knows about. Create build_ascstring() and use it in many instances in place of build_string(). The purpose of having Ascbyte * variants is to make the code more self-documenting in terms of what sort of semantics is expected for char * strings. In fact in the process of looking for uses of build_string(), much improperly Mule-ized was discovered. Mule-ize a lot of code as described in previous paragraph, e.g. in sysdep.c. Make the error functions take Ascbyte * strings and fix up a couple of places where non-pure-ASCII strings were being passed in (file-coding.c, mule-coding.c, unicode.c). (It's debatable whether we really need to make the error functions work this way. It helps catch places where code is written in a way that message translation won't work, but we may well never implement message translation.) Make staticpro() and friends take Ascbyte * strings instead of raw char * strings. Create a const_Ascbyte_ptr dynarr type to describe what's held by staticpro_names[] and friends, create pdump descriptions for const_Ascbyte_ptr dynarrs, and use them in place of specially-crafted staticpro descriptions. Mule-ize certain other functions (e.g. x_event_name) by correcting raw use of char * to Ascbyte *, Rawbyte * or another such type, and raw use of char[] buffers to another type (usually Ascbyte[]). Change many uses of write_c_string() to write_msg_string(), write_ascstring(), etc. Mule-ize emodules.c, emodules.h, sysdll.h. Fix some un-Mule-ized code in intl-win32.c. A comment in event-Xt.c and the limitations of the message snarfer (make-msgfile or whatever) is presumably incorrect -- it should be smart enough to handle function calls spread over more than one line. Clean up code in event-Xt.c that was written awkwardly for this reason. In config.h.in, instead of NEED_ERROR_CHECK_TYPES_INLINES, create a more general XEMACS_DEFS_NEEDS_INLINE_DECLS to indicate when inlined functions need to be declared in xemacs.defs.in.in, and make use of it in xemacs.defs.in.in. We need to do this because postgresql.c now calls qxestrdup(), which is an inline function. Make nconc2() and other such functions MODULE_API and put them in xemacs.defs.in.in since postgresql.c now uses them. Clean up indentation in lread.c and a few other places. In text.h, document ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN(), group together the stand-in encodings and add some more for DLL symbols, function and variable names, etc.
author Ben Wing <ben@xemacs.org>
date Tue, 26 Jan 2010 23:22:30 -0600
parents 061e030e3270
children 304aebb79cd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Record indices of function doc strings stored in a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Free Software Foundation, Inc.
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
4 Copyright (C) 2001, 2002, 2004 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
25 /* This file has been Mule-ized. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "bytecode.h"
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
32 #include "file-coding.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "keymap.h"
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
35 #include "lstream.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "sysfile.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 Lisp_Object Vinternal_doc_file_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
40 Lisp_Object QSsubstitute, Qdefvar;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
42 /* Work out what source file a function or variable came from, taking the
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
43 information from the documentation file. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
44
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
45 static Lisp_Object
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
46 extract_object_file_name (int fd, EMACS_INT doc_pos,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
47 Ibyte *name_nonreloc, Lisp_Object name_reloc,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
48 int standard_doc_file)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
49 {
3383
3583b965b1c5 [xemacs-hg @ 2006-05-07 14:20:33 by stephent]
stephent
parents: 3368
diff changeset
50 Ibyte buf[DOC_MAX_FILENAME_LENGTH+1];
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
51 Ibyte *buffer = buf;
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
52 int buffer_size = sizeof (buf) - 1, space_left;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
53 Ibyte *from, *to;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
54 REGISTER Ibyte *p = buffer;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
55 Lisp_Object return_me;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
56 Lisp_Object fdstream = Qnil, instream = Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
57 struct gcpro gcpro1, gcpro2;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
58 EMACS_INT position, seenS = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
59
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
60 GCPRO2 (fdstream, instream);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
61
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
62 position = doc_pos > buffer_size ?
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
63 doc_pos - buffer_size : 0;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
64
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
65 if (0 > lseek (fd, position, 0))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
66 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
67 if (name_nonreloc)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
68 name_reloc = build_intstring (name_nonreloc);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
69 return_me = list3 (build_msg_string
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
70 ("Position out of range in doc string file"),
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
71 name_reloc, make_int (position));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
72 goto done;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
73 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
74
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
75 fdstream = make_filedesc_input_stream (fd, 0, -1, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
76 Lstream_set_buffering (XLSTREAM (fdstream), LSTREAM_UNBUFFERED, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
77 instream =
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
78 make_coding_input_stream
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
79 (XLSTREAM (fdstream), standard_doc_file ? Qescape_quoted : Qbinary,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
80 CODING_DECODE, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
81 Lstream_set_buffering (XLSTREAM (instream), LSTREAM_UNBUFFERED, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
82
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
83 space_left = buffer_size - (p - buffer);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
84 while (space_left > 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
85 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
86 int nread;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
87
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
88 nread = Lstream_read (XLSTREAM (instream), p, space_left);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
89 if (nread < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
90 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
91 return_me = list1 (build_msg_string
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
92 ("Read error on documentation file"));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
93 goto done;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
94 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
95
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
96 p[nread] = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
97
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
98 if (!nread)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
99 break;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
100
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
101 p += nread;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
102 space_left = buffer_size - (p - buffer);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
103 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
104
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
105 /* First, search backward for the "\037S" that marks the beginning of the
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
106 file name, then search forward from that to the newline or to the end
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
107 of the buffer. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
108 from = p;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
109
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
110 while (from > buf)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
111 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
112 --from;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
113 if (seenS)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
114 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
115 if ('\037' == *from)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
116 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
117 /* Got a file name; adjust `from' to point to it, break out of
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
118 the loop. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
119 from += 2;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
120 break;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
121 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
122 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
123 /* Is *from 'S' ? */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
124 seenS = ('S' == *from);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
125 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
126
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
127 if (buf == from)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
128 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
129 /* We've scanned back to the beginning of the buffer without hitting
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
130 the file name. Either the file name plus the symbol name is longer
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
131 than DOC_MAX_FILENAME_LENGTH--which shouldn't happen, because it'll
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
132 trigger an assertion failure in make-docfile, the DOC file is
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
133 corrupt, or it was produced by a version of make-docfile that
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
134 doesn't store the file name with the symbol name and docstring. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
135 return_me = list1 (build_msg_string
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
136 ("Object file name not stored in doc file"));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
137 goto done;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
138 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
139
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
140 to = from;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
141 /* Search for the end of the file name. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
142 while (++to < p)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
143 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
144 if ('\n' == *to || '\037' == *to)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
145 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
146 break;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
147 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
148 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
149
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
150 /* Don't require the file name to end in a newline. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
151 return_me = make_string (from, to - from);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
152
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
153 done:
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
154 if (!NILP (instream))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
155 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
156 Lstream_delete (XLSTREAM (instream));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
157 Lstream_delete (XLSTREAM (fdstream));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
158 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
159
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
160 UNGCPRO;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
161 return return_me;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
162 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 unparesseuxify_doc_string (int fd, EMACS_INT position,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
166 Ibyte *name_nonreloc, Lisp_Object name_reloc,
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
167 int standard_doc_file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
169 Ibyte buf[512 * 32 + 1];
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
170 Ibyte *buffer = buf;
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
171 int buffer_size = sizeof (buf) - 1;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
172 Ibyte *from, *to;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
173 REGISTER Ibyte *p = buffer;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 Lisp_Object return_me;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
175 Lisp_Object fdstream = Qnil, instream = Qnil;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
176 struct gcpro gcpro1, gcpro2;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
177
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
178 GCPRO2 (fdstream, instream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 if (0 > lseek (fd, position, 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (name_nonreloc)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
183 name_reloc = build_intstring (name_nonreloc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
184 return_me = list3 (build_msg_string
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 ("Position out of range in doc string file"),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 name_reloc, make_int (position));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
190 fdstream = make_filedesc_input_stream (fd, 0, -1, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
191 Lstream_set_buffering (XLSTREAM (fdstream), LSTREAM_UNBUFFERED, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
192 instream =
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
193 make_coding_input_stream
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
194 /* Major trouble if we are too clever when reading byte-code
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
195 instructions!
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
196
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
197 #### We should have a way of handling escape-quoted elc files
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
198 (i.e. files with non-ASCII/Latin-1 chars in them). Currently this
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
199 is "solved" in bytecomp.el by never inserting lazy references in
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
200 such files. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
201 (XLSTREAM (fdstream), standard_doc_file ? Qescape_quoted : Qbinary,
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
202 CODING_DECODE, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
203 Lstream_set_buffering (XLSTREAM (instream), LSTREAM_UNBUFFERED, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
204
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 /* Read the doc string into a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 Use the fixed buffer BUF if it is big enough; otherwise allocate one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 We store the buffer in use in BUFFER and its size in BUFFER_SIZE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 int space_left = buffer_size - (p - buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 int nread;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 /* Switch to a bigger buffer if we need one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 if (space_left == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
217 Ibyte *old_buffer = buffer;
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
218 buffer_size *= 2;
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
219
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
220 if (buffer == buf)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
221 {
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
222 buffer = xnew_ibytes (buffer_size + 1);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
223 memcpy (buffer, old_buffer, p - old_buffer);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
224 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
225 else
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
226 XREALLOC_ARRAY (buffer, Ibyte, buffer_size + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 p += buffer - old_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 space_left = buffer_size - (p - buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 /* Don't read too much at one go. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 if (space_left > 1024 * 8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 space_left = 1024 * 8;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
234 nread = Lstream_read (XLSTREAM (instream), p, space_left);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 if (nread < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
237 return_me = list1 (build_msg_string
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 ("Read error on documentation file"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 p[nread] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 if (!nread)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
245 Ibyte *p1 = qxestrchr (p, '\037'); /* End of doc string marker */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
246 if (p1)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
247 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
248 *p1 = 0;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
249 p = p1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
250 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
251 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 p += nread;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 /* Scan the text and remove quoting with ^A (char code 1).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 from = to = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 while (from < p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 if (*from != 1 /*^A*/)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 *to++ = *from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 int c = *(++from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 case 1: *to++ = c; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 case '0': *to++ = '\0'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 case '_': *to++ = '\037'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 default:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
274 return_me = list2 (build_msg_string
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 ("Invalid data in documentation file -- ^A followed by weird code"),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 make_int (c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
282 return_me = make_string (buffer, to - buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 done:
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
285 if (!NILP (instream))
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
286 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
287 Lstream_delete (XLSTREAM (instream));
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
288 Lstream_delete (XLSTREAM (fdstream));
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
289 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
290 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 if (buffer != buf) /* We must have allocated buffer above */
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1330
diff changeset
292 xfree (buffer, Ibyte *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 return return_me;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
296 #define string_join(dest, s1, s2) \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
297 memcpy (dest, XSTRING_DATA (s1), XSTRING_LENGTH (s1)); \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
298 memcpy (dest + XSTRING_LENGTH (s1), XSTRING_DATA (s2), \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
299 XSTRING_LENGTH (s2)); \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 dest[XSTRING_LENGTH (s1) + XSTRING_LENGTH (s2)] = '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 /* Extract a doc string from a file. FILEPOS says where to get it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (This could actually be byte code instructions/constants instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 of a doc string.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 If it is an integer, use that position in the standard DOC file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 If it is (FILE . INTEGER), use FILE as the file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 and INTEGER as the position in that file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 But if INTEGER is negative, make it positive.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (A negative integer is used for user variables, so we can distinguish
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 them without actually fetching the doc string.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 get_doc_string (Lisp_Object filepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 REGISTER int fd;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
316 REGISTER Ibyte *name_nonreloc = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 EMACS_INT position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 Lisp_Object file, tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 Lisp_Object name_reloc = Qnil;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
320 int standard_doc_file = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 if (INTP (filepos))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 file = Vinternal_doc_file_name;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
325 standard_doc_file = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 position = XINT (filepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 else if (CONSP (filepos) && INTP (XCDR (filepos)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 file = XCAR (filepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 position = XINT (XCDR (filepos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 if (position < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 position = - position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 if (!STRINGP (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 /* Put the file name in NAME as a C string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 If it is relative, combine it with Vdoc_directory. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 tem = Ffile_name_absolute_p (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 563
diff changeset
347 Bytecount minsize;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 /* XEmacs: Move this check here. OK if called during loadup to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 load byte code instructions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 if (!STRINGP (Vdoc_directory))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 minsize = XSTRING_LENGTH (Vdoc_directory);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 /* sizeof ("../lib-src/") == 12 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 if (minsize < 12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 minsize = 12;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
357 name_nonreloc = alloca_ibytes (minsize + XSTRING_LENGTH (file) + 8);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 string_join (name_nonreloc, Vdoc_directory, file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 name_reloc = file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
363 fd = qxe_open (name_nonreloc ? name_nonreloc :
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
364 XSTRING_DATA (name_reloc), O_RDONLY | OPEN_BINARY, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 if (fd < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 if (purify_flag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 /* sizeof ("../lib-src/") == 12 */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
370 name_nonreloc = alloca_ibytes (12 + XSTRING_LENGTH (file) + 8);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 /* Preparing to dump; DOC file is probably not installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 So check in ../lib-src. */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
373 qxestrcpy_ascii (name_nonreloc, "../lib-src/");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
374 qxestrcat (name_nonreloc, XSTRING_DATA (file));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
376 fd = qxe_open (name_nonreloc, O_RDONLY | OPEN_BINARY, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 if (fd < 0)
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
380 report_file_error ("Cannot open doc string file",
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
381 name_nonreloc ? build_intstring (name_nonreloc) :
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
382 name_reloc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
385 tem = unparesseuxify_doc_string (fd, position, name_nonreloc, name_reloc,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
386 standard_doc_file);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
387 retry_close (fd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 if (!STRINGP (tem))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
390 signal_error_1 (Qinvalid_byte_code, tem);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 return tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 /* Get a string from position FILEPOS and pass it through the Lisp reader.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 We use this for fetching the bytecode string and constants vector
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 of a compiled function from the .elc file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 read_doc_string (Lisp_Object filepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 Lisp_Object string = get_doc_string (filepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 if (!STRINGP (string))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
405 invalid_state ("loading bytecode failed to return string", string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 return Fread (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
409 static Lisp_Object
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
410 get_object_file_name (Lisp_Object filepos)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
411 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
412 REGISTER int fd;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
413 REGISTER Ibyte *name_nonreloc = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
414 EMACS_INT position;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
415 Lisp_Object file, tem;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
416 Lisp_Object name_reloc = Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
417 int standard_doc_file = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
418
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
419 if (INTP (filepos))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
420 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
421 file = Vinternal_doc_file_name;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
422 standard_doc_file = 1;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
423 position = XINT (filepos);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
424 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
425 else if (CONSP (filepos) && INTP (XCDR (filepos)))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
426 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
427 file = XCAR (filepos);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
428 position = XINT (XCDR (filepos));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
429 if (position < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
430 position = - position;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
431 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
432 else
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
433 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
434
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
435 if (!STRINGP (file))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
436 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
437
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
438 /* Put the file name in NAME as a C string.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
439 If it is relative, combine it with Vdoc_directory. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
440
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
441 tem = Ffile_name_absolute_p (file);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
442 if (NILP (tem))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
443 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
444 Bytecount minsize;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
445 /* XEmacs: Move this check here. OK if called during loadup to
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
446 load byte code instructions. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
447 if (!STRINGP (Vdoc_directory))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
448 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
449
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
450 minsize = XSTRING_LENGTH (Vdoc_directory);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
451 /* sizeof ("../lib-src/") == 12 */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
452 if (minsize < 12)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
453 minsize = 12;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
454 name_nonreloc = alloca_ibytes (minsize + XSTRING_LENGTH (file) + 8);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
455 string_join (name_nonreloc, Vdoc_directory, file);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
456 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
457 else
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
458 name_reloc = file;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
459
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
460 fd = qxe_open (name_nonreloc ? name_nonreloc :
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
461 XSTRING_DATA (name_reloc), O_RDONLY | OPEN_BINARY, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
462 if (fd < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
463 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
464 if (purify_flag)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
465 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
466 /* sizeof ("../lib-src/") == 12 */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
467 name_nonreloc = alloca_ibytes (12 + XSTRING_LENGTH (file) + 8);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
468 /* Preparing to dump; DOC file is probably not installed.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
469 So check in ../lib-src. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
470 qxestrcpy_ascii (name_nonreloc, "../lib-src/");
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
471 qxestrcat (name_nonreloc, XSTRING_DATA (file));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
472
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
473 fd = qxe_open (name_nonreloc, O_RDONLY | OPEN_BINARY, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
474 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
475
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
476 if (fd < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
477 report_file_error ("Cannot open doc string file",
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
478 name_nonreloc ? build_intstring (name_nonreloc) :
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
479 name_reloc);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
480 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
481
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
482 tem = extract_object_file_name (fd, position, name_nonreloc, name_reloc,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
483 standard_doc_file);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
484 retry_close (fd);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
485
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
486 if (!STRINGP (tem))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
487 signal_error_1 (Qinvalid_byte_code, tem);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
488
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
489 return tem;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
490 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
491
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
492
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
493 static void
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
494 weird_doc (Lisp_Object sym, const Ascbyte *weirdness, const Ascbyte *type,
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
495 int pos)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
496 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
497 if (!strcmp (weirdness, "duplicate")) return;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
498 message ("Note: Strange doc (%s) for %s %s @ %d",
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
499 GETTEXT (weirdness), GETTEXT (type),
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
500 XSTRING_DATA (XSYMBOL (sym)->name), pos);
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
501 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
502
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
503 DEFUN ("built-in-symbol-file", Fbuilt_in_symbol_file, 1, 2, 0, /*
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
504 Return the C source file built-in symbol SYM comes from.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
505 Don't use this. Use the more general `symbol-file' (q.v.) instead.
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
506
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
507 If TYPE is nil or omitted, any kind of definition is acceptable.
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
508 If TYPE is `defun', then function, subr, special form or macro definitions
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
509 are acceptable.
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
510 If TYPE is `defvar', then variable definitions are acceptable.
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
511 */
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
512 (symbol, type))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
513 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
514 /* This function can GC */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
515 Lisp_Object fun;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
516 Lisp_Object filename = Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
517
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
518 if (EQ(Ffboundp(symbol), Qt) && (EQ(type, Qnil) || EQ(type, Qdefun)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
519 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
520 fun = Findirect_function (symbol);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
521
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
522 if (SUBRP (fun) || (CONSP(fun) && (EQ (Qmacro, Fcar_safe (fun)))
4381
3906442b491b Improve style and add tests for 'built-in-symbol-file'.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4377
diff changeset
523 && (fun = Fcdr_safe (fun), SUBRP (fun))))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
524 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
525 if (XSUBR (fun)->doc == 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
526 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
527
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
528 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
529 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
530 weird_doc (symbol, "No file info available for function",
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
531 GETTEXT("function"), 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
532 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
533 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
534 else
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
535 {
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
536 filename = get_object_file_name
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
537 (make_int (- (EMACS_INT) XSUBR (fun)->doc));
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
538 return filename;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
539 }
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
540 }
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
541
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
542 if (COMPILED_FUNCTIONP (fun) || (CONSP(fun) &&
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
543 (EQ (Qmacro, Fcar_safe (fun)))
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
544 && (fun = Fcdr_safe (fun),
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
545 COMPILED_FUNCTIONP (fun))))
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
546 {
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
547 Lisp_Object tem;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
548 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
549
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
550 if (! (f->flags.documentationp))
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
551 return Qnil;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
552 tem = compiled_function_documentation (f);
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
553 if (NATNUMP (tem) || CONSP (tem))
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
554 {
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
555 filename = get_object_file_name (tem);
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
556 return filename;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
557 }
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
558 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
559 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
560
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
561 if (EQ(Fboundp(symbol), Qt) && (EQ(type, Qnil) || EQ(type, Qdefvar)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
562 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
563 Lisp_Object doc_offset = Fget (symbol, Qvariable_documentation, Qnil);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
564
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
565 if (!NILP(doc_offset))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
566 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
567 if (INTP(doc_offset))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
568 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
569 filename = get_object_file_name
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
570 (XINT (doc_offset) > 0 ? doc_offset
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
571 : make_int (- XINT (doc_offset)));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
572 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
573 else if (CONSP(doc_offset))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
574 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
575 filename = get_object_file_name(doc_offset);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
576 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
577 return filename;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
578 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
579 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
580
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
581 return Qnil;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
582 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
583
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 Return the documentation string of FUNCTION.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
586 Unless a non-nil second argument RAW is given, the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 string is passed through `substitute-command-keys'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (function, raw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 Lisp_Object fun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 Lisp_Object doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 fun = Findirect_function (function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 if (SUBRP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 if (XSUBR (fun)->doc == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 doc = build_string (XSUBR (fun)->doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 doc = get_doc_string (make_int (- (EMACS_INT) XSUBR (fun)->doc));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 else if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 Lisp_Object tem;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
609 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 if (! (f->flags.documentationp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 tem = compiled_function_documentation (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 if (STRINGP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 doc = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 else if (NATNUMP (tem) || CONSP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 doc = get_doc_string (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 else if (KEYMAPP (fun))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
621 return build_msg_string ("Prefix command (definition is a keymap of subcommands).");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 else if (STRINGP (fun) || VECTORP (fun))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
623 return build_msg_string ("Keyboard macro.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 else if (CONSP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 Lisp_Object funcar = Fcar (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 if (!SYMBOLP (funcar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 return Fsignal (Qinvalid_function, list1 (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 else if (EQ (funcar, Qlambda)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 || EQ (funcar, Qautoload))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 Lisp_Object tem, tem1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 tem1 = Fcdr (Fcdr (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 tem = Fcar (tem1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 if (STRINGP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 doc = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 /* Handle a doc reference--but these never come last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 in the function body, so reject them if they are last. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 else if ((NATNUMP (tem) || CONSP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 && ! NILP (XCDR (tem1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 doc = get_doc_string (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 else if (EQ (funcar, Qmacro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 return Fdocumentation (Fcdr (fun), raw);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 goto oops;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 oops:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 return Fsignal (Qinvalid_function, list1 (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 if (NILP (raw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 Lisp_Object domain = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 domain = compiled_function_domain (XCOMPILED_FUNCTION (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 if (NILP (domain))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 doc = Fgettext (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 doc = Fdgettext (domain, doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 GCPRO1 (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 doc = Fsubstitute_command_keys (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 return doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 Return the documentation string that is SYMBOL's PROP property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 This is like `get', but it can refer to strings stored in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 `doc-directory/DOC' file; and if the value is a string, it is passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 through `substitute-command-keys'. A non-nil third argument avoids this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 translation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
684 (symbol, prop, raw))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 /* This function can GC */
1849
21549d437f09 [xemacs-hg @ 2004-01-03 21:54:41 by james]
james
parents: 1726
diff changeset
687 Lisp_Object doc = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 REGISTER Lisp_Object domain;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 GCPRO1 (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
695 doc = Fget (symbol, prop, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 if (INTP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 doc = get_doc_string (XINT (doc) > 0 ? doc : make_int (- XINT (doc)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 else if (CONSP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 doc = get_doc_string (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 if (!NILP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
703 domain = Fget (symbol, Qvariable_domain, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 if (NILP (domain))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 doc = Fgettext (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 doc = Fdgettext (domain, doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 if (NILP (raw) && STRINGP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 doc = Fsubstitute_command_keys (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 return doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 Used during Emacs initialization, before dumping runnable Emacs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 to find pointers to doc strings stored in `.../lib-src/DOC' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 record them in function definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 One arg, FILENAME, a string which does not include a directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 The file is written to `../lib-src', and later found in `exec-directory'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 when doc strings are referred to in the dumped Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 (filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 int fd;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
728 Ibyte buf[1024 + 1];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 REGISTER int filled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 REGISTER int pos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
731 REGISTER Ibyte *p, *end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 Lisp_Object sym, fun, tem;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
733 Ibyte *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
735 /* This function should not pass the data it's reading through a coding
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
736 stream. The reason is that the only purpose of this function is to
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
737 find the file offsets for the documentation of the various functions,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
738 not do anything with the documentation itself. If we pass through a
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
739 coding stream, the pointers will get messed up when we start reading
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
740 ISO 2022 data because our pointers will reflect internal format, not
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
741 external format. */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
742
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 if (!purify_flag)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
744 invalid_operation ("Snarf-documentation can only be called in an undumped Emacs", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 CHECK_STRING (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 867
diff changeset
748 {
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 867
diff changeset
749 name = alloca_ibytes (XSTRING_LENGTH (filename) + 14);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
750 qxestrcpy_ascii (name, "../lib-src/");
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 867
diff changeset
751 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
753 qxestrcat (name, XSTRING_DATA (filename));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
755 fd = qxe_open (name, O_RDONLY | OPEN_BINARY, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 if (fd < 0)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
757 report_file_error ("Opening doc string file", build_intstring (name));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 Vinternal_doc_file_name = filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 filled = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 pos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 if (filled < 512)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
764 filled += retry_read (fd, &buf[filled], sizeof (buf) - 1 - filled);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 if (!filled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 buf[filled] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 p = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 end = buf + (filled < 512 ? filled : filled - 128);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 while (p != end && *p != '\037') p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 if (p != end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
775 end = qxestrchr (p, '\n');
3548
9b8943d0d12a [xemacs-hg @ 2006-08-07 20:33:23 by aidan]
aidan
parents: 3545
diff changeset
776 /* If you trigger a failure with this assertion, you probably
9b8943d0d12a [xemacs-hg @ 2006-08-07 20:33:23 by aidan]
aidan
parents: 3545
diff changeset
777 configured with --quick-build and need to rebuild your DOC
3545
2ba8b7a25429 [xemacs-hg @ 2006-08-06 16:37:31 by aidan]
aidan
parents: 3411
diff changeset
778 file. */
2ba8b7a25429 [xemacs-hg @ 2006-08-06 16:37:31 by aidan]
aidan
parents: 3411
diff changeset
779 assert((end - p - 2) > -1);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
780 sym = oblookup (Vobarray, p + 2, end - p - 2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 if (SYMBOLP (sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 Lisp_Object offset = make_int (pos + end + 1 - buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 /* Attach a docstring to a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 if (p[1] == 'V')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 /* Install file-position as variable-documentation property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 and make it negative for a user-variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (doc starts with a `*'). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 Lisp_Object old = Fget (sym, Qvariable_documentation, Qzero);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 if (!ZEROP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
793 weird_doc (sym, "duplicate",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
794 "variable", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 /* In the case of duplicate doc file entries, always
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 take the later one. But if the doc is not an int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 (a string, say) leave it alone. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 if (!INTP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 Fput (sym, Qvariable_documentation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 ((end[1] == '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 ? make_int (- XINT (offset))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 : offset));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 /* Attach a docstring to a function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 The type determines where the docstring is stored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 else if (p[1] == 'F')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 fun = indirect_function (sym,0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 fun = XCDR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 if (UNBOUNDP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
817 #if 0 /* There are lots of legitimate cases where this message will appear
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
818 (e.g. any function that's only defined when MULE is defined,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
819 provided that the function is used somewhere in a dumped Lisp
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
820 file, so that the symbol is interned in the dumped XEmacs), and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
821 there's not a lot that can be done to eliminate the warning other
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
822 than kludges like moving the function to a Mule-only source file,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
823 which often results in ugly code. Furthermore, the only point of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
824 this warning is to warn you when you have a DEFUN that you forget
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
825 to DEFSUBR, but the compiler will also warn you, because the DEFUN
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
826 declares a static object, and the object will be unused -- you'll
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
827 get something like
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
828
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
829 /src/xemacs/mule/src/abbrev.c:269: warning: `SFexpand_abbrev' defined but not used
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
830
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
831 So I'm disabling this. --ben */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
832
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 /* May have been #if'ed out or something */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
834 weird_doc (sym, "not fboundp",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
835 "function", pos);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
836 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 else if (SUBRP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 /* Lisp_Subrs have a slot for it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 if (XSUBR (fun)->doc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
844 weird_doc (sym, "duplicate",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
845 "subr", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 XSUBR (fun)->doc = (char *) (- XINT (offset));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 else if (CONSP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 /* If it's a lisp form, stick it in the form. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 tem = XCAR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 tem = Fcdr (Fcdr (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 if (CONSP (tem) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 INTP (XCAR (tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 Lisp_Object old = XCAR (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 if (!ZEROP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
863 if (EQ (tem, Qlambda))
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
864 weird_doc (sym, "duplicate", "lambda",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
865 pos);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
866 else
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
867 weird_doc (sym, "duplicate", "autoload",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
868 pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 /* In the case of duplicate doc file entries,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 always take the later one. But if the doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 is not an int (a string, say) leave it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 alone. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 if (!INTP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 XCAR (tem) = offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 else if (!CONSP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
880 weird_doc (sym, "!CONSP(tem)", "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 goto cont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 /* DOC string is a string not integer 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 #if 0
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
887 weird_doc (sym, "!INTP(XCAR(tem))",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
888 "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 goto cont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
895 weird_doc (sym, "not lambda or autoload",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
896 "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 goto cont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 else if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 /* Compiled-Function objects sometimes have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 slots for it. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
904 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 /* This compiled-function object must have a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 slot for the docstring, since we've found a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 docstring for it. Unless there were multiple
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 definitions of it, and the latter one didn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 have any doc, which is a legal if slightly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 bogus situation, so don't blow up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 if (! (f->flags.documentationp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
915 weird_doc (sym, "no doc slot", "bytecode", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 Lisp_Object old =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 compiled_function_documentation (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 if (!ZEROP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
924 weird_doc (sym, "duplicate", "bytecode", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 /* In the case of duplicate doc file entries,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 always take the later one. But if the doc is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 not an int (a string, say) leave it alone. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 if (!INTP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 set_compiled_function_documentation (f, offset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 /* Otherwise the function is undefined or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 otherwise weird. Ignore it. */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
938 weird_doc (sym, "weird function", "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 /* lose: */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
945 signal_error (Qfile_error, "DOC file invalid at position",
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
946 make_int (pos));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 weird:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 /* goto lose */;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 cont:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 pos += end - buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 filled -= end - buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 memmove (buf, end, filled);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
957 retry_close (fd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 #if 1 /* Don't warn about functions whose doc was lost because they were
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 wrapped by advice-freeze.el... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 kludgily_ignore_lost_doc_p (Lisp_Object sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 # define kludge_prefix "ad-Orig-"
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
967 Lisp_Object name = XSYMBOL (sym)->name;
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
968 return (XSTRING_LENGTH (name) > (Bytecount) (sizeof (kludge_prefix)) &&
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
969 !qxestrncmp_ascii (XSTRING_DATA (name), kludge_prefix,
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
970 sizeof (kludge_prefix) - 1));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 # undef kludge_prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 # define kludgily_ignore_lost_doc_p(sym) 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 verify_doc_mapper (Lisp_Object sym, void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
981 Lisp_Object closure = * (Lisp_Object *) arg;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 if (!NILP (Ffboundp (sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 int doc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 Lisp_Object fun = XSYMBOL (sym)->function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 if (CONSP (fun) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 EQ (XCAR (fun), Qmacro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 fun = XCDR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 if (SUBRP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 doc = (EMACS_INT) XSUBR (fun)->doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 else if (SYMBOLP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 else if (KEYMAPP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 else if (CONSP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 Lisp_Object tem = XCAR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 tem = Fcdr (Fcdr (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 if (CONSP (tem) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 INTP (XCAR (tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 doc = XINT (XCAR (tem));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 else if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1011 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 if (! (f->flags.documentationp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 Lisp_Object tem = compiled_function_documentation (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 if (INTP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 doc = XINT (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 if (doc == 0 && !kludgily_ignore_lost_doc_p (sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 message ("Warning: doc lost for function %s.",
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1025 XSTRING_DATA (XSYMBOL (sym)->name));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 XCDR (closure) = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 if (!NILP (Fboundp (sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 Lisp_Object doc = Fget (sym, Qvariable_documentation, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 if (ZEROP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 message ("Warning: doc lost for variable %s.",
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1035 XSTRING_DATA (XSYMBOL (sym)->name));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 XCDR (closure) = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 return 0; /* Never stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 DEFUN ("Verify-documentation", Fverify_documentation, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 Used to make sure everything went well with Snarf-documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 Writes to stderr if not.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 Lisp_Object closure = Fcons (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 GCPRO1 (closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 map_obarray (Vobarray, verify_doc_mapper, &closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 if (!NILP (Fcdr (closure)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 message ("\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 "This is usually because some files were preloaded by loaddefs.el or\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 "site-load.el, but were not passed to make-docfile by Makefile.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 return NILP (Fcdr (closure)) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 DEFUN ("substitute-command-keys", Fsubstitute_command_keys, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 Substitute key descriptions for command names in STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 Return a new string which is STRING with substrings of the form \\=\\[COMMAND]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 replaced by either: a keystroke sequence that will invoke COMMAND,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 or "M-x COMMAND" if COMMAND is not on any keys.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 Substrings of the form \\=\\{MAPVAR} are replaced by summaries
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1067 \(made by `describe-bindings') of the value of MAPVAR, taken as a keymap.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 as the keymap for future \\=\\[COMMAND] substrings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 \\=\\= quotes the following character and is discarded;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1073 (string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 /* This function can GC */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1076 Ibyte *buf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 int changed = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1078 REGISTER Ibyte *strdata;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1079 REGISTER Ibyte *bufp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 Bytecount strlength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 Bytecount idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 Bytecount bsize;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1083 Ibyte *new_;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1084 Lisp_Object tem = Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1085 Lisp_Object keymap = Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1086 Lisp_Object name = Qnil;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1087 Ibyte *start;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 Bytecount length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1091 if (NILP (string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1094 CHECK_STRING (string);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1095 GCPRO4 (string, tem, keymap, name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 /* There is the possibility that the string is not destined for a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 translating stream, and it could be argued that we should do the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 same thing here as in Fformat(), but there are very few times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 when this will be the case and many calls to this function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 would have to have `gettext' calls added. (I18N3) */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1102 string = LISP_GETTEXT (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 /* KEYMAP is either nil (which means search all the active keymaps)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 or a specified local map (which means search just that and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 global map). If non-nil, it might come from Voverriding_local_map,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1107 or from a \\<mapname> construct in STRING itself.. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 /* This is really weird and garbagey. If keymap is nil and there's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 an overriding-local-map, `where-is-internal' will correctly note
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 this, so there's no reason to do it here. Maybe FSFmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 `where-is-internal' is broken. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 keymap = current_kboard->Voverriding_terminal_local_map;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 if (NILP (keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 keymap = Voverriding_local_map;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1120 strlength = XSTRING_LENGTH (string);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
1121 bsize = ITEXT_ZTERM_SIZE + strlength;
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
1122 buf = xnew_ibytes (bsize);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 bufp = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 /* Have to reset strdata every time GC might be called */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1126 strdata = XSTRING_DATA (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 for (idx = 0; idx < strlength; )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1129 Ibyte *strp = strdata + idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 if (strp[0] != '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 /* just copy other chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 /* As it happens, this will work with Mule even if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 character quoted is multi-byte; the remaining multi-byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 characters will just be copied by this loop. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 *bufp++ = *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 else switch (strp[1])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 /* just copy unknown escape sequences */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 *bufp++ = *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 /* \= quotes the next character;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 thus, to put in \[ without its special meaning, use \=\[. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 /* As it happens, this will work with Mule even if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 character quoted is multi-byte; the remaining multi-byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 characters will just be copied by this loop. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 *bufp++ = strp[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 idx += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 case '[':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 idx += 2; /* skip \[ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 strp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 start = strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 while ((idx < strlength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 && *strp != ']')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 strp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 length = strp - start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 idx++; /* skip ] */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 tem = Fintern (make_string (start, length), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 #if 0 /* FSFmacs */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1181 /* Disregard menu bar bindings; it is positively annoying to
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1182 mention them when there's no menu bar, and it isn't terribly
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1183 useful even when there is a menu bar. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1184 if (!NILP (tem))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1185 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1186 firstkey = Faref (tem, Qzero);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1187 if (EQ (firstkey, Qmenu_bar))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1188 tem = Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1189 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 if (NILP (tem)) /* but not on any keys */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1194 new_ = (Ibyte *) xrealloc (buf, bsize += 4);
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1195 bufp += new_ - buf;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1196 buf = new_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 memcpy (bufp, "M-x ", 4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 bufp += 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 goto subst;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 { /* function is on a key */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 tem = Fkey_description (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 goto subst_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 case '<':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1210 Lisp_Object buffer = Fget_buffer_create (QSsubstitute);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1211 struct buffer *buf_ = XBUFFER (buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 Fbuffer_disable_undo (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 Ferase_buffer (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 /* \{foo} is replaced with a summary of keymap (symbol-value foo).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 \<foo> just sets the keymap used for \[cmd]. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 idx += 2; /* skip \{ or \< */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 strp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 start = strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 while ((idx < strlength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 && *strp != '}' && *strp != '>')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 strp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 length = strp - start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 idx++; /* skip } or > */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 /* Get the value of the keymap in TEM, or nil if undefined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 Do this while still in the user's current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 in case it is a local variable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 name = Fintern (make_string (start, length), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 tem = Fboundp (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 if (! NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 tem = Fsymbol_value (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 if (! NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 tem = get_keymap (tem, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1246 buffer_insert_c_string (buf_, "(uses keymap \"");
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1247 buffer_insert_lisp_string (buf_, Fsymbol_name (name));
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1248 buffer_insert_c_string (buf_, "\", which is not currently defined) ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 if (start[-1] == '<') keymap = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 else if (start[-1] == '<')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 keymap = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 describe_map_tree (tem, 1, Qnil, Qnil, 0, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 tem = make_string_from_buffer (buf_, BUF_BEG (buf_),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 BUF_Z (buf_) - BUF_BEG (buf_));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 Ferase_buffer (buffer);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1260 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1261 goto subst_string;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1263 subst_string:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1264 start = XSTRING_DATA (tem);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1265 length = XSTRING_LENGTH (tem);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1266 subst:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1267 bsize += length;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1268 new_ = (Ibyte *) xrealloc (buf, bsize);
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1269 bufp += new_ - buf;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1270 buf = new_;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1271 memcpy (bufp, start, length);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1272 bufp += length;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1274 /* Reset STRDATA in case gc relocated it. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1275 strdata = XSTRING_DATA (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1277 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 if (changed) /* don't bother if nothing substituted */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 tem = make_string (buf, bufp - buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 else
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1284 tem = string;
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1330
diff changeset
1285 xfree (buf, Ibyte *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 return tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 syms_of_doc (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 {
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
1298 DEFSUBR (Fbuilt_in_symbol_file);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 DEFSUBR (Fdocumentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 DEFSUBR (Fdocumentation_property);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 DEFSUBR (Fsnarf_documentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 DEFSUBR (Fverify_documentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 DEFSUBR (Fsubstitute_command_keys);
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
1304
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
1305 DEFSYMBOL (Qdefvar);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 vars_of_doc (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 DEFVAR_LISP ("internal-doc-file-name", &Vinternal_doc_file_name /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 Name of file containing documentation strings of built-in symbols.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 Vinternal_doc_file_name = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
1316 QSsubstitute = build_ascstring (" *substitute*");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 staticpro (&QSsubstitute);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 }