[ruby/prism] Rename fgets parameter to fix NetBSD
Fixes [Bug #21165] https://github.com/ruby/prism/commit/3f0acf7560
This commit is contained in:
parent
c93f30ab67
commit
617e8608b2
@ -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) {
|
||||
pm_parse_stream_read(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *stream_fgets) {
|
||||
#define LINE_SIZE 4096
|
||||
char line[LINE_SIZE];
|
||||
|
||||
while (memset(line, '\n', LINE_SIZE), fgets(line, LINE_SIZE, stream) != NULL) {
|
||||
while (memset(line, '\n', LINE_SIZE), stream_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 streaming 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_parse_stream(pm_parser_t *parser, pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *stream_fgets, const pm_options_t *options) {
|
||||
pm_buffer_init(buffer);
|
||||
|
||||
bool eof = pm_parse_stream_read(buffer, stream, fgets);
|
||||
bool eof = pm_parse_stream_read(buffer, stream, 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);
|
||||
eof = pm_parse_stream_read(buffer, stream, 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_serialize_parse_stream(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *stream_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_node_t *node = pm_parse_stream(&parser, &parser_buffer, stream, 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 stream_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);
|
||||
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t *parser, pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *stream_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 stream_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);
|
||||
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *stream_fgets, const char *data);
|
||||
|
||||
/**
|
||||
* Serialize the given list of comments to the given buffer.
|
||||
|
Loading…
x
Reference in New Issue
Block a user