Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
On Sat, 22 Jan 2005 15:31:39 +0100, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Nicolai Tufar wrote: > > 1. I renamed snprintf() to pg_snprintf(), vsnprintf() to > > pg_vsnprintf() and introduced pg_printf() that calls pg_vsnprintf(). > > This is not necessary. You will notice that we already have configure > tests of snprintf format specifiers (%lld etc.), so using the original > function names is OK even in that case. how about a test for the thing like: printf("%2$s %1$s!\n", "world", "Hello"); It is what I am trying to solve :( > > 5. Before running regression test I always ran make install, > > apparently because libpq is read from /usr/local/. > > That's because of the -rpath. I see. Thanks for information. > > > 2. Why would we not just take FreeBSD's vfprintf() and use it > > instead? > > Try it. It's painful. src/port/snprintf.c is not not a particularly pretty. And after my rework it got even uglier. I have looked at FreeBDS's one and it is not *that* complicated. Would you like me to try to incorporate into PostgreSQL. NetBSD's one is somewhat simplier but does not support %n$ feature by the way. > > 4. What %m format string is used for? And where is it handled. Do I > > need to implement it? > > It's only used in the error reporting functions in the server and is > handled there. You don't need to worry about it. Oh, that is a relief. > Peter Eisentraut Nicolai ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
Nicolai Tufar wrote: > 1. I renamed snprintf() to pg_snprintf(), vsnprintf() to > pg_vsnprintf() and introduced pg_printf() that calls pg_vsnprintf(). This is not necessary. You will notice that we already have configure tests of snprintf format specifiers (%lld etc.), so using the original function names is OK even in that case. > 4. I introduced a volatile static char[] variable in snprintf.c code > so I can grep executables for this string and be sure that it is > included. Remove that when finalizing the code. > 5. Before running regression test I always ran make install, > apparently because libpq is read from /usr/local/. That's because of the -rpath. > 2. Why would we not just take FreeBSD's vfprintf() and use it > instead? Try it. It's painful. > 4. What %m format string is used for? And where is it handled. Do I > need to implement it? It's only used in the error reporting functions in the server and is handled there. You don't need to worry about it. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
Greetings, for a couple of days I have been hacking on src/port/snprintf.c. With Magnus' help I have managed to implement argument replacement in snprintf(). The code is very crude and not quite optimised, any suggestions will be more than welcome. Here is what I did: 1. I renamed snprintf() to pg_snprintf(), vsnprintf() to pg_vsnprintf() and introduced pg_printf() that calls pg_vsnprintf(). 2. After running configure I manually added snprintf.o to src/Makefile.global's LIBOBJ declaration and -lpgport to Makefile.shlib's DLLWRAP declaration 3. To make sure these functions are used everywhere I introduced the following lines at the end of src/include/c.h: #define snprintf pg_snprintf #define vsnprintf pg_vsnprintf #define printf pg_printf 4. I introduced a volatile static char[] variable in snprintf.c code so I can grep executables for this string and be sure that it is included. 5. Before running regression test I always ran make install, apparently because libpq is read from /usr/local/. During compilation the following warnings were reported: ../../../src/include/utils/elog.h:121: warning: `pg_printf' is an unrecognized format function type which is perfectly fine because we replace printf with pg_printf and gcc's format() does know anything about it. On Linux, PostgreSQL passed regression tests with flying colours and prints messages with %n$ just fine. On win32: int8, timestamp, timestamptz, abstime, horology, constraints, vacuum, and many others failed. To check my code, I reverted snprintf.c to the original one from CVS and forced win32 port to use these functions and it fails in same places. After examining regression tests diff I came to conclusion that problem is in fmtnum() function when it operates with particularly long integers. In snprintf() file I changed only and only dopr() function, neve touching fmtnum(), fmtstr() or fmtfolat(). I would like to kindly ask these questions: 1. Am I on the right to implement %n$ ? Can it be accepted? 2. Why would we not just take FreeBSD's vfprintf() and use it instead? 3. What is wrong with fmtnum() on Win32? 4. What %m format string is used for? And where is it handled. Do I need to implement it? I am attaching my version if snprintf.c (because it is too different from the original to make a patch) and regression.diff of a failed Win32 regression test produced wither with my or with original snprintf.c. Best regards, Nicolai Tufar ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
On Mon, 17 Jan 2005 16:17:33 -0300, Fx <[EMAIL PROTECTED]> wrote: > unix/win32 libc doesnt support "$n" variables.. What can we do then? ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Re: [HACKERS] %2$, %1$ gettext placeholder replacement is not working under Win32
unix/win32 libc doesnt support "$n" variables.. On Mon, 17 Jan 2005 21:03:56 +0200, Nicolai Tufar <[EMAIL PROTECTED]> wrote: > Sorry for such a late submission. > > I just downloaded the latest postgresql-8.0.0-rc5-3.zip installer > for windows and it appears that Windows' printf() does not > support placeholder replacement as described in > http://developer.postgresql.org/docs/postgres/nls.html#AEN57284 > > I searched list archives but found no explanation for this. > Original string is <<%s at or near \"%s\">> and we > replaced it in Turkish for <<\"%2$s\" yerinde %1$s>>. > > It works perfectly fine on Linux but fails miserably under > Windows with something like: > <> > while on Linux the same version works fine: > <> > > What is it? I suppose that Windows' printf() does > not support changing the order of placeholder > characters with %2$ %1$. Did some one else > deal with it? Is it because of compilation flags? > > In any case PostgreSQL version in current pginstaller > is broken. > > Best regards, > Nicolai > > ---(end of broadcast)--- > TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] > -- /* Jumping Flowers */ ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly