mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Fix bug #19587
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25057 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
06d1115491
commit
b6f5848178
6 changed files with 168 additions and 8 deletions
79
config/config.wprintf.c
Normal file
79
config/config.wprintf.c
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* See if we have a broken register_printf function (e.g. an old version of glibc) */
|
||||
/*
|
||||
Copyright (C) 2005 Free Software Foundation
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <printf.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* <sattler@volker.cs.Uni-Magdeburg.DE>, with libc-5.3.9 thinks this
|
||||
flag PRINTF_ATSIGN_VA_LIST should be 0, but for me, with libc-5.0.9,
|
||||
it crashes. -mccallum
|
||||
|
||||
Apparently GNU libc 2.xx needs this to be 0 also, along with Linux
|
||||
libc versions 5.2.xx and higher (including libc6, which is just GNU
|
||||
libc). -chung */
|
||||
#define PRINTF_ATSIGN_VA_LIST \
|
||||
(defined(_LINUX_C_LIB_VERSION_MINOR) \
|
||||
&& _LINUX_C_LIB_VERSION_MAJOR <= 5 \
|
||||
&& _LINUX_C_LIB_VERSION_MINOR < 2)
|
||||
|
||||
#if ! PRINTF_ATSIGN_VA_LIST
|
||||
static int
|
||||
arginfo_func (const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
*argtypes = PA_POINTER;
|
||||
return 1;
|
||||
}
|
||||
#endif /* !PRINTF_ATSIGN_VA_LIST */
|
||||
|
||||
static int
|
||||
handle_printf_atsign (FILE *stream,
|
||||
const struct printf_info *info,
|
||||
#if PRINTF_ATSIGN_VA_LIST
|
||||
va_list *ap_pointer)
|
||||
#elif defined(_LINUX_C_LIB_VERSION_MAJOR) \
|
||||
&& _LINUX_C_LIB_VERSION_MAJOR < 6
|
||||
const void **const args)
|
||||
#else /* GNU libc needs the following. */
|
||||
const void *const *args)
|
||||
#endif
|
||||
{
|
||||
#if ! PRINTF_ATSIGN_VA_LIST
|
||||
const void *ptr = *args;
|
||||
#endif
|
||||
char * string_object;
|
||||
int len = 0;
|
||||
|
||||
/* xxx This implementation may not pay pay attention to as much
|
||||
of printf_info as it should. */
|
||||
|
||||
#if PRINTF_ATSIGN_VA_LIST
|
||||
string_object = va_arg (*ap_pointer, char *);
|
||||
#else
|
||||
string_object = *((char **) ptr);
|
||||
#endif
|
||||
if (info->wide == 0)
|
||||
len = fprintf(stream, "%s", string_object);
|
||||
return len;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char *d = "hi there";
|
||||
|
||||
register_printf_function ('@',
|
||||
handle_printf_atsign,
|
||||
#if PRINTF_ATSIGN_VA_LIST
|
||||
0);
|
||||
#else
|
||||
arginfo_func);
|
||||
#endif
|
||||
|
||||
printf("test %s = %@\n", d, d);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue