diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/ChangeLog-roam.txt ./ChangeLog-roam.txt
--- ../../branches/vendor/bomstrip/ChangeLog-roam.txt	1970-01-01 02:00:00.000000000 +0200
+++ ./ChangeLog-roam.txt	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,79 @@
+This is a log of the changes made in the bomstrip-roam patchsets.
+
+bomstrip-8-roam-06	2008/06/16
+	- bomstrip.cpp
+	  - include <cstdlib> for exit(3)
+
+bomstrip-8-roam-05	2008/06/16
+	- Makefile
+	  - actually install the GNU Forth implementation
+
+bomstrip-8-roam-04	2008/06/16
+	- bomstrip.1
+	  - list the authors of the bomstrip implementations
+	- bomstrip.fs
+	  - add a GNU Forth implementation
+
+bomstrip-8-roam-03	2008/06/14
+	- start this ChangeLog :)
+	- Makefile
+	  - install the bomstrip.awk and bomstrip-2.pl implementations
+	- bomstrip.awk
+	  - add an awk implementation that fails on files with EOL on
+	    the last line
+	- bomstrip-2.pl
+	  - add a one-liner Perl implementation
+
+bomstrip-8-roam-02	2008/06/13
+	- actually install the C++ implementation of bomstrip that I added
+	  in the roam-01 patch :)
+
+bomstrip-8-roam-01	2008/06/13
+	- the first bomstrip-roam patchset
+	- bomstrip.c
+	  - fix a signed/unsigned (ssize_t) bug
+	  - make the buffer global so that it is always initialized with
+	    zeroes, thus making sure strcmp() will always work and also being
+	    a bit nicer to the main() function's stack
+	  - clean up the code a bit, fixing all C compiler warnings
+	- bomstrip.cpp
+	  - add a C++ implementation
+	- bomstrip.pl
+	  - do what the author seems to have meant - the input record
+	    separator is in the $/ special variable, not $! :)
+	    Still, bomscript.pl worked previously, too, because the "print"
+	    function evaluates its arguments in list context, and it still
+	    read the whole of the <STDIN> contents, albeit somewhat
+	    inefficiently, line by line :)
+	- bomstrip.py
+	  - remove the diagnostic output, since it messed up the stripped
+	    data :)
+	- bomstrip-files.sh
+	  - add a Bourne shell script to strip files in-place
+	- bomstrip.1
+	  - add a manual page, hopefully describing all implementations :)
+	  - also describe the bomstrip-files utility
+	- Makefile
+	  - add a Makefile
+	  - install the implementation sources and the tests into
+	    share/bomstrip/
+	  - install the bomstrip and bomstrip-files utilities
+	  - install the bomstrip(1) manual page
+	- bom-ml1, bom-ml2, bom-ml3, bom-ml4,
+	  nobom-ml1, nobom-ml2, nobom-ml3, nobom-ml4,
+	  correct/rbom-ml1, correct/rbom-ml2, correct/rbom-ml3,
+	  correct/rbom-ml4,
+	  correct/rnobom-ml1, correct/rnobom-ml2, correct/rnobom-ml3,
+	  correct/rnobom-ml4
+	  - add a couple of tests:
+	    - multi-line messages
+	    - no line-feed character on the last line
+	    - DOS-style CR/LF line endings
+	- test.sh
+	  - make this a bit more efficient with a loop on the files
+	  - make the test command and the test set configurable
+	  - exit with a non-zero result code if any of the tests fails,
+	    but only after running all the tests
+	  - add the new tests
+
+Comments: Peter Pentchev <roam@ringlet.net>
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/Makefile ./Makefile
--- ../../branches/vendor/bomstrip/Makefile	1970-01-01 02:00:00.000000000 +0200
+++ ./Makefile	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,108 @@
+# Makefile for bomstrip, the UTF-8 BOM stripper
+#
+# Written by Peter Pentchev in 2008.
+# This file is hereby placed into the public domain.
+
+LOCALBASE?=	/usr/local
+PREFIX?=	${LOCALBASE}
+BINDIR?=	${PREFIX}/bin
+MANDIR?=	${PREFIX}/man/man
+SHAREDIR?=	${PREFIX}/share/bomstrip
+
+PROG=		bomstrip
+SRCS=		bomstrip.c
+OBJS=		${SRCS:%.c=%.o}
+BFILES=		bomstrip-files
+
+SOURCES=	bomstrip.awk \
+		bomstrip.b \
+		bomstrip.bf \
+		bomstrip.c \
+		bomstrip.cpp \
+		bomstrip.fs \
+		bomstrip.hs \
+		bomstrip.ocaml \
+		bomstrip.ook \
+		bomstrip.pas \
+		bomstrip.php \
+		bomstrip.pl \
+		bomstrip-2.pl \
+		bomstrip.ps \
+		bomstrip.py \
+		bomstrip.rb \
+		bomstrip.sed \
+		bomstrip.unl
+TESTS=		bom0 bom1 bom-ml1 bom-ml2 bom-ml3 bom-ml4 \
+		nobom0 nobom1 nobom2 nobom-ml1 nobom-ml2 nobom-ml3 nobom-ml4
+TESTS_CORRECT=	${TESTS:%=correct/r%}
+
+CFLAGS_WARN?=	-Wall -W -Werror -ansi -pedantic -Wbad-function-cast \
+		-Wcast-align -Wcast-qual -Wchar-subscripts -Winline \
+		-Wmissing-prototypes -Wnested-externs -Wpointer-arith \
+		-Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings
+CFLAGS_OPT?=	-O2 -pipe
+CFLAGS_DBG?=
+
+CFLAGS?=	${CFLAGS_WARN} ${CFLAGS_OPT} ${CFLAGS_DBG}
+LDFLAGS?=
+LIBS?=
+
+COPY?=		-c
+STRIP?=		-s
+
+BINOWN?=	root
+BINGRP?=	root
+BINMODE?=	755
+
+SHAREOWN?=	${BINOWN}
+SHAREGRP?=	${BINGRP}
+SHAREMODE?=	644
+
+CC?=		cc
+GZIP?=		gzip -c -9
+LN?=		ln
+MKDIR?=		mkdir -p
+RM?=		rm -f
+
+INSTALL?=	install
+INSTALL_PROGRAM?=	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
+INSTALL_SCRIPT?=	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
+INSTALL_DATA?=		${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
+
+all:		${PROG} ${PROG}.1.gz
+
+clean:
+		${RM} ${PROG} ${OBJS} ${PROG}.1.gz
+
+install:	all
+		${MKDIR} ${DESTDIR}${BINDIR}
+		${INSTALL_PROGRAM} ${PROG} ${DESTDIR}${BINDIR}
+		${INSTALL_SCRIPT} ${BFILES}.sh ${DESTDIR}${BINDIR}/${BFILES}
+		${MKDIR} ${DESTDIR}${MANDIR}1
+		${INSTALL_DATA} ${PROG}.1.gz ${DESTDIR}${MANDIR}1
+		${RM} ${DESTDIR}${MANDIR}1/${BFILES}.1.gz
+		${LN} ${DESTDIR}${MANDIR}1/${PROG}.1.gz ${DESTDIR}${MANDIR}1/${BFILES}.1.gz
+		${MKDIR} ${DESTDIR}${SHAREDIR}/source
+		${INSTALL_DATA} ${SOURCES} ${DESTDIR}${SHAREDIR}/source
+		${MKDIR} ${DESTDIR}${SHAREDIR}/tests/correct
+		${INSTALL_DATA} ${TESTS} ${DESTDIR}${SHAREDIR}/tests
+		${INSTALL_DATA} ${TESTS_CORRECT} ${DESTDIR}${SHAREDIR}/tests/correct
+
+# If you set the TEST_X environment variable to, say, "-x", you may
+# get a bit more verbose shell output.
+# For the present, the test.sh script does not take any arguments, but
+# why not foresee the possibility - just set TEST_ARGS and go.
+#
+test:		all
+		BOM=./bomstrip BOMFILES="${TESTS}" sh ${TEST_X} test.sh ${TEST_ARGS}
+
+${PROG}:	${OBJS}
+		${CC} ${LDFLAGS} ${STRIP} -o ${PROG} ${OBJS} ${LIBS}
+
+.c.o:
+		${CC} -c ${CFLAGS} $<
+
+%.1.gz:		%.1
+		${GZIP} $< > $@
+
+.PHONY:		all clean install test
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip-2.pl ./bomstrip-2.pl
--- ../../branches/vendor/bomstrip/bomstrip-2.pl	1970-01-01 02:00:00.000000000 +0200
+++ ./bomstrip-2.pl	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,8 @@
+#!/usr/bin/perl -wp
+#
+# A Perl one-liner implementation of bomstrip
+#
+# Written by Peter Pentchev in 2008.
+# This file is hereby placed into the public domain.
+
+$. == 1 && s/^\xef\xbb\xbf//;
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip-files.sh ./bomstrip-files.sh
--- ../../branches/vendor/bomstrip/bomstrip-files.sh	1970-01-01 02:00:00.000000000 +0200
+++ ./bomstrip-files.sh	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Written by Peter Pentchev in 2008.
+# This file is hereby placed into the public domain.
+
+set -e
+
+[ -z "$BOMSTRIP" ] && BOMSTRIP='bomstrip'
+
+if [ "$#" -eq 0 ]; then
+	echo 'Usage: bomstrip-files file...' 1>&2
+	exit 1
+fi
+
+while [ "$#" -ne 0 ]; do
+	cp "$1" "$1.bom"
+	$BOMSTRIP < "$1.bom" > "$1"
+	shift
+done
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.1 ./bomstrip.1
--- ../../branches/vendor/bomstrip/bomstrip.1	1970-01-01 02:00:00.000000000 +0200
+++ ./bomstrip.1	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,83 @@
+.\" Written by Peter Pentchev in 2008.
+.\" This file is hereby placed into the public domain.
+.\"
+.Dd June 14, 2008
+.Dt BOMSTRIP 1
+.Os
+.Sh NAME
+.Nm bomstrip ,
+.Nm bomstrip-files
+.Nd strip the BOM sequence from UTF-8 files
+.Sh SYNOPSIS
+.Nm
+.Nm bomstrip-files
+.Ar
+.Sh DESCRIPTION
+The
+.Nm
+utility reads UTF-8 data from its standard input and copies it to
+its standard output, stripping the BOM (byte-order mark) from
+the beginning of the text if it is present.
+There are no command-line options and no parameters.
+.Pp
+The
+.Nm bomstrip-files
+utility removes the UTF-8 BOM from the specified files, saving each
+file's original contents with a
+.Pa .bom
+extension.
+It uses the
+.Nm
+utility, trying to execute it as
+.Dq Nm ;
+if the
+.Nm
+utility is installed under another name, or if a more complex command
+is desired, it may be supplied in the
+.Ev BOMSTRIP
+environment variable.
+.Sh EXAMPLES
+Strip the BOM, if present, from a text file:
+.Pp
+.Dl bomstrip < bom.txt > nobom.txt
+.Pp
+Strip the BOM, if present, from all text files, backing them up with a
+.Pa .bom
+extension:
+.Pp
+.Dl bomstrip-files *.txt
+.Pp
+Use the OCAML implementation of
+.Nm :
+.Pp
+.Dl env BOMSTRIP='ocaml bomstrip.ocaml' bomstrip-files *.txt
+.Sh SEE ALSO
+The
+.Nm
+home page:
+.Li http://www.xs4all.nl/~mechiel/projects/bomstrip/
+.Sh HISTORY
+The
+.Nm
+utility (in many languages) was written by
+.An Mechiel Lukkien ,
+with implementations in various languages sent to him by others, including
+.An Andreas Gohr ,
+.An Andrew Gerrand ,
+.An Berteun Damman ,
+.An Matthijs Bomhoff ,
+.An Peter Pentchev ,
+and
+.An Ruben Smelik .
+The
+.Nm bomstrip-files
+utility and this manual page were written by
+.An Peter Pentchev
+in the hope that they reflect the behavior of all the
+.Nm
+implementations in all languages.
+.Sh AUTHORS
+.An Mechiel Lukkien
+.Aq mechiel@xs4all.nl
+.An Peter Pentchev
+.Aq roam@ringlet.net
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.awk ./bomstrip.awk
--- ../../branches/vendor/bomstrip/bomstrip.awk	1970-01-01 02:00:00.000000000 +0200
+++ ./bomstrip.awk	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,12 @@
+#!/usr/bin/awk -f
+#
+# A simplistic awk implementation of bomstrip
+#
+# Written by Peter Pentchev in 2008.
+# This file is hereby placed into the public domain.
+#
+# This is the logical way to implement bomstrip in awk; it is also wrong.
+# It fails miserably if the last line does not end with a LF.
+
+NR == 1 && /^﻿/ { sub("^...", "") }
+{ print }
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.c ./bomstrip.c
--- ../../branches/vendor/bomstrip/bomstrip.c	2008-06-13 16:03:15.000000000 +0300
+++ ./bomstrip.c	2008-06-16 02:57:12.000000000 +0300
@@ -3,19 +3,25 @@
 #include <unistd.h>
 #include <string.h>
 
-void
-usage(char *prog)
+char		 buf[BUFSIZ];
+const char	*utf8bom = "\xef\xbb\xbf";
+
+static void	 usage(const char *);
+
+static void
+usage(const char *prog)
 {
 	fprintf(stderr, "usage: %s\n", prog);
 	exit(1);
 }
 
 int
-main(int argc, char *argv[])
+main(int argc, const char * const argv[])
 {
-	size_t nread;
-	char buf[65536];
-	char *utf8bom = "\xef\xbb\xbf";
+	ssize_t nread;
+
+	if (argc > 1)
+		usage(argv[0]);
 
 	nread = fread(buf, 1, strlen(utf8bom), stdin);
 	if (nread == 0)
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.cpp ./bomstrip.cpp
--- ../../branches/vendor/bomstrip/bomstrip.cpp	1970-01-01 02:00:00.000000000 +0200
+++ ./bomstrip.cpp	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,50 @@
+// Written by Peter Pentchev in 2008
+// This file is hereby placed into the public domain.
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+const char	*utf8bom = "\xef\xbb\xbf";
+
+static void	 usage(const char *);
+static void	 outendl(string &);
+
+static void
+usage(const char *prog)
+{
+	cerr << "usage: " << prog << endl;
+	exit(1);
+}
+
+static void
+outendl(string &s)
+{
+	cout << s;
+	if (!cin.eof())
+		cout << endl;
+}
+
+int
+main(int argc, const char * const argv[])
+{
+	string s;
+
+	if (argc > 1)
+		usage(argv[0]);
+
+	/* Empty? */
+	if (!getline(cin, s))
+		return 0;
+
+	/* First line... */
+	if (!s.substr(0, 3).compare(utf8bom))
+		s = s.substr(3);
+	outendl(s);
+
+	/* ...and the rest. */
+	while (getline(cin, s))
+		outendl(s);
+}
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.fs ./bomstrip.fs
--- ../../branches/vendor/bomstrip/bomstrip.fs	1970-01-01 02:00:00.000000000 +0200
+++ ./bomstrip.fs	2008-06-16 02:57:12.000000000 +0300
@@ -0,0 +1,48 @@
+\ A bomstrip implementation for GNU Forth
+\ 
+\ Written by Peter Pentchev in 2008.
+\ This file is hereby placed into the public domain.
+\ 
+\ This works with GNU Forth.  It really ought to work with other
+\ Forths, too - as long as they have the STDIN and STDOUT words,
+\ which at least FICL seems to be missing.
+
+\ The buffer where the input is read - 8KB should be enough for everyone ;)
+CREATE STRIP-BUF 8192 CHARS ALLOT
+
+\ The UTF-8 BOM to compare to
+CREATE UTF-8-BOM 239 C, 187 C, 191 C,
+
+\ Read three bytes, skip them if it is the BOM, output them otherwise
+: STRIP-FIRST ( -- )
+	( read three bytes )
+	STRIP-BUF 3 STDIN READ-FILE IF EXIT THEN
+	( less than three bytes read? )
+	DUP 3 < IF
+		( yep, just write them to stdout )
+		STRIP-BUF SWAP STDOUT WRITE-FILE IF BYE THEN
+	ELSE
+		( are they the same as the three bytes in the UTF-8-BOM? )
+		STRIP-BUF SWAP 2DUP UTF-8-BOM 3 COMPARE IF
+			( nope, must copy them, write them to stdout )
+			STDOUT WRITE-FILE IF BYE THEN
+		THEN
+	THEN ;
+
+\ Read as much as we can from stdin and copy it to stdout, in 8192-byte blocks
+: STRIP-REST ( -- )
+	( read up to 8KB )
+	STRIP-BUF 8192 STDIN READ-FILE IF BYE THEN
+	( just return on EOF )
+	DUP 0= IF EXIT THEN
+	( copy to stdout )
+	STRIP-BUF SWAP STDOUT WRITE-FILE IF BYE THEN
+	( actually equivalent to a forever loop :)
+	RECURSE ;
+
+\ First examine the first three bytes, then copy the rest
+: BOMSTRIP ( -- )
+	STRIP-FIRST STRIP-REST ;
+
+\ This is a bomstrip filter - run BOMSTRIP, then exit the interpreter
+BOMSTRIP BYE
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.pl ./bomstrip.pl
--- ../../branches/vendor/bomstrip/bomstrip.pl	2008-06-13 16:03:15.000000000 +0300
+++ ./bomstrip.pl	2008-06-16 02:57:12.000000000 +0300
@@ -3,6 +3,6 @@
 my $buf;
 if (read STDIN, $buf, 3) {
 	print $buf if $buf ne "\xef\xbb\xbf";
-	undef $!;
+	undef $/;
 	print <STDIN>;
 }
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/bomstrip.py ./bomstrip.py
--- ../../branches/vendor/bomstrip/bomstrip.py	2008-06-13 16:03:15.000000000 +0300
+++ ./bomstrip.py	2008-06-16 02:57:12.000000000 +0300
@@ -33,11 +33,8 @@
 		return
 
 	while True:
-		print 'reading...'
 		buf = inf.read(bufsize)
-		print 'read!'
 		if buf == '':
-			print 'empty string'
 			break
 		outf.write(buf)
 	
diff -urN -x .svn -x '*bom-ml*' ../../branches/vendor/bomstrip/test.sh ./test.sh
--- ../../branches/vendor/bomstrip/test.sh	2008-06-13 16:03:15.000000000 +0300
+++ ./test.sh	2008-06-16 02:57:12.000000000 +0300
@@ -1,9 +1,17 @@
 #!/bin/sh
 
-cmd='ocaml ./bomstrip.ocaml'
+[ -z "$BOM" ] && BOM='ocaml ./bomstrip.ocaml'
+[ -z "$BOMFILES" ] && BOMFILES='bom0 bom1 bom-ml1 bom-ml2 bom-ml3 bom-ml4 '\
+'nobom0 nobom1 nobom2 nobom-ml1 nobom-ml2 nobom-ml3 nobom-ml4'
 
-$cmd < bom0 > rbom0 && cmp rbom0 correct/rbom0 || echo bom0 is wrong
-$cmd < bom1 > rbom1 && cmp rbom1 correct/rbom1 || echo bom1 is wrong
-$cmd < nobom0 > rnobom0 && cmp rnobom0 correct/rnobom0 || echo nobom0 is wrong
-$cmd < nobom1 > rnobom1 && cmp rnobom1 correct/rnobom1 || echo nobom1 is wrong
-$cmd < nobom2 > rnobom2 && cmp rnobom2 correct/rnobom2 || echo nobom2 is wrong
+res=0
+for f in $BOMFILES; do
+	$BOM < "$f" > "r$f"
+	if ! cmp "r$f" correct/"r$f"; then
+		echo "$f is wrong"
+		res=1
+	else
+		rm -f "r$f"
+	fi
+done
+exit "$res"
