diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-28 10:33:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-28 10:33:53 -0300 |
commit | 460a35cbcb33fbc56f5a658b96a793b9bb8963e9 (patch) | |
tree | 138df91e9dec0544b64bad3334d01ca38d2b7408 /lpvm.c | |
parent | 503126fec29117e31d633b81203f887b99040c4a (diff) | |
download | lpeg-460a35cbcb33fbc56f5a658b96a793b9bb8963e9.tar.gz lpeg-460a35cbcb33fbc56f5a658b96a793b9bb8963e9.tar.bz2 lpeg-460a35cbcb33fbc56f5a658b96a793b9bb8963e9.zip |
New type name 'uint' (unsigned int)
Diffstat (limited to 'lpvm.c')
-rw-r--r-- | lpvm.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -23,10 +23,10 @@ | |||
23 | static const Instruction giveup = {{IGiveup, 0, {0}}}; | 23 | static const Instruction giveup = {{IGiveup, 0, {0}}}; |
24 | 24 | ||
25 | 25 | ||
26 | int charinset (const Instruction *i, const byte *buff, unsigned int c) { | 26 | int charinset (const Instruction *i, const byte *buff, uint c) { |
27 | c -= i->i.aux2.set.offset; | 27 | c -= i->i.aux2.set.offset; |
28 | if (c >= ((unsigned int)i->i.aux2.set.size /* size in instructions... */ | 28 | if (c >= ((uint)i->i.aux2.set.size /* size in instructions... */ |
29 | * (unsigned int)sizeof(Instruction) /* in bytes... */ | 29 | * (uint)sizeof(Instruction) /* in bytes... */ |
30 | * 8u)) /* in bits */ | 30 | * 8u)) /* in bits */ |
31 | return i->i.aux1; /* out of range; return default value */ | 31 | return i->i.aux1; /* out of range; return default value */ |
32 | return testchar(buff, c); | 32 | return testchar(buff, c); |
@@ -37,10 +37,10 @@ int charinset (const Instruction *i, const byte *buff, unsigned int c) { | |||
37 | ** Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. | 37 | ** Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. |
38 | */ | 38 | */ |
39 | static const char *utf8_decode (const char *o, int *val) { | 39 | static const char *utf8_decode (const char *o, int *val) { |
40 | static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFFu}; | 40 | static const uint limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFFu}; |
41 | const unsigned char *s = (const unsigned char *)o; | 41 | const unsigned char *s = (const unsigned char *)o; |
42 | unsigned int c = s[0]; /* first byte */ | 42 | uint c = s[0]; /* first byte */ |
43 | unsigned int res = 0; /* final result */ | 43 | uint res = 0; /* final result */ |
44 | if (c < 0x80) /* ascii? */ | 44 | if (c < 0x80) /* ascii? */ |
45 | res = c; | 45 | res = c; |
46 | else { | 46 | else { |
@@ -99,7 +99,7 @@ static Capture *growcap (lua_State *L, Capture *capture, int *capsize, | |||
99 | return capture; /* no need to grow array */ | 99 | return capture; /* no need to grow array */ |
100 | else { /* must grow */ | 100 | else { /* must grow */ |
101 | Capture *newc; | 101 | Capture *newc; |
102 | unsigned int newsize = captop + n + 1; /* minimum size needed */ | 102 | uint newsize = captop + n + 1; /* minimum size needed */ |
103 | if (newsize < (MAXNEWSIZE / 3) * 2) | 103 | if (newsize < (MAXNEWSIZE / 3) * 2) |
104 | newsize += newsize / 2; /* 1.5 that size, if not too big */ | 104 | newsize += newsize / 2; /* 1.5 that size, if not too big */ |
105 | else if (newsize < (MAXNEWSIZE / 9) * 8) | 105 | else if (newsize < (MAXNEWSIZE / 9) * 8) |
@@ -269,14 +269,14 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e, | |||
269 | continue; | 269 | continue; |
270 | } | 270 | } |
271 | case ISet: { | 271 | case ISet: { |
272 | unsigned int c = (byte)*s; | 272 | uint c = (byte)*s; |
273 | if (charinset(p, (p+1)->buff, c) && s < e) | 273 | if (charinset(p, (p+1)->buff, c) && s < e) |
274 | { p += 1 + p->i.aux2.set.size; s++; } | 274 | { p += 1 + p->i.aux2.set.size; s++; } |
275 | else goto fail; | 275 | else goto fail; |
276 | continue; | 276 | continue; |
277 | } | 277 | } |
278 | case ITestSet: { | 278 | case ITestSet: { |
279 | unsigned int c = (byte)*s; | 279 | uint c = (byte)*s; |
280 | if (charinset(p, (p + 2)->buff, c) && s < e) | 280 | if (charinset(p, (p + 2)->buff, c) && s < e) |
281 | p += 2 + p->i.aux2.set.size; | 281 | p += 2 + p->i.aux2.set.size; |
282 | else p += getoffset(p); | 282 | else p += getoffset(p); |
@@ -290,7 +290,7 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e, | |||
290 | } | 290 | } |
291 | case ISpan: { | 291 | case ISpan: { |
292 | for (; s < e; s++) { | 292 | for (; s < e; s++) { |
293 | unsigned int c = (byte)*s; | 293 | uint c = (byte)*s; |
294 | if (!charinset(p, (p+1)->buff, c)) break; | 294 | if (!charinset(p, (p+1)->buff, c)) break; |
295 | } | 295 | } |
296 | p += 1 + p->i.aux2.set.size; | 296 | p += 1 + p->i.aux2.set.size; |