Re: [PATCHES] [HACKERS] snprintf() argument reordering not working under Windows in 8.1
Greetings, I thought it will be as simple as changing Makefile, the issue seem to be much more complicated. Unfortunately I have no PostgreSQL building environment handy and will not be able to look at it until the end of next week because I am moving my house :( But since this issue waited for so long it may wait a week more. 2005/12/3, Bruce Momjian pgman@candle.pha.pa.us: Sure, I remember. So glad you returned at this time. I found a design limitation in that file yesterday. It can not output more then 4096 characters, and there are some cases with NUMERIC that try to output more than that. For example: SELECT pow(10::numeric, 1) + 1; should show a '1' at the end of the number, but with the existing code you will just see 4095 0's and no more. I am attaching the new snprintf.c and the patch itself for your review. The change is to pass 'stream' down into the routines and output to the FILE* right from inside the routine, rather than using a string. This fixes the problem. Your patch increase buffers from 4095 to 8192. Sounds good to me. I am also thinking of modifying the code so if we are using snprintf.c only because we need positional parameter control, we check for '$' in the string and only use snprintf.c in those cases. I too, was thinking of it at the beginning but decided that the code would get even more complicated than it was at the moment and was afraid that core team would not accept my patch. :) NLS messages of some languages, like Turkish, rely heavily on argument reordering because of the language structure. In 8.1 Turkish messages in Windows version are all broken because argument reordering is not there. Really? I have not heard any report of that but this is new code in 8.1. Windows installer does not set lc_messages configuration variable correctly in postgresql.conf file. It is a known issue and will be solved in next version. Meanwhile user needs to open postgresql.conf file and change lc_messages = 'Turkish_Turkey.28599' to lc_messages = 'tr_TR.UTF-8' manually. Apparently nobody cared to do it and Devrim never ever touches Windows. The problem is there, I am definitely positive about it, here are two lines from log file: 2005-11-20 12:36:37 HATA: $s yerinde $s 1 karakterinde 2005-12-03 19:14:27 LOG: $s veritabanın transaction ID warp limiti $u Actually, that changes means that there was nothing backend-specific in snprintf.c so we don't need a _special_ version for the backend. The real change not to use snprintf.c on Win32 is in configure.in with this comment: # Force use of our snprintf if system's doesn't do arg control # This feature is used by NLS if test $enable_nls = yes test $pgac_need_repl_snprintf = no # On Win32, libintl replaces snprintf() with its own version that # understands arg control, so we don't need our own. In fact, it # also uses macros that conflict with ours, so we _can't_ use # our own. test $PORTNAME != win32; then PGAC_FUNC_PRINTF_ARG_CONTROL if test $pgac_cv_printf_arg_control != yes ; then pgac_need_repl_snprintf=yes fi fi Here is the commit: revision 1.409 date: 2005/05/05 19:15:54; author: momjian; state: Exp; lines: +8 -2 On Win32, libintl replaces snprintf() with its own version that understands arg control, so we don't need our own. In fact, it also uses macros that conflict with ours, so we _can't_ use our own. I don't have MinGW build environment on my computer at the moment and will not be able to install it until the end of next week but log messages above were produced by PostgreSQL installed with 8.1.0-2 Windows installer downloaded from postgresql.org. Since Turkish messages are printed I suppose it was compiled with $enable_nls = yes Thank you for your attention, Regards, Nicolai Tufar ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Re: [PATCHES] [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests to fail
On Wed, 16 Mar 2005 01:00:21 -0500 (EST), Bruce Momjian pgman@candle.pha.pa.us wrote: I have applied a modified version of your patch, attached. I am so sorry, I sent untested patch again. Thank you very much for patience in fixing it. The patch looks perfectly fine and works under Solaris. Under win32 I am still struggling with build environment. In many directories link fails with undefined reference to `pg_snprintf' in other it fails with undefined reference to `_imp__libintl_sprintf'. In yet another directory it fails with both, like in src/interfaces/ecpg/pgtypeslib: dlltool --export-all --output-def pgtypes.def numeric.o datetime.o common.o dt_common.o timestamp.o interval.o pgstrcasecmp.o dllwrap -o libpgtypes.dll --dllname libpgtypes.dll --def pgtypes.def numeric.o datetime.o common.o dt_common.o timestamp.o interval.o pgstrcasecmp.o -L../../../../src/port -lm numeric.o(.text+0x19ea):numeric.c: undefined reference to `_imp__libintl_sprintf' datetime.o(.text+0x476):datetime.c: undefined reference to `pg_snprintf' common.o(.text+0x1cd):common.c: undefined reference to `pg_snprintf' common.o(.text+0x251):common.c: undefined reference to `pg_snprintf' dt_common.o(.text+0x538):dt_common.c: undefined reference to `_imp__libintl_sprintf' dt_common.o(.text+0x553):dt_common.c: undefined reference to `_imp__libintl_sprintf' dt_common.o(.text+0x597):dt_common.c: undefined reference to `_imp__libintl_sprintf' dt_common.o(.text+0x5d5):dt_common.c: undefined reference to `_imp__libintl_sprintf' dt_common.o(.text+0x628):dt_common.c: undefined reference to `_imp__libintl_sprintf' dt_common.o(.text+0x7e8):dt_common.c: more undefined references to `_imp__libintl_sprintf' follow c:\MinGW\bin\dllwrap.exe: c:\MinGW\bin\gcc exited with status 1 make: *** [libpgtypes.a] Error 1 Could someone with a better grasp of configure and win32 environment check it? Aparently no one regularily compiles source code under win32 during development cycle these days. Best regards, Nicolai ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Re: [PATCHES] [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests to fail
Resubmission of yesterday's patch so that it would cont conflict with Bruce's cvs commit. Pleas apply. Best regards, Nicolai. On Sat, 12 Mar 2005 01:58:15 +0200, Nicolai Tufar [EMAIL PROTECTED] wrote: On Thu, 10 Mar 2005 19:21:41 -0500 (EST), Bruce Momjian pgman@candle.pha.pa.us wrote: The CVS-tip implementation is fundamentally broken and won't work even for our internal uses. I've not wasted time complaining about it because I thought we were going to replace it. If we can't find a usable replacement then we're going to have to put a lot of effort into fixing what's there. On the whole I think the effort would be better spent importing someone else's solution. Oh, so our existing implementation doesn't even meet our needs. OK. Which made me wander why did I not aggree with Tom Lane's suggestion to make do three passes instead of two. Tom was right, as usual. It happened to be much easier than I expected. The patch is attached. Please apply. Tom, what do you think? Will it be fine with you? Best regards, Nicolai *** ./src/port/snprintf.c.orig Sat Mar 12 09:13:43 2005 --- ./src/port/snprintf.c Sat Mar 12 10:01:44 2005 *** *** 195,200 --- 195,202 int pointflag; char func; int realpos; + int longflag; + int longlongflag; } *fmtpar, **fmtparptr; /* Create enough structures to hold all arguments */ *** *** 264,275 --- 266,279 realpos = position; len = 0; goto nextch; + /* case '*': if (pointflag) maxwidth = va_arg(args, int); else len = va_arg(args, int); goto nextch; + */ case '.': pointflag = 1; goto nextch; *** *** 301,316 #endif case 'u': case 'U': ! /* fmtnum(value,base,dosign,ljust,len,zpad,output) */ ! if (longflag) ! { ! if (longlongflag) ! value = va_arg(args, uint64); ! else ! value = va_arg(args, unsigned long); ! } ! else ! value = va_arg(args, unsigned int); fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; --- 305,312 #endif case 'u': case 'U': ! fmtpar[fmtpos].longflag = longflag; ! fmtpar[fmtpos].longlongflag = longlongflag; fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; *** *** 325,340 break; case 'o': case 'O': ! /* fmtnum(value,base,dosign,ljust,len,zpad,output) */ ! if (longflag) ! { ! if (longlongflag) ! value = va_arg(args, uint64); ! else ! value = va_arg(args, unsigned long); ! } ! else ! value = va_arg(args, unsigned int); fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; --- 321,328 break; case 'o': case 'O': ! fmtpar[fmtpos].longflag = longflag; ! fmtpar[fmtpos].longlongflag = longlongflag; fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; *** *** 349,365 break; case 'd': case 'D': ! if (longflag) ! { ! if (longlongflag) ! { ! value = va_arg(args, int64); ! } ! else ! value = va_arg(args, long); ! } ! else ! value = va_arg(args, int); fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; --- 337,344 break; case 'd': case 'D': ! fmtpar[fmtpos].longflag = longflag; ! fmtpar[fmtpos].longlongflag = longlongflag; fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; *** *** 373,387 fmtpos++; break; case 'x': ! if (longflag) ! { ! if (longlongflag) ! value = va_arg(args, uint64); ! else ! value = va_arg(args, unsigned long); ! } ! else ! value = va_arg(args, unsigned int); fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; --- 352,359 fmtpos++; break; case 'x': ! fmtpar[fmtpos].longflag = longflag; ! fmtpar[fmtpos].longlongflag = longlongflag; fmtpar[fmtpos].fmtbegin = fmtbegin; fmtpar[fmtpos].fmtend = format; fmtpar[fmtpos].numvalue = value; *** *** 395,409 fmtpos++; break; case 'X': ! if (longflag) ! { ! if (longlongflag) ! value = va_arg(args, uint64); ! else ! value = va_arg(args, unsigned long
Re: [PATCHES] [pgsql-hackers-win32] [HACKERS] snprintf causes regression tests to fail
Tom lane wrote: With CVS-tip snprintf I get result = '3 42' result = '3 3505' I get similar results: result = '3 42' result = '9e-313 1413754129' Now I agree with you, it is fundamentally broken. We need to replace this implementation. Bruce Momjian wrote: I can confirm that using %I64d for the printf format allows the regression tests to pass for int8. But snprintf.c code does not support %I64d construct. It must be picking OS's vsnprintf() Bruce Momjian wrote: I think FreeBSD does. I started with FreeBSD's vsnprintf() at first but was set back by it's complexity and decided to modify the port/snprintf.c code. Now would you like me to incorporate FreeBSD's one into the code. Give me a week and I will come with the patch. Best regards, Nicolai Tufar ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[PATCHES] Thread-safe snprintf() vsnprintf() and printf()
And while we are on it, I would like to submit minor changes to make snprintf() vsnprintf() and printf() functions in src/port/snprintf.c thread-safe. Best regards, Nicolai Tufar Index: src/port/snprintf.c === RCS file: /projects/cvsroot/pgsql/src/port/snprintf.c,v retrieving revision 1.7 diff -c -r1.7 snprintf.c *** src/port/snprintf.c 28 Feb 2005 14:16:16 - 1.7 --- src/port/snprintf.c 28 Feb 2005 23:11:22 - *** *** 82,105 * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from ! * causing nast effects. **/ ! /*static char _id[] = $PostgreSQL: pgsql/src/port/snprintf.c,v 1.7 2005/02/28 14:16:16 momjian Exp $;*/ ! static char *end; ! static int SnprfOverflow; int snprintf(char *str, size_t count, const char *fmt,...); int vsnprintf(char *str, size_t count, const char *fmt, va_list args); int printf(const char *format, ...); ! static void dopr(char *buffer, const char *format, va_list args); int printf(const char *fmt,...) { int len; va_list args; ! static char* buffer[4096]; char* p; va_start(args, fmt); --- 82,103 * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from ! * causing nasty effects. **/ ! /*static char _id[] = $PostgreSQL: pgsql/src/port/snprintf.c,v 1.6 2005/02/22 04:57:24 momjian Exp $;*/ int snprintf(char *str, size_t count, const char *fmt,...); int vsnprintf(char *str, size_t count, const char *fmt, va_list args); int printf(const char *format, ...); ! static void dopr(char *buffer, const char *format, va_list args, char *end); int printf(const char *fmt,...) { int len; va_list args; ! char* buffer[4096]; char* p; va_start(args, fmt); *** *** 127,136 int vsnprintf(char *str, size_t count, const char *fmt, va_list args) { str[0] = '\0'; end = str + count - 1; ! SnprfOverflow = 0; ! dopr(str, fmt, args); if (count 0) end[0] = '\0'; return strlen(str); --- 125,134 int vsnprintf(char *str, size_t count, const char *fmt, va_list args) { + char *end; str[0] = '\0'; end = str + count - 1; ! dopr(str, fmt, args, end); if (count 0) end[0] = '\0'; return strlen(str); *** *** 140,150 * dopr(): poor man's version of doprintf */ ! static void fmtstr(char *value, int ljust, int len, int zpad, int maxwidth); ! static void fmtnum(long_long value, int base, int dosign, int ljust, int len, int zpad); ! static void fmtfloat(double value, char type, int ljust, int len, int precision, int pointflag); ! static void dostr(char *str, int cut); ! static void dopr_outch(int c); static char *output; --- 138,148 * dopr(): poor man's version of doprintf */ ! static void fmtstr(char *value, int ljust, int len, int zpad, int maxwidth, char *end); ! static void fmtnum(long_long value, int base, int dosign, int ljust, int len, int zpad, char *end); ! static void fmtfloat(double value, char type, int ljust, int len, int precision, int pointflag, char *end); ! static void dostr(char *str, int cut, char *end); ! static void dopr_outch(int c, char *end); static char *output; *** *** 154,160 #define FMTCHAR 4 static void ! dopr(char *buffer, const char *format, va_list args) { int ch; long_long value; --- 152,158 #define FMTCHAR 4 static void ! dopr(char *buffer, const char *format, va_list args, char *end) { int ch; long_long value; *** *** 417,427 case '%': break; default: ! dostr(???, 0); } break; default: ! dopr_outch(ch); break; } } --- 415,425 case '%': break; default: ! dostr(???, 0, end); } break; default: ! dopr_outch(ch, end); break; } } *** *** 448,474 case FMTSTR: fmtstr(fmtparptr[i]-value, fmtparptr[i]-ljust, fmtparptr[i]-len, fmtparptr[i]-zpad, ! fmtparptr[i]-maxwidth); break; case FMTNUM: fmtnum(fmtparptr[i]-numvalue, fmtparptr[i]-base, fmtparptr[i]-dosign, fmtparptr[i]-ljust, ! fmtparptr[i]-len, fmtparptr[i]-zpad); break; case FMTFLOAT: fmtfloat(fmtparptr[i]-fvalue, fmtparptr[i]-type, fmtparptr[i]-ljust, fmtparptr[i]-len, ! fmtparptr[i]-precision, fmtparptr[i]-pointflag); break; case FMTCHAR: ! dopr_outch(fmtparptr[i]-charvalue); break; } format = fmtpar[i].fmtend; goto nochar; } } ! dopr_outch(ch); nochar: /* nothing */ ; /* semicolon required
Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c
On Thu, 24 Feb 2005 22:18:11 -0500, Tom Lane [EMAIL PROTECTED] wrote: Didn't we do that already? No :( I promised to do it a couple of weeks ago but could not get to do it. Now with Magnus's help I finaly did it. The last patch should be fine. regards, tom lane Nicolai ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
Re: [PATCHES] Repleacement for src/port/snprintf.c
On Mon, Feb 21, 2005 at 10:53:08PM -0500, Bruce Momjian wrote: Applied. Thanks a lot. The patch attached solves the tread safety problem. Please review it before applying, I am not sure I am doing the right thing On Tue, 22 Feb 2005 19:57:15 +0100, Kurt Roeckx [EMAIL PROTECTED] wrote: The configure test is a little broken. It needs to quote the $'s. I've rewritten the test a little. This one needs applying too. $'s do get scrambled. Best regards, Nicolai. *** ./src/port/snprintf.c.orig sali Şub 22 20:02:03 2005 --- ./src/port/snprintf.c sali Şub 22 21:59:48 2005 *** *** 80,96 * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from ! * causing nast effects. **/ /*static char _id[] = $PostgreSQL: pgsql/src/port/snprintf.c,v 1.6 2005/02/22 04:57:24 momjian Exp $;*/ - static char *end; - static int SnprfOverflow; int snprintf(char *str, size_t count, const char *fmt,...); int vsnprintf(char *str, size_t count, const char *fmt, va_list args); int printf(const char *format, ...); ! static void dopr(char *buffer, const char *format, va_list args); int printf(const char *fmt,...) --- 80,94 * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from ! * causing nasty effects. **/ /*static char _id[] = $PostgreSQL: pgsql/src/port/snprintf.c,v 1.6 2005/02/22 04:57:24 momjian Exp $;*/ int snprintf(char *str, size_t count, const char *fmt,...); int vsnprintf(char *str, size_t count, const char *fmt, va_list args); int printf(const char *format, ...); ! static void dopr(char *buffer, const char *format, va_list args, char *end); int printf(const char *fmt,...) *** *** 97,103 { int len; va_list args; ! static char* buffer[4096]; char* p; va_start(args, fmt); --- 95,101 { int len; va_list args; ! char* buffer[4096]; char* p; va_start(args, fmt); *** *** 125,134 int vsnprintf(char *str, size_t count, const char *fmt, va_list args) { str[0] = '\0'; end = str + count - 1; ! SnprfOverflow = 0; ! dopr(str, fmt, args); if (count 0) end[0] = '\0'; return strlen(str); --- 123,132 int vsnprintf(char *str, size_t count, const char *fmt, va_list args) { + char *end; str[0] = '\0'; end = str + count - 1; ! dopr(str, fmt, args, end); if (count 0) end[0] = '\0'; return strlen(str); *** *** 138,148 * dopr(): poor man's version of doprintf */ ! static void fmtstr(char *value, int ljust, int len, int zpad, int maxwidth); ! static void fmtnum(long_long value, int base, int dosign, int ljust, int len, int zpad); ! static void fmtfloat(double value, char type, int ljust, int len, int precision, int pointflag); ! static void dostr(char *str, int cut); ! static void dopr_outch(int c); static char *output; --- 136,146 * dopr(): poor man's version of doprintf */ ! static void fmtstr(char *value, int ljust, int len, int zpad, int maxwidth, char *end); ! static void fmtnum(long_long value, int base, int dosign, int ljust, int len, int zpad, char *end); ! static void fmtfloat(double value, char type, int ljust, int len, int precision, int pointflag, char *end); ! static void dostr(char *str, int cut, char *end); ! static void dopr_outch(int c, char *end); static char *output; *** *** 152,158 #define FMTCHAR 4 static void ! dopr(char *buffer, const char *format, va_list args) { int ch; long_long value; --- 150,156 #define FMTCHAR 4 static void ! dopr(char *buffer, const char *format, va_list args, char *end) { int ch; long_long value; *** *** 415,425 case '%': break; default: ! dostr(???, 0); } break; default: ! dopr_outch(ch); break; } } --- 413,423 case '%': break; default: ! dostr(???, 0, end); } break; default: ! dopr_outch(ch, end); break; } } *** *** 446,465 case FMTSTR: fmtstr(fmtparptr[i]-value, fmtparptr[i]-ljust, fmtparptr[i]-len, fmtparptr[i]-zpad, ! fmtparptr[i]-maxwidth); break; case FMTNUM: fmtnum(fmtparptr[i]-numvalue, fmtparptr[i]-base, fmtparptr[i]-dosign, fmtparptr[i]-ljust, ! fmtparptr[i]-len, fmtparptr[i]-zpad); break; case FMTFLOAT: fmtfloat(fmtparptr[i]-fvalue, fmtparptr[i]-type, fmtparptr[i]-ljust, fmtparptr[i]-len, ! fmtparptr[i]-precision, fmtparptr[i]-pointflag); break; case FMTCHAR: ! dopr_outch(fmtparptr[i]-charvalue); break; }
Re: [PATCHES] [pgsql-hackers-win32] Repleacement for src/port/snprintf.c
On Sun, 13 Feb 2005 19:06:34 -0500 (EST), Bruce Momjian pgman@candle.pha.pa.us wrote: Anyway, this is too large to put into 8.0, but I am attaching a patch for 8.1 that has the proper configure tests to check if the C library supports this behavior. If it does not, the build will use our port/snprintf.c. One problem with that is that our snprintf.c is not thread-safe. Seems the increases use of it will require us to fix this soon. I have added to TODO: * Make src/port/snprintf.c thread-safe Okay, I am applying your patch to CVS HEAD and getting hands on making snprintf.c thread-safe. I will submit a roll up pathch in a day or two. Regards, Nicolai ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
[PATCHES] Repleacement for src/port/snprintf.c
Hello all, I would like to submit my changes to src/port/snprintf.c to enable %n$ format placeholder replacement in snprintf() and vsnprintf(). Additionally I implemented a trivial printf(). I also attach a diff for configure.in to include snprintf.o in pgport but I am sure it is not the right thing to do. Could someone give a hint on where I need to place such a definition. Please review my patch. as Tom Lane pointed out there are 150 messages in the following files that do not print properly: src/backend/po/pt_BR.po src/backend/po/de.po src/backend/po/es.po src/backend/po/zh_CN.po src/backend/po/tr.po src/bin/pg_dump/po/zh_CN.po src/bin/pg_dump/po/tr.po src/bin/psql/po/zh_CN.po src/bin/psql/po/zh_TW.po src/bin/psql/po/tr.po src/bin/scripts/po/zh_CN.po we need to fix snprintf.c before next release Best regards, Nicolai Tufar *** ./src/port/snprintf.c.orig 2005-01-20 01:27:22.0 +0200 --- ./src/port/snprintf.c 2005-01-24 03:09:31.0 +0200 *** *** 57,62 --- 57,66 typedef unsigned long ulong_long; #endif + #ifndef NL_ARGMAX + #define NL_ARGMAX 4096 + #endif + /* **SNPRINTF, VSNPRINT -- counted versions of printf ** *** *** 85,93 --- 89,115 int snprintf(char *str, size_t count, const char *fmt,...); int vsnprintf(char *str, size_t count, const char *fmt, va_list args); + int printf(const char *format, ...); static void dopr(char *buffer, const char *format, va_list args); int + printf(const char *fmt,...) + { + int len; + va_list args; + static char*buffer[4096]; + char* p; + + va_start(args, fmt); + len = vsnprintf((char*)buffer, (size_t)4096, fmt, args); + va_end(args); + p = (char*)buffer; + for(;*p;p++) + putchar(*p); + return len; + } + + int snprintf(char *str, size_t count, const char *fmt,...) { int len; *** *** 124,129 --- 146,155 static char *output; + #define FMTSTR 1 + #define FMTNUM 2 + #define FMTFLOAT3 + #define FMTCHAR 4 static void dopr(char *buffer, const char *format, va_list args) *** *** 139,145 --- 165,200 int ljust; int len; int zpad; + int i; + const char* format_save; + const char* fmtbegin; + int fmtpos = 1; + int realpos = 0; + int position; + static struct{ + const char* fmtbegin; + const char* fmtend; + union{ + void* value; + long_long numvalue; + double fvalue; + int charvalue; + }; + int ljust; + int len; + int zpad; + int maxwidth; + int base; + int dosign; + chartype; + int precision; + int pointflag; + charfunc; + int realpos; + }fmtpar[NL_ARGMAX+1], *fmtparptr[NL_ARGMAX+1]; + + format_save = format; output = buffer; while ((ch = *format++)) { *** *** 148,161 case '%': ljust = len = zpad = maxwidth = 0; longflag = longlongflag = pointflag = 0; nextch: ch = *format++; switch (ch) { case 0: ! dostr(**end of format**, 0); ! *output = '\0'; ! return; case '-': ljust = 1; goto nextch; --- 203,217 case '%': ljust = len = zpad = maxwidth = 0; longflag = longlongflag = pointflag = 0; + fmtbegin = format - 1; + realpos = 0; + position = 0; nextch: ch = *format++; switch (ch) { case 0: ! goto performpr
[PATCHES] Repleacement for src/port/snprintf.c
Greetings, I would like to submit my changes to src/port/snprintf.c to enable %n$ format placeholder replacement in snprintf() and vsnprintf(). Additionally I implemented a trivial printf(). I also attach a diff for configure.in to include snprintf.o in pgport but I am sure it is not the right thing to do. Could someone give a hint on where I need to place such a definition. Best regards, Nicolai Tufar *** ./src/port/snprintf.c.orig 2005-01-20 01:27:22.0 +0200 --- ./src/port/snprintf.c 2005-01-24 03:09:31.0 +0200 *** *** 57,62 --- 57,66 typedef unsigned long ulong_long; #endif + #ifndef NL_ARGMAX + #define NL_ARGMAX 4096 + #endif + /* **SNPRINTF, VSNPRINT -- counted versions of printf ** *** *** 85,93 --- 89,115 int snprintf(char *str, size_t count, const char *fmt,...); int vsnprintf(char *str, size_t count, const char *fmt, va_list args); + int printf(const char *format, ...); static void dopr(char *buffer, const char *format, va_list args); int + printf(const char *fmt,...) + { + int len; + va_list args; + static char*buffer[4096]; + char* p; + + va_start(args, fmt); + len = vsnprintf((char*)buffer, (size_t)4096, fmt, args); + va_end(args); + p = (char*)buffer; + for(;*p;p++) + putchar(*p); + return len; + } + + int snprintf(char *str, size_t count, const char *fmt,...) { int len; *** *** 124,129 --- 146,155 static char *output; + #define FMTSTR 1 + #define FMTNUM 2 + #define FMTFLOAT3 + #define FMTCHAR 4 static void dopr(char *buffer, const char *format, va_list args) *** *** 139,145 --- 165,200 int ljust; int len; int zpad; + int i; + const char* format_save; + const char* fmtbegin; + int fmtpos = 1; + int realpos = 0; + int position; + static struct{ + const char* fmtbegin; + const char* fmtend; + union{ + void* value; + long_long numvalue; + double fvalue; + int charvalue; + }; + int ljust; + int len; + int zpad; + int maxwidth; + int base; + int dosign; + chartype; + int precision; + int pointflag; + charfunc; + int realpos; + }fmtpar[NL_ARGMAX+1], *fmtparptr[NL_ARGMAX+1]; + + format_save = format; output = buffer; while ((ch = *format++)) { *** *** 148,161 case '%': ljust = len = zpad = maxwidth = 0; longflag = longlongflag = pointflag = 0; nextch: ch = *format++; switch (ch) { case 0: ! dostr(**end of format**, 0); ! *output = '\0'; ! return; case '-': ljust = 1; goto nextch; --- 203,217 case '%': ljust = len = zpad = maxwidth = 0; longflag = longlongflag = pointflag = 0; + fmtbegin = format - 1; + realpos = 0; + position = 0; nextch: ch = *format++; switch (ch) { case 0: ! goto performpr; case '-': ljust = 1; goto nextch; *** *** 174,180 --- 230,243 if (pointflag) maxwidth = maxwidth * 10 + ch - '0'; else
Re: [HACKERS] [PATCHES] Latest Turkish translation updates
Wow, Turkish seem to be the first translation to report 100% translation completion for 8.0 release. Congratulations for great work! And thanks to Peter for being patient with us all this time. We can't reproduce it with msgfmt -v. How do you get those errors? The scripts that produce these tables do not use the standard gettext tools; they use hand-crafted Perl scripts. In some cases, these catch more errors. In all cases that I have analyzed further, this was because %m was not identified as a format specifier by msgfmt. Could you share these scripts with us? Many update submissions we made were beacause of these %m errors. Also would it be easier to you Peter if we give you login to our CVS poject (on sf.net) so that you just run cvs up every time you package a new update and not bother with emails. Thank you all folks for your efforts. I will open a bottle of chamgne tonight to celebrate 8.0. Peter Eisentraut http://developer.postgresql.org/~petere/ Best regards, Nicolai Tufar ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
[PATCHES] C locale sort in src/tools/make_ctags
Greetings, Attached is a simple one-liner for src/tools/make_ctags. If tags are sorted in locale other than C, vim complains: E432: Tags file not sorted: tags Solution is to set LANG variable to C before calling sort. Regards, Nicolai Tufar ctags-sort.diff Description: Binary data ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [PATCHES] C locale sort in src/tools/make_ctags
-Original Message- From: Peter Eisentraut [mailto:[EMAIL PROTECTED] Nicolai Tufar wrote: Greetings, Attached is a simple one-liner for src/tools/make_ctags. If tags are sorted in locale other than C, vim complains: E432: Tags file not sorted: tags Solution is to set LANG variable to C before calling sort. That should be LC_ALL. Sounds fair. Both could be done. It worked for me just with LANG. Should I submit a new patch? ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org