From 2a513e211797a7a35e6e426c709a8e22e1780212 Mon Sep 17 00:00:00 2001 From: mccallum Date: Mon, 6 May 1996 18:59:01 +0000 Subject: [PATCH] All uses of @"" were crashing in Linux libc-5.3.9. (arginfo_func): New function. (handle_printf_atsign): Get the string object without va_arg(). ([NSString +initialize]): Use new function. (Reported and fixed by Kai-Uwe Sattler .) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1492 72102866-910b-0410-8b05-ffd578937521 --- Source/NSString.m | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/NSString.m b/Source/NSString.m index f00384f1c..3bd41e556 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -99,18 +99,28 @@ static Class NSMutableString_c_concrete_class; #include #include #include -int + +static int +arginfo_func (const struct printf_info *info, + size_t n, + int *argtypes) { + *argtypes = PA_POINTER; + return 1; +} + +static int handle_printf_atsign (FILE *stream, const struct printf_info *info, - va_list *ap_pointer) + const void **const args) { + const void *ptr = *args; 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, id); + string_object = *((id *) ptr); len = fprintf(stream, "%*s", (info->left ? - info->width : info->width), [string_object cStringNoCopy]); @@ -133,7 +143,7 @@ handle_printf_atsign (FILE *stream, #if HAVE_REGISTER_PRINTF_FUNCTION if (register_printf_function ('@', (printf_function)handle_printf_atsign, - NULL)) + (printf_arginfo_function)arginfo_func)) [NSException raise: NSGenericException format: @"register printf handling of %%@ failed"]; #endif /* HAVE_REGISTER_PRINTF_FUNCTION */