Author: rfm
Date: Tue Jun 30 10:41:38 2015
New Revision: 38721
URL: http://svn.gna.org/viewcvs/gnustep?rev=38721&view=rev
Log:
Tidy to match conding conventions
Modified:
libs/base/trunk/Headers/Foundation/NSData.h
libs/base/trunk/Source/NSData.m
Modified: libs/base/trunk/Headers/Foundation/NSData.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/Foundation/NSData.h?rev=38721&r1=38720&r2=38721&view=diff
==============================================================================
--- libs/base/trunk/Headers/Foundation/NSData.h (original)
+++ libs/base/trunk/Headers/Foundation/NSData.h Tue Jun 30 10:41:38 2015
@@ -123,8 +123,8 @@
// base64
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9,GS_API_LATEST)
-- (NSData *)base64EncodedDataWithOptions:(NSDataBase64EncodingOptions)options;
-- (NSString
*)base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)options;
+- (NSData *) base64EncodedDataWithOptions:
(NSDataBase64EncodingOptions)options;
+- (NSString *) base64EncodedStringWithOptions:
(NSDataBase64EncodingOptions)options;
#endif
// Querying a Data Object
Modified: libs/base/trunk/Source/NSData.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSData.m?rev=38721&r1=38720&r2=38721&view=diff
==============================================================================
--- libs/base/trunk/Source/NSData.m (original)
+++ libs/base/trunk/Source/NSData.m Tue Jun 30 10:41:38 2015
@@ -150,8 +150,14 @@
static char b64[]
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const int crlf64 = NSDataBase64EncodingEndLineWithCarriageReturn
+ | NSDataBase64EncodingEndLineWithLineFeed;
+
static NSUInteger
-encodebase64(unsigned char **dstRef, const unsigned char *src, NSUInteger
length, NSDataBase64EncodingOptions options)
+encodebase64(unsigned char **dstRef,
+ const unsigned char *src,
+ NSUInteger length,
+ NSDataBase64EncodingOptions options)
{
unsigned char *dst;
NSUInteger dIndex = 0;
@@ -166,11 +172,12 @@
else if (options & NSDataBase64Encoding76CharacterLineLength)
lineLength = 76;
- /* if no EndLine options are set but a line length is given, CR+LF is
implied */
- if (lineLength && !(options & NSDataBase64EncodingEndLineWithCarriageReturn)
&& !(options & NSDataBase64EncodingEndLineWithLineFeed))
- {
- options |= NSDataBase64EncodingEndLineWithCarriageReturn;
- options |= NSDataBase64EncodingEndLineWithLineFeed;
+ /* if no EndLine options are set but a line length is given,
+ * CR+LF is implied
+ */
+ if (lineLength && !(options & crlf64))
+ {
+ options |= crlf64;
}
/* estimate destination length */
@@ -178,10 +185,10 @@
/* we need to take in account line-endings */
if (lineLength)
{
- if (options & (NSDataBase64EncodingEndLineWithCarriageReturn |
NSDataBase64EncodingEndLineWithLineFeed))
- destLen += (destLen / lineLength)*2;
+ if ((options & crlf64) == crlf64)
+ destLen += (destLen / lineLength)*2; // CR and LF
else
- destLen += (destLen / lineLength);
+ destLen += (destLen / lineLength); // CR or LF
}
#if GS_WITH_GC
@@ -1041,28 +1048,37 @@
return [NSData dataWithBytesNoCopy: buffer length: aRange.length];
}
-- (NSData *)base64EncodedDataWithOptions:(NSDataBase64EncodingOptions)options
-{
- void *srcBytes = (void*)[self bytes];
- NSUInteger length = [self length];
- NSUInteger resLen;
+- (NSData *) base64EncodedDataWithOptions: (NSDataBase64EncodingOptions)options
+{
+ void *srcBytes = (void*)[self bytes];
+ NSUInteger length = [self length];
+ NSUInteger resLen;
unsigned char *resBytes;
+ NSData *result;
resLen = encodebase64(&resBytes, srcBytes, length, options);
- return AUTORELEASE([[NSData alloc] initWithBytesNoCopy: resBytes length:
resLen freeWhenDone: YES]);
-}
-
-- (NSString
*)base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)options
-{
- void *srcBytes = (void*)[self bytes];
- NSUInteger length = [self length];
- NSUInteger resLen;
+ result = [[NSData alloc] initWithBytesNoCopy: resBytes
+ length: resLen
+ freeWhenDone: YES];
+ return AUTORELEASE(result);
+}
+
+- (NSString *) base64EncodedStringWithOptions:
+ (NSDataBase64EncodingOptions)options
+{
+ void *srcBytes = (void*)[self bytes];
+ NSUInteger length = [self length];
+ NSUInteger resLen;
unsigned char *resBytes;
+ NSString *result;
resLen = encodebase64(&resBytes, srcBytes, length, options);
- return AUTORELEASE([[NSString alloc] initWithBytesNoCopy: resBytes length:
resLen encoding: NSASCIIStringEncoding freeWhenDone: YES]);
-}
-
+ result = [[NSString alloc] initWithBytesNoCopy: resBytes
+ length: resLen
+ encoding: NSASCIIStringEncoding
+ freeWhenDone: YES];
+ return AUTORELEASE(result);
+}
- (NSUInteger) hash
{
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs