This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
overriding defaults with register_printf_function
- From: "a.w. kinnunen" <a dot w dot kinnunen at gmail dot com>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 18 Apr 2007 15:42:33 +0000
- Subject: overriding defaults with register_printf_function
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Lx0Eu2nERpBfCHfiOrD/7n4ccpc+fT9aJf22SVtXxjKSP0qTUnePNSI2mA09wS109uH9NEyMfC3wOrA+u08tvVxWfTw94OaZR+f1Jw0WCzIEORhyMU4YLd4NpPkWSPznewHOk2qwEXbfKaLlYPjLTEuZoWs/OkzY/E3zak+oE54=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=afi4GZK+fUOfIebeEZzjlCB7cCnnrttQxPNuViCyxMCxfeaRKws/ecckDfp4i+vBeHK0XxAyW5h86WOz3xCk1v2dYbDCmY/CxNQoAl7MSqPje4T8RX8npx7SnOVNFm7itwhlS32SbBtwsHeBh/Yl4HQCIN85a/GUD46jl0+/62k=
Hi!
Here's a bug I suppose. libc manual says in
12.13.1 Registering New Conversions :
...You can redefine the built-in conversions like `%s',...
but it doesn't seems to work. I'm porting an application to linux, and
I need to maintain non-unicode+windows support. This happens with
glibc-2.3.5-0ubuntu1
Here's the code, it won't compile for as it is but you'll get the point:
#ifdef _UNICODE
/*
these can be used to redefine %s and %S to work
in windows style,
they need to be registered using register_printfs;
*/
int print_char_callback( FILE *stream,
const struct printf_info *info_box, const void
*const *args){
const char *chr;
chr = *((const char **) (args[0]));
return fprintf( stream, "%ls", char_to_TCHAR(chr));
}
int print_wchar_callback( FILE *stream,
const struct printf_info *info_box, const void
*const *args){
const TCHAR *chr;
chr = *((const TCHAR **) (args[0]));
return fprintf( stream, "%ls", chr);
}
int printf_wchars_arginfo( const struct printf_info *info, size_t n,
int *argtypes ){
if (n > 0)
argtypes[0] = PA_WSTRING;
return 1;
}
void register_printfs(){
// these work if I printf with %y
// register_printf_function('Y', print_char_callback, printf_wchars_arginfo);
// register_printf_function('y', print_wchar_callback,
printf_wchars_arginfo);
// and these below won't just work
register_printf_function('S', print_char_callback, printf_wchars_arginfo);
register_printf_function('s', print_wchar_callback, printf_wchars_arginfo);
}
#endif