Skip to content

Commit 9285091

Browse files
committed
Add braces to if/else and comment to empty capture early return in integer_at
1 parent e4c6a1e commit 9285091

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

ext/strscan/strscan.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,12 +1949,14 @@ parse_decimal_fast(const char *ptr, long len)
19491949
}
19501950
if (!overflow) {
19511951
if (negative) {
1952-
if (result == limit)
1952+
if (result == limit) {
19531953
return LONG2NUM(LONG_MIN);
1954+
}
19541955
return LONG2NUM(-(long)result);
19551956
}
1956-
else
1957+
else {
19571958
return LONG2NUM((long)result);
1959+
}
19581960
}
19591961
}
19601962
}
@@ -2012,7 +2014,7 @@ strscan_integer_at(int argc, VALUE *argv, VALUE self)
20122014
end = adjust_register_position(p, p->regs.end[i]);
20132015
len = end - beg;
20142016

2015-
if (len <= 0) return INT2FIX(0);
2017+
if (len <= 0) return INT2FIX(0); /* empty capture: String#to_i("") == 0 */
20162018

20172019
ptr = S_PBEG(p) + beg;
20182020

0 commit comments

Comments
 (0)