Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -7,21 +7,19 @@ * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ -#import - #import "OFObject.h" /** * A class for storing and modifying strings. */ @interface OFString: OFObject { - wchar_t *string; - size_t length; + char *string; + size_t length; } /** * Creates a new OFString. * @@ -35,18 +33,10 @@ * \param str A C string to initialize the OFString with * \return A new OFString */ + newFromCString: (const char*)str; -/** - * Creates a new OFString from a wide C string. - * - * \param str A wide C string to initialize the OFString with - * \return A new OFString - */ -+ newFromWideCString: (const wchar_t*)str; - /** * Initializes an already allocated OFString. * * \return An initialized OFString */ @@ -58,34 +48,20 @@ * \param str A C string to initialize the OFString with * \return An initialized OFString */ - initFromCString: (const char*)str; -/** - * Initializes an already allocated OFString from a wide C string. - * - * \param str A wide C string to initialize the OFString with - * \return An initialized OFString - */ -- initFromWideCString: (const wchar_t*)str; - /** * \return The OFString as a wide C string */ -- (const wchar_t*)wideCString; +- (const char*)cString; /** * \return The length of the OFString */ - (size_t)length; -/** - * \return The OFString as a C string, if possible (if not, returns NULL). - * If not needed anymore, it is usefull to call freeMem:. - */ -- (char*)getCString; - /** * Clones the OFString, creating a new one. * * \return A copy of the OFString */ @@ -119,17 +95,10 @@ * * \param str A C string to append */ - appendCString: (const char*)str; -/** - * Append a wide C string to the OFString. - * - * \param str A wide C string to append - */ -- appendWideCString: (const wchar_t*)str; - /** * Reverse the OFString. */ - reverse; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -11,12 +11,11 @@ #import "config.h" #import #import -#import -#import +#import #import "OFString.h" #import "OFExceptions.h" @implementation OFString @@ -28,15 +27,10 @@ + newFromCString: (const char*)str { return [[self alloc] initFromCString: str]; } -+ newFromWideCString: (const wchar_t*)str -{ - return [[self alloc] initFromWideCString: str]; -} - - init { if ((self = [super init])) { length = 0; string = NULL; @@ -50,77 +44,32 @@ if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { - if ((length = mbstowcs(NULL, str, 0)) == (size_t)-1) { - [super free]; - @throw [OFCharsetConversionFailedException - newWithObject: nil]; - } - - string = [self getMemForNItems: length + 1 - ofSize: sizeof(wchar_t)]; - - if (mbstowcs(string, str, length + 1) != length) { - [super free]; - return nil; - } + length = strlen(str); + string = [self getMemWithSize: length + 1]; + memcpy(string, str, length + 1); } } return self; } -- initFromWideCString: (const wchar_t*)str -{ - if ((self = [super init])) { - if (str == NULL) { - length = 0; - string = NULL; - } else { - length = wcslen(str); - string = [self getMemForNItems: length + 1 - ofSize: sizeof(wchar_t)]; - wmemcpy(string, str, length + 1); - } - } - - return self; -} - -- (const wchar_t*)wideCString +- (const char*)cString { return string; } - (size_t)length { return length; } -- (char*)getCString -{ - char *str; - size_t len; - - if ((len = wcstombs(NULL, string, 0)) == (size_t)-1) - @throw [OFCharsetConversionFailedException newWithObject: self]; - - str = [self getMemWithSize: len + 1]; - - if (wcstombs(str, string, len + 1) != len) { - [self freeMem: str]; - @throw [OFCharsetConversionFailedException newWithObject: self]; - } - - return str; -} - - (OFString*)clone { - return [OFString newFromWideCString: string]; + return [OFString newFromCString: string]; } - (OFString*)setTo: (OFString*)str { [self free]; @@ -127,68 +76,33 @@ return (self = [str clone]); } - (int)compareTo: (OFString*)str { - return wcscmp(string, [str wideCString]); + return strcmp(string, [str cString]); } - append: (OFString*)str { - return [self appendWideCString: [str wideCString]]; + return [self appendCString: [str cString]]; } - appendCString: (const char*)str { - wchar_t *newstr, *tmpstr; - size_t newlen, strlength; + char *newstr; + size_t newlen, strlength; if (string == NULL) return [self setTo: [OFString newFromCString: str]]; - if ((strlength = mbstowcs(NULL, str, 0)) == (size_t)-1) - @throw [OFCharsetConversionFailedException newWithObject: self]; - - tmpstr = [self getMemForNItems: strlength + 1 - ofSize: sizeof(wchar_t)]; - - if (mbstowcs(tmpstr, str, strlength) != strlength) { - [self freeMem: tmpstr]; - @throw [OFCharsetConversionFailedException newWithObject: self]; - } - - newlen = length + strlength; - newstr = [self resizeMem: string - toNItems: newlen + 1 - ofSize: sizeof(wchar_t)]; - - wmemcpy(newstr + length, tmpstr, strlength + 1); - - length = newlen; - string = newstr; - - [self freeMem: tmpstr]; - - return self; -} - -- appendWideCString: (const wchar_t*)str -{ - wchar_t *newstr; - size_t newlen, strlength; - - if (string == NULL) - return [self setTo: [OFString newFromWideCString: str]]; - - strlength = wcslen(str); - newlen = length + strlength; - - newstr = [self resizeMem: string - toNItems: newlen + 1 - ofSize: sizeof(wchar_t)]; - - wmemcpy(newstr + length, str, strlength + 1); + strlength = strlen(str); + newlen = length + strlength; + + newstr = [self resizeMem: string + toSize: newlen + 1]; + + memcpy(newstr + length, str, strlength + 1); length = newlen; string = newstr; return self; @@ -210,20 +124,20 @@ - upper { size_t i = length; while (i--) - string[i] = towupper(string[i]); + string[i] = toupper(string[i]); return self; } - lower { size_t i = length; while (i--) - string[i] = towlower(string[i]); + string[i] = tolower(string[i]); return self; } @end Index: src/OFXMLFactory.h ================================================================== --- src/OFXMLFactory.h +++ src/OFXMLFactory.h @@ -7,12 +7,10 @@ * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ -#import - #import "OFObject.h" /** * The OFXMLFactory class provides an easy way to create XML stanzas. */ @@ -24,19 +22,10 @@ * \return The escaped C string. * You need to free it manually! */ + (char*)escapeCString: (const char*)s; -/** - * XML-escapes a wide C string. - * - * \param s The wide C string to escape - * \return The escaped wide C string. - * You need to free it manually! - */ -+ (wchar_t*)escapeWideCString: (const wchar_t*)s; - /** * Creates an XML stanza. * * \param name The name of the tag as a C string * \param close A boolean whether the tag should be closed @@ -51,43 +40,15 @@ */ + (char*)createStanza: (const char*)name withCloseTag: (BOOL)close andData: (const char*)data, ...; -/** - * Creates an XML stanza as a wide C string. - * - * \param name The name of the tag as a wide C string - * \param close A boolean whether the tag should be closed - * \param data Data that should be inside the tag as a wide C string. - * It will NOT be escaped, so you can also include other stanzas. - * \param ... Field / value pairs for the tag in the form "field", "value" as - * wide C strings. - * Last element must be NULL. - * Example: L"field1", L"value1", L"field2", L"value2", NULL - * \return The created XML stanza as a wide C string. - * You need to free it manually! - */ -+ (wchar_t*)createWideStanza: (const wchar_t*)name - withCloseTag: (BOOL)close - andData: (const wchar_t*)data, ...; - /** * Concats an array of C strings into one C string and frees the array of C * strings. * * \param strs An array of C strings * \return The concatenated C strings. * You need to free it manually! */ + (char*)concatAndFreeCStrings: (char**)strs; - -/** - * Concats an array of wide C strings into one wide C string and frees the - * array of wide C strings. - * - * \param strs An array of wide C strings - * \return The concatenated wide C strings. - * You need to free it manually! - */ -+ (wchar_t*)concatAndFreeWideCStrings: (wchar_t**)strs; @end Index: src/OFXMLFactory.m ================================================================== --- src/OFXMLFactory.m +++ src/OFXMLFactory.m @@ -12,11 +12,10 @@ #import "config.h" #import #import #import -#import #import "OFXMLFactory.h" #import "OFExceptions.h" #import "OFMacros.h" @@ -35,38 +34,12 @@ size_t len2; if (add > SIZE_MAX - *len) @throw [OFOutOfRangeException newWithObject: nil]; len2 = *len + add; - - if ((str2 = realloc(*str, len2)) == NULL) { - if (*str) - free(*str); - *str = NULL; - return NO; - } - - *str = str2; - *len = len2; - - return YES; -} - -static inline BOOL -xf_resize_wchars(wchar_t **str, size_t *len, size_t add) -{ - wchar_t *str2; - size_t len2; - - if (add > SIZE_MAX - *len) - @throw [OFOutOfRangeException newWithObject: nil]; - len2 = *len + add; - - if (len2 > SIZE_MAX / sizeof(wchar_t)) - @throw [OFOutOfRangeException newWithObject: nil]; - - if ((str2 = realloc(*str, len2 * sizeof(wchar_t))) == NULL) { + + if ((str2 = realloc(*str, len2)) == NULL) { if (*str) free(*str); *str = NULL; return NO; } @@ -88,26 +61,10 @@ return NO; memcpy(*str + *pos, add, add_len); *pos += add_len; - return YES; -} - -static inline BOOL -xf_add2wchars(wchar_t **str, size_t *len, size_t *pos, const wchar_t *add) -{ - size_t add_len; - - add_len = wcslen(add); - - if (!xf_resize_wchars(str, len, add_len)) - return NO; - - wmemcpy(*str + *pos, add, add_len); - *pos += add_len; - return YES; } @implementation OFXMLFactory + (char*)escapeCString: (const char*)s @@ -157,79 +114,10 @@ "&"))) @throw [OFNoMemException newWithObject: nil andSize: nlen + 5]; break; - default: - ret[j++] = s[i]; - break; - } - } - - ret[j] = 0; - return ret; -} - -+ (wchar_t*)escapeWideCString: (const wchar_t*)s -{ - wchar_t *ret; - size_t i, j, len, nlen; - - len = nlen = wcslen(s); - if (SIZE_MAX - len < 1) - @throw [OFOutOfRangeException newWithObject: nil]; - nlen++; - - if (nlen > SIZE_MAX / sizeof(wchar_t)) - @throw [OFOutOfRangeException newWithObject: nil]; - - if ((ret = malloc(nlen * sizeof(wchar_t))) == NULL) - @throw [OFNoMemException newWithObject: nil - andSize: nlen * sizeof(wchar_t)]; - - for (i = j = 0; i < len; i++) { - switch (s[i]) { - case L'<': - if (OF_UNLIKELY(!xf_add2wchars(&ret, &nlen, &j, - L"<"))) - @throw [OFNoMemException - newWithObject: nil - andSize: (nlen + 4) * - sizeof(wchar_t)]; - break; - case L'>': - if (OF_UNLIKELY(!xf_add2wchars(&ret, &nlen, &j, - L">"))) - @throw [OFNoMemException - newWithObject: nil - andSize: (nlen + 4) * - sizeof(wchar_t)]; - break; - case L'"': - if (OF_UNLIKELY(!xf_add2wchars(&ret, &nlen, &j, - L"""))) - @throw [OFNoMemException - newWithObject: nil - andSize: (nlen + 6) * - sizeof(wchar_t)]; - break; - case L'\'': - if (OF_UNLIKELY(!xf_add2wchars(&ret, &nlen, &j, - L"'"))) - @throw [OFNoMemException - newWithObject: nil - andSize: (nlen + 6) * - sizeof(wchar_t)]; - break; - case L'&': - if (OF_UNLIKELY(!xf_add2wchars(&ret, &nlen, &j, - L"&"))) - @throw [OFNoMemException - newWithObject: nil - andSize: (nlen + 5) * - sizeof(wchar_t)]; - break; default: ret[j++] = s[i]; break; } } @@ -304,21 +192,21 @@ if (data == NULL) { if (!xf_resize_chars(&xml, &len, 2 - 1)) @throw [OFNoMemException newWithObject: nil andSize: len + 2 - 1]; - + xml[i++] = '/'; xml[i++] = '>'; } else { if (!xf_resize_chars(&xml, &len, 1 + strlen(data) + 2 + strlen(name) + 1 - 1)) @throw [OFNoMemException newWithObject: nil andSize: len + 1 + strlen(data) + 2 + strlen(name) + 1 - 1]; - + xml[i++] = '>'; memcpy(xml + i, data, strlen(data)); i += strlen(data); xml[i++] = '<'; xml[i++] = '/'; @@ -327,111 +215,10 @@ xml[i++] = '>'; } } else xml[i++] = '>'; - xml[i] = 0; - return xml; -} - -+ (wchar_t*)createWideStanza: (const wchar_t*)name - withCloseTag: (BOOL)close - andData: (const wchar_t*)data, ... -{ - wchar_t *arg, *val, *xml; - size_t i, len; - va_list args; - - /* Start of tag */ - len = wcslen(name); - if (SIZE_MAX - len < 3) - @throw [OFOutOfRangeException newWithObject: nil]; - len += 3; - - if (len > SIZE_MAX / sizeof(wchar_t)) - @throw [OFOutOfRangeException newWithObject: nil]; - - if ((xml = malloc(len * sizeof(wchar_t))) == NULL) - @throw [OFNoMemException newWithObject: nil - andSize: len * sizeof(wchar_t)]; - - i = 0; - xml[i++] = L'<'; - wmemcpy(xml + i, name, wcslen(name)); - i += wcslen(name); - - /* Arguments */ - va_start(args, data); - while ((arg = va_arg(args, wchar_t*)) != NULL && - (val = va_arg(args, wchar_t*)) != NULL) { - wchar_t *esc_val; - - if (OF_UNLIKELY((esc_val = - [OFXMLFactory escapeWideCString: val]) == NULL)) { - /* - * escapeWideCString already throws an exception, - * no need to throw a second one here. - */ - free(xml); - return NULL; - } - - if (OF_UNLIKELY(!xf_resize_wchars(&xml, &len, 1 + wcslen(arg) + - 2 + wcslen(esc_val) + 1))) { - free(esc_val); - @throw [OFNoMemException - newWithObject: nil - andSize: (len + 1 + wcslen(arg) + 2 + - wcslen(esc_val) + 1) * - sizeof(wchar_t)]; - } - - xml[i++] = L' '; - wmemcpy(xml + i, arg, wcslen(arg)); - i += wcslen(arg); - xml[i++] = L'='; - xml[i++] = L'\''; - wmemcpy(xml + i, esc_val, wcslen(esc_val)); - i += wcslen(esc_val); - xml[i++] = L'\''; - - free(esc_val); - } - va_end(args); - - /* End of tag */ - if (close) { - if (data == NULL) { - if (!xf_resize_wchars(&xml, &len, 2 - 1)) - @throw [OFNoMemException - newWithObject: nil - andSize: (len + 2 - 1) * - sizeof(wchar_t)]; - - xml[i++] = L'/'; - xml[i++] = L'>'; - } else { - if (!xf_resize_wchars(&xml, &len, 1 + wcslen(data) + - 2 + wcslen(name) + 1 - 1)) - @throw [OFNoMemException - newWithObject: nil - andSize: (len + 1 + wcslen(data) + 2 + - wcslen(name) + 1 - 1) * - sizeof(wchar_t)]; - - xml[i++] = L'>'; - wmemcpy(xml + i, data, wcslen(data)); - i += wcslen(data); - xml[i++] = L'<'; - xml[i++] = L'/'; - wmemcpy(xml + i, name, wcslen(name)); - i += wcslen(name); - xml[i++] = L'>'; - } - } else - xml[i++] = L'>'; - xml[i] = 0; return xml; } + (char*)concatAndFreeCStrings: (char**)strs @@ -444,11 +231,11 @@ len = strlen(*strs); if (SIZE_MAX - len < 1) @throw [OFOutOfRangeException newWithObject: nil]; len++; - + if ((ret = malloc(len)) == NULL) @throw [OFNoMemException newWithObject: nil andSize: len]; memcpy(ret, strs[0], len - 1); @@ -461,52 +248,12 @@ newWithObject: nil andSize: len + strlen(strs[i])]; } } - for (i = 0; strs[i] != NULL; i++) - free(strs[i]); - - ret[pos] = 0; - return ret; -} - -+ (wchar_t*)concatAndFreeWideCStrings: (wchar_t**)strs -{ - wchar_t *ret; - size_t i, len, pos; - - if (strs[0] == NULL) - return NULL; - - len = wcslen(*strs); - if (SIZE_MAX - len < 1) - @throw [OFOutOfRangeException newWithObject: nil]; - len++; - - if (len > SIZE_MAX - sizeof(wchar_t)) - @throw [OFOutOfRangeException newWithObject: nil]; - - if ((ret = malloc(len * sizeof(wchar_t))) == NULL) - @throw [OFNoMemException newWithObject: nil - andSize: len * sizeof(wchar_t)]; - - wmemcpy(ret, strs[0], len - 1); - pos = len - 1; - - for (i = 1; strs[i] != NULL; i++) { - if (!xf_add2wchars(&ret, &len, &pos, strs[i])) { - free(ret); - @throw [OFNoMemException - newWithObject: nil - andSize: (wcslen(strs[i]) + len) * - sizeof(wchar_t)]; - } - } - for (i = 0; strs[i] != NULL; i++) free(strs[i]); ret[pos] = 0; return ret; } @end Index: tests/OFList/OFList.m ================================================================== --- tests/OFList/OFList.m +++ tests/OFList/OFList.m @@ -9,28 +9,26 @@ * the packaging of this file. */ #import "config.h" -#define _ISOC99_SOURCE - +#import #import -#import #import "OFString.h" #import "OFList.h" #define NUM_TESTS 5 #define SUCCESS \ { \ - wprintf(L"\r\033[1;%dmTests successful: %d/%d\033[0m", \ + printf("\r\033[1;%dmTests successful: %d/%d\033[0m", \ (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS); \ fflush(stdout); \ } #define FAIL \ { \ - wprintf(L"\r\033[K\033[1;31mTest %d/%d failed!\033[m\n", \ + printf("\r\033[K\033[1;31mTest %d/%d failed!\033[m\n", \ i + 1, NUM_TESTS); \ return 1; \ } #define CHECK(cond) \ if (cond) \ @@ -37,14 +35,14 @@ SUCCESS \ else \ FAIL \ i++; -const wchar_t *strings[] = { - L"First String Object", - L"Second String Object", - L"Third String Object" +const char *strings[] = { + "First String Object", + "Second String Object", + "Third String Object" }; int main() { @@ -52,24 +50,24 @@ OFList *list; OFListObject *iter; list = [OFList new]; - [list addNew: [OFString newFromWideCString: strings[0]]]; - [list addNew: [OFString newFromWideCString: strings[1]]]; - [list addNew: [OFString newFromWideCString: strings[2]]]; + [list addNew: [OFString newFromCString: strings[0]]]; + [list addNew: [OFString newFromCString: strings[1]]]; + [list addNew: [OFString newFromCString: strings[2]]]; for (iter = [list first], i = 0; iter != nil; iter = [iter next], i++) - if (!wcscmp([(OFString*)[iter data] wideCString], strings[i])) + if (!strcmp([(OFString*)[iter data] cString], strings[i])) SUCCESS else FAIL - CHECK(!wcscmp([(OFString*)[[list first] data] wideCString], strings[0])) - CHECK(!wcscmp([(OFString*)[[list last] data] wideCString], strings[2])) + CHECK(!strcmp([(OFString*)[[list first] data] cString], strings[0])) + CHECK(!strcmp([(OFString*)[[list last] data] cString], strings[2])) - wprintf(L"\n"); + puts(""); [list freeIncludingData]; return 0; } Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -41,39 +41,39 @@ else { puts("s2 and s4 don't match!"); return 1; } - if (!strcmp([[s1 append: s2] getCString], "test123")) + if (!strcmp([[s1 append: s2] cString], "test123")) puts("s1 appended with s2 is the expected string! GOOD!"); else { puts("s1 appended with s2 is not the expected string!"); return 1; } - if (strlen([s1 getCString]) == [s1 length] && [s1 length] == 7) + if (strlen([s1 cString]) == [s1 length] && [s1 length] == 7) puts("s1 has the expected length. GOOD!"); else { puts("s1 does not have the expected length!"); return 1; } - if (!strcmp([[s1 reverse] getCString], "321tset")) + if (!strcmp([[s1 reverse] cString], "321tset")) puts("Reversed s1 is expected string! GOOD!"); else { puts("Reversed s1 is NOT the expected string!"); return 1; } - if (!strcmp([[s1 upper] getCString], "321TSET")) + if (!strcmp([[s1 upper] cString], "321TSET")) puts("Upper s1 is expected string! GOOD!"); else { puts("Upper s1 is NOT expected string!"); return 1; } - if (!strcmp([[s1 lower] getCString], "321tset")) + if (!strcmp([[s1 lower] cString], "321tset")) puts("Lower s1 is expected string! GOOD!"); else { puts("Lower s1 is NOT expected string!"); return 1; } Index: tests/OFXMLFactory/OFXMLFactory.m ================================================================== --- tests/OFXMLFactory/OFXMLFactory.m +++ tests/OFXMLFactory/OFXMLFactory.m @@ -9,15 +9,12 @@ * the packaging of this file. */ #import "config.h" -#define _ISOC99_SOURCE - #import #import -#import #import "OFXMLFactory.h" #define NUM_TESTS 10 @@ -24,40 +21,20 @@ static int i; inline void check_result(char *result, const char *should) { - /* Use wprintf here so we don't mix printf and wprintf! */ - i++; - - if (!strcmp(result, should)) { - wprintf(L"\r\033[1;%dmchar* tests successful: %2d/%d\033[0m", - (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS); - fflush(stdout); - } else { - wprintf(L"\r\033[K\033[1;31mchar* test %d/%d failed!\033[0m\n", - i, NUM_TESTS); - wprintf(L"%s is NOT expected result!\n", result); - exit(1); - } - - free(result); -} - -inline void -check_result_wide(wchar_t *result, const wchar_t *should) -{ - i++; - - if (!wcscmp(result, should)) { - wprintf(L"\r\033[1;%dmwchar_t* tests successful: %2d/%d\033[0m", - (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS); - fflush(stdout); - } else { - wprintf(L"\r\033[K\033[1;31mwchar_t* test %d/%d failed!\033[0m" - "\n", i, NUM_TESTS); - wprintf(L"%s is NOT expected result!\n", result); + i++; + + if (!strcmp(result, should)) { + printf("\r\033[1;%dmTests successful: %2d/%d\033[0m", + (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS); + fflush(stdout); + } else { + printf("\r\033[K\033[1;31mTest %d/%d failed!\033[0m\n", + i, NUM_TESTS); + printf("%s is NOT expected result!\n", result); exit(1); } free(result); } @@ -85,35 +62,10 @@ check_result([OFXMLFactory concatAndFreeCStrings: strs], "bar"); } -inline void -test_concat_wide() -{ - const wchar_t *c1 = L"", *c2 = L"bar", *c3 = L""; - wchar_t *s1, *s2, *s3; - wchar_t *strs[4]; - - if ((s1 = malloc((wcslen(c1) + 1) * sizeof(wchar_t))) == NULL || - (s2 = malloc((wcslen(c2) + 1) * sizeof(wchar_t))) == NULL || - (s3 = malloc((wcslen(c3) + 1) * sizeof(wchar_t))) == NULL) - exit(1); - - wcsncpy(s1, c1, wcslen(c1) + 1); - wcsncpy(s2, c2, wcslen(c2) + 1); - wcsncpy(s3, c3, wcslen(c3) + 1); - - strs[0] = s1; - strs[1] = s2; - strs[2] = s3; - strs[3] = NULL; - - check_result_wide([OFXMLFactory concatAndFreeWideCStrings: strs], - L"bar"); -} - inline void test_create_stanza() { check_result([OFXMLFactory createStanza: "foo" withCloseTag: NO @@ -165,92 +117,22 @@ "a", "b", NULL], "bar"); } -inline void -test_create_stanza_wide() -{ - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: NO - andData: NULL, - NULL], - L""); - - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: NO - andData: NULL, - L"bar", L"baz", - L"blub", L"asd", - NULL], - L""); - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: YES - andData: NULL, - NULL], - L""); - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: YES - andData: L"bar", - NULL], - L"bar"); - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: YES - andData: NULL, - L"bar", L"b&az", - NULL], - L""); - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: YES - andData: L"bar", - L"bar", L"b'az", - NULL], - L"bar"); - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: YES - andData: NULL, - L"bar", L"b&az", - L"x", L"asd\"", - NULL], - L""); - check_result_wide([OFXMLFactory createWideStanza: L"foo" - withCloseTag: YES - andData: L"bar", - L"bar", L"b'az", - L"x", L"y", - L"a", L"b", - NULL], - L"bar"); -} - inline void test_escape() { check_result([OFXMLFactory escapeCString: " &welt'\"!&"], "<hallo> &welt'"!&"); } - -inline void -test_escape_wide() -{ - check_result_wide( - [OFXMLFactory escapeWideCString: L" &welt'\"!&"], - L"<hallo> &welt'"!&"); -} - int main() { i = 0; test_escape(); test_create_stanza(); test_concat(); - wprintf(L"\n"); - - i = 0; - test_escape_wide(); - test_create_stanza_wide(); - test_concat_wide(); - wprintf(L"\n"); + puts(""); return 0; }