aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-02 12:57:26 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-02 12:57:26 +0200
commitea8b252cb30c4b4463df43a5342af95931920f09 (patch)
treeb32f4cfd202c9b98cbb2a59bb5a629275e1b4119
parent8837c5dec402fd6782589c0a676bc7f90dea4061 (diff)
downloadbusybox-w32-ea8b252cb30c4b4463df43a5342af95931920f09.tar.gz
busybox-w32-ea8b252cb30c4b4463df43a5342af95931920f09.tar.bz2
busybox-w32-ea8b252cb30c4b4463df43a5342af95931920f09.zip
*: 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>
-rw-r--r--archival/bzip2.c4
-rw-r--r--archival/libunarchive/decompress_unxz.c2
-rw-r--r--archival/libunarchive/decompress_unzip.c2
-rw-r--r--coreutils/head.c2
-rw-r--r--coreutils/od_bloaty.c2
-rw-r--r--coreutils/tail.c8
-rw-r--r--miscutils/less.c2
-rw-r--r--modutils/modutils-24.c6
-rw-r--r--shell/ash.c14
-rw-r--r--util-linux/fdisk.c6
10 files changed, 22 insertions, 26 deletions
diff --git a/archival/bzip2.c b/archival/bzip2.c
index f1c84d681..fdb8b9306 100644
--- a/archival/bzip2.c
+++ b/archival/bzip2.c
@@ -88,7 +88,7 @@ IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, vo
88 if (n2 != n) { 88 if (n2 != n) {
89 if (n2 >= 0) 89 if (n2 >= 0)
90 errno = 0; /* prevent bogus error message */ 90 errno = 0; /* prevent bogus error message */
91 bb_perror_msg(n2 >= 0 ? "short write" : "write error"); 91 bb_perror_msg(n2 >= 0 ? "short write" : bb_msg_write_error);
92 return -1; 92 return -1;
93 } 93 }
94 } 94 }
@@ -118,7 +118,7 @@ IF_DESKTOP(long long) int FAST_FUNC compressStream(unpack_info_t *info UNUSED_PA
118 while (1) { 118 while (1) {
119 count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE); 119 count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
120 if (count < 0) { 120 if (count < 0) {
121 bb_perror_msg("read error"); 121 bb_perror_msg(bb_msg_read_error);
122 total = -1; 122 total = -1;
123 break; 123 break;
124 } 124 }
diff --git a/archival/libunarchive/decompress_unxz.c b/archival/libunarchive/decompress_unxz.c
index 3f9392984..1302e29fb 100644
--- a/archival/libunarchive/decompress_unxz.c
+++ b/archival/libunarchive/decompress_unxz.c
@@ -86,7 +86,7 @@ unpack_xz_stream(int src_fd, int dst_fd)
86 if (rd) { 86 if (rd) {
87 rd = safe_read(src_fd, membuf + insz, rd); 87 rd = safe_read(src_fd, membuf + insz, rd);
88 if (rd < 0) { 88 if (rd < 0) {
89 bb_error_msg("read error"); 89 bb_error_msg(bb_msg_read_error);
90 total = -1; 90 total = -1;
91 break; 91 break;
92 } 92 }
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 33e877ec8..bccd0262e 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -1072,7 +1072,7 @@ static int top_up(STATE_PARAM unsigned n)
1072 bytebuffer_offset = 0; 1072 bytebuffer_offset = 0;
1073 bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count); 1073 bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
1074 if ((int)bytebuffer_size < 0) { 1074 if ((int)bytebuffer_size < 0) {
1075 bb_error_msg("read error"); 1075 bb_error_msg(bb_msg_read_error);
1076 return 0; 1076 return 0;
1077 } 1077 }
1078 bytebuffer_size += count; 1078 bytebuffer_size += count;
diff --git a/coreutils/head.c b/coreutils/head.c
index 75189eda8..cc2837411 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -27,7 +27,7 @@ static const struct suffix_mult head_suffixes[] = {
27 { "", 0 } 27 { "", 0 }
28}; 28};
29 29
30static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n"; 30#define header_fmt_str "\n==> %s <==\n"
31 31
32int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 32int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
33int head_main(int argc, char **argv) 33int head_main(int argc, char **argv)
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 6aba0f6bb..a9a45c8d3 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -502,7 +502,7 @@ check_and_close(void)
502 } 502 }
503 503
504 if (ferror(stdout)) { 504 if (ferror(stdout)) {
505 bb_error_msg("write error"); 505 bb_error_msg(bb_msg_write_error);
506 ioerror = 1; 506 ioerror = 1;
507 } 507 }
508} 508}
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 8fc22f562..6397702a0 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -66,7 +66,7 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
66 return r; 66 return r;
67} 67}
68 68
69static const char header_fmt[] ALIGN1 = "\n==> %s <==\n"; 69#define header_fmt_str "\n==> %s <==\n"
70 70
71static unsigned eat_num(const char *p) 71static unsigned eat_num(const char *p)
72{ 72{
@@ -166,7 +166,7 @@ int tail_main(int argc, char **argv)
166 tailbuf = xmalloc(tailbufsize); 166 tailbuf = xmalloc(tailbufsize);
167 167
168 /* tail the files */ 168 /* tail the files */
169 fmt = header_fmt + 1; /* skip header leading newline on first output */ 169 fmt = header_fmt_str + 1; /* skip header leading newline on first output */
170 i = 0; 170 i = 0;
171 do { 171 do {
172 char *buf; 172 char *buf;
@@ -181,7 +181,7 @@ int tail_main(int argc, char **argv)
181 181
182 if (nfiles > header_threshhold) { 182 if (nfiles > header_threshhold) {
183 tail_xprint_header(fmt, argv[i]); 183 tail_xprint_header(fmt, argv[i]);
184 fmt = header_fmt; 184 fmt = header_fmt_str;
185 } 185 }
186 186
187 if (!from_top) { 187 if (!from_top) {
@@ -333,7 +333,7 @@ int tail_main(int argc, char **argv)
333 if (ENABLE_FEATURE_FANCY_TAIL && fd < 0) 333 if (ENABLE_FEATURE_FANCY_TAIL && fd < 0)
334 continue; 334 continue;
335 if (nfiles > header_threshhold) { 335 if (nfiles > header_threshhold) {
336 fmt = header_fmt; 336 fmt = header_fmt_str;
337 } 337 }
338 while ((nread = tail_read(fd, tailbuf, BUFSIZ)) > 0) { 338 while ((nread = tail_read(fd, tailbuf, BUFSIZ)) > 0) {
339 if (fmt) { 339 if (fmt) {
diff --git a/miscutils/less.c b/miscutils/less.c
index 848266212..da2cd07af 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -430,7 +430,7 @@ static void read_lines(void)
430 * immediately */ 430 * immediately */
431 eof_error = 1; 431 eof_error = 1;
432 } else { 432 } else {
433 print_statusline("read error"); 433 print_statusline(bb_msg_read_error);
434 } 434 }
435 } 435 }
436#if !ENABLE_FEATURE_LESS_REGEXP 436#if !ENABLE_FEATURE_LESS_REGEXP
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index 5c1611c29..7f39e253d 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -3529,20 +3529,18 @@ static void set_tainted(int fd, const char *m_name,
3529/* Check if loading this module will taint the kernel. */ 3529/* Check if loading this module will taint the kernel. */
3530static void check_tainted_module(struct obj_file *f, const char *m_name) 3530static void check_tainted_module(struct obj_file *f, const char *m_name)
3531{ 3531{
3532 static const char tainted_file[] ALIGN1 = TAINT_FILENAME;
3533
3534 int fd, kernel_has_tainted; 3532 int fd, kernel_has_tainted;
3535 const char *ptr; 3533 const char *ptr;
3536 3534
3537 kernel_has_tainted = 1; 3535 kernel_has_tainted = 1;
3538 fd = open(tainted_file, O_RDWR); 3536 fd = open(TAINT_FILENAME, O_RDWR);
3539 if (fd < 0) { 3537 if (fd < 0) {
3540 if (errno == ENOENT) 3538 if (errno == ENOENT)
3541 kernel_has_tainted = 0; 3539 kernel_has_tainted = 0;
3542 else if (errno == EACCES) 3540 else if (errno == EACCES)
3543 kernel_has_tainted = 1; 3541 kernel_has_tainted = 1;
3544 else { 3542 else {
3545 perror(tainted_file); 3543 perror(TAINT_FILENAME);
3546 kernel_has_tainted = 0; 3544 kernel_has_tainted = 0;
3547 } 3545 }
3548 } 3546 }
diff --git a/shell/ash.c b/shell/ash.c
index d77d9d3c2..08ad0f451 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -119,9 +119,7 @@ enum { NOPTS = ARRAY_SIZE(optletters_optnames) };
119 119
120/* ============ Misc data */ 120/* ============ Misc data */
121 121
122static const char homestr[] ALIGN1 = "HOME"; 122#define msg_illnum "Illegal number: %s"
123static const char snlfmt[] ALIGN1 = "%s\n";
124static const char msg_illnum[] ALIGN1 = "Illegal number: %s";
125 123
126/* 124/*
127 * We enclose jmp_buf in a structure so that we can declare pointers to 125 * 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)
2520 flags = cdopt(); 2518 flags = cdopt();
2521 dest = *argptr; 2519 dest = *argptr;
2522 if (!dest) 2520 if (!dest)
2523 dest = bltinlookup(homestr); 2521 dest = bltinlookup("HOME");
2524 else if (LONE_DASH(dest)) { 2522 else if (LONE_DASH(dest)) {
2525 dest = bltinlookup("OLDPWD"); 2523 dest = bltinlookup("OLDPWD");
2526 flags |= CD_PRINT; 2524 flags |= CD_PRINT;
@@ -2567,7 +2565,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
2567 /* NOTREACHED */ 2565 /* NOTREACHED */
2568 out: 2566 out:
2569 if (flags & CD_PRINT) 2567 if (flags & CD_PRINT)
2570 out1fmt(snlfmt, curdir); 2568 out1fmt("%s\n", curdir);
2571 return 0; 2569 return 0;
2572} 2570}
2573 2571
@@ -2583,7 +2581,7 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
2583 setpwd(dir, 0); 2581 setpwd(dir, 0);
2584 dir = physdir; 2582 dir = physdir;
2585 } 2583 }
2586 out1fmt(snlfmt, dir); 2584 out1fmt("%s\n", dir);
2587 return 0; 2585 return 0;
2588} 2586}
2589 2587
@@ -5625,7 +5623,7 @@ exptilde(char *startp, char *p, int flags)
5625 done: 5623 done:
5626 *p = '\0'; 5624 *p = '\0';
5627 if (*name == '\0') { 5625 if (*name == '\0') {
5628 home = lookupvar(homestr); 5626 home = lookupvar("HOME");
5629 } else { 5627 } else {
5630 pw = getpwnam(name); 5628 pw = getpwnam(name);
5631 if (pw == NULL) 5629 if (pw == NULL)
@@ -9857,7 +9855,7 @@ chkmail(void)
9857 } 9855 }
9858 if (!mail_var_path_changed && statb.st_mtime != *mtp) { 9856 if (!mail_var_path_changed && statb.st_mtime != *mtp) {
9859 fprintf( 9857 fprintf(
9860 stderr, snlfmt, 9858 stderr, "%s\n",
9861 pathopt ? pathopt : "you have mail" 9859 pathopt ? pathopt : "you have mail"
9862 ); 9860 );
9863 } 9861 }
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 8e133178d..7227a829e 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -107,9 +107,9 @@ struct partition {
107 unsigned char size4[4]; /* nr of sectors in partition */ 107 unsigned char size4[4]; /* nr of sectors in partition */
108} PACKED; 108} PACKED;
109 109
110static const char unable_to_open[] ALIGN1 = "can't open '%s'"; 110#define unable_to_open "can't open '%s'"
111static const char unable_to_read[] ALIGN1 = "can't read from %s"; 111#define unable_to_read "can't read from %s"
112static const char unable_to_seek[] ALIGN1 = "can't seek on %s"; 112#define unable_to_seek "can't seek on %s"
113 113
114enum label_type { 114enum label_type {
115 LABEL_DOS, LABEL_SUN, LABEL_SGI, LABEL_AIX, LABEL_OSF 115 LABEL_DOS, LABEL_SUN, LABEL_SGI, LABEL_AIX, LABEL_OSF