mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
15ee9c7c1b
commit
26a05c4217
3 changed files with 12 additions and 3 deletions
|
@ -23,6 +23,15 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
// PRISM_ATTRIBUTE_FORMAT
|
||||
#if defined(__GNUC__)
|
||||
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(printf, string_index, argument_index)))
|
||||
#elif defined(__clang__)
|
||||
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((__format__(__printf__, string_index, argument_index)))
|
||||
#else
|
||||
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index)
|
||||
#endif
|
||||
|
||||
// PRISM_ATTRIBUTE_UNUSED
|
||||
#if defined(__GNUC__)
|
||||
# define PRISM_ATTRIBUTE_UNUSED __attribute__((unused))
|
||||
|
|
|
@ -39,7 +39,7 @@ static inline void
|
|||
prettyprint_location(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_location_t *location) {
|
||||
pm_line_column_t start = pm_newline_list_line_column(&parser->newline_list, location->start);
|
||||
pm_line_column_t end = pm_newline_list_line_column(&parser->newline_list, location->end);
|
||||
pm_buffer_append_format(output_buffer, "(%d,%d)-(%d,%d)", start.line + 1, start.column, end.line + 1, end.column);
|
||||
pm_buffer_append_format(output_buffer, "(%lu,%lu)-(%lu,%lu)", (unsigned long) (start.line + 1), (unsigned long) start.column, (unsigned long) (end.line + 1), (unsigned long) end.column);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -95,7 +95,7 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|||
prettyprint_source(output_buffer, pm_string_source(&cast-><%= field.name %>), pm_string_length(&cast-><%= field.name %>));
|
||||
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
||||
<%- when Prism::NodeListField -%>
|
||||
pm_buffer_append_format(output_buffer, " (length: %d)\n", cast-><%= field.name %>.size);
|
||||
pm_buffer_append_format(output_buffer, " (length: %lu)\n", (unsigned long) (cast-><%= field.name %>.size));
|
||||
|
||||
size_t last_index = cast-><%= field.name %>.size;
|
||||
for (uint32_t index = 0; index < last_index; index++) {
|
||||
|
|
|
@ -37,7 +37,7 @@ PRISM_EXPORTED_FUNCTION size_t pm_buffer_length(pm_buffer_t *buffer);
|
|||
void pm_buffer_append_zeroes(pm_buffer_t *buffer, size_t length);
|
||||
|
||||
// Append a formatted string to the buffer.
|
||||
void pm_buffer_append_format(pm_buffer_t *buffer, const char *format, ...);
|
||||
void pm_buffer_append_format(pm_buffer_t *buffer, const char *format, ...) PRISM_ATTRIBUTE_FORMAT(2, 3);
|
||||
|
||||
// Append a string to the buffer.
|
||||
void pm_buffer_append_string(pm_buffer_t *buffer, const char *value, size_t length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue