mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
* 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. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17084 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a8fd582a87
commit
f1fb026bb9
5 changed files with 77 additions and 62 deletions
|
@ -1,3 +1,11 @@
|
|||
2003-07-01 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* 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.
|
||||
|
||||
2003-07-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/Unicode.m: Flush iconv buffer at end of conversion
|
||||
|
|
|
@ -407,6 +407,23 @@ GSAutoreleasedBuffer(unsigned size);
|
|||
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
|
||||
|
|
|
@ -47,7 +47,6 @@ GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler;
|
|||
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, ...);
|
||||
|
|
|
@ -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>
|
||||
|
@ -1513,3 +1515,50 @@ GSLastErrorStr(long error_id)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -186,10 +186,11 @@ NSLog_printf_handler *_NSLog_printf_handler = _NSLog_standard_printf_handler;
|
|||
* 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
|
||||
|
@ -272,62 +273,3 @@ NSLogv (NSString* format, va_list args)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue