[darcs-users] Re: petition for '\0' to be removed from binary auto-detection code

Mark Stosberg mark at summersault.com
Tue Nov 16 15:46:09 UTC 2004


On 2004-11-16, David Roundy <droundy at abridgegame.org> wrote:
>
> It's in fpstring.c, actually written in C for blinding speed (well,
> blinding may be an overstatement...).
>
> Another option would be to add a set of regexps that indicate files that
> are *always* text.  This would be an ugly option, but might be used to keep
> \0 as a binary test, but special-case .pl files out of getting checked.

I think a better general purpose solution here is to re-use a
pre-existing well here. 

On Unixy systems, 'file -i filename' does this fairly well.  

A more portable solution is to use something like perl's File::MMagic
module, which has the same function.

I don't know of Haskell has something like that now.

Unless someone has a better suggestion, we could perhaps use
'file' on Unix, and keep the current behavior on Win32.

I found a related discussion here:
http://lists.trolltech.com/qt-interest/2003-05/thread00462-0.html

Suggestions included:
    - checking for ASCII values > 127
    - checking the file extension
    - just using 'file'. :)

    Mark

--
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark Stosberg            Principal Developer  
   mark at summersault.com     Summersault, LLC     
   765-939-9301 ext 202     database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .





More information about the darcs-users mailing list