ObjFW  Diff

Differences From Artifact [52284dc401]:

To Artifact [2defafe592]:


1246
1247
1248
1249
1250
1251
1252


1253
1254

1255





1256

1257
1258
1259
1260










1261
1262

1263
1264
1265
1266
1267





1268
1269
1270
1271

1272
1273
1274
1275
1276
1277
1278


1279
1280

1281
1282
1283







1284
1285
1286

1287
1288

1289
1290
1291
1292
1293
1294

1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307




















1308
1309
1310
1311
1312
1313
1314
1315
1316
1317



1318
1319
1320
1321
1322
1323
1324
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263

1264
1265
1266


1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277

1278
1279
1280
1281


1282
1283
1284
1285
1286
1287
1288
1289

1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302



1303
1304
1305
1306
1307
1308
1309
1310
1311

1312
1313

1314
1315
1316




1317
1318
1319











1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359







+
+


+

+
+
+
+
+
-
+


-
-
+
+
+
+
+
+
+
+
+
+

-
+



-
-
+
+
+
+
+



-
+







+
+


+
-
-
-
+
+
+
+
+
+
+


-
+

-
+


-
-
-
-
+


-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+










+
+
+







					    length: 1];

	return @".";
}

- (intmax_t)decimalValue
{
	const char *str = string;
	size_t len = length;
	int i = 0;
	intmax_t num = 0;
	BOOL expectWhitespace = NO;

	while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r') {
		str++;
		len--;
	}

	if (string[0] == '-' || string[0] == '+')
	if (str[0] == '-' || str[0] == '+')
		i++;

	for (; i < length; i++) {
		if (string[i] >= '0' && string[i] <= '9') {
	for (; i < len; i++) {
		if (expectWhitespace) {
			if (str[i] != ' ' && str[i] != '\t' &&
			    str[i] != '\n' && str[i] != '\r')
				@throw [OFInvalidFormatException
				    newWithClass: isa];
			continue;
		}

		if (str[i] >= '0' && str[i] <= '9') {
			if (INTMAX_MAX / 10 < num ||
			    INTMAX_MAX - num * 10 < string[i] - '0')
			    INTMAX_MAX - num * 10 < str[i] - '0')
				@throw [OFOutOfRangeException
				    newWithClass: isa];

			num = (num * 10) + (string[i] - '0');
		} else
			num = (num * 10) + (str[i] - '0');
		} else if (str[i] == ' ' || str[i] == '\t' ||
		    str[i] == '\n' || str[i] == '\r')
			expectWhitespace = YES;
		else
			@throw [OFInvalidFormatException newWithClass: isa];
	}

	if (string[0] == '-')
	if (str[0] == '-')
		num *= -1;

	return num;
}

- (uintmax_t)hexadecimalValue
{
	const char *str = string;
	size_t len = length;
	int i = 0;
	uintmax_t num = 0;
	BOOL expectWhitespace = NO, gotNumber = NO;
	BOOL suffix = NO;

	if (length == 0)

	while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r') {
		str++;
		len--;
	}

	if (len == 0)
		return 0;

	if (length >= 2 && string[0] == '0' && string[1] == 'x')
	if (len >= 2 && str[0] == '0' && str[1] == 'x')
		i = 2;
	else if (length >= 1 && (string[0] == 'x' || string[0] == '$'))
	else if (len >= 1 && (str[0] == 'x' || str[0] == '$'))
		i = 1;

	if (i == length)
		@throw [OFInvalidFormatException newWithClass: isa];

	for (; i < length; i++) {
	for (; i < len; i++) {
		uintmax_t newnum;

		if (suffix)
			@throw [OFInvalidFormatException newWithClass: isa];

		if (string[i] >= '0' && string[i] <= '9')
			newnum = (num << 4) | (string[i] - '0');
		else if (string[i] >= 'A' && string[i] <= 'F')
			newnum = (num << 4) | (string[i] - 'A' + 10);
		else if (string[i] >= 'a' && string[i] <= 'f')
			newnum = (num << 4) | (string[i] - 'a' + 10);
		else if (string[i] == 'h') {
			suffix = YES;
		if (expectWhitespace) {
			if (str[i] != ' ' && str[i] != '\t' &&
			    str[i] != '\n' && str[i] != '\r')
				@throw [OFInvalidFormatException
				    newWithClass: isa];
			continue;
		}

		if (str[i] >= '0' && str[i] <= '9') {
			newnum = (num << 4) | (str[i] - '0');
			gotNumber = YES;
		} else if (str[i] >= 'A' && str[i] <= 'F') {
			newnum = (num << 4) | (str[i] - 'A' + 10);
			gotNumber = YES;
		} else if (str[i] >= 'a' && str[i] <= 'f') {
			newnum = (num << 4) | (str[i] - 'a' + 10);
			gotNumber = YES;
		} else if (str[i] == 'h' || str[i] == ' ' || str[i] == '\t' ||
		    str[i] == '\n' || str[i] == '\r') {
			expectWhitespace = YES;
			continue;
		} else
			@throw [OFInvalidFormatException newWithClass: isa];

		if (newnum < num)
			@throw [OFOutOfRangeException newWithClass: isa];

		num = newnum;
	}

	if (!gotNumber)
		@throw [OFInvalidFormatException newWithClass: isa];

	return num;
}

- (of_unichar_t*)unicodeString
{
	of_unichar_t *ret;
	size_t i, j, len;