ObjFW  Check-in [2fca00b926]

Overview
Comment:Fix wrong calculated cStringLength in +[stringWithUTF16String:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2fca00b9265622634708e008b1f2cd17d66393f14eda34caa58b43a5e74d98ae
User & Date: js on 2011-07-08 19:58:00
Other Links: manifest | tags
Context
2011-07-08
20:07
Rename OF_PATH_DELIM to OF_PATH_DELIMITER. check-in: 7d9efc3924 user: js tags: trunk
19:58
Fix wrong calculated cStringLength in +[stringWithUTF16String:]. check-in: 2fca00b926 user: js tags: trunk
19:50
Add -std=gnu99 to OBJCFLAGS in objfw-config.
This is required now as we use restrict.
check-in: ce742708e6 user: js tags: trunk
Changes

Modified src/OFString.m from [77cf5c9b5c] to [c391b87c87].

784
785
786
787
788
789
790
791

792
793
794
795
796
797
798
799

800
801
802
803
804
805
806
784
785
786
787
788
789
790

791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807







-
+








+







				    newWithClass: isa];

			if ((character & 0xFC00) == 0xD800) {
				uint16_t nextCharacter;

				if (length <= i + 1)
					@throw [OFInvalidEncodingException
						newWithClass: isa];
					    newWithClass: isa];

				nextCharacter = (swap
				    ? of_bswap16(string[i + 1])
				    : string[i + 1]);
				character = (((character & 0x3FF) << 10) |
				    (nextCharacter & 0x3FF)) + 0x10000;

				i++;
				s->cStringLength--;
			}

			characterLen = of_string_unicode_to_utf8(
			    character, buffer);

			switch (characterLen) {
			case 1:
1140
1141
1142
1143
1144
1145
1146



1147
1148
1149
1150
1151
1152
1153
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157







+
+
+







	return s->cStringLength;
}

- (BOOL)isEqual: (id)object
{
	if (![object isKindOfClass: [OFString class]])
		return NO;

	if ([object cStringLength] != s->cStringLength)
		return NO;

	if (strcmp(s->cString, [object cString]))
		return NO;

	return YES;
}