Mercurial > emacs
changeset 109313:e856a274549b
Constify functions taking char *
* alloc.c (pending_malloc_warning, malloc_warning): Add const.
* callproc.c (relocate_fd, getenv_internal_1, getenv_internal)
(egetenv): Likewise.
* doprnt.c (doprnt): Likewise.
* editfns.c (set_time_zone_rule, format2): Likewise.
* emacs.c (decode_env_path): Likewise.
* eval.c (signal_error, error): Likewise.
* insdel.c (replace_range_2): Likewise.
* keyboard.c (cmd_error_internal): Likewise.
* lread.c (isfloat_string, make_symbol, dir_warning): Likewise.
* print.c (write_string, write_string_1, print_error_message):
Likewise.
* vm-limit.c (warn_function, memory_warnings): Likewise.
* xdisp.c (message1, message1_nolog, message_with_string)
(vmessage, message, message_nolog): Likewise.
* emacs.c: Remove duplicate declaration.
* keyboard.h: Likewise.
* lisp.h: Update prototypes.
author | Andreas Schwab <schwab@linux-m68k.org> |
---|---|
date | Sun, 11 Jul 2010 11:27:13 +0200 |
parents | 67391fa3496b |
children | b7a866c9460c |
files | src/ChangeLog src/alloc.c src/callproc.c src/doprnt.c src/editfns.c src/emacs.c src/eval.c src/insdel.c src/keyboard.c src/keyboard.h src/lisp.h src/lread.c src/print.c src/vm-limit.c src/xdisp.c |
diffstat | 15 files changed, 92 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Sun Jul 11 10:44:34 2010 +0200 +++ b/src/ChangeLog Sun Jul 11 11:27:13 2010 +0200 @@ -1,5 +1,24 @@ 2010-07-11 Andreas Schwab <schwab@linux-m68k.org> + * alloc.c (pending_malloc_warning, malloc_warning): Add const. + * callproc.c (relocate_fd, getenv_internal_1, getenv_internal) + (egetenv): Likewise. + * doprnt.c (doprnt): Likewise. + * editfns.c (set_time_zone_rule, format2): Likewise. + * emacs.c (decode_env_path): Likewise. + * eval.c (signal_error, error): Likewise. + * insdel.c (replace_range_2): Likewise. + * keyboard.c (cmd_error_internal): Likewise. + * lread.c (isfloat_string, make_symbol, dir_warning): Likewise. + * print.c (write_string, write_string_1, print_error_message): + Likewise. + * vm-limit.c (warn_function, memory_warnings): Likewise. + * xdisp.c (message1, message1_nolog, message_with_string) + (vmessage, message, message_nolog): Likewise. + * emacs.c: Remove duplicate declaration. + * keyboard.h: Likewise. + * lisp.h: Update prototypes. + * eval.c: Fix indentation problem. * keyboard.c: Include "process.h"
--- a/src/alloc.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/alloc.c Sun Jul 11 11:27:13 2010 +0200 @@ -298,7 +298,7 @@ /* If nonzero, this is a warning delivered by malloc and not yet displayed. */ -char *pending_malloc_warning; +const char *pending_malloc_warning; /* Pre-computed signal argument for use when memory is exhausted. */ @@ -514,7 +514,7 @@ /* Function malloc calls this if it finds we are near exhausting storage. */ void -malloc_warning (char *str) +malloc_warning (const char *str) { pending_malloc_warning = str; }
--- a/src/callproc.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/callproc.c Sun Jul 11 11:27:13 2010 +0200 @@ -1291,9 +1291,9 @@ int new = dup (fd); if (new == -1) { - char *message1 = "Error while setting up child: "; - char *errmessage = strerror (errno); - char *message2 = "\n"; + const char *message1 = "Error while setting up child: "; + const char *errmessage = strerror (errno); + const char *message2 = "\n"; emacs_write (2, message1, strlen (message1)); emacs_write (2, errmessage, strlen (errmessage)); emacs_write (2, message2, strlen (message2)); @@ -1308,7 +1308,8 @@ } static int -getenv_internal_1 (char *var, int varlen, char **value, int *valuelen, Lisp_Object env) +getenv_internal_1 (const char *var, int varlen, char **value, int *valuelen, + Lisp_Object env) { for (; CONSP (env); env = XCDR (env)) { @@ -1342,7 +1343,8 @@ } static int -getenv_internal (char *var, int varlen, char **value, int *valuelen, Lisp_Object frame) +getenv_internal (const char *var, int varlen, char **value, int *valuelen, + Lisp_Object frame) { /* Try to find VAR in Vprocess_environment first. */ if (getenv_internal_1 (var, varlen, value, valuelen, @@ -1403,7 +1405,7 @@ /* A version of getenv that consults the Lisp environment lists, easily callable from C. */ char * -egetenv (char *var) +egetenv (const char *var) { char *value; int valuelen;
--- a/src/doprnt.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/doprnt.c Sun Jul 11 11:27:13 2010 +0200 @@ -59,9 +59,10 @@ Integers are passed as C integers. */ int -doprnt (char *buffer, register int bufsize, char *format, char *format_end, va_list ap) +doprnt (char *buffer, register int bufsize, const char *format, + const char *format_end, va_list ap) { - register char *fmt = format; /* Pointer into format string */ + const char *fmt = format; /* Pointer into format string */ register char *bufptr = buffer; /* Pointer into output buffer.. */ /* Use this for sprintf unless we need something really big. */
--- a/src/editfns.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/editfns.c Sun Jul 11 11:27:13 2010 +0200 @@ -2045,7 +2045,7 @@ responsibility to free. */ void -set_time_zone_rule (char *tzstring) +set_time_zone_rule (const char *tzstring) { int envptrs; char **from, **to, **newenv; @@ -4111,7 +4111,7 @@ } Lisp_Object -format2 (char *string1, Lisp_Object arg0, Lisp_Object arg1) +format2 (const char *string1, Lisp_Object arg0, Lisp_Object arg1) { Lisp_Object args[3]; args[0] = build_string (string1);
--- a/src/emacs.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/emacs.c Sun Jul 11 11:27:13 2010 +0200 @@ -90,8 +90,6 @@ const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc."; const char emacs_version[] = "24.0.50"; -extern void malloc_warning (char *); -extern void set_time_zone_rule (char *); #ifdef HAVE_INDEX extern char *index (const char *, int); #endif @@ -2344,17 +2342,16 @@ #endif Lisp_Object -decode_env_path (evarname, defalt) - char *evarname, *defalt; +decode_env_path (const char *evarname, const char *defalt) { - register char *path, *p; + const char *path, *p; Lisp_Object lpath, element, tem; /* It's okay to use getenv here, because this function is only used to initialize variables when Emacs starts up, and isn't called after that. */ if (evarname != 0) - path = (char *) getenv (evarname); + path = getenv (evarname); else path = 0; if (!path) @@ -2363,18 +2360,18 @@ /* Ensure values from the environment use the proper directory separator. */ if (path) { - p = alloca (strlen (path) + 1); - strcpy (p, path); - path = p; - - dostounix_filename (path); + char *path_copy = alloca (strlen (path) + 1); + strcpy (path_copy, path); + dostounix_filename (path_copy); + path = path_copy; } #endif lpath = Qnil; while (1) { p = index (path, SEPCHAR); - if (!p) p = path + strlen (path); + if (!p) + p = path + strlen (path); element = (p - path ? make_string (path, p - path) : build_string ("."));
--- a/src/eval.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/eval.c Sun Jul 11 11:27:13 2010 +0200 @@ -1775,7 +1775,7 @@ If ARG is not a genuine list, make it a one-element list. */ void -signal_error (char *s, Lisp_Object arg) +signal_error (const char *s, Lisp_Object arg) { Lisp_Object tortoise, hare; @@ -1995,7 +1995,7 @@ /* VARARGS 1 */ void -error (char *m, ...) +error (const char *m, ...) { char buf[200]; int size = 200;
--- a/src/insdel.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/insdel.c Sun Jul 11 11:27:13 2010 +0200 @@ -1628,7 +1628,7 @@ void replace_range_2 (EMACS_INT from, EMACS_INT from_byte, EMACS_INT to, EMACS_INT to_byte, - char *ins, EMACS_INT inschars, EMACS_INT insbytes, + const char *ins, EMACS_INT inschars, EMACS_INT insbytes, int markers) { EMACS_INT nbytes_del, nchars_del;
--- a/src/keyboard.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/keyboard.c Sun Jul 11 11:27:13 2010 +0200 @@ -1238,7 +1238,7 @@ string. */ void -cmd_error_internal (Lisp_Object data, char *context) +cmd_error_internal (Lisp_Object data, const char *context) { struct frame *sf = SELECTED_FRAME ();
--- a/src/keyboard.h Sun Jul 11 10:44:34 2010 +0200 +++ b/src/keyboard.h Sun Jul 11 11:27:13 2010 +0200 @@ -468,7 +468,6 @@ extern void swallow_events (int); extern int help_char_p (Lisp_Object); extern void quit_throw_to_read_char (void) NO_RETURN; -extern void cmd_error_internal (Lisp_Object, char *); extern int lucid_event_type_list_p (Lisp_Object); extern void kbd_buffer_store_event (struct input_event *); extern void kbd_buffer_store_event_hold (struct input_event *,
--- a/src/lisp.h Sun Jul 11 10:44:34 2010 +0200 +++ b/src/lisp.h Sun Jul 11 11:27:13 2010 +0200 @@ -2616,7 +2616,7 @@ EMACS_INT, EMACS_INT); extern void replace_range (EMACS_INT, EMACS_INT, Lisp_Object, int, int, int); extern void replace_range_2 (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, - char *, EMACS_INT, EMACS_INT, int); + const char *, EMACS_INT, EMACS_INT, int); extern void syms_of_insdel (void); /* Defined in dispnew.c */ @@ -2650,16 +2650,16 @@ extern Lisp_Object current_message (void); extern void set_message (const char *s, Lisp_Object, int, int); extern void clear_message (int, int); -extern void message (char *, ...); -extern void message_nolog (char *, ...); -extern void message1 (char *); -extern void message1_nolog (char *); +extern void message (const char *, ...); +extern void message_nolog (const char *, ...); +extern void message1 (const char *); +extern void message1_nolog (const char *); extern void message2 (const char *, int, int); extern void message2_nolog (const char *, int, int); extern void message3 (Lisp_Object, int, int); extern void message3_nolog (Lisp_Object, int, int); extern void message_dolog (const char *, int, int, int); -extern void message_with_string (char *, Lisp_Object, int); +extern void message_with_string (const char *, Lisp_Object, int); extern void message_log_maybe_newline (void); extern void update_echo_area (void); extern void truncate_echo_area (int); @@ -2680,14 +2680,14 @@ extern void syms_of_xsettings (void); /* Defined in vm-limit.c. */ -extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (char*)); +extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (const char *)); /* Defined in alloc.c */ extern void check_pure_size (void); extern void allocate_string_data (struct Lisp_String *, int, int); extern void reset_malloc_hooks (void); extern void uninterrupt_malloc (void); -extern void malloc_warning (char *); +extern void malloc_warning (const char *); extern void memory_full (void) NO_RETURN; extern void buffer_memory_full (void) NO_RETURN; extern int survives_gc_p (Lisp_Object); @@ -2791,16 +2791,17 @@ extern void temp_output_buffer_setup (const char *); extern int print_level, print_escape_newlines; extern Lisp_Object Qprint_escape_newlines; -extern void write_string (char *, int); -extern void write_string_1 (char *, int, Lisp_Object); -extern void print_error_message (Lisp_Object, Lisp_Object, char *, Lisp_Object); +extern void write_string (const char *, int); +extern void write_string_1 (const char *, int, Lisp_Object); +extern void print_error_message (Lisp_Object, Lisp_Object, const char *, + Lisp_Object); extern Lisp_Object internal_with_output_to_temp_buffer (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); extern void float_to_string (unsigned char *, double); extern void syms_of_print (void); /* Defined in doprnt.c */ -extern int doprnt (char *, int, char *, char *, va_list); +extern int doprnt (char *, int, const char *, const char *, va_list); /* Defined in lread.c */ extern Lisp_Object Qvariable_documentation, Qstandard_input; @@ -2819,7 +2820,7 @@ extern Lisp_Object check_obarray (Lisp_Object); extern Lisp_Object intern (const char *); extern Lisp_Object intern_c_string (const char *); -extern Lisp_Object make_symbol (char *); +extern Lisp_Object make_symbol (const char *); extern Lisp_Object oblookup (Lisp_Object, const char *, int, int); #define LOADHIST_ATTACH(x) \ do { \ @@ -2829,10 +2830,10 @@ extern Lisp_Object Vload_history, Vload_suffixes, Vload_file_rep_suffixes; extern int openp (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object *, Lisp_Object); -extern int isfloat_string (char *, int); +extern int isfloat_string (const char *, int); extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), Lisp_Object); -extern void dir_warning (char *, Lisp_Object); +extern void dir_warning (const char *, Lisp_Object); extern void close_load_descs (void); extern void init_obarray (void); extern void init_lread (void); @@ -2885,7 +2886,7 @@ extern void xsignal1 (Lisp_Object, Lisp_Object) NO_RETURN; extern void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object) NO_RETURN; extern void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object) NO_RETURN; -extern void signal_error (char *, Lisp_Object) NO_RETURN; +extern void signal_error (const char *, Lisp_Object) NO_RETURN; EXFUN (Fautoload, 5); EXFUN (Fcommandp, 2); EXFUN (Feval, 1); @@ -2912,7 +2913,7 @@ extern void specbind (Lisp_Object, Lisp_Object); extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); extern Lisp_Object unbind_to (int, Lisp_Object); -extern void error (char *, ...) NO_RETURN; +extern void error (const char *, ...) NO_RETURN; extern void do_autoload (Lisp_Object, Lisp_Object); extern Lisp_Object un_autoload (Lisp_Object); EXFUN (Ffetch_bytecode, 1); @@ -2951,7 +2952,7 @@ EXFUN (Fbobp, 0); EXFUN (Fformat, MANY); EXFUN (Fmessage, MANY); -extern Lisp_Object format2 (char *, Lisp_Object, Lisp_Object); +extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); EXFUN (Fbuffer_substring, 2); EXFUN (Fbuffer_string, 0); extern Lisp_Object save_excursion_save (void); @@ -2977,7 +2978,7 @@ EXFUN (Ffield_beginning, 3); EXFUN (Ffield_end, 3); EXFUN (Ffield_string_no_properties, 1); -extern void set_time_zone_rule (char *); +extern void set_time_zone_rule (const char *); /* Defined in buffer.c */ extern int mouse_face_overlay_overlaps (Lisp_Object); @@ -3177,7 +3178,7 @@ extern int detect_input_pending_ignore_squeezables (void); extern int detect_input_pending_run_timers (int); extern void safe_run_hooks (Lisp_Object); -extern void cmd_error_internal (Lisp_Object, char *); +extern void cmd_error_internal (Lisp_Object, const char *); extern Lisp_Object command_loop_1 (void); extern Lisp_Object recursive_edit_1 (void); extern void record_auto_save (void); @@ -3241,7 +3242,7 @@ extern void syms_of_frame (void); /* Defined in emacs.c */ -extern Lisp_Object decode_env_path (char *, char *); +extern Lisp_Object decode_env_path (const char *, const char *); extern Lisp_Object Vinvocation_name, Vinvocation_directory; extern Lisp_Object Vbefore_init_time, Vafter_init_time; extern Lisp_Object Vinstallation_directory; @@ -3527,7 +3528,7 @@ extern char *xstrdup (const char *); -extern char *egetenv (char *); +extern char *egetenv (const char *); /* Set up the name of the machine we're running on. */ extern void init_system_name (void);
--- a/src/lread.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/lread.c Sun Jul 11 11:27:13 2010 +0200 @@ -3190,11 +3190,10 @@ #define EXP_INT 16 int -isfloat_string (register char *cp, int ignore_trailing) +isfloat_string (const char *cp, int ignore_trailing) { - register int state; - - char *start = cp; + int state; + const char *start = cp; state = 0; if (*cp == '+' || *cp == '-') @@ -3245,7 +3244,8 @@ } return ((ignore_trailing - || (*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f')) + || *cp == 0 || *cp == ' ' || *cp == '\t' || *cp == '\n' + || *cp == '\r' || *cp == '\f') && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) || state == (DOT_CHAR|TRAIL_INT) || state == (LEAD_INT|E_CHAR|EXP_INT) @@ -3588,13 +3588,13 @@ /* Create an uninterned symbol with name STR. */ Lisp_Object -make_symbol (char *str) +make_symbol (const char *str) { int len = strlen (str); - return Fmake_symbol ((!NILP (Vpurify_flag) - ? make_pure_string (str, len, len, 0) - : make_string (str, len))); + return Fmake_symbol (!NILP (Vpurify_flag) + ? make_pure_string (str, len, len, 0) + : make_string (str, len)); } DEFUN ("intern", Fintern, Sintern, 1, 2, 0, @@ -4170,7 +4170,7 @@ does not exist. Print it on stderr and put it in *Messages*. */ void -dir_warning (char *format, Lisp_Object dirname) +dir_warning (const char *format, Lisp_Object dirname) { char *buffer = (char *) alloca (SCHARS (dirname) + strlen (format) + 5);
--- a/src/print.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/print.c Sun Jul 11 11:27:13 2010 +0200 @@ -540,7 +540,7 @@ Do not use this on the contents of a Lisp string. */ void -write_string (char *data, int size) +write_string (const char *data, int size) { PRINTDECLARE; Lisp_Object printcharfun; @@ -557,7 +557,7 @@ Do not use this on the contents of a Lisp string. */ void -write_string_1 (char *data, int size, Lisp_Object printcharfun) +write_string_1 (const char *data, int size, Lisp_Object printcharfun) { PRINTDECLARE; @@ -1007,7 +1007,8 @@ CALLER is the Lisp function inside which the error was signaled. */ void -print_error_message (Lisp_Object data, Lisp_Object stream, char *context, Lisp_Object caller) +print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, + Lisp_Object caller) { Lisp_Object errname, errmsg, file_error, tail; struct gcpro gcpro1;
--- a/src/vm-limit.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/vm-limit.c Sun Jul 11 11:27:13 2010 +0200 @@ -42,7 +42,7 @@ /* Function to call to issue a warning; 0 means don't issue them. */ -static void (*warn_function) (char *); +static void (*warn_function) (const char *); /* Start of data space; can be changed by calling malloc_init. */ static POINTER data_space_start; @@ -289,7 +289,7 @@ WARNFUN specifies the function to call to issue a warning. */ void -memory_warnings (POINTER start, void (*warnfun) (char *)) +memory_warnings (POINTER start, void (*warnfun) (const char *)) { extern void (* __after_morecore_hook) (void); /* From gmalloc.c */
--- a/src/xdisp.c Sun Jul 11 10:44:34 2010 +0200 +++ b/src/xdisp.c Sun Jul 11 11:27:13 2010 +0200 @@ -8413,7 +8413,7 @@ that was alloca'd. */ void -message1 (char *m) +message1 (const char *m) { message2 (m, (m ? strlen (m) : 0), 0); } @@ -8422,7 +8422,7 @@ /* The non-logging counterpart of message1. */ void -message1_nolog (char *m) +message1_nolog (const char *m) { message2_nolog (m, (m ? strlen (m) : 0), 0); } @@ -8431,7 +8431,7 @@ which gets replaced with STRING. */ void -message_with_string (char *m, Lisp_Object string, int log) +message_with_string (const char *m, Lisp_Object string, int log) { CHECK_STRING (string); @@ -8495,7 +8495,7 @@ any existing message, and let the mini-buffer text show through. */ static void -vmessage (char *m, va_list ap) +vmessage (const char *m, va_list ap) { if (noninteractive) { @@ -8549,7 +8549,7 @@ } void -message (char *m, ...) +message (const char *m, ...) { va_list ap; va_start (ap, m); @@ -8561,7 +8561,7 @@ /* The non-logging version of message. */ void -message_nolog (char *m, ...) +message_nolog (const char *m, ...) { Lisp_Object old_log_max; va_list ap;