diff options
author | Kevin Newton <[email protected]> | 2025-03-02 10:53:04 -0500 |
---|---|---|
committer | git <[email protected]> | 2025-03-02 18:14:36 +0000 |
commit | 617e8608b2cff8be1d063c2f47ab425cda839d58 () | |
tree | f829023322db8d431edea64b297d658ff124046f | |
parent | c93f30ab67a37276d6cc50ec33186fd55f62c0a3 (diff) |
[ruby/prism] Rename fgets parameter to fix NetBSD
Fixes [Bug #21165] https://.com/ruby/prism/commit/3f0acf7560
-rw-r--r-- | prism/prism.c | 14 | ||||
-rw-r--r-- | prism/prism.h | 8 |
2 files changed, 11 insertions, 11 deletions
@@ -22769,11 +22769,11 @@ pm_parse(pm_parser_t *parser) { * otherwise return true. */ static bool -pm_parse_stream_read(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets) { #define LINE_SIZE 4096 char line[LINE_SIZE]; - while (memset(line, '\n', LINE_SIZE), fgets(line, LINE_SIZE, stream) != NULL) { size_t length = LINE_SIZE; while (length > 0 && line[length - 1] == '\n') length--; @@ -22840,16 +22840,16 @@ pm_parse_stream_unterminated_heredoc_p(pm_parser_t *parser) { * can stream stdin in to Ruby so we need to support a API. */ PRISM_EXPORTED_FUNCTION pm_node_t * -pm_parse_stream(pm_parser_t *parser, pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets, const pm_options_t *options) { pm_buffer_init(buffer); - bool eof = pm_parse_stream_read(buffer, stream, fgets); pm_parser_init(parser, (const uint8_t *) pm_buffer_value(buffer), pm_buffer_length(buffer), options); pm_node_t *node = pm_parse(parser); while (!eof && parser->error_list.size > 0 && (parser->lex_modes.index > 0 || pm_parse_stream_unterminated_heredoc_p(parser))) { pm_node_destroy(parser, node); - eof = pm_parse_stream_read(buffer, stream, fgets); pm_parser_free(parser); pm_parser_init(parser, (const uint8_t *) pm_buffer_value(buffer), pm_buffer_length(buffer), options); @@ -22941,13 +22941,13 @@ pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, cons * given stream into to the given buffer. */ PRISM_EXPORTED_FUNCTION void -pm_serialize_parse_stream(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets, const char *data) { pm_parser_t parser; pm_options_t options = { 0 }; pm_options_read(&options, data); pm_buffer_t parser_buffer; - pm_node_t *node = pm_parse_stream(&parser, &parser_buffer, stream, fgets, &options); pm_serialize_header(buffer); pm_serialize_content(&parser, node, buffer); pm_buffer_append_byte(buffer, '\0'); @@ -93,11 +93,11 @@ typedef char * (pm_parse_stream_fgets_t)(char *string, int size, void *stream); * @param parser The parser to use. * @param buffer The buffer to use. * @param stream The stream to parse. - * @param fgets The function to use to read from the stream. * @param options The optional options to use when parsing. * @return The AST representing the source. */ -PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t *parser, pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets, const pm_options_t *options); // We optionally support serializing to a binary string. For systems that don't // want or need this functionality, it can be turned off with the @@ -110,10 +110,10 @@ PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t *parser, pm_buff * * @param buffer The buffer to serialize to. * @param stream The stream to parse. - * @param fgets The function to use to read from the stream. * @param data The optional data to pass to the parser. */ -PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets, const char *data); /** * Serialize the given list of comments to the given buffer. |