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>
......@@ -114,7 +114,7 @@ alloc_number(long n)
}
lispobj
alloc_string(char *str)
alloc_string(const char *str)
{
int len = strlen(str);
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_
#define _ALLOC_H_
......@@ -7,7 +7,7 @@
extern lispobj alloc_cons(lispobj car, lispobj cdr);
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);
#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_
#define _CORE_H_
......@@ -34,6 +34,6 @@ struct ndir_entry {
#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_ */
/* $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 <sys/types.h>
#include <sys/file.h>
......@@ -75,7 +75,7 @@ process_directory(int fd, long *ptr, int count)
}
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;
......
......@@ -8,7 +8,7 @@
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>
......@@ -399,7 +399,7 @@ read_section_header_entry(int fd, Elf_Shdr *shp)
is not set until some time after this is done.
*/
void
map_core_sections(char *exec_name)
map_core_sections(const char *exec_name)
{
int exec_fd;
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
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);
void elf_cleanup(const 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__)
typedef Elf32_Ehdr Elf_Ehdr;
......
/*
* 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)
/* Noise to convert argv and envp into lists. */
static lispobj
alloc_str_list(char *list[])
alloc_str_list(const char *list[])
{
lispobj result, newcons;
struct cons *ptr;
......@@ -105,10 +105,10 @@ static int debug_lisp_search = FALSE;
* From the current location of the lisp executable, create a suitable
* default for CMUCLLIB
*/
char *
default_cmucllib(char *argv0arg)
static const char *
default_cmucllib(const char *argv0arg)
{
char *p;
char *p0;
char *defpath;
char *cwd;
char *argv0_dir = strdup(argv0arg);
......@@ -118,11 +118,11 @@ default_cmucllib(char *argv0arg)
* executable name
*/
p = strrchr(argv0_dir, '/');
if (p == NULL) {
p0 = strrchr(argv0_dir, '/');
if (p0 == NULL) {
*argv0_dir = '\0';
} else if (p != argv0_dir) {
*p = '\0';
} else if (p0 != argv0_dir) {
*p0 = '\0';
}
/*
......@@ -175,10 +175,7 @@ default_cmucllib(char *argv0arg)
cwd[0] = '\0';
if (path) {
if (p == NULL) {
p = argv0arg;
}
const char *ptr = (p0 != NULL) ? p0 : argv0arg;
for (p1 = path; *p1 != '\0'; p1 = p2) {
p2 = strchr(p1, ':');
......@@ -187,7 +184,7 @@ default_cmucllib(char *argv0arg)
strncpy(cwd, p1, p2 - p1);
cwd[p2 - p1] = '/';
cwd[p2 - p1 + 1] = '\0';
strcpy(cwd + (p2 - p1 + 1), p);
strcpy(cwd + (p2 - p1 + 1), ptr);
if (debug_lisp_search) {
fprintf(stderr, "User's PATH, trying %s\n", cwd);
......@@ -274,7 +271,7 @@ default_cmucllib(char *argv0arg)
free(argv0_dir);
free(cwd);
return defpath;
return (const char *) defpath;
}
/*
......@@ -336,8 +333,8 @@ search_core(const char *lib, const char *default_core)
*
* Return the new lib path.
*/
char *
prepend_core_path(char *lib, char *corefile)
static const char *
prepend_core_path(const char *lib, const char *corefile)
{
char cwd[FILENAME_MAX];
char *path;
......@@ -372,9 +369,8 @@ prepend_core_path(char *lib, char *corefile)
strcat(result, lib);
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
......@@ -396,9 +392,8 @@ extern long initial_function_addr;
fpu_mode_t fpu_mode = AUTO;
/* And here be main. */
const char* locate_core(const char* cmucllib, const char* core, const char* default_core)
static const char*
locate_core(const char* cmucllib, const char* core, const char* default_core)
{
if (core == NULL) {
if (getenv("CMUCLCORE") == NULL) {
......@@ -407,17 +402,16 @@ const char* locate_core(const char* cmucllib, const char* core, const char* defa
core = getenv("CMUCLCORE");
}
}
{
struct stat statbuf;
if (stat(core, &statbuf) != 0) {
if (access(core, R_OK) != 0) {
core = NULL;
}
}
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");
......@@ -430,13 +424,14 @@ void core_failure(const char* core, const char** argv)
}
int
main(int argc, char *argv[], char *envp[])
main(int argc, const char *argv[], const char *envp[])
{
char *arg, **argptr;
char *core = NULL;
char *default_core;
char *lib = NULL;
char *cmucllib = NULL;
const char *arg, **argptr;
const char *core = NULL;
const char *default_core;
const char *lib = NULL;
const char *cmucllib = NULL;
fpu_mode_t fpu_type = AUTO;
boolean monitor;
lispobj initial_function = 0;
......@@ -486,7 +481,7 @@ main(int argc, char *argv[], char *envp[])
exit(1);
}
} else if (strcmp(arg, "-dynamic-space-size") == 0) {
char *str;
const char *str;
str = *++argptr;
if (str == NULL) {
......@@ -535,7 +530,7 @@ main(int argc, char *argv[], char *envp[])
}
#ifdef i386
else if (strcmp(arg, "-fpu") == 0) {
char *str;
const char *str;
str = *++argptr;
if (str == NULL) {
......@@ -621,7 +616,7 @@ main(int argc, char *argv[], char *envp[])
if (builtin_image_flag == 0)
#endif
{
char *newlib = NULL;
const char *newlib = NULL;
/*
* We need to use our default search path. If a core file
......@@ -637,7 +632,7 @@ main(int argc, char *argv[], char *envp[])
}
if (newlib != NULL) {
free(cmucllib);
free((void *) cmucllib);
cmucllib = newlib;
}
}
......@@ -652,7 +647,7 @@ main(int argc, char *argv[], char *envp[])
* 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);
#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