Make "%u" an alias of "%d" on 1.9 #2265
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix the last remaining failing RubySpec for
String#%
by turning the%u
format into an alias of%d
.In the process of implementing this, I found out that in both 1.8 and 1.9 mode, certain format strings such as
%024.30d
(zero padding + fixed width + precision) were ignoring the precision specifier, producing strings that had fewer padding zeros than on MRI.This was because the "fast, common case" branch in
IntegerAtom
was being executed even when the format string had a precision, even though the special optimised method that was later invoked only took the width into account. This was fixed by making sure the optimised branch isn't executed when a precision is given.This pull request also contains a commit adding a RubySpec for the aforementioned behaviour of
%d
(and, consequently,%u
under 1.9).