aboutsummaryrefslogtreecommitdiffstats
path: root/prism
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-11-30 20:59:00 -0500
committerKevin Newton <kddnewton@gmail.com>2023-11-30 21:37:56 -0500
commite2bbbacc233b1b1c13298baff9eacfe1ef0052f4 (patch)
treec3d5f5e7f96041acc8e483479996a29e1157b4d2 /prism
parentb4a85e402f0f4d33a3dd3eb58b6312207549d415 (diff)
downloadruby-e2bbbacc233b1b1c13298baff9eacfe1ef0052f4.tar.gz
[ruby/prism] Correctly pass around const pm_encoding_t *
https://github.com/ruby/prism/commit/ce4c67fb3a
Diffstat (limited to 'prism')
-rw-r--r--prism/extension.c2
-rw-r--r--prism/regexp.c6
-rw-r--r--prism/regexp.h2
-rw-r--r--prism/util/pm_memchr.c2
-rw-r--r--prism/util/pm_memchr.h2
5 files changed, 7 insertions, 7 deletions
diff --git a/prism/extension.c b/prism/extension.c
index c3ee58d15e..cf3f62f6e6 100644
--- a/prism/extension.c
+++ b/prism/extension.c
@@ -814,7 +814,7 @@ static VALUE
named_captures(VALUE self, VALUE source) {
pm_string_list_t string_list = { 0 };
- if (!pm_regexp_named_capture_group_names((const uint8_t *) RSTRING_PTR(source), RSTRING_LEN(source), &string_list, false, &pm_encoding_utf_8)) {
+ if (!pm_regexp_named_capture_group_names((const uint8_t *) RSTRING_PTR(source), RSTRING_LEN(source), &string_list, false, pm_encoding_utf_8)) {
pm_string_list_free(&string_list);
return Qnil;
}
diff --git a/prism/regexp.c b/prism/regexp.c
index cd52857f79..ba498ecc83 100644
--- a/prism/regexp.c
+++ b/prism/regexp.c
@@ -20,14 +20,14 @@ typedef struct {
bool encoding_changed;
/** The encoding of the source. */
- pm_encoding_t *encoding;
+ const pm_encoding_t *encoding;
} pm_regexp_parser_t;
/**
* This initializes a new parser with the given source.
*/
static void
-pm_regexp_parser_init(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding) {
+pm_regexp_parser_init(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding) {
*parser = (pm_regexp_parser_t) {
.start = start,
.cursor = start,
@@ -631,7 +631,7 @@ pm_regexp_parse_pattern(pm_regexp_parser_t *parser) {
* groups.
*/
PRISM_EXPORTED_FUNCTION bool
-pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding) {
+pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding) {
pm_regexp_parser_t parser;
pm_regexp_parser_init(&parser, source, source + size, named_captures, encoding_changed, encoding);
return pm_regexp_parse_pattern(&parser);
diff --git a/prism/regexp.h b/prism/regexp.h
index f969eb45d4..c5ceab11f9 100644
--- a/prism/regexp.h
+++ b/prism/regexp.h
@@ -28,6 +28,6 @@
* @param encoding The encoding of the source code.
* @return Whether or not the parsing was successful.
*/
-PRISM_EXPORTED_FUNCTION bool pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding);
+PRISM_EXPORTED_FUNCTION bool pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding);
#endif
diff --git a/prism/util/pm_memchr.c b/prism/util/pm_memchr.c
index b2049250e4..7ea20ace6d 100644
--- a/prism/util/pm_memchr.c
+++ b/prism/util/pm_memchr.c
@@ -8,7 +8,7 @@
* of a multibyte character.
*/
void *
-pm_memchr(const void *memory, int character, size_t number, bool encoding_changed, pm_encoding_t *encoding) {
+pm_memchr(const void *memory, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding) {
if (encoding_changed && encoding->multibyte && character >= PRISM_MEMCHR_TRAILING_BYTE_MINIMUM) {
const uint8_t *source = (const uint8_t *) memory;
size_t index = 0;
diff --git a/prism/util/pm_memchr.h b/prism/util/pm_memchr.h
index fd5879a201..e0671eaed3 100644
--- a/prism/util/pm_memchr.h
+++ b/prism/util/pm_memchr.h
@@ -24,6 +24,6 @@
* @return A pointer to the first occurrence of the character in the source
* string, or NULL if no such character exists.
*/
-void * pm_memchr(const void *source, int character, size_t number, bool encoding_changed, pm_encoding_t *encoding);
+void * pm_memchr(const void *source, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding);
#endif