[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature proposal: \x## notation in strings
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 11 Mar 2009 12:54:01 +0200
On Wed, Mar 11, 2009 at 12:45 PM, Paul Hudson <phudson@pobox.com> wrote:
> I think it should be exactly two hex digits.
Which makes the implementation very straightforward, just 17 extra lines:
llex.c, at line 297 in read_string() after case 'v':
case 'x': { /*xXX hex escape */
int i,cu;
c = 0;
next(ls);
for (i = 0; i < 2; i++) {
cu = toupper(ls->current);
if (!isxdigit(cu))
luaX_lexerror(ls, "hex escape too short", TK_STRING);
if (isdigit(cu))
c = 16*c + (cu-'0');
else
c = 16*c + (cu-'A'+10);
next(ls);
}
save(ls,c);
continue;
} break;
Whereas the code for a decimal escape further down is somewhat ambiguous:
int i = 0;
c = 0;
do {
c = 10*c + (ls->current-'0');
next(ls);
} while (++i<3 && isdigit(ls->current));
i.e. it can be cut short, which allows for \0 but also for \23.
steve d.
- References:
- Feature proposal: \x## notation in strings, Ico
- Re: Feature proposal: \x## notation in strings, Peter Cawley
- Re: Feature proposal: \x## notation in strings, David Given
- Re: Feature proposal: \x## notation in strings, Eike Decker
- Re: Feature proposal: \x## notation in strings, David Given
- Re: Feature proposal: \x## notation in strings, Philippe Lhoste
- Re: Feature proposal: \x## notation in strings, Roberto Ierusalimschy
- Re: Feature proposal: \x## notation in strings, Philippe Lhoste
- Re: Feature proposal: \x## notation in strings, Enrico Colombini
- RE: Feature proposal: \x## notation in strings, Paul Hudson