+2005-02-08 Helge Hess <helge.hess@opengroupware.org>
+
+ * FdExt.subproj/NSString+misc.m: added new method
+ -stringByApplyingMailQuoting for placing "> " in front of each line
+ contained in the string (v4.5.142)
+
2005-01-09 Helge Hess <helge.hess@opengroupware.org>
* NGExtensions/AutoDefines.h, common.h: fixed defines on MacOSX (fixes
@end /* NSString(NGScanning) */
+
+@implementation NSString(MailQuoting)
+
+- (NSString *)stringByApplyingMailQuoting {
+ NSString *s;
+ unsigned i, len, nl;
+ unichar *sourceBuf, *targetBuf;
+
+ if ((len = [self length]) == 0)
+ return @"";
+
+ sourceBuf = malloc((len + 4) * sizeof(unichar));
+ [self getCharacters:sourceBuf];
+
+ for (nl = 0, i = 0; i < len; i++) {
+ if (sourceBuf[i] == '\n')
+ nl++;
+ }
+
+ if (nl == 0) {
+ if (sourceBuf) free(sourceBuf);
+ return [@"> " stringByAppendingString:self];
+ }
+
+ targetBuf = malloc((len + 8 + (nl * 3)) * sizeof(unichar));
+ targetBuf[0] = '>';
+ targetBuf[1] = ' ';
+ nl = 2;
+
+ for (i = 0; i < len; i++) {
+ targetBuf[nl] = sourceBuf[i];
+ nl++;
+
+ if (sourceBuf[i] == '\n') {
+ targetBuf[nl] = '>'; nl++;
+ targetBuf[nl] = ' '; nl++;
+ }
+ }
+
+ s = [[NSString alloc] initWithCharacters:targetBuf length:nl];
+ if (targetBuf) free(targetBuf);
+ if (sourceBuf) free(sourceBuf);
+ return [s autorelease];
+}
+
+@end /* NSString(MailQuoting) */
+
// linking
void __link_NSString_misc(void) {