From 16a97296c05ec9d5bb4ffeae9dce90fc63f578ed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 18:41:15 -0700 Subject: Make Emacs functions such as Fatom 'static' by default. This makes it easier for human readers (and static analyzers) to see whether these functions can be called from other modules. DEFUN now defines a static function. To make the function external so that it can be used in other C modules, use the new macro DEFUE. * lisp.h (DEFINE_FUNC): New macro, with the old contents of DEFUN. (DEFUN): Rewrite in terms of DEFINE_FUNC. It now generates a static function definition. Use DEFUE if you want an extern one. (DEFUE, INFUN): New macros. (Funibyte_char_to_multibyte, Fsyntax_table_p, Finit_image_library): (Feval_region, Fbacktrace, Ffetch_bytecode, Fswitch_to_buffer): (Ffile_executable_p, Fmake_symbolic_link, Fcommand_execute): (Fget_process, Fdocumentation_property, Fbyte_code, Ffile_attributes): Remove decls, since these functions are now static. (Funintern, Fget_internal_run_time): New decls, since these functions were already external. * alloc.c, buffer.c, callint.c, callproc.c, casefiddle.c, casetab.c: * ccl.c, character.c, chartab.c, cmds.c, coding.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, floatfns.c: * fns.c, font.c, fontset.c, frame.c, image.c, indent.c: * keyboard.c, keymap.c, lread.c: * macros.c, marker.c, menu.c, minibuf.c, print.c, process.c, search.c: * syntax.c, term.c, terminal.c, textprop.c, undo.c: * window.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xsettings.c: Mark functions with DEFUE instead of DEFUN, if they are used in other modules. * buffer.c (Fset_buffer_major_mode, Fdelete_overlay): New forward decls for now-static functions. * buffer.h (Fdelete_overlay): Remove decl. * callproc.c (Fgetenv_internal): Mark as internal. * composite.c (Fremove_list_of_text_properties): Remove decl. (Fcomposition_get_gstring): New forward static decl. * composite.h (Fcomposite_get_gstring): Remove decl. * dired.c (Ffile_attributes): New forward static decl. * doc.c (Fdocumntation_property): New forward static decl. * eval.c (Ffetch_bytecode): New forward static decl. (Funintern): Remove extern decl; now in .h file where it belongs. * fileio.c (Fmake_symbolic_link): New forward static decl. * image.c (Finit_image_library): New forward static decl. * insdel.c (Fcombine_after_change_execute): Make forward decl static. * intervals.h (Fprevious_property_change): (Fremove_list_of_text_properties): Remove decls. * keyboard.c (Fthis_command_keys): Remove decl. (Fcommand_execute): New forward static decl. * keymap.c (Flookup_key): New forward static decl. (Fcopy_keymap): Now static. * keymap.h (Flookup_key): Remove decl. * process.c (Fget_process): New forward static decl. (Fprocess_datagram_address): Mark as internal. * syntax.c (Fsyntax_table_p): New forward static decl. (skip_chars): Remove duplicate decl. * textprop.c (Fprevious_property_change): New forward static decl. * window.c (Fset_window_fringes, Fset_window_scroll_bars): Now internal. (Fset_window_margins, Fset_window_vscroll): New forward static decls. * window.h (Fset_window_vscroll, Fset_window_margins): Remove decls. --- src/coding.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 711ada59c85..13fcb7fb8a5 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7991,7 +7991,7 @@ preferred_coding_system (void) #ifdef emacs /*** 8. Emacs Lisp library functions ***/ -DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, +DEFUE ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, doc: /* Return t if OBJECT is nil or a coding-system. See the documentation of `define-coding-system' for information about coding-system objects. */) @@ -8006,7 +8006,7 @@ about coding-system objects. */) return Qt; } -DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, +DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system, Sread_non_nil_coding_system, 1, 1, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) (Lisp_Object prompt) @@ -8021,7 +8021,7 @@ DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, return (Fintern (val, Qnil)); } -DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, +DEFUE ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. Ignores case when completing coding systems (all Emacs coding systems @@ -8041,7 +8041,7 @@ are lower-case). */) return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); } -DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, +DEFUE ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, 1, 1, 0, doc: /* Check validity of CODING-SYSTEM. If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. @@ -8976,7 +8976,7 @@ code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, } -DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, +DEFUE ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 2, 4, 0, doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. @@ -9250,7 +9250,7 @@ DEFUN ("keyboard-coding-system", } -DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, +DEFUE ("find-operation-coding-system", Ffind_operation_coding_system, Sfind_operation_coding_system, 1, MANY, 0, doc: /* Choose a coding system for an operation based on the target name. The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM). @@ -10093,7 +10093,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, return Qnil; } -DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, +DEFUE ("coding-system-base", Fcoding_system_base, Scoding_system_base, 1, 1, 0, doc: /* Return the base of CODING-SYSTEM. Any alias or subsidiary coding system is not a base coding system. */) @@ -10136,7 +10136,7 @@ DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, return AREF (spec, 1); } -DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, +DEFUE ("coding-system-eol-type", Fcoding_system_eol_type, Scoding_system_eol_type, 1, 1, 0, doc: /* Return eol-type of CODING-SYSTEM. An eol-type is an integer 0, 1, 2, or a vector of coding systems. -- cgit v1.2.1 From 955cbe7b1720f09b2991b7d981147d9cc79d52e3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 20:39:45 -0700 Subject: Declare Lisp_Object Q* variables to be 'static' if not exproted. This makes it easier for human readers (and static analyzers) to see whether these variables are used from other modules. * alloc.c, buffer.c, bytecode.c, callint.c, casetab.c, category.c: * ccl.c, character.c, charset.c, cmds.c, coding.c, composite.c: * data.c, dbusbind.c, dired.c, editfns.c, eval.c, fileio.c, fns.c: * font.c, frame.c, fringe.c, ftfont.c, image.c, keyboard.c, keymap.c: * lread.c, macros.c, minibuf.c, print.c, process.c, search.c: * sound.c, syntax.c, textprop.c, window.c, xdisp.c, xfaces.c, xfns.c: * xmenu.c, xselect.c: Declare Q* vars static if they are not used in other modules. * ccl.h, character.h, charset.h, coding.h, composite.h, font.h: * frame.h, intervals.h, keyboard.h, lisp.h, process.h, syntax.h: Remove decls of unexported vars. * keyboard.h (EVENT_HEAD_UNMODIFIED): Remove now-unused macro. --- src/coding.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 13fcb7fb8a5..d2124db73f2 100644 --- a/src/coding.c +++ b/src/coding.c @@ -300,27 +300,30 @@ encode_coding_XXX (struct coding_system *coding) Lisp_Object Vcoding_system_hash_table; -Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type; +static Lisp_Object Qcoding_system, Qeol_type; +static Lisp_Object Qcoding_aliases; Lisp_Object Qunix, Qdos; Lisp_Object Qbuffer_file_coding_system; -Lisp_Object Qpost_read_conversion, Qpre_write_conversion; -Lisp_Object Qdefault_char; +static Lisp_Object Qpost_read_conversion, Qpre_write_conversion; +static Lisp_Object Qdefault_char; Lisp_Object Qno_conversion, Qundecided; -Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5; -Lisp_Object Qbig, Qlittle; -Lisp_Object Qcoding_system_history; -Lisp_Object Qvalid_codes; -Lisp_Object QCcategory, QCmnemonic, QCdefault_char; -Lisp_Object QCdecode_translation_table, QCencode_translation_table; -Lisp_Object QCpost_read_conversion, QCpre_write_conversion; -Lisp_Object QCascii_compatible_p; +Lisp_Object Qcharset, Qutf_8; +static Lisp_Object Qiso_2022; +static Lisp_Object Qutf_16, Qshift_jis, Qbig5; +static Lisp_Object Qbig, Qlittle; +static Lisp_Object Qcoding_system_history; +static Lisp_Object Qvalid_codes; +static Lisp_Object QCcategory, QCmnemonic, QCdefault_char; +static Lisp_Object QCdecode_translation_table, QCencode_translation_table; +static Lisp_Object QCpost_read_conversion, QCpre_write_conversion; +static Lisp_Object QCascii_compatible_p; Lisp_Object Qcall_process, Qcall_process_region; Lisp_Object Qstart_process, Qopen_network_stream; -Lisp_Object Qtarget_idx; +static Lisp_Object Qtarget_idx; -Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; -Lisp_Object Qinterrupted, Qinsufficient_memory; +static Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; +static Lisp_Object Qinterrupted, Qinsufficient_memory; /* If a symbol has this property, evaluate the value to define the symbol as a coding system. */ @@ -351,8 +354,8 @@ struct coding_system safe_terminal_coding; Lisp_Object Qtranslation_table; Lisp_Object Qtranslation_table_id; -Lisp_Object Qtranslation_table_for_decode; -Lisp_Object Qtranslation_table_for_encode; +static Lisp_Object Qtranslation_table_for_decode; +static Lisp_Object Qtranslation_table_for_encode; /* Two special coding systems. */ Lisp_Object Vsjis_coding_system; -- cgit v1.2.1 From 74ab6df507f0f4707a8bd25924fbdba9d1610f4f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Apr 2011 23:58:57 -0700 Subject: * coding.h (coding, code_convert_region, encode_coding_gap): Remove decls. * coding.c (Vsjis_coding_system, Vbig5_coding_system): (iso_code_class, detect_coding, code_convert_region): Now static. (encode_coding_gap): Remove; unused. --- src/coding.c | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index d2124db73f2..c29713a5c0c 100644 --- a/src/coding.c +++ b/src/coding.c @@ -358,8 +358,8 @@ static Lisp_Object Qtranslation_table_for_decode; static Lisp_Object Qtranslation_table_for_encode; /* Two special coding systems. */ -Lisp_Object Vsjis_coding_system; -Lisp_Object Vbig5_coding_system; +static Lisp_Object Vsjis_coding_system; +static Lisp_Object Vbig5_coding_system; /* ISO2022 section */ @@ -2862,7 +2862,7 @@ encode_coding_emacs_mule (struct coding_system *coding) COMPOSITION_WITH_RULE_ALTCHARS: ESC 4 ALTCHAR [ RULE ALTCHAR ] ESC 0 CHAR [ CHAR ] ESC 1 */ -enum iso_code_class_type iso_code_class[256]; +static enum iso_code_class_type iso_code_class[256]; #define SAFE_CHARSET_P(coding, id) \ ((id) <= (coding)->max_charset_id \ @@ -6212,7 +6212,7 @@ adjust_coding_eol_type (struct coding_system *coding, int eol_seen) system is detected, update fields of CODING by the detected coding system. */ -void +static void detect_coding (struct coding_system *coding) { const unsigned char *src, *src_end; @@ -7530,30 +7530,6 @@ decode_coding_gap (struct coding_system *coding, return coding->result; } -int -encode_coding_gap (struct coding_system *coding, - EMACS_INT chars, EMACS_INT bytes) -{ - int count = SPECPDL_INDEX (); - - code_conversion_save (0, 0); - - coding->src_object = Fcurrent_buffer (); - coding->src_chars = chars; - coding->src_bytes = bytes; - coding->src_pos = -chars; - coding->src_pos_byte = -bytes; - coding->src_multibyte = chars < bytes; - coding->dst_object = coding->src_object; - coding->dst_pos = PT; - coding->dst_pos_byte = PT_BYTE; - - encode_coding (coding); - - unbind_to (count, Qnil); - return coding->result; -} - /* Decode the text in the range FROM/FROM_BYTE and TO/TO_BYTE in SRC_OBJECT into DST_OBJECT by coding context CODING. @@ -8834,7 +8810,7 @@ is nil. */) } -Lisp_Object +static Lisp_Object code_convert_region (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object dst_object, int encodep, int norecord) -- cgit v1.2.1 From a7ca3326c4740ed3ed118b794d35d235de49f346 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 22:04:02 -0700 Subject: Undo the DEFUN->DEFUE change. --- src/coding.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index c29713a5c0c..b49070e5e16 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7970,7 +7970,7 @@ preferred_coding_system (void) #ifdef emacs /*** 8. Emacs Lisp library functions ***/ -DEFUE ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, +DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, doc: /* Return t if OBJECT is nil or a coding-system. See the documentation of `define-coding-system' for information about coding-system objects. */) @@ -7985,7 +7985,7 @@ about coding-system objects. */) return Qt; } -DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system, +DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, Sread_non_nil_coding_system, 1, 1, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) (Lisp_Object prompt) @@ -8000,7 +8000,7 @@ DEFUE ("read-non-nil-coding-system", Fread_non_nil_coding_system, return (Fintern (val, Qnil)); } -DEFUE ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, +DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. Ignores case when completing coding systems (all Emacs coding systems @@ -8020,7 +8020,7 @@ are lower-case). */) return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil)); } -DEFUE ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, +DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, 1, 1, 0, doc: /* Check validity of CODING-SYSTEM. If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. @@ -8955,7 +8955,7 @@ code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, } -DEFUE ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, +DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 2, 4, 0, doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. @@ -9229,7 +9229,7 @@ DEFUN ("keyboard-coding-system", } -DEFUE ("find-operation-coding-system", Ffind_operation_coding_system, +DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, Sfind_operation_coding_system, 1, MANY, 0, doc: /* Choose a coding system for an operation based on the target name. The value names a pair of coding systems: (DECODING-SYSTEM . ENCODING-SYSTEM). @@ -10072,7 +10072,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, return Qnil; } -DEFUE ("coding-system-base", Fcoding_system_base, Scoding_system_base, +DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, 1, 1, 0, doc: /* Return the base of CODING-SYSTEM. Any alias or subsidiary coding system is not a base coding system. */) @@ -10115,7 +10115,7 @@ DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, return AREF (spec, 1); } -DEFUE ("coding-system-eol-type", Fcoding_system_eol_type, +DEFUN ("coding-system-eol-type", Fcoding_system_eol_type, Scoding_system_eol_type, 1, 1, 0, doc: /* Return eol-type of CODING-SYSTEM. An eol-type is an integer 0, 1, 2, or a vector of coding systems. -- cgit v1.2.1