ObjFW  Diff

Differences From Artifact [c5cbe08edf]:

  • File src/OFXMLParser.m — part of check-in [3d16a30f41] at 2013-06-22 12:12:36 on branch trunk — Rework exceptions.

    This mostly removes the argument for the class in which the exception
    occurred. As backtraces were recently added for all platforms, the
    passed class does not give any extra information on where the exception
    occurred anymore.

    This also removes a few other arguments which were not too helpful. In
    the past, the idea was to pass as many arguments as possible so that it
    is easier to find the origin of the exception. However, as backtraces
    are a much better way to find the origin, those are not useful anymore
    and just make the exception more cumbersome to use. The rule is now to
    only pass arguments that might help in recovering from the exception or
    provide information that is otherwise not easily accessible. (user: js, size: 23947) [annotate] [blame] [check-ins using]

To Artifact [a08464f480]:


150
151
152
153
154
155
156
157

158
159
160
161
162
163
164
165
150
151
152
153
154
155
156

157

158
159
160
161
162
163
164







-
+
-







		@selector(OF_inAttributeNameState),
		@selector(OF_expectDelimiterState),
		@selector(OF_inAttributeValueState),
		@selector(OF_expectCloseState),
		@selector(OF_expectSpaceOrCloseState),
		@selector(OF_inExclamationMarkState),
		@selector(OF_inCDATAOpeningState),
		@selector(OF_inCDATAState1),
		@selector(OF_inCDATAState),
		@selector(OF_inCDATAState2),
		@selector(OF_inCommentOpeningState),
		@selector(OF_inCommentState1),
		@selector(OF_inCommentState2),
		@selector(OF_inDOCTYPEState)
	};
	memcpy(selectors, selectors_, sizeof(selectors_));

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
944
945
946
947
948
949
950


951
952
953
954




955
956

957
958

959
960
961




962
963
964
965
966
967
968
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


944
945
946
947
948
949
950
951
952
953
954







-
+






-
+

+


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

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

-
-
-
+
+
+
+

-
+

-
+

-
-
+
+
+
+







/* CDATA */
- (void)OF_inCDATAOpeningState
{
	if (_data[_i] != "CDATA["[_level])
		@throw [OFMalformedXMLException exceptionWithParser: self];

	if (++_level == 6) {
		_state = OF_XMLPARSER_IN_CDATA_1;
		_state = OF_XMLPARSER_IN_CDATA;
		_level = 0;
	}

	_last = _i + 1;
}

- (void)OF_inCDATAState1
- (void)OF_inCDATAState
{

	if (_data[_i] == ']')
		_level++;
	else
		_level = 0;

	else if (_data[_i] == '>' && _level >= 2) {
	if (_level == 2)
		_state = OF_XMLPARSER_IN_CDATA_2;
}

- (void)OF_inCDATAState2
{
	void *pool;
	OFString *CDATA;
		void *pool = objc_autoreleasePoolPush();
		OFString *CDATA;

	if (_data[_i] != '>') {
		_state = OF_XMLPARSER_IN_CDATA_1;
		_level = (_data[_i] == ']' ? 1 : 0);

		return;
	}

	pool = objc_autoreleasePoolPush();

	buffer_append(_buffer, _data + _last, _encoding, _i - _last);
	CDATA = transform_string(_buffer, 2, false, nil);
		buffer_append(_buffer, _data + _last, _encoding, _i - _last);
		CDATA = transform_string(_buffer, 2, false, nil);

	if ([_delegate respondsToSelector: @selector(parser:foundCDATA:)])
		[_delegate parser: self
		       foundCDATA: CDATA];
		if ([_delegate respondsToSelector:
		    @selector(parser:foundCDATA:)])
			[_delegate parser: self
			       foundCDATA: CDATA];

	objc_autoreleasePoolPop(pool);
		objc_autoreleasePoolPop(pool);

	[_buffer removeAllItems];
		[_buffer removeAllItems];

	_last = _i + 1;
	_state = OF_XMLPARSER_OUTSIDE_TAG;
		_last = _i + 1;
		_state = OF_XMLPARSER_OUTSIDE_TAG;
	} else
		_level = 0;
}

/* Comment */
- (void)OF_inCommentOpeningState
{
	if (_data[_i] != '-')
		@throw [OFMalformedXMLException exceptionWithParser: self];