Author: rfm
Date: Sun Aug 30 09:28:26 2015
New Revision: 38953

URL: http://svn.gna.org/viewcvs/gnustep?rev=38953&view=rev
Log:
Use base64 in gnustep property lists

Modified:
    libs/base/trunk/Source/NSPropertyList.m
    libs/base/trunk/Tests/base/PropertyLists/test01.m

Modified: libs/base/trunk/Source/NSPropertyList.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSPropertyList.m?rev=38953&r1=38952&r2=38953&view=diff
==============================================================================
--- libs/base/trunk/Source/NSPropertyList.m     (original)
+++ libs/base/trunk/Source/NSPropertyList.m     Sun Aug 30 09:28:26 2015
@@ -1970,12 +1970,18 @@
     }
   else if ([obj isKindOfClass: NSDataClass])
     {
-      if (x == NSPropertyListXMLFormat_v1_0)
+      if (NSPropertyListXMLFormat_v1_0 == x)
        {
          [dest appendBytes: "<data>\n" length: 7];
          encodeBase64(obj, dest);
          [dest appendBytes: "</data>\n" length: 8];
        }
+      else if (NSPropertyListGNUstepFormat == x)
+        {
+          [dest appendBytes: "<[" length: 2];
+         encodeBase64(obj, dest);
+          [dest appendBytes: "]>" length: 2];
+        }
       else
        {
          const unsigned char   *src;

Modified: libs/base/trunk/Tests/base/PropertyLists/test01.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/PropertyLists/test01.m?rev=38953&r1=38952&r2=38953&view=diff
==============================================================================
--- libs/base/trunk/Tests/base/PropertyLists/test01.m   (original)
+++ libs/base/trunk/Tests/base/PropertyLists/test01.m   Sun Aug 30 09:28:26 2015
@@ -78,6 +78,21 @@
     errorDescription: 0];
   return [u isEqual: object];
 }
+static BOOL
+test_parse_unparse_gnustep(id object)
+{
+  NSPropertyListFormat format;
+  NSData               *d;
+  id                   u;
+
+  d = [NSPropertyListSerialization dataFromPropertyList: object
+    format: NSPropertyListGNUstepFormat errorDescription: 0];
+  u = [NSPropertyListSerialization propertyListFromData: d
+    mutabilityOption: NSPropertyListImmutable
+    format: &format
+    errorDescription: 0];
+  return [u isEqual: object];
+}
 #endif
 
 int main()
@@ -86,7 +101,7 @@
   int  i;
   NSAutoreleasePool   *arp = [NSAutoreleasePool new];
 
-  for (i = 0; i < 5; i++)
+  for (i = 0; i < 6; i++)
     {
       switch (i)
         {
@@ -106,6 +121,13 @@
            func = test_parse_unparse_openstep;
            NSLog(@"test OpenStep");
            break;
+         case 4:
+#if     defined(GNUSTEP_BASE_LIBRARY)
+           func = test_parse_unparse_gnustep;
+           NSLog(@"test GNUStep text");
+#else
+           func = 0;
+#endif
          case 5:
 #if     defined(GNUSTEP_BASE_LIBRARY)
            func = test_parse_unparse_binary_old;
@@ -120,6 +142,9 @@
 
       PASS(func(@"ariosto"),
           "We can generate a property list from a string");
+
+      PASS(func([@"ariosto" dataUsingEncoding: NSASCIIStringEncoding]),
+          "We can generate a property list from data");
 
       PASS(func([NSArray array]),
           "We can generate a property list from an empty array");


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to