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/syntax.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index 1301c0689ad..819a7542a7b 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -138,6 +138,7 @@ static EMACS_INT find_start_begv; static int find_start_modiff; +INFUN (Fsyntax_table_p, 1); static Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object); static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int); @@ -1337,7 +1338,7 @@ scan_words (register EMACS_INT from, register EMACS_INT count) return from; } -DEFUN ("forward-word", Fforward_word, Sforward_word, 0, 1, "^p", +DEFUE ("forward-word", Fforward_word, Sforward_word, 0, 1, "^p", doc: /* Move point forward ARG words (backward if ARG is negative). Normally returns t. If an edge of the buffer or a field boundary is reached, point is left there @@ -1366,9 +1367,7 @@ and the function returns nil. Field boundaries are not noticed if return val == orig_val ? Qt : Qnil; } -Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); - -DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, +DEFUE ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, doc: /* Move point forward, stopping before a char not in STRING, or at pos LIM. STRING is like the inside of a `[...]' in a regular expression except that `]' is never special and `\\' quotes `^', `-' or `\\' @@ -1383,7 +1382,7 @@ Returns the distance traveled, either zero or positive. */) return skip_chars (1, string, lim, 1); } -DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, +DEFUE ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM. See `skip-chars-forward' for details. Returns the distance traveled, either zero or negative. */) -- 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/syntax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index 819a7542a7b..96d50f9a4e3 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -95,7 +95,8 @@ along with GNU Emacs. If not, see . */ #define ST_COMMENT_STYLE (256 + 1) #define ST_STRING_STYLE (256 + 2) -Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; +static Lisp_Object Qsyntax_table_p; +static Lisp_Object Qsyntax_table, Qscan_error; /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, if not compiled with GCC. No need to mark it, since it is used -- cgit v1.2.1 From d4b43b229a8b7c104c928521001dd48bd339953c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 19:27:17 -0700 Subject: * syntax.c (syntax_temp): Define only if !__GNUC__. --- src/syntax.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index 96d50f9a4e3..518ba3bba15 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -98,10 +98,12 @@ along with GNU Emacs. If not, see . */ static Lisp_Object Qsyntax_table_p; static Lisp_Object Qsyntax_table, Qscan_error; +#ifndef __GNUC__ /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h, if not compiled with GCC. No need to mark it, since it is used only very temporarily. */ Lisp_Object syntax_temp; +#endif /* This is the internal form of the parse state used in parse-partial-sexp. */ -- 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/syntax.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index 518ba3bba15..ce203948b04 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1341,7 +1341,7 @@ scan_words (register EMACS_INT from, register EMACS_INT count) return from; } -DEFUE ("forward-word", Fforward_word, Sforward_word, 0, 1, "^p", +DEFUN ("forward-word", Fforward_word, Sforward_word, 0, 1, "^p", doc: /* Move point forward ARG words (backward if ARG is negative). Normally returns t. If an edge of the buffer or a field boundary is reached, point is left there @@ -1370,7 +1370,7 @@ and the function returns nil. Field boundaries are not noticed if return val == orig_val ? Qt : Qnil; } -DEFUE ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, +DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, doc: /* Move point forward, stopping before a char not in STRING, or at pos LIM. STRING is like the inside of a `[...]' in a regular expression except that `]' is never special and `\\' quotes `^', `-' or `\\' @@ -1385,7 +1385,7 @@ Returns the distance traveled, either zero or positive. */) return skip_chars (1, string, lim, 1); } -DEFUE ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, +DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, 0, doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM. See `skip-chars-forward' for details. Returns the distance traveled, either zero or negative. */) -- cgit v1.2.1 From cd64ea1d0df393beb93d1bdf19bd3990e3378f85 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 14 Apr 2011 12:34:42 -0700 Subject: * lisp.h (INFUN): Remove. Suggested by Dan Nicolaescu in . All uses spelled out. --- src/syntax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/syntax.c') diff --git a/src/syntax.c b/src/syntax.c index ce203948b04..031409144b1 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -141,7 +141,7 @@ static EMACS_INT find_start_begv; static int find_start_modiff; -INFUN (Fsyntax_table_p, 1); +static Lisp_Object Fsyntax_table_p (Lisp_Object); static Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object); static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int); -- cgit v1.2.1