ObjFW  Check-in [df5e33bec7]

Overview
Comment:OFNumber: Make description locale-compatible
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: df5e33bec724407b4d4c132367f8bd60c8812154adb180f6821cd916c26a3f8f
User & Date: js on 2017-01-07 00:09:10
Other Links: manifest | tags
Context
2017-01-07
00:37
Add of_ascii_{to{upper,lower},is{alpha,alnum}} check-in: d9eb7b50b3 user: js tags: trunk
00:09
OFNumber: Make description locale-compatible check-in: df5e33bec7 user: js tags: trunk
2017-01-06
23:59
Add more _Nonnull to make Clang 4.0 happy check-in: b56ef2c415 user: js tags: trunk
Changes

Modified src/OFNumber.m from [114905a94e] to [424f2af76e].

13
14
15
16
17
18
19

20
21
22
23
24
25
26
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <inttypes.h>

#include <math.h>

#import "OFNumber.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFXMLAttribute.h"
#import "OFDataArray.h"







>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <inttypes.h>
#include <locale.h>
#include <math.h>

#import "OFNumber.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFXMLAttribute.h"
#import "OFDataArray.h"
902
903
904
905
906
907
908





909
910



911
912
913
914
915
916
917





918
919



920
921
922
923
924
925
926
	case OF_NUMBER_TYPE_INTMAX:
	case OF_NUMBER_TYPE_PTRDIFF:
	case OF_NUMBER_TYPE_INTPTR:
		return [OFString stringWithFormat: @"%jd", [self intMaxValue]];
	case OF_NUMBER_TYPE_FLOAT:
		ret = [OFMutableString stringWithFormat: @"%g", _value.float_];






		if (![ret containsString: @"."])
			[ret appendString: @".0"];




		[ret makeImmutable];

		return ret;
	case OF_NUMBER_TYPE_DOUBLE:
		ret = [OFMutableString stringWithFormat: @"%g", _value.double_];






		if (![ret containsString: @"."])
			[ret appendString: @".0"];




		[ret makeImmutable];

		return ret;
	default:
		@throw [OFInvalidFormatException exception];
	}







>
>
>
>
>
|
|
>
>
>







>
>
>
>
>
|
|
>
>
>







903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
	case OF_NUMBER_TYPE_INTMAX:
	case OF_NUMBER_TYPE_PTRDIFF:
	case OF_NUMBER_TYPE_INTPTR:
		return [OFString stringWithFormat: @"%jd", [self intMaxValue]];
	case OF_NUMBER_TYPE_FLOAT:
		ret = [OFMutableString stringWithFormat: @"%g", _value.float_];

		{
			void *pool = objc_autoreleasePoolPush();
			OFString *decimalPoint = [OFString stringWithUTF8String:
			    localeconv()->decimal_point];

			if (![ret containsString: decimalPoint])
			       [ret appendFormat: @"%@0", decimalPoint];

			objc_autoreleasePoolPop(pool);
		}

		[ret makeImmutable];

		return ret;
	case OF_NUMBER_TYPE_DOUBLE:
		ret = [OFMutableString stringWithFormat: @"%g", _value.double_];

		{
			void *pool = objc_autoreleasePoolPush();
			OFString *decimalPoint = [OFString stringWithUTF8String:
			    localeconv()->decimal_point];

			if (![ret containsString: decimalPoint])
			       [ret appendFormat: @"%@0", decimalPoint];

			objc_autoreleasePoolPop(pool);
		}

		[ret makeImmutable];

		return ret;
	default:
		@throw [OFInvalidFormatException exception];
	}