This new code, #if HAVE_REGISTER_PRINTF_FUNCTION, a function defined

by GNU libc.
(handle_printf_atsign): New function to handle %@ in printf strings.
([NSString +initialize]): Register the new printf-handler function.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@779 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-01-23 23:30:05 +00:00
parent 5afcd8233e
commit 5f48440f84

View file

@ -91,6 +91,24 @@ static Class NSMutableString_c_concrete_class;
return NSMutableString_c_concrete_class;
}
#if HAVE_REGISTER_PRINTF_FUNCTION
int handle_printf_atsign (FILE *stream, const struct printf_info *info,
va_list *ap_pointer)
{
id string_object;
int len;
/* xxx This implementation may not pay pay attention to as much
of printf_info as it should. */
string_object = va_arg (*ap_pointer, void*);
len = fprintf(stream, "%*s",
(info->left ? - info->width : info->width),
[string_object cStringNoCopy]);
return len;
}
#endif /* HAVE_REGISTER_PRINTF_FUNCTION */
+ (void) initialize
{
static int done = 0;
@ -102,6 +120,11 @@ static Class NSMutableString_c_concrete_class;
NSString_c_concrete_class = [NSGCString class];
NSMutableString_concrete_class = [NSGMutableCString class];
NSMutableString_c_concrete_class = [NSGMutableCString class];
#if HAVE_REGISTER_PRINTF_FUNCTION
if (register_printf_function ('@', handle_printf_atsign, NULL))
[self error: "register printf handling of %%@ failed"];
#endif /* HAVE_REGISTER_PRINTF_FUNCTION */
}
}