Author: rfm
Date: Sat Aug 29 22:25:16 2015
New Revision: 38947

URL: http://svn.gna.org/viewcvs/gnustep?rev=38947&view=rev
Log:
keep old format if there are no nul bytes to print

Modified:
    libs/base/trunk/Source/GSHTTPURLHandle.m

Modified: libs/base/trunk/Source/GSHTTPURLHandle.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSHTTPURLHandle.m?rev=38947&r1=38946&r2=38947&view=diff
==============================================================================
--- libs/base/trunk/Source/GSHTTPURLHandle.m    (original)
+++ libs/base/trunk/Source/GSHTTPURLHandle.m    Sat Aug 29 22:25:16 2015
@@ -232,19 +232,43 @@
 debugRead(GSHTTPURLHandle *handle, NSData *data)
 {
   unsigned     len = (unsigned)[data length];
-  char         *esc = [data escapedRepresentation: 0];
-
-  NSLog(@"Read for %p of %u bytes - '%s'\n%@", handle, len, esc, data); 
-  free(esc);
+  const char   *ptr = (const char*)[data bytes];
+  int           pos;
+
+  for (pos = 0; pos < len; pos++)
+    {
+      if (0 == ptr[pos])
+        {
+          char  *esc = [data escapedRepresentation: 0];
+
+          NSLog(@"Read for %p of %u bytes (escaped) - '%s'\n%@",
+            handle, len, esc, data); 
+          free(esc);
+          return;
+        }
+    }
+  NSLog(@"Read for %p of %d bytes - '%*.*s'", handle, len, len, len, ptr); 
 }
 static void
 debugWrite(GSHTTPURLHandle *handle, NSData *data)
 {
   unsigned     len = (unsigned)[data length];
-  char         *esc = [data escapedRepresentation: 0];
-
-  NSLog(@"Write for %p of %u bytes - '%s'\n%@", handle, len, esc, data); 
-  free(esc);
+  const char   *ptr = (const char*)[data bytes];
+  int           pos;
+
+  for (pos = 0; pos < len; pos++)
+    {
+      if (0 == ptr[pos])
+        {
+          char  *esc = [data escapedRepresentation: 0];
+
+          NSLog(@"Write for %p of %u bytes (escaped) - '%s'\n%@",
+            handle, len, esc, data); 
+          free(esc);
+          return;
+        }
+    }
+  NSLog(@"Write for %p of %d bytes - '%*.*s'", handle, len, len, len, ptr); 
 }
 
 + (NSURLHandle*) cachedHandleForURL: (NSURL*)newUrl


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

Reply via email to