Overview
Comment: | Add -[enumerateLinesUsingBlock:] to OFString. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6dd03a129eddffa054dc7633d35ac208 |
User & Date: | js on 2011-09-15 19:26:00 |
Other Links: | manifest | tags |
Context
2011-09-16
| ||
11:02 | Fix compilation with -fblocks on QNX. check-in: af54c117c6 user: js tags: trunk | |
2011-09-15
| ||
19:26 | Add -[enumerateLinesUsingBlock:] to OFString. check-in: 6dd03a129e user: js tags: trunk | |
11:18 | Update buildsys. check-in: 76cc08b755 user: js tags: trunk | |
Changes
Modified src/OFConstantString.m from [7b7f10cde1] to [993ed1e2bc].
︙ | |||
640 641 642 643 644 645 646 647 | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | + + + + + + + + + + | - (void)writeToFile: (OFString*)path { if (initialized != SIZE_MAX) [self finishInitialization]; return [super writeToFile: path]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { if (initialized != SIZE_MAX) [self finishInitialization]; return [super enumerateLinesUsingBlock: block]; } #endif @end |
Modified src/OFString.h from [5e6b1ff86f] to [1581ec724e].
︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | + + + + | OF_STRING_ENCODING_ISO_8859_15, OF_STRING_ENCODING_WINDOWS_1252, OF_STRING_ENCODING_AUTODETECT = 0xFF } of_string_encoding_t; /* FIXME */ #define OF_STRING_ENCODING_NATIVE OF_STRING_ENCODING_UTF_8 #ifdef OF_HAVE_BLOCKS typedef void (^of_string_line_enumeration_block_t)(OFString *line, BOOL *stop); #endif #ifdef __cplusplus extern "C" { #endif extern int of_string_check_utf8(const char*, size_t, size_t*); extern size_t of_string_unicode_to_utf8(of_unichar_t, char*); extern size_t of_string_utf8_to_unicode(const char*, size_t, of_unichar_t*); |
︙ | |||
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | + + + + + + + + + | /** * \brief Writes the string into the specified file using UTF-8 encoding. * * \param path The path of the file to write to */ - (void)writeToFile: (OFString*)path; #ifdef OF_HAVE_BLOCKS /** * Enumerates all lines in the receiver using the specified block. * * \brief block The block to call for each line */ - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block; #endif @end #import "OFConstantString.h" #import "OFMutableString.h" #import "OFString+Hashing.h" #import "OFString+Serialization.h" #import "OFString+URLEncoding.h" #import "OFString+XMLEscaping.h" #import "OFString+XMLUnescaping.h" |
Modified src/OFString.m from [f1011efbdf] to [ba997373bf].
︙ | |||
1923 1924 1925 1926 1927 1928 1929 1930 | 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | file = [OFFile fileWithPath: path mode: @"wb"]; [file writeString: self]; [pool release]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; const char *cString = s->cString; const char *last = cString; BOOL stop = NO, lastCarriageReturn = NO; while (!stop && *cString != 0) { if (lastCarriageReturn && *cString == '\n') { lastCarriageReturn = NO; cString++; last++; continue; } if (*cString == '\n' || *cString == '\r') { block([OFString stringWithUTF8String: last length: cString - last], &stop); last = cString + 1; [pool releaseObjects]; } lastCarriageReturn = (*cString == '\r'); cString++; } if (!stop) block([OFString stringWithUTF8String: last length: cString - last], &stop); [pool release]; } #endif @end |