Index: trunk/dports/www/tidy/Portfile
===================================================================
--- trunk/dports/www/tidy/Portfile	(revision 1887)
+++ trunk/dports/www/tidy/Portfile	(revision 1887)
@@ -0,0 +1,29 @@
+PortSystem 1.0
+name		tidy
+version		20000804
+categories	www
+maintainers	mij@opendarwin.org
+description	Fixes and tidies up HTML files
+homepage	http://www.w3.org/People/Raggett/
+platforms	darwin
+
+long_description Tidy is a utility to clean up and fix broken HTML files.
+
+master_sites	http://www.w3.org/People/Raggett/
+distname	tidy4aug00
+extract.sufx	.tgz
+checksums	md5 5faa2b127ae7f1c7ab07ed677db189e7
+
+worksrcdir	${distname}
+
+patchfiles	patch-Makefile patch-html.h patch-localize.c \
+		patch-platform.h patch-config.c  patch-lexer.c \
+		patch-man_page.txt  patch-tidy.c
+
+configure	{}
+
+pre-install	{ system "install -o root -m 755 -d ${destroot}${prefix}/bin"
+		  system "install -o root -m 755 -d \
+		    ${destroot}${prefix}/man/man1" }
+
+install.args	prefix=${destroot}${prefix}
Index: trunk/dports/www/tidy/files/patch-Makefile
===================================================================
--- trunk/dports/www/tidy/files/patch-Makefile	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-Makefile	(revision 1887)
@@ -0,0 +1,37 @@
+--- Makefile.orig	Sat Jan 25 15:47:54 2003
++++ Makefile	Sat Jan 25 15:49:28 2003
+@@ -1,16 +1,10 @@
+ # Makefile - for tidy
+ 
+-CC= gcc
++CC?= gcc
+ 
+-CFLAGS= -O
++CFLAGS?= -D__USE_MISC
+ 
+-# Makefile - for tidy
+-
+-CC= gcc
+-
+-CFLAGS= -O
+-
+-INSTALLDIR= /usr/local/
++INSTALLDIR= ${destroot}${prefix}
+ 
+ OFILES=		attrs.o         istack.o        parser.o        tags.o \
+ 		entities.o      lexer.o         pprint.o        clean.o \
+@@ -36,12 +30,5 @@
+ 		rm -f $(OFILES) tab2space.o  tidy tab2space
+ 
+ install:
+-	cp -f tidy $(INSTALLDIR)bin
+-	cp -f man_page.txt $(INSTALLDIR)man/man1/tidy.1
+-	cd $(INSTALLDIR)bin; \
+-	chmod 755 tidy; \
+-	chgrp bin tidy; \
+-	chown bin tidy;
+-
+-
+-
++	install -o root -m 755 tidy $(INSTALLDIR)/bin
++	install -o root -m 644 man_page.txt $(INSTALLDIR)/man/man1/tidy.1
Index: trunk/dports/www/tidy/files/patch-config.c
===================================================================
--- trunk/dports/www/tidy/files/patch-config.c	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-config.c	(revision 1887)
@@ -0,0 +1,53 @@
+--- config.c.orig	Sat Aug  5 01:21:05 2000
++++ config.c	Mon Jul  8 23:07:17 2002
+@@ -94,6 +94,7 @@
+ Bool TidyMark = yes;        /* add meta element indicating tidied doc */
+ Bool Emacs = no;            /* if true format error output for GNU Emacs */
+ Bool LiteralAttribs = no;   /* if true attributes may use newlines */
++Bool PreserveEntities = no; /* if true don't convert entities to chars */
+ 
+ typedef struct _lex PLex;
+ 
+@@ -186,6 +187,7 @@
+     {"doctype",         {(int *)&doctype_str},      ParseDocType},
+     {"fix-backslash",   {(int *)&FixBackslash},     ParseBool},
+     {"gnu-emacs",       {(int *)&Emacs},            ParseBool},
++    {"preserve-entities", {(int *)&PreserveEntities}, ParseBool},
+ 
+   /* this must be the final entry */
+     {0,          0,             0}
+@@ -392,7 +394,8 @@
+         home_dir = passwd->pw_dir;
+     }
+ 
+-    if (p = realloc(expanded_filename, strlen(filename)+strlen(home_dir)+1))
++    if (home_dir != NULL &&
++	(p = realloc(expanded_filename, strlen(filename)+strlen(home_dir)+1)))
+     {
+         strcat(strcpy(expanded_filename = p, home_dir), filename);
+         return(expanded_filename);
+@@ -423,7 +426,10 @@
+     /* open the file and parse its contents */
+ 
+     if ((fin = fopen(fname, "r")) == null)
+-        FileError(stderr, fname);
++    {
++        if (FileExists(fname))		/* quiet file open error on */
++            FileError(stderr, fname);   /* non-existent file */
++    }
+     else
+     {
+         config_text = null;
+@@ -533,6 +539,12 @@
+     {
+         QuoteAmpersand = yes;
+         HideEndTags = no;
++    }
++
++ /* Avoid &amp;copy; in preserve-entities case */
++    if (PreserveEntities)
++    {
++       QuoteAmpersand = no;
+     }
+ }
+ 
Index: trunk/dports/www/tidy/files/patch-html.h
===================================================================
--- trunk/dports/www/tidy/files/patch-html.h	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-html.h	(revision 1887)
@@ -0,0 +1,27 @@
+--- html.h.orig	Fri Aug  4 18:21:05 2000
++++ html.h	Sat Jul 20 16:20:55 2002
+@@ -4,6 +4,8 @@
+   See tidy.c for the copyright notice.
+ */
+ 
++#include <sys/types.h>
++
+ /* indentation modes */
+ 
+ #define NO_INDENT      0
+@@ -380,6 +382,7 @@
+ 
+ void FatalError(char *msg);
+ void FileError(FILE *fp, const char *file);
++int FileExists(const char *file);
+ 
+ Node *GetToken(Lexer *lexer, uint mode);
+ 
+@@ -758,6 +761,7 @@
+ extern Bool Word2000;
+ extern Bool Emacs;  /* sasdjb 01May00 GNU Emacs error output format */
+ extern Bool LiteralAttribs;
++extern Bool PreserveEntities;
+ 
+ /* Parser methods for tags */
+ 
Index: trunk/dports/www/tidy/files/patch-lexer.c
===================================================================
--- trunk/dports/www/tidy/files/patch-lexer.c	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-lexer.c	(revision 1887)
@@ -0,0 +1,24 @@
+--- lexer.c.orig	Fri Aug  4 19:21:05 2000
++++ lexer.c	Thu Nov 15 21:44:03 2001
+@@ -1517,8 +1517,10 @@
+ 
+                     continue;
+                 }
+-                else if (c == '&' && mode != IgnoreMarkup)
+-                    ParseEntity(lexer, mode);
++                else if (c == '&' && mode != IgnoreMarkup
++				&& !PreserveEntities) {
++               		ParseEntity(lexer, mode);
++		}
+ 
+                 /* this is needed to avoid trimming trailing whitespace */
+                 if (mode == IgnoreWhitespace)
+@@ -2624,7 +2626,7 @@
+                 seen_gt = yes;
+         }
+ 
+-        if (c == '&')
++        if (c == '&')	/* XXX: possibly need support for PreserveEntities */
+         {
+             AddCharToLexer(lexer, c);
+             ParseEntity(lexer, null);
Index: trunk/dports/www/tidy/files/patch-localize.c
===================================================================
--- trunk/dports/www/tidy/files/patch-localize.c	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-localize.c	(revision 1887)
@@ -0,0 +1,37 @@
+--- localize.c.orig	Fri Aug  4 19:21:05 2000
++++ localize.c	Mon Nov 19 14:39:38 2001
+@@ -8,6 +8,9 @@
+   to localize HTML tidy.
+ */
+ 
++#include <sys/types.h>
++#include <sys/stat.h>
++
+ #include "platform.h"
+ #include "html.h"
+ 
+@@ -50,6 +53,16 @@
+     tidy_out(fp, "Can't open \"%s\"\n", file);
+ }
+ 
++int FileExists(const char *file)
++{
++    struct stat st;
++
++    if (stat(file, &st) < 0)
++        return (0);
++    else
++        return (1);
++}
++
+ static void ReportTag(Lexer *lexer, Node *tag)
+ {
+     if (tag)
+@@ -736,6 +749,7 @@
+     tidy_out(out, "  -xml            use this when input is wellformed xml\n");
+     tidy_out(out, "  -asxml          to convert html to wellformed xml\n");
+     tidy_out(out, "  -slides         to burst into slides on h2 elements\n");
++    tidy_out(out, "  -preserve       to preserve entities from source file\n");
+     tidy_out(out, "\n");
+ 
+     tidy_out(out, "Character encodings\n");
Index: trunk/dports/www/tidy/files/patch-man_page.txt
===================================================================
--- trunk/dports/www/tidy/files/patch-man_page.txt	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-man_page.txt	(revision 1887)
@@ -0,0 +1,20 @@
+--- man_page.txt.orig	Fri Aug  4 19:21:05 2000
++++ man_page.txt	Thu Nov 15 21:54:05 2001
+@@ -12,6 +12,7 @@
+ .IR column ]
+ .RB [ -upper ]
+ .RB [ -clean ]
++.RB [ -preserve ]
+ .RB [ -raw
+ |
+ .B -ascii
+@@ -106,6 +107,9 @@
+ .TP
+ .B -slides
+ Burst into slides on <H2> elements.
++.TP
++.B -preserve
++Preserve source file entities as is.
+ .TP
+ .BR -help ", " -h
+ List command-line options.
Index: trunk/dports/www/tidy/files/patch-platform.h
===================================================================
--- trunk/dports/www/tidy/files/patch-platform.h	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-platform.h	(revision 1887)
@@ -0,0 +1,13 @@
+--- platform.h.orig	Thu Jan 13 07:19:19 2000
++++ platform.h	Mon Mar 27 16:31:20 2000
+@@ -17,9 +17,8 @@
+   It enables tidy to find config files named ~/.tidyrc
+   and ~your/.tidyrc etc if the HTML_TIDY environment
+   variable is not set. Contributed by Todd Lewis.
+-
+-#define SUPPORT_GETPWNAM
+ */
++#define SUPPORT_GETPWNAM
+ 
+ #include <ctype.h>
+ #include <stdio.h>
Index: trunk/dports/www/tidy/files/patch-tidy.c
===================================================================
--- trunk/dports/www/tidy/files/patch-tidy.c	(revision 1887)
+++ trunk/dports/www/tidy/files/patch-tidy.c	(revision 1887)
@@ -0,0 +1,11 @@
+--- tidy.c.orig	Fri Aug  4 19:21:05 2000
++++ tidy.c	Mon Nov 19 14:39:50 2001
+@@ -785,6 +785,8 @@
+                 Quiet = yes;
+             else if (strcmp(arg, "slides") == 0)
+                 BurstSlides = yes;
++            else if (strcmp(arg, "preserve") == 0)
++                PreserveEntities = yes;
+             else if (strcmp(arg, "help") == 0 ||
+                      argv[1][1] == '?'|| argv[1][1] == 'h')
+             {
