Differences From Artifact [676c6715db]:
- File utils/ofhttp/OFHTTP.m — part of check-in [9a43c41721] at 2016-08-28 10:12:29 on branch trunk — ofhttp: Add -f / --force to overwrite file (user: js, size: 20845) [annotate] [blame] [check-ins using]
To Artifact [3ef2bcb62b]:
- File
utils/ofhttp/OFHTTP.m
— part of check-in
[6dff0f5922]
at
2017-01-07 02:34:39
on branch trunk
— Always use "." for the decimal point
This is achieved by replacing the locale's decimal point with "." after
formatting and replacing "." with the locale's decimal point before
parsing.To still use the decimal point from the locale for formatting, the new
flag "," is introduced to formats. This is useful for just printing a
string to the user that is not saved to a file or sent via a network.While this is an ugly hack, there is no better way to do this other than
implementing the functionality of printf and strtod myself, as POSIX
does not specify versions of these that take a locale as an argument.
While this is a lot of work and error-prone, I will most likely end up
doing this eventually.This commit also enables the locale in OFApplication to notice when
things break. As a nice side effect, ofhttp now uses the locale's
decimal point in its user interface. (user: js, size: 20848) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
709 710 711 712 713 714 715 | if (!_quiet) { if (type == nil) type = @"unknown"; if (_length >= 0) { if (_resumedFrom + _length >= GIBIBYTE) lengthString = [OFString stringWithFormat: | | | | | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | if (!_quiet) { if (type == nil) type = @"unknown"; if (_length >= 0) { if (_resumedFrom + _length >= GIBIBYTE) lengthString = [OFString stringWithFormat: @"%,.2f GiB", (float)(_resumedFrom + _length) / GIBIBYTE]; else if (_resumedFrom + _length >= MEBIBYTE) lengthString = [OFString stringWithFormat: @"%,.2f MiB", (float)(_resumedFrom + _length) / MEBIBYTE]; else if (_resumedFrom + _length >= KIBIBYTE) lengthString = [OFString stringWithFormat: @"%,.2f KiB", (float)(_resumedFrom + _length) / KIBIBYTE]; else lengthString = [OFString stringWithFormat: @"%jd bytes", _resumedFrom + _length]; } else lengthString = @"unknown"; |
︙ | ︙ |