diff --git a/ChangeLog b/ChangeLog index fe5900c12..1db57fc35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ Documented the class. * Source/NSData.m: ([-writeToFile:atomically:]) implement workaround for bug in windoze implementation of rename() + * Source/NSString.m: Remove some redundant code duplicating stuff in + GSMime.m 2002-09-15 Richard Frith-Macdonald diff --git a/Source/NSString.m b/Source/NSString.m index 58ae74d3c..8efa5c0a4 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -4387,63 +4388,7 @@ handle_printf_atsign (FILE *stream, #ifdef HAVE_LIBXML #include - static int XML_ELEMENT_NODE; - -static void -decodeBase64Unit(const char* ptr, unsigned char *out) -{ - out[0] = (ptr[0] << 2) | ((ptr[1] & 0x30) >> 4); - out[1] = ((ptr[1] & 0x0F) << 4) | ((ptr[2] & 0x3C) >> 2); - out[2] = ((ptr[2] & 0x03) << 6) | (ptr[3] & 0x3F); - out[3] = 0; -} - -static NSData* -decodeBase64(const char *source) -{ - int length = strlen(source); - char *sourceBuffer; - NSMutableData *data; - int i; - int j; - unsigned char tmp[4]; - - if (length == 0) - { - return [NSData data]; - } - - data = [NSMutableData dataWithCapacity: 0]; - sourceBuffer = objc_malloc(length+1); - strcpy(sourceBuffer, source); - j = 0; - - for (i = 0; i < length; i++) - { - if (!isspace(source[i])) - { - sourceBuffer[j++] = source[i]; - } - } - - sourceBuffer[j] = '\0'; - length = strlen(sourceBuffer); - while (length > 0 && sourceBuffer[length-1] == '=') - { - sourceBuffer[--length] = '\0'; - } - for (i = 0; i < length; i += 4) - { - decodeBase64Unit(&sourceBuffer[i], tmp); - [data appendBytes: tmp length: strlen(tmp)]; - } - - objc_free(sourceBuffer); - - return data; -} - #endif #define inrange(ch,min,max) ((ch)>=(min) && (ch)<=(max)) @@ -5120,7 +5065,7 @@ nodeToObject(GSXMLNode* node) } else if ([name isEqualToString: @"data"]) { - return decodeBase64([content cString]); + return [GSMimeDocument decodeBase64String: content]; } // container class else if ([name isEqualToString: @"array"])