Don't use private ObjFW functions
FossilOrigin-Name: 3e008e29646a6eaeccbc4560352d3444691e9bee4da9ef70be30408df6ecb4b1
This commit is contained in:
parent
8c6a7d082b
commit
a881575bf3
1 changed files with 10 additions and 16 deletions
|
@ -43,34 +43,28 @@
|
||||||
|
|
||||||
- (instancetype)initWithString: (OFString *)string
|
- (instancetype)initWithString: (OFString *)string
|
||||||
{
|
{
|
||||||
char *tmp2 = NULL;
|
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
char *tmp;
|
size_t pos;
|
||||||
|
|
||||||
tmp2 = OFStrDup(string.UTF8String);
|
pos = [string rangeOfString: @"@"].location;
|
||||||
|
if (pos == OFNotFound)
|
||||||
if ((tmp = strchr(tmp2, '@')) == NULL)
|
|
||||||
@throw [OFInvalidFormatException exception];
|
@throw [OFInvalidFormatException exception];
|
||||||
|
|
||||||
*tmp = '\0';
|
_hostname = [[string substringFromIndex: pos + 1] copy];
|
||||||
_hostname = [[OFString alloc] initWithUTF8String: tmp + 1];
|
|
||||||
|
|
||||||
if ((tmp = strchr(tmp2, '!')) == NULL)
|
string = [string substringToIndex: pos];
|
||||||
|
|
||||||
|
pos = [string rangeOfString: @"!"].location;
|
||||||
|
if (pos == OFNotFound)
|
||||||
@throw [OFInvalidFormatException exception];
|
@throw [OFInvalidFormatException exception];
|
||||||
|
|
||||||
*tmp = '\0';
|
_username = [[string substringFromIndex: pos + 1] copy];
|
||||||
_username = [[OFString alloc] initWithUTF8String: tmp + 1];
|
_nickname = [[string substringToIndex: pos] copy];
|
||||||
|
|
||||||
_nickname = [[OFString alloc] initWithUTF8String: tmp2];
|
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
@throw e;
|
@throw e;
|
||||||
} @finally {
|
|
||||||
if (tmp2 != NULL)
|
|
||||||
free(tmp2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue