ObjFW  Diff

Differences From Artifact [5a551cb41a]:

To Artifact [cdfb24dfd4]:


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

- (instancetype)initWithStringValue: (OFString *)stringValue
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		const char *cString = [stringValue UTF8String];
		size_t length = [stringValue UTF8StringLength];

		for (size_t i = 0; i < length; i++)
			if (!of_ascii_isdigit(cString[i]) && cString[i] != ' ')
				@throw [OFInvalidEncodingException exception];

		_numericStringValue = [stringValue copy];








|
|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

- (instancetype)initWithStringValue: (OFString *)stringValue
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		const char *cString = stringValue.UTF8String;
		size_t length = stringValue.UTF8StringLength;

		for (size_t i = 0; i < length; i++)
			if (!of_ascii_isdigit(cString[i]) && cString[i] != ' ')
				@throw [OFInvalidEncodingException exception];

		_numericStringValue = [stringValue copy];

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

	@try {
		if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
		    tagNumber != OF_ASN1_TAG_NUMBER_NUMERIC_STRING ||
		    constructed)
			@throw [OFInvalidArgumentException exception];

		if ([DEREncodedContents itemSize] != 1)
			@throw [OFInvalidArgumentException exception];

		numericStringValue = [OFString
		    stringWithCString: [DEREncodedContents items]
			     encoding: OF_STRING_ENCODING_ASCII
			       length: [DEREncodedContents count]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [self initWithStringValue: numericStringValue];








|



|

|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

	@try {
		if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
		    tagNumber != OF_ASN1_TAG_NUMBER_NUMERIC_STRING ||
		    constructed)
			@throw [OFInvalidArgumentException exception];

		if (DEREncodedContents.itemSize != 1)
			@throw [OFInvalidArgumentException exception];

		numericStringValue = [OFString
		    stringWithCString: DEREncodedContents.items
			     encoding: OF_STRING_ENCODING_ASCII
			       length: DEREncodedContents.count];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [self initWithStringValue: numericStringValue];

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
	[_numericStringValue release];

	[super dealloc];
}

- (OFString *)stringValue
{
	return [self numericStringValue];
}

- (bool)isEqual: (id)object
{
	OFASN1NumericString *numericString;

	if (![object isKindOfClass: [OFASN1NumericString class]])
		return false;

	numericString = object;

	if (![numericString->_numericStringValue isEqual: _numericStringValue])
		return false;

	return true;
}

- (uint32_t)hash
{
	return [_numericStringValue hash];
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<OFASN1NumericString: %@>",
					   _numericStringValue];
}
@end







|



















|








99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
	[_numericStringValue release];

	[super dealloc];
}

- (OFString *)stringValue
{
	return self.numericStringValue;
}

- (bool)isEqual: (id)object
{
	OFASN1NumericString *numericString;

	if (![object isKindOfClass: [OFASN1NumericString class]])
		return false;

	numericString = object;

	if (![numericString->_numericStringValue isEqual: _numericStringValue])
		return false;

	return true;
}

- (uint32_t)hash
{
	return _numericStringValue.hash;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<OFASN1NumericString: %@>",
					   _numericStringValue];
}
@end