Index: files/patch-4.20-REG_STARTEND
===================================================================
--- files/patch-4.20-REG_STARTEND	(revision 0)
+++ files/patch-4.20-REG_STARTEND	(revision 0)
@@ -0,0 +1,38 @@
+Index: softmagic.c
+===================================================================
+RCS file: /p/file/cvsroot/file/src/softmagic.c,v
+retrieving revision 1.91
+retrieving revision 1.95
+diff -u -r1.91 -r1.95
+--- softmagic.c	18 Jan 2007 05:29:33 -0000	1.91
++++ softmagic.c	3 Mar 2007 19:09:25 -0000	1.95
+@@ -38,7 +38,7 @@
+ 
+ 
+ #ifndef	lint
+-FILE_RCSID("@(#)$File: softmagic.c,v 1.91 2007/01/18 05:29:33 ljt Exp $")
++FILE_RCSID("@(#)$File: softmagic.c,v 1.95 2007/03/03 19:09:25 christos Exp $")
+ #endif	/* lint */
+ 
+ private int match(struct magic_set *, struct magic *, uint32_t,
+@@ -1523,10 +1523,20 @@
+ 		}
+ 		else {
+ 			regmatch_t pmatch[1];
++#ifndef REG_STARTEND
++#define	REG_STARTEND	0
++			size_t l = ms->search.s_len - 1;
++			char c = ms->search.s[l];
++			((char *)(intptr_t)ms->search.s)[l] = '\0';
++#else
+ 			pmatch[0].rm_so = 0;
+ 			pmatch[0].rm_eo = ms->search.s_len;
++#endif
+ 			rc = regexec(&rx, (const char *)ms->search.s,
+ 			    1, pmatch, REG_STARTEND);
++#if REG_STARTEND == 0
++			((char *)(intptr_t)ms->search.s)[l] = c;
++#endif
+ 			switch (rc) {
+ 			case 0:
+ 				ms->search.s += (int)pmatch[0].rm_so;
Index: files/src__file.h.diff_mod
===================================================================
--- files/src__file.h.diff_mod	(revision 0)
+++ files/src__file.h.diff_mod	(revision 0)
@@ -0,0 +1,25 @@
+--- src/file.h.orig	2007-04-08 05:17:02.000000000 +0200
++++ src/file.h	2007-04-08 05:19:11.000000000 +0200
+@@ -96,11 +96,11 @@
+ #endif
+ #define MAXMAGIS 8192		/* max entries in /etc/magic */
+ #define MAXDESC	64		/* max leng of text description */
+-#define MAXstring 32		/* max leng of "string" types */
++#define MAXstring 256		/* max leng of "string" types */
+ 
+ #define MAGICNO		0xF11E041C
+ #define VERSIONNO	4
+-#define FILE_MAGICSIZE	(32 * 4)
++#define FILE_MAGICSIZE	(32 * 11)
+ 
+ #define	FILE_LOAD	0
+ #define FILE_CHECK	1
+@@ -312,6 +312,8 @@
+ protected int file_reset(struct magic_set *);
+ protected int file_tryelf(struct magic_set *, int, const unsigned char *,
+     size_t);
++protected int file_tryfat(struct magic_set *, int, const unsigned char *,
++    size_t, const char *);
+ protected int file_zmagic(struct magic_set *, int, const char *,
+     const unsigned char *, size_t);
+ protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
Index: files/magic__Makefile.in.diff_mod
===================================================================
--- files/magic__Makefile.in.diff_mod	(revision 0)
+++ files/magic__Makefile.in.diff_mod	(revision 0)
@@ -0,0 +1,12 @@
+--- magic/Makefile.in.orig	2007-04-08 05:52:16.000000000 +0200
++++ magic/Makefile.in	2007-04-08 05:52:49.000000000 +0200
+@@ -554,7 +554,8 @@
+ 	$(FILE_COMPILE) -C -m magic
+ 
+ magic.mime.mgc: magic.mime
+-	$(FILE_COMPILE) -C -m $(srcdir)/magic.mime
++	$(FILE_COMPILE) -C -m magic.mime
++	cat $(srcdir)/magic.mime > magic.mime
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
Index: files/src__Makefile.in.diff_mod
===================================================================
--- files/src__Makefile.in.diff_mod	(revision 0)
+++ files/src__Makefile.in.diff_mod	(revision 0)
@@ -0,0 +1,30 @@
+--- src/Makefile.in.orig	2007-04-08 05:11:59.000000000 +0200
++++ src/Makefile.in	2007-04-08 05:14:16.000000000 +0200
+@@ -62,8 +62,8 @@
+ LTLIBRARIES = $(lib_LTLIBRARIES)
+ libmagic_la_LIBADD =
+ am_libmagic_la_OBJECTS = magic.lo apprentice.lo softmagic.lo \
+-	ascmagic.lo compress.lo is_tar.lo readelf.lo print.lo \
+-	fsmagic.lo funcs.lo apptype.lo
++	ascmagic.lo compress.lo is_tar.lo readelf.lo readfat.lo \
++	print.lo fsmagic.lo funcs.lo apptype.lo
+ libmagic_la_OBJECTS = $(am_libmagic_la_OBJECTS)
+ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+ PROGRAMS = $(bin_PROGRAMS)
+@@ -198,7 +198,7 @@
+ EXTRA_DIST = test.c
+ AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
+ libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \
+-	compress.c is_tar.c readelf.c print.c fsmagic.c \
++	compress.c is_tar.c readelf.c readfat.c print.c fsmagic.c \
+ 	funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c
+ 
+ libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0
+@@ -315,6 +315,7 @@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/magic.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readelf.Plo@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readfat.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/softmagic.Plo@am__quote@
+ 
+ .c.o:
Index: Portfile
===================================================================
--- Portfile	(revision 23728)
+++ Portfile	(working copy)
@@ -18,18 +18,53 @@
 master_sites        ftp://ftp.fu-berlin.de/unix/tools/file/ \
                     ftp://ftp.astron.com/pub/file/ \
                     ftp://ftp.gw.com/mirrors/pub/unix/file/
-patchfiles          patch-4.20-REG_STARTEND
+                    
+patchfiles          magic__Magdir__macintosh.diff \
+                    magic__Makefile.in.diff_mod \
+                    magic__magic.mime.diff \
+                    src__Makefile.am.diff \
+                    src__Makefile.in.diff_mod \
+                    src__file.h.diff_mod \
+                    src__funcs.c.diff \
+                    src__magic.c.diff \
+                    src__readfat.c.diff
 checksums           ${distfiles} \
                         md5 402bdb26356791bd5d277099adacc006 \
                         sha1 af5878e3c61c725a82ff185fcef5b631ad8468ab \
                         rmd160 ff4f1a677a6377df3d7925ab4e36fec71dd3ebe7 \
-                    ${patchfiles} \
+                    patch-4.20-REG_STARTEND \
                         md5 119b5fd6c60eede06ef909aa13fd65d2 \
                         sha1 4470ba5651e7a41ce8b30114a750a4479b6efe66 \
-                        rmd160 30ca934188bafe6fbe3967c1aee980bd7710b0b1
+                        rmd160 30ca934188bafe6fbe3967c1aee980bd7710b0b1 \
+                    magic__Magdir__macintosh.diff \
+                        md5 508b6844947a11aebf59febe9e40b11e \
+                        sha1 084004407cc98028a361f2c2cef9e0403423dbbe \
+                        rmd160 7910e67e72612fded0b667a0b1cda9c5a078e9cb \
+                    magic__magic.mime.diff \
+                        md5 64c6b3caf36cc6a4e12e6dba47e9b06f \
+                        sha1 045bad6ad99a9b190717a90f898c5e91a98d2346 \
+                        rmd160 9b78645e84db770132786820965f4345a37b2bb3 \
+                    src__Makefile.am.diff \
+                        md5 fbd10d36360e13a58968efbe9f7e4365 \
+                        sha1 7c31fb4b5fb2b66cb2eb4b3c93a715c792c5dd5c \
+                        rmd160 21852b22340c4ecf1bff6621bb10bd9773e819b6 \
+                    src__funcs.c.diff \
+                        md5 35e0a0cf29101a709524435b02ae1072 \
+                        sha1 5728fd660f7244c1c32aa503fcdc61af2233246d \
+                        rmd160 7bb1eb825d0205d3d9e56c4b99d72adcdec255d0 \
+                    src__magic.c.diff \
+                        md5 a3e658af1a32f2087e71e57b69835047 \
+                        sha1 82e5cfa7bb68dbfc7b02af335a4cc533dd48a652 \
+                        rmd160 d51fdfe5272cade4958722055d237ce39438af1e \
+                    src__readfat.c.diff \
+                        md5 5c8b6dcc62a7dd57be219d1b3542981e \
+                        sha1 477e0230bdb48040a580d8a0276d30f0faf24128 \
+                        rmd160 bc46d75e30629d211ff2ef0ff0a21905e186bab1
 
-patch_sites         ${master_sites}
-patch.dir           ${worksrcpath}/src
+patch_sites         http://www.opensource.apple.com/darwinsource/10.4.8.ppc/file-6/patches
+pre-patch {
+    system "cd ${worksrcpath}/src && patch -p0 < ${filespath}/patch-4.20-REG_STARTEND"
+}
                     
 configure.args      --mandir=${prefix}/share/man \
                     --enable-fsect-man5 \
