bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Windows: stdout isn't properly set to binary mode


From: Ray Satiro
Subject: Re: [Bug-wget] Windows: stdout isn't properly set to binary mode
Date: Thu, 13 Jan 2011 11:42:13 -0800 (PST)

--- On Thu, 1/13/11, Adrien <address@hidden> wrote:

> On windows, when running inside a terminal, there are two
> "outputs":
> stdout and console output (CONOUT). They are bound together
> by default
> but currently, wget changes CONOUT instead of stdout and
> that prevents
> redirection (content will always go to CONOUT and won't be
> redirected).
> 
> The following patch changes that by using
> "_setmode(_fileno(stdout),
> _O_BINARY);", which is also much simpler.
> 
> Available on cgit and attached to this mail.
> http://cgit.notk.org/adrien/mingw-builds/slackware64-current/tree/slackware64-current/source/n/wget/0005-Properly-set-stdout-to-binary-mode.patch


Hello,

It appears Yahoo has taken away my ability to specify outoging mail width. Why 
Yahoo? Why?! Your quoted text above may be disjointed.

I agree, stdout not CONOUT, but you should still check the return. The change 
was made in 2009:

2009-02-27  Gisle Vanem  <address@hidden>

        * main.c (main): "freopen (NULL,.." causes an assertion in MSVC
        debug-mode.  I.e. NULL isn't legal. But the "CONOUT$" device works
        fine.

This is true, NULL is not a valid parameter for freopen(), f etc, in windows. 
Generally speaking with concern to all API all parameters must be valid and 
cannot be NULL unless explicitly permitted. For example, free(NULL) is ok 
because the C standard explicitly permits it. However fclose(NULL) can segfault 
depending on whether your CRT (or its underlying API) has parameter vallidation 
for it, and an invalid parameter handler. In XP you'll likely cause a segfault 
but in Vista you won't, for example.

So the author was right but probably did not realize that CONOUT$ cannot be 
redirected.

The development version that is offered as a supplement with GetGnuWin32 is 
affected.
wget-1.12 --version
GNU Wget 1.12.1-dev Mar 04 2010 (mainline-013c8e2f5997) built on Windows-MinGW.

C:\Users\Internet\Desktop\xml>wget-1.12 -O - http://hg.addictivecode.org/ > abc
--2011-01-13 14:25:09--  http://hg.addictivecode.org/
Resolving hg.addictivecode.org... 206.123.88.136
Connecting to hg.addictivecode.org|206.123.88.136|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25 [text/html]
Saving to: `STDOUT'

 0% [                                       ] 0           --.-K/s              (
There is no site here.)
100%[======================================>] 25          --.-K/s   in 0s

2011-01-13 14:25:10 (689 KB/s) - written to stdout [25/25]


01/13/2011  02:25 PM                 0 abc


Thanks,

Jay 



      



reply via email to

[Prev in Thread] Current Thread [Next in Thread]