aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 08:42:43 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 08:42:43 +0000
commitcdf62770af9e8bf7d5bb2344ddef8acb3216cfe2 (patch)
treef3c72eba4318ead484dfb36c6e21d55f443c5f6b /coreutils
parent107fe7c081c2e0ab96628b431d9d812cdf9c82b2 (diff)
downloadbusybox-cdf62770af9e8bf7d5bb2344ddef8acb3216cfe2.tar.gz
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.c15
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)
{
FILE *in, *out;
int i;
-#define name_buf bb_common_bufsiz1
+ char *name_buf = name_buf; /* for compiler */
in = stdin;
out = stdout;
if (fn != NULL) {
- in = xfopen(fn, "rw");
+ in = xfopen(fn, "r");
/*
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
- snprintf(name_buf, sizeof(name_buf), "%sXXXXXX", fn);
- i = mkstemp(&name_buf[0]);
+ name_buf = xasprintf("%sXXXXXX", fn);
+ i = mkstemp(name_buf);
if (i == -1
|| fchmod(i, 0600) == -1
|| !(out = fdopen(i, "w+"))
@@ -48,12 +48,9 @@ static void convert(char *fn, int conv_type)
while ((i = fgetc(in)) != EOF) {
if (i == '\r')
continue;
- if (i == '\n') {
+ if (i == '\n')
if (conv_type == CT_UNIX2DOS)
fputc('\r', out);
- fputc('\n', out);
- continue;
- }
fputc(i, out);
}
@@ -62,7 +59,9 @@ static void convert(char *fn, int conv_type)
unlink(name_buf);
bb_perror_nomsg_and_die();
}
+// TODO: destroys symlinks. See how passwd handles this
xrename(name_buf, fn);
+ free(name_buf);
}
}