Tofrodos

Converts text files between MSDOS/Windows and Unix formats


What is Tofrodos?

Tofrodos is a text file conversion utility that converts ASCII and Unicode UTF-8 files between the MSDOS (or Windows) format, which traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters, and the Unix format, which usually have LFs (line feeds) to terminate each line.

It is a useful utility to have around when you have to convert files between MSDOS (or Windows) and Unix/Linux/BSD (and her clones and variants). It comes standard with a number of systems and is often found on the system as "todos", "fromdos", "dos2unix" and "unix2dos".

Licence

Tofrodos is licensed under the GNU General Public License version 2. The source code is provided with the Tofrodos package.

Downloading Tofrodos

Tofrodos comes in source code form. Precompiled binaries (executables) are only provided for the Windows console (ie, run the "todos.exe" and "fromdos.exe" executables in a command prompt window). If you are using Linux, Mac OS X, FreeBSD or any other system, you will need to compile the source code yourself. Makefiles for Linux/Mac OS X/FreeBSD (same makefile) and numerous compilers under Windows/MSDOS are provided.

Note: both archives listed here are identical — both contain the same complete source code and the Windows executables (binaries).

What's New in Tofrodos

Version 1.7.13 (28 October 2013)
  • [Hurd, NetBSD, FreeBSD kernel] Added support for Hurd, NetBSD and FreeBSD kernel. As a side benefit, Tofrodos is slightly more portable since it no longer depends on certain system-specific macros (namely MAXPATHLEN from sys/param.h).

  • [All systems] Improved error reporting for certain failure conditions.

  • [All systems] The -a option is now documented as "deprecated". This option has never been needed and you should not be using it.

  • [All systems] Minor changes to the documentation to improve clarity.

Version 1.7.12 (1 October 2012)
  • [All systems] Under certain error conditions, Tofrodos may fail to remove the temporary files that it creates. This is now fixed.

  • [All systems] Fixed another bug where an exit code of 0, instead of 1, is returned under certain failure conditions.

  • [MSDOS] Although MSDOS is not a multitasking system, and thus should not need it, the DOS port of Tofrodos now also uses my implementation of mkstemp(). This simplifies maintenance since I'll have fewer code paths to test.

  • [Windows and MSDOS] Support for compiling the source code using DJGPP 2, Borland C/C++, LCC-Win32 and Digital Mars C has been removed. Please use one of the other supported compilers (eg, Open Watcom C, etc). Alternatively, for Windows, just use the precompiled binary included in the package.

  • [All systems] The documentation now has information about the exit codes returned by Tofrodos.

Version 1.7.11 (27 September 2012)
  • [All systems] Tofrodos now consistently returns an exit code of 1 when there's a failure. Previously, under certain error conditions, it could return an exit code of -1 (which is not a valid exit code for some operating systems) instead of 1.

  • [Windows] This version now includes an implementation of mkstemp() for Windows (when compiled with Open Watcom C), bringing the Windows (Open Watcom) port of tofrodos up to par with versions for systems like Linux and Mac OS X which provide mkstemp() in their C libraries. Hopefully, this will help those of you who run multiple instances of tofrodos at the same time in the same directory.

  • [Windows] Fixed a bug introduced in 1.7.9 where the Windows port of tofrodos always creates the temporary file in the current directory instead of the directory where the target file is.

  • [Mac OS X] The Mac OS X port of tofrodos now uses mkstemp() to create the temporary file the way it does on Linux.

  • [Mac OS X] Added more information in readme.txt for Mac users.

  • [All systems] Improved documentation about the -p and -b options.

It's best to update to the current version, even if you're not using Windows or Mac OS X. This is especially the case if you redirect stdin and stdout when running tofrodos (instead of putting filenames on the command line), and test the exit code for success/failure (see the first item listed above).

Version 1.7.9 (27 February 2011)
  • [Windows, Linux, Mac OS X, Unix] The behaviour of the -b option (create backup file) has been changed to be more useful on systems with support for long filenames and an arbitrary number of file extensions (ie, all systems except MSDOS). It now backs up "filename.ext" as "filename.ext.bak" instead of "filename.bak".

    Note that with this version, the DOS version no longer behaves the same way (when the -b option is used) as the Windows, Linux, Mac OS X, *BSD and other Unix versions, since DOS systems have filename limitations. At least this way, we're not held back by the least common denominator (DOS), especially since few people use DOS nowadays.

  • [All systems] The documentation has been updated to explain the behaviour of the -b option in more detail.

Please update to the current version. It may only be a slight behaviour change on a rarely used option that doesn't affect the main functionality of the program, but for someone who wants to use the option, it actually makes it usable. For all you know, no one used the option before because of its old, brain-dead behaviour.

Version 1.7.8 (7 April 2008)
  • [Mac OS X] Fixed an error that only shows up when compiling in Mac OS X. The config.h in the distribution package was corrupted in the section enclosed by the APPLE macros. I'm very sorry.
Version 1.7.7 (1 April 2008)
  • [Mac OS X] Added support for compiling tofrodos under Mac OS X.
  • [FreeBSD] Added support for compiling tofrodos under FreeBSD.
  • [OpenBSD] Added support for compiling tofrodos under OpenBSD (not tested).
  • [All systems] Fixed typos in documentation (Unix man page and HTML version). Thanks to Florian Ernst, the maintainer of the Debian package that includes tofrodos.

If you are not using Mac OS X, FreeBSD or OpenBSD, it is not necessary to download this version (unless you want the fixed documentation). Other than documentation fixes, there are no changes that affect the other supported operating systems.

Version 1.7.6 (15 March 2005)
  • [All systems] New option: -l allows you to send the error messages to a log file. It's particularly convenient for systems with less powerful command line shells that do not allow you to easily redirect stderr.
  • [All systems] Fixed: all error and verbose messages are now sent to stderr or the error log file (if -l is given).
  • [Windows] Older versions of compilers like Borland 4.X and 5.0, Watcom 10.X and Visual C++ 6.0 no longer have makefiles. Use the latest versions; all these compilers are now available free of charge from their vendors (see the Free C/C++ Compilers page) so using the latest version to compile tofrodos should not be a great hardship.
  • [All systems] Other minor fixes.

If you are a maintainer of one of the Linux distributions that uses tofrodos, please update your version of tofrodos to the current version. If you're an ordinary user, you can of course also update your own installation by simply downloading the package and installing it. Instructions can be found in the readme.txt file.

Version 1.7 (26 November 2003)
  • [Linux/Unix] Bug fix: now handles symbolic link arguments correctly. This bug only affects Unix-type sytems (like Linux, FreeBSD, OpenBSD, etc).
  • [Linux] tofrodos now uses mkstemp() to create the temporary file to avoid a race between file name creation and opening which may occur when using mktemp(). If you use a non-Linux system, and have mkstemp(), you can take advantage of this by defining HAVE_MKSTEMP in config.h (defined by default for Linux only).
  • [Linux/Unix] "make install" now installs to /usr/bin by default (you can still change this easily) since Linux distributions using tofrodos appear to use this value. (Makes it easier for the maintainers of those distributions.)
  • [All systems] Made some error messages a bit more informative.
  • [All systems] Verbose mode is slightly more informative.
  • [Windows] Added support for compiling with the MinGW (GNU) C Compiler on Win32 systems.
  • [All systems] Added an HTML version of the manual page. Useful for systems that don't have a built-in facility to read a "man page" (like MSDOS and Windows).
Version 1.6 (1 July 2002)
  • Added support for the LCC-Win32 Compiler. If you already have version 1.5, and are using the provided Windows binaries, you needn't bother upgrading to this version.
Version 1.5 (19 June 2002)
Version 1.4 (16 March 1999)
  • Fixed bug where Tofrodos would crash when invoked with -b on a file in a directory that was not the current directory.
Version 1.3 (8 October 1997)
  • Added new option (-p) to preserve file ownership and time.
  • Added support for Win32 compilation and some compilers under DOS and Windows.
Version 1.1 (5 April 1997)
  • Fixed bug in creation of temporary and backup filenames on Linux.
Version 1.0 (22 June 1996)
  • Initial version.

Reporting a Bug

If you find a bug or feedback, please let me know. Be sure to specify that you're referring to Tofrodos since the contact form is a general contact form for my entire site.

Related Pages

Newest Pages

Popular Pages

How to Link to This Page

It will appear on your page as:

Tofrodos - Convert text files to/from MSDOS/Windows/Unix (freeware)

 


 

thesitewizard.com: Free Webmaster Tutorials, Scripts and Articles

HowtoHaven.com: Free How-To Guides

thefreecountry.com: Free Programmers, Webmasters and Security Resources
If you find this site useful, please link to us.