Commit d4bc586c authored by agoncharov's avatar agoncharov
Browse files

Use 'const char *' instead of 'char *' where appropriate

parent 113b409a
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alloc.c,v 1.10 2005/09/15 18:26:50 rtoy Exp $ */ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alloc.c,v 1.11 2009/01/20 03:58:11 agoncharov Exp $ */
#include <string.h> #include <string.h>
...@@ -114,7 +114,7 @@ alloc_number(long n) ...@@ -114,7 +114,7 @@ alloc_number(long n)
} }
lispobj lispobj
alloc_string(char *str) alloc_string(const char *str)
{ {
int len = strlen(str); int len = strlen(str);
lispobj result = alloc_vector(type_SimpleString, len + 1, 8); lispobj result = alloc_vector(type_SimpleString, len + 1, 8);
......
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alloc.h,v 1.2 2002/05/02 21:10:52 toy Exp $ */ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/alloc.h,v 1.3 2009/01/20 03:58:11 agoncharov Rel $ */
#ifndef _ALLOC_H_ #ifndef _ALLOC_H_
#define _ALLOC_H_ #define _ALLOC_H_
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
extern lispobj alloc_cons(lispobj car, lispobj cdr); extern lispobj alloc_cons(lispobj car, lispobj cdr);
extern lispobj alloc_number(long n); extern lispobj alloc_number(long n);
extern lispobj alloc_string(char *str); extern lispobj alloc_string(const char *str);
extern lispobj alloc_sap(void *ptr); extern lispobj alloc_sap(void *ptr);
#endif /* _ALLOC_H_ */ #endif /* _ALLOC_H_ */
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/core.h,v 1.8 2008/12/10 02:46:12 rtoy Exp $ */ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/core.h,v 1.9 2009/01/20 03:58:11 agoncharov Rel $ */
#ifndef _CORE_H_ #ifndef _CORE_H_
#define _CORE_H_ #define _CORE_H_
...@@ -34,6 +34,6 @@ struct ndir_entry { ...@@ -34,6 +34,6 @@ struct ndir_entry {
#endif #endif
}; };
extern lispobj load_core_file(char *file, fpu_mode_t *fpu_type); extern lispobj load_core_file(const char *file, fpu_mode_t *fpu_type);
#endif /* _CORE_H_ */ #endif /* _CORE_H_ */
/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/coreparse.c,v 1.13 2008/12/10 02:46:12 rtoy Exp $ */ /* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/coreparse.c,v 1.14 2009/01/20 03:58:11 agoncharov Rel $ */
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/file.h> #include <sys/file.h>
...@@ -75,7 +75,7 @@ process_directory(int fd, long *ptr, int count) ...@@ -75,7 +75,7 @@ process_directory(int fd, long *ptr, int count)
} }
lispobj lispobj
load_core_file(char *file, fpu_mode_t* fpu_type) load_core_file(const char *file, fpu_mode_t* fpu_type)
{ {
int fd = open(file, O_RDONLY), count; int fd = open(file, O_RDONLY), count;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Above changes put into main CVS branch. 05-Jul-2007. Above changes put into main CVS branch. 05-Jul-2007.
$Id: elf.c,v 1.17 2008/03/18 09:22:55 cshapiro Exp $ $Id: elf.c,v 1.18 2009/01/20 03:58:11 agoncharov Exp $
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -399,7 +399,7 @@ read_section_header_entry(int fd, Elf_Shdr *shp) ...@@ -399,7 +399,7 @@ read_section_header_entry(int fd, Elf_Shdr *shp)
is not set until some time after this is done. is not set until some time after this is done.
*/ */
void void
map_core_sections(char *exec_name) map_core_sections(const char *exec_name)
{ {
int exec_fd; int exec_fd;
Elf_Shdr sh; /* A section header entry. */ Elf_Shdr sh; /* A section header entry. */
......
/* $Id: elf.h,v 1.9 2008/05/16 13:30:22 rswindells Exp $ */ /* $Id: elf.h,v 1.10 2009/01/20 03:58:11 agoncharov Rel $ */
/* This code was written by Fred Gilham and has been placed in the public domain. It is /* This code was written by Fred Gilham and has been placed in the public domain. It is
provided "AS-IS" and without warranty of any kind. provided "AS-IS" and without warranty of any kind.
...@@ -31,7 +31,7 @@ int write_elf_object(const char *, int, os_vm_address_t, os_vm_address_t); ...@@ -31,7 +31,7 @@ int write_elf_object(const char *, int, os_vm_address_t, os_vm_address_t);
void elf_cleanup(const char *); void elf_cleanup(const char *);
int elf_run_linker(long, char *); int elf_run_linker(long, char *);
void map_core_sections(char *); void map_core_sections(const char *);
#if defined(SOLARIS) || defined(linux) || defined(__NetBSD__) #if defined(SOLARIS) || defined(linux) || defined(__NetBSD__)
typedef Elf32_Ehdr Elf_Ehdr; typedef Elf32_Ehdr Elf_Ehdr;
......
/* /*
* main() entry point for a stand alone lisp image. * main() entry point for a stand alone lisp image.
* *
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.66 2009/01/05 22:26:27 rtoy Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.67 2009/01/20 03:58:11 agoncharov Exp $
* *
*/ */
...@@ -59,7 +59,7 @@ sigint_init(void) ...@@ -59,7 +59,7 @@ sigint_init(void)
/* Noise to convert argv and envp into lists. */ /* Noise to convert argv and envp into lists. */
static lispobj static lispobj
alloc_str_list(char *list[]) alloc_str_list(const char *list[])
{ {
lispobj result, newcons; lispobj result, newcons;
struct cons *ptr; struct cons *ptr;
...@@ -105,10 +105,10 @@ static int debug_lisp_search = FALSE; ...@@ -105,10 +105,10 @@ static int debug_lisp_search = FALSE;
* From the current location of the lisp executable, create a suitable * From the current location of the lisp executable, create a suitable
* default for CMUCLLIB * default for CMUCLLIB
*/ */
char * static const char *
default_cmucllib(char *argv0arg) default_cmucllib(const char *argv0arg)
{ {
char *p; char *p0;
char *defpath; char *defpath;
char *cwd; char *cwd;
char *argv0_dir = strdup(argv0arg); char *argv0_dir = strdup(argv0arg);
...@@ -118,11 +118,11 @@ default_cmucllib(char *argv0arg) ...@@ -118,11 +118,11 @@ default_cmucllib(char *argv0arg)
* executable name * executable name
*/ */
p = strrchr(argv0_dir, '/'); p0 = strrchr(argv0_dir, '/');
if (p == NULL) { if (p0 == NULL) {
*argv0_dir = '\0'; *argv0_dir = '\0';
} else if (p != argv0_dir) { } else if (p0 != argv0_dir) {
*p = '\0'; *p0 = '\0';
} }
/* /*
...@@ -175,10 +175,7 @@ default_cmucllib(char *argv0arg) ...@@ -175,10 +175,7 @@ default_cmucllib(char *argv0arg)
cwd[0] = '\0'; cwd[0] = '\0';
if (path) { if (path) {
const char *ptr = (p0 != NULL) ? p0 : argv0arg;
if (p == NULL) {
p = argv0arg;
}
for (p1 = path; *p1 != '\0'; p1 = p2) { for (p1 = path; *p1 != '\0'; p1 = p2) {
p2 = strchr(p1, ':'); p2 = strchr(p1, ':');
...@@ -187,7 +184,7 @@ default_cmucllib(char *argv0arg) ...@@ -187,7 +184,7 @@ default_cmucllib(char *argv0arg)
strncpy(cwd, p1, p2 - p1); strncpy(cwd, p1, p2 - p1);
cwd[p2 - p1] = '/'; cwd[p2 - p1] = '/';
cwd[p2 - p1 + 1] = '\0'; cwd[p2 - p1 + 1] = '\0';
strcpy(cwd + (p2 - p1 + 1), p); strcpy(cwd + (p2 - p1 + 1), ptr);
if (debug_lisp_search) { if (debug_lisp_search) {
fprintf(stderr, "User's PATH, trying %s\n", cwd); fprintf(stderr, "User's PATH, trying %s\n", cwd);
...@@ -274,7 +271,7 @@ default_cmucllib(char *argv0arg) ...@@ -274,7 +271,7 @@ default_cmucllib(char *argv0arg)
free(argv0_dir); free(argv0_dir);
free(cwd); free(cwd);
return defpath; return (const char *) defpath;
} }
/* /*
...@@ -336,8 +333,8 @@ search_core(const char *lib, const char *default_core) ...@@ -336,8 +333,8 @@ search_core(const char *lib, const char *default_core)
* *
* Return the new lib path. * Return the new lib path.
*/ */
char * static const char *
prepend_core_path(char *lib, char *corefile) prepend_core_path(const char *lib, const char *corefile)
{ {
char cwd[FILENAME_MAX]; char cwd[FILENAME_MAX];
char *path; char *path;
...@@ -372,9 +369,8 @@ prepend_core_path(char *lib, char *corefile) ...@@ -372,9 +369,8 @@ prepend_core_path(char *lib, char *corefile)
strcat(result, lib); strcat(result, lib);
free(path); free(path);
return result; return (const char *) result; /* Don't let the caller modify the buffer we built */
} }
/* /*
The symbol builtin_image_flag is used globally as a flag to indicate The symbol builtin_image_flag is used globally as a flag to indicate
...@@ -396,9 +392,8 @@ extern long initial_function_addr; ...@@ -396,9 +392,8 @@ extern long initial_function_addr;
fpu_mode_t fpu_mode = AUTO; fpu_mode_t fpu_mode = AUTO;
/* And here be main. */ static const char*
locate_core(const char* cmucllib, const char* core, const char* default_core)
const char* locate_core(const char* cmucllib, const char* core, const char* default_core)
{ {
if (core == NULL) { if (core == NULL) {
if (getenv("CMUCLCORE") == NULL) { if (getenv("CMUCLCORE") == NULL) {
...@@ -407,17 +402,16 @@ const char* locate_core(const char* cmucllib, const char* core, const char* defa ...@@ -407,17 +402,16 @@ const char* locate_core(const char* cmucllib, const char* core, const char* defa
core = getenv("CMUCLCORE"); core = getenv("CMUCLCORE");
} }
} }
{
struct stat statbuf;
if (stat(core, &statbuf) != 0) { if (access(core, R_OK) != 0) {
core = NULL; core = NULL;
}
} }
return core; return core;
} }
void core_failure(const char* core, const char** argv) static void
core_failure(const char* core, const char* argv[])
{ {
fprintf(stderr, "Cannot find core file"); fprintf(stderr, "Cannot find core file");
...@@ -430,13 +424,14 @@ void core_failure(const char* core, const char** argv) ...@@ -430,13 +424,14 @@ void core_failure(const char* core, const char** argv)
} }
int int
main(int argc, char *argv[], char *envp[]) main(int argc, const char *argv[], const char *envp[])
{ {
char *arg, **argptr; const char *arg, **argptr;
char *core = NULL; const char *core = NULL;
char *default_core; const char *default_core;
char *lib = NULL; const char *lib = NULL;
char *cmucllib = NULL; const char *cmucllib = NULL;
fpu_mode_t fpu_type = AUTO; fpu_mode_t fpu_type = AUTO;
boolean monitor; boolean monitor;
lispobj initial_function = 0; lispobj initial_function = 0;
...@@ -486,7 +481,7 @@ main(int argc, char *argv[], char *envp[]) ...@@ -486,7 +481,7 @@ main(int argc, char *argv[], char *envp[])
exit(1); exit(1);
} }
} else if (strcmp(arg, "-dynamic-space-size") == 0) { } else if (strcmp(arg, "-dynamic-space-size") == 0) {
char *str; const char *str;
str = *++argptr; str = *++argptr;
if (str == NULL) { if (str == NULL) {
...@@ -535,7 +530,7 @@ main(int argc, char *argv[], char *envp[]) ...@@ -535,7 +530,7 @@ main(int argc, char *argv[], char *envp[])
} }
#ifdef i386 #ifdef i386
else if (strcmp(arg, "-fpu") == 0) { else if (strcmp(arg, "-fpu") == 0) {
char *str; const char *str;
str = *++argptr; str = *++argptr;
if (str == NULL) { if (str == NULL) {
...@@ -621,7 +616,7 @@ main(int argc, char *argv[], char *envp[]) ...@@ -621,7 +616,7 @@ main(int argc, char *argv[], char *envp[])
if (builtin_image_flag == 0) if (builtin_image_flag == 0)
#endif #endif
{ {
char *newlib = NULL; const char *newlib = NULL;
/* /*
* We need to use our default search path. If a core file * We need to use our default search path. If a core file
...@@ -637,7 +632,7 @@ main(int argc, char *argv[], char *envp[]) ...@@ -637,7 +632,7 @@ main(int argc, char *argv[], char *envp[])
} }
if (newlib != NULL) { if (newlib != NULL) {
free(cmucllib); free((void *) cmucllib);
cmucllib = newlib; cmucllib = newlib;
} }
} }
...@@ -652,7 +647,7 @@ main(int argc, char *argv[], char *envp[]) ...@@ -652,7 +647,7 @@ main(int argc, char *argv[], char *envp[])
* If no core file specified, search for it in CMUCLLIB * If no core file specified, search for it in CMUCLLIB
*/ */
{ {
char* found_core; const char* found_core;
found_core = locate_core(cmucllib, core, default_core); found_core = locate_core(cmucllib, core, default_core);
#ifdef FEATURE_SSE2 #ifdef FEATURE_SSE2
......
Supports Markdown
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