mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 01:21:08 +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
9d1d627729
commit
2a513e2117
1 changed files with 14 additions and 4 deletions
|
@ -99,18 +99,28 @@ static Class NSMutableString_c_concrete_class;
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <printf.h>
|
#include <printf.h>
|
||||||
#include <stdarg.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,
|
handle_printf_atsign (FILE *stream,
|
||||||
const struct printf_info *info,
|
const struct printf_info *info,
|
||||||
va_list *ap_pointer)
|
const void **const args)
|
||||||
{
|
{
|
||||||
|
const void *ptr = *args;
|
||||||
id string_object;
|
id string_object;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* xxx This implementation may not pay pay attention to as much
|
/* xxx This implementation may not pay pay attention to as much
|
||||||
of printf_info as it should. */
|
of printf_info as it should. */
|
||||||
|
|
||||||
string_object = va_arg (*ap_pointer, id);
|
string_object = *((id *) ptr);
|
||||||
len = fprintf(stream, "%*s",
|
len = fprintf(stream, "%*s",
|
||||||
(info->left ? - info->width : info->width),
|
(info->left ? - info->width : info->width),
|
||||||
[string_object cStringNoCopy]);
|
[string_object cStringNoCopy]);
|
||||||
|
@ -133,7 +143,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
#if HAVE_REGISTER_PRINTF_FUNCTION
|
#if HAVE_REGISTER_PRINTF_FUNCTION
|
||||||
if (register_printf_function ('@',
|
if (register_printf_function ('@',
|
||||||
(printf_function)handle_printf_atsign,
|
(printf_function)handle_printf_atsign,
|
||||||
NULL))
|
(printf_arginfo_function)arginfo_func))
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"register printf handling of %%@ failed"];
|
format: @"register printf handling of %%@ failed"];
|
||||||
#endif /* HAVE_REGISTER_PRINTF_FUNCTION */
|
#endif /* HAVE_REGISTER_PRINTF_FUNCTION */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue