Merge: Revamp `Text::format`
authorJean Privat <jean@pryen.org>
Tue, 16 Feb 2016 19:52:37 +0000 (14:52 -0500)
committerJean Privat <jean@pryen.org>
Tue, 16 Feb 2016 19:52:37 +0000 (14:52 -0500)
commitbaad9ef9b02722e35632f04f44cdb6d205f98fc4
tree0313be8e9e9bb2ba9ff8d9775da46f10cfd09794
parentcd7b7bd997d9279e596fa777066c8003d407dc9c
parent0b4b90e326ae7dafd773f771288f82e6fcc5dc05
Merge: Revamp `Text::format`

Change the behavior of `Text::format` so it uses an index from 0 (instead of 1), and the escape sequence to a double percentage sign (ex, `%%4` to get `%4`). Also, now `format` ignores `%` that are not followed by a number.

There were problems with the previous escape sequence (using `\%`):
1. In literal strings, the `\` itself has to be escaped, so a whole escaped sequence look like `\\%4`.
2. The extra `\\` were not removed from the resulting string, so it was still impossible to produce a `%4` because `\\%4` resulted in `\\%4`.

These changes were prompted by an error in the code generated the i18n phase on a lone `%` not related to the `format` method. Also, the index beginning at 1 were always confusing to me, it was a different behavior than `Array` and other

@R4PaSs I would like your opinion on this.

Pull-Request: #1951
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>