diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-16 18:19:00 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-16 18:19:00 -0300 |
| commit | c2bb9abceceef125554595e23b7cc18ad3555c7c (patch) | |
| tree | 2c00262ddf0e4f8acc1db83bdee4a56bb2458117 /lstrlib.c | |
| parent | da32450c3d4c8abd3fd6709692859a12a8886511 (diff) | |
| download | lua-c2bb9abceceef125554595e23b7cc18ad3555c7c.tar.gz lua-c2bb9abceceef125554595e23b7cc18ad3555c7c.tar.bz2 lua-c2bb9abceceef125554595e23b7cc18ad3555c7c.zip | |
better quotes for strings in error messages
Diffstat (limited to 'lstrlib.c')
| -rw-r--r-- | lstrlib.c | 14 |
1 files changed, 6 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.112 2005/05/05 15:34:03 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.113 2005/05/16 19:21:11 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 | */ |
| @@ -200,14 +200,14 @@ static const char *classend (MatchState *ms, const char *p) { | |||
| 200 | switch (*p++) { | 200 | switch (*p++) { |
| 201 | case L_ESC: { | 201 | case L_ESC: { |
| 202 | if (*p == '\0') | 202 | if (*p == '\0') |
| 203 | luaL_error(ms->L, "malformed pattern (ends with `%%')"); | 203 | luaL_error(ms->L, "malformed pattern (ends with '%%')"); |
| 204 | return p+1; | 204 | return p+1; |
| 205 | } | 205 | } |
| 206 | case '[': { | 206 | case '[': { |
| 207 | if (*p == '^') p++; | 207 | if (*p == '^') p++; |
| 208 | do { /* look for a `]' */ | 208 | do { /* look for a `]' */ |
| 209 | if (*p == '\0') | 209 | if (*p == '\0') |
| 210 | luaL_error(ms->L, "malformed pattern (missing `]')"); | 210 | luaL_error(ms->L, "malformed pattern (missing ']')"); |
| 211 | if (*(p++) == L_ESC && *p != '\0') | 211 | if (*(p++) == L_ESC && *p != '\0') |
| 212 | p++; /* skip escapes (e.g. `%]') */ | 212 | p++; /* skip escapes (e.g. `%]') */ |
| 213 | } while (*p != ']'); | 213 | } while (*p != ']'); |
| @@ -382,7 +382,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
| 382 | const char *ep; char previous; | 382 | const char *ep; char previous; |
| 383 | p += 2; | 383 | p += 2; |
| 384 | if (*p != '[') | 384 | if (*p != '[') |
| 385 | luaL_error(ms->L, "missing `[' after `%%f' in pattern"); | 385 | luaL_error(ms->L, "missing '[' after '%%f' in pattern"); |
| 386 | ep = classend(ms, p); /* points to what is next */ | 386 | ep = classend(ms, p); /* points to what is next */ |
| 387 | previous = (s == ms->src_init) ? '\0' : *(s-1); | 387 | previous = (s == ms->src_init) ? '\0' : *(s-1); |
| 388 | if (matchbracketclass(uchar(previous), p, ep-1) || | 388 | if (matchbracketclass(uchar(previous), p, ep-1) || |
| @@ -705,8 +705,6 @@ static int str_format (lua_State *L) { | |||
| 705 | char form[MAX_FORMAT]; /* to store the format (`%...') */ | 705 | char form[MAX_FORMAT]; /* to store the format (`%...') */ |
| 706 | char buff[MAX_ITEM]; /* to store the formatted item */ | 706 | char buff[MAX_ITEM]; /* to store the formatted item */ |
| 707 | int hasprecision = 0; | 707 | int hasprecision = 0; |
| 708 | if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') | ||
| 709 | return luaL_error(L, "obsolete option (d$) to `format'"); | ||
| 710 | arg++; | 708 | arg++; |
| 711 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); | 709 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); |
| 712 | switch (*strfrmt++) { | 710 | switch (*strfrmt++) { |
| @@ -725,7 +723,7 @@ static int str_format (lua_State *L) { | |||
| 725 | } | 723 | } |
| 726 | case 'q': { | 724 | case 'q': { |
| 727 | addquoted(L, &b, arg); | 725 | addquoted(L, &b, arg); |
| 728 | continue; /* skip the `addsize' at the end */ | 726 | continue; /* skip the 'addsize' at the end */ |
| 729 | } | 727 | } |
| 730 | case 's': { | 728 | case 's': { |
| 731 | size_t l; | 729 | size_t l; |
| @@ -743,7 +741,7 @@ static int str_format (lua_State *L) { | |||
| 743 | } | 741 | } |
| 744 | } | 742 | } |
| 745 | default: { /* also treat cases `pnLlh' */ | 743 | default: { /* also treat cases `pnLlh' */ |
| 746 | return luaL_error(L, "invalid option to `format'"); | 744 | return luaL_error(L, "invalid option to " LUA_SM, "format"); |
| 747 | } | 745 | } |
| 748 | } | 746 | } |
| 749 | luaL_addlstring(&b, buff, strlen(buff)); | 747 | luaL_addlstring(&b, buff, strlen(buff)); |
