Eric Andersen | cff3fe3 | 2000-09-20 19:22:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | Mini dos2unix implementation for busybox |
| 3 | |
| 4 | Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA |
| 5 | All rights reserved. |
| 6 | |
| 7 | Redistribution and use of this source code, with or without modification, is |
| 8 | permitted provided that the following condition is met: |
| 9 | |
| 10 | 1. Redistributions of this source code must retain the above copyright |
| 11 | notice, this condition, and the following disclaimer. |
| 12 | |
| 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 16 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 17 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 18 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 19 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 20 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 21 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | */ |
| 24 | |
| 25 | #include "internal.h" |
| 26 | #include <stdio.h> |
| 27 | |
| 28 | int dos2unix_main( int argc, char **argv ) { |
| 29 | int c; |
| 30 | if (argc > 1) { |
| 31 | c = *argv[1]; |
| 32 | if (c == '-') { |
| 33 | usage(dos2unix_usage); |
| 34 | } |
| 35 | } |
| 36 | c = getchar(); |
| 37 | while (c != EOF) { |
| 38 | /* Eat any \r's... they shouldn't be here */ |
| 39 | while (c == '\r') c = getchar(); |
| 40 | if (c == EOF) break; |
| 41 | putchar(c); |
| 42 | c = getchar(); |
| 43 | } |
| 44 | return 0; |
| 45 | } |