[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Discuss-gnustep Digest, Vol 8, Issue 1
From: |
David Ayers |
Subject: |
Re: Discuss-gnustep Digest, Vol 8, Issue 1 |
Date: |
Tue, 01 Jul 2003 19:05:26 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507 |
Adam Fedor wrote:
Sure go ahead. I was thinking the same thing. Although there is
documentation for the function which didn't seem to go to the right
place when I made the Documentation.
* Headers/gnustep/base/GSObjCRuntime.h/m (GSPrintf),
* Headers/gnustep/base/NSObjCRuntime.h (GSPrintf),
* Source/NSLog.m (GSPrintf): Moved implementation from NSLog.m to
GSObjCRuntime.m and declaration from NSObjCRuntime.h to
GSObjCRuntime.h.
Commited.
Please update from CVS if available and let me know if Additions
compiles and you can produce executables now.
Cheers,
David
Index: Headers/gnustep/base/GSObjCRuntime.h
===================================================================
RCS file:
/cvsroot/gnustep/gnustep/core/base/Headers/gnustep/base/GSObjCRuntime.h,v
retrieving revision 1.18
diff -u -r1.18 GSObjCRuntime.h
--- Headers/gnustep/base/GSObjCRuntime.h 28 Jun 2003 05:25:30 -0000
1.18
+++ Headers/gnustep/base/GSObjCRuntime.h 1 Jul 2003 16:55:11 -0000
@@ -407,6 +407,23 @@
GS_EXPORT const char *
GSLastErrorStr(long error_id);
+/**
+ * <p>Prints a message to fptr using the format string provided and any
+ * additional arguments. The format string is interpreted as by
+ * the NSString formatted initialisers, and understands the '%@' syntax
+ * for printing an object.
+ * </p>
+ * <p>The data is written to the file pointer in the default CString
+ * encoding if possible, as a UTF8 string otherwise.
+ * </p>
+ * <p>This function is recommended for printing general log messages.
+ * For debug messages use NSDebugLog() and friends. For error logging
+ * use NSLog(), and for warnings you might consider NSWarnLog().
+ * </p>
+ */
+GS_EXPORT BOOL
+GSPrintf (FILE *fptr, NSString *format, ...);
+
#ifndef NO_DEPRECATED
Index: Headers/gnustep/base/NSObjCRuntime.h
===================================================================
RCS file:
/cvsroot/gnustep/gnustep/core/base/Headers/gnustep/base/NSObjCRuntime.h,v
retrieving revision 1.41
diff -u -r1.41 NSObjCRuntime.h
--- Headers/gnustep/base/NSObjCRuntime.h 27 Nov 2002 12:52:28 -0000
1.41
+++ Headers/gnustep/base/NSObjCRuntime.h 1 Jul 2003 16:55:11 -0000
@@ -47,7 +47,6 @@
GS_EXPORT int _NSLogDescriptor;
@class NSRecursiveLock;
GS_EXPORT NSRecursiveLock *GSLogLock(void);
-GS_EXPORT BOOL GSPrintf (FILE *fptr, NSString *format, ...);
#endif
GS_EXPORT void NSLog (NSString *format, ...);
Index: Source/NSLog.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSLog.m,v
retrieving revision 1.41
diff -u -r1.41 NSLog.m
--- Source/NSLog.m 7 Jun 2003 01:24:41 -0000 1.41
+++ Source/NSLog.m 1 Jul 2003 16:55:11 -0000
@@ -186,10 +186,11 @@
* the lower level NSLogv() function (which this function uses).
* </p>
* <p>GNUstep provides powerful alternatives for logging ... see
- * NSDebugLog(), NSWarnLog(), and GSPrintf() for example. We recommend
+ * NSDebugLog(), NSWarnLog() and GSPrintf() for example. We recommend
* the use of NSDebugLog() and its relatives for debug purposes, and
* GSPrintf() for general log messages, with NSLog() being reserved
- * for reporting possible/likely errors.
+ * for reporting possible/likely errors. GSPrintf() is declared in
+ * GSObjCRuntime.h.
* </p>
*/
void
@@ -270,64 +271,5 @@
[myLock unlock];
RELEASE(arp);
-}
-
-/**
- * <p>Prints a message to fptr using the format string provided and any
- * additional arguments. The format string is interpreted as by
- * the NSString formatted initialisers, and understands the '%@' syntax
- * for printing an object.
- * </p>
- * <p>The data is written to the file pointer in the default CString
- * encoding if possible, as a UTF8 string otherwise.
- * </p>
- * <p>This function is recommended for printing general log messages.
- * For debug messages use NSDebugLog() and friends. For error logging
- * use NSLog(), and for warnings you might consider NSWarnLog().
- * </p>
- */
-BOOL
-GSPrintf (FILE *fptr, NSString* format, ...)
-{
- static Class stringClass = 0;
- static NSStringEncoding enc;
- CREATE_AUTORELEASE_POOL(arp);
- va_list ap;
- NSString *message;
- NSData *data;
- BOOL ok = NO;
-
- if (stringClass == 0)
- {
- [gnustep_global_lock lock];
- if (stringClass == 0)
- {
- stringClass = [NSString class];
- enc = [stringClass defaultCStringEncoding];
- }
- [gnustep_global_lock unlock];
- }
- message = [stringClass allocWithZone: NSDefaultMallocZone()];
- va_start (ap, format);
- message = [message initWithFormat: format locale: nil arguments: ap];
- va_end (ap);
- data = [message dataUsingEncoding: enc];
- if (data == nil)
- {
- data = [message dataUsingEncoding: NSUTF8StringEncoding];
- }
- RELEASE(message);
-
- if (data != nil)
- {
- unsigned int length = [data length];
-
- if (length == 0 || fwrite([data bytes], 1, length, fptr) == length)
- {
- ok = YES;
- }
- }
- RELEASE(arp);
- return ok;
}
Index: Source/Additions/GSObjCRuntime.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/Additions/GSObjCRuntime.m,v
retrieving revision 1.20
diff -u -r1.20 GSObjCRuntime.m
--- Source/Additions/GSObjCRuntime.m 22 Jun 2003 08:45:48 -0000 1.20
+++ Source/Additions/GSObjCRuntime.m 1 Jul 2003 16:55:11 -0000
@@ -33,9 +33,11 @@
#ifndef NeXT_Foundation_LIBRARY
#include <Foundation/NSArray.h>
#include <Foundation/NSAutoreleasePool.h>
+#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSException.h>
+#include <Foundation/NSLock.h>
#include <Foundation/NSMethodSignature.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSSet.h>
@@ -1512,4 +1514,51 @@
#else
return strerror(error_id);
#endif
+}
+
+
+
+BOOL
+GSPrintf (FILE *fptr, NSString* format, ...)
+{
+ static Class stringClass = 0;
+ static NSStringEncoding enc;
+ CREATE_AUTORELEASE_POOL(arp);
+ va_list ap;
+ NSString *message;
+ NSData *data;
+ BOOL ok = NO;
+
+ if (stringClass == 0)
+ {
+ [gnustep_global_lock lock];
+ if (stringClass == 0)
+ {
+ stringClass = [NSString class];
+ enc = [stringClass defaultCStringEncoding];
+ }
+ [gnustep_global_lock unlock];
+ }
+ message = [stringClass allocWithZone: NSDefaultMallocZone()];
+ va_start (ap, format);
+ message = [message initWithFormat: format locale: nil arguments: ap];
+ va_end (ap);
+ data = [message dataUsingEncoding: enc];
+ if (data == nil)
+ {
+ data = [message dataUsingEncoding: NSUTF8StringEncoding];
+ }
+ RELEASE(message);
+
+ if (data != nil)
+ {
+ unsigned int length = [data length];
+
+ if (length == 0 || fwrite([data bytes], 1, length, fptr) == length)
+ {
+ ok = YES;
+ }
+ }
+ RELEASE(arp);
+ return ok;
}