ObjFW  Check-in [b4ead4bdd2]

Overview
Comment:Fix a bug in OFWideString and add test for OFWideString.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b4ead4bdd2a5b8b1a9c7fd8029959f019b72b778042c9b90c0f48193c27f3365
User & Date: js on 2008-09-14 15:12:24
Other Links: manifest | tags
Context
2008-09-14
15:29
Coding style. check-in: 778be56179 user: js tags: trunk
15:12
Fix a bug in OFWideString and add test for OFWideString. check-in: b4ead4bdd2 user: js tags: trunk
12:53
Add OFWideString and OFConstWideString. check-in: 1fe9cb366e user: js tags: trunk
Changes

Modified Makefile from [365ae7cf3c] to [46a291b6bc].

1
2
3
4
SUBDIRS = src tests
DISTCLEAN = autom4te.cache buildsys.mk config.log

include buildsys.mk

|


1
2
3
4
SUBDIRS = src tests
DISTCLEAN = aclocal.m4 autom4te.cache buildsys.mk config.log config.status

include buildsys.mk

Modified src/OFWideString.m from [b821122f3b] to [f3e926533b].

100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
				      sizeof(wchar_t)]) == NULL) {
		/* FIXME: Add error handling */
		return nil;
	}

	wstring = newstr;

	memcpy(wstring + length, wstr, strlength);

	wstring[newlen] = '\0';

	length = newlen;

	return self;
}
@end







|
>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
				      sizeof(wchar_t)]) == NULL) {
		/* FIXME: Add error handling */
		return nil;
	}

	wstring = newstr;

	memcpy(wstring + length * sizeof(wchar_t), wstr,
	    strlength * sizeof(wchar_t));
	wstring[newlen] = '\0';

	length = newlen;

	return self;
}
@end

Modified tests/Makefile from [da5756f9a4] to [40930cdf32].

1
2
3
SUBDIRS = OFString OFList

include ../buildsys.mk
|


1
2
3
SUBDIRS = OFString OFList OFWideString

include ../buildsys.mk

Added tests/OFWideString/Makefile version [644bd3eb54].















>
>
>
>
>
>
>
1
2
3
4
5
6
7
PROG_NOINST = ofwidestring
SRCS = OFWideString.m

include ../../buildsys.mk

CPPFLAGS += -I../../src
LIBS += -lobjc -L../../src -lobjfw

Added tests/OFWideString/OFWideString.m version [2a8f622845].



























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * 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 <stdio.h>
#import <wchar.h>

#import "OFWideString.h"

int
main()
{
	OFWideString *s1 = [OFWideString new:L"foo"];
	OFWideString *s2 = [[OFWideString alloc] init:L""];
	OFWideString *s3;
	OFWideString *s4 = [OFWideString new];

	printf("%p\n", [s2 append:L"bar"]);
	s3 = [s1 clone];

	[s4 setTo:[s2 wcString]];

	wprintf(L"s1 = %S\n", [s1 wcString]);
	wprintf(L"s2 = %S\n", [s2 wcString]);
	wprintf(L"s3 = %S\n", [s3 wcString]);
	wprintf(L"s4 = %S\n", [s4 wcString]);

	[s1 append: [s2 wcString]];
	wprintf(L"s1 append s2 = %S\n", [s1 wcString]);
	wprintf(L"strlen(s1) = %zd, [s1 length] = %zd\n",
	    wcslen([s1 wcString]), [s1 length]);
	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	return 0;
}