On Mon, 26 Jan 2009, Mindaugas Kavaliauskas wrote:
Hi,
>> There are also some small differences to original print behavior, f.e.:
>> %012d in C printf() is 0 padded 12 length 'd' formatting and in this code
>> it's parameter 12-th 'd' formatting.
> Can you give an error example? I'm unable to find the bug. I get correct
> result for:
> ? HB_SPRINTF( "[%012d]", 123 ) // [000000000123]
Ups, My fault I only watch in the source code without real tests
and I missed that patern pointer is reverted when '$' is missing.
Sorry.
> I'll still a little confused on functionality of Harbour's formats itself.
> Should we support argument length modifier (h,l,L) because Harbour has
> argument length determined by item structure, etc. Anyone's ideas are
> welcome.
Probably we should add at least basic support to properly parse patterns
ignoring things which are not necessary for us though some modifiers can
be used to strip the number, f.e. 0x12345678 as "%hx" should give "5678"
so we can support them partially. Keeping full support for C printf
modifiers should help when people use the same strings in C and .prg
code. For .prg snprintf() wrapper we only have the possibilities to make
additional parameters validation and of course we should introduce it but
we do not have to make any limitations in supported format.
> You've proposed rc_snprintf(). Do you mean HB_STRFORMAT() should use
> original C s[n]printf() function, thus making it's output more C
> compatible, but possibly STR() incompatible for rounding errors, etc? I've
> used hb_itemStrBuf() to avoid incompatible results for STR(nValue, 20, 10)
> and HB_STRFORMAT("%20.10f", nValue).
And this is OK for me. I also prefer using the same rules for numbers
conversions as in core code. rc_snprintf() is my internal name not a
proposition and this code was not related to Harbour at all. It's pure
C code which to use as snprintf() replacement. It should be updated to
use it with Harbour. It can be also adopted to be core of .prg snprintf()
wrapper. In such case the code can be greatly simplified and reduced.
best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour