ObjFW  Diff

Differences From Artifact [539d29c205]:

  • File src/OFString_UTF8.m — part of check-in [b7b33247d6] at 2016-08-29 00:05:29 on branch trunk — configure: Add --disable-unicode-tables option

    This is only useful for size-constrained systems and changes the
    behavior as follows:

    * Case-insensitive comparisons only work as expected for ASCII
    characters. This means that while a and A compare equal, ä and Ä do
    not.

    * -[OFMutableString {upper,lower}] and
    -[OFString {upper,lower}caseString] only work on ASCII characters;
    all other characters are left as they are. This means that the upper
    version of a is A, but the upper version of ä is still ä (and vice
    versa for lower). (user: js, size: 28512) [annotate] [blame] [check-ins using]

To Artifact [b0d3c841b5]:


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
static inline int
memcasecmp(const char *first, const char *second, size_t length)
{
	for (size_t i = 0; i < length; i++) {
		unsigned char f = first[i];
		unsigned char s = second[i];

		if (f <= 0x7F)
			f = toupper(f);
		if (s <= 0x7F)
			s = toupper(s);

		if (f > s)
			return OF_ORDERED_DESCENDING;
		if (f < s)
			return OF_ORDERED_ASCENDING;
	}








<
|
<
|







45
46
47
48
49
50
51

52

53
54
55
56
57
58
59
60
static inline int
memcasecmp(const char *first, const char *second, size_t length)
{
	for (size_t i = 0; i < length; i++) {
		unsigned char f = first[i];
		unsigned char s = second[i];


		f = of_ascii_toupper(f);

		s = of_ascii_toupper(s);

		if (f > s)
			return OF_ORDERED_DESCENDING;
		if (f < s)
			return OF_ORDERED_ASCENDING;
	}

777
778
779
780
781
782
783
784



785
786
787
788
789
790
791
	else
		return OF_ORDERED_ASCENDING;
}

- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	const char *otherCString;
	size_t i, j, otherCStringLength, minimumCStringLength;



	int compare;

	if (otherString == self)
		return OF_ORDERED_SAME;

	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];







|
>
>
>







775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
	else
		return OF_ORDERED_ASCENDING;
}

- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	const char *otherCString;
	size_t otherCStringLength, minimumCStringLength;
#ifdef OF_HAVE_UNICODE_TABLES
	size_t i, j;
#endif
	int compare;

	if (otherString == self)
		return OF_ORDERED_SAME;

	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];
849
850
851
852
853
854
855
856
857
858
859
860
861

862
863
864
865
866
867
868
			return OF_ORDERED_DESCENDING;
		if (c1 < c2)
			return OF_ORDERED_ASCENDING;

		i += l1;
		j += l2;
	}
#endif

	if (_s->cStringLength - i > otherCStringLength - j)
		return OF_ORDERED_DESCENDING;
	else if (_s->cStringLength - i < otherCStringLength - j)
		return OF_ORDERED_ASCENDING;


	return OF_ORDERED_SAME;
}

- (uint32_t)hash
{
	uint32_t hash;







<





>







850
851
852
853
854
855
856

857
858
859
860
861
862
863
864
865
866
867
868
869
			return OF_ORDERED_DESCENDING;
		if (c1 < c2)
			return OF_ORDERED_ASCENDING;

		i += l1;
		j += l2;
	}


	if (_s->cStringLength - i > otherCStringLength - j)
		return OF_ORDERED_DESCENDING;
	else if (_s->cStringLength - i < otherCStringLength - j)
		return OF_ORDERED_ASCENDING;
#endif

	return OF_ORDERED_SAME;
}

- (uint32_t)hash
{
	uint32_t hash;