ObjFW  Diff

Differences From Artifact [ee8d4c3fc0]:

To Artifact [d68d151905]:


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
969
970
971
972
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
969







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


+



-
+
-
-

-
-
-
-
-









+
+
+
+
+
-
+
+

-
+

+







		OFString *component;
		size_t i, cStringLength;
		va_list argumentsCopy;

		s = [self allocMemoryWithSize: sizeof(*s)];
		memset(s, 0, sizeof(*s));

		/*
		 * First needs to be a call to be sure it is initialized, in
		s->cStringLength = [firstComponent cStringLength];

		 * case it's a constant string.
		 */
		switch (of_string_check_utf8([firstComponent cString],
		    s->cStringLength)) {
		s->cStringLength = [firstComponent cStringLength];
		case 1:
			s->isUTF8 = YES;
		s->isUTF8 = firstComponent->s->isUTF8;
			break;
		case -1:
			@throw [OFInvalidEncodingException newWithClass: isa];
		}


		/* Calculate length */
		/* Calculate length and see if we need UTF-8 */
		va_copy(argumentsCopy, arguments);
		while ((component = va_arg(argumentsCopy, OFString*)) != nil) {
			/* First needs to be a call, see above */
			cStringLength = [component cStringLength];
			s->cStringLength += 1 + cStringLength;

			switch (of_string_check_utf8([component cString],
			if (component->s->isUTF8)
			    cStringLength)) {
			case 1:
				s->isUTF8 = YES;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
			}
		}

		s->cString = [self allocMemoryWithSize: s->cStringLength + 1];

		cStringLength = [firstComponent cStringLength];
		memcpy(s->cString, [firstComponent cString], cStringLength);
		i = cStringLength;

		while ((component = va_arg(arguments, OFString*)) != nil) {
			/*
			 * We already sent each component a message, so we can
			 * be sure they are initialized and access them
			 * directly.
			 */
			cStringLength = [component cStringLength];
			cStringLength = component->s->cStringLength;

			s->cString[i] = OF_PATH_DELIMITER;
			memcpy(s->cString + i + 1, [component cString],
			memcpy(s->cString + i + 1, component->s->cString,
			    cStringLength);

			i += 1 + cStringLength;
		}

		s->cString[i] = '\0';
	} @catch (id e) {
		[self release];
		@throw e;