Differences From Artifact [cd4f1dfd47]:
- File
tests/OFStringTests.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: 29298) [annotate] [blame] [check-ins using]
To Artifact [e6c617fc86]:
- File
tests/OFStringTests.m
— part of check-in
[0ad678f125]
at
2017-01-07 03:26:50
on branch trunk
— Use strtof_l, strtod_l and asprintf_l if available
This avoids the hacks introduced in the previous commit, if those
functions are available. (user: js, size: 29764) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
523 524 525 526 527 528 529 530 531 | EXPECT_EXCEPTION(@"Detect invalid chars in -[hexadecimalValue] #4", OFInvalidFormatException, [@"$ " hexadecimalValue]) EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #1", OFInvalidFormatException, [@"0.0a" floatValue]) EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #2", OFInvalidFormatException, [@"0 0" floatValue]) EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #1", | > > > > > > > > | | > > > > > > > > | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | EXPECT_EXCEPTION(@"Detect invalid chars in -[hexadecimalValue] #4", OFInvalidFormatException, [@"$ " hexadecimalValue]) EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #1", OFInvalidFormatException, [@"0.0a" floatValue]) EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #2", OFInvalidFormatException, [@"0 0" floatValue]) #ifdef HAVE_STRTOF_L /* * Only do this if we have strtof_l, as the locale might allow the * comma. */ EXPECT_EXCEPTION(@"Detect invalid chars in -[floatValue] #3", OFInvalidFormatException, [@"0,0" floatValue]) #endif EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #1", OFInvalidFormatException, [@"0.0a" doubleValue]) EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #2", OFInvalidFormatException, [@"0 0" doubleValue]) #ifdef HAVE_STRTOD_L /* * Only do this if we have strtod_l, as the locale might allow the * comma. */ EXPECT_EXCEPTION(@"Detect invalid chars in -[doubleValue] #3", OFInvalidFormatException, [@"0,0" doubleValue]) #endif EXPECT_EXCEPTION(@"Detect out of range in -[decimalValue]", OFOutOfRangeException, [@"12345678901234567890123456789012345678901234567890" @"12345678901234567890123456789012345678901234567890" decimalValue]) |
︙ | ︙ |