Re: [Monotone-devel] Two new lists to get commit logs

2005-04-17 Thread Florian Weimer
* Richard Levitte:

 I was a bit clumsy in the way I wrote that.  My question is, how do I
 correctly detect a binary blob from text?

A few GNU tools use the presence of NUL characters to identify binary
files (some of them only in the first few K of the file, AFAIK).


___
Monotone-devel mailing list
Monotone-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monotone-devel


Re: [Monotone-devel] Two new lists to get commit logs

2005-04-17 Thread Nathan Myers
On Sun, Apr 17, 2005 at 03:05:43PM -0700, Nathaniel Smith wrote:
 
 ... it helps if your existing guess_binary function
 doesn't contain a C-style string of characters that imply binary, of
 which the first element is NUL ;-)

Who would use a null-terminated string for anything in a C++ program?
Here's a handy idiom:

  template unsigned N
int f(const char (a)[N])
  { return ::write(1, a, N-1); }

  int main() { return f(abc\n); }

The template engine deduces the size of the literal string and binds N
to that value, so you don't need to search for any dumb terminator.
Better yet, if you call f with a pointer, the compiler rejects it.

Nathan Myers
[EMAIL PROTECTED]


___
Monotone-devel mailing list
Monotone-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monotone-devel