Commit b23b5a5b authored by Paul Eggert's avatar Paul Eggert

Declare file-scope functions and variables static if not exported.

This is more consistent, and is nicer with gcc -Wstrict-prototypes.
* ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c:
* profile.c, test-distrib.c, update-game-score.c:
Declare non-'main' functions and variables to be static.
* ebrowse.c: Omit redundant function prototypes.
parent 6d713256
2011-02-21 Paul Eggert <eggert@cs.ucla.edu>
Declare file-scope functions and variables static if not exported.
This is more consistent, and is nicer with gcc -Wstrict-prototypes.
* ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c:
* profile.c, test-distrib.c, update-game-score.c:
Declare non-'main' functions and variables to be static.
* ebrowse.c: Omit redundant function prototypes.
2011-02-20 Juanma Barranquero <lekktu@gmail.com>
* makefile.w32-in (obj): Remove md5.o.
......
This diff is collapsed.
......@@ -150,8 +150,8 @@ const char *server_file = NULL;
/* PID of the Emacs server process. */
int emacs_pid = 0;
void print_help_and_exit (void) NO_RETURN;
void fail (void) NO_RETURN;
static void print_help_and_exit (void) NO_RETURN;
static void fail (void) NO_RETURN;
struct option longopts[] =
......@@ -178,7 +178,7 @@ struct option longopts[] =
/* Like malloc but get fatal error if memory is exhausted. */
long *
static long *
xmalloc (unsigned int size)
{
long *result = (long *) malloc (size);
......@@ -192,7 +192,7 @@ xmalloc (unsigned int size)
/* Like strdup but get a fatal error if memory is exhausted. */
char *
static char *
xstrdup (const char *s)
{
char *result = strdup (s);
......@@ -473,7 +473,7 @@ ttyname (int fd)
/* Display a normal or error message.
On Windows, use a message box if compiled as a Windows app. */
void
static void
message (int is_error, const char *message, ...)
{
char msg[2048];
......@@ -504,7 +504,7 @@ message (int is_error, const char *message, ...)
/* Decode the options from argv and argc.
The global variable `optind' will say how many arguments we used up. */
void
static void
decode_options (int argc, char **argv)
{
alternate_editor = egetenv ("ALTERNATE_EDITOR");
......@@ -630,7 +630,7 @@ an empty string");
}
void
static void
print_help_and_exit (void)
{
/* Spaces and tabs are significant in this message; they're chosen so the
......@@ -675,7 +675,7 @@ Report bugs with M-x report-emacs-bug.\n", progname);
defined-- exit with an errorcode.
Uses argv, but gets it from the global variable main_argv.
*/
void
static void
fail (void)
{
if (alternate_editor)
......@@ -718,7 +718,7 @@ HSOCKET emacs_socket = 0;
/* On Windows, the socket library was historically separate from the standard
C library, so errors are handled differently. */
void
static void
sock_err_message (const char *function_name)
{
#ifdef WINDOWSNT
......@@ -742,7 +742,7 @@ sock_err_message (const char *function_name)
- the data ends in "\n", or
- the buffer is full (but this shouldn't happen)
Otherwise, we just accumulate it. */
void
static void
send_to_emacs (HSOCKET s, const char *data)
{
while (data)
......@@ -781,7 +781,7 @@ send_to_emacs (HSOCKET s, const char *data)
return value never contains a space.
Does not change the string. Outputs the result to S. */
void
static void
quote_argument (HSOCKET s, const char *str)
{
char *copy = (char *) xmalloc (strlen (str) * 2 + 1);
......@@ -822,7 +822,7 @@ quote_argument (HSOCKET s, const char *str)
/* The inverse of quote_argument. Removes quoting in string STR by
modifying the string in place. Returns STR. */
char *
static char *
unquote_argument (char *str)
{
char *p, *q;
......@@ -853,7 +853,7 @@ unquote_argument (char *str)
}
int
static int
file_name_absolute_p (const char *filename)
{
/* Sanity check, it shouldn't happen. */
......@@ -907,7 +907,7 @@ initialize_sockets (void)
* Read the information needed to set up a TCP comm channel with
* the Emacs server: host, port, and authentication string.
*/
int
static int
get_server_config (struct sockaddr_in *server, char *authentication)
{
char dotted[32];
......@@ -965,7 +965,7 @@ get_server_config (struct sockaddr_in *server, char *authentication)
return TRUE;
}
HSOCKET
static HSOCKET
set_tcp_socket (void)
{
HSOCKET s;
......@@ -1024,7 +1024,7 @@ strprefix (const char *prefix, const char *string)
and the name in TTY_NAME, and return 1. Otherwise, fail if NOABORT
is zero, or return 0 if NOABORT is non-zero. */
int
static int
find_tty (char **tty_type, char **tty_name, int noabort)
{
char *type = egetenv ("TERM");
......@@ -1097,7 +1097,7 @@ socket_status (char *socket_name)
/* A signal handler that passes the signal to the Emacs process.
Useful for SIGWINCH. */
SIGTYPE
static SIGTYPE
pass_signal_to_emacs (int signalnum)
{
int old_errno = errno;
......@@ -1112,7 +1112,7 @@ pass_signal_to_emacs (int signalnum)
/* Signal handler for SIGCONT; notify the Emacs process that it can
now resume our tty frame. */
SIGTYPE
static SIGTYPE
handle_sigcont (int signalnum)
{
int old_errno = errno;
......@@ -1138,7 +1138,7 @@ handle_sigcont (int signalnum)
reality, we may get a SIGTSTP on C-z. Handling this signal and
notifying Emacs about it should get things under control again. */
SIGTYPE
static SIGTYPE
handle_sigtstp (int signalnum)
{
int old_errno = errno;
......@@ -1162,7 +1162,7 @@ handle_sigtstp (int signalnum)
/* Set up signal handlers before opening a frame on the current tty. */
void
static void
init_signals (void)
{
/* Set up signal handlers. */
......@@ -1182,7 +1182,7 @@ init_signals (void)
}
HSOCKET
static HSOCKET
set_local_socket (void)
{
HSOCKET s;
......@@ -1331,7 +1331,7 @@ To start the server in Emacs, type \"M-x server-start\".\n",
}
#endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */
HSOCKET
static HSOCKET
set_socket (int no_exit_if_error)
{
HSOCKET s;
......@@ -1447,7 +1447,7 @@ w32_give_focus (void)
/* Start the emacs daemon and try to connect to it. */
void
static void
start_daemon_and_retry_set_socket (void)
{
#ifndef WINDOWSNT
......@@ -1722,7 +1722,7 @@ main (int argc, char **argv)
if (rl <= 0)
break;
string[rl] = '\0';
p = string + strlen (string) - 1;
......
......@@ -198,7 +198,7 @@ xrealloc (long int *ptr, int size)
/* Initialize a linebuffer for use */
void
static void
init_linebuffer (struct linebuffer *linebuffer)
{
linebuffer->size = INITIAL_LINE_SIZE;
......@@ -208,7 +208,7 @@ init_linebuffer (struct linebuffer *linebuffer)
/* Read a line of text from `stream' into `linebuffer'.
Return the length of the line. */
long
static long
readline (struct linebuffer *linebuffer, FILE *stream)
{
char *buffer = linebuffer->buffer;
......@@ -243,7 +243,7 @@ readline (struct linebuffer *linebuffer, FILE *stream)
If there is no keyword, return NULL and don't alter *REST. */
char *
static char *
get_keyword (register char *field, char **rest)
{
static char keyword[KEYWORD_SIZE];
......@@ -268,7 +268,7 @@ get_keyword (register char *field, char **rest)
/* Nonzero if the string FIELD starts with a colon-terminated keyword. */
boolean
static boolean
has_keyword (char *field)
{
char *ignored;
......@@ -285,7 +285,7 @@ has_keyword (char *field)
We don't pay attention to overflowing WHERE;
the caller has to make it big enough. */
char *
static char *
add_field (line_list the_list, register char *field, register char *where)
{
register char c;
......@@ -341,7 +341,7 @@ add_field (line_list the_list, register char *field, register char *where)
return where;
}
line_list
static line_list
make_file_preface (void)
{
char *the_string, *temp;
......@@ -385,7 +385,7 @@ make_file_preface (void)
return result;
}
void
static void
write_line_list (register line_list the_list, FILE *the_stream)
{
for ( ;
......@@ -398,7 +398,7 @@ write_line_list (register line_list the_list, FILE *the_stream)
return;
}
int
static int
close_the_streams (void)
{
register stream_list rem;
......@@ -411,7 +411,7 @@ close_the_streams (void)
return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE);
}
void
static void
add_a_stream (FILE *the_stream, int (*closing_action) (FILE *))
{
stream_list old = the_streams;
......@@ -422,7 +422,7 @@ add_a_stream (FILE *the_stream, int (*closing_action) (FILE *))
return;
}
int
static int
my_fclose (FILE *the_file)
{
putc ('\n', the_file);
......@@ -430,7 +430,7 @@ my_fclose (FILE *the_file)
return fclose (the_file);
}
boolean
static boolean
open_a_file (char *name)
{
FILE *the_stream = fopen (name, "a");
......@@ -445,7 +445,7 @@ open_a_file (char *name)
return false;
}
void
static void
put_string (char *s)
{
register stream_list rem;
......@@ -456,7 +456,7 @@ put_string (char *s)
return;
}
void
static void
put_line (const char *string)
{
register stream_list rem;
......@@ -516,7 +516,7 @@ put_line (const char *string)
the header name), and THE_LIST holds the continuation lines if any.
Call open_a_file for each file. */
void
static void
setup_files (register line_list the_list, register char *field)
{
register char *start;
......@@ -552,7 +552,7 @@ setup_files (register line_list the_list, register char *field)
/* Compute the total size of all recipient names stored in THE_HEADER.
The result says how big to make the buffer to pass to parse_header. */
int
static int
args_size (header the_header)
{
register header old = the_header;
......@@ -583,7 +583,7 @@ args_size (header the_header)
Also, if the header has any FCC fields, call setup_files for each one. */
void
static void
parse_header (header the_header, register char *where)
{
register header old = the_header;
......@@ -615,7 +615,7 @@ parse_header (header the_header, register char *where)
one for each line in that field.
Continuation lines are grouped in the headers they continue. */
header
static header
read_header (void)
{
register header the_header = ((header) NULL);
......@@ -669,7 +669,7 @@ read_header (void)
return the_header->next;
}
void
static void
write_header (header the_header)
{
register header old = the_header;
......
......@@ -66,12 +66,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
#endif
int scan_file (char *filename);
int scan_lisp_file (const char *filename, const char *mode);
int scan_c_file (char *filename, const char *mode);
void fatal (const char *s1, const char *s2) NO_RETURN;
void start_globals (void);
void write_globals (void);
static int scan_file (char *filename);
static int scan_lisp_file (const char *filename, const char *mode);
static int scan_c_file (char *filename, const char *mode);
static void fatal (const char *s1, const char *s2) NO_RETURN;
static void start_globals (void);
static void write_globals (void);
#ifdef MSDOS
/* s/msdos.h defines this as sys_chdir, but we're not linking with the
......@@ -93,7 +93,7 @@ int generate_globals;
/* Print error message. `s1' is printf control string, `s2' is arg for it. */
/* VARARGS1 */
void
static void
error (const char *s1, const char *s2)
{
fprintf (stderr, "%s: ", progname);
......@@ -104,7 +104,7 @@ error (const char *s1, const char *s2)
/* Print error message and exit. */
/* VARARGS1 */
void
static void
fatal (const char *s1, const char *s2)
{
error (s1, s2);
......@@ -113,7 +113,7 @@ fatal (const char *s1, const char *s2)
/* Like malloc but get fatal error if memory is exhausted. */
void *
static void *
xmalloc (unsigned int size)
{
void *result = (void *) malloc (size);
......@@ -124,7 +124,7 @@ xmalloc (unsigned int size)
/* Like realloc but get fatal error if memory is exhausted. */
void *
static void *
xrealloc (void *arg, unsigned int size)
{
void *result = (void *) realloc (arg, size);
......@@ -212,7 +212,7 @@ main (int argc, char **argv)
}
/* Add a source file name boundary marker in the output file. */
void
static void
put_filename (char *filename)
{
char *tmp;
......@@ -231,7 +231,7 @@ put_filename (char *filename)
/* Read file FILENAME and output its doc strings to outfile. */
/* Return 1 if file is not found, 0 if it is found. */
int
static int
scan_file (char *filename)
{
......@@ -247,7 +247,7 @@ scan_file (char *filename)
return scan_c_file (filename, READ_TEXT);
}
void
static void
start_globals (void)
{
fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n");
......@@ -255,7 +255,7 @@ start_globals (void)
fprintf (outfile, "struct emacs_globals {\n");
}
char buf[128];
static char buf[128];
/* Some state during the execution of `read_c_string_or_comment'. */
struct rcsoc_state
......@@ -388,7 +388,7 @@ scan_keyword_or_put_char (int ch, struct rcsoc_state *state)
at the beginning of a line will be removed, and *SAW_USAGE set to
true if any were encountered. */
int
static int
read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usage)
{
register int c;
......@@ -476,7 +476,7 @@ read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usa
/* Write to file OUT the argument names of function FUNC, whose text is in BUF.
MINARGS and MAXARGS are the minimum and maximum number of arguments. */
void
static void
write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
{
register char *p;
......@@ -610,7 +610,7 @@ compare_globals (const void *a, const void *b)
return strcmp (ga->name, gb->name);
}
void
static void
write_globals (void)
{
int i;
......@@ -652,7 +652,7 @@ write_globals (void)
Looks for DEFUN constructs such as are defined in ../src/lisp.h.
Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
int
static int
scan_c_file (char *filename, const char *mode)
{
FILE *infile;
......@@ -979,7 +979,7 @@ scan_c_file (char *filename, const char *mode)
An entry is output only if DOCSTRING has \ newline just after the opening "
*/
void
static void
skip_white (FILE *infile)
{
char c = ' ';
......@@ -988,7 +988,7 @@ skip_white (FILE *infile)
ungetc (c, infile);
}
void
static void
read_lisp_symbol (FILE *infile, char *buffer)
{
char c;
......@@ -1016,7 +1016,7 @@ read_lisp_symbol (FILE *infile, char *buffer)
skip_white (infile);
}
int
static int
scan_lisp_file (const char *filename, const char *mode)
{
FILE *infile;
......
......@@ -161,7 +161,7 @@ static int mbx_delimit_end (FILE *mbf);
#endif
/* Nonzero means this is name of a lock file to delete on fatal error. */
char *delete_lockname;
static char *delete_lockname;
int
main (int argc, char **argv)
......@@ -672,12 +672,12 @@ xmalloc (unsigned int size)
#define OK 0
#define DONE 1
char *progname;
FILE *sfi;
FILE *sfo;
char ibuffer[BUFSIZ];
char obuffer[BUFSIZ];
char Errmsg[200]; /* POP errors, at least, can exceed
static char *progname;
static FILE *sfi;
static FILE *sfo;
static char ibuffer[BUFSIZ];
static char obuffer[BUFSIZ];
static char Errmsg[200]; /* POP errors, at least, can exceed
the original length of 80. */
/*
......
......@@ -38,7 +38,7 @@ static char time_string[30];
/* Reset the stopwatch to zero. */
void
static void
reset_watch (void)
{
EMACS_GET_TIME (TV1);
......@@ -49,7 +49,7 @@ reset_watch (void)
is returned as a string with the format <seconds>.<micro-seconds>
If reset_watch was not called yet, exit. */
char *
static char *
get_time (void)
{
if (watch_not_started)
......
......@@ -26,18 +26,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Break string in two parts to avoid buggy C compilers that ignore characters
after nulls in strings. */
char string1[] = "Testing distribution of nonprinting chars:\n\
static char string1[] = "Testing distribution of nonprinting chars:\n\
Should be 0177: \177 Should be 0377: \377 Should be 0212: \212.\n\
Should be 0000: ";
char string2[] = ".\n\
static char string2[] = ".\n\
This file is read by the `test-distribution' program.\n\
If you change it, you will make that program fail.\n";
char buf[300];
static char buf[300];
/* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */
int
static int
cool_read (int fd, char *buf, size_t size)
{
ssize_t num;
......
......@@ -57,7 +57,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
extern char *optarg;
extern int optind, opterr;
int usage (int err) NO_RETURN;
static int usage (int err) NO_RETURN;
#define MAX_ATTEMPTS 5
#define MAX_SCORES 200
......@@ -68,7 +68,7 @@ int usage (int err) NO_RETURN;
#define difftime(t1, t0) (double)((t1) - (t0))
#endif
int
static int
usage (int err)
{
fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n");
......@@ -80,8 +80,8 @@ usage (int err)
exit (err);
}
int lock_file (const char *filename, void **state);
int unlock_file (const char *filename, void *state);
static int lock_file (const char *filename, void **state);
static int unlock_file (const char *filename, void *state);
struct score_entry
{
......@@ -90,24 +90,24 @@ struct score_entry
char *data;
};
int read_scores (const char *filename, struct score_entry **scores,
int *count);
int push_score (struct score_entry **scores, int *count,
int newscore, char *username, char *newdata);
void sort_scores (struct score_entry *scores, int count, int reverse);
int write_scores (const char *filename, const struct score_entry *scores,
int count);
static int read_scores (const char *filename, struct score_entry **scores,
int *count);
static int push_score (struct score_entry **scores, int *count,
int newscore, char *username, char *newdata);
static void sort_scores (struct score_entry *scores, int count, int reverse);
static int write_scores (const char *filename,
const struct score_entry *scores, int count);
void lose (const char *msg) NO_RETURN;
static void lose (const char *msg) NO_RETURN;
void
static void
lose (const char *msg)
{
fprintf (stderr, "%s\n", msg);
exit (EXIT_FAILURE);
}
void lose_syserr (const char *msg) NO_RETURN;
static void lose_syserr (const char *msg) NO_RETURN;
/* Taken from sysdep.c. */
#ifndef HAVE_STRERROR
......@@ -126,14 +126,14 @@ strerror (errnum)
#endif /* not WINDOWSNT */
#endif /* ! HAVE_STRERROR */
void
static void
lose_syserr (const char *msg)
{
fprintf (stderr, "%s: %s\n", msg, strerror (errno));
exit (EXIT_FAILURE);
}
char *
static char *
get_user_id (void)
{
char *name;
......@@ -154,7 +154,7 @@ get_user_id (void)
return buf->pw_name;
}
const char *
static const char *
get_prefix (int running_suid, const char *user_prefix)
{
if (!running_suid && user_prefix == NULL)
......@@ -258,7 +258,7 @@ main (int argc, char **argv)
exit (EXIT_SUCCESS);
}
int
static int
read_score (FILE *f, struct score_entry *score)
{
int c;
......@@ -342,7 +342,7 @@ read_score (FILE *f, struct score_entry *score)