Index: generators/TableGenerator.m ================================================================== --- generators/TableGenerator.m +++ generators/TableGenerator.m @@ -65,15 +65,13 @@ [line cString]]; [OFApplication terminateWithStatus: 1]; } splitted_carray = [splitted cArray]; - codep = [splitted_carray[0] hexadecimalValueAsInteger]; - upperTable[codep] = - [splitted_carray[12] hexadecimalValueAsInteger]; - lowerTable[codep] = - [splitted_carray[13] hexadecimalValueAsInteger]; + codep = [splitted_carray[0] hexadecimalValue]; + upperTable[codep] = [splitted_carray[12] hexadecimalValue]; + lowerTable[codep] = [splitted_carray[13] hexadecimalValue]; [pool2 releaseObjects]; } [pool release]; @@ -105,13 +103,12 @@ if (![splitted_carray[1] isEqual: @"S"] && ![splitted_carray[1] isEqual: @"C"]) continue; - codep = [splitted_carray[0] hexadecimalValueAsInteger]; - casefoldingTable[codep] = - [splitted_carray[2] hexadecimalValueAsInteger]; + codep = [splitted_carray[0] hexadecimalValue]; + casefoldingTable[codep] = [splitted_carray[2] hexadecimalValue]; [pool2 releaseObjects]; } [pool release]; Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -350,21 +350,21 @@ /** * Returns the decimal value of the string as an intmax_t or throws an * OFInvalidEncoding exception if the string contains any non-number characters. * - * \return An OFNumber + * \return An intmax_t with the value of the string */ -- (intmax_t)decimalValueAsInteger; +- (intmax_t)decimalValue; /** * Returns the hexadecimal value of the string as an intmax_t or throws an * OFInvalidEncoding exception if the string contains any non-number characters. * - * \return An OFNumber + * \return A uintmax_t with the value of the string */ -- (uintmax_t)hexadecimalValueAsInteger; +- (uintmax_t)hexadecimalValue; /** * Returns the string as an array of of_unichar_t. The result needs to be * free()'d by the caller, as the memory is not marked as belonging to the * object. Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -964,11 +964,11 @@ [pool release]; return array; } -- (intmax_t)decimalValueAsInteger +- (intmax_t)decimalValue { int i = 0; intmax_t num = 0; if (string[0] == '-') @@ -991,11 +991,11 @@ num *= -1; return num; } -- (uintmax_t)hexadecimalValueAsInteger +- (uintmax_t)hexadecimalValue { int i = 0; uintmax_t num = 0; if (length == 0) Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -219,50 +219,45 @@ [[a objectAtIndex: i++] isEqual: @""] && [[a objectAtIndex: i++] isEqual: @"baz"] && [[a objectAtIndex: i++] isEqual: @""] && [[a objectAtIndex: i++] isEqual: @""]) - TEST(@"-[decimalValueAsInteger]", - [@"1234" decimalValueAsInteger] == 1234 && - [@"-500" decimalValueAsInteger] == -500 && - [@"" decimalValueAsInteger] == 0) - - TEST(@"-[hexadecimalValueAsInteger]", - [@"123f" hexadecimalValueAsInteger] == 0x123f && - [@"0xABcd" hexadecimalValueAsInteger] == 0xABCD && - [@"xbCDE" hexadecimalValueAsInteger] == 0xBCDE && - [@"$CdEf" hexadecimalValueAsInteger] == 0xCDEF && - [@"" hexadecimalValueAsInteger] == 0) - - EXPECT_EXCEPTION(@"Detect invalid characters in " - @"-[decimalValueAsInteger] #1", OFInvalidEncodingException, - [@"abc" decimalValueAsInteger]) - EXPECT_EXCEPTION(@"Detect invalid characters in " - @"-[decimalValueAsInteger] #2", OFInvalidEncodingException, - [@"0a" decimalValueAsInteger]) - - EXPECT_EXCEPTION(@"Detect invalid chars in " - @"-[hexadecimalValueAsInteger] #1", OFInvalidEncodingException, - [@"0xABCDEFG" hexadecimalValueAsInteger]) - EXPECT_EXCEPTION(@"Detect invalid chars in " - @"-[hexadecimalValueAsInteger] #2", OFInvalidEncodingException, - [@"0x" hexadecimalValueAsInteger]) - EXPECT_EXCEPTION(@"Detect invalid chars in " - @"-[hexadecimalValueAsInteger] #3", OFInvalidEncodingException, - [@"$" hexadecimalValueAsInteger]) - - EXPECT_EXCEPTION(@"Detect out of range in -[decimalValueAsInteger", + TEST(@"-[decimalValue]", + [@"1234" decimalValue] == 1234 && + [@"-500" decimalValue] == -500 && + [@"" decimalValue] == 0) + + TEST(@"-[hexadecimalValue]", + [@"123f" hexadecimalValue] == 0x123f && + [@"0xABcd" hexadecimalValue] == 0xABCD && + [@"xbCDE" hexadecimalValue] == 0xBCDE && + [@"$CdEf" hexadecimalValue] == 0xCDEF && + [@"" hexadecimalValue] == 0) + + EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #1", + OFInvalidEncodingException, [@"abc" decimalValue]) + EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #2", + OFInvalidEncodingException, [@"0a" decimalValue]) + + EXPECT_EXCEPTION(@"Detect invalid chars in -[hexadecimalValue] #1", + OFInvalidEncodingException, [@"0xABCDEFG" hexadecimalValue]) + EXPECT_EXCEPTION(@"Detect invalid chars in -[hexadecimalValue] #2", + OFInvalidEncodingException, [@"0x" hexadecimalValue]) + EXPECT_EXCEPTION(@"Detect invalid chars in -[hexadecimalValue] #3", + OFInvalidEncodingException, [@"$" hexadecimalValue]) + + EXPECT_EXCEPTION(@"Detect out of range in -[decimalValue]", OFOutOfRangeException, [@"12345678901234567890123456789012345678901234567890" @"12345678901234567890123456789012345678901234567890" - decimalValueAsInteger]) + decimalValue]) - EXPECT_EXCEPTION(@"Detect out of range in -[hexadecilamValueAsInteger", + EXPECT_EXCEPTION(@"Detect out of range in -[hexadecimalValue]", OFOutOfRangeException, [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" - hexadecimalValueAsInteger]) + hexadecimalValue]) TEST(@"-[unicodeString]", (ua = [@"fööbär" unicodeString]) && !memcmp(ua, ucstr, 7 * sizeof(of_unichar_t)) && R(free(ua))) TEST(@"-[MD5Hash]", [[@"asdfoobar" MD5Hash]