ObjFW  Diff

Differences From Artifact [114905a94e]:

To Artifact [424f2af76e]:


13
14
15
16
17
18
19

20
21
22
23
24
25
26
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
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: @"."])
			[ret appendString: @".0"];
			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: @"."])
			[ret appendString: @".0"];
			if (![ret containsString: decimalPoint])
			       [ret appendFormat: @"%@0", decimalPoint];

			objc_autoreleasePoolPop(pool);
		}

		[ret makeImmutable];

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