[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103378: Merge: minor lib-src cleanup
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103378: Merge: minor lib-src cleanups |
Date: |
Mon, 21 Feb 2011 16:15:53 -0800 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103378 [merge]
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2011-02-21 16:15:53 -0800
message:
Merge: minor lib-src cleanups
added:
lib/min-max.h
modified:
ChangeLog
lib-src/ChangeLog
lib-src/Makefile.in
lib-src/ebrowse.c
lib-src/emacsclient.c
lib-src/fakemail.c
lib-src/make-docfile.c
lib-src/movemail.c
lib-src/pop.c
lib-src/profile.c
lib-src/test-distrib.c
lib-src/update-game-score.c
=== modified file 'ChangeLog'
--- a/ChangeLog 2011-02-21 20:16:43 +0000
+++ b/ChangeLog 2011-02-21 23:46:32 +0000
@@ -1,3 +1,7 @@
+2011-02-21 Paul Eggert <address@hidden>
+
+ * lib/min-max.h: New file, for "min" and "max".
+
2011-02-21 Christoph Scholtes <address@hidden>
* lib/makefile.w32-in: ($(BLD)/md5.$(O)): Added dependency on
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2011-02-21 20:00:19 +0000
+++ b/lib-src/ChangeLog 2011-02-22 00:11:56 +0000
@@ -1,3 +1,32 @@
+2011-02-21 Paul Eggert <address@hidden>
+
+ New file "lib/min-max.h".
+ * ebrowse.c (min, max): Define them by including <min-max.h>
+ instead of defining it ourselves.
+ * pop.c (min): Likewise.
+ * Makefile.in (ebrowse${EXEEXT}, pop.o): Depend on min-max.h.
+
+ * movemail.c (popmail): Report fchown failure instead of ignoring it.
+ But if the file already has the right ownership, don't worry about it.
+
+ * make-docfile.c (input_buffer): Rename variables to avoid shadowing.
+ * test-distrib.c (buf): Make this local, to avoid shadowing.
+
+ * movemail.c (main, pop_retr): Rename locals to avoid shadowing.
+ (progname, sfi, sfo, ibuffer, obuffer): Remove unused vars.
+ (DONE): Remove unused macro.
+ (DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_FROM_LINE):
+ Define these macros only in the contexts that need them.
+ * pop.c (index): Remove unused macro.
+ (KPOP_PORT): Define only if KERBEROS is defined.
+
+ 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-21 Eli Zaretskii <address@hidden>
* makefile.w32-in ($(BLD)/ctags.$(O), $(BLD)/emacsclient.$(O))
=== modified file 'lib-src/Makefile.in'
--- a/lib-src/Makefile.in 2011-01-25 04:08:28 +0000
+++ b/lib-src/Makefile.in 2011-02-22 00:08:53 +0000
@@ -325,7 +325,7 @@
-DVERSION="\"${version}\"" ${srcdir}/etags.c \
$(REGEXPOBJ) $(LOADLIBES) -o etags
-ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ../src/config.h
+ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ${srcdir}/../lib/min-max.h
../src/config.h
$(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \
${srcdir}/ebrowse.c $(LOADLIBES) -o ebrowse
@@ -350,7 +350,7 @@
movemail.o: ${srcdir}/movemail.c ../src/config.h
$(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c
-pop.o: ${srcdir}/pop.c ../src/config.h
+pop.o: ${srcdir}/pop.c ${srcdir}/../lib/min-max.h ../src/config.h
$(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c
fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h
=== modified file 'lib-src/ebrowse.c'
--- a/lib-src/ebrowse.c 2011-01-31 08:12:52 +0000
+++ b/lib-src/ebrowse.c 2011-02-21 23:22:34 +0000
@@ -41,12 +41,7 @@
#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
-/* The ubiquitous `max' and `min' macros. */
-
-#ifndef max
-#define max(X, Y) ((X) > (Y) ? (X) : (Y))
-#define min(X, Y) ((X) < (Y) ? (X) : (Y))
-#endif
+#include <min-max.h>
/* Files are read in chunks of this number of bytes. */
@@ -465,59 +460,16 @@
/* Function prototypes. */
-int yylex (void);
-void yyparse (void);
-void re_init_parser (void);
-const char *token_string (int);
-char *matching_regexp (void);
-void init_sym (void);
-struct sym *add_sym (const char *, struct sym *);
-void add_link (struct sym *, struct sym *);
-void add_member_defn (struct sym *, char *, char *,
- int, unsigned, int, int, int);
-void add_member_decl (struct sym *, char *, char *, int,
- unsigned, int, int, int, int);
-void dump_roots (FILE *);
-void *xmalloc (int);
-void xfree (void *);
-void add_global_defn (char *, char *, int, unsigned, int, int, int);
-void add_global_decl (char *, char *, int, unsigned, int, int, int);
-void add_define (char *, char *, int);
-void mark_inherited_virtual (void);
-void leave_namespace (void);
-void enter_namespace (char *);
-void register_namespace_alias (char *, struct link *);
-void insert_keyword (const char *, int);
-void re_init_scanner (void);
-void init_scanner (void);
-void process_file (char *);
-void add_search_path (char *);
-FILE *open_file (char *);
-int process_pp_line (void);
-int dump_members (FILE *, struct member *);
-void dump_sym (FILE *, struct sym *);
-int dump_tree (FILE *, struct sym *);
-struct member *find_member (struct sym *, char *, int, int, unsigned);
-struct member *add_member (struct sym *, char *, int, int, unsigned);
-void mark_virtual (struct sym *);
-struct sym *make_namespace (char *, struct sym *);
-char *sym_scope (struct sym *);
-char *sym_scope_1 (struct sym *);
-int skip_to (int);
-void skip_matching (void);
-void member (struct sym *, int);
-void class_body (struct sym *, int);
-void class_definition (struct sym *, int, int, int);
-void declaration (int);
-unsigned parm_list (int *);
-char *operator_name (int *);
-struct sym *parse_classname (void);
-struct sym *parse_qualified_ident_or_type (char **);
-void parse_qualified_param_ident_or_type (char **);
-int globals (int);
-void yyerror (const char *, const char *);
-void usage (int) NO_RETURN;
-void version (void) NO_RETURN;
+static char *matching_regexp (void);
+static struct sym *add_sym (const char *, struct sym *);
+static void add_global_defn (char *, char *, int, unsigned, int, int, int);
+static void add_global_decl (char *, char *, int, unsigned, int, int, int);
+static struct member *add_member (struct sym *, char *, int, int, unsigned);
+static void class_definition (struct sym *, int, int, int);
+static char *operator_name (int *);
+static void parse_qualified_param_ident_or_type (char **);
+static void usage (int) NO_RETURN;
+static void version (void) NO_RETURN;
@@ -528,7 +480,7 @@
/* Print an error in a printf-like style with the current input file
name and line number. */
-void
+static void
yyerror (const char *format, const char *s)
{
fprintf (stderr, "%s:%d: ", filename, yyline);
@@ -540,7 +492,7 @@
/* Like malloc but print an error and exit if not enough memory is
available. */
-void *
+static void *
xmalloc (int nbytes)
{
void *p = malloc (nbytes);
@@ -555,7 +507,7 @@
/* Like realloc but print an error and exit if out of memory. */
-void *
+static void *
xrealloc (void *p, int sz)
{
p = realloc (p, sz);
@@ -571,7 +523,7 @@
/* Like strdup, but print an error and exit if not enough memory is
available.. If S is null, return null. */
-char *
+static char *
xstrdup (char *s)
{
if (s)
@@ -588,7 +540,7 @@
/* Initialize the symbol table. This currently only sets up the
special symbol for globals (`*Globals*'). */
-void
+static void
init_sym (void)
{
global_symbols = add_sym (GLOBALS_NAME, NULL);
@@ -602,7 +554,7 @@
If a symbol for NAME already exists, return that. Otherwise
create a new symbol and set it to default values. */
-struct sym *
+static struct sym *
add_sym (const char *name, struct sym *nested_in_class)
{
struct sym *sym;
@@ -643,7 +595,7 @@
/* Add links between superclass SUPER and subclass SUB. */
-void
+static void
add_link (struct sym *super, struct sym *sub)
{
struct link *lnk, *lnk2, *p, *prev;
@@ -683,7 +635,7 @@
parameter types of functions. Value is a pointer to the member
found or null if not found. */
-struct member *
+static struct member *
find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
{
struct member **list;
@@ -733,7 +685,7 @@
a bit set giving additional information about the member (see the
F_* defines). */
-void
+static void
add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned
int hash, int var, int sc, int vis, int flags)
{
struct member *m;
@@ -781,7 +733,7 @@
a bit set giving additional information about the member (see the
F_* defines). */
-void
+static void
add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned
int hash, int var, int sc, int flags)
{
struct member *m;
@@ -823,7 +775,7 @@
REGEXP is a regular expression matching the define in the source,
if it is non-null. POS is the position in the file. */
-void
+static void
add_define (char *name, char *regexp, int pos)
{
add_global_defn (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE);
@@ -841,7 +793,7 @@
a bit set giving additional information about the member (see the
F_* defines). */
-void
+static void
add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int
var, int sc, int flags)
{
int i;
@@ -872,7 +824,7 @@
a bit set giving additional information about the member (see the
F_* defines). */
-void
+static void
add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int
var, int sc, int flags)
{
/* Add declaration only if not already declared. Header files must
@@ -911,7 +863,7 @@
member. HASH is a hash code for the parameter types of a function.
Value is a pointer to the member's structure. */
-struct member *
+static struct member *
add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
{
struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name));
@@ -982,7 +934,7 @@
recursively, marking functions as virtual that are declared virtual
in base classes. */
-void
+static void
mark_virtual (struct sym *r)
{
struct link *p;
@@ -1006,7 +958,7 @@
/* For all roots of the class tree, mark functions as virtual that
are virtual because of a virtual declaration in a base class. */
-void
+static void
mark_inherited_virtual (void)
{
struct sym *r;
@@ -1021,7 +973,7 @@
/* Create and return a symbol for a namespace with name NAME. */
-struct sym *
+static struct sym *
make_namespace (char *name, struct sym *context)
{
struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name));
@@ -1036,7 +988,7 @@
/* Find the symbol for namespace NAME. If not found, retrun NULL */
-struct sym *
+static struct sym *
check_namespace (char *name, struct sym *context)
{
struct sym *p = NULL;
@@ -1053,7 +1005,7 @@
/* Find the symbol for namespace NAME. If not found, add a new symbol
for NAME to all_namespaces. */
-struct sym *
+static struct sym *
find_namespace (char *name, struct sym *context)
{
struct sym *p = check_namespace (name, context);
@@ -1067,7 +1019,7 @@
/* Find namespace alias with name NAME. If not found return NULL. */
-struct link *
+static struct link *
check_namespace_alias (char *name)
{
struct link *p = NULL;
@@ -1091,7 +1043,7 @@
/* Register the name NEW_NAME as an alias for namespace list OLD_NAME. */
-void
+static void
register_namespace_alias (char *new_name, struct link *old_name)
{
unsigned h;
@@ -1119,7 +1071,7 @@
/* Enter namespace with name NAME. */
-void
+static void
enter_namespace (char *name)
{
struct sym *p = find_namespace (name, current_namespace);
@@ -1140,7 +1092,7 @@
/* Leave the current namespace. */
-void
+static void
leave_namespace (void)
{
assert (namespace_sp > 0);
@@ -1182,7 +1134,7 @@
/* Make sure scope_buffer has enough room to add LEN chars to it. */
-void
+static void
ensure_scope_buffer_room (int len)
{
if (scope_buffer_len + len >= scope_buffer_size)
@@ -1198,7 +1150,7 @@
namespaces to scope_buffer. Value is a pointer to the complete
scope name constructed. */
-char *
+static char *
sym_scope_1 (struct sym *p)
{
int len;
@@ -1232,7 +1184,7 @@
/* Return the scope of symbol P in printed representation, i.e.
as it would appear in a C*+ source file. */
-char *
+static char *
sym_scope (struct sym *p)
{
if (!scope_buffer)
@@ -1254,7 +1206,7 @@
/* Dump the list of members M to file FP. Value is the length of the
list. */
-int
+static int
dump_members (FILE *fp, struct member *m)
{
int n;
@@ -1287,7 +1239,7 @@
/* Dump class ROOT to stream FP. */
-void
+static void
dump_sym (FILE *fp, struct sym *root)
{
fputs (CLASS_STRUCT, fp);
@@ -1313,7 +1265,7 @@
/* Dump class ROOT and its subclasses to file FP. Value is the
number of classes written. */
-int
+static int
dump_tree (FILE *fp, struct sym *root)
{
struct link *lk;
@@ -1360,7 +1312,7 @@
/* Dump the entire class tree to file FP. */
-void
+static void
dump_roots (FILE *fp)
{
int i, n = 0;
@@ -1434,7 +1386,7 @@
/* Process a preprocessor line. Value is the next character from the
input buffer not consumed. */
-int
+static int
process_pp_line (void)
{
int in_comment = 0, in_string = 0;
@@ -1505,7 +1457,7 @@
/* Value is the next token from the input buffer. */
-int
+static int
yylex (void)
{
int c;
@@ -1927,7 +1879,7 @@
position in the input buffer, or maybe a bit more if that string is
shorter than min_regexp. */
-char *
+static char *
matching_regexp (void)
{
char *p;
@@ -1978,7 +1930,7 @@
/* Return a printable representation of token T. */
-const char *
+static const char *
token_string (int t)
{
static char b[3];
@@ -2095,7 +2047,7 @@
/* Reinitialize the scanner for a new input file. */
-void
+static void
re_init_scanner (void)
{
in = inbuffer;
@@ -2113,7 +2065,7 @@
/* Insert a keyword NAME with token value TK into the keyword hash
table. */
-void
+static void
insert_keyword (const char *name, int tk)
{
const char *s;
@@ -2134,7 +2086,7 @@
/* Initialize the scanner for the first file. This sets up the
character class vectors and fills the keyword hash table. */
-void
+static void
init_scanner (void)
{
int i;
@@ -2278,7 +2230,7 @@
/* Skip forward until a given token TOKEN or YYEOF is seen and return
the current lookahead token after skipping. */
-int
+static int
skip_to (int token)
{
while (!LOOKING_AT2 (YYEOF, token))
@@ -2289,7 +2241,7 @@
/* Skip over pairs of tokens (parentheses, square brackets,
angle brackets, curly brackets) matching the current lookahead. */
-void
+static void
skip_matching (void)
{
int open, close, n;
@@ -2332,7 +2284,7 @@
}
}
-void
+static void
skip_initializer (void)
{
for (;;)
@@ -2359,7 +2311,7 @@
/* Build qualified namespace alias (A::B::c) and return it. */
-struct link *
+static struct link *
match_qualified_namespace_alias (void)
{
struct link *head = NULL;
@@ -2396,7 +2348,7 @@
/* Re-initialize the parser by resetting the lookahead token. */
-void
+static void
re_init_parser (void)
{
tk = -1;
@@ -2409,7 +2361,7 @@
Returns a hash code for the parameter types. This value is used to
distinguish between overloaded functions. */
-unsigned
+static unsigned
parm_list (int *flags)
{
unsigned hash = 0;
@@ -2522,7 +2474,7 @@
/* Print position info to stdout. */
-void
+static void
print_info (void)
{
if (info_position >= 0 && BUFFER_POS () <= info_position)
@@ -2537,7 +2489,7 @@
the access specifier for the member (private, protected,
public). */
-void
+static void
member (struct sym *cls, int vis)
{
char *id = NULL;
@@ -2746,7 +2698,7 @@
/* Parse the body of class CLS. TAG is the tag of the class (struct,
union, class). */
-void
+static void
class_body (struct sym *cls, int tag)
{
int vis = tag == CLASS ? PRIVATE : PUBLIC;
@@ -2807,7 +2759,7 @@
qualified ident has the form `X<..>::Y<...>::T<...>. Returns a
symbol for that class. */
-struct sym *
+static struct sym *
parse_classname (void)
{
struct sym *last_class = NULL;
@@ -2837,7 +2789,7 @@
implicitly static operator has been parsed. Value is a pointer to
a static buffer holding the constructed operator name string. */
-char *
+static char *
operator_name (int *sc)
{
static int id_size = 0;
@@ -2927,7 +2879,7 @@
`X::Y::z'. This IDENT is returned in LAST_ID. Value is the
symbol structure for the ident. */
-struct sym *
+static struct sym *
parse_qualified_ident_or_type (char **last_id)
{
struct sym *cls = NULL;
@@ -2992,7 +2944,7 @@
`X::Y::z'. This IDENT is returned in LAST_ID. Value is the
symbol structure for the ident. */
-void
+static void
parse_qualified_param_ident_or_type (char **last_id)
{
struct sym *cls = NULL;
@@ -3034,7 +2986,7 @@
Current lookahead is the class name. */
-void
+static void
class_definition (struct sym *containing, int tag, int flags, int nested)
{
struct sym *current;
@@ -3131,7 +3083,7 @@
the storage class of *ID. FLAGS is a bit set giving additional
information about the member (see the F_* defines). */
-void
+static void
add_declarator (struct sym **cls, char **id, int flags, int sc)
{
if (LOOKING_AT2 (';', ','))
@@ -3174,7 +3126,7 @@
/* Parse a declaration. */
-void
+static void
declaration (int flags)
{
char *id = NULL;
@@ -3328,7 +3280,7 @@
parsing in an `extern "C"' block. Value is 1 if EOF is reached, 0
otherwise. */
-int
+static int
globals (int start_flags)
{
int anonymous;
@@ -3446,7 +3398,7 @@
/* Parse the current input file. */
-void
+static void
yyparse (void)
{
while (globals (0) == 0)
@@ -3462,7 +3414,7 @@
/* Add the list of paths PATH_LIST to the current search path for
input files. */
-void
+static void
add_search_path (char *path_list)
{
while (*path_list)
@@ -3497,7 +3449,7 @@
opened. Try to find FILE in search_path first, then try the
unchanged file name. */
-FILE *
+static FILE *
open_file (char *file)
{
FILE *fp = NULL;
@@ -3556,7 +3508,7 @@
--version display version info\n\
"
-void
+static void
usage (int error)
{
puts (USAGE);
@@ -3571,7 +3523,7 @@
# define VERSION "21"
#endif
-void
+static void
version (void)
{
/* Makes it easier to update automatically. */
@@ -3587,7 +3539,7 @@
/* Parse one input file FILE, adding classes and members to the symbol
table. */
-void
+static void
process_file (char *file)
{
FILE *fp;
@@ -3642,7 +3594,7 @@
containing its contents without the terminating newline. Value
is null when EOF is reached. */
-char *
+static char *
read_line (FILE *fp)
{
static char *buffer;
=== modified file 'lib-src/emacsclient.c'
--- a/lib-src/emacsclient.c 2011-02-18 22:28:09 +0000
+++ b/lib-src/emacsclient.c 2011-02-21 18:06:25 +0000
@@ -150,8 +150,8 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
}
-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 @@
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 @@
/* 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 @@
- 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 @@
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 @@
/* 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 @@
}
-int
+static int
file_name_absolute_p (const char *filename)
{
/* Sanity check, it shouldn't happen. */
@@ -907,7 +907,7 @@
* 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 @@
return TRUE;
}
-HSOCKET
+static HSOCKET
set_tcp_socket (void)
{
HSOCKET s;
@@ -1024,7 +1024,7 @@
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 @@
/* 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 @@
/* 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 @@
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 @@
/* 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 @@
}
-HSOCKET
+static HSOCKET
set_local_socket (void)
{
HSOCKET s;
@@ -1331,7 +1331,7 @@
}
#endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */
-HSOCKET
+static HSOCKET
set_socket (int no_exit_if_error)
{
HSOCKET s;
@@ -1447,7 +1447,7 @@
/* 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 @@
if (rl <= 0)
break;
-
+
string[rl] = '\0';
p = string + strlen (string) - 1;
=== modified file 'lib-src/fakemail.c'
--- a/lib-src/fakemail.c 2011-01-25 04:08:28 +0000
+++ b/lib-src/fakemail.c 2011-02-21 18:06:25 +0000
@@ -198,7 +198,7 @@
/* Initialize a linebuffer for use */
-void
+static void
init_linebuffer (struct linebuffer *linebuffer)
{
linebuffer->size = INITIAL_LINE_SIZE;
@@ -208,7 +208,7 @@
/* 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 @@
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 @@
/* Nonzero if the string FIELD starts with a colon-terminated keyword. */
-boolean
+static boolean
has_keyword (char *field)
{
char *ignored;
@@ -285,7 +285,7 @@
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 @@
return where;
}
-line_list
+static line_list
make_file_preface (void)
{
char *the_string, *temp;
@@ -385,7 +385,7 @@
return result;
}
-void
+static void
write_line_list (register line_list the_list, FILE *the_stream)
{
for ( ;
@@ -398,7 +398,7 @@
return;
}
-int
+static int
close_the_streams (void)
{
register stream_list rem;
@@ -411,7 +411,7 @@
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 @@
return;
}
-int
+static int
my_fclose (FILE *the_file)
{
putc ('\n', the_file);
@@ -430,7 +430,7 @@
return fclose (the_file);
}
-boolean
+static boolean
open_a_file (char *name)
{
FILE *the_stream = fopen (name, "a");
@@ -445,7 +445,7 @@
return false;
}
-void
+static void
put_string (char *s)
{
register stream_list rem;
@@ -456,7 +456,7 @@
return;
}
-void
+static void
put_line (const char *string)
{
register stream_list rem;
@@ -516,7 +516,7 @@
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 @@
/* 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 @@
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 @@
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 @@
return the_header->next;
}
-void
+static void
write_header (header the_header)
{
register header old = the_header;
=== modified file 'lib-src/make-docfile.c'
--- a/lib-src/make-docfile.c 2011-02-21 18:02:49 +0000
+++ b/lib-src/make-docfile.c 2011-02-21 19:37:54 +0000
@@ -66,12 +66,12 @@
#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 @@
/* 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 @@
/* Print error message and exit. */
/* VARARGS1 */
-void
+static void
fatal (const char *s1, const char *s2)
{
error (s1, s2);
@@ -113,7 +113,7 @@
/* 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 @@
/* 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 @@
}
/* Add a source file name boundary marker in the output file. */
-void
+static void
put_filename (char *filename)
{
char *tmp;
@@ -231,7 +231,7 @@
/* 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 @@
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 @@
fprintf (outfile, "struct emacs_globals {\n");
}
-char buf[128];
+static char input_buffer[128];
/* Some state during the execution of `read_c_string_or_comment'. */
struct rcsoc_state
@@ -388,14 +388,14 @@
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;
struct rcsoc_state state;
state.in_file = infile;
- state.buf_ptr = (printflag < 0 ? buf : 0);
+ state.buf_ptr = (printflag < 0 ? input_buffer : 0);
state.out_file = (printflag > 0 ? outfile : 0);
state.pending_spaces = 0;
state.pending_newlines = 0;
@@ -476,7 +476,7 @@
/* 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 @@
return strcmp (ga->name, gb->name);
}
-void
+static void
write_globals (void)
{
int i;
@@ -652,7 +652,7 @@
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;
@@ -795,15 +795,15 @@
/* Read in the identifier. */
do
{
- buf[i++] = c;
+ input_buffer[i++] = c;
c = getc (infile);
}
while (! (c == ',' || c == ' ' || c == '\t' ||
c == '\n' || c == '\r'));
- buf[i] = '\0';
+ input_buffer[i] = '\0';
name = xmalloc (i + 1);
- memcpy (name, buf, i + 1);
+ memcpy (name, input_buffer, i + 1);
add_global (type, name);
continue;
}
@@ -888,7 +888,7 @@
putc (037, outfile);
putc (defvarflag ? 'V' : 'F', outfile);
- fprintf (outfile, "%s\n", buf);
+ fprintf (outfile, "%s\n", input_buffer);
if (comment)
getc (infile); /* Skip past `*' */
@@ -931,11 +931,12 @@
*p = '\0';
/* Output them. */
fprintf (outfile, "\n\n");
- write_c_args (outfile, buf, argbuf, minargs, maxargs);
+ write_c_args (outfile, input_buffer, argbuf, minargs, maxargs);
}
else if (defunflag && maxargs == -1 && !saw_usage)
/* The DOC should provide the usage form. */
- fprintf (stderr, "Missing `usage' for function `%s'.\n", buf);
+ fprintf (stderr, "Missing `usage' for function `%s'.\n",
+ input_buffer);
}
}
eof:
@@ -979,7 +980,7 @@
An entry is output only if DOCSTRING has \ newline just after the opening "
*/
-void
+static void
skip_white (FILE *infile)
{
char c = ' ';
@@ -988,7 +989,7 @@
ungetc (c, infile);
}
-void
+static void
read_lisp_symbol (FILE *infile, char *buffer)
{
char c;
@@ -1016,7 +1017,7 @@
skip_white (infile);
}
-int
+static int
scan_lisp_file (const char *filename, const char *mode)
{
FILE *infile;
=== modified file 'lib-src/movemail.c'
--- a/lib-src/movemail.c 2011-01-26 08:36:39 +0000
+++ b/lib-src/movemail.c 2011-02-22 00:11:56 +0000
@@ -80,13 +80,6 @@
#undef access
#endif /* MSDOS */
-#ifndef DIRECTORY_SEP
-#define DIRECTORY_SEP '/'
-#endif
-#ifndef IS_DIRECTORY_SEP
-#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
-#endif
-
#ifdef WINDOWSNT
#include "ntlib.h"
#undef access
@@ -161,7 +154,7 @@
#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)
@@ -169,7 +162,7 @@
char *inname, *outname;
int indesc, outdesc;
ssize_t nread;
- int status;
+ int wait_status;
int c, preserve_mail = 0;
#ifndef MAIL_USE_SYSTEM_LOCK
@@ -269,6 +262,13 @@
if (! spool_name)
#endif
{
+ #ifndef DIRECTORY_SEP
+ #define DIRECTORY_SEP '/'
+ #endif
+ #ifndef IS_DIRECTORY_SEP
+ #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
+ #endif
+
/* Use a lock file named after our first argument with .lock appended:
If it exists, the mail file is locked. */
/* Note: this locking mechanism is *required* by the mailer
@@ -527,11 +527,11 @@
exit (EXIT_SUCCESS);
}
- wait (&status);
- if (!WIFEXITED (status))
+ wait (&wait_status);
+ if (!WIFEXITED (wait_status))
exit (EXIT_FAILURE);
- else if (WRETCODE (status) != 0)
- exit (WRETCODE (status));
+ else if (WRETCODE (wait_status) != 0)
+ exit (WRETCODE (wait_status));
#if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK)
#ifdef MAIL_USE_MAILLOCK
@@ -670,14 +670,8 @@
#define NOTOK (-1)
#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 Errmsg[200]; /* POP errors, at least, can exceed
the original length of 80. */
/*
@@ -736,7 +730,18 @@
error ("Error in open: %s, %s", strerror (errno), outfile);
return EXIT_FAILURE;
}
- fchown (mbfi, getuid (), -1);
+
+ if (fchown (mbfi, getuid (), -1) != 0)
+ {
+ int fchown_errno = errno;
+ struct stat st;
+ if (fstat (mbfi, &st) != 0 || st.st_uid != getuid ())
+ {
+ pop_close (server);
+ error ("Error in fchown: %s, %s", strerror (fchown_errno), outfile);
+ return EXIT_FAILURE;
+ }
+ }
if ((mbf = fdopen (mbfi, "wb")) == NULL)
{
@@ -828,10 +833,10 @@
if (pop_retrieve_first (server, msgno, &line))
{
- char *error = concat ("Error from POP server: ", pop_error, "");
- strncpy (Errmsg, error, sizeof (Errmsg));
+ char *msg = concat ("Error from POP server: ", pop_error, "");
+ strncpy (Errmsg, msg, sizeof (Errmsg));
Errmsg[sizeof (Errmsg)-1] = '\0';
- free(error);
+ free (msg);
return (NOTOK);
}
@@ -850,27 +855,26 @@
if (ret)
{
- char *error = concat ("Error from POP server: ", pop_error, "");
- strncpy (Errmsg, error, sizeof (Errmsg));
+ char *msg = concat ("Error from POP server: ", pop_error, "");
+ strncpy (Errmsg, msg, sizeof (Errmsg));
Errmsg[sizeof (Errmsg)-1] = '\0';
- free(error);
+ free (msg);
return (NOTOK);
}
return (OK);
}
-/* Do this as a macro instead of using strcmp to save on execution time. */
-#define IS_FROM_LINE(a) ((a[0] == 'F') \
- && (a[1] == 'r') \
- && (a[2] == 'o') \
- && (a[3] == 'm') \
- && (a[4] == ' '))
-
static int
mbx_write (char *line, int len, FILE *mbf)
{
#ifdef MOVEMAIL_QUOTE_POP_FROM_LINES
+ /* Do this as a macro instead of using strcmp to save on execution time. */
+ # define IS_FROM_LINE(a) ((a[0] == 'F') \
+ && (a[1] == 'r') \
+ && (a[2] == 'o') \
+ && (a[3] == 'm') \
+ && (a[4] == ' '))
if (IS_FROM_LINE (line))
{
if (fputc ('>', mbf) == EOF)
=== modified file 'lib-src/pop.c'
--- a/lib-src/pop.c 2011-01-26 08:36:39 +0000
+++ b/lib-src/pop.c 2011-02-21 23:22:34 +0000
@@ -67,7 +67,6 @@
#include <stdio.h>
#ifdef STDC_HEADERS
#include <string.h>
-#define index strchr
#endif
#include <unistd.h>
@@ -91,6 +90,8 @@
# endif
#endif /* KERBEROS */
+#include <min-max.h>
+
#ifdef KERBEROS
#ifndef KERBEROS5
extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *,
@@ -122,19 +123,15 @@
to be bigger than the original
value of 80 */
#define POP_PORT 110
+#define POP_SERVICE "pop3" /* we don't want the POP2 port! */
+#ifdef KERBEROS
#define KPOP_PORT 1109
-#define POP_SERVICE "pop3" /* we don't want the POP2 port! */
-#ifdef KERBEROS
#define KPOP_SERVICE "kpop" /* never used: look for 20060515 to see why */
#endif
char pop_error[ERROR_MAX];
int pop_debug = 0;
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
/*
* Function: pop_open (char *host, char *username, char *password,
* int flags)
=== modified file 'lib-src/profile.c'
--- a/lib-src/profile.c 2011-01-25 04:08:28 +0000
+++ b/lib-src/profile.c 2011-02-21 18:06:25 +0000
@@ -38,7 +38,7 @@
/* Reset the stopwatch to zero. */
-void
+static void
reset_watch (void)
{
EMACS_GET_TIME (TV1);
@@ -49,7 +49,7 @@
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)
=== modified file 'lib-src/test-distrib.c'
--- a/lib-src/test-distrib.c 2011-01-25 04:08:28 +0000
+++ b/lib-src/test-distrib.c 2011-02-21 23:15:17 +0000
@@ -26,18 +26,16 @@
/* 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];
-
/* 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,6 +55,7 @@
main (int argc, char **argv)
{
int fd;
+ char buf[300];
if (argc != 2)
{
=== modified file 'lib-src/update-game-score.c'
--- a/lib-src/update-game-score.c 2011-01-26 08:36:39 +0000
+++ b/lib-src/update-game-score.c 2011-02-21 18:06:25 +0000
@@ -57,7 +57,7 @@
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 @@
#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 @@
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 @@
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);
-
-void lose (const char *msg) NO_RETURN;
-
-void
+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);
+
+static void lose (const char *msg) NO_RETURN;
+
+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 @@
#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 @@
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 @@
exit (EXIT_SUCCESS);
}
-int
+static int
read_score (FILE *f, struct score_entry *score)
{
int c;
@@ -342,7 +342,7 @@
return 0;
}
-int
+static int
read_scores (const char *filename, struct score_entry **scores, int *count)
{
int readval, scorecount, cursize;
@@ -375,7 +375,7 @@
return 0;
}
-int
+static int
score_compare (const void *a, const void *b)
{
const struct score_entry *sa = (const struct score_entry *) a;
@@ -383,7 +383,7 @@
return (sb->score > sa->score) - (sb->score < sa->score);
}
-int
+static int
score_compare_reverse (const void *a, const void *b)
{
const struct score_entry *sa = (const struct score_entry *) a;
@@ -407,14 +407,14 @@
return 0;
}
-void
+static void
sort_scores (struct score_entry *scores, int count, int reverse)
{
qsort (scores, count, sizeof (struct score_entry),
reverse ? score_compare_reverse : score_compare);
}
-int
+static int
write_scores (const char *filename, const struct score_entry *scores, int
count)
{
FILE *f;
@@ -443,7 +443,7 @@
return 0;
}
-int
+static int
lock_file (const char *filename, void **state)
{
int fd;
@@ -484,7 +484,7 @@
return 0;
}
-int
+static int
unlock_file (const char *filename, void *state)
{
char *lockpath = (char *) state;
=== added file 'lib/min-max.h'
--- a/lib/min-max.h 1970-01-01 00:00:00 +0000
+++ b/lib/min-max.h 2011-02-21 23:22:34 +0000
@@ -0,0 +1,6 @@
+#ifndef min
+# define min(a,b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef max
+# define max(a,b) ((a) > (b) ? (a) : (b))
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103378: Merge: minor lib-src cleanups,
Paul Eggert <=