mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
5afcd8233e
commit
5f48440f84
1 changed files with 23 additions and 0 deletions
|
@ -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 */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue