Skip to content

Commit

Permalink
Extract end_with_newline_p
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Dec 1, 2023
1 parent baf2508 commit 573ee84
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ parse_isxdigit(int c)
#undef ISXDIGIT
#define ISXDIGIT(c) parse_isxdigit(c)

static inline bool
end_with_newline_p(VALUE str)
{
return RSTRING_LEN(str) > 0 && RSTRING_END(str)[-1] == '\n';
}

#include "parser_st.h"

#undef STRCASECMP
Expand Down Expand Up @@ -15965,7 +15971,7 @@ rb_parser_printf(struct parser_params *p, const char *fmt, ...)
va_start(ap, fmt);
rb_str_vcatf(mesg, fmt, ap);
va_end(ap);
if (RSTRING_END(mesg)[-1] == '\n') {
if (end_with_newline_p(mesg)) {
rb_io_write(p->debug_output, mesg);
p->debug_buffer = Qnil;
}
Expand Down

0 comments on commit 573ee84

Please sign in to comment.