Skip to content

Commit 18ce64d

Browse files
committed
re.c: Fix conflicting flags for RMatch
`RMATCH_OFFSETS_EXTERNAL` and `MATCH_BUSY` were both assigned to `FL_USER2`, which could have created weird bugs. Also add flag documentation for both RMatch and RRegexp.
1 parent a31b13e commit 18ce64d

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

re.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@
3232
#include "ruby/util.h"
3333
#include "ractor_core.h"
3434

35+
/* Flags of RRegexp
36+
*
37+
* 4: KCODE_FIXED
38+
* The regexp has "fixed encoding", meaning it can't be match against any ASCII-compatible string.
39+
* 6: REG_ENCODING_NONE
40+
* The regexp has no encoding. Means the `n` modifier was used.
41+
*/
42+
43+
#define KCODE_FIXED FL_USER4
44+
#define REG_ENCODING_NONE FL_USER6
45+
46+
/* Flags of RMatch
47+
*
48+
* 0: MATCH_BUSY
49+
* The match is currently in use or may have escaped and can no longer be recycled.
50+
* 1: RMATCH_ONIG
51+
* TBD.
52+
* 2: RMATCH_OFFSETS_EXTERNAL
53+
* The match layout isn't fully embedded, offsets are stored in an external buffer,
54+
* which will need to be freed during sweep.
55+
*/
56+
57+
#define MATCH_BUSY FL_USER0
58+
3559
VALUE rb_eRegexpError, rb_eRegexpTimeoutError;
3660

3761
typedef char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN];
@@ -285,10 +309,6 @@ rb_memsearch(const void *x0, long m, const void *y0, long n, rb_encoding *enc)
285309
return rb_memsearch_qs(x0, m, y0, n);
286310
}
287311

288-
#define REG_ENCODING_NONE FL_USER6
289-
290-
#define KCODE_FIXED FL_USER4
291-
292312
static int
293313
char_to_option(int c)
294314
{
@@ -1528,8 +1548,6 @@ match_nth_length(VALUE match, VALUE n)
15281548
return LONG2NUM(ofs->end - ofs->beg);
15291549
}
15301550

1531-
#define MATCH_BUSY FL_USER2
1532-
15331551
void
15341552
rb_match_busy(VALUE match)
15351553
{

0 commit comments

Comments
 (0)