Hany's Home Page

Software

Hany's Dos2Unix 0.9.2 (development release)

[Author] [Contributors] [Description] [Copying] [Requirements] [Download] [Installation] [Usage] [Contribute] [Changelog] [Todo]

Author

Peter Hanecak <hany (at) hany.sk>

Contributors

Thank you.

Description

hd2u is Hany's DOS <-> Unix convertor.

dos2unix is filter used to convert plain texts from DOS (CR/LF) format to UNIX format (LF) and vice versa. Aditionaly it can also handle files in Macintosh format (CR) and convert them into other formats.

Copying

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

See the COPYING file or GNU General Public License page for license information.

Copyright 1997,.. by Peter Hanecak <hany (at) hany.sk>.
All rights reserved.

Requirements

popt

Popt library is required to process command line arguments.

For more information about mktemp see http://freshmeat.net/projects/popt/. Sources can be downloaded from ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/. RPM package of mktemp can be found for example at http://rpmfind.net/linux/RPM/popt.html.

Download

You can find sources at:

  1. http://www.megaloman.com/~hany/_data/hd2u/
  2. http://terminus.sk/~hany/_data/hd2u/

Also you can download RPM packages from:

  1. http://www.megaloman.com/~hany/RPM/hd2u.html

Installation

First, you need some UNIX system which have some basic C development tools alredy installed.

Note: If you're using some package management tool on your system you should have also installed so called 'development' package of popt library (popt-dev or popt-devel, etc.) so required header files are also installed.

After you sucessfuly downloaded and unpacked source tarball, do the following in source directory:

$ ./configure
$ make
$ make install

This will build and install 'dos2unix' into default location, which is /usr/local/bin .

If you want to use another prefix than /usr/local use for example:

$ ./configure --prefix=/usr

This will install 'dos2unix' into /usr/bin .

For more information use:

$ ./configure --help

Usage

dos2unix [--verbose|-v] [--test|-t] [--force|-f] [--<x>2<y>|--auto|-<Z>] [<file name> [...]]
 
--auto, -A   output will be set based upon autodetection of source format
--d2u, -U   perform DOS -> UNIX conversion
--m2u, -T   perform MAC -> UNIX conversion
--u2d, -D   perform UNIX -> DOS conversion
--u2m, -M   perform UNIX -> MAC conversion
--d2m, -O   perform DOS -> MAC conversion
--m2d, -C   perform MAC -> DOS conversion
 
--force, -f   suppress internal conversion type corrections based on autodetected input format
--skipbin, -b   skip binary files
--test, -t   don't write any conversion results; usefull with --verbose to just report on source type
--verbose, -v   print extra information on stderr
--version, -V   print version information on stderr

When no options are given then input format will be automatically detected and converted as follows:

Same as above applies if --auto option is used.

When no file is given, then stdin is used as input and stdout as output.

When concrete conversion type is used (--d2u or --u2d option) and file format is autodetected as target format, file is skipped - not touched - so there is no modification time change.

Binary files will be skipped automatically if option --skipbin (or -b) is used.

Stray '\r' characters (without a following '\n') are reported but only conversion 'DOS -> Unix' affects them (they are skipped).

You can display usage information using 'dos2unix -h' or 'dos2unix --help'.

Examples:

How to contribute

If you would like to submit a patch, send it to me <hany (at) hany.sk>. Please be sure to include a textual explanation of what your patch does.

The preferred format for changes is 'diff -u' output. You might generate it like this:

$ cd hd2u-work
$ [your changes]
$ make mrproper
$ cd ..
$ diff -urN hd2u-orig hd2u-work > mydiffs.patch

ChangeLog

0.9.2 2004/10/28
  • NEWS: updated
  2004/10/25
  • dos2unix.c: do not clear FT_BINARY flag from fileType when Mac line endings are detected which should avoid image or sound (or other binary) files to be confused with Mac text files (thanks to basic <basic (at) mozdev.org> and Caj Nordström <caj.nordstrom (at) beamex.com> for pointing out the bug and suggesting the fix)
  • README: fixed typo (thanks to N. Roeser <n-roeser (at) gmx.net> and Ryan Schmidt <hello-200407 (at) ryandesign.com> for pointing out the mistake)
  • INSTALL: added notice about popt-devel as suggested by max
  • install-sh: updated from automake-1.8.3 package
  • Makefile.in: changed '$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).c $(LIBS)' to '$(CC) $(CFLAGS) -o $@ $(@:%=%.c) $(LIBS)' (based on suggestion by Marty Leisner <mleisner (at) eng.mc.xerox.com>)
  2004/04/18
  • ChangeLog, README: fixed typos
0.9.1 2004/04/14
  • Makefile.in: 'make cleanall' removes also cache directory created by 'autoconf'
  • dos2unix.c: --version (-V) option added: display version information
  • configure.in: incorporated changes sugested by configure.scan generated by 'autoscan'
  • config.h.in added (as created by 'autoheader')
  • configure.in: config.h is generated by 'configure'
  • Makefile.in: incorporated changes done to configure.in
  • README: added info about --version (-V) option
0.9.0 2003/11/14
  • dos2unix.c: files in Mac format are now recognized; thanks to Sam Barnum <sbarnum (at) pointsystems.com> and max for suggestion (and to max also for pushing me to actualy do that :)
  • dos2unix.c: new conversion types: MAC -> UNIX, UNIX -> MAC, DOS -> MAC and MAC -> DOS
  • dos2unix.c: when autodetected input format does not match input format suggested by conversion type option on command line, conversion type is automaticaly corrected
  • dos2unix.c: --force (-f) option, which supress above mentioned behaviour
  • install-sh: updated from automake-1.6 package
  • README: updated
  • TODO: what should be fixed till next stable release
0.8.2 2003/10/03
  • dos2unix.c: read/write buffers implemented - increases performance about 9 times
  • dos2unix.c: message "File format '<file>':" changed to "File format of '<file>':"
  • TODO: updated
0.8.1 2003/02/26
  • dos2unix.c: mkstemp() used instead of tmpnam()
  • dos2unix.c: temporary directory specified by TMPDIR or TMP environment variable used; if none of them is avialable, then "/tmp" is used
0.8.0 2002/05/07
  • ChangeLog: fixed typo
  • README: updated "Usage" chapter
  • dos2unix.c: updated help
  • applied patch from Philip White <pwhite (at) gigacluster.net> (minor grammar corrections and miscellaneous beautifying in help & docs)
0.7.2 2002/01/04
  • INSTALL: fixed info about changing prefix
  • Makefile.in: create bin directory before installing hd2u binary into it; this should solve the problem when using custom prefix in which 'bin' directory does not exists (thanks to Emanuele Olivetti <olivetti (at) itc.it> for reporting the problem)
  • dos2unix.c: fix gcc 2.96 warning: string length '687' is greater than the minimum length '509' ISO C89 is required to support
0.7.1 2001/01/11
  • dos2unix.c: --skipbin (-b) switch added: binary files won't be converted
  • dos2unix.c: --test (-t): NO output (not even verbose)
  • dos2unix.c: conversion of input data from stdin works again
  • dos2unix.c: reworked convert(): conversion of input data from stdin works again; better separation of detection, verbose info output and other logic
  • dos2unix.c: rouge '\r' are reported but only conversion dos -> unix affects them (they are skipped)
  • dos2unix.c: directories when given as input are skipped
0.7.0 2001/02/11
  • dos2unix.c: more robust source format detection can detect binary files, mixed mode files, and files with no line endings at all
  • dos2unix.c: added automatic skipping of binary files
  • dos2unix.c: added --test mode to check filetype without converting
  • dos2unix.c: added --verbose option to show status messages while working
  • dos2unix.c: converted C++ style (//) comments to C style (/**/) (some C compilers will choke on //)
  • dos2unix.c: reordered function definition to avoid prototypes
  • dos2unix.c: replaced hard tabs with 4 spaces
  • dos2unix.c: added emacs modeline (2001/02/07 - Rob Ginda <rginda (at) netscape.com>)
  • documentation updates (see TODO!!!)
0.6.0 2001/01/21
  • documentation: fixed typos
  • dos2unix.c: handle NULL when returned by tmpnam()
  • Makefile.in: added '-Wall -pedantic' to CFLAGS
0.5.12 2000/10/03
  • documentation extended (popt) and updated (configure)
  • configure.in: check for getopt_long() function
0.5.11 2000/09/26
  • ./configure.in: check popt library
  • Makefile.in: LIBS
0.5.10 2000/08/07
  • autoconfigure
0.5.9 2000/08/05
  • --auto option
  • do not touch files which are alredy in specified target format
0.5.0 1999/11/25
  • first public release
  • full enought feature set

TODO