bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] Reusing vasnprintf


From: Bruno Haible
Subject: Re: [bug-gnulib] Reusing vasnprintf
Date: Wed, 18 Oct 2006 21:44:58 +0200
User-agent: KMail/1.9.1

Daniel Jacobowitz wrote:
> A standard printf.  We're not trying to print out new things, we're
> trying to print out standard things using different sorts of arguments.
> 
> Here's an example.  You can open up GDB and say this:
> 
> (gdb) printf "%lld\n", 1
> 1

OK, thanks, I see the intent and the cross-compilation issues...

> > How does what you need compare with the register_printf_function /
> > parse_printf_format facility in glibc's public header file <printf.h> ?
> 
> Wow, I knew about register_printf_function, but I'd never noticed
> parse_printf_format before.

But without the other part, which constructs the output string, this
function is useless to gdb, right? So there's no point in gnulib trying
to make a 100% glibc compatible parse_printf_format.

> printf breaks down into three stages: parsing the format string,
> recovering the arguments, and constructing the output string.  We need
> completely normal versions of the first and third, but a non-va_arg
> based version of the second.

Are you sure you can use the parsing stage and the output stage without
modifications?
- In the parsing phase, you need to recognize %lld also if the host environment
  doesn't support long longs (e.g. on MSVC hosts). This means the
  #ifdef HAVE_LONG_LONG_INT
  in printf-args.h needs to be adjusted for your use case.
- In the output stage, when the host has 32-bit 'long's and the target
  environment has 64-bit 'long's, the output routine that converts a
  'long' to decimal needs to be able to produce 20 decimal digits, not
  just 10.
- Also in the output stage, when you encounter a %ls directive with a
  wide string argument, to you perform the wcstombs on the host machine
  or on the target machine?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]