From 52ee91dd73199e068d31d3ac138d933ddd4fb9b1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 22 Feb 2001 14:15:18 -0300 Subject: better encapsulation of some types --- lstrlib.c | 72 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'lstrlib.c') diff --git a/lstrlib.c b/lstrlib.c index 42e4e9d3..07ec43ad 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.61 2001/01/10 16:58:11 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.62 2001/02/02 19:02:40 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -55,7 +55,7 @@ static int str_lower (lua_State *L) { const char *s = luaL_check_lstr(L, 1, &l); luaL_buffinit(L, &b); for (i=0; isrc_end && luaI_singlematch((unsigned char)*(s+i), p, ep)) + while ((s+i)src_end && luaI_singlematch(*(s+i), p, ep)) i++; /* keeps trying to match with the maximum repetitions */ while (i>=0) { @@ -276,7 +276,7 @@ static const char *min_expand (MatchState *ms, const char *s, const char *p, const char *res = match(ms, s, ep+1); if (res != NULL) return res; - else if (ssrc_end && luaI_singlematch((unsigned char)*s, p, ep)) + else if (ssrc_end && luaI_singlematch(*s, p, ep)) s++; /* try with one more repetition */ else return NULL; } @@ -328,7 +328,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { case ')': /* end capture */ return end_capture(ms, s, p+1); case ESC: /* may be %[0-9] or %b */ - if (isdigit((unsigned char)(*(p+1)))) { /* capture? */ + if (isdigit(uchar(*(p+1)))) { /* capture? */ s = match_capture(ms, s, *(p+1)); if (s == NULL) return NULL; p+=2; goto init; /* else return match(ms, s, p+2) */ @@ -347,7 +347,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { else goto dflt; default: dflt: { /* it is a pattern item */ const char *ep = luaI_classend(ms, p); /* points to what is next */ - int m = ssrc_end && luaI_singlematch((unsigned char)*s, p, ep); + int m = ssrc_end && luaI_singlematch(*s, p, ep); switch (*ep) { case '?': { /* optional */ const char *res; @@ -460,7 +460,7 @@ static void add_s (MatchState *ms, luaL_Buffer *b) { luaL_putchar(b, news[i]); else { i++; /* skip ESC */ - if (!isdigit((unsigned char)news[i])) + if (!isdigit(uchar(news[i]))) luaL_putchar(b, news[i]); else { int level = check_capture(ms, news[i]); @@ -552,15 +552,15 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form, int *hasprecision) { const char *p = strfrmt; while (strchr("-+ #0", *p)) p++; /* skip flags */ - if (isdigit((unsigned char)*p)) p++; /* skip width */ - if (isdigit((unsigned char)*p)) p++; /* (2 digits at most) */ + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ if (*p == '.') { p++; *hasprecision = 1; - if (isdigit((unsigned char)*p)) p++; /* skip precision */ - if (isdigit((unsigned char)*p)) p++; /* (2 digits at most) */ + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ } - if (isdigit((unsigned char)*p)) + if (isdigit(uchar(*p))) lua_error(L, "invalid format (width or precision too long)"); if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ lua_error(L, "invalid format (too long)"); @@ -585,7 +585,7 @@ static int str_format (lua_State *L) { char form[MAX_FORMAT]; /* to store the format (`%...') */ char buff[MAX_ITEM]; /* to store the formatted item */ int hasprecision = 0; - if (isdigit((unsigned char)*strfrmt) && *(strfrmt+1) == '$') + if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') lua_error(L, "obsolete `format' option (d$)"); arg++; strfrmt = scanformat(L, strfrmt, form, &hasprecision); -- cgit v1.2.3-55-g6feb