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/process.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 624610069d8..ec96c1aa67e 100644 --- a/src/process.c +++ b/src/process.c @@ -235,6 +235,7 @@ static int process_output_skip; #define process_output_delay_count 0 #endif +INFUN (Fget_process, 1); static int keyboard_bit_set (SELECT_TYPE *); static void deactivate_process (Lisp_Object); static void status_notify (struct Lisp_Process *); @@ -782,7 +783,7 @@ nil, indicating the current buffer's process. */) return Qnil; } -DEFUN ("process-status", Fprocess_status, Sprocess_status, 1, 1, 0, +DEFUE ("process-status", Fprocess_status, Sprocess_status, 1, 1, 0, doc: /* Return the status of PROCESS. The returned value is one of the following symbols: run -- for a process that is running. @@ -1083,7 +1084,7 @@ DEFUN ("process-query-on-exit-flag", } #ifdef DATAGRAM_SOCKETS -Lisp_Object Fprocess_datagram_address (Lisp_Object process); +INFUN (Fprocess_datagram_address, 1); #endif DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, @@ -5775,7 +5776,7 @@ don't send the signal. */) return process; } -DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0, +DEFUE ("kill-process", Fkill_process, Skill_process, 0, 2, 0, doc: /* Kill process PROCESS. May be process or name of one. See function `interrupt-process' for more details on usage. */) (Lisp_Object process, Lisp_Object current_group) @@ -6915,7 +6916,7 @@ close_process_descs (void) #endif } -DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, +DEFUE ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, doc: /* Return the (or a) process associated with BUFFER. BUFFER may be a buffer or the name of one. */) (register Lisp_Object buffer) @@ -6982,8 +6983,8 @@ kill_buffer_processes (Lisp_Object buffer) #endif /* subprocesses */ } -DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p, - 0, 0, 0, +DEFUE ("waiting-for-user-input-p", Fwaiting_for_user_input_p, + Swaiting_for_user_input_p, 0, 0, 0, doc: /* Returns non-nil if Emacs is waiting for input from the user. This is intended for use by asynchronous process output filters and sentinels. */) (void) -- 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/process.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index ec96c1aa67e..89d04081eb7 100644 --- a/src/process.c +++ b/src/process.c @@ -127,22 +127,24 @@ int inhibit_sentinels; #ifdef subprocesses -Lisp_Object Qprocessp; -Lisp_Object Qrun, Qstop, Qsignal; -Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; -Lisp_Object Qlocal, Qipv4, Qdatagram, Qseqpacket; -Lisp_Object Qreal, Qnetwork, Qserial; +static Lisp_Object Qprocessp; +static Lisp_Object Qrun, Qstop, Qsignal; +static Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; +Lisp_Object Qlocal; +static Lisp_Object Qipv4, Qdatagram, Qseqpacket; +static Lisp_Object Qreal, Qnetwork, Qserial; #ifdef AF_INET6 -Lisp_Object Qipv6; +static Lisp_Object Qipv6; #endif -Lisp_Object QCport, QCspeed, QCprocess; +static Lisp_Object QCport, QCprocess; +Lisp_Object QCspeed; Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; -Lisp_Object QCbuffer, QChost, QCservice; -Lisp_Object QClocal, QCremote, QCcoding; -Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; -Lisp_Object QCsentinel, QClog, QCoptions, QCplist; -Lisp_Object Qlast_nonmenu_event; +static Lisp_Object QCbuffer, QChost, QCservice; +static Lisp_Object QClocal, QCremote, QCcoding; +static Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; +static Lisp_Object QCsentinel, QClog, QCoptions, QCplist; +static Lisp_Object Qlast_nonmenu_event; /* QCfamily is declared and initialized in xfaces.c, QCfilter in keyboard.c. */ extern Lisp_Object QCfamily, QCfilter; -- cgit v1.2.1 From f44bd759cb8b78ee8759f4681643807fe6c572ff Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 15:28:14 -0700 Subject: * editfns.c: Move a (normally-unused) function to its only use. * editfns.c, lisp.h (get_operating_system_release): Remove. * process.c (init_process) [DARWIN_OS]: Do it inline, as it is not worth the hassle of breaking this out. --- src/process.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 89d04081eb7..51546e7c78a 100644 --- a/src/process.c +++ b/src/process.c @@ -7188,7 +7188,9 @@ init_process (void) processes. As such, we only change the default value. */ if (initialized) { - const char *release = get_operating_system_release (); + char const *release = (STRINGP (Voperating_system_release) + ? SSDATA (Voperating_system_release) + : 0); if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION && release[1] == '.')) { Vprocess_connection_type = Qnil; -- cgit v1.2.1 From 40ccffa6ff0f62689cac373e3d21d25084c1b7b3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Apr 2011 19:16:00 -0700 Subject: * process.c: Make symbols static if they're not exported. (process_tick, update_tick, create_process, chan_process): (Vprocess_alist, proc_buffered_char, datagram_access): (fd_callback_data, send_process_frame, process_sent_to): Now static. (deactivate_process): Mark defn as static, as well as decl. * lisp.h (create_process): Remove decl. * process.h (chan_process, Vprocess_alist): Remove decls. --- src/process.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 51546e7c78a..7efbab11190 100644 --- a/src/process.c +++ b/src/process.c @@ -165,12 +165,10 @@ extern Lisp_Object QCfilter; extern int h_errno; #endif -/* These next two vars are non-static since sysdep.c uses them in the - emulation of `select'. */ /* Number of events of change of status of a process. */ -int process_tick; +static int process_tick; /* Number of events for which the user or sentinel has been notified. */ -int update_tick; +static int update_tick; /* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */ @@ -238,6 +236,7 @@ static int process_output_skip; #endif INFUN (Fget_process, 1); +static void create_process (Lisp_Object, char **, Lisp_Object); static int keyboard_bit_set (SELECT_TYPE *); static void deactivate_process (Lisp_Object); static void status_notify (struct Lisp_Process *); @@ -287,10 +286,10 @@ static int max_process_desc; static int max_input_desc; /* Indexed by descriptor, gives the process (if any) for that descriptor */ -Lisp_Object chan_process[MAXDESC]; +static Lisp_Object chan_process[MAXDESC]; /* Alist of elements (NAME . PROCESS) */ -Lisp_Object Vprocess_alist; +static Lisp_Object Vprocess_alist; /* Buffered-ahead input char from process, indexed by channel. -1 means empty (no char is buffered). @@ -298,8 +297,7 @@ Lisp_Object Vprocess_alist; output from the process is to read at least one char. Always -1 on systems that support FIONREAD. */ -/* Don't make static; need to access externally. */ -int proc_buffered_char[MAXDESC]; +static int proc_buffered_char[MAXDESC]; /* Table of `struct coding-system' for each process. */ static struct coding_system *proc_decode_coding_system[MAXDESC]; @@ -307,7 +305,7 @@ static struct coding_system *proc_encode_coding_system[MAXDESC]; #ifdef DATAGRAM_SOCKETS /* Table of `partner address' for datagram sockets. */ -struct sockaddr_and_len { +static struct sockaddr_and_len { struct sockaddr *sa; int len; } datagram_address[MAXDESC]; @@ -323,7 +321,7 @@ static int pty_max_bytes; -struct fd_callback_data +static struct fd_callback_data { fd_callback func; void *data; @@ -1521,7 +1519,7 @@ create_process_1 (struct atimer *timer) } -void +static void create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) { int inchannel, outchannel; @@ -3793,7 +3791,7 @@ FLAGS is the current flags of the interface. */) /* Turn off input and output for process PROC. */ -void +static void deactivate_process (Lisp_Object proc) { register int inchannel, outchannel; @@ -5219,8 +5217,8 @@ read_process_output (Lisp_Object proc, register int channel) /* Sending data to subprocess */ -jmp_buf send_process_frame; -Lisp_Object process_sent_to; +static jmp_buf send_process_frame; +static Lisp_Object process_sent_to; static void send_process_trap (int ignore) -- 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/process.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 7efbab11190..0cec8977ad0 100644 --- a/src/process.c +++ b/src/process.c @@ -783,7 +783,7 @@ nil, indicating the current buffer's process. */) return Qnil; } -DEFUE ("process-status", Fprocess_status, Sprocess_status, 1, 1, 0, +DEFUN ("process-status", Fprocess_status, Sprocess_status, 1, 1, 0, doc: /* Return the status of PROCESS. The returned value is one of the following symbols: run -- for a process that is running. @@ -5776,7 +5776,7 @@ don't send the signal. */) return process; } -DEFUE ("kill-process", Fkill_process, Skill_process, 0, 2, 0, +DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0, doc: /* Kill process PROCESS. May be process or name of one. See function `interrupt-process' for more details on usage. */) (Lisp_Object process, Lisp_Object current_group) @@ -6916,7 +6916,7 @@ close_process_descs (void) #endif } -DEFUE ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, +DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, doc: /* Return the (or a) process associated with BUFFER. BUFFER may be a buffer or the name of one. */) (register Lisp_Object buffer) @@ -6983,7 +6983,7 @@ kill_buffer_processes (Lisp_Object buffer) #endif /* subprocesses */ } -DEFUE ("waiting-for-user-input-p", Fwaiting_for_user_input_p, +DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p, 0, 0, 0, doc: /* Returns non-nil if Emacs is waiting for input from the user. This is intended for use by asynchronous process output filters and sentinels. */) -- 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/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 0cec8977ad0..741f2e363f3 100644 --- a/src/process.c +++ b/src/process.c @@ -235,7 +235,7 @@ static int process_output_skip; #define process_output_delay_count 0 #endif -INFUN (Fget_process, 1); +static Lisp_Object Fget_process (Lisp_Object); static void create_process (Lisp_Object, char **, Lisp_Object); static int keyboard_bit_set (SELECT_TYPE *); static void deactivate_process (Lisp_Object); @@ -1084,7 +1084,7 @@ DEFUN ("process-query-on-exit-flag", } #ifdef DATAGRAM_SOCKETS -INFUN (Fprocess_datagram_address, 1); +static Lisp_Object Fprocess_datagram_address (Lisp_Object); #endif DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, -- cgit v1.2.1 From 6c60eb9f2c4778c5fc07dd44b283edeb8583a3a0 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 14 Apr 2011 21:58:49 -0300 Subject: * src/process.c (Qprocessp): Don't declare static. * src/lisp.h (Qprocessp): Declare again. --- src/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 741f2e363f3..e9ac324845b 100644 --- a/src/process.c +++ b/src/process.c @@ -24,7 +24,7 @@ along with GNU Emacs. If not, see . */ #include #include #include -#include /* some typedefs are used in sys/file.h */ +#include /* Some typedefs are used in sys/file.h. */ #include #include #include @@ -127,7 +127,7 @@ int inhibit_sentinels; #ifdef subprocesses -static Lisp_Object Qprocessp; +Lisp_Object Qprocessp; static Lisp_Object Qrun, Qstop, Qsignal; static Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; Lisp_Object Qlocal; -- cgit v1.2.1