Add const to many utility functions

This commit is contained in:
2019-08-25 22:12:34 +03:00
parent 55cb24023b
commit e3d60bb776
8 changed files with 22 additions and 20 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
static void argcount(char *fname, uint32_t nargs, uint32_t c)
static void argcount(const char *fname, uint32_t nargs, uint32_t c)
{
if (__unlikely(nargs != c))
lerrorf(ArgError, "%s: too %s arguments", fname,
+3 -3
View File
@@ -1,7 +1,7 @@
extern void DivideByZeroError(void);
#pragma noreturn(DivideByZeroError)
extern void lerrorf(value_t e, char *format, ...);
extern void lerrorf(value_t e, const char *format, ...);
#pragma noreturn(lerrorf)
extern void lerror(value_t e, const char *msg);
@@ -10,8 +10,8 @@ extern void lerror(value_t e, const char *msg);
extern void fl_raise(value_t e);
#pragma noreturn(fl_raise)
extern void type_error(char *fname, char *expected, value_t got);
extern void type_error(const char *fname, const char *expected, value_t got);
#pragma noreturn(type_error)
extern void bounds_error(char *fname, value_t arr, value_t ind);
extern void bounds_error(const char *fname, value_t arr, value_t ind);
#pragma noreturn(bounds_error)
+4 -3
View File
@@ -1,13 +1,14 @@
void DivideByZeroError(void) __attribute__((__noreturn__));
void lerrorf(value_t e, char *format, ...) __attribute__((__noreturn__));
void lerrorf(value_t e, const char *format, ...)
__attribute__((__noreturn__));
void lerror(value_t e, const char *msg) __attribute__((__noreturn__));
void fl_raise(value_t e) __attribute__((__noreturn__));
void type_error(char *fname, char *expected, value_t got)
void type_error(const char *fname, const char *expected, value_t got)
__attribute__((__noreturn__));
void bounds_error(char *fname, value_t arr, value_t ind)
void bounds_error(const char *fname, value_t arr, value_t ind)
__attribute__((__noreturn__));
+4 -3
View File
@@ -1,13 +1,14 @@
__declspec(noreturn) extern void DivideByZeroError(void);
__declspec(noreturn) extern void lerrorf(value_t e, char *format, ...);
__declspec(noreturn) extern void lerrorf(value_t e, const char *format, ...);
__declspec(noreturn) extern void lerror(value_t e, const char *msg);
__declspec(noreturn) extern void fl_raise(value_t e);
__declspec(noreturn) extern void type_error(char *fname, char *expected,
__declspec(noreturn) extern void type_error(const char *fname,
const char *expected,
value_t got);
__declspec(noreturn) extern void bounds_error(char *fname, value_t arr,
__declspec(noreturn) extern void bounds_error(const char *fname, value_t arr,
value_t ind);
+3 -3
View File
@@ -2,7 +2,7 @@
extern void DivideByZeroError(void);
#pragma aux lerrorf aborts;
extern void lerrorf(value_t e, char *format, ...);
extern void lerrorf(value_t e, const char *format, ...);
#pragma aux lerror aborts;
extern void lerror(value_t e, const char *msg);
@@ -11,7 +11,7 @@ extern void lerror(value_t e, const char *msg);
extern void fl_raise(value_t e);
#pragma aux type_error aborts;
extern void type_error(char *fname, char *expected, value_t got);
extern void type_error(const char *fname, const char *expected, value_t got);
#pragma aux bounds_error aborts;
extern void bounds_error(char *fname, value_t arr, value_t ind);
extern void bounds_error(const char *fname, value_t arr, value_t ind);
+4 -4
View File
@@ -208,7 +208,7 @@ void fl_raise(value_t e)
longjmp(thisctx->buf, 1);
}
static value_t make_error_msg(char *format, va_list args)
static value_t make_error_msg(const char *format, va_list args)
{
char msgbuf[512];
@@ -216,7 +216,7 @@ static value_t make_error_msg(char *format, va_list args)
return string_from_cstr(msgbuf);
}
void lerrorf(value_t e, char *format, ...)
void lerrorf(value_t e, const char *format, ...)
{
va_list args;
value_t msg;
@@ -239,12 +239,12 @@ void lerror(value_t e, const char *msg)
fl_raise(fl_list2(e, m));
}
void type_error(char *fname, char *expected, value_t got)
void type_error(const char *fname, const char *expected, value_t got)
{
fl_raise(fl_listn(4, TypeError, symbol(fname), symbol(expected), got));
}
void bounds_error(char *fname, value_t arr, value_t ind)
void bounds_error(const char *fname, value_t arr, value_t ind)
{
fl_raise(fl_listn(4, BoundsError, symbol(fname), arr, ind));
}
+1 -1
View File
@@ -335,7 +335,7 @@ int fl_isstring(value_t v);
int fl_isnumber(value_t v);
int fl_isgensym(value_t v);
int fl_isiostream(value_t v);
struct ios *fl_toiostream(value_t v, char *fname);
struct ios *fl_toiostream(value_t v, const char *fname);
value_t cvalue_compare(value_t a, value_t b);
int numeric_compare(value_t a, value_t b, int eq, int eqnans, char *fname);
+2 -2
View File
@@ -81,14 +81,14 @@ value_t fl_eof_objectp(value_t *args, uint32_t nargs)
return (FL_EOF == args[0]) ? FL_T : FL_F;
}
static struct ios *toiostream(value_t v, char *fname)
static struct ios *toiostream(value_t v, const char *fname)
{
if (!fl_isiostream(v))
type_error(fname, "iostream", v);
return value2c(struct ios *, v);
}
struct ios *fl_toiostream(value_t v, char *fname)
struct ios *fl_toiostream(value_t v, const char *fname)
{
return toiostream(v, fname);
}