mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-04 11:40:22 +00:00
Merge: lib-src changes mostly to avoid GCC warnings
This commit is contained in:
commit
ae3f8fbfc3
@ -1,3 +1,49 @@
|
||||
2011-02-26 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* ebrowse.c (parse_qualified_param_ident_or_type): Make it clear
|
||||
to reader (and to the compiler) that the loop always executes at
|
||||
least once. This prevents a warning with recent GCC.
|
||||
(BROWSE_STRUCT): Remove unused macro.
|
||||
|
||||
* fakemail.c: Include <ignore-value.h>.
|
||||
(put_line): Explicitly ignore fwrite return value, for benefit of
|
||||
recent glibc + gcc.
|
||||
(close_the_streams): Diagnose output errors instead of merely
|
||||
exiting with nonzero status.
|
||||
(my_fclose, main): Diagnose input errors, and exit with nonzero status.
|
||||
Formerly, input errors were silently ignored.
|
||||
|
||||
* ebrowse.c (putstr): Rename from PUTSTR and turn into a function.
|
||||
All callers changed. This is cleaner, and avoids GCC warnings about
|
||||
passing NULL to fputs.
|
||||
(insert_keyword): Rename parameter to avoid shadowing diagnostic.
|
||||
|
||||
2011-02-25 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* emacsclient.c (main): Avoid dangling 'if'.
|
||||
(xstrdup): Remove; no longer needed.
|
||||
(get_current_dir_name, w32_getenv, get_server_config, find_tty):
|
||||
(set_local_socket, main):
|
||||
Use const char *, not char *, for pointers that are not assigned
|
||||
through.
|
||||
(IF_LINT): New macro.
|
||||
(set_local_socket, main): Use it to suppress warnings with
|
||||
GCC -Wuninitialized.
|
||||
|
||||
* emacsclient.c: Redo local variables to avoid shadowing problems.
|
||||
(message, socket_status, start_daemon_and_retry_set_socket):
|
||||
Rename locals.
|
||||
(main): Move decl of "i".
|
||||
|
||||
* etags.c (ISUPPER): Move to inside the only #ifdef where it's used.
|
||||
This avoids an unused-macro warning with some GCC settings.
|
||||
|
||||
* make-docfile.c (write_globals): Change char * to char const *
|
||||
to avoid a GCC "assignment discards qualifiers" diagnostic
|
||||
in some configurations.
|
||||
(scan_c_file): Refactor local variable decls to make their scope
|
||||
more accurate and to avoid a GCC -Wuninitialized diagnostic.
|
||||
|
||||
2011-02-22 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* etags.c (canonicalize_filename, ISUPPER): Fix last change.
|
||||
|
@ -77,7 +77,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
#define TREE_HEADER_STRUCT "[ebrowse-hs "
|
||||
#define TREE_STRUCT "[ebrowse-ts "
|
||||
#define MEMBER_STRUCT "[ebrowse-ms "
|
||||
#define BROWSE_STRUCT "[ebrowse-bs "
|
||||
#define CLASS_STRUCT "[ebrowse-cs "
|
||||
|
||||
/* The name of the symbol table entry for global functions, variables,
|
||||
@ -1108,22 +1107,23 @@ leave_namespace (void)
|
||||
/* Write string S to the output file FP in a Lisp-readable form.
|
||||
If S is null, write out `()'. */
|
||||
|
||||
#define PUTSTR(s, fp) \
|
||||
do { \
|
||||
if (!s) \
|
||||
{ \
|
||||
putc ('(', fp); \
|
||||
putc (')', fp); \
|
||||
putc (' ', fp); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
putc ('"', fp); \
|
||||
fputs (s, fp); \
|
||||
putc ('"', fp); \
|
||||
putc (' ', fp); \
|
||||
} \
|
||||
} while (0)
|
||||
static inline void
|
||||
putstr (const char *s, FILE *fp)
|
||||
{
|
||||
if (!s)
|
||||
{
|
||||
putc ('(', fp);
|
||||
putc (')', fp);
|
||||
putc (' ', fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
putc ('"', fp);
|
||||
fputs (s, fp);
|
||||
putc ('"', fp);
|
||||
putc (' ', fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* A dynamically allocated buffer for constructing a scope name. */
|
||||
|
||||
@ -1216,16 +1216,16 @@ dump_members (FILE *fp, struct member *m)
|
||||
for (n = 0; m; m = m->next, ++n)
|
||||
{
|
||||
fputs (MEMBER_STRUCT, fp);
|
||||
PUTSTR (m->name, fp);
|
||||
PUTSTR (NULL, fp); /* FIXME? scope for globals */
|
||||
putstr (m->name, fp);
|
||||
putstr (NULL, fp); /* FIXME? scope for globals */
|
||||
fprintf (fp, "%u ", (unsigned) m->flags);
|
||||
PUTSTR (m->filename, fp);
|
||||
PUTSTR (m->regexp, fp);
|
||||
putstr (m->filename, fp);
|
||||
putstr (m->regexp, fp);
|
||||
fprintf (fp, "%u ", (unsigned) m->pos);
|
||||
fprintf (fp, "%u ", (unsigned) m->vis);
|
||||
putc (' ', fp);
|
||||
PUTSTR (m->def_filename, fp);
|
||||
PUTSTR (m->def_regexp, fp);
|
||||
putstr (m->def_filename, fp);
|
||||
putstr (m->def_regexp, fp);
|
||||
fprintf (fp, "%u", (unsigned) m->def_pos);
|
||||
putc (']', fp);
|
||||
putc ('\n', fp);
|
||||
@ -1243,20 +1243,20 @@ static void
|
||||
dump_sym (FILE *fp, struct sym *root)
|
||||
{
|
||||
fputs (CLASS_STRUCT, fp);
|
||||
PUTSTR (root->name, fp);
|
||||
putstr (root->name, fp);
|
||||
|
||||
/* Print scope, if any. */
|
||||
if (root->namesp)
|
||||
PUTSTR (sym_scope (root), fp);
|
||||
putstr (sym_scope (root), fp);
|
||||
else
|
||||
PUTSTR (NULL, fp);
|
||||
putstr (NULL, fp);
|
||||
|
||||
/* Print flags. */
|
||||
fprintf (fp, "%u", root->flags);
|
||||
PUTSTR (root->filename, fp);
|
||||
PUTSTR (root->regexp, fp);
|
||||
putstr (root->filename, fp);
|
||||
putstr (root->regexp, fp);
|
||||
fprintf (fp, "%u", (unsigned) root->pos);
|
||||
PUTSTR (root->sfilename, fp);
|
||||
putstr (root->sfilename, fp);
|
||||
putc (']', fp);
|
||||
putc ('\n', fp);
|
||||
}
|
||||
@ -1323,7 +1323,7 @@ dump_roots (FILE *fp)
|
||||
if (!f_append)
|
||||
{
|
||||
fputs (TREE_HEADER_STRUCT, fp);
|
||||
PUTSTR (EBROWSE_FILE_VERSION, fp);
|
||||
putstr (EBROWSE_FILE_VERSION, fp);
|
||||
|
||||
putc ('\"', fp);
|
||||
if (!f_structs)
|
||||
@ -2062,11 +2062,11 @@ re_init_scanner (void)
|
||||
}
|
||||
|
||||
|
||||
/* Insert a keyword NAME with token value TK into the keyword hash
|
||||
/* Insert a keyword NAME with token value TKV into the keyword hash
|
||||
table. */
|
||||
|
||||
static void
|
||||
insert_keyword (const char *name, int tk)
|
||||
insert_keyword (const char *name, int tkv)
|
||||
{
|
||||
const char *s;
|
||||
unsigned h = 0;
|
||||
@ -2077,7 +2077,7 @@ insert_keyword (const char *name, int tk)
|
||||
|
||||
h %= KEYWORD_TABLE_SIZE;
|
||||
k->name = name;
|
||||
k->tk = tk;
|
||||
k->tk = tkv;
|
||||
k->next = keyword_table[h];
|
||||
keyword_table[h] = k;
|
||||
}
|
||||
@ -2951,7 +2951,9 @@ parse_qualified_param_ident_or_type (char **last_id)
|
||||
static char *id = NULL;
|
||||
static int id_size = 0;
|
||||
|
||||
while (LOOKING_AT (IDENT))
|
||||
assert (LOOKING_AT (IDENT));
|
||||
|
||||
do
|
||||
{
|
||||
int len = strlen (yytext) + 1;
|
||||
if (len > id_size)
|
||||
@ -2974,6 +2976,7 @@ parse_qualified_param_ident_or_type (char **last_id)
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (LOOKING_AT (IDENT));
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,6 +112,13 @@ char *(getcwd) (char *, size_t);
|
||||
/* Additional space when allocating buffers for filenames, etc. */
|
||||
#define EXTRA_SPACE 100
|
||||
|
||||
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
|
||||
#ifdef lint
|
||||
# define IF_LINT(Code) Code
|
||||
#else
|
||||
# define IF_LINT(Code) /* empty */
|
||||
#endif
|
||||
|
||||
|
||||
/* Name used to invoke this program. */
|
||||
const char *progname;
|
||||
@ -190,20 +197,6 @@ xmalloc (unsigned int size)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Like strdup but get a fatal error if memory is exhausted. */
|
||||
|
||||
static char *
|
||||
xstrdup (const char *s)
|
||||
{
|
||||
char *result = strdup (s);
|
||||
if (result == NULL)
|
||||
{
|
||||
perror ("strdup");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* From sysdep.c */
|
||||
#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME)
|
||||
|
||||
@ -233,7 +226,7 @@ char*
|
||||
get_current_dir_name (void)
|
||||
{
|
||||
char *buf;
|
||||
char *pwd;
|
||||
const char *pwd;
|
||||
struct stat dotstat, pwdstat;
|
||||
/* If PWD is accurate, use it instead of calling getwd. PWD is
|
||||
sometimes a nicer name, and using it may avoid a fatal error if a
|
||||
@ -353,7 +346,7 @@ w32_getenv (char *envvar)
|
||||
{
|
||||
/* "w32console" is what Emacs on Windows uses for tty-type under -nw. */
|
||||
if (strcmp (envvar, "TERM") == 0)
|
||||
return xstrdup ("w32console");
|
||||
return "w32console";
|
||||
/* Found neither in the environment nor in the registry. */
|
||||
return NULL;
|
||||
}
|
||||
@ -474,13 +467,13 @@ ttyname (int fd)
|
||||
/* Display a normal or error message.
|
||||
On Windows, use a message box if compiled as a Windows app. */
|
||||
static void
|
||||
message (int is_error, const char *message, ...)
|
||||
message (int is_error, const char *format, ...)
|
||||
{
|
||||
char msg[2048];
|
||||
va_list args;
|
||||
|
||||
va_start (args, message);
|
||||
vsprintf (msg, message, args);
|
||||
va_start (args, format);
|
||||
vsprintf (msg, format, args);
|
||||
va_end (args);
|
||||
|
||||
#ifdef WINDOWSNT
|
||||
@ -918,7 +911,7 @@ get_server_config (struct sockaddr_in *server, char *authentication)
|
||||
config = fopen (server_file, "rb");
|
||||
else
|
||||
{
|
||||
char *home = egetenv ("HOME");
|
||||
const char *home = egetenv ("HOME");
|
||||
|
||||
if (home)
|
||||
{
|
||||
@ -1025,10 +1018,10 @@ strprefix (const char *prefix, const char *string)
|
||||
is zero, or return 0 if NOABORT is non-zero. */
|
||||
|
||||
static int
|
||||
find_tty (char **tty_type, char **tty_name, int noabort)
|
||||
find_tty (const char **tty_type, const char **tty_name, int noabort)
|
||||
{
|
||||
char *type = egetenv ("TERM");
|
||||
char *name = ttyname (fileno (stdout));
|
||||
const char *type = egetenv ("TERM");
|
||||
const char *name = ttyname (fileno (stdout));
|
||||
|
||||
if (!name)
|
||||
{
|
||||
@ -1080,11 +1073,11 @@ find_tty (char **tty_type, char **tty_name, int noabort)
|
||||
0 - success: none of the above */
|
||||
|
||||
static int
|
||||
socket_status (char *socket_name)
|
||||
socket_status (char *name)
|
||||
{
|
||||
struct stat statbfr;
|
||||
|
||||
if (stat (socket_name, &statbfr) == -1)
|
||||
if (stat (name, &statbfr) == -1)
|
||||
return 2;
|
||||
|
||||
if (statbfr.st_uid != geteuid ())
|
||||
@ -1205,7 +1198,7 @@ set_local_socket (void)
|
||||
int default_sock = !socket_name;
|
||||
int saved_errno = 0;
|
||||
const char *server_name = "server";
|
||||
const char *tmpdir;
|
||||
const char *tmpdir IF_LINT ( = NULL);
|
||||
|
||||
if (socket_name && !strchr (socket_name, '/')
|
||||
&& !strchr (socket_name, '\\'))
|
||||
@ -1260,10 +1253,10 @@ set_local_socket (void)
|
||||
associated with the name. This is reminiscent of the logic
|
||||
that init_editfns uses to set the global Vuser_full_name. */
|
||||
|
||||
char *user_name = (char *) egetenv ("LOGNAME");
|
||||
const char *user_name = egetenv ("LOGNAME");
|
||||
|
||||
if (!user_name)
|
||||
user_name = (char *) egetenv ("USER");
|
||||
user_name = egetenv ("USER");
|
||||
|
||||
if (user_name)
|
||||
{
|
||||
@ -1483,8 +1476,8 @@ start_daemon_and_retry_set_socket (void)
|
||||
else
|
||||
{
|
||||
char emacs[] = "emacs";
|
||||
char daemon[] = "--daemon";
|
||||
char *d_argv[] = {emacs, daemon, 0 };
|
||||
char daemon_option[] = "--daemon";
|
||||
char *d_argv[] = {emacs, daemon_option, 0 };
|
||||
if (socket_name != NULL)
|
||||
{
|
||||
/* Pass --daemon=socket_name as argument. */
|
||||
@ -1504,10 +1497,12 @@ start_daemon_and_retry_set_socket (void)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i, rl, needlf = 0;
|
||||
int rl, needlf = 0;
|
||||
char *cwd, *str;
|
||||
char string[BUFSIZ+1];
|
||||
int null_socket_name, null_server_file, start_daemon_if_needed;
|
||||
int null_socket_name IF_LINT ( = 0);
|
||||
int null_server_file IF_LINT ( = 0);
|
||||
int start_daemon_if_needed;
|
||||
int exit_status = EXIT_SUCCESS;
|
||||
|
||||
main_argv = argv;
|
||||
@ -1543,21 +1538,21 @@ main (int argc, char **argv)
|
||||
null_server_file = (server_file == NULL);
|
||||
}
|
||||
|
||||
if ((emacs_socket = set_socket (alternate_editor
|
||||
|| start_daemon_if_needed)) == INVALID_SOCKET)
|
||||
if (start_daemon_if_needed)
|
||||
{
|
||||
/* Reset socket_name and server_file if they were NULL
|
||||
before the set_socket call. */
|
||||
if (null_socket_name)
|
||||
socket_name = NULL;
|
||||
if (null_server_file)
|
||||
server_file = NULL;
|
||||
emacs_socket = set_socket (alternate_editor || start_daemon_if_needed);
|
||||
if (emacs_socket == INVALID_SOCKET)
|
||||
{
|
||||
if (! start_daemon_if_needed)
|
||||
fail ();
|
||||
|
||||
start_daemon_and_retry_set_socket ();
|
||||
}
|
||||
else
|
||||
fail ();
|
||||
/* Reset socket_name and server_file if they were NULL
|
||||
before the set_socket call. */
|
||||
if (null_socket_name)
|
||||
socket_name = NULL;
|
||||
if (null_server_file)
|
||||
server_file = NULL;
|
||||
|
||||
start_daemon_and_retry_set_socket ();
|
||||
}
|
||||
|
||||
cwd = get_current_dir_name ();
|
||||
if (cwd == 0)
|
||||
@ -1615,7 +1610,7 @@ main (int argc, char **argv)
|
||||
frame is available. */
|
||||
if (tty || (current_frame && !eval))
|
||||
{
|
||||
char *tty_type, *tty_name;
|
||||
const char *tty_type, *tty_name;
|
||||
|
||||
if (find_tty (&tty_type, &tty_name, !tty))
|
||||
{
|
||||
@ -1635,6 +1630,7 @@ main (int argc, char **argv)
|
||||
|
||||
if ((argc - optind > 0))
|
||||
{
|
||||
int i;
|
||||
for (i = optind; i < argc; i++)
|
||||
{
|
||||
|
||||
|
@ -236,7 +236,6 @@ If you want regular expression support, you should delete this notice and
|
||||
#define ISALNUM(c) isalnum (CHAR(c))
|
||||
#define ISALPHA(c) isalpha (CHAR(c))
|
||||
#define ISDIGIT(c) isdigit (CHAR(c))
|
||||
#define ISUPPER(c) isupper (CHAR(c))
|
||||
#define ISLOWER(c) islower (CHAR(c))
|
||||
|
||||
#define lowcase(c) tolower (CHAR(c))
|
||||
@ -6648,6 +6647,7 @@ canonicalize_filename (register char *fn)
|
||||
|
||||
#ifdef DOS_NT
|
||||
/* Canonicalize drive letter case. */
|
||||
# define ISUPPER(c) isupper (CHAR(c))
|
||||
if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0]))
|
||||
fn[0] = lowcase (fn[0]);
|
||||
|
||||
|
@ -62,6 +62,8 @@ main ()
|
||||
|
||||
/* This is to declare cuserid. */
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ignore-value.h>
|
||||
|
||||
/* Type definitions */
|
||||
|
||||
@ -405,8 +407,8 @@ close_the_streams (void)
|
||||
for (rem = the_streams;
|
||||
rem != ((stream_list) NULL);
|
||||
rem = rem->rest_streams)
|
||||
no_problems = (no_problems &&
|
||||
((*rem->action) (rem->handle) == 0));
|
||||
if (no_problems && (*rem->action) (rem->handle) != 0)
|
||||
error ("output error", NULL);
|
||||
the_streams = ((stream_list) NULL);
|
||||
return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
@ -427,6 +429,8 @@ my_fclose (FILE *the_file)
|
||||
{
|
||||
putc ('\n', the_file);
|
||||
fflush (the_file);
|
||||
if (ferror (the_file))
|
||||
return EOF;
|
||||
return fclose (the_file);
|
||||
}
|
||||
|
||||
@ -496,7 +500,7 @@ put_line (const char *string)
|
||||
}
|
||||
}
|
||||
/* Output that much, then break the line. */
|
||||
fwrite (s, 1, breakpos - s, rem->handle);
|
||||
ignore_value (fwrite (s, 1, breakpos - s, rem->handle));
|
||||
column = 8;
|
||||
|
||||
/* Skip whitespace and prepare to print more addresses. */
|
||||
@ -729,6 +733,9 @@ main (int argc, char **argv)
|
||||
put_string (buf);
|
||||
}
|
||||
|
||||
if (no_problems && (ferror (stdin) || fclose (stdin) != 0))
|
||||
error ("input error", NULL);
|
||||
|
||||
exit (close_the_streams ());
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ write_globals (void)
|
||||
qsort (globals, num_globals, sizeof (struct global), compare_globals);
|
||||
for (i = 0; i < num_globals; ++i)
|
||||
{
|
||||
char *type;
|
||||
char const *type;
|
||||
|
||||
switch (globals[i].type)
|
||||
{
|
||||
@ -658,12 +658,8 @@ scan_c_file (char *filename, const char *mode)
|
||||
FILE *infile;
|
||||
register int c;
|
||||
register int commas;
|
||||
register int defunflag;
|
||||
register int defvarperbufferflag;
|
||||
register int defvarflag;
|
||||
int minargs, maxargs;
|
||||
int extension = filename[strlen (filename) - 1];
|
||||
enum global_type type;
|
||||
|
||||
if (extension == 'o')
|
||||
filename[strlen (filename) - 1] = 'c';
|
||||
@ -693,6 +689,10 @@ scan_c_file (char *filename, const char *mode)
|
||||
while (!feof (infile))
|
||||
{
|
||||
int doc_keyword = 0;
|
||||
int defunflag = 0;
|
||||
int defvarperbufferflag = 0;
|
||||
int defvarflag = 0;
|
||||
enum global_type type = INVALID;
|
||||
|
||||
if (c != '\n' && c != '\r')
|
||||
{
|
||||
@ -726,7 +726,6 @@ scan_c_file (char *filename, const char *mode)
|
||||
continue;
|
||||
|
||||
defvarflag = 1;
|
||||
defunflag = 0;
|
||||
|
||||
c = getc (infile);
|
||||
defvarperbufferflag = (c == 'P');
|
||||
@ -738,8 +737,6 @@ scan_c_file (char *filename, const char *mode)
|
||||
type = LISP_OBJECT;
|
||||
else if (c == 'B')
|
||||
type = BOOLEAN;
|
||||
else
|
||||
type = INVALID;
|
||||
}
|
||||
|
||||
c = getc (infile);
|
||||
@ -758,8 +755,6 @@ scan_c_file (char *filename, const char *mode)
|
||||
continue;
|
||||
c = getc (infile);
|
||||
defunflag = c == 'U';
|
||||
defvarflag = 0;
|
||||
defvarperbufferflag = 0;
|
||||
}
|
||||
else continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user