diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-25 09:50:46 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-25 09:50:46 -0200 |
| commit | bdf566a8a32450c2eb6273c8c1a92e2181b6846e (patch) | |
| tree | b301da541fbad81034216a6e0465cc381082431e /lstrlib.c | |
| parent | c3c78030f79fdbbb06265d50645e408d60e7798e (diff) | |
| download | lua-bdf566a8a32450c2eb6273c8c1a92e2181b6846e.tar.gz lua-bdf566a8a32450c2eb6273c8c1a92e2181b6846e.tar.bz2 lua-bdf566a8a32450c2eb6273c8c1a92e2181b6846e.zip | |
`name' in comments changed to 'name'
Diffstat (limited to 'lstrlib.c')
| -rw-r--r-- | lstrlib.c | 26 |
1 files changed, 13 insertions, 13 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.205 2014/10/20 16:44:54 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.206 2014/10/24 11:42:29 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 | */ |
| @@ -30,7 +30,7 @@ | |||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | /* macro to `unsign' a character */ | 33 | /* macro to 'unsign' a character */ |
| 34 | #define uchar(c) ((unsigned char)(c)) | 34 | #define uchar(c) ((unsigned char)(c)) |
| 35 | 35 | ||
| 36 | 36 | ||
| @@ -255,11 +255,11 @@ static const char *classend (MatchState *ms, const char *p) { | |||
| 255 | } | 255 | } |
| 256 | case '[': { | 256 | case '[': { |
| 257 | if (*p == '^') p++; | 257 | if (*p == '^') p++; |
| 258 | do { /* look for a `]' */ | 258 | do { /* look for a ']' */ |
| 259 | if (p == ms->p_end) | 259 | if (p == ms->p_end) |
| 260 | luaL_error(ms->L, "malformed pattern (missing ']')"); | 260 | luaL_error(ms->L, "malformed pattern (missing ']')"); |
| 261 | if (*(p++) == L_ESC && p < ms->p_end) | 261 | if (*(p++) == L_ESC && p < ms->p_end) |
| 262 | p++; /* skip escapes (e.g. `%]') */ | 262 | p++; /* skip escapes (e.g. '%]') */ |
| 263 | } while (*p != ']'); | 263 | } while (*p != ']'); |
| 264 | return p+1; | 264 | return p+1; |
| 265 | } | 265 | } |
| @@ -294,7 +294,7 @@ static int matchbracketclass (int c, const char *p, const char *ec) { | |||
| 294 | int sig = 1; | 294 | int sig = 1; |
| 295 | if (*(p+1) == '^') { | 295 | if (*(p+1) == '^') { |
| 296 | sig = 0; | 296 | sig = 0; |
| 297 | p++; /* skip the `^' */ | 297 | p++; /* skip the '^' */ |
| 298 | } | 298 | } |
| 299 | while (++p < ec) { | 299 | while (++p < ec) { |
| 300 | if (*p == L_ESC) { | 300 | if (*p == L_ESC) { |
| @@ -431,7 +431,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
| 431 | break; | 431 | break; |
| 432 | } | 432 | } |
| 433 | case '$': { | 433 | case '$': { |
| 434 | if ((p + 1) != ms->p_end) /* is the `$' the last char in pattern? */ | 434 | if ((p + 1) != ms->p_end) /* is the '$' the last char in pattern? */ |
| 435 | goto dflt; /* no; go to default */ | 435 | goto dflt; /* no; go to default */ |
| 436 | s = (s == ms->src_end) ? s : NULL; /* check end of string */ | 436 | s = (s == ms->src_end) ? s : NULL; /* check end of string */ |
| 437 | break; | 437 | break; |
| @@ -519,16 +519,16 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
| 519 | static const char *lmemfind (const char *s1, size_t l1, | 519 | static const char *lmemfind (const char *s1, size_t l1, |
| 520 | const char *s2, size_t l2) { | 520 | const char *s2, size_t l2) { |
| 521 | if (l2 == 0) return s1; /* empty strings are everywhere */ | 521 | if (l2 == 0) return s1; /* empty strings are everywhere */ |
| 522 | else if (l2 > l1) return NULL; /* avoids a negative `l1' */ | 522 | else if (l2 > l1) return NULL; /* avoids a negative 'l1' */ |
| 523 | else { | 523 | else { |
| 524 | const char *init; /* to search for a `*s2' inside `s1' */ | 524 | const char *init; /* to search for a '*s2' inside 's1' */ |
| 525 | l2--; /* 1st char will be checked by `memchr' */ | 525 | l2--; /* 1st char will be checked by 'memchr' */ |
| 526 | l1 = l1-l2; /* `s2' cannot be found after that */ | 526 | l1 = l1-l2; /* 's2' cannot be found after that */ |
| 527 | while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { | 527 | while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { |
| 528 | init++; /* 1st char is already checked */ | 528 | init++; /* 1st char is already checked */ |
| 529 | if (memcmp(init, s2+1, l2) == 0) | 529 | if (memcmp(init, s2+1, l2) == 0) |
| 530 | return init-1; | 530 | return init-1; |
| 531 | else { /* correct `l1' and `s1' to try again */ | 531 | else { /* correct 'l1' and 's1' to try again */ |
| 532 | l1 -= init-s1; | 532 | l1 -= init-s1; |
| 533 | s1 = init; | 533 | s1 = init; |
| 534 | } | 534 | } |
| @@ -879,7 +879,7 @@ static int str_format (lua_State *L) { | |||
| 879 | else if (*++strfrmt == L_ESC) | 879 | else if (*++strfrmt == L_ESC) |
| 880 | luaL_addchar(&b, *strfrmt++); /* %% */ | 880 | luaL_addchar(&b, *strfrmt++); /* %% */ |
| 881 | else { /* format item */ | 881 | else { /* format item */ |
| 882 | char form[MAX_FORMAT]; /* to store the format (`%...') */ | 882 | char form[MAX_FORMAT]; /* to store the format ('%...') */ |
| 883 | char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ | 883 | char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ |
| 884 | int nb = 0; /* number of bytes in added item */ | 884 | int nb = 0; /* number of bytes in added item */ |
| 885 | if (++arg > top) | 885 | if (++arg > top) |
| @@ -925,7 +925,7 @@ static int str_format (lua_State *L) { | |||
| 925 | break; | 925 | break; |
| 926 | } | 926 | } |
| 927 | } | 927 | } |
| 928 | default: { /* also treat cases `pnLlh' */ | 928 | default: { /* also treat cases 'pnLlh' */ |
| 929 | return luaL_error(L, "invalid option '%%%c' to 'format'", | 929 | return luaL_error(L, "invalid option '%%%c' to 'format'", |
| 930 | *(strfrmt - 1)); | 930 | *(strfrmt - 1)); |
| 931 | } | 931 | } |
