summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-11-30 11:40:13 -0500
committerKevin Newton <kddnewton@gmail.com>2023-11-30 21:37:56 -0500
commitea409958b38424f296aacc5c2d8d7bf3bcd1d2db (patch)
tree356114fc7c8e79459bee887cfcda830fe7d06c1c
parent997083188b8f7c2b058544a805a0dec83ea5483d (diff)
[ruby/prism] Remove ability to decode other encodings
https://github.com/ruby/prism/commit/98e218d989
-rw-r--r--prism/parser.h16
-rw-r--r--prism/prism.c27
-rw-r--r--prism/prism.h12
3 files changed, 1 insertions, 54 deletions
diff --git a/prism/parser.h b/prism/parser.h
index 424d150ebe..bfad39a1d9 100644
--- a/prism/parser.h
+++ b/prism/parser.h
@@ -422,14 +422,6 @@ typedef struct {
typedef void (*pm_encoding_changed_callback_t)(pm_parser_t *parser);
/**
- * When an encoding is encountered that isn't understood by prism, we provide
- * the ability here to call out to a user-defined function to get an encoding
- * struct. If the function returns something that isn't NULL, we set that to
- * our encoding and use it to parse identifiers.
- */
-typedef pm_encoding_t *(*pm_encoding_decode_callback_t)(pm_parser_t *parser, const uint8_t *name, size_t width);
-
-/**
* When you are lexing through a file, the lexer needs all of the information
* that the parser additionally provides (for example, the local table). So if
* you want to properly lex Ruby, you need to actually lex it in the context of
@@ -609,14 +601,6 @@ struct pm_parser {
pm_encoding_changed_callback_t encoding_changed_callback;
/**
- * When an encoding is encountered that isn't understood by prism, we
- * provide the ability here to call out to a user-defined function to get an
- * encoding struct. If the function returns something that isn't NULL, we
- * set that to our encoding and use it to parse identifiers.
- */
- pm_encoding_decode_callback_t encoding_decode_callback;
-
- /**
* This pointer indicates where a comment must start if it is to be
* considered an encoding comment.
*/
diff --git a/prism/prism.c b/prism/prism.c
index baab318b9a..effe3661c4 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -6155,19 +6155,7 @@ static bool
parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *start, const uint8_t *end) {
size_t width = (size_t) (end - start);
- // First, we're going to call out to a user-defined callback if one was
- // provided. If they return an encoding struct that we can use, then we'll
- // use that here.
- if (parser->encoding_decode_callback != NULL) {
- pm_encoding_t *encoding = parser->encoding_decode_callback(parser, start, width);
-
- if (encoding != NULL) {
- parser->encoding = *encoding;
- return true;
- }
- }
-
- // Next, we're going to check for UTF-8. This is the most common encoding.
+ // First, we're going to check for UTF-8. This is the most common encoding.
// utf-8 can contain extra information at the end about the platform it is
// encoded on, such as utf-8-mac or utf-8-unix. We'll ignore those suffixes.
if ((start + 5 <= end) && (pm_strncasecmp(start, (const uint8_t *) "utf-8", 5) == 0)) {
@@ -17039,7 +17027,6 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
.current_context = NULL,
.encoding = pm_encoding_utf_8,
.encoding_changed_callback = NULL,
- .encoding_decode_callback = NULL,
.encoding_comment_start = source,
.lex_callback = NULL,
.filepath_string = { 0 },
@@ -17155,18 +17142,6 @@ pm_parser_register_encoding_changed_callback(pm_parser_t *parser, pm_encoding_ch
}
/**
- * Register a callback that will be called when prism encounters a magic comment
- * with an encoding referenced that it doesn't understand. The callback should
- * return NULL if it also doesn't understand the encoding or it should return a
- * pointer to a pm_encoding_t struct that contains the functions necessary to
- * parse identifiers.
- */
-PRISM_EXPORTED_FUNCTION void
-pm_parser_register_encoding_decode_callback(pm_parser_t *parser, pm_encoding_decode_callback_t callback) {
- parser->encoding_decode_callback = callback;
-}
-
-/**
* Free all of the memory associated with the comment list.
*/
static inline void
diff --git a/prism/prism.h b/prism/prism.h
index 5eec5f49ec..ab5811f9ac 100644
--- a/prism/prism.h
+++ b/prism/prism.h
@@ -62,18 +62,6 @@ PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *
PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_changed_callback(pm_parser_t *parser, pm_encoding_changed_callback_t callback);
/**
- * Register a callback that will be called when prism encounters a magic comment
- * with an encoding referenced that it doesn't understand. The callback should
- * return NULL if it also doesn't understand the encoding or it should return a
- * pointer to a pm_encoding_t struct that contains the functions necessary to
- * parse identifiers.
- *
- * @param parser The parser to register the callback with.
- * @param callback The callback to register.
- */
-PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_decode_callback(pm_parser_t *parser, pm_encoding_decode_callback_t callback);
-
-/**
* Free any memory associated with the given parser.
*
* @param parser The parser to free.