diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-17 08:42:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-17 08:42:43 +0000 |
commit | cdf62770af9e8bf7d5bb2344ddef8acb3216cfe2 (patch) | |
tree | f3c72eba4318ead484dfb36c6e21d55f443c5f6b /coreutils | |
parent | 107fe7c081c2e0ab96628b431d9d812cdf9c82b2 (diff) | |
download | busybox-w32-cdf62770af9e8bf7d5bb2344ddef8acb3216cfe2.tar.gz busybox-w32-cdf62770af9e8bf7d5bb2344ddef8acb3216cfe2.tar.bz2 busybox-w32-cdf62770af9e8bf7d5bb2344ddef8acb3216cfe2.zip |
dos2unix: tiny shrink
login,su: fix setup_environment() so that it works as intended
(parameter names were a bit misleading)
fdisk: shrink
help text: shrink
function old new delta
login_main 1658 1701 +43
setup_environment 206 203 -3
dos_compatible_flag 4 1 -3
dos2unix_main 383 375 -8
get_boot 1724 1702 -22
fdisk_main 2949 2889 -60
packed_usage 24250 23948 -302
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 43/-398) Total: -355 bytes
text data bss dec hex filename
798768 661 7428 806857 c4fc9 busybox_old
798327 658 7428 806413 c4e0d busybox_unstripped
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/dos2unix.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 7776133f4..2db7e11a1 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -24,19 +24,19 @@ static void convert(char *fn, int conv_type) | |||
24 | { | 24 | { |
25 | FILE *in, *out; | 25 | FILE *in, *out; |
26 | int i; | 26 | int i; |
27 | #define name_buf bb_common_bufsiz1 | 27 | char *name_buf = name_buf; /* for compiler */ |
28 | 28 | ||
29 | in = stdin; | 29 | in = stdin; |
30 | out = stdout; | 30 | out = stdout; |
31 | if (fn != NULL) { | 31 | if (fn != NULL) { |
32 | in = xfopen(fn, "rw"); | 32 | in = xfopen(fn, "r"); |
33 | /* | 33 | /* |
34 | The file is then created with mode read/write and | 34 | The file is then created with mode read/write and |
35 | permissions 0666 for glibc 2.0.6 and earlier or | 35 | permissions 0666 for glibc 2.0.6 and earlier or |
36 | 0600 for glibc 2.0.7 and later. | 36 | 0600 for glibc 2.0.7 and later. |
37 | */ | 37 | */ |
38 | snprintf(name_buf, sizeof(name_buf), "%sXXXXXX", fn); | 38 | name_buf = xasprintf("%sXXXXXX", fn); |
39 | i = mkstemp(&name_buf[0]); | 39 | i = mkstemp(name_buf); |
40 | if (i == -1 | 40 | if (i == -1 |
41 | || fchmod(i, 0600) == -1 | 41 | || fchmod(i, 0600) == -1 |
42 | || !(out = fdopen(i, "w+")) | 42 | || !(out = fdopen(i, "w+")) |
@@ -48,12 +48,9 @@ static void convert(char *fn, int conv_type) | |||
48 | while ((i = fgetc(in)) != EOF) { | 48 | while ((i = fgetc(in)) != EOF) { |
49 | if (i == '\r') | 49 | if (i == '\r') |
50 | continue; | 50 | continue; |
51 | if (i == '\n') { | 51 | if (i == '\n') |
52 | if (conv_type == CT_UNIX2DOS) | 52 | if (conv_type == CT_UNIX2DOS) |
53 | fputc('\r', out); | 53 | fputc('\r', out); |
54 | fputc('\n', out); | ||
55 | continue; | ||
56 | } | ||
57 | fputc(i, out); | 54 | fputc(i, out); |
58 | } | 55 | } |
59 | 56 | ||
@@ -62,7 +59,9 @@ static void convert(char *fn, int conv_type) | |||
62 | unlink(name_buf); | 59 | unlink(name_buf); |
63 | bb_perror_nomsg_and_die(); | 60 | bb_perror_nomsg_and_die(); |
64 | } | 61 | } |
62 | // TODO: destroys symlinks. See how passwd handles this | ||
65 | xrename(name_buf, fn); | 63 | xrename(name_buf, fn); |
64 | free(name_buf); | ||
66 | } | 65 | } |
67 | } | 66 | } |
68 | 67 | ||