diff options
| author | Andre Murbach Maidl <andremm@gmail.com> | 2015-10-15 23:21:49 -0300 |
|---|---|---|
| committer | Andre Murbach Maidl <andremm@gmail.com> | 2015-10-15 23:21:49 -0300 |
| commit | e52350f421ef0d9c8dbe1736623ee0cc58a70eea (patch) | |
| tree | 5def891e9ae1f56106f6dff00868b7d013a11887 | |
| parent | be06a4b58518a54143f6e219edf32a51021e55c6 (diff) | |
| download | lpeglabel-e52350f421ef0d9c8dbe1736623ee0cc58a70eea.tar.gz lpeglabel-e52350f421ef0d9c8dbe1736623ee0cc58a70eea.tar.bz2 lpeglabel-e52350f421ef0d9c8dbe1736623ee0cc58a70eea.zip | |
Increasing MAXLABELS from 32 to 64
| -rw-r--r-- | lptree.c | 14 | ||||
| -rw-r--r-- | lptypes.h | 6 |
2 files changed, 10 insertions, 10 deletions
| @@ -706,8 +706,8 @@ static int lp_throw (lua_State *L) { | |||
| 706 | Labelset ls = 0; | 706 | Labelset ls = 0; |
| 707 | int i; | 707 | int i; |
| 708 | for (i = 1; i <= n; i++) { | 708 | for (i = 1; i <= n; i++) { |
| 709 | int d = (int)luaL_checkinteger(L, i); | 709 | long long int d = (long long int)luaL_checkinteger(L, i); |
| 710 | luaL_argcheck(L, d >= 0 && d < (int)MAXLABELS, i, "invalid label index"); | 710 | luaL_argcheck(L, d >= 0 && d < (long long int)MAXLABELS, i, "invalid label index"); |
| 711 | setlabel(ls, d); | 711 | setlabel(ls, d); |
| 712 | } | 712 | } |
| 713 | newlabelleaf(L, ls); | 713 | newlabelleaf(L, ls); |
| @@ -723,8 +723,8 @@ static int lp_labchoice (lua_State *L) { | |||
| 723 | int i; | 723 | int i; |
| 724 | Labelset ls = 0; | 724 | Labelset ls = 0; |
| 725 | for (i = 3; i <= n; i++) { | 725 | for (i = 3; i <= n; i++) { |
| 726 | int d = (int)luaL_checkinteger(L, i); | 726 | long long int d = (long long int)luaL_checkinteger(L, i); |
| 727 | luaL_argcheck(L, d >= 0 && d < (int)MAXLABELS, i, "invalid label index"); | 727 | luaL_argcheck(L, d >= 0 && d < (long long int)MAXLABELS, i, "invalid label index"); |
| 728 | setlabel(ls, d); | 728 | setlabel(ls, d); |
| 729 | } | 729 | } |
| 730 | tree = newroot2sib(L, TLabChoice); | 730 | tree = newroot2sib(L, TLabChoice); |
| @@ -1205,11 +1205,11 @@ static int lp_match (lua_State *L) { | |||
| 1205 | r = match(L, s, s + i, s + l, code, capture, ptop, &labelf, &sfail); /* labeled failure */ | 1205 | r = match(L, s, s + i, s + l, code, capture, ptop, &labelf, &sfail); /* labeled failure */ |
| 1206 | /*printf("sfail = %s\n", sfail);*/ | 1206 | /*printf("sfail = %s\n", sfail);*/ |
| 1207 | if (r == NULL) { /* labeled failure begin */ | 1207 | if (r == NULL) { /* labeled failure begin */ |
| 1208 | int j = 0; | 1208 | long long int j = 0; |
| 1209 | int n = 1; | 1209 | int n = 1; |
| 1210 | lua_pushnil(L); | 1210 | lua_pushnil(L); |
| 1211 | while (j < (int) MAXLABELS) { | 1211 | while (j < (long long int) MAXLABELS) { |
| 1212 | if (labelf & (1 << j)) { | 1212 | if (labelf & (1ULL << j)) { |
| 1213 | lua_pushinteger(L, j); | 1213 | lua_pushinteger(L, j); |
| 1214 | n++; | 1214 | n++; |
| 1215 | break; /* Changing the semantics: only one label */ | 1215 | break; /* Changing the semantics: only one label */ |
| @@ -111,14 +111,14 @@ typedef struct Charset { | |||
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | /* labeled failure begin */ | 113 | /* labeled failure begin */ |
| 114 | typedef int Labelset; | 114 | typedef long long int Labelset; |
| 115 | 115 | ||
| 116 | #define MAXLABELS (sizeof(int) * 8) | 116 | #define MAXLABELS (sizeof(long long int) * 8) |
| 117 | 117 | ||
| 118 | #define LFAIL 1 | 118 | #define LFAIL 1 |
| 119 | 119 | ||
| 120 | /* set bit 'b' in set 's' */ | 120 | /* set bit 'b' in set 's' */ |
| 121 | #define setlabel(s, b) ((s) |= (1 << (b))) | 121 | #define setlabel(s, b) ((s) |= (1ULL << (b))) |
| 122 | /* labeled failure end */ | 122 | /* labeled failure end */ |
| 123 | 123 | ||
| 124 | 124 | ||
