@@ -20,16 +20,10 @@ #include #include #include #include -#ifdef HAVE_MADVISE -# include -#else -# define madvise(addr, len, advise) -#endif - #import "OFString.h" #import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" @@ -287,44 +281,36 @@ - (void)reverse { size_t i, j; - madvise(s->cString, s->cStringLength, MADV_SEQUENTIAL); - /* We reverse all bytes and restore UTF-8 later, if necessary */ for (i = 0, j = s->cStringLength - 1; i < s->cStringLength / 2; i++, j--) { s->cString[i] ^= s->cString[j]; s->cString[j] ^= s->cString[i]; s->cString[i] ^= s->cString[j]; } - if (!s->UTF8) { - madvise(s->cString, s->cStringLength, MADV_NORMAL); + if (!s->UTF8) return; - } for (i = 0; i < s->cStringLength; i++) { /* ASCII */ if (OF_LIKELY(!(s->cString[i] & 0x80))) continue; /* A start byte can't happen first as we reversed everything */ - if (OF_UNLIKELY(s->cString[i] & 0x40)) { - madvise(s->cString, s->cStringLength, MADV_NORMAL); + if (OF_UNLIKELY(s->cString[i] & 0x40)) @throw [OFInvalidEncodingException exceptionWithClass: isa]; - } /* Next byte must not be ASCII */ if (OF_UNLIKELY(s->cStringLength < i + 1 || - !(s->cString[i + 1] & 0x80))) { - madvise(s->cString, s->cStringLength, MADV_NORMAL); + !(s->cString[i + 1] & 0x80))) @throw [OFInvalidEncodingException exceptionWithClass: isa]; - } /* Next byte is the start byte */ if (OF_LIKELY(s->cString[i + 1] & 0x40)) { s->cString[i] ^= s->cString[i + 1]; s->cString[i + 1] ^= s->cString[i]; @@ -334,15 +320,13 @@ continue; } /* Second next byte must not be ASCII */ if (OF_UNLIKELY(s->cStringLength < i + 2 || - !(s->cString[i + 2] & 0x80))) { - madvise(s->cString, s->cStringLength, MADV_NORMAL); + !(s->cString[i + 2] & 0x80))) @throw [OFInvalidEncodingException exceptionWithClass: isa]; - } /* Second next byte is the start byte */ if (OF_LIKELY(s->cString[i + 2] & 0x40)) { s->cString[i] ^= s->cString[i + 2]; s->cString[i + 2] ^= s->cString[i]; @@ -352,15 +336,13 @@ continue; } /* Third next byte must not be ASCII */ if (OF_UNLIKELY(s->cStringLength < i + 3 || - !(s->cString[i + 3] & 0x80))) { - madvise(s->cString, s->cStringLength, MADV_NORMAL); + !(s->cString[i + 3] & 0x80))) @throw [OFInvalidEncodingException exceptionWithClass: isa]; - } /* Third next byte is the start byte */ if (OF_LIKELY(s->cString[i + 3] & 0x40)) { s->cString[i] ^= s->cString[i + 3]; s->cString[i + 3] ^= s->cString[i]; @@ -373,15 +355,12 @@ i += 3; continue; } /* UTF-8 does not allow more than 4 bytes per character */ - madvise(s->cString, s->cStringLength, MADV_NORMAL); @throw [OFInvalidEncodingException exceptionWithClass: isa]; } - - madvise(s->cString, s->cStringLength, MADV_NORMAL); } - (void)upper { [self _applyTable: of_unicode_upper_table