Mercurial > hg > xemacs-beta
view src/doc.c @ 2720:6fa9919a9a0b
[xemacs-hg @ 2005-04-08 23:10:01 by crestani]
ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* configure.ac (XE_COMPLEX_ARG_ENABLE): Add `--enable-mc-alloc' as
a new configure flag.
* configure.in (AC_INIT_PARSE_ARGS): Add `--mc-alloc' as a new
configure flag.
* configure.usage: Add description for `mc-alloc'.
DUMP_IN_EXEC:
* Makefile.in.in: Condition the installation of a separate dump
file on !DUMP_ON_EXEC.
* configure.ac (XE_COMPLEX_ARG_ENABLE): Add
`--enable-dump-in-exec' as a new configure flag.
* configure.ac: DUMP_IN_EXEC is define as default for PDUMP but
not default for MC_ALLOC.
* configure.in (AC_INIT_PARSE_ARGS): Add `--dump-in-exec' as a
new configure flag.
* configure.in: DUMP_IN_EXEC is define as default for PDUMP but
not default for MC_ALLOC.
* configure.usage: Add description for `dump-in-exec'.
lib-src/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
DUMP_IN_EXEC:
* Makefile.in.in: Only compile insert-data-in-exec if
DUMP_IN_EXEC is defined.
lisp/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
MEMORY_USAGE_STATS
* diagnose.el: Add new lisp function to pretty print statistics
about the new allocator.
* diagnose.el (show-mc-alloc-memory-usage): New.
modules/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
Remove Lcrecords:
* postgresql/postgresql.c (allocate_pgconn): Allocate with new
allocator.
* postgresql/postgresql.c (allocate_pgresult): Allocate PGresult
with new allocator.
* postgresql/postgresql.h (struct Lisp_PGconn): Add
lrecord_header.
* postgresql/postgresql.h (struct Lisp_PGresult): Add
lrecord_header.
* ldap/eldap.c (allocate_ldap): Allocate with new allocator.
* ldap/eldap.h (struct Lisp_LDAP): Add lrecord_header.
nt/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* config.inc.samp: Add new flag `MC_ALLOC'.
* xemacs.mak: Add flag and configuration output for `MC_ALLOC'.
New files:
* xemacs.dsp: Add source files mc-alloc.c and mc-alloc.h.
* xemacs.mak: Add new object file mc-alloc.obj to dependencies.
src/ChangeLog addition:
2005-04-01 Marcus Crestani <crestani@xemacs.org>
The new allocator.
New configure flag: `MC_ALLOC':
* config.h.in: Add new flag `MC_ALLOC'.
New files:
* Makefile.in.in: Add new object file mc-alloc.o.
* depend: Add new files to dependencies.
* mc-alloc.c: New.
* mc-alloc.h: New.
Running the new allocator from XEmacs:
* alloc.c (deadbeef_memory): Moved to mc-alloc.c.
* emacs.c (main_1): Initialize the new allocator and add
syms_of_mc_alloc.
* symsinit.h: Add syms_of_mc_alloc.
New lrecord allocation and free functions:
* alloc.c (alloc_lrecord): New. Allocates an lrecord, includes
type checking and initializing of the lrecord_header.
* alloc.c (noseeum_alloc_lrecord): Same as above, but increments
the NOSEEUM cons counter.
* alloc.c (free_lrecord): New. Calls the finalizer and frees the
lrecord.
* lrecord.h: Add lrecord allocation prototypes and comments.
Remove old lrecord FROB block allocation:
* alloc.c (allocate_lisp_storage): Former function to expand
heap. Not needed anymore, remove.
* alloc.c: Completely remove `Fixed-size type macros'
* alloc.c (release_breathing_space): Remove.
* alloc.c (memory_full): Remove release_breathing_space.
* alloc.c (refill_memory_reserve): Remove.
* alloc.c (TYPE_ALLOC_SIZE): Remove.
* alloc.c (DECLARE_FIXED_TYPE_ALLOC): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE_FROM_BLOCK): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE_1): Remove.
* alloc.c (ALLOCATE_FIXED_TYPE): Remove.
* alloc.c (NOSEEUM_ALLOCATE_FIXED_TYPE): Remove.
* alloc.c (struct Lisp_Free): Remove.
* alloc.c (LRECORD_FREE_P): Remove.
* alloc.c (MARK_LRECORD_AS_FREE): Remove.
* alloc.c (MARK_LRECORD_AS_NOT_FREE): Remove.
* alloc.c (PUT_FIXED_TYPE_ON_FREE_LIST): Remove.
* alloc.c (FREE_FIXED_TYPE): Remove.
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC): Remove.
Allocate old lrecords with new allocator:
* alloc.c: DECLARE_FIXED_TYPE_ALLOC removed for all lrecords
defined in alloc.c.
* alloc.c (Fcons): Allocate with new allocator.
* alloc.c (noseeum_cons): Allocate with new allocator.
* alloc.c (make_float): Allocate with new allocator.
* alloc.c (make_bignum): Allocate with new allocator.
* alloc.c (make_bignum_bg): Allocate with new allocator.
* alloc.c (make_ratio): Allocate with new allocator.
* alloc.c (make_ratio_bg): Allocate with new allocator.
* alloc.c (make_ratio_rt): Allocate with new allocator.
* alloc.c (make_bigfloat): Allocate with new allocator.
* alloc.c (make_bigfloat_bf): Allocate with new allocator.
* alloc.c (make_compiled_function): Allocate with new allocator.
* alloc.c (Fmake_symbol): Allocate with new allocator.
* alloc.c (allocate_extent): Allocate with new allocator.
* alloc.c (allocate_event): Allocate with new allocator.
* alloc.c (make_key_data): Allocate with new allocator.
* alloc.c (make_button_data): Allocate with new allocator.
* alloc.c (make_motion_data): Allocate with new allocator.
* alloc.c (make_process_data): Allocate with new allocator.
* alloc.c (make_timeout_data): Allocate with new allocator.
* alloc.c (make_magic_data): Allocate with new allocator.
* alloc.c (make_magic_eval_data): Allocate with new allocator.
* alloc.c (make_eval_data): Allocate with new allocator.
* alloc.c (make_misc_user_data): Allocate with new allocator.
* alloc.c (Fmake_marker): Allocate with new allocator.
* alloc.c (noseeum_make_marker): Allocate with new allocator.
* alloc.c (make_uninit_string): Allocate with new allocator.
* alloc.c (resize_string): Allocate with new allocator.
* alloc.c (make_string_nocopy): Allocate with new allocator.
Garbage Collection:
* alloc.c (GC_CHECK_NOT_FREE): Remove obsolete assertions.
* alloc.c (SWEEP_FIXED_TYPE_BLOCK): Remove.
* alloc.c (SWEEP_FIXED_TYPE_BLOCK_1): Remove.
* alloc.c (sweep_conses): Remove.
* alloc.c (free_cons): Use new allocator to free.
* alloc.c (sweep_compiled_functions): Remove.
* alloc.c (sweep_floats): Remove.
* alloc.c (sweep_bignums): Remove.
* alloc.c (sweep_ratios): Remove.
* alloc.c (sweep_bigfloats): Remove.
* alloc.c (sweep_symbols): Remove.
* alloc.c (sweep_extents): Remove.
* alloc.c (sweep_events): Remove.
* alloc.c (sweep_key_data): Remove.
* alloc.c (free_key_data): Use new allocator to free.
* alloc.c (sweep_button_data): Remove.
* alloc.c (free_button_data): Use new allocator to free.
* alloc.c (sweep_motion_data): Remove.
* alloc.c (free_motion_data): Use new allocator to free.
* alloc.c (sweep_process_data): Remove.
* alloc.c (free_process_data): Use new allocator to free.
* alloc.c (sweep_timeout_data): Remove.
* alloc.c (free_timeout_data): Use new allocator to free.
* alloc.c (sweep_magic_data): Remove.
* alloc.c (free_magic_data): Use new allocator to free.
* alloc.c (sweep_magic_eval_data): Remove.
* alloc.c (free_magic_eval_data): Use new allocator to free.
* alloc.c (sweep_eval_data): Remove.
* alloc.c (free_eval_data): Use new allocator to free.
* alloc.c (sweep_misc_user_data): Remove.
* alloc.c (free_misc_user_data): Use new allocator to free.
* alloc.c (sweep_markers): Remove.
* alloc.c (free_marker): Use new allocator to free.
* alloc.c (garbage_collect_1): Remove release_breathing_space.
* alloc.c (gc_sweep): Remove all the old lcrecord and lrecord
related stuff. Sweeping now works like this: compact string
chars, finalize, sweep.
* alloc.c (common_init_alloc_early): Remove old lrecord
initializations, remove breathing_space.
* emacs.c (Fdump_emacs): Remove release_breathing_space.
* lisp.h: Remove prototype for release_breathing_space.
* lisp.h: Adjust the special cons mark makros.
Lrecord Finalizer:
* alloc.c: Add finalizer to lrecord definition.
* alloc.c (finalize_string): Add finalizer for string.
* bytecode.c: Add finalizer to lrecord definition.
* bytecode.c (finalize_compiled_function): Add finalizer for
compiled function.
* marker.c: Add finalizer to lrecord definition.
* marker.c (finalize_marker): Add finalizer for marker.
These changes build the interface to mc-alloc:
* lrecord.h (MC_ALLOC_CALL_FINALIZER): Tell mc-alloc how to
finalize lrecords.
* lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE): Tell
mc-alloc how to finalize for disksave.
Unify lrecords and lcrecords:
* lisp.h (struct Lisp_String): Adjust string union hack to
new lrecord header.
* lrecord.h: Adjust comments.
* lrecord.h (struct lrecord_header): The new lrecord header
includes type, lisp-readonly, free, and uid.
* lrecord.h (set_lheader_implementation): Adjust to new
lrecord_header.
* lrecord.h (struct lrecord_implementation): The field basic_p
for indication of an old lrecord is not needed anymore, remove.
* lrecord.h (MAKE_LRECORD_IMPLEMENTATION): Remove basic_p.
* lrecord.h (MAKE_EXTERNAL_LRECORD_IMPLEMENTATION): Remove
basic_p.
* lrecord.h (copy_sized_lrecord): Remove distinction between
old lrecords and lcrecords.
* lrecord.h (copy_lrecord): Remove distinction between old
lrecords and lcrecords.
* lrecord.h (zero_sized_lrecord): Remove distinction between
old lrecords and lcrecords.
* lrecord.h (zero_lrecord): Remove distinction between old
lrecords and lcrecords.
Remove lcrecords and lcrecord lists:
* alloc.c (basic_alloc_lcrecord): Not needed anymore, remove.
* alloc.c (very_old_free_lcrecord): Not needed anymore, remove.
* alloc.c (copy_lisp_object): No more distinction between
lrecords and lcrecords.
* alloc.c (all_lcrecords): Not needed anymore, remove.
* alloc.c (make_vector_internal): Allocate as lrecord.
* alloc.c (make_bit_vector_internal): Allocate as lrecord.
* alloc.c: Completely remove `lcrecord lists'.
* alloc.c (free_description): Remove.
* alloc.c (lcrecord_list_description): Remove.
* alloc.c (mark_lcrecord_list): Remove.
* alloc.c (make_lcrecord_list): Remove.
* alloc.c (alloc_managed_lcrecord): Remove.
* alloc.c (free_managed_lcrecord): Remove.
* alloc.c (alloc_automanaged_lcrecord): Remove.
* alloc.c (free_lcrecord): Remove.
* alloc.c (lcrecord_stats): Remove.
* alloc.c (tick_lcrecord_stats): Remove.
* alloc.c (disksave_object_finalization_1): Add call to
mc_finalize_for_disksave. Remove the lcrecord way to visit all
objects.
* alloc.c (kkcc_marking): Remove XD_FLAG_FREE_LISP_OBJECT
* alloc.c (sweep_lcrecords_1): Remove.
* alloc.c (common_init_alloc_early): Remove everything related
to lcrecords, remove old lrecord initializations,
* alloc.c (init_lcrecord_lists): Not needed anymore, remove.
* alloc.c (reinit_alloc_early): Remove everything related to
lcrecords.
* alloc.c (init_alloc_once_early): Remove everything related to
lcrecords.
* buffer.c (allocate_buffer): Allocate as lrecord.
* buffer.c (nuke_all_buffer_slots): Use lrecord functions.
* buffer.c (common_init_complex_vars_of_buffer): Allocate as
lrecord.
* buffer.h (struct buffer): Add lrecord_header.
* casetab.c (allocate_case_table): Allocate as lrecord.
* casetab.h (struct Lisp_Case_Table): Add lrecord_header.
* charset.h (struct Lisp_Charset): Add lrecord_header.
* chartab.c (fill_char_table): Use lrecord functions.
* chartab.c (Fmake_char_table): Allocate as lrecord.
* chartab.c (make_char_table_entry): Allocate as lrecord.
* chartab.c (copy_char_table_entry): Allocate as lrecord.
* chartab.c (Fcopy_char_table): Allocate as lrecord.
* chartab.c (put_char_table): Use lrecord functions.
* chartab.h (struct Lisp_Char_Table_Entry): Add lrecord_header.
* chartab.h (struct Lisp_Char_Table): Add lrecord_header.
* console-impl.h (struct console): Add lrecord_header.
* console-msw-impl.h (struct Lisp_Devmode): Add lrecord_header.
* console-msw-impl.h (struct mswindows_dialog_id): Add
lrecord_header.
* console.c (allocate_console): Allocate as lrecord.
* console.c (nuke_all_console_slots): Use lrecord functions.
* console.c (common_init_complex_vars_of_console): Allocate as
lrecord.
* data.c (make_weak_list): Allocate as lrecord.
* data.c (make_weak_box): Allocate as lrecord.
* data.c (make_ephemeron): Allocate as lrecord.
* database.c (struct Lisp_Database): Add lrecord_header.
* database.c (allocate_database): Allocate as lrecord.
* device-impl.h (struct device): Add lrecord_header.
* device-msw.c (allocate_devmode): Allocate as lrecord.
* device.c (nuke_all_device_slots): Use lrecord functions.
* device.c (allocate_device): Allocate as lrecord.
* dialog-msw.c (handle_question_dialog_box): Allocate as lrecord.
* elhash.c (struct Lisp_Hash_Table): Add lrecord_header.
* elhash.c (make_general_lisp_hash_table): Allocate as lrecord.
* elhash.c (Fcopy_hash_table): Allocate as lrecord.
* event-stream.c: Lcrecord lists Vcommand_builder_free_list and
Vtimeout_free_list are no longer needed. Remove.
* event-stream.c (allocate_command_builder): Allocate as lrecord.
* event-stream.c (free_command_builder): Use lrecord functions.
* event-stream.c (event_stream_generate_wakeup): Allocate as
lrecord.
* event-stream.c (event_stream_resignal_wakeup): Use lrecord
functions.
* event-stream.c (event_stream_disable_wakeup): Use lrecord
functions.
* event-stream.c (reinit_vars_of_event_stream): Lcrecord lists
remove.
* events.h (struct Lisp_Timeout): Add lrecord_header.
* events.h (struct command_builder): Add lrecord_header.
* extents-impl.h (struct extent_auxiliary): Add lrecord_header.
* extents-impl.h (struct extent_info): Add lrecord_header.
* extents.c (allocate_extent_auxiliary): Allocate as lrecord.
* extents.c (allocate_extent_info): Allocate as lrecord.
* extents.c (copy_extent): Allocate as lrecord.
* faces.c (allocate_face): Allocate as lrecord.
* faces.h (struct Lisp_Face): Add lrecord_header.
* file-coding.c (allocate_coding_system): Allocate as lrecord.
* file-coding.c (Fcopy_coding_system): Allocate as lrecord.
* file-coding.h (struct Lisp_Coding_System): Add lrecord_header.
* fns.c (Ffillarray): Allocate as lrecord.
* frame-impl.h (struct frame): Add lrecord_header.
* frame.c (nuke_all_frame_slots): Use lrecord functions.
* frame.c (allocate_frame_core): Allocate as lrecord.
* glyphs.c (allocate_image_instance): Allocate as lrecord.
* glyphs.c (Fcolorize_image_instance): Allocate as lrecord.
* glyphs.c (allocate_glyph): Allocate as lrecord.
* glyphs.h (struct Lisp_Image_Instance): Add lrecord_header.
* glyphs.h (struct Lisp_Glyph): Add lrecord_header.
* gui.c (allocate_gui_item): Allocate as lrecord.
* gui.h (struct Lisp_Gui_Item): Add lrecord_header.
* keymap.c (struct Lisp_Keymap): Add lrecord_header.
* keymap.c (make_keymap): Allocate as lrecord.
* lisp.h (struct Lisp_Vector): Add lrecord_header.
* lisp.h (struct Lisp_Bit_Vector): Add lrecord_header.
* lisp.h (struct weak_box): Add lrecord_header.
* lisp.h (struct ephemeron): Add lrecord_header.
* lisp.h (struct weak_list): Add lrecord_header.
* lrecord.h (struct lcrecord_header): Not used, remove.
* lrecord.h (struct free_lcrecord_header): Not used, remove.
* lrecord.h (struct lcrecord_list): Not needed anymore, remove.
* lrecord.h (lcrecord_list): Not needed anymore, remove.
* lrecord.h: (enum data_description_entry_flags): Remove
XD_FLAG_FREE_LISP_OBJECT.
* lstream.c: Lrecord list Vlstream_free_list remove.
* lstream.c (Lstream_new): Allocate as lrecord.
* lstream.c (Lstream_delete): Use lrecod functions.
* lstream.c (reinit_vars_of_lstream): Vlstream_free_list
initialization remove.
* lstream.h (struct lstream): Add lrecord_header.
* emacs.c (main_1): Remove lstream initialization.
* mule-charset.c (make_charset): Allocate as lrecord.
* objects-impl.h (struct Lisp_Color_Instance): Add
lrecord_header.
* objects-impl.h (struct Lisp_Font_Instance): Add lrecord_header.
* objects.c (Fmake_color_instance): Allocate as lrecord.
* objects.c (Fmake_font_instance): Allocate as lrecord.
* objects.c (reinit_vars_of_objects): Allocate as lrecord.
* opaque.c: Lcreord list Vopaque_ptr_list remove.
* opaque.c (make_opaque): Allocate as lrecord.
* opaque.c (make_opaque_ptr): Allocate as lrecord.
* opaque.c (free_opaque_ptr): Use lrecord functions.
* opaque.c (reinit_opaque_early):
* opaque.c (init_opaque_once_early): Vopaque_ptr_list
initialization remove.
* opaque.h (Lisp_Opaque): Add lrecord_header.
* opaque.h (Lisp_Opaque_Ptr): Add lrecord_header.
* emacs.c (main_1): Remove opaque variable initialization.
* print.c (default_object_printer): Use new lrecord_header.
* print.c (print_internal): Use new lrecord_header.
* print.c (debug_p4): Use new lrecord_header.
* process.c (make_process_internal): Allocate as lrecord.
* procimpl.h (struct Lisp_Process): Add lrecord_header.
* rangetab.c (Fmake_range_table): Allocate as lrecord.
* rangetab.c (Fcopy_range_table): Allocate as lrecord.
* rangetab.h (struct Lisp_Range_Table): Add lrecord_header.
* scrollbar.c (create_scrollbar_instance): Allocate as lrecord.
* scrollbar.h (struct scrollbar_instance): Add lrecord_header.
* specifier.c (make_specifier_internal): Allocate as lrecord.
* specifier.h (struct Lisp_Specifier): Add lrecord_header.
* symbols.c:
* symbols.c (Fmake_variable_buffer_local): Allocate as lrecord.
* symbols.c (Fdontusethis_set_symbol_value_handler): Allocate
as lrecord.
* symbols.c (Fdefvaralias): Allocate as lrecord.
* symeval.h (struct symbol_value_magic): Add lrecord_header.
* toolbar.c (update_toolbar_button): Allocate as lrecord.
* toolbar.h (struct toolbar_button): Add lrecord_header.
* tooltalk.c (struct Lisp_Tooltalk_Message): Add lrecord_header.
* tooltalk.c (make_tooltalk_message): Allocate as lrecord.
* tooltalk.c (struct Lisp_Tooltalk_Pattern): Add lrecord_header.
* tooltalk.c (make_tooltalk_pattern): Allocate as lrecord.
* ui-gtk.c (allocate_ffi_data): Allocate as lrecord.
* ui-gtk.c (allocate_emacs_gtk_object_data): Allocate as lrecord.
* ui-gtk.c (allocate_emacs_gtk_boxed_data): Allocate as lrecord.
* ui-gtk.h (structs): Add lrecord_header.
* window-impl.h (struct window): Add lrecord_header.
* window-impl.h (struct window_mirror): Add lrecord_header.
* window.c (allocate_window): Allocate as lrecord.
* window.c (new_window_mirror): Allocate as lrecord.
* window.c (make_dummy_parent): Allocate as lrecord.
MEMORY_USAGE_STATS
* alloc.c (fixed_type_block_overhead): Not used anymore, remove.
* buffer.c (compute_buffer_usage): Get storage size from new
allocator.
* marker.c (compute_buffer_marker_usage): Get storage size from
new allocator.
* mule-charset.c (compute_charset_usage): Get storage size from
new allocator.
* scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): Get
storage size from new allocator.
* scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage):
Get storage size from new allocator.
* scrollbar-x.c (x_compute_scrollbar_instance_usage): Get
storage size from new allocator.
* scrollbar.c (compute_scrollbar_instance_usage): Get storage
size from new allocator.
* unicode.c (compute_from_unicode_table_size_1): Get storage
size from new allocator.
* unicode.c (compute_to_unicode_table_size_1): Get storage size
from new allocator.
* window.c (compute_window_mirror_usage): Get storage size from
new allocator.
* window.c (compute_window_usage): Get storage size from new
allocator.
MC_ALLOC_TYPE_STATS:
* alloc.c (alloc_lrecord): Bump lrecord count.
* alloc.c (noseeum_alloc_lrecord): Bump lrecord count.
* alloc.c (struct lrecord_stats): Storage for counts.
* alloc.c (init_lrecord_stats): Zero statistics.
* alloc.c (inc_lrecord_stats): Increase the statistic.
* alloc.c (dec_lrecord_stats): Decrease the statistic.
* alloc.c (gc_plist_hack): Used to print the information.
* alloc.c (Fgarbage_collect): Return the collected information.
* mc-alloc.c (remove_cell): Decrease lrecord count.
* mc-alloc.h: Set flag MC_ALLOC_TYPE_STATS.
* emacs.c (main_1): Init lrecord statistics.
* lrecord.h: Add prototypes for *_lrecord_stats.
Strings:
* alloc.c (Fmake_string): Initialize ascii_begin to zero.
* alloc.c (gc_count_num_short_string_in_use): Remove.
* alloc.c (gc_count_string_total_size): Remove.
* alloc.c (gc_count_short_string_total_size): Remove.
* alloc.c (debug_string_purity): Remove.
* alloc.c (debug_string_purity_print): Remove.
* alloc.c (sweep_strings): Remove.
Remove static C-readonly Lisp objects:
* alloc.c (c_readonly): Not needed anymore, remove.
* alloc.c (GC_CHECK_LHEADER_INVARIANTS): Remove some obsolete
lheader invariants assertions.
* buffer.c (DEFVAR_BUFFER_LOCAL_1): Allocate dynamically.
* console.c (DEFVAR_CONSOLE_LOCAL_1): Allocate dynamically.
* gpmevent.c: Indirection via MC_ALLOC_Freceive_gpm_event.
* gpmevent.c (Fgpm_enable): Allocate dynamically.
* gpmevent.c (syms_of_gpmevent): Allocate dynamically.
* lisp.h (C_READONLY): Not needed anymore, remove.
* lisp.h (DEFUN): Allocate dynamically.
* lrecord.h (C_READONLY_RECORD_HEADER_P): Not needed anymore,
remove.
* lrecord.h (SET_C_READONLY_RECORD_HEADER): Not needed anymore,
remove.
* symbols.c (guts_of_unbound_marker):
* symeval.h (defsubr): Allocate dynamically.
* symeval.h (DEFSUBR_MACRO): Allocate dynamically.
* symeval.h (DEFVAR_ SYMVAL_FWD): Allocate dynamically.
* tests.c (TESTS_DEFSUBR): Allocate dynamically.
Definition of mcpro:
* lisp.h: Add mcpro prototypes.
* alloc.c (common_init_alloc_early): Add initialization for
mcpros.
* alloc.c (mcpro_description_1): New.
* alloc.c (mcpro_description): New.
* alloc.c (mcpros_description_1): New.
* alloc.c (mcpros_description): New.
* alloc.c (mcpro_one_name_description_1): New.
* alloc.c (mcpro_one_name_description): New.
* alloc.c (mcpro_names_description_1): New.
* alloc.c (mcpro_names_description): New.
* alloc.c (mcpros): New.
* alloc.c (mcpro_names): New.
* alloc.c (mcpro_1): New.
* alloc.c (mc_pro): New.
* alloc.c (garbage_collect_1): Add mcpros to root set.
Usage of mcpro:
* alloc.c (make_string_nocopy): Add string to root set.
* symbols.c (init_symbols_once_early): Add Qunbound to root set.
Changes to the Portable Dumper:
* alloc.c (FREE_OR_REALLOC_BEGIN): Since dumped objects can be
freed with the new allocator, remove assertion for !DUMPEDP.
* dumper.c: Adjust comments, increase PDUMP_HASHSIZE.
* dumper.c (pdump_make_hash): Shift address only 2 bytes, to
avoid collisions.
* dumper.c (pdump_objects_unmark): No more mark bits within
the object, remove.
* dumper.c (mc_addr_elt): New. Element data structure for mc
hash table.
* dumper.c (pdump_mc_hash): New hash table: `lookup table'.
* dumper.c (pdump_get_mc_addr): New. Lookup for hash table.
* dumper.c (pdump_get_indirect_mc_addr): New. Lookup for
convertibles.
* dumper.c (pdump_put_mc_addr): New. Putter for hash table.
* dumper.c (pdump_dump_mc_data): New. Writes the table for
relocation at load time to the dump file.
* dumper.c (pdump_scan_lisp_objects_by_alignment): New.
Visits all dumped Lisp objects.
* dumper.c (pdump_scan_non_lisp_objects_by_alignment): New.
Visits all other dumped objects.
* dumper.c (pdump_reloc_one_mc): New. Updates all pointers
of an object by using the hash table pdump_mc_hash.
* dumper.c (pdump_reloc_one): Replaced by pdump_reloc_one_mc.
* dumper.c (pdump): Change the structure of the dump file, add
the mc post dump relocation table to dump file.
* dumper.c (pdump_load_finish): Hand all dumped objects to the
new allocator and use the mc post dump relocation table for
relocating the dumped objects at dump file load time, free not
longer used data structures.
* dumper.c (pdump_load): Free the dump file.
* dumper.h: Remove pdump_objects_unmark.
* lrecord.h (DUMPEDP): Dumped objects can be freed, remove.
DUMP_IN_EXEC:
* Makefile.in.in: Linking for and with dump in executable only if
DUMP_IN_EXEC is defined.
* config.h.in: Add new flag `DUMP_IN_EXEC'
* emacs.c: Condition dump-data.h on DUMP_IN_EXEC.
* emacs.c (main_1): Flag `-si' only works if dump image is
written into executable.
Miscellanious
* lrecord.h (enum lrecord_type): Added numbers to all types,
very handy for debugging.
* xemacs.def.in.in: Add mc-alloc functions to make them visible
to the modules.
| author | crestani |
|---|---|
| date | Fri, 08 Apr 2005 23:11:35 +0000 |
| parents | ecf1ebac70d8 |
| children | facf3239ba30 |
line wrap: on
line source
/* Record indices of function doc strings stored in a file. Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. Copyright (C) 2001, 2002, 2004 Ben Wing. This file is part of XEmacs. XEmacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. XEmacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with XEmacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Synched up with: FSF 19.30. */ /* This file has been Mule-ized. */ #include <config.h> #include "lisp.h" #include "buffer.h" #include "bytecode.h" #include "file-coding.h" #include "insdel.h" #include "keymap.h" #include "lstream.h" #include "sysfile.h" Lisp_Object Vinternal_doc_file_name; Lisp_Object QSsubstitute; /* Read and return doc string or instructions from open file descriptor FD at position POSITION. Does not close the file. Returns string; or if error, returns a cons holding the error data to pass to Fsignal. NAME_NONRELOC and NAME_RELOC are only used for the error messages. */ Lisp_Object unparesseuxify_doc_string (int fd, EMACS_INT position, Ibyte *name_nonreloc, Lisp_Object name_reloc, int standard_doc_file) { Ibyte buf[512 * 32 + 1]; Ibyte *buffer = buf; int buffer_size = sizeof (buf); Ibyte *from, *to; REGISTER Ibyte *p = buffer; Lisp_Object return_me; Lisp_Object fdstream = Qnil, instream = Qnil; struct gcpro gcpro1, gcpro2; GCPRO2 (fdstream, instream); if (0 > lseek (fd, position, 0)) { if (name_nonreloc) name_reloc = build_intstring (name_nonreloc); return_me = list3 (build_msg_string ("Position out of range in doc string file"), name_reloc, make_int (position)); goto done; } fdstream = make_filedesc_input_stream (fd, 0, -1, 0); Lstream_set_buffering (XLSTREAM (fdstream), LSTREAM_UNBUFFERED, 0); instream = make_coding_input_stream /* Major trouble if we are too clever when reading byte-code instructions! #### We should have a way of handling escape-quoted elc files (i.e. files with non-ASCII/Latin-1 chars in them). Currently this is "solved" in bytecomp.el by never inserting lazy references in such files. */ (XLSTREAM (fdstream), standard_doc_file ? Qescape_quoted : Qbinary, CODING_DECODE, 0); Lstream_set_buffering (XLSTREAM (instream), LSTREAM_UNBUFFERED, 0); /* Read the doc string into a buffer. Use the fixed buffer BUF if it is big enough; otherwise allocate one. We store the buffer in use in BUFFER and its size in BUFFER_SIZE. */ while (1) { int space_left = buffer_size - (p - buffer); int nread; /* Switch to a bigger buffer if we need one. */ if (space_left == 0) { Ibyte *old_buffer = buffer; if (buffer == buf) { buffer = xnew_ibytes (buffer_size *= 2); memcpy (buffer, old_buffer, p - old_buffer); } else XREALLOC_ARRAY (buffer, Ibyte, buffer_size *= 2); p += buffer - old_buffer; space_left = buffer_size - (p - buffer); } /* Don't read too much at one go. */ if (space_left > 1024 * 8) space_left = 1024 * 8; nread = Lstream_read (XLSTREAM (instream), p, space_left); if (nread < 0) { return_me = list1 (build_msg_string ("Read error on documentation file")); goto done; } p[nread] = 0; if (!nread) break; { Ibyte *p1 = qxestrchr (p, '\037'); /* End of doc string marker */ if (p1) { *p1 = 0; p = p1; break; } } p += nread; } /* Scan the text and remove quoting with ^A (char code 1). ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */ from = to = buffer; while (from < p) { if (*from != 1 /*^A*/) *to++ = *from++; else { int c = *(++from); from++; switch (c) { case 1: *to++ = c; break; case '0': *to++ = '\0'; break; case '_': *to++ = '\037'; break; default: return_me = list2 (build_msg_string ("Invalid data in documentation file -- ^A followed by weird code"), make_int (c)); goto done; } } } return_me = make_string (buffer, to - buffer); done: if (!NILP (instream)) { Lstream_delete (XLSTREAM (instream)); Lstream_delete (XLSTREAM (fdstream)); } UNGCPRO; if (buffer != buf) /* We must have allocated buffer above */ xfree (buffer, Ibyte *); return return_me; } #define string_join(dest, s1, s2) \ memcpy (dest, XSTRING_DATA (s1), XSTRING_LENGTH (s1)); \ memcpy (dest + XSTRING_LENGTH (s1), XSTRING_DATA (s2), \ XSTRING_LENGTH (s2)); \ dest[XSTRING_LENGTH (s1) + XSTRING_LENGTH (s2)] = '\0' /* Extract a doc string from a file. FILEPOS says where to get it. (This could actually be byte code instructions/constants instead of a doc string.) If it is an integer, use that position in the standard DOC file. If it is (FILE . INTEGER), use FILE as the file name and INTEGER as the position in that file. But if INTEGER is negative, make it positive. (A negative integer is used for user variables, so we can distinguish them without actually fetching the doc string.) */ static Lisp_Object get_doc_string (Lisp_Object filepos) { REGISTER int fd; REGISTER Ibyte *name_nonreloc = 0; EMACS_INT position; Lisp_Object file, tem; Lisp_Object name_reloc = Qnil; int standard_doc_file = 0; if (INTP (filepos)) { file = Vinternal_doc_file_name; standard_doc_file = 1; position = XINT (filepos); } else if (CONSP (filepos) && INTP (XCDR (filepos))) { file = XCAR (filepos); position = XINT (XCDR (filepos)); if (position < 0) position = - position; } else return Qnil; if (!STRINGP (file)) return Qnil; /* Put the file name in NAME as a C string. If it is relative, combine it with Vdoc_directory. */ tem = Ffile_name_absolute_p (file); if (NILP (tem)) { Bytecount minsize; /* XEmacs: Move this check here. OK if called during loadup to load byte code instructions. */ if (!STRINGP (Vdoc_directory)) return Qnil; minsize = XSTRING_LENGTH (Vdoc_directory); /* sizeof ("../lib-src/") == 12 */ if (minsize < 12) minsize = 12; name_nonreloc = alloca_ibytes (minsize + XSTRING_LENGTH (file) + 8); string_join (name_nonreloc, Vdoc_directory, file); } else name_reloc = file; fd = qxe_open (name_nonreloc ? name_nonreloc : XSTRING_DATA (name_reloc), O_RDONLY | OPEN_BINARY, 0); if (fd < 0) { if (purify_flag) { /* sizeof ("../lib-src/") == 12 */ name_nonreloc = alloca_ibytes (12 + XSTRING_LENGTH (file) + 8); /* Preparing to dump; DOC file is probably not installed. So check in ../lib-src. */ qxestrcpy_ascii (name_nonreloc, "../lib-src/"); qxestrcat (name_nonreloc, XSTRING_DATA (file)); fd = qxe_open (name_nonreloc, O_RDONLY | OPEN_BINARY, 0); } if (fd < 0) report_file_error ("Cannot open doc string file", name_nonreloc ? build_intstring (name_nonreloc) : name_reloc); } tem = unparesseuxify_doc_string (fd, position, name_nonreloc, name_reloc, standard_doc_file); retry_close (fd); if (!STRINGP (tem)) signal_error_1 (Qinvalid_byte_code, tem); return tem; } /* Get a string from position FILEPOS and pass it through the Lisp reader. We use this for fetching the bytecode string and constants vector of a compiled function from the .elc file. */ Lisp_Object read_doc_string (Lisp_Object filepos) { Lisp_Object string = get_doc_string (filepos); if (!STRINGP (string)) invalid_state ("loading bytecode failed to return string", string); return Fread (string); } DEFUN ("documentation", Fdocumentation, 1, 2, 0, /* Return the documentation string of FUNCTION. Unless a non-nil second argument RAW is given, the string is passed through `substitute-command-keys'. */ (function, raw)) { /* This function can GC */ Lisp_Object fun; Lisp_Object doc; fun = Findirect_function (function); if (SUBRP (fun)) { if (XSUBR (fun)->doc == 0) return Qnil; if ((EMACS_INT) XSUBR (fun)->doc >= 0) doc = build_string (XSUBR (fun)->doc); else doc = get_doc_string (make_int (- (EMACS_INT) XSUBR (fun)->doc)); } else if (COMPILED_FUNCTIONP (fun)) { Lisp_Object tem; Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun); if (! (f->flags.documentationp)) return Qnil; tem = compiled_function_documentation (f); if (STRINGP (tem)) doc = tem; else if (NATNUMP (tem) || CONSP (tem)) doc = get_doc_string (tem); else return Qnil; } else if (KEYMAPP (fun)) return build_msg_string ("Prefix command (definition is a keymap of subcommands)."); else if (STRINGP (fun) || VECTORP (fun)) return build_msg_string ("Keyboard macro."); else if (CONSP (fun)) { Lisp_Object funcar = Fcar (fun); if (!SYMBOLP (funcar)) return Fsignal (Qinvalid_function, list1 (fun)); else if (EQ (funcar, Qlambda) || EQ (funcar, Qautoload)) { Lisp_Object tem, tem1; tem1 = Fcdr (Fcdr (fun)); tem = Fcar (tem1); if (STRINGP (tem)) doc = tem; /* Handle a doc reference--but these never come last in the function body, so reject them if they are last. */ else if ((NATNUMP (tem) || CONSP (tem)) && ! NILP (XCDR (tem1))) doc = get_doc_string (tem); else return Qnil; } else if (EQ (funcar, Qmacro)) return Fdocumentation (Fcdr (fun), raw); else goto oops; } else { oops: return Fsignal (Qinvalid_function, list1 (fun)); } if (NILP (raw)) { struct gcpro gcpro1; #ifdef I18N3 Lisp_Object domain = Qnil; if (COMPILED_FUNCTIONP (fun)) domain = compiled_function_domain (XCOMPILED_FUNCTION (fun)); if (NILP (domain)) doc = Fgettext (doc); else doc = Fdgettext (domain, doc); #endif GCPRO1 (doc); doc = Fsubstitute_command_keys (doc); UNGCPRO; } return doc; } DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /* Return the documentation string that is SYMBOL's PROP property. This is like `get', but it can refer to strings stored in the `doc-directory/DOC' file; and if the value is a string, it is passed through `substitute-command-keys'. A non-nil third argument avoids this translation. */ (symbol, prop, raw)) { /* This function can GC */ Lisp_Object doc = Qnil; #ifdef I18N3 REGISTER Lisp_Object domain; #endif struct gcpro gcpro1; GCPRO1 (doc); doc = Fget (symbol, prop, Qnil); if (INTP (doc)) doc = get_doc_string (XINT (doc) > 0 ? doc : make_int (- XINT (doc))); else if (CONSP (doc)) doc = get_doc_string (doc); #ifdef I18N3 if (!NILP (doc)) { domain = Fget (symbol, Qvariable_domain, Qnil); if (NILP (domain)) doc = Fgettext (doc); else doc = Fdgettext (domain, doc); } #endif if (NILP (raw) && STRINGP (doc)) doc = Fsubstitute_command_keys (doc); UNGCPRO; return doc; } static void weird_doc (Lisp_Object sym, const CIbyte *weirdness, const CIbyte *type, int pos) { if (!strcmp (weirdness, GETTEXT ("duplicate"))) return; message ("Note: Strange doc (%s) for %s %s @ %d", weirdness, type, XSTRING_DATA (XSYMBOL (sym)->name), pos); } DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /* Used during Emacs initialization, before dumping runnable Emacs, to find pointers to doc strings stored in `.../lib-src/DOC' and record them in function definitions. One arg, FILENAME, a string which does not include a directory. The file is written to `../lib-src', and later found in `exec-directory' when doc strings are referred to in the dumped Emacs. */ (filename)) { int fd; Ibyte buf[1024 + 1]; REGISTER int filled; REGISTER int pos; REGISTER Ibyte *p, *end; Lisp_Object sym, fun, tem; Ibyte *name; /* This function should not pass the data it's reading through a coding stream. The reason is that the only purpose of this function is to find the file offsets for the documentation of the various functions, not do anything with the documentation itself. If we pass through a coding stream, the pointers will get messed up when we start reading ISO 2022 data because our pointers will reflect internal format, not external format. */ if (!purify_flag) invalid_operation ("Snarf-documentation can only be called in an undumped Emacs", Qunbound); CHECK_STRING (filename); { name = alloca_ibytes (XSTRING_LENGTH (filename) + 14); qxestrcpy_ascii (name, "../lib-src/"); } qxestrcat (name, XSTRING_DATA (filename)); fd = qxe_open (name, O_RDONLY | OPEN_BINARY, 0); if (fd < 0) report_file_error ("Opening doc string file", build_intstring (name)); Vinternal_doc_file_name = filename; filled = 0; pos = 0; while (1) { if (filled < 512) filled += retry_read (fd, &buf[filled], sizeof (buf) - 1 - filled); if (!filled) break; buf[filled] = 0; p = buf; end = buf + (filled < 512 ? filled : filled - 128); while (p != end && *p != '\037') p++; /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ if (p != end) { end = qxestrchr (p, '\n'); sym = oblookup (Vobarray, p + 2, end - p - 2); if (SYMBOLP (sym)) { Lisp_Object offset = make_int (pos + end + 1 - buf); /* Attach a docstring to a variable */ if (p[1] == 'V') { /* Install file-position as variable-documentation property and make it negative for a user-variable (doc starts with a `*'). */ Lisp_Object old = Fget (sym, Qvariable_documentation, Qzero); if (!ZEROP (old)) { weird_doc (sym, GETTEXT ("duplicate"), GETTEXT ("variable"), pos); /* In the case of duplicate doc file entries, always take the later one. But if the doc is not an int (a string, say) leave it alone. */ if (!INTP (old)) goto weird; } Fput (sym, Qvariable_documentation, ((end[1] == '*') ? make_int (- XINT (offset)) : offset)); } /* Attach a docstring to a function. The type determines where the docstring is stored. */ else if (p[1] == 'F') { fun = indirect_function (sym,0); if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) fun = XCDR (fun); if (UNBOUNDP (fun)) { #if 0 /* There are lots of legitimate cases where this message will appear (e.g. any function that's only defined when MULE is defined, provided that the function is used somewhere in a dumped Lisp file, so that the symbol is interned in the dumped XEmacs), and there's not a lot that can be done to eliminate the warning other than kludges like moving the function to a Mule-only source file, which often results in ugly code. Furthermore, the only point of this warning is to warn you when you have a DEFUN that you forget to DEFSUBR, but the compiler will also warn you, because the DEFUN declares a static object, and the object will be unused -- you'll get something like /src/xemacs/mule/src/abbrev.c:269: warning: `SFexpand_abbrev' defined but not used So I'm disabling this. --ben */ /* May have been #if'ed out or something */ weird_doc (sym, GETTEXT ("not fboundp"), GETTEXT ("function"), pos); #endif goto weird; } else if (SUBRP (fun)) { /* Lisp_Subrs have a slot for it. */ if (XSUBR (fun)->doc) { weird_doc (sym, GETTEXT ("duplicate"), GETTEXT ("subr"), pos); goto weird; } XSUBR (fun)->doc = (char *) (- XINT (offset)); } else if (CONSP (fun)) { /* If it's a lisp form, stick it in the form. */ tem = XCAR (fun); if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTP (XCAR (tem))) { Lisp_Object old = XCAR (tem); if (!ZEROP (old)) { weird_doc (sym, GETTEXT ("duplicate"), (EQ (tem, Qlambda) ? GETTEXT ("lambda") : GETTEXT ("autoload")), pos); /* In the case of duplicate doc file entries, always take the later one. But if the doc is not an int (a string, say) leave it alone. */ if (!INTP (old)) goto weird; } XCAR (tem) = offset; } else if (!CONSP (tem)) { weird_doc (sym, GETTEXT ("!CONSP(tem)"), GETTEXT ("function"), pos); goto cont; } else { /* DOC string is a string not integer 0 */ #if 0 weird_doc (sym, GETTEXT ("!INTP(XCAR(tem))"), GETTEXT ("function"), pos); #endif goto cont; } } else { weird_doc (sym, GETTEXT ("not lambda or autoload"), GETTEXT ("function"), pos); goto cont; } } else if (COMPILED_FUNCTIONP (fun)) { /* Compiled-Function objects sometimes have slots for it. */ Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun); /* This compiled-function object must have a slot for the docstring, since we've found a docstring for it. Unless there were multiple definitions of it, and the latter one didn't have any doc, which is a legal if slightly bogus situation, so don't blow up. */ if (! (f->flags.documentationp)) { weird_doc (sym, GETTEXT ("no doc slot"), GETTEXT ("bytecode"), pos); goto weird; } else { Lisp_Object old = compiled_function_documentation (f); if (!ZEROP (old)) { weird_doc (sym, GETTEXT ("duplicate"), GETTEXT ("bytecode"), pos); /* In the case of duplicate doc file entries, always take the later one. But if the doc is not an int (a string, say) leave it alone. */ if (!INTP (old)) goto weird; } set_compiled_function_documentation (f, offset); } } else { /* Otherwise the function is undefined or otherwise weird. Ignore it. */ weird_doc (sym, GETTEXT ("weird function"), GETTEXT ("function"), pos); goto weird; } } else { /* lose: */ signal_error (Qfile_error, "DOC file invalid at position", make_int (pos)); weird: /* goto lose */; } } } cont: pos += end - buf; filled -= end - buf; memmove (buf, end, filled); } retry_close (fd); return Qnil; } #if 1 /* Don't warn about functions whose doc was lost because they were wrapped by advice-freeze.el... */ static int kludgily_ignore_lost_doc_p (Lisp_Object sym) { # define kludge_prefix "ad-Orig-" Lisp_Object name = XSYMBOL (sym)->name; return (XSTRING_LENGTH (name) > (Bytecount) (sizeof (kludge_prefix)) && !qxestrncmp_ascii (XSTRING_DATA (name), kludge_prefix, sizeof (kludge_prefix) - 1)); # undef kludge_prefix } #else # define kludgily_ignore_lost_doc_p(sym) 0 #endif static int verify_doc_mapper (Lisp_Object sym, void *arg) { Lisp_Object closure = * (Lisp_Object *) arg; if (!NILP (Ffboundp (sym))) { int doc = 0; Lisp_Object fun = XSYMBOL (sym)->function; if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) fun = XCDR (fun); if (SUBRP (fun)) doc = (EMACS_INT) XSUBR (fun)->doc; else if (SYMBOLP (fun)) doc = -1; else if (KEYMAPP (fun)) doc = -1; else if (CONSP (fun)) { Lisp_Object tem = XCAR (fun); if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) { doc = -1; tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTP (XCAR (tem))) doc = XINT (XCAR (tem)); } } else if (COMPILED_FUNCTIONP (fun)) { Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun); if (! (f->flags.documentationp)) doc = -1; else { Lisp_Object tem = compiled_function_documentation (f); if (INTP (tem)) doc = XINT (tem); } } if (doc == 0 && !kludgily_ignore_lost_doc_p (sym)) { message ("Warning: doc lost for function %s.", XSTRING_DATA (XSYMBOL (sym)->name)); XCDR (closure) = Qt; } } if (!NILP (Fboundp (sym))) { Lisp_Object doc = Fget (sym, Qvariable_documentation, Qnil); if (ZEROP (doc)) { message ("Warning: doc lost for variable %s.", XSTRING_DATA (XSYMBOL (sym)->name)); XCDR (closure) = Qt; } } return 0; /* Never stop */ } DEFUN ("Verify-documentation", Fverify_documentation, 0, 0, 0, /* Used to make sure everything went well with Snarf-documentation. Writes to stderr if not. */ ()) { Lisp_Object closure = Fcons (Qnil, Qnil); struct gcpro gcpro1; GCPRO1 (closure); map_obarray (Vobarray, verify_doc_mapper, &closure); if (!NILP (Fcdr (closure))) message ("\n" "This is usually because some files were preloaded by loaddefs.el or\n" "site-load.el, but were not passed to make-docfile by Makefile.\n"); UNGCPRO; return NILP (Fcdr (closure)) ? Qt : Qnil; } DEFUN ("substitute-command-keys", Fsubstitute_command_keys, 1, 1, 0, /* Substitute key descriptions for command names in STRING. Return a new string which is STRING with substrings of the form \\=\\[COMMAND] replaced by either: a keystroke sequence that will invoke COMMAND, or "M-x COMMAND" if COMMAND is not on any keys. Substrings of the form \\=\\{MAPVAR} are replaced by summaries \(made by `describe-bindings') of the value of MAPVAR, taken as a keymap. Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR as the keymap for future \\=\\[COMMAND] substrings. \\=\\= quotes the following character and is discarded; thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output. */ (string)) { /* This function can GC */ Ibyte *buf; int changed = 0; REGISTER Ibyte *strdata; REGISTER Ibyte *bufp; Bytecount strlength; Bytecount idx; Bytecount bsize; Ibyte *new; Lisp_Object tem = Qnil; Lisp_Object keymap = Qnil; Lisp_Object name = Qnil; Ibyte *start; Bytecount length; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; if (NILP (string)) return Qnil; CHECK_STRING (string); GCPRO4 (string, tem, keymap, name); /* There is the possibility that the string is not destined for a translating stream, and it could be argued that we should do the same thing here as in Fformat(), but there are very few times when this will be the case and many calls to this function would have to have `gettext' calls added. (I18N3) */ string = LISP_GETTEXT (string); /* KEYMAP is either nil (which means search all the active keymaps) or a specified local map (which means search just that and the global map). If non-nil, it might come from Voverriding_local_map, or from a \\<mapname> construct in STRING itself.. */ #if 0 /* FSFmacs */ /* This is really weird and garbagey. If keymap is nil and there's an overriding-local-map, `where-is-internal' will correctly note this, so there's no reason to do it here. Maybe FSFmacs `where-is-internal' is broken. */ /* keymap = current_kboard->Voverriding_terminal_local_map; if (NILP (keymap)) keymap = Voverriding_local_map; */ #endif strlength = XSTRING_LENGTH (string); bsize = ITEXT_ZTERM_SIZE + strlength; buf = xnew_ibytes (bsize); bufp = buf; /* Have to reset strdata every time GC might be called */ strdata = XSTRING_DATA (string); for (idx = 0; idx < strlength; ) { Ibyte *strp = strdata + idx; if (strp[0] != '\\') { /* just copy other chars */ /* As it happens, this will work with Mule even if the character quoted is multi-byte; the remaining multi-byte characters will just be copied by this loop. */ *bufp++ = *strp; idx++; } else switch (strp[1]) { default: { /* just copy unknown escape sequences */ *bufp++ = *strp; idx++; break; } case '=': { /* \= quotes the next character; thus, to put in \[ without its special meaning, use \=\[. */ /* As it happens, this will work with Mule even if the character quoted is multi-byte; the remaining multi-byte characters will just be copied by this loop. */ changed = 1; *bufp++ = strp[2]; idx += 3; break; } case '[': { changed = 1; idx += 2; /* skip \[ */ strp += 2; start = strp; while ((idx < strlength) && *strp != ']') { strp++; idx++; } length = strp - start; idx++; /* skip ] */ tem = Fintern (make_string (start, length), Qnil); tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil); #if 0 /* FSFmacs */ /* Disregard menu bar bindings; it is positively annoying to mention them when there's no menu bar, and it isn't terribly useful even when there is a menu bar. */ if (!NILP (tem)) { firstkey = Faref (tem, Qzero); if (EQ (firstkey, Qmenu_bar)) tem = Qnil; } #endif if (NILP (tem)) /* but not on any keys */ { new = (Ibyte *) xrealloc (buf, bsize += 4); bufp += new - buf; buf = new; memcpy (bufp, "M-x ", 4); bufp += 4; goto subst; } else { /* function is on a key */ tem = Fkey_description (tem); goto subst_string; } } case '{': case '<': { Lisp_Object buffer = Fget_buffer_create (QSsubstitute); struct buffer *buf_ = XBUFFER (buffer); Fbuffer_disable_undo (buffer); Ferase_buffer (buffer); /* \{foo} is replaced with a summary of keymap (symbol-value foo). \<foo> just sets the keymap used for \[cmd]. */ changed = 1; idx += 2; /* skip \{ or \< */ strp += 2; start = strp; while ((idx < strlength) && *strp != '}' && *strp != '>') { strp++; idx++; } length = strp - start; idx++; /* skip } or > */ /* Get the value of the keymap in TEM, or nil if undefined. Do this while still in the user's current buffer in case it is a local variable. */ name = Fintern (make_string (start, length), Qnil); tem = Fboundp (name); if (! NILP (tem)) { tem = Fsymbol_value (name); if (! NILP (tem)) tem = get_keymap (tem, 0, 1); } if (NILP (tem)) { buffer_insert_c_string (buf_, "(uses keymap \""); buffer_insert_lisp_string (buf_, Fsymbol_name (name)); buffer_insert_c_string (buf_, "\", which is not currently defined) "); if (start[-1] == '<') keymap = Qnil; } else if (start[-1] == '<') keymap = tem; else describe_map_tree (tem, 1, Qnil, Qnil, 0, buffer); tem = make_string_from_buffer (buf_, BUF_BEG (buf_), BUF_Z (buf_) - BUF_BEG (buf_)); Ferase_buffer (buffer); } goto subst_string; subst_string: start = XSTRING_DATA (tem); length = XSTRING_LENGTH (tem); subst: bsize += length; new = (Ibyte *) xrealloc (buf, bsize); bufp += new - buf; buf = new; memcpy (bufp, start, length); bufp += length; /* Reset STRDATA in case gc relocated it. */ strdata = XSTRING_DATA (string); break; } } if (changed) /* don't bother if nothing substituted */ tem = make_string (buf, bufp - buf); else tem = string; xfree (buf, Ibyte *); UNGCPRO; return tem; } /************************************************************************/ /* initialization */ /************************************************************************/ void syms_of_doc (void) { DEFSUBR (Fdocumentation); DEFSUBR (Fdocumentation_property); DEFSUBR (Fsnarf_documentation); DEFSUBR (Fverify_documentation); DEFSUBR (Fsubstitute_command_keys); } void vars_of_doc (void) { DEFVAR_LISP ("internal-doc-file-name", &Vinternal_doc_file_name /* Name of file containing documentation strings of built-in symbols. */ ); Vinternal_doc_file_name = Qnil; QSsubstitute = build_string (" *substitute*"); staticpro (&QSsubstitute); }
