| PLEX86 | ||
|
LineEndings.cI've been looking for a common UNIX-Linux tool that that easily converts text files between different line-ending conventions. Does such a thing exist? If not, let me offer the following program: it reads files using any of the three common conventions, and converts them to any one of the three that you specify. * LineEndings -- a simple filter to convert the format of line endings in text files. Call this tool from the command line as follows: LineEndings format where format specifies the format to which the line endings are to be converted: "dos" -- carriage return followed by line feed "mac" -- carriage return only "net" -- carriage return followed by line feed (same as "dos") "unix" -- line feed only The conversion is done on standard input, and the results are written to standard output. There is no need to specify the input line-ending format, since the program recognizes all three formats on input. LineEndings.c 3022 That misses the entire point of a main() function! The main() function is the interface between the startup module... Linux Harddrive Question In a message on 20 Feb 2005 17:30:59 -0800, wrote : While this is true, it is still a *sort of backup*. It is unlikely that two disk drives... Adapted from Mac version 2005 February 19 by * typedef enum {false, true} bool; typedef unsigned char uchar; void main ( int argc, const char * const * argv ) { enum { LinefeedChar = 10, ReturnChar = 13, }; uchar Newline2; unsigned short NewlineLen; bool LastWasCR; int ExitStatus; ExitStatus = 0; do*once* { if (argc != 2) { fprintf(stderr, "Usage:-n-t%s dosmacunix-n", argv0); ExitStatus = 1; break; }*if* if (strcmp(argv1, "dos") == 0 strcmp(argv1, "net") == 0) { Newline0 = ReturnChar; Newline1 = LinefeedChar; NewlineLen = 2; } else if (strcmp(argv1, "mac") == 0) { Newline0 = ReturnChar; NewlineLen = 1; } else if (strcmp(argv1, "unix") == 0) { Newline0 = LinefeedChar; NewlineLen = 1; } else { fprintf(stderr, "%s -- unrecognized conversion format-n", argv0); ExitStatus = 1; break; }*if* LastWasCR = false; for (;;) { const int ThisCh = getc(stdin); break; if (ThisCh == ReturnChar ThisCh == LinefeedChar && !LastWasCR) { fwrite(Newline, NewlineLen, 1, stdout); } else if (ThisCh == LinefeedChar) { * ignore LF after CR * } else { putc(ThisCh, stdout); }*if* LastWasCR = ThisCh == ReturnChar; }*for* } while (false); exit(ExitStatus); }*main*
|
||||
Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||