Commit 988e88ab authored by Jan D's avatar Jan D

Fix warnings produced by compiling with -Wwrite_strings (i.e. use const char *).

* b2m.c (concat, fatal): Use const char*.
(main): Don't assign labels a string literal.

* ebrowse.c (struct member): filename, def_filename is const.
(struct sym): filename, sfilename is const.
(struct kw): name is const.
(add_sym, yyerror, token_string, insert_keyword, main): Use const char*.

* emacsclient.c (message, sock_err_message, send_to_emacs)
(quote_argument, set_local_socket)
(start_daemon_and_retry_set_socket): Use const char*.

* etags.c (compressor, language, Ada_suffix, Ada_help, Asm_suffixes)
(Asm_help, default_C_suffixes, default_C_help, Cplusplus_suffixes)
(Cplusplus_help, Cjava_suffixes, Cobol_suffixes, Cstar_suffixes)
(Erlang_suffixes, Erlang_help, Forth_suffixes, Forth_help)
(Fortran_suffixes, Fortran_help, HTML_suffixes,  HTML_help)
(Lisp_suffixes, Lisp_help, Lua_suffixes, Lua_help)
(Makefile_filenames, Makefile_help, Objc_suffixes, Objc_help)
(Pascal_suffixes, Pascal_help, Perl_suffixes, Perl_interpreters)
(Perl_help, PHP_suffixes, PHP_help, plain_C_suffixses, PS_suffixes)
(PS_help, Prolog_suffixes, Prolog_help, Python_suffixes, Python_help)
(Scheme_suffixes, Scheme_help, TeX_suffixes, TeX_help, Texinfo_suffixes)
(Texinfo_help, Yacc_suffixes, Yacc_help, auto_help, none_help)
(no_lang_help, print_language_names)
(get_language_from_interpreter, get_language_from_filename)
(init, make_tag, struct C_stab_entry, write_classname, TEX_defenv)
(TEX_decode_env, nocase_tail, savestr, savenstr, fatal, pfatal)
(concat): Use const char*.

* make-docfile.c (error, fatal, scan_c_file, scan_lisp_file): Use
const char *.

* movemail.c (fatal, error, concat): Use const char *.

* pop.c (pop_multi_first, socket_connection, sendline): Use conat char*.

* pop.h (pop_multi_first): Use const char *.
(_ARGS): Remove.

* sorted-doc.c (error, fatal, states): Use const char *.

* update-game-score.c (get_prefix, write_scores, main): Use const char*.
parent 97eedd1b
2010-08-11 Jan Djärv <jan.h.d@swipnet.se>
* update-game-score.c (get_prefix, write_scores, main): Use const char*.
* sorted-doc.c (error, fatal, states): Use const char *.
* pop.h (pop_multi_first): Use const char *.
(_ARGS): Remove.
* pop.c (pop_multi_first, socket_connection, sendline): Use conat char*.
* movemail.c (fatal, error, concat): Use const char *.
* make-docfile.c (error, fatal, scan_c_file, scan_lisp_file): Use
const char *.
* etags.c (compressor, language, Ada_suffix, Ada_help, Asm_suffixes)
(Asm_help, default_C_suffixes, default_C_help, Cplusplus_suffixes)
(Cplusplus_help, Cjava_suffixes, Cobol_suffixes, Cstar_suffixes)
(Erlang_suffixes, Erlang_help, Forth_suffixes, Forth_help)
(Fortran_suffixes, Fortran_help, HTML_suffixes, HTML_help)
(Lisp_suffixes, Lisp_help, Lua_suffixes, Lua_help)
(Makefile_filenames, Makefile_help, Objc_suffixes, Objc_help)
(Pascal_suffixes, Pascal_help, Perl_suffixes, Perl_interpreters)
(Perl_help, PHP_suffixes, PHP_help, plain_C_suffixses, PS_suffixes)
(PS_help, Prolog_suffixes, Prolog_help, Python_suffixes, Python_help)
(Scheme_suffixes, Scheme_help, TeX_suffixes, TeX_help, Texinfo_suffixes)
(Texinfo_help, Yacc_suffixes, Yacc_help, auto_help, none_help)
(no_lang_help, print_language_names)
(get_language_from_interpreter, get_language_from_filename)
(init, make_tag, struct C_stab_entry, write_classname, TEX_defenv)
(TEX_decode_env, nocase_tail, savestr, savenstr, fatal, pfatal)
(concat): Use const char*.
* emacsclient.c (message, sock_err_message, send_to_emacs)
(quote_argument, set_local_socket)
(start_daemon_and_retry_set_socket): Use const char*.
* ebrowse.c (struct member): filename, def_filename is const.
(struct sym): filename, sfilename is const.
(struct kw): name is const.
(add_sym, yyerror, token_string, insert_keyword, main): Use const char*.
* b2m.c (concat, fatal): Use const char*.
(main): Don't assign labels a string literal.
2010-08-07 Juanma Barranquero <lekktu@gmail.com>
* ebrowse.c (usage, version, mark_virtual):
......
......@@ -68,9 +68,9 @@ extern char *strtok(char *, const char *);
long *xmalloc (unsigned int size);
long *xrealloc (char *ptr, unsigned int size);
char *concat (char *s1, char *s2, char *s3);
char *concat (const char *s1, const char *s2, const char *s3);
long readline (struct linebuffer *linebuffer, register FILE *stream);
void fatal (char *message) NO_RETURN;
void fatal (const char *message) NO_RETURN;
/*
* xnew -- allocate storage. SYNOPSIS: Type *xnew (int n, Type);
......@@ -170,6 +170,7 @@ main (int argc, char **argv)
continue;
else if (data.buffer[1] == '\f')
{
static char babyl[] = "X-Babyl-Labels: ";
if (first)
first = FALSE;
else if (! last_was_blank_line)
......@@ -177,7 +178,7 @@ main (int argc, char **argv)
/* Save labels. */
readline (&data, stdin);
p = strtok (data.buffer, " ,\r\n\t");
labels = "X-Babyl-Labels: ";
labels = babyl;
while ((p = strtok (NULL, " ,\r\n\t")))
labels = concat (labels, p, ", ");
......@@ -218,7 +219,7 @@ main (int argc, char **argv)
* concatenate those of s1, s2, s3.
*/
char *
concat (char *s1, char *s2, char *s3)
concat (const char *s1, const char *s2, const char *s3)
{
int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
char *result = xnew (len1 + len2 + len3 + 1, char);
......@@ -305,7 +306,7 @@ xrealloc (char *ptr, unsigned int size)
}
void
fatal (char *message)
fatal (const char *message)
{
fprintf (stderr, "%s: %s\n", progname, message);
exit (EXIT_FAILURE);
......
......@@ -249,10 +249,10 @@ struct member
int vis; /* Visibility (public, ...). */
int flags; /* See F_* above. */
char *regexp; /* Matching regular expression. */
char *filename; /* Don't free this shared string. */
const char *filename; /* Don't free this shared string. */
int pos; /* Buffer position of occurrence. */
char *def_regexp; /* Regular expression matching definition. */
char *def_filename; /* File name of definition. */
const char *def_filename; /* File name of definition. */
int def_pos; /* Buffer position of definition. */
char name[1]; /* Member name. */
};
......@@ -294,8 +294,8 @@ struct sym
struct member *types; /* List of local types. */
char *regexp; /* Matching regular expression. */
int pos; /* Buffer position. */
char *filename; /* File in which it can be found. */
char *sfilename; /* File in which members can be found. */
const char *filename; /* File in which it can be found. */
const char *sfilename; /* File in which members can be found. */
struct sym *namesp; /* Namespace in which defined. . */
char name[1]; /* Name of the class. */
};
......@@ -353,7 +353,7 @@ int yyline;
/* The name of the current input file. */
char *filename;
const char *filename;
/* Three character class vectors, and macros to test membership
of characters. */
......@@ -444,7 +444,7 @@ int tk = -1;
struct kw
{
char *name; /* Spelling. */
const char *name; /* Spelling. */
int tk; /* Token value. */
struct kw *next; /* Next in collision chain. */
};
......@@ -470,10 +470,10 @@ struct search_path *search_path_tail;
int yylex (void);
void yyparse (void);
void re_init_parser (void);
char *token_string (int);
const char *token_string (int);
char *matching_regexp (void);
void init_sym (void);
struct sym *add_sym (char *, struct sym *);
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);
......@@ -489,7 +489,7 @@ void mark_inherited_virtual (void);
void leave_namespace (void);
void enter_namespace (char *);
void register_namespace_alias (char *, struct link *);
void insert_keyword (char *, int);
void insert_keyword (const char *, int);
void re_init_scanner (void);
void init_scanner (void);
void process_file (char *);
......@@ -517,7 +517,7 @@ 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 (char *, char *);
void yyerror (const char *, const char *);
void usage (int) NO_RETURN;
void version (void) NO_RETURN;
......@@ -531,7 +531,7 @@ void version (void) NO_RETURN;
name and line number. */
void
yyerror (char *format, char *s)
yyerror (const char *format, const char *s)
{
fprintf (stderr, "%s:%d: ", filename, yyline);
fprintf (stderr, format, s);
......@@ -605,11 +605,11 @@ init_sym (void)
create a new symbol and set it to default values. */
struct sym *
add_sym (char *name, struct sym *nested_in_class)
add_sym (const char *name, struct sym *nested_in_class)
{
struct sym *sym;
unsigned h;
char *s;
const char *s;
struct sym *scope = nested_in_class ? nested_in_class : current_namespace;
for (s = name, h = 0; *s; ++s)
......@@ -1975,7 +1975,7 @@ matching_regexp (void)
/* Return a printable representation of token T. */
char *
const char *
token_string (int t)
{
static char b[3];
......@@ -2111,9 +2111,9 @@ re_init_scanner (void)
table. */
void
insert_keyword (char *name, int tk)
insert_keyword (const char *name, int tk)
{
char *s;
const char *s;
unsigned h = 0;
struct kw *k = (struct kw *) xmalloc (sizeof *k);
......@@ -2839,7 +2839,7 @@ operator_name (int *sc)
{
static int id_size = 0;
static char *id = NULL;
char *s;
const char *s;
int len;
MATCH ();
......@@ -3680,7 +3680,7 @@ main (int argc, char **argv)
{
int i;
int any_inputfiles = 0;
static char *out_filename = DEFAULT_OUTFILE;
static const char *out_filename = DEFAULT_OUTFILE;
static char **input_filenames = NULL;
static int input_filenames_size = 0;
static int n_input_files;
......
......@@ -134,7 +134,7 @@ int eval = 0;
int current_frame = 1;
/* The display on which Emacs should work. --display. */
char *display = NULL;
const char *display = NULL;
/* The parent window ID, if we are opening a frame via XEmbed. */
char *parent_id = NULL;
......@@ -150,7 +150,7 @@ const char *alternate_editor = NULL;
char *socket_name = NULL;
/* If non-NULL, the filename of the authentication file. */
char *server_file = NULL;
const char *server_file = NULL;
/* PID of the Emacs server process. */
int emacs_pid = 0;
......@@ -479,7 +479,7 @@ ttyname (int fd)
/* Display a normal or error message.
On Windows, use a message box if compiled as a Windows app. */
void
message (int is_error, char *message, ...)
message (int is_error, const char *message, ...)
{
char msg[2048];
va_list args;
......@@ -724,7 +724,7 @@ HSOCKET emacs_socket = 0;
/* On Windows, the socket library was historically separate from the standard
C library, so errors are handled differently. */
void
sock_err_message (char *function_name)
sock_err_message (const char *function_name)
{
#ifdef WINDOWSNT
char* msg = NULL;
......@@ -748,7 +748,7 @@ sock_err_message (char *function_name)
- the buffer is full (but this shouldn't happen)
Otherwise, we just accumulate it. */
void
send_to_emacs (HSOCKET s, char *data)
send_to_emacs (HSOCKET s, const char *data)
{
while (data)
{
......@@ -787,10 +787,11 @@ send_to_emacs (HSOCKET s, char *data)
Does not change the string. Outputs the result to S. */
void
quote_argument (HSOCKET s, char *str)
quote_argument (HSOCKET s, const char *str)
{
char *copy = (char *) xmalloc (strlen (str) * 2 + 1);
char *p, *q;
const char *p;
char *q;
p = str;
q = copy;
......@@ -1026,7 +1027,7 @@ set_tcp_socket (void)
/* Returns 1 if PREFIX is a prefix of STRING. */
static int
strprefix (char *prefix, char *string)
strprefix (const char *prefix, const char *string)
{
return !strncmp (prefix, string, strlen (prefix));
}
......@@ -1215,8 +1216,8 @@ set_local_socket (void)
int sock_status = 0;
int default_sock = !socket_name;
int saved_errno = 0;
char *server_name = "server";
char *tmpdir;
const char *server_name = "server";
const char *tmpdir;
if (socket_name && !strchr (socket_name, '/')
&& !strchr (socket_name, '\\'))
......@@ -1479,11 +1480,13 @@ start_daemon_and_retry_set_socket (void)
}
else
{
char *d_argv[] = {"emacs", "--daemon", 0 };
char emacs[] = "emacs";
char daemon[] = "--daemon";
char *d_argv[] = {emacs, daemon, 0 };
if (socket_name != NULL)
{
/* Pass --daemon=socket_name as argument. */
char *deq = "--daemon=";
const char *deq = "--daemon=";
char *daemon_arg = alloca (strlen (deq)
+ strlen (socket_name) + 1);
strcpy (daemon_arg, deq);
......
This diff is collapsed.
......@@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#if defined (BSD_SYSTEM) && !defined (USE_FAKEMAIL)
/* This program isnot used in BSD, so just avoid loader complaints. */
int
main ()
main (void)
{
return 0;
}
......
......@@ -68,9 +68,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif
int scan_file (char *filename);
int scan_lisp_file (char *filename, char *mode);
int scan_c_file (char *filename, char *mode);
void fatal (char *s1, char *s2) NO_RETURN;
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;
#ifdef MSDOS
/* s/msdos.h defines this as sys_chdir, but we're not linking with the
......@@ -92,7 +92,7 @@ char *progname;
/* VARARGS1 */
void
error (char *s1, char *s2)
error (const char *s1, const char *s2)
{
fprintf (stderr, "%s: ", progname);
fprintf (stderr, s1, s2);
......@@ -103,7 +103,7 @@ error (char *s1, char *s2)
/* VARARGS1 */
void
fatal (char *s1, char *s2)
fatal (const char *s1, const char *s2)
{
error (s1, s2);
exit (EXIT_FAILURE);
......@@ -233,10 +233,10 @@ struct rcsoc_state
/* A keyword we look for at the beginning of lines. If found, it is
not copied, and SAW_KEYWORD is set to true. */
char *keyword;
const char *keyword;
/* The current point we've reached in an occurrence of KEYWORD in
the input stream. */
char *cur_keyword_ptr;
const char *cur_keyword_ptr;
/* Set to true if we saw an occurrence of KEYWORD. */
int saw_keyword;
};
......@@ -326,7 +326,7 @@ scan_keyword_or_put_char (int ch, struct rcsoc_state *state)
keyword, but it was a false alarm. Output the
part we scanned. */
{
char *p;
const char *p;
for (p = state->keyword; p < state->cur_keyword_ptr; p++)
put_char (*p, state);
......@@ -521,7 +521,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
int
scan_c_file (char *filename, char *mode)
scan_c_file (char *filename, const char *mode)
{
FILE *infile;
register int c;
......@@ -834,7 +834,7 @@ read_lisp_symbol (FILE *infile, char *buffer)
}
int
scan_lisp_file (char *filename, char *mode)
scan_lisp_file (const char *filename, const char *mode)
{
FILE *infile;
register int c;
......
......@@ -147,11 +147,11 @@ static char *mail_spool_name ();
char *strerror (int);
#endif
static void fatal (char *s1, char *s2, char *s3) NO_RETURN;
static void error (char *s1, char *s2, char *s3);
static void fatal (const char *s1, const char *s2, const char *s3) NO_RETURN;
static void error (const char *s1, const char *s2, const char *s3);
static void pfatal_with_name (char *name) NO_RETURN;
static void pfatal_and_delete (char *name) NO_RETURN;
static char *concat (char *s1, char *s2, char *s3);
static char *concat (const char *s1, const char *s2, const char *s3);
static long *xmalloc (unsigned int size);
#ifdef MAIL_USE_POP
static int popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse_order);
......@@ -589,7 +589,7 @@ mail_spool_name (inname)
/* Print error message and exit. */
static void
fatal (char *s1, char *s2, char *s3)
fatal (const char *s1, const char *s2, const char *s3)
{
if (delete_lockname)
unlink (delete_lockname);
......@@ -601,7 +601,7 @@ fatal (char *s1, char *s2, char *s3)
are args for it or null. */
static void
error (char *s1, char *s2, char *s3)
error (const char *s1, const char *s2, const char *s3)
{
fprintf (stderr, "movemail: ");
if (s3)
......@@ -630,7 +630,7 @@ pfatal_and_delete (char *name)
/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */
static char *
concat (char *s1, char *s2, char *s3)
concat (const char *s1, const char *s2, const char *s3)
{
int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
char *result = (char *) xmalloc (len1 + len2 + len3 + 1);
......
......@@ -110,7 +110,7 @@ extern int h_errno;
static int socket_connection (char *, int);
static int pop_getline (popserver, char **);
static int sendline (popserver, char *);
static int sendline (popserver, const char *);
static int fullwrite (int, char *, int);
static int getok (popserver);
#if 0
......@@ -676,7 +676,7 @@ pop_top_flush (popserver server)
}
int
pop_multi_first (popserver server, char *command, char **response)
pop_multi_first (popserver server, const char *command, char **response)
{
if (server->in_multi)
{
......@@ -988,7 +988,7 @@ socket_connection (char *host, int flags)
struct servent *servent;
struct sockaddr_in addr;
char found_port = 0;
char *service;
const char *service;
int sock;
char *realhost;
#ifdef KERBEROS
......@@ -1414,7 +1414,7 @@ pop_getline (popserver server, char **line)
* Side effects: Closes the connection on error.
*/
static int
sendline (popserver server, char *line)
sendline (popserver server, const char *line)
{
#define SENDLINE_ERROR "Error writing to POP server: "
int ret;
......
......@@ -49,39 +49,31 @@ typedef struct _popserver *popserver;
#define POP_NO_HESIOD (1<<1)
#define POP_NO_GETPASS (1<<2)
#ifdef __STDC__
#define _ARGS(a) a
#else
#define _ARGS(a) ()
#endif
extern popserver pop_open _ARGS((char *host, char *username, char *password,
int flags));
extern int pop_stat _ARGS((popserver server, int *count, int *size));
extern int pop_list _ARGS((popserver server, int message, int **IDs,
int **size));
extern int pop_retrieve _ARGS((popserver server, int message, int markfrom,
char **));
extern int pop_retrieve_first _ARGS((popserver server, int message,
char **response));
extern int pop_retrieve_next _ARGS((popserver server, char **line));
extern int pop_retrieve_flush _ARGS((popserver server));
extern int pop_top_first _ARGS((popserver server, int message, int lines,
char **response));
extern int pop_top_next _ARGS((popserver server, char **line));
extern int pop_top_flush _ARGS((popserver server));
extern int pop_multi_first _ARGS((popserver server, char *command,
char **response));
extern int pop_multi_next _ARGS((popserver server, char **line));
extern int pop_multi_flush _ARGS((popserver server));
extern int pop_delete _ARGS((popserver server, int message));
extern int pop_noop _ARGS((popserver server));
extern int pop_last _ARGS((popserver server));
extern int pop_reset _ARGS((popserver server));
extern int pop_quit _ARGS((popserver server));
extern void pop_close _ARGS((popserver));
#undef _ARGS
extern popserver pop_open (char *host, char *username, char *password,
int flags);
extern int pop_stat (popserver server, int *count, int *size);
extern int pop_list (popserver server, int message, int **IDs,
int **size);
extern int pop_retrieve (popserver server, int message, int markfrom,
char **);
extern int pop_retrieve_first (popserver server, int message,
char **response);
extern int pop_retrieve_next (popserver server, char **line);
extern int pop_retrieve_flush (popserver server);
extern int pop_top_first (popserver server, int message, int lines,
char **response);
extern int pop_top_next (popserver server, char **line);
extern int pop_top_flush (popserver server);
extern int pop_multi_first (popserver server, const char *command,
char **response);
extern int pop_multi_next (popserver server, char **line);
extern int pop_multi_flush (popserver server);
extern int pop_delete (popserver server, int message);
extern int pop_noop (popserver server);
extern int pop_last (popserver server);
extern int pop_reset (popserver server);
extern int pop_quit (popserver server);
extern void pop_close (popserver);
/* arch-tag: 76cc5f58-8e86-48fa-bc72-a7c6cb1c4f1c
(do not change this comment) */
......@@ -65,7 +65,7 @@ struct docstr /* Allocated thing for an entry. */
/* Print error message. `s1' is printf control string, `s2' is arg for it. */
void
error (char *s1, char *s2)
error (const char *s1, const char *s2)
{
fprintf (stderr, "sorted-doc: ");
fprintf (stderr, s1, s2);
......@@ -75,7 +75,7 @@ error (char *s1, char *s2)
/* Print error message and exit. */
void
fatal (char *s1, char *s2)
fatal (const char *s1, const char *s2)
{
error (s1, s2);
exit (EXIT_FAILURE);
......@@ -117,7 +117,7 @@ enum state
WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
};
char *states[] =
const char *states[] =
{
"WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
};
......
......@@ -157,8 +157,8 @@ get_user_id (void)
return buf->pw_name;
}
char *
get_prefix (int running_suid, char *user_prefix)
const char *
get_prefix (int running_suid, const char *user_prefix)
{
if (!running_suid && user_prefix == NULL)
lose ("Not using a shared game directory, and no prefix given.");
......@@ -178,7 +178,8 @@ main (int argc, char **argv)
{
int c, running_suid;
void *lockstate;
char *user_id, *scorefile, *prefix, *user_prefix = NULL;
char *user_id, *scorefile;
const char *prefix, *user_prefix = NULL;
struct stat buf;
struct score_entry *scores;
int newscore, scorecount, reverse = 0, max = MAX_SCORES;
......@@ -451,7 +452,7 @@ lock_file (const char *filename, void **state)
int fd;
struct stat buf;
int attempts = 0;
char *lockext = ".lockfile";
const char *lockext = ".lockfile";
char *lockpath = malloc (strlen (filename) + strlen (lockext) + 60);
if (!lockpath)
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment