develooper Front page | perl.perl5.porters | Postings from June 2012

Re: [perl #113536] GetEnvironmentStrings() mess up the values for non-ascii strings

Thread Previous | Thread Next
Kartlee Schrodinger
June 16, 2012 21:36
Re: [perl #113536] GetEnvironmentStrings() mess up the values for non-ascii strings
Message ID:

Sent from my iPhone

On Jun 13, 2012, at 3:22 AM, "Steve Hay via RT" <> wrote:

> On Tue Jun 12 08:41:15 2012, kartlee05 wrote:
>>> That was mistake on my part not to pass WC_NO_BEST_FIT_CHARS in acutal 
>>> conversion call from UTF-16 to ACP. I will revise the patch and sent 
>> it 
>>> now.
>>> BTW, I don't think the win32 code would really work if UTF-8 is 
>>> internally used for conversion. I see we use lot of calls toUpper, 
>>> tolower which would not really work with utf-8 directly. So it is good 
>>> if ACP is used.
>>> -Karthik
>> I now fixed the patch to use WC_NO_BEST_FIT_CHARS in the actual 
>> conversion call. Please give a shot.
> I think there is a bug in this and the previous patch (but not your
> original one): the calculation of 'wenvstrings_len' wrongly sets 'size'
> to 1 at the start of the for-loop, but never uses 'size' again. It
> should have set 'wenvstrings_len' to 1 instead, otherwise that ends up
> with the wrong value and causes many, many tests to fail when running
> the full regression test suite.
> After changing
> for(size = 1; *lpWTmp != '\0'; lpWTmp += env_len + 1) {
> to
> for(wenvstrings_len = 1; *lpWTmp != '\0'; lpWTmp += env_len + 1) {

I agree. I have not taken care for the additional null char to indicate the end of environment strings in my last two patches. I will add this now and resend.

> the patch looks good to me code-wise, but I will await any further input
> from bulk88 before committing.
> Could you also fix up a couple of the comments, though, please? The
> comment about converting from UTF-16 to UTF-8 should say *to the ANSI
> codepage* instead. You also use C++ style comments in two places, but
> perl always uses C style comments since most files are C and not all C
> compilers accept C++ style comments.

Sure, I will do that and send you in an hour.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About