diff options
Diffstat (limited to '')
| -rw-r--r-- | lstrlib.c | 18 |
1 files changed, 9 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.62 2001/02/02 19:02:40 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.63 2001/02/22 17:15:18 roberto Exp roberto $ |
| 3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -17,7 +17,7 @@ | |||
| 17 | #include "lualib.h" | 17 | #include "lualib.h" |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | typedef long sint32; /* a "signed" version for size_t */ | 20 | typedef long sint32; /* a signed version for size_t */ |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | static int str_len (lua_State *L) { | 23 | static int str_len (lua_State *L) { |
| @@ -128,7 +128,7 @@ static int str_char (lua_State *L) { | |||
| 128 | 128 | ||
| 129 | typedef struct MatchState { | 129 | typedef struct MatchState { |
| 130 | const char *src_init; /* init of source string */ | 130 | const char *src_init; /* init of source string */ |
| 131 | const char *src_end; /* end ('\0') of source string */ | 131 | const char *src_end; /* end (`\0') of source string */ |
| 132 | int level; /* total number of captures (finished or unfinished) */ | 132 | int level; /* total number of captures (finished or unfinished) */ |
| 133 | struct { | 133 | struct { |
| 134 | const char *init; | 134 | const char *init; |
| @@ -166,9 +166,9 @@ static const char *luaI_classend (MatchState *ms, const char *p) { | |||
| 166 | return p+1; | 166 | return p+1; |
| 167 | case '[': | 167 | case '[': |
| 168 | if (*p == '^') p++; | 168 | if (*p == '^') p++; |
| 169 | do { /* look for a ']' */ | 169 | do { /* look for a `]' */ |
| 170 | if (*p == '\0') lua_error(ms->L, "malformed pattern (missing `]')"); | 170 | if (*p == '\0') lua_error(ms->L, "malformed pattern (missing `]')"); |
| 171 | if (*(p++) == ESC && *p != '\0') p++; /* skip escapes (e.g. '%]') */ | 171 | if (*(p++) == ESC && *p != '\0') p++; /* skip escapes (e.g. `%]') */ |
| 172 | } while (*p != ']'); | 172 | } while (*p != ']'); |
| 173 | return p+1; | 173 | return p+1; |
| 174 | default: | 174 | default: |
| @@ -200,7 +200,7 @@ static int matchbracketclass (char c, const char *p, const char *endclass) { | |||
| 200 | int sig = 1; | 200 | int sig = 1; |
| 201 | if (*(p+1) == '^') { | 201 | if (*(p+1) == '^') { |
| 202 | sig = 0; | 202 | sig = 0; |
| 203 | p++; /* skip the '^' */ | 203 | p++; /* skip the `^' */ |
| 204 | } | 204 | } |
| 205 | while (++p < endclass) { | 205 | while (++p < endclass) { |
| 206 | if (*p == ESC) { | 206 | if (*p == ESC) { |
| @@ -342,7 +342,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
| 342 | case '\0': /* end of pattern */ | 342 | case '\0': /* end of pattern */ |
| 343 | return s; /* match succeeded */ | 343 | return s; /* match succeeded */ |
| 344 | case '$': | 344 | case '$': |
| 345 | if (*(p+1) == '\0') /* is the '$' the last char in pattern? */ | 345 | if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ |
| 346 | return (s == ms->src_end) ? s : NULL; /* check end of string */ | 346 | return (s == ms->src_end) ? s : NULL; /* check end of string */ |
| 347 | else goto dflt; | 347 | else goto dflt; |
| 348 | default: dflt: { /* it is a pattern item */ | 348 | default: dflt: { /* it is a pattern item */ |
| @@ -601,7 +601,7 @@ static int str_format (lua_State *L) { | |||
| 601 | break; | 601 | break; |
| 602 | case 'q': | 602 | case 'q': |
| 603 | luaI_addquoted(L, &b, arg); | 603 | luaI_addquoted(L, &b, arg); |
| 604 | continue; /* skip the "addsize" at the end */ | 604 | continue; /* skip the `addsize' at the end */ |
| 605 | case 's': { | 605 | case 's': { |
| 606 | size_t l; | 606 | size_t l; |
| 607 | const char *s = luaL_check_lstr(L, arg, &l); | 607 | const char *s = luaL_check_lstr(L, arg, &l); |
| @@ -610,7 +610,7 @@ static int str_format (lua_State *L) { | |||
| 610 | keep original string */ | 610 | keep original string */ |
| 611 | lua_pushvalue(L, arg); | 611 | lua_pushvalue(L, arg); |
| 612 | luaL_addvalue(&b); | 612 | luaL_addvalue(&b); |
| 613 | continue; /* skip the "addsize" at the end */ | 613 | continue; /* skip the `addsize' at the end */ |
| 614 | } | 614 | } |
| 615 | else { | 615 | else { |
| 616 | sprintf(buff, form, s); | 616 | sprintf(buff, form, s); |
