debian/0000755000000000000000000000000012242136050007161 5ustar debian/bomstrip.10000644000000000000000000000346411026466050011116 0ustar .\" 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 debian/bomstrip-files.sh0000644000000000000000000000047511026466066012476 0ustar #!/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 debian/rules0000755000000000000000000000236212242135360010247 0ustar #!/usr/bin/make -f # # Debhelper rules for bomstrip, the UTF-8 BOM strip utility # Written by Peter Pentchev in 2008. # This file is hereby placed into the public domain. # Aim for the top, adapt if anything should break on the buildds. DEB_BUILD_MAINT_OPTIONS= hardening=+all export DEB_BUILD_MAINT_OPTIONS CFLAGS= $(shell dpkg-buildflags --get CFLAGS) CPPFLAGS= $(shell dpkg-buildflags --get CPPFLAGS) LDFLAGS= $(shell dpkg-buildflags --get LDFLAGS) DEB_CPPFLAGS_MAINT_APPEND= -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 DEB_CFLAGS_MAINT_APPEND= -pipe -Wall -W -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 ifneq (,$(filter werror,$(DEB_BUILD_OPTIONS))) DEB_CFLAGS_MAINT_APPEND+= -Werror endif export DEB_CFLAGS_MAINT_APPEND DEB_CPPFLAGS_MAINT_APPEND CC?= cc override_dh_auto_build: ${CC} -c ${CPPFLAGS} ${CFLAGS} bomstrip.c ${CC} ${LDFLAGS} -o bomstrip bomstrip.o sed -e "s@'bomstrip'@/usr/bin/bomstrip@" < debian/bomstrip-files.sh > bomstrip-files override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) env BOM=./bomstrip sh test.sh endif %: dh $@ --parallel debian/watch0000644000000000000000000000012311524245174010220 0ustar version=3 http://www.ueber.net/who/mjl/projects/bomstrip/ files/bomstrip-(.*)\.tgz debian/source/0000755000000000000000000000000012242135372010467 5ustar debian/source/format0000644000000000000000000000001411524244540011675 0ustar 3.0 (quilt) debian/changelog0000644000000000000000000001214512242136050011036 0ustar bomstrip (9-7) unstable; urgency=low * Remove the DM-Upload-Allowed flag since Damyan Ivanov was kind enough to grant me permission using the new dak mechanism. * Bump Standards-Version to 3.9.5 with no changes. * Update the copyright file to the copyright-format/1.0 format. * Bump the debhelper compatibility version to 9 with no changes. * Get the hardening options directly from dpkg-buildflags: - bump the build dependency on dpkg-dev to 1.16.1~ - remove the build dependency on hardening-includes - no longer include the hardening Makefile snippet into the rules file - explicitly enable all the hardening features; they may be disabled in the future if bomstrip should fail to build anywhere * Enable parallel building - not that it matters a lot in this case :) * Use DEB_CFLAGS_MAINT_APPEND to append the warning compiler flags. * Add _POSIX_C_SOURCE and _XOPEN_SOURCE specifications, just in case. * Drop the explicit compression specification for the Debian tarball; it really does not matter for this package. -- Peter Pentchev Sun, 17 Nov 2013 14:52:55 +0200 bomstrip (9-6) unstable; urgency=low * Update the copyright file to the latest DEP 5 candidate format. * Bump Standards-Version to 3.9.2 with no changes. * Update the copyright file to the latest DEP 5 candidate format and fix the DEP 5 URL after the Alioth migration. * Specify Multi-Arch: foreign for the binary package, just in case. -- Peter Pentchev Thu, 14 Jul 2011 19:04:00 +0300 bomstrip (9-5) unstable; urgency=low * The upstream site has moved, update the Homepage field, the watch file and the copyright file. * Update the copyright file to rev. 166 of the DEP 5 candidate. * Upload to unstable. -- Peter Pentchev Tue, 08 Feb 2011 16:14:12 +0200 bomstrip (9-4) experimental; urgency=low * Switch to Git and point the Vcs-* fields to Gitorious. * We haven't been using dpatch for more than two years, so drop the executable permissions on the patch file. * Bump Standards-Version to 3.9.1 with no changes. * Switch to bzip2 compression for the Debian tarball. * Depend on a hardening package so that the build hardening is actually done in the automated builds, and use the hardening-includes package instead of hardening-wrapper so that the hardening flags are visible in CFLAGS and LDFLAGS. * Bump the debhelper compatibility level to 8 with no changes. -- Peter Pentchev Fri, 24 Dec 2010 15:02:51 +0200 bomstrip (9-3) unstable; urgency=low * Bump Standards-Version to 3.9.0: - honor the "nocheck" build option and do not run dh_auto_test anyway * Simplify the rules file: - simplify the DEB_BUILD_HARDENING logic - move various dh_* command parameters out into separate debian/* files - use debhelper override rules * Fix a rules file bug: use LDFLAGS, not CFLAGS, to link a C program. * Use dpkg-buildflags from dpkg-dev 1.15.7 to obtain default values for CFLAGS, CPPFLAGS, and LDFLAGS. * Convert to the 3.0 (quilt) source format. * Convert the copyright file to the latest DEP 5 format. * Convert the single patch's header to the DEP 3 format. * Shorten the Vcs-Browser URL and actually point it at the Debian package. * Honor CPPFLAGS. * Add DM-Upload-Allowed with Damyan Ivanov's permission. -- Peter Pentchev Wed, 30 Jun 2010 08:35:48 +0300 bomstrip (9-2) unstable; urgency=low * Fix the short description. Closes: #489795 * Switch to quilt as Damyan Ivanov (dmn) suggested. * Fix some of the checks in my "C warnings fix" patch * Add two checks reported by the Debian hardening wrapper * Enable build hardening unless DEB_BUILD_OPTIONS contains "nohardening" * Use debhelper 7's features to minimize the rules file * Spell "Public Domain" as "PD", not "other", in the copyright file * debian/README.source - describe the usage of quilt, not dpatch * debian/changelog - use the "PD" name for the public domain license * debian/control - fix the short description. Closes: #489795 - build-depend on quilt, at least 0.40 for quilt.make * debian/patches/series - renamed from dpatch's 00list * debian/patches/01_c_warnings.patch - renamed from dpatch's 01_c_warnings.dpatch - refresh the patch with -p ab --no-index --no-timestamps - rewrite the header, dropping the dpatch-style comments - check the fwrite() return code for errors, found by the Debian hardening wrapper - restore the size_t type of nread and fix the signedness warning the right way - fread() may never return a negative value, but if it should returns zero, check for ferror() * debian/rules - use quilt.make and ${QUILT_STAMPFN} instead of dpatch's ones - enable build hardening unless DEB_BUILD_OPTIONS contains "nohardening" - use debhelper 7's "dh" wrapper to do most of the work -- Peter Pentchev Wed, 09 Jul 2008 13:40:31 +0300 bomstrip (9-1) unstable; urgency=low * Initial release. Closes: #486425 -- Peter Pentchev Fri, 27 Jun 2008 12:38:16 +0300 debian/bomstrip.manpages0000644000000000000000000000002211406245546012543 0ustar debian/bomstrip.1 debian/bomstrip.dirs0000644000000000000000000000003311406245336011710 0ustar usr/bin usr/share/man/man1 debian/control0000644000000000000000000000142412242135570010573 0ustar Source: bomstrip Section: text Priority: optional Maintainer: Peter Pentchev Build-Depends: debhelper (>> 9), dpkg-dev (>= 1.16.1~) Standards-Version: 3.9.5 Homepage: http://www.ueber.net/who/mjl/projects/bomstrip/ Vcs-Git: git://gitorious.org/bomstrip/pkg-debian.git Vcs-Browser: http://gitorious.org/bomstrip/pkg-debian Package: bomstrip Architecture: any Multi-Arch: foreign Depends: ${shlibs:Depends}, ${misc:Depends} Description: tool to strip Byte-Order Marks from UTF-8 text files Bomstrip is a very simple tool that removes BOM's (byte-order-marks) from UTF-8 files. UTF-8 does not have byte-ordering issues, so there is absolutely no need to have three bytes (the UTF-8-BOM) that do not say anything about the byte-order (since there is nothing to say). debian/copyright0000644000000000000000000000072012242131464011117 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: bomstrip Upstream-Contact: Mechiel Lukkien Source: http://www.ueber.net/who/mjl/projects/bomstrip/ License: public-domain Files: * Copyright: All files are in the public domain License: public-domain License: public-domain The bomstrip utility, all implementations, and all related files, including the Debian package files, are in the public domain. debian/bomstrip.links0000644000000000000000000000010211406245662012066 0ustar usr/share/man/man1/bomstrip.1 usr/share/man/man1/bomstrip-files.1 debian/patches/0000755000000000000000000000000012242132045010610 5ustar debian/patches/01_c_warnings.patch0000644000000000000000000000246511524244540014300 0ustar Description: Make this program really work and fix some compiler warnings - make buf[] and utf8bom[] global to make sure they're zero-initialized and also to save stack space - use a sane size for buf[] - replace the fread() < 0 check with one for ferror() - check the return code of fwrite(), too Forwarded: yes Author: Peter Pentchev Last-Update: 2010-06-16 --- a/bomstrip.c +++ b/bomstrip.c @@ -3,19 +3,22 @@ #include #include -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"; if (argc > 1) usage(argv[0]); @@ -24,14 +27,14 @@ if (nread == 0) return 0; if (strcmp(buf, utf8bom) != 0) - fwrite(buf, 1, nread, stdout); + if (fwrite(buf, 1, nread, stdout) < nread) + exit(1); for (;;) { nread = fread(buf, 1, sizeof buf, stdin); - if (nread < 0) - exit(1); if (nread == 0) - return 0; - fwrite(buf, 1, nread, stdout); + return ferror(stdin) && 1; + if (fwrite(buf, 1, nread, stdout) < nread) + exit(1); } return 0; } debian/patches/series0000644000000000000000000000002411034646473012036 0ustar 01_c_warnings.patch debian/compat0000644000000000000000000000000212242131464010363 0ustar 9 debian/clean0000644000000000000000000000004311406250101010156 0ustar bomstrip.o bomstrip bomstrip-files debian/bomstrip.install0000644000000000000000000000004011406245416012412 0ustar bomstrip bomstrip-files usr/bin debian/README.Debian0000644000000000000000000000120511030742544011225 0ustar bomstrip for Debian ------------------- This package provides the compiled C implementation of bomstrip with a couple of warning and reliability fixes. It also adds a manual page and another command-line tool, bomstrip-files, for stripping files in-place similarly to perl -i.bom or sed -i.bom. The bomstrip distribution itself consists of implementations of bomstrip filters in many languages. You may see those filters in the source package, and you may find several fixes to some of them on my bomstrip patchset webpage - http://devel.ringlet.net/textproc/bomstrip/ -- Peter Pentchev Thu, 19 Jun 2008 14:49:22 +0300