*: better string sharing

text   data    bss    dec    hex filename
 849427    441   7556 857424  d1550 busybox_old
 849355    441   7556 857352  d1508 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2010-06-02 12:57:26 +02:00
parent 8837c5dec4
commit ea8b252cb3
10 changed files with 22 additions and 26 deletions

View File

@ -119,9 +119,7 @@ enum { NOPTS = ARRAY_SIZE(optletters_optnames) };
/* ============ Misc data */
static const char homestr[] ALIGN1 = "HOME";
static const char snlfmt[] ALIGN1 = "%s\n";
static const char msg_illnum[] ALIGN1 = "Illegal number: %s";
#define msg_illnum "Illegal number: %s"
/*
* We enclose jmp_buf in a structure so that we can declare pointers to
@ -2520,7 +2518,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
flags = cdopt();
dest = *argptr;
if (!dest)
dest = bltinlookup(homestr);
dest = bltinlookup("HOME");
else if (LONE_DASH(dest)) {
dest = bltinlookup("OLDPWD");
flags |= CD_PRINT;
@ -2567,7 +2565,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
/* NOTREACHED */
out:
if (flags & CD_PRINT)
out1fmt(snlfmt, curdir);
out1fmt("%s\n", curdir);
return 0;
}
@ -2583,7 +2581,7 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
setpwd(dir, 0);
dir = physdir;
}
out1fmt(snlfmt, dir);
out1fmt("%s\n", dir);
return 0;
}
@ -5625,7 +5623,7 @@ exptilde(char *startp, char *p, int flags)
done:
*p = '\0';
if (*name == '\0') {
home = lookupvar(homestr);
home = lookupvar("HOME");
} else {
pw = getpwnam(name);
if (pw == NULL)
@ -9857,7 +9855,7 @@ chkmail(void)
}
if (!mail_var_path_changed && statb.st_mtime != *mtp) {
fprintf(
stderr, snlfmt,
stderr, "%s\n",
pathopt ? pathopt : "you have mail"
);
}