monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] "monotone cat file" not binary save?


From: Thomas Haas
Subject: Re: [Monotone-devel] "monotone cat file" not binary save?
Date: Wed, 07 Sep 2005 10:38:55 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Richard Levitte - VMS Whacker wrote:
> In message <address@hidden> on Tue, 6 Sep
> 2005 14:27:23 -0700, Nathaniel Smith <address@hidden> said:
> 
> njs> It's definitely not an intentional feature of 'cat'.  However, 
> njs> it's possible that it's some unavaoidable win32 bogosity, like 
> njs> stdout being provided as a text-mode descriptor that is njs>
> inherently lossy or something...
> 
> As most other operating systems that have a line endine sequence
> other than NL, I think Windows C library *correctly* does NL->CRNL 
> conversion on stdout unless you somehow explicitely tell it that the 
> output should remain unconverted.
> 
> njs> if that's the case (and I'm just guessing) then we might not be 
> njs> able to fix it.  Can any of the win32-clued people out there
> shed njs> any more light on this?  If it's not inherently unfixable, 
> njs> though, we should fix it.
> 
> One way to fix it is to have a --output parameter, to have an
> explicit output file that monotone can treat the way it sees fit.
> This might ctually be the cleanest way to do it, considering other
> operating systems may have yet other tweaks to get this right.
> 
> Cheers, Richard

Googled and found something about setmode(fd,mode) on
http://www.cs.toronto.edu/~cosmin/TA/prog/sysconf/ (worth reading):

  Handling binary files via standard I/O

  In a portable C program, text files are opened using one of the modes
  "r", "w", "a", etc., as in the example:

  FILE *ftext = fopen(fname, "r");

  On the other hand, binary files are opened using one of the modes
  "rb", "wb", "ab", etc.

  FILE *fbin = fopen(fname, "rb");

  On non-Unix systems, like DOS, OS/2 and Windows, text files are
  treated differently than binary files, and the use of the 'b' code
  letter is essential. Unfortunately, Standard C provides no way to
  change the mode on standard I/O (stdin, stdout, stderr). This is
  necessary when handling binary files in a pipeline; e.g.

  echo Hello | gzip -c > hello.gz
  [...]

HTH.

- tom









reply via email to

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