lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 3b91b07fd9b6e8eb7ee7a00fb378925b755f435f
parent 349badabc19e02a96f4620d7de7724442cd9e0a0
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Thu,  1 Sep 2016 13:14:30 -0300

detail (macro 'l_checkmode' reimplemented as function)

Diffstat:
Mliolib.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/liolib.c b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.148 2015/11/23 11:36:11 roberto Exp roberto $ +** $Id: liolib.c,v 2.149 2016/05/02 14:03:19 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -37,10 +37,11 @@ #endif /* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */ -#define l_checkmode(mode) \ - (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \ - (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ \ - (strspn(mode, L_MODEEXT) == strlen(mode))) +static int l_checkmode (const char *mode) { + return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && + (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ + (strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */ +} #endif