8000 Fix linting line end · ruby/ruby@b3b63de · GitHub
[go: up one dir, main page]

Skip to content

Commit b3b63de

Browse files
committed
Fix linting line end
str is an array, but *str points to its beginning, that does not make sense and will never be true. Fixes: 989a6f1 ("ruby.c: simplify")
1 parent 475663f commit b3b63de

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ruby.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,9 +2562,16 @@ load_file_internal(VALUE argp_v)
25622562
}
25632563

25642564
start_read:
2565-
str += len - 1;
2566-
if (*str == '\n') *str-- = '\0';
2567-
if (*str == '\r') *str-- = '\0';
2565+
if (str[len-1] == '\n') {
2566+
str[len-1] = '\0';
2567+
}
2568+
if (str[len-1] == '\r') {
2569+
str[len-1] = '\0';
2570+
}
2571+
if (str[len-1] != '\0') {
2572+
str += len - 1;
2573+
str[len-1] = '\0';
2574+
}
25682575
/* ruby_engine should not contain a space */
25692576
if ((p = strstr(p, " -")) != 0) {
25702577
opt->warning = 0;

0 commit comments

Comments
 (0)
0