Overview
Comment: | Fix FIXMEs in OFString; new exception. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4f7378978c0b0bdc7da4bf482158eded |
User & Date: | js on 2008-12-10 20:53:13 |
Other Links: | manifest | tags |
Context
2008-12-11
| ||
13:43 |
Remove - close from OFStream protocol. The reason is that closing a file isn't too useful, because an OFFile object can't be reused, whereas an OFTCPSocket can. So only the OFTCPSocket should have closed. Plus, we don't need to handle the case that someone tried to read from / write to a closed OFFile. check-in: c83137e7cd user: js tags: trunk | |
2008-12-10
| ||
20:53 | Fix FIXMEs in OFString; new exception. check-in: 4f7378978c user: js tags: trunk | |
18:00 | Enhance exceptions; fix some FIXMEs in OFTCPSocket. check-in: a01c94d9dd user: js tags: trunk | |
Changes
Modified src/OFExceptions.h from [077a4ec303] to [d80b50b5d0].
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | @end /** * An OFException indicating the given value is out of range. */ @interface OFOutOfRangeException: OFException {} /** * \return An error message for the exception as a C String */ - (char*)cString; @end /** * An OFException indicating the file couldn't be opened. | > > > > > > > > > > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | @end /** * An OFException indicating the given value is out of range. */ @interface OFOutOfRangeException: OFException {} /** * \return An error message for the exception as a C String */ - (char*)cString; @end /** * An OFException indicating that the conversation between two charsets failed. */ @interface OFCharsetConversionFailedException: OFException {} /** * \return An error message for the exception as a C String */ - (char*)cString; @end /** * An OFException indicating the file couldn't be opened. |
︙ | ︙ |
Modified src/OFExceptions.m from [47e102896c] to [5e428f851d].
︙ | ︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 | { if (string != NULL) return string; asprintf(&string, "Value out of range in object of class %s!", object != nil ? [object name] : "(null)"); return string; } @end @implementation OFOpenFileFailedException + newWithObject: (id)obj andPath: (const char*)p | > > > > > > > > > > > > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | { if (string != NULL) return string; asprintf(&string, "Value out of range in object of class %s!", object != nil ? [object name] : "(null)"); return string; } @end @implementation OFCharsetConversionFailedException - (char*)cString { if (string != NULL) return string; asprintf(&string, "Charset conversion failed in object of classs %s!", [object name]); return string; } @end @implementation OFOpenFileFailedException + newWithObject: (id)obj andPath: (const char*)p |
︙ | ︙ |
Modified src/OFString.m from [56af24d281] to [f6358fc52b].
︙ | ︙ | |||
49 50 51 52 53 54 55 | { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { if ((length = mbstowcs(NULL, str, 0)) == (size_t)-1) { | < > | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | { 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]; |
︙ | ︙ | |||
89 90 91 92 93 94 95 | } - (char*)getCString { char *str; size_t len; | | | < < < < > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | } - (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; } - (wchar_t*)wideCString { |
︙ | ︙ | |||
144 145 146 147 148 149 150 | { wchar_t *newstr, *tmpstr; size_t newlen, strlength; if (string == NULL) return [self setTo: [OFString newFromCString: str]]; | | | < < < < > | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | { wchar_t *newstr, *tmpstr; 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)]; |
︙ | ︙ |