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
This commit is contained in:
Denis Vlasenko
2008-03-17 08:42:43 +00:00
parent 107fe7c081
commit cdf62770af
8 changed files with 204 additions and 208 deletions

View File

@ -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);
}
}