mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 17:10:48 +00:00
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 <sattler@volker.cs.Uni-Magdeburg.DE>.) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1492 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e74c56158b
commit
b00a575e5e
1 changed files with 14 additions and 4 deletions
|
@ -99,18 +99,28 @@ static Class NSMutableString_c_concrete_class;
|
|||
#include <stdio.h>
|
||||
#include <printf.h>
|
||||
#include <stdarg.h>
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue