Skip site navigation (1) Skip section navigation (2)

Re: utffile patch

From: Max Khon <fjoe(at)samodelkin(dot)net>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: pgadmin-hackers(at)postgresql(dot)org,Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
Subject: Re: utffile patch
Date: 2005-02-24 11:30:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgadmin-hackers

On Thu, Feb 24, 2005 at 10:22:22AM +0000, Andreas Pflug wrote:

> >>>Attached patch fixes coredump in non-Unicode version of pgadmin3.
> >>>This allows to build (non-Unicode) pgadmin3 on FreeBSD 4.x.
> >>
> >>This patch appears highly dubious to me (apart from the fact that I'd 
> >>call non-unicode unsupported).
> >>
> >>
> >>>+#if wxUSE_UNICODE
> >>>+            size_t buf_len = nLen;
> >>>+#else
> >>>+            size_t buf_len = nLen * sizeof(wchar_t);
> >>>+#endif
> >>>+ 
> >>
> >>m_conversion->MB2WC((wchar_t*)(wxChar*)wxStringBuffer(str, buf_len), 
> >>(const char*)buffer, (size_t)(nLen+1));
> >>
> >>wxStringBuffers expects the second parameter to contain the number of 
> >>characters (not bytes), which will be the same for unicode as and 
> >>non-unicode.
> >
> >
> >No. wxStringBuffer uses wxWCharBuffer in Unicode case and
> >wxCharBuffer in non-Unicode case.
> Which is the same.
> 1 character = wchar_t = wxChar = wxWChar in Unicode,
> 1 character = char = wxChar in non-Unicode.
> Anyhow, having a deeper look at wx unicode conversions it seems that (in 
> contrast to earlier versions) now utf-conversions are supported in 
> non-unicode too, making that offending line more than a no-op. 
> Unfortunately, the usage of wxStringBuffer as argument to MB2WC is 
> *plain wrong*, because writing wchar_t to char is pure bullsh*t for 
> non-unicode. The code assumes wxChar==wchar_t, which is true in unicode 
> only.
> Which condenses down to "utffile.cpp is not non-unicode compatible". 
> I've added a #error accordingly. Until utffile is thoroughly reworked 
> for non-unicode, compiling pgadmin in unicode mode is *required*.

You are correct. The patch I submitted is a workaround and was never supposed
to fix the root of the problem. But it allows to run pgadmin3 1.2.0 on FreeBSD
4.x which lacks proper wchar_t support but is still widely used.

I removed non-Unicode support in FreeBSD port initially because of the
problems you described, but the a few users asked me if it is possible to
add it back.


In response to


pgadmin-hackers by date

Next:From: Andreas PflugDate: 2005-02-24 11:55:11
Subject: Re: utffile patch
Previous:From: Andreas PflugDate: 2005-02-24 10:22:22
Subject: Re: utffile patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group