From 3b91b07fd9b6e8eb7ee7a00fb378925b755f435f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 1 Sep 2016 13:14:56 -0300 Subject: detail (macro 'l_checkmode' reimplemented as function) --- liolib.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index f885be25..db2f01c2 100644 --- 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 -- cgit v1.2.3-55-g6feb