ref: 7e16fa1da1b72dcaef505e62939bb3b27d2899ef
parent: 5836685f1a22c7625daacc353e8513aa39b3fcad
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Mar 27 09:57:18 EDT 2023
NULL -> nil
--- a/builtins.c
+++ b/builtins.c
@@ -86,7 +86,7 @@
}
else if (iscvalue(a)) {
cv = (cvalue_t*)ptr(a);
- if (cv_class(cv)->eltype != NULL)
+ if (cv_class(cv)->eltype != nil)
return size_wrap(cvalue_arraylen(a));
}
else if (a == FL_NIL) {
@@ -147,7 +147,7 @@
static void global_env_list(symbol_t *root, value_t *pv)
{
- while (root != NULL) {
+ while (root != nil) {
if (root->name[0] != ':' && (root->binding != UNBOUND)) {
*pv = fl_cons(tagptr(root,TAG_SYM), *pv);
}
@@ -352,7 +352,7 @@
argcount("os.getenv", nargs, 1);
char *name = tostring(args[0], "os.getenv");
char *val = getenv(name);
- if (val == NULL) return FL_F;
+ if (val == nil) return FL_F;
if (*val == 0)
return symbol_value(emptystringsym);
return cvalue_static_cstring(val);
@@ -487,7 +487,7 @@
{ "os.getenv", fl_os_getenv },
{ "os.setenv", fl_os_setenv },
- { NULL, NULL }
+ { nil, nil }
};
void builtins_init(void)
--- a/cvalues.c
+++ b/cvalues.c
@@ -40,7 +40,7 @@
static size_t malloc_pressure = 0;
-static cvalue_t **Finalizers = NULL;
+static cvalue_t **Finalizers = nil;
static size_t nfinalizers=0;
static size_t maxfinalizers=0;
@@ -49,7 +49,7 @@
if (nfinalizers == maxfinalizers) {
size_t nn = (maxfinalizers==0 ? 256 : maxfinalizers*2);
cvalue_t **temp = realloc(Finalizers, nn*sizeof(cvalue_t*));
- if (temp == NULL)
+ if (temp == nil)
lerrorf(MemoryError, "out of memory");
Finalizers = temp;
maxfinalizers = nn;
@@ -75,7 +75,7 @@
}
else {
fltype_t *t = cv_class(tmp);
- if (t->vtable != NULL && t->vtable->finalize != NULL) {
+ if (t->vtable != nil && t->vtable->finalize != nil) {
t->vtable->finalize(tagptr(tmp, TAG_CVALUE));
}
if (!isinlined(tmp) && owned(tmp)) {
@@ -146,7 +146,7 @@
pcv = (cvalue_t*)alloc_words(nw);
pcv->type = type;
pcv->data = &pcv->_space[0];
- if (type->vtable != NULL && type->vtable->finalize != NULL)
+ if (type->vtable != nil && type->vtable->finalize != nil)
add_finalizer(pcv);
}
else {
@@ -378,7 +378,7 @@
static int isarray(value_t v)
{
- return iscvalue(v) && cv_class((cvalue_t*)ptr(v))->eltype != NULL;
+ return iscvalue(v) && cv_class((cvalue_t*)ptr(v))->eltype != nil;
}
static size_t predict_arraylen(value_t arg)
@@ -532,7 +532,7 @@
{
symbol_t *s;
- if (issymbol(type) && (s = ptr(type)) != NULL && valid_numtype(s->numtype)) {
+ if (issymbol(type) && (s = ptr(type)) != nil && valid_numtype(s->numtype)) {
*palign = s->align;
return s->size;
}
@@ -643,7 +643,7 @@
nv->data = &nv->_space[0];
ncv = tagptr(nv, TAG_CVALUE);
fltype_t *t = cv_class(cv);
- if (t->vtable != NULL && t->vtable->relocate != NULL)
+ if (t->vtable != nil && t->vtable->relocate != nil)
t->vtable->relocate(v, ncv);
forward(v, ncv);
return ncv;
@@ -700,7 +700,7 @@
{
cvinitfunc_t f=type->init;
- if (f == NULL)
+ if (f == nil)
lerrorf(ArgError, "c-value: invalid c type");
f(type, v, dest);
@@ -717,7 +717,7 @@
value_t type = args[0];
fltype_t *ft = get_type(type);
value_t cv;
- if (ft->eltype != NULL) {
+ if (ft->eltype != nil) {
// special case to handle incomplete array types bla[]
size_t elsz = ft->elsz;
size_t cnt;
@@ -820,7 +820,7 @@
argcount("builtin", nargs, 1);
symbol_t *name = tosymbol(args[0], "builtin");
cvalue_t *cv;
- if (ismanaged(args[0]) || (cv=name->dlcache) == NULL)
+ if (ismanaged(args[0]) || (cv=name->dlcache) == nil)
lerrorf(ArgError, "builtin: function %s not found", name->name);
return tagptr(cv, TAG_CVALUE);
}
@@ -861,7 +861,7 @@
{ "lognot", fl_lognot },
{ "ash", fl_ash },
// todo: autorelease
- { NULL, NULL }
+ { nil, nil }
};
#define cv_intern(tok) \
@@ -892,7 +892,7 @@
htable_new(&TypeTable, 256);
htable_new(&reverse_dlsym_lookup_table, 256);
- builtintype = define_opaque_type(builtinsym, sizeof(builtin_t), NULL, NULL);
+ builtintype = define_opaque_type(builtinsym, sizeof(builtin_t), nil, nil);
ctor_cv_intern(int8, T_INT8, int8_t);
ctor_cv_intern(uint8, T_UINT8, uint8_t);
@@ -1191,7 +1191,7 @@
eqnans: NaNs considered equal to each other
-0.0 not considered equal to 0.0
inexact not considered equal to exact
- fname: if not NULL, throws type errors, else returns 2 for type errors
+ fname: if not nil, throws type errors, else returns 2 for type errors
*/
int numeric_compare(value_t a, value_t b, int eq, int eqnans, char *fname)
{
@@ -1298,7 +1298,7 @@
{
lltint_t ai, bi;
numerictype_t ta, tb, itmp;
- void *aptr=NULL, *bptr=NULL, *ptmp;
+ void *aptr=nil, *bptr=nil, *ptmp;
int64_t b64;
if (!num_to_ptr(a, &ai, &ta, &aptr) || ta >= T_FLOAT)
--- a/equal.c
+++ b/equal.c
@@ -72,7 +72,7 @@
if (iscprim(b)) {
if (cp_class((cprim_t*)ptr(b)) == wchartype)
return fixnum(1);
- return fixnum(numeric_compare(a, b, eq, 1, NULL));
+ return fixnum(numeric_compare(a, b, eq, 1, nil));
}
return fixnum(-1);
case TAG_SYM:
@@ -92,7 +92,7 @@
else if (iscprim(b) && cp_class((cprim_t*)ptr(b)) == wchartype) {
return fixnum(1);
}
- c = numeric_compare(a, b, eq, 1, NULL);
+ c = numeric_compare(a, b, eq, 1, nil);
if (c != 2)
return fixnum(c);
break;
--- a/flisp.c
+++ b/flisp.c
@@ -22,7 +22,7 @@
int isbuiltin(value_t x)
{
int i = uintval(x);
- return tag(x) == TAG_FUNCTION && i < nelem(builtins) && builtins[i].name != NULL;
+ return tag(x) == TAG_FUNCTION && i < nelem(builtins) && builtins[i].name != nil;
}
static uint32_t N_STACK;
@@ -57,7 +57,7 @@
static value_t *alloc_words(int n);
static value_t relocate(value_t v);
-static fl_readstate_t *readstate = NULL;
+static fl_readstate_t *readstate = nil;
static void free_readstate(fl_readstate_t *rs)
{
@@ -75,7 +75,7 @@
// error utilities ------------------------------------------------------------
// saved execution state for an unwind target
-fl_exception_context_t *fl_ctx = NULL;
+fl_exception_context_t *fl_ctx = nil;
uint32_t fl_throwing_frame=0; // active frame when exception was thrown
value_t fl_lasterror;
@@ -179,7 +179,7 @@
// symbol table ---------------------------------------------------------------
-symbol_t *symtab = NULL;
+symbol_t *symtab = nil;
int fl_is_keyword_name(char *str, size_t len)
{
@@ -211,7 +211,7 @@
{
int x;
- while(*ptree != NULL) {
+ while(*ptree != nil) {
x = strcmp(str, (*ptree)->name);
if (x == 0)
return ptree;
@@ -228,7 +228,7 @@
symbol_t **pnode;
pnode = symtab_lookup(&symtab, str);
- if (*pnode == NULL)
+ if (*pnode == nil)
*pnode = mk_symbol(str);
return tagptr(*pnode, TAG_SYM);
}
@@ -246,7 +246,7 @@
gs->id = _gensym_ctr++;
gs->binding = UNBOUND;
gs->isconst = 0;
- gs->type = NULL;
+ gs->type = nil;
return tagptr(gs, TAG_SYM);
}
@@ -455,7 +455,7 @@
static void trace_globals(symbol_t *root)
{
- while (root != NULL) {
+ while (root != nil) {
if (root->binding != UNBOUND)
root->binding = relocate(root->binding);
trace_globals(root->left);
@@ -532,13 +532,13 @@
// grow the other half of the heap this time to catch up.
if (grew || ((lim-curheap) < (int)(heapsize/5)) || mustgrow) {
temp = LLT_REALLOC(tospace, heapsize*2);
- if (temp == NULL)
+ if (temp == nil)
fl_raise(memory_exception_value);
tospace = temp;
if (grew) {
heapsize*=2;
temp = bitvector_resize(consflags, 0, heapsize/sizeof(cons_t), 1);
- if (temp == NULL)
+ if (temp == nil)
fl_raise(memory_exception_value);
consflags = (uint32_t*)temp;
}
@@ -552,7 +552,7 @@
{
size_t newsz = N_STACK + (N_STACK>>1);
value_t *ns = realloc(Stack, newsz*sizeof(value_t));
- if (ns == NULL)
+ if (ns == nil)
lerrorf(MemoryError, "stack overflow");
Stack = ns;
N_STACK = newsz;
@@ -574,7 +574,7 @@
}
else if (isbuiltin(f)) {
value_t tab = symbol_value(builtins_table_sym);
- if (ptr(tab) == NULL)
+ if (ptr(tab) == nil)
lerrorf(UnboundError, "builtins table");
Stack[SP-n-1] = vector_elt(tab, uintval(f));
v = apply_cl(n);
@@ -1818,7 +1818,7 @@
void assign_global_builtins(builtinspec_t *b)
{
- while (b->name != NULL) {
+ while (b->name != nil) {
setc(symbol(b->name), cbuiltin(b->name, b->fptr));
b++;
}
@@ -2042,7 +2042,7 @@
{ "append", fl_append },
{ "list*", fl_liststar },
{ "map", fl_map1 },
- { NULL, NULL }
+ { nil, nil }
};
// initialization -------------------------------------------------------------
--- a/flisp.h
+++ b/flisp.h
@@ -292,7 +292,7 @@
#define cv_type(cv) (cv_class(cv)->type)
#define cv_data(cv) ((cv)->data)
#define cv_isstr(cv) (cv_class(cv)->eltype == bytetype)
-#define cv_isPOD(cv) (cv_class(cv)->init != NULL)
+#define cv_isPOD(cv) (cv_class(cv)->init != nil)
#define cvalue_data(v) cv_data((cvalue_t*)ptr(v))
#define cvalue_len(v) cv_len((cvalue_t*)ptr(v))
--- a/iostream.c
+++ b/iostream.c
@@ -27,7 +27,7 @@
}
cvtable_t iostream_vtable = { print_iostream, relocate_iostream,
- free_iostream, NULL };
+ free_iostream, nil };
int fl_isiostream(value_t v)
{
@@ -81,7 +81,7 @@
value_t f = cvalue(iostreamtype, sizeof(ios_t));
char *fname = tostring(args[0], "file");
ios_t *s = value2c(ios_t*, f);
- if (ios_file(s, fname, r, w, c, t) == NULL)
+ if (ios_file(s, fname, r, w, c, t) == nil)
lerrorf(IOError, "file: could not open \"%s\"", fname);
if (a) ios_seek_end(s);
return f;
@@ -93,7 +93,7 @@
USED(args);
value_t f = cvalue(iostreamtype, sizeof(ios_t));
ios_t *s = value2c(ios_t*, f);
- if (ios_mem(s, 0) == NULL)
+ if (ios_mem(s, 0) == nil)
lerrorf(MemoryError, "buffer: could not allocate stream");
return f;
}
@@ -243,7 +243,7 @@
}
else {
ft = get_type(args[1]);
- if (ft->eltype != NULL && !iscons(cdr_(cdr_(args[1]))))
+ if (ft->eltype != nil && !iscons(cdr_(cdr_(args[1]))))
lerrorf(ArgError, "io.read: incomplete type");
n = ft->size;
}
@@ -430,7 +430,7 @@
{ "io.copyuntil", fl_iocopyuntil },
{ "io.tostring!", fl_iotostring },
- { NULL, NULL }
+ { nil, nil }
};
void iostream_init(void)
@@ -444,7 +444,7 @@
instrsym = symbol("*input-stream*");
outstrsym = symbol("*output-stream*");
iostreamtype = define_opaque_type(iostreamsym, sizeof(ios_t),
- &iostream_vtable, NULL);
+ &iostream_vtable, nil);
assign_global_builtins(iostreamfunc_info);
setc(symbol("*stdout*"), cvalue_from_ref(iostreamtype, ios_stdout,
--- a/llt/bitvector.c
+++ b/llt/bitvector.c
@@ -37,7 +37,7 @@
uint32_t *p;
size_t sz = ((newsz+31)>>5) * sizeof(uint32_t);
p = LLT_REALLOC(b, sz);
- if (p == NULL) return NULL;
+ if (p == nil) return nil;
if (initzero && newsz>oldsz) {
size_t osz = ((oldsz+31)>>5) * sizeof(uint32_t);
memset(&p[osz/sizeof(uint32_t)], 0, sz-osz);
@@ -47,7 +47,7 @@
uint32_t *bitvector_new(uint64_t n, int initzero)
{
- return bitvector_resize(NULL, 0, n, initzero);
+ return bitvector_resize(nil, 0, n, initzero);
}
size_t bitvector_nwords(uint64_t nbits)
--- a/llt/htable.c
+++ b/llt/htable.c
@@ -18,7 +18,7 @@
h->size = size;
h->table = (void**)LLT_ALLOC(size*sizeof(void*));
}
- if (h->table == NULL) return NULL;
+ if (h->table == nil) return nil;
size_t i;
for(i=0; i < size; i++)
h->table[i] = HT_NOTFOUND;
@@ -38,7 +38,7 @@
if (h->size > sz*4 && h->size > HT_N_INLINE) {
size_t newsz = sz*4;
void **newtab = (void**)LLT_REALLOC(h->table, newsz*sizeof(void*));
- if (newtab == NULL)
+ if (newtab == nil)
return;
h->size = newsz;
h->table = newtab;
--- a/llt/htable.inc
+++ b/llt/htable.inc
@@ -53,10 +53,9 @@
newsz = HT_N_INLINE; \
else \
newsz = sz<<2; \
- /*printf("trying to allocate %d words.\n", newsz); fflush(stdout);*/ \
tab = (void**)LLT_ALLOC(newsz*sizeof(void*)); \
- if (tab == NULL) \
- return NULL; \
+ if (tab == nil) \
+ return nil; \
for(i=0; i < newsz; i++) \
tab[i] = HT_NOTFOUND; \
h->table = tab; \
@@ -88,8 +87,8 @@
return HTNAME##_lookup_bp(h, key); \
} \
\
-/* returns bp if key is in hash, otherwise NULL */ \
-/* if return is non-NULL and *bp == HT_NOTFOUND then key was deleted */ \
+/* returns bp if key is in hash, otherwise nil */ \
+/* if return is non-nil and *bp == HT_NOTFOUND then key was deleted */ \
static void **HTNAME##_peek_bp(htable_t *h, void *key) \
{ \
size_t sz = hash_size(h); \
@@ -102,7 +101,7 @@
\
do { \
if (tab[index] == HT_NOTFOUND) \
- return NULL; \
+ return nil; \
if (EQFUNC(key, tab[index])) \
return &tab[index+1]; \
\
@@ -112,13 +111,13 @@
break; \
} while (index != orig); \
\
- return NULL; \
+ return nil; \
} \
\
void *HTNAME##_get(htable_t *h, void *key) \
{ \
void **bp = HTNAME##_peek_bp(h, key); \
- if (bp == NULL) \
+ if (bp == nil) \
return HT_NOTFOUND; \
return *bp; \
} \
@@ -131,7 +130,7 @@
int HTNAME##_remove(htable_t *h, void *key) \
{ \
void **bp = HTNAME##_peek_bp(h, key); \
- if (bp != NULL) { \
+ if (bp != nil) { \
*bp = HT_NOTFOUND; \
return 1; \
} \
--- a/llt/htableh.inc
+++ b/llt/htableh.inc
@@ -21,7 +21,7 @@
// logically remove key
// get a pointer to the location of the value for the given key.
-// creates the location if it doesn't exist. only returns NULL
+// creates the location if it doesn't exist. only returns nil
// if memory allocation fails.
// this should be used for updates, for example:
// void **bp = ptrhash_bp(h, key);
--- a/llt/ios.c
+++ b/llt/ios.c
@@ -11,7 +11,7 @@
while (--src >= (uint8_t *) s)
if (*src == uc)
return (void *) src;
- return NULL;
+ return nil;
}
#if !defined(__plan9__)
@@ -112,7 +112,7 @@
{
char *temp;
- if ((s->buf==NULL || s->buf==&s->local[0]) && (sz <= IOS_INLSIZE)) {
+ if ((s->buf==nil || s->buf==&s->local[0]) && (sz <= IOS_INLSIZE)) {
/* TODO: if we want to allow shrinking, see if the buffer shrank
down to this size, in which case we need to copy. */
s->buf = &s->local[0];
@@ -128,13 +128,13 @@
// always allocate 1 bigger in case user wants to add a NUL
// terminator after taking over the buffer
temp = LLT_REALLOC(s->buf, sz+1);
- if (temp == NULL)
- return NULL;
+ if (temp == nil)
+ return nil;
}
else {
temp = LLT_ALLOC(sz+1);
- if (temp == NULL)
- return NULL;
+ if (temp == nil)
+ return nil;
s->ownbuf = 1;
if (s->size > 0)
memmove(temp, s->buf, s->size);
@@ -162,7 +162,7 @@
newsize = s->maxsize ? s->maxsize * 2 : 8;
while (s->bpos + n > newsize)
newsize *= 2;
- if (_buf_realloc(s, newsize) == NULL) {
+ if (_buf_realloc(s, newsize) == nil) {
/* no more space; write as much as we can */
amt = s->maxsize - s->bpos;
if (amt > 0) {
@@ -275,7 +275,7 @@
s->bpos = 0;
}
else {
- if (_buf_realloc(s, s->bpos + n)==NULL)
+ if (_buf_realloc(s, s->bpos + n)==nil)
return space;
}
}
@@ -323,7 +323,7 @@
else if (n <= space) {
if (s->bm == bm_line) {
char *nl;
- if ((nl=llt_memrchr(data, '\n', n)) != NULL) {
+ if ((nl=llt_memrchr(data, '\n', n)) != nil) {
size_t linesz = nl-data+1;
s->bm = bm_block;
wrote += ios_write(s, data, linesz);
@@ -451,7 +451,7 @@
s->bpos = size;
}
else {
- if (_buf_realloc(s, size)==NULL)
+ if (_buf_realloc(s, size)==nil)
return s->size;
}
s->size = size;
@@ -474,7 +474,7 @@
int ios_flush(ios_t *s)
{
- if (s->ndirty == 0 || s->bm == bm_mem || s->buf == NULL)
+ if (s->ndirty == 0 || s->bm == bm_mem || s->buf == nil)
return 0;
if (s->fd == -1)
return -1;
@@ -523,9 +523,9 @@
if (s->fd != -1 && s->ownfd)
close(s->fd);
s->fd = -1;
- if (s->buf!=NULL && s->ownbuf && s->buf!=&s->local[0])
+ if (s->buf!=nil && s->ownbuf && s->buf!=&s->local[0])
LLT_FREE(s->buf);
- s->buf = NULL;
+ s->buf = nil;
s->size = s->maxsize = s->bpos = 0;
}
@@ -537,7 +537,7 @@
s->maxsize = IOS_INLSIZE;
}
else {
- s->buf = NULL;
+ s->buf = nil;
_buf_realloc(s, IOS_BUFSIZE);
}
s->size = s->bpos = 0;
@@ -551,8 +551,8 @@
if (s->buf == &s->local[0]) {
buf = LLT_ALLOC(s->size+1);
- if (buf == NULL)
- return NULL;
+ if (buf == nil)
+ return nil;
if (s->size)
memmove(buf, s->buf, s->size);
}
@@ -583,7 +583,7 @@
}
s->size = nvalid;
- if (s->buf!=NULL && s->ownbuf && s->buf!=&s->local[0])
+ if (s->buf!=nil && s->ownbuf && s->buf!=&s->local[0])
LLT_FREE(s->buf);
s->buf = buf;
s->maxsize = size;
@@ -660,7 +660,7 @@
}
size_t written;
char *pd = (char*)memchr(from->buf+from->bpos, delim, avail);
- if (pd == NULL) {
+ if (pd == nil) {
written = ios_write(to, from->buf+from->bpos, avail);
from->bpos += avail;
total += written;
@@ -685,7 +685,7 @@
s->bm = bm_block;
s->state = bst_none;
s->errcode = 0;
- s->buf = NULL;
+ s->buf = nil;
s->maxsize = 0;
s->size = 0;
s->bpos = 0;
@@ -724,7 +724,7 @@
return s;
open_file_err:
s->fd = -1;
- return NULL;
+ return nil;
}
ios_t *ios_mem(ios_t *s, size_t initsize)
@@ -738,7 +738,7 @@
ios_t *ios_str(ios_t *s, char *str)
{
size_t n = strlen(str);
- if (ios_mem(s, n+1)==NULL) return NULL;
+ if (ios_mem(s, n+1)==nil) return nil;
ios_write(s, str, n+1);
ios_seek(s, 0);
return s;
@@ -765,9 +765,9 @@
return s;
}
-ios_t *ios_stdin = NULL;
-ios_t *ios_stdout = NULL;
-ios_t *ios_stderr = NULL;
+ios_t *ios_stdin = nil;
+ios_t *ios_stdout = nil;
+ios_t *ios_stderr = nil;
void ios_init_stdstreams(void)
{
@@ -835,7 +835,7 @@
return c;
}
if (s->size == s->maxsize) {
- if (_buf_realloc(s, s->maxsize*2) == NULL)
+ if (_buf_realloc(s, s->maxsize*2) == nil)
return IOS_EOF;
}
memmove(s->buf + 1, s->buf, s->size);
--- a/llt/lltinit.c
+++ b/llt/lltinit.c
@@ -15,10 +15,10 @@
ios_init_stdstreams();
- D_PNAN = strtod("+NaN",NULL);
- D_NNAN = strtod("-NaN",NULL);
- D_PINF = strtod("+Inf",NULL);
- D_NINF = strtod("-Inf",NULL);
+ D_PNAN = strtod("+NaN",nil);
+ D_NNAN = strtod("-NaN",nil);
+ D_PINF = strtod("+Inf",nil);
+ D_NINF = strtod("-Inf",nil);
#if defined(__plan9__)
u32int x;
x = 0x7fc00000; memmove(&F_PNAN, &x, 4);
@@ -26,9 +26,9 @@
x = 0x7f800000; memmove(&F_PINF, &x, 4);
x = 0xff800000; memmove(&F_NINF, &x, 4);
#else
- F_PNAN = strtof("+NaN",NULL);
- F_NNAN = -strtof("+NaN",NULL);
- F_PINF = strtof("+Inf",NULL);
- F_NINF = strtof("-Inf",NULL);
+ F_PNAN = strtof("+NaN",nil);
+ F_NNAN = -strtof("+NaN",nil);
+ F_PINF = strtof("+Inf",nil);
+ F_NINF = strtof("-Inf",nil);
#endif
}
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -25,7 +25,7 @@
a = nsec();
#else
struct timeval now;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nil);
a = (((uint64_t)now.tv_sec)<<32) + (uint64_t)now.tv_usec;
#endif
@@ -39,7 +39,7 @@
#else
struct timeval now;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nil);
return tv2float(&now);
#endif
}
@@ -79,7 +79,7 @@
struct tm tm;
res = strptime(str, fmt, &tm);
- if (res != NULL) {
+ if (res != nil) {
tm.tm_isdst = -1; /* Not set by strptime(); tells mktime() to determine
whether daylight saving time is in effect */
t = mktime(&tm);
@@ -103,6 +103,6 @@
timeout.tv_sec = ms/1000;
timeout.tv_usec = (ms % 1000) * 1000;
- select(0, NULL, NULL, NULL, &timeout);
+ select(0, nil, nil, nil, &timeout);
#endif
}
--- a/llt/utf8.c
+++ b/llt/utf8.c
@@ -358,7 +358,7 @@
digs[dno++] = str[i++];
} while (i<ssz && octal_digit(str[i]) && dno<3);
digs[dno] = '\0';
- ch = strtol(digs, NULL, 8);
+ ch = strtol(digs, nil, 8);
}
else if ((c0=='x' && (ndig=2)) ||
(c0=='u' && (ndig=4)) ||
@@ -368,7 +368,7 @@
}
if (dno == 0) return 0;
digs[dno] = '\0';
- ch = strtol(digs, NULL, 16);
+ ch = strtol(digs, nil, 16);
}
else {
ch = (uint32_t)read_escape_control_char(c0);
@@ -495,7 +495,7 @@
lasti = i;
(*charn)++;
}
- return NULL;
+ return nil;
}
char *u8_memchr(const char *s, uint32_t ch, size_t sz, size_t *charn)
@@ -520,7 +520,7 @@
lasti = i;
(*charn)++;
}
- return NULL;
+ return nil;
}
char *u8_memrchr(const char *s, uint32_t ch, size_t sz)
@@ -528,7 +528,7 @@
size_t i = sz-1, tempi=0;
uint32_t c;
- if (sz == 0) return NULL;
+ if (sz == 0) return nil;
while (i && !isutf(s[i])) i--;
@@ -545,7 +545,7 @@
if (i > tempi)
break;
}
- return NULL;
+ return nil;
}
size_t u8_vprintf(const char *fmt, va_list ap)
--- a/llt/utf8.h
+++ b/llt/utf8.h
@@ -79,7 +79,7 @@
int octal_digit(char c);
int hex_digit(char c);
-/* return a pointer to the first occurrence of ch in s, or NULL if not
+/* return a pointer to the first occurrence of ch in s, or nil if not
found. character index of found character returned in *charn. */
char *u8_strchr(const char *s, uint32_t ch, size_t *charn);
--- a/opaque_type_template.c
+++ b/opaque_type_template.c
@@ -45,7 +45,7 @@
static builtinspec_t TYPEfunc_info[] = {
{ "TYPE?", fl_TYPEp },
- { NULL, NULL }
+ { nil, nil }
};
void TYPE_init()
@@ -52,6 +52,6 @@
{
TYPEsym = symbol("TYPE");
TYPEtype = define_opaque_type(TYPEsym, sizeof(TYPE_t),
- &TYPE_vtable, NULL);
+ &TYPE_vtable, nil);
assign_global_builtins(TYPEfunc_info);
}
--- a/plan9/platform.h
+++ b/plan9/platform.h
@@ -44,7 +44,6 @@
#define PRIdPTR "ld"
#endif
-#define NULL nil
#define INT32_MAX 0x7fffffff
#define UINT32_MAX 0xffffffffU
#define INT32_MIN (-INT32_MAX-1)
--- a/posix/platform.h
+++ b/posix/platform.h
@@ -30,6 +30,7 @@
#define ULONG64 1
#endif
+#define nil NULL
#define USED(x) ((void)(x))
#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
--- a/print.c
+++ b/print.c
@@ -103,7 +103,7 @@
if (!cv_isstr(cv) || cv_len(cv)!=0)
mark_cons(v);
fltype_t *t = cv_class(cv);
- if (t->vtable != NULL && t->vtable->print_traverse != NULL)
+ if (t->vtable != nil && t->vtable->print_traverse != nil)
t->vtable->print_traverse(v);
}
}
@@ -115,7 +115,7 @@
if ((name[0] == '\0') ||
(name[0] == '.' && name[1] == '\0') ||
(name[0] == '#') ||
- isnumtok(name, NULL))
+ isnumtok(name, nil))
escape = 1;
i=0;
while (name[i]) {
@@ -205,7 +205,7 @@
// get the width of an expression if we can do so cheaply
if (issymbol(v))
return u8_strwidth(symbol_name(v));
- if (iscprim(v) && ptr(v) != NULL && cp_class((cprim_t*)ptr(v)) == wchartype)
+ if (iscprim(v) && ptr(v) != nil && cp_class((cprim_t*)ptr(v)) == wchartype)
return 4;
return -1;
}
@@ -682,7 +682,7 @@
}
else {
snprint_real(buf, sizeof(buf), d, 0, ndec, 3, 10);
- int hasdec = (strpbrk(buf, ".eE") != NULL);
+ int hasdec = (strpbrk(buf, ".eE") != nil);
outs(buf, f);
if (!hasdec) outsn(".0", f, 2);
if (type == floatsym && !print_princ && !weak)
@@ -817,8 +817,8 @@
}
}
}
- else if (cv_class(cv)->vtable != NULL &&
- cv_class(cv)->vtable->print != NULL) {
+ else if (cv_class(cv)->vtable != nil &&
+ cv_class(cv)->vtable->print != nil) {
cv_class(cv)->vtable->print(v, f);
}
else {
--- a/read.c
+++ b/read.c
@@ -492,7 +492,7 @@
if (i >= sz-4) { // -4: leaves room for longest utf8 sequence
sz *= 2;
temp = realloc(buf, sz);
- if (temp == NULL) {
+ if (temp == nil) {
free(buf);
lerrorf(ParseError, "read: out of memory reading string");
}
@@ -519,7 +519,7 @@
} while (octal_digit(c) && j<3 && (c!=IOS_EOF));
if (c!=IOS_EOF) ios_ungetc(c, F);
eseq[j] = '\0';
- wc = strtol(eseq, NULL, 8);
+ wc = strtol(eseq, nil, 8);
// \DDD and \xXX read bytes, not characters
buf[i++] = ((char)wc);
}
@@ -533,7 +533,7 @@
}
if (c!=IOS_EOF) ios_ungetc(c, F);
eseq[j] = '\0';
- if (j) wc = strtol(eseq, NULL, 16);
+ if (j) wc = strtol(eseq, nil, 16);
if (!j || wc > 0x10ffff) {
free(buf);
lerrorf(ParseError, "read: invalid escape sequence");
@@ -714,7 +714,7 @@
case TOK_GENSYM:
pv = (value_t*)ptrhash_bp(&readstate->gensyms, (void*)tokval);
if (*pv == (value_t)HT_NOTFOUND)
- *pv = fl_gensym(NULL, 0);
+ *pv = fl_gensym(nil, 0);
return *pv;
case TOK_DOUBLEQUOTE:
return read_string();
--- a/string.c
+++ b/string.c
@@ -113,7 +113,7 @@
{
if (nargs == 1 && fl_isstring(args[0]))
return args[0];
- value_t arg, buf = fl_buffer(NULL, 0);
+ value_t arg, buf = fl_buffer(nil, 0);
fl_gc_handle(&buf);
ios_t *s = value2c(ios_t*,buf);
uint32_t i;
@@ -243,7 +243,7 @@
static value_t mem_find_byte(char *s, char c, size_t start, size_t len)
{
char *p = memchr(s+start, c, len-start);
- if (p == NULL)
+ if (p == nil)
return FL_F;
return size_wrap((size_t)(p - s));
}
@@ -415,7 +415,7 @@
{ "number->string", fl_numbertostring },
{ "string->number", fl_stringtonumber },
- { NULL, NULL }
+ { nil, nil }
};
void stringfuncs_init(void)
--- a/table.c
+++ b/table.c
@@ -83,7 +83,7 @@
value_t nt;
// prevent small tables from being added to finalizer list
if (cnt <= HT_N_INLINE) {
- tabletype->vtable->finalize = NULL;
+ tabletype->vtable->finalize = nil;
nt = cvalue(tabletype, sizeof(htable_t));
tabletype->vtable->finalize = free_htable;
}
@@ -192,7 +192,7 @@
{ "has?", fl_table_has },
{ "del!", fl_table_del },
{ "table.foldl", fl_table_foldl },
- { NULL, NULL }
+ { nil, nil }
};
void table_init(void)
@@ -199,6 +199,6 @@
{
tablesym = symbol("table");
tabletype = define_opaque_type(tablesym, sizeof(htable_t),
- &table_vtable, NULL);
+ &table_vtable, nil);
assign_global_builtins(tablefunc_info);
}
--- a/types.c
+++ b/types.c
@@ -5,7 +5,7 @@
fltype_t *ft;
if (issymbol(t)) {
ft = ((symbol_t*)ptr(t))->type;
- if (ft != NULL)
+ if (ft != nil)
return ft;
}
void **bp = equalhash_bp(&TypeTable, (void*)t);
@@ -56,7 +56,7 @@
fltype_t *get_array_type(value_t eltype)
{
fltype_t *et = get_type(eltype);
- if (et->artype == NULL)
+ if (et->artype == nil)
et->artype = get_type(fl_list2(arraysym, eltype));
return et->artype;
}