758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
|
{
return [self tryReadLineWithEncoding: OF_STRING_ENCODING_UTF_8];
}
- (OFString*)tryReadTillDelimiter: (OFString*)delimiter
encoding: (of_string_encoding_t)encoding
{
const char *delimiterUTF8String;
size_t i, j, delimiterLength, bufferLength, retLength;
char *retCString, *buffer, *newCache;
OFString *ret;
/* FIXME: Convert delimiter to specified charset */
delimiterUTF8String = [delimiter UTF8String];
delimiterLength = [delimiter UTF8StringLength];
j = 0;
if (delimiterLength == 0)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
/* Look if there's something in our cache */
if (!waitingForDelimiter && cache != NULL) {
for (i = 0; i < cacheLength; i++) {
if (cache[i] != delimiterUTF8String[j++])
j = 0;
if (j == delimiterLength || cache[i] == '\0') {
if (cache[i] == '\0')
delimiterLength = 1;
ret = [OFString
|
|
<
|
|
|
|
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
|
{
return [self tryReadLineWithEncoding: OF_STRING_ENCODING_UTF_8];
}
- (OFString*)tryReadTillDelimiter: (OFString*)delimiter
encoding: (of_string_encoding_t)encoding
{
const char *delimiterCString;
size_t i, j, delimiterLength, bufferLength, retLength;
char *retCString, *buffer, *newCache;
OFString *ret;
delimiterCString = [delimiter cStringUsingEncoding: encoding];
delimiterLength = [delimiter lengthOfBytesUsingEncoding: encoding];
j = 0;
if (delimiterLength == 0)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
/* Look if there's something in our cache */
if (!waitingForDelimiter && cache != NULL) {
for (i = 0; i < cacheLength; i++) {
if (cache[i] != delimiterCString[j++])
j = 0;
if (j == delimiterLength || cache[i] == '\0') {
if (cache[i] == '\0')
delimiterLength = 1;
ret = [OFString
|
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
|
}
bufferLength = [self lowlevelReadIntoBuffer: buffer
length: of_pagesize];
/* Look if there's a delimiter or \0 */
for (i = 0; i < bufferLength; i++) {
if (buffer[i] != delimiterUTF8String[j++])
j = 0;
if (j == delimiterLength || buffer[i] == '\0') {
if (buffer[i] == '\0')
delimiterLength = 1;
retLength = cacheLength + i + 1 -
|
|
|
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
|
}
bufferLength = [self lowlevelReadIntoBuffer: buffer
length: of_pagesize];
/* Look if there's a delimiter or \0 */
for (i = 0; i < bufferLength; i++) {
if (buffer[i] != delimiterCString[j++])
j = 0;
if (j == delimiterLength || buffer[i] == '\0') {
if (buffer[i] == '\0')
delimiterLength = 1;
retLength = cacheLength + i + 1 -
|