summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/compile.c2
-rw-r--r--lisp/core.c3
-rw-r--r--lisp/debugger.c16
-rw-r--r--lisp/format.c43
-rw-r--r--lisp/internal.h50
-rw-r--r--lisp/io.c37
-rw-r--r--lisp/io.h16
-rw-r--r--lisp/lisp.c97
-rw-r--r--lisp/lisp.h2
-rw-r--r--lisp/mathimp.c4
-rw-r--r--lisp/package.c6
-rw-r--r--lisp/package.h4
-rw-r--r--lisp/pathname.c3
-rw-r--r--lisp/private.h13
-rw-r--r--lisp/re/re.c4
-rw-r--r--lisp/read.c81
-rw-r--r--lisp/stream.c2
-rw-r--r--lisp/write.c25
-rw-r--r--lisp/write.h2
19 files changed, 208 insertions, 202 deletions
diff --git a/lisp/compile.c b/lisp/compile.c
index 829baea..474aac5 100644
--- a/lisp/compile.c
+++ b/lisp/compile.c
@@ -144,7 +144,7 @@ Com_C_r(LispCom *com, LispBuiltin *builtin)
*/
{
LispObj *list;
- char *desc;
+ const char *desc;
list = ARGUMENT(0);
diff --git a/lisp/core.c b/lisp/core.c
index a9792e9..46930a2 100644
--- a/lisp/core.c
+++ b/lisp/core.c
@@ -1853,7 +1853,8 @@ Lisp_Gensym(LispBuiltin *builtin)
gensym &optional arg
*/
{
- char *preffix = "G", name[132];
+ const char *preffix = "G";
+ char name[132];
long counter = LONGINT_VALUE(Ogensym_counter->data.atom->property->value);
LispObj *symbol;
diff --git a/lisp/debugger.c b/lisp/debugger.c
index c9de39d..f07824b 100644
--- a/lisp/debugger.c
+++ b/lisp/debugger.c
@@ -64,9 +64,9 @@ static void LispDebuggerCommand(LispObj *obj);
* Initialization
*/
static struct {
- char *name;
+ const char *name;
int action;
-} commands[] = {
+} const commands[] = {
{"help", DebuggerHelp},
{"abort", DebuggerAbort},
{"backtrace", DebuggerBacktrace},
@@ -91,15 +91,15 @@ static struct {
};
static struct {
- char *name;
+ const char *name;
int subaction;
-} info_commands[] = {
+} const info_commands[] = {
{"breakpoints", DebuggerInfoBreakpoints},
{"stack", DebuggerInfoBacktrace},
{"watchpoints", DebuggerInfoBreakpoints},
};
-static char debugger_help[] =
+static const char *debugger_help =
"Available commands are:\n\
\n\
help - This message.\n\
@@ -120,7 +120,7 @@ up - Set environment to frame that called the current one.\n\
\n\
Commands may be abbreviated.\n";
-static char debugger_info_help[] =
+static const char *debugger_info_help =
"Available subcommands are:\n\
\n\
breakpoints - List and prints status of breakpoints, and watchpoints.\n\
@@ -407,7 +407,7 @@ LispDebuggerCommand(LispObj *args)
else {
for (i = matches = 0; i < sizeof(commands) / sizeof(commands[0]);
i++) {
- char *str = commands[i].name;
+ const char *str = commands[i].name;
ptr = cmd;
while (*ptr && *ptr == *str) {
@@ -450,7 +450,7 @@ LispDebuggerCommand(LispObj *args)
for (i = matches = 0;
i < sizeof(info_commands) / sizeof(info_commands[0]);
i++) {
- char *str = info_commands[i].name;
+ const char *str = info_commands[i].name;
ptr = arg;
while (*ptr && *ptr == *str) {
diff --git a/lisp/format.c b/lisp/format.c
index ab85565..733ca9a 100644
--- a/lisp/format.c
+++ b/lisp/format.c
@@ -118,12 +118,12 @@ typedef struct {
/*
* Prototypes
*/
-static void merge_arguments(FmtArgs*, FmtDefs*, int*);
+static void merge_arguments(FmtArgs*, const FmtDefs*, int*);
static char *parse_arguments(char*, FmtArgs*, int*, LispObj**, int*);
static void merge_error(FmtArgs*, int);
static void parse_error(FmtArgs*, int);
static void generic_error(FmtArgs*, int);
-static void format_error(FmtArgs*, char*);
+static void format_error(FmtArgs*, const char*);
static int format_object(LispObj*, LispObj*);
@@ -155,7 +155,7 @@ static void LispFormat(LispObj*, FmtInfo*);
/*
* Initialization
*/
-static FmtDefs AsciiDefs = {
+static const FmtDefs AsciiDefs = {
4,
{
{0, 0}, /* mincol */
@@ -165,7 +165,7 @@ static FmtDefs AsciiDefs = {
},
};
-static FmtDefs IntegerDefs = {
+static const FmtDefs IntegerDefs = {
4,
{
{0, 0}, /* mincol */
@@ -175,7 +175,7 @@ static FmtDefs IntegerDefs = {
},
};
-static FmtDefs RadixDefs = {
+static const FmtDefs RadixDefs = {
5,
{
{0, 10}, /* radix */
@@ -186,11 +186,11 @@ static FmtDefs RadixDefs = {
},
};
-static FmtDefs NoneDefs = {
+static const FmtDefs NoneDefs = {
0,
};
-static FmtDefs FixedFloatDefs = {
+static const FmtDefs FixedFloatDefs = {
5,
{
{0, 0}, /* w */
@@ -201,7 +201,7 @@ static FmtDefs FixedFloatDefs = {
},
};
-static FmtDefs ExponentialFloatDefs = {
+static const FmtDefs ExponentialFloatDefs = {
7,
{
{0, 0}, /* w */
@@ -216,7 +216,7 @@ static FmtDefs ExponentialFloatDefs = {
},
};
-static FmtDefs DollarFloatDefs = {
+static const FmtDefs DollarFloatDefs = {
4,
{
{0, 2}, /* d */
@@ -226,14 +226,14 @@ static FmtDefs DollarFloatDefs = {
},
};
-static FmtDefs OneDefs = {
+static const FmtDefs OneDefs = {
1,
{
{0, 1},
},
};
-static FmtDefs TabulateDefs = {
+static const FmtDefs TabulateDefs = {
2,
{
{0, 0}, /* colnum */
@@ -247,10 +247,10 @@ extern LispObj *Oprint_escape;
* Implementation
*/
static void
-merge_arguments(FmtArgs *arguments, FmtDefs *defaults, int *code)
+merge_arguments(FmtArgs *arguments, const FmtDefs *defaults, int *code)
{
int count;
- FmtDef *defaul;
+ const FmtDef *defaul;
FmtArg *argument;
defaul = &(defaults->defaults[0]);
@@ -428,7 +428,7 @@ parse_arguments(char *format, FmtArgs *arguments,
static void
parse_error(FmtArgs *args, int code)
{
- static char *errors[] = {
+ static const char * const errors[] = {
NULL,
"too many parameters to directive",
"too many @ parameters",
@@ -445,7 +445,7 @@ parse_error(FmtArgs *args, int code)
static void
merge_error(FmtArgs *args, int code)
{
- static char *errors[] = {
+ static const char * const errors[] = {
NULL,
"too many parameters to directive",
"argument must be a character",
@@ -458,7 +458,7 @@ merge_error(FmtArgs *args, int code)
static void
generic_error(FmtArgs *args, int code)
{
- static char *errors[] = {
+ static const char * const errors[] = {
NULL,
"radix must be in the range 2 to 36, inclusive",
"parameter must be positive",
@@ -470,7 +470,7 @@ generic_error(FmtArgs *args, int code)
}
static void
-format_error(FmtArgs *args, char *str)
+format_error(FmtArgs *args, const char *str)
{
char *message;
int errorlen, formatlen;
@@ -565,7 +565,7 @@ format_ascii(LispObj *stream, LispObj *object, FmtArgs *args)
length = format_object(stream, object);
else {
int size;
- char *str = LispGetSstring(SSTREAMP(string), &size);
+ const char *str = LispGetSstring(SSTREAMP(string), &size);
LispWriteStr(stream, str, size);
}
@@ -1499,7 +1499,8 @@ format_justify(LispObj *stream, FmtInfo *info)
{
GC_ENTER();
FmtInfo justify_info;
- char **formats, *format, *next_format, *str;
+ char **formats, *format, *next_format;
+ const char *str;
LispObj *string, *strings = NIL, *cons;
int atsign = info->args.atsign,
collon = info->args.collon,
@@ -1723,7 +1724,7 @@ static void
LispFormat(LispObj *stream, FmtInfo *info)
{
FmtArgs *args;
- FmtDefs *defs = NULL;
+ const FmtDefs *defs = NULL;
LispObj *object, *arguments;
char stk[256], *format, *next_format;
int length, num_arguments, code, need_update, need_argument, hash, head;
@@ -2109,7 +2110,7 @@ Lisp_Format(LispBuiltin *builtin)
/* else if printing to string-stream, return a string */
else if (stream->data.stream.type == LispStreamString) {
int length;
- char *string;
+ const char *string;
string = LispGetSstring(SSTREAMP(stream), &length);
stream = LSTRING(string, length);
diff --git a/lisp/internal.h b/lisp/internal.h
index 2ca4991..988c0dc 100644
--- a/lisp/internal.h
+++ b/lisp/internal.h
@@ -78,13 +78,13 @@ typedef struct _LispMac LispMac;
/* make a gc never released variable with a static string argument */
#define STATIC_ATOM(string) LispNewStaticAtom(string)
-#define STRING(str) LispNewString(str, strlen(str), 0)
-#define LSTRING(str, size) LispNewString(str, size, 0)
+#define STRING(str) LispNewString(str, strlen(str))
+#define LSTRING(str, size) LispNewString(str, size)
/* string must be from the LispXXX allocation functions,
* and LispMused not yet called on it */
-#define STRING2(str) LispNewString(str, strlen(str), 1)
-#define LSTRING2(str, size) LispNewString(str, size, 1)
+#define STRING2(str) LispNewStringAlloced(str, strlen(str))
+#define LSTRING2(str, size) LispNewStringAlloced(str, size)
#define VECTOR(objects) LispNewVector(objects)
@@ -92,13 +92,13 @@ typedef struct _LispMac LispMac;
* string be allocated from the LispXXX allocation functions,
* and LispMused not yet called on it */
#define STRINGSTREAM(str, flag) \
- LispNewStringStream(str, flag, strlen(str), 0)
+ LispNewStringStream(str, flag, strlen(str))
#define STRINGSTREAM2(str, flag) \
- LispNewStringStream(str, flag, strlen(str), 1)
+ LispNewStringStreamAlloced(str, flag, strlen(str))
#define LSTRINGSTREAM(str, flag, length) \
- LispNewStringStream(str, flag, length, 0)
+ LispNewStringStream(str, flag, length)
#define LSTRINGSTREAM2(str, flag, length) \
- LispNewStringStream(str, flag, length, 1)
+ LispNewStringStreamAlloced(str, flag, length)
#define FILESTREAM(file, path, flag) \
LispNewFileStream(file, path, flag)
@@ -664,7 +664,7 @@ struct _LispBuiltin {
/* these fields must be set */
LispFunType type;
LispFunPtr function;
- char *declaration;
+ const char *declaration;
/* this field is optional, set if the function returns multiple values */
int multiple_values;
@@ -700,12 +700,13 @@ LispObj *LispApply3(LispObj*, LispObj*, LispObj*, LispObj*);
LispObj *LispNew(LispObj*, LispObj*);
LispObj *LispNewSymbol(LispAtom*);
-LispObj *LispNewAtom(char*, int);
+LispObj *LispNewAtom(const char*, int);
LispObj *LispNewFunction(LispObj*);
LispObj *LispNewFunctionQuote(LispObj*);
-LispObj *LispNewStaticAtom(char*);
+LispObj *LispNewStaticAtom(const char*);
LispObj *LispNewDFloat(double);
-LispObj *LispNewString(char*, long, int);
+LispObj *LispNewString(const char*, long);
+LispObj *LispNewStringAlloced(char*, long);
LispObj *LispNewInteger(long);
LispObj *LispNewRatio(long, long);
LispObj *LispNewVector(LispObj*);
@@ -717,24 +718,25 @@ LispObj *LispNewLambda(LispObj*, LispObj*, LispObj*, LispFunType);
LispObj *LispNewStruct(LispObj*, LispObj*);
LispObj *LispNewComplex(LispObj*, LispObj*);
LispObj *LispNewOpaque(void*, int);
-LispObj *LispNewKeyword(char*);
+LispObj *LispNewKeyword(const char*);
LispObj *LispNewPathname(LispObj*);
-LispObj *LispNewStringStream(char*, int, long, int);
+LispObj *LispNewStringStream(const char*, int, long);
+LispObj *LispNewStringStreamAlloced(char*, int, long);
LispObj *LispNewFileStream(LispFile*, LispObj*, int);
LispObj *LispNewPipeStream(LispPipe*, LispObj*, int);
LispObj *LispNewBignum(mpi*);
LispObj *LispNewBigratio(mpr*);
-LispAtom *LispGetAtom(char*);
+LispAtom *LispGetAtom(const char*);
/* This function does not allocate a copy of it's argument, but the argument
* itself. The argument string should never change. */
-LispAtom *LispGetPermAtom(char*);
+LispAtom *LispGetPermAtom(const char*);
void *LispMalloc(size_t);
void *LispCalloc(size_t, size_t);
void *LispRealloc(void*, size_t);
-char *LispStrdup(char*);
+char *LispStrdup(const char*);
void LispFree(void*);
/* LispMused means memory is now safe from LispDestroy, and should not be
* freed in case of an error */
@@ -749,18 +751,16 @@ char *LispStrObj(LispObj*);
#else
#define PRINTF_FORMAT /**/
#endif
-void LispDestroy(char *fmt, ...) PRINTF_FORMAT;
+void LispDestroy(const char *fmt, ...) PRINTF_FORMAT;
/* continuable error */
-void LispContinuable(char *fmt, ...) PRINTF_FORMAT;
-void LispMessage(char *fmt, ...) PRINTF_FORMAT;
-void LispWarning(char *fmt, ...) PRINTF_FORMAT;
+void LispContinuable(const char *fmt, ...) PRINTF_FORMAT;
+void LispMessage(const char *fmt, ...) PRINTF_FORMAT;
+void LispWarning(const char *fmt, ...) PRINTF_FORMAT;
#undef PRINTF_FORMAT
-LispObj *LispSetVariable(LispObj*, LispObj*, char*, int);
+LispObj *LispSetVariable(LispObj*, LispObj*, const char*, int);
-int LispRegisterOpaqueType(char*);
-
-int LispPrintString(LispObj*, char*);
+int LispRegisterOpaqueType(const char*);
void LispProtect(LispObj*, LispObj*);
void LispUProtect(LispObj*, LispObj*);
diff --git a/lisp/io.c b/lisp/io.c
index 9db73ee..3ec9cf5 100644
--- a/lisp/io.c
+++ b/lisp/io.c
@@ -44,11 +44,6 @@
#define UNBUFFERED_BIT 0x10
#define BINARY_BIT 0x20
-/*
- * Prototypes
- */
-static int calculate_line(void*, int);
-static int calculate_column(void*, int, int);
/*
* Initialization
@@ -160,12 +155,13 @@ LispPopInput(LispObj *stream)
* Low level functions
*/
static int
-calculate_line(void *data, int size)
+calculate_line(const void *data, int size)
{
int line = 0;
- char *str, *ptr;
+ const char *str, *ptr;
- for (str = (char*)data, ptr = (char*)data + size; str < ptr; str++)
+ for (str = (const char *)data, ptr = (const char *)data + size;
+ str < ptr; str++)
if (*ptr == '\n')
++line;
@@ -173,12 +169,13 @@ calculate_line(void *data, int size)
}
static int
-calculate_column(void *data, int size, int column)
+calculate_column(const void *data, int size, int column)
{
- char *str, *ptr;
+ const char *str, *ptr;
/* search for newline in data */
- for (str = (char*)data, ptr = (char*)data + size - 1; ptr >= str; ptr--)
+ for (str = (const char *)data, ptr = (const char *)data + size - 1;
+ ptr >= str; ptr--)
if (*ptr == '\n')
break;
@@ -225,7 +222,7 @@ LispFdopen(int descriptor, int mode)
}
LispFile *
-LispFopen(char *path, int mode)
+LispFopen(const char *path, int mode)
{
LispFile *file;
int descriptor;
@@ -467,13 +464,13 @@ LispFgets(LispFile *file, char *string, int size)
}
int
-LispFputs(LispFile *file, char *buffer)
+LispFputs(LispFile *file, const char *buffer)
{
return (LispFwrite(file, buffer, strlen(buffer)));
}
int
-LispSputs(LispString *string, char *buffer)
+LispSputs(LispString *string, const char *buffer)
{
return (LispSwrite(string, buffer, strlen(buffer)));
}
@@ -557,7 +554,7 @@ LispFread(LispFile *file, void *data, int size)
}
int
-LispFwrite(LispFile *file, void *data, int size)
+LispFwrite(LispFile *file, const void *data, int size)
{
if (!file->writable || size < 0)
return (EOF);
@@ -567,7 +564,7 @@ LispFwrite(LispFile *file, void *data, int size)
if (file->buffered) {
int length, bytes;
- char *buffer = (char*)data;
+ const char *buffer = (const char *)data;
length = 0;
if (size + file->length > pagesize) {
@@ -633,7 +630,7 @@ LispFwrite(LispFile *file, void *data, int size)
}
int
-LispSwrite(LispString *string, void *data, int size)
+LispSwrite(LispString *string, const void *data, int size)
{
int bytes;
@@ -676,7 +673,7 @@ LispSwrite(LispString *string, void *data, int size)
return (size);
}
-char *
+const char *
LispGetSstring(LispString *string, int *length)
{
if (string->string == NULL || string->length <= 0) {
@@ -707,13 +704,13 @@ LispGetSstring(LispString *string, int *length)
}
int
-LispRename(char *from, char *to)
+LispRename(const char *from, const char *to)
{
return (rename(from, to));
}
int
-LispUnlink(char *name)
+LispUnlink(const char *name)
{
return (unlink(name));
}
diff --git a/lisp/io.h b/lisp/io.h
index 2bb8c4d..84fb754 100644
--- a/lisp/io.h
+++ b/lisp/io.h
@@ -88,18 +88,18 @@ void LispPopInput(LispObj*);
/* functions that read/write using the LispFile structure */
LispFile *LispFdopen(int, int);
-LispFile *LispFopen(char*, int);
+LispFile *LispFopen(const char*, int);
void LispFclose(LispFile*);
int LispFflush(LispFile*);
int LispFungetc(LispFile*, int);
int LispFgetc(LispFile*);
int LispFputc(LispFile*, int);
char *LispFgets(LispFile*, char*, int);
-int LispFputs(LispFile*, char*);
+int LispFputs(LispFile*, const char*);
int LispFread(LispFile*, void*, int);
-int LispFwrite(LispFile*, void*, int);
-int LispRename(char*, char*);
-int LispUnlink(char*);
+int LispFwrite(LispFile*, const void*, int);
+int LispRename(const char*, const char*);
+int LispUnlink(const char*);
/* io wrappers */
io_write_fn LispSetFileWrite(LispFile*, io_write_fn);
@@ -107,9 +107,9 @@ io_write_fn LispSetFileWrite(LispFile*, io_write_fn);
/* functions that read/write using the LispString structure */
int LispSgetc(LispString*);
int LispSputc(LispString*, int);
-int LispSputs(LispString*, char*);
-int LispSwrite(LispString*, void*, int);
+int LispSputs(LispString*, const char*);
+int LispSwrite(LispString*, const void*, int);
-char *LispGetSstring(LispString*, int*);
+const char *LispGetSstring(LispString*, int*);
#endif /* Lisp_io_h */
diff --git a/lisp/lisp.c b/lisp/lisp.c
index 411240a..b999b8a 100644
--- a/lisp/lisp.c
+++ b/lisp/lisp.c
@@ -662,7 +662,7 @@ LispGetPageSize(void)
}
void
-LispDestroy(char *fmt, ...)
+LispDestroy(const char *fmt, ...)
{
static char Error[] = "*** ";
@@ -720,7 +720,7 @@ LispDestroy(char *fmt, ...)
LispTopLevel();
if (!lisp__data.running) {
- static char Fatal[] = "*** Fatal: nowhere to longjmp.\n";
+ static const char *Fatal = "*** Fatal: nowhere to longjmp.\n";
LispFputs(Stderr, Fatal);
LispFflush(Stderr);
@@ -731,11 +731,11 @@ LispDestroy(char *fmt, ...)
}
void
-LispContinuable(char *fmt, ...)
+LispContinuable(const char *fmt, ...)
{
va_list ap;
char string[128];
- static char Error[] = "*** Error: ";
+ static const char *Error = "*** Error: ";
if (Stderr->column)
LispFputc(Stderr, '\n');
@@ -757,7 +757,7 @@ LispContinuable(char *fmt, ...)
}
void
-LispMessage(char *fmt, ...)
+LispMessage(const char *fmt, ...)
{
va_list ap;
char string[128];
@@ -773,11 +773,11 @@ LispMessage(char *fmt, ...)
}
void
-LispWarning(char *fmt, ...)
+LispWarning(const char *fmt, ...)
{
va_list ap;
char string[128];
- static char Warning[] = "*** Warning: ";
+ static const char *Warning = "*** Warning: ";
if (Stderr->column)
LispFputc(Stderr, '\n');
@@ -1229,7 +1229,7 @@ index_found:
}
char *
-LispStrdup(char *str)
+LispStrdup(const char *str)
{
char *ptr = LispMalloc(strlen(str) + 1);
@@ -1264,7 +1264,7 @@ free_done:
}
LispObj *
-LispSetVariable(LispObj *var, LispObj *val, char *fname, int eval)
+LispSetVariable(LispObj *var, LispObj *val, const char *fname, int eval)
{
if (!SYMBOLP(var))
LispDestroy("%s: %s is not a symbol", fname, STROBJ(var));
@@ -1275,7 +1275,7 @@ LispSetVariable(LispObj *var, LispObj *val, char *fname, int eval)
}
int
-LispRegisterOpaqueType(char *desc)
+LispRegisterOpaqueType(const char *desc)
{
int length;
LispOpaque *opaque;
@@ -1317,7 +1317,7 @@ LispIntToOpaqueType(int type)
}
hash_key *
-LispGetAtomKey(char *string, int perm)
+LispGetAtomKey(const char *string, int perm)
{
int length;
hash_entry *entry;
@@ -1328,7 +1328,7 @@ LispGetAtomKey(char *string, int perm)
entry = LispCalloc(1, sizeof(hash_entry));
entry->key = LispCalloc(1, sizeof(hash_key));
if (perm)
- entry->key->value = string;
+ entry->key->value = (char *) string;
else
entry->key->value = LispStrdup(string);
entry->key->length = length;
@@ -1344,7 +1344,7 @@ LispGetAtomKey(char *string, int perm)
}
LispAtom *
-LispDoGetAtom(char *str, int perm)
+LispDoGetAtom(const char *str, int perm)
{
int length;
LispAtom *atom;
@@ -1618,13 +1618,13 @@ LispRemAtomStructProperty(LispAtom *atom)
}
LispAtom *
-LispGetAtom(char *str)
+LispGetAtom(const char *str)
{
return (LispDoGetAtom(str, 0));
}
LispAtom *
-LispGetPermAtom(char *str)
+LispGetPermAtom(const char *str)
{
return (LispDoGetAtom(str, 1));
}
@@ -1863,15 +1863,15 @@ LispListProtectedArguments(LispArgList *alist)
}
LispArgList *
-LispCheckArguments(LispFunType type, LispObj *list, char *name, int builtin)
+LispCheckArguments(LispFunType type, LispObj *list, const char *name, int builtin)
{
- static char *types[4] = {"LAMBDA-LIST", "FUNCTION", "MACRO", "SETF-METHOD"};
- static char *fnames[4] = {"LAMBDA", "DEFUN", "DEFMACRO", "DEFSETF"};
+ static const char *types[4] = {"LAMBDA-LIST", "FUNCTION", "MACRO", "SETF-METHOD"};
+ static const char *fnames[4] = {"LAMBDA", "DEFUN", "DEFMACRO", "DEFSETF"};
#define IKEY 0
#define IOPTIONAL 1
#define IREST 2
#define IAUX 3
- static char *keys[4] = {"&KEY", "&OPTIONAL", "&REST", "&AUX"};
+ static const char *keys[4] = {"&KEY", "&OPTIONAL", "&REST", "&AUX"};
int rest, optional, key, aux, count;
LispArgList *alist;
LispObj *spec, *sform, *defval, *default_value;
@@ -2633,7 +2633,7 @@ LispNew(LispObj *car, LispObj *cdr)
}
LispObj *
-LispNewAtom(char *str, int intern)
+LispNewAtom(const char *str, int intern)
{
LispObj *object;
LispAtom *atom = LispDoGetAtom(str, 0);
@@ -2661,7 +2661,7 @@ LispNewAtom(char *str, int intern)
}
LispObj *
-LispNewStaticAtom(char *str)
+LispNewStaticAtom(const char *str)
{
LispObj *object;
LispAtom *atom = LispDoGetAtom(str, 1);
@@ -2778,9 +2778,17 @@ LispNewDFloat(double value)
}
LispObj *
-LispNewString(char *str, long length, int alloced)
+LispNewString(const char *str, long length)
+{
+ char *cstring = LispMalloc(length + 1);
+ memcpy(cstring, str, length);
+ cstring[length] = '\0';
+ return LispNewStringAlloced(cstring, length);
+}
+
+LispObj *
+LispNewStringAlloced(char *cstring, long length)
{
- char *cstring;
LispObj *string = objseg.freeobj;
if (string == NIL)
@@ -2789,13 +2797,6 @@ LispNewString(char *str, long length, int alloced)
objseg.freeobj = CDR(string);
--objseg.nfree;
}
- if (alloced)
- cstring = str;
- else {
- cstring = LispMalloc(length + 1);
- memcpy(cstring, str, length);
- cstring[length] = '\0';
- }
LispMused(cstring);
string->type = LispString_t;
THESTR(string) = cstring;
@@ -2976,7 +2977,7 @@ LispNewOpaque(void *data, int type)
/* string argument must be static, or allocated */
LispObj *
-LispNewKeyword(char *string)
+LispNewKeyword(const char *string)
{
LispObj *keyword;
@@ -3027,18 +3028,22 @@ LispNewPathname(LispObj *obj)
}
LispObj *
-LispNewStringStream(char *string, int flags, long length, int alloced)
+LispNewStringStream(const char *string, int flags, long length)
+{
+ char *newstring = LispMalloc(length + 1);
+ memcpy(newstring, string, length);
+ newstring[length] = '\0';
+
+ return LispNewStringStreamAlloced(newstring, flags, length);
+}
+
+LispObj *
+LispNewStringStreamAlloced(char *string, int flags, long length)
{
LispObj *stream = LispNew(NIL, NIL);
SSTREAMP(stream) = LispCalloc(1, sizeof(LispString));
- if (alloced)
- SSTREAMP(stream)->string = string;
- else {
- SSTREAMP(stream)->string = LispMalloc(length + 1);
- memcpy(SSTREAMP(stream)->string, string, length);
- SSTREAMP(stream)->string[length] = '\0';
- }
+ SSTREAMP(stream)->string = string;
stream->type = LispStream_t;
@@ -5012,7 +5017,7 @@ LispSignalHandler(int signum)
void
LispSignal(int signum)
{
- char *errstr;
+ const char *errstr;
char buffer[32];
if (lisp__disable_int) {
@@ -5387,15 +5392,15 @@ LispBegin(void)
#ifdef LISPDIR
{
int length;
- char *pathname = LISPDIR;
+ const char *pathname = LISPDIR;
length = strlen(pathname);
if (length && pathname[length - 1] != '/') {
- pathname = LispMalloc(length + 2);
+ char *fixed_pathname = LispMalloc(length + 2);
- strcpy(pathname, LISPDIR);
- strcpy(pathname + length, "/");
- path = LSTRING2(pathname, length + 1);
+ strcpy(fixed_pathname, LISPDIR);
+ strcpy(fixed_pathname + length, "/");
+ path = LSTRING2(fixed_pathname, length + 1);
}
else
path = LSTRING(pathname, length);
@@ -5447,7 +5452,7 @@ LispEnd(void)
}
void
-LispSetPrompt(char *prompt)
+LispSetPrompt(const char *prompt)
{
lisp__data.prompt = prompt;
}
diff --git a/lisp/lisp.h b/lisp/lisp.h
index baabb85..39d702a 100644
--- a/lisp/lisp.h
+++ b/lisp/lisp.h
@@ -36,7 +36,7 @@ void LispBegin(void);
void LispEnd(void);
void *LispExecute(char*);
void LispMachine(void);
-void LispSetPrompt(char*);
+void LispSetPrompt(const char*);
void LispSetInteractive(int);
void LispSetExitOnError(int);
void LispDebug(int); /* argument is boolean to enable/disable */
diff --git a/lisp/mathimp.c b/lisp/mathimp.c
index 5f8bd4d..0433968 100644
--- a/lisp/mathimp.c
+++ b/lisp/mathimp.c
@@ -436,7 +436,7 @@ static INLINE int cmp_br_br(mpr*, mpr*);
*/
static n_real zero, one, two;
-static char *fatal_error_strings[] = {
+static const char *fatal_error_strings[] = {
#define DIVIDE_BY_ZERO 0
"divide by zero",
#define FLOATING_POINT_OVERFLOW 1
@@ -445,7 +445,7 @@ static char *fatal_error_strings[] = {
"floating point exception"
};
-static char *fatal_object_error_strings[] = {
+static const char *fatal_object_error_strings[] = {
#define NOT_A_NUMBER 0
"is not a number",
#define NOT_A_REAL_NUMBER 1
diff --git a/lisp/package.c b/lisp/package.c
index 8b941ec..9e39048 100644
--- a/lisp/package.c
+++ b/lisp/package.c
@@ -61,7 +61,7 @@ LispPackageInit(void)
}
LispObj *
-LispFindPackageFromString(char *string)
+LispFindPackageFromString(const char *string)
{
LispObj *list, *package, *nick;
@@ -97,9 +97,9 @@ LispFindPackage(LispObj *name)
}
int
-LispCheckAtomString(char *string)
+LispCheckAtomString(const char *string)
{
- char *ptr;
+ const char *ptr;
if (*string == '\0')
return (0);
diff --git a/lisp/package.h b/lisp/package.h
index f6940c8..6fcfd1e 100644
--- a/lisp/package.h
+++ b/lisp/package.h
@@ -36,9 +36,9 @@
void LispPackageInit(void);
LispObj *LispFindPackage(LispObj*);
-LispObj *LispFindPackageFromString(char*);
+LispObj *LispFindPackageFromString(const char*);
/* returns 1 if string can safely be read back */
-int LispCheckAtomString(char*);
+int LispCheckAtomString(const char*);
LispObj *Lisp_DoAllSymbols(LispBuiltin*);
LispObj *Lisp_DoExternalSymbols(LispBuiltin*);
diff --git a/lisp/pathname.c b/lisp/pathname.c
index 5d991fe..a8c2108 100644
--- a/lisp/pathname.c
+++ b/lisp/pathname.c
@@ -484,7 +484,8 @@ Lisp_ParseNamestring(LispBuiltin *builtin)
if (STRINGP(object)) {
LispObj *cons, *cdr;
char *name = THESTR(object), *ptr, *str, data[PATH_MAX + 1],
- string[PATH_MAX + 1], *namestr, *typestr, *send;
+ string[PATH_MAX + 1], *send;
+ const char *namestr, *typestr;
long start, end, length, alength, namelen, typelen;
LispCheckSequenceStartEnd(builtin, object, ostart, oend,
diff --git a/lisp/private.h b/lisp/private.h
index 2e5b634..f6aeff0 100644
--- a/lisp/private.h
+++ b/lisp/private.h
@@ -373,7 +373,7 @@ struct _LispMac {
} mem; /* memory from Lisp*Alloc, to be release in error */
LispModule *module;
LispObj *modules;
- char *prompt;
+ const char *prompt;
LispObj *features;
@@ -407,7 +407,7 @@ struct _LispMac {
};
struct _LispCharInfo {
- char **names;
+ const char * const *names;
};
@@ -416,7 +416,7 @@ struct _LispCharInfo {
*/
void LispUseArgList(LispArgList*);
void LispFreeArgList(LispArgList*);
-LispArgList *LispCheckArguments(LispFunType, LispObj*, char*, int);
+LispArgList *LispCheckArguments(LispFunType, LispObj*, const char*, int);
LispObj *LispListProtectedArguments(LispArgList*);
LispObj *LispGetDoc(LispObj*);
@@ -441,8 +441,7 @@ void LispExportSymbol(LispObj*);
void LispImportSymbol(LispObj*);
/* always returns the same string */
-hash_key *LispGetAtomKey(char*, int);
-char *LispGetAtomString(char*, int);
+hash_key *LispGetAtomKey(const char*, int);
/* destructive fast reverse, note that don't receive a LispMac* argument */
LispObj *LispReverse(LispObj *list);
@@ -464,7 +463,7 @@ void LispBlockUnwind(LispBlock*);
void LispUpdateResults(LispObj*, LispObj*);
void LispTopLevel(void);
-LispAtom *LispDoGetAtom(char *str, int);
+LispAtom *LispDoGetAtom(const char *str, int);
/* get value from atom's property list */
LispObj *LispGetAtomProperty(LispAtom*, LispObj*);
/* put value in atom's property list */
@@ -515,7 +514,7 @@ void LispMoreProtects(void);
/* Initialization */
extern int LispArgList_t;
-extern LispCharInfo LispChars[256];
+extern const LispCharInfo LispChars[256];
/* This function will return if the interpreter cannot be stopped */
extern void LispSignal(int);
diff --git a/lisp/re/re.c b/lisp/re/re.c
index f4c1246..55ba17b 100644
--- a/lisp/re/re.c
+++ b/lisp/re/re.c
@@ -1665,7 +1665,7 @@ done:
int
reerror(int ecode, const re_cod *preg, char *ebuffer, int ebuffer_size)
{
- static char *errors[] = {
+ static const char *errors[] = {
"No error",
"Failed to match", /* NOMATCH */
@@ -1687,7 +1687,7 @@ reerror(int ecode, const re_cod *preg, char *ebuffer, int ebuffer_size)
"Assertion error - you found a bug", /* ASSERT */
"Invalid argument" /* INVARG */
};
- char *str;
+ const char *str;
if (ecode >= 0 && ecode < sizeof(errors) / sizeof(errors[0]))
str = errors[ecode];
diff --git a/lisp/read.c b/lisp/read.c
index a49e240..02f71f6 100644
--- a/lisp/read.c
+++ b/lisp/read.c
@@ -106,7 +106,7 @@ static int LispGetLine(LispObj*);
#else
#define PRINTF_FORMAT /**/
#endif
-static void LispReadError(LispObj*, int, char*, ...);
+static void LispReadError(LispObj*, int, const char*, ...);
#undef PRINTF_FORMAT
static void LispReadFixCircle(LispObj*, read_info*);
static LispObj *LispReadLabelCircle(LispObj*, read_info*);
@@ -140,42 +140,42 @@ static LispObj *LispEvalFeature(LispObj*);
/*
* Initialization
*/
-static char *Char_Nul[] = {"Null", "Nul", NULL};
-static char *Char_Soh[] = {"Soh", NULL};
-static char *Char_Stx[] = {"Stx", NULL};
-static char *Char_Etx[] = {"Etx", NULL};
-static char *Char_Eot[] = {"Eot", NULL};
-static char *Char_Enq[] = {"Enq", NULL};
-static char *Char_Ack[] = {"Ack", NULL};
-static char *Char_Bel[] = {"Bell", "Bel", NULL};
-static char *Char_Bs[] = {"Backspace", "Bs", NULL};
-static char *Char_Tab[] = {"Tab", NULL};
-static char *Char_Nl[] = {"Newline", "Nl", "Lf", "Linefeed", NULL};
-static char *Char_Vt[] = {"Vt", NULL};
-static char *Char_Np[] = {"Page", "Np", NULL};
-static char *Char_Cr[] = {"Return", "Cr", NULL};
-static char *Char_Ff[] = {"So", "Ff", NULL};
-static char *Char_Si[] = {"Si", NULL};
-static char *Char_Dle[] = {"Dle", NULL};
-static char *Char_Dc1[] = {"Dc1", NULL};
-static char *Char_Dc2[] = {"Dc2", NULL};
-static char *Char_Dc3[] = {"Dc3", NULL};
-static char *Char_Dc4[] = {"Dc4", NULL};
-static char *Char_Nak[] = {"Nak", NULL};
-static char *Char_Syn[] = {"Syn", NULL};
-static char *Char_Etb[] = {"Etb", NULL};
-static char *Char_Can[] = {"Can", NULL};
-static char *Char_Em[] = {"Em", NULL};
-static char *Char_Sub[] = {"Sub", NULL};
-static char *Char_Esc[] = {"Escape", "Esc", NULL};
-static char *Char_Fs[] = {"Fs", NULL};
-static char *Char_Gs[] = {"Gs", NULL};
-static char *Char_Rs[] = {"Rs", NULL};
-static char *Char_Us[] = {"Us", NULL};
-static char *Char_Sp[] = {"Space", "Sp", NULL};
-static char *Char_Del[] = {"Rubout", "Del", "Delete", NULL};
-
-LispCharInfo LispChars[256] = {
+static const char * const Char_Nul[] = {"Null", "Nul", NULL};
+static const char * const Char_Soh[] = {"Soh", NULL};
+static const char * const Char_Stx[] = {"Stx", NULL};
+static const char * const Char_Etx[] = {"Etx", NULL};
+static const char * const Char_Eot[] = {"Eot", NULL};
+static const char * const Char_Enq[] = {"Enq", NULL};
+static const char * const Char_Ack[] = {"Ack", NULL};
+static const char * const Char_Bel[] = {"Bell", "Bel", NULL};
+static const char * const Char_Bs[] = {"Backspace", "Bs", NULL};
+static const char * const Char_Tab[] = {"Tab", NULL};
+static const char * const Char_Nl[] = {"Newline", "Nl", "Lf", "Linefeed", NULL};
+static const char * const Char_Vt[] = {"Vt", NULL};
+static const char * const Char_Np[] = {"Page", "Np", NULL};
+static const char * const Char_Cr[] = {"Return", "Cr", NULL};
+static const char * const Char_Ff[] = {"So", "Ff", NULL};
+static const char * const Char_Si[] = {"Si", NULL};
+static const char * const Char_Dle[] = {"Dle", NULL};
+static const char * const Char_Dc1[] = {"Dc1", NULL};
+static const char * const Char_Dc2[] = {"Dc2", NULL};
+static const char * const Char_Dc3[] = {"Dc3", NULL};
+static const char * const Char_Dc4[] = {"Dc4", NULL};
+static const char * const Char_Nak[] = {"Nak", NULL};
+static const char * const Char_Syn[] = {"Syn", NULL};
+static const char * const Char_Etb[] = {"Etb", NULL};
+static const char * const Char_Can[] = {"Can", NULL};
+static const char * const Char_Em[] = {"Em", NULL};
+static const char * const Char_Sub[] = {"Sub", NULL};
+static const char * const Char_Esc[] = {"Escape", "Esc", NULL};
+static const char * const Char_Fs[] = {"Fs", NULL};
+static const char * const Char_Gs[] = {"Gs", NULL};
+static const char * const Char_Rs[] = {"Rs", NULL};
+static const char * const Char_Us[] = {"Us", NULL};
+static const char * const Char_Sp[] = {"Space", "Sp", NULL};
+static const char * const Char_Del[] = {"Rubout", "Del", "Delete", NULL};
+
+const LispCharInfo LispChars[256] = {
{Char_Nul},
{Char_Soh},
{Char_Stx},
@@ -597,9 +597,10 @@ LispGetLine(LispObj *stream)
}
static void
-LispReadError(LispObj *stream, int line, char *fmt, ...)
+LispReadError(LispObj *stream, int line, const char *fmt, ...)
{
- char string[128], *buffer_string;
+ char string[128];
+ const char *buffer_string;
LispObj *buffer = LSTRINGSTREAM("", STREAM_READ | STREAM_WRITE, 0);
int length;
va_list ap;
@@ -1721,7 +1722,7 @@ LispReadCharacter(read_info *info)
stk[len++] = ch;
}
if (len > 1) {
- char **names;
+ const char * const *names;
int found = 0;
stk[len] = '\0';
diff --git a/lisp/stream.c b/lisp/stream.c
index aad89cf..98d6d3e 100644
--- a/lisp/stream.c
+++ b/lisp/stream.c
@@ -613,7 +613,7 @@ Lisp_GetOutputStreamString(LispBuiltin *builtin)
*/
{
int length;
- char *string;
+ const char *string;
LispObj *string_output_stream, *result;
string_output_stream = ARGUMENT(0);
diff --git a/lisp/write.c b/lisp/write.c
index 6c7d979..9201d68 100644
--- a/lisp/write.c
+++ b/lisp/write.c
@@ -90,7 +90,7 @@ static int LispWriteCharacter(LispObj*, LispObj*, write_info*);
static int LispWriteString(LispObj*, LispObj*, write_info*);
static int LispWriteFloat(LispObj*, LispObj*);
static int LispWriteAtom(LispObj*, LispObj*, write_info*);
-static int LispDoWriteAtom(LispObj*, char*, int, int);
+static int LispDoWriteAtom(LispObj*, const char*, int, int);
static int LispWriteList(LispObj*, LispObj*, write_info*, int);
static int LispWriteArray(LispObj*, LispObj*, write_info*);
static int LispWriteStruct(LispObj*, LispObj*, write_info*);
@@ -861,7 +861,8 @@ LispDoWriteObject(LispObj *stream, LispObj *object, write_info *info, int paren)
{
long print_level;
int length = 0;
- char stk[64], *string = NULL;
+ char stk[64];
+ const char *string = NULL;
write_again:
switch (OBJECT_TYPE(object)) {
@@ -1195,7 +1196,7 @@ LispWriteChars(LispObj *stream, int character, int count)
/* write a string to stream */
int
-LispWriteStr(LispObj *stream, char *buffer, long length)
+LispWriteStr(LispObj *stream, const char *buffer, long length)
{
LispFile *file;
LispString *string;
@@ -1207,7 +1208,7 @@ LispWriteStr(LispObj *stream, char *buffer, long length)
}
static int
-LispDoWriteAtom(LispObj *stream, char *string, int length, int print_case)
+LispDoWriteAtom(LispObj *stream, const char *string, int length, int print_case)
{
int bytes = 0, cap = 0;
char buffer[128], *ptr;
@@ -1653,30 +1654,30 @@ LispFormatRomanInteger(LispObj *stream, long value, int new_roman)
int
LispFormatEnglishInteger(LispObj *stream, long number, int ordinal)
{
- static char *ds[] = {
+ static const char *ds[] = {
"", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
};
- static char *dsth[] = {
+ static const char *dsth[] = {
"", "first", "second", "third", "fourth",
"fifth", "sixth", "seventh", "eighth", "ninth",
"tenth", "eleventh", "twelfth", "thirteenth", "fourteenth",
"fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"
};
- static char *hs[] = {
+ static const char *hs[] = {
"", "", "twenty", "thirty", "forty",
"fifty", "sixty", "seventy", "eighty", "ninety"
};
- static char *hsth[] = {
+ static const char *hsth[] = {
"", "", "twentieth", "thirtieth", "fortieth",
"fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"
};
- static char *ts[] = {
+ static const char *ts[] = {
"", "thousand", "million"
};
- static char *tsth[] = {
+ static const char *tsth[] = {
"", "thousandth", "millionth"
};
char stk[256];
@@ -1704,7 +1705,7 @@ LispFormatEnglishInteger(LispObj *stream, long number, int ordinal)
}
for (;;) {
int count, temp;
- char *t, *h, *d;
+ const char *t, *h, *d;
long value = number;
for (count = 0; value >= 1000; value /= 1000, count++)
@@ -1811,7 +1812,7 @@ LispFormatCharacter(LispObj *stream, LispObj *object,
if (atsign && !collon)
length += LispWriteStr(stream, "#\\", 2);
if ((atsign || collon) && (ch <= ' ' || ch == 0177)) {
- char *name = LispChars[ch].names[0];
+ const char *name = LispChars[ch].names[0];
length += LispWriteStr(stream, name, strlen(name));
}
diff --git a/lisp/write.h b/lisp/write.h
index b66ba6b..57d7227 100644
--- a/lisp/write.h
+++ b/lisp/write.h
@@ -53,7 +53,7 @@ int LispGetColumn(LispObj*);
int LispWriteChar(LispObj*, int);
int LispWriteChars(LispObj*, int, int);
-int LispWriteStr(LispObj*, char*, long);
+int LispWriteStr(LispObj*, const char*, long);
/* write any lisp object to stream */
int LispWriteObject(LispObj*, LispObj*);