@@ -188,7 +188,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) {
188188 }
189189 argword = " argument" ;
190190 }
191- if (ar.name == NULL )
191+ if (ar.name == nullptr )
192192 ar.name = (pushglobalfuncname (L, &ar)) ? lua_tostring (L, -1 ) : " ?" ;
193193 return luaL_error (L, " bad %s #%d to '%s' (%s)" ,
194194 argword, arg, ar.name , extramsg);
@@ -291,7 +291,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
291291
292292LUALIB_API int luaL_execresult (lua_State *L, int stat) {
293293 if (stat == -1 ) /* error with an 'errno'? */
294- return luaL_fileresult (L, 0 , NULL );
294+ return luaL_fileresult (L, 0 , nullptr );
295295 else {
296296 const char *what = " exit" ; /* type of termination */
297297 l_inspectstat (stat, what); /* interpret result */
@@ -336,22 +336,22 @@ LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) {
336336
337337LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
338338 void *p = lua_touserdata (L, ud);
339- if (p != NULL ) { /* value is a userdata? */
339+ if (p != nullptr ) { /* value is a userdata? */
340340 if (lua_getmetatable (L, ud)) { /* does it have a metatable? */
341341 luaL_getmetatable (L, tname); /* get correct metatable */
342342 if (!lua_rawequal (L, -1 , -2 )) /* not the same? */
343- p = NULL ; /* value is a userdata with wrong metatable */
343+ p = nullptr ; /* value is a userdata with wrong metatable */
344344 lua_pop (L, 2 ); /* remove both metatables */
345345 return p;
346346 }
347347 }
348- return NULL ; /* value is not a userdata with a metatable */
348+ return nullptr ; /* value is not a userdata with a metatable */
349349}
350350
351351
352352LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
353353 void *p = luaL_testudata (L, ud, tname);
354- luaL_argexpected (L, p != NULL , ud, tname);
354+ luaL_argexpected (L, p != nullptr , ud, tname);
355355 return p;
356356}
357357
@@ -490,7 +490,7 @@ static void *resizebox (lua_State *L, int idx, size_t newsize) {
490490 void *ud;
491491 lua_Alloc allocf = lua_getallocf (L, &ud);
492492 void *temp = allocf (ud, box->box , box->bsize , newsize);
493- if (l_unlikely (temp == NULL && newsize > 0 )) { /* allocation error? */
493+ if (l_unlikely (temp == nullptr && newsize > 0 )) { /* allocation error? */
494494 lua_pushliteral (L, " not enough memory" );
495495 lua_error (L); /* raise a memory error */
496496 }
@@ -510,13 +510,13 @@ static int boxgc (lua_State *L) {
510510static const luaL_Reg boxmt[] = { /* box metamethods */
511511 {" __gc" , boxgc},
512512 {" __close" , boxgc},
513- {NULL , NULL }
513+ {nullptr , nullptr }
514514};
515515
516516
517517static void newbox (lua_State *L) {
518518 UBox *box = (UBox *)lua_newuserdatauv (L, sizeof (UBox), 0 );
519- box->box = NULL ;
519+ box->box = nullptr ;
520520 box->bsize = 0 ;
521521 if (luaL_newmetatable (L, " _UBOX*" )) /* creating metatable? */
522522 luaL_setfuncs (L, boxmt, 0 ); /* set its metamethods */
@@ -533,10 +533,10 @@ static void newbox (lua_State *L) {
533533
534534/*
535535** Whenever buffer is accessed, slot 'idx' must either be a box (which
536- ** cannot be NULL ) or it is a placeholder for the buffer.
536+ ** cannot be nullptr ) or it is a placeholder for the buffer.
537537*/
538538#define checkbufferlevel (B,idx ) \
539- lua_assert (buffonstack(B) ? lua_touserdata(B->L, idx) != NULL \
539+ lua_assert (buffonstack(B) ? lua_touserdata(B->L, idx) != nullptr \
540540 : lua_touserdata(B->L, idx) == (void *)B)
541541
542542
@@ -596,7 +596,7 @@ LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
596596
597597
598598LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
599- if (l > 0 ) { /* avoid 'std::copy_n' when 's' can be NULL */
599+ if (l > 0 ) { /* avoid 'std::copy_n' when 's' can be nullptr */
600600 char *b = prepbuffsize (B, l, -1 );
601601 std::copy_n (s, l, b);
602602 luaL_addsize (B, l);
@@ -624,7 +624,7 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
624624 s = (char *)box->box ; /* final buffer address */
625625 s[len] = ' \0 ' ; /* add ending zero */
626626 /* clear box, as Lua will take control of the buffer */
627- box->bsize = 0 ; box->box = NULL ;
627+ box->bsize = 0 ; box->box = nullptr ;
628628 lua_pushexternalstring (L, s, len, allocf, ud);
629629 lua_closeslot (L, -2 ); /* close the box */
630630 lua_gc (L, LUA_GCSTEP, len);
@@ -752,7 +752,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
752752 /* 'fread' can return > 0 *and* set the EOF flag. If next call to
753753 'getF' called 'fread', it might still wait for user input.
754754 The next check avoids this problem. */
755- if (feof (lf->f )) return NULL ;
755+ if (feof (lf->f )) return nullptr ;
756756 *size = fread (lf->buff , 1 , sizeof (lf->buff ), lf->f ); /* read block */
757757 }
758758 return lf->buff ;
@@ -812,15 +812,15 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
812812 int status, readstatus;
813813 int c;
814814 int fnameindex = lua_gettop (L) + 1 ; /* index of filename on the stack */
815- if (filename == NULL ) {
815+ if (filename == nullptr ) {
816816 lua_pushliteral (L, " =stdin" );
817817 lf.f = stdin;
818818 }
819819 else {
820820 lua_pushfstring (L, " @%s" , filename);
821821 errno = 0 ;
822822 lf.f = fopen (filename, " r" );
823- if (lf.f == NULL ) return errfile (L, " open" , fnameindex);
823+ if (lf.f == nullptr ) return errfile (L, " open" , fnameindex);
824824 }
825825 lf.n = 0 ;
826826 if (skipcomment (lf.f , &c)) /* read initial portion */
@@ -830,7 +830,7 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
830830 if (filename) { /* "real" file? */
831831 errno = 0 ;
832832 lf.f = freopen (filename, " rb" , lf.f ); /* reopen in binary mode */
833- if (lf.f == NULL ) return errfile (L, " reopen" , fnameindex);
833+ if (lf.f == nullptr ) return errfile (L, " reopen" , fnameindex);
834834 skipcomment (lf.f , &c); /* re-read initial portion */
835835 }
836836 }
@@ -858,7 +858,7 @@ typedef struct LoadS {
858858static const char *getS (lua_State *L, void *ud, size_t *size) {
859859 LoadS *ls = (LoadS *)ud;
860860 (void )L; /* not used */
861- if (ls->size == 0 ) return NULL ;
861+ if (ls->size == 0 ) return nullptr ;
862862 *size = ls->size ;
863863 ls->size = 0 ;
864864 return ls->s ;
@@ -965,8 +965,8 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
965965*/
966966LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
967967 luaL_checkstack (L, nup, " too many upvalues" );
968- for (; l->name != NULL ; l++) { /* fill the table with given functions */
969- if (l->func == NULL ) /* placeholder? */
968+ for (; l->name != nullptr ; l++) { /* fill the table with given functions */
969+ if (l->func == nullptr ) /* placeholder? */
970970 lua_pushboolean (L, 0 );
971971 else {
972972 int i;
@@ -1028,7 +1028,7 @@ LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,
10281028 const char *p, const char *r) {
10291029 const char *wild;
10301030 size_t l = strlen (p);
1031- while ((wild = strstr (s, p)) != NULL ) {
1031+ while ((wild = strstr (s, p)) != nullptr ) {
10321032 luaL_addlstring (b, s, ct_diff2sz (wild - s)); /* push prefix */
10331033 luaL_addstring (b, r); /* push replacement in place of pattern */
10341034 s = wild + l; /* continue after 'p' */
@@ -1051,7 +1051,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
10511051 (void )ud; (void )osize; /* not used */
10521052 if (nsize == 0 ) {
10531053 free (ptr);
1054- return NULL ;
1054+ return nullptr ;
10551055 }
10561056 else
10571057 return realloc (ptr, nsize);
@@ -1157,7 +1157,7 @@ static unsigned int luai_makeseed (void) {
11571157 unsigned int buff[BUFSEED];
11581158 unsigned int res;
11591159 unsigned int i;
1160- time_t t = time (NULL );
1160+ time_t t = time (nullptr );
11611161 char *b = (char *)buff;
11621162 addbuff (b, b); /* local variable's address */
11631163 addbuff (b, t); /* time */
@@ -1183,7 +1183,7 @@ LUALIB_API unsigned int luaL_makeseed (lua_State *L) {
11831183** as a macro.
11841184*/
11851185LUALIB_API lua_State *(luaL_newstate) (void ) {
1186- lua_State *L = lua_newstate (l_alloc, NULL , luai_makeseed ());
1186+ lua_State *L = lua_newstate (l_alloc, nullptr , luai_makeseed ());
11871187 if (l_likely (L)) {
11881188 lua_atpanic (L, &panic);
11891189 lua_setwarnf (L, warnfoff, L); /* default is warnings off */
0 commit comments